From e0504389dcfb8a69136f2e4ffecb34139a0d4ad0 Mon Sep 17 00:00:00 2001 From: Mats Date: Sat, 1 Feb 2025 22:05:03 +0100 Subject: [PATCH] some more fixes --- .tool-versions | 2 +- dev-resources/spawn-test-spigot.sh | 2 +- plugin/src/main/bash/data.bin | 2 +- .../modules/speakers/utils/SpeakerUtils.java | 40 ++++++++++--------- .../spigot/services/threading/Executor.java | 1 - plugin/src/main/resources/data.bin | 2 +- .../resources/openaudiomc-build.properties | 4 +- 7 files changed, 27 insertions(+), 26 deletions(-) diff --git a/.tool-versions b/.tool-versions index b1e51edda..bb5e99345 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1 @@ -java adoptopenjdk-8.0.332+9 +java openjdk-21 diff --git a/dev-resources/spawn-test-spigot.sh b/dev-resources/spawn-test-spigot.sh index 30f923997..16c692c7f 100755 --- a/dev-resources/spawn-test-spigot.sh +++ b/dev-resources/spawn-test-spigot.sh @@ -28,4 +28,4 @@ echo "Starting server.." rm world/session.lock rm world_the_end/session.lock rm world_nether/session.lock -java -Xms3G -Xmx3G -DIReallyKnowWhatIAmDoingISwear -jar spigot-1.21.4.jar nogui +java -Xms3G -Xmx3G -DIReallyKnowWhatIAmDoingISwear -jar paper-1.20.4-499.jar nogui diff --git a/plugin/src/main/bash/data.bin b/plugin/src/main/bash/data.bin index d225e0c40..003083741 100755 --- a/plugin/src/main/bash/data.bin +++ b/plugin/src/main/bash/data.bin @@ -1 +1 @@ -BUILD_NUM="1523" +BUILD_NUM="1531" diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/speakers/utils/SpeakerUtils.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/speakers/utils/SpeakerUtils.java index ea487a6b5..f768ce104 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/speakers/utils/SpeakerUtils.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/speakers/utils/SpeakerUtils.java @@ -12,6 +12,7 @@ import de.tr7zw.changeme.nbtapi.iface.ReadWriteNBT; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.OfflinePlayer; import org.bukkit.block.Block; import org.bukkit.block.Skull; import org.bukkit.inventory.ItemStack; @@ -28,6 +29,10 @@ public class SpeakerUtils { public static final String speakerSkin = SETTINGS_SPEAKER_SKIN_NAME.getString(); public static final UUID speakerUUID = UUID.fromString(SETTINGS_SPEAKER_SKIN_UUID.getString()); public static final String textureValue; + private static OfflinePlayer FAKE_SKULL_OWNER = new ClassMocker(OfflinePlayer.class) + .addReturnValue("getUniqueId", speakerUUID) + .addReturnValue("getName", speakerSkin) + .createProxy(); static { String rawUrl = SETTINGS_SPEAKER_SKIN_TEXTURE.getString(); @@ -56,7 +61,6 @@ public static boolean isSpeakerSkull(Block block) { } return valid; } - return skull.getOwningPlayer().getUniqueId().equals(speakerUUID); } else { if (skull.getOwner() == null) return false; @@ -70,13 +74,25 @@ public static ItemStack getSkull(String source, int radius) { ItemStack skull = new ItemStack(SPEAKER_SERVICE.getPlayerSkullItem()); skull.setDurability((short) 3); + SkullMeta sm = (SkullMeta) skull.getItemMeta(); + if (sm != null) { + sm.setDisplayName(ChatColor.AQUA + "OpenAudioMc Speaker"); + sm.setOwningPlayer(FAKE_SKULL_OWNER); + sm.setLore(Arrays.asList( + ChatColor.AQUA + "I'm a super cool speaker!", + ChatColor.AQUA + "Simply place me in your world", + ChatColor.AQUA + "and I'll play your customized music", + "", + ChatColor.AQUA + "SRC: " + ChatColor.GREEN + source, + ChatColor.AQUA + "Radius: " + ChatColor.GREEN + radius + )); + skull.setItemMeta(sm); + } + // For Minecraft 1.20.4 and below NBT.modify(skull, nbt -> { ReadWriteNBT skullOwnerCompound = nbt.getOrCreateCompound("SkullOwner"); - - // The owner UUID. Note that skulls with the same UUID but different textures will misbehave and only one texture will load. - // They will share the texture. To avoid this limitation, it is recommended to use a random UUID. - skullOwnerCompound.setUUID("Id", UUID.randomUUID()); + skullOwnerCompound.setUUID("Id", speakerUUID); skullOwnerCompound.getOrCreateCompound("Properties") .getCompoundList("textures") @@ -100,20 +116,6 @@ public static ItemStack getSkull(String source, int radius) { } } - SkullMeta sm = (SkullMeta) skull.getItemMeta(); - if (sm != null) { - sm.setDisplayName(ChatColor.AQUA + "OpenAudioMc Speaker"); - sm.setLore(Arrays.asList( - ChatColor.AQUA + "I'm a super cool speaker!", - ChatColor.AQUA + "Simply place me in your world", - ChatColor.AQUA + "and I'll play your customized music", - "", - ChatColor.AQUA + "SRC: " + ChatColor.GREEN + source, - ChatColor.AQUA + "Radius: " + ChatColor.GREEN + radius - )); - skull.setItemMeta(sm); - } - NBTItem nbti = new NBTItem(skull); nbti.setString("oa-src", source); nbti.setInteger("oa-radius", radius); diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/services/threading/Executor.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/services/threading/Executor.java index 037272f60..493b62701 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/services/threading/Executor.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/services/threading/Executor.java @@ -91,7 +91,6 @@ public void setPauseRuns(int pauseRuns) { public void stop() { running = false; - this.thread.stop(); } } diff --git a/plugin/src/main/resources/data.bin b/plugin/src/main/resources/data.bin index d225e0c40..003083741 100755 --- a/plugin/src/main/resources/data.bin +++ b/plugin/src/main/resources/data.bin @@ -1 +1 @@ -BUILD_NUM="1523" +BUILD_NUM="1531" diff --git a/plugin/src/main/resources/openaudiomc-build.properties b/plugin/src/main/resources/openaudiomc-build.properties index 367093703..109fb05ad 100644 --- a/plugin/src/main/resources/openaudiomc-build.properties +++ b/plugin/src/main/resources/openaudiomc-build.properties @@ -1,3 +1,3 @@ -BUILD_VERSION="1523" -BUILD_COMMIT="50da9f7890c067f107178548078bfdf0d3a3aaf3" +BUILD_VERSION="1531" +BUILD_COMMIT="f096ea69ea9b8334f56c8eae16b41d0efba888a4" BUILD_AUTHOR="Mats"