Events don't work anymore.

Discussion in 'Plugin Development' started by Saturisk, Mar 2, 2011.

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

    Saturisk

    What happened to the events?
    i have several things like: event.getPlayer(); etc... none them work.

    My code is:
    Code:
    package com.saturisk.shawn.PackagePlugin;
    
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Event;
    import org.bukkit.event.Event.Priority;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class PackagePlugin extends JavaPlugin {
    
        PackagePluginPlayerListener playerListener = new PackagePluginPlayerListener();
    
        @Override
        public void onDisable() {
            PluginDescriptionFile pdfFile = this.getDescription();
            System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " stopping...");
    
        }
    
        @Override
        public void onEnable() {
            PluginDescriptionFile pdfFile = this.getDescription();
            System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " starting!");
    
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this );
    
        }
    
        public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
    
            if (!(sender instanceof Player)) {
                sender.sendMessage(ChatColor.RED + "You have to be a player!");
                return true;
            }
    
            Player player = (Player)sender;
    
            return false;
    
        }
    
    }
    Working on the commands portion of it, i can figure it out just need to make the other part first which is this:

    Code:
    package com.saturisk.shawn.PackagePlugin;
    
    import org.bukkit.entity.Player;
    import org.bukkit.event.player.PlayerListener;
    
    public class PackagePluginPlayerListener extends PlayerListener {
    
        public PackagePluginPlayerListener(){
    
        }
    
        public void setFire(Player player){
    
        String s = "";
    
        if(event.getPlayer().isOp() && s[0].equalsIgnoreCase("/fire")){
            //Define a variable of type Player for storing the person to set on fire (initially set to null).
            Player target = null;
            //Check whether there command includes an extra argument for player name
            if(s.length() > 1)
                //If so, set target to be the player with the name given
                target = event.getPlayer().getServer().getPlayer(s[1]);
            //if by this point target is still equal to null, either a name argument wasn't supplied or there was no player with that name.
            if(target == null)
                //in that case, target the player calling the command.
                target = event.getPlayer();
            //set target on fire.
            target.setFireTicks(100);
    
        }
    
    
        }
    
    }
    
    This command is supposed to be for example:
    '/fire shadow8549' it would like a person named shadow8549 on fire for 2 secs, it used to work before the new update.

    How do i fix it to work with the new update? Please be descriptive. I need to fix many more plugins other than this one.
    --- merged: Mar 3, 2011 6:18 AM ---
    wow i suck at trying to ask for help, nicely....
     
  2. Offline

    Edward Hand

  3. Offline

    Saturisk

    See, i'm still learning java. I looked at a buddies code and tried to make the same thing just with my functions and stuff. It didn't work. Thanks for the events page by the way that really helps.
     
Thread Status:
Not open for further replies.

Share This Page