Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ru.frank.connector;
- import java.util.ArrayList;
- import java.util.List;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.World;
- import org.bukkit.block.Block;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import ru.frank.api.Cuboid;
- public class Private implements CommandExecutor {
- private Mainclass plugin = Mainclass.getPlugin(Mainclass.class);
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- if(cmd.getName().equalsIgnoreCase("private")) {
- if(!(sender instanceof Player)) {
- sender.sendMessage(ChatColor.RED + "Только для игроков!");
- } else {
- if(args.length != 1) {
- sender.sendMessage(ChatColor.RED + "Недостаточно аргументов!");
- } else {
- Player p = (Player) sender;
- List<String> list = new ArrayList<String>();
- for(int i = 0; i != Mainclass.getPrivate().size(); i++) {
- if(Mainclass.getPrivate().get(i).getPlayer().getName().equals(p.getName())) {
- list.add(String.valueOf(i));
- }
- }
- Boolean next = true;
- if(list.size() != 2) {
- p.sendMessage(ChatColor.RED + "Не выделены точки!");
- } else {
- for(String privater : plugin.getConfig().getStringList(".Privates")) {
- World world = Bukkit.getWorld(plugin.getConfig().getString("Private." + privater + ".world"));
- double x1 = plugin.getConfig().getDouble("Private." + privater + ".x1");
- double y1 = plugin.getConfig().getDouble("Private." + privater + ".y1");
- double z1 = plugin.getConfig().getDouble("Private." + privater + ".z1");
- double x2 = plugin.getConfig().getDouble("Private." + privater + ".x2");
- double y2 = plugin.getConfig().getDouble("Private." + privater + ".y2");
- double z2 = plugin.getConfig().getDouble("Private." + privater + ".z2");
- Location loc1 = new Location(world, x1, y1, z1);
- Location loc2 = new Location(world, x2, y2, z2);
- Cuboid cub1 = new Cuboid(loc1, loc2);
- Cuboid cub2 = new Cuboid(Mainclass.getPrivate().get(Integer.parseInt(list.get(0))).getLocation(), Mainclass.getPrivate().get(Integer.parseInt(list.get(1))).getLocation());
- for(Block block : cub2.getBlocks()) {
- if(cub1.contains(block.getLocation())) {
- next = false;
- break;
- }
- }
- }
- if(next == false) {
- p.sendMessage(ChatColor.RED + "Происходит пересечение с другими регионами!");
- } else {
- if(plugin.getConfig().getStringList(".Privates").contains(args[0])) {
- p.sendMessage(ChatColor.RED + "Такое название региона уже используется!");
- } else {
- plugin.getConfig().set("Private." + args[0] + ".world", Mainclass.getPrivate().get(Integer.parseInt(list.get(0))).getLocation().getWorld().getName());
- plugin.getConfig().set("Private." + args[0] + ".x1", Mainclass.getPrivate().get(Integer.parseInt(list.get(0))).getLocation().getX());
- plugin.getConfig().set("Private." + args[0] + ".y1", Mainclass.getPrivate().get(Integer.parseInt(list.get(0))).getLocation().getY());
- plugin.getConfig().set("Private." + args[0] + ".z1", Mainclass.getPrivate().get(Integer.parseInt(list.get(0))).getLocation().getZ());
- plugin.getConfig().set("Private." + args[0] + ".x2", Mainclass.getPrivate().get(Integer.parseInt(list.get(1))).getLocation().getX());
- plugin.getConfig().set("Private." + args[0] + ".y2", Mainclass.getPrivate().get(Integer.parseInt(list.get(1))).getLocation().getY());
- plugin.getConfig().set("Private." + args[0] + ".z2", Mainclass.getPrivate().get(Integer.parseInt(list.get(1))).getLocation().getZ());
- List<String> liste = new ArrayList<String>();
- liste.add(p.getName());
- plugin.getConfig().set("Private." + args[0] + ".players", liste);
- List<String> esketit = plugin.getConfig().getStringList(".Privates");
- esketit.add(args[0]);
- plugin.getConfig().set(".Privates", esketit);
- plugin.saveConfig();
- p.sendMessage(ChatColor.GREEN + "Территория успешно запривачена!");
- }
- }
- }
- }
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement