Split util classes.

This commit is contained in:
KHobbits 2013-06-08 22:31:19 +01:00
parent 98e427e831
commit 09f67c9723
103 changed files with 1245 additions and 1071 deletions

View file

@ -1,5 +1,7 @@
package com.earth2me.essentials;
import com.earth2me.essentials.utils.NumberUtil;
import com.earth2me.essentials.utils.StringUtil;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@ -142,7 +144,7 @@ public class Enchantments
public static Enchantment getByName(String name) {
Enchantment enchantment;
if (Util.isInt(name)) {
if (NumberUtil.isInt(name)) {
enchantment = Enchantment.getById(Integer.parseInt(name));
} else {
enchantment = Enchantment.getByName(name.toUpperCase(Locale.ENGLISH));

View file

@ -31,6 +31,7 @@ import com.earth2me.essentials.register.payment.Methods;
import com.earth2me.essentials.signs.SignBlockListener;
import com.earth2me.essentials.signs.SignEntityListener;
import com.earth2me.essentials.signs.SignPlayerListener;
import com.earth2me.essentials.utils.DateUtil;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
@ -411,7 +412,7 @@ public class Essentials extends JavaPlugin implements IEssentials
{
if (user.getJailTimeout() > 0)
{
user.sendMessage(_("playerJailedFor", user.getName(), Util.formatDateDiff(user.getJailTimeout())));
user.sendMessage(_("playerJailedFor", user.getName(), DateUtil.formatDateDiff(user.getJailTimeout())));
}
else
{

View file

@ -1,5 +1,7 @@
package com.earth2me.essentials;
import com.earth2me.essentials.utils.LocationUtil;
import com.earth2me.essentials.utils.StringUtil;
import org.bukkit.GameMode;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -22,7 +24,7 @@ public class EssentialsBlockListener implements Listener
{
// Do not rely on getItemInHand();
// http://leaky.bukkit.org/issues/663
final ItemStack is = Util.convertBlockToItem(event.getBlockPlaced());
final ItemStack is = LocationUtil.convertBlockToItem(event.getBlockPlaced());
if (is == null)
{
return;

View file

@ -5,6 +5,8 @@ import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.textreader.KeywordReplacer;
import com.earth2me.essentials.textreader.TextInput;
import com.earth2me.essentials.textreader.TextPager;
import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.LocationUtil;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
@ -117,7 +119,7 @@ public class EssentialsPlayerListener implements Listener
to.setZ(from.getZ());
try
{
event.setTo(Util.getSafeDestination(to));
event.setTo(LocationUtil.getSafeDestination(to));
}
catch (Exception ex)
{
@ -261,7 +263,7 @@ public class EssentialsPlayerListener implements Listener
final int x = user.getLocation().getBlockX();
int y = user.getLocation().getBlockY();
final int z = user.getLocation().getBlockZ();
while (Util.isBlockUnsafe(world, x, y, z) && y > -1)
while (LocationUtil.isBlockUnsafe(world, x, y, z) && y > -1)
{
y--;
}
@ -322,7 +324,7 @@ public class EssentialsPlayerListener implements Listener
if (user.getBanTimeout() > 0)
{
//TODO: TL This
banReason += "\n\n" + "Expires in " + Util.formatDateDiff(user.getBanTimeout());
banReason += "\n\n" + "Expires in " + DateUtil.formatDateDiff(user.getBanTimeout());
}
event.disallow(Result.KICK_BANNED, banReason);
return;
@ -491,7 +493,7 @@ public class EssentialsPlayerListener implements Listener
{
try
{
final Location otarget = Util.getTarget(user);
final Location otarget = LocationUtil.getTarget(user);
ess.scheduleSyncDelayedTask(
new Runnable()
@ -502,7 +504,7 @@ public class EssentialsPlayerListener implements Listener
Location loc = user.getLocation();
loc.setX(otarget.getX());
loc.setZ(otarget.getZ());
while (Util.isBlockDamaging(loc.getWorld(), loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ()))
while (LocationUtil.isBlockDamaging(loc.getWorld(), loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ()))
{
loc.setY(loc.getY() + 1d);
}

View file

@ -1,5 +1,6 @@
package com.earth2me.essentials;
import com.earth2me.essentials.utils.StringUtil;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.craftbukkit.FakeWorld;
import com.earth2me.essentials.settings.Spawns;
@ -580,7 +581,7 @@ public class EssentialsUpgrade
{
continue;
}
final String sanitizedFilename = Util.sanitizeFileName(filename.substring(0, filename.length() - 4)) + ".yml";
final String sanitizedFilename = StringUtil.sanitizeFileName(filename.substring(0, filename.length() - 4)) + ".yml";
if (sanitizedFilename.equals(filename))
{
continue;

View file

@ -1,7 +1,6 @@
package com.earth2me.essentials;
import org.bukkit.Location;
import org.bukkit.Server;
public interface ITarget

View file

@ -1,7 +1,9 @@
package com.earth2me.essentials;
import com.earth2me.essentials.utils.StringUtil;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IItemDb;
import com.earth2me.essentials.utils.NumberUtil;
import java.util.*;
import java.util.regex.Pattern;
import org.bukkit.Material;
@ -94,7 +96,7 @@ public class ItemDb implements IConf, IItemDb
itemid = Integer.parseInt(parts[0]);
metaData = Short.parseShort(parts[1]);
}
else if (Util.isInt(id))
else if (NumberUtil.isInt(id))
{
itemid = Integer.parseInt(id);
}
@ -158,7 +160,7 @@ public class ItemDb implements IConf, IItemDb
{
nameList = nameList.subList(0, 14);
}
return Util.joinList(", ", nameList);
return StringUtil.joinList(", ", nameList);
}

View file

@ -8,6 +8,8 @@ import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.textreader.KeywordReplacer;
import com.earth2me.essentials.textreader.SimpleTextInput;
import com.earth2me.essentials.utils.NumberUtil;
import com.earth2me.essentials.utils.DateUtil;
import java.math.BigDecimal;
import java.util.*;
import java.util.logging.Level;
@ -37,7 +39,7 @@ public class Kit
BigDecimal costPrice = new Trade("kit-" + kitItem.toLowerCase(Locale.ENGLISH), ess).getCommandCost(user);
if (costPrice.signum() > 0)
{
cost = _("kitCost", Util.displayCurrency(costPrice, ess));
cost = _("kitCost", NumberUtil.displayCurrency(costPrice, ess));
}
final Map<String, Object> kit = ess.getSettings().getKit(kitItem);
@ -74,7 +76,7 @@ public class Kit
}
else
{
user.sendMessage(_("kitTimed", Util.formatDateDiff(nextUse)));
user.sendMessage(_("kitTimed", DateUtil.formatDateDiff(nextUse)));
throw new NoChargeException();
}
}

View file

@ -1,9 +1,12 @@
package com.earth2me.essentials;
import com.earth2me.essentials.utils.StringUtil;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.textreader.BookInput;
import com.earth2me.essentials.textreader.BookPager;
import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.utils.FormatUtil;
import com.earth2me.essentials.utils.NumberUtil;
import java.util.*;
import java.util.regex.Pattern;
import org.bukkit.Color;
@ -126,7 +129,7 @@ public class MetaItemStack
if (split.length > 1 && split[0].equalsIgnoreCase("name") && hasMetaPermission(sender, "name", false, true, ess))
{
final String displayName = Util.replaceFormat(split[1].replace('_', ' '));
final String displayName = FormatUtil.replaceFormat(split[1].replace('_', ' '));
final ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(displayName);
stack.setItemMeta(meta);
@ -136,7 +139,7 @@ public class MetaItemStack
final List<String> lore = new ArrayList<String>();
for (String line : split[1].split("\\|"))
{
lore.add(Util.replaceFormat(line.replace('_', ' ')));
lore.add(FormatUtil.replaceFormat(line.replace('_', ' ')));
}
final ItemMeta meta = stack.getItemMeta();
meta.setLore(lore);
@ -176,14 +179,14 @@ public class MetaItemStack
}
else if (split.length > 1 && split[0].equalsIgnoreCase("title") && stack.getType() == Material.WRITTEN_BOOK && hasMetaPermission(sender, "title", false, true, ess))
{
final String title = Util.replaceFormat(split[1].replace('_', ' '));
final String title = FormatUtil.replaceFormat(split[1].replace('_', ' '));
final BookMeta meta = (BookMeta)stack.getItemMeta();
meta.setTitle(title);
stack.setItemMeta(meta);
}
else if (split.length > 1 && split[0].equalsIgnoreCase("power") && stack.getType() == Material.FIREWORK && hasMetaPermission(sender, "firework-power", false, true, ess))
{
final int power = Util.isInt(split[1]) ? Integer.parseInt(split[1]) : 0;
final int power = NumberUtil.isInt(split[1]) ? Integer.parseInt(split[1]) : 0;
final FireworkMeta meta = (FireworkMeta)stack.getItemMeta();
meta.setPower(power > 3 ? 4 : power);
stack.setItemMeta(meta);
@ -205,9 +208,9 @@ public class MetaItemStack
final String[] color = split[1].split("(\\||,)");
if (color.length == 3)
{
final int red = Util.isInt(color[0]) ? Integer.parseInt(color[0]) : 0;
final int green = Util.isInt(color[1]) ? Integer.parseInt(color[1]) : 0;
final int blue = Util.isInt(color[2]) ? Integer.parseInt(color[2]) : 0;
final int red = NumberUtil.isInt(color[0]) ? Integer.parseInt(color[0]) : 0;
final int green = NumberUtil.isInt(color[1]) ? Integer.parseInt(color[1]) : 0;
final int blue = NumberUtil.isInt(color[2]) ? Integer.parseInt(color[2]) : 0;
final LeatherArmorMeta meta = (LeatherArmorMeta)stack.getItemMeta();
meta.setColor(Color.fromRGB(red, green, blue));
stack.setItemMeta(meta);
@ -360,7 +363,7 @@ public class MetaItemStack
}
else if (split[0].equalsIgnoreCase("power") || (allowShortName && split[0].equalsIgnoreCase("p")))
{
if (Util.isInt(split[1]))
if (NumberUtil.isInt(split[1]))
{
validPotionPower = true;
power = Integer.parseInt(split[1]);
@ -376,7 +379,7 @@ public class MetaItemStack
}
else if (split[0].equalsIgnoreCase("duration") || (allowShortName && split[0].equalsIgnoreCase("d")))
{
if (Util.isInt(split[1]))
if (NumberUtil.isInt(split[1]))
{
validPotionDuration = true;
duration = Integer.parseInt(split[1]) * 20; //Duration is in ticks by default, converted to seconds

View file

@ -1,5 +1,7 @@
package com.earth2me.essentials;
import com.earth2me.essentials.utils.NumberUtil;
import com.earth2me.essentials.utils.StringUtil;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@ -104,7 +106,7 @@ public class Potions
public static PotionEffectType getByName(String name)
{
PotionEffectType peffect;
if (Util.isInt(name))
if (NumberUtil.isInt(name))
{
peffect = PotionEffectType.getById(Integer.parseInt(name));
}

View file

@ -6,6 +6,7 @@ import com.earth2me.essentials.signs.EssentialsSign;
import com.earth2me.essentials.signs.Signs;
import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.textreader.SimpleTextInput;
import com.earth2me.essentials.utils.FormatUtil;
import java.io.File;
import java.math.BigDecimal;
import java.text.MessageFormat;
@ -411,7 +412,7 @@ public class Settings implements ISettings
{
String format = config.getString("chat.group-formats." + (group == null ? "Default" : group),
config.getString("chat.format", "&7[{GROUP}]&r {DISPLAYNAME}&7:&r {MESSAGE}"));
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");
@ -434,7 +435,7 @@ public class Settings implements ISettings
@Override
public IText getAnnounceNewPlayerFormat()
{
return new SimpleTextInput(Util.replaceFormat(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!")));
return new SimpleTextInput(FormatUtil.replaceFormat(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!")));
}
@Override

View file

@ -1,7 +1,10 @@
package com.earth2me.essentials;
import com.earth2me.essentials.utils.StringUtil;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Mob.MobException;
import com.earth2me.essentials.utils.LocationUtil;
import com.earth2me.essentials.utils.NumberUtil;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@ -38,7 +41,7 @@ public class SpawnMob
{
availableList.add(_("none"));
}
return Util.joinList(availableList);
return StringUtil.joinList(availableList);
}
public static List<String> mobParts(final String mobString)
@ -80,7 +83,7 @@ public class SpawnMob
// This method spawns a mob where the user is looking, owned by user
public static void spawnmob(final IEssentials ess, final Server server, final User user, final List<String> parts, final List<String> data, int mobCount) throws Exception
{
final Block block = Util.getTarget(user).getBlock();
final Block block = LocationUtil.getTarget(user).getBlock();
if (block == null)
{
throw new Exception(_("unableToSpawnMob"));
@ -103,7 +106,7 @@ public class SpawnMob
// This method spawns a mob at loc, owned by target
public static void spawnmob(final IEssentials ess, final Server server, final CommandSender sender, final User target, final Location loc, final List<String> parts, final List<String> data, int mobCount) throws Exception
{
final Location sloc = Util.getSafeDestination(loc);
final Location sloc = LocationUtil.getSafeDestination(loc);
for (int i = 0; i < parts.size(); i++)
{
@ -393,7 +396,7 @@ public class SpawnMob
if (type == EntityType.EXPERIENCE_ORB)
{
if (Util.isInt(data))
if (NumberUtil.isInt(data))
{
((ExperienceOrb)spawned).setExperience(Integer.parseInt(data));

View file

@ -2,6 +2,8 @@ package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.ITeleport;
import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.LocationUtil;
import java.util.Calendar;
import java.util.GregorianCalendar;
import org.bukkit.Location;
@ -50,7 +52,7 @@ public class Teleport implements ITeleport
time.setTimeInMillis(lastTime);
time.add(Calendar.SECOND, (int)cooldown);
time.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
throw new Exception(_("timeBeforeTeleport", Util.formatDateDiff(time.getTimeInMillis())));
throw new Exception(_("timeBeforeTeleport", DateUtil.formatDateDiff(time.getTimeInMillis())));
}
}
// if justCheck is set, don't update lastTeleport; we're just checking
@ -65,7 +67,7 @@ public class Teleport implements ITeleport
Calendar c = new GregorianCalendar();
c.add(Calendar.SECOND, (int)delay);
c.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
user.sendMessage(_("dontMoveMessage", Util.formatDateDiff(c.getTimeInMillis())));
user.sendMessage(_("dontMoveMessage", DateUtil.formatDateDiff(c.getTimeInMillis())));
}
//The now function is used when you want to skip tp delay when teleporting someone to a location or player.
@ -93,7 +95,7 @@ public class Teleport implements ITeleport
{
cancel(false);
teleportee.setLastLocation();
teleportee.getBase().teleport(Util.getSafeDestination(target.getLocation()), cause);
teleportee.getBase().teleport(LocationUtil.getSafeDestination(target.getLocation()), cause);
}
//The teleportPlayer function is used when you want to normally teleportPlayer someone to a location or player.

View file

@ -3,6 +3,9 @@ package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.commands.IEssentialsCommand;
import com.earth2me.essentials.register.payment.Method;
import com.earth2me.essentials.utils.NumberUtil;
import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.FormatUtil;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.GregorianCalendar;
@ -117,7 +120,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
if (cooldownTime.after(now) && !isAuthorized("essentials.heal.cooldown.bypass"))
{
throw new Exception(_("timeBeforeHeal", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
throw new Exception(_("timeBeforeHeal", DateUtil.formatDateDiff(cooldownTime.getTimeInMillis())));
}
}
setLastHealTimestamp(now.getTimeInMillis());
@ -136,10 +139,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return;
}
setMoney(getMoney().add(value));
sendMessage(_("addedToAccount", Util.displayCurrency(value, ess)));
sendMessage(_("addedToAccount", NumberUtil.displayCurrency(value, ess)));
if (initiator != null)
{
initiator.sendMessage(_("addedToOthersAccount", Util.displayCurrency(value, ess), this.getDisplayName(), Util.displayCurrency(getMoney(), ess)));
initiator.sendMessage(_("addedToOthersAccount", NumberUtil.displayCurrency(value, ess), this.getDisplayName(), NumberUtil.displayCurrency(getMoney(), ess)));
}
}
@ -153,8 +156,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
setMoney(getMoney().subtract(value));
reciever.setMoney(reciever.getMoney().add(value));
sendMessage(_("moneySentTo", Util.displayCurrency(value, ess), reciever.getDisplayName()));
reciever.sendMessage(_("moneyRecievedFrom", Util.displayCurrency(value, ess), getDisplayName()));
sendMessage(_("moneySentTo", NumberUtil.displayCurrency(value, ess), reciever.getDisplayName()));
reciever.sendMessage(_("moneyRecievedFrom", NumberUtil.displayCurrency(value, ess), getDisplayName()));
}
else
{
@ -175,10 +178,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return;
}
setMoney(getMoney().subtract(value));
sendMessage(_("takenFromAccount", Util.displayCurrency(value, ess)));
sendMessage(_("takenFromAccount", NumberUtil.displayCurrency(value, ess)));
if (initiator != null)
{
initiator.sendMessage(_("takenFromOthersAccount", Util.displayCurrency(value, ess), this.getDisplayName(), Util.displayCurrency(getMoney(), ess)));
initiator.sendMessage(_("takenFromOthersAccount", NumberUtil.displayCurrency(value, ess), this.getDisplayName(), NumberUtil.displayCurrency(getMoney(), ess)));
}
}
@ -222,7 +225,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
@Override
public int compareTo(final User other)
{
return Util.stripFormat(this.getDisplayName()).compareToIgnoreCase(Util.stripFormat(other.getDisplayName()));
return FormatUtil.stripFormat(this.getDisplayName()).compareToIgnoreCase(FormatUtil.stripFormat(other.getDisplayName()));
}
@Override
@ -336,11 +339,11 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
if (!longnick && output.length() > 16)
{
output = Util.lastCode(strPrefix) + nickname;
output = FormatUtil.lastCode(strPrefix) + nickname;
}
if (!longnick && output.length() > 16)
{
output = Util.lastCode(strPrefix) + nickname.substring(0, 14);
output = FormatUtil.lastCode(strPrefix) + nickname.substring(0, 14);
}
if (output.charAt(output.length() - 1) == '§')
{

View file

@ -1,6 +1,8 @@
package com.earth2me.essentials;
import com.earth2me.essentials.utils.StringUtil;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.utils.NumberUtil;
import java.io.File;
import java.math.BigDecimal;
import java.util.*;
@ -25,7 +27,7 @@ public abstract class UserData extends PlayerExtension implements IConf
{
folder.mkdirs();
}
config = new EssentialsConf(new File(folder, Util.sanitizeFileName(base.getName()) + ".yml"));
config = new EssentialsConf(new File(folder, StringUtil.sanitizeFileName(base.getName()) + ".yml"));
reloadConfig();
}
@ -124,7 +126,7 @@ public abstract class UserData extends PlayerExtension implements IConf
private String getHomeName(String search)
{
if (Util.isInt(search))
if (NumberUtil.isInt(search))
{
try
{
@ -174,7 +176,7 @@ public abstract class UserData extends PlayerExtension implements IConf
public void setHome(String name, Location loc)
{
//Invalid names will corrupt the yaml
name = Util.safeString(name);
name = StringUtil.safeString(name);
homes.put(name, loc);
config.setProperty("homes." + name, loc);
config.save();
@ -185,7 +187,7 @@ public abstract class UserData extends PlayerExtension implements IConf
String search = getHomeName(name);
if (!homes.containsKey(search))
{
search = Util.safeString(search);
search = StringUtil.safeString(search);
}
if (homes.containsKey(search))
{
@ -634,7 +636,7 @@ public abstract class UserData extends PlayerExtension implements IConf
public void setBanReason(String reason)
{
config.setProperty("ban.reason", Util.sanitizeString(reason));
config.setProperty("ban.reason", StringUtil.sanitizeString(reason));
config.save();
}

View file

@ -1,5 +1,6 @@
package com.earth2me.essentials;
import com.earth2me.essentials.utils.StringUtil;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
@ -46,7 +47,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
continue;
}
final String name = string.substring(0, string.length() - 4);
keys.add(Util.sanitizeFileName(name));
keys.add(StringUtil.sanitizeFileName(name));
}
}
});
@ -54,7 +55,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
public boolean userExists(final String name)
{
return keys.contains(Util.sanitizeFileName(name));
return keys.contains(StringUtil.sanitizeFileName(name));
}
public User getUser(final String name)
@ -76,7 +77,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
@Override
public User load(final String name) throws Exception
{
String sanitizedName = Util.sanitizeFileName(name);
String sanitizedName = StringUtil.sanitizeFileName(name);
if (!sanitizedName.equals(name))
{
User user = getUser(sanitizedName);
@ -114,8 +115,8 @@ public class UserMap extends CacheLoader<String, User> implements IConf
public void removeUser(final String name)
{
keys.remove(Util.sanitizeFileName(name));
users.invalidate(Util.sanitizeFileName(name));
keys.remove(StringUtil.sanitizeFileName(name));
users.invalidate(StringUtil.sanitizeFileName(name));
users.invalidate(name);
}
@ -131,7 +132,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
public File getUserFile(final String name)
{
return getUserFile2(Util.sanitizeFileName(name));
return getUserFile2(StringUtil.sanitizeFileName(name));
}
private File getUserFile2(final String name)

View file

@ -1,736 +0,0 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.*;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
public class Util
{
private Util()
{
}
private final static Logger logger = Logger.getLogger("Minecraft");
private final static Pattern INVALIDFILECHARS = Pattern.compile("[^a-z0-9]");
private final static Pattern INVALIDCHARS = Pattern.compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");
//Used to clean file names before saving to disk
public static String sanitizeFileName(final String name)
{
return safeString(name);
}
//Used to clean strings/names before saving as filenames/permissions
public static String safeString(final String string)
{
return INVALIDFILECHARS.matcher(string.toLowerCase(Locale.ENGLISH)).replaceAll("_");
}
//Less restrictive string sanitizing, when not used as perm or filename
public static String sanitizeString(final String string)
{
return INVALIDCHARS.matcher(string).replaceAll("");
}
public static String formatDateDiff(long date)
{
Calendar c = new GregorianCalendar();
c.setTimeInMillis(date);
Calendar now = new GregorianCalendar();
return Util.formatDateDiff(now, c);
}
public static String formatDateDiff(Calendar fromDate, Calendar toDate)
{
boolean future = false;
if (toDate.equals(fromDate))
{
return _("now");
}
if (toDate.after(fromDate))
{
future = true;
}
StringBuilder sb = new StringBuilder();
int[] types = new int[]
{
Calendar.YEAR,
Calendar.MONTH,
Calendar.DAY_OF_MONTH,
Calendar.HOUR_OF_DAY,
Calendar.MINUTE,
Calendar.SECOND
};
String[] names = new String[]
{
_("year"),
_("years"),
_("month"),
_("months"),
_("day"),
_("days"),
_("hour"),
_("hours"),
_("minute"),
_("minutes"),
_("second"),
_("seconds")
};
int accuracy = 0;
for (int i = 0; i < types.length; i++)
{
if (accuracy > 2)
{
break;
}
int diff = dateDiff(types[i], fromDate, toDate, future);
if (diff > 0)
{
accuracy++;
sb.append(" ").append(diff).append(" ").append(names[i * 2 + (diff > 1 ? 1 : 0)]);
}
}
if (sb.length() == 0)
{
return "now";
}
return sb.toString().trim();
}
private static int dateDiff(int type, Calendar fromDate, Calendar toDate, boolean future)
{
int diff = 0;
long savedDate = fromDate.getTimeInMillis();
while ((future && !fromDate.after(toDate)) || (!future && !fromDate.before(toDate)))
{
savedDate = fromDate.getTimeInMillis();
fromDate.add(type, future ? 1 : -1);
diff++;
}
diff--;
fromDate.setTimeInMillis(savedDate);
return diff;
}
public static long parseDateDiff(String time, boolean future) throws Exception
{
Pattern timePattern = Pattern.compile(
"(?:([0-9]+)\\s*y[a-z]*[,\\s]*)?"
+ "(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?"
+ "(?:([0-9]+)\\s*w[a-z]*[,\\s]*)?"
+ "(?:([0-9]+)\\s*d[a-z]*[,\\s]*)?"
+ "(?:([0-9]+)\\s*h[a-z]*[,\\s]*)?"
+ "(?:([0-9]+)\\s*m[a-z]*[,\\s]*)?"
+ "(?:([0-9]+)\\s*(?:s[a-z]*)?)?", Pattern.CASE_INSENSITIVE);
Matcher m = timePattern.matcher(time);
int years = 0;
int months = 0;
int weeks = 0;
int days = 0;
int hours = 0;
int minutes = 0;
int seconds = 0;
boolean found = false;
while (m.find())
{
if (m.group() == null || m.group().isEmpty())
{
continue;
}
for (int i = 0; i < m.groupCount(); i++)
{
if (m.group(i) != null && !m.group(i).isEmpty())
{
found = true;
break;
}
}
if (found)
{
if (m.group(1) != null && !m.group(1).isEmpty())
{
years = Integer.parseInt(m.group(1));
}
if (m.group(2) != null && !m.group(2).isEmpty())
{
months = Integer.parseInt(m.group(2));
}
if (m.group(3) != null && !m.group(3).isEmpty())
{
weeks = Integer.parseInt(m.group(3));
}
if (m.group(4) != null && !m.group(4).isEmpty())
{
days = Integer.parseInt(m.group(4));
}
if (m.group(5) != null && !m.group(5).isEmpty())
{
hours = Integer.parseInt(m.group(5));
}
if (m.group(6) != null && !m.group(6).isEmpty())
{
minutes = Integer.parseInt(m.group(6));
}
if (m.group(7) != null && !m.group(7).isEmpty())
{
seconds = Integer.parseInt(m.group(7));
}
break;
}
}
if (!found)
{
throw new Exception(_("illegalDate"));
}
Calendar c = new GregorianCalendar();
if (years > 0)
{
c.add(Calendar.YEAR, years * (future ? 1 : -1));
}
if (months > 0)
{
c.add(Calendar.MONTH, months * (future ? 1 : -1));
}
if (weeks > 0)
{
c.add(Calendar.WEEK_OF_YEAR, weeks * (future ? 1 : -1));
}
if (days > 0)
{
c.add(Calendar.DAY_OF_MONTH, days * (future ? 1 : -1));
}
if (hours > 0)
{
c.add(Calendar.HOUR_OF_DAY, hours * (future ? 1 : -1));
}
if (minutes > 0)
{
c.add(Calendar.MINUTE, minutes * (future ? 1 : -1));
}
if (seconds > 0)
{
c.add(Calendar.SECOND, seconds * (future ? 1 : -1));
}
Calendar max = new GregorianCalendar();
max.add(Calendar.YEAR, 10);
if (c.after(max))
{
return max.getTimeInMillis();
}
return c.getTimeInMillis();
}
// The player can stand inside these materials
private static final Set<Integer> HOLLOW_MATERIALS = new HashSet<Integer>();
private static final HashSet<Byte> TRANSPARENT_MATERIALS = new HashSet<Byte>();
static
{
HOLLOW_MATERIALS.add(Material.AIR.getId());
HOLLOW_MATERIALS.add(Material.SAPLING.getId());
HOLLOW_MATERIALS.add(Material.POWERED_RAIL.getId());
HOLLOW_MATERIALS.add(Material.DETECTOR_RAIL.getId());
HOLLOW_MATERIALS.add(Material.LONG_GRASS.getId());
HOLLOW_MATERIALS.add(Material.DEAD_BUSH.getId());
HOLLOW_MATERIALS.add(Material.YELLOW_FLOWER.getId());
HOLLOW_MATERIALS.add(Material.RED_ROSE.getId());
HOLLOW_MATERIALS.add(Material.BROWN_MUSHROOM.getId());
HOLLOW_MATERIALS.add(Material.RED_MUSHROOM.getId());
HOLLOW_MATERIALS.add(Material.TORCH.getId());
HOLLOW_MATERIALS.add(Material.REDSTONE_WIRE.getId());
HOLLOW_MATERIALS.add(Material.SEEDS.getId());
HOLLOW_MATERIALS.add(Material.SIGN_POST.getId());
HOLLOW_MATERIALS.add(Material.WOODEN_DOOR.getId());
HOLLOW_MATERIALS.add(Material.LADDER.getId());
HOLLOW_MATERIALS.add(Material.RAILS.getId());
HOLLOW_MATERIALS.add(Material.WALL_SIGN.getId());
HOLLOW_MATERIALS.add(Material.LEVER.getId());
HOLLOW_MATERIALS.add(Material.STONE_PLATE.getId());
HOLLOW_MATERIALS.add(Material.IRON_DOOR_BLOCK.getId());
HOLLOW_MATERIALS.add(Material.WOOD_PLATE.getId());
HOLLOW_MATERIALS.add(Material.REDSTONE_TORCH_OFF.getId());
HOLLOW_MATERIALS.add(Material.REDSTONE_TORCH_ON.getId());
HOLLOW_MATERIALS.add(Material.STONE_BUTTON.getId());
HOLLOW_MATERIALS.add(Material.SNOW.getId());
HOLLOW_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId());
HOLLOW_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId());
HOLLOW_MATERIALS.add(Material.DIODE_BLOCK_ON.getId());
HOLLOW_MATERIALS.add(Material.PUMPKIN_STEM.getId());
HOLLOW_MATERIALS.add(Material.MELON_STEM.getId());
HOLLOW_MATERIALS.add(Material.VINE.getId());
HOLLOW_MATERIALS.add(Material.FENCE_GATE.getId());
HOLLOW_MATERIALS.add(Material.WATER_LILY.getId());
HOLLOW_MATERIALS.add(Material.NETHER_WARTS.getId());
for (Integer integer : HOLLOW_MATERIALS)
{
TRANSPARENT_MATERIALS.add(integer.byteValue());
}
TRANSPARENT_MATERIALS.add((byte)Material.WATER.getId());
TRANSPARENT_MATERIALS.add((byte)Material.STATIONARY_WATER.getId());
}
public static Location getTarget(final LivingEntity entity) throws Exception
{
final Block block = entity.getTargetBlock(TRANSPARENT_MATERIALS, 300);
if (block == null)
{
throw new Exception("Not targeting a block");
}
return block.getLocation();
}
public final static int RADIUS = 3;
public final static Vector3D[] VOLUME;
public static class Vector3D
{
public Vector3D(int x, int y, int z)
{
this.x = x;
this.y = y;
this.z = z;
}
public int x;
public int y;
public int z;
}
static
{
List<Vector3D> pos = new ArrayList<Vector3D>();
for (int x = -RADIUS; x <= RADIUS; x++)
{
for (int y = -RADIUS; y <= RADIUS; y++)
{
for (int z = -RADIUS; z <= RADIUS; z++)
{
pos.add(new Vector3D(x, y, z));
}
}
}
Collections.sort(pos, new Comparator<Vector3D>()
{
@Override
public int compare(Vector3D a, Vector3D b)
{
return (a.x * a.x + a.y * a.y + a.z * a.z) - (b.x * b.x + b.y * b.y + b.z * b.z);
}
});
VOLUME = pos.toArray(new Vector3D[0]);
}
public static Location getSafeDestination(final Location loc) throws Exception
{
if (loc == null || loc.getWorld() == null)
{
throw new Exception(_("destinationNotSet"));
}
final World world = loc.getWorld();
int x = loc.getBlockX();
int y = (int)Math.round(loc.getY());
int z = loc.getBlockZ();
final int origX = x;
final int origY = y;
final int origZ = z;
while (isBlockAboveAir(world, x, y, z))
{
y -= 1;
if (y < 0)
{
y = origY;
break;
}
}
if (isBlockUnsafe(world, x, y, z))
{
x = Math.round(loc.getX()) == origX ? x - 1 : x + 1;
z = Math.round(loc.getZ()) == origZ ? z - 1 : z + 1;
}
int i = 0;
while (isBlockUnsafe(world, x, y, z))
{
i++;
if (i >= VOLUME.length)
{
x = origX;
y = origY + RADIUS;
z = origZ;
break;
}
x = origX + VOLUME[i].x;
y = origY + VOLUME[i].y;
z = origZ + VOLUME[i].z;
}
while (isBlockUnsafe(world, x, y, z))
{
y += 1;
if (y >= world.getMaxHeight())
{
x += 1;
break;
}
}
while (isBlockUnsafe(world, x, y, z))
{
y -= 1;
if (y <= 1)
{
x += 1;
y = world.getHighestBlockYAt(x, z);
if (x - 48 > loc.getBlockX())
{
throw new Exception(_("holeInFloor"));
}
}
}
return new Location(world, x + 0.5D, y, z + 0.5D, loc.getYaw(), loc.getPitch());
}
private static boolean isBlockAboveAir(final World world, final int x, final int y, final int z)
{
return HOLLOW_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType().getId());
}
public static boolean isBlockUnsafe(final World world, final int x, final int y, final int z)
{
if (isBlockDamaging(world, x, y, z))
{
return true;
}
return isBlockAboveAir(world, x, y, z);
}
public static boolean isBlockDamaging(final World world, final int x, final int y, final int z)
{
final Block below = world.getBlockAt(x, y - 1, z);
if (below.getType() == Material.LAVA || below.getType() == Material.STATIONARY_LAVA)
{
return true;
}
if (below.getType() == Material.FIRE)
{
return true;
}
if (below.getType() == Material.BED_BLOCK)
{
return true;
}
if ((!HOLLOW_MATERIALS.contains(world.getBlockAt(x, y, z).getType().getId()))
|| (!HOLLOW_MATERIALS.contains(world.getBlockAt(x, y + 1, z).getType().getId())))
{
return true;
}
return false;
}
public static ItemStack convertBlockToItem(final Block block)
{
final ItemStack is = new ItemStack(block.getType(), 1, (short)0, block.getData());
switch (is.getType())
{
case WOODEN_DOOR:
is.setType(Material.WOOD_DOOR);
is.setDurability((short)0);
break;
case IRON_DOOR_BLOCK:
is.setType(Material.IRON_DOOR);
is.setDurability((short)0);
break;
case SIGN_POST:
case WALL_SIGN:
is.setType(Material.SIGN);
is.setDurability((short)0);
break;
case CROPS:
is.setType(Material.SEEDS);
is.setDurability((short)0);
break;
case CAKE_BLOCK:
is.setType(Material.CAKE);
is.setDurability((short)0);
break;
case BED_BLOCK:
is.setType(Material.BED);
is.setDurability((short)0);
break;
case REDSTONE_WIRE:
is.setType(Material.REDSTONE);
is.setDurability((short)0);
break;
case REDSTONE_TORCH_OFF:
case REDSTONE_TORCH_ON:
is.setType(Material.REDSTONE_TORCH_ON);
is.setDurability((short)0);
break;
case DIODE_BLOCK_OFF:
case DIODE_BLOCK_ON:
is.setType(Material.DIODE);
is.setDurability((short)0);
break;
case DOUBLE_STEP:
is.setType(Material.STEP);
break;
case TORCH:
case RAILS:
case LADDER:
case WOOD_STAIRS:
case COBBLESTONE_STAIRS:
case LEVER:
case STONE_BUTTON:
case FURNACE:
case DISPENSER:
case PUMPKIN:
case JACK_O_LANTERN:
case WOOD_PLATE:
case STONE_PLATE:
case PISTON_STICKY_BASE:
case PISTON_BASE:
case IRON_FENCE:
case THIN_GLASS:
case TRAP_DOOR:
case FENCE:
case FENCE_GATE:
case NETHER_FENCE:
is.setDurability((short)0);
break;
case FIRE:
return null;
case PUMPKIN_STEM:
is.setType(Material.PUMPKIN_SEEDS);
break;
case MELON_STEM:
is.setType(Material.MELON_SEEDS);
break;
}
return is;
}
private static DecimalFormat currencyFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
public static String formatAsCurrency(final BigDecimal value)
{
currencyFormat.setRoundingMode(RoundingMode.FLOOR);
String str = currencyFormat.format(value);
if (str.endsWith(".00"))
{
str = str.substring(0, str.length() - 3);
}
return str;
}
public static String displayCurrency(final BigDecimal value, final IEssentials ess)
{
return _("currency", ess.getSettings().getCurrencySymbol(), formatAsCurrency(value));
}
public static String shortCurrency(final BigDecimal value, final IEssentials ess)
{
return ess.getSettings().getCurrencySymbol() + formatAsCurrency(value);
}
private static DecimalFormat threeDPlaces = new DecimalFormat("#,###.###");
public static String formatDouble(final double value)
{
threeDPlaces.setRoundingMode(RoundingMode.HALF_UP);
return threeDPlaces.format(value);
}
public static boolean isInt(final String sInt)
{
try
{
Integer.parseInt(sInt);
}
catch (NumberFormatException e)
{
return false;
}
return true;
}
public static String joinList(Object... list)
{
return joinList(", ", list);
}
public static String joinList(String seperator, Object... list)
{
StringBuilder buf = new StringBuilder();
for (Object each : list)
{
if (buf.length() > 0)
{
buf.append(seperator);
}
if (each instanceof Collection)
{
buf.append(joinList(seperator, ((Collection)each).toArray()));
}
else
{
try
{
buf.append(each.toString());
}
catch (Exception e)
{
buf.append(each.toString());
}
}
}
return buf.toString();
}
public static String lastCode(final String input)
{
int pos = input.lastIndexOf("§");
if (pos == -1 || (pos + 1) == input.length())
{
return "";
}
return input.substring(pos, pos + 2);
}
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 LOGCOLOR_PATTERN = Pattern.compile("\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]");
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])");
//This method is used to simply strip the native minecraft colour codes
public static String stripFormat(final String input)
{
if (input == null)
{
return null;
}
return VANILLA_PATTERN.matcher(input).replaceAll("");
}
public static String stripLogColorFormat(final String input)
{
if (input == null)
{
return null;
}
return LOGCOLOR_PATTERN.matcher(input).replaceAll("");
}
//This method is used to simply replace the ess colour codes with minecraft ones, ie &c
public static String replaceFormat(final String input)
{
if (input == null)
{
return null;
}
return REPLACE_PATTERN.matcher(input).replaceAll("\u00a7$1");
}
//This is the general permission sensitive message format function, does not touch urls.
public static String formatString(final IUser user, final String permBase, final String input)
{
if (input == null)
{
return null;
}
String message;
if (user.isAuthorized(permBase + ".color"))
{
message = Util.replaceColor(input, REPLACE_COLOR_PATTERN);
}
else
{
message = Util.stripColor(input, VANILLA_COLOR_PATTERN);
}
if (user.isAuthorized(permBase + ".magic"))
{
message = Util.replaceColor(message, REPLACE_MAGIC_PATTERN);
}
else
{
message = Util.stripColor(message, VANILLA_MAGIC_PATTERN);
}
if (user.isAuthorized(permBase + ".format"))
{
message = Util.replaceColor(message, REPLACE_FORMAT_PATTERN);
}
else
{
message = Util.stripColor(message, VANILLA_FORMAT_PATTERN);
}
return message;
}
//This is the general permission sensitive message format function, checks for urls.
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 (!user.isAuthorized(permBase + ".url"))
{
message = Util.blockURL(message);
}
return message;
}
private 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;
}
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");
}
private static final Pattern IPPATTERN = Pattern.compile(
"^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
+ "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$");
public static boolean validIP(String ipAddress)
{
return IPPATTERN.matcher(ipAddress).matches();
}
}

View file

@ -1,5 +1,6 @@
package com.earth2me.essentials;
import com.earth2me.essentials.utils.StringUtil;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IWarps;
import com.earth2me.essentials.api.InvalidNameException;
@ -64,7 +65,7 @@ public class Warps implements IConf, IWarps
@Override
public void setWarp(String name, Location loc) throws Exception
{
String filename = Util.sanitizeFileName(name);
String filename = StringUtil.sanitizeFileName(name);
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(name));
if (conf == null)
{

View file

@ -4,7 +4,8 @@ import com.earth2me.essentials.EssentialsConf;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.NumberUtil;
import java.io.File;
import java.math.BigDecimal;
import java.math.MathContext;
@ -40,7 +41,7 @@ public final class Economy
{
folder.mkdirs();
}
EssentialsConf npcConfig = new EssentialsConf(new File(folder, Util.sanitizeFileName(name) + ".yml"));
EssentialsConf npcConfig = new EssentialsConf(new File(folder, StringUtil.sanitizeFileName(name) + ".yml"));
npcConfig.load();
npcConfig.setProperty("npc", true);
npcConfig.setProperty("money", ess.getSettings().getStartingBalance());
@ -54,7 +55,7 @@ public final class Economy
{
folder.mkdirs();
}
File config = new File(folder, Util.sanitizeFileName(name) + ".yml");
File config = new File(folder, StringUtil.sanitizeFileName(name) + ".yml");
EssentialsConf npcConfig = new EssentialsConf(config);
npcConfig.load();
if (npcConfig.hasProperty("npc") && npcConfig.getBoolean("npc", false))
@ -375,7 +376,7 @@ public final class Economy
{
throw new RuntimeException(noCallBeforeLoad);
}
return Util.displayCurrency(amount, ess);
return NumberUtil.displayCurrency(amount, ess);
}
/**

View file

@ -1,7 +1,8 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.LocationUtil;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.entity.TNTPrimed;
@ -23,7 +24,7 @@ public class Commandantioch extends EssentialsCommand
ess.broadcastMessage(user, "who being naughty in My sight, shall snuff it.");
}
final Location loc = Util.getTarget(user);
final Location loc = LocationUtil.getTarget(user);
loc.getWorld().spawn(loc, TNTPrimed.class);
}
}

View file

@ -2,7 +2,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.NumberUtil;
import java.math.BigDecimal;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -24,7 +25,7 @@ public class Commandbalance extends EssentialsCommand
}
User target = getPlayer(server, args, 0, true, true);
sender.sendMessage(_("balanceOther", target.getDisplayName(), Util.displayCurrency(target.getMoney(), ess)));
sender.sendMessage(_("balanceOther", target.getDisplayName(), NumberUtil.displayCurrency(target.getMoney(), ess)));
}
@Override
@ -34,13 +35,13 @@ public class Commandbalance extends EssentialsCommand
if (args.length < 1 || !user.isAuthorized("essentials.balance.others"))
{
final BigDecimal bal = user.getMoney();
user.sendMessage(_("balance", Util.displayCurrency(bal, ess)));
user.sendMessage(_("balance", NumberUtil.displayCurrency(bal, ess)));
}
else
{
final User target = getPlayer(server, args, 0, true, true);
final BigDecimal bal = target.getMoney();
user.sendMessage(_("balanceOther", target.getDisplayName(), Util.displayCurrency(bal, ess)));
user.sendMessage(_("balanceOther", target.getDisplayName(), NumberUtil.displayCurrency(bal, ess)));
}
}
}

View file

@ -2,9 +2,10 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.textreader.SimpleTextInput;
import com.earth2me.essentials.textreader.TextPager;
import com.earth2me.essentials.utils.NumberUtil;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.util.*;
@ -132,11 +133,11 @@ public class Commandbalancetop extends EssentialsCommand
}
});
cache.getLines().add(_("serverTotal", Util.displayCurrency(totalMoney, ess)));
cache.getLines().add(_("serverTotal", NumberUtil.displayCurrency(totalMoney, ess)));
int pos = 1;
for (Map.Entry<String, BigDecimal> entry : sortedEntries)
{
cache.getLines().add(pos + ". " + entry.getKey() + ", " + Util.displayCurrency(entry.getValue(), ess));
cache.getLines().add(pos + ". " + entry.getKey() + ", " + NumberUtil.displayCurrency(entry.getValue(), ess));
pos++;
}
cacheage = System.currentTimeMillis();

View file

@ -4,7 +4,8 @@ import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.FormatUtil;
import java.util.logging.Level;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -56,7 +57,7 @@ public class Commandban extends EssentialsCommand
String banReason;
if (args.length > 1)
{
banReason = Util.replaceFormat(getFinalArg(args, 1).replace("\\n", "\n").replace("|", "\n"));
banReason = FormatUtil.replaceFormat(getFinalArg(args, 1).replace("\\n", "\n").replace("|", "\n"));
}
else
{

View file

@ -2,7 +2,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.LocationUtil;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.TreeType;
@ -36,8 +37,8 @@ public class Commandbigtree extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
final Location loc = Util.getTarget(user);
final Location safeLocation = Util.getSafeDestination(loc);
final Location loc = LocationUtil.getTarget(user);
final Location safeLocation = LocationUtil.getSafeDestination(loc);
final boolean success = user.getWorld().generateTree(safeLocation, tree);
if (success)
{

View file

@ -2,7 +2,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.FormatUtil;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -22,7 +23,7 @@ public class Commandbroadcast extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
ess.broadcastMessage(null, _("broadcast", Util.replaceFormat(getFinalArg(args, 0)), user.getDisplayName()));
ess.broadcastMessage(null, _("broadcast", FormatUtil.replaceFormat(getFinalArg(args, 0)), user.getDisplayName()));
}
@Override
@ -33,6 +34,6 @@ public class Commandbroadcast extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
ess.broadcastMessage(null, _("broadcast", Util.replaceFormat(getFinalArg(args, 0)), sender.getName()));
ess.broadcastMessage(null, _("broadcast", FormatUtil.replaceFormat(getFinalArg(args, 0)), sender.getName()));
}
}

View file

@ -2,7 +2,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.NumberUtil;
import com.earth2me.essentials.utils.StringUtil;
import java.util.List;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -137,7 +138,7 @@ public class Commandclearinventory extends EssentialsCommand
final ItemStack item = ess.getItemDb().get(split[0]);
final int type = item.getTypeId();
if (split.length > 1 && Util.isInt(split[1]))
if (split.length > 1 && NumberUtil.isInt(split[1]))
{
player.getInventory().clear(type, Integer.parseInt(split[1]));
}
@ -147,7 +148,7 @@ public class Commandclearinventory extends EssentialsCommand
}
else
{
if (Util.isInt(split[0]))
if (NumberUtil.isInt(split[0]))
{
player.getInventory().clear(type, -1);
}

View file

@ -2,7 +2,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.NumberUtil;
import java.math.BigDecimal;
import java.util.Locale;
import org.bukkit.Server;
@ -108,11 +109,11 @@ public class Commandeco extends EssentialsCommand
if (broadcast != null)
{
server.broadcastMessage(_("resetBal", Util.displayCurrency(broadcast, ess)));
server.broadcastMessage(_("resetBal", NumberUtil.displayCurrency(broadcast, ess)));
}
if (broadcastAll != null)
{
server.broadcastMessage(_("resetBalAll", Util.displayCurrency(broadcastAll, ess)));
server.broadcastMessage(_("resetBalAll", NumberUtil.displayCurrency(broadcastAll, ess)));
}
}
@ -127,7 +128,7 @@ public class Commandeco extends EssentialsCommand
else if (sender == null)
{
player.setMoney(minBalance);
player.sendMessage(_("takenFromAccount", Util.displayCurrency(player.getMoney(), ess)));
player.sendMessage(_("takenFromAccount", NumberUtil.displayCurrency(player.getMoney(), ess)));
}
else
{
@ -140,10 +141,10 @@ public class Commandeco extends EssentialsCommand
BigDecimal minBalance = ess.getSettings().getMinMoney();
boolean underMinimum = (amount.compareTo(minBalance) < 0);
player.setMoney(underMinimum ? minBalance : amount);
player.sendMessage(_("setBal", Util.displayCurrency(player.getMoney(), ess)));
player.sendMessage(_("setBal", NumberUtil.displayCurrency(player.getMoney(), ess)));
if (sender != null)
{
sender.sendMessage(_("setBalOthers", player.getDisplayName(), Util.displayCurrency(player.getMoney(), ess)));
sender.sendMessage(_("setBalOthers", player.getDisplayName(), NumberUtil.displayCurrency(player.getMoney(), ess)));
}
}

View file

@ -4,7 +4,7 @@ import com.earth2me.essentials.Enchantments;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.MetaItemStack;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
@ -43,7 +43,7 @@ public class Commandenchant extends EssentialsCommand
//enchantmentslist.add(enchantmentName);
}
}
throw new NotEnoughArgumentsException(_("enchantments", Util.joinList(enchantmentslist.toArray())));
throw new NotEnoughArgumentsException(_("enchantments", StringUtil.joinList(enchantmentslist.toArray())));
}
int level = -1;

View file

@ -3,8 +3,10 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.UserMap;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.metrics.Metrics;
import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.NumberUtil;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@ -218,7 +220,7 @@ public class Commandessentials extends EssentialsCommand
private void run_cleanup(final Server server, final CommandSender sender, final String command, final String args[]) throws Exception
{
if (args.length < 2 || !Util.isInt(args[1]))
if (args.length < 2 || !NumberUtil.isInt(args[1]))
{
sender.sendMessage("This sub-command will delete users who havent logged in in the last <days> days.");
sender.sendMessage("Optional parameters define the minium amount required to prevent deletion.");
@ -229,8 +231,8 @@ public class Commandessentials extends EssentialsCommand
final long daysArg = Long.parseLong(args[1]);
final double moneyArg = args.length >= 3 ? Double.parseDouble(args[2].replaceAll("[^0-9\\.]", "")) : 0;
final int homesArg = args.length >= 4 && Util.isInt(args[3]) ? Integer.parseInt(args[3]) : 0;
final int bansArg = args.length >= 5 && Util.isInt(args[4]) ? Integer.parseInt(args[4]) : 0;
final int homesArg = args.length >= 4 && NumberUtil.isInt(args[3]) ? Integer.parseInt(args[3]) : 0;
final int bansArg = args.length >= 5 && NumberUtil.isInt(args[4]) ? Integer.parseInt(args[4]) : 0;
final UserMap userMap = ess.getUserMap();
ess.runTaskAsynchronously(new Runnable()
@ -272,7 +274,7 @@ public class Commandessentials extends EssentialsCommand
if (ess.getSettings().isDebug())
{
ess.getLogger().info("Deleting user: " + user.getName() + " Money: " + moneyCount + " Homes: " + homeCount + " Last seen: " + Util.formatDateDiff(lastLog));
ess.getLogger().info("Deleting user: " + user.getName() + " Money: " + moneyCount + " Homes: " + homeCount + " Last seen: " + DateUtil.formatDateDiff(lastLog));
}
user.reset();

View file

@ -2,8 +2,9 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.craftbukkit.SetExpFix;
import com.earth2me.essentials.utils.NumberUtil;
import java.util.List;
import java.util.Locale;
import org.bukkit.Server;
@ -61,7 +62,7 @@ public class Commandexp extends EssentialsCommand
}
else
{
if (args.length >= 1 && Util.isInt(args[0].toLowerCase(Locale.ENGLISH).replace("l", "")) && user.isAuthorized("essentials.exp.give"))
if (args.length >= 1 && NumberUtil.isInt(args[0].toLowerCase(Locale.ENGLISH).replace("l", "")) && user.isAuthorized("essentials.exp.give"))
{
if (args.length >= 2 && user.isAuthorized("essentials.exp.give.others"))
{
@ -102,7 +103,7 @@ public class Commandexp extends EssentialsCommand
else
{
String match = args[0].trim();
if (args.length >= 2 && Util.isInt(args[0].toLowerCase(Locale.ENGLISH).replace("l", "")))
if (args.length >= 2 && NumberUtil.isInt(args[0].toLowerCase(Locale.ENGLISH).replace("l", "")))
{
match = args[1].trim();
expMatch(server, sender, match, args[0], true);

View file

@ -3,7 +3,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.MetaItemStack;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.NumberUtil;
import com.earth2me.essentials.utils.StringUtil;
import java.util.regex.Pattern;
import org.bukkit.FireworkEffect;
import org.bukkit.Material;
@ -75,7 +76,7 @@ public class Commandfirework extends EssentialsCommand
boolean direction = false;
if (args.length > 1)
{
if (Util.isInt(args[1]))
if (NumberUtil.isInt(args[1]))
{
final int serverLimit = ess.getSettings().getSpawnMobLimit();
amount = Integer.parseInt(args[1]);

View file

@ -1,7 +1,9 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.NumberUtil;
import com.earth2me.essentials.utils.DateUtil;
import java.lang.management.ManagementFactory;
import java.util.List;
import org.bukkit.ChatColor;
@ -35,8 +37,8 @@ public class Commandgc extends EssentialsCommand
color = ChatColor.RED;
}
sender.sendMessage(_("uptime", Util.formatDateDiff(ManagementFactory.getRuntimeMXBean().getStartTime())));
sender.sendMessage(_("tps", "" + color + Util.formatDouble(tps)));
sender.sendMessage(_("uptime", DateUtil.formatDateDiff(ManagementFactory.getRuntimeMXBean().getStartTime())));
sender.sendMessage(_("tps", "" + color + NumberUtil.formatDouble(tps)));
sender.sendMessage(_("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
sender.sendMessage(_("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
sender.sendMessage(_("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));

View file

@ -3,8 +3,9 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.MetaItemStack;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
import com.earth2me.essentials.utils.NumberUtil;
import java.util.Locale;
import org.bukkit.Material;
import org.bukkit.Server;
@ -46,7 +47,7 @@ public class Commandgive extends EssentialsCommand
try
{
if (args.length > 3 && Util.isInt(args[2]) && Util.isInt(args[3]))
if (args.length > 3 && NumberUtil.isInt(args[2]) && NumberUtil.isInt(args[3]))
{
stack.setAmount(Integer.parseInt(args[2]));
stack.setDurability(Short.parseShort(args[3]));
@ -78,7 +79,7 @@ public class Commandgive extends EssentialsCommand
allowUnsafe = false;
}
metaStack.parseStringMeta(sender, allowUnsafe, args, Util.isInt(args[3]) ? 4 : 3, ess);
metaStack.parseStringMeta(sender, allowUnsafe, args, NumberUtil.isInt(args[3]) ? 4 : 3, ess);
stack = metaStack.getItemStack();
}

View file

@ -2,8 +2,9 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.textreader.*;
import com.earth2me.essentials.utils.NumberUtil;
import java.util.Locale;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -27,7 +28,7 @@ public class Commandhelp extends EssentialsCommand
if (input.getLines().isEmpty())
{
if (Util.isInt(pageStr) || pageStr == null)
if (NumberUtil.isInt(pageStr) || pageStr == null)
{
output = new HelpInput(user, "", ess);
}

View file

@ -3,7 +3,8 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.FormatUtil;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -35,7 +36,7 @@ public class Commandhelpop extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
final String message = _("helpOp", from, Util.stripFormat(getFinalArg(args, 0)));
final String message = _("helpOp", from, FormatUtil.stripFormat(getFinalArg(args, 0)));
CommandSender cs = Console.getCommandSender(server);
cs.sendMessage(message);
for (Player onlinePlayer : server.getOnlinePlayers())

View file

@ -3,7 +3,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import java.util.List;
import java.util.Locale;
import org.bukkit.Location;
@ -87,7 +87,7 @@ public class Commandhome extends EssentialsCommand
homes.add(_("bedNull"));
}
}
user.sendMessage(_("homes", Util.joinList(homes)));
user.sendMessage(_("homes", StringUtil.joinList(homes)));
}
}
throw new NoChargeException();

View file

@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -15,6 +15,6 @@ public class Commandjails extends EssentialsCommand
@Override
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
sender.sendMessage("§7" + Util.joinList(" ", ess.getJails().getList()));
sender.sendMessage("§7" + StringUtil.joinList(" ", ess.getJails().getList()));
}
}

View file

@ -3,7 +3,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.LocationUtil;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
@ -39,7 +40,7 @@ public class Commandjump extends EssentialsCommand
try
{
loc = Util.getTarget(user);
loc = LocationUtil.getTarget(user);
loc.setYaw(cloc.getYaw());
loc.setPitch(cloc.getPitch());
loc.setY(loc.getY() + 1);

View file

@ -3,7 +3,8 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.FormatUtil;
import java.util.logging.Level;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -41,7 +42,7 @@ public class Commandkick extends EssentialsCommand
}
String kickReason = args.length > 1 ? getFinalArg(args, 1) : _("kickDefault");
kickReason = Util.replaceFormat(kickReason.replace("\\n", "\n").replace("|", "\n"));
kickReason = FormatUtil.replaceFormat(kickReason.replace("\\n", "\n").replace("|", "\n"));
target.kickPlayer(kickReason);
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;

View file

@ -1,7 +1,8 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.FormatUtil;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -18,7 +19,7 @@ public class Commandkickall extends EssentialsCommand
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
String kickReason = args.length > 0 ? getFinalArg(args, 0) : _("kickDefault");
kickReason = Util.replaceFormat(kickReason.replace("\\n", "\n").replace("|", "\n"));
kickReason = FormatUtil.replaceFormat(kickReason.replace("\\n", "\n").replace("|", "\n"));
for (Player onlinePlayer : server.getOnlinePlayers())
{

View file

@ -4,7 +4,7 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Kit;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@ -31,12 +31,12 @@ public class Commandkit extends EssentialsCommand
else if (args.length > 1 && user.isAuthorized("essentials.kit.others"))
{
final User userTo = getPlayer(server, user, args, 1);
final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH)).trim();
final String kitName = StringUtil.sanitizeString(args[0].toLowerCase(Locale.ENGLISH)).trim();
giveKit(userTo, user, kitName);
}
else
{
final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH)).trim();
final String kitName = StringUtil.sanitizeString(args[0].toLowerCase(Locale.ENGLISH)).trim();
giveKit(user, user, kitName);
}
}

View file

@ -2,7 +2,9 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.FormatUtil;
import com.earth2me.essentials.utils.NumberUtil;
import java.util.*;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -73,7 +75,7 @@ public class Commandlist extends EssentialsCommand
{
continue;
}
final String group = Util.stripFormat(onlineUser.getGroup().toLowerCase());
final String group = FormatUtil.stripFormat(onlineUser.getGroup().toLowerCase());
List<User> list = playerList.get(group);
if (list == null)
{
@ -163,7 +165,7 @@ public class Commandlist extends EssentialsCommand
List<User> matchedList = playerList.get(configGroup);
// If the group value is an int, then we might need to truncate it
if (Util.isInt(groupValue))
if (NumberUtil.isInt(groupValue))
{
if (matchedList != null && !matchedList.isEmpty())
{
@ -172,7 +174,7 @@ public class Commandlist extends EssentialsCommand
int limit = Integer.parseInt(groupValue);
if (matchedList.size() > limit)
{
sender.sendMessage(outputFormat(oConfigGroup, _("groupNumber", matchedList.size(), commandLabel, Util.stripFormat(configGroup))));
sender.sendMessage(outputFormat(oConfigGroup, _("groupNumber", matchedList.size(), commandLabel, FormatUtil.stripFormat(configGroup))));
}
else
{
@ -262,7 +264,7 @@ public class Commandlist extends EssentialsCommand
private String outputFormat(String group, String message)
{
final StringBuilder outputString = new StringBuilder();
outputString.append(_("listGroupTag", Util.replaceFormat(group)));
outputString.append(_("listGroupTag", FormatUtil.replaceFormat(group)));
outputString.append(message);
outputString.setCharAt(0, Character.toTitleCase(outputString.charAt(0)));
return outputString.toString();

View file

@ -2,7 +2,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.FormatUtil;
import java.util.List;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -51,7 +52,7 @@ public class Commandmail extends EssentialsCommand
}
if (!u.isIgnoredPlayer(user))
{
final String mail = user.getName() + ": " + Util.sanitizeString(Util.stripFormat(getFinalArg(args, 2)));
final String mail = user.getName() + ": " + StringUtil.sanitizeString(FormatUtil.stripFormat(getFinalArg(args, 2)));
if (mail.length() > 1000)
{
throw new Exception("Mail message too long. Try to keep it below 1000");
@ -77,7 +78,7 @@ public class Commandmail extends EssentialsCommand
{
throw new Exception(_("noPerm", "essentials.mail.sendall"));
}
ess.runTaskAsynchronously(new SendAll(user.getName() + ": " + Util.stripFormat(getFinalArg(args, 1))));
ess.runTaskAsynchronously(new SendAll(user.getName() + ": " + FormatUtil.stripFormat(getFinalArg(args, 1))));
user.sendMessage(_("mailSent"));
return;
}

View file

@ -2,7 +2,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.FormatUtil;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -28,7 +29,7 @@ public class Commandme extends EssentialsCommand
}
String message = getFinalArg(args, 0);
message = Util.formatMessage(user, "essentials.chat", message);
message = FormatUtil.formatMessage(user, "essentials.chat", message);
user.setDisplayNick();
ess.broadcastMessage(user, _("action", user.getDisplayName(), message));
@ -43,7 +44,7 @@ public class Commandme extends EssentialsCommand
}
String message = getFinalArg(args, 0);
message = Util.replaceFormat(message);
message = FormatUtil.replaceFormat(message);
ess.getServer().broadcastMessage(_("action", "@", message));
}

View file

@ -4,7 +4,8 @@ import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IReplyTo;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.FormatUtil;
import java.util.List;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -34,11 +35,11 @@ public class Commandmsg extends EssentialsCommand
{
throw new Exception(_("voiceSilenced"));
}
message = Util.formatMessage(user, "essentials.msg", message);
message = FormatUtil.formatMessage(user, "essentials.msg", message);
}
else
{
message = Util.replaceFormat(message);
message = FormatUtil.replaceFormat(message);
}
final String translatedMe = _("me");

View file

@ -2,7 +2,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.DateUtil;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -33,7 +34,7 @@ public class Commandmute extends EssentialsCommand
if (args.length > 1)
{
final String time = getFinalArg(args, 1);
muteTimestamp = Util.parseDateDiff(time, true);
muteTimestamp = DateUtil.parseDateDiff(time, true);
player.setMuted(true);
}
else
@ -46,8 +47,8 @@ public class Commandmute extends EssentialsCommand
{
if (muteTimestamp > 0)
{
sender.sendMessage(_("mutedPlayerFor", player.getDisplayName(), Util.formatDateDiff(muteTimestamp)));
player.sendMessage(_("playerMutedFor", Util.formatDateDiff(muteTimestamp)));
sender.sendMessage(_("mutedPlayerFor", player.getDisplayName(), DateUtil.formatDateDiff(muteTimestamp)));
player.sendMessage(_("playerMutedFor", DateUtil.formatDateDiff(muteTimestamp)));
}
else
{

View file

@ -2,7 +2,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.FormatUtil;
import java.util.Locale;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -66,11 +67,11 @@ public class Commandnick extends EssentialsCommand
{
if (user == null)
{
return Util.replaceFormat(nick);
return FormatUtil.replaceFormat(nick);
}
else
{
return Util.formatString(user, "essentials.nick", nick);
return FormatUtil.formatString(user, "essentials.nick", nick);
}
}

View file

@ -1,7 +1,8 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.FormatUtil;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -23,7 +24,7 @@ public class Commandping extends EssentialsCommand
}
else
{
sender.sendMessage(Util.replaceFormat(getFinalArg(args, 0)));
sender.sendMessage(FormatUtil.replaceFormat(getFinalArg(args, 0)));
}
}
}

View file

@ -4,7 +4,7 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.MetaItemStack;
import com.earth2me.essentials.Potions;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
@ -40,7 +40,7 @@ public class Commandpotion extends EssentialsCommand
potionslist.add(entry.getKey());
}
}
throw new NotEnoughArgumentsException(_("potions", Util.joinList(potionslist.toArray())));
throw new NotEnoughArgumentsException(_("potions", StringUtil.joinList(potionslist.toArray())));
}
if (stack.getType() == Material.POTION)

View file

@ -2,7 +2,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@ -68,7 +68,7 @@ public class Commandpowertool extends EssentialsCommand
}
else
{
sender.sendMessage(_("powerToolList", Util.joinList(powertools), itemName));
sender.sendMessage(_("powerToolList", StringUtil.joinList(powertools), itemName));
}
throw new NoChargeException();
}
@ -108,7 +108,7 @@ public class Commandpowertool extends EssentialsCommand
}
powertools.add(command);
sender.sendMessage(_("powerToolAttach", Util.joinList(powertools), itemName));
sender.sendMessage(_("powerToolAttach", StringUtil.joinList(powertools), itemName));
}
}
else

View file

@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.DescParseTickFormat;
import com.earth2me.essentials.utils.DescParseTickFormat;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import java.util.*;

View file

@ -4,7 +4,8 @@ import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IReplyTo;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.FormatUtil;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -32,13 +33,13 @@ public class Commandr extends EssentialsCommand
if (sender instanceof Player)
{
User user = ess.getUser(sender);
message = Util.formatMessage(user, "essentials.msg", message);
message = FormatUtil.formatMessage(user, "essentials.msg", message);
replyTo = user;
senderName = user.getDisplayName();
}
else
{
message = Util.replaceFormat(message);
message = FormatUtil.replaceFormat(message);
replyTo = Console.getConsoleReplyTo();
senderName = Console.NAME;
}

View file

@ -2,7 +2,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.FormatUtil;
import java.util.Locale;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -34,7 +35,7 @@ public class Commandrealname extends EssentialsCommand
continue;
}
u.setDisplayNick();
final String displayName = Util.stripFormat(u.getDisplayName()).toLowerCase(Locale.ENGLISH);
final String displayName = FormatUtil.stripFormat(u.getDisplayName()).toLowerCase(Locale.ENGLISH);
if (displayName.contains(whois))
{
foundUser = true;

View file

@ -2,7 +2,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.NumberUtil;
import com.earth2me.essentials.utils.StringUtil;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
@ -34,7 +35,7 @@ public class Commandrecipe extends EssentialsCommand
if (args.length > 1)
{
if (Util.isInt(args[1]))
if (NumberUtil.isInt(args[1]))
{
recipeNo = Integer.parseInt(args[1]) - 1;
}

View file

@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.utils.StringUtil;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.*;
import java.util.ArrayList;
@ -80,7 +81,7 @@ public class Commandrepair extends EssentialsCommand
}
else
{
user.sendMessage(_("repair", Util.joinList(repaired)));
user.sendMessage(_("repair", StringUtil.joinList(repaired)));
}
}

View file

@ -3,7 +3,9 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.UserMap;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.FormatUtil;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
@ -47,7 +49,7 @@ public class Commandseen extends EssentialsCommand
User player = ess.getOfflineUser(args[0]);
if (player == null)
{
if (ipLookup && Util.validIP(args[0]))
if (ipLookup && FormatUtil.validIP(args[0]))
{
seenIP(server, sender, args[0]);
return;
@ -65,7 +67,7 @@ public class Commandseen extends EssentialsCommand
{
user.setDisplayNick();
sender.sendMessage(_("seenOnline", user.getDisplayName(), Util.formatDateDiff(user.getLastLogin())));
sender.sendMessage(_("seenOnline", user.getDisplayName(), DateUtil.formatDateDiff(user.getLastLogin())));
if (user.isAfk())
{
sender.sendMessage(_("whoisAFK", _("true")));
@ -73,13 +75,13 @@ public class Commandseen extends EssentialsCommand
if (user.isJailed())
{
sender.sendMessage(_("whoisJail", (user.getJailTimeout() > 0
? Util.formatDateDiff(user.getJailTimeout())
? DateUtil.formatDateDiff(user.getJailTimeout())
: _("true"))));
}
if (user.isMuted())
{
sender.sendMessage(_("whoisMuted", (user.getMuteTimeout() > 0
? Util.formatDateDiff(user.getMuteTimeout())
? DateUtil.formatDateDiff(user.getMuteTimeout())
: _("true"))));
}
final String location = user.getGeoLocation();
@ -98,7 +100,7 @@ public class Commandseen extends EssentialsCommand
user.setDisplayNick();
if (user.getLastLogout() > 0)
{
sender.sendMessage(_("seenOffline", user.getName(), Util.formatDateDiff(user.getLastLogout())));
sender.sendMessage(_("seenOffline", user.getName(), DateUtil.formatDateDiff(user.getLastLogout())));
}
else
{
@ -157,7 +159,7 @@ public class Commandseen extends EssentialsCommand
if (matches.size() > 0)
{
sender.sendMessage(_("matchingIPAddress"));
sender.sendMessage(Util.joinList(matches));
sender.sendMessage(StringUtil.joinList(matches));
}
else
{

View file

@ -3,7 +3,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.NumberUtil;
import java.math.BigDecimal;
import java.util.Locale;
import java.util.logging.Level;
@ -51,7 +52,7 @@ public class Commandsell extends EssentialsCommand
}
if (totalWorth.signum() > 0)
{
user.sendMessage(_("totalWorthAll", type, Util.displayCurrency(totalWorth, ess)));
user.sendMessage(_("totalWorthAll", type, NumberUtil.displayCurrency(totalWorth, ess)));
}
return;
}
@ -73,7 +74,7 @@ public class Commandsell extends EssentialsCommand
}
if (totalWorth.signum() > 0)
{
user.sendMessage(_("totalWorthBlocks", type, Util.displayCurrency(totalWorth, ess)));
user.sendMessage(_("totalWorthBlocks", type, NumberUtil.displayCurrency(totalWorth, ess)));
}
return;
}
@ -163,8 +164,8 @@ public class Commandsell extends EssentialsCommand
user.updateInventory();
Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(result, ess), user.getLocation(), ess);
user.giveMoney(result);
user.sendMessage(_("itemSold", Util.displayCurrency(result, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth, ess)));
logger.log(Level.INFO, _("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(result, ess), amount, Util.displayCurrency(worth, ess)));
user.sendMessage(_("itemSold", NumberUtil.displayCurrency(result, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), NumberUtil.displayCurrency(worth, ess)));
logger.log(Level.INFO, _("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(Locale.ENGLISH), NumberUtil.displayCurrency(result, ess), amount, NumberUtil.displayCurrency(worth, ess)));
return result;
}
}

View file

@ -2,7 +2,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.NumberUtil;
import com.earth2me.essentials.utils.StringUtil;
import java.util.Locale;
import org.bukkit.Location;
import org.bukkit.Server;
@ -52,7 +53,7 @@ public class Commandsethome extends EssentialsCommand
{
name = "home";
}
if ("bed".equals(name) || Util.isInt(name))
if ("bed".equals(name) || NumberUtil.isInt(name))
{
throw new NoSuchFieldException(_("invalidHomeName"));
}

View file

@ -2,7 +2,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import org.bukkit.Server;
@ -21,7 +21,7 @@ public class Commandsetjail extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
ess.getJails().setJail(args[0], user.getLocation());
user.sendMessage(_("jailSet", Util.sanitizeString(args[0])));
user.sendMessage(_("jailSet", StringUtil.sanitizeString(args[0])));
}
}

View file

@ -2,8 +2,9 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.api.IWarps;
import com.earth2me.essentials.utils.NumberUtil;
import org.bukkit.Location;
import org.bukkit.Server;
@ -23,7 +24,7 @@ public class Commandsetwarp extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
if (Util.isInt(args[0]) || args[0].isEmpty())
if (NumberUtil.isInt(args[0]) || args[0].isEmpty())
{
throw new NoSuchFieldException(_("invalidWarpName"));
}
@ -40,7 +41,7 @@ public class Commandsetwarp extends EssentialsCommand
{
}
if (warpLoc == null || user.isAuthorized("essentials.warp.overwrite." + Util.safeString(args[0])))
if (warpLoc == null || user.isAuthorized("essentials.warp.overwrite." + StringUtil.safeString(args[0])))
{
warps.setWarp(args[0], loc);
}

View file

@ -4,7 +4,9 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Mob;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.LocationUtil;
import com.earth2me.essentials.utils.NumberUtil;
import java.util.Locale;
import org.bukkit.Location;
import org.bukkit.Material;
@ -24,10 +26,10 @@ public class Commandspawner extends EssentialsCommand
{
if (args.length < 1 || args[0].length() < 2)
{
throw new NotEnoughArgumentsException(_("mobsAvailable", Util.joinList(Mob.getMobList())));
throw new NotEnoughArgumentsException(_("mobsAvailable", StringUtil.joinList(Mob.getMobList())));
}
final Location target = Util.getTarget(user);
final Location target = LocationUtil.getTarget(user);
if (target == null || target.getBlock().getType() != Material.MOB_SPAWNER)
{
throw new Exception(_("mobSpawnTarget"));
@ -52,7 +54,7 @@ public class Commandspawner extends EssentialsCommand
}
if (args.length > 1)
{
if (Util.isInt(args[1]))
if (NumberUtil.isInt(args[1]))
{
delay = Integer.parseInt(args[1]);
}

View file

@ -4,7 +4,7 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Mob;
import com.earth2me.essentials.SpawnMob;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import java.util.List;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -55,7 +55,7 @@ public class Commandspawnmob extends EssentialsCommand
{
if (args.length < 3)
{
final String mobList = Util.joinList(Mob.getMobList());
final String mobList = StringUtil.joinList(Mob.getMobList());
throw new NotEnoughArgumentsException(_("mobsAvailable", mobList));
}

View file

@ -3,7 +3,8 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.DateUtil;
import java.util.GregorianCalendar;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -43,7 +44,7 @@ public class Commandtempban extends EssentialsCommand
}
}
final String time = getFinalArg(args, 1);
final long banTimestamp = Util.parseDateDiff(time, true);
final long banTimestamp = DateUtil.parseDateDiff(time, true);
final long maxBanLength = ess.getSettings().getMaxTempban() * 1000;
if (maxBanLength > 0 && ((banTimestamp - GregorianCalendar.getInstance().getTimeInMillis()) > maxBanLength)
@ -54,7 +55,7 @@ public class Commandtempban extends EssentialsCommand
}
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
final String banReason = _("tempBanned", Util.formatDateDiff(banTimestamp), senderName);
final String banReason = _("tempBanned", DateUtil.formatDateDiff(banTimestamp), senderName);
user.setBanReason(banReason);
user.setBanTimeout(banTimestamp);
user.setBanned(true);

View file

@ -1,9 +1,10 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.DescParseTickFormat;
import com.earth2me.essentials.utils.DescParseTickFormat;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.NumberUtil;
import com.earth2me.essentials.utils.StringUtil;
import java.util.*;
import org.bukkit.Server;
import org.bukkit.World;
@ -22,11 +23,11 @@ public class Commandtime extends EssentialsCommand
{
boolean add = false;
final List<String> argList = new ArrayList<String>(Arrays.asList(args));
if (argList.remove("set") && !argList.isEmpty() && Util.isInt(argList.get(0)))
if (argList.remove("set") && !argList.isEmpty() && NumberUtil.isInt(argList.get(0)))
{
argList.set(0, argList.get(0) + "t");
}
if (argList.remove("add") && !argList.isEmpty() && Util.isInt(argList.get(0)))
if (argList.remove("add") && !argList.isEmpty() && NumberUtil.isInt(argList.get(0)))
{
add = true;
argList.set(0, argList.get(0) + "t");

View file

@ -2,7 +2,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.DateUtil;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -61,11 +62,11 @@ public class Commandtogglejail extends EssentialsCommand
if (args.length > 2)
{
final String time = getFinalArg(args, 2);
timeDiff = Util.parseDateDiff(time, true);
timeDiff = DateUtil.parseDateDiff(time, true);
player.setJailTimeout(timeDiff);
}
sender.sendMessage((timeDiff > 0
? _("playerJailedFor", player.getName(), Util.formatDateDiff(timeDiff))
? _("playerJailedFor", player.getName(), DateUtil.formatDateDiff(timeDiff))
: _("playerJailed", player.getName())));
return;
}
@ -79,9 +80,9 @@ public class Commandtogglejail extends EssentialsCommand
if (args.length >= 2 && player.isJailed() && args[1].equalsIgnoreCase(player.getJail()))
{
final String time = getFinalArg(args, 2);
final long timeDiff = Util.parseDateDiff(time, true);
final long timeDiff = DateUtil.parseDateDiff(time, true);
player.setJailTimeout(timeDiff);
sender.sendMessage(_("jailSentenceExtended", Util.formatDateDiff(timeDiff)));
sender.sendMessage(_("jailSentenceExtended", DateUtil.formatDateDiff(timeDiff)));
return;
}

View file

@ -2,7 +2,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.LocationUtil;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.TreeType;
@ -60,8 +61,8 @@ public class Commandtree extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
final Location loc = Util.getTarget(user);
final Location safeLocation = Util.getSafeDestination(loc);
final Location loc = LocationUtil.getTarget(user);
final Location safeLocation = LocationUtil.getSafeDestination(loc);
final boolean success = user.getWorld().generateTree(safeLocation, tree);
if (success)
{

View file

@ -3,7 +3,8 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.FormatUtil;
import java.util.logging.Level;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -25,7 +26,7 @@ public class Commandunbanip extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
String ipAddress;
if (Util.validIP(args[0]))
if (FormatUtil.validIP(args[0]))
{
ipAddress = args[0];
}

View file

@ -3,8 +3,9 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.api.IWarps;
import com.earth2me.essentials.utils.NumberUtil;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Iterator;
@ -54,7 +55,7 @@ public class Commandwarp extends EssentialsCommand
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2 || Util.isInt(args[0]))
if (args.length < 2 || NumberUtil.isInt(args[0]))
{
warpList(sender, args);
throw new NoChargeException();
@ -88,13 +89,13 @@ public class Commandwarp extends EssentialsCommand
}
}
int page = 1;
if (args.length > 0 && Util.isInt(args[0]))
if (args.length > 0 && NumberUtil.isInt(args[0]))
{
page = Integer.parseInt(args[0]);
}
final int warpPage = (page - 1) * WARPS_PER_PAGE;
final String warpList = Util.joinList(warpNameList.subList(warpPage, warpPage + Math.min(warpNameList.size() - warpPage, WARPS_PER_PAGE)));
final String warpList = StringUtil.joinList(warpNameList.subList(warpPage, warpPage + Math.min(warpNameList.size() - warpPage, WARPS_PER_PAGE)));
if (warpNameList.size() > WARPS_PER_PAGE)
{

View file

@ -2,8 +2,10 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.craftbukkit.SetExpFix;
import com.earth2me.essentials.utils.NumberUtil;
import com.earth2me.essentials.utils.DateUtil;
import java.util.Locale;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -36,7 +38,7 @@ public class Commandwhois extends EssentialsCommand
sender.sendMessage(_("whoisLocation", user.getLocation().getWorld().getName(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ()));
if (!ess.getSettings().isEcoDisabled())
{
sender.sendMessage(_("whoisMoney", Util.displayCurrency(user.getMoney(), ess)));
sender.sendMessage(_("whoisMoney", NumberUtil.displayCurrency(user.getMoney(), ess)));
}
sender.sendMessage(_("whoisIPAddress", user.getAddress().getAddress().toString()));
final String location = user.getGeoLocation();
@ -52,12 +54,12 @@ public class Commandwhois extends EssentialsCommand
sender.sendMessage(_("whoisAFK", (user.isAfk() ? _("true") : _("false"))));
sender.sendMessage(_("whoisJail", (user.isJailed()
? user.getJailTimeout() > 0
? Util.formatDateDiff(user.getJailTimeout())
? DateUtil.formatDateDiff(user.getJailTimeout())
: _("true")
: _("false"))));
sender.sendMessage(_("whoisMuted", (user.isMuted()
? user.getMuteTimeout() > 0
? Util.formatDateDiff(user.getMuteTimeout())
? DateUtil.formatDateDiff(user.getMuteTimeout())
: _("true")
: _("false"))));

View file

@ -2,7 +2,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.NumberUtil;
import java.math.BigDecimal;
import java.util.Locale;
import org.bukkit.Server;
@ -54,14 +55,14 @@ public class Commandworth extends EssentialsCommand
? _("worthMeta",
iStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""),
iStack.getDurability(),
Util.displayCurrency(result, ess),
NumberUtil.displayCurrency(result, ess),
amount,
Util.displayCurrency(worth, ess))
NumberUtil.displayCurrency(worth, ess))
: _("worth",
iStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""),
Util.displayCurrency(result, ess),
NumberUtil.displayCurrency(result, ess),
amount,
Util.displayCurrency(worth, ess)));
NumberUtil.displayCurrency(worth, ess)));
}
@Override
@ -100,13 +101,13 @@ public class Commandworth extends EssentialsCommand
? _("worthMeta",
iStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""),
iStack.getDurability(),
Util.displayCurrency(result, ess),
NumberUtil.displayCurrency(result, ess),
amount,
Util.displayCurrency(worth, ess))
NumberUtil.displayCurrency(worth, ess))
: _("worth",
iStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""),
Util.displayCurrency(result, ess),
NumberUtil.displayCurrency(result, ess),
amount,
Util.displayCurrency(worth, ess)));
NumberUtil.displayCurrency(worth, ess)));
}
}

View file

@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.*;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.utils.FormatUtil;
import java.util.List;
import java.util.Locale;
import java.util.logging.Logger;
@ -94,7 +95,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand
final User userMatch = ess.getUser(onlinePlayer);
if (getHidden || !userMatch.isHidden() || userMatch.equals(sourceUser))
{
final String displayName = Util.stripFormat(userMatch.getDisplayName()).toLowerCase(Locale.ENGLISH);
final String displayName = FormatUtil.stripFormat(userMatch.getDisplayName()).toLowerCase(Locale.ENGLISH);
if (displayName.contains(matchText))
{
return userMatch;

View file

@ -1,6 +1,7 @@
package com.earth2me.essentials.perm;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.NumberUtil;
import com.earth2me.essentials.utils.StringUtil;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
@ -160,7 +161,7 @@ public class PermissionsHandler implements IPermissionsHandler
if (bPermPlugin != null && bPermPlugin.isEnabled())
{
final String bVer = bPermPlugin.getDescription().getVersion().replace(".", "");
if (Util.isInt(bVer) && Integer.parseInt(bVer) < 284)
if (NumberUtil.isInt(bVer) && Integer.parseInt(bVer) < 284)
{
if (!(handler instanceof BPermissionsHandler))
{

View file

@ -2,6 +2,7 @@ package com.earth2me.essentials.signs;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.*;
import com.earth2me.essentials.utils.NumberUtil;
import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Locale;
@ -289,7 +290,7 @@ public class EssentialsSign
final BigDecimal money = trade.getMoney();
if (money != null)
{
sign.setLine(index, Util.shortCurrency(money, ess));
sign.setLine(index, NumberUtil.shortCurrency(money, ess));
}
}

View file

@ -3,7 +3,8 @@ package com.earth2me.essentials.signs;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.NumberUtil;
public class SignBalance extends EssentialsSign
@ -16,7 +17,7 @@ public class SignBalance extends EssentialsSign
@Override
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
{
player.sendMessage(_("balance", Util.displayCurrency(player.getMoney(), ess)));
player.sendMessage(_("balance", NumberUtil.displayCurrency(player.getMoney(), ess)));
return true;
}
}

View file

@ -2,7 +2,8 @@ package com.earth2me.essentials.signs;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.FormatUtil;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Material;
@ -90,7 +91,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)));
}
final String topLine = event.getLine(0);
@ -99,7 +100,7 @@ public class SignBlockListener implements Listener
final EssentialsSign sign = signs.getSign();
if (topLine.equalsIgnoreCase(sign.getSuccessName()))
{
event.setLine(0, Util.stripFormat(topLine));
event.setLine(0, FormatUtil.stripFormat(topLine));
}
}
}

View file

@ -3,6 +3,7 @@ package com.earth2me.essentials.signs;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.*;
import com.earth2me.essentials.Trade.OverflowType;
import com.earth2me.essentials.utils.FormatUtil;
import java.util.*;
import org.bukkit.Location;
import org.bukkit.Material;
@ -145,7 +146,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;
}

View file

@ -4,6 +4,7 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade.TradeType;
import com.earth2me.essentials.*;
import com.earth2me.essentials.Trade.OverflowType;
import com.earth2me.essentials.utils.NumberUtil;
import java.math.BigDecimal;
import java.util.Map;
import org.bukkit.inventory.ItemStack;
@ -175,11 +176,11 @@ public class SignTrade extends EssentialsSign
final BigDecimal money = getMoney(split[0]);
if (money != null)
{
if (Util.shortCurrency(money, ess).length() * 2 > 15)
if (NumberUtil.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, NumberUtil.shortCurrency(money, ess) + ":0");
return;
}
}
@ -195,7 +196,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, NumberUtil.shortCurrency(money, ess) + ":" + NumberUtil.shortCurrency(amount, ess).substring(1));
return;
}
}
@ -384,7 +385,7 @@ public class SignTrade extends EssentialsSign
final BigDecimal amount = getBigDecimal(split[1]);
if (money != null && amount != null)
{
final String newline = Util.shortCurrency(money, ess) + ":" + Util.shortCurrency(value, ess).substring(1);
final String newline = NumberUtil.shortCurrency(money, ess) + ":" + NumberUtil.shortCurrency(value, ess).substring(1);
if (newline.length() > 15)
{
throw new SignException("This sign is full: Line too long!");

View file

@ -1,6 +1,7 @@
package com.earth2me.essentials.storage;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.NumberUtil;
import com.earth2me.essentials.utils.StringUtil;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Locale;
@ -43,7 +44,7 @@ public class BukkitConstructor extends CustomClassLoaderConstructor
{
final String val = (String)constructScalar((ScalarNode)node);
Material mat;
if (Util.isInt(val))
if (NumberUtil.isInt(val))
{
final int typeId = Integer.parseInt(val);
mat = Material.getMaterial(typeId);
@ -67,7 +68,7 @@ public class BukkitConstructor extends CustomClassLoaderConstructor
return null;
}
Material mat;
if (Util.isInt(split[0]))
if (NumberUtil.isInt(split[0]))
{
final int typeId = Integer.parseInt(split[0]);
mat = Material.getMaterial(typeId);
@ -81,7 +82,7 @@ public class BukkitConstructor extends CustomClassLoaderConstructor
return null;
}
byte data = 0;
if (split.length == 2 && Util.isInt(split[1]))
if (split.length == 2 && NumberUtil.isInt(split[1]))
{
data = Byte.parseByte(split[1]);
}
@ -105,7 +106,7 @@ public class BukkitConstructor extends CustomClassLoaderConstructor
return null;
}
Material mat;
if (Util.isInt(split2[0]))
if (NumberUtil.isInt(split2[0]))
{
final int typeId = Integer.parseInt(split2[0]);
mat = Material.getMaterial(typeId);
@ -119,12 +120,12 @@ public class BukkitConstructor extends CustomClassLoaderConstructor
return null;
}
short data = 0;
if (split2.length == 2 && Util.isInt(split2[1]))
if (split2.length == 2 && NumberUtil.isInt(split2[1]))
{
data = Short.parseShort(split2[1]);
}
int size = mat.getMaxStackSize();
if (split1.length > 1 && Util.isInt(split1[1]))
if (split1.length > 1 && NumberUtil.isInt(split1[1]))
{
size = Integer.parseInt(split1[1]);
}
@ -139,7 +140,7 @@ public class BukkitConstructor extends CustomClassLoaderConstructor
continue;
}
Enchantment enchantment;
if (Util.isInt(split3[0]))
if (NumberUtil.isInt(split3[0]))
{
final int enchantId = Integer.parseInt(split3[0]);
enchantment = Enchantment.getById(enchantId);
@ -153,7 +154,7 @@ public class BukkitConstructor extends CustomClassLoaderConstructor
continue;
}
int level = enchantment.getStartLevel();
if (split3.length == 2 && Util.isInt(split3[1]))
if (split3.length == 2 && NumberUtil.isInt(split3[1]))
{
level = Integer.parseInt(split3[1]);
}
@ -183,7 +184,7 @@ public class BukkitConstructor extends CustomClassLoaderConstructor
return null;
}
Enchantment enchant;
if (Util.isInt(split[0]))
if (NumberUtil.isInt(split[0]))
{
final int typeId = Integer.parseInt(split[0]);
enchant = Enchantment.getById(typeId);
@ -197,7 +198,7 @@ public class BukkitConstructor extends CustomClassLoaderConstructor
return null;
}
int level = enchant.getStartLevel();
if (split.length == 2 && Util.isInt(split[1]))
if (split.length == 2 && NumberUtil.isInt(split[1]))
{
level = Integer.parseInt(split[1]);
}

View file

@ -1,9 +1,10 @@
package com.earth2me.essentials.textreader;
import com.earth2me.essentials.DescParseTickFormat;
import com.earth2me.essentials.utils.DescParseTickFormat;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.NumberUtil;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
@ -43,7 +44,7 @@ public class KeywordReplacer implements IText
userName = user.getName();
ipAddress = user.getAddress() == null || user.getAddress().getAddress() == null ? "" : user.getAddress().getAddress().toString();
address = user.getAddress() == null ? "" : user.getAddress().toString();
balance = Util.displayCurrency(user.getMoney(), ess);
balance = NumberUtil.displayCurrency(user.getMoney(), ess);
mails = Integer.toString(user.getMails().size());
world = user.getLocation() == null || user.getLocation().getWorld() == null ? "" : user.getLocation().getWorld().getName();
worldTime12 = DescParseTickFormat.format12(user.getWorld() == null ? 0 : user.getWorld().getTime());

View file

@ -2,7 +2,7 @@ package com.earth2me.essentials.textreader;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import java.io.*;
import java.lang.ref.SoftReference;
import java.util.*;
@ -25,10 +25,10 @@ public class TextInput implements IText
if (sender instanceof Player)
{
final User user = ess.getUser(sender);
file = new File(ess.getDataFolder(), filename + "_" + Util.sanitizeFileName(user.getName()) + ".txt");
file = new File(ess.getDataFolder(), filename + "_" + StringUtil.sanitizeFileName(user.getName()) + ".txt");
if (!file.exists())
{
file = new File(ess.getDataFolder(), filename + "_" + Util.sanitizeFileName(user.getGroup()) + ".txt");
file = new File(ess.getDataFolder(), filename + "_" + StringUtil.sanitizeFileName(user.getGroup()) + ".txt");
}
}
if (file == null || !file.exists())

View file

@ -0,0 +1,176 @@
package com.earth2me.essentials.utils;
import static com.earth2me.essentials.I18n._;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class DateUtil
{
public static long parseDateDiff(String time, boolean future) throws Exception
{
Pattern timePattern = Pattern.compile("(?:([0-9]+)\\s*y[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*w[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*d[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*h[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*m[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*(?:s[a-z]*)?)?", Pattern.CASE_INSENSITIVE);
Matcher m = timePattern.matcher(time);
int years = 0;
int months = 0;
int weeks = 0;
int days = 0;
int hours = 0;
int minutes = 0;
int seconds = 0;
boolean found = false;
while (m.find())
{
if (m.group() == null || m.group().isEmpty())
{
continue;
}
for (int i = 0; i < m.groupCount(); i++)
{
if (m.group(i) != null && !m.group(i).isEmpty())
{
found = true;
break;
}
}
if (found)
{
if (m.group(1) != null && !m.group(1).isEmpty())
{
years = Integer.parseInt(m.group(1));
}
if (m.group(2) != null && !m.group(2).isEmpty())
{
months = Integer.parseInt(m.group(2));
}
if (m.group(3) != null && !m.group(3).isEmpty())
{
weeks = Integer.parseInt(m.group(3));
}
if (m.group(4) != null && !m.group(4).isEmpty())
{
days = Integer.parseInt(m.group(4));
}
if (m.group(5) != null && !m.group(5).isEmpty())
{
hours = Integer.parseInt(m.group(5));
}
if (m.group(6) != null && !m.group(6).isEmpty())
{
minutes = Integer.parseInt(m.group(6));
}
if (m.group(7) != null && !m.group(7).isEmpty())
{
seconds = Integer.parseInt(m.group(7));
}
break;
}
}
if (!found)
{
throw new Exception(_("illegalDate"));
}
Calendar c = new GregorianCalendar();
if (years > 0)
{
c.add(Calendar.YEAR, years * (future ? 1 : -1));
}
if (months > 0)
{
c.add(Calendar.MONTH, months * (future ? 1 : -1));
}
if (weeks > 0)
{
c.add(Calendar.WEEK_OF_YEAR, weeks * (future ? 1 : -1));
}
if (days > 0)
{
c.add(Calendar.DAY_OF_MONTH, days * (future ? 1 : -1));
}
if (hours > 0)
{
c.add(Calendar.HOUR_OF_DAY, hours * (future ? 1 : -1));
}
if (minutes > 0)
{
c.add(Calendar.MINUTE, minutes * (future ? 1 : -1));
}
if (seconds > 0)
{
c.add(Calendar.SECOND, seconds * (future ? 1 : -1));
}
Calendar max = new GregorianCalendar();
max.add(Calendar.YEAR, 10);
if (c.after(max))
{
return max.getTimeInMillis();
}
return c.getTimeInMillis();
}
static int dateDiff(int type, Calendar fromDate, Calendar toDate, boolean future)
{
int diff = 0;
long savedDate = fromDate.getTimeInMillis();
while ((future && !fromDate.after(toDate)) || (!future && !fromDate.before(toDate)))
{
savedDate = fromDate.getTimeInMillis();
fromDate.add(type, future ? 1 : -1);
diff++;
}
diff--;
fromDate.setTimeInMillis(savedDate);
return diff;
}
public static String formatDateDiff(long date)
{
Calendar c = new GregorianCalendar();
c.setTimeInMillis(date);
Calendar now = new GregorianCalendar();
return DateUtil.formatDateDiff(now, c);
}
public static String formatDateDiff(Calendar fromDate, Calendar toDate)
{
boolean future = false;
if (toDate.equals(fromDate))
{
return _("now");
}
if (toDate.after(fromDate))
{
future = true;
}
StringBuilder sb = new StringBuilder();
int[] types = new int[]
{
Calendar.YEAR, Calendar.MONTH, Calendar.DAY_OF_MONTH, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND
};
String[] names = new String[]
{
_("year"), _("years"), _("month"), _("months"), _("day"), _("days"), _("hour"), _("hours"), _("minute"), _("minutes"), _("second"), _("seconds")
};
int accuracy = 0;
for (int i = 0; i < types.length; i++)
{
if (accuracy > 2)
{
break;
}
int diff = dateDiff(types[i], fromDate, toDate, future);
if (diff > 0)
{
accuracy++;
sb.append(" ").append(diff).append(" ").append(names[i * 2 + (diff > 1 ? 1 : 0)]);
}
}
if (sb.length() == 0)
{
return "now";
}
return sb.toString().trim();
}
}

View file

@ -1,4 +1,4 @@
package com.earth2me.essentials;
package com.earth2me.essentials.utils;
import static com.earth2me.essentials.I18n._;
import java.text.SimpleDateFormat;

View file

@ -0,0 +1,138 @@
package com.earth2me.essentials.utils;
import com.earth2me.essentials.IUser;
import java.util.regex.Pattern;
public class FormatUtil
{
static final transient Pattern REPLACE_COLOR_PATTERN = Pattern.compile("&([0-9a-f])");
static final transient Pattern VANILLA_MAGIC_PATTERN = Pattern.compile("\u00a7+[Kk]");
static final transient Pattern VANILLA_FORMAT_PATTERN = Pattern.compile("\u00a7+[L-ORl-or]");
static final transient Pattern REPLACE_FORMAT_PATTERN = Pattern.compile("&([l-or])");
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 LOGCOLOR_PATTERN = Pattern.compile("\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]");
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 URL_PATTERN = Pattern.compile("((?:(?:https?)://)?[\\w-_\\.]{2,})\\.([a-z]{2,3}(?:/\\S+)?)");
public static final Pattern IPPATTERN = Pattern.compile("^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$");
//This method is used to simply strip the native minecraft colour codes
public static String stripFormat(final String input)
{
if (input == null)
{
return null;
}
return VANILLA_PATTERN.matcher(input).replaceAll("");
}
//This is the general permission sensitive message format function, checks for urls.
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 (!user.isAuthorized(permBase + ".url"))
{
message = FormatUtil.blockURL(message);
}
return message;
}
//This method is used to simply replace the ess colour codes with minecraft ones, ie &c
public static String replaceFormat(final String input)
{
if (input == null)
{
return null;
}
return REPLACE_PATTERN.matcher(input).replaceAll("\u00a7$1");
}
static String replaceColor(final String input, final Pattern pattern)
{
return pattern.matcher(input).replaceAll("\u00a7$1");
}
//This is the general permission sensitive message format function, does not touch urls.
public static String formatString(final IUser user, final String permBase, final String input)
{
if (input == null)
{
return null;
}
String message;
if (user.isAuthorized(permBase + ".color"))
{
message = FormatUtil.replaceColor(input, REPLACE_COLOR_PATTERN);
}
else
{
message = FormatUtil.stripColor(input, VANILLA_COLOR_PATTERN);
}
if (user.isAuthorized(permBase + ".magic"))
{
message = FormatUtil.replaceColor(message, REPLACE_MAGIC_PATTERN);
}
else
{
message = FormatUtil.stripColor(message, VANILLA_MAGIC_PATTERN);
}
if (user.isAuthorized(permBase + ".format"))
{
message = FormatUtil.replaceColor(message, REPLACE_FORMAT_PATTERN);
}
else
{
message = FormatUtil.stripColor(message, VANILLA_FORMAT_PATTERN);
}
return message;
}
public static String stripLogColorFormat(final String input)
{
if (input == null)
{
return null;
}
return LOGCOLOR_PATTERN.matcher(input).replaceAll("");
}
static String stripColor(final String input, final Pattern pattern)
{
return pattern.matcher(input).replaceAll("");
}
public static String lastCode(final String input)
{
int pos = input.lastIndexOf("\u00a7");
if (pos == -1 || (pos + 1) == input.length())
{
return "";
}
return input.substring(pos, pos + 2);
}
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 boolean validIP(String ipAddress)
{
return IPPATTERN.matcher(ipAddress).matches();
}
}

View file

@ -0,0 +1,306 @@
package com.earth2me.essentials.utils;
import static com.earth2me.essentials.I18n._;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
public class LocationUtil
{
// The player can stand inside these materials
public static final Set<Integer> HOLLOW_MATERIALS = new HashSet<Integer>();
private static final HashSet<Byte> TRANSPARENT_MATERIALS = new HashSet<Byte>();
static
{
HOLLOW_MATERIALS.add(Material.AIR.getId());
HOLLOW_MATERIALS.add(Material.SAPLING.getId());
HOLLOW_MATERIALS.add(Material.POWERED_RAIL.getId());
HOLLOW_MATERIALS.add(Material.DETECTOR_RAIL.getId());
HOLLOW_MATERIALS.add(Material.LONG_GRASS.getId());
HOLLOW_MATERIALS.add(Material.DEAD_BUSH.getId());
HOLLOW_MATERIALS.add(Material.YELLOW_FLOWER.getId());
HOLLOW_MATERIALS.add(Material.RED_ROSE.getId());
HOLLOW_MATERIALS.add(Material.BROWN_MUSHROOM.getId());
HOLLOW_MATERIALS.add(Material.RED_MUSHROOM.getId());
HOLLOW_MATERIALS.add(Material.TORCH.getId());
HOLLOW_MATERIALS.add(Material.REDSTONE_WIRE.getId());
HOLLOW_MATERIALS.add(Material.SEEDS.getId());
HOLLOW_MATERIALS.add(Material.SIGN_POST.getId());
HOLLOW_MATERIALS.add(Material.WOODEN_DOOR.getId());
HOLLOW_MATERIALS.add(Material.LADDER.getId());
HOLLOW_MATERIALS.add(Material.RAILS.getId());
HOLLOW_MATERIALS.add(Material.WALL_SIGN.getId());
HOLLOW_MATERIALS.add(Material.LEVER.getId());
HOLLOW_MATERIALS.add(Material.STONE_PLATE.getId());
HOLLOW_MATERIALS.add(Material.IRON_DOOR_BLOCK.getId());
HOLLOW_MATERIALS.add(Material.WOOD_PLATE.getId());
HOLLOW_MATERIALS.add(Material.REDSTONE_TORCH_OFF.getId());
HOLLOW_MATERIALS.add(Material.REDSTONE_TORCH_ON.getId());
HOLLOW_MATERIALS.add(Material.STONE_BUTTON.getId());
HOLLOW_MATERIALS.add(Material.SNOW.getId());
HOLLOW_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId());
HOLLOW_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId());
HOLLOW_MATERIALS.add(Material.DIODE_BLOCK_ON.getId());
HOLLOW_MATERIALS.add(Material.PUMPKIN_STEM.getId());
HOLLOW_MATERIALS.add(Material.MELON_STEM.getId());
HOLLOW_MATERIALS.add(Material.VINE.getId());
HOLLOW_MATERIALS.add(Material.FENCE_GATE.getId());
HOLLOW_MATERIALS.add(Material.WATER_LILY.getId());
HOLLOW_MATERIALS.add(Material.NETHER_WARTS.getId());
for (Integer integer : HOLLOW_MATERIALS)
{
TRANSPARENT_MATERIALS.add(integer.byteValue());
}
TRANSPARENT_MATERIALS.add((byte)Material.WATER.getId());
TRANSPARENT_MATERIALS.add((byte)Material.STATIONARY_WATER.getId());
}
public final static int RADIUS = 3;
public final static Vector3D[] VOLUME;
public static ItemStack convertBlockToItem(final Block block)
{
final ItemStack is = new ItemStack(block.getType(), 1, (short)0, block.getData());
switch (is.getType())
{
case WOODEN_DOOR:
is.setType(Material.WOOD_DOOR);
is.setDurability((short)0);
break;
case IRON_DOOR_BLOCK:
is.setType(Material.IRON_DOOR);
is.setDurability((short)0);
break;
case SIGN_POST:
case WALL_SIGN:
is.setType(Material.SIGN);
is.setDurability((short)0);
break;
case CROPS:
is.setType(Material.SEEDS);
is.setDurability((short)0);
break;
case CAKE_BLOCK:
is.setType(Material.CAKE);
is.setDurability((short)0);
break;
case BED_BLOCK:
is.setType(Material.BED);
is.setDurability((short)0);
break;
case REDSTONE_WIRE:
is.setType(Material.REDSTONE);
is.setDurability((short)0);
break;
case REDSTONE_TORCH_OFF:
case REDSTONE_TORCH_ON:
is.setType(Material.REDSTONE_TORCH_ON);
is.setDurability((short)0);
break;
case DIODE_BLOCK_OFF:
case DIODE_BLOCK_ON:
is.setType(Material.DIODE);
is.setDurability((short)0);
break;
case DOUBLE_STEP:
is.setType(Material.STEP);
break;
case TORCH:
case RAILS:
case LADDER:
case WOOD_STAIRS:
case COBBLESTONE_STAIRS:
case LEVER:
case STONE_BUTTON:
case FURNACE:
case DISPENSER:
case PUMPKIN:
case JACK_O_LANTERN:
case WOOD_PLATE:
case STONE_PLATE:
case PISTON_STICKY_BASE:
case PISTON_BASE:
case IRON_FENCE:
case THIN_GLASS:
case TRAP_DOOR:
case FENCE:
case FENCE_GATE:
case NETHER_FENCE:
is.setDurability((short)0);
break;
case FIRE:
return null;
case PUMPKIN_STEM:
is.setType(Material.PUMPKIN_SEEDS);
break;
case MELON_STEM:
is.setType(Material.MELON_SEEDS);
break;
}
return is;
}
public static class Vector3D
{
public Vector3D(int x, int y, int z)
{
this.x = x;
this.y = y;
this.z = z;
}
public int x;
public int y;
public int z;
}
static
{
List<Vector3D> pos = new ArrayList<Vector3D>();
for (int x = -RADIUS; x <= RADIUS; x++)
{
for (int y = -RADIUS; y <= RADIUS; y++)
{
for (int z = -RADIUS; z <= RADIUS; z++)
{
pos.add(new Vector3D(x, y, z));
}
}
}
Collections.sort(
pos, new Comparator<Vector3D>()
{
@Override
public int compare(Vector3D a, Vector3D b)
{
return (a.x * a.x + a.y * a.y + a.z * a.z) - (b.x * b.x + b.y * b.y + b.z * b.z);
}
});
VOLUME = pos.toArray(new Vector3D[0]);
}
public static Location getTarget(final LivingEntity entity) throws Exception
{
final Block block = entity.getTargetBlock(TRANSPARENT_MATERIALS, 300);
if (block == null)
{
throw new Exception("Not targeting a block");
}
return block.getLocation();
}
static boolean isBlockAboveAir(final World world, final int x, final int y, final int z)
{
return HOLLOW_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType().getId());
}
public static boolean isBlockUnsafe(final World world, final int x, final int y, final int z)
{
if (isBlockDamaging(world, x, y, z))
{
return true;
}
return isBlockAboveAir(world, x, y, z);
}
public static boolean isBlockDamaging(final World world, final int x, final int y, final int z)
{
final Block below = world.getBlockAt(x, y - 1, z);
if (below.getType() == Material.LAVA || below.getType() == Material.STATIONARY_LAVA)
{
return true;
}
if (below.getType() == Material.FIRE)
{
return true;
}
if (below.getType() == Material.BED_BLOCK)
{
return true;
}
if ((!HOLLOW_MATERIALS.contains(world.getBlockAt(x, y, z).getType().getId())) || (!HOLLOW_MATERIALS.contains(world.getBlockAt(x, y + 1, z).getType().getId())))
{
return true;
}
return false;
}
public static Location getSafeDestination(final Location loc) throws Exception
{
if (loc == null || loc.getWorld() == null)
{
throw new Exception(_("destinationNotSet"));
}
final World world = loc.getWorld();
int x = loc.getBlockX();
int y = (int)Math.round(loc.getY());
int z = loc.getBlockZ();
final int origX = x;
final int origY = y;
final int origZ = z;
while (isBlockAboveAir(world, x, y, z))
{
y -= 1;
if (y < 0)
{
y = origY;
break;
}
}
if (isBlockUnsafe(world, x, y, z))
{
x = Math.round(loc.getX()) == origX ? x - 1 : x + 1;
z = Math.round(loc.getZ()) == origZ ? z - 1 : z + 1;
}
int i = 0;
while (isBlockUnsafe(world, x, y, z))
{
i++;
if (i >= VOLUME.length)
{
x = origX;
y = origY + RADIUS;
z = origZ;
break;
}
x = origX + VOLUME[i].x;
y = origY + VOLUME[i].y;
z = origZ + VOLUME[i].z;
}
while (isBlockUnsafe(world, x, y, z))
{
y += 1;
if (y >= world.getMaxHeight())
{
x += 1;
break;
}
}
while (isBlockUnsafe(world, x, y, z))
{
y -= 1;
if (y <= 1)
{
x += 1;
y = world.getHighestBlockYAt(x, z);
if (x - 48 > loc.getBlockX())
{
throw new Exception(_("holeInFloor"));
}
}
}
return new Location(world, x + 0.5, y, z + 0.5, loc.getYaw(), loc.getPitch());
}
}

View file

@ -0,0 +1,56 @@
package com.earth2me.essentials.utils;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
public class NumberUtil
{
static DecimalFormat threeDPlaces = new DecimalFormat("#,###.###");
static DecimalFormat currencyFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
public static String shortCurrency(final BigDecimal value, final IEssentials ess)
{
return ess.getSettings().getCurrencySymbol() + formatAsCurrency(value);
}
public static String formatDouble(final double value)
{
threeDPlaces.setRoundingMode(RoundingMode.HALF_UP);
return threeDPlaces.format(value);
}
public static String formatAsCurrency(final BigDecimal value)
{
currencyFormat.setRoundingMode(RoundingMode.FLOOR);
String str = currencyFormat.format(value);
if (str.endsWith(".00"))
{
str = str.substring(0, str.length() - 3);
}
return str;
}
public static String displayCurrency(final BigDecimal value, final IEssentials ess)
{
return _("currency", ess.getSettings().getCurrencySymbol(), formatAsCurrency(value));
}
public static boolean isInt(final String sInt)
{
try
{
Integer.parseInt(sInt);
}
catch (NumberFormatException e)
{
return false;
}
return true;
}
}

View file

@ -0,0 +1,66 @@
package com.earth2me.essentials.utils;
import java.util.*;
import java.util.regex.Pattern;
public class StringUtil
{
private StringUtil()
{
}
private final static Pattern INVALIDFILECHARS = Pattern.compile("[^a-z0-9]");
private final static Pattern INVALIDCHARS = Pattern.compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");
//Used to clean file names before saving to disk
public static String sanitizeFileName(final String name)
{
return safeString(name);
}
//Used to clean strings/names before saving as filenames/permissions
public static String safeString(final String string)
{
return INVALIDFILECHARS.matcher(string.toLowerCase(Locale.ENGLISH)).replaceAll("_");
}
//Less restrictive string sanitizing, when not used as perm or filename
public static String sanitizeString(final String string)
{
return INVALIDCHARS.matcher(string).replaceAll("");
}
public static String joinList(Object... list)
{
return joinList(", ", list);
}
public static String joinList(String seperator, Object... list)
{
StringBuilder buf = new StringBuilder();
for (Object each : list)
{
if (buf.length() > 0)
{
buf.append(seperator);
}
if (each instanceof Collection)
{
buf.append(joinList(seperator, ((Collection)each).toArray()));
}
else
{
try
{
buf.append(each.toString());
}
catch (Exception e)
{
buf.append(each.toString());
}
}
}
return buf.toString();
}
}

View file

@ -1,5 +1,7 @@
package com.earth2me.essentials;
import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.LocationUtil;
import java.io.IOException;
import java.util.Calendar;
import java.util.GregorianCalendar;
@ -46,25 +48,25 @@ public class UtilTest extends TestCase
testSet.add(x + ":" + y + ":" + z);
count++;
i++;
if (i >= Util.VOLUME.length)
if (i >= LocationUtil.VOLUME.length)
{
break;
}
x = origX + Util.VOLUME[i].x;
y = origY + Util.VOLUME[i].y;
z = origZ + Util.VOLUME[i].z;
x = origX + LocationUtil.VOLUME[i].x;
y = origY + LocationUtil.VOLUME[i].y;
z = origZ + LocationUtil.VOLUME[i].z;
}
assertTrue(testSet.contains("0:0:0"));
assertTrue(testSet.contains("3:3:3"));
assertEquals(testSet.size(), count);
int diameter = Util.RADIUS * 2 + 1;
int diameter = LocationUtil.RADIUS * 2 + 1;
assertEquals(diameter * diameter * diameter, count);
}
public void testFDDnow()
{
Calendar c = new GregorianCalendar();
String resp = Util.formatDateDiff(c, c);
String resp = DateUtil.formatDateDiff(c, c);
assertEquals(resp, "now");
}
@ -73,67 +75,67 @@ public class UtilTest extends TestCase
Calendar a, b;
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 10, 0, 1);
assertEquals("1 second", Util.formatDateDiff(a, b));
assertEquals("1 second", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 10, 0, 2);
assertEquals("2 seconds", Util.formatDateDiff(a, b));
assertEquals("2 seconds", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 10, 0, 3);
assertEquals("3 seconds", Util.formatDateDiff(a, b));
assertEquals("3 seconds", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 10, 1, 0);
assertEquals("1 minute", Util.formatDateDiff(a, b));
assertEquals("1 minute", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 10, 2, 0);
assertEquals("2 minutes", Util.formatDateDiff(a, b));
assertEquals("2 minutes", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 10, 3, 0);
assertEquals("3 minutes", Util.formatDateDiff(a, b));
assertEquals("3 minutes", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 11, 0, 0);
assertEquals("1 hour", Util.formatDateDiff(a, b));
assertEquals("1 hour", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 12, 0, 0);
assertEquals("2 hours", Util.formatDateDiff(a, b));
assertEquals("2 hours", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 13, 0, 0);
assertEquals("3 hours", Util.formatDateDiff(a, b));
assertEquals("3 hours", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 2, 10, 0, 0);
assertEquals("1 day", Util.formatDateDiff(a, b));
assertEquals("1 day", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 3, 10, 0, 0);
assertEquals("2 days", Util.formatDateDiff(a, b));
assertEquals("2 days", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 4, 10, 0, 0);
assertEquals("3 days", Util.formatDateDiff(a, b));
assertEquals("3 days", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 2, 1, 10, 0, 0);
assertEquals("1 month", Util.formatDateDiff(a, b));
assertEquals("1 month", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 3, 1, 10, 0, 0);
assertEquals("2 months", Util.formatDateDiff(a, b));
assertEquals("2 months", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 4, 1, 10, 0, 0);
assertEquals("3 months", Util.formatDateDiff(a, b));
assertEquals("3 months", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2011, 1, 1, 10, 0, 0);
assertEquals("1 year", Util.formatDateDiff(a, b));
assertEquals("1 year", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2012, 1, 1, 10, 0, 0);
assertEquals("2 years", Util.formatDateDiff(a, b));
assertEquals("2 years", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2013, 1, 1, 10, 0, 0);
assertEquals("3 years", Util.formatDateDiff(a, b));
assertEquals("3 years", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2011, 4, 5, 23, 38, 12);
assertEquals("1 year 3 months 4 days", Util.formatDateDiff(a, b));
assertEquals("1 year 3 months 4 days", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 9, 17, 23, 45, 45);
b = new GregorianCalendar(2015, 3, 7, 10, 0, 0);
assertEquals("4 years 5 months 20 days", Util.formatDateDiff(a, b));
assertEquals("4 years 5 months 20 days", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2011, 4, 31, 10, 0, 0);
b = new GregorianCalendar(2011, 4, 31, 10, 5, 0);
assertEquals("5 minutes", Util.formatDateDiff(a, b));
assertEquals("5 minutes", DateUtil.formatDateDiff(a, b));
}
public void testFDDpast()
@ -141,63 +143,63 @@ public class UtilTest extends TestCase
Calendar a, b;
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 9, 59, 59);
assertEquals("1 second", Util.formatDateDiff(a, b));
assertEquals("1 second", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 9, 59, 58);
assertEquals("2 seconds", Util.formatDateDiff(a, b));
assertEquals("2 seconds", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 9, 59, 57);
assertEquals("3 seconds", Util.formatDateDiff(a, b));
assertEquals("3 seconds", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 9, 59, 0);
assertEquals("1 minute", Util.formatDateDiff(a, b));
assertEquals("1 minute", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 9, 58, 0);
assertEquals("2 minutes", Util.formatDateDiff(a, b));
assertEquals("2 minutes", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 9, 57, 0);
assertEquals("3 minutes", Util.formatDateDiff(a, b));
assertEquals("3 minutes", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 9, 0, 0);
assertEquals("1 hour", Util.formatDateDiff(a, b));
assertEquals("1 hour", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 8, 0, 0);
assertEquals("2 hours", Util.formatDateDiff(a, b));
assertEquals("2 hours", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 7, 0, 0);
assertEquals("3 hours", Util.formatDateDiff(a, b));
assertEquals("3 hours", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 5, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 4, 10, 0, 0);
assertEquals("1 day", Util.formatDateDiff(a, b));
assertEquals("1 day", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 5, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 3, 10, 0, 0);
assertEquals("2 days", Util.formatDateDiff(a, b));
assertEquals("2 days", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 5, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 2, 10, 0, 0);
assertEquals("3 days", Util.formatDateDiff(a, b));
assertEquals("3 days", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 5, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 4, 1, 10, 0, 0);
assertEquals("1 month", Util.formatDateDiff(a, b));
assertEquals("1 month", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 5, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 3, 1, 10, 0, 0);
assertEquals("2 months", Util.formatDateDiff(a, b));
assertEquals("2 months", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 5, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 2, 1, 10, 0, 0);
assertEquals("3 months", Util.formatDateDiff(a, b));
assertEquals("3 months", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2009, 1, 1, 10, 0, 0);
assertEquals("1 year", Util.formatDateDiff(a, b));
assertEquals("1 year", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2008, 1, 1, 10, 0, 0);
assertEquals("2 years", Util.formatDateDiff(a, b));
assertEquals("2 years", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2007, 1, 1, 10, 0, 0);
assertEquals("3 years", Util.formatDateDiff(a, b));
assertEquals("3 years", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2009, 4, 5, 23, 38, 12);
assertEquals("8 months 26 days 10 hours", Util.formatDateDiff(a, b));
assertEquals("8 months 26 days 10 hours", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 9, 17, 23, 45, 45);
b = new GregorianCalendar(2000, 3, 7, 10, 0, 0);
assertEquals("10 years 6 months 10 days", Util.formatDateDiff(a, b));
assertEquals("10 years 6 months 10 days", DateUtil.formatDateDiff(a, b));
}
}

View file

@ -395,6 +395,11 @@ is divided into following sections:
</and>
</condition>
</target>
<target name="-init-test-properties">
<property name="test.binaryincludes" value="&lt;nothing&gt;"/>
<property name="test.binarytestincludes" value=""/>
<property name="test.binaryexcludes" value=""/>
</target>
<target if="${nb.junit.single}" name="-init-macrodef-junit-single" unless="${nb.junit.batch}">
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
@ -418,7 +423,7 @@ is divided into following sections:
</sequential>
</macrodef>
</target>
<target if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
<target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
@ -432,6 +437,9 @@ is divided into following sections:
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
<fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
<filename name="${test.binarytestincludes}"/>
</fileset>
</batchtest>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
@ -559,7 +567,7 @@ is divided into following sections:
</sequential>
</macrodef>
</target>
<target if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
<target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
<macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
@ -573,6 +581,9 @@ is divided into following sections:
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
<fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
<filename name="${test.binarytestincludes}"/>
</fileset>
</batchtest>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
@ -952,7 +963,7 @@ is divided into following sections:
<target if="has.persistence.xml" name="-copy-persistence-xml">
<mkdir dir="${build.classes.dir}/META-INF"/>
<copy todir="${build.classes.dir}/META-INF">
<fileset dir="${meta.inf.dir}" includes="persistence.xml"/>
<fileset dir="${meta.inf.dir}" includes="persistence.xml orm.xml"/>
</copy>
</target>
<target name="-post-compile">

View file

@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.38.3.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=ddb4519c
nbproject/build-impl.xml.script.CRC32=00e1454b
nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46
nbproject/build-impl.xml.script.CRC32=1c67208a
nbproject/build-impl.xml.stylesheet.CRC32=c6d2a60f@1.56.1.46

View file

@ -395,6 +395,11 @@ is divided into following sections:
</and>
</condition>
</target>
<target name="-init-test-properties">
<property name="test.binaryincludes" value="&lt;nothing&gt;"/>
<property name="test.binarytestincludes" value=""/>
<property name="test.binaryexcludes" value=""/>
</target>
<target if="${nb.junit.single}" name="-init-macrodef-junit-single" unless="${nb.junit.batch}">
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
@ -418,7 +423,7 @@ is divided into following sections:
</sequential>
</macrodef>
</target>
<target if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
<target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
@ -432,6 +437,9 @@ is divided into following sections:
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
<fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
<filename name="${test.binarytestincludes}"/>
</fileset>
</batchtest>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
@ -559,7 +567,7 @@ is divided into following sections:
</sequential>
</macrodef>
</target>
<target if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
<target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
<macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
@ -573,6 +581,9 @@ is divided into following sections:
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
<fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
<filename name="${test.binarytestincludes}"/>
</fileset>
</batchtest>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
@ -952,7 +963,7 @@ is divided into following sections:
<target if="has.persistence.xml" name="-copy-persistence-xml">
<mkdir dir="${build.classes.dir}/META-INF"/>
<copy todir="${build.classes.dir}/META-INF">
<fileset dir="${meta.inf.dir}" includes="persistence.xml"/>
<fileset dir="${meta.inf.dir}" includes="persistence.xml orm.xml"/>
</copy>
</target>
<target name="-post-compile">

View file

@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.38.2.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=7c7f517b
nbproject/build-impl.xml.script.CRC32=9ec3d353
nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46
nbproject/build-impl.xml.script.CRC32=c6c8dc20
nbproject/build-impl.xml.stylesheet.CRC32=c6d2a60f@1.56.1.46

View file

@ -2,7 +2,8 @@ package com.earth2me.essentials.chat;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.FormatUtil;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.Map;
@ -44,7 +45,7 @@ public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer
/**
* This listener should apply the general chat formatting only...then return control back the event handler
*/
event.setMessage(Util.formatMessage(user, "essentials.chat", event.getMessage()));
event.setMessage(FormatUtil.formatMessage(user, "essentials.chat", event.getMessage()));
String group = user.getGroup();
String world = user.getWorld().getName();
MessageFormat format = ess.getSettings().getChatFormat(group);

View file

@ -395,6 +395,11 @@ is divided into following sections:
</and>
</condition>
</target>
<target name="-init-test-properties">
<property name="test.binaryincludes" value="&lt;nothing&gt;"/>
<property name="test.binarytestincludes" value=""/>
<property name="test.binaryexcludes" value=""/>
</target>
<target if="${nb.junit.single}" name="-init-macrodef-junit-single" unless="${nb.junit.batch}">
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
@ -418,7 +423,7 @@ is divided into following sections:
</sequential>
</macrodef>
</target>
<target if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
<target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
@ -432,6 +437,9 @@ is divided into following sections:
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
<fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
<filename name="${test.binarytestincludes}"/>
</fileset>
</batchtest>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
@ -559,7 +567,7 @@ is divided into following sections:
</sequential>
</macrodef>
</target>
<target if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
<target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
<macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
@ -573,6 +581,9 @@ is divided into following sections:
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
<fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
<filename name="${test.binarytestincludes}"/>
</fileset>
</batchtest>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
@ -952,7 +963,7 @@ is divided into following sections:
<target if="has.persistence.xml" name="-copy-persistence-xml">
<mkdir dir="${build.classes.dir}/META-INF"/>
<copy todir="${build.classes.dir}/META-INF">
<fileset dir="${meta.inf.dir}" includes="persistence.xml"/>
<fileset dir="${meta.inf.dir}" includes="persistence.xml orm.xml"/>
</copy>
</target>
<target name="-post-compile">

View file

@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.44.1.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=cbf94f59
nbproject/build-impl.xml.script.CRC32=af872325
nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46
nbproject/build-impl.xml.script.CRC32=e3c8394c
nbproject/build-impl.xml.stylesheet.CRC32=c6d2a60f@1.56.1.46

View file

@ -370,6 +370,11 @@ is divided into following sections:
</and>
</condition>
</target>
<target name="-init-test-properties">
<property name="test.binaryincludes" value="&lt;nothing&gt;"/>
<property name="test.binarytestincludes" value=""/>
<property name="test.binaryexcludes" value=""/>
</target>
<target if="${nb.junit.single}" name="-init-macrodef-junit-single" unless="${nb.junit.batch}">
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
@ -393,7 +398,7 @@ is divided into following sections:
</sequential>
</macrodef>
</target>
<target if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
<target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
@ -407,6 +412,9 @@ is divided into following sections:
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
<fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
<filename name="${test.binarytestincludes}"/>
</fileset>
</batchtest>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
@ -534,7 +542,7 @@ is divided into following sections:
</sequential>
</macrodef>
</target>
<target if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
<target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
<macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
@ -548,6 +556,9 @@ is divided into following sections:
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
<fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
<filename name="${test.binarytestincludes}"/>
</fileset>
</batchtest>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
@ -920,7 +931,7 @@ is divided into following sections:
<target if="has.persistence.xml" name="-copy-persistence-xml">
<mkdir dir="${build.classes.dir}/META-INF"/>
<copy todir="${build.classes.dir}/META-INF">
<fileset dir="${meta.inf.dir}" includes="persistence.xml"/>
<fileset dir="${meta.inf.dir}" includes="persistence.xml orm.xml"/>
</copy>
</target>
<target name="-post-compile">

View file

@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.38.2.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=a6709b83
nbproject/build-impl.xml.script.CRC32=3be9db7e
nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46
nbproject/build-impl.xml.script.CRC32=e5c840ec
nbproject/build-impl.xml.stylesheet.CRC32=c6d2a60f@1.56.1.46

View file

@ -395,6 +395,11 @@ is divided into following sections:
</and>
</condition>
</target>
<target name="-init-test-properties">
<property name="test.binaryincludes" value="&lt;nothing&gt;"/>
<property name="test.binarytestincludes" value=""/>
<property name="test.binaryexcludes" value=""/>
</target>
<target if="${nb.junit.single}" name="-init-macrodef-junit-single" unless="${nb.junit.batch}">
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
@ -418,7 +423,7 @@ is divided into following sections:
</sequential>
</macrodef>
</target>
<target if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
<target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
@ -432,6 +437,9 @@ is divided into following sections:
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
<fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
<filename name="${test.binarytestincludes}"/>
</fileset>
</batchtest>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
@ -559,7 +567,7 @@ is divided into following sections:
</sequential>
</macrodef>
</target>
<target if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
<target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
<macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
@ -573,6 +581,9 @@ is divided into following sections:
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
<fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
<filename name="${test.binarytestincludes}"/>
</fileset>
</batchtest>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
@ -952,7 +963,7 @@ is divided into following sections:
<target if="has.persistence.xml" name="-copy-persistence-xml">
<mkdir dir="${build.classes.dir}/META-INF"/>
<copy todir="${build.classes.dir}/META-INF">
<fileset dir="${meta.inf.dir}" includes="persistence.xml"/>
<fileset dir="${meta.inf.dir}" includes="persistence.xml orm.xml"/>
</copy>
</target>
<target name="-post-compile">

View file

@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.38.3.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=40644caa
nbproject/build-impl.xml.script.CRC32=eecff97a
nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46
nbproject/build-impl.xml.script.CRC32=60fc07c9
nbproject/build-impl.xml.stylesheet.CRC32=c6d2a60f@1.56.1.46

View file

@ -395,6 +395,11 @@ is divided into following sections:
</and>
</condition>
</target>
<target name="-init-test-properties">
<property name="test.binaryincludes" value="&lt;nothing&gt;"/>
<property name="test.binarytestincludes" value=""/>
<property name="test.binaryexcludes" value=""/>
</target>
<target if="${nb.junit.single}" name="-init-macrodef-junit-single" unless="${nb.junit.batch}">
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
@ -418,7 +423,7 @@ is divided into following sections:
</sequential>
</macrodef>
</target>
<target if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
<target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
@ -432,6 +437,9 @@ is divided into following sections:
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
<fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
<filename name="${test.binarytestincludes}"/>
</fileset>
</batchtest>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
@ -559,7 +567,7 @@ is divided into following sections:
</sequential>
</macrodef>
</target>
<target if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
<target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
<macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
@ -573,6 +581,9 @@ is divided into following sections:
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
<fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
<filename name="${test.binarytestincludes}"/>
</fileset>
</batchtest>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
@ -952,7 +963,7 @@ is divided into following sections:
<target if="has.persistence.xml" name="-copy-persistence-xml">
<mkdir dir="${build.classes.dir}/META-INF"/>
<copy todir="${build.classes.dir}/META-INF">
<fileset dir="${meta.inf.dir}" includes="persistence.xml"/>
<fileset dir="${meta.inf.dir}" includes="persistence.xml orm.xml"/>
</copy>
</target>
<target name="-post-compile">

View file

@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.38.2.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=e7b96939
nbproject/build-impl.xml.script.CRC32=731b5e85
nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46
nbproject/build-impl.xml.script.CRC32=1d8d66ff
nbproject/build-impl.xml.stylesheet.CRC32=c6d2a60f@1.56.1.46

Some files were not shown because too many files have changed in this diff Show more