use of biz.princeps.landlord.util.OwnedLand in project LandLord by SpatiumPrinceps.
the class Addfriend method onAddfriend.
public void onAddfriend(Player player, String[] names) {
Chunk chunk = player.getWorld().getChunkAt(player.getLocation());
OwnedLand land = plugin.getWgHandler().getRegion(chunk);
if (land != null) {
if (!land.isOwner(player.getUniqueId()) && !player.hasPermission("landlord.admin.modifyfriends")) {
player.sendMessage(lm.getString("Commands.Addfriend.notOwn").replace("%owner%", land.printOwners()));
return;
}
if (names.length == 0) {
player.sendMessage(lm.getString("Commands.Addfriend.noPlayer").replace("%players%", Arrays.asList(names).toString()));
return;
}
for (String target : names) {
plugin.getPlayerManager().getOfflinePlayer(target, lPlayer -> {
if (lPlayer == null) {
player.sendMessage(lm.getString("Commands.Addfriend.noPlayer").replace("%players%", Arrays.asList(names).toString()));
} else {
// Success
if (!land.getWGLand().getOwners().getUniqueIds().contains(lPlayer.getUuid())) {
land.getWGLand().getMembers().addPlayer(lPlayer.getUuid());
player.sendMessage(lm.getString("Commands.Addfriend.success").replace("%players%", Arrays.asList(names).toString()));
} else {
player.sendMessage(lm.getString("Commands.Addfriend.alreadyOwn"));
}
}
});
// lets delay it, because we cant be sure, that the requests are done when executing this piece of code
new BukkitRunnable() {
@Override
public void run() {
plugin.getMapManager().updateAll();
}
}.runTaskLater(plugin, 60L);
}
}
}
use of biz.princeps.landlord.util.OwnedLand in project LandLord by SpatiumPrinceps.
the class ListLands method onListLands.
public void onListLands(Player sender, LPlayer target, int page) {
List<ProtectedRegion> lands = new ArrayList<>(plugin.getWgHandler().getRegions(target.getUuid()));
if (lands.size() > 0) {
String mode = plugin.getConfig().getString("CommandSettings.ListLands.mode");
if (mode.equals("gui")) {
MultiPagedGUI landGui = new MultiPagedGUI(sender, 5, plugin.getLangManager().getRawString("Commands.ListLands.header").replace("%player%", target.getName()));
lands.forEach(land -> landGui.addIcon(new Icon(new ItemStack(Material.GRASS)).setName(land.getId())));
landGui.setIcon(52, new Icon(new ItemStack(Material.BEACON)).setName(lm.getRawString("Commands.ListLands.manageAll")).addClickAction((p, ic2) -> {
ManageGUIAll manageGUIAll = new ManageGUIAll(sender, landGui, plugin.getWgHandler().getRegionsAsOL(target.getUuid()));
manageGUIAll.display();
}));
landGui.display();
} else {
// Chat based system
List<String> formatted = new ArrayList<>();
String segment = lm.getRawString("Commands.ListLands.chat.segment");
lands.forEach(land -> {
OwnedLand ol = plugin.getLand(land);
formatted.add(segment.replace("%landname%", ol.getName()).replace("%members%", ol.printMembers()));
});
String prev = lm.getRawString("Commands.ListLands.chat.previous");
String next = lm.getRawString("Commands.ListLands.chat.next");
MultiPagedMessage message = new MultiPagedMessage("/land list", plugin.getLangManager().getRawString("Commands.ListLands.header").replace("%player%", target.getName()), plugin.getConfig().getInt("CommandSettings.ListLands.landsPerPage"), formatted, prev, next, page);
sender.spigot().sendMessage(message.create());
}
} else {
sender.sendMessage(plugin.getLangManager().getString("Commands.ListLands.noLands"));
}
}
use of biz.princeps.landlord.util.OwnedLand in project LandLord by SpatiumPrinceps.
the class LandAlerter method onMove.
@EventHandler
public void onMove(PlayerMoveEvent e) {
Player p = e.getPlayer();
Location comingFrom = e.getFrom();
Location headingTowards = e.getTo();
OwnedLand landFrom = pl.getWgHandler().getRegion(comingFrom);
OwnedLand landTowards = pl.getWgHandler().getRegion(headingTowards);
if (landTowards == null) {
// System.out.println(playerInLand.get(p.getUniqueId()) + " removed");
playerInLand.remove(p.getUniqueId());
} else if (!landTowards.equals(landFrom)) {
playerInLand.put(p.getUniqueId(), landTowards);
// System.out.println(landTowards.getName() + " added");
}
}
use of biz.princeps.landlord.util.OwnedLand in project LandLord by SpatiumPrinceps.
the class TresholdListener method onBreak.
@EventHandler
public void onBreak(BlockBreakEvent e) {
Player p = e.getPlayer();
OwnedLand land = plugin.getLand(e.getBlock().getLocation());
handleLand(p, e.getBlock().getLocation(), land, e);
}
use of biz.princeps.landlord.util.OwnedLand in project LandLord by SpatiumPrinceps.
the class TresholdListener method onPlace.
@EventHandler
public void onPlace(BlockPlaceEvent e) {
Player p = e.getPlayer();
OwnedLand land = plugin.getLand(e.getBlock().getLocation());
handleLand(p, e.getBlockPlaced().getLocation(), land, e);
}
Aggregations