1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-10-04 01:51:58 +02:00

Merge pull request #52 from Zenexer/3.0

Misc Cleaning
This commit is contained in:
KHobbits
2012-02-23 11:47:01 -08:00
45 changed files with 106 additions and 100 deletions

1
.gitignore vendored
View File

@@ -44,3 +44,4 @@
/Essentials2Compat/build/
/EssentialsGroupManager/bin
/EssentialsGroupManager/.externalToolBuilders
/EssentialsGeoIP/build

View File

@@ -27,20 +27,15 @@ import com.earth2me.essentials.user.UserMap;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -60,7 +55,7 @@ public class Essentials extends JavaPlugin implements IEssentials
public static final int BUKKIT_VERSION = 1952;
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient ISettings settings;
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);
private final transient TntExplodeListener tntListener = new TntExplodeListener(this);
private transient IJails jails;
private transient IKits kits;
private transient IWarps warps;
@@ -230,7 +225,7 @@ public class Essentials extends JavaPlugin implements IEssentials
final String timeroutput = execTimer.end();
if (getSettings().isDebug())
{
LOGGER.log(Level.INFO, "Essentials load " + timeroutput);
LOGGER.log(Level.INFO, "Essentials load {0}", timeroutput);
}
}
@@ -380,7 +375,7 @@ public class Essentials extends JavaPlugin implements IEssentials
}
@Override
public TNTExplodeListener getTNTListener()
public TntExplodeListener getTNTListener()
{
return tntListener;
}

View File

@@ -44,6 +44,7 @@ public class I18n implements II18n
instance = null;
}
@Override
public Locale getCurrentLocale()
{
return currentLocale;

View File

@@ -1,5 +1,6 @@
package com.earth2me.essentials;
import com.earth2me.essentials.storage.ManagedFile;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.api.IItemDb;

View File

@@ -1,6 +1,7 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.ChargeException;
import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.api.ISettings;
import com.earth2me.essentials.api.IUser;
@@ -115,21 +116,21 @@ public class Trade
{
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItem(user.getInventory(), true, getItemStack());
final Location loc = user.getLocation();
for (ItemStack itemStack : leftOver.values())
for (ItemStack dropStack : leftOver.values())
{
final int maxStackSize = itemStack.getType().getMaxStackSize();
final int stacks = itemStack.getAmount() / maxStackSize;
final int leftover = itemStack.getAmount() % maxStackSize;
final int maxStackSize = dropStack.getType().getMaxStackSize();
final int stacks = dropStack.getAmount() / maxStackSize;
final int leftover = dropStack.getAmount() % maxStackSize;
final Item[] itemStacks = new Item[stacks + (leftover > 0 ? 1 : 0)];
for (int i = 0; i < stacks; i++)
{
final ItemStack stack = itemStack.clone();
final ItemStack stack = dropStack.clone();
stack.setAmount(maxStackSize);
itemStacks[i] = loc.getWorld().dropItem(loc, stack);
}
if (leftover > 0)
{
final ItemStack stack = itemStack.clone();
final ItemStack stack = dropStack.clone();
stack.setAmount(leftover);
itemStacks[stacks] = loc.getWorld().dropItem(loc, stack);
}

View File

@@ -1,4 +1,4 @@
package com.earth2me.essentials;
package com.earth2me.essentials.api;
public class ChargeException extends Exception

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.api;
import com.earth2me.essentials.listener.TNTExplodeListener;
import com.earth2me.essentials.listener.TntExplodeListener;
import com.earth2me.essentials.register.payment.Methods;
import org.bukkit.World;
import org.bukkit.entity.Player;
@@ -52,10 +52,9 @@ public interface IEssentials extends Plugin
int scheduleSyncRepeatingTask(Runnable run, long delay, long period);
//IPermissionsHandler getPermissionsHandler();
void reload();
TNTExplodeListener getTNTListener();
TntExplodeListener getTNTListener();
void setGroups(IGroups groups);

View File

@@ -1,5 +1,6 @@
package com.earth2me.essentials.api;
public interface IEssentialsModule
{
}

View File

@@ -6,7 +6,7 @@ import java.util.Collection;
public interface IKits extends IReload
{
Kit getKit(String kit)throws Exception;
Kit getKit(String kit) throws Exception;
void sendKit(IUser user, String kit) throws Exception;

View File

@@ -2,7 +2,9 @@ package com.earth2me.essentials.api;
import org.bukkit.command.CommandSender;
public interface IReplyTo {
public interface IReplyTo
{
void setReplyTo(CommandSender user);
CommandSender getReplyTo();

View File

@@ -1,6 +1,5 @@
package com.earth2me.essentials.api;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.storage.IStorageObjectHolder;
import com.earth2me.essentials.user.CooldownException;
import com.earth2me.essentials.user.UserData;

View File

@@ -6,5 +6,4 @@ import com.earth2me.essentials.storage.IStorageObjectHolder;
public interface IWarp extends IStorageObjectHolder<Warp>
{
}

View File

@@ -3,7 +3,6 @@ package com.earth2me.essentials.api;
public class InvalidNameException extends Exception
{
public InvalidNameException(Throwable thrwbl)
{
super(thrwbl);

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.api.ChargeException;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.Util;

View File

@@ -5,6 +5,7 @@ import com.earth2me.essentials.api.IReload;
import com.earth2me.essentials.api.ISettings;
import com.earth2me.essentials.perm.GMGroups;
import com.earth2me.essentials.perm.VaultGroups;
import com.earth2me.essentials.register.payment.Methods;
import com.earth2me.essentials.settings.General;
import com.earth2me.essentials.settings.GroupsHolder;
import java.util.logging.Level;
@@ -32,11 +33,11 @@ public class EssentialsPluginListener implements Listener, IReload
checkGroups();
//ess.getPermissionsHandler().checkPermissions();
ess.getCommandHandler().addPlugin(event.getPlugin());
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(ess.getServer().getPluginManager()))
if (!Methods.hasMethod() && Methods.setMethod(ess.getServer().getPluginManager()))
{
ess.getLogger().log(Level.INFO, "Payment method found ({0} version: {1})", new Object[]
{
ess.getPaymentMethod().getMethod().getName(), ess.getPaymentMethod().getMethod().getVersion()
Methods.getMethod().getName(), Methods.getMethod().getVersion()
});
}
}
@@ -48,9 +49,9 @@ public class EssentialsPluginListener implements Listener, IReload
//ess.getPermissionsHandler().checkPermissions();
ess.getCommandHandler().removePlugin(event.getPlugin());
// Check to see if the plugin thats being disabled is the one we are using
if (ess.getPaymentMethod() != null && ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().checkDisabled(event.getPlugin()))
if (Methods.hasMethod() && Methods.checkDisabled(event.getPlugin()))
{
ess.getPaymentMethod().reset();
Methods.reset();
ess.getLogger().log(Level.INFO, "Payment method was disabled. No longer accepting payments.");
}
}

View File

@@ -10,13 +10,13 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
public class TNTExplodeListener implements Listener, Runnable
public class TntExplodeListener implements Listener, Runnable
{
private final transient IEssentials ess;
private transient AtomicBoolean enabled = new AtomicBoolean(false);
private transient int timer = -1;
public TNTExplodeListener(final IEssentials ess)
public TntExplodeListener(final IEssentials ess)
{
super();
this.ess = ess;

View File

@@ -69,7 +69,7 @@ public abstract class AbstractDelayedYamlFileReader<T extends StorageObject> imp
catch (FileNotFoundException ex)
{
onException(ex);
Bukkit.getLogger().log(Level.INFO, "File not found: " + file.toString());
Bukkit.getLogger().log(Level.INFO, "File not found: {0}", file.toString());
}
catch (ObjectLoadException ex)
{

View File

@@ -210,7 +210,8 @@ public class BukkitConstructor extends Constructor
}
return new EnchantmentLevel(enchant, level);
}
if (node.getType().isEnum()) {
if (node.getType().isEnum())
{
final String val = (String)constructScalar((ScalarNode)node);
if (val.isEmpty())
{
@@ -218,7 +219,8 @@ public class BukkitConstructor extends Constructor
}
for (Object object : node.getType().getEnumConstants())
{
if (object.toString().equalsIgnoreCase(val)) {
if (object.toString().equalsIgnoreCase(val))
{
return object;
}
}
@@ -292,7 +294,8 @@ public class BukkitConstructor extends Constructor
final Field typeDefField = Constructor.class.getDeclaredField("typeDefinitions");
typeDefField.setAccessible(true);
typeDefinitions = (Map<Class<? extends Object>, TypeDescription>)typeDefField.get((Constructor)BukkitConstructor.this);
if (typeDefinitions == null) {
if (typeDefinitions == null)
{
throw new NullPointerException();
}
}

View File

@@ -70,9 +70,9 @@ public class EnchantmentLevel implements Entry<Enchantment, Integer>
if (entry.getKey() instanceof Enchantment
&& entry.getValue() instanceof Integer)
{
final Enchantment enchantment = (Enchantment)entry.getKey();
final Integer level = (Integer)entry.getValue();
return this.enchantment.equals(enchantment) && this.level == level.intValue();
final Enchantment objEnchantment = (Enchantment)entry.getKey();
final Integer objLevel = (Integer)entry.getValue();
return enchantment.equals(objEnchantment) && level == objLevel.intValue();
}
}
return false;

View File

@@ -1,4 +1,3 @@
package com.earth2me.essentials.storage;
import com.earth2me.essentials.api.IReload;
@@ -7,7 +6,6 @@ import java.io.File;
import java.util.Set;
interface IStorageObjectMap<I> extends IReload
{
boolean objectExists(final String name);

View File

@@ -3,5 +3,5 @@ package com.earth2me.essentials.storage;
public interface IStorageReader
{
<T extends StorageObject> T load(final Class<? extends T> clazz) throws ObjectLoadException;
<T extends StorageObject> T load(final Class<? extends T> clazz) throws ObjectLoadException;
}

View File

@@ -56,13 +56,16 @@ public class Location
if (loc == null)
{
World world = null;
if (worldUID != null) {
if (worldUID != null)
{
world = Bukkit.getWorld(worldUID);
}
if (world == null) {
if (world == null)
{
world = Bukkit.getWorld(worldname);
}
if (world == null) {
if (world == null)
{
throw new WorldNotLoadedException(worldname);
}
loc = new org.bukkit.Location(world, getX(), getY(), getZ(), getYaw(), getPitch());
@@ -101,11 +104,12 @@ public class Location
return pitch;
}
public static class WorldNotLoadedException extends Exception
{
public WorldNotLoadedException(String worldname)
{
super("World "+worldname+" is not loaded.");
super("World " + worldname + " is not loaded.");
}
}
}

View File

@@ -1,4 +1,4 @@
package com.earth2me.essentials;
package com.earth2me.essentials.storage;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IEssentials;

View File

@@ -45,7 +45,8 @@ public class YamlStorageReader implements IStorageReader
try
{
T object = (T)yaml.load(reader);
if (object == null) {
if (object == null)
{
object = clazz.newInstance();
}
return object;

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.user;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.api.ChargeException;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Teleport;

View File

@@ -1,5 +1,6 @@
package com.earth2me.essentials;
import com.earth2me.essentials.storage.ManagedFile;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.settings.Spawns;

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.chat;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.api.ChargeException;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.Util;

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.signs;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.api.ChargeException;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.Util;

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.signs;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.api.ChargeException;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.api.IUser;

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.signs;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.api.ChargeException;
import com.earth2me.essentials.Enchantments;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.signs;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.api.ChargeException;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.api.IEssentials;

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.signs;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.api.ChargeException;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.api.IEssentials;

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.signs;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.api.ChargeException;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.api.IUser;

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.signs;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.api.ChargeException;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.Util;

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.signs;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.api.ChargeException;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.api.IUser;

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.signs;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.api.ChargeException;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.api.IUser;

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.signs;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.api.ChargeException;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.api.IEssentials;

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.signs;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.api.ChargeException;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.Util;

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.signs;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.api.ChargeException;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.api.IUser;

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.signs;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.api.ChargeException;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.api.IEssentials;