@@ -57,6 +57,10 @@ public void disable() {
57
57
HandlerList .unregisterAll (this );
58
58
}
59
59
60
+ private void teleportUpAndCenter (Player player , Location from ) {
61
+ player .teleport (from .clone ().add (0.5 , 1 , 0.5 ));
62
+ }
63
+
60
64
@ EventHandler (priority = EventPriority .HIGHEST , ignoreCancelled = true )
61
65
private void onPlayerMove (PlayerMoveEvent event ) {
62
66
Player player = event .getPlayer ();
@@ -81,7 +85,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
81
85
if (burrowMaterial .isOccluding () && !isSinkInBlock (burrowMaterial )) {
82
86
if (!allowSlabs || !isSlab (burrowMaterial )) {
83
87
player .damage (damageWhenMovingInBurrow );
84
- if (shouldTeleportUp ) player . teleportAsync ( burrowBlock .getLocation (). add ( 0.5 , 1 , 0.5 ));
88
+ if (shouldTeleportUp ) teleportUpAndCenter ( player , burrowBlock .getLocation ());
85
89
}
86
90
return ;
87
91
}
@@ -90,7 +94,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
90
94
if (burrowMaterial .equals (Material .ENDER_CHEST ) || isSinkInBlock (burrowMaterial )) {
91
95
if (playerLocation .getY () - playerLocation .getBlockY () < 0.875 ) {
92
96
player .damage (damageWhenMovingInBurrow );
93
- if (shouldTeleportUp ) player . teleportAsync ( burrowBlock .getLocation (). add ( 0.5 , 1 , 0.5 ));
97
+ if (shouldTeleportUp ) teleportUpAndCenter ( player , burrowBlock .getLocation ());
94
98
}
95
99
return ;
96
100
}
@@ -99,7 +103,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
99
103
if (burrowMaterial .equals (Material .ENCHANTING_TABLE )) {
100
104
if (playerLocation .getY () - playerLocation .getBlockY () < 0.75 ) {
101
105
player .damage (damageWhenMovingInBurrow );
102
- if (shouldTeleportUp ) player . teleportAsync ( burrowBlock .getLocation (). add ( 0.5 , 1 , 0.5 ));
106
+ if (shouldTeleportUp ) teleportUpAndCenter ( player , burrowBlock .getLocation ());
103
107
}
104
108
return ;
105
109
}
@@ -110,36 +114,36 @@ private void onPlayerMove(PlayerMoveEvent event) {
110
114
if (breakAnvilInsteadOfTP ) {
111
115
burrowBlock .breakNaturally ();
112
116
} else {
113
- if (shouldTeleportUp ) player . teleportAsync ( burrowBlock .getLocation (). add ( 0.5 , 1 , 0.5 ));
117
+ if (shouldTeleportUp ) teleportUpAndCenter ( player , burrowBlock .getLocation ());
114
118
}
115
119
return ;
116
120
}
117
121
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 )) {
120
124
player .damage (damageWhenMovingInBurrow );
121
- if (shouldTeleportUp ) player . teleportAsync ( burrowBlock .getLocation (). add ( 0.5 , 1 , 0.5 ));
125
+ if (shouldTeleportUp ) teleportUpAndCenter ( player , burrowBlock .getLocation ());
122
126
}
123
127
}
124
128
}
125
129
126
- private static boolean isSinkInBlock (Material burrowBlockMaterial ) {
130
+ private boolean isSinkInBlock (final Material burrowBlockMaterial ) {
127
131
if (burrowBlockMaterial == null ) return false ;
128
132
return switch (burrowBlockMaterial ) {
129
133
case SOUL_SAND , MUD , FARMLAND -> true ;
130
134
default -> false ;
131
135
};
132
136
}
133
137
134
- private static boolean isAnvil (Material burrowBlockMaterial ) {
138
+ private boolean isAnvil (final Material burrowBlockMaterial ) {
135
139
if (burrowBlockMaterial == null ) return false ;
136
140
return switch (burrowBlockMaterial ) {
137
141
case ANVIL , CHIPPED_ANVIL , DAMAGED_ANVIL -> true ;
138
142
default -> false ;
139
143
};
140
144
}
141
145
142
- private static boolean isSlab (Material burrowBlockMaterial ) {
146
+ private boolean isSlab (final Material burrowBlockMaterial ) {
143
147
if (burrowBlockMaterial == null ) return false ;
144
148
return switch (burrowBlockMaterial ) {
145
149
case
@@ -161,4 +165,4 @@ private static boolean isSlab(Material burrowBlockMaterial) {
161
165
default -> false ;
162
166
};
163
167
}
164
- }
168
+ }
0 commit comments