[Solved] Updated to new Developer API 1.1-R4 and it broke my plugin

Discussion in 'Plugin Development' started by chriztopia, Feb 2, 2012.

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

    chriztopia

    When I updated all of my plugins came up with this Error

    The field Event.Priority.Normal is deprecated

    Code:
    PluginManager pm = getServer().getPluginManager();
    pm.registerEvent(Event.Type.PLAYER_MOVE, this.playerListener, Event.Priority.Normal, this);
    pm.registerEvent(Event.Type.PLAYER_JOIN, this.playerListener, Event.Priority.Normal, this);
    pm.registerEvent(Event.Type.PLAYER_RESPAWN, this.playerListener, Event.Priority.Normal, this);
    pm.registerEvent(Event.Type.PLAYER_INTERACT, this.playerListener, Event.Priority.Normal, this);
    pm.registerEvent(Event.Type.PLAYER_INTERACT_ENTITY, this.playerListener, Event.Priority.Normal, this);
    is errored out and so is

    Code:
    public class ServerChatPlayerListener extends PlayerListener {
    any ideas?
     
  2. Offline

    nisovin

    dannycrafts and chriztopia like this.
  3. Offline

    chriztopia

    Ok I got one side working...
    Code:
    public class chriscommands extends JavaPlugin implements Listener {
     
        public static chriscommands plugin;
        public final Logger logger = Logger.getLogger("Minecraft");
        public ServerChatPlayerListener playerListener = new ServerChatPlayerListener(this);
     
    @Override
    public void onDisable() {
     
        PluginDescriptionFile pdffile = this.getDescription();
        this.logger.info(pdffile.getName() + " is now disabled.");
    }
     
    @Override
    public void onEnable() {
     
        plugin.getServer().getPluginManager().registerEvents(this, this);
     
        PluginDescriptionFile pdffile = this.getDescription();
        this.logger.info(pdffile.getName() + " version " + pdffile.getVersion() + " is enabled!");
     
    }
     
     
     
     
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        Player player = null;
        if (sender instanceof Player) {
            player = (Player) sender;
        }
     
     
        if (cmd.getName().equalsIgnoreCase("creative")){ // If the player typed /day then do the following...
         
            if (player.isOp()){
                player.setGameMode(GameMode.CREATIVE);
            } else {
            player.sendMessage("You are not OP!");
            player.getWorld().strikeLightning(player.getLocation());
            player.sendMessage("You shouldnt be cheating!");
            }
         
            return true;
        }
    But my other class file isnt? What am I not adding?

    Code:
    public class ServerChatPlayerListener implements Listener {
     
        public static chriscommands plugin;
     
        public ServerChatPlayerListener(chriscommands instance) {
            plugin = instance;
        }
         
     
        @EventHandler(priority = EventPriority.NORMAL)
        public void onPlayerRespawn(PlayerRespawnEvent event){
               
            ChatColor RED = ChatColor.RED;
            Player p1 = event.getPlayer().getPlayer();
            p1.sendMessage(RED + "Welcome back from the dead!");
       
        }

    btw this isnt all of the code just the top half.
     
  4. Offline

    Coelho

    chriscommands.java does not need to implement Listener, as it does not listen.
    Plus, you never registered events for your ServerChatPlayerListener
     
  5. Offline

    chriztopia

    Ok how do I register the events for ServerChatPlayerListener? I have read the site just a little confused with the new coding...
     
  6. Offline

    emikodo

    In chriscommands:
    Code:
    plugin.getServer().getPluginManager().registerEvents(new ServerChatPlayerListener(this), this);
     
    chriztopia likes this.
  7. Offline

    chriztopia

    Works Great thanks....
     
  8. Offline

    emikodo

    Glad it helped.
     
Thread Status:
Not open for further replies.

Share This Page