use of br.net.fabiozumbi12.RedProtect.Bukkit.region.RegionBuilder in project RedProtect by FabioZumbi12.
the class DefineCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof ConsoleCommandSender) {
HandleHelpPage(sender, 1);
return true;
}
Player player = (Player) sender;
if (args.length == 0) {
PlayerRegion serverName = new PlayerRegion(RedProtect.get().getConfigManager().configRoot().region_settings.default_leader, RedProtect.get().getConfigManager().configRoot().region_settings.default_leader);
String name = RedProtect.get().getUtil().nameGen(RedProtect.get().getConfigManager().configRoot().region_settings.default_leader, player.getWorld().getName());
RedProtect.get().getLanguageManager().sendMessage(player, "regionbuilder.creating");
// Run claim async
Bukkit.getScheduler().runTaskAsynchronously(RedProtect.get(), () -> {
RegionBuilder rb2 = new DefineRegionBuilder(player, RedProtect.get().firstLocationSelections.get(player), RedProtect.get().secondLocationSelections.get(player), name, serverName, new HashSet<>(), true);
if (rb2.ready()) {
Region r2 = rb2.build();
RedProtect.get().getLanguageManager().sendMessage(player, RedProtect.get().getLanguageManager().get("cmdmanager.region.created") + " " + r2.getName() + ".");
RedProtect.get().getRegionManager().add(r2, player.getWorld().getName());
RedProtect.get().firstLocationSelections.remove(player);
RedProtect.get().secondLocationSelections.remove(player);
RedProtect.get().logger.addLog("(World " + r2.getWorld() + ") Player " + player.getName() + " DEFINED region " + r2.getName());
}
});
return true;
}
if (args.length == 1) {
PlayerRegion serverName = new PlayerRegion(RedProtect.get().getConfigManager().configRoot().region_settings.default_leader, RedProtect.get().getConfigManager().configRoot().region_settings.default_leader);
RedProtect.get().getLanguageManager().sendMessage(player, "regionbuilder.creating");
// Run claim async
Bukkit.getScheduler().runTaskAsynchronously(RedProtect.get(), () -> {
RegionBuilder rb2 = new DefineRegionBuilder(player, RedProtect.get().firstLocationSelections.get(player), RedProtect.get().secondLocationSelections.get(player), args[0], serverName, new HashSet<>(), true);
if (rb2.ready()) {
Region r2 = rb2.build();
RedProtect.get().getLanguageManager().sendMessage(player, RedProtect.get().getLanguageManager().get("cmdmanager.region.created") + " " + r2.getName() + ".");
RedProtect.get().getRegionManager().add(r2, player.getWorld().getName());
RedProtect.get().firstLocationSelections.remove(player);
RedProtect.get().secondLocationSelections.remove(player);
RedProtect.get().logger.addLog("(World " + r2.getWorld() + ") Player " + player.getName() + " DEFINED region " + r2.getName());
}
});
return true;
}
RedProtect.get().getLanguageManager().sendCommandHelp(sender, "define", true);
return true;
}
Aggregations