Few Fixes

This commit is contained in:
Driftay 2019-11-09 15:20:25 -05:00
parent 472cb86465
commit 8bde1385fc
2 changed files with 17 additions and 8 deletions

View File

@ -82,7 +82,7 @@ public class FactionsPlayerListener implements Listener {
faction.isWilderness(); faction.isWilderness();
} }
public static boolean playerCanUseItemHere(Player player, Location location, Material material, boolean justCheck) { public static boolean playerCanUseItemHere(Player player, Location location, Material material, boolean justCheck, PermissableAction permissableAction) {
String name = player.getName(); String name = player.getName();
if (Conf.playersWhoBypassAllProtection.contains(name)) { if (Conf.playersWhoBypassAllProtection.contains(name)) {
return true; return true;
@ -163,8 +163,8 @@ public class FactionsPlayerListener implements Listener {
return false; return false;
} }
Access access = otherFaction.getAccess(me, PermissableAction.ITEM); Access access = otherFaction.getAccess(me, permissableAction);
return CheckPlayerAccess(player, me, loc, otherFaction, access, PermissableAction.ITEM, false); return CheckPlayerAccess(player, me, loc, otherFaction, access, permissableAction, false);
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@ -729,7 +729,7 @@ public class FactionsPlayerListener implements Listener {
(relationTo == Relation.ALLY && me.canflyinAlly()) || (relationTo == Relation.ALLY && me.canflyinAlly()) ||
(relationTo == Relation.TRUCE && me.canflyinTruce()) || (relationTo == Relation.TRUCE && me.canflyinTruce()) ||
(relationTo == Relation.NEUTRAL && me.canflyinNeutral() && !isSystemFaction(factionTo))) { (relationTo == Relation.NEUTRAL && me.canflyinNeutral() && !isSystemFaction(factionTo))) {
enableFly(me); Bukkit.getScheduler().runTask(FactionsPlugin.instance, () -> enableFly(me));
} }
} }
if (me.getAutoClaimFor() != null) { if (me.getAutoClaimFor() != null) {
@ -804,6 +804,15 @@ public class FactionsPlayerListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
// Check if the material is bypassing protection // Check if the material is bypassing protection
if (block == null) return; // clicked in air, apparently if (block == null) return; // clicked in air, apparently
Material type;
if (event.getItem() != null) {
// Convert 1.8 Material Names -> 1.14
type = XMaterial.matchXMaterial(event.getItem().getType().toString()).parseMaterial();
} else {
type = null;
}
if (Conf.territoryBypassProtectedMaterials.contains(block.getType())) return; if (Conf.territoryBypassProtectedMaterials.contains(block.getType())) return;
if (GetPermissionFromUsableBlock(event.getClickedBlock().getType()) != null) { if (GetPermissionFromUsableBlock(event.getClickedBlock().getType()) != null) {
@ -824,7 +833,7 @@ public class FactionsPlayerListener implements Listener {
} }
if (event.getItem() == null) return; if (event.getItem() == null) return;
if (!playerCanUseItemHere(player, block.getLocation(), event.getItem().getType(), false)) { if (type != null && !playerCanUseItemHere(player, block.getLocation(), event.getItem().getType(), false, PermissableAction.ITEM)) {
event.setCancelled(true); event.setCancelled(true);
event.setUseInteractedBlock(Event.Result.DENY); event.setUseInteractedBlock(Event.Result.DENY);
} }
@ -879,7 +888,7 @@ public class FactionsPlayerListener implements Listener {
Block block = event.getBlockClicked(); Block block = event.getBlockClicked();
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false)) { if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false, PermissableAction.BUILD)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -889,7 +898,7 @@ public class FactionsPlayerListener implements Listener {
Block block = event.getBlockClicked(); Block block = event.getBlockClicked();
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false)) { if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false, PermissableAction.DESTROY)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -146,7 +146,7 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
return faction.hasHome() ? String.valueOf(faction.getHome().getBlockY()) : ""; return faction.hasHome() ? String.valueOf(faction.getHome().getBlockY()) : "";
case "faction_home_z": case "faction_home_z":
return faction.hasHome() ? String.valueOf(faction.getHome().getBlockZ()) : ""; return faction.hasHome() ? String.valueOf(faction.getHome().getBlockZ()) : "";
case "facion_land_value": case "faction_land_value":
return Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandValue(faction.getLandRounded())) : TL.ECON_OFF.format("value"); return Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandValue(faction.getLandRounded())) : TL.ECON_OFF.format("value");
case "faction_land_refund": case "faction_land_refund":
return Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandRefund(faction.getLandRounded())) : TL.ECON_OFF.format("refund"); return Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandRefund(faction.getLandRounded())) : TL.ECON_OFF.format("refund");