From 0056be2d5ff0327dac222d1eeede5a6277301533 Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 27 Feb 2014 10:56:21 -0500 Subject: [PATCH] Assorted cleanup. --- .../com/gmail/nossr50/api/ExperienceAPI.java | 4 +- .../commands/database/McremoveCommand.java | 2 +- .../experience/ExperienceCommand.java | 2 +- .../experience/SkillresetCommand.java | 2 +- .../commands/party/PartyInviteCommand.java | 2 +- .../alliance/PartyAllianceInviteCommand.java | 2 +- .../commands/player/InspectCommand.java | 2 +- .../commands/player/McrankCommand.java | 2 +- .../commands/skills/FishingCommand.java | 5 +-- .../java/com/gmail/nossr50/config/Config.java | 2 - .../config/skills/alchemy/PotionConfig.java | 1 - .../nossr50/database/DatabaseManager.java | 2 +- .../database/FlatfileDatabaseManager.java | 2 +- .../nossr50/database/SQLDatabaseManager.java | 9 +--- .../gmail/nossr50/datatypes/party/Party.java | 5 --- .../nossr50/datatypes/player/McMMOPlayer.java | 29 ------------- ...ryAbilityWeightedActivationCheckEvent.java | 7 +++- .../nossr50/listeners/BlockListener.java | 6 ++- .../nossr50/listeners/InventoryListener.java | 2 +- .../nossr50/listeners/PlayerListener.java | 2 +- .../nossr50/listeners/WorldListener.java | 6 +-- src/main/java/com/gmail/nossr50/mcMMO.java | 19 +++------ .../com/gmail/nossr50/party/PartyManager.java | 10 ----- .../database/FormulaConversionTask.java | 2 +- .../gmail/nossr50/skills/SkillManager.java | 4 -- .../skills/alchemy/AlchemyManager.java | 1 - .../skills/alchemy/AlchemyPotionBrewer.java | 27 ++++++------ .../gmail/nossr50/skills/fishing/Fishing.java | 2 - .../nossr50/skills/mining/MiningManager.java | 4 +- .../com/gmail/nossr50/util/ItemUtils.java | 6 +-- .../java/com/gmail/nossr50/util/Misc.java | 41 +------------------ .../nossr50/util/player/UserManager.java | 28 +++---------- .../util/scoreboards/ScoreboardManager.java | 2 +- 33 files changed, 55 insertions(+), 187 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java index 8cc30c9ba..fa4ee21aa 100644 --- a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java +++ b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java @@ -43,9 +43,7 @@ public final class ExperienceAPI { public static boolean isNonChildSkill(String skillType) { SkillType skill = SkillType.getSkill(skillType); - if (skill == null) return false; - - return !skill.isChildSkill(); + return skill != null && !skill.isChildSkill(); } @Deprecated diff --git a/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java b/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java index 8eb46ac9b..769ca2b8d 100644 --- a/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java @@ -23,7 +23,7 @@ public class McremoveCommand implements TabExecutor { case 1: String playerName = CommandUtils.getMatchedPlayerName(args[0]); - if (UserManager.getPlayer(playerName, true) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false))) { + if (UserManager.getOfflinePlayer(playerName) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false))) { return true; } diff --git a/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java index 1daab0a3f..433c2e170 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java @@ -68,7 +68,7 @@ public abstract class ExperienceCommand implements TabExecutor { int value = Integer.parseInt(args[2]); String playerName = CommandUtils.getMatchedPlayerName(args[0]); - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true); + McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. if (mcMMOPlayer == null) { diff --git a/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java index cb86f9423..1b06eb3de 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java @@ -66,7 +66,7 @@ public class SkillresetCommand implements TabExecutor { } String playerName = CommandUtils.getMatchedPlayerName(args[0]); - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true); + McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. if (mcMMOPlayer == null) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java index 902d1ac72..9af015cbb 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java @@ -18,7 +18,7 @@ public class PartyInviteCommand implements CommandExecutor { switch (args.length) { case 2: String targetName = CommandUtils.getMatchedPlayerName(args[1]); - McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName, true); + McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName); if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { return false; diff --git a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceInviteCommand.java b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceInviteCommand.java index 570f55dc0..057f0014a 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceInviteCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceInviteCommand.java @@ -18,7 +18,7 @@ public class PartyAllianceInviteCommand implements CommandExecutor { switch (args.length) { case 3: String targetName = CommandUtils.getMatchedPlayerName(args[2]); - McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName, true); + McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName); if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { return false; diff --git a/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java b/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java index cd288d879..5118bf5ee 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java @@ -29,7 +29,7 @@ public class InspectCommand implements TabExecutor { switch (args.length) { case 1: String playerName = CommandUtils.getMatchedPlayerName(args[0]); - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true); + McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. if (mcMMOPlayer == null) { diff --git a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java index 8e676c634..654d934e6 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -47,7 +47,7 @@ public class McrankCommand implements TabExecutor { } String playerName = CommandUtils.getMatchedPlayerName(args[0]); - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true); + McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); if (mcMMOPlayer != null) { Player player = mcMMOPlayer.getPlayer(); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java index c14d9370a..5381b6f55 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java @@ -51,7 +51,6 @@ public class FishingCommand extends SkillCommand { @Override protected void dataCalculations(Player player, float skillValue, boolean isLucky) { FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager(); - boolean isStorming = player.getWorld().hasStorm(); // TREASURE HUNTER if (canTreasureHunt) { @@ -70,7 +69,7 @@ public class FishingCommand extends SkillCommand { double totalEnchantChance = 0; for (Rarity rarity : Rarity.values()) { - if (rarity != Rarity.TRAP || rarity != Rarity.RECORD) { + if (rarity != Rarity.TRAP && rarity != Rarity.RECORD) { totalEnchantChance += TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, rarity); } } @@ -92,7 +91,7 @@ public class FishingCommand extends SkillCommand { // MASTER ANGLER if (canMasterAngler) { - double rawBiteChance = 1.0 / (isStorming ? 300 : 500); + double rawBiteChance = 1.0 / (player.getWorld().hasStorm() ? 300 : 500); Location location = fishingManager.getHookLocation(); if (location == null) { diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 247f93f9c..722494bae 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -217,8 +217,6 @@ public class Config extends AutoUpdateConfigLoader { public boolean getUpdateCheckEnabled() { return config.getBoolean("General.Update_Check", true); } public boolean getPreferBeta() { return config.getBoolean("General.Prefer_Beta", false); } public boolean getEventCallbackEnabled() { return config.getBoolean("General.Event_Callback", true); } - public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); } - public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); } public String getPartyChatPrefix() { return config.getString("Commands.partychat.Chat_Prefix_Format", "[[GREEN]]([[WHITE]]{0}[[GREEN]])"); } public boolean getPartyChatColorLeaderName() { return config.getBoolean("Commands.partychat.Gold_Leader_Name", true); } diff --git a/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java b/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java index 0a0f91eb3..c939d2d64 100644 --- a/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java +++ b/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java @@ -5,7 +5,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import com.gmail.nossr50.skills.alchemy.Alchemy; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.inventory.ItemStack; diff --git a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java index 11f17a6b9..5d99fde64 100644 --- a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java @@ -44,7 +44,7 @@ public interface DatabaseManager { /** * Retrieve leaderboard info. * - * @param skillName The skill to retrieve info on + * @param skill The skill to retrieve info on * @param pageNumber Which page in the leaderboards to retrieve * @param statsPerPage The number of stats per page * @return the requested leaderboard information diff --git a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java index 49e387134..640e4f0c3 100644 --- a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java @@ -814,7 +814,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { } } - private PlayerProfile loadFromLine(String[] character) throws Exception { + private PlayerProfile loadFromLine(String[] character) { Map skills = getSkillMapFromLine(character); // Skill levels Map skillsXp = new HashMap(); // Skill & XP Map skillsDATS = new HashMap(); // Ability & Cooldown diff --git a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java index 38f67e4fb..b0eeff586 100644 --- a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java @@ -799,7 +799,6 @@ public final class SQLDatabaseManager implements DatabaseManager { } ResultSet resultSet; - HashMap> rows = new HashMap>(); PreparedStatement statement = null; try { @@ -811,13 +810,7 @@ public final class SQLDatabaseManager implements DatabaseManager { resultSet = statement.executeQuery(); while (resultSet.next()) { - ArrayList column = new ArrayList(); - - for (int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) { - column.add(resultSet.getString(i)); - } - - rows.put(resultSet.getRow(), column); + // No reason to do anything here... we're just trying to catch exceptions } } catch (SQLException ex) { diff --git a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java index 7297355cf..da5b5a81b 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java +++ b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java @@ -337,9 +337,4 @@ public class Party { return this.getName().equals(other.getName()); } - - @Override - public int hashCode() { - return super.hashCode(); - } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index 9bcdb3e0e..f39df7bc8 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -79,7 +79,6 @@ public class McMMOPlayer { private final Map abilityInformed = new HashMap(); private final Map toolMode = new HashMap(); - private final Map toolATS = new HashMap(); private int recentlyHurt; private int respawnATS; @@ -122,7 +121,6 @@ public class McMMOPlayer { for (ToolType toolType : ToolType.values()) { toolMode.put(toolType, false); - toolATS.put(toolType, 0); } if (!profile.isLoaded()) { @@ -340,28 +338,6 @@ public class McMMOPlayer { toolMode.put(tool, isPrepared); } - /** - * Get the current prep ATS of a tool. - * - * @param tool Tool to get the ATS for - * @return the ATS for the tool - */ - public long getToolPreparationATS(ToolType tool) { - return toolATS.get(tool); - } - - /** - * Set the current prep ATS of a tool. - * - * @param tool Tool to set the ATS for - * @param ATS the ATS of the tool - */ - public void setToolPreparationATS(ToolType tool, long ATS) { - int startTime = (int) (ATS / Misc.TIME_CONVERSION_FACTOR); - - toolATS.put(tool, startTime); - } - /* * Recently Hurt */ @@ -594,10 +570,6 @@ public class McMMOPlayer { return player; } - public void setPlayer(Player player) { - this.player = player; - } - public PlayerProfile getProfile() { return profile; } @@ -877,7 +849,6 @@ public class McMMOPlayer { player.sendMessage(tool.getRaiseTool()); } - setToolPreparationATS(tool, System.currentTimeMillis()); setToolPreparationMode(tool, true); new ToolLowerTask(this, tool).runTaskLaterAsynchronously(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR); } diff --git a/src/main/java/com/gmail/nossr50/events/skills/secondaryabilities/SecondaryAbilityWeightedActivationCheckEvent.java b/src/main/java/com/gmail/nossr50/events/skills/secondaryabilities/SecondaryAbilityWeightedActivationCheckEvent.java index 7d5888960..c27805caf 100644 --- a/src/main/java/com/gmail/nossr50/events/skills/secondaryabilities/SecondaryAbilityWeightedActivationCheckEvent.java +++ b/src/main/java/com/gmail/nossr50/events/skills/secondaryabilities/SecondaryAbilityWeightedActivationCheckEvent.java @@ -15,6 +15,7 @@ public class SecondaryAbilityWeightedActivationCheckEvent extends SecondaryAbili /** * Gets the activation chance of the ability 0D being no chance, 1.0D being 100% chance + * * @return The activation chance of the ability */ public double getChance() { @@ -23,7 +24,8 @@ public class SecondaryAbilityWeightedActivationCheckEvent extends SecondaryAbili /** * Sets the activation chance of the ability [0D-1.0D] - * @param The activation chance of the ability + * + * @param chance The activation chance of the ability */ public void setChance(double chance) { this.chance = chance; @@ -31,7 +33,8 @@ public class SecondaryAbilityWeightedActivationCheckEvent extends SecondaryAbili /** * Sets the activation chance of the ability to 100% or 0% - * @param whether it should be successful or not + * + * @param success whether it should be successful or not */ public void setSuccessful(boolean success) { this.chance = success ? 1.0D : 0D; diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index fe8b61c4c..7622a1732 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -3,6 +3,7 @@ package com.gmail.nossr50.listeners; import java.util.List; import org.bukkit.GameMode; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; @@ -132,14 +133,15 @@ public class BlockListener implements Listener { } BlockState blockState = event.getBlock().getState(); + Location location = blockState.getLocation(); if (!BlockUtils.shouldBeWatched(blockState)) { return; } /* ALCHEMY - Cancel any brew in progress for that BrewingStand */ - if (blockState instanceof BrewingStand && Alchemy.brewingStandMap.containsKey(event.getBlock())) { - Alchemy.brewingStandMap.get(event.getBlock()).cancelBrew(); + if (blockState instanceof BrewingStand && Alchemy.brewingStandMap.containsKey(location)) { + Alchemy.brewingStandMap.get(location).cancelBrew(); } Player player = event.getPlayer(); diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 5f10f0826..779eaee6a 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -183,7 +183,7 @@ public class InventoryListener implements Listener { return; } - AlchemyPotionBrewer.transferItems(event.getView(), event.getRawSlot(), Alchemy.INGREDIENT_SLOT, click); + AlchemyPotionBrewer.transferItems(event.getView(), event.getRawSlot(), click); event.setCancelled(true); AlchemyPotionBrewer.scheduleUpdate(inventory); AlchemyPotionBrewer.scheduleCheck(player, stand); diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index b065b8dcc..d866f8e70 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -633,7 +633,7 @@ public class PlayerListener implements Listener { return; } - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player, true); + McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(player); if (mcMMOPlayer == null) { mcMMO.p.debug(player.getName() + "is chatting, but is currently not logged in to the server."); diff --git a/src/main/java/com/gmail/nossr50/listeners/WorldListener.java b/src/main/java/com/gmail/nossr50/listeners/WorldListener.java index 6254f748b..ed3b71750 100644 --- a/src/main/java/com/gmail/nossr50/listeners/WorldListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/WorldListener.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.listeners; import java.io.File; -import java.util.ArrayList; import org.bukkit.Chunk; import org.bukkit.World; @@ -18,7 +17,6 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionMain; public class WorldListener implements Listener { - private final ArrayList converters = new ArrayList(); private final mcMMO plugin; public WorldListener(final mcMMO plugin) { @@ -56,9 +54,7 @@ public class WorldListener implements Listener { plugin.getLogger().info("Converting block storage for " + world.getName() + " to a new format."); - BlockStoreConversionMain converter = new BlockStoreConversionMain(world); - converter.run(); - converters.add(converter); + new BlockStoreConversionMain(world).run(); } /** diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 4cbee75a0..190ff3844 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -87,9 +87,6 @@ public class mcMMO extends JavaPlugin { /* Plugin Checks */ private static boolean combatTagEnabled; private static boolean healthBarPluginEnabled; - private static boolean noCheatPlusPluginEnabled; - private static boolean compatNoCheatPlusPluginEnabled; - private static boolean mcpcEnabled; // Config Validation Check public boolean noErrorsInConfigFiles = true; @@ -125,11 +122,9 @@ public class mcMMO extends JavaPlugin { getLogger().setFilter(new LogFilter(this)); metadataValue = new FixedMetadataValue(this, true); - mcpcEnabled = getServer().getName().equals("MCPC+"); - combatTagEnabled = getServer().getPluginManager().getPlugin("CombatTag") != null; - healthBarPluginEnabled = getServer().getPluginManager().getPlugin("HealthBar") != null; - noCheatPlusPluginEnabled = getServer().getPluginManager().getPlugin("NoCheatPlus") != null; - compatNoCheatPlusPluginEnabled = getServer().getPluginManager().getPlugin("CompatNoCheatPlus") != null; + PluginManager pluginManager = getServer().getPluginManager(); + combatTagEnabled = pluginManager.getPlugin("CombatTag") != null; + healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null; setupFilePaths(); @@ -141,7 +136,7 @@ public class mcMMO extends JavaPlugin { return; } - if (mcpcEnabled) { + if (getServer().getName().equals("MCPC+")) { checkModConfigs(); } @@ -149,7 +144,7 @@ public class mcMMO extends JavaPlugin { getLogger().info("HealthBar plugin found, mcMMO's healthbars are automatically disabled."); } - if (noCheatPlusPluginEnabled && !compatNoCheatPlusPluginEnabled) { + if (pluginManager.getPlugin("NoCheatPlus") != null && pluginManager.getPlugin("CompatNoCheatPlus") == null) { getLogger().warning("NoCheatPlus plugin found, but CompatNoCheatPlus was not found!"); getLogger().warning("mcMMO will not work properly alongside NoCheatPlus without CompatNoCheatPlus"); } @@ -315,10 +310,6 @@ public class mcMMO extends JavaPlugin { return healthBarPluginEnabled; } - public static boolean isMCPCEnabled() { - return mcpcEnabled; - } - /** * Setup the various storage file paths */ diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index 2f51aaf45..93fe944d0 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -459,16 +459,6 @@ public final class PartyManager { return !party.isLocked() || party.getLeader().equalsIgnoreCase(mcMMOPlayer.getPlayer().getName()); } - /** - * Check if a string is a valid party name. - * - * @param partyName The party name to check - * @return true if this is a valid party, false otherwise - */ - public static boolean isParty(String partyName) { - return getParty(partyName) != null; - } - /** * Load party file. */ diff --git a/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java b/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java index 099346561..801d802ea 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java @@ -28,7 +28,7 @@ public class FormulaConversionTask extends BukkitRunnable { int convertedUsers = 0; long startMillis = System.currentTimeMillis(); for (String playerName : mcMMO.getDatabaseManager().getStoredUsers()) { - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true); + McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); PlayerProfile profile; // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. diff --git a/src/main/java/com/gmail/nossr50/skills/SkillManager.java b/src/main/java/com/gmail/nossr50/skills/SkillManager.java index 267938bf2..580f6538e 100644 --- a/src/main/java/com/gmail/nossr50/skills/SkillManager.java +++ b/src/main/java/com/gmail/nossr50/skills/SkillManager.java @@ -17,10 +17,6 @@ public abstract class SkillManager { this.skill = skill; } - public McMMOPlayer getMcMMOPlayer() { - return mcMMOPlayer; - } - public Player getPlayer() { return mcMMOPlayer.getPlayer(); } diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyManager.java b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyManager.java index 27c7b2433..e91fd15cd 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyManager.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyManager.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.skills.alchemy; import java.util.List; -import com.gmail.nossr50.util.Permissions; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.config.experience.ExperienceConfig; diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java index d45b92e05..0dbfd9ac4 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java @@ -124,25 +124,24 @@ public final class AlchemyPotionBrewer { } } - public static boolean transferItems(InventoryView view, int fromSlot, int toSlot, ClickType click) { + public static boolean transferItems(InventoryView view, int fromSlot, ClickType click) { boolean success = false; if (click.isLeftClick()) { - success = transferItems(view, fromSlot, toSlot); + success = transferItems(view, fromSlot); } else if (click.isRightClick()) { - success = transferOneItem(view, fromSlot, toSlot); + success = transferOneItem(view, fromSlot); } return success; } - private static boolean transferOneItem(InventoryView view, int fromSlot, int toSlot) { + private static boolean transferOneItem(InventoryView view, int fromSlot) { ItemStack from = view.getItem(fromSlot).clone(); - ItemStack to = view.getItem(toSlot).clone(); - boolean emptyFrom = isEmpty(from); + ItemStack to = view.getItem(Alchemy.INGREDIENT_SLOT).clone(); - if (emptyFrom) { + if (isEmpty(from)) { return false; } @@ -162,8 +161,8 @@ public final class AlchemyPotionBrewer { } from.setAmount(fromAmount - 1); - view.setItem(toSlot, emptyTo ? null : to); - view.setItem(fromSlot, emptyFrom ? null : from); + view.setItem(Alchemy.INGREDIENT_SLOT, emptyTo ? null : to); + view.setItem(fromSlot, from); return true; } @@ -174,15 +173,15 @@ public final class AlchemyPotionBrewer { /** * Transfer items between two ItemStacks, returning the leftover status */ - private static boolean transferItems(InventoryView view, int fromSlot, int toSlot) { + private static boolean transferItems(InventoryView view, int fromSlot) { ItemStack from = view.getItem(fromSlot).clone(); - ItemStack to = view.getItem(toSlot).clone(); + ItemStack to = view.getItem(Alchemy.INGREDIENT_SLOT).clone(); if (isEmpty(from)) { return false; } else if (isEmpty(to)) { - view.setItem(toSlot, from); + view.setItem(Alchemy.INGREDIENT_SLOT, from); view.setItem(fromSlot, null); return true; @@ -196,7 +195,7 @@ public final class AlchemyPotionBrewer { int left = fromAmount + toAmount - maxSize; to.setAmount(maxSize); - view.setItem(toSlot, to); + view.setItem(Alchemy.INGREDIENT_SLOT, to); from.setAmount(left); view.setItem(fromSlot, from); @@ -206,7 +205,7 @@ public final class AlchemyPotionBrewer { to.setAmount(fromAmount + toAmount); view.setItem(fromSlot, null); - view.setItem(toSlot, to); + view.setItem(Alchemy.INGREDIENT_SLOT, to); return true; } diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java index 9ae2b9a4f..e734c6d0a 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java @@ -54,8 +54,6 @@ public final class Fishing { public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2; public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5; - public static final double STORM_MODIFIER = 0.909; - private Fishing() {} /** diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index 062056315..27bfef4e7 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -115,8 +115,8 @@ public class MiningManager extends SkillManager { /** * Handler for explosion drops and XP gain. * - * @param yield - * @param blockList + * @param yield The % of blocks to drop + * @param blockList The list of blocks to drop */ public void blastMiningDropProcessing(float yield, List blockList) { List ores = new ArrayList(); diff --git a/src/main/java/com/gmail/nossr50/util/ItemUtils.java b/src/main/java/com/gmail/nossr50/util/ItemUtils.java index 1116018e8..d0c5d9b00 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemUtils.java +++ b/src/main/java/com/gmail/nossr50/util/ItemUtils.java @@ -498,11 +498,7 @@ public final class ItemUtils { } public static boolean isSmeltable(ItemStack item) { - if (item == null) { - return false; - } - - return MaterialUtils.isOre(item.getData()); + return item != null && MaterialUtils.isOre(item.getData()); } public static boolean isSmelted(ItemStack item) { diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index 5c860b1e5..db99a2fda 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -64,11 +64,7 @@ public final class Misc { * @return true if the distance between {@code first} and {@code second} is less than {@code maxDistance}, false otherwise */ public static boolean isNear(Location first, Location second, double maxDistance) { - if (first.getWorld() != second.getWorld()) { - return false; - } - - return first.distanceSquared(second) < (maxDistance * maxDistance) || maxDistance == 0; + return (first.getWorld() == second.getWorld()) && (first.distanceSquared(second) < (maxDistance * maxDistance) || maxDistance == 0); } public static void dropItems(Location location, Collection drops) { @@ -90,41 +86,6 @@ public final class Misc { } } - /** - * Randomly drop an item at a given location. - * - * @param location The location to drop the items at - * @param is The item to drop - * @param chance The percentage chance for the item to drop - */ - public static void randomDropItem(Location location, ItemStack is, double chance) { - if (random.nextInt(100) < chance) { - dropItem(location, is); - } - } - - /** - * Drop items with random quantity at a given location. - * - * @param location The location to drop the items at - * @param is The item to drop - * @param quantity The amount of items to drop - */ - public static void randomDropItems(Location location, ItemStack is, int quantity) { - int dropCount = random.nextInt(quantity + 1); - - if (dropCount > 0) { - is.setAmount(dropCount); - dropItem(location, is); - } - } - - public static void randomDropItems(Location location, Collection drops, double chance) { - for (ItemStack item : drops) { - randomDropItem(location, item, chance); - } - } - /** * Drop an item at a given location. * diff --git a/src/main/java/com/gmail/nossr50/util/player/UserManager.java b/src/main/java/com/gmail/nossr50/util/player/UserManager.java index 1d0cf7984..cf758239c 100644 --- a/src/main/java/com/gmail/nossr50/util/player/UserManager.java +++ b/src/main/java/com/gmail/nossr50/util/player/UserManager.java @@ -90,28 +90,16 @@ public final class UserManager { return retrieveMcMMOPlayer(playerName, false); } - /** - * Get the McMMOPlayer of a player. - * - * @param player The player whose McMMOPlayer to retrieve - * @return the player's McMMOPlayer object - */ - public static McMMOPlayer getPlayer(OfflinePlayer player) { + public static McMMOPlayer getOfflinePlayer(OfflinePlayer player) { if (player instanceof Player) { return getPlayer((Player) player); } - return retrieveMcMMOPlayer(player.getName(), false); + + return retrieveMcMMOPlayer(player.getName(), true); } - public static McMMOPlayer getPlayer(OfflinePlayer player, boolean offlineValid) { - if (player instanceof Player) { - return getPlayer((Player) player); - } - return retrieveMcMMOPlayer(player.getName(), offlineValid); - } - - public static McMMOPlayer getPlayer(String playerName, boolean offlineValid) { - return retrieveMcMMOPlayer(playerName, offlineValid); + public static McMMOPlayer getOfflinePlayer(String playerName) { + return retrieveMcMMOPlayer(playerName, true); } public static McMMOPlayer getPlayer(Player player) { @@ -133,10 +121,6 @@ public final class UserManager { } public static boolean hasPlayerDataKey(Entity entity) { - if (entity == null) { - return false; - } - - return entity.hasMetadata(mcMMO.playerDataKey); + return entity != null && entity.hasMetadata(mcMMO.playerDataKey); } } diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java index 155952705..477035fa6 100644 --- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java @@ -329,7 +329,7 @@ public class ScoreboardManager { } for (String playerName : dirtyPowerLevels) { - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true); + McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); if (mcMMOPlayer == null) { continue;