1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-18 20:41:37 +02:00

Cleanup and more API work

This commit is contained in:
Iaccidentally
2013-05-26 10:50:58 -04:00
parent cf3ab408b4
commit f81688b25f
15 changed files with 48 additions and 45 deletions

View File

@@ -9,7 +9,6 @@ import java.net.URL;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.*; import java.util.*;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import net.ess3.api.IEssentials; import net.ess3.api.IEssentials;
import net.ess3.api.II18n; import net.ess3.api.II18n;

View File

@@ -6,13 +6,11 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Locale; import java.util.Locale;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger;
import static net.ess3.I18n._; import static net.ess3.I18n._;
import net.ess3.api.IEssentials; import net.ess3.api.IEssentials;
import net.ess3.api.IJails; import net.ess3.api.IJails;
import net.ess3.api.IUser; import net.ess3.api.IUser;
import net.ess3.storage.AsyncStorageObjectHolder; import net.ess3.storage.AsyncStorageObjectHolder;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@@ -106,7 +104,14 @@ public class Jails extends AsyncStorageObjectHolder<net.ess3.settings.Jails> imp
@Override @Override
public int getCount() public int getCount()
{ {
throw new UnsupportedOperationException("Not supported yet."); try
{
return getList().size();
}
catch (Exception ex)
{
return 0;
}
} }

View File

@@ -1,7 +1,8 @@
package net.ess3; package net.ess3;
import java.util.*;
import java.util.regex.Pattern;
import static net.ess3.I18n._; import static net.ess3.I18n._;
import net.ess3.api.IEssentials; import net.ess3.api.IEssentials;
import net.ess3.api.IUser; import net.ess3.api.IUser;
import net.ess3.bukkit.Enchantments; import net.ess3.bukkit.Enchantments;
@@ -11,8 +12,6 @@ import net.ess3.utils.Util;
import net.ess3.utils.textreader.BookInput; import net.ess3.utils.textreader.BookInput;
import net.ess3.utils.textreader.BookPager; import net.ess3.utils.textreader.BookPager;
import net.ess3.utils.textreader.IText; import net.ess3.utils.textreader.IText;
import java.util.*;
import java.util.regex.Pattern;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect;

View File

@@ -5,7 +5,6 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import net.ess3.utils.Util; import net.ess3.utils.Util;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;

View File

@@ -7,45 +7,51 @@ import org.bukkit.Location;
public interface IJails extends IReload public interface IJails extends IReload
{ {
/** /**
* Used to get the location of a jail with the given name
* *
* @param jailName * @param jailName the name of the jail to get
* @return * @return the location of the jail
* @throws Exception * @throws Exception if the jail does not exist
*/ */
Location getJail(String jailName) throws Exception; Location getJail(String jailName) throws Exception;
/** /**
* Used to get a list of jails by name
* *
* @return * @return a list of jails
* @throws Exception * @throws Exception
*/ */
Collection<String> getList() throws Exception; Collection<String> getList() throws Exception;
/** /**
* Used to get the number of jails set
* *
* @return * @return the number of jails
*/ */
int getCount(); int getCount();
/** /**
* Used to remove a jail
* *
* @param jail * @param jail the name of the jail to remove
* @throws Exception * @throws Exception
*/ */
void removeJail(String jail) throws Exception; void removeJail(String jail) throws Exception;
/** /**
* Used to send a user to jail
* *
* @param user * @param user the user to send to jail
* @param jail * @param jail the name of the jail to send them to
* @throws Exception * @throws Exception
*/ */
void sendToJail(IUser user, String jail) throws Exception; void sendToJail(IUser user, String jail) throws Exception;
/** /**
* Used to set a jail
* *
* @param jailName * @param jailName the name for the jail
* @param loc * @param loc the location to set the jail at
* @throws Exception * @throws Exception
*/ */
void setJail(String jailName, Location loc) throws Exception; void setJail(String jailName, Location loc) throws Exception;

View File

@@ -8,47 +8,53 @@ import net.ess3.settings.Kit;
public interface IKits extends IReload public interface IKits extends IReload
{ {
/** /**
* Used to get a kit by name
* *
* @param kit * @param kit the name of the kit to get
* @return * @return the kit
* @throws Exception * @throws Exception if the kit does not exist or is improperly defined (due to broken config formatting)
*/ */
Kit getKit(String kit) throws Exception; Kit getKit(String kit) throws Exception;
/** /**
* Sends a kit to a user
* *
* @param user * @param user the user to send the kit to
* @param kit * @param kit the kit to send
* @throws Exception * @throws Exception if the user cannot afford the kit
*/ */
void sendKit(IUser user, String kit) throws Exception; void sendKit(IUser user, String kit) throws Exception;
/** /**
* Sends a kit to a user
* *
* @param user * @param user the user to send the kit to
* @param kit * @param kit the kit to send
* @throws Exception * @throws Exception if the user cannot afford the kit
*/ */
void sendKit(IUser user, Kit kit) throws Exception; void sendKit(IUser user, Kit kit) throws Exception;
/** /**
* Used to get a list of kits by name
* *
* @return * @return the list of kits
* @throws Exception * @throws Exception
*/ */
Collection<String> getList() throws Exception; Collection<String> getList() throws Exception;
/** /**
* Used to check if the list of kits is empty
* *
* @return * @return true if the list is empty, false if not
*/ */
boolean isEmpty(); boolean isEmpty();
/** /**
* Used to check kit delay for cooldowns
* *
* @param user * @param user the user to check
* @param kit * @param kit the kit to check
* @throws NoChargeException * @throws NoChargeException if the kit cannot be used **TODO: use a better exception here**
*/ */
void checkTime(final IUser user, Kit kit) throws NoChargeException; void checkTime(final IUser user, Kit kit) throws NoChargeException;
} }

View File

@@ -1,8 +1,7 @@
package net.ess3.commands; package net.ess3.commands;
import static net.ess3.I18n._;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static net.ess3.I18n._;
import net.ess3.MetaItemStack; import net.ess3.MetaItemStack;
import net.ess3.api.ISettings; import net.ess3.api.ISettings;
import net.ess3.api.IUser; import net.ess3.api.IUser;

View File

@@ -2,10 +2,8 @@ package net.ess3.commands;
import java.util.*; import java.util.*;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger;
import static net.ess3.I18n._; import static net.ess3.I18n._;
import net.ess3.api.*; import net.ess3.api.*;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.*; import org.bukkit.command.*;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@@ -5,7 +5,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static net.ess3.I18n._; import static net.ess3.I18n._;
import net.ess3.api.IEssentials; import net.ess3.api.IEssentials;

View File

@@ -6,7 +6,6 @@ import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.util.logging.Level; import java.util.logging.Level;
import net.ess3.api.IEssentials; import net.ess3.api.IEssentials;
import org.bukkit.Bukkit;
public abstract class AbstractDelayedYamlFileReader<T extends StorageObject> implements Runnable public abstract class AbstractDelayedYamlFileReader<T extends StorageObject> implements Runnable

View File

@@ -6,7 +6,6 @@ import java.io.PrintWriter;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import net.ess3.api.IEssentials; import net.ess3.api.IEssentials;
import org.bukkit.Bukkit;
public abstract class AbstractDelayedYamlFileWriter implements Runnable public abstract class AbstractDelayedYamlFileWriter implements Runnable

View File

@@ -5,7 +5,6 @@ import java.io.FileNotFoundException;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level; import java.util.logging.Level;
import net.ess3.api.IEssentials; import net.ess3.api.IEssentials;
import org.bukkit.Bukkit;
public abstract class AsyncStorageObjectHolder<T extends StorageObject> implements IStorageObjectHolder<T> public abstract class AsyncStorageObjectHolder<T extends StorageObject> implements IStorageObjectHolder<T>

View File

@@ -407,8 +407,7 @@ public class BukkitConstructor extends Constructor
} }
catch (Exception e) catch (Exception e)
{ {
throw new YAMLException( throw new YAMLException("Cannot create property=" + key + " for JavaBean=" + object + "; " + e.getMessage(), e);
"Cannot create property=" + key + " for JavaBean=" + object + "; " + e.getMessage(), e);
} }
} }
return object; return object;

View File

@@ -3,7 +3,6 @@ package net.ess3.utils.textreader;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger;
import static net.ess3.I18n._; import static net.ess3.I18n._;
import net.ess3.api.IEssentials; import net.ess3.api.IEssentials;
import net.ess3.api.ISettings; import net.ess3.api.ISettings;

View File

@@ -1,7 +1,5 @@
package net.ess3; package net.ess3;
import net.ess3.api.IUser;
public class UserTest extends EssentialsTest public class UserTest extends EssentialsTest
{ {