API & misc cleanup

This commit is contained in:
Iaccidentally 2013-04-30 12:25:25 -04:00
parent 42dc6a2e07
commit 1ab2a51550
7 changed files with 57 additions and 7 deletions

View File

@ -74,6 +74,7 @@ public class ItemDb implements IConf, IItemDb
}
}
@Override
public ItemStack get(final String id, final int quantity) throws Exception
{
final ItemStack retval = get(id.toLowerCase(Locale.ENGLISH));
@ -81,12 +82,13 @@ public class ItemDb implements IConf, IItemDb
return retval;
}
@Override
public ItemStack get(final String id) throws Exception
{
int itemid = 0;
String itemname = null;
short metaData = 0;
String[] parts = splitPattern.split(id);;
String[] parts = splitPattern.split(id);
if (id.matches("^\\d+[:+',;.]\\d+$"))
{
itemid = Integer.parseInt(parts[0]);
@ -137,7 +139,7 @@ public class ItemDb implements IConf, IItemDb
retval.setDurability(metaData);
return retval;
}
public String names(ItemStack item)
{
ItemData itemData = new ItemData(item.getTypeId(), item.getDurability());

View File

@ -231,6 +231,7 @@ public class Teleport implements Runnable, ITeleport
}
//The now function is used when you want to skip tp delay when teleporting someone to a location or player.
@Override
public void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception
{
if (cooldown)
@ -387,7 +388,7 @@ public class Teleport implements Runnable, ITeleport
teleport(new Target(loc), chargeFor, cause);
}
//The back function is a wrapper used to teleport a player /back to their previous location.
//The back function is a wrapper used to teleport a player /back to their previous location.
public void back(Trade chargeFor) throws Exception
{
teleport(new Target(user.getLastLocation()), chargeFor, TeleportCause.COMMAND);

View File

@ -5,5 +5,9 @@ import java.util.Locale;
public interface II18n
{
/**
* Gets the current locale setting
* @return the current locale, if not set it will return the default locale
*/
Locale getCurrentLocale();
}

View File

@ -6,6 +6,6 @@ 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;
}

View File

@ -6,15 +6,47 @@ import org.bukkit.Location;
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(com.earth2me.essentials.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;
}

View File

@ -6,5 +6,12 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public interface ITeleport
{
/**
* Used to skip teleport delay when teleporting someone to a location or player.
* @param loc
* @param cooldown
* @param cause
* @throws Exception
*/
void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception;
}

View File

@ -2,15 +2,19 @@ package com.earth2me.essentials.api;
import static com.earth2me.essentials.I18n._;
public class InvalidWorldException extends Exception {
public class InvalidWorldException extends Exception
{
private final String world;
public InvalidWorldException(final String world) {
public InvalidWorldException(final String world)
{
super(_("invalidWorld"));
this.world = world;
}
public String getWorld() {
public String getWorld()
{
return this.world;
}
}