Skip to content

Commit

Permalink
Support for Tropical Fish patterns or species, fixes #14. Bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
PikaMug committed May 12, 2021
1 parent 541e6d1 commit d8c647e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>me.pikamug.localelib</groupId>
<artifactId>LocaleLib</artifactId>
<version>1.9</version>
<version>2.0</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
31 changes: 23 additions & 8 deletions src/main/java/me/pikamug/localelib/LocaleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -156,23 +157,19 @@ 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) {
return false;
}
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 {
Expand All @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -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/
Expand Down

0 comments on commit d8c647e

Please sign in to comment.