Adds a Message enum to avoid string keys
This commit is contained in:
@@ -4,6 +4,7 @@ import net.knarcraft.knarlib.util.UpdateChecker;
|
||||
import net.knarcraft.stargate.command.CommandStarGate;
|
||||
import net.knarcraft.stargate.command.StarGateTabCompleter;
|
||||
import net.knarcraft.stargate.config.EconomyConfig;
|
||||
import net.knarcraft.stargate.config.Message;
|
||||
import net.knarcraft.stargate.config.MessageSender;
|
||||
import net.knarcraft.stargate.config.StargateConfig;
|
||||
import net.knarcraft.stargate.config.StargateGateConfig;
|
||||
@@ -298,26 +299,22 @@ public class Stargate extends JavaPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a translated string given its string key
|
||||
*
|
||||
* <p>The name/key is the string before the equals sign in the language files</p>
|
||||
* Gets a translated string given its message key
|
||||
*
|
||||
* @param name <p>The name/key of the string to get</p>
|
||||
* @return <p>The full translated string</p>
|
||||
*/
|
||||
public static @NotNull String getString(@NotNull String name) {
|
||||
public static @NotNull String getString(@NotNull Message name) {
|
||||
return stargateConfig.getLanguageLoader().getString(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a backup string given its string key
|
||||
*
|
||||
* <p>The name/key is the string before the equals sign in the language files</p>
|
||||
* Gets a backup string given its message key
|
||||
*
|
||||
* @param name <p>The name/key of the string to get</p>
|
||||
* @return <p>The full string in the backup language (English)</p>
|
||||
*/
|
||||
public static @NotNull String getBackupString(@NotNull String name) {
|
||||
public static @NotNull String getBackupString(@NotNull Message name) {
|
||||
return stargateConfig.getLanguageLoader().getBackupString(name);
|
||||
}
|
||||
|
||||
|
@@ -2,6 +2,7 @@ package net.knarcraft.stargate.command;
|
||||
|
||||
import de.themoep.minedown.MineDown;
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.config.Message;
|
||||
import net.knarcraft.stargate.utility.FileHelper;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
@@ -34,7 +35,7 @@ public class CommandAbout implements CommandExecutor {
|
||||
} catch (IOException ioException) {
|
||||
commandSender.sendMessage("Internal error");
|
||||
}
|
||||
String author = Stargate.getStargateConfig().getLanguageLoader().getString("author");
|
||||
String author = Stargate.getStargateConfig().getLanguageLoader().getString(Message.AUTHOR);
|
||||
if (!author.isEmpty()) {
|
||||
commandSender.sendMessage(textColor + "Language created by " + highlightColor + author);
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.config.ConfigOption;
|
||||
import net.knarcraft.stargate.config.ConfigTag;
|
||||
import net.knarcraft.stargate.config.DynmapManager;
|
||||
import net.knarcraft.stargate.config.Message;
|
||||
import net.knarcraft.stargate.config.OptionDataType;
|
||||
import net.knarcraft.stargate.portal.Portal;
|
||||
import net.knarcraft.stargate.portal.PortalRegistry;
|
||||
@@ -418,7 +419,7 @@ public class CommandConfig implements CommandExecutor {
|
||||
* @param sender <p>The command sender to display the config list to</p>
|
||||
*/
|
||||
private void displayConfigValues(@NotNull CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.GREEN + Stargate.getBackupString("prefix") + ChatColor.GOLD +
|
||||
sender.sendMessage(ChatColor.GREEN + Stargate.getBackupString(Message.PREFIX) + ChatColor.GOLD +
|
||||
"Config values:");
|
||||
for (ConfigOption option : ConfigOption.values()) {
|
||||
sender.sendMessage(getOptionDescription(option));
|
||||
|
@@ -192,10 +192,10 @@ public final class EconomyConfig {
|
||||
this.vault = vault;
|
||||
return true;
|
||||
} else {
|
||||
Stargate.logInfo(Stargate.getString("ecoLoadError"));
|
||||
Stargate.logInfo(Stargate.getString(Message.ECONOMY_LOAD_ERROR));
|
||||
}
|
||||
} else {
|
||||
Stargate.logInfo(Stargate.getString("vaultLoadError"));
|
||||
Stargate.logInfo(Stargate.getString(Message.VAULT_LOAD_ERROR));
|
||||
}
|
||||
configOptions.put(ConfigOption.USE_ECONOMY, false);
|
||||
return false;
|
||||
|
@@ -21,9 +21,9 @@ import java.util.Set;
|
||||
public final class LanguageLoader {
|
||||
|
||||
private final String languageFolder;
|
||||
private final Map<String, String> loadedBackupStrings;
|
||||
private final Map<Message, String> loadedBackupStrings;
|
||||
private String chosenLanguage;
|
||||
private Map<String, String> loadedStringTranslations;
|
||||
private Map<Message, String> loadedStringTranslations;
|
||||
|
||||
/**
|
||||
* Instantiates a new language loader
|
||||
@@ -62,34 +62,34 @@ public final class LanguageLoader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string to display given its name/key
|
||||
* Gets the string to display given its message key
|
||||
*
|
||||
* @param name <p>The name/key of the string to display</p>
|
||||
* @return <p>The string in the user's preferred language</p>
|
||||
* @param message <p>The message to display</p>
|
||||
* @return <p>The message in the user's preferred language</p>
|
||||
*/
|
||||
@NotNull
|
||||
public String getString(@NotNull String name) {
|
||||
public String getString(@NotNull Message message) {
|
||||
String value = null;
|
||||
if (loadedStringTranslations != null) {
|
||||
value = loadedStringTranslations.get(name);
|
||||
value = loadedStringTranslations.get(message);
|
||||
}
|
||||
if (value == null) {
|
||||
value = getBackupString(name);
|
||||
value = getBackupString(message);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string to display given its name/key
|
||||
* Gets the string to display given its message key
|
||||
*
|
||||
* @param name <p>The name/key of the string to display</p>
|
||||
* @param message <p>The message to display</p>
|
||||
* @return <p>The string in the backup language (English)</p>
|
||||
*/
|
||||
@NotNull
|
||||
public String getBackupString(@NotNull String name) {
|
||||
public String getBackupString(@NotNull Message message) {
|
||||
String value = null;
|
||||
if (loadedBackupStrings != null) {
|
||||
value = loadedBackupStrings.get(name);
|
||||
value = loadedBackupStrings.get(message);
|
||||
}
|
||||
if (value == null) {
|
||||
return "";
|
||||
@@ -112,7 +112,7 @@ public final class LanguageLoader {
|
||||
* @param language <p>The language to update</p>
|
||||
*/
|
||||
private void updateLanguage(@NotNull String language) {
|
||||
Map<String, String> currentLanguageValues = load(language);
|
||||
Map<Message, String> currentLanguageValues = load(language);
|
||||
|
||||
InputStream inputStream = getClass().getResourceAsStream("/lang/" + language + ".txt");
|
||||
if (inputStream == null) {
|
||||
@@ -138,11 +138,11 @@ public final class LanguageLoader {
|
||||
* @throws IOException <p>if unable to read a language file</p>
|
||||
*/
|
||||
private void readChangedLanguageStrings(@NotNull InputStream inputStream, @NotNull String language,
|
||||
@Nullable Map<String, String> currentLanguageValues) throws IOException {
|
||||
@Nullable Map<Message, String> currentLanguageValues) throws IOException {
|
||||
//Get language values
|
||||
BufferedReader bufferedReader = FileHelper.getBufferedReaderFromInputStream(inputStream);
|
||||
Map<String, String> internalLanguageValues = FileHelper.readKeyValuePairs(bufferedReader, "=",
|
||||
ColorConversion.NORMAL);
|
||||
Map<Message, String> internalLanguageValues = fromStringMap(FileHelper.readKeyValuePairs(bufferedReader,
|
||||
"=", ColorConversion.NORMAL));
|
||||
|
||||
//If currentLanguageValues is null; the chosen language has not been used before
|
||||
if (currentLanguageValues == null) {
|
||||
@@ -153,9 +153,9 @@ public final class LanguageLoader {
|
||||
|
||||
//If a key is not found in the language file, add the one in the internal file. Must update the external file
|
||||
if (!internalLanguageValues.keySet().equals(currentLanguageValues.keySet())) {
|
||||
Map<String, String> newLanguageValues = new HashMap<>();
|
||||
Map<Message, String> newLanguageValues = new HashMap<>();
|
||||
boolean updateNecessary = false;
|
||||
for (String key : internalLanguageValues.keySet()) {
|
||||
for (Message key : internalLanguageValues.keySet()) {
|
||||
if (currentLanguageValues.get(key) == null) {
|
||||
newLanguageValues.put(key, internalLanguageValues.get(key));
|
||||
//Found at least one value in the internal file not in the external file. Need to update
|
||||
@@ -181,19 +181,19 @@ public final class LanguageLoader {
|
||||
* @param customLanguageStrings <p>Any custom language strings not recognized</p>
|
||||
* @throws IOException <p>If unable to write to the language file</p>
|
||||
*/
|
||||
private void updateLanguageFile(@NotNull String language, @NotNull Map<String, String> languageStrings,
|
||||
@Nullable Map<String, String> customLanguageStrings) throws IOException {
|
||||
private void updateLanguageFile(@NotNull String language, @NotNull Map<Message, String> languageStrings,
|
||||
@Nullable Map<Message, String> customLanguageStrings) throws IOException {
|
||||
BufferedWriter bufferedWriter = FileHelper.getBufferedWriterFromString(languageFolder + language + ".txt");
|
||||
|
||||
//Output normal Language data
|
||||
for (String key : languageStrings.keySet()) {
|
||||
for (Message key : languageStrings.keySet()) {
|
||||
bufferedWriter.write(key + "=" + languageStrings.get(key));
|
||||
bufferedWriter.newLine();
|
||||
}
|
||||
bufferedWriter.newLine();
|
||||
//Output any custom language strings the user had
|
||||
if (customLanguageStrings != null) {
|
||||
for (String key : customLanguageStrings.keySet()) {
|
||||
for (Message key : customLanguageStrings.keySet()) {
|
||||
bufferedWriter.write(key + "=" + customLanguageStrings.get(key));
|
||||
bufferedWriter.newLine();
|
||||
}
|
||||
@@ -207,8 +207,7 @@ public final class LanguageLoader {
|
||||
* @param lang <p>The language to load</p>
|
||||
* @return <p>A mapping between loaded string indexes and the strings to display</p>
|
||||
*/
|
||||
@Nullable
|
||||
private Map<String, String> load(@NotNull String lang) {
|
||||
private Map<Message, String> load(@NotNull String lang) {
|
||||
return load(lang, null);
|
||||
}
|
||||
|
||||
@@ -219,9 +218,7 @@ public final class LanguageLoader {
|
||||
* @param inputStream <p>An optional input stream to use. Defaults to using a file input stream</p>
|
||||
* @return <p>A mapping between loaded string indexes and the strings to display</p>
|
||||
*/
|
||||
@Nullable
|
||||
private Map<String, String> load(@NotNull String lang, @Nullable InputStream inputStream) {
|
||||
Map<String, String> strings;
|
||||
private Map<Message, String> load(@NotNull String lang, @Nullable InputStream inputStream) {
|
||||
BufferedReader bufferedReader;
|
||||
try {
|
||||
if (inputStream == null) {
|
||||
@@ -229,14 +226,13 @@ public final class LanguageLoader {
|
||||
} else {
|
||||
bufferedReader = FileHelper.getBufferedReaderFromInputStream(inputStream);
|
||||
}
|
||||
strings = FileHelper.readKeyValuePairs(bufferedReader, "=", ColorConversion.NORMAL);
|
||||
return fromStringMap(FileHelper.readKeyValuePairs(bufferedReader, "=", ColorConversion.NORMAL));
|
||||
} catch (Exception exception) {
|
||||
if (Stargate.getStargateConfig().isDebuggingEnabled()) {
|
||||
Stargate.logInfo("Unable to load language " + lang);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return strings;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,8 +240,8 @@ public final class LanguageLoader {
|
||||
*/
|
||||
public void debug() {
|
||||
if (loadedStringTranslations != null) {
|
||||
Set<String> keys = loadedStringTranslations.keySet();
|
||||
for (String key : keys) {
|
||||
Set<Message> keys = loadedStringTranslations.keySet();
|
||||
for (Message key : keys) {
|
||||
Stargate.debug("LanguageLoader::Debug::loadedStringTranslations", key + " => " +
|
||||
loadedStringTranslations.get(key));
|
||||
}
|
||||
@@ -253,11 +249,27 @@ public final class LanguageLoader {
|
||||
if (loadedBackupStrings == null) {
|
||||
return;
|
||||
}
|
||||
Set<String> keys = loadedBackupStrings.keySet();
|
||||
for (String key : keys) {
|
||||
Set<Message> keys = loadedBackupStrings.keySet();
|
||||
for (Message key : keys) {
|
||||
Stargate.debug("LanguageLoader::Debug::loadedBackupStrings", key + " => " +
|
||||
loadedBackupStrings.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Map<Message, String> fromStringMap(@NotNull Map<String, String> configurationStrings) {
|
||||
Map<Message, String> output = new HashMap<>();
|
||||
for (Map.Entry<String, String> entry : configurationStrings.entrySet()) {
|
||||
Message message = Message.getFromKey(entry.getKey());
|
||||
if (message == null) {
|
||||
Stargate.logWarning("Found unrecognized language key " + entry.getKey());
|
||||
continue;
|
||||
}
|
||||
|
||||
output.put(message, entry.getValue());
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
|
251
src/main/java/net/knarcraft/stargate/config/Message.java
Normal file
251
src/main/java/net/knarcraft/stargate/config/Message.java
Normal file
@@ -0,0 +1,251 @@
|
||||
package net.knarcraft.stargate.config;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Translated messages displayed to players
|
||||
*/
|
||||
public enum Message {
|
||||
|
||||
/**
|
||||
* The prefix displayed in front of all messages shown in the chat
|
||||
*/
|
||||
PREFIX("prefix"),
|
||||
|
||||
/**
|
||||
* The message displayed when a player is teleported
|
||||
*/
|
||||
TELEPORTED("teleportMsg"),
|
||||
|
||||
/**
|
||||
* The message displayed when a player destroys a Stargate
|
||||
*/
|
||||
DESTROYED("destroyMsg"),
|
||||
|
||||
/**
|
||||
* The message displayed when the currently selected Stargate destination is invalid
|
||||
*/
|
||||
INVALID_DESTINATION("invalidMsg"),
|
||||
|
||||
/**
|
||||
* The message displayed when the destination portal is busy with another player
|
||||
*/
|
||||
DESTINATION_BLOCKED("blockMsg"),
|
||||
|
||||
/**
|
||||
* The message displayed when the Stargate has no destinations available to the player
|
||||
*/
|
||||
NO_DESTINATION("destEmpty"),
|
||||
|
||||
/**
|
||||
* The message displayed when a player is denied access to any action
|
||||
*/
|
||||
ACCESS_DENIED("denyMsg"),
|
||||
|
||||
/**
|
||||
* The message displayed when the plugin is reloaded
|
||||
*/
|
||||
RELOADED("reloaded"),
|
||||
|
||||
/**
|
||||
* The message displayed when a player has some currency deducted from their account
|
||||
*/
|
||||
ECONOMY_DEDUCTED("ecoDeduct"),
|
||||
|
||||
/**
|
||||
* The message displayed when a player has some currency refunded to their account
|
||||
*/
|
||||
ECONOMY_REFUNDED("ecoRefund"),
|
||||
|
||||
/**
|
||||
* The message displayed when a player obtains some currency to their account (from portal usage)
|
||||
*/
|
||||
ECONOMY_OBTAINED("ecoObtain"),
|
||||
|
||||
/**
|
||||
* The message displayed when the player has an insufficient amount of currency to perform an action
|
||||
*/
|
||||
ECONOMY_INSUFFICIENT("ecoInFunds"),
|
||||
|
||||
/**
|
||||
* The message displayed when economy fails to load
|
||||
*/
|
||||
ECONOMY_LOAD_ERROR("ecoLoadError"),
|
||||
|
||||
/**
|
||||
* The message displayed when Vault fails to load
|
||||
*/
|
||||
VAULT_LOAD_ERROR("vaultLoadError"),
|
||||
|
||||
/**
|
||||
* The message displayed when Vault successfully loads
|
||||
*/
|
||||
VAULT_LOADED("vaultLoaded"),
|
||||
|
||||
/**
|
||||
* The message displayed when a Stargate is successfully created
|
||||
*/
|
||||
CREATED("createMsg"),
|
||||
|
||||
/**
|
||||
* The message displayed when a player is denied from creating a Stargate on the selected network
|
||||
*/
|
||||
CREATION_NETWORK_DENIED("createNetDeny"),
|
||||
|
||||
/**
|
||||
* The message displayed when a player is denied from creating a Stargate of the given gate type
|
||||
*/
|
||||
CREATION_GATE_DENIED("createGateDeny"),
|
||||
|
||||
/**
|
||||
* The message displayed when a Stargate is created on the player's personal network
|
||||
*/
|
||||
CREATION_PERSONAL("createPersonal"),
|
||||
|
||||
/**
|
||||
* The message displayed when the name of a Stargate is too short or too long
|
||||
*/
|
||||
CREATION_NAME_LENGTH("createNameLength"),
|
||||
|
||||
/**
|
||||
* The message displayed when another Stargate on the network has the same name as the new Stargate
|
||||
*/
|
||||
CREATION_NAME_COLLISION("createExists"),
|
||||
|
||||
/**
|
||||
* The message displayed when the specified network is full
|
||||
*/
|
||||
CREATION_NETWORK_FULL("createFull"),
|
||||
|
||||
/**
|
||||
* The message displayed when a player is denied from creating a Stargate in the current world
|
||||
*/
|
||||
CREATION_WORLD_DENIED("createWorldDeny"),
|
||||
|
||||
/**
|
||||
* The message displayed when a gate is physically conflicting with another
|
||||
*/
|
||||
CREATION_CONFLICT("createConflict"),
|
||||
|
||||
/**
|
||||
* The right-click prompt displayed on Stargate signs
|
||||
*/
|
||||
SIGN_RIGHT_CLICK("signRightClick"),
|
||||
|
||||
/**
|
||||
* The to use prompt displayed on Stargate signs
|
||||
*/
|
||||
SIGN_TO_USE("signToUse"),
|
||||
|
||||
/**
|
||||
* The random string displayed on Stargate signs
|
||||
*/
|
||||
SIGN_RANDOM("signRandom"),
|
||||
|
||||
/**
|
||||
* The disconnected string displayed on Stargate signs
|
||||
*/
|
||||
SIGN_DISCONNECTED("signDisconnected"),
|
||||
|
||||
/**
|
||||
* The invalid gate string displayed on Stargate signs
|
||||
*/
|
||||
SIGN_INVALID("signInvalidGate"),
|
||||
|
||||
/**
|
||||
* The message displayed if trying to create a bungee gate when bungee is disabled
|
||||
*/
|
||||
BUNGEE_DISABLED("bungeeDisabled"),
|
||||
|
||||
/**
|
||||
* The message displayed when a player is denied from creating a bungee Stargate
|
||||
*/
|
||||
BUNGEE_CREATION_DENIED("bungeeDeny"),
|
||||
|
||||
/**
|
||||
* The message displayed if a Stargate is missing the destination, the network or both
|
||||
*/
|
||||
BUNGEE_MISSING_INFO("bungeeEmpty"),
|
||||
|
||||
/**
|
||||
* The teleportation prompt shown on bungee signs
|
||||
*/
|
||||
BUNGEE_SIGN("bungeeSign"),
|
||||
|
||||
/**
|
||||
* The format of the title of the portal info shown in chat
|
||||
*/
|
||||
PORTAL_INFO_TITLE("portalInfoTitle"),
|
||||
|
||||
/**
|
||||
* The format of the name of the portal info shown in chat
|
||||
*/
|
||||
PORTAL_INFO_NAME("portalInfoName"),
|
||||
|
||||
/**
|
||||
* The format of the destination of the portal info shown in chat
|
||||
*/
|
||||
PORTAL_INFO_DESTINATION("portalInfoDestination"),
|
||||
|
||||
/**
|
||||
* The format of the network of the portal info shown in chat
|
||||
*/
|
||||
PORTAL_INFO_NETWORK("portalInfoNetwork"),
|
||||
|
||||
/**
|
||||
* The format of the server of the portal info shown in chat
|
||||
*/
|
||||
PORTAL_INFO_SERVER("portalInfoServer"),
|
||||
|
||||
/**
|
||||
* The author that created the loaded translation
|
||||
*/
|
||||
AUTHOR("author"),
|
||||
;
|
||||
|
||||
private final String key;
|
||||
|
||||
/**
|
||||
* Instantiates a new message
|
||||
*
|
||||
* @param key <p>The key of the message in the language files</p>
|
||||
*/
|
||||
Message(@NotNull String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the language file key for this message
|
||||
*
|
||||
* @return <p>This message's key</p>
|
||||
*/
|
||||
@NotNull
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the message corresponding to the given key
|
||||
*
|
||||
* @param key <p>The key to get a message from</p>
|
||||
* @return <p>The message, or null if not found</p>
|
||||
*/
|
||||
@Nullable
|
||||
public static Message getFromKey(@NotNull String key) {
|
||||
for (Message message : Message.values()) {
|
||||
if (message.getKey().equalsIgnoreCase(key)) {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String toString() {
|
||||
return this.getKey();
|
||||
}
|
||||
|
||||
}
|
@@ -53,9 +53,9 @@ public final class MessageSender {
|
||||
}
|
||||
message = ChatColor.translateAlternateColorCodes('&', message);
|
||||
if (error) {
|
||||
sender.sendMessage(ChatColor.RED + languageLoader.getString("prefix") + ChatColor.WHITE + message);
|
||||
sender.sendMessage(ChatColor.RED + languageLoader.getString(Message.PREFIX) + ChatColor.WHITE + message);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GREEN + languageLoader.getString("prefix") + ChatColor.WHITE + message);
|
||||
sender.sendMessage(ChatColor.GREEN + languageLoader.getString(Message.PREFIX) + ChatColor.WHITE + message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -244,7 +244,7 @@ public final class StargateConfig {
|
||||
//Reload portal markers
|
||||
DynmapManager.addAllPortalMarkers();
|
||||
|
||||
messageSender.sendErrorMessage(sender, languageLoader.getString("reloaded"));
|
||||
messageSender.sendErrorMessage(sender, languageLoader.getString(Message.RELOADED));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -541,7 +541,7 @@ public final class StargateConfig {
|
||||
if (economyConfig.setupEconomy(Stargate.getPluginManager()) && economyConfig.getEconomy() != null &&
|
||||
economyConfig.getVault() != null) {
|
||||
String vaultVersion = economyConfig.getVault().getDescription().getVersion();
|
||||
Stargate.logInfo(Stargate.replacePlaceholders(Stargate.getString("vaultLoaded"), "%version%", vaultVersion));
|
||||
Stargate.logInfo(Stargate.replacePlaceholders(Stargate.getString(Message.VAULT_LOADED), "%version%", vaultVersion));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package net.knarcraft.stargate.listener;
|
||||
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.config.Message;
|
||||
import net.knarcraft.stargate.container.BlockChangeRequest;
|
||||
import net.knarcraft.stargate.container.BlockLocation;
|
||||
import net.knarcraft.stargate.event.StargateDestroyEvent;
|
||||
@@ -93,7 +94,7 @@ public class BlockEventListener implements Listener {
|
||||
Stargate.addBlockChangeRequest(request);
|
||||
}
|
||||
|
||||
Stargate.getMessageSender().sendSuccessMessage(player, Stargate.getString("createMsg"));
|
||||
Stargate.getMessageSender().sendSuccessMessage(player, Stargate.getString(Message.CREATED));
|
||||
Stargate.debug("onSignChange", "Initialized stargate: " + portal.getName());
|
||||
Stargate.getInstance().getServer().getScheduler().scheduleSyncDelayedTask(Stargate.getInstance(),
|
||||
portal::drawSign, 1);
|
||||
@@ -149,7 +150,7 @@ public class BlockEventListener implements Listener {
|
||||
|
||||
//Decide if the user can destroy the portal
|
||||
if (!PermissionHelper.canDestroyPortal(player, portal)) {
|
||||
denyMessage = Stargate.getString("denyMsg");
|
||||
denyMessage = Stargate.getString(Message.ACCESS_DENIED);
|
||||
deny = true;
|
||||
Stargate.logInfo(String.format("%s tried to destroy gate", player.getName()));
|
||||
}
|
||||
@@ -179,7 +180,7 @@ public class BlockEventListener implements Listener {
|
||||
}
|
||||
|
||||
PortalRegistry.unregisterPortal(portal, true);
|
||||
Stargate.getMessageSender().sendSuccessMessage(player, Stargate.getString("destroyMsg"));
|
||||
Stargate.getMessageSender().sendSuccessMessage(player, Stargate.getString(Message.DESTROYED));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2,6 +2,7 @@ package net.knarcraft.stargate.listener;
|
||||
|
||||
import net.knarcraft.knarlib.util.UpdateChecker;
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.config.Message;
|
||||
import net.knarcraft.stargate.config.MessageSender;
|
||||
import net.knarcraft.stargate.container.BlockLocation;
|
||||
import net.knarcraft.stargate.portal.Portal;
|
||||
@@ -154,7 +155,7 @@ public class PlayerEventListener implements Listener {
|
||||
new PlayerTeleporter(destination, player).teleportPlayer(entrancePortal, event);
|
||||
}
|
||||
if (!entrancePortal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendSuccessMessage(player, Stargate.getString("teleportMsg"));
|
||||
Stargate.getMessageSender().sendSuccessMessage(player, Stargate.getString(Message.TELEPORTED));
|
||||
}
|
||||
entrancePortal.getPortalOpener().closePortal(false);
|
||||
}
|
||||
@@ -202,7 +203,7 @@ public class PlayerEventListener implements Listener {
|
||||
//Decide if the user should be teleported to another bungee server
|
||||
if (entrancePortal.getOptions().isBungee()) {
|
||||
if (BungeeHelper.bungeeTeleport(player, entrancePortal, event) && !entrancePortal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendSuccessMessage(player, Stargate.getString("teleportMsg"));
|
||||
Stargate.getMessageSender().sendSuccessMessage(player, Stargate.getString(Message.TELEPORTED));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -306,7 +307,7 @@ public class PlayerEventListener implements Listener {
|
||||
|
||||
if (PermissionHelper.portalAccessDenied(player, portal, deny)) {
|
||||
if (!portal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.ACCESS_DENIED));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -378,16 +379,16 @@ public class PlayerEventListener implements Listener {
|
||||
//Display portal information as a portal without a sign does not display any
|
||||
if (portal.getOptions().hasNoSign() && (!portal.getOptions().isSilent() || player.isSneaking())) {
|
||||
MessageSender sender = Stargate.getMessageSender();
|
||||
sender.sendSuccessMessage(player, ChatColor.GOLD + Stargate.getString("portalInfoTitle"));
|
||||
sender.sendSuccessMessage(player, Stargate.replacePlaceholders(Stargate.getString("portalInfoName"),
|
||||
sender.sendSuccessMessage(player, ChatColor.GOLD + Stargate.getString(Message.PORTAL_INFO_TITLE));
|
||||
sender.sendSuccessMessage(player, Stargate.replacePlaceholders(Stargate.getString(Message.PORTAL_INFO_NAME),
|
||||
"%name%", portal.getName()));
|
||||
sender.sendSuccessMessage(player, Stargate.replacePlaceholders(Stargate.getString("portalInfoDestination"),
|
||||
sender.sendSuccessMessage(player, Stargate.replacePlaceholders(Stargate.getString(Message.PORTAL_INFO_DESTINATION),
|
||||
"%destination%", portal.getDestinationName()));
|
||||
if (portal.getOptions().isBungee()) {
|
||||
sender.sendSuccessMessage(player, Stargate.replacePlaceholders(Stargate.getString("portalInfoServer"),
|
||||
sender.sendSuccessMessage(player, Stargate.replacePlaceholders(Stargate.getString(Message.PORTAL_INFO_SERVER),
|
||||
"%server%", portal.getNetwork()));
|
||||
} else {
|
||||
sender.sendSuccessMessage(player, Stargate.replacePlaceholders(Stargate.getString("portalInfoNetwork"),
|
||||
sender.sendSuccessMessage(player, Stargate.replacePlaceholders(Stargate.getString(Message.PORTAL_INFO_NETWORK),
|
||||
"%network%", portal.getNetwork()));
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package net.knarcraft.stargate.listener;
|
||||
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.config.Message;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
@@ -38,7 +39,7 @@ public class PluginEventListener implements Listener {
|
||||
Plugin vault = Stargate.getEconomyConfig().getVault();
|
||||
if (vault != null) {
|
||||
String vaultVersion = vault.getDescription().getVersion();
|
||||
Stargate.logInfo(Stargate.replacePlaceholders(Stargate.getString("vaultLoaded"), "%version%",
|
||||
Stargate.logInfo(Stargate.replacePlaceholders(Stargate.getString(Message.VAULT_LOADED), "%version%",
|
||||
vaultVersion));
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package net.knarcraft.stargate.listener;
|
||||
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.config.Message;
|
||||
import net.knarcraft.stargate.portal.Portal;
|
||||
import net.knarcraft.stargate.portal.PortalHandler;
|
||||
import net.knarcraft.stargate.portal.teleporter.VehicleTeleporter;
|
||||
@@ -113,7 +114,7 @@ public class VehicleEventListener implements Listener {
|
||||
if (destinationPortal == null) {
|
||||
cancelTeleport = true;
|
||||
if (!entrancePortal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("invalidMsg"));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.INVALID_DESTINATION));
|
||||
}
|
||||
} else if (!TeleportHelper.playerCanTeleport(player, entrancePortal, destinationPortal)) {
|
||||
cancelTeleport = true;
|
||||
@@ -140,7 +141,7 @@ public class VehicleEventListener implements Listener {
|
||||
if (teleported) {
|
||||
if (!entrancePortal.getOptions().isSilent()) {
|
||||
for (Player player : players) {
|
||||
Stargate.getMessageSender().sendSuccessMessage(player, Stargate.getString("teleportMsg"));
|
||||
Stargate.getMessageSender().sendSuccessMessage(player, Stargate.getString(Message.TELEPORTED));
|
||||
}
|
||||
}
|
||||
entrancePortal.getPortalOpener().closePortal(false);
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package net.knarcraft.stargate.portal;
|
||||
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.config.Message;
|
||||
import net.knarcraft.stargate.event.StargateActivateEvent;
|
||||
import net.knarcraft.stargate.event.StargateDeactivateEvent;
|
||||
import net.knarcraft.stargate.utility.ListHelper;
|
||||
@@ -256,7 +257,7 @@ public class PortalActivator {
|
||||
//If no destinations are available, just tell the player and quit
|
||||
if (destinations.size() == 0) {
|
||||
if (!portal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("destEmpty"));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.NO_DESTINATION));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package net.knarcraft.stargate.portal;
|
||||
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.config.Message;
|
||||
import net.knarcraft.stargate.container.BlockLocation;
|
||||
import net.knarcraft.stargate.container.RelativeBlockVector;
|
||||
import net.knarcraft.stargate.event.StargateCreateEvent;
|
||||
@@ -130,11 +131,11 @@ public class PortalCreator {
|
||||
network = network.substring(0, getMaxNameNetworkLength());
|
||||
}
|
||||
Stargate.debug("createPortal", "Creating personal portal");
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("createPersonal"));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.CREATION_PERSONAL));
|
||||
} else {
|
||||
Stargate.debug("createPortal", "Player does not have access to network");
|
||||
deny = true;
|
||||
denyMessage = Stargate.getString("createNetDeny");
|
||||
denyMessage = Stargate.getString(Message.CREATION_NETWORK_DENIED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +145,7 @@ public class PortalCreator {
|
||||
if (!deny && !PermissionHelper.canCreatePortal(player, gateName)) {
|
||||
Stargate.debug("createPortal", "Player does not have access to gate layout");
|
||||
deny = true;
|
||||
denyMessage = Stargate.getString("createGateDeny");
|
||||
denyMessage = Stargate.getString(Message.CREATION_GATE_DENIED);
|
||||
}
|
||||
|
||||
//Check if the user can create portals to this world.
|
||||
@@ -155,7 +156,7 @@ public class PortalCreator {
|
||||
if (PermissionHelper.cannotAccessWorld(player, world)) {
|
||||
Stargate.debug("canCreateNetworkGate", "Player does not have access to destination world");
|
||||
deny = true;
|
||||
denyMessage = Stargate.getString("createWorldDeny");
|
||||
denyMessage = Stargate.getString(Message.CREATION_WORLD_DENIED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -245,7 +246,7 @@ public class PortalCreator {
|
||||
if (portal.getCleanName().length() < 1 || portal.getCleanName().length() > getMaxNameNetworkLength()) {
|
||||
Stargate.debug("createPortal", String.format("Name length error. %s is too long.",
|
||||
portal.getCleanName()));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("createNameLength"));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.CREATION_NAME_LENGTH));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -253,14 +254,14 @@ public class PortalCreator {
|
||||
//Check if the bungee portal's name has been duplicated
|
||||
if (PortalHandler.getBungeePortals().get(portal.getCleanName()) != null) {
|
||||
Stargate.debug("createPortal::Bungee", "Gate name duplicate");
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("createExists"));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.CREATION_NAME_COLLISION));
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
//Check if the portal name has been duplicated on the network
|
||||
if (PortalHandler.getByName(portal.getCleanName(), portal.getCleanNetwork()) != null) {
|
||||
Stargate.debug("createPortal", "Gate name duplicate");
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("createExists"));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.CREATION_NAME_COLLISION));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -268,7 +269,7 @@ public class PortalCreator {
|
||||
List<String> networkList = PortalHandler.getAllPortalNetworks().get(portal.getCleanNetwork());
|
||||
int maxGates = Stargate.getGateConfig().maxGatesEachNetwork();
|
||||
if (maxGates > 0 && networkList != null && networkList.size() >= maxGates) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("createFull"));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.CREATION_NETWORK_FULL));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -331,7 +332,7 @@ public class PortalCreator {
|
||||
BlockLocation borderBlockLocation = topLeft.getRelativeLocation(borderVector, yaw);
|
||||
if (PortalHandler.getByBlock(borderBlockLocation.getBlock()) != null) {
|
||||
Stargate.debug("createPortal", "Gate conflicts with existing gate");
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("createConflict"));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.CREATION_CONFLICT));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package net.knarcraft.stargate.portal;
|
||||
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.config.Message;
|
||||
import net.knarcraft.stargate.container.BlockLocation;
|
||||
import net.knarcraft.stargate.container.RelativeBlockVector;
|
||||
import net.knarcraft.stargate.portal.property.PortalLocation;
|
||||
@@ -135,13 +136,13 @@ public class PortalHandler {
|
||||
@NotNull String destinationName, String network) {
|
||||
if (portalOptions.get(PortalOption.BUNGEE)) {
|
||||
if (!PermissionHelper.hasPermission(player, "stargate.admin.bungee")) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("bungeeDeny"));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.BUNGEE_CREATION_DENIED));
|
||||
return false;
|
||||
} else if (!Stargate.getGateConfig().enableBungee()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("bungeeDisabled"));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.BUNGEE_DISABLED));
|
||||
return false;
|
||||
} else if (destinationName.isEmpty() || network.isEmpty()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("bungeeEmpty"));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.BUNGEE_MISSING_INFO));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package net.knarcraft.stargate.portal;
|
||||
import net.knarcraft.knarlib.property.ColorConversion;
|
||||
import net.knarcraft.knarlib.util.ColorHelper;
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.config.Message;
|
||||
import net.knarcraft.stargate.container.SignData;
|
||||
import net.knarcraft.stargate.portal.property.PortalLocation;
|
||||
import net.knarcraft.stargate.utility.PermissionHelper;
|
||||
@@ -296,7 +297,7 @@ public class PortalSignDrawer {
|
||||
private void drawBungeeSign(@NotNull SignData signData) {
|
||||
ChatColor highlightColor = signData.getHighlightSignColor();
|
||||
ChatColor mainColor = signData.getMainSignColor();
|
||||
setLine(signData, 1, Stargate.getString("bungeeSign"));
|
||||
setLine(signData, 1, Stargate.getString(Message.BUNGEE_SIGN));
|
||||
setLine(signData, 2, highlightColor + ">" + mainColor +
|
||||
translateAllColorCodes(portal.getDestinationName()) + highlightColor + "<");
|
||||
setLine(signData, 3, highlightColor + "[" + mainColor + translateAllColorCodes(portal.getNetwork()) +
|
||||
@@ -313,8 +314,8 @@ public class PortalSignDrawer {
|
||||
private void drawInactiveSign(@NotNull SignData signData) {
|
||||
ChatColor highlightColor = signData.getHighlightSignColor();
|
||||
ChatColor mainColor = signData.getMainSignColor();
|
||||
setLine(signData, 1, Stargate.getString("signRightClick"));
|
||||
setLine(signData, 2, Stargate.getString("signToUse"));
|
||||
setLine(signData, 1, Stargate.getString(Message.SIGN_RIGHT_CLICK));
|
||||
setLine(signData, 2, Stargate.getString(Message.SIGN_TO_USE));
|
||||
if (!portal.getOptions().isNoNetwork()) {
|
||||
setLine(signData, 3, highlightColor + "(" + mainColor + translateAllColorCodes(portal.getNetwork()) +
|
||||
highlightColor + ")");
|
||||
@@ -333,7 +334,7 @@ public class PortalSignDrawer {
|
||||
ChatColor mainColor = signData.getMainSignColor();
|
||||
Portal destinationPortal = PortalHandler.getByName(Portal.cleanString(portal.getDestinationName()),
|
||||
portal.getCleanNetwork());
|
||||
String destinationName = portal.getOptions().isRandom() ? Stargate.getString("signRandom") :
|
||||
String destinationName = portal.getOptions().isRandom() ? Stargate.getString(Message.SIGN_RANDOM) :
|
||||
(destinationPortal != null ? destinationPortal.getName() : portal.getDestinationName());
|
||||
setLine(signData, 1, highlightColor + ">" + mainColor + translateAllColorCodes(destinationName) +
|
||||
highlightColor + "<");
|
||||
@@ -347,7 +348,7 @@ public class PortalSignDrawer {
|
||||
Portal destination = PortalHandler.getByName(Portal.cleanString(portal.getDestinationName()),
|
||||
portal.getNetwork());
|
||||
if (destination == null && !portal.getOptions().isRandom()) {
|
||||
setLine(signData, 3, errorColor + Stargate.getString("signDisconnected"));
|
||||
setLine(signData, 3, errorColor + Stargate.getString(Message.SIGN_DISCONNECTED));
|
||||
} else {
|
||||
setLine(signData, 3, "");
|
||||
}
|
||||
@@ -366,7 +367,7 @@ public class PortalSignDrawer {
|
||||
if (!(blockState instanceof Sign sign)) {
|
||||
return;
|
||||
}
|
||||
SignHelper.setSignLine(sign, 3, errorColor + Stargate.getString("signInvalidGate"));
|
||||
SignHelper.setSignLine(sign, 3, errorColor + Stargate.getString(Message.SIGN_INVALID));
|
||||
sign.update();
|
||||
|
||||
Stargate.logInfo(String.format("Gate layout on line %d does not exist [%s]", lineIndex, gateName));
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package net.knarcraft.stargate.utility;
|
||||
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.config.Message;
|
||||
import net.knarcraft.stargate.portal.Portal;
|
||||
import net.knarcraft.stargate.portal.PortalHandler;
|
||||
import net.knarcraft.stargate.portal.teleporter.PlayerTeleporter;
|
||||
@@ -186,7 +187,7 @@ public final class BungeeHelper {
|
||||
//Check if bungee is actually enabled
|
||||
if (!Stargate.getGateConfig().enableBungee()) {
|
||||
if (!entrancePortal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("bungeeDisabled"));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.BUNGEE_DISABLED));
|
||||
}
|
||||
entrancePortal.getPortalOpener().closePortal(false);
|
||||
return false;
|
||||
|
@@ -3,6 +3,7 @@ package net.knarcraft.stargate.utility;
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.config.EconomyConfig;
|
||||
import net.knarcraft.stargate.config.Message;
|
||||
import net.knarcraft.stargate.portal.Portal;
|
||||
import net.knarcraft.stargate.portal.property.PortalOwner;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
@@ -81,7 +82,7 @@ public final class EconomyHelper {
|
||||
* @param earnings <p>The amount the owner earned</p>
|
||||
*/
|
||||
public static void sendObtainMessage(@NotNull String portalName, @NotNull Player portalOwner, int earnings) {
|
||||
String obtainedMsg = Stargate.getString("ecoObtain");
|
||||
String obtainedMsg = Stargate.getString(Message.ECONOMY_OBTAINED);
|
||||
obtainedMsg = replacePlaceholders(obtainedMsg, portalName, earnings);
|
||||
Stargate.getMessageSender().sendSuccessMessage(portalOwner, obtainedMsg);
|
||||
}
|
||||
@@ -94,7 +95,7 @@ public final class EconomyHelper {
|
||||
* @param cost <p>The cost of the interaction</p>
|
||||
*/
|
||||
public static void sendDeductMessage(@NotNull String portalName, @NotNull Player player, int cost) {
|
||||
String deductMsg = Stargate.getString("ecoDeduct");
|
||||
String deductMsg = Stargate.getString(Message.ECONOMY_DEDUCTED);
|
||||
deductMsg = replacePlaceholders(deductMsg, portalName, cost);
|
||||
Stargate.getMessageSender().sendSuccessMessage(player, deductMsg);
|
||||
}
|
||||
@@ -107,7 +108,7 @@ public final class EconomyHelper {
|
||||
* @param cost <p>The cost of the interaction</p>
|
||||
*/
|
||||
public static void sendInsufficientFundsMessage(@NotNull String portalName, @NotNull Player player, int cost) {
|
||||
String inFundMsg = Stargate.getString("ecoInFunds");
|
||||
String inFundMsg = Stargate.getString(Message.ECONOMY_INSUFFICIENT);
|
||||
inFundMsg = replacePlaceholders(inFundMsg, portalName, cost);
|
||||
Stargate.getMessageSender().sendErrorMessage(player, inFundMsg);
|
||||
}
|
||||
@@ -120,7 +121,7 @@ public final class EconomyHelper {
|
||||
* @param cost <p>The amount the user has to pay for destroying the portal. (expects a negative value)</p>
|
||||
*/
|
||||
public static void sendRefundMessage(@NotNull String portalName, @NotNull Player player, int cost) {
|
||||
String refundMsg = Stargate.getString("ecoRefund");
|
||||
String refundMsg = Stargate.getString(Message.ECONOMY_REFUNDED);
|
||||
refundMsg = replacePlaceholders(refundMsg, portalName, -cost);
|
||||
Stargate.getMessageSender().sendSuccessMessage(player, refundMsg);
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package net.knarcraft.stargate.utility;
|
||||
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.config.Message;
|
||||
import net.knarcraft.stargate.event.StargateAccessEvent;
|
||||
import net.knarcraft.stargate.portal.Portal;
|
||||
import net.knarcraft.stargate.portal.property.PortalOption;
|
||||
@@ -38,7 +39,7 @@ public final class PermissionHelper {
|
||||
//Destination is invalid or the same portal. Send an error message
|
||||
if (destination == null || destination == portal) {
|
||||
if (!portal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("invalidMsg"));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.INVALID_DESTINATION));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -56,7 +57,7 @@ public final class PermissionHelper {
|
||||
if (!portal.getOptions().isFixed() && portal.getPortalActivator().isActive() &&
|
||||
portal.getActivePlayer() != player) {
|
||||
if (!portal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.ACCESS_DENIED));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -64,7 +65,7 @@ public final class PermissionHelper {
|
||||
//Check if the player can use the private gate
|
||||
if (portal.getOptions().isPrivate() && !PermissionHelper.canUsePrivatePortal(player, portal)) {
|
||||
if (!portal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.ACCESS_DENIED));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -72,7 +73,7 @@ public final class PermissionHelper {
|
||||
//Destination is currently in use by another player, blocking teleportation
|
||||
if (destination.isOpen() && !destination.getOptions().isAlwaysOn()) {
|
||||
if (!portal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("blockMsg"));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.DESTINATION_BLOCKED));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -396,7 +397,7 @@ public final class PermissionHelper {
|
||||
//Not open for this player
|
||||
if (!entrancePortal.getPortalOpener().isOpenFor(player)) {
|
||||
if (!entrancePortal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.ACCESS_DENIED));
|
||||
}
|
||||
new PlayerTeleporter(entrancePortal, player).teleportPlayer(entrancePortal, event);
|
||||
return true;
|
||||
@@ -411,7 +412,7 @@ public final class PermissionHelper {
|
||||
//Player cannot access portal
|
||||
if (PermissionHelper.cannotAccessPortal(player, entrancePortal, destination)) {
|
||||
if (!entrancePortal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.ACCESS_DENIED));
|
||||
}
|
||||
new PlayerTeleporter(entrancePortal, player).teleportPlayer(entrancePortal, event);
|
||||
Stargate.debug("PermissionHelper::playerCannotTeleport", "Closed portal because player is " +
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package net.knarcraft.stargate.utility;
|
||||
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.config.Message;
|
||||
import net.knarcraft.stargate.portal.Portal;
|
||||
import net.knarcraft.stargate.portal.teleporter.EntityTeleporter;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -229,7 +230,7 @@ public final class TeleportHelper {
|
||||
//Make sure the user can access the portal
|
||||
if (PermissionHelper.cannotAccessPortal(player, entrancePortal, destinationPortal)) {
|
||||
if (!entrancePortal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.ACCESS_DENIED));
|
||||
}
|
||||
entrancePortal.getPortalOpener().closePortal(false);
|
||||
return false;
|
||||
@@ -240,7 +241,7 @@ public final class TeleportHelper {
|
||||
boolean canAffordFee = cost <= 0 || Stargate.getEconomyConfig().canAffordFee(player, cost);
|
||||
if (!canAffordFee) {
|
||||
if (!entrancePortal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("ecoInFunds"));
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.ECONOMY_INSUFFICIENT));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user