From 86619275992b4b29bfac91897986b10f2ef863cb Mon Sep 17 00:00:00 2001 From: KHobbits Date: Mon, 31 Dec 2012 02:28:52 +0000 Subject: Merge gravy's pull and reformat code --- .../src/com/earth2me/essentials/Economy.java | 31 ++++++++------- .../src/com/earth2me/essentials/Essentials.java | 4 +- .../com/earth2me/essentials/EssentialsConf.java | 24 ++++++----- .../src/com/earth2me/essentials/ISettings.java | 6 +-- .../src/com/earth2me/essentials/Settings.java | 38 +++++++++++++++--- .../com/earth2me/essentials/UpdateUserFiles.java | 14 +++---- .../src/com/earth2me/essentials/UserData.java | 46 ++++++++++++++++------ .../src/com/earth2me/essentials/Util.java | 6 ++- 8 files changed, 108 insertions(+), 61 deletions(-) (limited to 'Essentials2Compat/src/com/earth2me/essentials') diff --git a/Essentials2Compat/src/com/earth2me/essentials/Economy.java b/Essentials2Compat/src/com/earth2me/essentials/Economy.java index ea566eb90..15f0045ac 100644 --- a/Essentials2Compat/src/com/earth2me/essentials/Economy.java +++ b/Essentials2Compat/src/com/earth2me/essentials/Economy.java @@ -14,6 +14,7 @@ public final class Economy private Economy() { } + private static IEssentials ess; private static final String noCallBeforeLoad = "Essentials API is called before Essentials is loaded."; @@ -23,6 +24,7 @@ public final class Economy * @param name Name of the user * @return balance * @throws net.ess3.api.UserDoesNotExistException + * */ public static double getMoney(String name) throws UserDoesNotExistException { @@ -36,10 +38,11 @@ public final class Economy /** * Sets the balance of a user * - * @param name Name of the user + * @param name Name of the user * @param balance The balance you want to set * @throws UserDoesNotExistException If a user by that name does not exists - * @throws net.ess3.api.NoLoanPermittedException If the user is not allowed to have a negative balance + * @throws net.ess3.api.NoLoanPermittedException + * If the user is not allowed to have a negative balance */ public static void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException { @@ -53,10 +56,10 @@ public final class Economy /** * Adds money to the balance of a user * - * @param name Name of the user + * @param name Name of the user * @param amount The money you want to add * @throws UserDoesNotExistException If a user by that name does not exists - * @throws NoLoanPermittedException If the user is not allowed to have a negative balance + * @throws NoLoanPermittedException If the user is not allowed to have a negative balance */ public static void add(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException { @@ -67,10 +70,10 @@ public final class Economy /** * Substracts money from the balance of a user * - * @param name Name of the user + * @param name Name of the user * @param amount The money you want to substract * @throws UserDoesNotExistException If a user by that name does not exists - * @throws NoLoanPermittedException If the user is not allowed to have a negative balance + * @throws NoLoanPermittedException If the user is not allowed to have a negative balance */ public static void subtract(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException { @@ -81,10 +84,10 @@ public final class Economy /** * Divides the balance of a user by a value * - * @param name Name of the user + * @param name Name of the user * @param value The balance is divided by this value * @throws UserDoesNotExistException If a user by that name does not exists - * @throws NoLoanPermittedException If the user is not allowed to have a negative balance + * @throws NoLoanPermittedException If the user is not allowed to have a negative balance */ public static void divide(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException { @@ -95,10 +98,10 @@ public final class Economy /** * Multiplies the balance of a user by a value * - * @param name Name of the user + * @param name Name of the user * @param value The balance is multiplied by this value * @throws UserDoesNotExistException If a user by that name does not exists - * @throws NoLoanPermittedException If the user is not allowed to have a negative balance + * @throws NoLoanPermittedException If the user is not allowed to have a negative balance */ public static void multiply(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException { @@ -111,7 +114,7 @@ public final class Economy * * @param name Name of the user * @throws UserDoesNotExistException If a user by that name does not exists - * @throws NoLoanPermittedException If the user is not allowed to have a negative balance + * @throws NoLoanPermittedException If the user is not allowed to have a negative balance */ public static void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException { @@ -123,7 +126,7 @@ public final class Economy } /** - * @param name Name of the user + * @param name Name of the user * @param amount The amount of money the user should have * @return true, if the user has more or an equal amount of money * @throws UserDoesNotExistException If a user by that name does not exists @@ -134,7 +137,7 @@ public final class Economy } /** - * @param name Name of the user + * @param name Name of the user * @param amount The amount of money the user should have * @return true, if the user has more money * @throws UserDoesNotExistException If a user by that name does not exists @@ -145,7 +148,7 @@ public final class Economy } /** - * @param name Name of the user + * @param name Name of the user * @param amount The amount of money the user should not have * @return true, if the user has less money * @throws UserDoesNotExistException If a user by that name does not exists diff --git a/Essentials2Compat/src/com/earth2me/essentials/Essentials.java b/Essentials2Compat/src/com/earth2me/essentials/Essentials.java index 4d61e6b3d..d625586cd 100644 --- a/Essentials2Compat/src/com/earth2me/essentials/Essentials.java +++ b/Essentials2Compat/src/com/earth2me/essentials/Essentials.java @@ -1,11 +1,11 @@ package com.earth2me.essentials; import java.io.File; +import org.bukkit.Bukkit; +import org.bukkit.plugin.java.JavaPlugin; import net.ess3.api.IEssentials; import net.ess3.api.IItemDb; import net.ess3.api.IPlugin; -import org.bukkit.Bukkit; -import org.bukkit.plugin.java.JavaPlugin; public class Essentials extends JavaPlugin diff --git a/Essentials2Compat/src/com/earth2me/essentials/EssentialsConf.java b/Essentials2Compat/src/com/earth2me/essentials/EssentialsConf.java index 1fc101f8d..45f7b8a29 100644 --- a/Essentials2Compat/src/com/earth2me/essentials/EssentialsConf.java +++ b/Essentials2Compat/src/com/earth2me/essentials/EssentialsConf.java @@ -1,6 +1,6 @@ package com.earth2me.essentials; -import com.google.common.io.Files; +import static net.ess3.I18n._; import java.io.*; import java.nio.ByteBuffer; import java.nio.CharBuffer; @@ -13,8 +13,6 @@ import java.util.Locale; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; -import static net.ess3.I18n._; -import net.ess3.storage.StoredLocation; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Server; @@ -23,6 +21,8 @@ import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; +import com.google.common.io.Files; +import net.ess3.storage.StoredLocation; @Deprecated @@ -127,7 +127,9 @@ public class EssentialsConf extends YamlConfiguration { buffer.rewind(); data.clear(); - LOGGER.log(Level.INFO, "File " + configFile.getAbsolutePath().toString() + " is not utf-8 encoded, trying " + Charset.defaultCharset().displayName()); + LOGGER.log( + Level.INFO, + "File " + configFile.getAbsolutePath().toString() + " is not utf-8 encoded, trying " + Charset.defaultCharset().displayName()); decoder = Charset.defaultCharset().newDecoder(); result = decoder.decode(buffer, data, true); if (result.isError()) @@ -245,12 +247,10 @@ public class EssentialsConf extends YamlConfiguration { return null; } - return new StoredLocation(worldName, - getDouble((path == null ? "" : path + ".") + "x", 0), - getDouble((path == null ? "" : path + ".") + "y", 0), - getDouble((path == null ? "" : path + ".") + "z", 0), - (float)getDouble((path == null ? "" : path + ".") + "yaw", 0), - (float)getDouble((path == null ? "" : path + ".") + "pitch", 0)); + return new StoredLocation( + worldName, getDouble((path == null ? "" : path + ".") + "x", 0), getDouble((path == null ? "" : path + ".") + "y", 0), + getDouble((path == null ? "" : path + ".") + "z", 0), (float)getDouble((path == null ? "" : path + ".") + "yaw", 0), + (float)getDouble((path == null ? "" : path + ".") + "pitch", 0)); } public void setProperty(final String path, final Location loc) @@ -267,9 +267,7 @@ public class EssentialsConf extends YamlConfiguration public ItemStack getItemStack(final String path) { final ItemStack stack = new ItemStack( - Material.valueOf(getString(path + ".type", "AIR")), - getInt(path + ".amount", 1), - (short)getInt(path + ".damage", 0)); + Material.valueOf(getString(path + ".type", "AIR")), getInt(path + ".amount", 1), (short)getInt(path + ".damage", 0)); final ConfigurationSection enchants = getConfigurationSection(path + ".enchant"); if (enchants != null) { diff --git a/Essentials2Compat/src/com/earth2me/essentials/ISettings.java b/Essentials2Compat/src/com/earth2me/essentials/ISettings.java index 268a81ba0..db4af46fa 100644 --- a/Essentials2Compat/src/com/earth2me/essentials/ISettings.java +++ b/Essentials2Compat/src/com/earth2me/essentials/ISettings.java @@ -1,7 +1,6 @@ package com.earth2me.essentials; -import java.text.MessageFormat; import java.util.List; import java.util.Map; import java.util.Set; @@ -10,7 +9,7 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.event.EventPriority; -public interface ISettings +public interface ISettings { boolean areSignsDisabled(); @@ -29,7 +28,6 @@ public interface ISettings int getChatRadius(); - double getCommandCost(String label); String getCurrencySymbol(); @@ -71,7 +69,6 @@ public interface ISettings int getHomeLimit(String set); - boolean getSortListByGroups(); int getSpawnMobLimit(); @@ -85,7 +82,6 @@ public interface ISettings boolean hidePermissionlessHelp(); - boolean isCommandDisabled(String label); boolean isCommandOverridden(String name); diff --git a/Essentials2Compat/src/com/earth2me/essentials/Settings.java b/Essentials2Compat/src/com/earth2me/essentials/Settings.java index 262dbe140..406a1a540 100644 --- a/Essentials2Compat/src/com/earth2me/essentials/Settings.java +++ b/Essentials2Compat/src/com/earth2me/essentials/Settings.java @@ -1,17 +1,17 @@ package com.earth2me.essentials; +import static net.ess3.I18n._; import java.io.File; import java.text.MessageFormat; import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; -import static net.ess3.I18n._; -import net.ess3.api.IEssentials; import org.bukkit.ChatColor; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.MemoryConfiguration; import org.bukkit.event.EventPriority; import org.bukkit.inventory.ItemStack; +import net.ess3.api.IEssentials; public class Settings implements ISettings @@ -52,6 +52,7 @@ public class Settings implements ISettings { return config.getInt("sethome-multiple." + set, config.getInt("sethome-multiple.default", 3)); } + private int chatRadius = 0; private int _getChatRadius() @@ -141,8 +142,8 @@ public class Settings implements ISettings } return config.getBoolean("override-" + name.toLowerCase(Locale.ENGLISH), false); } - private ConfigurationSection commandCosts; + private ConfigurationSection commandCosts; public ConfigurationSection _getCommandCosts() @@ -177,6 +178,7 @@ public class Settings implements ISettings } return 0.0; } + private String nicknamePrefix = "~"; private String _getNicknamePrefix() @@ -201,6 +203,7 @@ public class Settings implements ISettings { return config.getDouble("heal-cooldown", 0); } + private ConfigurationSection kits; public ConfigurationSection _getKits() @@ -241,6 +244,7 @@ public class Settings implements ISettings } return null; } + private ChatColor operatorColor = null; @Override @@ -314,6 +318,7 @@ public class Settings implements ISettings { return config.getString("backup.command", null); } + private Map chatFormats = Collections.synchronizedMap(new HashMap()); /*@Override @@ -337,7 +342,7 @@ public class Settings implements ISettings } return mFormat; }*/ - + public String getDefaultChatformat() { return config.getString("chat.format", "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}"); @@ -410,6 +415,7 @@ public class Settings implements ISettings warnOnBuildDisallow = _warnOnBuildDisallow(); mailsPerMinute = _getMailsPerMinute(); } + private List itemSpawnBl = new ArrayList(); @Override @@ -445,6 +451,7 @@ public class Settings implements ISettings } return epItemSpwn; } + private List enabledSigns = new ArrayList(); private boolean signsEnabled = false; @@ -483,6 +490,7 @@ public class Settings implements ISettings } return newSigns; } + private boolean warnOnBuildDisallow; private boolean _warnOnBuildDisallow() @@ -495,6 +503,7 @@ public class Settings implements ISettings { return warnOnBuildDisallow; } + private boolean debug = false; private boolean configDebug = false; @@ -587,6 +596,7 @@ public class Settings implements ISettings { return config.getBoolean(configName, def); } + private final static double MAXMONEY = 10000000000000.0; @Override @@ -599,6 +609,7 @@ public class Settings implements ISettings } return max; } + private final static double MINMONEY = -10000000000000.0; @Override @@ -633,6 +644,7 @@ public class Settings implements ISettings { return config.getBoolean("remove-god-on-disconnect", false); } + private boolean changeDisplayName = true; private boolean _changeDisplayName() @@ -645,6 +657,7 @@ public class Settings implements ISettings { return changeDisplayName; } + private boolean changePlayerListName = false; private boolean _changePlayerListName() @@ -663,6 +676,7 @@ public class Settings implements ISettings { return config.getBoolean("use-bukkit-permissions", false); } + private boolean prefixsuffixconfigured = false; private boolean addprefixsuffix = false; private boolean essentialsChatActive = false; @@ -688,6 +702,7 @@ public class Settings implements ISettings { return prefixsuffixconfigured ? addprefixsuffix : essentialsChatActive; } + private boolean disablePrefix = false; private boolean _disablePrefix() @@ -700,6 +715,7 @@ public class Settings implements ISettings { return disablePrefix; } + private boolean disableSuffix = false; private boolean _disableSuffix() @@ -724,6 +740,7 @@ public class Settings implements ISettings { return config.getLong("auto-afk-kick", -1); } + private boolean getFreezeAfkPlayers; @Override @@ -736,6 +753,7 @@ public class Settings implements ISettings { return config.getBoolean("freeze-afk-players", false); } + private boolean cancelAfkOnMove; @Override @@ -754,6 +772,7 @@ public class Settings implements ISettings { return config.getBoolean("death-messages", true); } + private Set noGodWorlds = new HashSet(); @Override @@ -785,6 +804,7 @@ public class Settings implements ISettings { return config.getBoolean("world-home-permissions", false); } + private boolean registerBackInListener; @Override @@ -797,6 +817,7 @@ public class Settings implements ISettings { return config.getBoolean("register-back-in-listener", false); } + private boolean disableItemPickupWhileAfk; @Override @@ -854,6 +875,7 @@ public class Settings implements ISettings { this.metricsEnabled = metricsEnabled; } + private boolean teleportInvulnerability; @Override @@ -872,6 +894,7 @@ public class Settings implements ISettings { return teleportInvulnerability; } + private long loginAttackDelay; private long _getLoginAttackDelay() @@ -884,6 +907,7 @@ public class Settings implements ISettings { return loginAttackDelay; } + private int signUsePerSecond; private int _getSignUsePerSecond() @@ -913,12 +937,14 @@ public class Settings implements ISettings double maxSpeed = config.getDouble("max-walk-speed", 0.8); return maxSpeed > 1.0 ? 1.0 : Math.abs(maxSpeed); } - + private int mailsPerMinute; - private int _getMailsPerMinute() { + private int _getMailsPerMinute() + { return config.getInt("mails-per-minute", 1000); } + @Override public int getMailsPerMinute() { diff --git a/Essentials2Compat/src/com/earth2me/essentials/UpdateUserFiles.java b/Essentials2Compat/src/com/earth2me/essentials/UpdateUserFiles.java index 8a229081c..957ed9777 100644 --- a/Essentials2Compat/src/com/earth2me/essentials/UpdateUserFiles.java +++ b/Essentials2Compat/src/com/earth2me/essentials/UpdateUserFiles.java @@ -1,18 +1,14 @@ package com.earth2me.essentials; -import com.google.common.io.PatternFilenameFilter; import java.io.File; import java.util.HashMap; import java.util.Locale; import java.util.Map; import java.util.logging.Level; -import net.ess3.api.IEssentials; -import net.ess3.api.IUser; -import net.ess3.api.InvalidNameException; -import net.ess3.api.NoLoanPermittedException; -import net.ess3.api.UserDoesNotExistException; -import net.ess3.user.User; import org.bukkit.Material; +import com.google.common.io.PatternFilenameFilter; +import net.ess3.api.*; +import net.ess3.user.User; class UpdateUserFiles @@ -57,7 +53,8 @@ class UpdateUserFiles else { IUser user = ess.getUserMap().getUser(name); - if (user == null) { + if (user == null) + { try { user = new User(ess.getServer().getOfflinePlayer(name), ess); @@ -137,6 +134,7 @@ class UpdateUserFiles String realname = getPlayer(name); return realname == null ? BROKENNAME : realname; } + private final Map players = new HashMap(); private String getPlayer(String check) diff --git a/Essentials2Compat/src/com/earth2me/essentials/UserData.java b/Essentials2Compat/src/com/earth2me/essentials/UserData.java index f7c05d2c2..078535293 100644 --- a/Essentials2Compat/src/com/earth2me/essentials/UserData.java +++ b/Essentials2Compat/src/com/earth2me/essentials/UserData.java @@ -2,20 +2,20 @@ package com.earth2me.essentials; import java.io.File; import java.util.*; -import net.ess3.api.IEssentials; -import net.ess3.storage.StoredLocation; import org.bukkit.Location; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.MemoryConfiguration; import org.bukkit.inventory.ItemStack; +import net.ess3.api.IEssentials; +import net.ess3.storage.StoredLocation; -public class UserData +public class UserData { protected final transient IEssentials ess; private EssentialsConf config; private final File folder; - + protected UserData(IEssentials ess, File file) { @@ -59,6 +59,7 @@ public class UserData kitTimestamps = _getKitTimestamps(); nickname = _getNickname(); } + private double money; private double _getMoney() @@ -90,6 +91,7 @@ public class UserData config.setProperty("money", value); config.save(); } + private Map homes; private Map _getHomes() @@ -115,15 +117,14 @@ public class UserData } return search; } - + public StoredLocation getHome(String name) throws Exception { String search = getHomeName(name); - return config.getLocation("homes." + search, ess.getServer()); + return config.getLocation("homes." + search, ess.getServer()); } - public List getHomes() { return new ArrayList(homes.keySet()); @@ -165,6 +166,7 @@ public class UserData } return false; } + private String nickname; public String _getNickname() @@ -183,6 +185,7 @@ public class UserData config.setProperty("nickname", nick); config.save(); } + private List unlimited; private List _getUnlimited() @@ -213,6 +216,7 @@ public class UserData config.setProperty("unlimited", unlimited); config.save(); } + private Map powertools; private Map _getPowertools() @@ -223,8 +227,9 @@ public class UserData } return new HashMap(); } - - public Set getPowertools() { + + public Set getPowertools() + { return powertools.keySet(); } @@ -265,6 +270,7 @@ public class UserData { return !powertools.isEmpty(); } + private StoredLocation lastLocation; private StoredLocation _getLastLocation() @@ -303,6 +309,7 @@ public class UserData config.setProperty("timestamps.lastteleport", time); config.save(); } + private long lastHealTimestamp; private long _getLastHealTimestamp() @@ -321,6 +328,7 @@ public class UserData config.setProperty("timestamps.lastheal", time); config.save(); } + private String jail; private String _getJail() @@ -347,6 +355,7 @@ public class UserData } config.save(); } + private List mails; private List _getMails() @@ -379,6 +388,7 @@ public class UserData mails.add(mail); setMails(mails); } + private boolean teleportEnabled; private boolean getTeleportEnabled() @@ -411,6 +421,7 @@ public class UserData setSocialSpyEnabled(ret); return ret; } + private List ignoredPlayers; public List getIgnoredPlayers() @@ -452,6 +463,7 @@ public class UserData config.setProperty("godmode", set); config.save(); } + private boolean muted; public boolean getMuted() @@ -470,6 +482,7 @@ public class UserData config.setProperty("muted", set); config.save(); } + private long muteTimeout; private long _getMuteTimeout() @@ -488,6 +501,7 @@ public class UserData config.setProperty("timestamps.mute", time); config.save(); } + private boolean jailed; private boolean getJailed() @@ -513,6 +527,7 @@ public class UserData setJailed(ret); return ret; } + private long jailTimeout; private long _getJailTimeout() @@ -553,6 +568,7 @@ public class UserData config.setProperty("ban.timeout", time); config.save(); } + private long lastLogin; private long _getLastLogin() @@ -590,6 +606,7 @@ public class UserData config.setProperty("timestamps.logout", time); config.save(); } + private String lastLoginAddress; private String _getLastLoginAddress() @@ -607,6 +624,7 @@ public class UserData lastLoginAddress = address; config.setProperty("ipAddress", address); } + private boolean afk; private boolean getAfk() @@ -632,6 +650,7 @@ public class UserData setAfk(ret); return ret; } + private boolean newplayer; private String geolocation; @@ -659,6 +678,7 @@ public class UserData } config.save(); } + private boolean isSocialSpyEnabled; private boolean _isSocialSpyEnabled() @@ -677,6 +697,7 @@ public class UserData config.setProperty("socialspy", status); config.save(); } + private boolean isNPC; private boolean _isNPC() @@ -695,6 +716,7 @@ public class UserData config.setProperty("npc", set); config.save(); } + private boolean arePowerToolsEnabled; public boolean arePowerToolsEnabled() @@ -720,6 +742,7 @@ public class UserData { return config.getBoolean("powertoolsenabled", true); } + private ConfigurationSection kitTimestamps; private ConfigurationSection _getKitTimestamps() @@ -744,8 +767,9 @@ public class UserData } return new MemoryConfiguration(); } - - public Set getKitTimestamps() { + + public Set getKitTimestamps() + { return kitTimestamps.getKeys(false); } diff --git a/Essentials2Compat/src/com/earth2me/essentials/Util.java b/Essentials2Compat/src/com/earth2me/essentials/Util.java index 3a34a85fc..1bdc878bb 100644 --- a/Essentials2Compat/src/com/earth2me/essentials/Util.java +++ b/Essentials2Compat/src/com/earth2me/essentials/Util.java @@ -2,7 +2,8 @@ package com.earth2me.essentials; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; -import java.util.*; +import java.util.Collection; +import java.util.Locale; import java.util.logging.Logger; import java.util.regex.Pattern; @@ -12,6 +13,7 @@ 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]"); @@ -46,7 +48,7 @@ public class Util } return str; } - + public static double roundDouble(final double d) { return Math.round(d * 100.0) / 100.0; -- cgit v1.2.3