Help with my plugin (Fairly simple I guess)

Discussion in 'Plugin Development' started by Unscrewed, Apr 25, 2011.

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

    Unscrewed

    Hey there everyone! I am stuck on developing my plugin with something I think is fairly simple for you. But I'm stuck on it, lol. I want that the default is Enabled on default.

    Code:
    package me.Unscrewed.iBlock;
    
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.logging.Logger;
    import org.bukkit.block.Block;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Event;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class iBlock extends JavaPlugin {
    	private static final Logger log = Logger.getLogger("Minecraft");
    	private final iBlockBlockListener blockListener = new iBlockBlockListener(this);
        public final HashMap<Player, ArrayList<Block>> tdUsers = new HashMap<Player, ArrayList<Block>>();
        public void onEnable() {
    		PluginManager pm = getServer().getPluginManager();
    		pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener,
    				Event.Priority.Normal, this);
    		log.info("iBlock 0.1 is loaded succesfully");
    	}
    
    	public void onDisable() {
    		log.info("iBlock 0.1 is unloaded succesfully");
    	}
    	public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    		if(commandLabel.equalsIgnoreCase("iBlock")){
    			toggleiBlock((Player) sender);
    			return true;
    		}
    		return false;
    	}
    	public void toggleiBlock(Player player){
    		if(enabled(player)){
    			this.tdUsers.remove(player);
    			player.sendMessage("iBlock Disabled");
    		}else{
    			this.tdUsers.put(player, null);
    			player.sendMessage("iBlock Enabled");
    		}
    	}
    	public boolean enabled(Player player){
    		return this.tdUsers.containsKey(player);
    	}
    }
    
    Maybe it's a stupid question, but I'm really stuck here.
     
  2. Offline

    Andre_9796

    Please ask in thread plugin development because its made for these questions.
     
  3. Offline

    Unscrewed

    Ok! Thanks!
     
Thread Status:
Not open for further replies.

Share This Page