Help, ServerPopper

Discussion in 'Spigot Plugin Development' started by TimLampen, Apr 1, 2014.

Thread Status:
Not open for further replies.
  1. geNAZt

    Supporter

    Ok when you say you know Java then i can tell you what you have done wrong.

    Code (Text):
    - import snip-

    public class Pop implements Listener{
        public static Pop plugin; // Remove this, its never assigned or read from, also never use multiple statics for holding single instances
        @EventHandler
        public void onPlayerInteract(PlayerInteractEntityEvent event) {
           Player targetPlayer = event.gettargethere     // <-- No ; ? Invalid method ? Look it up here: http://jd.bukkit.org/dev/doxygen/dd/dcb/classorg_1_1bukkit_1_1event_1_1player_1_1PlayerInteractEntityEvent.html#a377861e2c6fae553f8fbf21a9204fadc
        if (event.getRightClicked() !=null) {         // This can never be null; Also you need to check if its a Player before you cast it
        PlayerEvent.hidePlayer(targetPlayer);    // What should PlayerEvent be ? Do you want to get the Player who hit the Player ? Look here: http://jd.bukkit.org/dev/doxygen/d9/d2a/classorg_1_1bukkit_1_1event_1_1player_1_1PlayerEvent.html#a7e1272ecc966a16548bda756bb009fc4
        event.getPlayer().sendMessage("hi");
        }
    }
    }
    Code (Text):
    - import snip -

    public class Main extends JavaPlugin{
        public final Logger logger = Logger.getLogger("Minecraft"); // Not needed and invalid in Minecraft 1.7+ use Plugin.getLogger()
        public static Main plugin; // Unneeded, never written and read to/from
        public final Pop bl = new Pop();
     
        @Override
        public void onDisable(){ // Remove this completly, Bukkit tells you when it disables a Plugin
            PluginDescriptionFile pdffile = this.getDescription();
            this.logger.info(pdffile.getName() + " Has Been Disabled!");
         
        }
        @Override
        public void onEnable() {
            PluginDescriptionFile pdffile = this.getDescription();
            this.logger.info(pdffile.getName() + " Version " + pdffile.getVersion() + " Has Been Enabled!"); // Same for enabled, bukkit logs it
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvents(this.bl, this);
     
        }
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
            Player player = (Player) sender; // No check if the sender is a Player also no commands => remove it
            return false;
        }
    }
    Problems are in the Comments
     
Thread Status:
Not open for further replies.