Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.noflyzone;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Entity;
- import org.bukkit.entity.Player;
- public class NoFlyCommands
- implements CommandExecutor
- {
- NoFlyZone plugin;
- public NoFlyCommands(NoFlyZone i)
- {
- this.plugin = i;
- }
- @SuppressWarnings("unchecked")
- public boolean onCommand(CommandSender s, Command c, String label, String[] args)
- {
- if ((s instanceof Player))
- {
- Player p = (Player)s;
- if (!p.hasPermission("noflyzone.admin"))
- {
- this.plugin.sms(p, "&cУ вас нет прав.");
- return true;
- }
- }
- if (args.length == 0)
- {
- this.plugin.sms(s, "&8&m+----------------+");
- this.plugin.sms(s, "&cNo&fFly&cZone &f&o" + this.plugin.getDescription().getVersion());
- this.plugin.sms(s, "&7Created by: &f&oextended_clip");
- this.plugin.sms(s, "&7Translate/ReCoded: &f&oWinLocker");
- this.plugin.sms(s, "&8&m+----------------+");
- }
- else
- {
- if ((args.length != 0) && (args[0].equalsIgnoreCase("help")))
- {
- this.plugin.sms(s, "&8&m+----------------+");
- this.plugin.sms(s, "&cNo&fFly&cZone &f&oпомощь");
- this.plugin.sms(s, "&7/noflyzone - &fверсия плагина");
- this.plugin.sms(s, "&7/noflyzone reload - &fперезагрузить конфиг");
- this.plugin.sms(s, "&7/noflyzone list (world) - &fСписок регионов где запрещён &cfly&f.");
- this.plugin.sms(s, "&7/noflyzone add <world> <region> - &fДобавить регион, для запрета");
- this.plugin.sms(s, "&7/noflyzone remove <world> <region> - &fУдалить регион, для запрета.");
- this.plugin.sms(s, "&7/pfly - &fКоманды для Event.");
- this.plugin.sms(s, "&8&m+----------------+");
- return true;
- }
- if ((args.length != 0) && (args[0].equalsIgnoreCase("reload")))
- {
- this.plugin.reloadConfig();
- this.plugin.saveConfig();
- NoFlyZone.noFlyMessage = this.plugin.cfg.noFlyMessage();
- NoFlyZone.autoFlyMessage = this.plugin.cfg.autoFlyMessage();
- this.plugin.cfg.loadNoFlyRegions();
- this.plugin.cfg.loadNoFlyWorlds();
- this.plugin.cfg.loadFlyRegions();
- this.plugin.sms(s, "&8&m+----------------+");
- this.plugin.sms(s, "&7Конфиг перезагружен!");
- this.plugin.sms(s, "&8&m+----------------+");
- return true;
- }
- if ((args.length != 0) && (args[0].equalsIgnoreCase("list")))
- {
- if ((NoFlyZone.noFlyRegions == null) || (NoFlyZone.noFlyRegions.isEmpty()))
- {
- this.plugin.sms(s, "&8&m+----------------+");
- this.plugin.sms(s, "&cСписок регионов пуст.");
- this.plugin.sms(s, "&8&m+----------------+");
- return true;
- }
- if (args.length == 1)
- {
- this.plugin.sms(s, "&8&m+----------------+");
- this.plugin.sms(s, "&cNo&fFly&cZone &7worlds: &f" + NoFlyZone.noFlyWorlds.size());
- for (String world : NoFlyZone.noFlyRegions.keySet())
- {
- List<String> regions = NoFlyZone.noFlyRegions.get(world);
- if ((regions == null) || (regions.isEmpty())) {
- this.plugin.sms(s, "&a" + world + "&7: &cСписок регионов пуст.");
- } else {
- this.plugin.sms(s, "&a" + world + "&7: &f" + regions.toString().replace("[", "").replace("]", "").replace(",", "&7,&f"));
- }
- }
- this.plugin.sms(s, "&8&m+----------------+");
- return true;
- }
- String world = args[1];
- if ((!NoFlyZone.noFlyRegions.containsKey(world)) || (NoFlyZone.noFlyRegions.get(world) == null) || ((NoFlyZone.noFlyRegions.get(world)).isEmpty()))
- {
- this.plugin.sms(s, "&8&m+----------------+");
- this.plugin.sms(s, "&cРегионы в данным мире не найдены&7: &f" + world);
- this.plugin.sms(s, "&8&m+----------------+");
- return true;
- }
- Object regions = NoFlyZone.noFlyRegions.get(world);
- this.plugin.sms(s, "&8&m+----------------+");
- this.plugin.sms(s, "&a" + world + " &cNo&fFly&cZone &7регионы: &f" + ((Map<String, List<String>>) regions).size());
- this.plugin.sms(s, regions.toString().replace("[", "").replace("]", "").replace(",", "&7,&f"));
- this.plugin.sms(s, "&8&m+----------------+");
- return true;
- }
- if ((args.length != 0) && (args[0].equalsIgnoreCase("add")))
- {
- if (args.length != 3)
- {
- this.plugin.sms(s, "&cВведите: &7/nfz add <world> <region>");
- return true;
- }
- String world = args[1];
- String region = args[2];
- if ((NoFlyZone.noFlyRegions == null) || (NoFlyZone.noFlyRegions.isEmpty()))
- {
- NoFlyZone.noFlyRegions = new HashMap<>();
- NoFlyZone.noFlyRegions.put(world, Arrays.asList(new String[] { region }));
- this.plugin.sms(s, "&8&m+----------------+");
- this.plugin.sms(s, region + " &aв мире &f" + world + " &aбыл отмечен как &cNo&fFly&cZone&a!");
- this.plugin.sms(s, "&8&m+----------------+");
- this.plugin.getConfig().set("no_fly_regions." + world, NoFlyZone.noFlyRegions.get(world));
- this.plugin.saveConfig();
- return true;
- }
- if ((!NoFlyZone.noFlyRegions.containsKey(world)) || (NoFlyZone.noFlyRegions.get(world) == null))
- {
- NoFlyZone.noFlyRegions.put(world, Arrays.asList(new String[] { region }));
- this.plugin.sms(s, "&8&m+----------------+");
- this.plugin.sms(s, region + " &aiв мире &f" + world + " &aбыл отмечен как &cNo&fFly&cZone&a!");
- this.plugin.sms(s, "&8&m+----------------+");
- this.plugin.getConfig().set("no_fly_regions." + world, NoFlyZone.noFlyRegions.get(world));
- this.plugin.saveConfig();
- return true;
- }
- List<String> regz = new ArrayList<>();
- boolean contains = false;
- for (String inList : NoFlyZone.noFlyRegions.get(world))
- {
- if (inList.equalsIgnoreCase(region))
- {
- contains = true;
- break;
- }
- regz.add(inList);
- }
- if (contains)
- {
- this.plugin.sms(s, "&8&m+----------------+");
- this.plugin.sms(s, "&cРегион &f" + region + " &cв мире &f" + world + " &cуже есть как &cNo&fFly&cZone&a!");
- this.plugin.sms(s, "&8&m+----------------+");
- return true;
- }
- regz.add(region);
- NoFlyZone.noFlyRegions.put(world, regz);
- this.plugin.getConfig().set("no_fly_regions." + world, regz);
- this.plugin.saveConfig();
- this.plugin.sms(s, "&8&m+----------------+");
- this.plugin.sms(s, region + " &aв мире &f" + world + " &aбыл отмечен как &cNo&fFly&cZone&a!");
- this.plugin.sms(s, "&8&m+----------------+");
- return true;
- }
- if ((args.length != 0) && (args[0].equalsIgnoreCase("remove")))
- {
- if (args.length != 3)
- {
- this.plugin.sms(s, "&cВведите: &7/nfz remove <world> <region>");
- return true;
- }
- if ((NoFlyZone.noFlyRegions == null) || (NoFlyZone.noFlyRegions.isEmpty()))
- {
- this.plugin.sms(s, "&8&m+----------------+");
- this.plugin.sms(s, "&cНет регионов, загруженных для удаления!");
- this.plugin.sms(s, "&8&m+----------------+");
- return true;
- }
- String world = args[1];
- if ((!NoFlyZone.noFlyRegions.containsKey(world)) || (NoFlyZone.noFlyRegions.get(world) == null) || ((NoFlyZone.noFlyRegions.get(world)).isEmpty()))
- {
- this.plugin.sms(s, "&8&m+----------------+");
- this.plugin.sms(s, "&cНет регионов, загруженных для &f" + world + " &cчтобы удалить!");
- this.plugin.sms(s, "&8&m+----------------+");
- return true;
- }
- Object temp = new ArrayList<>();
- String region = args[2];
- boolean contains = false;
- for (String inList : NoFlyZone.noFlyRegions.get(world)) {
- if (inList.equalsIgnoreCase(region)) {
- contains = true;
- } else {
- ((List<String>) temp).add(inList);
- }
- }
- if (!contains)
- {
- this.plugin.sms(s, "&8&m+----------------+");
- this.plugin.sms(s, "&cНи один регион не отмечен как NoFlyZone в мире &f" + world + " &cс именем &f" + region + "&a!");
- this.plugin.sms(s, "&8&m+----------------+");
- return true;
- }
- if (((Entity) temp).isEmpty())
- {
- NoFlyZone.noFlyRegions.remove(world);
- this.plugin.getConfig().set("no_fly_regions." + world, null);
- }
- else
- {
- NoFlyZone.noFlyRegions.put(world, (List<String>) temp);
- this.plugin.getConfig().set("no_fly_regions." + world, temp);
- }
- this.plugin.saveConfig();
- this.plugin.sms(s, "&8&m+----------------+");
- this.plugin.sms(s, region + " &aв мире &f" + world + " &aболье нет для &cNo&fFly&cZone&a!");
- this.plugin.sms(s, "&8&m+----------------+");
- return true;
- }
- this.plugin.sms(s, "&cНеизвестная команда. Команды &7/nfz help");
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement