Skip to content

Commit

Permalink
1.1.1: Disallow persona skins and fix languages
Browse files Browse the repository at this point in the history
Merge pull request #7 from KCodeYT/develop
  • Loading branch information
KCodeYT authored May 28, 2022
2 parents 7a1a180 + dcfe783 commit d4e1be6
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>de.kcodeyt</groupId>
<artifactId>Heads</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>

<repositories>
<repository>
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/de/kcodeyt/heads/Heads.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ public void onLoad() {
return;
}

try(final InputStreamReader inputReader = new InputStreamReader(this.getResource("lang"));
final BufferedReader bufferedReader = new BufferedReader(inputReader)) {
try(final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(this.getResource("lang/lang_list.txt")))) {
String line;
while((line = bufferedReader.readLine()) != null)
this.saveResource("lang/" + line);
this.saveResource("lang/" + line + ".txt");
} catch(Exception e) {
this.getLogger().error("Could not find the language resources of this plugin!", e);
return;
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/de/kcodeyt/heads/lang/TranslationKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
public enum TranslationKey {

CONSOLE_USES_PLAYER_COMMAND,
HEAD_COMMAND_USAGE, INVALID_NAME, PLAYER_NOT_FOUND, HEAD_GIVEN;
HEAD_COMMAND_USAGE,
INVALID_NAME,
PLAYER_NOT_FOUND,
HEAD_GIVEN;

@Getter
private final String key;
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/de/kcodeyt/heads/util/LocalSkinAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,14 @@ public static void loadNameLookup() {
}
}

private static boolean isLegacySkin(Skin skin) {
final int skinDataLength = skin.getSkinData().data.length;
return skinDataLength != 32 * 64 * 4 && skinDataLength != 64 * 64 * 4 && skinDataLength != 128 * 64 * 4 && skinDataLength != 128 * 128 * 4;
}

public static void addOrUpdatePlayer(String name, Skin skin) {
if(skin.isPersona() || !isLegacySkin(skin)) return;

NAME_TO_LATEST.put(name, skin.getSkinId());

final SkinData skinData = SkinData.builder().
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/lang/lang_list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
en_US
de_DE
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Heads
version: "1.1.0"
version: "1.1.1"
api: [ "1.0.0" ]
main: de.kcodeyt.heads.Heads

0 comments on commit d4e1be6

Please sign in to comment.