Skip to content

Commit 50ac971

Browse files
committed
further improve burrow
1 parent c861f8a commit 50ac971

File tree

2 files changed

+26
-18
lines changed
  • AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/combat
  • AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/modules/combat

2 files changed

+26
-18
lines changed

AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/combat/Burrow.java

+15-11
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ public void disable() {
5757
HandlerList.unregisterAll(this);
5858
}
5959

60+
private void teleportUpAndCenter(Player player, Location from) {
61+
player.teleport(from.clone().add(0.5, 1, 0.5));
62+
}
63+
6064
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
6165
private void onPlayerMove(PlayerMoveEvent event) {
6266
Player player = event.getPlayer();
@@ -81,7 +85,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
8185
if (burrowMaterial.isOccluding() && !isSinkInBlock(burrowMaterial)) {
8286
if (!allowSlabs || !isSlab(burrowMaterial)) {
8387
player.damage(damageWhenMovingInBurrow);
84-
if (shouldTeleportUp) player.teleportAsync(burrowBlock.getLocation().add(0.5, 1, 0.5));
88+
if (shouldTeleportUp) teleportUpAndCenter(player, burrowBlock.getLocation());
8589
}
8690
return;
8791
}
@@ -90,7 +94,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
9094
if (burrowMaterial.equals(Material.ENDER_CHEST) || isSinkInBlock(burrowMaterial)) {
9195
if (playerLocation.getY() - playerLocation.getBlockY() < 0.875) {
9296
player.damage(damageWhenMovingInBurrow);
93-
if (shouldTeleportUp) player.teleportAsync(burrowBlock.getLocation().add(0.5, 1, 0.5));
97+
if (shouldTeleportUp) teleportUpAndCenter(player, burrowBlock.getLocation());
9498
}
9599
return;
96100
}
@@ -99,7 +103,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
99103
if (burrowMaterial.equals(Material.ENCHANTING_TABLE)) {
100104
if (playerLocation.getY() - playerLocation.getBlockY() < 0.75) {
101105
player.damage(damageWhenMovingInBurrow);
102-
if (shouldTeleportUp) player.teleportAsync(burrowBlock.getLocation().add(0.5, 1, 0.5));
106+
if (shouldTeleportUp) teleportUpAndCenter(player, burrowBlock.getLocation());
103107
}
104108
return;
105109
}
@@ -110,36 +114,36 @@ private void onPlayerMove(PlayerMoveEvent event) {
110114
if (breakAnvilInsteadOfTP) {
111115
burrowBlock.breakNaturally();
112116
} else {
113-
if (shouldTeleportUp) player.teleportAsync(burrowBlock.getLocation().add(0.5, 1, 0.5));
117+
if (shouldTeleportUp) teleportUpAndCenter(player, burrowBlock.getLocation());
114118
}
115119
return;
116120
}
117121

118-
// Bedrock & Beacon
119-
if (burrowMaterial.equals(Material.BEDROCK) || burrowMaterial.equals(Material.BEACON)) {
122+
// Beacon and Indestructibles
123+
if (burrowMaterial.equals(Material.BEACON) || ItemUtils.isIndestructible(burrowMaterial)) {
120124
player.damage(damageWhenMovingInBurrow);
121-
if (shouldTeleportUp) player.teleportAsync(burrowBlock.getLocation().add(0.5, 1, 0.5));
125+
if (shouldTeleportUp) teleportUpAndCenter(player, burrowBlock.getLocation());
122126
}
123127
}
124128
}
125129

126-
private static boolean isSinkInBlock(Material burrowBlockMaterial) {
130+
private boolean isSinkInBlock(final Material burrowBlockMaterial) {
127131
if (burrowBlockMaterial == null) return false;
128132
return switch (burrowBlockMaterial) {
129133
case SOUL_SAND, MUD, FARMLAND -> true;
130134
default -> false;
131135
};
132136
}
133137

134-
private static boolean isAnvil(Material burrowBlockMaterial) {
138+
private boolean isAnvil(final Material burrowBlockMaterial) {
135139
if (burrowBlockMaterial == null) return false;
136140
return switch (burrowBlockMaterial) {
137141
case ANVIL, CHIPPED_ANVIL, DAMAGED_ANVIL -> true;
138142
default -> false;
139143
};
140144
}
141145

142-
private static boolean isSlab(Material burrowBlockMaterial) {
146+
private boolean isSlab(final Material burrowBlockMaterial) {
143147
if (burrowBlockMaterial == null) return false;
144148
return switch (burrowBlockMaterial) {
145149
case
@@ -161,4 +165,4 @@ private static boolean isSlab(Material burrowBlockMaterial) {
161165
default -> false;
162166
};
163167
}
164-
}
168+
}

AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/modules/combat/Burrow.java

+11-7
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ public boolean shouldEnable() {
9494
return AnarchyExploitFixes.getConfiguration().getBoolean("combat.prevent-burrow.enable", false);
9595
}
9696

97+
private void teleportUpAndCenter(Player player, Location from) {
98+
player.teleport(from.clone().add(0.5, 1, 0.5));
99+
}
100+
97101
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
98102
private void onPlayerMove(PlayerMoveEvent event) {
99103
Player player = event.getPlayer();
@@ -118,7 +122,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
118122
if (burrowMaterial.isOccluding() && !SINK_IN_BLOCKS.contains(burrowMaterial)) {
119123
if (!allowSlabs || !SLAB_LIKE.contains(burrowMaterial)) {
120124
player.damage(damageWhenMovingInBurrow);
121-
if (shouldTeleportUp) player.teleport(burrowBlock.getLocation().add(0.5, 1, 0.5));
125+
if (shouldTeleportUp) teleportUpAndCenter(player, burrowBlock.getLocation());
122126
}
123127
return;
124128
}
@@ -127,7 +131,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
127131
if (burrowMaterial.equals(ENDER_CHEST) || SINK_IN_BLOCKS.contains(burrowMaterial)) {
128132
if (playerLocation.getY() - playerLocation.getBlockY() < 0.875) {
129133
player.damage(damageWhenMovingInBurrow);
130-
if (shouldTeleportUp) player.teleport(burrowBlock.getLocation().add(0.5, 1, 0.5));
134+
if (shouldTeleportUp) teleportUpAndCenter(player, burrowBlock.getLocation());
131135
}
132136
return;
133137
}
@@ -136,7 +140,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
136140
if (burrowMaterial.equals(ENCHANTING_TABLE)) {
137141
if (playerLocation.getY() - playerLocation.getBlockY() < 0.75) {
138142
player.damage(damageWhenMovingInBurrow);
139-
if (shouldTeleportUp) player.teleport(burrowBlock.getLocation().add(0.5, 1, 0.5));
143+
if (shouldTeleportUp) teleportUpAndCenter(player, burrowBlock.getLocation());
140144
}
141145
return;
142146
}
@@ -147,15 +151,15 @@ private void onPlayerMove(PlayerMoveEvent event) {
147151
if (breakAnvilInsteadOfTP) {
148152
burrowBlock.breakNaturally();
149153
} else {
150-
if (shouldTeleportUp) player.teleport(burrowBlock.getLocation().add(0.5, 1, 0.5));
154+
if (shouldTeleportUp) teleportUpAndCenter(player, burrowBlock.getLocation());
151155
}
152156
return;
153157
}
154158

155-
// Bedrock & Beacons
156-
if (burrowMaterial.equals(BEDROCK) || burrowMaterial.equals(BEACON)) {
159+
// Beacons and Indestructibles
160+
if (burrowMaterial.equals(BEACON) || ItemUtils.isIndestructible(burrowMaterial)) {
157161
player.damage(damageWhenMovingInBurrow);
158-
if (shouldTeleportUp) player.teleport(burrowBlock.getLocation().add(0.5, 1, 0.5));
162+
if (shouldTeleportUp) teleportUpAndCenter(player, burrowBlock.getLocation());
159163
}
160164
}
161165
}

0 commit comments

Comments
 (0)