Skip to content
This repository was archived by the owner on Jul 7, 2023. It is now read-only.

Commit 2964092

Browse files
author
SvenjaReißaus
committed
Added pressure plates to permission items, moved version forward
1 parent 6a24b34 commit 2964092

File tree

3 files changed

+13
-20
lines changed

3 files changed

+13
-20
lines changed
-41 Bytes
Binary file not shown.

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.massivecraft</groupId>
66
<artifactId>Factions</artifactId>
7-
<version>1.6.9.5-U0.2.1-RC-1.6-RC</version>
7+
<version>1.6.9.5-U0.2.1-RC-1.6.1-RC</version>
88
<packaging>jar</packaging>
99

1010
<name>SavageFactions</name>

src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java

+12-19
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,9 @@ public static boolean canPlayerUseBlock(Player player, Block block, boolean just
178178
if (SavageFactions.plugin.getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() > otherFaction.getPowerRounded())
179179
return true;
180180

181+
if (otherFaction.getId().equals(myFaction.getId()) && me.getRole() == Role.LEADER) return true;
181182
PermissableAction action = GetPermissionFromUsableBlock(block);
182183
if (action == null) return false;
183-
184-
185184
// We only care about some material types.
186185
/// Who was the idiot?
187186
if (otherFaction.hasPlayersOnline()) {
@@ -734,34 +733,28 @@ public void onClose(InventoryCloseEvent e) {
734733
public void onPlayerInteract(PlayerInteractEvent event) {
735734
// only need to check right-clicks and physical as of MC 1.4+; good performance boost
736735
if (event.getAction().equals(Action.LEFT_CLICK_BLOCK) || event.getAction().equals(Action.LEFT_CLICK_AIR)) return;
737-
if (event.getPlayer().getItemInHand() != null) {
738-
Material handItem = event.getPlayer().getItemInHand().getType();
739-
if (handItem.isEdible()
740-
|| handItem.equals(Material.POTION)
741-
|| handItem.equals(Material.LINGERING_POTION)
742-
|| handItem.equals(Material.SPLASH_POTION)) {
743-
return;
744-
}
745-
}
746-
747736
Block block = event.getClickedBlock();
748737
Player player = event.getPlayer();
749-
750738
// Check if the material is bypassing protection
751739
if (Conf.territoryBypasssProtectedMaterials.contains(block.getType())) return;
752-
753740
if (block == null) return; // clicked in air, apparently
754-
SavageFactions.plugin.log("Checking for material permission");
755741
if (GetPermissionFromUsableBlock(event.getClickedBlock().getType()) != null) {
756-
SavageFactions.plugin.log("Checking for use block permission");
757742
if (!canPlayerUseBlock(player, block, false)) {
758743
event.setCancelled(true);
759744
event.setUseInteractedBlock(Event.Result.DENY);
760745
return;
761746
}
762747
}
748+
if (event.getPlayer().getItemInHand() != null) {
749+
Material handItem = event.getPlayer().getItemInHand().getType();
750+
if (handItem.isEdible()
751+
|| handItem.equals(Material.POTION)
752+
|| handItem.equals(Material.LINGERING_POTION)
753+
|| handItem.equals(Material.SPLASH_POTION)) {
754+
return;
755+
}
756+
}
763757
if (event.getMaterial().isSolid()) return;
764-
SavageFactions.plugin.log("Checking if you can use that item");
765758
if (!playerCanUseItemHere(player, block.getLocation(), event.getMaterial(), false)) {
766759
event.setCancelled(true);
767760
event.setUseInteractedBlock(Event.Result.DENY);
@@ -995,7 +988,6 @@ private static PermissableAction GetPermissionFromUsableBlock(Material material)
995988
case HOPPER:
996989
case BEACON:
997990
case JUKEBOX:
998-
999991
case ANVIL:
1000992
case CHIPPED_ANVIL:
1001993
case DAMAGED_ANVIL:
@@ -1004,6 +996,7 @@ private static PermissableAction GetPermissionFromUsableBlock(Material material)
1004996
// Check for doors that might have diff material name in old version.
1005997
if (material.name().contains("DOOR"))
1006998
return PermissableAction.DOOR;
999+
if (material.name().toUpperCase().contains("BUTTON") || material.name().toUpperCase().contains("PRESSURE")) return PermissableAction.BUTTON;
10071000
return null;
10081001
}
10091002
} else {
@@ -1039,7 +1032,7 @@ private static PermissableAction GetPermissionFromUsableBlock(Material material)
10391032
// Check for doors that might have diff material name in old version.
10401033
if (material.name().contains("DOOR"))
10411034
return PermissableAction.DOOR;
1042-
if (material.toString().toUpperCase().contains("BUTTON"))
1035+
if (material.toString().toUpperCase().contains("BUTTON") || material.toString().toUpperCase().contains("PRESSURE"))
10431036
return PermissableAction.BUTTON;
10441037
return null;
10451038
}

0 commit comments

Comments
 (0)