use of br.net.fabiozumbi12.RedProtect.Bukkit.API.events.DeleteRegionEvent in project RedProtect by FabioZumbi12.
the class CommandHandlers method handleDeleteName.
public static void handleDeleteName(Player p, String rname, String world) {
Region r = RedProtect.get().getRegionManager().getRegion(rname, p.getWorld().getName());
if (!world.equals("")) {
if (Sponge.getServer().getWorld(world).isPresent()) {
r = RedProtect.get().getRegionManager().getRegion(rname, world);
} else {
RedProtect.get().getLanguageManager().sendMessage(p, "cmdmanager.region.invalidworld");
return;
}
}
if (RedProtect.get().getPermissionHandler().hasRegionPermLeader(p, "delete", r)) {
if (r == null) {
RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.doesntexist") + ": " + rname);
return;
}
int claims = RedProtect.get().getConfigManager().configRoot().region_settings.can_delete_first_home_after_claims;
if (!r.canDelete() && (claims == -1 || RedProtect.get().getRegionManager().getPlayerRegions(p.getName(), p.getWorld().getName()) < claims) && !p.hasPermission("redprotect.bypass")) {
if (claims != -1) {
RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.cantdeletefirst-claims").replace("{claims}", "" + claims));
} else {
RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.cantdeletefirst"));
}
return;
}
DeleteRegionEvent event = new DeleteRegionEvent(r, p);
if (Sponge.getEventManager().post(event)) {
return;
}
RedProtect.get().getRegionManager().remove(r, r.getWorld());
RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.deleted") + " " + rname);
RedProtect.get().logger.addLog("(World " + world + ") Player " + p.getName() + " REMOVED region " + rname);
} else {
RedProtect.get().getLanguageManager().sendMessage(p, "no.permission");
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.API.events.DeleteRegionEvent in project RedProtect by FabioZumbi12.
the class CommandHandlers method handleDeleteName.
public static void handleDeleteName(Player p, String rname, String world) {
Region r = RedProtect.get().getRegionManager().getRegion(rname, p.getWorld().getName());
if (!world.equals("")) {
if (Bukkit.getWorld(world) != null) {
r = RedProtect.get().getRegionManager().getRegion(rname, world);
} else {
RedProtect.get().getLanguageManager().sendMessage(p, "cmdmanager.region.invalidworld");
return;
}
}
if (RedProtect.get().getPermissionHandler().hasRegionPermLeader(p, "delete", r)) {
if (r == null) {
RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.doesntexist") + ": " + rname);
return;
}
int claims = RedProtect.get().getConfigManager().configRoot().region_settings.can_delete_first_home_after_claims;
if (!r.canDelete() && (claims == -1 || RedProtect.get().getRegionManager().getPlayerRegions(p.getUniqueId().toString(), p.getWorld().getName()) < claims) && !p.hasPermission("redprotect.bypass")) {
if (claims != -1) {
RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.cantdeletefirst-claims").replace("{claims}", "" + claims));
} else {
RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.cantdeletefirst"));
}
return;
}
DeleteRegionEvent event = new DeleteRegionEvent(r, p);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
RedProtect.get().getRegionManager().remove(r, r.getWorld());
RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.deleted") + " " + rname);
RedProtect.get().logger.addLog("(World " + world + ") Player " + p.getName() + " REMOVED region " + rname);
// Handle money
handleDeleteRegionEconomy(r, p);
} else {
RedProtect.get().getLanguageManager().sendMessage(p, "no.permission");
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.API.events.DeleteRegionEvent in project RedProtect by FabioZumbi12.
the class CommandHandlers method handleDelete.
public static void handleDelete(Player p) {
Region r = RedProtect.get().getRegionManager().getTopRegion(p.getLocation());
if (RedProtect.get().getPermissionHandler().hasRegionPermLeader(p, "delete", r)) {
if (r == null) {
RedProtect.get().getLanguageManager().sendMessage(p, "cmdmanager.region.todo.that");
return;
}
int claims = RedProtect.get().getConfigManager().configRoot().region_settings.can_delete_first_home_after_claims;
if (!r.canDelete() && (claims == -1 || RedProtect.get().getRegionManager().getPlayerRegions(p.getUniqueId().toString(), p.getWorld().getName()) < claims) && !p.hasPermission("redprotect.bypass")) {
if (claims != -1) {
RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.cantdeletefirst-claims").replace("{claims}", "" + claims));
} else {
RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.cantdeletefirst"));
}
return;
}
DeleteRegionEvent event = new DeleteRegionEvent(r, p);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
String rname = r.getName();
String w = r.getWorld();
RedProtect.get().getRegionManager().remove(r, w);
RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.deleted") + " " + rname);
RedProtect.get().logger.addLog("(World " + w + ") Player " + p.getName() + " REMOVED region " + rname);
// Handle money
handleDeleteRegionEconomy(r, p);
} else {
RedProtect.get().getLanguageManager().sendMessage(p, "no.permission");
}
}
Aggregations