diff --git a/pom.xml b/pom.xml
index a2177e9..2d0fa75 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,14 +5,14 @@
4.0.0
com.xmooncorp
Magic8Ball
- 1.0.0
+ UNOFFICIAL
- 16
- 16
+ 16
+ 1.20.6
+ ${java.version}
+ ${java.version}
UTF-8
- 1.20.4
- 1.20.4
@@ -48,7 +48,7 @@
- ${project.name} v${project.version}
+ ${project.name} ${project.version}
clean package
${basedir}/src/main/java
@@ -59,6 +59,8 @@
maven-compiler-plugin
3.13.0
+
+ ${java.version}
**/package-info.java
@@ -89,17 +91,10 @@
io.papermc.paper
paper-api
- ${paper.version}-R0.1-SNAPSHOT
+ ${paper-spigot.version}-R0.1-SNAPSHOT
provided
-
-
com.github.Slimefun
Slimefun4
diff --git a/src/main/java/com/xmooncorp/magic8ball/Magic8Ball.java b/src/main/java/com/xmooncorp/magic8ball/Magic8Ball.java
index 58336d4..ba7e839 100644
--- a/src/main/java/com/xmooncorp/magic8ball/Magic8Ball.java
+++ b/src/main/java/com/xmooncorp/magic8ball/Magic8Ball.java
@@ -43,9 +43,8 @@ public void onEnable() {
@Override
public void onDisable() {
- // Logic for disabling the plugin...
- instance = null;
log(localization().getString("console.addon-disabled"));
+ instance = null;
}
@Override
diff --git a/src/main/java/com/xmooncorp/magic8ball/implementation/items/Magic8BallItem.java b/src/main/java/com/xmooncorp/magic8ball/implementation/items/Magic8BallItem.java
index 288c2af..d5ba6a1 100644
--- a/src/main/java/com/xmooncorp/magic8ball/implementation/items/Magic8BallItem.java
+++ b/src/main/java/com/xmooncorp/magic8ball/implementation/items/Magic8BallItem.java
@@ -3,6 +3,7 @@
import com.xmooncorp.magic8ball.Magic8Ball;
import com.xmooncorp.magic8ball.core.ConfigBasedLocalization;
import com.xmooncorp.magic8ball.utils.LocationUtils;
+import com.xmooncorp.magic8ball.utils.compatibility.VersionedParticle;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
@@ -58,17 +59,17 @@ public void sendRandom8BallMessage(@Nonnull Player player, @Nullable Block block
case "affirmative" -> {
color = "§a";
sound = Sound.ENTITY_VILLAGER_YES;
- particle = Particle.TOTEM;
+ particle = VersionedParticle.TOTEM_OF_UNDYING;
}
case "noncommittal" -> {
color = "§7";
sound = Sound.ENTITY_VILLAGER_TRADE;
- particle = Particle.CRIT;
+ particle = VersionedParticle.CRIT;
}
case "negative" -> {
color = "§c";
sound = Sound.ENTITY_VILLAGER_NO;
- particle = Particle.CRIT_MAGIC;
+ particle = VersionedParticle.ENCHANTED_HIT;
}
}
sendActionBarMessage(player, color + randomMessage[1]);
@@ -113,6 +114,7 @@ private void playSoundAtLocation(@Nonnull World world, @Nonnull Location locatio
world.playSound(location, sound, 1, 0.65f);
}
+ @SuppressWarnings("unused")
@EventHandler()
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() != Action.LEFT_CLICK_AIR) return;
diff --git a/src/main/java/com/xmooncorp/magic8ball/utils/compatibility/VersionedParticle.java b/src/main/java/com/xmooncorp/magic8ball/utils/compatibility/VersionedParticle.java
new file mode 100644
index 0000000..8872692
--- /dev/null
+++ b/src/main/java/com/xmooncorp/magic8ball/utils/compatibility/VersionedParticle.java
@@ -0,0 +1,49 @@
+package com.xmooncorp.magic8ball.utils.compatibility;
+
+import io.github.thebusybiscuit.slimefun4.libraries.paperlib.PaperLib;
+import org.bukkit.Particle;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.lang.reflect.Field;
+
+public class VersionedParticle {
+
+ public static final Particle PORTAL;
+ public static final Particle ENCHANTED_HIT;
+ public static final Particle TOTEM_OF_UNDYING;
+ public static final Particle CRIT;
+
+ static {
+
+ int version = PaperLib.getMinecraftVersion();
+ int patchVersion = PaperLib.getMinecraftPatchVersion();
+ boolean IS_MINECRAFT_1_20_5_OR_6 = (version == 20 && (patchVersion == 5 || patchVersion == 6));
+
+ // PORTAL was not renamed in 1.20.5
+ PORTAL = Particle.PORTAL;
+
+ // CRIT was not renamed in 1.20.5
+ CRIT = Particle.CRIT;
+
+ // CRIT_MAGIC is renamed to ENCHANTED_HIT in 1.20.5
+ ENCHANTED_HIT = IS_MINECRAFT_1_20_5_OR_6
+ ? getKey("ENCHANTED_HIT")
+ : getKey("CRIT_MAGIC");
+
+ // TOTEM is renamed to TOTEM_OF_UNDYING in 1.20.5
+ TOTEM_OF_UNDYING = IS_MINECRAFT_1_20_5_OR_6
+ ? getKey("TOTEM_OF_UNDYING")
+ : getKey("TOTEM");
+ }
+
+ @Nullable
+ private static Particle getKey(@Nonnull String key) {
+ try {
+ Field field = Particle.class.getDeclaredField(key);
+ return (Particle) field.get(null);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+}