can someone help me out with those errors?

Discussion in 'Spigot Plugin Help' started by Jeroen123, Jun 18, 2021.

  1. Code (Text):
    package com.WhosOnline.events;

    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.inventory.InventoryClickEvent;
    import org.bukkit.event.inventory.InventoryDragEvent;
    import org.bukkit.event.inventory.InventoryOpenEvent;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;

    import com.WhosOnline.menu.WhosOnlineMenu;
    import com.WhosOnline.menu.WhosOnlineStaffMenu;
    import com.WhosOnline.menu.items.WhosOnlineMenuItems;
    import org.jetbrains.annotations.NotNull;

    public class WhosOnlineMenuEvents implements Listener {

        private Object Player;

        @EventHandler
        public void onlineMenuActions(InventoryClickEvent ev) {

            Player p = (Player) ev.getWhoClicked();

            int i = Bukkit.getOnlinePlayers().size();
            int j = (int) Math.ceil(i / 45.0);

            if (ev.getCurrentItem() != null) {
                if (ev.getClickedInventory().getTitle().contains(WhosOnlineMenu.OnlineTitle)) {

                    // Lets split the title up. Getting everything past the #
                    // Check the page #, if it's less than 100 then open a new page
                    String[] s1 = ChatColor.stripColor(ev.getClickedInventory().getTitle()).split("#");
                    String s2 = s1[1];

                    if (ev.getCurrentItem().equals(WhosOnlineMenuItems.ArrowForward(p))) {
                        if (Integer.parseInt(s2) + 1 < j) {
                            p.openInventory(WhosOnlineMenu.onlinePlayers(p, Integer.parseInt(s2) + 1));
                        }
                    }

                    if (ev.getCurrentItem().equals(WhosOnlineMenuItems.ArrowBack(p))) {
                        if (Integer.parseInt(s2) > 1) {
                            p.openInventory(WhosOnlineMenu.onlinePlayers(p, Integer.parseInt(s2) - 1));
                        }
                    }

                    if (ev.getCurrentItem().equals(WhosOnlineMenuItems.StaffMenu(p))) {
                        if (p.hasPermission("WhosOnline.view.staff")) {
                            p.openInventory(WhosOnlineStaffMenu.onlinePlayers(p, 1));
                        } else {
                            ev.getInventory().setItem(49, WhosOnlineMenuItems.Error("&4&lERROR"));
                        }
                    }
                }
            }
        }

        @EventHandler
        public void guiClickEvent(InventoryClickEvent event) {
            event.setCancelled(true);

            Player p = (Player);

            switch (event.getSlot()) {
                case 2: {
                    p.closeInventory();
                    p.performCommand("sw spectplayer %player%");
                    break;
                }
            }
        }

        @EventHandler
        public void RemovePrevious(InventoryOpenEvent ev) {

            ItemStack air = new ItemStack(Material.AIR);

            if (ev.getInventory().getTitle().equals(WhosOnlineMenu.OnlineTitle + "1")) {
                ev.getInventory().setItem(48, air);
            }
        }

        @EventHandler
        public void MenuMove(InventoryClickEvent ev) {

            if (ev.getInventory().getName().contains(WhosOnlineMenu.OnlineTitle)) {
                ev.setCancelled(true);
            }
        }

        @EventHandler
        public void MenuDrag(InventoryDragEvent ev) {

            if (ev.getInventory().getName().contains(WhosOnlineMenu.OnlineTitle)) {
                ev.setCancelled(true);
            }
        }
    }
     
     
  2. Where are the errors? lol
     
  3. If you don't tell us what the problem is, we can't help.
     
  4. GetTitle and getName don’t work and idk why not
     
  5. PoSt ThE eRrOr!
     
  6. not contains use equalsIgnoreCase

    not getTitle().getName() use getTitle().equalsIgnoreCase