From 1cca4de9e5f4aaff7c60bf25db5978cbbe7f9922 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 5 Jun 2012 09:57:10 -0400 Subject: [PATCH] Cleanup! --- .../gmail/nossr50/commands/SkillCommand.java | 2 +- .../nossr50/commands/mc/McrefreshCommand.java | 2 +- .../nossr50/commands/mc/MctopCommand.java | 2 +- .../nossr50/commands/party/PartyCommand.java | 4 +- .../java/com/gmail/nossr50/config/Config.java | 2 +- .../com/gmail/nossr50/datatypes/HUDmmo.java | 2 +- .../nossr50/datatypes/PlayerProfile.java | 14 +++---- .../events/items/McMMOItemSpawnEvent.java | 3 +- .../nossr50/listeners/BlockListener.java | 4 +- .../nossr50/listeners/HardcoreListener.java | 2 +- .../nossr50/listeners/PlayerListener.java | 15 ++++---- .../nossr50/listeners/SpoutListener.java | 6 +-- src/main/java/com/gmail/nossr50/mcMMO.java | 2 + .../java/com/gmail/nossr50/party/Party.java | 2 +- .../gmail/nossr50/runnables/BleedTimer.java | 6 +-- .../gmail/nossr50/skills/combat/Swords.java | 2 +- .../gmail/nossr50/skills/combat/Taming.java | 2 +- .../nossr50/skills/gathering/Fishing.java | 2 +- .../nossr50/skills/gathering/Herbalism.java | 4 +- .../nossr50/skills/gathering/Mining.java | 2 +- .../nossr50/skills/gathering/WoodCutting.java | 4 +- .../com/gmail/nossr50/spout/SpoutStuff.java | 2 +- .../java/com/gmail/nossr50/util/Combat.java | 6 +-- .../java/com/gmail/nossr50/util/Database.java | 8 ++-- .../java/com/gmail/nossr50/util/Hardcore.java | 38 +++++++++---------- .../com/gmail/nossr50/util/ItemChecks.java | 2 +- .../java/com/gmail/nossr50/util/Metrics.java | 3 +- .../java/com/gmail/nossr50/util/Misc.java | 2 +- .../java/com/gmail/nossr50/util/Page.java | 26 ++++++------- .../java/com/gmail/nossr50/util/Users.java | 2 +- .../util/blockmeta/HashChunkletManager.java | 13 +++++++ .../blockmeta/PrimitiveChunkletStore.java | 4 ++ .../shatt/backup/ZipLibrary.java | 2 +- 33 files changed, 107 insertions(+), 85 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/SkillCommand.java b/src/main/java/com/gmail/nossr50/commands/SkillCommand.java index 9efc0aba2..b25edb77e 100644 --- a/src/main/java/com/gmail/nossr50/commands/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/SkillCommand.java @@ -46,7 +46,7 @@ public abstract class SkillCommand implements CommandExecutor { player = (Player) sender; profile = Users.getProfile(player); - skillValue = (float) profile.getSkillLevel(skill); + skillValue = profile.getSkillLevel(skill); dataCalculations(); permissionsCheck(); diff --git a/src/main/java/com/gmail/nossr50/commands/mc/McrefreshCommand.java b/src/main/java/com/gmail/nossr50/commands/mc/McrefreshCommand.java index 837d7e1d4..fd460cbcd 100644 --- a/src/main/java/com/gmail/nossr50/commands/mc/McrefreshCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/mc/McrefreshCommand.java @@ -61,7 +61,7 @@ public class McrefreshCommand implements CommandExecutor { return true; } - PP.setRecentlyHurt((long) 0); + PP.setRecentlyHurt(0); PP.resetCooldowns(); PP.resetToolPrepMode(); PP.resetAbilityMode(); diff --git a/src/main/java/com/gmail/nossr50/commands/mc/MctopCommand.java b/src/main/java/com/gmail/nossr50/commands/mc/MctopCommand.java index 88fff70ea..8a8df5f59 100644 --- a/src/main/java/com/gmail/nossr50/commands/mc/MctopCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/mc/MctopCommand.java @@ -19,7 +19,7 @@ public class MctopCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { String usage = ChatColor.RED + "Proper usage is /mctop [skill] [page]"; //TODO: Needs more locale. - + if (!Config.getInstance().getUseMySQL()) { switch (args.length) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java index a1b49f203..6a7283d5a 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java @@ -187,7 +187,7 @@ public class PartyCommand implements CommandExecutor { PlayerProfile PPt = Users.getProfile(target); String targetName = target.getName(); - if (!partyInstance.inSameParty(player, (Player) target)) { + if (!partyInstance.inSameParty(player, target)) { player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { targetName })); return true; } @@ -219,7 +219,7 @@ public class PartyCommand implements CommandExecutor { String targetName = target.getName(); - if (!partyInstance.inSameParty(player, (Player) target)) { + if (!partyInstance.inSameParty(player, target)) { player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { targetName })); return true; } diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 6dd9f04e7..5fdf2035f 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -195,7 +195,7 @@ public class Config extends ConfigLoader { } /* Mining */ - public int getMiningXPGoldOre() { return config.getInt("Experience.Mining.Gold", 250); } + public int getMiningXPGoldOre() { return config.getInt("Experience.Mining.Gold", 250); } public int getMiningXPDiamondOre() { return config.getInt("Experience.Mining.Diamond", 750); } public int getMiningXPIronOre() { return config.getInt("Experience.Mining.Iron", 250); } public int getMiningXPRedstoneOre() { return config.getInt("Experience.Mining.Redstone", 150); } diff --git a/src/main/java/com/gmail/nossr50/datatypes/HUDmmo.java b/src/main/java/com/gmail/nossr50/datatypes/HUDmmo.java index 34be0dd09..2259e82c4 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/HUDmmo.java +++ b/src/main/java/com/gmail/nossr50/datatypes/HUDmmo.java @@ -290,7 +290,7 @@ public class HUDmmo { return; } - ((GenericTexture) xpicon).setUrl(Misc.getCapitalized(theType.toString()) + ".png"); + xpicon.setUrl(Misc.getCapitalized(theType.toString()) + ".png"); xpicon.setDirty(true); ((GenericTexture) xpbar).setUrl(getUrlBar(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.STANDARD))); diff --git a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java index 516416cb2..049e5a44e 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -102,9 +102,9 @@ public class PlayerProfile { public boolean loadMySQL() { int id = 0; id = mcMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE user = '" + playerName + "'"); - + this.userid = id; - + if (id > 0) { HashMap> huds = mcMMO.database.read("SELECT hudtype FROM "+Config.getInstance().getMySQLTablePrefix()+"huds WHERE user_id = " + id); if(huds.get(1) == null) @@ -204,7 +204,7 @@ public class PlayerProfile { String[] character = line.split(":"); if(!character[0].equals(playerName)){continue;} - + //Get Mining if(character.length > 1 && Misc.isInt(character[1])) skills.put(SkillType.MINING, Integer.valueOf(character[1])); @@ -299,7 +299,7 @@ public class PlayerProfile { Long timestamp = System.currentTimeMillis() / 1000; //Convert to seconds // if we are using mysql save to database if (Config.getInstance().getUseMySQL()) { - + mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"huds SET hudtype = '"+hud.toString()+"' WHERE user_id = "+this.userid); mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + this.userid); mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"users SET party = '"+this.party+"' WHERE id = " +this.userid); @@ -440,7 +440,7 @@ public class PlayerProfile { //Open the file to write the player FileWriter file = new FileWriter(location, true); BufferedWriter out = new BufferedWriter(file); - + //Add the player to the end out.append(playerName + ":"); out.append(0 + ":"); //mining @@ -481,7 +481,7 @@ public class PlayerProfile { out.append(0+":"); //Blast Mining //Add more in the same format as the line above - + out.newLine(); out.close(); } catch (Exception e) { @@ -1039,7 +1039,7 @@ public class PlayerProfile { xp = (int) (xp * tool.getXpMultiplier()); } } - + if(player.hasPermission("mcmmo.perks.xp.quadruple")) { xp = xp * 4; } else if (player.hasPermission("mcmmo.perks.xp.triple")) { diff --git a/src/main/java/com/gmail/nossr50/events/items/McMMOItemSpawnEvent.java b/src/main/java/com/gmail/nossr50/events/items/McMMOItemSpawnEvent.java index 4da6a0740..b6d7dcb94 100644 --- a/src/main/java/com/gmail/nossr50/events/items/McMMOItemSpawnEvent.java +++ b/src/main/java/com/gmail/nossr50/events/items/McMMOItemSpawnEvent.java @@ -58,10 +58,11 @@ public class McMMOItemSpawnEvent extends Event implements Cancellable { public void setCancelled(boolean cancelled) { this.cancelled = cancelled; } - + /** Rest of file is required boilerplate for custom events **/ private static final HandlerList handlers = new HandlerList(); + @Override public HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 1ea6b148f..228855da8 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -264,11 +264,11 @@ public class BlockListener implements Listener { */ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockDamage(BlockDamageEvent event) { - + if (event instanceof FakeBlockDamageEvent) { return; } - + final int LEAF_BLOWER_LEVEL = 100; Player player = event.getPlayer(); diff --git a/src/main/java/com/gmail/nossr50/listeners/HardcoreListener.java b/src/main/java/com/gmail/nossr50/listeners/HardcoreListener.java index f7c1a22a0..ebeb6732c 100644 --- a/src/main/java/com/gmail/nossr50/listeners/HardcoreListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/HardcoreListener.java @@ -24,7 +24,7 @@ public class HardcoreListener implements Listener { if (!Permissions.getInstance().hardcoremodeBypass(player)) { if (player.getKiller() instanceof Player) { if (Config.getInstance().getHardcoreVampirismEnabled()) { - Hardcore.invokeVampirism(((Player)player.getKiller()), player); + Hardcore.invokeVampirism(player.getKiller(), player); } } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index b1818c620..c3835073c 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -158,13 +158,14 @@ public class PlayerListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); - + + //TODO: Locale ALL the things. if (Config.getInstance().getMOTDEnabled() && Permissions.getInstance().motd(player)) { String prefix = ChatColor.GOLD+"[mcMMO] "; String perkPrefix = ChatColor.RED+"[mcMMO Perks] "; - + player.sendMessage(prefix+ChatColor.YELLOW+"Running version " + ChatColor.DARK_AQUA + plugin.getDescription().getVersion()); //TODO: Locale - + if(Config.getInstance().getHardcoreEnabled()) { if(Config.getInstance().getHardcoreVampirismEnabled()) { player.sendMessage(prefix+ChatColor.DARK_RED+"Hardcore & Vampirism enabled."); @@ -174,7 +175,7 @@ public class PlayerListener implements Listener { player.sendMessage(prefix+ChatColor.DARK_AQUA+"Skill Death Penalty: "+ChatColor.DARK_RED+Config.getInstance().getHardcoreDeathStatPenaltyPercentage()+"%"); } } - + if(player.hasPermission("mcmmo.perks.xp.quadruple")) { player.sendMessage(perkPrefix+ChatColor.DARK_AQUA+"Quadruple XP - Receive 4x XP."); } else if (player.hasPermission("mcmmo.perks.xp.triple")) { @@ -182,7 +183,7 @@ public class PlayerListener implements Listener { } else if (player.hasPermission("mcmmo.perks.xp.double")) { player.sendMessage(perkPrefix+ChatColor.DARK_AQUA+"Double XP - Receive 2x XP."); } - + player.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.GREEN+ "http://www.mcmmo.info" + ChatColor.YELLOW + " - mcMMO Website & Forums"); //TODO: Locale //player.sendMessage(LocaleLoader.getString("mcMMO.MOTD", new Object[] {plugin.getDescription().getVersion()})); //player.sendMessage(LocaleLoader.getString("mcMMO.Website")); @@ -192,8 +193,8 @@ public class PlayerListener implements Listener { if (XprateCommand.xpevent) { player.sendMessage(LocaleLoader.getString("XPRate.Event", new Object[] {Config.getInstance().xpGainMultiplier})); } - - + + } /** diff --git a/src/main/java/com/gmail/nossr50/listeners/SpoutListener.java b/src/main/java/com/gmail/nossr50/listeners/SpoutListener.java index 1c7ccfdf5..2add0fd8f 100644 --- a/src/main/java/com/gmail/nossr50/listeners/SpoutListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/SpoutListener.java @@ -46,7 +46,7 @@ public class SpoutListener implements Listener { if (sPlayer.isSpoutCraftEnabled()) { SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin)); //Setup Party HUD stuff - + PPs.toggleSpoutEnabled(); } } @@ -60,12 +60,12 @@ public class SpoutListener implements Listener { public void onButtonClick(ButtonClickEvent event) { SpoutPlayer sPlayer = event.getPlayer(); PlayerProfile PP = Users.getProfile(sPlayer); - + if (event.getButton() instanceof ButtonHUDStyle) { if (SpoutStuff.playerHUDs.containsKey(sPlayer)) { SpoutStuff.playerHUDs.get(sPlayer).resetHUD(); SpoutStuff.playerHUDs.remove(sPlayer); - + switch (PP.getHUDType()) { case RETRO: PP.setHUDType(HUDType.STANDARD); diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index f051d30cd..835ea7cd6 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -76,6 +76,7 @@ public class mcMMO extends JavaPlugin { /** * Things to be run when the plugin is enabled. */ + @Override public void onEnable() { p = this; setupFilePaths(); @@ -238,6 +239,7 @@ public class mcMMO extends JavaPlugin { /** * Things to be run when the plugin is disabled. */ + @Override public void onDisable() { //Make sure to save player information if the server shuts down for (PlayerProfile x : Users.getProfiles().values()) { diff --git a/src/main/java/com/gmail/nossr50/party/Party.java b/src/main/java/com/gmail/nossr50/party/Party.java index 23fb9d546..76609d200 100644 --- a/src/main/java/com/gmail/nossr50/party/Party.java +++ b/src/main/java/com/gmail/nossr50/party/Party.java @@ -74,7 +74,7 @@ public class Party { * Get the number of players in this player's party. * * @param player The player to check - * @param players A list of players to + * @param players A list of players to * @return the number of players in this player's party */ public int partyCount(Player player) { diff --git a/src/main/java/com/gmail/nossr50/runnables/BleedTimer.java b/src/main/java/com/gmail/nossr50/runnables/BleedTimer.java index f5c27d27b..18e0f86e9 100644 --- a/src/main/java/com/gmail/nossr50/runnables/BleedTimer.java +++ b/src/main/java/com/gmail/nossr50/runnables/BleedTimer.java @@ -84,7 +84,7 @@ public class BleedTimer implements Runnable { /** * Instantly Bleed out a LivingEntity - * + * * @param entity LivingEntity to bleed out */ public static void bleedOut(LivingEntity entity) { @@ -96,7 +96,7 @@ public class BleedTimer implements Runnable { /** * Remove a LivingEntity from the bleedList if it is in it - * + * * @param entity LivingEntity to remove */ public static void remove(LivingEntity entity) { @@ -168,7 +168,7 @@ public class BleedTimer implements Runnable { /** * Check to see if a LivingEntity is in the bleedList - * + * * @param entity LivingEntity to check if in the bleedList * @return true if in the list, false if not */ diff --git a/src/main/java/com/gmail/nossr50/skills/combat/Swords.java b/src/main/java/com/gmail/nossr50/skills/combat/Swords.java index 314da5b6e..97d148bee 100644 --- a/src/main/java/com/gmail/nossr50/skills/combat/Swords.java +++ b/src/main/java/com/gmail/nossr50/skills/combat/Swords.java @@ -61,7 +61,7 @@ public class Swords { else { bleedTicks = 2; } - + BleedTimer.add(defender, bleedTicks); attacker.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding")); } diff --git a/src/main/java/com/gmail/nossr50/skills/combat/Taming.java b/src/main/java/com/gmail/nossr50/skills/combat/Taming.java index 2a33c41a8..507fd5ff5 100644 --- a/src/main/java/com/gmail/nossr50/skills/combat/Taming.java +++ b/src/main/java/com/gmail/nossr50/skills/combat/Taming.java @@ -36,7 +36,7 @@ public class Taming { * * @param PPo The PlayerProfile of the wolf's owner * @param theWolf The wolf using the ability - * @param damage The damage being absorbed by the wolf + * @param damage The damage being absorbed by the wolf */ public static void fastFoodService (PlayerProfile PPo, Wolf theWolf, int damage) { final int SKILL_ACTIVATION_LEVEL = 50; diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java b/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java index 5334bf0d9..c646bf285 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java @@ -276,7 +276,7 @@ public class Fishing { case SHEEP: Sheep sheep = (Sheep) le; - + if (!sheep.isSheared()) { Wool wool = new Wool(); wool.setColor(sheep.getColor()); diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java index 380af222b..927f19e5c 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java @@ -48,10 +48,10 @@ public class Herbalism { greenTerraConvert(player, block); } } - + public static void greenTerraConvert(Player player, Block block) { Material type = block.getType(); - + if (Misc.blockBreakSimulate(block, player, false)) { if (Config.getInstance().getHerbalismGreenThumbSmoothbrickToMossy() && type == Material.SMOOTH_BRICK && block.getData() == 0) { block.setTypeIdAndData(block.getTypeId(), (byte) 1, false); //Set type of the brick to mossy, force the client update diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java b/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java index bd72cf305..c5321f824 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java @@ -213,7 +213,7 @@ public class Mining { PlayerProfile PP = Users.getProfile(player); Material type = block.getType(); int xp = 0; - + switch (type) { case COAL_ORE: xp += Config.getInstance().getMiningXPCoalOre(); diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java b/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java index c83895606..3b8952166 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java @@ -100,7 +100,7 @@ public class WoodCutting { ItemStack spruce = new ItemStack(Material.LOG, 1, (short) 0, TreeSpecies.REDWOOD.getData()); ItemStack birch = new ItemStack(Material.LOG, 1, (short) 0, TreeSpecies.BIRCH.getData()); ItemStack jungle = new ItemStack(Material.LOG, 1, (short) 0, TreeSpecies.JUNGLE.getData()); - + for (Block x : toBeFelled) { if (Misc.blockBreakSimulate(x, player, true)) { if (Config.getInstance().getBlockModsEnabled()) { @@ -215,7 +215,7 @@ public class WoodCutting { */ private static void processTreeFelling(Block currentBlock, ArrayList toBeFelled) { Material type = currentBlock.getType(); - + if (toBeFelled.size() >= Config.getInstance().getTreeFellerThreshold()) { return; } diff --git a/src/main/java/com/gmail/nossr50/spout/SpoutStuff.java b/src/main/java/com/gmail/nossr50/spout/SpoutStuff.java index 0836f2d62..1ec2cf141 100644 --- a/src/main/java/com/gmail/nossr50/spout/SpoutStuff.java +++ b/src/main/java/com/gmail/nossr50/spout/SpoutStuff.java @@ -179,7 +179,7 @@ public class SpoutStuff { files.add(new File(hudStandardDirectory + Misc.getCapitalized(y.toString()) + ".png")); files.add(new File(hudRetroDirectory + Misc.getCapitalized(y.toString()) + "_r.png")); } - + /* Blank icons */ files.add(new File(hudStandardDirectory + "Icon.png")); files.add(new File(hudRetroDirectory + "Icon_r.png")); diff --git a/src/main/java/com/gmail/nossr50/util/Combat.java b/src/main/java/com/gmail/nossr50/util/Combat.java index 9f302b818..5472abf6b 100644 --- a/src/main/java/com/gmail/nossr50/util/Combat.java +++ b/src/main/java/com/gmail/nossr50/util/Combat.java @@ -113,7 +113,7 @@ public class Combat { if (permInstance.impact(attacker)) { Axes.impact(attacker, target, event); } - + if (PPa.getAbilityMode(AbilityType.SKULL_SPLIITER) && permInstance.skullSplitter(attacker)) { applyAbilityAoE(attacker, target, event.getDamage() / 2, plugin, SkillType.AXES); } @@ -319,7 +319,7 @@ public class Combat { */ private static void dealDamage(LivingEntity target, int dmg, DamageCause cause) { if (configInstance.getEventCallbackEnabled()) { - EntityDamageEvent ede = (EntityDamageEvent) new FakeEntityDamageEvent(target, cause, dmg); + EntityDamageEvent ede = new FakeEntityDamageEvent(target, cause, dmg); mcMMO.p.getServer().getPluginManager().callEvent(ede); if (ede.isCancelled()) { @@ -342,7 +342,7 @@ public class Combat { */ private static void dealDamage(LivingEntity target, int dmg, Player attacker) { if (configInstance.getEventCallbackEnabled()) { - EntityDamageEvent ede = (EntityDamageByEntityEvent) new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg); + EntityDamageEvent ede = new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg); mcMMO.p.getServer().getPluginManager().callEvent(ede); if (ede.isCancelled()) { diff --git a/src/main/java/com/gmail/nossr50/util/Database.java b/src/main/java/com/gmail/nossr50/util/Database.java index 87ecfea80..9182f99a1 100644 --- a/src/main/java/com/gmail/nossr50/util/Database.java +++ b/src/main/java/com/gmail/nossr50/util/Database.java @@ -222,23 +222,23 @@ public class Database { } return result; } - + /** * Get connection status - * + * * @return the boolean value for whether or not we are connected */ public static boolean isConnected() { if(conn == null) return false; - + try { return conn.isValid(3); } catch (SQLException e) { return false; } } - + /** * Schedules a Sync Delayed Task with the Bukkit Scheduler to attempt reconnection after a minute has elapsed * This will check for a connection being present or not to prevent unneeded reconnection attempts diff --git a/src/main/java/com/gmail/nossr50/util/Hardcore.java b/src/main/java/com/gmail/nossr50/util/Hardcore.java index ffdb4447b..6e8eec21a 100644 --- a/src/main/java/com/gmail/nossr50/util/Hardcore.java +++ b/src/main/java/com/gmail/nossr50/util/Hardcore.java @@ -11,56 +11,56 @@ public class Hardcore { public static void invokeStatPenalty(Player player) { if(Config.getInstance().getHardcoreDeathStatPenaltyPercentage() <= 0) return; - + PlayerProfile PP = Users.getProfile(player); - + int totalCount = 0; - + for(SkillType st : SkillType.values()) { - + if(st.equals(SkillType.ALL)) continue; - + int newValue = (int) (PP.getSkillLevel(st) - (PP.getSkillLevel(st) * (Config.getInstance().getHardcoreDeathStatPenaltyPercentage() * 0.01D))); - + if(newValue < 0) newValue = 0; - + totalCount+=PP.getSkillLevel(st)-newValue; - + PP.modifySkill(st, newValue); } - + player.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.DARK_RED+"You've lost "+ChatColor.BLUE+totalCount+ChatColor.DARK_RED+" from death."); } - + public static void invokeVampirism(Player killer, Player defender) { if(Config.getInstance().getHardcoreVampirismStatLeechPercentage() <= 0) return; - + PlayerProfile PPk = Users.getProfile(killer); PlayerProfile PPd = Users.getProfile(defender); - + int totalCount = 0; - + for(SkillType st : SkillType.values()) { if(st.equals(SkillType.ALL)) continue; - + if(PPd.getSkillLevel(st) <= 0 || PPd.getSkillLevel(st) < (PPk.getSkillLevel(st)/2)) continue; - + int newValue = (int) (PPd.getSkillLevel(st) * (Config.getInstance().getHardcoreVampirismStatLeechPercentage() * 0.01D)); - + if(newValue <= 0) newValue = 1; - + totalCount+=1; - + PPk.modifySkill(st, newValue+PPk.getSkillLevel(st)); PPd.modifySkill(st, PPd.getSkillLevel(st)-newValue); } - + if(totalCount >= 1) { killer.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.DARK_AQUA+"You've stolen "+ChatColor.BLUE+totalCount+ChatColor.DARK_AQUA+" levels from that player."); defender.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.YELLOW+killer.getName()+ChatColor.DARK_RED+" has stolen "+ChatColor.BLUE+totalCount+ChatColor.DARK_RED+" levels from you!"); diff --git a/src/main/java/com/gmail/nossr50/util/ItemChecks.java b/src/main/java/com/gmail/nossr50/util/ItemChecks.java index 54116e536..3c54c2d93 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemChecks.java +++ b/src/main/java/com/gmail/nossr50/util/ItemChecks.java @@ -74,7 +74,7 @@ public class ItemChecks { * * @param is Item to check * @return true if the item is a shovel, false otherwise - */ + */ public static boolean isShovel(ItemStack is) { switch (is.getType()) { case DIAMOND_SPADE: diff --git a/src/main/java/com/gmail/nossr50/util/Metrics.java b/src/main/java/com/gmail/nossr50/util/Metrics.java index c8da67e25..d1adba969 100644 --- a/src/main/java/com/gmail/nossr50/util/Metrics.java +++ b/src/main/java/com/gmail/nossr50/util/Metrics.java @@ -116,7 +116,7 @@ public class Metrics { * The plugin configuration file */ private final YamlConfiguration configuration; - + /** * The plugin configuration file */ @@ -225,6 +225,7 @@ public class Metrics { private boolean firstPost = true; + @Override public void run() { try { // This has to be synchronized or it can collide with the disable method. diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index 8037980a4..0dd5a6429 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -96,7 +96,7 @@ public class Misc { return false; } } - + /** * Simulate a block break event. * diff --git a/src/main/java/com/gmail/nossr50/util/Page.java b/src/main/java/com/gmail/nossr50/util/Page.java index e2e84fd43..00ea20b75 100644 --- a/src/main/java/com/gmail/nossr50/util/Page.java +++ b/src/main/java/com/gmail/nossr50/util/Page.java @@ -9,7 +9,7 @@ import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.LocaleLoader; public class Page { - + public static int getTotalPageNumber(String address) { String[] addressSplit = LocaleLoader.getString(address).split("\n"); @@ -18,24 +18,24 @@ public class Page { else return (addressSplit.length/8)+1; } - + public static ArrayList grabPageContents(String header, String address, int pagenum) { int pageIndexStart = 0; - + //Determine what string to start at if(pagenum > 1) { pageIndexStart = 8*(pagenum-1); } - + ArrayList allStrings = new ArrayList(); String split[] = LocaleLoader.getString(address).split("\n"); - + allStrings.add(ChatColor.GOLD+"-="+ChatColor.GREEN+header+ChatColor.GOLD+"=-"); //So stylish - + //Add targeted strings - + while(allStrings.size() < 9) { if(pageIndexStart+allStrings.size() > split.length) @@ -43,11 +43,11 @@ public class Page { else allStrings.add(split[pageIndexStart+allStrings.size()-1]); } - + allStrings.add("Page "+pagenum+" of "+getTotalPageNumber(address)); return allStrings; } - + public static void clearChat(Player player) { for(int x = 0; x < 20; x++) @@ -55,7 +55,7 @@ public class Page { player.sendMessage(""); } } - + public static void grabGuidePageForSkill(SkillType skilltype, Player player, String[] args) { String capitalized = Misc.getCapitalized(skilltype.toString()); @@ -64,9 +64,9 @@ public class Page { { if(args[0].equals("?")) { - + String address = "Guides."+capitalized; - + if(args.length > 1 && Misc.isInt(args[1]) && Misc.getInt(args[1]) <= Page.getTotalPageNumber(address)) { Page.clearChat(player); @@ -82,7 +82,7 @@ public class Page { player.sendMessage(target); } } - else if(args.length > 1 && Misc.getInt(args[1]) > Page.getTotalPageNumber(address)) + else if(args.length > 1 && Misc.getInt(args[1]) > Page.getTotalPageNumber(address)) { player.sendMessage("That page doesn't exist, there are only "+Page.getTotalPageNumber(address)+" total pages"); //TODO: Needs more locale. } diff --git a/src/main/java/com/gmail/nossr50/util/Users.java b/src/main/java/com/gmail/nossr50/util/Users.java index 1bb7c0bbd..ab12ac578 100644 --- a/src/main/java/com/gmail/nossr50/util/Users.java +++ b/src/main/java/com/gmail/nossr50/util/Users.java @@ -20,7 +20,7 @@ public class Users { * Load users. */ public static void loadUsers() { - + new File(plugin.flatFileDirectory).mkdir(); new File(plugin.leaderboardDirectory).mkdir(); diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java index 721dd013c..bb339b969 100644 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java @@ -18,6 +18,7 @@ import com.gmail.nossr50.mcMMO; public class HashChunkletManager implements ChunkletManager { private HashMap store = new HashMap(); + @Override public void chunkLoaded(int cx, int cz, World world) { File dataDir = new File(world.getWorldFolder(), "mcmmo_data"); File cxDir = new File(dataDir, "" + cx); @@ -38,6 +39,7 @@ public class HashChunkletManager implements ChunkletManager { } } + @Override public void chunkUnloaded(int cx, int cz, World world) { File dataDir = new File(world.getWorldFolder(), "mcmmo_data"); @@ -56,6 +58,7 @@ public class HashChunkletManager implements ChunkletManager { } } + @Override public void saveWorld(World world) { String worldName = world.getName(); File dataDir = new File(world.getWorldFolder(), "mcmmo_data"); @@ -74,6 +77,7 @@ public class HashChunkletManager implements ChunkletManager { } } + @Override public void unloadWorld(World world) { saveWorld(world); @@ -87,12 +91,14 @@ public class HashChunkletManager implements ChunkletManager { } } + @Override public void saveAll() { for(World world : Bukkit.getWorlds()) { saveWorld(world); } } + @Override public void unloadAll() { saveAll(); for(World world : Bukkit.getWorlds()) { @@ -100,6 +106,7 @@ public class HashChunkletManager implements ChunkletManager { } } + @Override public boolean isTrue(int x, int y, int z, World world) { int cx = x / 16; int cz = z / 16; @@ -114,10 +121,12 @@ public class HashChunkletManager implements ChunkletManager { return check.isTrue(ix, iy, iz); } + @Override public boolean isTrue(Block block) { return isTrue(block.getX(), block.getY(), block.getZ(), block.getWorld()); } + @Override public void setTrue(int x, int y, int z, World world) { int cx = x / 16; int cz = z / 16; @@ -137,10 +146,12 @@ public class HashChunkletManager implements ChunkletManager { cStore.setTrue(ix, iy, iz); } + @Override public void setTrue(Block block) { setTrue(block.getX(), block.getY(), block.getZ(), block.getWorld()); } + @Override public void setFalse(int x, int y, int z, World world) { int cx = x / 16; int cz = z / 16; @@ -159,10 +170,12 @@ public class HashChunkletManager implements ChunkletManager { cStore.setFalse(ix, iy, iz); } + @Override public void setFalse(Block block) { setFalse(block.getX(), block.getY(), block.getZ(), block.getWorld()); } + @Override public void cleanUp() { for(String key : store.keySet()) { if(store.get(key).isEmpty()) { diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/PrimitiveChunkletStore.java b/src/main/java/com/gmail/nossr50/util/blockmeta/PrimitiveChunkletStore.java index 64d9492f0..f3421189e 100644 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/PrimitiveChunkletStore.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/PrimitiveChunkletStore.java @@ -6,18 +6,22 @@ public class PrimitiveChunkletStore implements ChunkletStore { /** X, Z, Y */ private boolean[][][] store = new boolean[16][16][64]; + @Override public boolean isTrue(int x, int y, int z) { return store[x][z][y]; } + @Override public void setTrue(int x, int y, int z) { store[x][z][y] = true; } + @Override public void setFalse(int x, int y, int z) { store[x][z][y] = false; } + @Override public boolean isEmpty() { for(int x = 0; x < 16; x++) { for(int z = 0; z < 16; z++) { diff --git a/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java b/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java index dbcdbaf72..fcd0e0bf3 100644 --- a/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java +++ b/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java @@ -120,7 +120,7 @@ public class ZipLibrary { FileInputStream fis = new FileInputStream(file); byte[] buffer = new byte[4092]; int byteCount = 0; - + while ((byteCount = fis.read(buffer)) != -1) { zos.write(buffer, 0, byteCount); }