mirror of
https://github.com/songoda/EpicFarming.git
synced 2025-01-07 08:47:45 +01:00
fixed farm limit perm
This commit is contained in:
parent
4d28df97b0
commit
53ae6760ef
@ -65,6 +65,15 @@ public class BlockListeners implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int maxFarms(Player player) {
|
||||||
|
int limit = -1;
|
||||||
|
for (PermissionAttachmentInfo permissionAttachmentInfo : player.getEffectivePermissions()) {
|
||||||
|
if (!permissionAttachmentInfo.getPermission().toLowerCase().startsWith("epicfarming.limit")) continue;
|
||||||
|
limit = Integer.parseInt(permissionAttachmentInfo.getPermission().split("\\.")[2]);
|
||||||
|
}
|
||||||
|
return limit;
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBlockPlace(BlockPlaceEvent e) {
|
public void onBlockPlace(BlockPlaceEvent e) {
|
||||||
try {
|
try {
|
||||||
@ -84,11 +93,8 @@ public class BlockListeners implements Listener {
|
|||||||
if (!farmm.getPlacedBy().equals(e.getPlayer().getUniqueId())) continue;
|
if (!farmm.getPlacedBy().equals(e.getPlayer().getUniqueId())) continue;
|
||||||
amt ++;
|
amt ++;
|
||||||
}
|
}
|
||||||
int limit = -1;
|
int limit = maxFarms(e.getPlayer());
|
||||||
for (PermissionAttachmentInfo permissionAttachmentInfo : e.getPlayer().getEffectivePermissions()) {
|
|
||||||
if (!permissionAttachmentInfo.getPermission().toLowerCase().startsWith("epicfarming.limit")) continue;
|
|
||||||
limit = Integer.parseInt(permissionAttachmentInfo.getPermission().split("\\.")[2]);
|
|
||||||
}
|
|
||||||
if (limit != -1 && amt >= limit) {
|
if (limit != -1 && amt >= limit) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
e.getPlayer().sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("event.limit.hit", limit));
|
e.getPlayer().sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("event.limit.hit", limit));
|
||||||
|
Loading…
Reference in New Issue
Block a user