mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 22:56:45 +01:00
Assorted cleanup.
This commit is contained in:
parent
1d7e034d5e
commit
0056be2d5f
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
|
@ -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) {
|
||||
|
@ -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); }
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -814,7 +814,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
private PlayerProfile loadFromLine(String[] character) throws Exception {
|
||||
private PlayerProfile loadFromLine(String[] character) {
|
||||
Map<SkillType, Integer> skills = getSkillMapFromLine(character); // Skill levels
|
||||
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
|
||||
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
|
||||
|
@ -799,7 +799,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
ResultSet resultSet;
|
||||
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
||||
PreparedStatement statement = null;
|
||||
|
||||
try {
|
||||
@ -811,13 +810,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
while (resultSet.next()) {
|
||||
ArrayList<String> column = new ArrayList<String>();
|
||||
|
||||
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) {
|
||||
|
@ -337,9 +337,4 @@ public class Party {
|
||||
|
||||
return this.getName().equals(other.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,6 @@ public class McMMOPlayer {
|
||||
private final Map<AbilityType, Boolean> abilityInformed = new HashMap<AbilityType, Boolean>();
|
||||
|
||||
private final Map<ToolType, Boolean> toolMode = new HashMap<ToolType, Boolean>();
|
||||
private final Map<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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.");
|
||||
|
@ -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<BlockStoreConversionMain> converters = new ArrayList<BlockStoreConversionMain>();
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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.
|
||||
|
@ -17,10 +17,6 @@ public abstract class SkillManager {
|
||||
this.skill = skill;
|
||||
}
|
||||
|
||||
public McMMOPlayer getMcMMOPlayer() {
|
||||
return mcMMOPlayer;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return mcMMOPlayer.getPlayer();
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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() {}
|
||||
|
||||
/**
|
||||
|
@ -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<Block> blockList) {
|
||||
List<BlockState> ores = new ArrayList<BlockState>();
|
||||
|
@ -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) {
|
||||
|
@ -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<ItemStack> 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<ItemStack> drops, double chance) {
|
||||
for (ItemStack item : drops) {
|
||||
randomDropItem(location, item, chance);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop an item at a given location.
|
||||
*
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user