mirror of
https://github.com/songoda/EpicFarming.git
synced 2024-11-30 14:33:28 +01:00
Fixed issue with auto tilling.
Added a feature where you can set permissions for the amount of farms a player can have.
This commit is contained in:
parent
5f97cc646c
commit
fb3d6742f0
@ -243,7 +243,7 @@ public class EFarm implements Farm {
|
||||
|
||||
public boolean tillLand(Location location) {
|
||||
EpicFarmingPlugin instance = EpicFarmingPlugin.getInstance();
|
||||
if (!instance.getConfig().getBoolean("Main.Disable Auto Til Land")) return true;
|
||||
if (instance.getConfig().getBoolean("Main.Disable Auto Til Land")) return true;
|
||||
Block block = location.getBlock();
|
||||
int radius = level.getRadius();
|
||||
int bx = block.getX();
|
||||
|
@ -25,6 +25,7 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.entity.SheepRegrowWoolEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -77,6 +78,22 @@ public class BlockListeners implements Listener {
|
||||
|
||||
if (e.getBlockAgainst().getType() == farmBlock) e.setCancelled(true);
|
||||
|
||||
int amt = 0;
|
||||
for (Farm farmm : instance.getFarmManager().getFarms().values()) {
|
||||
if (!farmm.getPlacedBy().equals(e.getPlayer().getUniqueId())) continue;
|
||||
amt ++;
|
||||
}
|
||||
int limit = -1;
|
||||
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) {
|
||||
e.setCancelled(true);
|
||||
Bukkit.broadcastMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("event.limit.hit", limit));
|
||||
return;
|
||||
}
|
||||
|
||||
Location location = e.getBlock().getLocation();
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(instance, () -> {
|
||||
|
@ -28,4 +28,5 @@ event.general.nopermission = "&cYou do not have permission to do that."
|
||||
event.upgrade.cannotafford = "&cYou cannot afford this upgrade."
|
||||
event.upgrade.success = "&7You successfully upgraded this farm to &6level %level%&7!"
|
||||
event.upgrade.maxed = "&6This farm is maxed out."
|
||||
event.upgrade.successmaxed = "&7You maxed out this farm at &6%level%x&7."
|
||||
event.upgrade.successmaxed = "&7You maxed out this farm at &6%level%x&7."
|
||||
event.limit.hit = "&7You can only have &6%limit% &7farms at a single time."
|
Loading…
Reference in New Issue
Block a user