use of br.net.fabiozumbi12.RedProtect.Bukkit.API.events.DeleteRegionEvent in project RedProtect by FabioZumbi12.
the class RPCommands method handleDelete.
private static void handleDelete(Player p) {
Region r = RedProtect.get().rm.getTopRegion(p.getLocation());
if (RedProtect.get().ph.hasRegionPermLeader(p, "delete", r)) {
if (r == null) {
sendNotInRegionMessage(p);
return;
}
int claims = RPConfig.getInt("region-settings.first-home.can-delete-after-claims");
if (!r.canDelete() && (claims == -1 || RedProtect.get().rm.getPlayerRegions(p.getName(), p.getWorld()) < claims) && !p.hasPermission("redprotect.bypass")) {
if (claims != -1) {
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.cantdeletefirst-claims").replace("{claims}", "" + claims));
} else {
RPLang.sendMessage(p, RPLang.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().rm.remove(r, RedProtect.get().serv.getWorld(w));
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.deleted") + " " + rname);
RedProtect.get().logger.addLog("(World " + w + ") Player " + p.getName() + " REMOVED region " + rname);
} else {
sendNoPermissionMessage(p);
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.API.events.DeleteRegionEvent in project RedProtect by FabioZumbi12.
the class RPCommands method handleDeleteName.
private static void handleDeleteName(Player p, String rname, String world) {
Region r = RedProtect.get().rm.getRegion(rname, p.getWorld());
if (!world.equals("")) {
if (Bukkit.getWorld(world) != null) {
r = RedProtect.get().rm.getRegion(rname, Bukkit.getWorld(world));
} else {
RPLang.sendMessage(p, "cmdmanager.region.invalidworld");
return;
}
}
if (RedProtect.get().ph.hasRegionPermLeader(p, "delete", r)) {
if (r == null) {
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.doesntexist") + ": " + rname);
return;
}
int claims = RPConfig.getInt("region-settings.first-home.can-delete-after-claims");
if (!r.canDelete() && (claims == -1 || RedProtect.get().rm.getPlayerRegions(p.getName(), p.getWorld()) < claims) && !p.hasPermission("redprotect.bypass")) {
if (claims != -1) {
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.cantdeletefirst-claims").replace("{claims}", "" + claims));
} else {
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.cantdeletefirst"));
}
return;
}
DeleteRegionEvent event = new DeleteRegionEvent(r, p);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
RedProtect.get().rm.remove(r, RedProtect.get().serv.getWorld(r.getWorld()));
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.deleted") + " " + rname);
RedProtect.get().logger.addLog("(World " + world + ") Player " + p.getName() + " REMOVED region " + rname);
} else {
sendNoPermissionMessage(p);
}
}
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(), CommandHandlers.class.getName());
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.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;
}
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
if (RedProtect.get().getConfigManager().ecoRoot().claim_cost_per_block.enable && !p.hasPermission("redprotect.eco.bypass")) {
UniqueAccount acc = RedProtect.get().economy.getOrCreateAccount(p.getUniqueId()).get();
long reco = r.getArea() * RedProtect.get().getConfigManager().ecoRoot().claim_cost_per_block.cost_per_block;
if (!RedProtect.get().getConfigManager().ecoRoot().claim_cost_per_block.y_is_free) {
reco = reco * Math.abs(r.getMaxY() - r.getMinY());
}
if (reco > 0) {
acc.deposit(RedProtect.get().economy.getDefaultCurrency(), BigDecimal.valueOf(reco), RedProtect.get().getVersionHelper().getCause(p));
p.sendMessage(RedProtect.get().getUtil().toText(RedProtect.get().getLanguageManager().get("economy.region.deleted").replace("{price}", RedProtect.get().getConfigManager().ecoRoot().economy_symbol + reco + " " + RedProtect.get().getConfigManager().ecoRoot().economy_name)));
}
}
} 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 RPCommands method handleDeleteName.
private static void handleDeleteName(Player p, String rname, String world) {
Region r = RedProtect.get().rm.getRegion(rname, p.getWorld());
if (!world.equals("")) {
if (Sponge.getServer().getWorld(world).isPresent()) {
r = RedProtect.get().rm.getRegion(rname, Sponge.getServer().getWorld(world).get());
} else {
RPLang.sendMessage(p, "cmdmanager.region.invalidworld");
return;
}
}
if (RedProtect.get().ph.hasRegionPermLeader(p, "delete", r)) {
if (r == null) {
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.doesntexist") + ": " + rname);
return;
}
String puuid = RPUtil.PlayerToUUID(p.getName());
if (r.isRentFor(puuid)) {
RPLang.sendMessage(p, "cmdmanager.rent.cantdothisrent");
return;
}
int claims = RedProtect.get().cfgs.getInt("region-settings.first-home.can-delete-after-claims");
if (!r.canDelete() && (claims == -1 || RedProtect.get().rm.getPlayerRegions(p.getName(), p.getWorld()) < claims) && !p.hasPermission("redprotect.bypass")) {
if (claims != -1) {
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.cantdeletefirst-claims").replace("{claims}", "" + claims));
} else {
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.cantdeletefirst"));
}
return;
}
DeleteRegionEvent event = new DeleteRegionEvent(r, p);
if (Sponge.getEventManager().post(event)) {
return;
}
RedProtect.get().rm.remove(r, RedProtect.get().serv.getWorld(r.getWorld()).get());
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.deleted") + " " + rname);
RedProtect.get().logger.addLog("(World " + world + ") Player " + p.getName() + " REMOVED region " + rname);
} else {
sendNoPermissionMessage(p);
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.API.events.DeleteRegionEvent in project RedProtect by FabioZumbi12.
the class RPCommands method handleDelete.
private static void handleDelete(Player p) {
Region r = RedProtect.get().rm.getTopRegion(p.getLocation());
if (RedProtect.get().ph.hasRegionPermLeader(p, "delete", r)) {
if (r == null) {
sendNotInRegionMessage(p);
return;
}
String puuid = RPUtil.PlayerToUUID(p.getName());
if (r.isRentFor(puuid)) {
RPLang.sendMessage(p, "cmdmanager.rent.cantdothisrent");
return;
}
int claims = RedProtect.get().cfgs.getInt("region-settings.first-home.can-delete-after-claims");
if (!r.canDelete() && (claims == -1 || RedProtect.get().rm.getPlayerRegions(p.getName(), p.getWorld()) < claims) && !p.hasPermission("redprotect.bypass")) {
if (claims != -1) {
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.cantdeletefirst-claims").replace("{claims}", "" + claims));
} else {
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.cantdeletefirst"));
}
return;
}
DeleteRegionEvent event = new DeleteRegionEvent(r, p);
if (Sponge.getEventManager().post(event)) {
return;
}
String rname = r.getName();
String w = r.getWorld();
RedProtect.get().rm.remove(r, RedProtect.get().serv.getWorld(w).get());
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.deleted") + " " + rname);
RedProtect.get().logger.addLog("(World " + w + ") Player " + p.getName() + " REMOVED region " + rname);
} else {
sendNoPermissionMessage(p);
}
}
Aggregations