Skip to content

Commit 856f9cc

Browse files
committed
Fix potential issue on Paper 1.21.8+
1 parent 940e98f commit 856f9cc

8 files changed

Lines changed: 26 additions & 9 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.syntaxphoenix.spigot</groupId>
77
<artifactId>smoothtimber-legacy</artifactId>
8-
<version>1.27.6</version>
8+
<version>1.27.7</version>
99
<name>SmoothTimber</name>
1010
<packaging>jar</packaging>
1111

src/main/java/com/syntaxphoenix/spigot/smoothtimber/compatibility/coreprotect/CoreProtectChopListener.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.syntaxphoenix.spigot.smoothtimber.compatibility.coreprotect;
22

33
import org.bukkit.Location;
4+
import org.bukkit.block.BlockState;
45
import org.bukkit.event.EventHandler;
56
import org.bukkit.event.Listener;
67

@@ -28,7 +29,11 @@ public void onChopEvent(final AsyncPlayerChoppedTreeEvent event) {
2829

2930
private void handleChopEvent(final AsyncPlayerChoppedTreeEvent event) {
3031
for (final Location location : event.getBlockLocations()) {
31-
compat.logRemoval(event.getPlayer().getName(), location, Locator.getBlockState(location));
32+
BlockState state = Locator.getBlockState(location);
33+
if (state == null) {
34+
continue;
35+
}
36+
compat.logRemoval(event.getPlayer().getName(), location, state);
3237
}
3338
}
3439

src/main/java/com/syntaxphoenix/spigot/smoothtimber/platform/Platform.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
import com.syntaxphoenix.spigot.smoothtimber.SmoothTimber;
66
import com.syntaxphoenix.spigot.smoothtimber.utilities.Container;
7+
import com.syntaxphoenix.spigot.smoothtimber.version.manager.gen.MCVersion;
78
import com.syntaxphoenix.syntaxapi.reflection.ClassCache;
9+
import com.syntaxphoenix.syntaxapi.reflection.Reflect;
810

911
public abstract class Platform {
1012

@@ -26,13 +28,23 @@ public static void shutdown() {
2628
private static Platform createPlatform(final SmoothTimber plugin) {
2729
if (ClassCache.getOptionalClass("io.papermc.paper.threadedregions.RegionizedServer")
2830
.or(() -> ClassCache.getOptionalClass("io.papermc.paper.threadedregions.RegionizedServerInitEvent")).isPresent()) {
29-
return new FoliaPlatform(plugin);
31+
switch (MCVersion.getCoreVersion()) {
32+
case v1_21x:
33+
// On 1.21+ we can't only use the Regionized Server cause Paper for some reason includes that API now.
34+
if (ClassCache.getOptionalClass("io.papermc.paper.plugin.configuration.PluginMeta")
35+
.filter(clz -> new Reflect(clz).searchMethod("isFolia", "isFoliaSupported").containsMethod("isFolia")).isPresent()) {
36+
return new FoliaPlatform(plugin);
37+
}
38+
break;
39+
default:
40+
return new FoliaPlatform(plugin);
41+
}
3042
}
3143
return new SpigotPlatform(plugin);
3244
}
3345

3446
protected abstract void internalShutdown();
35-
47+
3648
public boolean isRegional() {
3749
return false;
3850
}

src/main/java/com/syntaxphoenix/spigot/smoothtimber/version/changer/v1_13xChanger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public ItemStack removeDurabilityFromItem(final ItemStack stack) {
6363
}
6464
}
6565
final ItemMeta meta = stack.getItemMeta();
66-
if (meta.isUnbreakable()) {
66+
if (meta == null || meta.isUnbreakable()) {
6767
return stack;
6868
}
6969
if (meta instanceof Damageable) {

src/main/java/com/syntaxphoenix/spigot/smoothtimber/version/changer/v1_16xChanger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public ItemStack removeDurabilityFromItem(final ItemStack stack) {
6363
}
6464
}
6565
final ItemMeta meta = stack.getItemMeta();
66-
if (meta.isUnbreakable()) {
66+
if (meta == null || meta.isUnbreakable()) {
6767
return stack;
6868
}
6969
if (meta instanceof Damageable) {

src/main/java/com/syntaxphoenix/spigot/smoothtimber/version/changer/v1_19xChanger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public ItemStack removeDurabilityFromItem(final ItemStack stack) {
5757
}
5858
}
5959
final ItemMeta meta = stack.getItemMeta();
60-
if (meta.isUnbreakable()) {
60+
if (meta == null || meta.isUnbreakable()) {
6161
return stack;
6262
}
6363
if (meta instanceof Damageable) {

src/main/java/com/syntaxphoenix/spigot/smoothtimber/version/changer/v1_20xChanger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public ItemStack removeDurabilityFromItem(final ItemStack stack) {
6262
}
6363
}
6464
final ItemMeta meta = stack.getItemMeta();
65-
if (meta.isUnbreakable()) {
65+
if (meta == null || meta.isUnbreakable()) {
6666
return stack;
6767
}
6868
if (meta instanceof Damageable) {

src/main/java/com/syntaxphoenix/spigot/smoothtimber/version/changer/v1_21xChanger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public ItemStack removeDurabilityFromItem(final ItemStack stack) {
5555
}
5656
}
5757
final ItemMeta meta = stack.getItemMeta();
58-
if (meta.isUnbreakable()) {
58+
if (meta == null || meta.isUnbreakable()) {
5959
return stack;
6060
}
6161
if (meta instanceof Damageable) {

0 commit comments

Comments
 (0)