Improve translations, fix a problem with the files
This commit is contained in:
parent
9d505d0e30
commit
4aa724fd6f
@ -104,7 +104,7 @@ public class DisguiseConfig {
|
|||||||
public static void setUseTranslations(boolean setUseTranslations) {
|
public static void setUseTranslations(boolean setUseTranslations) {
|
||||||
useTranslations = setUseTranslations;
|
useTranslations = setUseTranslations;
|
||||||
|
|
||||||
TranslateType.reloadTranslations();
|
TranslateType.refreshTranslations();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSaveEntityDisguises() {
|
public static boolean isSaveEntityDisguises() {
|
||||||
|
@ -46,12 +46,12 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||||||
|
|
||||||
if (help != null) {
|
if (help != null) {
|
||||||
if (help.isEnums()) {
|
if (help.isEnums()) {
|
||||||
sender.sendMessage(ChatColor.RED + help.getName() + ": " + ChatColor.GREEN + StringUtils
|
sender.sendMessage(LibsMsg.DHELP_HELP4.get(help.getName(),
|
||||||
.join(help.getEnums(""), ChatColor.RED + ", " + ChatColor.GREEN));
|
StringUtils.join(help.getEnums(""), LibsMsg.DHELP_HELP4_SEPERATOR.get())));
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(
|
sender.sendMessage(LibsMsg.DHELP_HELP5.get(help.getName(), help.getDescription()));
|
||||||
ChatColor.RED + help.getName() + ": " + ChatColor.GREEN + help.getDescription());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,14 +107,14 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||||||
|
|
||||||
if (declaring == LivingWatcher.class) {
|
if (declaring == LivingWatcher.class) {
|
||||||
methodColor = ChatColor.AQUA;
|
methodColor = ChatColor.AQUA;
|
||||||
} else if (!(FlagWatcher.class
|
} else if (!(FlagWatcher.class.isAssignableFrom(declaring)) ||
|
||||||
.isAssignableFrom(declaring)) || declaring == FlagWatcher.class) {
|
declaring == FlagWatcher.class) {
|
||||||
methodColor = ChatColor.GRAY;
|
methodColor = ChatColor.GRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
String str = TranslateType.DISGUISE_OPTIONS
|
String str =
|
||||||
.get(method.getName()) + ChatColor.DARK_RED + "(" + ChatColor.GREEN + info
|
TranslateType.DISGUISE_OPTIONS.get(method.getName()) + ChatColor.DARK_RED + "(" +
|
||||||
.getName() + ChatColor.DARK_RED + ")";
|
ChatColor.GREEN + info.getName() + ChatColor.DARK_RED + ")";
|
||||||
|
|
||||||
map.put(str, methodColor);
|
map.put(str, methodColor);
|
||||||
methods.add(str);
|
methods.add(str);
|
||||||
|
@ -8,14 +8,11 @@ import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
|
|||||||
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.LibsProfileLookup;
|
import me.libraryaddict.disguise.utilities.LibsProfileLookup;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||||
import me.libraryaddict.disguise.utilities.json.SerializerGameProfile;
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -84,6 +81,10 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
createDisguise();
|
createDisguise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UUID getUUID() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlayerDisguise addPlayer(Player player) {
|
public PlayerDisguise addPlayer(Player player) {
|
||||||
return (PlayerDisguise) super.addPlayer(player);
|
return (PlayerDisguise) super.addPlayer(player);
|
||||||
|
@ -410,7 +410,6 @@ public class DisguiseUtilities {
|
|||||||
// This here is a paradox.
|
// This here is a paradox.
|
||||||
// If fed a name. I can do this.
|
// If fed a name. I can do this.
|
||||||
// But the rest of the time.. Its going to conflict.
|
// But the rest of the time.. Its going to conflict.
|
||||||
// The below is debug output. Most people wouldn't care for it.
|
|
||||||
|
|
||||||
disguiseItel.remove();
|
disguiseItel.remove();
|
||||||
d.removeDisguise();
|
d.removeDisguise();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.utilities;
|
package me.libraryaddict.disguise.utilities;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -10,24 +11,28 @@ public enum LibsMsg {
|
|||||||
CAN_USE_DISGS(ChatColor.DARK_GREEN + "You can use the disguises: %s"),
|
CAN_USE_DISGS(ChatColor.DARK_GREEN + "You can use the disguises: %s"),
|
||||||
CANNOT_FIND_PLAYER(ChatColor.RED + "Cannot find the player/uuid '%s'"),
|
CANNOT_FIND_PLAYER(ChatColor.RED + "Cannot find the player/uuid '%s'"),
|
||||||
CLICK_TIMER(ChatColor.RED + "Right click a entity in the next %s seconds to grab the disguise reference!"),
|
CLICK_TIMER(ChatColor.RED + "Right click a entity in the next %s seconds to grab the disguise reference!"),
|
||||||
CLONE_HELP1(
|
CLONE_HELP1(ChatColor.DARK_GREEN +
|
||||||
ChatColor.DARK_GREEN + "Right click a entity to get a disguise reference you can pass to other disguise commands!"),
|
"Right click a entity to get a disguise reference you can pass to other disguise commands!"),
|
||||||
CLONE_HELP2(
|
CLONE_HELP2(ChatColor.DARK_GREEN +
|
||||||
ChatColor.DARK_GREEN + "Security note: Any references you create will be available to all players able to use disguise references."),
|
"Security note: Any references you create will be available to all players able to use disguise " +
|
||||||
CLONE_HELP3(
|
"references."),
|
||||||
ChatColor.DARK_GREEN + "/disguiseclone IgnoreEquipment" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")"),
|
CLONE_HELP3(ChatColor.DARK_GREEN + "/disguiseclone IgnoreEquipment" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN +
|
||||||
|
"Optional" + ChatColor.DARK_GREEN + ")"),
|
||||||
D_HELP1(ChatColor.DARK_GREEN + "Disguise another player!"),
|
D_HELP1(ChatColor.DARK_GREEN + "Disguise another player!"),
|
||||||
D_HELP3(ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> player <Name>"),
|
D_HELP3(ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> player <Name>"),
|
||||||
D_HELP4(ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> <DisguiseType> <Baby>"),
|
D_HELP4(ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> <DisguiseType> <Baby>"),
|
||||||
D_HELP5(ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> <Dropped_Item/Falling_Block> <Id> <Durability>"),
|
D_HELP5(ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> <Dropped_Item/Falling_Block> <Id> <Durability>"),
|
||||||
D_PARSE_NOPERM(ChatColor.RED + "You do not have permission to use the option %s"),
|
D_PARSE_NOPERM(ChatColor.RED + "You do not have permission to use the option %s"),
|
||||||
DHELP_CANTFIND(ChatColor.RED + "Cannot find the disguise %s"),
|
DHELP_CANTFIND(ChatColor.RED + "Cannot find the disguise %s"),
|
||||||
DHELP_HELP1(
|
DHELP_HELP1(ChatColor.RED + "/disguisehelp <DisguiseType> " + ChatColor.GREEN +
|
||||||
ChatColor.RED + "/disguisehelp <DisguiseType> " + ChatColor.GREEN + "- View the options you can set on a disguise. Add 'show' to reveal the options you don't have permission to use"),
|
"- View the options you can set on a disguise. Add 'show' to reveal the options you don't have permission" +
|
||||||
DHELP_HELP2(
|
" to use"),
|
||||||
ChatColor.RED + "/disguisehelp <DisguiseOption> " + ChatColor.GREEN + "- View information about the " +
|
DHELP_HELP2(ChatColor.RED + "/disguisehelp <DisguiseOption> " + ChatColor.GREEN + "- View information about the " +
|
||||||
"disguise options such as 'RabbitType'"),
|
"disguise options such as 'RabbitType'"),
|
||||||
DHELP_HELP3(ChatColor.RED + "/disguisehelp %s" + ChatColor.GREEN + " - %s"),
|
DHELP_HELP3(ChatColor.RED + "/disguisehelp %s" + ChatColor.GREEN + " - %s"),
|
||||||
|
DHELP_HELP4(ChatColor.RED + "%s: " + ChatColor.GREEN + "%s"),
|
||||||
|
DHELP_HELP4_SEPERATOR(ChatColor.RED + ", " + ChatColor.GREEN),
|
||||||
|
DHELP_HELP5(ChatColor.RED + "%s: " + ChatColor.GREEN + "%s"),
|
||||||
DHELP_OPTIONS("%s options: %s"),
|
DHELP_OPTIONS("%s options: %s"),
|
||||||
DISABLED_LIVING_TO_MISC(
|
DISABLED_LIVING_TO_MISC(
|
||||||
ChatColor.RED + "Can't disguise a living entity as a misc disguise. This has been disabled in the config!"),
|
ChatColor.RED + "Can't disguise a living entity as a misc disguise. This has been disabled in the config!"),
|
||||||
@ -64,11 +69,11 @@ public enum LibsMsg {
|
|||||||
DCLONE_SNEAKSPRINT("doSneakSprint"),
|
DCLONE_SNEAKSPRINT("doSneakSprint"),
|
||||||
DCLONE_SNEAK("doSneak"),
|
DCLONE_SNEAK("doSneak"),
|
||||||
DCLONE_SPRINT("doSprint"),
|
DCLONE_SPRINT("doSprint"),
|
||||||
DMODRADIUS_HELP2(
|
DMODRADIUS_HELP2((ChatColor.DARK_GREEN + "/disguisemodifyradius <DisguiseType" + ChatColor.DARK_GREEN + "(" +
|
||||||
(ChatColor.DARK_GREEN + "/disguisemodifyradius <DisguiseType" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")> <Radius> <Disguise Options>")
|
ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")> <Radius> <Disguise Options>")
|
||||||
.replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")),
|
.replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")),
|
||||||
DMODRADIUS_HELP3(
|
DMODRADIUS_HELP3(ChatColor.DARK_GREEN + "See the DisguiseType's usable by " + ChatColor.GREEN +
|
||||||
ChatColor.DARK_GREEN + "See the DisguiseType's usable by " + ChatColor.GREEN + "/disguisemodifyradius DisguiseType"),
|
"/disguisemodifyradius DisguiseType"),
|
||||||
DMODRADIUS_NEEDOPTIONS(ChatColor.RED + "You need to supply the disguise options as well as the radius"),
|
DMODRADIUS_NEEDOPTIONS(ChatColor.RED + "You need to supply the disguise options as well as the radius"),
|
||||||
DMODRADIUS_NEEDOPTIONS_ENTITY(
|
DMODRADIUS_NEEDOPTIONS_ENTITY(
|
||||||
ChatColor.RED + "You need to supply the disguise options as well as the radius and EntityType"),
|
ChatColor.RED + "You need to supply the disguise options as well as the radius and EntityType"),
|
||||||
@ -79,24 +84,27 @@ public enum LibsMsg {
|
|||||||
DPLAYER_SUPPLY(ChatColor.RED + "You need to supply a disguise as well as the player/uuid"),
|
DPLAYER_SUPPLY(ChatColor.RED + "You need to supply a disguise as well as the player/uuid"),
|
||||||
DRADIUS_ENTITIES(ChatColor.DARK_GREEN + "EntityTypes usable are: %s"),
|
DRADIUS_ENTITIES(ChatColor.DARK_GREEN + "EntityTypes usable are: %s"),
|
||||||
DRADIUS_HELP1(ChatColor.DARK_GREEN + "Disguise all entities in a radius! Caps at %s blocks!"),
|
DRADIUS_HELP1(ChatColor.DARK_GREEN + "Disguise all entities in a radius! Caps at %s blocks!"),
|
||||||
DRADIUS_HELP3(
|
DRADIUS_HELP3((ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN +
|
||||||
(ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")> <Radius> player <Name>")
|
"Optional" + ChatColor.DARK_GREEN + ")> <Radius> player <Name>").replace("<", "<" + ChatColor.GREEN)
|
||||||
.replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")),
|
.replace(">", ChatColor.DARK_GREEN + ">")),
|
||||||
DRADIUS_HELP4(
|
DRADIUS_HELP4((ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN +
|
||||||
(ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")> <Radius> <DisguiseType> <Baby" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")>")
|
"Optional" + ChatColor.DARK_GREEN + ")> <Radius> <DisguiseType> <Baby" + ChatColor.DARK_GREEN + "(" +
|
||||||
.replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")),
|
ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")>").replace("<", "<" + ChatColor.GREEN)
|
||||||
DRADIUS_HELP5(
|
.replace(">", ChatColor.DARK_GREEN + ">")),
|
||||||
(ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")> <Radius> <Dropped_Item/Falling_Block> <Id> <Durability" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")>")
|
DRADIUS_HELP5((ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN +
|
||||||
.replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")),
|
"Optional" + ChatColor.DARK_GREEN + ")> <Radius> <Dropped_Item/Falling_Block> <Id> <Durability" +
|
||||||
|
ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")>")
|
||||||
|
.replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")),
|
||||||
DRADIUS_HELP6(
|
DRADIUS_HELP6(
|
||||||
ChatColor.DARK_GREEN + "See the EntityType's usable by " + ChatColor.GREEN + "/disguiseradius EntityTypes"),
|
ChatColor.DARK_GREEN + "See the EntityType's usable by " + ChatColor.GREEN + "/disguiseradius EntityTypes"),
|
||||||
DRADIUS_MISCDISG(
|
DRADIUS_MISCDISG(ChatColor.RED +
|
||||||
ChatColor.RED + "Failed to disguise %s entities because the option to disguise a living entity as a non-living has been disabled in the config"),
|
"Failed to disguise %s entities because the option to disguise a living entity as a non-living has been " +
|
||||||
|
"disabled in the config"),
|
||||||
DRADIUS_NEEDOPTIONS(ChatColor.RED + "You need to supply a disguise as well as the radius"),
|
DRADIUS_NEEDOPTIONS(ChatColor.RED + "You need to supply a disguise as well as the radius"),
|
||||||
DRADIUS_NEEDOPTIONS_ENTITY(ChatColor.RED + "You need to supply a disguise as well as the radius and EntityType"),
|
DRADIUS_NEEDOPTIONS_ENTITY(ChatColor.RED + "You need to supply a disguise as well as the radius and EntityType"),
|
||||||
FAILED_DISGIUSE(ChatColor.RED + "Failed to disguise as a %s"),
|
FAILED_DISGIUSE(ChatColor.RED + "Failed to disguise as a %s"),
|
||||||
INVALID_CLONE(
|
INVALID_CLONE(ChatColor.DARK_RED + "Unknown option '%s' - Valid options are 'IgnoreEquipment' 'DoSneakSprint' " +
|
||||||
ChatColor.DARK_RED + "Unknown option '%s' - Valid options are 'IgnoreEquipment' 'DoSneakSprint' " + "'DoSneak' 'DoSprint'"),
|
"'DoSneak' 'DoSprint'"),
|
||||||
LIBS_RELOAD_WRONG(ChatColor.RED + "[LibsDisguises] Did you mean 'reload'?"),
|
LIBS_RELOAD_WRONG(ChatColor.RED + "[LibsDisguises] Did you mean 'reload'?"),
|
||||||
LIMITED_RADIUS(ChatColor.RED + "Limited radius to %s! Don't want to make too much lag right?"),
|
LIMITED_RADIUS(ChatColor.RED + "Limited radius to %s! Don't want to make too much lag right?"),
|
||||||
LISTEN_ENTITY_ENTITY_DISG_ENTITY(ChatColor.RED + "Disguised %s as a %s!"),
|
LISTEN_ENTITY_ENTITY_DISG_ENTITY(ChatColor.RED + "Disguised %s as a %s!"),
|
||||||
@ -117,8 +125,8 @@ public enum LibsMsg {
|
|||||||
NO_CONSOLE(ChatColor.RED + "You may not use this command from the console!"),
|
NO_CONSOLE(ChatColor.RED + "You may not use this command from the console!"),
|
||||||
NO_PERM(ChatColor.RED + "You are forbidden to use this command."),
|
NO_PERM(ChatColor.RED + "You are forbidden to use this command."),
|
||||||
NO_PERM_DISGUISE(ChatColor.RED + "You do not have permission for that disguise!"),
|
NO_PERM_DISGUISE(ChatColor.RED + "You do not have permission for that disguise!"),
|
||||||
NO_PERMS_USE_OPTIONS(
|
NO_PERMS_USE_OPTIONS(ChatColor.RED +
|
||||||
ChatColor.RED + "Ignored %s options you do not have permission to use. Add 'show' to view unusable options."),
|
"Ignored %s options you do not have permission to use. Add 'show' to view unusable options."),
|
||||||
NOT_DISGUISED(ChatColor.RED + "You are not disguised!"),
|
NOT_DISGUISED(ChatColor.RED + "You are not disguised!"),
|
||||||
NOT_NUMBER(ChatColor.RED + "Error! %s is not a number"),
|
NOT_NUMBER(ChatColor.RED + "Error! %s is not a number"),
|
||||||
PARSE_CANT_DISG_UNKNOWN(ChatColor.RED + "Error! You cannot disguise as " + ChatColor.GREEN + "Unknown!"),
|
PARSE_CANT_DISG_UNKNOWN(ChatColor.RED + "Error! You cannot disguise as " + ChatColor.GREEN + "Unknown!"),
|
||||||
@ -126,7 +134,8 @@ public enum LibsMsg {
|
|||||||
PARSE_DISG_NO_EXIST(
|
PARSE_DISG_NO_EXIST(
|
||||||
ChatColor.RED + "Error! The disguise " + ChatColor.GREEN + "%s" + ChatColor.RED + " doesn't exist!"),
|
ChatColor.RED + "Error! The disguise " + ChatColor.GREEN + "%s" + ChatColor.RED + " doesn't exist!"),
|
||||||
PARSE_EXPECTED_RECEIVED(
|
PARSE_EXPECTED_RECEIVED(
|
||||||
ChatColor.RED + "Expected " + ChatColor.GREEN + "%s" + ChatColor.RED + ", received " + ChatColor.GREEN + "%s" + ChatColor.RED + " instead for " + ChatColor.GREEN + "%s"),
|
ChatColor.RED + "Expected " + ChatColor.GREEN + "%s" + ChatColor.RED + ", received " + ChatColor.GREEN +
|
||||||
|
"%s" + ChatColor.RED + " instead for " + ChatColor.GREEN + "%s"),
|
||||||
PARSE_NO_ARGS("No arguments defined"),
|
PARSE_NO_ARGS("No arguments defined"),
|
||||||
PARSE_NO_OPTION_VALUE(ChatColor.RED + "No value was given for the option %s"),
|
PARSE_NO_OPTION_VALUE(ChatColor.RED + "No value was given for the option %s"),
|
||||||
PARSE_NO_PERM_NAME(ChatColor.RED + "Error! You don't have permission to use that name!"),
|
PARSE_NO_PERM_NAME(ChatColor.RED + "Error! You don't have permission to use that name!"),
|
||||||
@ -138,8 +147,9 @@ public enum LibsMsg {
|
|||||||
PARSE_SUPPLY_PLAYER(ChatColor.RED + "Error! You need to give a player name!"),
|
PARSE_SUPPLY_PLAYER(ChatColor.RED + "Error! You need to give a player name!"),
|
||||||
PARSE_TOO_MANY_ARGS(ChatColor.RED + "Error! %s doesn't know what to do with %s!"),
|
PARSE_TOO_MANY_ARGS(ChatColor.RED + "Error! %s doesn't know what to do with %s!"),
|
||||||
PARSE_USE_SECOND_NUM(ChatColor.RED + "Error! Only the disguises %s and %s uses a second number!"),
|
PARSE_USE_SECOND_NUM(ChatColor.RED + "Error! Only the disguises %s and %s uses a second number!"),
|
||||||
REF_TOO_MANY(
|
REF_TOO_MANY(ChatColor.RED +
|
||||||
ChatColor.RED + "Failed to store the reference, too many cloned disguises. Please raise the maximum cloned disguises, or lower the time they last"),
|
"Failed to store the reference, too many cloned disguises. Please raise the maximum cloned disguises, or " +
|
||||||
|
"lower the time they last"),
|
||||||
RELOADED_CONFIG(ChatColor.GREEN + "[LibsDisguises] Reloaded config."),
|
RELOADED_CONFIG(ChatColor.GREEN + "[LibsDisguises] Reloaded config."),
|
||||||
UND_ENTITY(ChatColor.RED + "Right click a disguised entity to undisguise them!"),
|
UND_ENTITY(ChatColor.RED + "Right click a disguised entity to undisguise them!"),
|
||||||
UNDISG(ChatColor.RED + "You are no longer disguised"),
|
UNDISG(ChatColor.RED + "You are no longer disguised"),
|
||||||
@ -147,8 +157,9 @@ public enum LibsMsg {
|
|||||||
UNDISG_PLAYER_FAIL(ChatColor.RED + "%s not disguised!"),
|
UNDISG_PLAYER_FAIL(ChatColor.RED + "%s not disguised!"),
|
||||||
UNDISG_PLAYER_HELP(ChatColor.RED + "/undisguiseplayer <Name>"),
|
UNDISG_PLAYER_HELP(ChatColor.RED + "/undisguiseplayer <Name>"),
|
||||||
UNDISRADIUS(ChatColor.RED + "Successfully undisguised %s entities!"),
|
UNDISRADIUS(ChatColor.RED + "Successfully undisguised %s entities!"),
|
||||||
UPDATE_READY(
|
UPDATE_READY(ChatColor.RED + "[LibsDisguises] " + ChatColor.DARK_RED +
|
||||||
ChatColor.RED + "[LibsDisguises] " + ChatColor.DARK_RED + "There is a update ready to be downloaded! You are using " + ChatColor.RED + "v%s" + ChatColor.DARK_RED + ", the new version is " + ChatColor.RED + "%s" + ChatColor.DARK_RED + "!"),
|
"There is a update ready to be downloaded! You are using " + ChatColor.RED + "v%s" + ChatColor.DARK_RED +
|
||||||
|
", the new version is " + ChatColor.RED + "%s" + ChatColor.DARK_RED + "!"),
|
||||||
VIEW_SELF_ON(ChatColor.GREEN + "Toggled viewing own disguise on!"),
|
VIEW_SELF_ON(ChatColor.GREEN + "Toggled viewing own disguise on!"),
|
||||||
VIEW_SELF_OFF(ChatColor.GREEN + "Toggled viewing own disguise off!");
|
VIEW_SELF_OFF(ChatColor.GREEN + "Toggled viewing own disguise off!");
|
||||||
|
|
||||||
@ -163,8 +174,14 @@ public enum LibsMsg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String get(Object... strings) {
|
public String get(Object... strings) {
|
||||||
if (strings.length == 0)
|
if (StringUtils.countMatches(getRaw(), "%s") != strings.length) {
|
||||||
|
System.out.println("[LibsDisguises] Mismatch in messages, incorrect parameters supplied for " + name() +
|
||||||
|
". Please inform plugin author.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strings.length == 0) {
|
||||||
return TranslateType.MESSAGES.get(getRaw());
|
return TranslateType.MESSAGES.get(getRaw());
|
||||||
|
}
|
||||||
|
|
||||||
return String.format(TranslateType.MESSAGES.get(getRaw()), (Object[]) strings);
|
return String.format(TranslateType.MESSAGES.get(getRaw()), (Object[]) strings);
|
||||||
}
|
}
|
||||||
|
@ -52,8 +52,8 @@ public class TranslateFiller {
|
|||||||
className = "Illager";
|
className = "Illager";
|
||||||
|
|
||||||
TranslateType.DISGUISE_OPTIONS.save(method.getName(),
|
TranslateType.DISGUISE_OPTIONS.save(method.getName(),
|
||||||
"Found in the disguise options for " + className + " and uses " + (para.isArray() ?
|
"Found in the disguise options for " + className + " and uses " +
|
||||||
"multiple" + " " : "a ") + para.getSimpleName().replace("[]", "s"));
|
(para.isArray() ? "multiple" + " " : "a ") + para.getSimpleName().replace("[]", "s"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,11 +72,11 @@ public class TranslateFiller {
|
|||||||
.save("DisgiseType", "Used for the disgiuse modify radius command to list all " + "disguisetypes");
|
.save("DisgiseType", "Used for the disgiuse modify radius command to list all " + "disguisetypes");
|
||||||
|
|
||||||
for (LibsMsg msg : LibsMsg.values()) {
|
for (LibsMsg msg : LibsMsg.values()) {
|
||||||
TranslateType.MESSAGES.save(msg.getRaw());
|
TranslateType.MESSAGES.save(msg.getRaw(), "Reference: " + msg.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (TranslateType type : TranslateType.values()) {
|
for (TranslateType type : TranslateType.values()) {
|
||||||
type.removeDuplicates();
|
type.saveTranslations();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,8 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@ -23,16 +23,16 @@ public enum TranslateType {
|
|||||||
DISGUISE_OPTIONS_PARAMETERS("disguise_option_parameters");
|
DISGUISE_OPTIONS_PARAMETERS("disguise_option_parameters");
|
||||||
|
|
||||||
private File file;
|
private File file;
|
||||||
private HashMap<String, String> translated = new HashMap<>();
|
private LinkedHashMap<String, String> translated = new LinkedHashMap<>();
|
||||||
private FileWriter writer;
|
private FileWriter writer;
|
||||||
|
|
||||||
TranslateType(String fileName) {
|
TranslateType(String fileName) {
|
||||||
file = new File("plugins/LibsDisguises/Translations", fileName + ".yml");
|
file = new File("plugins/LibsDisguises/Translations", fileName + ".yml");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reloadTranslations() {
|
public static void refreshTranslations() {
|
||||||
for (TranslateType type : values()) {
|
for (TranslateType type : values()) {
|
||||||
type.reload();
|
type.loadTranslations();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!LibsPremium.isPremium() && DisguiseConfig.isUseTranslations()) {
|
if (!LibsPremium.isPremium() && DisguiseConfig.isUseTranslations()) {
|
||||||
@ -42,7 +42,10 @@ public enum TranslateType {
|
|||||||
TranslateFiller.fillConfigs();
|
TranslateFiller.fillConfigs();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void removeDuplicates() {
|
protected void saveTranslations() {
|
||||||
|
// First remove translations which are not different from each other. We don't need to store messages that
|
||||||
|
// were not translated.
|
||||||
|
|
||||||
Iterator<Map.Entry<String, String>> itel = translated.entrySet().iterator();
|
Iterator<Map.Entry<String, String>> itel = translated.entrySet().iterator();
|
||||||
|
|
||||||
while (itel.hasNext()) {
|
while (itel.hasNext()) {
|
||||||
@ -54,6 +57,8 @@ public enum TranslateType {
|
|||||||
itel.remove();
|
itel.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close the writer
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (writer != null) {
|
if (writer != null) {
|
||||||
writer.close();
|
writer.close();
|
||||||
@ -65,37 +70,51 @@ public enum TranslateType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void wipeTranslations() {
|
private void loadTranslations() {
|
||||||
translated.clear();
|
translated.clear();
|
||||||
}
|
|
||||||
|
|
||||||
private void reload() {
|
|
||||||
wipeTranslations();
|
|
||||||
|
|
||||||
if (LibsPremium.isPremium() && DisguiseConfig.isUseTranslations()) {
|
if (LibsPremium.isPremium() && DisguiseConfig.isUseTranslations()) {
|
||||||
System.out.println("[LibsDisguises] Loading translations: " + name());
|
System.out.println("[LibsDisguises] Loading translations: " + name());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getFile().exists())
|
if (!getFile().exists()) {
|
||||||
|
System.out.println("[LibsDisguises] Translations for " + name() + " missing! Skipping...");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
YamlConfiguration config = new YamlConfiguration();
|
YamlConfiguration config = new YamlConfiguration();
|
||||||
config.options().pathSeparator(Character.toChars(0)[0]);
|
config.options().pathSeparator(Character.toChars(0)[0]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
config.load(getFile());
|
config.load(getFile());
|
||||||
|
int dupes = 0;
|
||||||
|
|
||||||
for (String key : config.getKeys(false)) {
|
for (String key : config.getKeys(false)) {
|
||||||
String value = config.getString(key);
|
String value = config.getString(key);
|
||||||
|
|
||||||
if (Objects.equals(key, value))
|
if (value == null) {
|
||||||
continue;
|
|
||||||
|
|
||||||
if (value == null)
|
|
||||||
System.err.println("Translation for " + name() + " has a null value for the key '" + key + "'");
|
System.err.println("Translation for " + name() + " has a null value for the key '" + key + "'");
|
||||||
else {
|
} else {
|
||||||
translated.put(ChatColor.translateAlternateColorCodes('&', key),
|
String newKey = ChatColor.translateAlternateColorCodes('&', key);
|
||||||
ChatColor.translateAlternateColorCodes('&', value));
|
|
||||||
|
if (translated.containsKey(newKey)) {
|
||||||
|
if (dupes++ < 5) {
|
||||||
|
System.out.println(
|
||||||
|
"[LibsDisguises] Alert! Duplicate translation entry for " + key + " in " + name() +
|
||||||
|
" translations!");
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
System.out.println(
|
||||||
|
"[LibsDisguises] Too many duplicated keys! It's likely that this file was mildly " +
|
||||||
|
"corrupted by a previous bug!");
|
||||||
|
System.out.println(
|
||||||
|
"[LibsDisguises] Delete the file, or you can remove every line after the first " +
|
||||||
|
"duplicate message!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
translated.put(newKey, ChatColor.translateAlternateColorCodes('&', value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,7 +145,7 @@ public enum TranslateType {
|
|||||||
|
|
||||||
translated.put(message, message);
|
translated.put(message, message);
|
||||||
|
|
||||||
message = StringEscapeUtils.escapeJava(message.replaceAll(ChatColor.COLOR_CHAR + "", "&"));
|
message = StringEscapeUtils.escapeJava(message.replace(ChatColor.COLOR_CHAR + "", "&"));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
boolean exists = getFile().exists();
|
boolean exists = getFile().exists();
|
||||||
|
Loading…
Reference in New Issue
Block a user