diff --git a/build.gradle.kts b/build.gradle.kts index bb6477b..25270e0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,7 +17,7 @@ labyMod { author = "RappyTV" description = "Shows the owner or head type of the head you're looking at" minecraftVersion = "1.8<1.20.2" - version = System.getenv().getOrDefault("VERSION", "1.0.2") + version = System.getenv().getOrDefault("VERSION", "1.0.3") } minecraft { diff --git a/core/src/main/java/com/rappytv/headowner/listeners/KeyListener.java b/core/src/main/java/com/rappytv/headowner/listeners/KeyListener.java index 232da5d..fa5c335 100644 --- a/core/src/main/java/com/rappytv/headowner/listeners/KeyListener.java +++ b/core/src/main/java/com/rappytv/headowner/listeners/KeyListener.java @@ -19,7 +19,12 @@ public KeyListener(HeadOwnerAddon addon) { @Subscribe public void onKey(KeyEvent event) { if(event.state() == State.PRESS && event.key() == addon.configuration().copyKey() && !Laby.labyAPI().minecraft().minecraftWindow().isScreenOpened()) { - Laby.labyAPI().minecraft().setClipboard(addon.getSkullApi().getCopy(addon.configuration())); + String skulldata = addon.getSkullApi().getCopy(addon.configuration()); + if(skulldata == null) { + Laby.references().chatExecutor().displayClientMessage(Component.translatable("headowner.messages.nothingToCopy", NamedTextColor.RED)); + return; + } + Laby.labyAPI().minecraft().setClipboard(skulldata); Laby.references().chatExecutor().displayClientMessage(Component.translatable("headowner.messages.copied", NamedTextColor.GREEN)); } } diff --git a/core/src/main/resources/assets/headowner/i18n/de_de.json b/core/src/main/resources/assets/headowner/i18n/de_de.json index bfaf36f..c95787f 100644 --- a/core/src/main/resources/assets/headowner/i18n/de_de.json +++ b/core/src/main/resources/assets/headowner/i18n/de_de.json @@ -29,6 +29,7 @@ "messages": { "copyFormat": "Kopf Typ: %s, Spielername: %s, UUID: %s, Texturenwert: %s", "copied": "Die Skull-Daten wurden in deine Zwischenablage gespeichert!", + "nothingToCopy": "Du schaust keinen gültigen Skull an!", "unknown": "Unbekannt", "unknownHead": "Unbekannter Kopf (wurde per Texturenwert erstellt)", "unknownHeadKey": "Unbekannter Kopf (wurde per Texturenwert erstellt, drücke %s um Daten zu kopieren)" diff --git a/core/src/main/resources/assets/headowner/i18n/en_us.json b/core/src/main/resources/assets/headowner/i18n/en_us.json index 3cd2f53..dd0f1b8 100644 --- a/core/src/main/resources/assets/headowner/i18n/en_us.json +++ b/core/src/main/resources/assets/headowner/i18n/en_us.json @@ -29,6 +29,7 @@ "messages": { "copyFormat": "Skull type: %s, Username: %s, UUID: %s, Texture value: %s", "copied": "The skull data was copied to your clipboard!", + "nothingToCopy": "You're not looking at a valid skull!", "unknown": "Unknown", "unknownHead": "Unknown Head (created by texture value)", "unknownHeadKey": "Unknown Head (created by texture value, press %s to copy skull data)" diff --git a/game-runner/src/v1_12_2/java/com/rappytv/headowner/v1_12_2/SkullApiImpl.java b/game-runner/src/v1_12_2/java/com/rappytv/headowner/v1_12_2/SkullApiImpl.java index ea6d73a..9ade847 100644 --- a/game-runner/src/v1_12_2/java/com/rappytv/headowner/v1_12_2/SkullApiImpl.java +++ b/game-runner/src/v1_12_2/java/com/rappytv/headowner/v1_12_2/SkullApiImpl.java @@ -25,7 +25,9 @@ public String getDisplay(HeadOwnerConfig config) { @Override public String getCopy(HeadOwnerConfig config) { - return new Skull(Skull.getTileLooking(config.distance())).getCopy(); + Skull skull = new Skull(Skull.getTileLooking(config.distance())); + if(skull.getSkullTypeName() == null) return null; + return skull.getCopy(); } public static class Skull { @@ -87,7 +89,6 @@ public String getCopy() { String value = this.value == null ? I18n.translate("headowner.messages.unknown") : this.value; String type = getSkullTypeName(); - return I18n.translate("headowner.messages.copyFormat", type, username, uuid, value); } diff --git a/game-runner/src/v1_16_5/java/com/rappytv/headowner/v1_16_5/SkullApiImpl.java b/game-runner/src/v1_16_5/java/com/rappytv/headowner/v1_16_5/SkullApiImpl.java index 0602eee..07d1f98 100644 --- a/game-runner/src/v1_16_5/java/com/rappytv/headowner/v1_16_5/SkullApiImpl.java +++ b/game-runner/src/v1_16_5/java/com/rappytv/headowner/v1_16_5/SkullApiImpl.java @@ -26,7 +26,9 @@ public String getDisplay(HeadOwnerConfig config) { @Override public String getCopy(HeadOwnerConfig config) { - return new Skull(Skull.getBlockLooking(config.distance())).getCopy(); + Skull skull = new Skull(Skull.getBlockLooking(config.distance())); + if(skull.getSkullTypeName() == null) return null; + return skull.getCopy(); } public static class Skull { @@ -87,7 +89,6 @@ public String getCopy() { String value = this.value == null ? I18n.translate("headowner.messages.unknown") : this.value; String type = getSkullTypeName(); - return I18n.translate("headowner.messages.copyFormat", type, username, uuid, value); } diff --git a/game-runner/src/v1_17_1/java/com/rappytv/headowner/v1_17_1/SkullApiImpl.java b/game-runner/src/v1_17_1/java/com/rappytv/headowner/v1_17_1/SkullApiImpl.java index bb7bf55..af100ae 100644 --- a/game-runner/src/v1_17_1/java/com/rappytv/headowner/v1_17_1/SkullApiImpl.java +++ b/game-runner/src/v1_17_1/java/com/rappytv/headowner/v1_17_1/SkullApiImpl.java @@ -27,7 +27,9 @@ public String getDisplay(HeadOwnerConfig config) { @Override public String getCopy(HeadOwnerConfig config) { - return new Skull(Skull.getBlockLooking(config.distance())).getCopy(); + Skull skull = new Skull(Skull.getBlockLooking(config.distance())); + if(skull.getSkullTypeName() == null) return null; + return skull.getCopy(); } public static class Skull { @@ -88,7 +90,6 @@ public String getCopy() { String value = this.value == null ? I18n.translate("headowner.messages.unknown") : this.value; String type = getSkullTypeName(); - return I18n.translate("headowner.messages.copyFormat", type, username, uuid, value); } diff --git a/game-runner/src/v1_18_2/java/com/rappytv/headowner/v1_18_2/SkullApiImpl.java b/game-runner/src/v1_18_2/java/com/rappytv/headowner/v1_18_2/SkullApiImpl.java index 97f0f9b..7b0c557 100644 --- a/game-runner/src/v1_18_2/java/com/rappytv/headowner/v1_18_2/SkullApiImpl.java +++ b/game-runner/src/v1_18_2/java/com/rappytv/headowner/v1_18_2/SkullApiImpl.java @@ -27,7 +27,9 @@ public String getDisplay(HeadOwnerConfig config) { @Override public String getCopy(HeadOwnerConfig config) { - return new Skull(Skull.getBlockLooking(config.distance())).getCopy(); + Skull skull = new Skull(Skull.getBlockLooking(config.distance())); + if(skull.getSkullTypeName() == null) return null; + return skull.getCopy(); } public static class Skull { @@ -88,7 +90,6 @@ public String getCopy() { String value = this.value == null ? I18n.translate("headowner.messages.unknown") : this.value; String type = getSkullTypeName(); - return I18n.translate("headowner.messages.copyFormat", type, username, uuid, value); } diff --git a/game-runner/src/v1_19_2/java/com/rappytv/headowner/v1_19_2/SkullApiImpl.java b/game-runner/src/v1_19_2/java/com/rappytv/headowner/v1_19_2/SkullApiImpl.java index 692c0ae..7ee6765 100644 --- a/game-runner/src/v1_19_2/java/com/rappytv/headowner/v1_19_2/SkullApiImpl.java +++ b/game-runner/src/v1_19_2/java/com/rappytv/headowner/v1_19_2/SkullApiImpl.java @@ -26,7 +26,9 @@ public String getDisplay(HeadOwnerConfig config) { @Override public String getCopy(HeadOwnerConfig config) { - return new Skull(Skull.getBlockLooking(config.distance())).getCopy(); + Skull skull = new Skull(Skull.getBlockLooking(config.distance())); + if(skull.getSkullTypeName() == null) return null; + return skull.getCopy(); } public static class Skull { @@ -87,7 +89,6 @@ public String getCopy() { String value = this.value == null ? I18n.translate("headowner.messages.unknown") : this.value; String type = getSkullTypeName(); - return I18n.translate("headowner.messages.copyFormat", type, username, uuid, value); } diff --git a/game-runner/src/v1_19_3/java/com/rappytv/headowner/v1_19_3/SkullApiImpl.java b/game-runner/src/v1_19_3/java/com/rappytv/headowner/v1_19_3/SkullApiImpl.java index ecbf510..26b1dad 100644 --- a/game-runner/src/v1_19_3/java/com/rappytv/headowner/v1_19_3/SkullApiImpl.java +++ b/game-runner/src/v1_19_3/java/com/rappytv/headowner/v1_19_3/SkullApiImpl.java @@ -26,7 +26,9 @@ public String getDisplay(HeadOwnerConfig config) { @Override public String getCopy(HeadOwnerConfig config) { - return new Skull(Skull.getBlockLooking(config.distance())).getCopy(); + Skull skull = new Skull(Skull.getBlockLooking(config.distance())); + if(skull.getSkullTypeName() == null) return null; + return skull.getCopy(); } public static class Skull { @@ -87,7 +89,6 @@ public String getCopy() { String value = this.value == null ? I18n.translate("headowner.messages.unknown") : this.value; String type = getSkullTypeName(); - return I18n.translate("headowner.messages.copyFormat", type, username, uuid, value); } diff --git a/game-runner/src/v1_19_4/java/com/rappytv/headowner/v1_19_4/SkullApiImpl.java b/game-runner/src/v1_19_4/java/com/rappytv/headowner/v1_19_4/SkullApiImpl.java index add8119..c3c5547 100644 --- a/game-runner/src/v1_19_4/java/com/rappytv/headowner/v1_19_4/SkullApiImpl.java +++ b/game-runner/src/v1_19_4/java/com/rappytv/headowner/v1_19_4/SkullApiImpl.java @@ -26,7 +26,9 @@ public String getDisplay(HeadOwnerConfig config) { @Override public String getCopy(HeadOwnerConfig config) { - return new Skull(Skull.getBlockLooking(config.distance())).getCopy(); + Skull skull = new Skull(Skull.getBlockLooking(config.distance())); + if(skull.getSkullTypeName() == null) return null; + return skull.getCopy(); } public static class Skull { @@ -87,7 +89,6 @@ public String getCopy() { String value = this.value == null ? I18n.translate("headowner.messages.unknown") : this.value; String type = getSkullTypeName(); - return I18n.translate("headowner.messages.copyFormat", type, username, uuid, value); } @@ -100,7 +101,7 @@ private String getSkullTypeName() { case PLAYER -> I18n.translate("headowner.types.player"); case CREEPER -> I18n.translate("headowner.types.creeper"); case DRAGON -> I18n.translate("headowner.types.dragon"); - default -> null; + case PIGLIN -> I18n.translate("headowner.types.piglin"); }; } } diff --git a/game-runner/src/v1_20_1/java/com/rappytv/headowner/v1_20_1/SkullApiImpl.java b/game-runner/src/v1_20_1/java/com/rappytv/headowner/v1_20_1/SkullApiImpl.java index 0a68092..d1b94c1 100644 --- a/game-runner/src/v1_20_1/java/com/rappytv/headowner/v1_20_1/SkullApiImpl.java +++ b/game-runner/src/v1_20_1/java/com/rappytv/headowner/v1_20_1/SkullApiImpl.java @@ -27,7 +27,9 @@ public String getDisplay(HeadOwnerConfig config) { @Override public String getCopy(HeadOwnerConfig config) { - return new Skull(Skull.getBlockLooking(config.distance())).getCopy(); + Skull skull = new Skull(Skull.getBlockLooking(config.distance())); + if(skull.getSkullTypeName() == null) return null; + return skull.getCopy(); } public static class Skull { @@ -88,7 +90,6 @@ public String getCopy() { String value = this.value == null ? I18n.translate("headowner.messages.unknown") : this.value; String type = getSkullTypeName(); - return I18n.translate("headowner.messages.copyFormat", type, username, uuid, value); } diff --git a/game-runner/src/v1_20_2/java/com/rappytv/headowner/v1_20_2/SkullApiImpl.java b/game-runner/src/v1_20_2/java/com/rappytv/headowner/v1_20_2/SkullApiImpl.java index d223a0f..7407ef2 100644 --- a/game-runner/src/v1_20_2/java/com/rappytv/headowner/v1_20_2/SkullApiImpl.java +++ b/game-runner/src/v1_20_2/java/com/rappytv/headowner/v1_20_2/SkullApiImpl.java @@ -26,7 +26,9 @@ public String getDisplay(HeadOwnerConfig config) { @Override public String getCopy(HeadOwnerConfig config) { - return new Skull(Skull.getBlockLooking(config.distance())).getCopy(); + Skull skull = new Skull(Skull.getBlockLooking(config.distance())); + if(skull.getSkullTypeName() == null) return null; + return skull.getCopy(); } public static class Skull { @@ -87,7 +89,6 @@ public String getCopy() { String value = this.value == null ? I18n.translate("headowner.messages.unknown") : this.value; String type = getSkullTypeName(); - return I18n.translate("headowner.messages.copyFormat", type, username, uuid, value); } diff --git a/game-runner/src/v1_8_9/java/com/rappytv/headowner/v1_8_9/SkullApiImpl.java b/game-runner/src/v1_8_9/java/com/rappytv/headowner/v1_8_9/SkullApiImpl.java index df79500..f8cb73e 100644 --- a/game-runner/src/v1_8_9/java/com/rappytv/headowner/v1_8_9/SkullApiImpl.java +++ b/game-runner/src/v1_8_9/java/com/rappytv/headowner/v1_8_9/SkullApiImpl.java @@ -25,7 +25,9 @@ public String getDisplay(HeadOwnerConfig config) { @Override public String getCopy(HeadOwnerConfig config) { - return new Skull(Skull.getTileLooking(config.distance())).getCopy(); + Skull skull = new Skull(Skull.getTileLooking(config.distance())); + if(skull.getSkullTypeName() == null) return null; + return skull.getCopy(); } public static class Skull { @@ -87,7 +89,6 @@ public String getCopy() { String value = this.value == null ? I18n.translate("headowner.messages.unknown") : this.value; String type = getSkullTypeName(); - return I18n.translate("headowner.messages.copyFormat", type, username, uuid, value); } diff --git a/settings.gradle.kts b/settings.gradle.kts index 5366d9c..1b141c8 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,7 +1,7 @@ rootProject.name = "HeadOwner" pluginManagement { - val labyGradlePluginVersion = "0.3.29" + val labyGradlePluginVersion = "0.3.31" plugins { id("net.labymod.gradle") version (labyGradlePluginVersion) }