This commit is contained in:
Juniormunk 2020-05-21 04:22:53 -04:00
parent ec1501bf4f
commit ddd3150732
3 changed files with 573 additions and 439 deletions

View File

@ -42,115 +42,155 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
public class FactionsBlockListener implements Listener { public class FactionsBlockListener implements Listener
{
public static HashMap<String, Location> bannerLocations = new HashMap<>(); public static HashMap<String, Location> bannerLocations = new HashMap<>();
private HashMap<String, Boolean> bannerCooldownMap = new HashMap<>(); private HashMap<String, Boolean> bannerCooldownMap = new HashMap<>();
private long placeTimer = TimeUnit.SECONDS.toMillis(15L); private long placeTimer = TimeUnit.SECONDS.toMillis(15L);
public static boolean playerCanBuildDestroyBlock(Player player, Location location, PermissableAction action, boolean justCheck)
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) { {
if (Conf.playersWhoBypassAllProtection.contains(player.getName())) return true; if (Conf.playersWhoBypassAllProtection.contains(player.getName()))
return true;
FPlayer me = FPlayers.getInstance().getById(player.getUniqueId().toString()); FPlayer me = FPlayers.getInstance().getById(player.getUniqueId().toString());
if (me.isAdminBypassing()) return true; if (me.isAdminBypassing())
return true;
FLocation loc = new FLocation(location); FLocation loc = new FLocation(location);
Faction otherFaction = Board.getInstance().getFactionAt(loc); Faction otherFaction = Board.getInstance().getFactionAt(loc);
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();
if (otherFaction.isWilderness()) { if (otherFaction.isWilderness())
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location)) return true; {
if (location.getWorld() != null) { if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location))
return true;
if (location.getWorld() != null)
{
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
return true; return true;
} }
if (!justCheck) me.msg(TL.ACTION_DENIED_WILDERNESS, action); if (!justCheck)
me.msg(TL.ACTION_DENIED_WILDERNESS, action.toString());
return false; return false;
} else if (otherFaction.isSafeZone()) { }
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location)) return true; else if (otherFaction.isSafeZone())
if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player)) return true; {
if (!justCheck) me.msg(TL.ACTION_DENIED_SAFEZONE, action); if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location))
return true;
if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player))
return true;
if (!justCheck)
me.msg(TL.ACTION_DENIED_SAFEZONE, action.toString());
return false; return false;
} else if (otherFaction.isWarZone()) { }
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location)) return true; else if (otherFaction.isWarZone())
if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player)) return true; {
if (!justCheck) me.msg(TL.ACTION_DENIED_WARZONE, action); if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location))
return true;
if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player))
return true;
if (!justCheck)
me.msg(TL.ACTION_DENIED_WARZONE, action.toString());
return false; return false;
} else if (!otherFaction.getId().equals(myFaction.getId())) { // If the faction target is not my own }
else if (!otherFaction.getId().equals(myFaction.getId()))
{ // If the faction target is not my own
if (FactionsPlugin.getInstance().getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() > otherFaction.getPowerRounded()) if (FactionsPlugin.getInstance().getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() > otherFaction.getPowerRounded())
return true; return true;
boolean pain = !justCheck && otherFaction.getAccess(me, PermissableAction.PAIN_BUILD) == Access.ALLOW; boolean pain = !justCheck && otherFaction.getAccess(me, PermissableAction.PAIN_BUILD) == Access.ALLOW;
return CheckActionState(otherFaction, loc, me, PermissableAction.fromString(action), pain); return CheckActionState(otherFaction, loc, me, action, pain, justCheck);
} else if (otherFaction.getId().equals(myFaction.getId())) { }
else if (otherFaction.getId().equals(myFaction.getId()))
{
boolean pain = !justCheck && myFaction.getAccess(me, PermissableAction.PAIN_BUILD) == Access.ALLOW; boolean pain = !justCheck && myFaction.getAccess(me, PermissableAction.PAIN_BUILD) == Access.ALLOW;
return CheckActionState(myFaction, loc, me, PermissableAction.fromString(action), pain); return CheckActionState(myFaction, loc, me, action, pain, justCheck);
} }
return false; return false;
} }
private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction myFaction, Access access, PermissableAction action, boolean shouldHurt) { private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction myFaction, Access access, PermissableAction action, boolean shouldHurt, boolean justCheck)
{
boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty()); boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty());
if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId()))) if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId())))
return true; return true;
else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) { else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName()))
{
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc))); me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
if (shouldHurt) { if (shouldHurt)
{
player.damage(Conf.actionDeniedPainAmount); player.damage(Conf.actionDeniedPainAmount);
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction))); me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
} }
return false; return false;
} else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway }
if (shouldHurt) { else if (!landOwned && access == Access.DENY)
{ // If land is not owned but access is set to DENY anyway
if (shouldHurt)
{
player.damage(Conf.actionDeniedPainAmount); player.damage(Conf.actionDeniedPainAmount);
if ((Board.getInstance().getFactionAt(loc).getTag(myFaction)) != null) if ((Board.getInstance().getFactionAt(loc).getTag(myFaction)) != null)
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction))); me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
} }
if (myFaction.getTag(me.getFaction()) != null && action != null) if (myFaction.getTag(me.getFaction()) != null && action != null && !justCheck)
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
return false;
} else if (access == Access.ALLOW) return true;
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString())); me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
return false; return false;
} }
else if (access == Access.ALLOW)
return true;
private static boolean CheckActionState(Faction target, FLocation location, FPlayer me, PermissableAction action, boolean pain) { if (!justCheck)
if (Conf.ownedAreasEnabled && target.doesLocationHaveOwnersSet(location) && !target.playerHasOwnershipRights(me, location)) { me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", me.getFaction().getTag()).replace("{action}", action.toString()));
return false;
}
private static boolean CheckActionState(Faction target, FLocation location, FPlayer me, PermissableAction action, boolean pain, boolean justCheck)
{
if (Conf.ownedAreasEnabled && target.doesLocationHaveOwnersSet(location) && !target.playerHasOwnershipRights(me, location))
{
// If pain should be applied // If pain should be applied
if (pain && Conf.ownedAreaPainBuild) if (pain && Conf.ownedAreaPainBuild)
me.msg(TL.ACTIONS_OWNEDTERRITORYPAINDENY.toString().replace("{action}", action.toString()).replace("{faction}", target.getOwnerListString(location))); me.msg(TL.ACTIONS_OWNEDTERRITORYPAINDENY.toString().replace("{action}", action.toString()).replace("{faction}", target.getOwnerListString(location)));
if (Conf.ownedAreaDenyBuild && pain) return false; if (Conf.ownedAreaDenyBuild && pain)
else if (Conf.ownedAreaDenyBuild) { return false;
else if (Conf.ownedAreaDenyBuild)
{
if(!justCheck)
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", target.getTag(me.getFaction())).replace("{action}", action.toString())); me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", target.getTag(me.getFaction())).replace("{action}", action.toString()));
return false; return false;
} }
} }
return CheckPlayerAccess(me.getPlayer(), me, location, target, target.getAccess(me, action), action, pain); return CheckPlayerAccess(me.getPlayer(), me, location, target, target.getAccess(me, action), action, pain, justCheck);
} }
public void handleSpawnerUpdate(Faction at, Player player, ItemStack spawnerItem, LogTimer.TimerSubType subType) { public void handleSpawnerUpdate(Faction at, Player player, ItemStack spawnerItem, LogTimer.TimerSubType subType)
{
FLogManager manager = FactionsPlugin.instance.getFlogManager(); FLogManager manager = FactionsPlugin.instance.getFlogManager();
LogTimer logTimer = manager.getLogTimers().computeIfAbsent(player.getUniqueId(), e -> new LogTimer(player.getName(), at.getId())); LogTimer logTimer = manager.getLogTimers().computeIfAbsent(player.getUniqueId(), e -> new LogTimer(player.getName(), at.getId()));
LogTimer.Timer timer = logTimer.attemptLog(LogTimer.TimerType.SPAWNER_EDIT, subType, 0L); LogTimer.Timer timer = logTimer.attemptLog(LogTimer.TimerType.SPAWNER_EDIT, subType, 0L);
Map<MaterialData, AtomicInteger> currentCounts = (timer.getExtraData() == null) ? new HashMap<>() : ((Map) timer.getExtraData()); Map<MaterialData, AtomicInteger> currentCounts = (timer.getExtraData() == null) ? new HashMap<>() : ((Map) timer.getExtraData());
currentCounts.computeIfAbsent(spawnerItem.getData(), e -> new AtomicInteger(0)).addAndGet(1); currentCounts.computeIfAbsent(spawnerItem.getData(), e -> new AtomicInteger(0)).addAndGet(1);
timer.setExtraData(currentCounts); timer.setExtraData(currentCounts);
if (timer.isReadyToLog(this.placeTimer)) { if (timer.isReadyToLog(this.placeTimer))
{
logTimer.pushLogs(at, LogTimer.TimerType.SPAWNER_EDIT); logTimer.pushLogs(at, LogTimer.TimerType.SPAWNER_EDIT);
} }
} }
@EventHandler( @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
priority = EventPriority.HIGH, public void onPlayerPlace(BlockPlaceEvent event)
ignoreCancelled = true {
)
public void onPlayerPlace(BlockPlaceEvent event) {
ItemStack item = event.getItemInHand(); ItemStack item = event.getItemInHand();
if (item != null && item.getType() == XMaterial.SPAWNER.parseMaterial()) { if (item != null && item.getType() == XMaterial.SPAWNER.parseMaterial())
{
Faction at = Board.getInstance().getFactionAt(new FLocation(event.getBlockPlaced())); Faction at = Board.getInstance().getFactionAt(new FLocation(event.getBlockPlaced()));
if (at != null && at.isNormal()) { if (at != null && at.isNormal())
{
FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer()); FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer());
if (fplayer != null && at.getRelationTo(fplayer.getFaction()).isAtLeast(Relation.TRUCE)) { if (fplayer != null && at.getRelationTo(fplayer.getFaction()).isAtLeast(Relation.TRUCE))
{
this.handleSpawnerUpdate(at, event.getPlayer(), item, LogTimer.TimerSubType.SPAWNER_PLACE); this.handleSpawnerUpdate(at, event.getPlayer(), item, LogTimer.TimerSubType.SPAWNER_PLACE);
} }
} }
@ -158,18 +198,24 @@ public class FactionsBlockListener implements Listener {
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockPlace(BlockPlaceEvent event)
{
if (!event.canBuild()) return; if (!event.canBuild())
if (event.getBlockPlaced().getType() == Material.FIRE) return; return;
if (event.getBlockPlaced().getType() == Material.FIRE)
return;
boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial()); boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial());
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) { if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), PermissableAction.BUILD, false))
{
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
if (isSpawner) { if (isSpawner)
if (Conf.spawnerLock) { {
if (Conf.spawnerLock)
{
event.setCancelled(true); event.setCancelled(true);
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString())); event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
} }
@ -177,22 +223,30 @@ public class FactionsBlockListener implements Listener {
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockFromTo(BlockFromToEvent event) { public void onBlockFromTo(BlockFromToEvent event)
if (!Conf.handleExploitLiquidFlow) return; {
if (!Conf.handleExploitLiquidFlow)
return;
if (event.getBlock().isLiquid()) { if (event.getBlock().isLiquid())
if (event.getToBlock().isEmpty()) { {
if (event.getToBlock().isEmpty())
{
Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock())); Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock())); Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock()));
if (from == to) return; if (from == to)
return;
// from faction != to faction // from faction != to faction
if(to.isSystemFaction()) { if (to.isSystemFaction())
{
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
if (to.isNormal()) { if (to.isNormal())
if (from.isNormal() && from.getRelationTo(to).isAlly()) { {
if (from.isNormal() && from.getRelationTo(to).isAlly())
{
return; return;
} }
event.setCancelled(true); event.setCancelled(true);
@ -202,15 +256,19 @@ public class FactionsBlockListener implements Listener {
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockDamage(BlockDamageEvent event) { public void onBlockDamage(BlockDamageEvent event)
if (event.getInstaBreak() && !playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) { {
if (event.getInstaBreak() && !playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), PermissableAction.DESTROY, false))
{
event.setCancelled(true); event.setCancelled(true);
} }
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockPistonExtend(BlockPistonExtendEvent event) { public void onBlockPistonExtend(BlockPistonExtendEvent event)
if (!Conf.pistonProtectionThroughDenyBuild) return; {
if (!Conf.pistonProtectionThroughDenyBuild)
return;
Faction pistonFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock())); Faction pistonFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
// target end-of-the-line empty (air) block which is being pushed into, including if piston itself would extend into air // target end-of-the-line empty (air) block which is being pushed into, including if piston itself would extend into air
@ -221,40 +279,46 @@ public class FactionsBlockListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler @EventHandler
public void onVaultPlace(BlockPlaceEvent e) { public void onVaultPlace(BlockPlaceEvent e)
if (e.getItemInHand().getType() == Material.CHEST) { {
if (e.getItemInHand().getType() == Material.CHEST)
{
ItemStack vault = new ItemBuilder(Material.CHEST) ItemStack vault = new ItemBuilder(Material.CHEST).amount(1).name(FactionsPlugin.instance.getConfig().getString("fvault.Item.Name")).lore(FactionsPlugin.instance.getConfig().getStringList("fvault.Item.Lore")).build();
.amount(1).name(FactionsPlugin.instance.getConfig().getString("fvault.Item.Name"))
.lore(FactionsPlugin.instance.getConfig().getStringList("fvault.Item.Lore"))
.build();
if (e.getItemInHand().isSimilar(vault)) { if (e.getItemInHand().isSimilar(vault))
{
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer()); FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
if (fme.getFaction().getVault() != null) { if (fme.getFaction().getVault() != null)
{
fme.msg(TL.COMMAND_GETVAULT_ALREADYSET); fme.msg(TL.COMMAND_GETVAULT_ALREADYSET);
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
FLocation flocation = new FLocation(e.getBlockPlaced().getLocation()); FLocation flocation = new FLocation(e.getBlockPlaced().getLocation());
if (Board.getInstance().getFactionAt(flocation) != fme.getFaction()) { if (Board.getInstance().getFactionAt(flocation) != fme.getFaction())
{
fme.msg(TL.COMMAND_GETVAULT_INVALIDLOCATION); fme.msg(TL.COMMAND_GETVAULT_INVALIDLOCATION);
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
Block start = e.getBlockPlaced(); Block start = e.getBlockPlaced();
int radius = 1; int radius = 1;
for (double x = start.getLocation().getX() - radius; x <= start.getLocation().getX() + radius; x++) { for (double x = start.getLocation().getX() - radius; x <= start.getLocation().getX() + radius; x++)
for (double y = start.getLocation().getY() - radius; y <= start.getLocation().getY() + radius; y++) { {
for (double z = start.getLocation().getZ() - radius; z <= start.getLocation().getZ() + radius; z++) { for (double y = start.getLocation().getY() - radius; y <= start.getLocation().getY() + radius; y++)
{
for (double z = start.getLocation().getZ() - radius; z <= start.getLocation().getZ() + radius; z++)
{
Location blockLoc = new Location(e.getPlayer().getWorld(), x, y, z); Location blockLoc = new Location(e.getPlayer().getWorld(), x, y, z);
if (blockLoc.getX() == start.getLocation().getX() && blockLoc.getY() == start.getLocation().getY() && blockLoc.getZ() == start.getLocation().getZ()) { if (blockLoc.getX() == start.getLocation().getX() && blockLoc.getY() == start.getLocation().getY() && blockLoc.getZ() == start.getLocation().getZ())
{
continue; continue;
} }
Material blockMaterial = blockLoc.getBlock().getType(); Material blockMaterial = blockLoc.getBlock().getType();
if (blockMaterial == Material.CHEST || (FactionsPlugin.instance.getConfig().getBoolean("fvault.No-Hoppers-near-vault") && blockMaterial == Material.HOPPER)) { if (blockMaterial == Material.CHEST || (FactionsPlugin.instance.getConfig().getBoolean("fvault.No-Hoppers-near-vault") && blockMaterial == Material.HOPPER))
{
e.setCancelled(true); e.setCancelled(true);
fme.msg(TL.COMMAND_GETVAULT_CHESTNEAR); fme.msg(TL.COMMAND_GETVAULT_CHESTNEAR);
return; return;
@ -270,24 +334,32 @@ public class FactionsBlockListener implements Listener {
} }
@EventHandler @EventHandler
public void onHopperPlace(BlockPlaceEvent e) { public void onHopperPlace(BlockPlaceEvent e)
{
if (e.getItemInHand().getType() != Material.HOPPER && !FactionsPlugin.instance.getConfig().getBoolean("fvault.No-Hoppers-near-vault")) if (e.getItemInHand().getType() != Material.HOPPER && !FactionsPlugin.instance.getConfig().getBoolean("fvault.No-Hoppers-near-vault"))
return; return;
Faction factionAt = Board.getInstance().getFactionAt(new FLocation(e.getBlockPlaced().getLocation())); Faction factionAt = Board.getInstance().getFactionAt(new FLocation(e.getBlockPlaced().getLocation()));
if (factionAt.isWilderness() || factionAt.getVault() == null) return; if (factionAt.isWilderness() || factionAt.getVault() == null)
return;
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer()); FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
Block start = e.getBlockPlaced(); Block start = e.getBlockPlaced();
int radius = 1; int radius = 1;
for (double x = start.getLocation().getX() - radius; x <= start.getLocation().getX() + radius; x++) { for (double x = start.getLocation().getX() - radius; x <= start.getLocation().getX() + radius; x++)
for (double y = start.getLocation().getY() - radius; y <= start.getLocation().getY() + radius; y++) { {
for (double z = start.getLocation().getZ() - radius; z <= start.getLocation().getZ() + radius; z++) { for (double y = start.getLocation().getY() - radius; y <= start.getLocation().getY() + radius; y++)
{
for (double z = start.getLocation().getZ() - radius; z <= start.getLocation().getZ() + radius; z++)
{
Location blockLoc = new Location(e.getPlayer().getWorld(), x, y, z); Location blockLoc = new Location(e.getPlayer().getWorld(), x, y, z);
if (blockLoc.getX() == start.getLocation().getX() && blockLoc.getY() == start.getLocation().getY() && blockLoc.getZ() == start.getLocation().getZ()) { if (blockLoc.getX() == start.getLocation().getX() && blockLoc.getY() == start.getLocation().getY() && blockLoc.getZ() == start.getLocation().getZ())
{
continue; continue;
} }
if (blockLoc.getBlock().getType() == XMaterial.CHEST.parseMaterial()) { if (blockLoc.getBlock().getType() == XMaterial.CHEST.parseMaterial())
if (factionAt.getVault().equals(blockLoc)) { {
if (factionAt.getVault().equals(blockLoc))
{
e.setCancelled(true); e.setCancelled(true);
fme.msg(TL.COMMAND_VAULT_NO_HOPPER); fme.msg(TL.COMMAND_VAULT_NO_HOPPER);
return; return;
@ -300,34 +372,43 @@ public class FactionsBlockListener implements Listener {
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) { public void onBlockPistonRetract(BlockPistonRetractEvent event)
{
// if not a sticky piston, retraction should be fine // if not a sticky piston, retraction should be fine
if (!event.isSticky() || !Conf.pistonProtectionThroughDenyBuild) return; if (!event.isSticky() || !Conf.pistonProtectionThroughDenyBuild)
return;
Location targetLoc = event.getRetractLocation(); Location targetLoc = event.getRetractLocation();
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(targetLoc)); Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(targetLoc));
// Check if the piston is moving in a faction's territory. This disables pistons entirely in faction territory. // Check if the piston is moving in a faction's territory. This disables pistons entirely in faction territory.
if (otherFaction.isNormal() && FactionsPlugin.instance.getConfig().getBoolean("disable-pistons-in-territory", false)) { if (otherFaction.isNormal() && FactionsPlugin.instance.getConfig().getBoolean("disable-pistons-in-territory", false))
{
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
// if potentially retracted block is just air/water/lava, no worries // if potentially retracted block is just air/water/lava, no worries
if (targetLoc.getBlock().isEmpty() || targetLoc.getBlock().isLiquid()) return; if (targetLoc.getBlock().isEmpty() || targetLoc.getBlock().isLiquid())
return;
Faction pistonFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock())); Faction pistonFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
if (!canPistonMoveBlock(pistonFaction, targetLoc)) event.setCancelled(true); if (!canPistonMoveBlock(pistonFaction, targetLoc))
event.setCancelled(true);
} }
@EventHandler @EventHandler
public void onBannerBreak(BlockBreakEvent e) { public void onBannerBreak(BlockBreakEvent e)
{
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer()); FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
if (FactionsPlugin.getInstance().mc17) { if (FactionsPlugin.getInstance().mc17)
{
return; return;
} }
if (bannerLocations.containsValue(e.getBlock().getLocation())) { if (bannerLocations.containsValue(e.getBlock().getLocation()))
if (e.getBlock().getType().name().contains("BANNER")) { {
if (e.getBlock().getType().name().contains("BANNER"))
{
e.setCancelled(true); e.setCancelled(true);
fme.msg(TL.BANNER_CANNOT_BREAK); fme.msg(TL.BANNER_CANNOT_BREAK);
} }
@ -335,20 +416,26 @@ public class FactionsBlockListener implements Listener {
} }
@EventHandler @EventHandler
public void onBannerPlace(BlockPlaceEvent e) { public void onBannerPlace(BlockPlaceEvent e)
if (FactionsPlugin.getInstance().mc17) return; {
if (FactionsPlugin.getInstance().mc17)
return;
if (e.getItemInHand().getType().name().contains("BANNER")) { if (e.getItemInHand().getType().name().contains("BANNER"))
{
ItemStack bannerInHand = e.getItemInHand(); ItemStack bannerInHand = e.getItemInHand();
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer()); FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
ItemStack warBanner = fme.getFaction().getBanner(); ItemStack warBanner = fme.getFaction().getBanner();
if (warBanner == null) return; if (warBanner == null)
return;
ItemMeta warmeta = warBanner.getItemMeta(); ItemMeta warmeta = warBanner.getItemMeta();
warmeta.setDisplayName(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fbanners.Item.Name"))); warmeta.setDisplayName(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fbanners.Item.Name")));
warmeta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Item.Lore"))); warmeta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Item.Lore")));
warBanner.setItemMeta(warmeta); warBanner.setItemMeta(warmeta);
if (warBanner.isSimilar(bannerInHand)) { if (warBanner.isSimilar(bannerInHand))
if (fme.getFaction().isWilderness()) { {
if (fme.getFaction().isWilderness())
{
fme.msg(TL.WARBANNER_NOFACTION); fme.msg(TL.WARBANNER_NOFACTION);
e.setCancelled(true); e.setCancelled(true);
return; return;
@ -356,13 +443,17 @@ public class FactionsBlockListener implements Listener {
int bannerTime = FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Time") * 20; int bannerTime = FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Time") * 20;
Location placedLoc = e.getBlockPlaced().getLocation(); Location placedLoc = e.getBlockPlaced().getLocation();
FLocation fplacedLoc = new FLocation(placedLoc); FLocation fplacedLoc = new FLocation(placedLoc);
if ((Board.getInstance().getFactionAt(fplacedLoc).isWarZone() && FactionsPlugin.getInstance().getConfig().getBoolean("fbanners.Placeable.Warzone")) || (fme.getFaction().getRelationTo(Board.getInstance().getFactionAt(fplacedLoc)) == Relation.ENEMY && FactionsPlugin.getInstance().getConfig().getBoolean("fbanners.Placeable.Enemy"))) { if ((Board.getInstance().getFactionAt(fplacedLoc).isWarZone() && FactionsPlugin.getInstance().getConfig().getBoolean("fbanners.Placeable.Warzone"))
if (bannerCooldownMap.containsKey(fme.getTag())) { || (fme.getFaction().getRelationTo(Board.getInstance().getFactionAt(fplacedLoc)) == Relation.ENEMY && FactionsPlugin.getInstance().getConfig().getBoolean("fbanners.Placeable.Enemy")))
{
if (bannerCooldownMap.containsKey(fme.getTag()))
{
fme.msg(TL.WARBANNER_COOLDOWN); fme.msg(TL.WARBANNER_COOLDOWN);
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
for (FPlayer fplayer : fme.getFaction().getFPlayers()) { for (FPlayer fplayer : fme.getFaction().getFPlayers())
{
fplayer.getPlayer().sendTitle(FactionsPlugin.getInstance().color(fme.getTag() + " Placed A WarBanner!"), FactionsPlugin.getInstance().color("&7use &c/f tpbanner&7 to tp to the banner!")); fplayer.getPlayer().sendTitle(FactionsPlugin.getInstance().color(fme.getTag() + " Placed A WarBanner!"), FactionsPlugin.getInstance().color("&7use &c/f tpbanner&7 to tp to the banner!"));
} }
bannerCooldownMap.put(fme.getTag(), true); bannerCooldownMap.put(fme.getTag(), true);
@ -382,33 +473,42 @@ public class FactionsBlockListener implements Listener {
banner.getWorld().strikeLightningEffect(banner.getLocation()); banner.getWorld().strikeLightningEffect(banner.getLocation());
int radius = FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Effect-Radius"); int radius = FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Effect-Radius");
List<String> effects = FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Effects"); List<String> effects = FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Effects");
int affectorTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> { int affectorTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () ->
for (Entity e1 : Objects.requireNonNull(banner.getLocation().getWorld()).getNearbyEntities(banner.getLocation(), radius, 255.0, radius)) { {
if (e1 instanceof Player) { for (Entity e1 : Objects.requireNonNull(banner.getLocation().getWorld()).getNearbyEntities(banner.getLocation(), radius, 255.0, radius))
{
if (e1 instanceof Player)
{
Player player = (Player) e1; Player player = (Player) e1;
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
if (fplayer.getFaction() != bannerFaction) { if (fplayer.getFaction() != bannerFaction)
{
continue; continue;
} }
for (String effect : effects) { for (String effect : effects)
{
String[] components = effect.split(":"); String[] components = effect.split(":");
player.addPotionEffect(new PotionEffect(Objects.requireNonNull(PotionEffectType.getByName(components[0])), 100, Integer.parseInt(components[1]))); player.addPotionEffect(new PotionEffect(Objects.requireNonNull(PotionEffectType.getByName(components[0])), 100, Integer.parseInt(components[1])));
} }
if (banner.getType() == bannerType) { if (banner.getType() == bannerType)
{
continue; continue;
} }
banner.setType(bannerType); banner.setType(bannerType);
} }
} }
}, 0L, 20L); }, 0L, 20L);
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.getInstance(), () -> { Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.getInstance(), () ->
{
banner.setType(Material.AIR); banner.setType(Material.AIR);
as.remove(); as.remove();
banner.getWorld().strikeLightningEffect(banner.getLocation()); banner.getWorld().strikeLightningEffect(banner.getLocation());
Bukkit.getScheduler().cancelTask(affectorTask); Bukkit.getScheduler().cancelTask(affectorTask);
FactionsBlockListener.bannerLocations.remove(bannerFaction.getTag()); FactionsBlockListener.bannerLocations.remove(bannerFaction.getTag());
}, Long.parseLong(bannerTime + "")); }, Long.parseLong(bannerTime + ""));
} else { }
else
{
fme.msg(TL.WARBANNER_INVALIDLOC); fme.msg(TL.WARBANNER_INVALIDLOC);
e.setCancelled(true); e.setCancelled(true);
} }
@ -417,78 +517,102 @@ public class FactionsBlockListener implements Listener {
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onFrostWalker(EntityBlockFormEvent event) { public void onFrostWalker(EntityBlockFormEvent event)
{
if (event.getEntity() == null || event.getEntity().getType() != EntityType.PLAYER || event.getBlock() == null) if (event.getEntity() == null || event.getEntity().getType() != EntityType.PLAYER || event.getBlock() == null)
return; return;
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
Location location = event.getBlock().getLocation(); Location location = event.getBlock().getLocation();
if (!event.getBlock().getType().equals(Material.WATER))
{
// If we are not replacing water then this is clearly not a frostwalker event.
return;
}
// only notify every 10 seconds // only notify every 10 seconds
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
boolean justCheck = fPlayer.getLastFrostwalkerMessage() + 10000 > System.currentTimeMillis(); boolean justCheck = fPlayer.getLastFrostwalkerMessage() + 10000 > System.currentTimeMillis();
if (!justCheck) fPlayer.setLastFrostwalkerMessage(); if (!justCheck)
fPlayer.setLastFrostwalkerMessage();
// Check if they have build permissions here. If not, block this from happening. // Check if they have build permissions here. If not, block this from happening.
if (!playerCanBuildDestroyBlock(player, location, PermissableAction.FROST_WALK.toString(), justCheck)) event.setCancelled(true); if (!playerCanBuildDestroyBlock(player, location, PermissableAction.FROST_WALK, justCheck))
event.setCancelled(true);
} }
@EventHandler @EventHandler
public void onFallingBlock(EntityChangeBlockEvent event) { public void onFallingBlock(EntityChangeBlockEvent event)
{
if (!FactionsPlugin.getInstance().getConfig().getBoolean("Falling-Block-Fix.Enabled")) if (!FactionsPlugin.getInstance().getConfig().getBoolean("Falling-Block-Fix.Enabled"))
return; return;
Faction faction = Board.getInstance().getFactionAt(new FLocation(event.getBlock())); Faction faction = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
if (faction.isWarZone() || faction.isSafeZone()) { if (faction.isWarZone() || faction.isSafeZone())
{
event.getBlock().setType(Material.AIR); event.getBlock().setType(Material.AIR);
event.setCancelled(true); event.setCancelled(true);
} }
} }
private boolean canPistonMoveBlock(Faction pistonFaction, Location target) { private boolean canPistonMoveBlock(Faction pistonFaction, Location target)
{
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(target)); Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(target));
if (pistonFaction == otherFaction) return true; if (pistonFaction == otherFaction)
return true;
if (otherFaction.isWilderness()) if (otherFaction.isWilderness())
return !Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName()); return !Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName());
else if (otherFaction.isSafeZone()) return !Conf.safeZoneDenyBuild; else if (otherFaction.isSafeZone())
else if (otherFaction.isWarZone()) return !Conf.warZoneDenyBuild; return !Conf.safeZoneDenyBuild;
else if (otherFaction.isWarZone())
return !Conf.warZoneDenyBuild;
Relation rel = pistonFaction.getRelationTo(otherFaction); Relation rel = pistonFaction.getRelationTo(otherFaction);
return !rel.confDenyBuild(otherFaction.hasPlayersOnline()); return !rel.confDenyBuild(otherFaction.hasPlayersOnline());
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event)
//If there is an error its much safer to not allow the block to be broken {
try { // If there is an error its much safer to not allow the block to be broken
try
{
Block block = event.getBlock(); Block block = event.getBlock();
Faction at = Board.getInstance().getFactionAt(new FLocation(block)); Faction at = Board.getInstance().getFactionAt(new FLocation(block));
boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial()); boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial());
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) { if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), PermissableAction.DESTROY, false))
{
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
FPlayer fme = FPlayers.getInstance().getByPlayer(event.getPlayer()); FPlayer fme = FPlayers.getInstance().getByPlayer(event.getPlayer());
if (fme == null || !fme.hasFaction()) return; if (fme == null || !fme.hasFaction())
return;
if (isSpawner) { if (isSpawner)
{
Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER); Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { if (access != Access.ALLOW && fme.getRole() != Role.LEADER)
{
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "mine spawners"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "mine spawners");
} }
} }
if (isSpawner && !fme.isAdminBypassing()) { if (isSpawner && !fme.isAdminBypassing())
{
ItemStack item = new ItemStack(block.getType(), 1, block.getData()); ItemStack item = new ItemStack(block.getType(), 1, block.getData());
if (at != null && at.isNormal()) { if (at != null && at.isNormal())
{
FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer()); FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer());
if (fplayer != null) { if (fplayer != null)
{
BlockState state = block.getState(); BlockState state = block.getState();
if (state instanceof CreatureSpawner) { if (state instanceof CreatureSpawner)
{
CreatureSpawner spawner = (CreatureSpawner) state; CreatureSpawner spawner = (CreatureSpawner) state;
item.setDurability(spawner.getSpawnedType().getTypeId()); item.setDurability(spawner.getSpawnedType().getTypeId());
} }
@ -496,20 +620,26 @@ public class FactionsBlockListener implements Listener {
} }
} }
} }
} catch (Exception e) { }
catch (Exception e)
{
event.setCancelled(true); event.setCancelled(true);
e.printStackTrace(); e.printStackTrace();
} }
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void FrameRemove(HangingBreakByEntityEvent event) { public void FrameRemove(HangingBreakByEntityEvent event)
if (event.getRemover() == null) return; {
if ((event.getRemover() instanceof Player)) { if (event.getRemover() == null)
if (event.getEntity().getType().equals(EntityType.ITEM_FRAME)) { return;
if ((event.getRemover() instanceof Player))
{
if (event.getEntity().getType().equals(EntityType.ITEM_FRAME))
{
Player p = (Player) event.getRemover(); Player p = (Player) event.getRemover();
if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), "destroy", true)) { if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), PermissableAction.DESTROY, true))
{
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -518,10 +648,13 @@ public class FactionsBlockListener implements Listener {
} }
@EventHandler @EventHandler
public void onFarmLandDamage(EntityChangeBlockEvent event) { public void onFarmLandDamage(EntityChangeBlockEvent event)
if (event.getEntity() instanceof Player) { {
if (event.getEntity() instanceof Player)
{
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), PermissableAction.DESTROY.name(), true)) { if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), PermissableAction.DESTROY, true))
{
FPlayer me = FPlayers.getInstance().getByPlayer(player); FPlayer me = FPlayers.getInstance().getByPlayer(player);
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock().getLocation())); Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock().getLocation()));
me.msg(TL.ACTION_DENIED_OTHER, otherFaction.getTag(), "trample crops"); me.msg(TL.ACTION_DENIED_OTHER, otherFaction.getTag(), "trample crops");

View File

@ -5,6 +5,7 @@ import com.massivecraft.factions.event.PowerLossEvent;
import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.util.MiscUtil; import com.massivecraft.factions.util.MiscUtil;
import com.massivecraft.factions.util.timer.type.GraceTimer; import com.massivecraft.factions.util.timer.type.GraceTimer;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -138,7 +139,7 @@ public class FactionsEntityListener implements Listener {
// Run the check for a player // Run the check for a player
if (damager instanceof Player) { if (damager instanceof Player) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock((Player) damager, damagee.getLocation(), "destroy", false)) if (!FactionsBlockListener.playerCanBuildDestroyBlock((Player) damager, damagee.getLocation(), PermissableAction.DESTROY, false))
event.setCancelled(true); event.setCancelled(true);
} else { } else {
@ -508,7 +509,7 @@ public class FactionsEntityListener implements Listener {
Player p = (Player) e.getRemover(); Player p = (Player) e.getRemover();
if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) { if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) { if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), PermissableAction.DESTROY, false)) {
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -519,7 +520,7 @@ public class FactionsEntityListener implements Listener {
if (e.getPlayer() == null) return; if (e.getPlayer() == null) return;
if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) { if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(e.getPlayer(), e.getBlock().getLocation(), "build", false)) { if (!FactionsBlockListener.playerCanBuildDestroyBlock(e.getPlayer(), e.getBlock().getLocation(), PermissableAction.BUILD, false)) {
e.setCancelled(true); e.setCancelled(true);
e.getPlayer().updateInventory(); e.getPlayer().updateInventory();
} }
@ -626,7 +627,7 @@ public class FactionsEntityListener implements Listener {
if (event.getRightClicked() == null) return; if (event.getRightClicked() == null) return;
if (!event.getRightClicked().getType().equals(EntityType.ITEM_FRAME)) return; if (!event.getRightClicked().getType().equals(EntityType.ITEM_FRAME)) return;
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getRightClicked().getLocation(), "build", false)) { if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getRightClicked().getLocation(), PermissableAction.BUILD, false)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -864,7 +864,7 @@ public class FactionsPlayerListener implements Listener {
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == XMaterial.GRASS_BLOCK.parseMaterial() if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == XMaterial.GRASS_BLOCK.parseMaterial()
&& event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()) { && event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true)) { if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD, true)) {
FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString()); FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString());
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();