Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cpr.core;
- 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 void onEnable() {
- getConfig().options().copyDefaults(true);
- saveDefaultConfig();
- }
- public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
- Player p = (Player) sender;
- if (cmd.getName().equalsIgnoreCase("NightVision")) {
- if (!sender.hasPermission("cmdpotion.nightvision")) {
- sender.sendMessage(ChatColor.DARK_RED + "You do not have access to tha command!");
- return true;
- }
- if (!(sender instanceof Player)) {
- sender.sendMessage("Only players can use this command!");
- return true;
- }
- if (args.length < 1) {
- for (String st : getConfig().getStringList("NightVisionInvalid"))
- p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
- return true;
- } else if (args[0].equalsIgnoreCase("on")) {
- for (String st : getConfig().getStringList("NightVisionOn"))
- p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
- p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 1));
- } else if (args[0].equalsIgnoreCase("off")) {
- for (String st : getConfig().getStringList("NightVisionOff"))
- p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
- p.removePotionEffect(PotionEffectType.NIGHT_VISION);
- } else {
- for (String st : getConfig().getStringList("NightVisionInvalid"))
- p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
- }
- }
- if (cmd.getName().equalsIgnoreCase("speed")) {
- if (!sender.hasPermission("cmdpotion.speed")) {
- sender.sendMessage(ChatColor.DARK_RED + "You do not have access to tha command!");
- return true;
- }
- if (!(sender instanceof Player)) {
- sender.sendMessage("Only players can use this command!");
- return true;
- }
- if (args.length < 1) {
- for (String st : getConfig().getStringList("SpeedInvalid"))
- p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
- return true;
- } else if (args[0].equalsIgnoreCase("on")) {
- for (String st : getConfig().getStringList("SpeedOn"))
- p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
- p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1));
- } else if (args[0].equalsIgnoreCase("off")) {
- for (String st : getConfig().getStringList("SpeedOff"))
- p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
- p.removePotionEffect(PotionEffectType.SPEED);
- } else {
- for (String st : getConfig().getStringList("SpeedInvalid"))
- p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
- }
- }
- if (cmd.getName().equalsIgnoreCase("haste")) {
- if (!sender.hasPermission("cmdpotion.haste")) {
- sender.sendMessage(ChatColor.DARK_RED + "You do not have access to tha command!");
- return true;
- }
- if (!(sender instanceof Player)) {
- sender.sendMessage("Only players can use this command!");
- return true;
- }
- if (args.length < 1) {
- for (String st : getConfig().getStringList("HasteInvalid"))
- p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
- return true;
- } else if (args[0].equalsIgnoreCase("on")) {
- for (String st : getConfig().getStringList("HasteOn"))
- p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
- p.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, Integer.MAX_VALUE, 1));
- } else if (args[0].equalsIgnoreCase("off")) {
- for (String st : getConfig().getStringList("HasteOff"))
- p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
- p.removePotionEffect(PotionEffectType.FAST_DIGGING);
- } else {
- for (String st : getConfig().getStringList("HasteInvalid"))
- p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
- }
- }
- if (cmd.getName().equalsIgnoreCase("WaterBreathing")) {
- if (!sender.hasPermission("cmdpotion.waterbreathing")) {
- sender.sendMessage(ChatColor.DARK_RED + "You do not have access to tha command!");
- return true;
- }
- if (!(sender instanceof Player)) {
- sender.sendMessage("Only players can use this command!");
- return true;
- }
- if (args.length < 1) {
- for (String st : getConfig().getStringList("WaterBreathingInvalid"))
- p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
- return true;
- } else if (args[0].equalsIgnoreCase("on")) {
- for (String st : getConfig().getStringList("WaterBreathingOn"))
- p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
- p.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, Integer.MAX_VALUE, 1));
- } else if (args[0].equalsIgnoreCase("off")) {
- for (String st : getConfig().getStringList("WaterBreathingOff"))
- p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
- p.removePotionEffect(PotionEffectType.WATER_BREATHING);
- } else {
- for (String st : getConfig().getStringList("WaterBreathingInvalid"))
- p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement