Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.Ramsay.effectme;
- import org.bukkit.Bukkit;
- 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 EffectMe extends JavaPlugin {
- public void onEnable() {
- Bukkit.getServer().getLogger().info("EffectMe has been enabled!");
- }
- public void onDisable() {
- Bukkit.getServer().getLogger().info("EffectMe has been disabled!");
- }
- public boolean onCommand(CommandSender sender, Command cmd,
- String commandLabel, String[] args) {
- Player player = (Player) sender;
- Player target = null;
- PotionEffect speed = new PotionEffect(PotionEffectType.SPEED,
- Integer.MAX_VALUE, 2);
- if (commandLabel.equalsIgnoreCase("effect")) {
- if (args.length < 2) {
- player.sendMessage("Please specify an effect!");
- }
- target = Bukkit.getServer().getPlayer(args[0]);
- if(target != null) { // Make sure the target exists
- target.addPotionEffect(speed);
- } else {
- player.sendMessage("Player not online!");
- }
- }
- if (commandLabel.equalsIgnoreCase("removeeffects")) {
- Player p = (Player) sender;
- if (target != null) {
- if (args[0].equalsIgnoreCase(target.getName())) { // Verify by player name
- for (PotionEffect pe : target.getActivePotionEffects()) { // Make the remove on the target
- target.removePotionEffect(pe.getType()); // remove the the effects from the target
- }
- }
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement