Freezing mobs with command help

Discussion in 'Plugin Development' started by QuipCream, Jan 29, 2014.

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

    QuipCream

    Hello, I am here today to ask of you of how I freeze mobs with a command, for instance if you typed /freeze, it would freeze the mob you're looking at. This is the code I got so far. I'm new to bukkit coding so I wouldn't know how to do this.
    Code:
    import org.bukkit.craftbukkit.v1_5_R2.entity.CraftLivingEntity;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class RemovePotionParticles extends JavaPlugin {
     
        public RemovePotionParticles plugin;
       
        public void onEnable() {
            startTask();
            getLogger().info("RemovePotionParticles is active and ready.");
        }
       
        public void onDisable() {
        }
     
        private void startTask() {
            long interval = 4;
            getServer().getScheduler().scheduleSyncRepeatingTask(this,
                    new removeParticle(), interval, interval);
        }
     
        private void endTask() {
            getServer().getScheduler().cancelTasks(this);
        }
     
        private class removeParticle implements Runnable {
     
            public void run() {
                for (Player player : getServer().getOnlinePlayers()) {
                    ((CraftLivingEntity) p).getHandle().getDataWatcher().watch(7, 0);
                }
            }
        }
    }
     
  2. Offline

    coolguy4744

    You actually want to add the command using the code here:
    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    2. if(cmd.getName().equalsIgnoreCase("basic")){ // If the player typed /basic then do the following...
    3. // doSomething
    4. return true;
    5. } //If this has happened the function will return true.
    6. // If this hasn't happened the a value of false will be returned.
    7. return false;
    8. }

    This is just a example, just paste it into Eclipse if this is what your using and use it as a template. If you get stuck just say.

    If you are new to bukkit I would suggest referring to the wiki which is where I copied that from. You can see it Here. Good luck with your plugin pal!
     
Thread Status:
Not open for further replies.

Share This Page