use of biz.princeps.landlord.util.OwnedLand in project LandLord by SpatiumPrinceps.
the class Manage method onManage.
public void onManage(Player player, String[] args) {
OwnedLand land = plugin.getWgHandler().getRegion(player.getLocation().getChunk());
if (land == null) {
player.sendMessage(lm.getString("Commands.Manage.notOwnFreeLand"));
return;
}
if (!land.isOwner(player.getUniqueId()) && !player.hasPermission("landlord.admin.manage")) {
player.sendMessage(lm.getString("Commands.Manage.notOwn").replace("%owner%", land.printOwners()));
return;
}
// land manage
if (args.length == 0) {
ManageGUI gui = new ManageGUI(player, land);
gui.display();
} else if (args.length == 1) {
// land manage <landid>
World world;
try {
world = Bukkit.getWorld(args[0].split("_")[0]);
} catch (IndexOutOfBoundsException e) {
player.sendMessage(lm.getString("Commands.manage.invalidArguments"));
return;
}
if (Bukkit.getWorlds().contains(world)) {
RegionManager rm = plugin.getWgHandler().getWG().getRegionManager(world);
if (rm != null) {
ProtectedRegion target = rm.getRegion(args[0]);
if (target != null) {
ManageGUI gui = new ManageGUI(player, plugin.getLand(target));
gui.display();
}
}
}
} else {
// land manage <allCommands>
switch(args[0]) {
case "setgreetall":
StringBuilder sb1 = new StringBuilder();
for (int i = 1; i < args.length; i++) {
sb1.append(args[i]).append(" ");
}
String newmsg1 = sb1.toString();
for (ProtectedRegion protectedRegion : plugin.getWgHandler().getRegions(player.getUniqueId())) {
protectedRegion.setFlag(DefaultFlag.GREET_MESSAGE, newmsg1);
}
player.sendMessage(lm.getString("Commands.Manage.SetGreet.successful").replace("%msg%", newmsg1));
break;
case "setfarewellall":
StringBuilder sb = new StringBuilder();
for (int i = 1; i < args.length; i++) {
sb.append(args[i]).append(" ");
}
String newmsg = sb.toString();
for (ProtectedRegion protectedRegion : plugin.getWgHandler().getRegions(player.getUniqueId())) {
protectedRegion.setFlag(DefaultFlag.FAREWELL_MESSAGE, newmsg);
}
player.sendMessage(lm.getString("Commands.Manage.SetFarewell.successful").replace("%msg%", newmsg));
break;
case "setgreet":
setGreet(player, args, plugin.getLand(player.getLocation()).getWGLand(), 1);
break;
case "setfarewell":
setFarewell(player, args, plugin.getLand(player.getLocation()).getWGLand(), 1);
break;
default:
try {
World world = Bukkit.getWorld(args[0].split("_")[0]);
if (Bukkit.getWorlds().contains(world)) {
RegionManager rm = plugin.getWgHandler().getWG().getRegionManager(world);
if (rm != null) {
ProtectedRegion target = rm.getRegion(args[0]);
switch(args[1]) {
case "setgreet":
setGreet(player, args, target, 2);
break;
case "setfarewell":
setFarewell(player, args, target, 2);
break;
}
}
}
} catch (IndexOutOfBoundsException e) {
player.sendMessage(lm.getString("Commands.manage.invalidArguments"));
}
break;
}
}
}
use of biz.princeps.landlord.util.OwnedLand in project LandLord by SpatiumPrinceps.
the class ManageAll method onManageAll.
public void onManageAll(Player player) {
List<OwnedLand> lands = new ArrayList<>();
for (World world : Bukkit.getWorlds()) {
for (ProtectedRegion pr : plugin.getWgHandler().getRegions(player.getUniqueId(), world)) {
lands.add(plugin.getLand(pr));
}
}
ManageGUIAll gui = new ManageGUIAll(player, lands);
gui.display();
}
use of biz.princeps.landlord.util.OwnedLand in project LandLord by SpatiumPrinceps.
the class WorldGuardHandler method getRegion.
public OwnedLand getRegion(Chunk chunk) {
RegionManager manager = wg.getRegionContainer().get(chunk.getWorld());
ProtectedRegion pr = manager != null ? manager.getRegion(OwnedLand.getName(chunk)) : null;
return (pr != null ? new OwnedLand(pr, chunk) : null);
}
use of biz.princeps.landlord.util.OwnedLand in project LandLord by SpatiumPrinceps.
the class WorldGuardHandler method getRegionsAsOL.
public List<OwnedLand> getRegionsAsOL(UUID id) {
List<OwnedLand> list = new ArrayList<>();
OfflinePlayer op = Bukkit.getOfflinePlayer(id);
if (op != null)
for (World world : Bukkit.getWorlds()) {
// Only count enabled worlds
if (!Landlord.getInstance().getConfig().getStringList("disabled-worlds").contains(world.getName()))
for (ProtectedRegion protectedRegion : getRegions(id, world)) {
list.add(getRegion(protectedRegion));
}
}
return list;
}
use of biz.princeps.landlord.util.OwnedLand in project LandLord by SpatiumPrinceps.
the class TresholdListener method onBucketEmpty.
@EventHandler
public void onBucketEmpty(PlayerBucketEmptyEvent e) {
Player p = e.getPlayer();
OwnedLand land = plugin.getLand(e.getBlockClicked().getLocation());
handleLand(p, e.getBlockClicked().getLocation(), land, e);
}
Aggregations