Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. package me.Ramsay.effectme;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.command.Command;
  5. import org.bukkit.command.CommandSender;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.plugin.java.JavaPlugin;
  8. import org.bukkit.potion.PotionEffect;
  9. import org.bukkit.potion.PotionEffectType;
  10.  
  11. public class EffectMe extends JavaPlugin {
  12.  
  13. public void onEnable() {
  14. Bukkit.getServer().getLogger().info("EffectMe has been enabled!");
  15. }
  16.  
  17. public void onDisable() {
  18. Bukkit.getServer().getLogger().info("EffectMe has been disabled!");
  19. }
  20.  
  21. public boolean onCommand(CommandSender sender, Command cmd,
  22. String commandLabel, String[] args) {
  23. Player player = (Player) sender;
  24. Player target = null;
  25. PotionEffect speed = new PotionEffect(PotionEffectType.SPEED,
  26. Integer.MAX_VALUE, 2);
  27.  
  28. if (commandLabel.equalsIgnoreCase("effect")) {
  29. if (args.length < 2) {
  30. player.sendMessage("Please specify an effect!");
  31. }
  32. target = Bukkit.getServer().getPlayer(args[0]);
  33. if(target != null) { // Make sure the target exists
  34. target.addPotionEffect(speed);
  35. } else {
  36. player.sendMessage("Player not online!");
  37. }
  38.  
  39. }
  40.  
  41. if (commandLabel.equalsIgnoreCase("removeeffects")) {
  42. Player p = (Player) sender;
  43. if (target != null) {
  44. if (args[0].equalsIgnoreCase(target.getName())) { // Verify by player name
  45. for (PotionEffect pe : target.getActivePotionEffects()) { // Make the remove on the target
  46. target.removePotionEffect(pe.getType()); // remove the the effects from the target
  47.  
  48. }
  49. }
  50. }
  51. }
  52. return false;
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement