diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 677caa941..94b737338 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -402,11 +402,9 @@ public class Essentials extends JavaPlugin implements IEssentials public void showError(final CommandSender sender, final Throwable exception, final String commandLabel) { sender.sendMessage(_("errorWithMessage", exception.getMessage())); - final LogRecord logRecord = new LogRecord(Level.WARNING, _("errorCallingCommand", commandLabel)); - logRecord.setThrown(exception); if (getSettings().isDebug()) { - LOGGER.log(logRecord); + LOGGER.log(Level.WARNING, _("errorCallingCommand", commandLabel), exception); } } diff --git a/Essentials/src/com/earth2me/essentials/I18n.java b/Essentials/src/com/earth2me/essentials/I18n.java index 4e2b033e6..33708e5cd 100644 --- a/Essentials/src/com/earth2me/essentials/I18n.java +++ b/Essentials/src/com/earth2me/essentials/I18n.java @@ -1,5 +1,6 @@ package com.earth2me.essentials; +import com.earth2me.essentials.api.II18n; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -12,7 +13,7 @@ import java.util.logging.Level; import java.util.logging.Logger; -public class I18n +public class I18n implements II18n { private static I18n instance; private static final String MESSAGES = "messages"; diff --git a/Essentials/src/com/earth2me/essentials/IConf.java b/Essentials/src/com/earth2me/essentials/IConf.java index a523f8638..580e6232f 100644 --- a/Essentials/src/com/earth2me/essentials/IConf.java +++ b/Essentials/src/com/earth2me/essentials/IConf.java @@ -1,5 +1,9 @@ package com.earth2me.essentials; +/** + * @deprecated New interface will be IReload in api package + */ +@Deprecated public interface IConf { public void reloadConfig(); } diff --git a/Essentials/src/com/earth2me/essentials/IEssentials.java b/Essentials/src/com/earth2me/essentials/IEssentials.java index 9b5c5457b..be09b8e37 100644 --- a/Essentials/src/com/earth2me/essentials/IEssentials.java +++ b/Essentials/src/com/earth2me/essentials/IEssentials.java @@ -8,7 +8,10 @@ import org.bukkit.command.CommandSender; import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitScheduler; - +/** + * @deprecated This will be moved to the api package soon + */ +@Deprecated public interface IEssentials extends Plugin { void addReloadListener(IConf listener); diff --git a/Essentials/src/com/earth2me/essentials/IUser.java b/Essentials/src/com/earth2me/essentials/IUser.java index 27f95430c..52252786b 100644 --- a/Essentials/src/com/earth2me/essentials/IUser.java +++ b/Essentials/src/com/earth2me/essentials/IUser.java @@ -5,8 +5,10 @@ import java.net.InetSocketAddress; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.inventory.PlayerInventory; - - +/** + * @deprecated This will be moved to the api package soon + */ +@Deprecated public interface IUser { int getHealth(); diff --git a/Essentials/src/com/earth2me/essentials/ItemDb.java b/Essentials/src/com/earth2me/essentials/ItemDb.java index 021e316a8..e3df50bab 100644 --- a/Essentials/src/com/earth2me/essentials/ItemDb.java +++ b/Essentials/src/com/earth2me/essentials/ItemDb.java @@ -1,5 +1,6 @@ package com.earth2me.essentials; +import com.earth2me.essentials.api.IItemDb; import static com.earth2me.essentials.I18n._; import java.util.HashMap; import java.util.List; @@ -9,7 +10,7 @@ import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -public class ItemDb implements IConf +public class ItemDb implements IConf, IItemDb { private final transient IEssentials ess; diff --git a/Essentials/src/com/earth2me/essentials/api/IAlternativeCommandsHandler.java b/Essentials/src/com/earth2me/essentials/api/IAlternativeCommandsHandler.java new file mode 100644 index 000000000..11619bca4 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/api/IAlternativeCommandsHandler.java @@ -0,0 +1,10 @@ +package com.earth2me.essentials.api; + +import java.util.Map; +import org.bukkit.command.PluginCommand; + + +public interface IAlternativeCommandsHandler +{ + Map disabledCommands(); +} diff --git a/Essentials/src/com/earth2me/essentials/api/IEssentials.java b/Essentials/src/com/earth2me/essentials/api/IEssentials.java new file mode 100644 index 000000000..68c053a51 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/api/IEssentials.java @@ -0,0 +1,51 @@ +package com.earth2me.essentials.api; + +import com.earth2me.essentials.perm.IPermissionsHandler; +import com.earth2me.essentials.register.payment.Methods; +import org.bukkit.World; +import org.bukkit.command.CommandSender; +import org.bukkit.plugin.Plugin; + + +public interface IEssentials extends Plugin, IReload +{ + void addReloadListener(IReload listener); + + IUser getUser(Object base); + + int broadcastMessage(IUser sender, String message); + + II18n getI18n(); + + ISettings getSettings(); + + IJail getJail(); + + IWarps getWarps(); + + IWorth getWorth(); + + IItemDb getItemDb(); + + IUserMap getUserMap(); + + IEssentialsEconomy getEconomy(); + + World getWorld(String name); + + Methods getPaymentMethod(); + + int scheduleAsyncDelayedTask(Runnable run); + + int scheduleSyncDelayedTask(Runnable run); + + int scheduleSyncDelayedTask(Runnable run, long delay); + + int scheduleSyncRepeatingTask(Runnable run, long delay, long period); + + IPermissionsHandler getPermissionsHandler(); + + IAlternativeCommandsHandler getAlternativeCommandsHandler(); + + void showCommandError(CommandSender sender, String commandLabel, Throwable exception); +} diff --git a/Essentials/src/com/earth2me/essentials/api/IEssentialsEconomy.java b/Essentials/src/com/earth2me/essentials/api/IEssentialsEconomy.java new file mode 100644 index 000000000..72fb89d26 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/api/IEssentialsEconomy.java @@ -0,0 +1,37 @@ +package com.earth2me.essentials.api; + + +public interface IEssentialsEconomy +{ + double getMoney(String name) throws UserDoesNotExistException; + + void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException; + + void add(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException; + + void subtract(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException; + + void divide(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException; + + void multiply(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException; + + void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException; + + boolean hasEnough(String name, double amount) throws UserDoesNotExistException; + + boolean hasMore(String name, double amount) throws UserDoesNotExistException; + + boolean hasLess(String name, double amount) throws UserDoesNotExistException; + + boolean isNegative(String name) throws UserDoesNotExistException; + + String format(double amount); + + boolean playerExists(String name); + + boolean isNPC(String name) throws UserDoesNotExistException; + + boolean createNPC(String name); + + void removeNPC(String name) throws UserDoesNotExistException; +} diff --git a/Essentials/src/com/earth2me/essentials/api/II18n.java b/Essentials/src/com/earth2me/essentials/api/II18n.java new file mode 100644 index 000000000..567d4e59e --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/api/II18n.java @@ -0,0 +1,9 @@ +package com.earth2me.essentials.api; + +import java.util.Locale; + + +public interface II18n +{ + Locale getCurrentLocale(); +} diff --git a/Essentials/src/com/earth2me/essentials/api/IItemDb.java b/Essentials/src/com/earth2me/essentials/api/IItemDb.java new file mode 100644 index 000000000..ee4819215 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/api/IItemDb.java @@ -0,0 +1,11 @@ +package com.earth2me.essentials.api; + +import org.bukkit.inventory.ItemStack; + + +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/IJail.java b/Essentials/src/com/earth2me/essentials/api/IJail.java new file mode 100644 index 000000000..02fac3174 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/api/IJail.java @@ -0,0 +1,18 @@ +package com.earth2me.essentials.api; + +import java.util.Collection; +import org.bukkit.Location; + + +public interface IJail extends IReload +{ + Location getJail(String jailName) throws Exception; + + Collection getJails() throws Exception; + + void removeJail(String jail) throws Exception; + + void sendToJail(IUser user, String jail) throws Exception; + + void setJail(Location loc, String jailName) throws Exception; +} diff --git a/Essentials/src/com/earth2me/essentials/api/IReload.java b/Essentials/src/com/earth2me/essentials/api/IReload.java new file mode 100644 index 000000000..75403b55c --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/api/IReload.java @@ -0,0 +1,7 @@ +package com.earth2me.essentials.api; + + +public interface IReload +{ + void onReload(); +} diff --git a/Essentials/src/com/earth2me/essentials/api/ISettings.java b/Essentials/src/com/earth2me/essentials/api/ISettings.java new file mode 100644 index 000000000..eff65ad87 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/api/ISettings.java @@ -0,0 +1,10 @@ +package com.earth2me.essentials.api; + +import com.earth2me.essentials.settings.Settings; +import com.earth2me.essentials.storage.IStorageObjectHolder; + + +public interface ISettings extends IStorageObjectHolder +{ + +} diff --git a/Essentials/src/com/earth2me/essentials/api/IUser.java b/Essentials/src/com/earth2me/essentials/api/IUser.java new file mode 100644 index 000000000..0d0734ad9 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/api/IUser.java @@ -0,0 +1,39 @@ +package com.earth2me.essentials.api; + +import com.earth2me.essentials.commands.IEssentialsCommand; +import org.bukkit.Location; +import org.bukkit.entity.Player; + + +public interface IUser extends Player, IReload +{ + long getLastTeleportTimestamp(); + + boolean isAuthorized(String node); + + boolean isAuthorized(IEssentialsCommand cmd); + + boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix); + + void setLastTeleportTimestamp(long time); + + Location getLastLocation(); + + Player getBase(); + + double getMoney(); + + void takeMoney(double value); + + void giveMoney(double value); + + String getGroup(); + + void setLastLocation(); + + Location getHome(String name) throws Exception; + + Location getHome(Location loc) throws Exception; + + boolean isHidden(); +} diff --git a/Essentials/src/com/earth2me/essentials/api/IUserMap.java b/Essentials/src/com/earth2me/essentials/api/IUserMap.java new file mode 100644 index 000000000..9e609ab37 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/api/IUserMap.java @@ -0,0 +1,20 @@ +package com.earth2me.essentials.api; + +import java.io.File; +import java.util.Set; + + +public interface IUserMap +{ + boolean userExists(final String name); + + IUser getUser(final String name); + + void removeUser(final String name); + + Set getAllUniqueUsers(); + + int getUniqueUsers(); + + File getUserFile(final String name); +} diff --git a/Essentials/src/com/earth2me/essentials/api/IWarps.java b/Essentials/src/com/earth2me/essentials/api/IWarps.java new file mode 100644 index 000000000..14779e327 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/api/IWarps.java @@ -0,0 +1,16 @@ +package com.earth2me.essentials.api; + +import java.util.Collection; +import org.bukkit.Location; + + +public interface IWarps extends IReload +{ + Location getWarp(String warp) throws Exception; + + Collection getWarps(); + + void removeWarp(String name) throws Exception; + + void setWarp(String name, Location loc) throws Exception; +} diff --git a/Essentials/src/com/earth2me/essentials/api/IWorth.java b/Essentials/src/com/earth2me/essentials/api/IWorth.java new file mode 100644 index 000000000..4add98771 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/api/IWorth.java @@ -0,0 +1,11 @@ +package com.earth2me.essentials.api; + +import org.bukkit.inventory.ItemStack; + + +public interface IWorth extends IReload +{ + double getPrice(ItemStack itemStack); + + void setPrice(ItemStack itemStack, double price); +}