Changes things for the non-static Translator
This commit is contained in:
parent
bb63fb59d1
commit
a9c97f71f9
@ -2,6 +2,7 @@ package net.knarcraft.paidsigns;
|
||||
|
||||
import net.knarcraft.knarlib.KnarLib;
|
||||
import net.knarcraft.knarlib.formatting.Translator;
|
||||
import net.knarcraft.knarlib.util.UpdateChecker;
|
||||
import net.knarcraft.paidsigns.command.AddCommand;
|
||||
import net.knarcraft.paidsigns.command.AddConditionCommand;
|
||||
import net.knarcraft.paidsigns.command.AddConditionTabCompleter;
|
||||
@ -38,6 +39,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
public final class PaidSigns extends JavaPlugin {
|
||||
|
||||
private static PaidSigns paidSigns;
|
||||
private static Translator translator;
|
||||
private PaidSignManager signManager;
|
||||
private String language;
|
||||
private boolean ignoreCase;
|
||||
@ -63,6 +65,15 @@ public final class PaidSigns extends JavaPlugin {
|
||||
return paidSigns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the translator to use for this plugin
|
||||
*
|
||||
* @return <p>The translator to use for this plugin</p>
|
||||
*/
|
||||
public static Translator getTranslator() {
|
||||
return translator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
KnarLib.setPlugin(this);
|
||||
@ -71,8 +82,9 @@ public final class PaidSigns extends JavaPlugin {
|
||||
loadConfig();
|
||||
|
||||
//Initialize translator
|
||||
Translator.registerMessageCategory(PaidSignsTranslatableMessage.BOOLEAN_TRUE);
|
||||
Translator.loadLanguages(language);
|
||||
translator = new Translator();
|
||||
translator.registerMessageCategory(PaidSignsTranslatableMessage.BOOLEAN_TRUE);
|
||||
translator.loadLanguages(language);
|
||||
|
||||
signManager = new PaidSignManager(PaidSignManager.loadSigns());
|
||||
TrackedSignManager.loadTrackedSigns();
|
||||
@ -82,6 +94,9 @@ public final class PaidSigns extends JavaPlugin {
|
||||
pluginManager.registerEvents(new SignBreakListener(), this);
|
||||
|
||||
registerCommands();
|
||||
|
||||
UpdateChecker.checkForUpdate(this, "https://api.spigotmc.org/legacy/update.php?resource=105842",
|
||||
() -> this.getDescription().getVersion(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -94,7 +109,7 @@ public final class PaidSigns extends JavaPlugin {
|
||||
public void reload() {
|
||||
this.reloadConfig();
|
||||
loadConfig();
|
||||
Translator.loadLanguages(language);
|
||||
translator.loadLanguages(language);
|
||||
signManager = new PaidSignManager(PaidSignManager.loadSigns());
|
||||
TrackedSignManager.loadTrackedSigns();
|
||||
}
|
||||
|
@ -30,7 +30,8 @@ public class AddCommand extends TokenizedCommand {
|
||||
try {
|
||||
cost = Double.parseDouble(arguments.get(1));
|
||||
} catch (NumberFormatException exception) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
return false;
|
||||
}
|
||||
String permission = "";
|
||||
@ -71,17 +72,20 @@ public class AddCommand extends TokenizedCommand {
|
||||
try {
|
||||
PaidSign sign = new PaidSign(signName, cost, permission, ignoreCase, ignoreColor, matchAnyCondition);
|
||||
if (manager.getPaidSign(signName) != null) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_NAME_DUPLICATE);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_NAME_DUPLICATE);
|
||||
return false;
|
||||
}
|
||||
manager.addPaidSign(sign);
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSignsTranslatableMessage.SUCCESS_ADDED_PAID_SIGN);
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.SUCCESS_ADDED_PAID_SIGN);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
return false;
|
||||
} catch (IllegalArgumentException e) {
|
||||
StringFormatter.displayErrorMessage(sender, StringFormatter.replacePlaceholder(
|
||||
StringFormatter.displayErrorMessage(sender, StringFormatter.replacePlaceholder(PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_INVALID_INPUT, "{input}", e.getMessage()));
|
||||
}
|
||||
return false;
|
||||
|
@ -30,11 +30,13 @@ public class AddConditionCommand extends TokenizedCommand {
|
||||
try {
|
||||
lineNumber = (short) (Short.parseShort(arguments.get(1)) - 1);
|
||||
if (lineNumber < 0 || lineNumber > 3) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
return false;
|
||||
}
|
||||
} catch (NumberFormatException exception) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
return false;
|
||||
}
|
||||
String stringToMatch = arguments.get(2);
|
||||
@ -73,17 +75,20 @@ public class AddConditionCommand extends TokenizedCommand {
|
||||
PaidSignManager signManager = PaidSigns.getInstance().getSignManager();
|
||||
PaidSign sign = signManager.getPaidSign(name);
|
||||
if (sign == null) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_PAID_SIGN_NOT_FOUND);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_PAID_SIGN_NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
sign.addCondition(lineNumber, stringToMatch, executeRegEx, ignoreCase, ignoreColor);
|
||||
try {
|
||||
signManager.saveSigns();
|
||||
} catch (IOException e) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
return false;
|
||||
}
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSignsTranslatableMessage.SUCCESS_ADDED_PAID_SIGN_CONDITION);
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.SUCCESS_ADDED_PAID_SIGN_CONDITION);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,8 @@ public class EditCommand extends TokenizedCommand {
|
||||
|
||||
PaidSign sign = PaidSigns.getInstance().getSignManager().getPaidSign(arguments.get(0));
|
||||
if (sign == null) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_PAID_SIGN_NOT_FOUND);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_PAID_SIGN_NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -44,7 +45,8 @@ public class EditCommand extends TokenizedCommand {
|
||||
return parseGivenProperty(sign, sender);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -61,7 +63,8 @@ public class EditCommand extends TokenizedCommand {
|
||||
@NotNull CommandSender sender) throws NumberFormatException {
|
||||
short signLine = (short) (Short.parseShort(arguments.get(1)) - 1);
|
||||
if (signLine < 0 || signLine > 3 || sign.getConditions().get(signLine) == null) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_NO_SUCH_CONDITION);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_NO_SUCH_CONDITION);
|
||||
return false;
|
||||
}
|
||||
if (argumentSize < 4) {
|
||||
@ -70,7 +73,8 @@ public class EditCommand extends TokenizedCommand {
|
||||
|
||||
PaidSignConditionProperty conditionProperty = PaidSignConditionProperty.getFromString(arguments.get(2));
|
||||
if (conditionProperty == null) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_PROPERTY_NOT_RECOGNIZED);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_PROPERTY_NOT_RECOGNIZED);
|
||||
return false;
|
||||
}
|
||||
String value = arguments.get(3);
|
||||
@ -89,7 +93,8 @@ public class EditCommand extends TokenizedCommand {
|
||||
@NotNull CommandSender sender) throws IOException {
|
||||
PaidSignProperty property = PaidSignProperty.getFromString(arguments.get(1));
|
||||
if (property == null) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_PROPERTY_NOT_RECOGNIZED);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_PROPERTY_NOT_RECOGNIZED);
|
||||
return false;
|
||||
}
|
||||
String value = arguments.get(2);
|
||||
@ -97,7 +102,8 @@ public class EditCommand extends TokenizedCommand {
|
||||
updateProperty(sender, sign, property, value);
|
||||
return true;
|
||||
} catch (NumberFormatException exception) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -135,7 +141,8 @@ public class EditCommand extends TokenizedCommand {
|
||||
manager.removePaidSign(sign.getName());
|
||||
manager.addPaidSign(updatedSign);
|
||||
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSignsTranslatableMessage.SUCCESS_UPDATED_PAID_SIGN);
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.SUCCESS_UPDATED_PAID_SIGN);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -171,11 +178,13 @@ public class EditCommand extends TokenizedCommand {
|
||||
try {
|
||||
PaidSigns.getInstance().getSignManager().saveSigns();
|
||||
} catch (IOException e) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
return false;
|
||||
}
|
||||
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSignsTranslatableMessage.SUCCESS_UPDATED_PAID_SIGN_CONDITION);
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.SUCCESS_UPDATED_PAID_SIGN_CONDITION);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.knarcraft.paidsigns.command;
|
||||
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
import net.knarcraft.knarlib.formatting.Translator;
|
||||
import net.knarcraft.paidsigns.PaidSigns;
|
||||
import net.knarcraft.paidsigns.container.PaidSign;
|
||||
import net.knarcraft.paidsigns.container.PaidSignCondition;
|
||||
@ -55,7 +54,7 @@ public class ListCommand extends TokenizedCommand {
|
||||
Set<String> signNames = PaidSigns.getInstance().getSignManager().getAllPaidSigns().keySet();
|
||||
List<String> signNameList = new ArrayList<>(signNames);
|
||||
Collections.sort(signNameList);
|
||||
String infoFormat = Translator.getTranslatedMessage(PaidSignsTranslatableMessage.PAID_SIGNS_INFO_FORMAT);
|
||||
String infoFormat = PaidSigns.getTranslator().getTranslatedMessage(PaidSignsTranslatableMessage.PAID_SIGNS_INFO_FORMAT);
|
||||
|
||||
//Display up to 10 signs per page
|
||||
int signsPerPage = 7;
|
||||
@ -72,11 +71,11 @@ public class ListCommand extends TokenizedCommand {
|
||||
boolean hasNextPage = alreadyDisplayed + signsPerPage < signNameList.size();
|
||||
String nextPagePrompt = "";
|
||||
if (hasNextPage) {
|
||||
nextPagePrompt = replacePlaceholder(Translator.getTranslatedMessage(
|
||||
nextPagePrompt = replacePlaceholder(PaidSigns.getTranslator().getTranslatedMessage(
|
||||
PaidSignsTranslatableMessage.PAID_SIGNS_NEXT_PROMPT), "{nextPage}", String.valueOf((pageNumber + 2)));
|
||||
}
|
||||
|
||||
sender.sendMessage(StringFormatter.replacePlaceholders(Translator.getTranslatedMessage(
|
||||
sender.sendMessage(StringFormatter.replacePlaceholders(PaidSigns.getTranslator().getTranslatedMessage(
|
||||
PaidSignsTranslatableMessage.PAID_SIGNS_INFO), new String[]{"{signs}", "{nextPagePrompt}"},
|
||||
new String[]{signs.toString(), nextPagePrompt}));
|
||||
}
|
||||
@ -90,7 +89,7 @@ public class ListCommand extends TokenizedCommand {
|
||||
private boolean parsePaidSignSelection(CommandSender sender) {
|
||||
PaidSign paidSign = PaidSigns.getInstance().getSignManager().getPaidSign(arguments.get(0));
|
||||
if (paidSign == null) {
|
||||
displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_PAID_SIGN_NOT_FOUND);
|
||||
displayErrorMessage(sender, PaidSigns.getTranslator(), PaidSignsTranslatableMessage.ERROR_PAID_SIGN_NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
if (argumentSize < 2) {
|
||||
@ -100,16 +99,18 @@ public class ListCommand extends TokenizedCommand {
|
||||
try {
|
||||
lineNumber = (short) (Short.parseShort(arguments.get(1)) - 1);
|
||||
if (lineNumber < 0 || lineNumber > 3) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
return false;
|
||||
}
|
||||
} catch (NumberFormatException exception) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
return false;
|
||||
}
|
||||
if (!paidSign.getConditions().containsKey(lineNumber)) {
|
||||
StringFormatter.displayErrorMessage(sender, replacePlaceholder(PaidSignsTranslatableMessage.ERROR_NO_SUCH_CONDITION,
|
||||
"{line}", String.valueOf(lineNumber)));
|
||||
StringFormatter.displayErrorMessage(sender, replacePlaceholder(PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_NO_SUCH_CONDITION, "{line}", String.valueOf(lineNumber)));
|
||||
return false;
|
||||
}
|
||||
PaidSignCondition condition = paidSign.getConditions().get(lineNumber);
|
||||
@ -128,11 +129,11 @@ public class ListCommand extends TokenizedCommand {
|
||||
*/
|
||||
private void displayPaidSignCondition(CommandSender sender, String signName, short signLine,
|
||||
PaidSignCondition condition) {
|
||||
sender.sendMessage(StringFormatter.replacePlaceholders(PaidSignsTranslatableMessage.PAID_SIGN_CONDITION_INFO,
|
||||
new String[]{"{name}", "{line}", "{match}", "{regex}", "{case}", "{color}"},
|
||||
new String[]{signName, String.valueOf(signLine + 1), condition.stringToMatch(),
|
||||
translateBoolean(condition.executeRegex()), translateBoolean(condition.ignoreCase()),
|
||||
translateBoolean(condition.ignoreColor())}));
|
||||
sender.sendMessage(StringFormatter.replacePlaceholders(PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.PAID_SIGN_CONDITION_INFO, new String[]{"{name}", "{line}", "{match}",
|
||||
"{regex}", "{case}", "{color}"}, new String[]{signName, String.valueOf(signLine + 1),
|
||||
condition.stringToMatch(), translateBoolean(condition.executeRegex()),
|
||||
translateBoolean(condition.ignoreCase()), translateBoolean(condition.ignoreColor())}));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -145,12 +146,13 @@ public class ListCommand extends TokenizedCommand {
|
||||
Map<Short, PaidSignCondition> signConditions = paidSign.getConditions();
|
||||
StringBuilder conditions = new StringBuilder();
|
||||
for (short lineIndex : signConditions.keySet()) {
|
||||
String format = Translator.getTranslatedMessage(PaidSignsTranslatableMessage.PAID_SIGN_INFO_CONDITION_FORMAT);
|
||||
String format = PaidSigns.getTranslator().getTranslatedMessage(
|
||||
PaidSignsTranslatableMessage.PAID_SIGN_INFO_CONDITION_FORMAT);
|
||||
conditions.append(StringFormatter.replacePlaceholders(format, new String[]{"{line}", "{condition}"},
|
||||
new String[]{String.valueOf((lineIndex + 1)), signConditions.get(lineIndex).stringToMatch()}));
|
||||
}
|
||||
|
||||
sender.sendMessage(replacePlaceholders(Translator.getTranslatedMessage(
|
||||
sender.sendMessage(replacePlaceholders(PaidSigns.getTranslator().getTranslatedMessage(
|
||||
PaidSignsTranslatableMessage.PAID_SIGN_INFO), new String[]{"{name}", "{cost}", "{permission}", "{case}",
|
||||
"{color}", "{any}", "{conditions}"}, new String[]{paidSign.getName(), String.valueOf(paidSign.getCost()),
|
||||
paidSign.getPermission(), translateBoolean(paidSign.getIgnoreCase()),
|
||||
@ -166,9 +168,9 @@ public class ListCommand extends TokenizedCommand {
|
||||
*/
|
||||
public static String translateBoolean(boolean booleanValue) {
|
||||
if (booleanValue) {
|
||||
return Translator.getTranslatedMessage(PaidSignsTranslatableMessage.BOOLEAN_TRUE);
|
||||
return PaidSigns.getTranslator().getTranslatedMessage(PaidSignsTranslatableMessage.BOOLEAN_TRUE);
|
||||
} else {
|
||||
return Translator.getTranslatedMessage(PaidSignsTranslatableMessage.BOOLEAN_FALSE);
|
||||
return PaidSigns.getTranslator().getTranslatedMessage(PaidSignsTranslatableMessage.BOOLEAN_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,8 @@ public class ReloadTabCommand implements TabExecutor {
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label,
|
||||
@NotNull String[] args) {
|
||||
PaidSigns.getInstance().reload();
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSignsTranslatableMessage.SUCCESS_RELOADED);
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.SUCCESS_RELOADED);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -28,22 +28,25 @@ public class RemoveConditionCommand extends TokenizedCommand {
|
||||
try {
|
||||
lineNumber = (short) (Short.parseShort(arguments.get(1)) - 1);
|
||||
if (lineNumber < 0 || lineNumber > 3) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
return false;
|
||||
}
|
||||
} catch (NumberFormatException exception) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
return false;
|
||||
}
|
||||
PaidSignManager signManager = PaidSigns.getInstance().getSignManager();
|
||||
PaidSign sign = signManager.getPaidSign(name);
|
||||
if (sign == null) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_PAID_SIGN_NOT_FOUND);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_PAID_SIGN_NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sign.getConditions().containsKey(lineNumber)) {
|
||||
StringFormatter.displayErrorMessage(sender, StringFormatter.replacePlaceholder(
|
||||
StringFormatter.displayErrorMessage(sender, StringFormatter.replacePlaceholder(PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_NO_SUCH_CONDITION, "{line}",
|
||||
String.valueOf((lineNumber + 1))));
|
||||
return false;
|
||||
@ -53,10 +56,12 @@ public class RemoveConditionCommand extends TokenizedCommand {
|
||||
try {
|
||||
signManager.saveSigns();
|
||||
} catch (IOException e) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
return false;
|
||||
}
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSignsTranslatableMessage.SUCCESS_REMOVED_CONDITION);
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.SUCCESS_REMOVED_CONDITION);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -31,13 +31,16 @@ public class RemoveTabCommand implements TabExecutor {
|
||||
|
||||
try {
|
||||
if (PaidSigns.getInstance().getSignManager().removePaidSign(name)) {
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSignsTranslatableMessage.SUCCESS_REMOVED_PAID_SIGN);
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.SUCCESS_REMOVED_PAID_SIGN);
|
||||
} else {
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSignsTranslatableMessage.ERROR_PAID_SIGN_NOT_FOUND);
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_PAID_SIGN_NOT_FOUND);
|
||||
}
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.knarcraft.paidsigns.command;
|
||||
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
import net.knarcraft.paidsigns.PaidSigns;
|
||||
import net.knarcraft.paidsigns.formatting.PaidSignsTranslatableMessage;
|
||||
import net.knarcraft.paidsigns.utility.Tokenizer;
|
||||
import org.bukkit.command.Command;
|
||||
@ -39,7 +40,8 @@ public class TokenizedCommand implements CommandExecutor {
|
||||
Pattern.compile(regularExpression);
|
||||
return false;
|
||||
} catch (PatternSyntaxException exception) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_INVALID_REGULAR_EXPRESSION);
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_INVALID_REGULAR_EXPRESSION);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -151,8 +151,8 @@ public class SignListener implements Listener {
|
||||
*/
|
||||
private String replaceCost(double cost, TranslatableMessage message) {
|
||||
String unit = EconomyManager.getCurrency(cost != 1);
|
||||
return String.format(StringFormatter.replacePlaceholders(message, new String[]{"{cost}", "{unit}"},
|
||||
new String[]{"%.2f", "%s"}), cost, unit);
|
||||
return String.format(StringFormatter.replacePlaceholders(PaidSigns.getTranslator(), message,
|
||||
new String[]{"{cost}", "{unit}"}, new String[]{"%.2f", "%s"}), cost, unit);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -156,8 +156,9 @@ public final class TrackedSignManager {
|
||||
EconomyManager.deposit(offlinePlayer, refundSum);
|
||||
if (offlinePlayer instanceof Player player) {
|
||||
StringFormatter.displaySuccessMessage(player, String.format(StringFormatter.replacePlaceholders(
|
||||
PaidSignsTranslatableMessage.SUCCESS_REFUNDED, new String[]{"{cost}", "{unit}"},
|
||||
new String[]{"%.2f", "%s"}), refundSum, EconomyManager.getCurrency(refundSum != 1)));
|
||||
PaidSigns.getTranslator(), PaidSignsTranslatableMessage.SUCCESS_REFUNDED,
|
||||
new String[]{"{cost}", "{unit}"}, new String[]{"%.2f", "%s"}), refundSum,
|
||||
EconomyManager.getCurrency(refundSum != 1)));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user