diff options
author | Iaccidentally <coryhuckaby@gmail.com> | 2013-07-13 13:40:46 -0400 |
---|---|---|
committer | Iaccidentally <coryhuckaby@gmail.com> | 2013-07-13 13:40:46 -0400 |
commit | 3652bd0aca9d3821f4d267b34e29f898b925b2fe (patch) | |
tree | 607edc55990957b15d36afa8f541c1e1a06f6248 | |
parent | 178164152ed850d4d672dc1dc997fdacbb87a3de (diff) | |
download | Essentials-3652bd0aca9d3821f4d267b34e29f898b925b2fe.tar Essentials-3652bd0aca9d3821f4d267b34e29f898b925b2fe.tar.gz Essentials-3652bd0aca9d3821f4d267b34e29f898b925b2fe.tar.lz Essentials-3652bd0aca9d3821f4d267b34e29f898b925b2fe.tar.xz Essentials-3652bd0aca9d3821f4d267b34e29f898b925b2fe.zip |
[API] flip! (╯°□°)╯︵ ┻━┻
21 files changed, 1063 insertions, 1065 deletions
diff --git a/Essentials/src/com/earth2me/essentials/IEssentials.java b/Essentials/src/com/earth2me/essentials/IEssentials.java index 3f541ee8c..f45f15b53 100644 --- a/Essentials/src/com/earth2me/essentials/IEssentials.java +++ b/Essentials/src/com/earth2me/essentials/IEssentials.java @@ -1,7 +1,82 @@ package com.earth2me.essentials; +import com.earth2me.essentials.metrics.Metrics; +import com.earth2me.essentials.perm.PermissionsHandler; +import com.earth2me.essentials.register.payment.Methods; +import java.util.List; +import net.ess3.api.IJails; +import net.ess3.api.IWarps; +import org.bukkit.World; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.plugin.Plugin; +import org.bukkit.scheduler.BukkitScheduler; +import org.bukkit.scheduler.BukkitTask; -public interface IEssentials extends net.ess3.api.IEssentials + +public interface IEssentials extends Plugin { + void addReloadListener(IConf listener); + + void reload(); + + boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix, IEssentialsModule module); + + User getUser(Object base); + + I18n getI18n(); + + User getOfflineUser(String name); + + World getWorld(String name); + + int broadcastMessage(String message); + + int broadcastMessage(net.ess3.api.IUser sender, String message); + + int broadcastMessage(String permission, String message); + + ISettings getSettings(); + + BukkitScheduler getScheduler(); + + IJails getJails(); + + IWarps getWarps(); + + Worth getWorth(); + + Backup getBackup(); + + Methods getPaymentMethod(); + + BukkitTask runTaskAsynchronously(Runnable run); + + BukkitTask runTaskLaterAsynchronously(Runnable run, long delay); + + int scheduleSyncDelayedTask(Runnable run); + + int scheduleSyncDelayedTask(Runnable run, long delay); + + int scheduleSyncRepeatingTask(final Runnable run, long delay, long period); + + TNTExplodeListener getTNTListener(); + + PermissionsHandler getPermissionsHandler(); + + AlternativeCommandsHandler getAlternativeCommandsHandler(); + + void showError(final CommandSender sender, final Throwable exception, final String commandLabel); + + ItemDb getItemDb(); + + UserMap getUserMap(); + + Metrics getMetrics(); + + void setMetrics(Metrics metrics); + + EssentialsTimer getTimer(); + List<String> getVanishedPlayers(); } diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index a50aa0af0..b9d7c1ed0 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -1,7 +1,198 @@ package com.earth2me.essentials; +import com.earth2me.essentials.commands.IEssentialsCommand; +import com.earth2me.essentials.signs.EssentialsSign; +import com.earth2me.essentials.textreader.IText; +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.bukkit.ChatColor; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.event.EventPriority; -public interface ISettings extends net.ess3.api.ISettings + +public interface ISettings extends IConf { + boolean areSignsDisabled(); + + IText getAnnounceNewPlayerFormat(); + + boolean getAnnounceNewPlayers(); + + String getNewPlayerKit(); + + String getBackupCommand(); + + long getBackupInterval(); + + String getChatFormat(String group); + + int getChatRadius(); + + BigDecimal getCommandCost(IEssentialsCommand cmd); + + BigDecimal getCommandCost(String label); + + String getCurrencySymbol(); + + int getOversizedStackSize(); + + int getDefaultStackSize(); + + double getHealCooldown(); + + Set<String> getSocialSpyCommands(); + + Map<String, Object> getKit(String name); + + ConfigurationSection getKits(); + + String getLocale(); + + String getNewbieSpawn(); + + String getNicknamePrefix(); + + ChatColor getOperatorColor() throws Exception; + + boolean getPerWarpPermission(); + + boolean getProtectBoolean(final String configName, boolean def); + + int getProtectCreeperMaxHeight(); + + List<Integer> getProtectList(final String configName); + + boolean getProtectPreventSpawn(final String creatureName); + + String getProtectString(final String configName); + + boolean getRespawnAtHome(); + + Set getMultipleHomes(); + + int getHomeLimit(String set); + + int getHomeLimit(User user); + + int getSpawnMobLimit(); + + BigDecimal getStartingBalance(); + + double getTeleportCooldown(); + + double getTeleportDelay(); + + boolean hidePermissionlessHelp(); + + boolean isCommandDisabled(final IEssentialsCommand cmd); + + boolean isCommandDisabled(String label); + + boolean isCommandOverridden(String name); + + boolean isDebug(); + + boolean isEcoDisabled(); + + boolean isTradeInStacks(int id); + + List<Integer> itemSpawnBlacklist(); + + List<EssentialsSign> enabledSigns(); + + boolean permissionBasedItemSpawn(); + + boolean showNonEssCommandsInHelp(); + + boolean warnOnBuildDisallow(); + + boolean warnOnSmite(); + + BigDecimal getMaxMoney(); + + BigDecimal getMinMoney(); + + boolean isEcoLogEnabled(); + + boolean isEcoLogUpdateEnabled(); + + boolean removeGodOnDisconnect(); + + boolean changeDisplayName(); + + boolean changePlayerListName(); + + boolean isPlayerCommand(String string); + + boolean useBukkitPermissions(); + + boolean addPrefixSuffix(); + + boolean disablePrefix(); + + boolean disableSuffix(); + + long getAutoAfk(); + + long getAutoAfkKick(); + + boolean getFreezeAfkPlayers(); + + boolean cancelAfkOnMove(); + + boolean cancelAfkOnInteract(); + + boolean areDeathMessagesEnabled(); + + public void setDebug(boolean debug); + + Set<String> getNoGodWorlds(); + + boolean getUpdateBedAtDaytime(); + + boolean allowUnsafeEnchantments(); + + boolean getRepairEnchanted(); + + boolean isWorldTeleportPermissions(); + + boolean isWorldHomePermissions(); + + boolean registerBackInListener(); + + boolean getDisableItemPickupWhileAfk(); + + EventPriority getRespawnPriority(); + + long getTpaAcceptCancellation(); + + boolean isMetricsEnabled(); + + void setMetricsEnabled(boolean metricsEnabled); + + long getTeleportInvulnerability(); + + boolean isTeleportInvulnerability(); + + long getLoginAttackDelay(); + + int getSignUsePerSecond(); + + double getMaxFlySpeed(); + + double getMaxWalkSpeed(); + + public int getMailsPerMinute(); + + public long getEconomyLagWarning(); + + public void setEssentialsChatActive(boolean b); + + long getMaxTempban(); + + public Map<String, Object> getListGroupConfig(); + public int getMaxNickLength(); } diff --git a/Essentials/src/com/earth2me/essentials/IUser.java b/Essentials/src/com/earth2me/essentials/IUser.java index c9822e90e..a991c2d1a 100644 --- a/Essentials/src/com/earth2me/essentials/IUser.java +++ b/Essentials/src/com/earth2me/essentials/IUser.java @@ -1,7 +1,92 @@ package com.earth2me.essentials; +import com.earth2me.essentials.commands.IEssentialsCommand; +import java.math.BigDecimal; +import java.util.Map; +import java.util.Set; +import net.ess3.api.ITeleport; +import org.bukkit.Location; +import org.bukkit.entity.Player; -public interface IUser extends net.ess3.api.IUser + +public interface IUser { + long getLastTeleportTimestamp(); + + boolean isAuthorized(String node); + + boolean isAuthorized(IEssentialsCommand cmd); + + boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix); + + void setLastTeleportTimestamp(long time); + + Location getLastLocation(); + + Player getBase(); + + BigDecimal getMoney(); + + void takeMoney(BigDecimal value); + + void giveMoney(BigDecimal value); + + boolean canAfford(BigDecimal value); + + String getGroup(); + + void setLastLocation(); + + Location getHome(String name) throws Exception; + + Location getHome(Location loc) throws Exception; + + /** + * 'Hidden' Represents when a player is hidden from others. This status includes when the player is hidden via other + * supported plugins. Use isVanished() if you want to check if a user is vanished by Essentials. + * + * @return If the user is hidden or not + * @see isVanished + */ + boolean isHidden(); + + void setHidden(boolean vanish); + + /** + * 'Vanished' Represents when a player is hidden from others by Essentials. This status does NOT include when the + * player is hidden via other plugins. Use isHidden() if you want to check if a user is vanished by any supported + * plugin. + * + * @return If the user is vanished or not + * @see isHidden + */ + boolean isVanished(); + + void setVanished(boolean vanish); + + ITeleport getTeleport(); + + void setJail(String jail); + + boolean isIgnoreExempt(); + + boolean isAfk(); + + void setAfk(final boolean set); + + void setLogoutLocation(); + + Location getLogoutLocation(); + + void setConfigProperty(String node, Object object); + + Set<String> getConfigKeys(); + + Map<String, Object> getConfigMap(); + + Map<String, Object> getConfigMap(String node); + + public void sendMessage(String message); + public String getName(); } diff --git a/Essentials/src/com/earth2me/essentials/api/Economy.java b/Essentials/src/com/earth2me/essentials/api/Economy.java index 0de818538..d5539357d 100644 --- a/Essentials/src/com/earth2me/essentials/api/Economy.java +++ b/Essentials/src/com/earth2me/essentials/api/Economy.java @@ -1,7 +1,453 @@ package com.earth2me.essentials.api; +import static net.ess3.api.Economy.add; +import static net.ess3.api.Economy.divide; +import static net.ess3.api.Economy.format; +import static net.ess3.api.Economy.getMoneyExact; +import static net.ess3.api.Economy.hasEnough; +import static net.ess3.api.Economy.hasLess; +import static net.ess3.api.Economy.hasMore; +import static net.ess3.api.Economy.multiply; +import static net.ess3.api.Economy.setMoney; +import static net.ess3.api.Economy.substract; +import net.ess3.api.IEssentials; +import com.earth2me.essentials.EssentialsConf; +import static com.earth2me.essentials.I18n._; +import com.earth2me.essentials.User; +import com.earth2me.essentials.utils.StringUtil; +import com.earth2me.essentials.utils.NumberUtil; +import java.io.File; +import java.math.BigDecimal; +import java.math.MathContext; +import java.util.logging.Level; +import java.util.logging.Logger; -public class Economy extends net.ess3.api.Economy + +/** + * Instead of using this api directly, we recommend to use the register plugin: http://bit.ly/RegisterMethod + */ +public class Economy { + public Economy() + { + } + private static final Logger logger = Logger.getLogger("Minecraft"); + private static IEssentials ess; + private static final String noCallBeforeLoad = "Essentials API is called before Essentials is loaded."; + public static final MathContext MATH_CONTEXT = MathContext.DECIMAL128; + + /** + * @param aEss the ess to set + */ + public static void setEss(IEssentials aEss) + { + ess = aEss; + } + + private static void createNPCFile(String name) + { + File folder = new File(ess.getDataFolder(), "userdata"); + if (!folder.exists()) + { + folder.mkdirs(); + } + EssentialsConf npcConfig = new EssentialsConf(new File(folder, StringUtil.sanitizeFileName(name) + ".yml")); + npcConfig.load(); + npcConfig.setProperty("npc", true); + npcConfig.setProperty("money", ess.getSettings().getStartingBalance()); + npcConfig.forceSave(); + } + + private static void deleteNPC(String name) + { + File folder = new File(ess.getDataFolder(), "userdata"); + if (!folder.exists()) + { + folder.mkdirs(); + } + File config = new File(folder, StringUtil.sanitizeFileName(name) + ".yml"); + EssentialsConf npcConfig = new EssentialsConf(config); + npcConfig.load(); + if (npcConfig.hasProperty("npc") && npcConfig.getBoolean("npc", false)) + { + if (!config.delete()) + { + logger.log(Level.WARNING, _("deleteFileError", config)); + } + ess.getUserMap().removeUser(name); + } + } + + private static User getUserByName(String name) + { + if (ess == null) + { + throw new RuntimeException(noCallBeforeLoad); + } + return ess.getUser(name); + } + + /** + * Returns the balance of a user + * + * @param name Name of the user + * @return balance + * @throws UserDoesNotExistException + */ + @Deprecated + public static double getMoney(String name) throws net.ess3.api.UserDoesNotExistException + { + return getMoneyExact(name).doubleValue(); + } + + public static BigDecimal getMoneyExact(String name) throws net.ess3.api.UserDoesNotExistException + { + User user = getUserByName(name); + if (user == null) + { + throw new net.ess3.api.UserDoesNotExistException(name); + } + return user.getMoney(); + } + + /** + * Sets the balance of a 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 NoLoanPermittedException If the user is not allowed to have a negative balance + */ + @Deprecated + public static void setMoney(String name, double balance) throws net.ess3.api.UserDoesNotExistException, net.ess3.api.NoLoanPermittedException + { + try + { + setMoney(name, BigDecimal.valueOf(balance)); + } + catch (ArithmeticException e) + { + logger.log(Level.WARNING, "Failed to set balance of " + name + " to " + balance + ": " + e.getMessage(), e); + } + } + + public static void setMoney(String name, BigDecimal balance) throws net.ess3.api.UserDoesNotExistException, net.ess3.api.NoLoanPermittedException + { + User user = getUserByName(name); + if (user == null) + { + throw new net.ess3.api.UserDoesNotExistException(name); + } + if (balance.compareTo(ess.getSettings().getMinMoney()) < 0) + { + throw new net.ess3.api.NoLoanPermittedException(); + } + if (balance.signum() < 0 && !user.isAuthorized("essentials.eco.loan")) + { + throw new net.ess3.api.NoLoanPermittedException(); + } + user.setMoney(balance); + } + + /** + * Adds money to the balance of a 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 + */ + @Deprecated + public static void add(String name, double amount) throws net.ess3.api.UserDoesNotExistException, net.ess3.api.NoLoanPermittedException + { + try + { + add(name, BigDecimal.valueOf(amount)); + } + catch (ArithmeticException e) + { + logger.log(Level.WARNING, "Failed to add " + amount + " to balance of " + name + ": " + e.getMessage(), e); + } + } + + public static void add(String name, BigDecimal amount) throws net.ess3.api.UserDoesNotExistException, net.ess3.api.NoLoanPermittedException, ArithmeticException + { + BigDecimal result = getMoneyExact(name).add(amount, MATH_CONTEXT); + setMoney(name, result); + } + + /** + * Substracts money from the balance of a 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 + */ + @Deprecated + public static void subtract(String name, double amount) throws net.ess3.api.UserDoesNotExistException, net.ess3.api.NoLoanPermittedException + { + try + { + substract(name, BigDecimal.valueOf(amount)); + } + catch (ArithmeticException e) + { + logger.log(Level.WARNING, "Failed to substract " + amount + " of balance of " + name + ": " + e.getMessage(), e); + } + } + + public static void substract(String name, BigDecimal amount) throws net.ess3.api.UserDoesNotExistException, net.ess3.api.NoLoanPermittedException, ArithmeticException + { + BigDecimal result = getMoneyExact(name).subtract(amount, MATH_CONTEXT); + setMoney(name, result); + } + + /** + * Divides the balance of a user by a value + * + * @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 + */ + @Deprecated + public static void divide(String name, double amount) throws net.ess3.api.UserDoesNotExistException, net.ess3.api.NoLoanPermittedException + { + try + { + divide(name, BigDecimal.valueOf(amount)); + } + catch (ArithmeticException e) + { + logger.log(Level.WARNING, "Failed to divide balance of " + name + " by " + amount + ": " + e.getMessage(), e); + } + } + + public static void divide(String name, BigDecimal amount) throws net.ess3.api.UserDoesNotExistException, net.ess3.api.NoLoanPermittedException, ArithmeticException + { + BigDecimal result = getMoneyExact(name).divide(amount, MATH_CONTEXT); + setMoney(name, result); + } + + /** + * Multiplies the balance of a user by a value + * + * @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 + */ + @Deprecated + public static void multiply(String name, double amount) throws net.ess3.api.UserDoesNotExistException, net.ess3.api.NoLoanPermittedException + { + try + { + multiply(name, BigDecimal.valueOf(amount)); + } + catch (ArithmeticException e) + { + logger.log(Level.WARNING, "Failed to multiply balance of " + name + " by " + amount + ": " + e.getMessage(), e); + } + } + public static void multiply(String name, BigDecimal amount) throws net.ess3.api.UserDoesNotExistException, net.ess3.api.NoLoanPermittedException, ArithmeticException + { + BigDecimal result = getMoneyExact(name).multiply(amount, MATH_CONTEXT); + setMoney(name, result); + } + + /** + * Resets the balance of a user to the starting balance + * + * @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 + */ + public static void resetBalance(String name) throws net.ess3.api.UserDoesNotExistException, net.ess3.api.NoLoanPermittedException + { + if (ess == null) + { + throw new RuntimeException(noCallBeforeLoad); + } + setMoney(name, ess.getSettings().getStartingBalance()); + } + + /** + * @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 + */ + @Deprecated + public static boolean hasEnough(String name, double amount) throws net.ess3.api.UserDoesNotExistException + { + try + { + return hasEnough(name, BigDecimal.valueOf(amount)); + } + catch (ArithmeticException e) + { + logger.log(Level.WARNING, "Failed to compare balance of " + name + " with " + amount + ": " + e.getMessage(), e); + return false; + } + } + + public static boolean hasEnough(String name, BigDecimal amount) throws net.ess3.api.UserDoesNotExistException, ArithmeticException + { + return amount.compareTo(getMoneyExact(name)) <= 0; + } + + /** + * @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 + */ + @Deprecated + public static boolean hasMore(String name, double amount) throws net.ess3.api.UserDoesNotExistException + { + try + { + return hasMore(name, BigDecimal.valueOf(amount)); + } + catch (ArithmeticException e) + { + logger.log(Level.WARNING, "Failed to compare balance of " + name + " with " + amount + ": " + e.getMessage(), e); + return false; + } + } + + public static boolean hasMore(String name, BigDecimal amount) throws net.ess3.api.UserDoesNotExistException, ArithmeticException + { + return amount.compareTo(getMoneyExact(name)) < 0; + } + + /** + * @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 + */ + @Deprecated + public static boolean hasLess(String name, double amount) throws net.ess3.api.UserDoesNotExistException + { + try + { + return hasLess(name, BigDecimal.valueOf(amount)); + } + catch (ArithmeticException e) + { + logger.log(Level.WARNING, "Failed to compare balance of " + name + " with " + amount + ": " + e.getMessage(), e); + return false; + } + } + + public static boolean hasLess(String name, BigDecimal amount) throws net.ess3.api.UserDoesNotExistException, ArithmeticException + { + return amount.compareTo(getMoneyExact(name)) > 0; + } + + /** + * Test if the user has a negative balance + * + * @param name Name of the user + * @return true, if the user has a negative balance + * @throws UserDoesNotExistException If a user by that name does not exists + */ + public static boolean isNegative(String name) throws net.ess3.api.UserDoesNotExistException + { + return getMoneyExact(name).signum() < 0; + } + + /** + * Formats the amount of money like all other Essentials functions. Example: $100000 or $12345.67 + * + * @param amount The amount of money + * @return Formatted money + */ + @Deprecated + public static String format(double amount) + { + try + { + return format(BigDecimal.valueOf(amount)); + } + catch (NumberFormatException e) + { + logger.log(Level.WARNING, "Failed to display " + amount + ": " + e.getMessage(), e); + return "NaN"; + } + } + + public static String format(BigDecimal amount) + { + if (ess == null) + { + throw new RuntimeException(noCallBeforeLoad); + } + return NumberUtil.displayCurrency(amount, ess); + } + + /** + * Test if a player exists to avoid the UserDoesNotExistException + * + * @param name Name of the user + * @return true, if the user exists + */ + public static boolean playerExists(String name) + { + return getUserByName(name) != null; + } + + /** + * Test if a player is a npc + * + * @param name Name of the player + * @return true, if it's a npc + * @throws UserDoesNotExistException + */ + public static boolean isNPC(String name) throws net.ess3.api.UserDoesNotExistException + { + User user = getUserByName(name); + if (user == null) + { + throw new net.ess3.api.UserDoesNotExistException(name); + } + return user.isNPC(); + } + + /** + * Creates dummy files for a npc, if there is no player yet with that name. + * + * @param name Name of the player + * @return true, if a new npc was created + */ + public static boolean createNPC(String name) + { + User user = getUserByName(name); + if (user == null) + { + createNPCFile(name); + return true; + } + return false; + } + + /** + * Deletes a user, if it is marked as npc. + * + * @param name Name of the player + * @throws UserDoesNotExistException + */ + public static void removeNPC(String name) throws net.ess3.api.UserDoesNotExistException + { + User user = getUserByName(name); + if (user == null) + { + throw new net.ess3.api.UserDoesNotExistException(name); + } + deleteNPC(name); + } } + diff --git a/Essentials/src/com/earth2me/essentials/api/II18n.java b/Essentials/src/com/earth2me/essentials/api/II18n.java index 2c0df4f64..6845ba8d1 100644 --- a/Essentials/src/com/earth2me/essentials/api/II18n.java +++ b/Essentials/src/com/earth2me/essentials/api/II18n.java @@ -1,7 +1,13 @@ package com.earth2me.essentials.api; +import java.util.Locale; -public interface II18n extends net.ess3.api.II18n -{ +public interface II18n +{ + /** + * Gets the current locale setting + * @return the current locale, if not set it will return the default locale + */ + Locale getCurrentLocale(); } diff --git a/Essentials/src/com/earth2me/essentials/api/IItemDb.java b/Essentials/src/com/earth2me/essentials/api/IItemDb.java index 24cd9df19..678b5c7b0 100644 --- a/Essentials/src/com/earth2me/essentials/api/IItemDb.java +++ b/Essentials/src/com/earth2me/essentials/api/IItemDb.java @@ -1,8 +1,12 @@ package com.earth2me.essentials.api; +import org.bukkit.inventory.ItemStack; -public interface IItemDb extends net.ess3.api.IItemDb + +public interface IItemDb { + ItemStack get(final String name, final int quantity) throws Exception; + ItemStack get(final String name) throws Exception; } diff --git a/Essentials/src/com/earth2me/essentials/api/IJails.java b/Essentials/src/com/earth2me/essentials/api/IJails.java index c12a427da..ea45ea73a 100644 --- a/Essentials/src/com/earth2me/essentials/api/IJails.java +++ b/Essentials/src/com/earth2me/essentials/api/IJails.java @@ -1,7 +1,53 @@ package com.earth2me.essentials.api; +import java.util.Collection; +import net.ess3.api.IUser; +import org.bukkit.Location; -public interface IJails extends net.ess3.api.IJails + +public interface IJails extends IReload { + /** + * Gets the location of the jail with the given name + * @param jailName The name of the jail + * @return the location of the jail + * @throws Exception if the jail does not exist + */ + Location getJail(String jailName) throws Exception; + + /** + * Gets a list of jails by names + * @return a list of jails, if there are none the list will be empty + * @throws Exception + */ + Collection<String> getList() throws Exception; + + /** + * Gets the number of jails + * @return the size of the list of jails + */ + int getCount(); + + /** + * Remove the jail with the given name + * @param jail the jail to remove + * @throws Exception if the jail does not exist + */ + void removeJail(String jail) throws Exception; + + /** + * Attempts to send the given user to the given jail + * @param user the user to send to jail + * @param jail the jail to send the user to + * @throws Exception if the user is offline or jail does not exist + */ + void sendToJail(IUser user, String jail) throws Exception; + /** + * Set a new jail with the given name and location + * @param jailName the name of the jail being set + * @param loc the location of the jail being set + * @throws Exception + */ + void setJail(String jailName, Location loc) throws Exception; } diff --git a/Essentials/src/com/earth2me/essentials/api/IReload.java b/Essentials/src/com/earth2me/essentials/api/IReload.java index 7a598ce4d..75403b55c 100644 --- a/Essentials/src/com/earth2me/essentials/api/IReload.java +++ b/Essentials/src/com/earth2me/essentials/api/IReload.java @@ -1,7 +1,7 @@ package com.earth2me.essentials.api; -public interface IReload extends net.ess3.api.IReload +public interface IReload { - + void onReload(); } diff --git a/Essentials/src/com/earth2me/essentials/api/ITeleport.java b/Essentials/src/com/earth2me/essentials/api/ITeleport.java index 9475f83b3..798ecfdfb 100644 --- a/Essentials/src/com/earth2me/essentials/api/ITeleport.java +++ b/Essentials/src/com/earth2me/essentials/api/ITeleport.java @@ -1,7 +1,130 @@ package com.earth2me.essentials.api; +import com.earth2me.essentials.Trade; +import net.ess3.api.IUser; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerTeleportEvent; -public interface ITeleport extends net.ess3.api.ITeleport + +public interface ITeleport { + /** + * Used to skip teleportPlayer delay when teleporting someone to a location or player. + * + * @param loc - Where should the player end up + * @param cooldown - If cooldown should be enforced + * @param cause - The reported teleportPlayer cause + * @throws Exception + */ + void now(Location loc, boolean cooldown, PlayerTeleportEvent.TeleportCause cause) throws Exception; + + /** + * Used to skip teleportPlayer delay when teleporting someone to a location or player. + * + * @param entity - Where should the player end up + * @param cooldown - If cooldown should be enforced + * @param cause - The reported teleportPlayer cause + * @throws Exception + */ + void now(Player entity, boolean cooldown, PlayerTeleportEvent.TeleportCause cause) throws Exception; + + @Deprecated + void teleport(Location loc, Trade chargeFor) throws Exception; + + /** + * Teleport a player to a specific location + * + * @param loc - Where should the player end up + * @param chargeFor - What the user will be charged if teleportPlayer is successful + * @param cause - The reported teleportPlayer cause + * @throws Exception + */ + void teleport(Location loc, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception; + + /** + * Teleport a player to a specific player + * + * @param entity - Where should the player end up + * @param chargeFor - What the user will be charged if teleportPlayer is successful + * @param cause - The reported teleportPlayer cause + * @throws Exception + */ + void teleport(Player entity, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception; + + /** + * Teleport a player to a specific location + * + * @param otherUser - Which user will be teleported + * @param loc - Where should the player end up + * @param chargeFor - What the user will be charged if teleportPlayer is successful + * @param cause - The reported teleportPlayer cause + * @throws Exception + */ + void teleportPlayer(IUser otherUser, Location loc, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception; + + /** + * Teleport a player to a specific player + * + * @param otherUser - Which user will be teleported + * @param entity - Where should the player end up + * @param chargeFor - What the user will be charged if teleportPlayer is successful + * @param cause - The reported teleportPlayer cause + * @throws Exception + */ + void teleportPlayer(IUser otherUser, Player entity, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception; + + /** + * Teleport wrapper used to handle teleporting players to them, like /tphere + * + * @param otherUser - Which user will be teleported + * @param chargeFor - What the user will be charged if teleportPlayer is successful + * @param cause - The reported teleportPlayer cause + * @throws Exception + */ + public void teleportToMe(IUser otherUser, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception; + + /** + * Teleport wrapper used to handle tp fallback on /jail and /home + * + * @param chargeFor - What the user will be charged if teleportPlayer is successful + * @param cause - The reported teleportPlayer cause + * @throws Exception + */ + public void respawn(final Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception; + + /** + * Teleport wrapper used to handle /warp teleports + * + * @param otherUser - Which user will be teleported + * @param warp - The name of the warp the user will be teleported too. + * @param chargeFor - What the user will be charged if teleportPlayer is successful + * @param cause - The reported teleportPlayer cause + * @throws Exception + */ + public void warp(IUser otherUser, String warp, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception; + + /** + * Teleport wrapper used to handle /back teleports + * + * @param chargeFor - What the user will be charged if teleportPlayer is successful + * @throws Exception + */ + public void back(Trade chargeFor) throws Exception; + + /** + * Teleport wrapper used to handle throwing user home after a jail sentence + * + * @throws Exception + */ + public void back() throws Exception; + /** + * Teleport wrapper used to handle /home teleports + * + * @param loc - Location where player will be teleported too + * @param chargeFor - What the user will be charged if teleportPlayer is successful + * @throws Exception + */ + public void home(Location loc, Trade chargeFor) throws Exception; } diff --git a/Essentials/src/com/earth2me/essentials/api/IWarps.java b/Essentials/src/com/earth2me/essentials/api/IWarps.java index ee60cc3ca..705822d8e 100644 --- a/Essentials/src/com/earth2me/essentials/api/IWarps.java +++ b/Essentials/src/com/earth2me/essentials/api/IWarps.java @@ -1,8 +1,68 @@ package com.earth2me.essentials.api; +import com.earth2me.essentials.IConf; +import com.earth2me.essentials.commands.WarpNotFoundException; +import java.io.File; +import java.util.Collection; +import org.bukkit.Location; -public interface IWarps extends net.ess3.api.IWarps +public interface IWarps extends IConf { + /** + * Get a warp by name + * + * @param warp - Warp name + * @return - Location the warp is set to + * @throws WarpNotFoundException When the warp is not found + * @throws InvalidWorldException When the world the warp is in is not found + */ + Location getWarp(String warp) throws WarpNotFoundException, net.ess3.api.InvalidWorldException; + /** + * Gets a list of warps + * + * @return - A {@link Collection} of warps + */ + Collection<String> getList(); + + /** + * Gets the number of warps + * + * @return the size of the list of warps + */ + int getCount(); + + /** + * Delete a warp from the warp DB + * + * @param name - Name of warp + * @throws Exception + */ + void removeWarp(String name) throws Exception; + + /** + * Set a warp + * + * @param name - Name of warp + * @param loc - Location of warp + * @throws Exception + */ + void setWarp(String name, Location loc) throws Exception; + + /** + * Check to see if the file is empty + * + * @return + */ + boolean isEmpty(); + + /** + * Get a warp file note: this is not yet implemented, as 3.x uses different storage methods + * + * @param name - name of file + * @return - an instance of the file + * @throws InvalidNameException - When the file is not found + */ + File getWarpFile(String name) throws net.ess3.api.InvalidNameException; } diff --git a/Essentials/src/net/ess3/api/Economy.java b/Essentials/src/net/ess3/api/Economy.java index 73fe51e62..283ef3722 100644 --- a/Essentials/src/net/ess3/api/Economy.java +++ b/Essentials/src/net/ess3/api/Economy.java @@ -1,441 +1,7 @@ package net.ess3.api; -import com.earth2me.essentials.EssentialsConf; -import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.User; -import com.earth2me.essentials.utils.StringUtil; -import com.earth2me.essentials.utils.NumberUtil; -import java.io.File; -import java.math.BigDecimal; -import java.math.MathContext; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Instead of using this api directly, we recommend to use the register plugin: http://bit.ly/RegisterMethod - */ -public class Economy +public class Economy extends com.earth2me.essentials.api.Economy { - public Economy() - { - } - private static final Logger logger = Logger.getLogger("Minecraft"); - private static IEssentials ess; - private static final String noCallBeforeLoad = "Essentials API is called before Essentials is loaded."; - public static final MathContext MATH_CONTEXT = MathContext.DECIMAL128; - - /** - * @param aEss the ess to set - */ - public static void setEss(IEssentials aEss) - { - ess = aEss; - } - - private static void createNPCFile(String name) - { - File folder = new File(ess.getDataFolder(), "userdata"); - if (!folder.exists()) - { - folder.mkdirs(); - } - EssentialsConf npcConfig = new EssentialsConf(new File(folder, StringUtil.sanitizeFileName(name) + ".yml")); - npcConfig.load(); - npcConfig.setProperty("npc", true); - npcConfig.setProperty("money", ess.getSettings().getStartingBalance()); - npcConfig.forceSave(); - } - - private static void deleteNPC(String name) - { - File folder = new File(ess.getDataFolder(), "userdata"); - if (!folder.exists()) - { - folder.mkdirs(); - } - File config = new File(folder, StringUtil.sanitizeFileName(name) + ".yml"); - EssentialsConf npcConfig = new EssentialsConf(config); - npcConfig.load(); - if (npcConfig.hasProperty("npc") && npcConfig.getBoolean("npc", false)) - { - if (!config.delete()) - { - logger.log(Level.WARNING, _("deleteFileError", config)); - } - ess.getUserMap().removeUser(name); - } - } - - private static User getUserByName(String name) - { - if (ess == null) - { - throw new RuntimeException(noCallBeforeLoad); - } - return ess.getUser(name); - } - - /** - * Returns the balance of a user - * - * @param name Name of the user - * @return balance - * @throws UserDoesNotExistException - */ - @Deprecated - public static double getMoney(String name) throws UserDoesNotExistException - { - return getMoneyExact(name).doubleValue(); - } - - public static BigDecimal getMoneyExact(String name) throws UserDoesNotExistException - { - User user = getUserByName(name); - if (user == null) - { - throw new UserDoesNotExistException(name); - } - return user.getMoney(); - } - - /** - * Sets the balance of a 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 NoLoanPermittedException If the user is not allowed to have a negative balance - */ - @Deprecated - public static void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException - { - try - { - setMoney(name, BigDecimal.valueOf(balance)); - } - catch (ArithmeticException e) - { - logger.log(Level.WARNING, "Failed to set balance of " + name + " to " + balance + ": " + e.getMessage(), e); - } - } - - public static void setMoney(String name, BigDecimal balance) throws UserDoesNotExistException, NoLoanPermittedException - { - User user = getUserByName(name); - if (user == null) - { - throw new UserDoesNotExistException(name); - } - if (balance.compareTo(ess.getSettings().getMinMoney()) < 0) - { - throw new NoLoanPermittedException(); - } - if (balance.signum() < 0 && !user.isAuthorized("essentials.eco.loan")) - { - throw new NoLoanPermittedException(); - } - user.setMoney(balance); - } - - /** - * Adds money to the balance of a 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 - */ - @Deprecated - public static void add(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException - { - try - { - add(name, BigDecimal.valueOf(amount)); - } - catch (ArithmeticException e) - { - logger.log(Level.WARNING, "Failed to add " + amount + " to balance of " + name + ": " + e.getMessage(), e); - } - } - - public static void add(String name, BigDecimal amount) throws UserDoesNotExistException, NoLoanPermittedException, ArithmeticException - { - BigDecimal result = getMoneyExact(name).add(amount, MATH_CONTEXT); - setMoney(name, result); - } - - /** - * Substracts money from the balance of a 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 - */ - @Deprecated - public static void subtract(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException - { - try - { - substract(name, BigDecimal.valueOf(amount)); - } - catch (ArithmeticException e) - { - logger.log(Level.WARNING, "Failed to substract " + amount + " of balance of " + name + ": " + e.getMessage(), e); - } - } - - public static void substract(String name, BigDecimal amount) throws UserDoesNotExistException, NoLoanPermittedException, ArithmeticException - { - BigDecimal result = getMoneyExact(name).subtract(amount, MATH_CONTEXT); - setMoney(name, result); - } - - /** - * Divides the balance of a user by a value - * - * @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 - */ - @Deprecated - public static void divide(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException - { - try - { - divide(name, BigDecimal.valueOf(amount)); - } - catch (ArithmeticException e) - { - logger.log(Level.WARNING, "Failed to divide balance of " + name + " by " + amount + ": " + e.getMessage(), e); - } - } - - public static void divide(String name, BigDecimal amount) throws UserDoesNotExistException, NoLoanPermittedException, ArithmeticException - { - BigDecimal result = getMoneyExact(name).divide(amount, MATH_CONTEXT); - setMoney(name, result); - } - - /** - * Multiplies the balance of a user by a value - * - * @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 - */ - @Deprecated - public static void multiply(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException - { - try - { - multiply(name, BigDecimal.valueOf(amount)); - } - catch (ArithmeticException e) - { - logger.log(Level.WARNING, "Failed to multiply balance of " + name + " by " + amount + ": " + e.getMessage(), e); - } - } - - public static void multiply(String name, BigDecimal amount) throws UserDoesNotExistException, NoLoanPermittedException, ArithmeticException - { - BigDecimal result = getMoneyExact(name).multiply(amount, MATH_CONTEXT); - setMoney(name, result); - } - - /** - * Resets the balance of a user to the starting balance - * - * @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 - */ - public static void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException - { - if (ess == null) - { - throw new RuntimeException(noCallBeforeLoad); - } - setMoney(name, ess.getSettings().getStartingBalance()); - } - - /** - * @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 - */ - @Deprecated - public static boolean hasEnough(String name, double amount) throws UserDoesNotExistException - { - try - { - return hasEnough(name, BigDecimal.valueOf(amount)); - } - catch (ArithmeticException e) - { - logger.log(Level.WARNING, "Failed to compare balance of " + name + " with " + amount + ": " + e.getMessage(), e); - return false; - } - } - - public static boolean hasEnough(String name, BigDecimal amount) throws UserDoesNotExistException, ArithmeticException - { - return amount.compareTo(getMoneyExact(name)) <= 0; - } - - /** - * @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 - */ - @Deprecated - public static boolean hasMore(String name, double amount) throws UserDoesNotExistException - { - try - { - return hasMore(name, BigDecimal.valueOf(amount)); - } - catch (ArithmeticException e) - { - logger.log(Level.WARNING, "Failed to compare balance of " + name + " with " + amount + ": " + e.getMessage(), e); - return false; - } - } - - public static boolean hasMore(String name, BigDecimal amount) throws UserDoesNotExistException, ArithmeticException - { - return amount.compareTo(getMoneyExact(name)) < 0; - } - - /** - * @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 - */ - @Deprecated - public static boolean hasLess(String name, double amount) throws UserDoesNotExistException - { - try - { - return hasLess(name, BigDecimal.valueOf(amount)); - } - catch (ArithmeticException e) - { - logger.log(Level.WARNING, "Failed to compare balance of " + name + " with " + amount + ": " + e.getMessage(), e); - return false; - } - } - - public static boolean hasLess(String name, BigDecimal amount) throws UserDoesNotExistException, ArithmeticException - { - return amount.compareTo(getMoneyExact(name)) > 0; - } - - /** - * Test if the user has a negative balance - * - * @param name Name of the user - * @return true, if the user has a negative balance - * @throws UserDoesNotExistException If a user by that name does not exists - */ - public static boolean isNegative(String name) throws UserDoesNotExistException - { - return getMoneyExact(name).signum() < 0; - } - - /** - * Formats the amount of money like all other Essentials functions. Example: $100000 or $12345.67 - * - * @param amount The amount of money - * @return Formatted money - */ - @Deprecated - public static String format(double amount) - { - try - { - return format(BigDecimal.valueOf(amount)); - } - catch (NumberFormatException e) - { - logger.log(Level.WARNING, "Failed to display " + amount + ": " + e.getMessage(), e); - return "NaN"; - } - } - - public static String format(BigDecimal amount) - { - if (ess == null) - { - throw new RuntimeException(noCallBeforeLoad); - } - return NumberUtil.displayCurrency(amount, ess); - } - - /** - * Test if a player exists to avoid the UserDoesNotExistException - * - * @param name Name of the user - * @return true, if the user exists - */ - public static boolean playerExists(String name) - { - return getUserByName(name) != null; - } - - /** - * Test if a player is a npc - * - * @param name Name of the player - * @return true, if it's a npc - * @throws UserDoesNotExistException - */ - public static boolean isNPC(String name) throws UserDoesNotExistException - { - User user = getUserByName(name); - if (user == null) - { - throw new UserDoesNotExistException(name); - } - return user.isNPC(); - } - - /** - * Creates dummy files for a npc, if there is no player yet with that name. - * - * @param name Name of the player - * @return true, if a new npc was created - */ - public static boolean createNPC(String name) - { - User user = getUserByName(name); - if (user == null) - { - createNPCFile(name); - return true; - } - return false; - } - - /** - * Deletes a user, if it is marked as npc. - * - * @param name Name of the player - * @throws UserDoesNotExistException - */ - public static void removeNPC(String name) throws UserDoesNotExistException - { - User user = getUserByName(name); - if (user == null) - { - throw new UserDoesNotExistException(name); - } - deleteNPC(name); - } + } diff --git a/Essentials/src/net/ess3/api/IEssentials.java b/Essentials/src/net/ess3/api/IEssentials.java index 7a896de7e..be5671176 100644 --- a/Essentials/src/net/ess3/api/IEssentials.java +++ b/Essentials/src/net/ess3/api/IEssentials.java @@ -1,91 +1,6 @@ package net.ess3.api; -import com.earth2me.essentials.AlternativeCommandsHandler; -import com.earth2me.essentials.Backup; -import com.earth2me.essentials.EssentialsTimer; -import com.earth2me.essentials.I18n; -import com.earth2me.essentials.IConf; -import com.earth2me.essentials.IEssentialsModule; -import com.earth2me.essentials.ItemDb; -import com.earth2me.essentials.TNTExplodeListener; -import com.earth2me.essentials.User; -import com.earth2me.essentials.UserMap; -import com.earth2me.essentials.Worth; -import com.earth2me.essentials.metrics.Metrics; -import com.earth2me.essentials.perm.PermissionsHandler; -import com.earth2me.essentials.register.payment.Methods; -import java.util.List; -import org.bukkit.World; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.plugin.Plugin; -import org.bukkit.scheduler.BukkitScheduler; -import org.bukkit.scheduler.BukkitTask; - - -public interface IEssentials extends Plugin +public interface IEssentials extends com.earth2me.essentials.IEssentials { - void addReloadListener(IConf listener); - - void reload(); - - boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix, IEssentialsModule module); - - User getUser(Object base); - - I18n getI18n(); - - User getOfflineUser(String name); - - World getWorld(String name); - - int broadcastMessage(String message); - - int broadcastMessage(IUser sender, String message); - - int broadcastMessage(String permission, String message); - - ISettings getSettings(); - - BukkitScheduler getScheduler(); - - IJails getJails(); - - IWarps getWarps(); - - Worth getWorth(); - - Backup getBackup(); - - Methods getPaymentMethod(); - - BukkitTask runTaskAsynchronously(Runnable run); - - BukkitTask runTaskLaterAsynchronously(Runnable run, long delay); - - int scheduleSyncDelayedTask(Runnable run); - - int scheduleSyncDelayedTask(Runnable run, long delay); - - int scheduleSyncRepeatingTask(final Runnable run, long delay, long period); - - TNTExplodeListener getTNTListener(); - - PermissionsHandler getPermissionsHandler(); - - AlternativeCommandsHandler getAlternativeCommandsHandler(); - - void showError(final CommandSender sender, final Throwable exception, final String commandLabel); - - ItemDb getItemDb(); - - UserMap getUserMap(); - - Metrics getMetrics(); - - void setMetrics(Metrics metrics); - - EssentialsTimer getTimer(); - - List<String> getVanishedPlayers(); + } diff --git a/Essentials/src/net/ess3/api/II18n.java b/Essentials/src/net/ess3/api/II18n.java index 9cefb32ee..5bbe0e702 100644 --- a/Essentials/src/net/ess3/api/II18n.java +++ b/Essentials/src/net/ess3/api/II18n.java @@ -1,13 +1,7 @@ package net.ess3.api; -import java.util.Locale; - -public interface II18n +public interface II18n extends com.earth2me.essentials.api.II18n { - /** - * Gets the current locale setting - * @return the current locale, if not set it will return the default locale - */ - Locale getCurrentLocale(); + } diff --git a/Essentials/src/net/ess3/api/IItemDb.java b/Essentials/src/net/ess3/api/IItemDb.java index 70ddf0771..eb9afb3c5 100644 --- a/Essentials/src/net/ess3/api/IItemDb.java +++ b/Essentials/src/net/ess3/api/IItemDb.java @@ -1,11 +1,7 @@ package net.ess3.api; -import org.bukkit.inventory.ItemStack; - -public interface IItemDb +public interface IItemDb extends com.earth2me.essentials.api.IItemDb { - ItemStack get(final String name, final int quantity) throws Exception; - ItemStack get(final String name) throws Exception; } diff --git a/Essentials/src/net/ess3/api/IJails.java b/Essentials/src/net/ess3/api/IJails.java index 8a11cdcf7..d36e4f76b 100644 --- a/Essentials/src/net/ess3/api/IJails.java +++ b/Essentials/src/net/ess3/api/IJails.java @@ -1,52 +1,7 @@ package net.ess3.api; -import java.util.Collection; -import org.bukkit.Location; - -public interface IJails extends IReload +public interface IJails extends com.earth2me.essentials.api.IJails { - /** - * Gets the location of the jail with the given name - * @param jailName The name of the jail - * @return the location of the jail - * @throws Exception if the jail does not exist - */ - Location getJail(String jailName) throws Exception; - - /** - * Gets a list of jails by names - * @return a list of jails, if there are none the list will be empty - * @throws Exception - */ - Collection<String> getList() throws Exception; - - /** - * Gets the number of jails - * @return the size of the list of jails - */ - int getCount(); - - /** - * Remove the jail with the given name - * @param jail the jail to remove - * @throws Exception if the jail does not exist - */ - void removeJail(String jail) throws Exception; - - /** - * Attempts to send the given user to the given jail - * @param user the user to send to jail - * @param jail the jail to send the user to - * @throws Exception if the user is offline or jail does not exist - */ - void sendToJail(net.ess3.api.IUser user, String jail) throws Exception; - /** - * Set a new jail with the given name and location - * @param jailName the name of the jail being set - * @param loc the location of the jail being set - * @throws Exception - */ - void setJail(String jailName, Location loc) throws Exception; } diff --git a/Essentials/src/net/ess3/api/IReload.java b/Essentials/src/net/ess3/api/IReload.java index 964d88841..b706342e2 100644 --- a/Essentials/src/net/ess3/api/IReload.java +++ b/Essentials/src/net/ess3/api/IReload.java @@ -1,7 +1,7 @@ package net.ess3.api; -public interface IReload +public interface IReload extends com.earth2me.essentials.api.IReload { - void onReload(); + } diff --git a/Essentials/src/net/ess3/api/ISettings.java b/Essentials/src/net/ess3/api/ISettings.java index d7ac3b570..256cf1635 100644 --- a/Essentials/src/net/ess3/api/ISettings.java +++ b/Essentials/src/net/ess3/api/ISettings.java @@ -1,201 +1,7 @@ package net.ess3.api; -import com.earth2me.essentials.IConf; -import com.earth2me.essentials.User; -import com.earth2me.essentials.commands.IEssentialsCommand; -import com.earth2me.essentials.signs.EssentialsSign; -import com.earth2me.essentials.textreader.IText; -import java.math.BigDecimal; -import java.text.MessageFormat; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.bukkit.ChatColor; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.event.EventPriority; - -public interface ISettings extends IConf +public interface ISettings extends com.earth2me.essentials.ISettings { - boolean areSignsDisabled(); - - IText getAnnounceNewPlayerFormat(); - - boolean getAnnounceNewPlayers(); - - String getNewPlayerKit(); - - String getBackupCommand(); - - long getBackupInterval(); - - String getChatFormat(String group); - - int getChatRadius(); - - BigDecimal getCommandCost(IEssentialsCommand cmd); - - BigDecimal getCommandCost(String label); - - String getCurrencySymbol(); - - int getOversizedStackSize(); - - int getDefaultStackSize(); - - double getHealCooldown(); - - Set<String> getSocialSpyCommands(); - - Map<String, Object> getKit(String name); - - ConfigurationSection getKits(); - - String getLocale(); - - String getNewbieSpawn(); - - String getNicknamePrefix(); - - ChatColor getOperatorColor() throws Exception; - - boolean getPerWarpPermission(); - - boolean getProtectBoolean(final String configName, boolean def); - - int getProtectCreeperMaxHeight(); - - List<Integer> getProtectList(final String configName); - - boolean getProtectPreventSpawn(final String creatureName); - - String getProtectString(final String configName); - - boolean getRespawnAtHome(); - - Set getMultipleHomes(); - - int getHomeLimit(String set); - - int getHomeLimit(User user); - - int getSpawnMobLimit(); - - BigDecimal getStartingBalance(); - - double getTeleportCooldown(); - - double getTeleportDelay(); - - boolean hidePermissionlessHelp(); - - boolean isCommandDisabled(final IEssentialsCommand cmd); - - boolean isCommandDisabled(String label); - - boolean isCommandOverridden(String name); - - boolean isDebug(); - - boolean isEcoDisabled(); - - boolean isTradeInStacks(int id); - - List<Integer> itemSpawnBlacklist(); - - List<EssentialsSign> enabledSigns(); - - boolean permissionBasedItemSpawn(); - - boolean showNonEssCommandsInHelp(); - - boolean warnOnBuildDisallow(); - - boolean warnOnSmite(); - - BigDecimal getMaxMoney(); - - BigDecimal getMinMoney(); - - boolean isEcoLogEnabled(); - - boolean isEcoLogUpdateEnabled(); - - boolean removeGodOnDisconnect(); - - boolean changeDisplayName(); - - boolean changePlayerListName(); - - boolean isPlayerCommand(String string); - - boolean useBukkitPermissions(); - - boolean addPrefixSuffix(); - - boolean disablePrefix(); - - boolean disableSuffix(); - - long getAutoAfk(); - - long getAutoAfkKick(); - - boolean getFreezeAfkPlayers(); - - boolean cancelAfkOnMove(); - - boolean cancelAfkOnInteract(); - - boolean areDeathMessagesEnabled(); - - public void setDebug(boolean debug); - - Set<String> getNoGodWorlds(); - - boolean getUpdateBedAtDaytime(); - - boolean allowUnsafeEnchantments(); - - boolean getRepairEnchanted(); - - boolean isWorldTeleportPermissions(); - - boolean isWorldHomePermissions(); - - boolean registerBackInListener(); - - boolean getDisableItemPickupWhileAfk(); - - EventPriority getRespawnPriority(); - - long getTpaAcceptCancellation(); - - boolean isMetricsEnabled(); - - void setMetricsEnabled(boolean metricsEnabled); - - long getTeleportInvulnerability(); - - boolean isTeleportInvulnerability(); - - long getLoginAttackDelay(); - - int getSignUsePerSecond(); - - double getMaxFlySpeed(); - - double getMaxWalkSpeed(); - - public int getMailsPerMinute(); - - public long getEconomyLagWarning(); - - public void setEssentialsChatActive(boolean b); - - long getMaxTempban(); - - public Map<String, Object> getListGroupConfig(); - public int getMaxNickLength(); } diff --git a/Essentials/src/net/ess3/api/ITeleport.java b/Essentials/src/net/ess3/api/ITeleport.java index 75c249ab2..967b38ba3 100644 --- a/Essentials/src/net/ess3/api/ITeleport.java +++ b/Essentials/src/net/ess3/api/ITeleport.java @@ -1,129 +1,7 @@ package net.ess3.api; -import com.earth2me.essentials.Trade; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; +public interface ITeleport extends com.earth2me.essentials.api.ITeleport +{ -public interface ITeleport -{ - /** - * Used to skip teleportPlayer delay when teleporting someone to a location or player. - * - * @param loc - Where should the player end up - * @param cooldown - If cooldown should be enforced - * @param cause - The reported teleportPlayer cause - * @throws Exception - */ - void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception; - - /** - * Used to skip teleportPlayer delay when teleporting someone to a location or player. - * - * @param entity - Where should the player end up - * @param cooldown - If cooldown should be enforced - * @param cause - The reported teleportPlayer cause - * @throws Exception - */ - void now(Player entity, boolean cooldown, TeleportCause cause) throws Exception; - - @Deprecated - void teleport(Location loc, Trade chargeFor) throws Exception; - - /** - * Teleport a player to a specific location - * - * @param loc - Where should the player end up - * @param chargeFor - What the user will be charged if teleportPlayer is successful - * @param cause - The reported teleportPlayer cause - * @throws Exception - */ - void teleport(Location loc, Trade chargeFor, TeleportCause cause) throws Exception; - - /** - * Teleport a player to a specific player - * - * @param entity - Where should the player end up - * @param chargeFor - What the user will be charged if teleportPlayer is successful - * @param cause - The reported teleportPlayer cause - * @throws Exception - */ - void teleport(Player entity, Trade chargeFor, TeleportCause cause) throws Exception; - - /** - * Teleport a player to a specific location - * - * @param otherUser - Which user will be teleported - * @param loc - Where should the player end up - * @param chargeFor - What the user will be charged if teleportPlayer is successful - * @param cause - The reported teleportPlayer cause - * @throws Exception - */ - void teleportPlayer(IUser otherUser, Location loc, Trade chargeFor, TeleportCause cause) throws Exception; - - /** - * Teleport a player to a specific player - * - * @param otherUser - Which user will be teleported - * @param entity - Where should the player end up - * @param chargeFor - What the user will be charged if teleportPlayer is successful - * @param cause - The reported teleportPlayer cause - * @throws Exception - */ - void teleportPlayer(IUser otherUser, Player entity, Trade chargeFor, TeleportCause cause) throws Exception; - - /** - * Teleport wrapper used to handle teleporting players to them, like /tphere - * - * @param otherUser - Which user will be teleported - * @param chargeFor - What the user will be charged if teleportPlayer is successful - * @param cause - The reported teleportPlayer cause - * @throws Exception - */ - public void teleportToMe(IUser otherUser, Trade chargeFor, TeleportCause cause) throws Exception; - - /** - * Teleport wrapper used to handle tp fallback on /jail and /home - * - * @param chargeFor - What the user will be charged if teleportPlayer is successful - * @param cause - The reported teleportPlayer cause - * @throws Exception - */ - public void respawn(final Trade chargeFor, TeleportCause cause) throws Exception; - - /** - * Teleport wrapper used to handle /warp teleports - * - * @param otherUser - Which user will be teleported - * @param warp - The name of the warp the user will be teleported too. - * @param chargeFor - What the user will be charged if teleportPlayer is successful - * @param cause - The reported teleportPlayer cause - * @throws Exception - */ - public void warp(IUser otherUser, String warp, Trade chargeFor, TeleportCause cause) throws Exception; - - /** - * Teleport wrapper used to handle /back teleports - * - * @param chargeFor - What the user will be charged if teleportPlayer is successful - * @throws Exception - */ - public void back(Trade chargeFor) throws Exception; - - /** - * Teleport wrapper used to handle throwing user home after a jail sentence - * - * @throws Exception - */ - public void back() throws Exception; - - /** - * Teleport wrapper used to handle /home teleports - * - * @param loc - Location where player will be teleported too - * @param chargeFor - What the user will be charged if teleportPlayer is successful - * @throws Exception - */ - public void home(Location loc, Trade chargeFor) throws Exception; } diff --git a/Essentials/src/net/ess3/api/IUser.java b/Essentials/src/net/ess3/api/IUser.java index bae00f212..b68c6e5cf 100644 --- a/Essentials/src/net/ess3/api/IUser.java +++ b/Essentials/src/net/ess3/api/IUser.java @@ -1,93 +1,8 @@ package net.ess3.api; -import net.ess3.api.ITeleport; -import com.earth2me.essentials.commands.IEssentialsCommand; -import java.math.BigDecimal; -import java.util.Map; -import java.util.Set; -import org.bukkit.Location; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -public interface IUser +public interface IUser extends com.earth2me.essentials.IUser { - long getLastTeleportTimestamp(); - boolean isAuthorized(String node); - - boolean isAuthorized(IEssentialsCommand cmd); - - boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix); - - void setLastTeleportTimestamp(long time); - - Location getLastLocation(); - - Player getBase(); - - BigDecimal getMoney(); - - void takeMoney(BigDecimal value); - - void giveMoney(BigDecimal value); - - boolean canAfford(BigDecimal value); - - String getGroup(); - - void setLastLocation(); - - Location getHome(String name) throws Exception; - - Location getHome(Location loc) throws Exception; - - /** - * 'Hidden' Represents when a player is hidden from others. This status includes when the player is hidden via other - * supported plugins. Use isVanished() if you want to check if a user is vanished by Essentials. - * - * @return If the user is hidden or not - * @see isVanished - */ - boolean isHidden(); - - void setHidden(boolean vanish); - - /** - * 'Vanished' Represents when a player is hidden from others by Essentials. This status does NOT include when the - * player is hidden via other plugins. Use isHidden() if you want to check if a user is vanished by any supported - * plugin. - * - * @return If the user is vanished or not - * @see isHidden - */ - boolean isVanished(); - - void setVanished(boolean vanish); - - ITeleport getTeleport(); - - void setJail(String jail); - - boolean isIgnoreExempt(); - - boolean isAfk(); - - void setAfk(final boolean set); - - void setLogoutLocation(); - - Location getLogoutLocation(); - - void setConfigProperty(String node, Object object); - - Set<String> getConfigKeys(); - - Map<String, Object> getConfigMap(); - - Map<String, Object> getConfigMap(String node); - - public void sendMessage(String message); - - public String getName(); } diff --git a/Essentials/src/net/ess3/api/IWarps.java b/Essentials/src/net/ess3/api/IWarps.java index 65bcf9437..c71ef7d7f 100644 --- a/Essentials/src/net/ess3/api/IWarps.java +++ b/Essentials/src/net/ess3/api/IWarps.java @@ -1,69 +1,7 @@ package net.ess3.api; -import com.earth2me.essentials.IConf; -import java.io.File; -import java.util.Collection; -import com.earth2me.essentials.commands.WarpNotFoundException; -import org.bukkit.Location; - - -public interface IWarps extends IConf +public interface IWarps extends com.earth2me.essentials.api.IWarps { - /** - * Get a warp by name - * - * @param warp - Warp name - * @return - Location the warp is set to - * @throws WarpNotFoundException When the warp is not found - * @throws InvalidWorldException When the world the warp is in is not found - */ - Location getWarp(String warp) throws WarpNotFoundException, InvalidWorldException; - - /** - * Gets a list of warps - * - * @return - A {@link Collection} of warps - */ - Collection<String> getList(); - - /** - * Gets the number of warps - * - * @return the size of the list of warps - */ - int getCount(); - - /** - * Delete a warp from the warp DB - * - * @param name - Name of warp - * @throws Exception - */ - void removeWarp(String name) throws Exception; - - /** - * Set a warp - * - * @param name - Name of warp - * @param loc - Location of warp - * @throws Exception - */ - void setWarp(String name, Location loc) throws Exception; - - /** - * Check to see if the file is empty - * - * @return - */ - boolean isEmpty(); - /** - * Get a warp file note: this is not yet implemented, as 3.x uses different storage methods - * - * @param name - name of file - * @return - an instance of the file - * @throws InvalidNameException - When the file is not found - */ - File getWarpFile(String name) throws InvalidNameException; } diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsConnect.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsConnect.java index 09f84efe2..2c87ce332 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsConnect.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsConnect.java @@ -51,7 +51,6 @@ public class EssentialsConnect {
protect.getSettingsBoolean().put(protectConfig, ess.getSettings().getProtectBoolean(protectConfig.getConfigName(), protectConfig.getDefaultValueBoolean()));
}
-
}
}
}
|