1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-29 17:29:56 +02:00

Lets get this API party started. I invited the JavaDucks. (In all seriousness this is mostly just adding blank javadocs and a few small refactorings)

This commit is contained in:
Iaccidentally
2013-05-25 15:09:18 -04:00
parent 03c47f1f8a
commit 1129a6af88
24 changed files with 762 additions and 5 deletions

View File

@@ -8,11 +8,20 @@ public class ChargeException extends Exception
*/
private static final long serialVersionUID = 200058474023860487L;
/**
*
* @param message
*/
public ChargeException(final String message)
{
super(message);
}
/**
*
* @param message
* @param throwable
*/
public ChargeException(final String message, final Throwable throwable)
{
super(message, throwable);

View File

@@ -4,7 +4,7 @@ import net.ess3.utils.FormatUtil;
/**
* Instead of using this api directly, we recommend to use the register plugin: http://bit.ly/RegisterMethod
* Instead of using this api directly, we recommend to use Vault
*/
public final class Economy
{

View File

@@ -3,5 +3,8 @@ package net.ess3.api;
public interface IBackup extends Runnable
{
/**
* Used to start the backup task
*/
void startTask();
}

View File

@@ -8,11 +8,31 @@ import org.bukkit.plugin.Plugin;
public interface ICommandHandler extends IReload, TabExecutor
{
/**
* Returns a map of disabled commands and the alternate command found
* String one is the name of the disabled command
* String two is the alternate that was found
* @return
*/
Map<String, String> disabledCommands();
/**
*
* @param plugin the plugin to add
*/
void removePlugin(Plugin plugin);
/**
*
* @param plugin the plugin to remove
*/
void addPlugin(Plugin plugin);
/**
*
* @param sender
* @param commandLabel
* @param exception
*/
void showCommandError(CommandSender sender, String commandLabel, Throwable exception);
}

View File

@@ -3,19 +3,72 @@ package net.ess3.api;
public interface IEconomy extends IReload
{
/**
* Used to get the balance of a user
*
* @param name the name of the user
* @return the balance
* @throws UserDoesNotExistException thrown if the user does not exist
*/
double getMoney(String name) throws UserDoesNotExistException;
/**
* Used to set the balance of a user
*
* @param name the name of the user
* @param balance the amount to set the balance to
* @throws UserDoesNotExistException thrown if the user does not exist
* @throws NoLoanPermittedException **TODO: this needs to be removed, due to changes in eco handling**
*/
void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException;
/**
* Used to reset the balance of a user to the starting balance (as defined in the config)
*
* @param name the name of the user
* @throws UserDoesNotExistException
* @throws NoLoanPermittedException **TODO: this needs to be removed, due to changes in eco handling**
*/
void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException;
/**
* Used to format the balance as a string
*
* @param amount the balance to format
* @return the formatted string
*/
String format(double amount);
/**
* Used to check if a user exists. A user exists if they have played on the server and have not had their user data deleted.
*
* @param name the name of the user to check
* @return true if the user exists, false if not
*/
boolean playerExists(String name);
/**
* Used to check if the given user is a NPC. An example of a NPC would be a town or faction, which has a balance, but is not a player.
*
* @param name the name of the user to check
* @return true if the user is a NPC, false if not
* @throws UserDoesNotExistException thrown if the user does not exist
*/
boolean isNPC(String name) throws UserDoesNotExistException;
/**
* Used to create a new NPC.
*
* @param name the name to give the new NPC
* @return true if the NPC was successfully created, false if not (should never happen)
*/
boolean createNPC(String name);
/**
* Used to remove a NPC with the given name
*
* @param name the name of the NPC to remove
* @throws UserDoesNotExistException thrown if the NPC does not exist
*/
void removeNPC(String name) throws UserDoesNotExistException;
}

View File

@@ -13,57 +13,168 @@ import org.bukkit.World;
public interface IEssentials extends IComponent
{
/**
*
* @param listener
*/
void addReloadListener(IReload listener);
/**
*
* @param sender
* @param message
* @return
*/
int broadcastMessage(IUser sender, String message);
/**
*
* @return
*/
II18n getI18n();
/**
*
* @return
*/
ISettings getSettings();
/**
*
* @return
*/
IRanks getRanks();
/**
*
* @return
*/
IJails getJails();
/**
*
* @return
*/
IKits getKits();
/**
*
* @return
*/
IWarps getWarps();
/**
*
* @return
*/
IWorth getWorth();
/**
*
* @return
*/
IItemDb getItemDb();
/**
*
* @return
*/
IUserMap getUserMap();
/**
*
* @return
*/
IBackup getBackup();
/**
*
* @return
*/
ICommandHandler getCommandHandler();
/**
*
* @param name
* @return
*/
World getWorld(String name);
/**
*
* @return
*/
Methods getPaymentMethod();
/**
*
* @param groups
*/
void setRanks(IRanks groups);
/**
*
* @param groups
*/
void removeReloadListener(IReload groups);
/**
*
* @return
*/
IEconomy getEconomy();
/**
*
* @return
*/
Server getServer();
/**
*
* @return
*/
Logger getLogger();
/**
*
* @return
*/
IPlugin getPlugin();
/**
*
* @return
*/
List<String> getVanishedPlayers();
/**
*
* @return
*/
EssentialsTimer getTimer();
/**
*
* @return
*/
Metrics getMetrics();
/**
*
* @param metrics
*/
void setMetrics(Metrics metrics);
/**
*
* @return
*/
SpawnsHolder getSpawns();
/**
*
* @return
*/
StorageQueue getStorageQueue();
}

View File

@@ -5,5 +5,10 @@ import java.util.Locale;
public interface II18n
{
/**
* Used to get the locale currently being used
*
* @return the current locale
*/
Locale getCurrentLocale();
}

View File

@@ -5,9 +5,29 @@ import org.bukkit.inventory.ItemStack;
public interface IItemDb extends IReload
{
/**
*
* @param name
* @param user
* @return
* @throws Exception
*/
ItemStack get(final String name, final IUser user) throws Exception;
/**
*
* @param name
* @param quantity
* @return
* @throws Exception
*/
ItemStack get(final String name, final int quantity) throws Exception;
/**
*
* @param name
* @return
* @throws Exception
*/
ItemStack get(final String name) throws Exception;
}

View File

@@ -6,15 +6,47 @@ import org.bukkit.Location;
public interface IJails extends IReload
{
/**
*
* @param jailName
* @return
* @throws Exception
*/
Location getJail(String jailName) throws Exception;
/**
*
* @return
* @throws Exception
*/
Collection<String> getList() throws Exception;
/**
*
* @return
*/
int getCount();
/**
*
* @param jail
* @throws Exception
*/
void removeJail(String jail) throws Exception;
/**
*
* @param user
* @param jail
* @throws Exception
*/
void sendToJail(IUser user, String jail) throws Exception;
/**
*
* @param jailName
* @param loc
* @throws Exception
*/
void setJail(String jailName, Location loc) throws Exception;
}

View File

@@ -7,15 +7,48 @@ import net.ess3.settings.Kit;
public interface IKits extends IReload
{
/**
*
* @param kit
* @return
* @throws Exception
*/
Kit getKit(String kit) throws Exception;
/**
*
* @param user
* @param kit
* @throws Exception
*/
void sendKit(IUser user, String kit) throws Exception;
/**
*
* @param user
* @param kit
* @throws Exception
*/
void sendKit(IUser user, Kit kit) throws Exception;
/**
*
* @return
* @throws Exception
*/
Collection<String> getList() throws Exception;
/**
*
* @return
*/
boolean isEmpty();
/**
*
* @param user
* @param kit
* @throws NoChargeException
*/
void checkTime(final IUser user, Kit kit) throws NoChargeException;
}

View File

@@ -16,7 +16,15 @@ public interface IPermission
*/
boolean isAuthorized(CommandSender sender);
/**
*
* @return
*/
String getParentPermission();
/**
*
* @return
*/
PermissionDefault getPermissionDefault();
}

View File

@@ -41,7 +41,15 @@ public interface IPlugin extends Plugin
*/
BukkitTask runTaskLaterAsynchronously(final Runnable run, final long delay);
BukkitTask runTaskTimerAsynchronously(final Runnable run, final long delay, final long delay2);
/**
* Call an a-sync task to be run with a given delay
*
* @param run - Code to be run
* @param delay - Long that represents how long to wait
* @param period - Time to wait between every run after the first
* @return - BukkitTask for the task created
*/
BukkitTask runTaskTimerAsynchronously(final Runnable run, final long delay, final long period);
/**
* Schedule a sync (ran in main thread) delayed task
@@ -72,6 +80,10 @@ public interface IPlugin extends Plugin
*/
BukkitTask scheduleAsyncRepeatingTask(final Runnable run, final long delay, final long period);
/**
*
* @return
*/
File getRootFolder();
/**
@@ -128,8 +140,16 @@ public interface IPlugin extends Plugin
*/
boolean isModuleEnabled(String name);
/**
*
* @param plugin
*/
void onPluginEnable(Plugin plugin);
/**
*
* @param plugin
*/
void onPluginDisable(Plugin plugin);
/**

View File

@@ -9,21 +9,67 @@ import org.bukkit.command.CommandSender;
*/
public interface IRanks
{
/**
*
* @param player
* @return
*/
String getMainGroup(CommandSender player);
/**
*
* @param player
* @param groupname
* @return
*/
boolean inGroup(CommandSender player, String groupname);
/**
*
* @param player
* @return
*/
double getHealCooldown(CommandSender player);
/**
*
* @param player
* @return
*/
double getTeleportCooldown(CommandSender player);
/**
*
* @param player
* @return
*/
double getTeleportDelay(CommandSender player);
/**
*
* @param player
* @return
*/
String getPrefix(CommandSender player);
/**
*
* @param player
* @return
*/
String getSuffix(CommandSender player);
/**
*
* @param player
* @return
*/
int getHomeLimit(CommandSender player);
/**
*
* @param player
* @return
*/
MessageFormat getChatFormat(CommandSender player);
}

View File

@@ -3,5 +3,8 @@ package net.ess3.api;
public interface IReload
{
/**
*
*/
void onReload();
}

View File

@@ -5,7 +5,15 @@ import org.bukkit.command.CommandSender;
public interface IReplyTo
{
/**
*
* @param user
*/
void setReplyTo(CommandSender user);
/**
*
* @return
*/
CommandSender getReplyTo();
}

View File

@@ -6,9 +6,21 @@ import net.ess3.storage.IStorageObjectHolder;
public interface ISettings extends IStorageObjectHolder<Settings>
{
/**
*
* @return
*/
String getLocale();
/**
*
* @return
*/
boolean isDebug();
/**
*
* @param b **TODO: rename this, "b" is a terrible name**
*/
void setDebug(boolean b);
}

View File

@@ -19,23 +19,85 @@ public interface ITeleport
*/
void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception;
/**
*
* @param entity
* @param cooldown
* @param cause
* @throws Exception
*/
void now(Entity entity, boolean cooldown, TeleportCause cause) throws Exception;
/**
*
* @param target
* @param cause
* @throws Exception
*/
void now(final Target target, final TeleportCause cause) throws Exception;
/**
*
* @param chargeFor
* @throws Exception
*/
void back(Trade chargeFor) throws Exception;
/**
*
* @param bed
* @param charge
* @param teleportCause
* @throws Exception
*/
void teleport(Location bed, Trade charge, TeleportCause teleportCause) throws Exception;
/**
*
* @param entity
* @param chargeFor
* @param cause
* @throws Exception
*/
void teleport(Entity entity, Trade chargeFor, TeleportCause cause) throws Exception;
/**
*
* @param otherUser
* @param chargeFor
* @param cause
* @throws Exception
*/
void teleportToMe(IUser otherUser, Trade chargeFor, TeleportCause cause) throws Exception;
/**
*
* @param loc
* @param chargeFor
* @throws Exception
*/
void home(Location loc, Trade chargeFor) throws Exception;
/**
*
* @param charge
* @param teleportCause
* @throws Exception
*/
void respawn(Trade charge, TeleportCause teleportCause) throws Exception;
/**
*
* @throws Exception
*/
void back() throws Exception;
/**
*
* @param name
* @param charge
* @param teleportCause
* @throws Exception
*/
void warp(String name, Trade charge, TeleportCause teleportCause) throws Exception;
}

View File

@@ -28,113 +28,354 @@ public interface IUser extends OfflinePlayer, CommandSender, IStorageObjectHolde
*/
void takeMoney(double value);
/**
*
* @param value
* @param initiator
*/
void takeMoney(double value, CommandSender initiator);
/**
*
* @param value
*/
void giveMoney(double value);
/**
*
* @param value
* @param initiator
*/
void giveMoney(double value, CommandSender initiator);
/**
*
* @param itemStack
* @param canSpew
* @throws ChargeException
*/
void giveItems(ItemStack itemStack, Boolean canSpew) throws ChargeException;
/**
*
* @param itemStacks
* @param canSpew
* @throws ChargeException
*/
void giveItems(List<ItemStack> itemStacks, Boolean canSpew) throws ChargeException;
/**
*
* @param value
*/
void setMoney(double value);
/**
*
* @param receiver
* @param value
* @throws Exception
*/
void payUser(final IUser receiver, final double value) throws Exception;
/**
*
*/
void setLastLocation();
/**
*
* @param name
* @return
* @throws Exception
*/
Location getHome(String name) throws Exception;
/**
*
* @param loc
* @return
*/
Location getHome(Location loc);
//boolean isHidden(); TODO: implement this?
/**
*
* @return
*/
boolean isHidden(); //TODO: implement this?
/**
*
* @return
*/
ITeleport getTeleport();
/**
*
* @param cooldownType
* @param cooldown
* @param set
* @param bypassPermission
* @throws CooldownException
*/
void checkCooldown(UserData.TimestampType cooldownType, double cooldown, boolean set, IPermission bypassPermission) throws CooldownException;
/**
*
* @return
*/
boolean toggleAfk();
/**
*
* @param broadcast
*/
void updateActivity(boolean broadcast);
/**
*
*/
void updateDisplayName();
/**
*
*/
void setDisplayNick();
/**
*
* @param currentTime
* @return
*/
boolean checkJailTimeout(long currentTime);
/**
*
* @param currentTime
* @return
*/
boolean checkMuteTimeout(long currentTime);
/**
*
* @param currentTime
* @return
*/
boolean checkBanTimeout(long currentTime);
/**
*
* @param name
* @return
*/
long getTimestamp(UserData.TimestampType name);
/**
*
* @param name
* @param value
*/
void setTimestamp(UserData.TimestampType name, long value);
/**
*
* @param currentTime
*/
void setLastOnlineActivity(long currentTime);
/**
*
*/
void checkActivity();
/**
*
* @return
*/
long getLastOnlineActivity();
/**
*
* @return
*/
boolean isGodModeEnabled();
/**
*
* @param user
* @return
*/
boolean isIgnoringPlayer(IUser user);
/**
*
* @param user
* @param set
*/
void setIgnoredPlayer(IUser user, boolean set);
/**
*
* @return
*/
Location getAfkPosition();
/**
*
*/
void updateCompass();
/**
*
* @return
*/
Set<String> getHomes();
/**
*
* @param string
*/
void addMail(String string);
/**
*
* @param mute
*/
void setMuted(boolean mute);
/**
*
* @param user
* @param b
*/
void requestTeleport(IUser user, boolean b);
/**
*
* @return
*/
boolean isTpRequestHere();
/**
*
* @return
*/
IUser getTeleportRequester();
/**
*
* @return
*/
long getTeleportRequestTime();
/**
*
* @return
*/
boolean gotMailInfo();
/**
*
* @return
*/
List<String> getMails();
/**
*
* @param money
* @return
*/
boolean canAfford(double money);
/**
*
* @param userMoney
*/
void updateMoneyCache(double userMoney);
/**
*
* @param amount
* @param b
* @return
*/
boolean canAfford(double amount, boolean b);
/**
*
* @return
*/
boolean isVanished();
/**
*
*/
void resetInvulnerabilityAfterTeleport();
/**
*
*/
void toggleVanished();
/**
*
* @return
*/
boolean isInvSee();
/**
*
* @param invsee
*/
void setInvSee(boolean invsee);
/**
*
* @return
*/
boolean isEnderSee();
/**
*
* @param endersee
*/
void setEnderSee(boolean endersee);
/**
*
* @return
*/
boolean hasInvulnerabilityAfterTeleport();
/**
*
* @param set
*/
void setGodModeEnabled(boolean set);
/**
*
* @param set
*/
void setVanished(boolean set);
/**
*
* @param throttle
* @return
*/
boolean checkSignThrottle(int throttle);
/**
*
* @return
*/
boolean isRecipeSee();
/**
*
* @param recipeSee
*/
void setRecipeSee(boolean recipeSee);
/**

View File

@@ -9,18 +9,52 @@ import org.bukkit.entity.Player;
public interface IUserMap extends IReload
{
/**
*
* @param name
* @return
*/
boolean userExists(final String name);
/**
*
* @param player
* @return
*/
IUser getUser(final Player player);
/**
*
* @param playerName
* @return
*/
IUser getUser(final String playerName);
/**
*
* @param name
* @throws InvalidNameException
*/
void removeUser(final String name) throws InvalidNameException;
/**
*
* @return
*/
Set<String> getAllUniqueUsers();
/**
*
* @return
*/
int getUniqueUsers();
/**
*
* @param name
* @return
* @throws InvalidNameException
*/
File getUserFile(final String name) throws InvalidNameException;
/**
@@ -45,11 +79,31 @@ public interface IUserMap extends IReload
*/
IUser matchUserExcludingHidden(final String name, final Player requester) throws TooManyMatchesException, PlayerNotFoundException;
/**
*
* @param name
* @param includeOffline
* @return
*/
Set<IUser> matchUsers(final String name, final boolean includeOffline);
/**
*
* @param name
* @param requester
* @return
*/
Set<IUser> matchUsersExcludingHidden(final String name, final Player requester);
/**
*
* @param player
*/
void addPrejoinedPlayer(Player player);
/**
*
* @param player
*/
void removePrejoinedPlayer(Player player);
}

View File

@@ -8,6 +8,10 @@ public class InvalidNameException extends Exception
*/
private static final long serialVersionUID = 1485321420293663139L;
/**
*
* @param thrwbl
*/
public InvalidNameException(Throwable thrwbl)
{
super(thrwbl);

View File

@@ -10,6 +10,9 @@ public class NoLoanPermittedException extends Exception
*/
private static final long serialVersionUID = 1897047051293914036L;
/**
*
*/
public NoLoanPermittedException()
{
super(_("§4User is not allowed to have a negative balance."));

View File

@@ -10,6 +10,10 @@ public class UserDoesNotExistException extends Exception
*/
private static final long serialVersionUID = -6540804196206916310L;
/**
*
* @param name
*/
public UserDoesNotExistException(String name)
{
super(_("§4The user§c {0} §4does not exist.", name));

View File

@@ -154,9 +154,9 @@ public class BukkitPlugin extends JavaPlugin implements IPlugin
}
@Override
public BukkitTask runTaskTimerAsynchronously(final Runnable run, final long delay, final long delay2)
public BukkitTask runTaskTimerAsynchronously(final Runnable run, final long delay, final long period)
{
return getServer().getScheduler().runTaskTimerAsynchronously(this, run, delay, delay2);
return getServer().getScheduler().runTaskTimerAsynchronously(this, run, delay, period);
}
@Override

View File

@@ -681,4 +681,10 @@ public class User extends UserBase implements IUser
{
lastThrottledAction = System.currentTimeMillis();
}
@Override
public boolean isHidden()
{
throw new UnsupportedOperationException("Not supported yet.");
}
}