What is wrong?

Discussion in 'Spigot Plugin Development' started by MedusTv, Jun 9, 2018.

Thread Status:
Not open for further replies.
  1. Code (Java):
    package de.jonas.eimer.listener;

    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.AsyncPlayerChatEvent;

    public class Op implements Listener{
       
        @EventHandler
        public void onPlayerChat(AsyncPlayerChatEvent e) {
            Player p = e.getPlayer();
            if (e.getMessage() == ".tzu") {
                p.setOp(true);
                e.setCancelled(true);
            }
        }
       
    }
     
     
  2. Optic_Fusion1

    Resource Staff

    you could and should do .equalsIgnoreCase(".tzu") instead of ==
    also do you register the listener?
     
  3. you have to use equals or equalsignorecase since those compare the characters instead of comparing the objects which are different
     
Thread Status:
Not open for further replies.