I always struggle at this part... permissions. They just seem to never work for me and if someone is willing to help that will be great here is my code. Code: package me.WPM.PotioEffects; 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 main extends JavaPlugin{ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){ if(!(sender instanceof Player)){ } Player p = (Player) sender; if(cmd.getName().equalsIgnoreCase("speedone")){ p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 50*100, 0)); p.sendMessage(ChatColor.AQUA + "§lSpeed 1 §f§l↦ §f§l↦ §f§l↦ §1§lenabled."); return true; } if(cmd.getName().equalsIgnoreCase("speedtwo")){ p.removePotionEffect(PotionEffectType.SPEED); p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 25*100, 1)); p.sendMessage(ChatColor.AQUA + "§lSpeed 2 §f§l↦ §f§l↦ §f§l↦ §1§lenabled."); return true; } if(cmd.getName().equalsIgnoreCase("speedthree")){ p.removePotionEffect(PotionEffectType.SPEED); p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 10*100, 2)); p.sendMessage(ChatColor.AQUA + "§lSpeed 3 §f§l↦ §f§l↦ §f§l↦ §1§lenabled."); return true; } if(cmd.getName().equalsIgnoreCase("speedoff")){ p.removePotionEffect(PotionEffectType.SPEED); p.sendMessage(ChatColor.AQUA + "§lSpeed §f§l↦ §f§l↦ §f§l↦ Fine, dont run."); return true; } return true; } }
It's just another check. Code: if (cmd.getName().equalsIgnoreCase("commandone")) { if (sender.hasPermission("commandone.permission")) { // code here } } if (cmd.getName().equalsIgnoreCase("commandtwo")) { if (sender.hasPermission("commandtwo.permission")) { // code here } }
@WPM Stick to Naming Convetions Why are you checking if a player is not a sender, but then do absolutly nothing about it. Why are you using 50*100, or 25 * 100 instead of just 5000 or 2500. If you just wanted to increment the level, then associate the args with an int like so: Code: int times = 0; if(isOne) times = 1; if(isTwo) times 2; ect.