use of br.net.fabiozumbi12.RedProtect.Sponge.events.RenameRegionEvent in project RedProtect by FabioZumbi12.
the class RPCommands method handleRename.
private static void handleRename(Player p, String newName) {
Region r = RedProtect.get().rm.getTopRegion(p.getLocation());
if (RedProtect.get().ph.hasRegionPermLeader(p, "rename", r)) {
if (r == null) {
sendNotInRegionMessage(p);
return;
}
// region name conform
newName = newName.replace("/", "|");
if (RedProtect.get().rm.getRegion(newName, p.getWorld()) != null) {
RPLang.sendMessage(p, "cmdmanager.region.rename.already");
return;
}
if (newName.length() < 2 || newName.length() > 16) {
RPLang.sendMessage(p, "cmdmanager.region.rename.invalid");
return;
}
if (newName.contains(" ")) {
RPLang.sendMessage(p, "cmdmanager.region.rename.spaces");
return;
}
if (newName.contains("@")) {
p.sendMessage(RPLang.get("regionbuilder.regionname.invalid.charac").replace("{charac}", "@"));
return;
}
RenameRegionEvent event = new RenameRegionEvent(r, newName, r.getName(), p);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
String oldname = event.getOldName();
newName = event.getNewName();
RedProtect.get().rm.renameRegion(newName, r);
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.rename.newname") + " " + newName);
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " RENAMED region " + oldname + " to " + newName);
} else {
RPLang.sendMessage(p, "no.permission");
}
}
use of br.net.fabiozumbi12.RedProtect.Sponge.events.RenameRegionEvent in project RedProtect by FabioZumbi12.
the class RPCommands method handleRename.
private static void handleRename(Player p, String newName) {
Region r = RedProtect.get().rm.getTopRegion(p.getLocation());
if (RedProtect.get().ph.hasRegionPermLeader(p, "rename", r)) {
if (r == null) {
sendNotInRegionMessage(p);
return;
}
// region name conform
newName = newName.replace("/", "|");
if (RedProtect.get().rm.getRegion(newName, p.getWorld()) != null) {
RPLang.sendMessage(p, "cmdmanager.region.rename.already");
return;
}
if (newName.length() < 2 || newName.length() > 16) {
RPLang.sendMessage(p, "cmdmanager.region.rename.invalid");
return;
}
if (newName.contains(" ")) {
RPLang.sendMessage(p, "cmdmanager.region.rename.spaces");
return;
}
if (newName.contains("@")) {
p.sendMessage(RPUtil.toText(RPLang.get("regionbuilder.regionname.invalid.charac").replace("{charac}", "@")));
return;
}
RenameRegionEvent event = new RenameRegionEvent(r, newName, r.getName(), p);
if (Sponge.getEventManager().post(event)) {
return;
}
String oldname = event.getOldName();
newName = event.getNewName();
RedProtect.get().rm.renameRegion(newName, r);
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.rename.newname") + " " + newName);
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " RENAMED region " + oldname + " to " + newName);
} else {
RPLang.sendMessage(p, "no.permission");
}
}
Aggregations