mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-16 03:24:31 +02:00
Move format methods from Util to FormatUtil
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package net.ess3.api;
|
||||
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
|
||||
|
||||
@@ -169,7 +170,7 @@ public final class Economy
|
||||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
}
|
||||
return Util.displayCurrency(amount, ess);
|
||||
return FormatUtil.displayCurrency(amount, ess);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -3,6 +3,7 @@ package net.ess3.commands;
|
||||
import static net.ess3.I18n._;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.permissions.Permissions;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -16,7 +17,7 @@ public class Commandbalance extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
sender.sendMessage(_("balance", Util.displayCurrency(ess.getUserMap().matchUser(args[0], true, true).getMoney(), ess)));
|
||||
sender.sendMessage(_("balance", FormatUtil.displayCurrency(ess.getUserMap().matchUser(args[0], true, true).getMoney(), ess)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -26,6 +27,6 @@ public class Commandbalance extends EssentialsCommand
|
||||
|| !Permissions.BALANCE_OTHERS.isAuthorized(user)
|
||||
? user
|
||||
: ess.getUserMap().matchUser(args[0], true, true)).getMoney();
|
||||
user.sendMessage(_("balance", Util.displayCurrency(bal, ess)));
|
||||
user.sendMessage(_("balance", FormatUtil.displayCurrency(bal, ess)));
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import java.util.Map.Entry;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import static net.ess3.I18n._;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
import net.ess3.utils.textreader.ArrayListInput;
|
||||
import net.ess3.utils.textreader.TextPager;
|
||||
@@ -125,11 +126,11 @@ public class Commandbalancetop extends EssentialsCommand
|
||||
}
|
||||
});
|
||||
|
||||
cache.getLines().add(_("serverTotal", Util.displayCurrency(totalMoney, ess)));
|
||||
cache.getLines().add(_("serverTotal", FormatUtil.displayCurrency(totalMoney, ess)));
|
||||
int pos = 1;
|
||||
for (Map.Entry<String, Double> entry : sortedEntries)
|
||||
{
|
||||
cache.getLines().add(pos + ". " + entry.getKey() + ", " + Util.displayCurrency(entry.getValue(), ess));
|
||||
cache.getLines().add(pos + ". " + entry.getKey() + ", " + FormatUtil.displayCurrency(entry.getValue(), ess));
|
||||
pos++;
|
||||
}
|
||||
cacheage = System.currentTimeMillis();
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package net.ess3.commands;
|
||||
|
||||
import static net.ess3.I18n._;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -15,6 +16,6 @@ public class Commandbroadcast extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
ess.broadcastMessage(null, _("broadcast", Util.replaceFormat(getFinalArg(args, 0))));
|
||||
ess.broadcastMessage(null, _("broadcast", FormatUtil.replaceFormat(getFinalArg(args, 0))));
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import java.util.logging.Level;
|
||||
import static net.ess3.I18n._;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.permissions.Permissions;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -18,7 +19,7 @@ public class Commandhelpop extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
user.setDisplayNick();
|
||||
final String message = _("helpOp", user.getPlayer().getDisplayName(), Util.stripFormat(getFinalArg(args, 0)));
|
||||
final String message = _("helpOp", user.getPlayer().getDisplayName(), FormatUtil.stripFormat(getFinalArg(args, 0)));
|
||||
logger.log(Level.INFO, message);
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
|
@@ -5,6 +5,7 @@ import static net.ess3.I18n._;
|
||||
import net.ess3.api.ISettings;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.permissions.Permissions;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -75,7 +76,7 @@ public class Commandlist extends EssentialsCommand
|
||||
for (String group : groups)
|
||||
{
|
||||
final StringBuilder groupString = new StringBuilder();
|
||||
groupString.append(_("listGroupTag",Util.replaceFormat(group)));
|
||||
groupString.append(_("listGroupTag",FormatUtil.replaceFormat(group)));
|
||||
final List<IUser> users = sort.get(group);
|
||||
Collections.sort(users);
|
||||
boolean first = true;
|
||||
|
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
import static net.ess3.I18n._;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.permissions.Permissions;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -43,7 +44,7 @@ public class Commandmail extends EssentialsCommand
|
||||
}
|
||||
if (!u.isIgnoringPlayer(user))
|
||||
{
|
||||
final String mail = Util.sanitizeString(Util.stripFormat(getFinalArg(args, 2)));
|
||||
final String mail = Util.sanitizeString(FormatUtil.stripFormat(getFinalArg(args, 2)));
|
||||
u.addMail(user.getName() + ": " + mail);
|
||||
}
|
||||
user.sendMessage(_("mailSent"));
|
||||
@@ -55,7 +56,7 @@ public class Commandmail extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(_("noPerm", "essentials.mail.sendall"));
|
||||
}
|
||||
ess.getPlugin().scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + Util.stripColor(getFinalArg(args, 1))));
|
||||
ess.getPlugin().scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + FormatUtil.stripColor(getFinalArg(args, 1))));
|
||||
user.sendMessage(_("mailSent"));
|
||||
return;
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package net.ess3.commands;
|
||||
import static net.ess3.I18n._;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.permissions.Permissions;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
|
||||
|
||||
@@ -24,10 +25,10 @@ public class Commandme extends EssentialsCommand
|
||||
String message = getFinalArg(args, 0);
|
||||
if (Permissions.CHAT_COLOR.isAuthorized(user))
|
||||
{
|
||||
message = Util.replaceFormat(message);
|
||||
message = FormatUtil.replaceFormat(message);
|
||||
}
|
||||
else {
|
||||
message = Util.stripColor(message);
|
||||
message = FormatUtil.stripColor(message);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -8,6 +8,7 @@ import static net.ess3.I18n._;
|
||||
import net.ess3.api.IReplyTo;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.permissions.Permissions;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -35,16 +36,16 @@ public class Commandmsg extends EssentialsCommand
|
||||
}
|
||||
if (Permissions.MSG_COLOR.isAuthorized(user))
|
||||
{
|
||||
message = Util.replaceFormat(message);
|
||||
message = FormatUtil.replaceFormat(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.stripColor(message);
|
||||
message = FormatUtil.stripColor(message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.replaceFormat(message);
|
||||
message = FormatUtil.replaceFormat(message);
|
||||
}
|
||||
|
||||
final String translatedMe = _("me");
|
||||
|
@@ -6,6 +6,7 @@ import static net.ess3.I18n._;
|
||||
import net.ess3.api.ISettings;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.permissions.Permissions;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -70,11 +71,11 @@ public class Commandnick extends EssentialsCommand
|
||||
{
|
||||
if (user == null || Permissions.NICK_COLOR.isAuthorized(user))
|
||||
{
|
||||
return Util.replaceFormat(nick);
|
||||
return FormatUtil.replaceFormat(nick);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Util.formatString(user, "essentials.nick", nick);
|
||||
return FormatUtil.formatString(user, "essentials.nick", nick);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,6 +2,7 @@ package net.ess3.commands;
|
||||
|
||||
import static net.ess3.I18n._;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
|
||||
|
||||
@@ -16,7 +17,7 @@ public class Commandping extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.replaceFormat(getFinalArg(args, 0)));
|
||||
user.sendMessage(FormatUtil.replaceFormat(getFinalArg(args, 0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@ import static net.ess3.I18n._;
|
||||
import net.ess3.api.IReplyTo;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.permissions.Permissions;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -29,18 +30,18 @@ public class Commandr extends EssentialsCommand
|
||||
IUser user = ess.getUserMap().getUser((Player)sender);
|
||||
if (Permissions.MSG_COLOR.isAuthorized(user))
|
||||
{
|
||||
message = Util.replaceFormat(message);
|
||||
message = FormatUtil.replaceFormat(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.replaceFormat(message);
|
||||
message = FormatUtil.replaceFormat(message);
|
||||
}
|
||||
replyTo = user;
|
||||
senderName = user.getPlayer().getDisplayName();
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.replaceFormat(message);
|
||||
message = FormatUtil.replaceFormat(message);
|
||||
replyTo = Console.getConsoleReplyTo();
|
||||
senderName = Console.NAME;
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@ import lombok.Cleanup;
|
||||
import static net.ess3.I18n._;
|
||||
import net.ess3.api.ISettings;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -30,10 +31,10 @@ public class Commandrealname extends EssentialsCommand
|
||||
continue;
|
||||
}
|
||||
u.setDisplayNick();
|
||||
final String displayName = Util.stripFormat(u.getPlayer().getDisplayName()).toLowerCase(Locale.ENGLISH);
|
||||
final String displayName = FormatUtil.stripFormat(u.getPlayer().getDisplayName()).toLowerCase(Locale.ENGLISH);
|
||||
settings.acquireReadLock();
|
||||
if (!whois.equals(displayName)
|
||||
&& !displayName.equals(Util.stripFormat(settings.getData().getChat().getNicknamePrefix()) + whois)
|
||||
&& !displayName.equals(FormatUtil.stripFormat(settings.getData().getChat().getNicknamePrefix()) + whois)
|
||||
&& !whois.equalsIgnoreCase(u.getName()))
|
||||
{
|
||||
continue;
|
||||
|
@@ -6,6 +6,7 @@ import static net.ess3.I18n._;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.craftbukkit.InventoryWorkaround;
|
||||
import net.ess3.economy.Trade;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -146,8 +147,8 @@ public class Commandsell extends EssentialsCommand
|
||||
user.getPlayer().updateInventory();
|
||||
Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(worth * amount, ess), user.getPlayer().getLocation(), ess);
|
||||
user.giveMoney(worth * amount);
|
||||
user.sendMessage(_("itemSold", Util.displayCurrency(worth * amount, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth, ess)));
|
||||
logger.log(Level.INFO, _("itemSoldConsole", user.getPlayer().getDisplayName(), is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth * amount, ess), amount, Util.displayCurrency(worth, ess)));
|
||||
user.sendMessage(_("itemSold", FormatUtil.displayCurrency(worth * amount, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), FormatUtil.displayCurrency(worth, ess)));
|
||||
logger.log(Level.INFO, _("itemSoldConsole", user.getPlayer().getDisplayName(), is.getType().toString().toLowerCase(Locale.ENGLISH), FormatUtil.displayCurrency(worth * amount, ess), amount, FormatUtil.displayCurrency(worth, ess)));
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@ import net.ess3.craftbukkit.SetExpFix;
|
||||
import net.ess3.permissions.Permissions;
|
||||
import net.ess3.user.UserData;
|
||||
import net.ess3.utils.DateUtil;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -40,7 +41,7 @@ public class Commandwhois extends EssentialsCommand
|
||||
@Cleanup
|
||||
ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
final int prefixLength = Util.stripColor(settings.getData().getChat().getNicknamePrefix()).length();
|
||||
final int prefixLength = FormatUtil.stripColor(settings.getData().getChat().getNicknamePrefix()).length();
|
||||
boolean foundPlayer = false;
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
@@ -52,7 +53,7 @@ public class Commandwhois extends EssentialsCommand
|
||||
continue;
|
||||
}
|
||||
user.acquireReadLock();
|
||||
final String nickName = Util.stripFormat(user.getData().getNickname());
|
||||
final String nickName = FormatUtil.stripFormat(user.getData().getNickname());
|
||||
if (!whois.equalsIgnoreCase(nickName)
|
||||
&& !whois.substring(prefixLength).equalsIgnoreCase(nickName)
|
||||
&& !whois.equalsIgnoreCase(user.getName()))
|
||||
@@ -66,7 +67,7 @@ public class Commandwhois extends EssentialsCommand
|
||||
sender.sendMessage(_("whoisHealth", user.getPlayer().getHealth()));
|
||||
sender.sendMessage(_("whoisExp", SetExpFix.getTotalExperience(user.getPlayer()), user.getPlayer().getLevel()));
|
||||
sender.sendMessage(_("whoisLocation", user.getPlayer().getLocation().getWorld().getName(), user.getPlayer().getLocation().getBlockX(), user.getPlayer().getLocation().getBlockY(), user.getPlayer().getLocation().getBlockZ()));
|
||||
sender.sendMessage(_("whoisMoney", Util.displayCurrency(user.getMoney(), ess)));
|
||||
sender.sendMessage(_("whoisMoney", FormatUtil.displayCurrency(user.getMoney(), ess)));
|
||||
sender.sendMessage(_("whoisIPAddress", user.getPlayer().getAddress().getAddress().toString()));
|
||||
final String location = user.getData().getGeolocation();
|
||||
if (location != null
|
||||
|
@@ -3,6 +3,7 @@ package net.ess3.commands;
|
||||
import java.util.Locale;
|
||||
import static net.ess3.I18n._;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -45,14 +46,14 @@ public class Commandworth extends EssentialsCommand
|
||||
? _("worthMeta",
|
||||
iStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""),
|
||||
iStack.getDurability(),
|
||||
Util.displayCurrency(worth * amount, ess),
|
||||
FormatUtil.displayCurrency(worth * amount, ess),
|
||||
amount,
|
||||
Util.displayCurrency(worth, ess))
|
||||
FormatUtil.displayCurrency(worth, ess))
|
||||
: _("worth",
|
||||
iStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""),
|
||||
Util.displayCurrency(worth * amount, ess),
|
||||
FormatUtil.displayCurrency(worth * amount, ess),
|
||||
amount,
|
||||
Util.displayCurrency(worth, ess)));
|
||||
FormatUtil.displayCurrency(worth, ess)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,14 +90,14 @@ public class Commandworth extends EssentialsCommand
|
||||
? _("worthMeta",
|
||||
iStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""),
|
||||
iStack.getDurability(),
|
||||
Util.displayCurrency(worth * amount, ess),
|
||||
FormatUtil.displayCurrency(worth * amount, ess),
|
||||
amount,
|
||||
Util.displayCurrency(worth, ess))
|
||||
FormatUtil.displayCurrency(worth, ess))
|
||||
: _("worth",
|
||||
iStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""),
|
||||
Util.displayCurrency(worth * amount, ess),
|
||||
FormatUtil.displayCurrency(worth * amount, ess),
|
||||
amount,
|
||||
Util.displayCurrency(worth, ess)));
|
||||
FormatUtil.displayCurrency(worth, ess)));
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import net.ess3.api.*;
|
||||
import net.ess3.permissions.Permissions;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
|
||||
|
||||
@@ -123,7 +124,7 @@ public class Economy implements IEconomy
|
||||
@Override
|
||||
public String format(double amount)
|
||||
{
|
||||
return Util.displayCurrency(amount, ess);
|
||||
return FormatUtil.displayCurrency(amount, ess);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -6,6 +6,7 @@ import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.IRanks;
|
||||
import net.ess3.api.ISettings;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
|
||||
@@ -91,7 +92,7 @@ public class GMGroups implements IRanks {
|
||||
public MessageFormat getChatFormat(final IUser player)
|
||||
{
|
||||
String format = getRawChatFormat(player);
|
||||
format = Util.replaceFormat(format);
|
||||
format = FormatUtil.replaceFormat(format);
|
||||
format = format.replace("{DISPLAYNAME}", "%1$s");
|
||||
format = format.replace("{GROUP}", "{0}");
|
||||
format = format.replace("{MESSAGE}", "%2$s");
|
||||
|
@@ -14,6 +14,7 @@ import net.ess3.api.ISettings;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.permissions.GroupsPermissions;
|
||||
import net.ess3.storage.AsyncStorageObjectHolder;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
|
||||
|
||||
@@ -155,7 +156,7 @@ public class RanksStorage extends AsyncStorageObjectHolder<Ranks> implements IRa
|
||||
public MessageFormat getChatFormat(final IUser player)
|
||||
{
|
||||
String format = getRawChatFormat(player);
|
||||
format = Util.replaceFormat(format);
|
||||
format = FormatUtil.replaceFormat(format);
|
||||
format = format.replace("{DISPLAYNAME}", "%1$s");
|
||||
format = format.replace("{GROUP}", "{0}");
|
||||
format = format.replace("{MESSAGE}", "%2$s");
|
||||
|
@@ -6,6 +6,7 @@ import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.IRanks;
|
||||
import net.ess3.api.ISettings;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
@@ -71,7 +72,7 @@ public class VaultGroups implements IRanks
|
||||
public MessageFormat getChatFormat(final IUser player)
|
||||
{
|
||||
String format = getRawChatFormat(player);
|
||||
format = Util.replaceFormat(format);
|
||||
format = FormatUtil.replaceFormat(format);
|
||||
format = format.replace("{DISPLAYNAME}", "%1$s");
|
||||
format = format.replace("{GROUP}", "{0}");
|
||||
format = format.replace("{MESSAGE}", "%2$s");
|
||||
|
@@ -17,6 +17,7 @@ import net.ess3.craftbukkit.InventoryWorkaround;
|
||||
import net.ess3.economy.register.Method;
|
||||
import net.ess3.permissions.Permissions;
|
||||
import net.ess3.utils.DateUtil;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -154,10 +155,10 @@ public class User extends UserBase implements IUser
|
||||
try
|
||||
{
|
||||
setMoney(getMoney() + value);
|
||||
sendMessage(_("addedToAccount", Util.displayCurrency(value, ess)));
|
||||
sendMessage(_("addedToAccount", FormatUtil.displayCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage(_("addedToOthersAccount", Util.displayCurrency(value, ess), this.getPlayer().getDisplayName()));
|
||||
initiator.sendMessage(_("addedToOthersAccount", FormatUtil.displayCurrency(value, ess), this.getPlayer().getDisplayName()));
|
||||
}
|
||||
}
|
||||
finally
|
||||
@@ -177,8 +178,8 @@ public class User extends UserBase implements IUser
|
||||
{
|
||||
setMoney(getMoney() - value);
|
||||
reciever.setMoney(reciever.getMoney() + value);
|
||||
sendMessage(_("moneySentTo", Util.displayCurrency(value, ess), reciever.getPlayer().getDisplayName()));
|
||||
reciever.sendMessage(_("moneyRecievedFrom", Util.displayCurrency(value, ess), getPlayer().getDisplayName()));
|
||||
sendMessage(_("moneySentTo", FormatUtil.displayCurrency(value, ess), reciever.getPlayer().getDisplayName()));
|
||||
reciever.sendMessage(_("moneyRecievedFrom", FormatUtil.displayCurrency(value, ess), getPlayer().getDisplayName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -200,10 +201,10 @@ public class User extends UserBase implements IUser
|
||||
return;
|
||||
}
|
||||
setMoney(getMoney() - value);
|
||||
sendMessage(_("takenFromAccount", Util.displayCurrency(value, ess)));
|
||||
sendMessage(_("takenFromAccount", FormatUtil.displayCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage(_("takenFromOthersAccount", Util.displayCurrency(value, ess), this.getPlayer().getDisplayName()));
|
||||
initiator.sendMessage(_("takenFromOthersAccount", FormatUtil.displayCurrency(value, ess), this.getPlayer().getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -573,7 +574,7 @@ public class User extends UserBase implements IUser
|
||||
@Override
|
||||
public int compareTo(final IUser t)
|
||||
{
|
||||
return Util.stripColor(this.getPlayer().getDisplayName()).compareTo(Util.stripColor(t.getPlayer().getDisplayName()));
|
||||
return FormatUtil.stripColor(this.getPlayer().getDisplayName()).compareTo(FormatUtil.stripColor(t.getPlayer().getDisplayName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -10,6 +10,7 @@ import net.ess3.api.IUser;
|
||||
import net.ess3.api.IUserMap;
|
||||
import net.ess3.api.InvalidNameException;
|
||||
import net.ess3.storage.StorageObjectMap;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -121,11 +122,11 @@ public class UserMap extends StorageObjectMap<IUser> implements IUserMap
|
||||
@Override
|
||||
public Set<IUser> matchUsers(final String name, final boolean includeHidden, final boolean includeOffline)
|
||||
{
|
||||
final String colorlessName = Util.stripColor(name);
|
||||
final String colorlessName = FormatUtil.stripColor(name);
|
||||
final String[] search = colorlessName.split(",");
|
||||
final boolean multisearch = search.length > 1;
|
||||
final Set<IUser> result = new LinkedHashSet<IUser>();
|
||||
final String nicknamePrefix = Util.stripColor(getNickNamePrefix());
|
||||
final String nicknamePrefix = FormatUtil.stripColor(getNickNamePrefix());
|
||||
for (String searchString : search)
|
||||
{
|
||||
if (searchString.isEmpty())
|
||||
|
151
Essentials/src/net/ess3/utils/FormatUtil.java
Normal file
151
Essentials/src/net/ess3/utils/FormatUtil.java
Normal file
@@ -0,0 +1,151 @@
|
||||
package net.ess3.utils;
|
||||
|
||||
import de.bananaco.bpermissions.imp.Permissions;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Pattern;
|
||||
import lombok.Cleanup;
|
||||
import static net.ess3.I18n._;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.ISettings;
|
||||
import net.ess3.api.IUser;
|
||||
|
||||
public class FormatUtil {
|
||||
static final transient Pattern REPLACE_COLOR_PATTERN = Pattern.compile("&([0-9a-f])");
|
||||
static final transient Pattern REPLACE_MAGIC_PATTERN = Pattern.compile("&(k)");
|
||||
static final transient Pattern REPLACE_PATTERN = Pattern.compile("&([0-9a-fk-or])");
|
||||
static final transient Pattern VANILLA_PATTERN = Pattern.compile("\u00a7+[0-9A-FK-ORa-fk-or]");
|
||||
static final transient Pattern VANILLA_COLOR_PATTERN = Pattern.compile("\u00a7+[0-9A-Fa-f]");
|
||||
static final transient Pattern REPLACE_FORMAT_PATTERN = Pattern.compile("&([l-or])");
|
||||
static final transient Pattern VANILLA_FORMAT_PATTERN = Pattern.compile("\u00a7+[L-ORl-or]");
|
||||
static final transient Pattern VANILLA_MAGIC_PATTERN = Pattern.compile("\u00a7+[Kk]");
|
||||
static final transient Pattern URL_PATTERN = Pattern.compile("((?:(?:https?)://)?[\\w-_\\.]{2,})\\.([a-z]{2,3}(?:/\\S+)?)");
|
||||
static DecimalFormat dFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
|
||||
|
||||
static String stripColor(final String input, final Pattern pattern)
|
||||
{
|
||||
return pattern.matcher(input).replaceAll("");
|
||||
}
|
||||
|
||||
public static String stripColor(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return VANILLA_COLOR_PATTERN.matcher(input).replaceAll("");
|
||||
}
|
||||
|
||||
public static String blockURL(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String text = URL_PATTERN.matcher(input).replaceAll("$1 $2");
|
||||
while (URL_PATTERN.matcher(text).find())
|
||||
{
|
||||
text = URL_PATTERN.matcher(text).replaceAll("$1 $2");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
static String replaceColor(final String input, final Pattern pattern)
|
||||
{
|
||||
return pattern.matcher(input).replaceAll("\u00a7$1");
|
||||
}
|
||||
|
||||
public static String stripFormat(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return VANILLA_PATTERN.matcher(input).replaceAll("");
|
||||
}
|
||||
|
||||
public static String replaceFormat(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return REPLACE_PATTERN.matcher(input).replaceAll("\u00a7$1");
|
||||
}
|
||||
|
||||
public static String formatString(final IUser user, final String permBase, final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String message;
|
||||
if (Permissions.hasPermission(user.getPlayer(), permBase + ".color"))
|
||||
{
|
||||
message = replaceColor(input, REPLACE_COLOR_PATTERN);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = stripColor(input, VANILLA_COLOR_PATTERN);
|
||||
}
|
||||
if (Permissions.hasPermission(user.getPlayer(), permBase + ".magic"))
|
||||
{
|
||||
message = replaceColor(message, REPLACE_MAGIC_PATTERN);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = stripColor(message, VANILLA_MAGIC_PATTERN);
|
||||
}
|
||||
if (Permissions.hasPermission(user.getPlayer(), permBase + ".format"))
|
||||
{
|
||||
message = replaceColor(message, REPLACE_FORMAT_PATTERN);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = stripColor(message, VANILLA_FORMAT_PATTERN);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public static String formatMessage(final IUser user, final String permBase, final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String message = formatString(user, permBase, input);
|
||||
if (!Permissions.hasPermission(user.getPlayer(), permBase + ".url"))
|
||||
{
|
||||
message = blockURL(message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public static String shortCurrency(final double value, final IEssentials ess)
|
||||
{
|
||||
@Cleanup
|
||||
final ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
return settings.getData().getEconomy().getCurrencySymbol() + formatAsCurrency(value);
|
||||
}
|
||||
|
||||
public static String displayCurrency(final double value, final IEssentials ess)
|
||||
{
|
||||
@Cleanup
|
||||
final ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
return _("currency", settings.getData().getEconomy().getCurrencySymbol(), formatAsCurrency(value));
|
||||
}
|
||||
|
||||
public static String formatAsCurrency(final double value)
|
||||
{
|
||||
String str = dFormat.format(value);
|
||||
if (str.endsWith(".00"))
|
||||
{
|
||||
str = str.substring(0, str.length() - 3);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
@@ -1,26 +1,14 @@
|
||||
package net.ess3.utils;
|
||||
|
||||
import de.bananaco.bpermissions.imp.Permissions;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Pattern;
|
||||
import lombok.Cleanup;
|
||||
import static net.ess3.I18n._;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.ISettings;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.api.InvalidNameException;
|
||||
import net.ess3.utils.gnu.inet.encoding.Punycode;
|
||||
import net.ess3.utils.gnu.inet.encoding.PunycodeException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
|
||||
public final class Util
|
||||
@@ -171,34 +159,6 @@ public final class Util
|
||||
}
|
||||
return is;
|
||||
}
|
||||
private static DecimalFormat dFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
|
||||
|
||||
public static String formatAsCurrency(final double value)
|
||||
{
|
||||
|
||||
String str = dFormat.format(value);
|
||||
if (str.endsWith(".00"))
|
||||
{
|
||||
str = str.substring(0, str.length() - 3);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String displayCurrency(final double value, final IEssentials ess)
|
||||
{
|
||||
@Cleanup
|
||||
final ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
return _("currency", settings.getData().getEconomy().getCurrencySymbol(), formatAsCurrency(value));
|
||||
}
|
||||
|
||||
public static String shortCurrency(final double value, final IEssentials ess)
|
||||
{
|
||||
@Cleanup
|
||||
final ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
return settings.getData().getEconomy().getCurrencySymbol() + formatAsCurrency(value);
|
||||
}
|
||||
|
||||
public static double roundDouble(final double d)
|
||||
{
|
||||
@@ -251,154 +211,4 @@ public final class Util
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public static void registerPermissions(String path, Collection<String> nodes, boolean hasDefault, IEssentials ess)
|
||||
{
|
||||
if (nodes == null || nodes.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PluginManager pluginManager = ess.getServer().getPluginManager();
|
||||
Permission basePerm = pluginManager.getPermission(path + ".*");
|
||||
if (basePerm != null && !basePerm.getChildren().isEmpty())
|
||||
{
|
||||
basePerm.getChildren().clear();
|
||||
}
|
||||
if (basePerm == null)
|
||||
{
|
||||
basePerm = new Permission(path + ".*", PermissionDefault.OP);
|
||||
pluginManager.addPermission(basePerm);
|
||||
Permission mainPerm = pluginManager.getPermission("essentials.*");
|
||||
if (mainPerm == null)
|
||||
{
|
||||
mainPerm = new Permission("essentials.*", PermissionDefault.OP);
|
||||
pluginManager.addPermission(mainPerm);
|
||||
}
|
||||
mainPerm.getChildren().put(basePerm.getName(), Boolean.TRUE);
|
||||
}
|
||||
|
||||
for (String nodeName : nodes)
|
||||
{
|
||||
final String permissionName = path + "." + nodeName;
|
||||
Permission perm = pluginManager.getPermission(permissionName);
|
||||
if (perm == null)
|
||||
{
|
||||
final PermissionDefault defaultPerm = hasDefault && nodeName.equalsIgnoreCase("default") ? PermissionDefault.TRUE : PermissionDefault.OP;
|
||||
perm = new Permission(permissionName, defaultPerm);
|
||||
pluginManager.addPermission(perm);
|
||||
}
|
||||
basePerm.getChildren().put(permissionName, Boolean.TRUE);
|
||||
}
|
||||
basePerm.recalculatePermissibles();
|
||||
}
|
||||
|
||||
private static transient final Pattern URL_PATTERN = Pattern.compile("((?:(?:https?)://)?[\\w-_\\.]{2,})\\.([a-z]{2,3}(?:/\\S+)?)");
|
||||
private static transient final Pattern VANILLA_PATTERN = Pattern.compile("\u00A7+[0-9A-FK-ORa-fk-or]");
|
||||
private static transient final Pattern REPLACE_PATTERN = Pattern.compile("&([0-9a-fk-or])");
|
||||
private static transient final Pattern VANILLA_COLOR_PATTERN = Pattern.compile("\u00A7+[0-9A-Fa-f]");
|
||||
private static transient final Pattern VANILLA_MAGIC_PATTERN = Pattern.compile("\u00A7+[Kk]");
|
||||
private static transient final Pattern VANILLA_FORMAT_PATTERN = Pattern.compile("\u00A7+[L-ORl-or]");
|
||||
private static transient final Pattern REPLACE_COLOR_PATTERN = Pattern.compile("&([0-9a-f])");
|
||||
private static transient final Pattern REPLACE_MAGIC_PATTERN = Pattern.compile("&(k)");
|
||||
private static transient final Pattern REPLACE_FORMAT_PATTERN = Pattern.compile("&([l-or])");
|
||||
|
||||
public static String stripFormat(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return VANILLA_PATTERN.matcher(input).replaceAll("");
|
||||
}
|
||||
|
||||
public static String replaceFormat(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return REPLACE_PATTERN.matcher(input).replaceAll("\u00a7$1");
|
||||
}
|
||||
|
||||
public static String blockURL(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String text = URL_PATTERN.matcher(input).replaceAll("$1 $2");
|
||||
while (URL_PATTERN.matcher(text).find())
|
||||
{
|
||||
text = URL_PATTERN.matcher(text).replaceAll("$1 $2");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
public static String formatString(final IUser user, final String permBase, final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String message;
|
||||
if (Permissions.hasPermission(user.getPlayer(), permBase + ".color"))
|
||||
{
|
||||
message = Util.replaceColor(input, REPLACE_COLOR_PATTERN);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.stripColor(input, VANILLA_COLOR_PATTERN);
|
||||
}
|
||||
if (Permissions.hasPermission(user.getPlayer(), permBase + ".magic"))
|
||||
{
|
||||
message = Util.replaceColor(message, REPLACE_MAGIC_PATTERN);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.stripColor(message, VANILLA_MAGIC_PATTERN);
|
||||
}
|
||||
if (Permissions.hasPermission(user.getPlayer(), permBase + ".format"))
|
||||
{
|
||||
message = Util.replaceColor(message, REPLACE_FORMAT_PATTERN);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.stripColor(message, VANILLA_FORMAT_PATTERN);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public static String formatMessage(final IUser user, final String permBase, final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String message = formatString(user, permBase, input);
|
||||
if (!Permissions.hasPermission(user.getPlayer(), permBase + ".url"))
|
||||
{
|
||||
message = Util.blockURL(message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public static String stripColor(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return VANILLA_COLOR_PATTERN.matcher(input).replaceAll("");
|
||||
}
|
||||
|
||||
private static String stripColor(final String input, final Pattern pattern)
|
||||
{
|
||||
return pattern.matcher(input).replaceAll("");
|
||||
}
|
||||
|
||||
private static String replaceColor(final String input, final Pattern pattern)
|
||||
{
|
||||
return pattern.matcher(input).replaceAll("\u00a7$1");
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package com.earth2me.essentials;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.NoLoanPermittedException;
|
||||
import net.ess3.api.UserDoesNotExistException;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
|
||||
|
||||
@@ -179,7 +180,7 @@ public final class Economy
|
||||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
}
|
||||
return Util.displayCurrency(amount, ess);
|
||||
return FormatUtil.displayCurrency(amount, ess);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -12,6 +12,7 @@ import net.ess3.utils.Util;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -80,7 +81,7 @@ public abstract class EssentialsChatPlayer implements Listener
|
||||
final IUser user = chatStore.getUser();
|
||||
if (Permissions.CHAT_COLOR.isAuthorized(user))
|
||||
{
|
||||
event.setMessage(Util.stripColor(event.getMessage()));
|
||||
event.setMessage(FormatUtil.stripColor(event.getMessage()));
|
||||
}
|
||||
String group = ess.getRanks().getMainGroup(user);
|
||||
String world = user.getPlayer().getWorld().getName();
|
||||
|
@@ -10,6 +10,7 @@ import net.ess3.api.IUser;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@@ -268,7 +269,7 @@ public class EssentialsSign
|
||||
final Double money = trade.getMoney();
|
||||
if (money != null)
|
||||
{
|
||||
sign.setLine(index, Util.shortCurrency(money, ess));
|
||||
sign.setLine(index, FormatUtil.shortCurrency(money, ess));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -3,6 +3,7 @@ package net.ess3.signs;
|
||||
import static net.ess3.I18n._;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import net.ess3.utils.Util;
|
||||
|
||||
|
||||
@@ -16,7 +17,7 @@ public class SignBalance extends EssentialsSign
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException
|
||||
{
|
||||
player.sendMessage(_("balance", Util.displayCurrency(player.getMoney(), ess)));
|
||||
player.sendMessage(_("balance", FormatUtil.displayCurrency(player.getMoney(), ess)));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import net.ess3.api.IUser;
|
||||
import net.ess3.utils.Util;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
@@ -91,7 +92,7 @@ public class SignBlockListener implements Listener
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
event.setLine(i, Util.formatString(user, "essentials.signs", event.getLine(i)));
|
||||
event.setLine(i, FormatUtil.formatString(user, "essentials.signs", event.getLine(i)));
|
||||
}
|
||||
|
||||
for (Signs signs : Signs.values())
|
||||
|
@@ -7,6 +7,7 @@ import net.ess3.api.IUser;
|
||||
import net.ess3.economy.Trade;
|
||||
import net.ess3.utils.Util;
|
||||
import java.util.*;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -147,7 +148,7 @@ public class SignProtection extends EssentialsSign
|
||||
{
|
||||
return SignProtectionState.OWNER;
|
||||
}
|
||||
if (Util.stripFormat(sign.getLine(3)).equalsIgnoreCase(username))
|
||||
if (FormatUtil.stripFormat(sign.getLine(3)).equalsIgnoreCase(username))
|
||||
{
|
||||
return SignProtectionState.OWNER;
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import net.ess3.economy.Trade;
|
||||
import net.ess3.utils.Util;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
//TODO: Sell Enchantment on Trade signs?
|
||||
@@ -140,11 +141,11 @@ public class SignTrade extends EssentialsSign
|
||||
final Double money = getMoney(split[0]);
|
||||
if (money != null)
|
||||
{
|
||||
if (Util.shortCurrency(money, ess).length() * 2 > 15)
|
||||
if (FormatUtil.shortCurrency(money, ess).length() * 2 > 15)
|
||||
{
|
||||
throw new SignException("Line can be too long!");
|
||||
}
|
||||
sign.setLine(index, Util.shortCurrency(money, ess) + ":0");
|
||||
sign.setLine(index, FormatUtil.shortCurrency(money, ess) + ":0");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -160,7 +161,7 @@ public class SignTrade extends EssentialsSign
|
||||
{
|
||||
throw new SignException(_("moreThanZero"));
|
||||
}
|
||||
sign.setLine(index, Util.shortCurrency(money, ess) + ":" + Util.shortCurrency(amount, ess).substring(1));
|
||||
sign.setLine(index, FormatUtil.shortCurrency(money, ess) + ":" + FormatUtil.shortCurrency(amount, ess).substring(1));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -318,7 +319,7 @@ public class SignTrade extends EssentialsSign
|
||||
final Double amount = getDouble(split[1]);
|
||||
if (money != null && amount != null)
|
||||
{
|
||||
final String newline = Util.shortCurrency(money, ess) + ":" + Util.shortCurrency(amount + value, ess).substring(1);
|
||||
final String newline = FormatUtil.shortCurrency(money, ess) + ":" + FormatUtil.shortCurrency(amount + value, ess).substring(1);
|
||||
if (newline.length() > 15)
|
||||
{
|
||||
throw new SignException("This sign is full: Line too long!");
|
||||
|
@@ -9,6 +9,7 @@ import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jivesoftware.smack.*;
|
||||
@@ -60,7 +61,7 @@ public final class XMPPManager extends Handler implements MessageListener, ChatM
|
||||
disconnect();
|
||||
connect();
|
||||
}
|
||||
chat.sendMessage(Util.stripFormat(message));
|
||||
chat.sendMessage(FormatUtil.stripFormat(message));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user