Skip to content

Commit

Permalink
Merge pull request #6 from RappyLabyAddons/fix/copySkullData
Browse files Browse the repository at this point in the history
Fix copying of non-existent skull data
  • Loading branch information
RappyTV authored Nov 22, 2023
2 parents c848ab1 + bf6f8ed commit 02cfb74
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 24 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
1 change: 1 addition & 0 deletions core/src/main/resources/assets/headowner/i18n/de_de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
1 change: 1 addition & 0 deletions core/src/main/resources/assets/headowner/i18n/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand All @@ -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");
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
}
Expand Down

0 comments on commit 02cfb74

Please sign in to comment.