From d8c647e6f7517bb8f4baf063416b4f68c1f471a0 Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Tue, 11 May 2021 20:19:13 -0400 Subject: [PATCH] Support for Tropical Fish patterns or species, fixes #14. Bump version --- pom.xml | 2 +- .../me/pikamug/localelib/LocaleManager.java | 31 ++++++++++++++----- src/main/resources/plugin.yml | 2 +- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index ddc7ba6..758ac65 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ me.pikamug.localelib LocaleLib - 1.9 + 2.0 UTF-8 diff --git a/src/main/java/me/pikamug/localelib/LocaleManager.java b/src/main/java/me/pikamug/localelib/LocaleManager.java index 6aac884..35ffe32 100644 --- a/src/main/java/me/pikamug/localelib/LocaleManager.java +++ b/src/main/java/me/pikamug/localelib/LocaleManager.java @@ -17,6 +17,7 @@ import org.bukkit.entity.Ocelot; import org.bukkit.entity.Player; import org.bukkit.entity.Rabbit; +import org.bukkit.entity.TropicalFish; import org.bukkit.entity.Villager.Profession; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -156,7 +157,7 @@ public boolean sendMessage(final Player player, final String message, final Map< * @param player The player whom the message is to be sent to * @param message The message to be sent to the player * @param type The entity type to be translated - * @param extra Career, Ocelot, or Rabbit type if applicable + * @param extra Career, Ocelot, Rabbit, or TropicalFish type if applicable */ public boolean sendMessage(final Player player, final String message, final EntityType type, final String extra) { if (player == null || message == null || type == null) { @@ -164,15 +165,11 @@ public boolean sendMessage(final Player player, final String message, final Enti } String key = ""; if (oldVersion) { - if (type.name().equals("VILLAGER")) { - if (extra != null && Profession.valueOf(extra) != null) { + if (type.name().equals("VILLAGER") && extra != null && Profession.valueOf(extra) != null) { key = oldEntities.get(type.name() + "." + Profession.valueOf(extra).name()); - } else { - key = oldEntities.get(type.name()); - } - } else if (type.name().equals("OCELOT") && Ocelot.Type.valueOf(extra) != null) { + } else if (type.name().equals("OCELOT") && extra != null && Ocelot.Type.valueOf(extra) != null) { key = oldEntities.get(type.name() + "." + Ocelot.Type.valueOf(extra).name()); - } else if (type.name().equals("RABBIT") && Rabbit.Type.valueOf(extra) != null + } else if (type.name().equals("RABBIT") && extra != null && Rabbit.Type.valueOf(extra) != null && Rabbit.Type.valueOf(extra).equals(Rabbit.Type.THE_KILLER_BUNNY)) { key = oldEntities.get(type.name() + "." + Rabbit.Type.valueOf(extra).name()); } else { @@ -181,6 +178,24 @@ public boolean sendMessage(final Player player, final String message, final Enti } else { if (type.name().equals("PIG_ZOMBIE")) { key = "entity.minecraft.zombie_pigman"; + } else if (type.name().equals("VILLAGER") && extra != null && Profession.valueOf(extra) != null) { + key = "entity.minecraft.villager." + Profession.valueOf(extra).name(); + } else if (type.name().equals("RABBIT") && extra != null && Rabbit.Type.valueOf(extra) != null + && Rabbit.Type.valueOf(extra).equals(Rabbit.Type.THE_KILLER_BUNNY)) { + key = "entity.minecraft.killer_bunny"; + } else if (type.name().equals("TROPICAL_FISH") && extra != null) { + if (TropicalFish.Pattern.valueOf(extra) != null) { + key = "entity.minecraft.tropical_fish.type." + TropicalFish.Pattern.valueOf(extra); + } else { + try { + int value = Integer.valueOf(extra); + if (value >= 0 && value < 22) { + key = "entity.minecraft.tropical_fish.predefined." + extra; + } + } catch (NumberFormatException nfe) { + // Do nothing + } + } } else { key = "entity.minecraft." + type.toString().toLowerCase(); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index b13f419..a50088d 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: LocaleLib main: me.pikamug.localelib.LocaleLib -version: 1.9 +version: 2.0 api-version: 1.13 description: Show translated names of items, entities & more in client's language website: https://www.spigotmc.org/resources/quests.3711/