Skip to content

Commit 3e725ef

Browse files
committed
Cleanup various aspects of code, fix some formatting, more netbeans 7.4 stuff
1 parent d5196e3 commit 3e725ef

File tree

65 files changed

+432
-443
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+432
-443
lines changed

Essentials/src/com/earth2me/essentials/Console.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
public final class Console implements IReplyTo
88
{
9-
private static Console instance = new Console();
9+
private static final Console instance = new Console();
1010
private CommandSource replyTo;
1111
public final static String NAME = "Console";
1212

Essentials/src/com/earth2me/essentials/Essentials.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ else if (metricsStarter.getStart() != null && metricsStarter.getStart() == false
240240
LOGGER.log(Level.INFO, "Essentials load " + timeroutput);
241241
}
242242
}
243-
catch (Exception ex)
243+
catch (NumberFormatException ex)
244244
{
245245
handleCrash(ex);
246246
}
@@ -527,7 +527,7 @@ else if (user == null)
527527
}
528528
return true;
529529
}
530-
catch (Throwable ex)
530+
catch (Exception ex)
531531
{
532532
showError(sender, ex, commandLabel);
533533
return true;
@@ -600,11 +600,13 @@ public Backup getBackup()
600600
return backup;
601601
}
602602

603+
@Override
603604
public Metrics getMetrics()
604605
{
605606
return metrics;
606607
}
607608

609+
@Override
608610
public void setMetrics(Metrics metrics)
609611
{
610612
this.metrics = metrics;

Essentials/src/com/earth2me/essentials/EssentialsConf.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ public void run()
338338
{
339339
if (pendingDiskWrites.get() > 1)
340340
{
341-
// Writes can be skipped, because they are stored in a queue (in the executor).
341+
// Writes can be skipped, because they are stored in a queue (in the executor).
342342
// Only the last is actually written.
343343
pendingDiskWrites.decrementAndGet();
344344
//LOGGER.log(Level.INFO, configFile + " skipped writing in " + (System.nanoTime() - startTime) + " nsec.");

Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
public class EssentialsEntityListener implements Listener
2020
{
2121
private static final Logger LOGGER = Logger.getLogger("Minecraft");
22-
private final IEssentials ess;
2322
private static final transient Pattern powertoolPlayer = Pattern.compile("\\{player\\}");
23+
private final IEssentials ess;
2424

2525
public EssentialsEntityListener(IEssentials ess)
2626
{

Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.earth2me.essentials;
22

33
import com.earth2me.essentials.perm.PermissionsHandler;
4+
import com.earth2me.essentials.register.payment.Methods;
45
import java.util.logging.Level;
56
import net.ess3.api.IEssentials;
67
import org.bukkit.event.EventHandler;
@@ -28,9 +29,9 @@ public void onPluginEnable(final PluginEnableEvent event)
2829
}
2930
ess.getPermissionsHandler().checkPermissions();
3031
ess.getAlternativeCommandsHandler().addPlugin(event.getPlugin());
31-
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(ess.getServer().getPluginManager()))
32+
if (!Methods.hasMethod() && Methods.setMethod(ess.getServer().getPluginManager()))
3233
{
33-
ess.getLogger().log(Level.INFO, "Payment method found (" + ess.getPaymentMethod().getMethod().getLongName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
34+
ess.getLogger().log(Level.INFO, "Payment method found (" + Methods.getMethod().getLongName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
3435
}
3536
}
3637

@@ -48,7 +49,7 @@ public void onPluginDisable(final PluginDisableEvent event)
4849
}
4950
ess.getAlternativeCommandsHandler().removePlugin(event.getPlugin());
5051
// Check to see if the plugin thats being disabled is the one we are using
51-
if (ess.getPaymentMethod() != null && ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().checkDisabled(event.getPlugin()))
52+
if (ess.getPaymentMethod() != null && Methods.hasMethod() && Methods.checkDisabled(event.getPlugin()))
5253
{
5354
ess.getPaymentMethod().reset();
5455
ess.getLogger().log(Level.INFO, "Payment method was disabled. No longer accepting payments.");

Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private void moveWorthValuesToWorthYml()
7171
doneFile.setProperty("moveWorthValuesToWorthYml", true);
7272
doneFile.save();
7373
}
74-
catch (Throwable e)
74+
catch (Exception e)
7575
{
7676
LOGGER.log(Level.SEVERE, _("upgradingFilesError"), e);
7777
}
@@ -115,7 +115,7 @@ private void moveMotdRulesToFile(String name)
115115
doneFile.setProperty("move" + name + "ToFile", true);
116116
doneFile.save();
117117
}
118-
catch (Throwable e)
118+
catch (IOException e)
119119
{
120120
LOGGER.log(Level.SEVERE, _("upgradingFilesError"), e);
121121
}
@@ -575,10 +575,10 @@ private void sanitizeAllUserFilenames()
575575
return;
576576
}
577577
final File[] listOfFiles = usersFolder.listFiles();
578-
for (int i = 0; i < listOfFiles.length; i++)
578+
for (File listOfFile : listOfFiles)
579579
{
580-
final String filename = listOfFiles[i].getName();
581-
if (!listOfFiles[i].isFile() || !filename.endsWith(".yml"))
580+
final String filename = listOfFile.getName();
581+
if (!listOfFile.isFile() || !filename.endsWith(".yml"))
582582
{
583583
continue;
584584
}
@@ -587,9 +587,9 @@ private void sanitizeAllUserFilenames()
587587
{
588588
continue;
589589
}
590-
final File tmpFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename + ".tmp");
591-
final File newFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename);
592-
if (!listOfFiles[i].renameTo(tmpFile))
590+
final File tmpFile = new File(listOfFile.getParentFile(), sanitizedFilename + ".tmp");
591+
final File newFile = new File(listOfFile.getParentFile(), sanitizedFilename);
592+
if (!listOfFile.renameTo(tmpFile))
593593
{
594594
LOGGER.log(Level.WARNING, _("userdataMoveError", filename, sanitizedFilename));
595595
continue;

Essentials/src/com/earth2me/essentials/ItemDb.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313
public class ItemDb implements IConf, net.ess3.api.IItemDb
1414
{
1515
private final transient IEssentials ess;
16-
17-
public ItemDb(final IEssentials ess)
18-
{
19-
this.ess = ess;
20-
file = new ManagedFile("items.csv", ess);
21-
}
2216
private final transient Map<String, Integer> items = new HashMap<String, Integer>();
2317
private final transient Map<ItemData, List<String>> names = new HashMap<ItemData, List<String>>();
2418
private final transient Map<ItemData, String> primaryName = new HashMap<ItemData, String>();
2519
private final transient Map<String, Short> durabilities = new HashMap<String, Short>();
2620
private final transient ManagedFile file;
2721
private final transient Pattern splitPattern = Pattern.compile("[:+',;.]");
2822

23+
public ItemDb(final IEssentials ess)
24+
{
25+
this.ess = ess;
26+
file = new ManagedFile("items.csv", ess);
27+
}
28+
2929
@Override
3030
public void reloadConfig()
3131
{
@@ -70,7 +70,7 @@ public void reloadConfig()
7070
Collections.sort(nameList, new LengthCompare());
7171
}
7272
else
73-
{
73+
{
7474
List<String> nameList = new ArrayList<String>();
7575
nameList.add(itemName);
7676
names.put(itemData, nameList);
@@ -184,16 +184,16 @@ else if (args[0].equalsIgnoreCase("blocks"))
184184
{
185185
is.add(get(args[0]));
186186
}
187-
187+
188188
if (is.isEmpty() || is.get(0).getType() == Material.AIR)
189189
{
190190
throw new Exception(_("itemSellAir"));
191191
}
192-
192+
193193
return is;
194194
}
195195

196-
@Override
196+
@Override
197197
public String names(ItemStack item)
198198
{
199199
ItemData itemData = new ItemData(item.getTypeId(), item.getDurability());
@@ -214,7 +214,7 @@ public String names(ItemStack item)
214214
}
215215
return StringUtil.joinList(", ", nameList);
216216
}
217-
217+
218218
@Override
219219
public String name(ItemStack item)
220220
{
@@ -231,7 +231,7 @@ public String name(ItemStack item)
231231
}
232232
return name;
233233
}
234-
234+
235235
static class ItemData
236236
{
237237
final private int itemNo;

Essentials/src/com/earth2me/essentials/MetaItemStack.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,8 @@
2222

2323
public class MetaItemStack
2424
{
25-
private final transient Pattern splitPattern = Pattern.compile("[:+',;.]");
26-
private final ItemStack stack;
2725
private final static Map<String, DyeColor> colorMap = new HashMap<String, DyeColor>();
2826
private final static Map<String, FireworkEffect.Type> fireworkShape = new HashMap<String, FireworkEffect.Type>();
29-
private FireworkEffect.Builder builder = FireworkEffect.builder();
30-
private PotionEffectType pEffectType;
31-
private PotionEffect pEffect;
32-
private boolean validFirework = false;
33-
private boolean validPotionEffect = false;
34-
private boolean validPotionDuration = false;
35-
private boolean validPotionPower = false;
36-
private boolean completePotion = false;
37-
private int power = 1;
38-
private int duration = 120;
39-
4027
static
4128
{
4229
for (DyeColor color : DyeColor.values())
@@ -48,6 +35,18 @@ public class MetaItemStack
4835
fireworkShape.put(type.name(), type);
4936
}
5037
}
38+
private final transient Pattern splitPattern = Pattern.compile("[:+',;.]");
39+
private final ItemStack stack;
40+
private FireworkEffect.Builder builder = FireworkEffect.builder();
41+
private PotionEffectType pEffectType;
42+
private PotionEffect pEffect;
43+
private boolean validFirework = false;
44+
private boolean validPotionEffect = false;
45+
private boolean validPotionDuration = false;
46+
private boolean validPotionPower = false;
47+
private boolean completePotion = false;
48+
private int power = 1;
49+
private int duration = 120;
5150

5251
public MetaItemStack(final ItemStack stack)
5352
{
@@ -150,7 +149,7 @@ else if (split.length > 1 && (split[0].equalsIgnoreCase("player") || split[0].eq
150149
{
151150
final String owner = split[1];
152151
final SkullMeta meta = (SkullMeta)stack.getItemMeta();
153-
boolean result = meta.setOwner(owner);
152+
meta.setOwner(owner);
154153
stack.setItemMeta(meta);
155154
}
156155
else

Essentials/src/com/earth2me/essentials/MobData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ else if (this.value.equals(Data.EXP))
281281
((ExperienceOrb)spawned).setExperience(Integer.parseInt(rawData));
282282
this.matched = rawData;
283283
}
284-
catch (Exception e)
284+
catch (NumberFormatException e)
285285
{
286286
throw new Exception(_("invalidNumber"), e);
287287
}
@@ -293,7 +293,7 @@ else if (this.value.equals(Data.SIZE))
293293
((Slime)spawned).setSize(Integer.parseInt(rawData));
294294
this.matched = rawData;
295295
}
296-
catch (Exception e)
296+
catch (NumberFormatException e)
297297
{
298298
throw new Exception(_("slimeMalformedSize"), e);
299299
}

Essentials/src/com/earth2me/essentials/PlayerList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static public List<User> getMergedList(final IEssentials ess, final Map<String,
104104
for (String groupValue : groupValues)
105105
{
106106
groupValue = groupValue.toLowerCase(Locale.ENGLISH);
107-
if (groupValue == null || groupValue.equals(""))
107+
if (groupValue == null || groupValue.isEmpty())
108108
{
109109
continue;
110110
}

0 commit comments

Comments
 (0)