Skip to content

Instantly share code, notes, and snippets.

@brianherman
Created July 27, 2014 02:56
Show Gist options
  • Save brianherman/2c1285d15981ad734ec6 to your computer and use it in GitHub Desktop.
Save brianherman/2c1285d15981ad734ec6 to your computer and use it in GitHub Desktop.
package org.discordpvp;
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;
public class KitchenSink extends JavaPlugin{
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("removePotion")) {
if (!(sender instanceof Player)) {
sender.sendMessage("Only players can use this command!");
return true;
}
// After checking to make sure that the sender is a Player, we can safely case it to one.
Player s = (Player) sender;
for (PotionEffect effect : s.getActivePotionEffects())
s.removePotionEffect(effect.getType());
return true;
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment