PotionEffects

Discussion in 'Plugin Development' started by TripleXPenguin, Apr 6, 2012.

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

    TripleXPenguin

    I'm having a problem and it is kind of hard to explain but, I took my MoonJump plugin, which allowed players to increase their jumping height with /mj on and /mj off. I decided I was going to make another plugin which uses different PotionEffects, so in a test I just changed the JUMP potioneffect in my MoonJump plugin to CONFUSION. But whenever I use /mj on it shows the potion bubbles under me but confusion doesnt turn on. But If i go and stop the server, change the potioneffect in the plugin (say, to BLINDNESS) and start the server again the potioneffect from BEFORE (Confusion) starts to work! I have no clue why, and I cant turn it off because I already changed the potioneffect in the plugin (to Blindness). I'm not sure why it isn't working now because it works with Jump just not Confusion or Blindness. Here is the code:

    Code:
    package me.triple.moonjump;
     
    import java.util.logging.Logger;
     
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
     
    public class MoonJump extends JavaPlugin {
     
        public static MoonJump instance;
        Logger console = Logger.getLogger("Minecraft");
        String pName = "MoonJump";
     
        public void onDisable() {
            console.info("[" + pName + "] " + pName + " has been disabled.");
            console.info("[" + pName + "] " + pName
                    + " was created by TripleXPenguin");
        }
     
        public void onEnable() {
            console.info("[" + pName + "] " + pName + " has been enabled.");
            console.info("[" + pName + "] Created by TripleXPenguin");
        }
     
        public boolean onCommand(CommandSender sender, Command cmd, String label,
                String[] args) {
            Player player = (Player) sender;
            if (cmd.getName().equalsIgnoreCase("mj")) {
                if (sender.hasPermission("moonjump.jump")) {
                    if (args.length > 0 && args[0].equals("on")) {
                        player.addPotionEffect(new PotionEffect(
                                PotionEffectType.CONFUSION, 99999, 10));
                        sender.sendMessage("You are now on the moon!");
                        //player.removePotionEffect(PotionEffectType.JUMP);
                        return true;
                    } else if (args.length > 0 && args[0].equals("off")) {
                        player.addPotionEffect(new PotionEffect(
                            PotionEffectType.CONFUSION, 0, 0), true);
                        sender.sendMessage("Houston we have landed...");
                        return true;
                    } else {
                        sender.sendMessage("/mj [on/off]");
                        return true;
                    }
                } else {
                    sender.sendMessage(ChatColor.RED
                            + "You do not have permission to use MoonJump");
                    return true;
                }
            }
            return false;
     
        }
    }
    
     
Thread Status:
Not open for further replies.

Share This Page