mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-12 03:13:37 +01:00
New Interfaces in api package (WIP)
This commit is contained in:
parent
5433a68502
commit
58237a796a
@ -402,11 +402,9 @@ public class Essentials extends JavaPlugin implements IEssentials
|
|||||||
public void showError(final CommandSender sender, final Throwable exception, final String commandLabel)
|
public void showError(final CommandSender sender, final Throwable exception, final String commandLabel)
|
||||||
{
|
{
|
||||||
sender.sendMessage(_("errorWithMessage", exception.getMessage()));
|
sender.sendMessage(_("errorWithMessage", exception.getMessage()));
|
||||||
final LogRecord logRecord = new LogRecord(Level.WARNING, _("errorCallingCommand", commandLabel));
|
|
||||||
logRecord.setThrown(exception);
|
|
||||||
if (getSettings().isDebug())
|
if (getSettings().isDebug())
|
||||||
{
|
{
|
||||||
LOGGER.log(logRecord);
|
LOGGER.log(Level.WARNING, _("errorCallingCommand", commandLabel), exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.api.II18n;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@ -12,7 +13,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
|
||||||
public class I18n
|
public class I18n implements II18n
|
||||||
{
|
{
|
||||||
private static I18n instance;
|
private static I18n instance;
|
||||||
private static final String MESSAGES = "messages";
|
private static final String MESSAGES = "messages";
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated New interface will be IReload in api package
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public interface IConf {
|
public interface IConf {
|
||||||
public void reloadConfig();
|
public void reloadConfig();
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,10 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated This will be moved to the api package soon
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public interface IEssentials extends Plugin
|
public interface IEssentials extends Plugin
|
||||||
{
|
{
|
||||||
void addReloadListener(IConf listener);
|
void addReloadListener(IConf listener);
|
||||||
|
@ -5,8 +5,10 @@ import java.net.InetSocketAddress;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
/**
|
||||||
|
* @deprecated This will be moved to the api package soon
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public interface IUser
|
public interface IUser
|
||||||
{
|
{
|
||||||
int getHealth();
|
int getHealth();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.api.IItemDb;
|
||||||
import static com.earth2me.essentials.I18n._;
|
import static com.earth2me.essentials.I18n._;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -9,7 +10,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
|
||||||
public class ItemDb implements IConf
|
public class ItemDb implements IConf, IItemDb
|
||||||
{
|
{
|
||||||
private final transient IEssentials ess;
|
private final transient IEssentials ess;
|
||||||
|
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.earth2me.essentials.api;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import org.bukkit.command.PluginCommand;
|
||||||
|
|
||||||
|
|
||||||
|
public interface IAlternativeCommandsHandler
|
||||||
|
{
|
||||||
|
Map<String, String> disabledCommands();
|
||||||
|
}
|
51
Essentials/src/com/earth2me/essentials/api/IEssentials.java
Normal file
51
Essentials/src/com/earth2me/essentials/api/IEssentials.java
Normal file
@ -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);
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
9
Essentials/src/com/earth2me/essentials/api/II18n.java
Normal file
9
Essentials/src/com/earth2me/essentials/api/II18n.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package com.earth2me.essentials.api;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
||||||
|
public interface II18n
|
||||||
|
{
|
||||||
|
Locale getCurrentLocale();
|
||||||
|
}
|
11
Essentials/src/com/earth2me/essentials/api/IItemDb.java
Normal file
11
Essentials/src/com/earth2me/essentials/api/IItemDb.java
Normal file
@ -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;
|
||||||
|
}
|
18
Essentials/src/com/earth2me/essentials/api/IJail.java
Normal file
18
Essentials/src/com/earth2me/essentials/api/IJail.java
Normal file
@ -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<String> 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;
|
||||||
|
}
|
7
Essentials/src/com/earth2me/essentials/api/IReload.java
Normal file
7
Essentials/src/com/earth2me/essentials/api/IReload.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package com.earth2me.essentials.api;
|
||||||
|
|
||||||
|
|
||||||
|
public interface IReload
|
||||||
|
{
|
||||||
|
void onReload();
|
||||||
|
}
|
10
Essentials/src/com/earth2me/essentials/api/ISettings.java
Normal file
10
Essentials/src/com/earth2me/essentials/api/ISettings.java
Normal file
@ -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<Settings>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
39
Essentials/src/com/earth2me/essentials/api/IUser.java
Normal file
39
Essentials/src/com/earth2me/essentials/api/IUser.java
Normal file
@ -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();
|
||||||
|
}
|
20
Essentials/src/com/earth2me/essentials/api/IUserMap.java
Normal file
20
Essentials/src/com/earth2me/essentials/api/IUserMap.java
Normal file
@ -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<String> getAllUniqueUsers();
|
||||||
|
|
||||||
|
int getUniqueUsers();
|
||||||
|
|
||||||
|
File getUserFile(final String name);
|
||||||
|
}
|
16
Essentials/src/com/earth2me/essentials/api/IWarps.java
Normal file
16
Essentials/src/com/earth2me/essentials/api/IWarps.java
Normal file
@ -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<String> getWarps();
|
||||||
|
|
||||||
|
void removeWarp(String name) throws Exception;
|
||||||
|
|
||||||
|
void setWarp(String name, Location loc) throws Exception;
|
||||||
|
}
|
11
Essentials/src/com/earth2me/essentials/api/IWorth.java
Normal file
11
Essentials/src/com/earth2me/essentials/api/IWorth.java
Normal file
@ -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);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user