Skip to content

Commit

Permalink
some more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mindgamesnl committed Feb 1, 2025
1 parent f096ea6 commit e050438
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
java adoptopenjdk-8.0.332+9
java openjdk-21
2 changes: 1 addition & 1 deletion dev-resources/spawn-test-spigot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion plugin/src/main/bash/data.bin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BUILD_NUM="1523"
BUILD_NUM="1531"
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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>(OfflinePlayer.class)
.addReturnValue("getUniqueId", speakerUUID)
.addReturnValue("getName", speakerSkin)
.createProxy();

static {
String rawUrl = SETTINGS_SPEAKER_SKIN_TEXTURE.getString();
Expand Down Expand Up @@ -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;
Expand All @@ -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")
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ public void setPauseRuns(int pauseRuns) {

public void stop() {
running = false;
this.thread.stop();
}

}
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main/resources/data.bin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BUILD_NUM="1523"
BUILD_NUM="1531"
4 changes: 2 additions & 2 deletions plugin/src/main/resources/openaudiomc-build.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
BUILD_VERSION="1523"
BUILD_COMMIT="50da9f7890c067f107178548078bfdf0d3a3aaf3"
BUILD_VERSION="1531"
BUILD_COMMIT="f096ea69ea9b8334f56c8eae16b41d0efba888a4"
BUILD_AUTHOR="Mats"

0 comments on commit e050438

Please sign in to comment.