mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Enforce locale usage for enums to ensure correct casing (Fixes #4086)
This commit is contained in:
parent
da98be88ad
commit
601297799f
@ -1,3 +1,6 @@
|
|||||||
|
Version 2.1.112
|
||||||
|
Correct locale usage for enum access, now enforces using the english locale to prevent issues with oddball locales for configs/commands
|
||||||
|
|
||||||
Version 2.1.111
|
Version 2.1.111
|
||||||
mcMMO is compatible with the following versions of MC: 1.15 / 1.14.4 / 1.14.3 / 1.14.2 / 1.14.1 / 1.14 / 1.13.2
|
mcMMO is compatible with the following versions of MC: 1.15 / 1.14.4 / 1.14.3 / 1.14.2 / 1.14.1 / 1.14 / 1.13.2
|
||||||
Further prevent nesting of bleed damage calls
|
Further prevent nesting of bleed damage calls
|
||||||
|
@ -11,13 +11,15 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class ConvertExperienceCommand implements CommandExecutor {
|
public class ConvertExperienceCommand implements CommandExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
FormulaType previousType = mcMMO.getFormulaManager().getPreviousFormulaType();
|
FormulaType previousType = mcMMO.getFormulaManager().getPreviousFormulaType();
|
||||||
FormulaType newType = FormulaType.getFormulaType(args[1].toUpperCase());
|
FormulaType newType = FormulaType.getFormulaType(args[1].toUpperCase(Locale.ENGLISH));
|
||||||
|
|
||||||
if (newType == FormulaType.UNKNOWN) {
|
if (newType == FormulaType.UNKNOWN) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Invalid"));
|
||||||
|
@ -14,6 +14,8 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class PartyItemShareCommand implements CommandExecutor {
|
public class PartyItemShareCommand implements CommandExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
@ -32,7 +34,7 @@ public class PartyItemShareCommand implements CommandExecutor {
|
|||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
ShareMode mode = ShareMode.getShareMode(args[1].toUpperCase());
|
ShareMode mode = ShareMode.getShareMode(args[1].toUpperCase(Locale.ENGLISH));
|
||||||
|
|
||||||
if (mode == null) {
|
if (mode == null) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
|
||||||
@ -57,7 +59,7 @@ public class PartyItemShareCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
handleToggleItemShareCategory(party, ItemShareType.valueOf(args[1].toUpperCase()), toggle);
|
handleToggleItemShareCategory(party, ItemShareType.valueOf(args[1].toUpperCase(Locale.ENGLISH)), toggle);
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException ex) {
|
catch (IllegalArgumentException ex) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
|
||||||
|
@ -12,6 +12,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class Config extends AutoUpdateConfigLoader {
|
public class Config extends AutoUpdateConfigLoader {
|
||||||
@ -277,7 +278,7 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
/* Mob Healthbar */
|
/* Mob Healthbar */
|
||||||
public MobHealthbarType getMobHealthbarDefault() {
|
public MobHealthbarType getMobHealthbarDefault() {
|
||||||
try {
|
try {
|
||||||
return MobHealthbarType.valueOf(config.getString("Mob_Healthbar.Display_Type", "HEARTS").toUpperCase().trim());
|
return MobHealthbarType.valueOf(config.getString("Mob_Healthbar.Display_Type", "HEARTS").toUpperCase(Locale.ENGLISH).trim());
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException ex) {
|
catch (IllegalArgumentException ex) {
|
||||||
return MobHealthbarType.HEARTS;
|
return MobHealthbarType.HEARTS;
|
||||||
|
@ -5,6 +5,7 @@ import com.gmail.nossr50.util.StringUtils;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class ItemWeightConfig extends ConfigLoader {
|
public class ItemWeightConfig extends ConfigLoader {
|
||||||
private static ItemWeightConfig instance;
|
private static ItemWeightConfig instance;
|
||||||
@ -29,7 +30,7 @@ public class ItemWeightConfig extends ConfigLoader {
|
|||||||
HashSet<Material> miscItems = new HashSet<Material>();
|
HashSet<Material> miscItems = new HashSet<Material>();
|
||||||
|
|
||||||
for (String item : config.getStringList("Party_Shareables.Misc_Items")) {
|
for (String item : config.getStringList("Party_Shareables.Misc_Items")) {
|
||||||
Material material = Material.getMaterial(item.toUpperCase());
|
Material material = Material.getMaterial(item.toUpperCase(Locale.ENGLISH));
|
||||||
|
|
||||||
if (material != null) {
|
if (material != null) {
|
||||||
miscItems.add(material);
|
miscItems.add(material);
|
||||||
|
@ -14,6 +14,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class SalvageConfig extends ConfigLoader {
|
public class SalvageConfig extends ConfigLoader {
|
||||||
@ -78,7 +79,7 @@ public class SalvageConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
salvageMaterialType = MaterialType.valueOf(salvageMaterialTypeString.replace(" ", "_").toUpperCase());
|
salvageMaterialType = MaterialType.valueOf(salvageMaterialTypeString.replace(" ", "_").toUpperCase(Locale.ENGLISH));
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException ex) {
|
catch (IllegalArgumentException ex) {
|
||||||
reason.add(key + " has an invalid MaterialType of " + salvageMaterialTypeString);
|
reason.add(key + " has an invalid MaterialType of " + salvageMaterialTypeString);
|
||||||
@ -112,7 +113,7 @@ public class SalvageConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
salvageItemType = ItemType.valueOf(salvageItemTypeString.replace(" ", "_").toUpperCase());
|
salvageItemType = ItemType.valueOf(salvageItemTypeString.replace(" ", "_").toUpperCase(Locale.ENGLISH));
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException ex) {
|
catch (IllegalArgumentException ex) {
|
||||||
reason.add(key + " has an invalid ItemType of " + salvageItemTypeString);
|
reason.add(key + " has an invalid ItemType of " + salvageItemTypeString);
|
||||||
|
@ -6,6 +6,7 @@ import com.gmail.nossr50.util.StringUtils;
|
|||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class ChildConfig extends AutoUpdateConfigLoader {
|
public class ChildConfig extends AutoUpdateConfigLoader {
|
||||||
public ChildConfig() {
|
public ChildConfig() {
|
||||||
@ -27,7 +28,7 @@ public class ChildConfig extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
for (String name : config.getStringList(StringUtils.getCapitalized(skill.name()))) {
|
for (String name : config.getStringList(StringUtils.getCapitalized(skill.name()))) {
|
||||||
try {
|
try {
|
||||||
PrimarySkillType parentSkill = PrimarySkillType.valueOf(name.toUpperCase());
|
PrimarySkillType parentSkill = PrimarySkillType.valueOf(name.toUpperCase(Locale.ENGLISH));
|
||||||
FamilyTree.enforceNotChildSkill(parentSkill);
|
FamilyTree.enforceNotChildSkill(parentSkill);
|
||||||
parentSkills.add(parentSkill);
|
parentSkills.add(parentSkill);
|
||||||
}
|
}
|
||||||
@ -45,7 +46,7 @@ public class ChildConfig extends AutoUpdateConfigLoader {
|
|||||||
* If they're dedicated enough to have modified it, they can have the errors it may produce.
|
* If they're dedicated enough to have modified it, they can have the errors it may produce.
|
||||||
* Alternatively, this can be used to allow child skills to be parent skills, provided there are no circular dependencies this is an advanced sort of configuration.
|
* Alternatively, this can be used to allow child skills to be parent skills, provided there are no circular dependencies this is an advanced sort of configuration.
|
||||||
*/
|
*/
|
||||||
parentSkills.add(PrimarySkillType.valueOf(name.toUpperCase()));
|
parentSkills.add(PrimarySkillType.valueOf(name.toUpperCase(Locale.ENGLISH)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@ import org.bukkit.block.data.Ageable;
|
|||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class StringUtils {
|
public class StringUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user