use of br.net.fabiozumbi12.RedProtect.Bukkit.API.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.Bukkit.API.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");
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.API.events.RenameRegionEvent in project RedProtect by FabioZumbi12.
the class CommandHandlers method handleRename.
public static void handleRename(Player p, String newName) {
Region r = RedProtect.get().getRegionManager().getTopRegion(p.getLocation(), CommandHandlers.class.getName());
if (RedProtect.get().getPermissionHandler().hasRegionPermLeader(p, "rename", r)) {
if (r == null) {
RedProtect.get().getLanguageManager().sendMessage(p, "cmdmanager.region.todo.that");
return;
}
// filter name
newName = RedProtect.get().getUtil().fixRegionName(p, newName);
if (newName == null)
return;
RenameRegionEvent event = new RenameRegionEvent(r, newName, r.getName(), p);
if (Sponge.getEventManager().post(event)) {
return;
}
String oldName = event.getOldName();
newName = event.getNewName();
Region newRegion = RedProtect.get().getRegionManager().renameRegion(newName, r);
RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.rename.newname") + " " + newRegion.getName());
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " RENAMED region " + oldName + " to " + newRegion.getName());
} else {
RedProtect.get().getLanguageManager().sendMessage(p, "no.permission");
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.API.events.RenameRegionEvent in project RedProtect by FabioZumbi12.
the class CommandHandlers method handleRename.
public static void handleRename(Player p, String newName) {
Region r = RedProtect.get().getRegionManager().getTopRegion(p.getLocation());
if (RedProtect.get().getPermissionHandler().hasRegionPermLeader(p, "rename", r)) {
if (r == null) {
RedProtect.get().getLanguageManager().sendMessage(p, "cmdmanager.region.todo.that");
return;
}
// filter name
newName = RedProtect.get().getUtil().fixRegionName(p, newName);
if (newName == null)
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();
Region newRegion = RedProtect.get().getRegionManager().renameRegion(newName, r);
RedProtect.get().getLanguageManager().sendMessage(p, RedProtect.get().getLanguageManager().get("cmdmanager.region.rename.newname") + " " + newRegion.getName());
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " RENAMED region " + oldname + " to " + newRegion.getName());
} else {
RedProtect.get().getLanguageManager().sendMessage(p, "no.permission");
}
}
Aggregations