CoreProtect v20.0 release
This commit is contained in:
parent
415d7b323a
commit
48ef18e2c8
173 changed files with 25072 additions and 1 deletions
232
src/main/java/net/coreprotect/language/Language.java
Normal file
232
src/main/java/net/coreprotect/language/Language.java
Normal file
|
|
@ -0,0 +1,232 @@
|
|||
package net.coreprotect.language;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class Language {
|
||||
|
||||
private static ConcurrentHashMap<Phrase, String> phrases = new ConcurrentHashMap<>();
|
||||
private static ConcurrentHashMap<Phrase, String> userPhrases = new ConcurrentHashMap<>();
|
||||
private static ConcurrentHashMap<Phrase, String> translatedPhrases = new ConcurrentHashMap<>();
|
||||
|
||||
protected static String getPhrase(Phrase phrase) {
|
||||
return phrases.get(phrase);
|
||||
}
|
||||
|
||||
protected static String getUserPhrase(Phrase phrase) {
|
||||
return userPhrases.get(phrase);
|
||||
}
|
||||
|
||||
protected static String getTranslatedPhrase(Phrase phrase) {
|
||||
return translatedPhrases.get(phrase);
|
||||
}
|
||||
|
||||
protected static void setUserPhrase(Phrase phrase, String value) {
|
||||
userPhrases.put(phrase, value);
|
||||
}
|
||||
|
||||
protected static void setTranslatedPhrase(Phrase phrase, String value) {
|
||||
translatedPhrases.put(phrase, value);
|
||||
}
|
||||
|
||||
public static void loadPhrases() {
|
||||
phrases.put(Phrase.ACTION_NOT_SUPPORTED, "That action is not supported by the command.");
|
||||
phrases.put(Phrase.AMOUNT_BLOCK, "{0} {block|blocks}");
|
||||
phrases.put(Phrase.AMOUNT_CHUNK, "{0} {chunk|chunks}");
|
||||
phrases.put(Phrase.AMOUNT_ENTITY, "{0} {entity|entities}");
|
||||
phrases.put(Phrase.AMOUNT_ITEM, "{0} {item|items}");
|
||||
phrases.put(Phrase.API_TEST, "API test successful.");
|
||||
phrases.put(Phrase.CACHE_ERROR, "WARNING: Error while validating {0} cache.");
|
||||
phrases.put(Phrase.CACHE_RELOAD, "Forcing reload of {mapping|world} caches from database.");
|
||||
phrases.put(Phrase.CHECK_CONFIG, "Please check config.yml");
|
||||
phrases.put(Phrase.COMMAND_NOT_FOUND, "Command \"{0}\" not found.");
|
||||
phrases.put(Phrase.COMMAND_THROTTLED, "Please wait a moment and try again.");
|
||||
phrases.put(Phrase.CONTAINER_HEADER, "Container Transactions");
|
||||
phrases.put(Phrase.DATABASE_BUSY, "Database busy. Please try again later.");
|
||||
phrases.put(Phrase.DATABASE_INDEX_ERROR, "Unable to validate database indexes.");
|
||||
phrases.put(Phrase.DATABASE_LOCKED_1, "Database locked. Waiting up to 15 seconds...");
|
||||
phrases.put(Phrase.DATABASE_LOCKED_2, "Database is already in use. Please try again.");
|
||||
phrases.put(Phrase.DATABASE_LOCKED_3, "To disable database locking, set \"database-lock: false\".");
|
||||
phrases.put(Phrase.DATABASE_LOCKED_4, "Disabling database locking can result in data corruption.");
|
||||
phrases.put(Phrase.DATABASE_UNREACHABLE, "Database is unreachable. Discarding data and shutting down.");
|
||||
phrases.put(Phrase.DEVELOPMENT_BRANCH, "Development branch detected, skipping patch scripts.");
|
||||
phrases.put(Phrase.DIRT_BLOCK, "Placed a dirt block under you.");
|
||||
phrases.put(Phrase.DISABLE_SUCCESS, "Success! Disabled {0}");
|
||||
phrases.put(Phrase.ENABLE_FAILED, "{0} was unable to start.");
|
||||
phrases.put(Phrase.ENABLE_SUCCESS, "{0} has been successfully enabled!");
|
||||
phrases.put(Phrase.ENJOY_COREPROTECT, "Enjoy {0}? Join our Discord!");
|
||||
phrases.put(Phrase.FINISHING_CONVERSION, "Finishing up data conversion. Please wait...");
|
||||
phrases.put(Phrase.FINISHING_LOGGING, "Finishing up data logging. Please wait...");
|
||||
phrases.put(Phrase.FIRST_VERSION, "Initial DB: {0}");
|
||||
phrases.put(Phrase.GLOBAL_LOOKUP, "Don't specify a radius to do a global lookup.");
|
||||
phrases.put(Phrase.GLOBAL_ROLLBACK, "Use \"{0}\" to do a global {rollback|restore}");
|
||||
phrases.put(Phrase.HELP_ACTION_1, "Restrict the lookup to a certain action.");
|
||||
phrases.put(Phrase.HELP_ACTION_2, "Examples: [a:block], [a:+block], [a:-block] [a:click], [a:container], [a:inventory], [a:item], [a:kill], [a:chat], [a:command], [a:sign], [a:session], [a:username]");
|
||||
phrases.put(Phrase.HELP_COMMAND, "Display more info for that command.");
|
||||
phrases.put(Phrase.HELP_EXCLUDE_1, "Exclude blocks/users.");
|
||||
phrases.put(Phrase.HELP_EXCLUDE_2, "Examples: [e:stone], [e:Notch], [e:stone,Notch]");
|
||||
phrases.put(Phrase.HELP_HEADER, "{0} Help");
|
||||
phrases.put(Phrase.HELP_INCLUDE_1, "Include specific blocks/entities.");
|
||||
phrases.put(Phrase.HELP_INCLUDE_2, "Examples: [i:stone], [i:zombie], [i:stone,wood,bedrock]");
|
||||
phrases.put(Phrase.HELP_INSPECT_1, "With the inspector enabled, you can do the following:");
|
||||
phrases.put(Phrase.HELP_INSPECT_2, "Left-click a block to see who placed that block.");
|
||||
phrases.put(Phrase.HELP_INSPECT_3, "Right-click a block to see what adjacent block was broken.");
|
||||
phrases.put(Phrase.HELP_INSPECT_4, "Place a block to see what block was broken at that location.");
|
||||
phrases.put(Phrase.HELP_INSPECT_5, "Place a block in liquid (etc) to see who placed it.");
|
||||
phrases.put(Phrase.HELP_INSPECT_6, "Right-click on a door, chest, etc, to see who last used it.");
|
||||
phrases.put(Phrase.HELP_INSPECT_7, "Tip: You can use just \"/co i\" for quicker access.");
|
||||
phrases.put(Phrase.HELP_INSPECT_COMMAND, "Turns the block inspector on or off.");
|
||||
phrases.put(Phrase.HELP_LIST, "Displays a list of all commands.");
|
||||
phrases.put(Phrase.HELP_LOOKUP_1, "Command shortcut.");
|
||||
phrases.put(Phrase.HELP_LOOKUP_2, "Use after inspecting a block to view logs.");
|
||||
phrases.put(Phrase.HELP_LOOKUP_COMMAND, "Advanced block data lookup.");
|
||||
phrases.put(Phrase.HELP_NO_INFO, "Information for command \"{0}\" not found.");
|
||||
phrases.put(Phrase.HELP_PARAMETER, "Please see \"{0}\" for detailed parameter info.");
|
||||
phrases.put(Phrase.HELP_PARAMS_1, "Perform the {lookup|rollback|restore}.");
|
||||
phrases.put(Phrase.HELP_PARAMS_2, "Specify the user(s) to {lookup|rollback|restore}.");
|
||||
phrases.put(Phrase.HELP_PARAMS_3, "Specify the amount of time to {lookup|rollback|restore}.");
|
||||
phrases.put(Phrase.HELP_PARAMS_4, "Specify a radius area to limit the {lookup|rollback|restore} to.");
|
||||
phrases.put(Phrase.HELP_PARAMS_5, "Restrict the {lookup|rollback|restore} to a certain action.");
|
||||
phrases.put(Phrase.HELP_PARAMS_6, "Include specific blocks/entities in the {lookup|rollback|restore}.");
|
||||
phrases.put(Phrase.HELP_PARAMS_7, "Exclude blocks/users from the {lookup|rollback|restore}.");
|
||||
phrases.put(Phrase.HELP_PURGE_1, "Delete data older than specified time.");
|
||||
phrases.put(Phrase.HELP_PURGE_2, "For example, \"{0}\" will delete all data older than one month, and only keep the last 30 days of data.");
|
||||
phrases.put(Phrase.HELP_PURGE_COMMAND, "Delete old block data.");
|
||||
phrases.put(Phrase.HELP_RADIUS_1, "Specify a radius area.");
|
||||
phrases.put(Phrase.HELP_RADIUS_2, "Examples: [r:10] (Only make changes within 10 blocks of you)");
|
||||
phrases.put(Phrase.HELP_RELOAD_COMMAND, "Reloads the configuration file.");
|
||||
phrases.put(Phrase.HELP_RESTORE_COMMAND, "Restore block data.");
|
||||
phrases.put(Phrase.HELP_ROLLBACK_COMMAND, "Rollback block data.");
|
||||
phrases.put(Phrase.HELP_STATUS, "View the plugin status and version information.");
|
||||
phrases.put(Phrase.HELP_STATUS_COMMAND, "Displays the plugin status.");
|
||||
phrases.put(Phrase.HELP_TELEPORT, "Teleport to a location.");
|
||||
phrases.put(Phrase.HELP_TIME_1, "Specify the amount of time to lookup.");
|
||||
phrases.put(Phrase.HELP_TIME_2, "Examples: [t:2w,5d,7h,2m,10s], [t:5d2h], [t:2.50h]");
|
||||
phrases.put(Phrase.HELP_USER_1, "Specify the user(s) to lookup.");
|
||||
phrases.put(Phrase.HELP_USER_2, "Examples: [u:Notch], [u:Notch,#enderman]");
|
||||
phrases.put(Phrase.INCOMPATIBLE_ACTION, "\"{0}\" can't be used with that action.");
|
||||
phrases.put(Phrase.INSPECTOR_ERROR, "Inspector already {enabled|disabled}.");
|
||||
phrases.put(Phrase.INSPECTOR_TOGGLED, "Inspector now {enabled|disabled}.");
|
||||
phrases.put(Phrase.INTEGRATION_ERROR, "Unable to {initialize|disable} {0} logging.");
|
||||
phrases.put(Phrase.INTEGRATION_SUCCESS, "{0} logging successfully {initialized|disabled}.");
|
||||
phrases.put(Phrase.INTEGRATION_VERSION, "Invalid {0} version found.");
|
||||
phrases.put(Phrase.INTERACTIONS_HEADER, "Player Interactions");
|
||||
phrases.put(Phrase.INVALID_ACTION, "That is not a valid action.");
|
||||
phrases.put(Phrase.INVALID_BRANCH_1, "Invalid plugin version (branch has not been set).");
|
||||
phrases.put(Phrase.INVALID_BRANCH_2, "To continue, set project branch to \"development\".");
|
||||
phrases.put(Phrase.INVALID_BRANCH_3, "Running development code may result in data corruption.");
|
||||
phrases.put(Phrase.INVALID_CONTAINER, "Please inspect a valid container first.");
|
||||
phrases.put(Phrase.INVALID_DONATION_KEY, "Invalid donation key.");
|
||||
phrases.put(Phrase.INVALID_INCLUDE, "\"{0}\" is an invalid block/entity name.");
|
||||
phrases.put(Phrase.INVALID_INCLUDE_COMBO, "That is an invalid block/entity combination.");
|
||||
phrases.put(Phrase.INVALID_RADIUS, "Please enter a valid radius.");
|
||||
phrases.put(Phrase.INVALID_SELECTION, "{0} selection not found.");
|
||||
phrases.put(Phrase.INVALID_USERNAME, "\"{0}\" is an invalid username.");
|
||||
phrases.put(Phrase.INVALID_WORLD, "Please specify a valid world.");
|
||||
phrases.put(Phrase.LATEST_VERSION, "Latest Version: {0}");
|
||||
phrases.put(Phrase.LINK_DISCORD, "Discord: {0}");
|
||||
phrases.put(Phrase.LINK_DOWNLOAD, "Download: {0}");
|
||||
phrases.put(Phrase.LINK_PATREON, "Patreon: {0}");
|
||||
phrases.put(Phrase.LINK_WIKI_BLOCK, "Block Names: {0}");
|
||||
phrases.put(Phrase.LINK_WIKI_ENTITY, "Entity Names: {0}");
|
||||
phrases.put(Phrase.LOGGING_ITEMS, "{0} items left to log. Please wait...");
|
||||
phrases.put(Phrase.LOGGING_TIME_LIMIT, "Logging time limit reached. Discarding data and shutting down.");
|
||||
phrases.put(Phrase.LOOKUP_BLOCK, "{0} {placed|broke} {1}.");
|
||||
phrases.put(Phrase.LOOKUP_CONTAINER, "{0} {added|removed} {1} {2}.");
|
||||
phrases.put(Phrase.LOOKUP_HEADER, "{0} Lookup Results");
|
||||
phrases.put(Phrase.LOOKUP_INTERACTION, "{0} {clicked|killed} {1}.");
|
||||
phrases.put(Phrase.LOOKUP_ITEM, "{0} {picked up|dropped} {1} {2}.");
|
||||
phrases.put(Phrase.LOOKUP_LOGIN, "{0} logged {in|out}.");
|
||||
phrases.put(Phrase.LOOKUP_PAGE, "Page {0}");
|
||||
phrases.put(Phrase.LOOKUP_ROWS_FOUND, "{0} {row|rows} found.");
|
||||
phrases.put(Phrase.LOOKUP_SEARCHING, "Lookup searching. Please wait...");
|
||||
phrases.put(Phrase.LOOKUP_STORAGE, "{0} {deposited|withdrew} {1} {2}.");
|
||||
phrases.put(Phrase.LOOKUP_TIME, "{0} ago");
|
||||
phrases.put(Phrase.LOOKUP_USERNAME, "{0} logged in as {1}.");
|
||||
phrases.put(Phrase.LOOKUP_VIEW_PAGE, "To view a page, type \"{0}\".");
|
||||
phrases.put(Phrase.MAXIMUM_RADIUS, "The maximum {lookup|rollback|restore} radius is {0}.");
|
||||
phrases.put(Phrase.MISSING_ACTION_USER, "To use that action, please specify a user.");
|
||||
phrases.put(Phrase.MISSING_LOOKUP_TIME, "Please specify the amount of time to {lookup|rollback|restore}.");
|
||||
phrases.put(Phrase.MISSING_LOOKUP_USER, "Please specify a user or {block|radius} to lookup.");
|
||||
phrases.put(Phrase.MISSING_PARAMETERS, "Please use \"{0}\".");
|
||||
phrases.put(Phrase.MISSING_ROLLBACK_RADIUS, "You did not specify a {rollback|restore} radius.");
|
||||
phrases.put(Phrase.MISSING_ROLLBACK_USER, "You did not specify a {rollback|restore} user.");
|
||||
phrases.put(Phrase.MYSQL_UNAVAILABLE, "Unable to connect to MySQL server.");
|
||||
phrases.put(Phrase.NO_DATA, "No data found at {0}.");
|
||||
phrases.put(Phrase.NO_DATA_LOCATION, "No {data|transactions|interactions|messages} found at this location.");
|
||||
phrases.put(Phrase.NO_PERMISSION, "You do not have permission to do that.");
|
||||
phrases.put(Phrase.NO_RESULTS, "No results found.");
|
||||
phrases.put(Phrase.NO_RESULTS_PAGE, "No {results|data} found for that page.");
|
||||
phrases.put(Phrase.NO_ROLLBACK, "No {pending|previous} rollback/restore found.");
|
||||
phrases.put(Phrase.PATCH_INTERRUPTED, "Upgrade interrupted. Will try again on restart.");
|
||||
phrases.put(Phrase.PATCH_OUTDATED_1, "Unable to upgrade databases older than {0}.");
|
||||
phrases.put(Phrase.PATCH_OUTDATED_2, "Please upgrade with a supported version of CoreProtect.");
|
||||
phrases.put(Phrase.PATCH_PROCESSING, "Processing new data. Please wait...");
|
||||
phrases.put(Phrase.PATCH_SKIP_UPDATE, "Skipping {table|index} {update|creation|removal} on {0}.");
|
||||
phrases.put(Phrase.PATCH_STARTED, "Performing {0} upgrade. Please wait...");
|
||||
phrases.put(Phrase.PATCH_SUCCESS, "Successfully upgraded to {0}.");
|
||||
phrases.put(Phrase.PATCH_UPGRADING, "Database upgrade in progress. Please wait...");
|
||||
phrases.put(Phrase.PLEASE_SELECT, "Please select: \"{0}\" or \"{1}\".");
|
||||
phrases.put(Phrase.PREVIEW_CANCELLED, "Preview cancelled.");
|
||||
phrases.put(Phrase.PREVIEW_CANCELLING, "Cancelling preview...");
|
||||
phrases.put(Phrase.PREVIEW_CONTAINER, "You can't preview container transactions.");
|
||||
phrases.put(Phrase.PREVIEW_IN_GAME, "You can only preview rollbacks in-game.");
|
||||
phrases.put(Phrase.PURGE_ABORTED, "Purge failed. Database may be corrupt.");
|
||||
phrases.put(Phrase.PURGE_ERROR, "Unable to process {0} data!");
|
||||
phrases.put(Phrase.PURGE_FAILED, "Purge failed. Please try again later.");
|
||||
phrases.put(Phrase.PURGE_IN_PROGRESS, "Purge in progress. Please try again later.");
|
||||
phrases.put(Phrase.PURGE_MINIMUM_TIME, "You can only purge data older than {0} {days|hours}.");
|
||||
phrases.put(Phrase.PURGE_NOTICE_1, "Please note that this may take some time.");
|
||||
phrases.put(Phrase.PURGE_NOTICE_2, "Do not restart your server until completed.");
|
||||
phrases.put(Phrase.PURGE_OPTIMIZING, "Optimizing database. Please wait...");
|
||||
phrases.put(Phrase.PURGE_PROCESSING, "Processing {0} data...");
|
||||
phrases.put(Phrase.PURGE_REPAIRING, "Attempting to repair. This may take some time...");
|
||||
phrases.put(Phrase.PURGE_ROWS, "{0} {row|rows} of data deleted.");
|
||||
phrases.put(Phrase.PURGE_STARTED, "Data purge started on \"{0}\".");
|
||||
phrases.put(Phrase.PURGE_SUCCESS, "Data purge successful.");
|
||||
phrases.put(Phrase.RELOAD_STARTED, "Reloading configuration - please wait.");
|
||||
phrases.put(Phrase.RELOAD_SUCCESS, "Configuration successfully reloaded.");
|
||||
phrases.put(Phrase.ROLLBACK_ABORTED, "Rollback or restore aborted.");
|
||||
phrases.put(Phrase.ROLLBACK_CHUNKS_FOUND, "Found {0} {chunk|chunks} to modify.");
|
||||
phrases.put(Phrase.ROLLBACK_CHUNKS_MODIFIED, "Modified {0}/{1} {chunk|chunks}.");
|
||||
phrases.put(Phrase.ROLLBACK_COMPLETED, "{Rollback|Restore|Preview} completed for \"{0}\".");
|
||||
phrases.put(Phrase.ROLLBACK_EXCLUDED_USERS, "Excluded {user|users}: \"{0}\".");
|
||||
phrases.put(Phrase.ROLLBACK_INCLUDE, "{Included|Excluded} {block|entity|target} {type|types}: \"{0}\".");
|
||||
phrases.put(Phrase.ROLLBACK_IN_PROGRESS, "A rollback/restore is already in progress.");
|
||||
phrases.put(Phrase.ROLLBACK_LENGTH, "Time taken: {0} {second|seconds}.");
|
||||
phrases.put(Phrase.ROLLBACK_MODIFIED, "{Modified|Modifying} {0}.");
|
||||
phrases.put(Phrase.ROLLBACK_RADIUS, "Radius: {0} {block|blocks}.");
|
||||
phrases.put(Phrase.ROLLBACK_SELECTION, "Radius set to \"{0}\".");
|
||||
phrases.put(Phrase.ROLLBACK_STARTED, "{Rollback|Restore|Preview} started on \"{0}\".");
|
||||
phrases.put(Phrase.ROLLBACK_TIME, "Time range: {0}.");
|
||||
phrases.put(Phrase.ROLLBACK_WORLD_ACTION, "Restricted to {world|action} \"{0}\".");
|
||||
phrases.put(Phrase.SIGN_HEADER, "Sign Messages");
|
||||
phrases.put(Phrase.STATUS_CONSUMER, "Consumer: {0} {item|items} in queue.");
|
||||
phrases.put(Phrase.STATUS_DATABASE, "Database: Using {0}.");
|
||||
phrases.put(Phrase.STATUS_INTEGRATION, "{0}: Integration {enabled|disabled}.");
|
||||
phrases.put(Phrase.STATUS_LICENSE, "License: {0}");
|
||||
phrases.put(Phrase.STATUS_VERSION, "Version: {0}");
|
||||
phrases.put(Phrase.TELEPORTED, "Teleported to {0}.");
|
||||
phrases.put(Phrase.TELEPORTED_SAFETY, "Teleported you to safety.");
|
||||
phrases.put(Phrase.TELEPORT_PLAYERS, "Teleport command can only be used by players.");
|
||||
phrases.put(Phrase.TIME_DAYS, "{0} {day|days}");
|
||||
phrases.put(Phrase.TIME_HOURS, "{0} {hour|hours}");
|
||||
phrases.put(Phrase.TIME_MINUTES, "{0} {minute|minutes}");
|
||||
phrases.put(Phrase.TIME_SECONDS, "{0} {second|seconds}");
|
||||
phrases.put(Phrase.TIME_WEEKS, "{0} {week|weeks}");
|
||||
phrases.put(Phrase.UPDATE_ERROR, "An error occurred while checking for updates.");
|
||||
phrases.put(Phrase.UPDATE_HEADER, "{0} Update");
|
||||
phrases.put(Phrase.UPDATE_NOTICE, "Notice: {0} is now available.");
|
||||
phrases.put(Phrase.UPGRADE_IN_PROGRESS, "Upgrade in progress. Please try again later.");
|
||||
phrases.put(Phrase.USER_NOT_FOUND, "User \"{0}\" not found.");
|
||||
phrases.put(Phrase.USING_MYSQL, "Using MySQL for data storage.");
|
||||
phrases.put(Phrase.USING_SQLITE, "Using SQLite for data storage.");
|
||||
phrases.put(Phrase.VALID_DONATION_KEY, "Valid donation key.");
|
||||
phrases.put(Phrase.VERSION_NOTICE, "Version {0} is now available.");
|
||||
phrases.put(Phrase.VERSION_REQUIRED, "{0} {1} or higher is required.");
|
||||
phrases.put(Phrase.WORLD_NOT_FOUND, "World \"{0}\" not found.");
|
||||
|
||||
userPhrases.putAll(phrases);
|
||||
translatedPhrases.putAll(phrases);
|
||||
}
|
||||
|
||||
}
|
||||
286
src/main/java/net/coreprotect/language/Phrase.java
Normal file
286
src/main/java/net/coreprotect/language/Phrase.java
Normal file
|
|
@ -0,0 +1,286 @@
|
|||
package net.coreprotect.language;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.coreprotect.utility.ChatMessage;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public enum Phrase {
|
||||
|
||||
ACTION_NOT_SUPPORTED,
|
||||
AMOUNT_BLOCK,
|
||||
AMOUNT_CHUNK,
|
||||
AMOUNT_ENTITY,
|
||||
AMOUNT_ITEM,
|
||||
API_TEST,
|
||||
CACHE_ERROR,
|
||||
CACHE_RELOAD,
|
||||
CHECK_CONFIG,
|
||||
COMMAND_NOT_FOUND,
|
||||
COMMAND_THROTTLED,
|
||||
CONTAINER_HEADER,
|
||||
DATABASE_BUSY,
|
||||
DATABASE_INDEX_ERROR,
|
||||
DATABASE_LOCKED_1,
|
||||
DATABASE_LOCKED_2,
|
||||
DATABASE_LOCKED_3,
|
||||
DATABASE_LOCKED_4,
|
||||
DATABASE_UNREACHABLE,
|
||||
DEVELOPMENT_BRANCH,
|
||||
DIRT_BLOCK,
|
||||
DISABLE_SUCCESS,
|
||||
ENABLE_FAILED,
|
||||
ENABLE_SUCCESS,
|
||||
ENJOY_COREPROTECT,
|
||||
FINISHING_CONVERSION,
|
||||
FINISHING_LOGGING,
|
||||
FIRST_VERSION,
|
||||
GLOBAL_LOOKUP,
|
||||
GLOBAL_ROLLBACK,
|
||||
HELP_ACTION_1,
|
||||
HELP_ACTION_2,
|
||||
HELP_COMMAND,
|
||||
HELP_EXCLUDE_1,
|
||||
HELP_EXCLUDE_2,
|
||||
HELP_HEADER,
|
||||
HELP_INCLUDE_1,
|
||||
HELP_INCLUDE_2,
|
||||
HELP_INSPECT_1,
|
||||
HELP_INSPECT_2,
|
||||
HELP_INSPECT_3,
|
||||
HELP_INSPECT_4,
|
||||
HELP_INSPECT_5,
|
||||
HELP_INSPECT_6,
|
||||
HELP_INSPECT_7,
|
||||
HELP_INSPECT_COMMAND,
|
||||
HELP_LIST,
|
||||
HELP_LOOKUP_1,
|
||||
HELP_LOOKUP_2,
|
||||
HELP_LOOKUP_COMMAND,
|
||||
HELP_NO_INFO,
|
||||
HELP_PARAMETER,
|
||||
HELP_PARAMS_1,
|
||||
HELP_PARAMS_2,
|
||||
HELP_PARAMS_3,
|
||||
HELP_PARAMS_4,
|
||||
HELP_PARAMS_5,
|
||||
HELP_PARAMS_6,
|
||||
HELP_PARAMS_7,
|
||||
HELP_PURGE_1,
|
||||
HELP_PURGE_2,
|
||||
HELP_PURGE_COMMAND,
|
||||
HELP_RADIUS_1,
|
||||
HELP_RADIUS_2,
|
||||
HELP_RELOAD_COMMAND,
|
||||
HELP_RESTORE_COMMAND,
|
||||
HELP_ROLLBACK_COMMAND,
|
||||
HELP_STATUS,
|
||||
HELP_STATUS_COMMAND,
|
||||
HELP_TELEPORT,
|
||||
HELP_TIME_1,
|
||||
HELP_TIME_2,
|
||||
HELP_USER_1,
|
||||
HELP_USER_2,
|
||||
INCOMPATIBLE_ACTION,
|
||||
INSPECTOR_ERROR,
|
||||
INSPECTOR_TOGGLED,
|
||||
INTEGRATION_ERROR,
|
||||
INTEGRATION_SUCCESS,
|
||||
INTEGRATION_VERSION,
|
||||
INTERACTIONS_HEADER,
|
||||
INVALID_ACTION,
|
||||
INVALID_BRANCH_1,
|
||||
INVALID_BRANCH_2,
|
||||
INVALID_BRANCH_3,
|
||||
INVALID_CONTAINER,
|
||||
INVALID_DONATION_KEY,
|
||||
INVALID_INCLUDE,
|
||||
INVALID_INCLUDE_COMBO,
|
||||
INVALID_RADIUS,
|
||||
INVALID_SELECTION,
|
||||
INVALID_USERNAME,
|
||||
INVALID_WORLD,
|
||||
LATEST_VERSION,
|
||||
LINK_DISCORD,
|
||||
LINK_DOWNLOAD,
|
||||
LINK_PATREON,
|
||||
LINK_WIKI_BLOCK,
|
||||
LINK_WIKI_ENTITY,
|
||||
LOGGING_ITEMS,
|
||||
LOGGING_TIME_LIMIT,
|
||||
LOOKUP_BLOCK,
|
||||
LOOKUP_CONTAINER,
|
||||
LOOKUP_HEADER,
|
||||
LOOKUP_INTERACTION,
|
||||
LOOKUP_ITEM,
|
||||
LOOKUP_LOGIN,
|
||||
LOOKUP_PAGE,
|
||||
LOOKUP_ROWS_FOUND,
|
||||
LOOKUP_SEARCHING,
|
||||
LOOKUP_STORAGE,
|
||||
LOOKUP_TIME,
|
||||
LOOKUP_USERNAME,
|
||||
LOOKUP_VIEW_PAGE,
|
||||
MAXIMUM_RADIUS,
|
||||
MISSING_ACTION_USER,
|
||||
MISSING_LOOKUP_TIME,
|
||||
MISSING_LOOKUP_USER,
|
||||
MISSING_PARAMETERS,
|
||||
MISSING_ROLLBACK_RADIUS,
|
||||
MISSING_ROLLBACK_USER,
|
||||
MYSQL_UNAVAILABLE,
|
||||
NO_DATA,
|
||||
NO_DATA_LOCATION,
|
||||
NO_PERMISSION,
|
||||
NO_RESULTS,
|
||||
NO_RESULTS_PAGE,
|
||||
NO_ROLLBACK,
|
||||
PATCH_INTERRUPTED,
|
||||
PATCH_OUTDATED_1,
|
||||
PATCH_OUTDATED_2,
|
||||
PATCH_PROCESSING,
|
||||
PATCH_SKIP_UPDATE,
|
||||
PATCH_STARTED,
|
||||
PATCH_SUCCESS,
|
||||
PATCH_UPGRADING,
|
||||
PLEASE_SELECT,
|
||||
PREVIEW_CANCELLED,
|
||||
PREVIEW_CANCELLING,
|
||||
PREVIEW_CONTAINER,
|
||||
PREVIEW_IN_GAME,
|
||||
PURGE_ABORTED,
|
||||
PURGE_ERROR,
|
||||
PURGE_FAILED,
|
||||
PURGE_IN_PROGRESS,
|
||||
PURGE_MINIMUM_TIME,
|
||||
PURGE_NOTICE_1,
|
||||
PURGE_NOTICE_2,
|
||||
PURGE_OPTIMIZING,
|
||||
PURGE_PROCESSING,
|
||||
PURGE_REPAIRING,
|
||||
PURGE_ROWS,
|
||||
PURGE_STARTED,
|
||||
PURGE_SUCCESS,
|
||||
RELOAD_STARTED,
|
||||
RELOAD_SUCCESS,
|
||||
ROLLBACK_ABORTED,
|
||||
ROLLBACK_CHUNKS_FOUND,
|
||||
ROLLBACK_CHUNKS_MODIFIED,
|
||||
ROLLBACK_COMPLETED,
|
||||
ROLLBACK_EXCLUDED_USERS,
|
||||
ROLLBACK_INCLUDE,
|
||||
ROLLBACK_IN_PROGRESS,
|
||||
ROLLBACK_LENGTH,
|
||||
ROLLBACK_MODIFIED,
|
||||
ROLLBACK_RADIUS,
|
||||
ROLLBACK_SELECTION,
|
||||
ROLLBACK_STARTED,
|
||||
ROLLBACK_TIME,
|
||||
ROLLBACK_WORLD_ACTION,
|
||||
SIGN_HEADER,
|
||||
STATUS_CONSUMER,
|
||||
STATUS_DATABASE,
|
||||
STATUS_INTEGRATION,
|
||||
STATUS_LICENSE,
|
||||
STATUS_VERSION,
|
||||
TELEPORTED,
|
||||
TELEPORTED_SAFETY,
|
||||
TELEPORT_PLAYERS,
|
||||
TIME_DAYS,
|
||||
TIME_HOURS,
|
||||
TIME_MINUTES,
|
||||
TIME_SECONDS,
|
||||
TIME_WEEKS,
|
||||
UPDATE_ERROR,
|
||||
UPDATE_HEADER,
|
||||
UPDATE_NOTICE,
|
||||
UPGRADE_IN_PROGRESS,
|
||||
USER_NOT_FOUND,
|
||||
USING_MYSQL,
|
||||
USING_SQLITE,
|
||||
VALID_DONATION_KEY,
|
||||
VERSION_NOTICE,
|
||||
VERSION_REQUIRED,
|
||||
WORLD_NOT_FOUND;
|
||||
|
||||
final private static Set<Phrase> HEADERS = new HashSet<>(Arrays.asList(Phrase.CONTAINER_HEADER, Phrase.HELP_HEADER, Phrase.INTERACTIONS_HEADER, Phrase.LOOKUP_HEADER, Phrase.SIGN_HEADER, Phrase.UPDATE_HEADER));
|
||||
final private static Set<String> COLORS = new HashSet<>(Arrays.asList(Color.WHITE, Color.DARK_AQUA));
|
||||
final private static String split = ":";
|
||||
|
||||
public String getPhrase() {
|
||||
return Language.getPhrase(this);
|
||||
}
|
||||
|
||||
public String getUserPhrase() {
|
||||
return Language.getUserPhrase(this);
|
||||
}
|
||||
|
||||
public String getTranslatedPhrase() {
|
||||
return Language.getTranslatedPhrase(this);
|
||||
}
|
||||
|
||||
public static String build(Phrase phrase, String... params) {
|
||||
String output = phrase.getTranslatedPhrase();
|
||||
String color = "";
|
||||
|
||||
if (HEADERS.contains(phrase)) {
|
||||
output = Util.capitalize(output, true);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
int indexExtra = 0;
|
||||
for (String param : params) {
|
||||
if (index == 0 && COLORS.contains(param)) {
|
||||
color = param;
|
||||
indexExtra++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Selector.SELECTORS.contains(param)) {
|
||||
output = Selector.processSelection(output, param, color);
|
||||
indexExtra++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (output.contains("{" + index + "}")) {
|
||||
output = output.replace("{" + index + "}", param);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
if ((index + indexExtra) != params.length) { // fallback for issues with user modified phrases
|
||||
// System.out.println("buildInternal"); // debug
|
||||
output = buildInternal(phrase, params, color);
|
||||
}
|
||||
|
||||
if (color.length() > 0) {
|
||||
output = output.replaceFirst(split, split + color);
|
||||
output = ChatMessage.parseQuotes(output, color);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
private static String buildInternal(Phrase phrase, String[] params, String color) {
|
||||
String output = phrase.getPhrase(); // get internal phrase
|
||||
|
||||
int index = 0;
|
||||
for (String param : params) {
|
||||
if (index == 0 && COLORS.contains(param)) {
|
||||
continue;
|
||||
}
|
||||
if (Selector.SELECTORS.contains(param)) {
|
||||
output = Selector.processSelection(output, param, color);
|
||||
continue;
|
||||
}
|
||||
output = output.replace("{" + index + "}", param);
|
||||
index++;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
60
src/main/java/net/coreprotect/language/Selector.java
Normal file
60
src/main/java/net/coreprotect/language/Selector.java
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
package net.coreprotect.language;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.coreprotect.utility.Color;
|
||||
|
||||
public class Selector {
|
||||
|
||||
final public static String FIRST = "{1}";
|
||||
final public static String SECOND = "{2}";
|
||||
final public static String THIRD = "{3}";
|
||||
final public static String FOURTH = "{4}";
|
||||
|
||||
final protected static Set<String> SELECTORS = new HashSet<>(Arrays.asList(Selector.FIRST, Selector.SECOND, Selector.THIRD, Selector.FOURTH));
|
||||
|
||||
protected static String processSelection(String output, String param, String color) {
|
||||
String substring = output;
|
||||
try {
|
||||
substring = substring.substring(substring.indexOf("{") + 1);
|
||||
substring = substring.substring(0, substring.indexOf("}"));
|
||||
}
|
||||
catch (Exception e) {
|
||||
substring = "";
|
||||
}
|
||||
|
||||
if (substring.contains("|")) {
|
||||
int selector = Integer.parseInt(param.substring(1, 2)) - 1;
|
||||
int index = substring(substring, "|", selector);
|
||||
if (index == -1) {
|
||||
param = substring.substring(0, substring.indexOf("|"));
|
||||
}
|
||||
else {
|
||||
param = substring.substring(index + 1, (substring.lastIndexOf("|") > index ? substring(substring, "|", selector + 1) : substring.length()));
|
||||
}
|
||||
|
||||
output = output.replace("{" + substring + "}", color + param + (color.length() > 0 ? Color.WHITE : color));
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
private static int substring(String string, String search, int index) {
|
||||
int result = string.indexOf("|");
|
||||
if (result == -1 || index == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int i = 1; i < index; i++) {
|
||||
result = string.indexOf("|", result + 1);
|
||||
if (result == -1) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue