Updates code to account for KnarLib changes
This commit is contained in:
parent
a9c97f71f9
commit
5c095e79f6
@ -1,6 +1,6 @@
|
||||
package net.knarcraft.paidsigns;
|
||||
|
||||
import net.knarcraft.knarlib.KnarLib;
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
import net.knarcraft.knarlib.formatting.Translator;
|
||||
import net.knarcraft.knarlib.util.UpdateChecker;
|
||||
import net.knarcraft.paidsigns.command.AddCommand;
|
||||
@ -40,6 +40,7 @@ public final class PaidSigns extends JavaPlugin {
|
||||
|
||||
private static PaidSigns paidSigns;
|
||||
private static Translator translator;
|
||||
private static StringFormatter stringFormatter;
|
||||
private PaidSignManager signManager;
|
||||
private String language;
|
||||
private boolean ignoreCase;
|
||||
@ -74,17 +75,25 @@ public final class PaidSigns extends JavaPlugin {
|
||||
return translator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string formatter to use for this plugin
|
||||
*
|
||||
* @return <p>The string formatter to use for this plugin</p>
|
||||
*/
|
||||
public static StringFormatter getStringFormatter() {
|
||||
return stringFormatter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
KnarLib.setPlugin(this);
|
||||
|
||||
setupVault();
|
||||
loadConfig();
|
||||
|
||||
//Initialize translator
|
||||
translator = new Translator();
|
||||
translator.registerMessageCategory(PaidSignsTranslatableMessage.BOOLEAN_TRUE);
|
||||
translator.loadLanguages(language);
|
||||
translator.loadLanguages(this.getDataFolder(), language);
|
||||
stringFormatter = new StringFormatter(this.getDescription().getPrefix(), translator);
|
||||
|
||||
signManager = new PaidSignManager(PaidSignManager.loadSigns());
|
||||
TrackedSignManager.loadTrackedSigns();
|
||||
@ -109,7 +118,7 @@ public final class PaidSigns extends JavaPlugin {
|
||||
public void reload() {
|
||||
this.reloadConfig();
|
||||
loadConfig();
|
||||
translator.loadLanguages(language);
|
||||
translator.loadLanguages(this.getDataFolder(), language);
|
||||
signManager = new PaidSignManager(PaidSignManager.loadSigns());
|
||||
TrackedSignManager.loadTrackedSigns();
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.knarcraft.paidsigns.command;
|
||||
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
import net.knarcraft.paidsigns.PaidSigns;
|
||||
import net.knarcraft.paidsigns.container.PaidSign;
|
||||
import net.knarcraft.paidsigns.formatting.PaidSignsTranslatableMessage;
|
||||
@ -30,8 +29,7 @@ public class AddCommand extends TokenizedCommand {
|
||||
try {
|
||||
cost = Double.parseDouble(arguments.get(1));
|
||||
} catch (NumberFormatException exception) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
return false;
|
||||
}
|
||||
String permission = "";
|
||||
@ -72,20 +70,17 @@ public class AddCommand extends TokenizedCommand {
|
||||
try {
|
||||
PaidSign sign = new PaidSign(signName, cost, permission, ignoreCase, ignoreColor, matchAnyCondition);
|
||||
if (manager.getPaidSign(signName) != null) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_NAME_DUPLICATE);
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_NAME_DUPLICATE);
|
||||
return false;
|
||||
}
|
||||
manager.addPaidSign(sign);
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.SUCCESS_ADDED_PAID_SIGN);
|
||||
PaidSigns.getStringFormatter().displaySuccessMessage(sender, PaidSignsTranslatableMessage.SUCCESS_ADDED_PAID_SIGN);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
return false;
|
||||
} catch (IllegalArgumentException e) {
|
||||
StringFormatter.displayErrorMessage(sender, StringFormatter.replacePlaceholder(PaidSigns.getTranslator(),
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender, PaidSigns.getStringFormatter().replacePlaceholder(
|
||||
PaidSignsTranslatableMessage.ERROR_INVALID_INPUT, "{input}", e.getMessage()));
|
||||
}
|
||||
return false;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.knarcraft.paidsigns.command;
|
||||
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
import net.knarcraft.paidsigns.PaidSigns;
|
||||
import net.knarcraft.paidsigns.container.PaidSign;
|
||||
import net.knarcraft.paidsigns.formatting.PaidSignsTranslatableMessage;
|
||||
@ -30,13 +29,11 @@ public class AddConditionCommand extends TokenizedCommand {
|
||||
try {
|
||||
lineNumber = (short) (Short.parseShort(arguments.get(1)) - 1);
|
||||
if (lineNumber < 0 || lineNumber > 3) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
return false;
|
||||
}
|
||||
} catch (NumberFormatException exception) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
return false;
|
||||
}
|
||||
String stringToMatch = arguments.get(2);
|
||||
@ -75,20 +72,17 @@ public class AddConditionCommand extends TokenizedCommand {
|
||||
PaidSignManager signManager = PaidSigns.getInstance().getSignManager();
|
||||
PaidSign sign = signManager.getPaidSign(name);
|
||||
if (sign == null) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_PAID_SIGN_NOT_FOUND);
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_PAID_SIGN_NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
sign.addCondition(lineNumber, stringToMatch, executeRegEx, ignoreCase, ignoreColor);
|
||||
try {
|
||||
signManager.saveSigns();
|
||||
} catch (IOException e) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
return false;
|
||||
}
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.SUCCESS_ADDED_PAID_SIGN_CONDITION);
|
||||
PaidSigns.getStringFormatter().displaySuccessMessage(sender, PaidSignsTranslatableMessage.SUCCESS_ADDED_PAID_SIGN_CONDITION);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.knarcraft.paidsigns.command;
|
||||
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
import net.knarcraft.paidsigns.PaidSigns;
|
||||
import net.knarcraft.paidsigns.container.PaidSign;
|
||||
import net.knarcraft.paidsigns.container.PaidSignCondition;
|
||||
@ -31,8 +30,7 @@ public class EditCommand extends TokenizedCommand {
|
||||
|
||||
PaidSign sign = PaidSigns.getInstance().getSignManager().getPaidSign(arguments.get(0));
|
||||
if (sign == null) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_PAID_SIGN_NOT_FOUND);
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_PAID_SIGN_NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -45,8 +43,7 @@ public class EditCommand extends TokenizedCommand {
|
||||
return parseGivenProperty(sign, sender);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -63,8 +60,7 @@ 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, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_NO_SUCH_CONDITION);
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_NO_SUCH_CONDITION);
|
||||
return false;
|
||||
}
|
||||
if (argumentSize < 4) {
|
||||
@ -73,8 +69,7 @@ public class EditCommand extends TokenizedCommand {
|
||||
|
||||
PaidSignConditionProperty conditionProperty = PaidSignConditionProperty.getFromString(arguments.get(2));
|
||||
if (conditionProperty == null) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_PROPERTY_NOT_RECOGNIZED);
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_PROPERTY_NOT_RECOGNIZED);
|
||||
return false;
|
||||
}
|
||||
String value = arguments.get(3);
|
||||
@ -93,8 +88,7 @@ public class EditCommand extends TokenizedCommand {
|
||||
@NotNull CommandSender sender) throws IOException {
|
||||
PaidSignProperty property = PaidSignProperty.getFromString(arguments.get(1));
|
||||
if (property == null) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_PROPERTY_NOT_RECOGNIZED);
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_PROPERTY_NOT_RECOGNIZED);
|
||||
return false;
|
||||
}
|
||||
String value = arguments.get(2);
|
||||
@ -102,8 +96,7 @@ public class EditCommand extends TokenizedCommand {
|
||||
updateProperty(sender, sign, property, value);
|
||||
return true;
|
||||
} catch (NumberFormatException exception) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -141,8 +134,7 @@ public class EditCommand extends TokenizedCommand {
|
||||
manager.removePaidSign(sign.getName());
|
||||
manager.addPaidSign(updatedSign);
|
||||
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.SUCCESS_UPDATED_PAID_SIGN);
|
||||
PaidSigns.getStringFormatter().displaySuccessMessage(sender, PaidSignsTranslatableMessage.SUCCESS_UPDATED_PAID_SIGN);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -178,13 +170,11 @@ public class EditCommand extends TokenizedCommand {
|
||||
try {
|
||||
PaidSigns.getInstance().getSignManager().saveSigns();
|
||||
} catch (IOException e) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
return false;
|
||||
}
|
||||
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.SUCCESS_UPDATED_PAID_SIGN_CONDITION);
|
||||
PaidSigns.getStringFormatter().displaySuccessMessage(sender, PaidSignsTranslatableMessage.SUCCESS_UPDATED_PAID_SIGN_CONDITION);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static net.knarcraft.knarlib.formatting.StringFormatter.displayErrorMessage;
|
||||
import static net.knarcraft.knarlib.formatting.StringFormatter.replacePlaceholder;
|
||||
import static net.knarcraft.knarlib.formatting.StringFormatter.replacePlaceholders;
|
||||
|
||||
@ -89,7 +88,8 @@ public class ListCommand extends TokenizedCommand {
|
||||
private boolean parsePaidSignSelection(CommandSender sender) {
|
||||
PaidSign paidSign = PaidSigns.getInstance().getSignManager().getPaidSign(arguments.get(0));
|
||||
if (paidSign == null) {
|
||||
displayErrorMessage(sender, PaidSigns.getTranslator(), PaidSignsTranslatableMessage.ERROR_PAID_SIGN_NOT_FOUND);
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender,
|
||||
PaidSignsTranslatableMessage.ERROR_PAID_SIGN_NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
if (argumentSize < 2) {
|
||||
@ -99,18 +99,20 @@ public class ListCommand extends TokenizedCommand {
|
||||
try {
|
||||
lineNumber = (short) (Short.parseShort(arguments.get(1)) - 1);
|
||||
if (lineNumber < 0 || lineNumber > 3) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender,
|
||||
PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
return false;
|
||||
}
|
||||
} catch (NumberFormatException exception) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender,
|
||||
PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
return false;
|
||||
}
|
||||
if (!paidSign.getConditions().containsKey(lineNumber)) {
|
||||
StringFormatter.displayErrorMessage(sender, replacePlaceholder(PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_NO_SUCH_CONDITION, "{line}", String.valueOf(lineNumber)));
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender,
|
||||
PaidSigns.getStringFormatter().replacePlaceholder(
|
||||
PaidSignsTranslatableMessage.ERROR_NO_SUCH_CONDITION, "{line}",
|
||||
String.valueOf(lineNumber)));
|
||||
return false;
|
||||
}
|
||||
PaidSignCondition condition = paidSign.getConditions().get(lineNumber);
|
||||
@ -129,7 +131,7 @@ public class ListCommand extends TokenizedCommand {
|
||||
*/
|
||||
private void displayPaidSignCondition(CommandSender sender, String signName, short signLine,
|
||||
PaidSignCondition condition) {
|
||||
sender.sendMessage(StringFormatter.replacePlaceholders(PaidSigns.getTranslator(),
|
||||
sender.sendMessage(PaidSigns.getStringFormatter().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()),
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.knarcraft.paidsigns.command;
|
||||
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
import net.knarcraft.paidsigns.PaidSigns;
|
||||
import net.knarcraft.paidsigns.formatting.PaidSignsTranslatableMessage;
|
||||
import org.bukkit.command.Command;
|
||||
@ -20,8 +19,7 @@ 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, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.SUCCESS_RELOADED);
|
||||
PaidSigns.getStringFormatter().displaySuccessMessage(sender, PaidSignsTranslatableMessage.SUCCESS_RELOADED);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.knarcraft.paidsigns.command;
|
||||
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
import net.knarcraft.paidsigns.PaidSigns;
|
||||
import net.knarcraft.paidsigns.container.PaidSign;
|
||||
import net.knarcraft.paidsigns.formatting.PaidSignsTranslatableMessage;
|
||||
@ -17,7 +16,8 @@ import java.io.IOException;
|
||||
public class RemoveConditionCommand extends TokenizedCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label,
|
||||
@NotNull String[] args) {
|
||||
super.onCommand(sender, command, label, args);
|
||||
if (argumentSize < 2) {
|
||||
return false;
|
||||
@ -28,25 +28,23 @@ public class RemoveConditionCommand extends TokenizedCommand {
|
||||
try {
|
||||
lineNumber = (short) (Short.parseShort(arguments.get(1)) - 1);
|
||||
if (lineNumber < 0 || lineNumber > 3) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
return false;
|
||||
}
|
||||
} catch (NumberFormatException exception) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_INVALID_NUMBER);
|
||||
return false;
|
||||
}
|
||||
PaidSignManager signManager = PaidSigns.getInstance().getSignManager();
|
||||
PaidSign sign = signManager.getPaidSign(name);
|
||||
if (sign == null) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender,
|
||||
PaidSignsTranslatableMessage.ERROR_PAID_SIGN_NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sign.getConditions().containsKey(lineNumber)) {
|
||||
StringFormatter.displayErrorMessage(sender, StringFormatter.replacePlaceholder(PaidSigns.getTranslator(),
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender, PaidSigns.getStringFormatter().replacePlaceholder(
|
||||
PaidSignsTranslatableMessage.ERROR_NO_SUCH_CONDITION, "{line}",
|
||||
String.valueOf((lineNumber + 1))));
|
||||
return false;
|
||||
@ -56,12 +54,10 @@ public class RemoveConditionCommand extends TokenizedCommand {
|
||||
try {
|
||||
signManager.saveSigns();
|
||||
} catch (IOException e) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender, PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
return false;
|
||||
}
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSignsTranslatableMessage.SUCCESS_REMOVED_CONDITION);
|
||||
PaidSigns.getStringFormatter().displaySuccessMessage(sender, PaidSignsTranslatableMessage.SUCCESS_REMOVED_CONDITION);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
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.PaidSignsTabCompleteHelper;
|
||||
@ -31,15 +30,15 @@ public class RemoveTabCommand implements TabExecutor {
|
||||
|
||||
try {
|
||||
if (PaidSigns.getInstance().getSignManager().removePaidSign(name)) {
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSigns.getStringFormatter().displaySuccessMessage(sender,
|
||||
PaidSignsTranslatableMessage.SUCCESS_REMOVED_PAID_SIGN);
|
||||
} else {
|
||||
StringFormatter.displaySuccessMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSigns.getStringFormatter().displaySuccessMessage(sender,
|
||||
PaidSignsTranslatableMessage.ERROR_PAID_SIGN_NOT_FOUND);
|
||||
}
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender,
|
||||
PaidSignsTranslatableMessage.ERROR_EXCEPTION_OCCURRED);
|
||||
}
|
||||
return false;
|
||||
|
@ -1,6 +1,5 @@
|
||||
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;
|
||||
@ -40,7 +39,7 @@ public class TokenizedCommand implements CommandExecutor {
|
||||
Pattern.compile(regularExpression);
|
||||
return false;
|
||||
} catch (PatternSyntaxException exception) {
|
||||
StringFormatter.displayErrorMessage(sender, PaidSigns.getTranslator(),
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(sender,
|
||||
PaidSignsTranslatableMessage.ERROR_INVALID_REGULAR_EXPRESSION);
|
||||
return true;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.knarcraft.paidsigns.listener;
|
||||
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
import net.knarcraft.knarlib.formatting.TranslatableMessage;
|
||||
import net.knarcraft.paidsigns.PaidSigns;
|
||||
import net.knarcraft.paidsigns.container.PaidSign;
|
||||
@ -130,11 +129,11 @@ public class SignListener implements Listener {
|
||||
double cost = paidSign.getCost();
|
||||
boolean canAfford = EconomyManager.canAfford(player, cost);
|
||||
if (!canAfford) {
|
||||
StringFormatter.displayErrorMessage(player, replaceCost(cost, PaidSignsTranslatableMessage.ERROR_CANNOT_AFFORD));
|
||||
PaidSigns.getStringFormatter().displayErrorMessage(player, replaceCost(cost, PaidSignsTranslatableMessage.ERROR_CANNOT_AFFORD));
|
||||
event.setCancelled(true);
|
||||
} else {
|
||||
EconomyManager.withdraw(player, cost);
|
||||
StringFormatter.displaySuccessMessage(player, replaceCost(cost, PaidSignsTranslatableMessage.SUCCESS_PAID_FOR_SIGN));
|
||||
PaidSigns.getStringFormatter().displaySuccessMessage(player, replaceCost(cost, PaidSignsTranslatableMessage.SUCCESS_PAID_FOR_SIGN));
|
||||
try {
|
||||
TrackedSignManager.addTrackedSign(event.getBlock().getLocation(), player.getUniqueId(), cost);
|
||||
} catch (IOException ignored) {
|
||||
@ -151,7 +150,7 @@ public class SignListener implements Listener {
|
||||
*/
|
||||
private String replaceCost(double cost, TranslatableMessage message) {
|
||||
String unit = EconomyManager.getCurrency(cost != 1);
|
||||
return String.format(StringFormatter.replacePlaceholders(PaidSigns.getTranslator(), message,
|
||||
return String.format(PaidSigns.getStringFormatter().replacePlaceholders(message,
|
||||
new String[]{"{cost}", "{unit}"}, new String[]{"%.2f", "%s"}), cost, unit);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.knarcraft.paidsigns.manager;
|
||||
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
import net.knarcraft.paidsigns.PaidSigns;
|
||||
import net.knarcraft.paidsigns.container.TrackedSign;
|
||||
import net.knarcraft.paidsigns.formatting.PaidSignsTranslatableMessage;
|
||||
@ -155,8 +154,8 @@ public final class TrackedSignManager {
|
||||
double refundSum = trackedSign.cost() / 100 * PaidSigns.getInstance().getRefundPercentage();
|
||||
EconomyManager.deposit(offlinePlayer, refundSum);
|
||||
if (offlinePlayer instanceof Player player) {
|
||||
StringFormatter.displaySuccessMessage(player, String.format(StringFormatter.replacePlaceholders(
|
||||
PaidSigns.getTranslator(), PaidSignsTranslatableMessage.SUCCESS_REFUNDED,
|
||||
PaidSigns.getStringFormatter().displaySuccessMessage(player, String.format(
|
||||
PaidSigns.getStringFormatter().replacePlaceholders(PaidSignsTranslatableMessage.SUCCESS_REFUNDED,
|
||||
new String[]{"{cost}", "{unit}"}, new String[]{"%.2f", "%s"}), refundSum,
|
||||
EconomyManager.getCurrency(refundSum != 1)));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user