summaryrefslogtreecommitdiffstats
path: root/Essentials/src/net/ess3
diff options
context:
space:
mode:
Diffstat (limited to 'Essentials/src/net/ess3')
-rw-r--r--Essentials/src/net/ess3/api/Economy.java3
-rw-r--r--Essentials/src/net/ess3/commands/Commandbalance.java5
-rw-r--r--Essentials/src/net/ess3/commands/Commandbalancetop.java5
-rw-r--r--Essentials/src/net/ess3/commands/Commandbroadcast.java3
-rw-r--r--Essentials/src/net/ess3/commands/Commandhelpop.java3
-rw-r--r--Essentials/src/net/ess3/commands/Commandlist.java3
-rw-r--r--Essentials/src/net/ess3/commands/Commandmail.java5
-rw-r--r--Essentials/src/net/ess3/commands/Commandme.java5
-rw-r--r--Essentials/src/net/ess3/commands/Commandmsg.java7
-rw-r--r--Essentials/src/net/ess3/commands/Commandnick.java5
-rw-r--r--Essentials/src/net/ess3/commands/Commandping.java3
-rw-r--r--Essentials/src/net/ess3/commands/Commandr.java7
-rw-r--r--Essentials/src/net/ess3/commands/Commandrealname.java5
-rw-r--r--Essentials/src/net/ess3/commands/Commandsell.java5
-rw-r--r--Essentials/src/net/ess3/commands/Commandwhois.java7
-rw-r--r--Essentials/src/net/ess3/commands/Commandworth.java17
-rw-r--r--Essentials/src/net/ess3/economy/Economy.java3
-rw-r--r--Essentials/src/net/ess3/ranks/GMGroups.java3
-rw-r--r--Essentials/src/net/ess3/ranks/RanksStorage.java3
-rw-r--r--Essentials/src/net/ess3/ranks/VaultGroups.java3
-rw-r--r--Essentials/src/net/ess3/user/User.java15
-rw-r--r--Essentials/src/net/ess3/user/UserMap.java5
-rw-r--r--Essentials/src/net/ess3/utils/FormatUtil.java151
-rw-r--r--Essentials/src/net/ess3/utils/Util.java190
24 files changed, 222 insertions, 239 deletions
diff --git a/Essentials/src/net/ess3/api/Economy.java b/Essentials/src/net/ess3/api/Economy.java
index b16db0556..8b02dbbf1 100644
--- a/Essentials/src/net/ess3/api/Economy.java
+++ b/Essentials/src/net/ess3/api/Economy.java
@@ -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);
}
/**
diff --git a/Essentials/src/net/ess3/commands/Commandbalance.java b/Essentials/src/net/ess3/commands/Commandbalance.java
index a51083e2f..a7c89e63a 100644
--- a/Essentials/src/net/ess3/commands/Commandbalance.java
+++ b/Essentials/src/net/ess3/commands/Commandbalance.java
@@ -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)));
}
}
diff --git a/Essentials/src/net/ess3/commands/Commandbalancetop.java b/Essentials/src/net/ess3/commands/Commandbalancetop.java
index 2a9b5cd60..f085846c2 100644
--- a/Essentials/src/net/ess3/commands/Commandbalancetop.java
+++ b/Essentials/src/net/ess3/commands/Commandbalancetop.java
@@ -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();
diff --git a/Essentials/src/net/ess3/commands/Commandbroadcast.java b/Essentials/src/net/ess3/commands/Commandbroadcast.java
index c9620cb65..4f01c11bb 100644
--- a/Essentials/src/net/ess3/commands/Commandbroadcast.java
+++ b/Essentials/src/net/ess3/commands/Commandbroadcast.java
@@ -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))));
}
}
diff --git a/Essentials/src/net/ess3/commands/Commandhelpop.java b/Essentials/src/net/ess3/commands/Commandhelpop.java
index a80123c82..d3bb267fb 100644
--- a/Essentials/src/net/ess3/commands/Commandhelpop.java
+++ b/Essentials/src/net/ess3/commands/Commandhelpop.java
@@ -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())
{
diff --git a/Essentials/src/net/ess3/commands/Commandlist.java b/Essentials/src/net/ess3/commands/Commandlist.java
index 3469f8479..826dc12d2 100644
--- a/Essentials/src/net/ess3/commands/Commandlist.java
+++ b/Essentials/src/net/ess3/commands/Commandlist.java
@@ -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;
diff --git a/Essentials/src/net/ess3/commands/Commandmail.java b/Essentials/src/net/ess3/commands/Commandmail.java
index 5c5c9c371..935a31803 100644
--- a/Essentials/src/net/ess3/commands/Commandmail.java
+++ b/Essentials/src/net/ess3/commands/Commandmail.java
@@ -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;
}
diff --git a/Essentials/src/net/ess3/commands/Commandme.java b/Essentials/src/net/ess3/commands/Commandme.java
index 087b22b13..59c28fdfe 100644
--- a/Essentials/src/net/ess3/commands/Commandme.java
+++ b/Essentials/src/net/ess3/commands/Commandme.java
@@ -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);
}
diff --git a/Essentials/src/net/ess3/commands/Commandmsg.java b/Essentials/src/net/ess3/commands/Commandmsg.java
index 53872e942..35b01bcf6 100644
--- a/Essentials/src/net/ess3/commands/Commandmsg.java
+++ b/Essentials/src/net/ess3/commands/Commandmsg.java
@@ -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");
diff --git a/Essentials/src/net/ess3/commands/Commandnick.java b/Essentials/src/net/ess3/commands/Commandnick.java
index c521cc37c..0be72fd81 100644
--- a/Essentials/src/net/ess3/commands/Commandnick.java
+++ b/Essentials/src/net/ess3/commands/Commandnick.java
@@ -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);
}
}
diff --git a/Essentials/src/net/ess3/commands/Commandping.java b/Essentials/src/net/ess3/commands/Commandping.java
index 13e99b912..cf247e8de 100644
--- a/Essentials/src/net/ess3/commands/Commandping.java
+++ b/Essentials/src/net/ess3/commands/Commandping.java
@@ -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)));
}
}
}
diff --git a/Essentials/src/net/ess3/commands/Commandr.java b/Essentials/src/net/ess3/commands/Commandr.java
index 777be3d2a..d080c696f 100644
--- a/Essentials/src/net/ess3/commands/Commandr.java
+++ b/Essentials/src/net/ess3/commands/Commandr.java
@@ -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;
}
diff --git a/Essentials/src/net/ess3/commands/Commandrealname.java b/Essentials/src/net/ess3/commands/Commandrealname.java
index dcd30abb0..a5b5e933c 100644
--- a/Essentials/src/net/ess3/commands/Commandrealname.java
+++ b/Essentials/src/net/ess3/commands/Commandrealname.java
@@ -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;
diff --git a/Essentials/src/net/ess3/commands/Commandsell.java b/Essentials/src/net/ess3/commands/Commandsell.java
index 7ae290953..06d759d90 100644
--- a/Essentials/src/net/ess3/commands/Commandsell.java
+++ b/Essentials/src/net/ess3/commands/Commandsell.java
@@ -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)));
}
}
diff --git a/Essentials/src/net/ess3/commands/Commandwhois.java b/Essentials/src/net/ess3/commands/Commandwhois.java
index b6eeaa2db..1b4d8fae4 100644
--- a/Essentials/src/net/ess3/commands/Commandwhois.java
+++ b/Essentials/src/net/ess3/commands/Commandwhois.java
@@ -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
diff --git a/Essentials/src/net/ess3/commands/Commandworth.java b/Essentials/src/net/ess3/commands/Commandworth.java
index 9bf9ca561..bfcb81d81 100644
--- a/Essentials/src/net/ess3/commands/Commandworth.java
+++ b/Essentials/src/net/ess3/commands/Commandworth.java
@@ -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)));
}
}
diff --git a/Essentials/src/net/ess3/economy/Economy.java b/Essentials/src/net/ess3/economy/Economy.java
index cfd1f899e..0eef9e99a 100644
--- a/Essentials/src/net/ess3/economy/Economy.java
+++ b/Essentials/src/net/ess3/economy/Economy.java
@@ -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
diff --git a/Essentials/src/net/ess3/ranks/GMGroups.java b/Essentials/src/net/ess3/ranks/GMGroups.java
index 3cda0003a..3c38eaff2 100644
--- a/Essentials/src/net/ess3/ranks/GMGroups.java
+++ b/Essentials/src/net/ess3/ranks/GMGroups.java
@@ -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");
diff --git a/Essentials/src/net/ess3/ranks/RanksStorage.java b/Essentials/src/net/ess3/ranks/RanksStorage.java
index c99deb535..d76077b6c 100644
--- a/Essentials/src/net/ess3/ranks/RanksStorage.java
+++ b/Essentials/src/net/ess3/ranks/RanksStorage.java
@@ -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");
diff --git a/Essentials/src/net/ess3/ranks/VaultGroups.java b/Essentials/src/net/ess3/ranks/VaultGroups.java
index 76bad31eb..d6cc35d10 100644
--- a/Essentials/src/net/ess3/ranks/VaultGroups.java
+++ b/Essentials/src/net/ess3/ranks/VaultGroups.java
@@ -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");
diff --git a/Essentials/src/net/ess3/user/User.java b/Essentials/src/net/ess3/user/User.java
index 9409fa321..e066ebc05 100644
--- a/Essentials/src/net/ess3/user/User.java
+++ b/Essentials/src/net/ess3/user/User.java
@@ -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
diff --git a/Essentials/src/net/ess3/user/UserMap.java b/Essentials/src/net/ess3/user/UserMap.java
index e821e7785..011ee578e 100644
--- a/Essentials/src/net/ess3/user/UserMap.java
+++ b/Essentials/src/net/ess3/user/UserMap.java
@@ -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())
diff --git a/Essentials/src/net/ess3/utils/FormatUtil.java b/Essentials/src/net/ess3/utils/FormatUtil.java
new file mode 100644
index 000000000..f84368901
--- /dev/null
+++ b/Essentials/src/net/ess3/utils/FormatUtil.java
@@ -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;
+ }
+
+}
diff --git a/Essentials/src/net/ess3/utils/Util.java b/Essentials/src/net/ess3/utils/Util.java
index 23d334638..7814c519d 100644
--- a/Essentials/src/net/ess3/utils/Util.java
+++ b/Essentials/src/net/ess3/utils/Util.java
@@ -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");
- }
}