Run IntelliJ IDEA inspections

This commit is contained in:
vemacs 2015-06-03 14:11:56 -06:00
parent c03765803c
commit 73ac6488ce
46 changed files with 134 additions and 158 deletions

View File

@ -13,8 +13,8 @@ import java.util.logging.Logger;
public class AlternativeCommandsHandler {
private static final Logger LOGGER = Logger.getLogger("Essentials");
private final transient Map<String, List<PluginCommand>> altcommands = new HashMap<String, List<PluginCommand>>();
private final transient Map<String, String> disabledList = new HashMap<String, String>();
private final transient Map<String, List<PluginCommand>> altcommands = new HashMap<>();
private final transient Map<String, String> disabledList = new HashMap<>();
private final transient IEssentials ess;
public AlternativeCommandsHandler(final IEssentials ess) {
@ -35,7 +35,7 @@ public class AlternativeCommandsHandler {
for (Command command : commands) {
final PluginCommand pc = (PluginCommand) command;
final List<String> labels = new ArrayList<String>(pc.getAliases());
final List<String> labels = new ArrayList<>(pc.getAliases());
labels.add(pc.getName());
PluginCommand reg = ess.getServer().getPluginCommand(pluginName + ":" + pc.getName().toLowerCase(Locale.ENGLISH));
@ -48,7 +48,7 @@ public class AlternativeCommandsHandler {
for (String label : labels) {
List<PluginCommand> plugincommands = altcommands.get(label.toLowerCase(Locale.ENGLISH));
if (plugincommands == null) {
plugincommands = new ArrayList<PluginCommand>();
plugincommands = new ArrayList<>();
altcommands.put(label.toLowerCase(Locale.ENGLISH), plugincommands);
}
boolean found = false;

View File

@ -94,7 +94,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
private transient I18n i18n;
private transient Metrics metrics;
private transient EssentialsTimer timer;
private final transient List<String> vanishedPlayers = new ArrayList<String>();
private final transient List<String> vanishedPlayers = new ArrayList<>();
private transient Method oldGetOnlinePlayers;
private transient SpawnerUtil spawnerUtil;
@ -128,7 +128,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
userMap = new UserMap(this);
permissionsHandler = new PermissionsHandler(this, false);
Economy.setEss(this);
confList = new ArrayList<IConf>();
confList = new ArrayList<>();
jails = new Jails(this);
registerListeners(server.getPluginManager());
}
@ -160,7 +160,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
upgrade.beforeSettings();
execTimer.mark("Upgrade");
confList = new ArrayList<IConf>();
confList = new ArrayList<>();
settings = new Settings(this);
confList.add(settings);
execTimer.mark("Settings");

View File

@ -291,8 +291,7 @@ public class EssentialsPlayerListener implements Listener {
loc = user.getBase().getBedSpawnLocation();
}
if (loc != null) {
final Location updateLoc = loc;
user.getBase().setCompassTarget(updateLoc);
user.getBase().setCompassTarget(loc);
}
}

View File

@ -136,9 +136,9 @@ public class EssentialsUpgrade {
}
for (Map.Entry<String, Object> entry : powertools.entrySet()) {
if (entry.getValue() instanceof String) {
List<String> temp = new ArrayList<String>();
List<String> temp = new ArrayList<>();
temp.add((String) entry.getValue());
((Map<String, Object>) powertools).put(entry.getKey(), temp);
powertools.put(entry.getKey(), temp);
}
}
config.forceSave();
@ -274,7 +274,7 @@ public class EssentialsUpgrade {
final File file = new File(ess.getDataFolder(), "items.csv");
if (file.exists()) {
try {
final Set<BigInteger> oldconfigs = new HashSet<BigInteger>();
final Set<BigInteger> oldconfigs = new HashSet<>();
oldconfigs.add(new BigInteger("66ec40b09ac167079f558d1099e39f10", 16)); // sep 1
oldconfigs.add(new BigInteger("34284de1ead43b0bee2aae85e75c041d", 16)); // crlf
oldconfigs.add(new BigInteger("c33bc9b8ee003861611bbc2f48eb6f4f", 16)); // jul 24
@ -282,13 +282,10 @@ public class EssentialsUpgrade {
MessageDigest digest = ManagedFile.getDigest();
final BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
final DigestInputStream dis = new DigestInputStream(bis, digest);
final byte[] buffer = new byte[1024];
try {
try (DigestInputStream dis = new DigestInputStream(bis, digest)) {
while (dis.read(buffer) != -1) {
}
} finally {
dis.close();
}
BigInteger hash = new BigInteger(1, digest.digest());
@ -323,11 +320,8 @@ public class EssentialsUpgrade {
if (!configFile.renameTo(new File(ess.getDataFolder(), "spawn.yml.old"))) {
throw new Exception(tl("fileRenameError", "spawn.yml"));
}
PrintWriter writer = new PrintWriter(configFile);
try {
try (PrintWriter writer = new PrintWriter(configFile)) {
new YamlStorageWriter(writer).save(spawns);
} finally {
writer.close();
}
}
} catch (Exception ex) {
@ -358,11 +352,8 @@ public class EssentialsUpgrade {
if (!configFile.renameTo(new File(ess.getDataFolder(), "jail.yml.old"))) {
throw new Exception(tl("fileRenameError", "jail.yml"));
}
PrintWriter writer = new PrintWriter(configFile);
try {
try (PrintWriter writer = new PrintWriter(configFile)) {
new YamlStorageWriter(writer).save(jails);
} finally {
writer.close();
}
}
} catch (Exception ex) {

View File

@ -38,8 +38,8 @@ public class ExecuteTimer {
double duration;
for (ExecuteRecord pair : times) {
mark = (String) pair.getMark();
time2 = (Long) pair.getTime();
mark = pair.getMark();
time2 = pair.getTime();
if (time1 > 0) {
duration = (time2 - time1) / 1000000.0;
output.append(mark).append(": ").append(decimalFormat.format(duration)).append("ms - ");

View File

@ -1,5 +1,5 @@
package com.earth2me.essentials;
public interface IConf {
public void reloadConfig();
void reloadConfig();
}

View File

@ -6,12 +6,12 @@ public interface IReplyTo {
*
* @param user
*/
public void setReplyTo(CommandSource user);
void setReplyTo(CommandSource user);
/**
* Gets the user the sender should reply to
*
* @return
*/
public CommandSource getReplyTo();
CommandSource getReplyTo();
}

View File

@ -4,5 +4,5 @@ import org.bukkit.Location;
public interface ITarget {
public Location getLocation();
Location getLocation();
}

View File

@ -92,7 +92,7 @@ public interface IUser {
boolean isIgnoreExempt();
public void sendMessage(String message);
void sendMessage(String message);
/*
* UserData
@ -142,5 +142,5 @@ public interface IUser {
CommandSource getSource();
public String getName();
String getName();
}

View File

@ -61,14 +61,14 @@ public enum Mob {
public static final Logger logger = Logger.getLogger("Essentials");
private Mob(String n, Enemies en, String s, EntityType type) {
Mob(String n, Enemies en, String s, EntityType type) {
this.suffix = s;
this.name = n;
this.type = en;
this.bukkitType = type;
}
private Mob(String n, Enemies en, EntityType type) {
Mob(String n, Enemies en, EntityType type) {
this.name = n;
this.type = en;
this.bukkitType = type;
@ -93,7 +93,7 @@ public enum Mob {
}
public Entity spawn(final World world, final Server server, final Location loc) throws MobException {
final Entity entity = world.spawn(loc, (Class<? extends Entity>) this.bukkitType.getEntityClass());
final Entity entity = world.spawn(loc, this.bukkitType.getEntityClass());
if (entity == null) {
logger.log(Level.WARNING, tl("unableToSpawnMob"));
throw new MobException();
@ -107,7 +107,7 @@ public enum Mob {
NEUTRAL("neutral"),
ENEMY("enemy");
private Enemies(final String type) {
Enemies(final String type) {
this.type = type;
}

View File

@ -114,12 +114,12 @@ public enum MobData {
TAMED,
COLORABLE,
EXP,
SIZE;
SIZE
}
public static final Logger logger = Logger.getLogger("Essentials");
private MobData(String n, Object type, Object value, boolean isPublic) {
MobData(String n, Object type, Object value, boolean isPublic) {
this.nickname = n;
this.matched = n;
this.helpMessage = n;
@ -128,7 +128,7 @@ public enum MobData {
this.isPublic = isPublic;
}
private MobData(String n, String h, Object type, Object value, boolean isPublic) {
MobData(String n, String h, Object type, Object value, boolean isPublic) {
this.nickname = n;
this.matched = n;
this.helpMessage = h;

View File

@ -84,7 +84,6 @@ public class UUIDMap {
}
try {
Future<?> future = _writeUUIDMap();
;
if (future != null) {
future.get();
}

View File

@ -119,7 +119,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
@Override
public void giveMoney(final BigDecimal value) throws MaxMoneyException {
giveMoney(value, (CommandSource) null);
giveMoney(value, null);
}
@Override
@ -151,7 +151,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
@Override
public void takeMoney(final BigDecimal value) {
takeMoney(value, (CommandSource) null);
takeMoney(value, null);
}
@Override

View File

@ -200,10 +200,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
}
public boolean hasHome() {
if (config.hasProperty("home")) {
return true;
}
return false;
return config.hasProperty("home");
}
private String nickname;

View File

@ -11,11 +11,11 @@ public interface IItemDb {
ItemStack get(final String name) throws Exception;
public String names(ItemStack item);
String names(ItemStack item);
public String name(ItemStack item);
String name(ItemStack item);
List<ItemStack> getMatching(User user, String[] args) throws Exception;
public String serialize(ItemStack is);
String serialize(ItemStack is);
}

View File

@ -87,7 +87,7 @@ public interface ITeleport {
*
* @throws Exception
*/
public void respawn(final Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
void respawn(final Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
/**
* Teleport wrapper used to handle /warp teleports
@ -99,7 +99,7 @@ public interface ITeleport {
*
* @throws Exception
*/
public void warp(IUser otherUser, String warp, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
void warp(IUser otherUser, String warp, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
/**
* Teleport wrapper used to handle /back teleports
@ -108,13 +108,13 @@ public interface ITeleport {
*
* @throws Exception
*/
public void back(Trade chargeFor) throws Exception;
void back(Trade chargeFor) throws Exception;
/**
* Teleport wrapper used to handle throwing user home after a jail sentence
*
* @throws Exception
*/
public void back() throws Exception;
void back() throws Exception;
}

View File

@ -22,11 +22,11 @@ public class Commandcondense extends EssentialsCommand {
super("condense");
}
private Map<ItemStack, SimpleRecipe> condenseList = new HashMap<ItemStack, SimpleRecipe>();
private Map<ItemStack, SimpleRecipe> condenseList = new HashMap<>();
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
List<ItemStack> is = new ArrayList<ItemStack>();
List<ItemStack> is = new ArrayList<>();
boolean validateReverse = false;
if (args.length > 0) {

View File

@ -30,7 +30,7 @@ public class Commandenchant extends EssentialsCommand {
throw new Exception(tl("nothingInHand"));
}
if (args.length == 0) {
final Set<String> enchantmentslist = new TreeSet<String>();
final Set<String> enchantmentslist = new TreeSet<>();
for (Map.Entry<String, Enchantment> entry : Enchantments.entrySet()) {
final String enchantmentName = entry.getValue().getName().toLowerCase(Locale.ENGLISH);
if (enchantmentslist.contains(enchantmentName) || (user.isAuthorized("essentials.enchantments." + enchantmentName) && entry.getValue().canEnchantItem(stack))) {

View File

@ -38,7 +38,7 @@ public class Commandlist extends EssentialsCommand {
// Output the standard /list output, when no group is specified
private void sendGroupedList(CommandSource sender, String commandLabel, Map<String, List<User>> playerList) {
final Set<String> configGroups = ess.getSettings().getListGroupConfig().keySet();
final List<String> asterisk = new ArrayList<String>();
final List<String> asterisk = new ArrayList<>();
// Loop through the custom defined groups and display them
for (String oConfigGroup : configGroups) {
@ -57,7 +57,7 @@ public class Commandlist extends EssentialsCommand {
continue;
}
List<User> outputUserList = new ArrayList<User>();
List<User> outputUserList = new ArrayList<>();
final List<User> matchedList = playerList.get(configGroup);
// If the group value is an int, then we might need to truncate it
@ -85,19 +85,20 @@ public class Commandlist extends EssentialsCommand {
sender.sendMessage(PlayerList.outputFormat(oConfigGroup, PlayerList.listUsers(ess, outputUserList, ", ")));
}
String[] onlineGroups = playerList.keySet().toArray(new String[0]);
Set<String> var = playerList.keySet();
String[] onlineGroups = var.toArray(new String[var.size()]);
Arrays.sort(onlineGroups, String.CASE_INSENSITIVE_ORDER);
// If we have an asterisk group, then merge all remaining groups
if (!asterisk.isEmpty()) {
List<User> asteriskUsers = new ArrayList<User>();
List<User> asteriskUsers = new ArrayList<>();
for (String onlineGroup : onlineGroups) {
asteriskUsers.addAll(playerList.get(onlineGroup));
}
for (String key : asterisk) {
playerList.put(key, asteriskUsers);
}
onlineGroups = asterisk.toArray(new String[0]);
onlineGroups = asterisk.toArray(new String[asterisk.size()]);
}
// If we have any groups remaining after the custom groups loop through and display them

View File

@ -93,10 +93,7 @@ public class Commandnick extends EssentialsLoopCommand {
return true;
}
}
if (ess.getUser(lowerNick) != null && ess.getUser(lowerNick) != target) {
return true;
}
return false;
return ess.getUser(lowerNick) != null && ess.getUser(lowerNick) != target;
}
private void setNickname(final Server server, final CommandSource sender, final User target, final String nickname) {

View File

@ -22,7 +22,7 @@ public class Commandnuke extends EssentialsCommand {
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws NoSuchFieldException, NotEnoughArgumentsException {
Collection<Player> targets;
if (args.length > 0) {
targets = new ArrayList<Player>();
targets = new ArrayList<>();
int pos = 0;
for (String arg : args) {
targets.add(getPlayer(server, sender, args, pos).getBase());

View File

@ -29,7 +29,7 @@ public class Commandpotion extends EssentialsCommand {
final ItemStack stack = user.getBase().getItemInHand();
if (args.length == 0) {
final Set<String> potionslist = new TreeSet<String>();
final Set<String> potionslist = new TreeSet<>();
for (Map.Entry<String, PotionEffectType> entry : Potions.entrySet()) {
final String potionName = entry.getValue().getName().toLowerCase(Locale.ENGLISH);
if (potionslist.contains(potionName) || (user.isAuthorized("essentials.potion." + potionName))) {

View File

@ -13,7 +13,7 @@ import static com.earth2me.essentials.I18n.tl;
public class Commandptime extends EssentialsCommand {
private static final Set<String> getAliases = new HashSet<String>();
private static final Set<String> getAliases = new HashSet<>();
static {
getAliases.add("get");
@ -146,7 +146,7 @@ public class Commandptime extends EssentialsCommand {
* Used to parse an argument of the type "users(s) selector"
*/
private Set<User> getUsers(final Server server, final CommandSource sender, final String selector) throws Exception {
final Set<User> users = new TreeSet<User>(new UserNameComparator());
final Set<User> users = new TreeSet<>(new UserNameComparator());
// If there is no selector we want the sender itself. Or all users if sender isn't a user.
if (selector == null) {
if (sender.isPlayer()) {

View File

@ -12,8 +12,8 @@ import static com.earth2me.essentials.I18n.tl;
public class Commandpweather extends EssentialsCommand {
public static final Set<String> getAliases = new HashSet<String>();
public static final Map<String, WeatherType> weatherAliases = new HashMap<String, WeatherType>();
public static final Set<String> getAliases = new HashSet<>();
public static final Map<String, WeatherType> weatherAliases = new HashMap<>();
static {
getAliases.add("get");
@ -113,7 +113,7 @@ public class Commandpweather extends EssentialsCommand {
* Used to parse an argument of the type "users(s) selector"
*/
private Set<User> getUsers(final Server server, final CommandSource sender, final String selector) throws Exception {
final Set<User> users = new TreeSet<User>(new UserNameComparator());
final Set<User> users = new TreeSet<>(new UserNameComparator());
// If there is no selector we want the sender itself. Or all users if sender isn't a user.
if (selector == null) {
if (sender.isPlayer()) {

View File

@ -95,7 +95,7 @@ public class Commandrecipe extends EssentialsCommand {
}
}
} else {
final HashMap<Material, String> colorMap = new HashMap<Material, String>();
final HashMap<Material, String> colorMap = new HashMap<>();
int i = 1;
for (Character c : "abcdefghi".toCharArray()) {
ItemStack item = recipeMap.get(c);

View File

@ -54,8 +54,8 @@ public class Commandremove extends EssentialsCommand {
}
private void parseCommand(Server server, CommandSource sender, String[] args, World world, int radius) throws Exception {
List<String> types = new ArrayList<String>();
List<String> customTypes = new ArrayList<String>();
List<String> types = new ArrayList<>();
List<String> customTypes = new ArrayList<>();
if (world == null) {
throw new Exception(tl("invalidWorld"));
@ -88,8 +88,8 @@ public class Commandremove extends EssentialsCommand {
radius *= radius;
}
ArrayList<ToRemove> removeTypes = new ArrayList<ToRemove>();
ArrayList<Mob> customRemoveTypes = new ArrayList<Mob>();
ArrayList<ToRemove> removeTypes = new ArrayList<>();
ArrayList<Mob> customRemoveTypes = new ArrayList<>();
for (String s : types) {
removeTypes.add(ToRemove.valueOf(s));
@ -129,7 +129,7 @@ public class Commandremove extends EssentialsCommand {
}
// We should skip any NAMED animals unless we are specifially targetting them.
if (e instanceof LivingEntity && ((LivingEntity) e).getCustomName() != null && !removeTypes.contains(ToRemove.NAMED)) {
if (e instanceof LivingEntity && e.getCustomName() != null && !removeTypes.contains(ToRemove.NAMED)) {
continue;
}
@ -141,7 +141,7 @@ public class Commandremove extends EssentialsCommand {
}
break;
case NAMED:
if (e instanceof LivingEntity && ((LivingEntity) e).getCustomName() != null) {
if (e instanceof LivingEntity && e.getCustomName() != null) {
e.remove();
removed++;
}

View File

@ -58,7 +58,7 @@ public class Commandrepair extends EssentialsCommand {
}
public void repairAll(User user) throws Exception {
final List<String> repaired = new ArrayList<String>();
final List<String> repaired = new ArrayList<>();
repairItems(user.getBase().getInventory().getContents(), user, repaired);
if (user.isAuthorized("essentials.repair.armor")) {

View File

@ -156,7 +156,7 @@ public class Commandseen extends EssentialsCommand {
ess.runTaskAsynchronously(new Runnable() {
@Override
public void run() {
final List<String> matches = new ArrayList<String>();
final List<String> matches = new ArrayList<>();
for (final UUID u : userMap.getAllUniqueUsers()) {
final User user = ess.getUserMap().getUser(u);
if (user == null) {

View File

@ -32,8 +32,7 @@ public class Commandsetwarp extends EssentialsCommand {
try {
warpLoc = warps.getWarp(args[0]);
} catch (WarpNotFoundException ex) {
} catch (InvalidWorldException ex) {
} catch (WarpNotFoundException | InvalidWorldException ex) {
}
if (warpLoc == null || user.isAuthorized("essentials.warp.overwrite." + StringUtil.safeString(args[0]))) {

View File

@ -22,12 +22,12 @@ public class Commandthunder extends EssentialsCommand {
final boolean setThunder = args[0].equalsIgnoreCase("true");
if (args.length > 1) {
world.setThundering(setThunder ? true : false);
world.setThundering(setThunder);
world.setThunderDuration(Integer.parseInt(args[1]) * 20);
user.sendMessage(tl("thunderDuration", (setThunder ? tl("enabled") : tl("disabled")), Integer.parseInt(args[1])));
} else {
world.setThundering(setThunder ? true : false);
world.setThundering(setThunder);
user.sendMessage(tl("thunder", setThunder ? tl("enabled") : tl("disabled")));
}

View File

@ -20,7 +20,7 @@ public class Commandtime extends EssentialsCommand {
@Override
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
boolean add = false;
final List<String> argList = new ArrayList<String>(Arrays.asList(args));
final List<String> argList = new ArrayList<>(Arrays.asList(args));
if (argList.remove("set") && !argList.isEmpty() && NumberUtil.isInt(argList.get(0))) {
argList.set(0, argList.get(0) + "t");
}
@ -28,7 +28,7 @@ public class Commandtime extends EssentialsCommand {
add = true;
argList.set(0, argList.get(0) + "t");
}
final String[] validArgs = argList.toArray(new String[0]);
final String[] validArgs = argList.toArray(new String[argList.size()]);
// Which World(s) are we interested in?
String worldSelector = null;
@ -112,7 +112,7 @@ public class Commandtime extends EssentialsCommand {
* Used to parse an argument of the type "world(s) selector"
*/
private Set<World> getWorlds(final Server server, final CommandSource sender, final String selector) throws Exception {
final Set<World> worlds = new TreeSet<World>(new WorldNameComparator());
final Set<World> worlds = new TreeSet<>(new WorldNameComparator());
// If there is no selector we want the world the user is currently in. Or all worlds if it isn't a user.
if (selector == null) {

View File

@ -42,7 +42,7 @@ public class Commandvanish extends EssentialsToggleCommand {
user.setVanished(enabled);
user.sendMessage(tl("vanish", user.getDisplayName(), enabled ? tl("enabled") : tl("disabled")));
if (enabled == true) {
if (enabled) {
user.sendMessage(tl("vanished"));
}
if (!sender.isPlayer() || !sender.getPlayer().equals(user.getBase())) {

View File

@ -63,7 +63,7 @@ public class Commandwarp extends EssentialsCommand {
//TODO: Use one of the new text classes, like /help ?
private void warpList(final CommandSource sender, final String[] args, final IUser user) throws Exception {
final IWarps warps = ess.getWarps();
final List<String> warpNameList = new ArrayList<String>(warps.getList());
final List<String> warpNameList = new ArrayList<>(warps.getList());
if (user != null) {
final Iterator<String> iterator = warpNameList.iterator();

View File

@ -37,7 +37,7 @@ public class Commandwhois extends EssentialsCommand {
}
sender.sendMessage(tl("whoisIPAddress", user.getBase().getAddress().getAddress().toString()));
final String location = user.getGeoLocation();
if (location != null && (sender.isPlayer() ? ess.getUser(sender.getPlayer()).isAuthorized("essentials.geoip.show") : true)) {
if (location != null && (!sender.isPlayer() || ess.getUser(sender.getPlayer()).isAuthorized("essentials.geoip.show"))) {
sender.sendMessage(tl("whoisGeoLocation", location));
}
sender.sendMessage(tl("whoisGamemode", tl(user.getBase().getGameMode().toString().toLowerCase(Locale.ENGLISH))));

View File

@ -63,7 +63,7 @@ public class SetExpFix {
//This method is required because the bukkit player.getTotalExperience() method, shows exp that has been 'spent'.
//Without this people would be able to use exp and then still sell it.
public static int getTotalExperience(final Player player) {
int exp = (int) Math.round(getExpAtLevel(player) * player.getExp());
int exp = Math.round(getExpAtLevel(player) * player.getExp());
int currentLevel = player.getLevel();
while (currentLevel > 0) {
@ -77,7 +77,7 @@ public class SetExpFix {
}
public static int getExpUntilNextLevel(final Player player) {
int exp = (int) Math.round(getExpAtLevel(player) * player.getExp());
int exp = Math.round(getExpAtLevel(player) * player.getExp());
int nextLevel = player.getLevel();
return getExpAtLevel(nextLevel) - exp;
}

View File

@ -28,8 +28,6 @@ public class MetricsStarter implements Runnable {
EssentialsXMPP
}
;
public MetricsStarter(final IEssentials plugin) {
ess = plugin;
try {

View File

@ -109,7 +109,6 @@ public class PermissionsHandler implements IPermissionsHandler {
if (vaultAPI != null && vaultAPI.isEnabled()) {
if (!(handler instanceof AbstractVaultHandler)) {
AbstractVaultHandler vaultHandler;
// No switch statements for Strings, this is Java 6
switch (enabledPermsPlugin) {
case "PermissionsEx":
vaultHandler = new PermissionsExHandler();

View File

@ -24,35 +24,35 @@ public interface Method {
* @see #getName()
* @see #getVersion()
*/
public Object getPlugin();
Object getPlugin();
/**
* Returns the actual name of this method.
*
* @return <code>String</code> Plugin name.
*/
public String getName();
String getName();
/**
* Returns the reported name of this method.
*
* @return <code>String</code> Plugin name.
*/
public String getLongName();
String getLongName();
/**
* Returns the actual version of this method.
*
* @return <code>String</code> Plugin version.
*/
public String getVersion();
String getVersion();
/**
* Returns the amount of decimal places that get stored NOTE: it will return -1 if there is no rounding
*
* @return <code>int</code> for each decimal place
*/
public int fractionalDigits();
int fractionalDigits();
/**
* Formats amounts into this payment methods style of currency display.
@ -61,14 +61,14 @@ public interface Method {
*
* @return <code>String</code> - Formatted Currency Display.
*/
public String format(double amount);
String format(double amount);
/**
* Allows the verification of bank API existence in this payment method.
*
* @return <code>boolean</code>
*/
public boolean hasBanks();
boolean hasBanks();
/**
* Determines the existence of a bank via name.
@ -79,7 +79,7 @@ public interface Method {
*
* @see #hasBanks
*/
public boolean hasBank(String bank);
boolean hasBank(String bank);
/**
* Determines the existence of an account via name.
@ -88,7 +88,7 @@ public interface Method {
*
* @return <code>boolean</code>
*/
public boolean hasAccount(String name);
boolean hasAccount(String name);
/**
* Check to see if an account <code>name</code> is tied to a <code>bank</code>.
@ -98,7 +98,7 @@ public interface Method {
*
* @return <code>boolean</code>
*/
public boolean hasBankAccount(String bank, String name);
boolean hasBankAccount(String bank, String name);
/**
* Forces an account creation
@ -107,7 +107,7 @@ public interface Method {
*
* @return <code>boolean</code>
*/
public boolean createAccount(String name);
boolean createAccount(String name);
/**
* Forces an account creation
@ -117,7 +117,7 @@ public interface Method {
*
* @return <code>boolean</code>
*/
public boolean createAccount(String name, Double balance);
boolean createAccount(String name, Double balance);
/**
* Returns a <code>MethodAccount</code> class for an account <code>name</code>.
@ -126,7 +126,7 @@ public interface Method {
*
* @return <code>MethodAccount</code> <em>or</em> <code>Null</code>
*/
public MethodAccount getAccount(String name);
MethodAccount getAccount(String name);
/**
* Returns a <code>MethodBankAccount</code> class for an account <code>name</code>.
@ -136,7 +136,7 @@ public interface Method {
*
* @return <code>MethodBankAccount</code> <em>or</em> <code>Null</code>
*/
public MethodBankAccount getBankAccount(String bank, String name);
MethodBankAccount getBankAccount(String bank, String name);
/**
* Checks to verify the compatibility between this Method and a plugin. Internal usage only, for the most part.
@ -145,78 +145,78 @@ public interface Method {
*
* @return <code>boolean</code>
*/
public boolean isCompatible(Plugin plugin);
boolean isCompatible(Plugin plugin);
/**
* Set Plugin data.
*
* @param plugin Plugin
*/
public void setPlugin(Plugin plugin);
void setPlugin(Plugin plugin);
/**
* Contains Calculator and Balance functions for Accounts.
*/
public interface MethodAccount {
public double balance();
interface MethodAccount {
double balance();
public boolean set(double amount);
boolean set(double amount);
public boolean add(double amount);
boolean add(double amount);
public boolean subtract(double amount);
boolean subtract(double amount);
public boolean multiply(double amount);
boolean multiply(double amount);
public boolean divide(double amount);
boolean divide(double amount);
public boolean hasEnough(double amount);
boolean hasEnough(double amount);
public boolean hasOver(double amount);
boolean hasOver(double amount);
public boolean hasUnder(double amount);
boolean hasUnder(double amount);
public boolean isNegative();
boolean isNegative();
public boolean remove();
boolean remove();
@Override
public String toString();
String toString();
}
/**
* Contains Calculator and Balance functions for Bank Accounts.
*/
public interface MethodBankAccount {
public double balance();
interface MethodBankAccount {
double balance();
public String getBankName();
String getBankName();
public int getBankId();
int getBankId();
public boolean set(double amount);
boolean set(double amount);
public boolean add(double amount);
boolean add(double amount);
public boolean subtract(double amount);
boolean subtract(double amount);
public boolean multiply(double amount);
boolean multiply(double amount);
public boolean divide(double amount);
boolean divide(double amount);
public boolean hasEnough(double amount);
boolean hasEnough(double amount);
public boolean hasOver(double amount);
boolean hasOver(double amount);
public boolean hasUnder(double amount);
boolean hasUnder(double amount);
public boolean isNegative();
boolean isNegative();
public boolean remove();
boolean remove();
@Override
public String toString();
String toString();
}
}

View File

@ -481,12 +481,12 @@ public class EssentialsSign {
public interface ISign {
public String getLine(final int index);
String getLine(final int index);
public void setLine(final int index, final String text);
void setLine(final int index, final String text);
public Block getBlock();
Block getBlock();
public void updateSign();
void updateSign();
}
}

View File

@ -22,7 +22,7 @@ public enum Signs {
WEATHER(new SignWeather());
private final EssentialsSign sign;
private Signs(final EssentialsSign sign) {
Signs(final EssentialsSign sign) {
this.sign = sign;
}

View File

@ -223,7 +223,7 @@ public class BukkitConstructor extends CustomClassLoaderConstructor {
try {
final Field typeDefField = Constructor.class.getDeclaredField("typeDefinitions");
typeDefField.setAccessible(true);
typeDefinitions = (Map<Class<? extends Object>, TypeDescription>) typeDefField.get((Constructor) BukkitConstructor.this);
typeDefinitions = (Map<Class<? extends Object>, TypeDescription>) typeDefField.get(BukkitConstructor.this);
if (typeDefinitions == null) {
throw new NullPointerException();
}

View File

@ -345,5 +345,5 @@ enum KeywordType {
enum KeywordCachable {
CACHEABLE, // This keyword can be cached as a string
SUBVALUE, // This keyword can be cached as a map
NOTCACHEABLE; // This keyword should never be cached
NOTCACHEABLE // This keyword should never be cached
}

View File

@ -222,10 +222,7 @@ public class LocationUtil {
if (below.getType() == Material.BED_BLOCK) {
return true;
}
if ((!HOLLOW_MATERIALS.contains(world.getBlockAt(x, y, z).getType().getId())) || (!HOLLOW_MATERIALS.contains(world.getBlockAt(x, y + 1, z).getType().getId()))) {
return true;
}
return false;
return (!HOLLOW_MATERIALS.contains(world.getBlockAt(x, y, z).getType().getId())) || (!HOLLOW_MATERIALS.contains(world.getBlockAt(x, y + 1, z).getType().getId()));
}
// Not needed if using getSafeDestination(loc)

View File

@ -890,12 +890,12 @@ public class FakeServer implements Server {
}
@Override
public CachedServerIcon loadServerIcon(File file) throws IllegalArgumentException, Exception {
public CachedServerIcon loadServerIcon(File file) throws Exception {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public CachedServerIcon loadServerIcon(BufferedImage bufferedImage) throws IllegalArgumentException, Exception {
public CachedServerIcon loadServerIcon(BufferedImage bufferedImage) throws Exception {
throw new UnsupportedOperationException("Not supported yet.");
}
@ -1112,5 +1112,4 @@ public class FakeServer implements Server {
}
}
;
}

View File

@ -35,7 +35,7 @@ public class StorageTest extends TestCase {
OfflinePlayer base1 = server.createPlayer("testPlayer1");
server.addPlayer(base1);
ext.mark("fake user created");
UserData user = (UserData) ess.getUser(base1);
UserData user = ess.getUser(base1);
ext.mark("load empty user");
for (int j = 0; j < 1; j++) {
user.setHome("home", new Location(world, j, j, j));

View File

@ -18,15 +18,15 @@ public enum AntiBuildConfig {
private final boolean isList;
private final boolean isString;
private AntiBuildConfig(final String configName) {
AntiBuildConfig(final String configName) {
this(configName, null, false, true, false);
}
private AntiBuildConfig(final String configName, final boolean defValueBoolean) {
AntiBuildConfig(final String configName, final boolean defValueBoolean) {
this(configName, null, defValueBoolean, false, false);
}
private AntiBuildConfig(final String configName, final String defValueString, final boolean defValueBoolean, final boolean isList, final boolean isString) {
AntiBuildConfig(final String configName, final String defValueString, final boolean defValueBoolean, final boolean isList, final boolean isString) {
this.configName = configName;
this.defValueString = defValueString;
this.defValueBoolean = defValueBoolean;