Improve translation of enchantments and tameable mob types. Bump version

This commit is contained in:
PikaMug 2020-01-07 02:18:02 -05:00
parent fd6024a601
commit 024e455698
12 changed files with 68 additions and 79 deletions

2
dist/pom.xml vendored
View File

@ -5,7 +5,7 @@
<parent>
<groupId>me.blackvein.quests</groupId>
<artifactId>quests-parent</artifactId>
<version>3.8.3</version>
<version>3.8.4</version>
</parent>
<artifactId>quests-dist</artifactId>
<packaging>pom</packaging>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>me.blackvein.quests</groupId>
<artifactId>quests-parent</artifactId>
<version>3.8.3</version>
<version>3.8.4</version>
</parent>
<artifactId>quests-main</artifactId>

View File

@ -20,6 +20,7 @@ import me.blackvein.quests.Quests;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.MiscUtil;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -387,15 +388,16 @@ public class ItemsPrompt extends FixedSetPrompt {
private class EnchantTypesPrompt extends StringPrompt {
@SuppressWarnings("deprecation")
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.LIGHT_PURPLE + "- " + ChatColor.DARK_PURPLE + Lang.get("stageEditorEnchantments")
+ ChatColor.LIGHT_PURPLE + " -\n";
for (int i = 0; i < Enchantment.values().length; i++) {
if (i == Enchantment.values().length - 1) {
text += ChatColor.GREEN + ItemUtil.getPrettyEnchantmentName(Enchantment.values()[i]) + " ";
text += ChatColor.GREEN + MiscUtil.snakeCaseToUpperCamelCase(Enchantment.values()[i].getName()) + " ";
} else {
text += ChatColor.GREEN + ItemUtil.getPrettyEnchantmentName(Enchantment.values()[i]) + ", ";
text += ChatColor.GREEN + MiscUtil.snakeCaseToUpperCamelCase(Enchantment.values()[i].getName()) + ", ";
}
}
text = text.substring(0, text.length() - 1);
@ -405,31 +407,22 @@ public class ItemsPrompt extends FixedSetPrompt {
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
String[] args = input.split(Lang.get("charSemi"));
LinkedList<String> enchs = new LinkedList<String>();
boolean valid;
for (String s : args) {
s = s.trim();
valid = false;
for (Enchantment e : Enchantment.values()) {
if (ItemUtil.getPrettyEnchantmentName(e).equalsIgnoreCase(s)) {
if (enchs.contains(s) == false) {
enchs.add(ItemUtil.getPrettyEnchantmentName(e));
valid = true;
break;
LinkedList<String> enchTypes = new LinkedList<String>();
for (String s : input.split(" ")) {
if (ItemUtil.getEnchantmentFromProperName(s) != null) {
if (enchTypes.contains(s) == false) {
enchTypes.add(s);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + " " + Lang.get("listDuplicate"));
return new EnchantTypesPrompt();
}
}
}
if (valid == false) {
} else {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + ChatColor.RED + " "
+ Lang.get("stageEditorInvalidEnchantment"));
return new EnchantTypesPrompt();
}
}
context.setSessionData(pref + CK.S_ENCHANT_TYPES, enchs);
context.setSessionData(pref + CK.S_ENCHANT_TYPES, enchTypes);
}
return new EnchantmentListPrompt();
}

View File

@ -376,13 +376,13 @@ public class MobsPrompt extends FixedSetPrompt {
for (String s : input.split(" ")) {
if (MiscUtil.getProperMobType(s) != null) {
mobTypes.add(s);
context.setSessionData(pref + CK.S_MOB_TYPES, mobTypes);
} else {
player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
+ Lang.get("stageEditorInvalidMob"));
return new MobTypesPrompt();
}
}
context.setSessionData(pref + CK.S_MOB_TYPES, mobTypes);
}
return new MobListPrompt();
}
@ -556,7 +556,7 @@ public class MobsPrompt extends FixedSetPrompt {
if (context.getSessionData(pref + CK.S_TAME_TYPES) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
+ Lang.get("stageEditorSetMobTypes") + " (" + Lang.get("noneSet") + ")\n";
text += ChatColor.GRAY + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GRAY
text += ChatColor.GRAY + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GRAY + " - "
+ Lang.get("stageEditorSetTameAmounts") + " (" + Lang.get("noneSet") + ")\n";
text += ChatColor.RED + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
+ Lang.get("clear") + "\n";
@ -663,7 +663,7 @@ public class MobsPrompt extends FixedSetPrompt {
if (MiscUtil.getProperMobType(s) != null) {
final EntityType type = MiscUtil.getProperMobType(s);
if (type.isAlive() || Tameable.class.isAssignableFrom(type.getEntityClass())) {
mobTypes.add(MiscUtil.getPrettyMobName(type));
mobTypes.add(s);
context.setSessionData(pref + CK.S_TAME_TYPES, mobTypes);
} else {
player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED

View File

@ -601,8 +601,17 @@ public class ItemUtil {
* @return pretty localized name
*/
public static String getPrettyEnchantmentName(Enchantment e) {
String prettyString = getEnchantmentName(e);
prettyString = MiscUtil.capitalsToSpaces(prettyString);
String baseString = e.getName();
String[] substrings = baseString.split("_");
String prettyString = "";
int size = 1;
for (String s : substrings) {
prettyString = prettyString.concat(MiscUtil.getCapitalized(s));
if (size < substrings.length) {
prettyString = prettyString.concat(" ");
}
size++;
}
return prettyString;
}
@ -612,7 +621,7 @@ public class ItemUtil {
* @param e Enchantment to get localized name of
* @return localized name
*/
private static String getEnchantmentName(Enchantment e) {
/*private static String getEnchantmentName(Enchantment e) {
try {
return (Lang.get("ENCHANTMENT_" + e.getName()));
} catch (NullPointerException ne) {
@ -620,15 +629,34 @@ public class ItemUtil {
+ "update the file or simply add an entry for the enchantment");
return e.getName().toLowerCase().replace("_", " ");
}
}*/
/**
* Gets enchantment from name
*
* @param properName Name to get enchantment from
* @return Enchantment or null if invalid
*/
public static Enchantment getEnchantmentFromProperName(String properName) {
properName = properName.replace(" ", "").toUpperCase();
for (Enchantment e : Enchantment.values()) {
if (e.getName().replace("_", "").equalsIgnoreCase(properName.replace("_", ""))) {
return e;
}
if (getEnchantmentFromProperLegacyName(properName) != null) {
return e;
}
}
return null;
}
public static Enchantment getEnchantmentFromProperName(String enchant) {
String ench = Lang.getKey(enchant.replace(" ", ""));
ench = ench.replace("ENCHANTMENT_", "");
Enchantment e = Enchantment.getByName(ench);
return e != null ? e : getEnchantmentFromProperLegacyName(ench.replace(" ", ""));
}
/**
* Gets Enchantment from name as it appears in lang file
*
* @deprecated Use {@link #getProperEnchantmentType(String)}
* @param enchant Name to match lang value to
* @return Enchantment or null if invalid
*/
public static Enchantment getEnchantmentFromProperLegacyName(String enchant) {
if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_ARROW_DAMAGE"))) {
return Enchantment.ARROW_DAMAGE;

View File

@ -154,7 +154,7 @@ public class LocaleQuery {
if (enchantments != null && !enchantments.isEmpty()) {
int count = 0;
for (Enchantment e : enchantments.keySet()) {
enchKeys[count] = "enchantment.minecraft." + e.toString().toLowerCase();
enchKeys[count] = "enchantment." + e.getKey().toString().toLowerCase().replace(":", ".");
count++;
}
}
@ -162,7 +162,7 @@ public class LocaleQuery {
String msg = message.replace("<item>", "\",{\"translate\":\"" + matKey + "\"},\"");
if (enchKeys != null && enchKeys.length > 0) {
for (String ek : enchKeys) {
msg.replaceFirst("<enchantment>", "\",{\"translate\":\"" + ek + "\"},\"");
msg = msg.replace("<enchantment>", "\",{\"translate\":\"" + ek + "\"},\"");
}
}
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " [\"" + msg + "\"]");

View File

@ -148,9 +148,9 @@ public class MiscUtil {
* @return EntityType or null if invalid
*/
public static EntityType getProperMobType(String properName) {
properName = properName.replaceAll("_", "").replaceAll(" ", "").toUpperCase();
properName = properName.replace("_", "").replace(" ", "").toUpperCase();
for (EntityType et : EntityType.values()) {
if (et.isAlive() && et.name().replaceAll("_", "").equalsIgnoreCase(properName)) {
if (et.isAlive() && et.name().replace("_", "").equalsIgnoreCase(properName)) {
return et;
}
}
@ -260,6 +260,8 @@ public class MiscUtil {
/**
* Adds a single space in front of all capital letters
*
* Unused internally. Left for external use
*
* @param s string to process
* @return processed string
*/

View File

@ -194,7 +194,7 @@ stageEditorEnterBlockAmounts: "Enter block amounts, <space>, <cancel>"
stageEditorEnterBlockDurability: "Enter block durabilities (numbers), <space>, <cancel>"
stageEditorCatchFishPrompt: "Enter number of fish to catch, <clear>, <cancel>"
stageEditorKillPlayerPrompt: "Enter number of players to kill, <clear>, <cancel>"
stageEditorEnchantTypePrompt: "Enter enchantment names, <semicolon>, <cancel>"
stageEditorEnchantTypePrompt: "Enter enchantment names, <space>, <cancel>"
stageEditorEnchantAmountsPrompt: "Enter enchant amounts (numbers), <space>, <cancel>"
stageEditorItemNamesPrompt: "Enter item names, <space>, <cancel>"
stageEditorNPCPrompt: "Enter NPC IDs, <space>, <cancel>"
@ -701,40 +701,6 @@ journalAlreadyHave: "You already have your Quest Journal out."
journalNoRoom: "You have no room in your inventory for your Quest Journal!"
journalNoQuests: "You have no accepted quests!"
journalDenied: "You cannot do that with your Quest Journal."
ENCHANTMENT_ARROW_DAMAGE: "Power"
ENCHANTMENT_ARROW_FIRE: "Flame"
ENCHANTMENT_ARROW_INFINITE: "Infinity"
ENCHANTMENT_ARROW_KNOCKBACK: "Punch"
ENCHANTMENT_BINDING_CURSE: "BindingCurse"
ENCHANTMENT_CHANNELING: "Channeling"
ENCHANTMENT_DAMAGE_ALL: "Sharpness"
ENCHANTMENT_DAMAGE_ARTHROPODS: "BaneOfArthropods"
ENCHANTMENT_DEPTH_STRIDER: "DepthStrider"
ENCHANTMENT_DAMAGE_UNDEAD: "Smite"
ENCHANTMENT_DIG_SPEED: "Efficiency"
ENCHANTMENT_DURABILITY: "Unbreaking"
ENCHANTMENT_FIRE_ASPECT: "FireAspect"
ENCHANTMENT_FROST_WALKER: "FrostWalker"
ENCHANTMENT_IMPALING: "Impaling"
ENCHANTMENT_KNOCKBACK: "Knockback"
ENCHANTMENT_LOOT_BONUS_BLOCKS: "Fortune"
ENCHANTMENT_LOOT_BONUS_MOBS: "Looting"
ENCHANTMENT_LOYALTY: "Loyalty"
ENCHANTMENT_LUCK: "LuckOfTheSea"
ENCHANTMENT_LURE: "Lure"
ENCHANTMENT_MENDING: "Mending"
ENCHANTMENT_OXYGEN: "Respiration"
ENCHANTMENT_PROTECTION_ENVIRONMENTAL: "Protection"
ENCHANTMENT_PROTECTION_EXPLOSIONS: "BlastProtection"
ENCHANTMENT_PROTECTION_FALL: "FeatherFalling"
ENCHANTMENT_PROTECTION_FIRE: "FireProtection"
ENCHANTMENT_PROTECTION_PROJECTILE: "ProjectileProtection"
ENCHANTMENT_RIPTIDE: "Riptide"
ENCHANTMENT_SILK_TOUCH: "SilkTouch"
ENCHANTMENT_SWEEPING_EDGE: "SweepingEdge"
ENCHANTMENT_THORNS: "Thorns"
ENCHANTMENT_VANISHING_CURSE: "VanishingCurse"
ENCHANTMENT_WATER_WORKER: "AquaAffinity"
COLOR_BLACK: "Black"
COLOR_BLUE: "Blue"
COLOR_BROWN: "Brown"

View File

@ -6,12 +6,12 @@
<groupId>me.blackvein.quests</groupId>
<artifactId>quests-parent</artifactId>
<version>3.8.3</version>
<version>3.8.4</version>
<name>quests</name>
<url>https://github.com/PikaMug/Quests/</url>
<properties>
<revision>3.8.3</revision>
<revision>3.8.4</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>me.blackvein.quests</groupId>
<artifactId>quests-parent</artifactId>
<version>3.8.3</version>
<version>3.8.4</version>
</parent>
<properties>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>me.blackvein.quests</groupId>
<artifactId>quests-parent</artifactId>
<version>3.8.3</version>
<version>3.8.4</version>
</parent>
<properties>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>me.blackvein.quests</groupId>
<artifactId>quests-parent</artifactId>
<version>3.8.3</version>
<version>3.8.4</version>
</parent>
<properties>