From 8b9432d1d9a7ab39edf947e0073f3c29ce5d4b18 Mon Sep 17 00:00:00 2001 From: gmcferrin Date: Wed, 9 Jan 2013 22:43:21 -0500 Subject: [PATCH] So many useless else statements... --- .../commands/general/InspectCommand.java | 63 ++++--- .../nossr50/commands/mc/MctopCommand.java | 65 ++++--- .../nossr50/commands/party/InviteCommand.java | 12 +- .../nossr50/commands/party/PartyCommand.java | 20 +-- .../java/com/gmail/nossr50/config/Config.java | 5 +- .../gmail/nossr50/config/TreasuresConfig.java | 9 +- .../nossr50/config/repair/RepairConfig.java | 9 +- .../gmail/nossr50/datatypes/McMMOPlayer.java | 10 +- .../nossr50/datatypes/PlayerProfile.java | 167 +++++++++--------- .../gmail/nossr50/datatypes/SkillType.java | 5 +- .../nossr50/listeners/BlockListener.java | 9 +- .../BlockStoreConversionZDirectory.java | 84 ++++----- .../com/gmail/nossr50/skills/combat/Axes.java | 5 +- .../nossr50/skills/gathering/WoodCutting.java | 5 +- .../mining/SuperBreakerEventHandler.java | 72 ++++---- .../skills/repair/SimpleRepairManager.java | 5 +- .../skills/taming/BeastLoreEventHandler.java | 5 +- .../nossr50/skills/taming/TamingManager.java | 15 +- .../skills/unarmed/UnarmedManager.java | 5 +- .../com/gmail/nossr50/util/BlockChecks.java | 45 ++--- .../com/gmail/nossr50/util/ItemChecks.java | 20 +-- .../com/gmail/nossr50/util/Leaderboard.java | 5 +- .../java/com/gmail/nossr50/util/Metrics.java | 21 ++- .../java/com/gmail/nossr50/util/Misc.java | 30 ++-- .../com/gmail/nossr50/util/ModChecks.java | 10 +- .../java/com/gmail/nossr50/util/Page.java | 4 +- .../java/com/gmail/nossr50/util/Skills.java | 25 ++- .../blockmeta/ChunkletManagerFactory.java | 4 +- .../util/blockmeta/HashChunkletManager.java | 10 +- .../chunkmeta/ChunkManagerFactory.java | 4 +- .../blockmeta/chunkmeta/HashChunkManager.java | 4 +- .../shatt/backup/ZipLibrary.java | 5 +- .../chunkstore/mcMMOSimpleRegionFile.java | 8 +- 33 files changed, 358 insertions(+), 407 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java b/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java index b413d2c97..b704047a7 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java @@ -43,42 +43,41 @@ public class InspectCommand implements CommandExecutor { return true; } - else { - if (sender instanceof Player && !sender.isOp() && !Permissions.inspectOfflineBypass((Player) sender)) { - sender.sendMessage(LocaleLoader.getString("Inspect.Offline")); - return true; - } - - PlayerProfile profile = new PlayerProfile(args[0], false); //Temporary Profile - - if (!profile.isLoaded()) { - sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); - return true; - } - - sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", new Object[] { args[0] })); - - sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering")); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION) })); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING) })); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM) })); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING) })); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Woodcutting.Listener"), profile.getSkillLevel(SkillType.WOODCUTTING), profile.getSkillXpLevel(SkillType.WOODCUTTING), profile.getXpToLevel(SkillType.WOODCUTTING) })); - - sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat")); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES) })); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY) })); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS) })); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING) })); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Unarmed.Listener"), profile.getSkillLevel(SkillType.UNARMED), profile.getSkillXpLevel(SkillType.UNARMED), profile.getXpToLevel(SkillType.UNARMED) })); - - sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc")); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS) })); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR) })); + if (sender instanceof Player && !sender.isOp() && !Permissions.inspectOfflineBypass((Player) sender)) { + sender.sendMessage(LocaleLoader.getString("Inspect.Offline")); return true; } + PlayerProfile profile = new PlayerProfile(args[0], false); //Temporary Profile + + if (!profile.isLoaded()) { + sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); + return true; + } + + sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", new Object[] { args[0] })); + + sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering")); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION) })); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING) })); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM) })); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING) })); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Woodcutting.Listener"), profile.getSkillLevel(SkillType.WOODCUTTING), profile.getSkillXpLevel(SkillType.WOODCUTTING), profile.getXpToLevel(SkillType.WOODCUTTING) })); + + sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat")); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES) })); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY) })); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS) })); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING) })); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Unarmed.Listener"), profile.getSkillLevel(SkillType.UNARMED), profile.getSkillXpLevel(SkillType.UNARMED), profile.getXpToLevel(SkillType.UNARMED) })); + + sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc")); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS) })); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR) })); + + return true; + default: sender.sendMessage(usage); return true; 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 ad6fbe07c..5d392142c 100644 --- a/src/main/java/com/gmail/nossr50/commands/mc/MctopCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/mc/MctopCommand.java @@ -62,46 +62,45 @@ public class MctopCommand implements CommandExecutor { return true; } } - else { - String powerlevel = "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing"; - switch (args.length) { - case 0: - sqlDisplay(1, powerlevel, sender); - return true; + String powerlevel = "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing"; - case 1: - if (Misc.isInt(args[0])) { - sqlDisplay(Integer.valueOf(args[0]), powerlevel, sender); - } - else if (Skills.isSkill(args[0])) { - sqlDisplay(1, args[0].toLowerCase(), sender); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); - } + switch (args.length) { + case 0: + sqlDisplay(1, powerlevel, sender); + return true; - return true; + case 1: + if (Misc.isInt(args[0])) { + sqlDisplay(Integer.valueOf(args[0]), powerlevel, sender); + } + else if (Skills.isSkill(args[0])) { + sqlDisplay(1, args[0].toLowerCase(), sender); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); + } - case 2: - if (!Skills.isSkill(args[0])) { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); - return true; - } + return true; - if (Misc.isInt(args[1])) { - sqlDisplay(Integer.valueOf(args[1]), args[0].toLowerCase(), sender); - } - else { - sender.sendMessage(usage); - } - - return true; - - default: - sender.sendMessage(usage); + case 2: + if (!Skills.isSkill(args[0])) { + sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); return true; } + + if (Misc.isInt(args[1])) { + sqlDisplay(Integer.valueOf(args[1]), args[0].toLowerCase(), sender); + } + else { + sender.sendMessage(usage); + } + + return true; + + default: + sender.sendMessage(usage); + return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/InviteCommand.java b/src/main/java/com/gmail/nossr50/commands/party/InviteCommand.java index e808ae01e..86f34682a 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/InviteCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/InviteCommand.java @@ -56,16 +56,14 @@ public class InviteCommand implements CommandExecutor { target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1")); return true; } - else { - player.sendMessage(LocaleLoader.getString("Party.Locked")); - return true; - } - } - else { - player.sendMessage(LocaleLoader.getString("Party.Player.Invalid")); + + player.sendMessage(LocaleLoader.getString("Party.Locked")); return true; } + player.sendMessage(LocaleLoader.getString("Party.Player.Invalid")); + return true; + default: sender.sendMessage(usage); return true; 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 9af05758c..986881d97 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java @@ -186,18 +186,17 @@ public class PartyCommand implements CommandExecutor { player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]})); return true; } - else { - String partyName = party.getName(); - McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, null, EventReason.KICKED_FROM_PARTY); - plugin.getServer().getPluginManager().callEvent(event); + String partyName = party.getName(); + McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, null, EventReason.KICKED_FROM_PARTY); - if (event.isCancelled()) { - return true; - } + plugin.getServer().getPluginManager().callEvent(event); - partyManagerInstance.removeFromParty(args[1], party); + if (event.isCancelled()) { + return true; } + + partyManagerInstance.removeFromParty(args[1], party); } else { player.sendMessage(LocaleLoader.getString("Party.NotOwner")); @@ -209,9 +208,8 @@ public class PartyCommand implements CommandExecutor { player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]})); return true; } - else { - partyManagerInstance.setPartyLeader(args[1], party); - } + + partyManagerInstance.setPartyLeader(args[1], party); } } else { diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index e242d7e7a..2d2aac6c7 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -48,9 +48,8 @@ public class Config extends ConfigLoader { if (getStringIncludingInts(config, "MySQL.Database.User_Password") != null) { return getStringIncludingInts(config, "MySQL.Database.User_Password"); } - else { - return ""; - } + + return ""; } private static String getStringIncludingInts(ConfigurationSection cfg, String key) { diff --git a/src/main/java/com/gmail/nossr50/config/TreasuresConfig.java b/src/main/java/com/gmail/nossr50/config/TreasuresConfig.java index e412a7caf..cbe0b50a5 100644 --- a/src/main/java/com/gmail/nossr50/config/TreasuresConfig.java +++ b/src/main/java/com/gmail/nossr50/config/TreasuresConfig.java @@ -265,11 +265,10 @@ public class TreasuresConfig extends ConfigLoader{ if (issues.isEmpty()) { return true; } - else { - for (String issue : issues) { - plugin.getLogger().warning(issue); - } - return false; + + for (String issue : issues) { + plugin.getLogger().warning(issue); } + return false; } } diff --git a/src/main/java/com/gmail/nossr50/config/repair/RepairConfig.java b/src/main/java/com/gmail/nossr50/config/repair/RepairConfig.java index fac81f730..a991b2b47 100644 --- a/src/main/java/com/gmail/nossr50/config/repair/RepairConfig.java +++ b/src/main/java/com/gmail/nossr50/config/repair/RepairConfig.java @@ -99,11 +99,10 @@ public class RepairConfig extends ConfigLoader { if (issues.isEmpty()) { return true; } - else { - for (String issue : issues) { - plugin.getLogger().warning(issue); - } - return false; + + for (String issue : issues) { + plugin.getLogger().warning(issue); } + return false; } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java index 4b1d189e7..c6c3d9a84 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java @@ -209,9 +209,8 @@ public class McMMOPlayer { if (invite != null) { return true; } - else { - return false; - } + + return false; } public void setParty(Party party) { @@ -226,9 +225,8 @@ public class McMMOPlayer { if (party != null) { return true; } - else { - return false; - } + + return false; } public void removeParty() { diff --git a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java index db50ba269..f9cb87fb2 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -96,89 +96,88 @@ public class PlayerProfile { if (userId == 0) { return false; } - else { - HashMap> huds = database.read("SELECT hudtype FROM " + tablePrefix + "huds WHERE user_id = " + userId); - if (huds.get(1) == null) { - database.write("INSERT INTO " + tablePrefix + "huds (user_id) VALUES (" + userId + ")"); - } - else { - for (HudType type : HudType.values()) { - if (type.toString().equals(huds.get(1).get(0))) { - hudType = type; - } + HashMap> huds = database.read("SELECT hudtype FROM " + tablePrefix + "huds WHERE user_id = " + userId); + + if (huds.get(1) == null) { + database.write("INSERT INTO " + tablePrefix + "huds (user_id) VALUES (" + userId + ")"); + } + else { + for (HudType type : HudType.values()) { + if (type.toString().equals(huds.get(1).get(0))) { + hudType = type; } } - - /* - * I'm still learning MySQL, this is a fix for adding a new table - * its not pretty but it works - */ - HashMap> cooldowns = database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM " + tablePrefix + "cooldowns WHERE user_id = " + userId); - ArrayList cooldownValues = cooldowns.get(1); - - if (cooldownValues == null) { - database.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")"); - mcMMO.p.getLogger().warning(playerName + "does not exist in the cooldown table. Their cooldowns will be reset."); - } - else { - skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(cooldownValues.get(0))); - skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(cooldownValues.get(1))); - skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(cooldownValues.get(2))); - skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(cooldownValues.get(3))); - skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(cooldownValues.get(4))); - skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(cooldownValues.get(5))); - skillsDATS.put(AbilityType.SKULL_SPLIITER, Integer.valueOf(cooldownValues.get(6))); - skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(cooldownValues.get(7))); - } - - HashMap> stats = database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "skills WHERE user_id = " + userId); - ArrayList statValues = stats.get(1); - - if (statValues == null) { - database.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")"); - mcMMO.p.getLogger().warning(playerName + "does not exist in the skills table. Their stats will be reset."); - } - else { - skills.put(SkillType.TAMING, Integer.valueOf(statValues.get(0))); - skills.put(SkillType.MINING, Integer.valueOf(statValues.get(1))); - skills.put(SkillType.REPAIR, Integer.valueOf(statValues.get(2))); - skills.put(SkillType.WOODCUTTING, Integer.valueOf(statValues.get(3))); - skills.put(SkillType.UNARMED, Integer.valueOf(statValues.get(4))); - skills.put(SkillType.HERBALISM, Integer.valueOf(statValues.get(5))); - skills.put(SkillType.EXCAVATION, Integer.valueOf(statValues.get(6))); - skills.put(SkillType.ARCHERY, Integer.valueOf(statValues.get(7))); - skills.put(SkillType.SWORDS, Integer.valueOf(statValues.get(8))); - skills.put(SkillType.AXES, Integer.valueOf(statValues.get(9))); - skills.put(SkillType.ACROBATICS, Integer.valueOf(statValues.get(10))); - skills.put(SkillType.FISHING, Integer.valueOf(statValues.get(11))); - } - - HashMap> experience = database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "experience WHERE user_id = " + userId); - ArrayList experienceValues = experience.get(1); - - if (experienceValues == null) { - database.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")"); - mcMMO.p.getLogger().warning(playerName + "does not exist in the experience table. Their experience will be reset."); - } - else { - skillsXp.put(SkillType.TAMING, Integer.valueOf(experienceValues.get(0))); - skillsXp.put(SkillType.MINING, Integer.valueOf(experienceValues.get(1))); - skillsXp.put(SkillType.REPAIR, Integer.valueOf(experienceValues.get(2))); - skillsXp.put(SkillType.WOODCUTTING, Integer.valueOf(experienceValues.get(3))); - skillsXp.put(SkillType.UNARMED, Integer.valueOf(experienceValues.get(4))); - skillsXp.put(SkillType.HERBALISM, Integer.valueOf(experienceValues.get(5))); - skillsXp.put(SkillType.EXCAVATION, Integer.valueOf(experienceValues.get(6))); - skillsXp.put(SkillType.ARCHERY, Integer.valueOf(experienceValues.get(7))); - skillsXp.put(SkillType.SWORDS, Integer.valueOf(experienceValues.get(8))); - skillsXp.put(SkillType.AXES, Integer.valueOf(experienceValues.get(9))); - skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(experienceValues.get(10))); - skillsXp.put(SkillType.FISHING, Integer.valueOf(experienceValues.get(11))); - } - - loaded = true; - return true; } + + /* + * I'm still learning MySQL, this is a fix for adding a new table + * its not pretty but it works + */ + HashMap> cooldowns = database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM " + tablePrefix + "cooldowns WHERE user_id = " + userId); + ArrayList cooldownValues = cooldowns.get(1); + + if (cooldownValues == null) { + database.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")"); + mcMMO.p.getLogger().warning(playerName + "does not exist in the cooldown table. Their cooldowns will be reset."); + } + else { + skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(cooldownValues.get(0))); + skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(cooldownValues.get(1))); + skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(cooldownValues.get(2))); + skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(cooldownValues.get(3))); + skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(cooldownValues.get(4))); + skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(cooldownValues.get(5))); + skillsDATS.put(AbilityType.SKULL_SPLIITER, Integer.valueOf(cooldownValues.get(6))); + skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(cooldownValues.get(7))); + } + + HashMap> stats = database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "skills WHERE user_id = " + userId); + ArrayList statValues = stats.get(1); + + if (statValues == null) { + database.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")"); + mcMMO.p.getLogger().warning(playerName + "does not exist in the skills table. Their stats will be reset."); + } + else { + skills.put(SkillType.TAMING, Integer.valueOf(statValues.get(0))); + skills.put(SkillType.MINING, Integer.valueOf(statValues.get(1))); + skills.put(SkillType.REPAIR, Integer.valueOf(statValues.get(2))); + skills.put(SkillType.WOODCUTTING, Integer.valueOf(statValues.get(3))); + skills.put(SkillType.UNARMED, Integer.valueOf(statValues.get(4))); + skills.put(SkillType.HERBALISM, Integer.valueOf(statValues.get(5))); + skills.put(SkillType.EXCAVATION, Integer.valueOf(statValues.get(6))); + skills.put(SkillType.ARCHERY, Integer.valueOf(statValues.get(7))); + skills.put(SkillType.SWORDS, Integer.valueOf(statValues.get(8))); + skills.put(SkillType.AXES, Integer.valueOf(statValues.get(9))); + skills.put(SkillType.ACROBATICS, Integer.valueOf(statValues.get(10))); + skills.put(SkillType.FISHING, Integer.valueOf(statValues.get(11))); + } + + HashMap> experience = database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "experience WHERE user_id = " + userId); + ArrayList experienceValues = experience.get(1); + + if (experienceValues == null) { + database.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")"); + mcMMO.p.getLogger().warning(playerName + "does not exist in the experience table. Their experience will be reset."); + } + else { + skillsXp.put(SkillType.TAMING, Integer.valueOf(experienceValues.get(0))); + skillsXp.put(SkillType.MINING, Integer.valueOf(experienceValues.get(1))); + skillsXp.put(SkillType.REPAIR, Integer.valueOf(experienceValues.get(2))); + skillsXp.put(SkillType.WOODCUTTING, Integer.valueOf(experienceValues.get(3))); + skillsXp.put(SkillType.UNARMED, Integer.valueOf(experienceValues.get(4))); + skillsXp.put(SkillType.HERBALISM, Integer.valueOf(experienceValues.get(5))); + skillsXp.put(SkillType.EXCAVATION, Integer.valueOf(experienceValues.get(6))); + skillsXp.put(SkillType.ARCHERY, Integer.valueOf(experienceValues.get(7))); + skillsXp.put(SkillType.SWORDS, Integer.valueOf(experienceValues.get(8))); + skillsXp.put(SkillType.AXES, Integer.valueOf(experienceValues.get(9))); + skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(experienceValues.get(10))); + skillsXp.put(SkillType.FISHING, Integer.valueOf(experienceValues.get(11))); + } + + loaded = true; + return true; } public void addMySQLPlayer() { @@ -1175,9 +1174,8 @@ public class PlayerProfile { if (invite != null) { return true; } - else { - return false; - } + + return false; } public void setParty(Party party) { @@ -1193,9 +1191,8 @@ public class PlayerProfile { if (party != null) { return true; } - else { - return false; - } + + return false; } public void removeParty() { diff --git a/src/main/java/com/gmail/nossr50/datatypes/SkillType.java b/src/main/java/com/gmail/nossr50/datatypes/SkillType.java index 658315b8b..c414f7980 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/SkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/SkillType.java @@ -57,9 +57,8 @@ public enum SkillType { if (maxLevel > 0) { return maxLevel; } - else { - return Integer.MAX_VALUE; - } + + return Integer.MAX_VALUE; } public ToolType getTool() { diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 8c65dbc88..7ec207eaf 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -136,11 +136,10 @@ public class BlockListener implements Listener { if (block.getRelative(0, y, 0).getType().equals(Material.AIR)) { continue; } - else { - Block newLocation = block.getRelative(0, y + 1, 0); - mcMMO.placeStore.setTrue(newLocation); - break; - } + + Block newLocation = block.getRelative(0, y + 1, 0); + mcMMO.placeStore.setTrue(newLocation); + break; } } diff --git a/src/main/java/com/gmail/nossr50/runnables/blockstoreconversion/BlockStoreConversionZDirectory.java b/src/main/java/com/gmail/nossr50/runnables/blockstoreconversion/BlockStoreConversionZDirectory.java index c8a3c1734..fce62fb22 100755 --- a/src/main/java/com/gmail/nossr50/runnables/blockstoreconversion/BlockStoreConversionZDirectory.java +++ b/src/main/java/com/gmail/nossr50/runnables/blockstoreconversion/BlockStoreConversionZDirectory.java @@ -83,61 +83,65 @@ public class BlockStoreConversionZDirectory implements Runnable { this.manager.loadChunk(this.cx, this.cz, this.world); - for(this.y = 0; this.y < (this.world.getMaxHeight() / 64); this.y++) { + for (this.y = 0; this.y < (this.world.getMaxHeight() / 64); this.y++) { this.chunkletName = this.world.getName() + "," + this.cx + "," + this.cz + "," + this.y; this.tempChunklet = this.manager.store.get(this.chunkletName); - if(this.tempChunklet instanceof PrimitiveChunkletStore) + + if (this.tempChunklet instanceof PrimitiveChunkletStore) { this.primitiveChunklet = (PrimitiveChunkletStore) this.tempChunklet; - else if(this.tempChunklet instanceof PrimitiveExChunkletStore) + } + else if (this.tempChunklet instanceof PrimitiveExChunkletStore) { this.primitiveExChunklet = (PrimitiveExChunkletStore) this.tempChunklet; - if(this.tempChunklet == null) { + } + + if (this.tempChunklet == null) { continue; - } else { - this.chunkName = this.world.getName() + "," + this.cx + "," + this.cz; - this.currentChunk = (PrimitiveChunkStore) this.newManager.store.get(this.chunkName); + } - if(this.currentChunk != null) { - this.xPos = this.cx * 16; - this.zPos = this.cz * 16; + this.chunkName = this.world.getName() + "," + this.cx + "," + this.cz; + this.currentChunk = (PrimitiveChunkStore) this.newManager.store.get(this.chunkName); - for(this.x = 0; this.x < 16; this.x++) { - for(this.z = 0; this.z < 16; this.z++) { - this.cxPos = this.xPos + this.x; - this.czPos = this.zPos + this.z; + if (this.currentChunk != null) { + this.xPos = this.cx * 16; + this.zPos = this.cz * 16; - for(this.y2 = (64 * this.y); this.y2 < (64 * this.y + 64); this.y2++) { - try { - if(!this.manager.isTrue(this.cxPos, this.y2, this.czPos, this.world)) - continue; + for (this.x = 0; this.x < 16; this.x++) { + for(this.z = 0; this.z < 16; this.z++) { + this.cxPos = this.xPos + this.x; + this.czPos = this.zPos + this.z; - this.newManager.setTrue(this.cxPos, this.y2, this.czPos, this.world); - } - catch(Exception e) {} + for(this.y2 = (64 * this.y); this.y2 < (64 * this.y + 64); this.y2++) { + try { + if(!this.manager.isTrue(this.cxPos, this.y2, this.czPos, this.world)) + continue; + + this.newManager.setTrue(this.cxPos, this.y2, this.czPos, this.world); } + catch(Exception e) {} } } - continue; } + continue; + } - this.newManager.setTrue(this.cx * 16, 0, this.cz * 16, this.world); - this.newManager.setFalse(this.cx * 16, 0, this.cz * 16, this.world); - this.currentChunk = (PrimitiveChunkStore) this.newManager.store.get(this.chunkName); + this.newManager.setTrue(this.cx * 16, 0, this.cz * 16, this.world); + this.newManager.setFalse(this.cx * 16, 0, this.cz * 16, this.world); + this.currentChunk = (PrimitiveChunkStore) this.newManager.store.get(this.chunkName); - for(this.x = 0; this.x < 16; this.x++) { - for(this.z = 0; this.z < 16; this.z++) { - if(this.primitiveChunklet != null) - this.oldArray = this.primitiveChunklet.store[x][z]; - if(this.primitiveExChunklet != null) - this.oldArray = this.primitiveExChunklet.store[x][z]; - else - return; - this.newArray = this.currentChunk.store[x][z]; - if(this.oldArray.length < 64) - return; - else if(this.newArray.length < ((this.y * 64) + 64)) - return; - System.arraycopy(this.oldArray, 0, this.newArray, (this.y * 64), 64); - } + for(this.x = 0; this.x < 16; this.x++) { + for(this.z = 0; this.z < 16; this.z++) { + if(this.primitiveChunklet != null) + this.oldArray = this.primitiveChunklet.store[x][z]; + if(this.primitiveExChunklet != null) + this.oldArray = this.primitiveExChunklet.store[x][z]; + else + return; + this.newArray = this.currentChunk.store[x][z]; + if(this.oldArray.length < 64) + return; + else if(this.newArray.length < ((this.y * 64) + 64)) + return; + System.arraycopy(this.oldArray, 0, this.newArray, (this.y * 64), 64); } } } diff --git a/src/main/java/com/gmail/nossr50/skills/combat/Axes.java b/src/main/java/com/gmail/nossr50/skills/combat/Axes.java index d451ec83c..dd5313872 100644 --- a/src/main/java/com/gmail/nossr50/skills/combat/Axes.java +++ b/src/main/java/com/gmail/nossr50/skills/combat/Axes.java @@ -211,8 +211,7 @@ public class Axes { if (inventory.getBoots() != null || inventory.getChestplate() != null || inventory.getHelmet() != null || inventory.getLeggings() != null) { return true; } - else { - return false; - } + + return false; } } 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 e50796000..53696e3ee 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java @@ -327,9 +327,8 @@ public class WoodCutting { if ((currentType.equals(Material.LEAVES) || currentType.equals(Material.AIR) || (Config.getInstance().getBlockModsEnabled() && ModChecks.isCustomLeafBlock(currentBlock))) && (newType.equals(Material.LEAVES) || newType.equals(Material.AIR) || (Config.getInstance().getBlockModsEnabled() && ModChecks.isCustomLeafBlock(currentBlock)))) { return true; } - else { - return false; - } + + return false; } /** diff --git a/src/main/java/com/gmail/nossr50/skills/mining/SuperBreakerEventHandler.java b/src/main/java/com/gmail/nossr50/skills/mining/SuperBreakerEventHandler.java index 1bc4f3297..79c1d2e9c 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/SuperBreakerEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/SuperBreakerEventHandler.java @@ -69,47 +69,45 @@ public class SuperBreakerEventHandler { if (ModChecks.getCustomBlock(block).getTier() < tier) { return false; } - else { - return true; - } + + return true; } - else { - switch (blockType) { - case OBSIDIAN: - if (tier < Mining.DIAMOND_TOOL_TIER) { - return false; - } - /* FALL THROUGH */ - case DIAMOND_ORE: - case GLOWING_REDSTONE_ORE: - case GOLD_ORE: - case LAPIS_ORE: - case REDSTONE_ORE: - case EMERALD_ORE: - if (tier < Mining.IRON_TOOL_TIER) { - return false; - } - /* FALL THROUGH */ - - case IRON_ORE: - if (tier < Mining.STONE_TOOL_TIER) { - return false; - } - /* FALL THROUGH */ - - case COAL_ORE: - case ENDER_STONE: - case GLOWSTONE: - case MOSSY_COBBLESTONE: - case NETHERRACK: - case SANDSTONE: - case STONE: - return true; - - default: + switch (blockType) { + case OBSIDIAN: + if (tier < Mining.DIAMOND_TOOL_TIER) { return false; } + /* FALL THROUGH */ + + case DIAMOND_ORE: + case GLOWING_REDSTONE_ORE: + case GOLD_ORE: + case LAPIS_ORE: + case REDSTONE_ORE: + case EMERALD_ORE: + if (tier < Mining.IRON_TOOL_TIER) { + return false; + } + /* FALL THROUGH */ + + case IRON_ORE: + if (tier < Mining.STONE_TOOL_TIER) { + return false; + } + /* FALL THROUGH */ + + case COAL_ORE: + case ENDER_STONE: + case GLOWSTONE: + case MOSSY_COBBLESTONE: + case NETHERRACK: + case SANDSTONE: + case STONE: + return true; + + default: + return false; } } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java b/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java index f3a85ef9f..725fb8b57 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java @@ -187,9 +187,8 @@ public class SimpleRepairManager implements RepairManager { if (inventory.getItem(location).getTypeId() == itemId) { return location; } - else { - return -1; - } + + return -1; } /** diff --git a/src/main/java/com/gmail/nossr50/skills/taming/BeastLoreEventHandler.java b/src/main/java/com/gmail/nossr50/skills/taming/BeastLoreEventHandler.java index 95816498c..c66db5045 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/BeastLoreEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/BeastLoreEventHandler.java @@ -44,8 +44,7 @@ public class BeastLoreEventHandler { if (tamer instanceof Player) { return ((Player) tamer).getName(); } - else { - return "Offline Master"; - } + + return "Offline Master"; } } diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java index 4ceb93b49..7a55739e5 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -195,15 +195,14 @@ public class TamingManager { eventHandler.sendInsufficientAmountMessage(); return; } + + if (eventHandler.nearbyEntityExists()) { + eventHandler.sendFailureMessage(); + } else { - if (eventHandler.nearbyEntityExists()) { - eventHandler.sendFailureMessage(); - } - else { - eventHandler.spawnCreature(); - eventHandler.processResourceCost(); - eventHandler.sendSuccessMessage(); - } + eventHandler.spawnCreature(); + eventHandler.processResourceCost(); + eventHandler.sendSuccessMessage(); } } diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java index b10160002..4cd22c3a1 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -134,9 +134,8 @@ public class UnarmedManager { eventHandler.sendAbilityMessages(); return true; } - else { - return false; - } + + return false; } protected int getSkillLevel() { diff --git a/src/main/java/com/gmail/nossr50/util/BlockChecks.java b/src/main/java/com/gmail/nossr50/util/BlockChecks.java index 5b328fa94..e11509630 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockChecks.java +++ b/src/main/java/com/gmail/nossr50/util/BlockChecks.java @@ -65,9 +65,8 @@ public class BlockChecks { if (customBlocksEnabled && CustomBlocksConfig.getInstance().customItems.contains(item)) { return true; } - else { - return false; - } + + return false; } } @@ -114,9 +113,8 @@ public class BlockChecks { if (block.getTypeId() == Config.getInstance().getRepairAnvilId() || block.getTypeId() == Config.getInstance().getSalvageAnvilId()) { return false; } - else { - return true; - } + + return true; } } @@ -142,9 +140,8 @@ public class BlockChecks { if (customBlocksEnabled && ModChecks.isCustomOreBlock(block)) { return true; } - else { - return false; - } + + return false; } } @@ -198,9 +195,8 @@ public class BlockChecks { if (block.getData() == CropState.RIPE.getData()) { return true; } - else { - return false; - } + + return false; default: ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); @@ -208,9 +204,8 @@ public class BlockChecks { if (customBlocksEnabled && CustomBlocksConfig.getInstance().customHerbalismBlocks.contains(item)) { return true; } - else { - return false; - } + + return false; } } @@ -245,9 +240,8 @@ public class BlockChecks { if (customBlocksEnabled && CustomBlocksConfig.getInstance().customMiningBlocks.contains(item)) { return true; } - else { - return false; - } + + return false; } } @@ -274,9 +268,8 @@ public class BlockChecks { if (customBlocksEnabled && CustomBlocksConfig.getInstance().customExcavationBlocks.contains(item)) { return true; } - else { - return false; - } + + return false; } } @@ -299,9 +292,8 @@ public class BlockChecks { if (customBlocksEnabled && CustomBlocksConfig.getInstance().customWoodcuttingBlocks.contains(item)) { return true; } - else { - return false; - } + + return false; } } @@ -309,8 +301,7 @@ public class BlockChecks { if (block.getType().equals(Material.LOG) || (customBlocksEnabled && ModChecks.isCustomLogBlock(block))) { return true; } - else { - return false; - } + + return false; } } diff --git a/src/main/java/com/gmail/nossr50/util/ItemChecks.java b/src/main/java/com/gmail/nossr50/util/ItemChecks.java index 098a42a9e..5169651da 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemChecks.java +++ b/src/main/java/com/gmail/nossr50/util/ItemChecks.java @@ -172,9 +172,8 @@ public class ItemChecks { if (customArmorEnabled && CustomArmorConfig.getInstance().customHelmetIDs.contains(is.getTypeId())) { return true; } - else { - return false; - } + + return false; } } @@ -196,9 +195,8 @@ public class ItemChecks { if (customArmorEnabled && CustomArmorConfig.getInstance().customChestplateIDs.contains(is.getTypeId())) { return true; } - else { - return false; - } + + return false; } } @@ -220,9 +218,8 @@ public class ItemChecks { if (customArmorEnabled && CustomArmorConfig.getInstance().customLeggingIDs.contains(is.getTypeId())) { return true; } - else { - return false; - } + + return false; } } @@ -244,9 +241,8 @@ public class ItemChecks { if (customArmorEnabled && CustomArmorConfig.getInstance().customBootIDs.contains(is.getTypeId())) { return true; } - else { - return false; - } + + return false; } } diff --git a/src/main/java/com/gmail/nossr50/util/Leaderboard.java b/src/main/java/com/gmail/nossr50/util/Leaderboard.java index 933384017..36c862838 100644 --- a/src/main/java/com/gmail/nossr50/util/Leaderboard.java +++ b/src/main/java/com/gmail/nossr50/util/Leaderboard.java @@ -55,9 +55,8 @@ public class Leaderboard { if (players.contains(p)) { continue; } - else { - players.add(p); - } + + players.add(p); if (character.length > 1 && Misc.isInt(character[1])) { Mining.add(new PlayerStat(p, Integer.valueOf(character[1]))); diff --git a/src/main/java/com/gmail/nossr50/util/Metrics.java b/src/main/java/com/gmail/nossr50/util/Metrics.java index 9f66a1d32..88e28a4c0 100644 --- a/src/main/java/com/gmail/nossr50/util/Metrics.java +++ b/src/main/java/com/gmail/nossr50/util/Metrics.java @@ -398,23 +398,22 @@ public class Metrics { if (response == null || response.startsWith("ERR")) { throw new IOException(response); //Throw the exception - } else { - // Is this the first update this hour? - if (response.contains("OK This is your first update this hour")) { - synchronized (graphs) { - final Iterator iter = graphs.iterator(); + } - while (iter.hasNext()) { - final Graph graph = iter.next(); + // Is this the first update this hour? + if (response.contains("OK This is your first update this hour")) { + synchronized (graphs) { + final Iterator iter = graphs.iterator(); - for (Plotter plotter : graph.getPlotters()) { - plotter.reset(); - } + while (iter.hasNext()) { + final Graph graph = iter.next(); + + for (Plotter plotter : graph.getPlotters()) { + plotter.reset(); } } } } - //if (response.startsWith("OK")) - We should get "OK" followed by an optional description if everything goes right } /** diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index 3ffab68b3..b127ca6c0 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -92,9 +92,8 @@ public class Misc { if (isInt(string)) { return Integer.parseInt(string); } - else { - return 0; - } + + return 0; } /** @@ -113,9 +112,8 @@ public class Misc { if (le.getNoDamageTicks() > le.getMaximumNoDamageTicks() / 2.0F && event.getDamage() <= le.getLastDamage()) { return true; } - else { - return false; - } + + return false; } /** @@ -145,9 +143,8 @@ public class Misc { if (!damageEvent.isCancelled() && !breakEvent.isCancelled()) { return true; } - else { - return false; - } + + return false; } /** @@ -197,9 +194,8 @@ public class Misc { if (first.distanceSquared(second) < (maxDistance * maxDistance)) { return true; } - else { - return false; - } + + return false; } /** @@ -294,9 +290,8 @@ public class Misc { if (skillLevel > maxLevel) { return maxLevel; } - else { - return skillLevel; - } + + return skillLevel; } /** @@ -310,8 +305,7 @@ public class Misc { if (levelCap > 0) { return levelCap; } - else { - return Integer.MAX_VALUE; - } + + return Integer.MAX_VALUE; } } diff --git a/src/main/java/com/gmail/nossr50/util/ModChecks.java b/src/main/java/com/gmail/nossr50/util/ModChecks.java index d5549ca8c..955a57db2 100644 --- a/src/main/java/com/gmail/nossr50/util/ModChecks.java +++ b/src/main/java/com/gmail/nossr50/util/ModChecks.java @@ -154,9 +154,8 @@ public class ModChecks { if (customToolsEnabled && toolInstance.customTools.containsKey(item.getTypeId())) { return true; } - else { - return false; - } + + return false; } /** @@ -169,8 +168,7 @@ public class ModChecks { if (customArmorEnabled && armorInstance.customArmor.containsKey(item.getTypeId())) { return true; } - else { - return false; - } + + return false; } } diff --git a/src/main/java/com/gmail/nossr50/util/Page.java b/src/main/java/com/gmail/nossr50/util/Page.java index 00ea20b75..353060206 100644 --- a/src/main/java/com/gmail/nossr50/util/Page.java +++ b/src/main/java/com/gmail/nossr50/util/Page.java @@ -15,8 +15,8 @@ public class Page { String[] addressSplit = LocaleLoader.getString(address).split("\n"); if(addressSplit.length <= 8) return 1; - else - return (addressSplit.length/8)+1; + + return (addressSplit.length/8)+1; } public static ArrayList grabPageContents(String header, String address, int pagenum) diff --git a/src/main/java/com/gmail/nossr50/util/Skills.java b/src/main/java/com/gmail/nossr50/util/Skills.java index 78dbf1117..894eaf020 100644 --- a/src/main/java/com/gmail/nossr50/util/Skills.java +++ b/src/main/java/com/gmail/nossr50/util/Skills.java @@ -56,9 +56,8 @@ public class Skills { if (currentTime - oldTime >= (adjustedCooldown * Misc.TIME_CONVERSION_FACTOR)) { return true; } - else { - return false; - } + + return false; } /** @@ -324,9 +323,8 @@ public class Skills { if (getSkillType(skillName) != null) { return true; } - else { - return false; - } + + return false; } /** @@ -343,9 +341,8 @@ public class Skills { || Permissions.unarmed(player)) { return true; } - else { - return false; - } + + return false; } /** @@ -362,9 +359,8 @@ public class Skills { || Permissions.woodcutting(player)) { return true; } - else { - return false; - } + + return false; } /** @@ -377,9 +373,8 @@ public class Skills { if (Permissions.acrobatics(player) || Permissions.repair(player)) { return true; } - else { - return false; - } + + return false; } /** diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManagerFactory.java b/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManagerFactory.java index efe719d13..b09e95eed 100644 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManagerFactory.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManagerFactory.java @@ -8,8 +8,8 @@ public class ChunkletManagerFactory { if(hConfig.getChunkletsEnabled()) { return new HashChunkletManager(); - } else { - return new NullChunkletManager(); } + + return new NullChunkletManager(); } } 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 b44462a04..be5e823d9 100644 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java @@ -65,11 +65,11 @@ public class HashChunkletManager implements ChunkletManager { File yFile = new File(czDir, "" + y); if(!yFile.exists()) { continue; - } else { - ChunkletStore in = deserializeChunkletStore(yFile); - if(in != null) { - store.put(world.getName() + "," + cx + "," + cz + "," + y, in); - } + } + + ChunkletStore in = deserializeChunkletStore(yFile); + if(in != null) { + store.put(world.getName() + "," + cx + "," + cz + "," + y, in); } } } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManagerFactory.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManagerFactory.java index a18731c4c..0ef913396 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManagerFactory.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManagerFactory.java @@ -8,8 +8,8 @@ public class ChunkManagerFactory { if(hConfig.getChunkletsEnabled()) { return new HashChunkManager(); - } else { - return new NullChunkManager(); } + + return new NullChunkManager(); } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java index 96675e270..bba0ed14a 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java @@ -61,9 +61,9 @@ public class HashChunkManager implements ChunkManager { Object o = objectStream.readObject(); if (o instanceof ChunkStore) { return (ChunkStore) o; - } else { - throw new RuntimeException("Wrong class type read for chunk meta data for " + x + ", " + z); } + + throw new RuntimeException("Wrong class type read for chunk meta data for " + x + ", " + z); } catch (IOException e) { // Assume the format changed return null; diff --git a/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java b/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java index eb5c669ef..80e01cace 100644 --- a/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java +++ b/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java @@ -84,9 +84,8 @@ public class ZipLibrary { if (path == null || path.isEmpty()) { return file; } - else { - return path + File.separator + file; - } + + return path + File.separator + file; } private static void zipDir(ZipOutputStream zos, String path, File dir) throws IOException { diff --git a/src/main/java/org/getspout/spoutapi/chunkstore/mcMMOSimpleRegionFile.java b/src/main/java/org/getspout/spoutapi/chunkstore/mcMMOSimpleRegionFile.java index 8fddb4f98..bbfb30261 100755 --- a/src/main/java/org/getspout/spoutapi/chunkstore/mcMMOSimpleRegionFile.java +++ b/src/main/java/org/getspout/spoutapi/chunkstore/mcMMOSimpleRegionFile.java @@ -216,9 +216,9 @@ public class mcMMOSimpleRegionFile { if (old != null && old == used) { if (old) { throw new IllegalStateException("Attempting to overwrite an in-use segment"); - } else { - throw new IllegalStateException("Attempting to delete empty segment"); } + + throw new IllegalStateException("Attempting to delete empty segment"); } } @@ -271,9 +271,9 @@ public class mcMMOSimpleRegionFile { private synchronized int sizeToSegments(int size) { if (size <= 0) { return 1; - } else { - return ((size - 1) >> segmentSize) + 1; } + + return ((size - 1) >> segmentSize) + 1; } private synchronized Integer getChunkIndex(int x, int z) {