Reverted Back To Old FactionsBlockListener to Reference Other Plugins Hook Systems
This commit is contained in:
parent
e84c69f2b0
commit
903129e462
@ -48,57 +48,48 @@ public class FactionsBlockListener implements Listener {
|
|||||||
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) {
|
|
||||||
if (Conf.playersWhoBypassAllProtection.contains(player.getName()))
|
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) {
|
||||||
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())
|
if (me.isAdminBypassing()) return true;
|
||||||
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))
|
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location)) return true;
|
||||||
return true;
|
|
||||||
if (location.getWorld() != null) {
|
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)
|
if (!justCheck) me.msg(TL.ACTION_DENIED_WILDERNESS, action);
|
||||||
me.msg(TL.ACTION_DENIED_WILDERNESS, action.toString());
|
|
||||||
return false;
|
return false;
|
||||||
} else if (otherFaction.isSafeZone()) {
|
} else if (otherFaction.isSafeZone()) {
|
||||||
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location))
|
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location)) return true;
|
||||||
return true;
|
if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player)) return true;
|
||||||
if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player))
|
if (!justCheck) me.msg(TL.ACTION_DENIED_SAFEZONE, action);
|
||||||
return true;
|
|
||||||
if (!justCheck)
|
|
||||||
me.msg(TL.ACTION_DENIED_SAFEZONE, action.toString());
|
|
||||||
return false;
|
return false;
|
||||||
} else if (otherFaction.isWarZone()) {
|
} else if (otherFaction.isWarZone()) {
|
||||||
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location))
|
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location)) return true;
|
||||||
return true;
|
if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player)) return true;
|
||||||
if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player))
|
if (!justCheck) me.msg(TL.ACTION_DENIED_WARZONE, action);
|
||||||
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, action, pain, justCheck);
|
return CheckActionState(otherFaction, loc, me, PermissableAction.fromString(action), pain);
|
||||||
} 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, action, pain, justCheck);
|
return CheckActionState(myFaction, loc, me, PermissableAction.fromString(action), pain);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction myFaction, Access access, PermissableAction action, boolean shouldHurt, boolean justCheck) {
|
private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction myFaction, Access access, PermissableAction action, boolean shouldHurt) {
|
||||||
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;
|
||||||
@ -115,32 +106,26 @@ public class FactionsBlockListener implements Listener {
|
|||||||
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 && !justCheck)
|
if (myFaction.getTag(me.getFaction()) != null && action != null)
|
||||||
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)
|
} else if (access == Access.ALLOW) return true;
|
||||||
return true;
|
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
|
||||||
|
|
||||||
if (!justCheck)
|
|
||||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", me.getFaction().getTag()).replace("{action}", action.toString()));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean CheckActionState(Faction target, FLocation location, FPlayer me, PermissableAction action, boolean pain, boolean justCheck) {
|
private static boolean CheckActionState(Faction target, FLocation location, FPlayer me, PermissableAction action, boolean pain) {
|
||||||
if (Conf.ownedAreasEnabled && target.doesLocationHaveOwnersSet(location) && !target.playerHasOwnershipRights(me, location)) {
|
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)
|
if (Conf.ownedAreaDenyBuild && pain) return false;
|
||||||
return false;
|
|
||||||
else if (Conf.ownedAreaDenyBuild) {
|
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, justCheck);
|
return CheckPlayerAccess(me.getPlayer(), me, location, target, target.getAccess(me, action), action, pain);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleSpawnerUpdate(Faction at, Player player, ItemStack spawnerItem, LogTimer.TimerSubType subType) {
|
public void handleSpawnerUpdate(Faction at, Player player, ItemStack spawnerItem, LogTimer.TimerSubType subType) {
|
||||||
@ -155,7 +140,10 @@ public class FactionsBlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(
|
||||||
|
priority = EventPriority.HIGH,
|
||||||
|
ignoreCancelled = true
|
||||||
|
)
|
||||||
public void onPlayerPlace(BlockPlaceEvent event) {
|
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()) {
|
||||||
@ -172,12 +160,10 @@ 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())
|
if (!event.canBuild()) return;
|
||||||
return;
|
if (event.getBlockPlaced().getType() == Material.FIRE) 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(), PermissableAction.BUILD, false)) {
|
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -192,15 +178,13 @@ 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)
|
if (!Conf.handleExploitLiquidFlow) return;
|
||||||
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)
|
if (from == to) return;
|
||||||
return;
|
|
||||||
// from faction != to faction
|
// from faction != to faction
|
||||||
if (to.isSystemFaction()) {
|
if (to.isSystemFaction()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -219,15 +203,14 @@ 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(), PermissableAction.DESTROY, false)) {
|
if (event.getInstaBreak() && !playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "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)
|
if (!Conf.pistonProtectionThroughDenyBuild) return;
|
||||||
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
|
||||||
@ -238,11 +221,15 @@ 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).amount(1).name(FactionsPlugin.instance.getConfig().getString("fvault.Item.Name")).lore(FactionsPlugin.instance.getConfig().getStringList("fvault.Item.Lore")).build();
|
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();
|
||||||
|
|
||||||
if (e.getItemInHand().isSimilar(vault)) {
|
if (e.getItemInHand().isSimilar(vault)) {
|
||||||
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
||||||
@ -287,8 +274,7 @@ public class FactionsBlockListener implements Listener {
|
|||||||
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)
|
if (factionAt.isWilderness() || factionAt.getVault() == null) return;
|
||||||
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;
|
||||||
@ -316,8 +302,7 @@ 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)
|
if (!event.isSticky() || !Conf.pistonProtectionThroughDenyBuild) return;
|
||||||
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));
|
||||||
@ -329,11 +314,9 @@ public class FactionsBlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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())
|
if (targetLoc.getBlock().isEmpty() || targetLoc.getBlock().isLiquid()) return;
|
||||||
return;
|
|
||||||
Faction pistonFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
Faction pistonFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
||||||
if (!canPistonMoveBlock(pistonFaction, targetLoc))
|
if (!canPistonMoveBlock(pistonFaction, targetLoc)) event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -353,15 +336,13 @@ public class FactionsBlockListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBannerPlace(BlockPlaceEvent e) {
|
public void onBannerPlace(BlockPlaceEvent e) {
|
||||||
if (FactionsPlugin.getInstance().mc17)
|
if (FactionsPlugin.getInstance().mc17) return;
|
||||||
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)
|
if (warBanner == null) return;
|
||||||
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")));
|
||||||
@ -375,8 +356,7 @@ 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"))
|
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"))) {
|
||||||
|| (fme.getFaction().getRelationTo(Board.getInstance().getFactionAt(fplacedLoc)) == Relation.ENEMY && FactionsPlugin.getInstance().getConfig().getBoolean("fbanners.Placeable.Enemy"))) {
|
|
||||||
if (bannerCooldownMap.containsKey(fme.getTag())) {
|
if (bannerCooldownMap.containsKey(fme.getTag())) {
|
||||||
fme.msg(TL.WARBANNER_COOLDOWN);
|
fme.msg(TL.WARBANNER_COOLDOWN);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
@ -402,8 +382,7 @@ 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)) {
|
for (Entity e1 : Objects.requireNonNull(banner.getLocation().getWorld()).getNearbyEntities(banner.getLocation(), radius, 255.0, radius)) {
|
||||||
if (e1 instanceof Player) {
|
if (e1 instanceof Player) {
|
||||||
Player player = (Player) e1;
|
Player player = (Player) e1;
|
||||||
@ -422,8 +401,7 @@ public class FactionsBlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 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());
|
||||||
@ -442,22 +420,17 @@ public class FactionsBlockListener implements Listener {
|
|||||||
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)
|
if (!justCheck) fPlayer.setLastFrostwalkerMessage();
|
||||||
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, justCheck))
|
if (!playerCanBuildDestroyBlock(player, location, PermissableAction.FROST_WALK.toString(), justCheck))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -476,15 +449,12 @@ public class FactionsBlockListener implements Listener {
|
|||||||
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)
|
if (pistonFaction == otherFaction) return true;
|
||||||
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())
|
else if (otherFaction.isSafeZone()) return !Conf.safeZoneDenyBuild;
|
||||||
return !Conf.safeZoneDenyBuild;
|
else if (otherFaction.isWarZone()) return !Conf.warZoneDenyBuild;
|
||||||
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());
|
||||||
@ -498,14 +468,13 @@ public class FactionsBlockListener implements Listener {
|
|||||||
|
|
||||||
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(), PermissableAction.DESTROY, false)) {
|
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "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())
|
if (fme == null || !fme.hasFaction()) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (isSpawner) {
|
if (isSpawner) {
|
||||||
Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER);
|
Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER);
|
||||||
@ -534,16 +503,15 @@ public class FactionsBlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void FrameRemove(HangingBreakByEntityEvent event) {
|
public void FrameRemove(HangingBreakByEntityEvent event) {
|
||||||
if (event.getRemover() == null)
|
if (event.getRemover() == null) return;
|
||||||
return;
|
|
||||||
if ((event.getRemover() instanceof Player)) {
|
if ((event.getRemover() instanceof Player)) {
|
||||||
if (event.getEntity().getType().equals(EntityType.ITEM_FRAME)) {
|
if (event.getEntity().getType().equals(EntityType.ITEM_FRAME)) {
|
||||||
Player p = (Player) event.getRemover();
|
Player p = (Player) event.getRemover();
|
||||||
if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), PermissableAction.DESTROY, true)) {
|
if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), "destroy", true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -553,7 +521,7 @@ public class FactionsBlockListener implements Listener {
|
|||||||
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, true)) {
|
if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), PermissableAction.DESTROY.name(), 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");
|
||||||
|
Loading…
Reference in New Issue
Block a user