From 33a68daa9c1920619c11b549eb0560123c4a2b65 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 12 Apr 2019 15:17:05 -0700 Subject: [PATCH 01/16] mcMMO now checks in all places for a loaded profile before executing processing on said profile --- Changelog.txt | 4 ++ pom.xml | 2 +- .../com/gmail/nossr50/api/ExperienceAPI.java | 7 +++ .../java/com/gmail/nossr50/api/PartyAPI.java | 16 ++++++ .../McMMOPlayerNotFoundException.java | 2 +- .../nossr50/commands/McnotifyCommand.java | 4 ++ .../commands/chat/PartyChatCommand.java | 4 ++ .../commands/experience/AddxpCommand.java | 4 ++ .../experience/ExperienceCommand.java | 8 +++ .../commands/party/PartyAcceptCommand.java | 9 ++++ .../party/PartyChangeOwnerCommand.java | 7 +++ .../party/PartyChangePasswordCommand.java | 6 +++ .../nossr50/commands/party/PartyCommand.java | 14 +++++ .../commands/party/PartyCreateCommand.java | 6 +++ .../commands/party/PartyDisbandCommand.java | 6 +++ .../commands/party/PartyInfoCommand.java | 5 ++ .../commands/party/PartyInviteCommand.java | 7 +++ .../commands/party/PartyItemShareCommand.java | 6 +++ .../commands/party/PartyJoinCommand.java | 7 +++ .../commands/party/PartyKickCommand.java | 6 +++ .../commands/party/PartyLockCommand.java | 6 +++ .../commands/party/PartyQuitCommand.java | 7 +++ .../commands/party/PartyRenameCommand.java | 6 +++ .../commands/party/PartyXpShareCommand.java | 6 +++ .../alliance/PartyAllianceAcceptCommand.java | 5 ++ .../party/alliance/PartyAllianceCommand.java | 6 +++ .../alliance/PartyAllianceDisbandCommand.java | 5 ++ .../alliance/PartyAllianceInviteCommand.java | 7 +++ .../party/teleport/PtpAcceptCommand.java | 6 +++ .../commands/party/teleport/PtpCommand.java | 24 +++++++++ .../commands/player/MccooldownCommand.java | 6 +++ .../commands/player/McrankCommand.java | 7 +++ .../commands/player/McstatsCommand.java | 6 +++ .../commands/skills/AlchemyCommand.java | 7 +++ .../nossr50/commands/skills/SkillCommand.java | 6 +++ .../nossr50/datatypes/player/McMMOPlayer.java | 8 +-- .../skills/subskills/acrobatics/Roll.java | 5 +- .../nossr50/listeners/BlockListener.java | 43 +++++++++++++++ .../nossr50/listeners/EntityListener.java | 35 ++++++++++++ .../nossr50/listeners/InventoryListener.java | 30 +++++++++++ .../nossr50/listeners/PlayerListener.java | 54 +++++++++++++++++++ .../com/gmail/nossr50/party/PartyManager.java | 37 +++++++++++++ .../com/gmail/nossr50/party/ShareHandler.java | 13 +++++ .../runnables/skills/AlchemyBrewTask.java | 6 ++- .../skills/alchemy/AlchemyPotionBrewer.java | 6 +++ .../skills/archery/ArcheryManager.java | 4 +- .../nossr50/skills/axes/AxesManager.java | 4 +- .../nossr50/skills/mining/BlastMining.java | 5 ++ .../nossr50/skills/swords/SwordsManager.java | 2 +- .../nossr50/skills/taming/TamingManager.java | 2 +- .../skills/unarmed/UnarmedManager.java | 3 ++ .../com/gmail/nossr50/util/ChimaeraWing.java | 4 ++ .../com/gmail/nossr50/util/EventUtils.java | 22 +++++++- .../gmail/nossr50/util/HardcoreManager.java | 6 +++ .../nossr50/util/commands/CommandUtils.java | 3 ++ .../util/player/NotificationManager.java | 17 ++++-- .../nossr50/util/player/UserManager.java | 10 +++- .../util/scoreboards/ScoreboardWrapper.java | 6 +++ .../nossr50/util/skills/CombatUtils.java | 4 ++ .../gmail/nossr50/util/skills/RankUtils.java | 6 +++ .../gmail/nossr50/util/skills/SkillUtils.java | 5 ++ .../resources/locale/locale_en_US.properties | 1 + 62 files changed, 560 insertions(+), 21 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index c357aaa5d..6bcf2a1ac 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,6 +7,10 @@ Key: ! Change - Removal +Version 2.1.41 + Fixed NullPointerException errors when trying to grab PlayerProfiles for players who have not loaded + Added new locale string Profile.PendingLoad + Version 2.1.40 (API) mcMMO will now return null in all cases for UserManager.getPlayerProfile() if they have not been loaded yet (API) Roll stores exploit data in AcrobaticsManager now diff --git a/pom.xml b/pom.xml index f5086f40b..f70a5bc37 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.40 + 2.1.41-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java index db5658f37..93eaef9a3 100644 --- a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java +++ b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java @@ -1158,6 +1158,13 @@ public final class ExperienceAPI { return formulaType; } + /** + * @deprecated Use UserManager::getPlayer(Player player) instead + * @param player target player + * @return McMMOPlayer for that player if the profile is loaded, otherwise null + * @throws McMMOPlayerNotFoundException + */ + @Deprecated private static McMMOPlayer getPlayer(Player player) throws McMMOPlayerNotFoundException { if (!UserManager.hasPlayerDataKey(player)) { throw new McMMOPlayerNotFoundException(player); diff --git a/src/main/java/com/gmail/nossr50/api/PartyAPI.java b/src/main/java/com/gmail/nossr50/api/PartyAPI.java index ebe0e63b1..eaea5027b 100644 --- a/src/main/java/com/gmail/nossr50/api/PartyAPI.java +++ b/src/main/java/com/gmail/nossr50/api/PartyAPI.java @@ -41,6 +41,9 @@ public final class PartyAPI { * @return true if the player is in a party, false otherwise */ public static boolean inParty(Player player) { + if(UserManager.getPlayer(player) == null) + return false; + return UserManager.getPlayer(player).inParty(); } @@ -79,6 +82,10 @@ public final class PartyAPI { */ @Deprecated public static void addToParty(Player player, String partyName) { + //Check if player profile is loaded + if(UserManager.getPlayer(player) == null) + return; + Party party = PartyManager.getParty(partyName); if (party == null) { @@ -113,7 +120,12 @@ public final class PartyAPI { * @param partyName The party to add the player to * @param bypassLimit if true bypasses party size limits */ + //TODO: bypasslimit not used? public static void addToParty(Player player, String partyName, boolean bypassLimit) { + //Check if player profile is loaded + if(UserManager.getPlayer(player) == null) + return; + Party party = PartyManager.getParty(partyName); if (party == null) { @@ -131,6 +143,10 @@ public final class PartyAPI { * @param player The player to remove */ public static void removeFromParty(Player player) { + //Check if player profile is loaded + if(UserManager.getPlayer(player) == null) + return; + PartyManager.removeFromParty(UserManager.getPlayer(player)); } diff --git a/src/main/java/com/gmail/nossr50/api/exceptions/McMMOPlayerNotFoundException.java b/src/main/java/com/gmail/nossr50/api/exceptions/McMMOPlayerNotFoundException.java index d087631cd..b0b0f0087 100644 --- a/src/main/java/com/gmail/nossr50/api/exceptions/McMMOPlayerNotFoundException.java +++ b/src/main/java/com/gmail/nossr50/api/exceptions/McMMOPlayerNotFoundException.java @@ -6,6 +6,6 @@ public class McMMOPlayerNotFoundException extends RuntimeException { private static final long serialVersionUID = 761917904993202836L; public McMMOPlayerNotFoundException(Player player) { - super("McMMOPlayer object was not found for: " + player.getName() + " " + player.getUniqueId()); + super("McMMOPlayer object was not found for [NOTE: This can mean the profile is not loaded yet!] : " + player.getName() + " " + player.getUniqueId()); } } diff --git a/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java b/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java index eb6139f33..08b4e59f2 100644 --- a/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java @@ -18,6 +18,10 @@ public class McnotifyCommand implements TabExecutor { case 0: McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender); + //Not Loaded yet + if(mcMMOPlayer == null) + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(LocaleLoader.getString("Commands.Notifications." + (mcMMOPlayer.useChatNotifications() ? "Off" : "On"))); mcMMOPlayer.toggleChatNotifications(); return true; diff --git a/src/main/java/com/gmail/nossr50/commands/chat/PartyChatCommand.java b/src/main/java/com/gmail/nossr50/commands/chat/PartyChatCommand.java index 606329eeb..8cb3a488e 100644 --- a/src/main/java/com/gmail/nossr50/commands/chat/PartyChatCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/chat/PartyChatCommand.java @@ -22,6 +22,10 @@ public class PartyChatCommand extends ChatCommand { String message; if (sender instanceof Player) { + //Check if player profile is loaded + if(UserManager.getPlayer((Player) sender) == null) + return; + party = UserManager.getPlayer((Player) sender).getParty(); if (party == null) { diff --git a/src/main/java/com/gmail/nossr50/commands/experience/AddxpCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/AddxpCommand.java index f79c8b9ca..f2f3a5370 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/AddxpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/AddxpCommand.java @@ -24,6 +24,10 @@ public class AddxpCommand extends ExperienceCommand { @Override protected void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value) { if (player != null) { + //Check if player profile is loaded + if(UserManager.getPlayer(player) == null) + return; + UserManager.getPlayer(player).applyXpGain(skill, value, XPGainReason.COMMAND, XPGainSource.COMMAND); } else { 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 120cbb853..139cd9fb5 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java @@ -51,6 +51,14 @@ public abstract class ExperienceCommand implements TabExecutor { return true; } + //Profile not loaded + if(UserManager.getPlayer(sender.getName()) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + + editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill, Integer.parseInt(args[1])); return true; diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java index 86543a3a2..d60868dd9 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java @@ -15,8 +15,17 @@ public class PartyAcceptCommand implements CommandExecutor { switch (args.length) { case 1: Player player = (Player) sender; + + //Check if player profile is loaded + if(UserManager.getPlayer(player) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + if (!mcMMOPlayer.hasPartyInvite()) { sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites")); return true; diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java index 5c4e4a55a..ef711fbef 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java @@ -17,6 +17,13 @@ public class PartyChangeOwnerCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 2: + //Check if player profile is loaded + if(UserManager.getPlayer((Player) sender) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + Party playerParty = UserManager.getPlayer((Player) sender).getParty(); String targetName = CommandUtils.getMatchedPlayerName(args[1]); OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(targetName); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java index 0c2065df0..dc641789b 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java @@ -11,6 +11,12 @@ import org.bukkit.entity.Player; public class PartyChangePasswordCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(UserManager.getPlayer((Player) sender) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + Party party = UserManager.getPlayer((Player) sender).getParty(); switch (args.length) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java index 994ff69f2..b1471d9a0 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java @@ -74,6 +74,12 @@ public class PartyCommand implements TabExecutor { return true; } + if(UserManager.getPlayer(player) == null) + { + player.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); if (args.length < 1) { @@ -197,6 +203,14 @@ public class PartyCommand implements TabExecutor { if (matches.size() == 0) { Player player = (Player) sender; + + //Not Loaded + if(UserManager.getPlayer(player) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return ImmutableList.of(); + } + Party party = UserManager.getPlayer(player).getParty(); playerNames = party.getOnlinePlayerNames(player); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java index 681972d69..ed5b95b72 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java @@ -18,6 +18,12 @@ public class PartyCreateCommand implements CommandExecutor { Player player = (Player) sender; McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + if(UserManager.getPlayer(player) == null) + { + player.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + // Check to see if the party exists, and if it does cancel creating a new party if (PartyManager.checkPartyExistence(player, args[1])) { return true; diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java index 8e6459676..8e10e1719 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java @@ -15,6 +15,12 @@ public class PartyDisbandCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 1: + if(UserManager.getPlayer((Player) sender) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + Party playerParty = UserManager.getPlayer((Player) sender).getParty(); String partyName = playerParty.getName(); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java index 6dc6c9017..0a8ddda48 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java @@ -23,6 +23,11 @@ public class PartyInfoCommand implements CommandExecutor { switch (args.length) { case 0: case 1: + if(UserManager.getPlayer((Player) sender) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } Player player = (Player) sender; McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); Party party = mcMMOPlayer.getParty(); 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 9a203c202..588feb3d7 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java @@ -25,6 +25,13 @@ public class PartyInviteCommand implements CommandExecutor { } Player target = mcMMOTarget.getPlayer(); + + if(UserManager.getPlayer((Player) sender) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + Player player = (Player) sender; McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); String playerName = player.getName(); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java index 81c47a1d7..e8d8db40d 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java @@ -17,6 +17,12 @@ import org.bukkit.entity.Player; public class PartyItemShareCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(UserManager.getPlayer((Player) sender) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + Party party = UserManager.getPlayer((Player) sender).getParty(); if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ITEM_SHARE)) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java index 88ea326ef..b3d7e6afb 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java @@ -32,6 +32,13 @@ public class PartyJoinCommand implements CommandExecutor { } Player player = (Player) sender; + + if(UserManager.getPlayer((Player) sender) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); Party targetParty = mcMMOTarget.getParty(); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java index 2c45077a2..ed0adde76 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java @@ -18,6 +18,12 @@ public class PartyKickCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 2: + if(UserManager.getPlayer((Player) sender) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + Party playerParty = UserManager.getPlayer((Player) sender).getParty(); String targetName = CommandUtils.getMatchedPlayerName(args[1]); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java index b12668902..fdf02ee23 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java @@ -54,6 +54,12 @@ public class PartyLockCommand implements CommandExecutor { } private void togglePartyLock(CommandSender sender, boolean lock) { + if(UserManager.getPlayer((Player) sender) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return; + } + Party party = UserManager.getPlayer((Player) sender).getParty(); if (!Permissions.partySubcommand(sender, lock ? PartySubcommandType.LOCK : PartySubcommandType.UNLOCK)) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java index 0f32b29b7..c8cd07fbf 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java @@ -17,6 +17,13 @@ public class PartyQuitCommand implements CommandExecutor { switch (args.length) { case 1: Player player = (Player) sender; + + if(UserManager.getPlayer((Player) sender) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); Party playerParty = mcMMOPlayer.getParty(); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java index bcc574ba1..592ac4ca7 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java @@ -16,6 +16,12 @@ public class PartyRenameCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 2: + if(UserManager.getPlayer((Player) sender) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender); Party playerParty = mcMMOPlayer.getParty(); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java index 2214a82dc..26b0922da 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java @@ -16,6 +16,12 @@ import org.bukkit.entity.Player; public class PartyXpShareCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(UserManager.getPlayer((Player) sender) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + Party party = UserManager.getPlayer((Player) sender).getParty(); if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.XP_SHARE)) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceAcceptCommand.java b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceAcceptCommand.java index fc57d1ba4..e4854a0cc 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceAcceptCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceAcceptCommand.java @@ -14,6 +14,11 @@ public class PartyAllianceAcceptCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 2: + if(UserManager.getPlayer((Player) sender) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } Player player = (Player) sender; McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); diff --git a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java index fa91b02ea..7741115fd 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java @@ -37,6 +37,12 @@ public class PartyAllianceCommand implements TabExecutor { return true; } + if(UserManager.getPlayer((Player) sender) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + player = (Player) sender; McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); diff --git a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceDisbandCommand.java b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceDisbandCommand.java index e3529285d..44829d4c8 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceDisbandCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceDisbandCommand.java @@ -15,6 +15,11 @@ public class PartyAllianceDisbandCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 2: + if(UserManager.getPlayer((Player) sender) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } Player player = (Player) sender; McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); Party party = mcMMOPlayer.getParty(); 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 b0c41455d..97461021a 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 @@ -24,6 +24,13 @@ public class PartyAllianceInviteCommand implements CommandExecutor { } Player target = mcMMOTarget.getPlayer(); + + if(UserManager.getPlayer((Player) sender) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + Player player = (Player) sender; McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); String playerName = player.getName(); diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java index b66f909e4..a22200d23 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java @@ -20,6 +20,12 @@ public class PtpAcceptCommand implements CommandExecutor { return true; } + if(UserManager.getPlayer((Player) sender) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + Player player = (Player) sender; PartyTeleportRecord ptpRecord = UserManager.getPlayer(player).getPartyTeleportRecord(); diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java index da8c5a05f..5ba7b5654 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java @@ -59,6 +59,12 @@ public class PtpCommand implements TabExecutor { return true; } + if(UserManager.getPlayer((Player) sender) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); if (!mcMMOPlayer.inParty()) { @@ -131,6 +137,12 @@ public class PtpCommand implements TabExecutor { List matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList(TELEPORT_SUBCOMMANDS.size())); if (matches.size() == 0) { + if(UserManager.getPlayer((Player) sender) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return ImmutableList.of(); + } + Player player = (Player) sender; McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); @@ -205,6 +217,18 @@ public class PtpCommand implements TabExecutor { } protected static void handleTeleportWarmup(Player teleportingPlayer, Player targetPlayer) { + if(UserManager.getPlayer(targetPlayer) == null) + { + targetPlayer.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return; + } + + if(UserManager.getPlayer(teleportingPlayer) == null) + { + teleportingPlayer.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return; + } + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer); McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetPlayer); diff --git a/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java index f9baec207..7a856f301 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java @@ -38,6 +38,12 @@ public class MccooldownCommand implements TabExecutor { } } + if(UserManager.getPlayer(player) == null) + { + player.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header")); 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 b2dd01241..b07fd4e5f 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -88,6 +88,13 @@ public class McrankCommand implements TabExecutor { private void display(CommandSender sender, String playerName) { if (sender instanceof Player) { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName()); + + if(mcMMOPlayer == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return; + } + long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750); if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) { diff --git a/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java index bbcf51095..187d866eb 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java @@ -26,6 +26,12 @@ public class McstatsCommand implements TabExecutor { switch (args.length) { case 0: + if(UserManager.getPlayer((Player) sender) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + Player player = (Player) sender; if (Config.getInstance().getStatsUseBoard() && Config.getInstance().getScoreboardsEnabled()) { diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AlchemyCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AlchemyCommand.java index c896ac9c4..3c68c0af9 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AlchemyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AlchemyCommand.java @@ -30,6 +30,13 @@ public class AlchemyCommand extends SkillCommand { } protected String[] calculateAbilityDisplayValues(Player player) { + //TODO: Needed? + if(UserManager.getPlayer(player) == null) + { + player.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return new String[] {"DATA NOT LOADED", "DATA NOT LOADED"}; + } + AlchemyManager alchemyManager = UserManager.getPlayer(player).getAlchemyManager(); String[] displayValues = new String[2]; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java index 4dc1a67ea..7d6765e06 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java @@ -56,6 +56,12 @@ public abstract class SkillCommand implements TabExecutor { return true; } + if(UserManager.getPlayer((Player) sender) == null) + { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + switch (args.length) { case 0: Player player = (Player) sender; 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 4b9613ce1..cd89f8fd0 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -542,7 +542,7 @@ public class McMMOPlayer { */ private void checkXp(PrimarySkillType primarySkillType, XPGainReason xpGainReason, XPGainSource xpGainSource) { if (getSkillXpLevelRaw(primarySkillType) < getXpToLevel(primarySkillType)) { - UserManager.getPlayer(player).processPostXpEvent(xpGainReason, primarySkillType, mcMMO.p, xpGainSource); + processPostXpEvent(xpGainReason, primarySkillType, mcMMO.p, xpGainSource); return; } @@ -560,7 +560,7 @@ public class McMMOPlayer { } if (!EventUtils.handleLevelChangeEvent(player, primarySkillType, levelsGained, xpRemoved, true, xpGainReason)) { - UserManager.getPlayer(player).processPostXpEvent(xpGainReason, primarySkillType, mcMMO.p, xpGainSource); + processPostXpEvent(xpGainReason, primarySkillType, mcMMO.p, xpGainSource); return; } @@ -572,10 +572,10 @@ public class McMMOPlayer { * Check to see if the player unlocked any new skills */ - NotificationManager.sendPlayerLevelUpNotification(UserManager.getPlayer(player), primarySkillType, levelsGained, profile.getSkillLevel(primarySkillType)); + NotificationManager.sendPlayerLevelUpNotification(this, primarySkillType, levelsGained, profile.getSkillLevel(primarySkillType)); //UPDATE XP BARS - UserManager.getPlayer(player).processPostXpEvent(xpGainReason, primarySkillType, mcMMO.p, xpGainSource); + processPostXpEvent(xpGainReason, primarySkillType, mcMMO.p, xpGainSource); } /* diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java index 5beeb42ab..d78d1f5c0 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java @@ -21,6 +21,7 @@ import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; +import com.google.common.collect.ImmutableList; import net.md_5.bungee.api.chat.ComponentBuilder; import org.bukkit.Location; import org.bukkit.Material; @@ -68,6 +69,9 @@ public class Roll extends AcrobaticsSubSkill { //Grab the player McMMOPlayer mcMMOPlayer = EventUtils.getMcMMOPlayer(entityDamageEvent.getEntity()); + if(mcMMOPlayer == null) + break; + /* * Check for success */ @@ -275,7 +279,6 @@ public class Roll extends AcrobaticsSubSkill { return true; } - if(UserManager.getPlayer(player).getAcrobaticsManager().hasFallenInLocationBefore(getBlockLocation(player))) return true; diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 956af224c..37a16afb7 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -10,6 +10,7 @@ import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.events.fake.FakeBlockBreakEvent; import com.gmail.nossr50.events.fake.FakeBlockDamageEvent; +import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.alchemy.Alchemy; import com.gmail.nossr50.skills.excavation.ExcavationManager; @@ -29,6 +30,7 @@ import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardUtils; +import com.google.common.collect.ImmutableList; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; @@ -244,6 +246,9 @@ public class BlockListener implements Listener { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + if(mcMMOPlayer == null) + return; + if (blockState.getType() == Repair.anvilMaterial && PrimarySkillType.REPAIR.getPermissions(player)) { mcMMOPlayer.getRepairManager().placedAnvilCheck(); } @@ -337,6 +342,11 @@ public class BlockListener implements Listener { } McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + + //Check if profile is loaded + if(mcMMOPlayer == null) + return; + ItemStack heldItem = player.getInventory().getItemInMainHand(); /* HERBALISM */ @@ -416,6 +426,12 @@ public class BlockListener implements Listener { return; } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + BlockState blockState = event.getBlock().getState(); ItemStack heldItem = player.getInventory().getItemInMainHand(); @@ -481,6 +497,12 @@ public class BlockListener implements Listener { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + //Profile not loaded + if(mcMMOPlayer == null) + { + return; + } + /* * ABILITY PREPARATION CHECKS * @@ -555,6 +577,13 @@ public class BlockListener implements Listener { } McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + ItemStack heldItem = player.getInventory().getItemInMainHand(); Block block = event.getBlock(); BlockState blockState = block.getState(); @@ -590,6 +619,14 @@ public class BlockListener implements Listener { public void onBlockDamageCleanup(BlockDamageEvent event) { Player player = event.getPlayer(); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + + BlockState blockState = event.getBlock().getState(); ItemStack heldItem = player.getInventory().getItemInMainHand(); @@ -600,6 +637,12 @@ public class BlockListener implements Listener { } public void debugStickDump(Player player, BlockState blockState) { + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + if(player.getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) { if(mcMMO.getPlaceStore().isTrue(blockState)) diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 748b4f9c7..649fcfa28 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -479,6 +479,10 @@ public class EntityListener implements Listener { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + //Profile not loaded + if(mcMMOPlayer == null) + return; + /* Check for invincibility */ if (mcMMOPlayer.getGodMode()) { event.setCancelled(true); @@ -510,6 +514,12 @@ public class EntityListener implements Listener { Player player = (Player) owner; Wolf wolf = (Wolf) pet; + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + TamingManager tamingManager = UserManager.getPlayer(player).getTamingManager(); switch (cause) { @@ -687,6 +697,12 @@ public class EntityListener implements Listener { return; } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + /* WORLD GUARD MAIN FLAG CHECK */ if(WorldGuardUtils.isWorldGuardLoaded()) { @@ -734,6 +750,12 @@ public class EntityListener implements Listener { return; } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + MiningManager miningManager = UserManager.getPlayer(player).getMiningManager(); if (miningManager.canUseBlastMining()) { @@ -783,6 +805,12 @@ public class EntityListener implements Listener { Player player = (Player) entity; + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + /* WORLD GUARD MAIN FLAG CHECK */ if(WorldGuardUtils.isWorldGuardLoaded()) { @@ -894,6 +922,13 @@ public class EntityListener implements Listener { } entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); + + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + UserManager.getPlayer(player).getTamingManager().awardTamingXP(entity); } diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index ea1ab8433..fb080fa32 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -57,6 +57,12 @@ public class InventoryListener implements Listener { return; } + //Profile not loaded + if(UserManager.getPlayer((Player) player) == null) + { + return; + } + if(!furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).size() == 0) furnaceBlock.setMetadata(mcMMO.furnaceMetadataKey, UserManager.getPlayer((Player) player).getPlayerMetadata()); } @@ -109,6 +115,12 @@ public class InventoryListener implements Listener { return; } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + event.setBurnTime(UserManager.getPlayer(player).getSmeltingManager().fuelEfficiency(event.getBurnTime())); } @@ -138,6 +150,12 @@ public class InventoryListener implements Listener { return; } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + event.setResult(UserManager.getPlayer(player).getSmeltingManager().smeltProcessing(smelting, event.getResult())); } @@ -166,6 +184,12 @@ public class InventoryListener implements Listener { return; } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + int exp = UserManager.getPlayer(player).getSmeltingManager().vanillaXPBoost(event.getExpToDrop()); event.setExpToDrop(exp); } @@ -188,6 +212,12 @@ public class InventoryListener implements Listener { if (furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).size() > 0) furnaceBlock.removeMetadata(mcMMO.furnaceMetadataKey, mcMMO.p); + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + furnaceBlock.setMetadata(mcMMO.furnaceMetadataKey, UserManager.getPlayer(player).getPlayerMetadata()); } } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index ce52b80cd..63e54e99b 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -80,6 +80,12 @@ public class PlayerListener implements Listener { return; } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + UserManager.getPlayer(player).actualizeTeleportATS(); } @@ -185,6 +191,12 @@ public class PlayerListener implements Listener { return; } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); mcMMOPlayer.checkGodMode(); @@ -250,6 +262,12 @@ public class PlayerListener implements Listener { return; } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager(); switch (event.getState()) { @@ -321,6 +339,12 @@ public class PlayerListener implements Listener { return; } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + Entity caught = event.getCaught(); FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager(); @@ -411,6 +435,12 @@ public class PlayerListener implements Listener { return; } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); Item drop = event.getItem(); @@ -463,6 +493,12 @@ public class PlayerListener implements Listener { return; } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); mcMMOPlayer.logout(false); } @@ -513,6 +549,12 @@ public class PlayerListener implements Listener { return; } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + UserManager.getPlayer(player).actualizeRespawnATS(); } @@ -540,6 +582,12 @@ public class PlayerListener implements Listener { return; } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); MiningManager miningManager = mcMMOPlayer.getMiningManager(); Block block = event.getClickedBlock(); @@ -643,6 +691,12 @@ public class PlayerListener implements Listener { return; } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); ItemStack heldItem = player.getInventory().getItemInMainHand(); diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index 4bdcefe9b..33913f13c 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -98,6 +98,18 @@ public final class PartyManager { * @return true if they are in the same party, false otherwise */ public static boolean inSameParty(Player firstPlayer, Player secondPlayer) { + //Profile not loaded + if(UserManager.getPlayer(firstPlayer) == null) + { + return false; + } + + //Profile not loaded + if(UserManager.getPlayer(secondPlayer) == null) + { + return false; + } + Party firstParty = UserManager.getPlayer(firstPlayer).getParty(); Party secondParty = UserManager.getPlayer(secondPlayer).getParty(); @@ -109,6 +121,18 @@ public final class PartyManager { } public static boolean areAllies(Player firstPlayer, Player secondPlayer) { + //Profile not loaded + if(UserManager.getPlayer(firstPlayer) == null) + { + return false; + } + + //Profile not loaded + if(UserManager.getPlayer(secondPlayer) == null) + { + return false; + } + Party firstParty = UserManager.getPlayer(firstPlayer).getParty(); Party secondParty = UserManager.getPlayer(secondPlayer).getParty(); @@ -263,6 +287,12 @@ public final class PartyManager { * @return the existing party, null otherwise */ public static Party getParty(Player player) { + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return null; + } + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); return mcMMOPlayer.getParty(); @@ -322,7 +352,14 @@ public final class PartyManager { * @param party The party to remove */ public static void disbandParty(Party party) { + //TODO: Potential issues with unloaded profile? for (Player member : party.getOnlineMembers()) { + //Profile not loaded + if(UserManager.getPlayer(member) == null) + { + continue; + } + processPartyLeaving(UserManager.getPlayer(member)); } diff --git a/src/main/java/com/gmail/nossr50/party/ShareHandler.java b/src/main/java/com/gmail/nossr50/party/ShareHandler.java index 0cdafff8f..c0a78e253 100644 --- a/src/main/java/com/gmail/nossr50/party/ShareHandler.java +++ b/src/main/java/com/gmail/nossr50/party/ShareHandler.java @@ -48,6 +48,12 @@ public final class ShareHandler { float splitXp = (float) (xp / partySize * shareBonus); for (Player member : nearMembers) { + //Profile not loaded + if(UserManager.getPlayer(member) == null) + { + continue; + } + UserManager.getPlayer(member).beginUnsharedXpGain(primarySkillType, splitXp, xpGainReason, XPGainSource.PARTY_MEMBERS); } @@ -105,6 +111,13 @@ public final class ShareHandler { for (Player member : nearMembers) { McMMOPlayer mcMMOMember = UserManager.getPlayer(member); + + //Profile not loaded + if(UserManager.getPlayer(member) == null) + { + continue; + } + int itemShareModifier = mcMMOMember.getItemShareModifier(); int diceRoll = Misc.getRandom().nextInt(itemShareModifier); diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java index c7fb56760..076cef3e2 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java @@ -37,7 +37,11 @@ public class AlchemyBrewTask extends BukkitRunnable { brewSpeed = DEFAULT_BREW_SPEED; brewTimer = DEFAULT_BREW_TICKS; - if (player != null && !Misc.isNPCEntity(player) && Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CATALYSIS)) { + if (player != null + && !Misc.isNPCEntity(player) + && Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CATALYSIS) + && UserManager.getPlayer(player) != null) { + double catalysis = UserManager.getPlayer(player).getAlchemyManager().calculateBrewSpeed(Permissions.lucky(player, PrimarySkillType.ALCHEMY)); McMMOPlayerCatalysisEvent event = new McMMOPlayerCatalysisEvent(player, catalysis); 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 9d1f902ca..96d1bc5e8 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java @@ -93,6 +93,11 @@ public final class AlchemyPotionBrewer { } private static List getValidIngredients(Player player) { + if(UserManager.getPlayer(player) != null) + { + return PotionConfig.getInstance().getIngredients(1); + } + return PotionConfig.getInstance().getIngredients((player == null || !Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CONCOCTIONS)) ? 1 : UserManager.getPlayer(player).getAlchemyManager().getTier()); } @@ -142,6 +147,7 @@ public final class AlchemyPotionBrewer { if (output != null && player != null) { PotionStage potionStage = PotionStage.getPotionStage(input, output); + //TODO: hmm if (UserManager.hasPlayerDataKey(player)) { UserManager.getPlayer(player).getAlchemyManager().handlePotionBrewSuccesses(potionStage, 1); } diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java index 32e38190b..b67c72274 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -9,7 +9,6 @@ import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.NotificationManager; -import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.SkillActivationType; @@ -90,7 +89,8 @@ public class ArcheryManager extends SkillManager { defender.teleport(dazedLocation); defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10)); - if (UserManager.getPlayer(defender).useChatNotifications()) { + + if (NotificationManager.doesPlayerUseNotifications(defender)) { NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Combat.TouchedFuzzy"); } diff --git a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java index 4a15bb45d..88c1136ab 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java @@ -95,7 +95,7 @@ public class AxesManager extends SkillManager { if (target instanceof Player) { Player defender = (Player) target; - if (UserManager.getPlayer(defender).useChatNotifications()) { + if (NotificationManager.doesPlayerUseNotifications(defender)) { NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.CritStruck"); } @@ -152,7 +152,7 @@ public class AxesManager extends SkillManager { if (target instanceof Player) { Player defender = (Player) target; - if (UserManager.getPlayer(defender).useChatNotifications()) { + if (NotificationManager.doesPlayerUseNotifications(defender)) { NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.GI.Struck"); } } diff --git a/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java b/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java index 5ed629a80..a299bb0be 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java @@ -103,6 +103,11 @@ public class BlastMining { return false; } + if(UserManager.getPlayer(defender) == null) + { + return false; + } + MiningManager miningManager = UserManager.getPlayer(defender).getMiningManager(); if (!miningManager.canUseDemolitionsExpertise()) { diff --git a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java index 59be2626b..e49ad5198 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java @@ -70,7 +70,7 @@ public class SwordsManager extends SkillManager { if(defender.isBlocking()) return; - if (UserManager.getPlayer(defender).useChatNotifications()) { + if (NotificationManager.doesPlayerUseNotifications(defender)) { if(!BleedTimerTask.isBleeding(defender)) NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding.Started"); } 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 d16ea91cc..a3f6765a5 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -225,7 +225,7 @@ public class TamingManager extends SkillManager { if (target instanceof Player) { Player defender = (Player) target; - if (UserManager.getPlayer(defender).useChatNotifications()) { + if (NotificationManager.doesPlayerUseNotifications(defender)) { NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Taming.SubSkill.Pummel.TargetMessage"); } } 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 af30a24c6..1ce5733f9 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -101,6 +101,9 @@ public class UnarmedManager extends SkillManager { return; } + if(UserManager.getPlayer(defender) == null) + return; + Item item = Misc.dropItem(defender.getLocation(), defender.getInventory().getItemInMainHand()); if (item != null && AdvancedConfig.getInstance().getDisarmProtected()) { diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index b8897d945..c1a82f9af 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -54,6 +54,10 @@ public final class ChimaeraWing { mcMMOPlayer = UserManager.getPlayer(player); + //Not loaded + if(mcMMOPlayer == null) + return; + if (mcMMOPlayer.getTeleportCommenceLocation() != null) { return; } diff --git a/src/main/java/com/gmail/nossr50/util/EventUtils.java b/src/main/java/com/gmail/nossr50/util/EventUtils.java index a96474f35..3f8b5a5a3 100644 --- a/src/main/java/com/gmail/nossr50/util/EventUtils.java +++ b/src/main/java/com/gmail/nossr50/util/EventUtils.java @@ -120,11 +120,16 @@ public class EventUtils { Player player = (Player) entity; if (!UserManager.hasPlayerDataKey(player)) { - return false; + return true; } McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + if(mcMMOPlayer == null) + { + return true; + } + /* Check for invincibility */ if (mcMMOPlayer.getGodMode()) { entityDamageEvent.setCancelled(true); @@ -242,6 +247,9 @@ public class EventUtils { public static void handlePartyTeleportEvent(Player teleportingPlayer, Player targetPlayer) { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer); + if(mcMMOPlayer == null) + return; + McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(teleportingPlayer, targetPlayer, mcMMOPlayer.getParty().getName()); mcMMO.p.getServer().getPluginManager().callEvent(event); @@ -300,6 +308,9 @@ public class EventUtils { } public static boolean handleStatsLossEvent(Player player, HashMap levelChanged, HashMap experienceChanged) { + if(UserManager.getPlayer(player) == null) + return true; + McMMOPlayerStatLossEvent event = new McMMOPlayerStatLossEvent(player, levelChanged, experienceChanged); mcMMO.p.getServer().getPluginManager().callEvent(event); @@ -346,6 +357,15 @@ public class EventUtils { HashMap experienceChangedVictim = eventVictim.getExperienceChanged(); McMMOPlayer killerPlayer = UserManager.getPlayer(killer); + + //Not loaded + if(killerPlayer == null) + return true; + + //Not loaded + if(UserManager.getPlayer(victim) == null) + return true; + PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile(); for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) { diff --git a/src/main/java/com/gmail/nossr50/util/HardcoreManager.java b/src/main/java/com/gmail/nossr50/util/HardcoreManager.java index 944df8cac..1ad92f15a 100644 --- a/src/main/java/com/gmail/nossr50/util/HardcoreManager.java +++ b/src/main/java/com/gmail/nossr50/util/HardcoreManager.java @@ -17,6 +17,9 @@ public final class HardcoreManager { double statLossPercentage = Config.getInstance().getHardcoreDeathStatPenaltyPercentage(); int levelThreshold = Config.getInstance().getHardcoreDeathStatPenaltyLevelThreshold(); + if(UserManager.getPlayer(player) == null) + return; + PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile(); int totalLevelsLost = 0; @@ -59,6 +62,9 @@ public final class HardcoreManager { double vampirismStatLeechPercentage = Config.getInstance().getHardcoreVampirismStatLeechPercentage(); int levelThreshold = Config.getInstance().getHardcoreVampirismLevelThreshold(); + if(UserManager.getPlayer(killer) == null || UserManager.getPlayer(victim) == null) + return; + PlayerProfile killerProfile = UserManager.getPlayer(killer).getProfile(); PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile(); int totalLevelsStolen = 0; diff --git a/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java index c23f06298..e5dc13558 100644 --- a/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java +++ b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java @@ -223,6 +223,9 @@ public final class CommandUtils { } private static void printGroupedSkillData(Player inspect, CommandSender display, String header, List skillGroup) { + if(UserManager.getPlayer(inspect) == null) + return; + PlayerProfile profile = UserManager.getPlayer(inspect).getProfile(); List displayData = new ArrayList(); diff --git a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java index b47627ff4..2f46df5a0 100644 --- a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java +++ b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java @@ -28,7 +28,7 @@ public class NotificationManager { */ public static void sendPlayerInformation(Player player, NotificationType notificationType, String key) { - if(!UserManager.getPlayer(player).useChatNotifications()) + if(UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications()) return; ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM; @@ -39,6 +39,15 @@ public class NotificationManager { sendNotification(player, customEvent); } + + public static boolean doesPlayerUseNotifications(Player player) + { + if(UserManager.getPlayer(player) == null) + return false; + else + return UserManager.getPlayer(player).useChatNotifications(); + } + /** * Sends players notifications from mcMMO * This does this by sending out an event so other plugins can cancel it @@ -60,7 +69,7 @@ public class NotificationManager { public static void sendPlayerInformation(Player player, NotificationType notificationType, String key, String... values) { - if(!UserManager.getPlayer(player).useChatNotifications()) + if(UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications()) return; ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM; @@ -108,7 +117,7 @@ public class NotificationManager { */ public static void sendPlayerLevelUpNotification(McMMOPlayer mcMMOPlayer, PrimarySkillType skillName, int levelsGained, int newLevel) { - if(!UserManager.getPlayer(mcMMOPlayer.getPlayer()).useChatNotifications()) + if(!mcMMOPlayer.useChatNotifications()) return; ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(NotificationType.LEVEL_UP_MESSAGE) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM; @@ -129,7 +138,7 @@ public class NotificationManager { public static void sendPlayerUnlockNotification(McMMOPlayer mcMMOPlayer, SubSkillType subSkillType) { - if(!UserManager.getPlayer(mcMMOPlayer.getPlayer()).useChatNotifications()) + if(!mcMMOPlayer.useChatNotifications()) return; //CHAT MESSAGE 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 ff0a53597..85506be2f 100644 --- a/src/main/java/com/gmail/nossr50/util/player/UserManager.java +++ b/src/main/java/com/gmail/nossr50/util/player/UserManager.java @@ -1,5 +1,6 @@ package com.gmail.nossr50.util.player; +import com.gmail.nossr50.api.exceptions.McMMOPlayerNotFoundException; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.mcMMO; import com.google.common.collect.ImmutableList; @@ -95,12 +96,17 @@ public final class UserManager { return retrieveMcMMOPlayer(playerName, true); } - public static McMMOPlayer getPlayer(Player player) { + /** + * Gets the McMMOPlayer object for a player, this can be null if the player has not yet been loaded. + * @param player target player + * @return McMMOPlayer object for this player, null if Player has not been loaded + */ + public static McMMOPlayer getPlayer(Player player) throws McMMOPlayerNotFoundException { //Avoid Array Index out of bounds if(player.hasMetadata(mcMMO.playerDataKey)) return (McMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value(); else - return null; + throw new McMMOPlayerNotFoundException(player); } private static McMMOPlayer retrieveMcMMOPlayer(String playerName, boolean offlineValid) { diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java index d2cc8da3d..bf5b4f367 100644 --- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java @@ -205,6 +205,9 @@ public class ScoreboardWrapper { // TODO is there any way to do the time that looks acceptable? // player.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Timer", StringUtils.capitalize(sidebarType.toString().toLowerCase()), ticks / 20F)); + if(UserManager.getPlayer(playerName) == null) + return; + PlayerProfile profile = UserManager.getPlayer(player).getProfile(); if (profile.getScoreboardTipsShown() >= Config.getInstance().getTipsAmount()) { @@ -435,6 +438,9 @@ public class ScoreboardWrapper { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + if(mcMMOPlayer == null) + return; + switch (sidebarType) { case NONE: break; diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index a9dd669ed..fbd9e8a13 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -628,6 +628,10 @@ public final class CombatUtils { if (entity instanceof Player) { Player defender = (Player) entity; + //TODO: NPC Interaction? + if(UserManager.getPlayer(defender) == null) + return true; + if (!defender.getWorld().getPVP() || defender == player || UserManager.getPlayer(defender).getGodMode()) { return false; } diff --git a/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java b/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java index b5df535a0..e854b1874 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java @@ -172,6 +172,9 @@ public class RankUtils { //Get our rank map HashMap rankMap = subSkillRanks.get(skillName); + if(UserManager.getPlayer(player) == null) + return 0; + //Skill level of parent skill int currentSkillLevel = UserManager.getPlayer(player).getSkillLevel(subSkillType.getParentSkill()); @@ -216,6 +219,9 @@ public class RankUtils { //Get our rank map HashMap rankMap = subSkillRanks.get(skillName); + if(UserManager.getPlayer(player) == null) + return 0; + //Skill level of parent skill int currentSkillLevel = UserManager.getPlayer(player).getSkillLevel(abstractSubSkill.getPrimarySkill()); diff --git a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java index ae1d75474..da495346f 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -167,6 +167,11 @@ public class SkillUtils { } McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + + //Not Loaded + if(mcMMOPlayer == null) + return; + PrimarySkillType skill = mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER) ? PrimarySkillType.MINING : PrimarySkillType.EXCAVATION; int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength(); diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 411eb88d4..52de864cb 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -1068,6 +1068,7 @@ Scoreboard.Misc.Cooldown=[[LIGHT_PURPLE]]Cooldown Scoreboard.Misc.Overall=[[GOLD]]Overall Scoreboard.Misc.Ability=Ability #DATABASE RECOVERY +Profile.PendingLoad=[[RED]]Your mcMMO player data has not yet been loaded. Profile.Loading.Success=[[GREEN]]Your mcMMO profile has been loaded. Profile.Loading.FailurePlayer=[[RED]]mcMMO is having trouble loading your data, we have attempted to load it [[GREEN]]{0}[[RED]] times.[[LIGHT_GRAY]] You may want to contact the server admins about this issue. mcMMO will attempt to load your data until you disconnect, you will not gain XP or be able to use skills while the data is not loaded. Profile.Loading.FailureNotice=[[DARK_RED]][A][[RED]] mcMMO was unable to load the player data for [[YELLOW]]{0}[[RED]]. [[LIGHT_PURPLE]]Please inspect your database setup. Attempts made so far {1}. From 6e3c2fcb76472530d8a4246ddfa62d6308e0428c Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 12 Apr 2019 15:24:01 -0700 Subject: [PATCH 02/16] Fix mcrank cd display --- Changelog.txt | 1 + .../com/gmail/nossr50/commands/player/McrankCommand.java | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 6bcf2a1ac..9806d5f17 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -10,6 +10,7 @@ Key: Version 2.1.41 Fixed NullPointerException errors when trying to grab PlayerProfiles for players who have not loaded Added new locale string Profile.PendingLoad + Fixed a display error preventing the remaining time on /mcrank from being shown if it was on cooldown Version 2.1.40 (API) mcMMO will now return null in all cases for UserManager.getPlayerProfile() if they have not been loaded yet 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 b07fd4e5f..742f5490d 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -98,7 +98,7 @@ public class McrankCommand implements TabExecutor { long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750); if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) { - sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown")); + sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown", getCDSeconds(mcMMOPlayer, cooldownMillis)); return; } @@ -117,4 +117,8 @@ public class McrankCommand implements TabExecutor { new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p); } + + private long getCDSeconds(McMMOPlayer mcMMOPlayer, long cooldownMillis) { + return (System.currentTimeMillis() - (mcMMOPlayer.getDatabaseATS() + cooldownMillis)) / 1000; + } } From 8c0076ff800de43e1a1dcdecef7370e9b8eb521c Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 12 Apr 2019 15:24:57 -0700 Subject: [PATCH 03/16] 2.1.41 --- pom.xml | 2 +- .../java/com/gmail/nossr50/commands/player/McrankCommand.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index f70a5bc37..7e4a1dc0d 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.41-SNAPSHOT + 2.1.41 mcMMO https://github.com/mcMMO-Dev/mcMMO 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 742f5490d..e61bd733f 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -98,7 +98,7 @@ public class McrankCommand implements TabExecutor { long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750); if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) { - sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown", getCDSeconds(mcMMOPlayer, cooldownMillis)); + sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown", getCDSeconds(mcMMOPlayer, cooldownMillis))); return; } From b5cbfc7f66feec50248738025a6b554b399fe7eb Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 12 Apr 2019 15:29:37 -0700 Subject: [PATCH 04/16] Commands.Database.CooldownMS - new locale string --- Changelog.txt | 1 + .../com/gmail/nossr50/commands/player/McrankCommand.java | 6 +++--- src/main/resources/locale/locale_en_US.properties | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 9806d5f17..3daef5543 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -10,6 +10,7 @@ Key: Version 2.1.41 Fixed NullPointerException errors when trying to grab PlayerProfiles for players who have not loaded Added new locale string Profile.PendingLoad + Added new locale string Commands.Database.CooldownMS Fixed a display error preventing the remaining time on /mcrank from being shown if it was on cooldown Version 2.1.40 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 e61bd733f..86b6e239e 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -95,10 +95,10 @@ public class McrankCommand implements TabExecutor { return; } - long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750); + long cooldownMillis = Math.min(Config.getInstance().getDatabasePlayerCooldown(), 1750); if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) { - sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown", getCDSeconds(mcMMOPlayer, cooldownMillis))); + sender.sendMessage(LocaleLoader.getString("Commands.Database.CooldownMS", getCDSeconds(mcMMOPlayer, cooldownMillis))); return; } @@ -119,6 +119,6 @@ public class McrankCommand implements TabExecutor { } private long getCDSeconds(McMMOPlayer mcMMOPlayer, long cooldownMillis) { - return (System.currentTimeMillis() - (mcMMOPlayer.getDatabaseATS() + cooldownMillis)) / 1000; + return (System.currentTimeMillis() - (mcMMOPlayer.getDatabaseATS() + cooldownMillis)); } } diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 52de864cb..c9e1f4e82 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -569,7 +569,7 @@ Commands.Chat.Console=*Console* Commands.Cooldowns.Header=[[GOLD]]--= [[GREEN]]mcMMO Ability Cooldowns[[GOLD]] =-- Commands.Cooldowns.Row.N=\ [[RED]]{0}[[WHITE]] - [[GOLD]]{1} seconds left Commands.Cooldowns.Row.Y=\ [[AQUA]]{0}[[WHITE]] - [[DARK_GREEN]]Ready! -Commands.Database.Cooldown=You must wait {0} seconds before using this command again. +Commands.Database.CooldownMS=You must wait {0} milliseconds before using this command again. Commands.Database.Processing=Your previous command is still being processed. Please wait. Commands.Disabled=This command is disabled. Commands.DoesNotExist= [[RED]]Player does not exist in the database! From 2a053a0be2682a05c29566ea1a05047648429a51 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 12 Apr 2019 15:34:33 -0700 Subject: [PATCH 05/16] Fixing logic error in mcrank CD msg --- .../java/com/gmail/nossr50/commands/player/McrankCommand.java | 2 +- .../nossr50/datatypes/skills/subskills/acrobatics/Roll.java | 1 - src/main/java/com/gmail/nossr50/listeners/BlockListener.java | 2 -- src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java | 1 - .../java/com/gmail/nossr50/skills/swords/SwordsManager.java | 1 - .../java/com/gmail/nossr50/skills/taming/TamingManager.java | 1 - 6 files changed, 1 insertion(+), 7 deletions(-) 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 86b6e239e..dc4150afd 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -119,6 +119,6 @@ public class McrankCommand implements TabExecutor { } private long getCDSeconds(McMMOPlayer mcMMOPlayer, long cooldownMillis) { - return (System.currentTimeMillis() - (mcMMOPlayer.getDatabaseATS() + cooldownMillis)); + return ((mcMMOPlayer.getDatabaseATS() + cooldownMillis) - System.currentTimeMillis()); } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java index d78d1f5c0..d889286ed 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java @@ -21,7 +21,6 @@ import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; -import com.google.common.collect.ImmutableList; import net.md_5.bungee.api.chat.ComponentBuilder; import org.bukkit.Location; import org.bukkit.Material; diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 37a16afb7..70dfa97c5 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -10,7 +10,6 @@ import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.events.fake.FakeBlockBreakEvent; import com.gmail.nossr50.events.fake.FakeBlockDamageEvent; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.alchemy.Alchemy; import com.gmail.nossr50.skills.excavation.ExcavationManager; @@ -30,7 +29,6 @@ import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardUtils; -import com.google.common.collect.ImmutableList; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; diff --git a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java index 88c1136ab..2346faa9c 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java @@ -10,7 +10,6 @@ import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.NotificationManager; -import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.skills.*; import org.bukkit.entity.LivingEntity; diff --git a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java index e49ad5198..e876957d8 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java @@ -11,7 +11,6 @@ import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.NotificationManager; -import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.RankUtils; 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 a3f6765a5..944cdd5d1 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -17,7 +17,6 @@ import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.player.NotificationManager; -import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.skills.ParticleEffectUtils; From f6e01ea910b006e1ece8ec601ae8ecb734288f93 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 13 Apr 2019 12:58:32 -0700 Subject: [PATCH 06/16] UserManager::getPlayer returns null again (oopsie) --- Changelog.txt | 6 ++++++ pom.xml | 2 +- .../java/com/gmail/nossr50/util/player/UserManager.java | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 3daef5543..5608b6582 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,6 +7,12 @@ Key: ! Change - Removal +Version 2.1.42 + Fixed McMMOPlayerNotFoundException being thrown instead of null + (API) UserManager.getPlayer() returns null again (oopsie) + + NOTE: Sorry about that, when trying to improve Bungee Cord compatibility I made a big oopsie! + Version 2.1.41 Fixed NullPointerException errors when trying to grab PlayerProfiles for players who have not loaded Added new locale string Profile.PendingLoad diff --git a/pom.xml b/pom.xml index 7e4a1dc0d..fec088a57 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.41 + 2.1.42-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO 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 85506be2f..2e220790e 100644 --- a/src/main/java/com/gmail/nossr50/util/player/UserManager.java +++ b/src/main/java/com/gmail/nossr50/util/player/UserManager.java @@ -101,12 +101,12 @@ public final class UserManager { * @param player target player * @return McMMOPlayer object for this player, null if Player has not been loaded */ - public static McMMOPlayer getPlayer(Player player) throws McMMOPlayerNotFoundException { + public static McMMOPlayer getPlayer(Player player) { //Avoid Array Index out of bounds if(player.hasMetadata(mcMMO.playerDataKey)) return (McMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value(); else - throw new McMMOPlayerNotFoundException(player); + return null; } private static McMMOPlayer retrieveMcMMOPlayer(String playerName, boolean offlineValid) { From d542098f8adbc43deaad85afc4e688a27c99e7f4 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 13 Apr 2019 13:17:28 -0700 Subject: [PATCH 07/16] New salvage enchant bypass permission node --- Changelog.txt | 5 +++++ .../commands/skills/RepairCommand.java | 2 +- .../nossr50/skills/repair/RepairManager.java | 2 +- .../skills/salvage/SalvageManager.java | 4 ++++ .../com/gmail/nossr50/util/Permissions.java | 5 +++++ src/main/resources/plugin.yml | 19 +++++++++++++++++++ 6 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 5608b6582..9dc8c1b07 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -10,8 +10,13 @@ Key: Version 2.1.42 Fixed McMMOPlayerNotFoundException being thrown instead of null (API) UserManager.getPlayer() returns null again (oopsie) + Added new perk permission node `mcmmo.perks.bypass.salvageenchant` - guarantees full enchantment return for Salvage + Added alternative permission node `mcmmo.perks.bypass.repairenchant` - guarantees full enchantment return for Repair + Added new wildcard perk `mcmmo.perks.bypass.*` and `mcmmo.perks.bypass.all` (either of these will grant all new mcmmo.perks.bypass perk permissions) NOTE: Sorry about that, when trying to improve Bungee Cord compatibility I made a big oopsie! + NOTE: Repair's new perk permission works in the exact same way as mcmmo.bypass.arcanebypass, bypass perk permissions will all eventually be moved to `mcmmo.perks.bypass` + NOTE: Expect perk permissions to all be moved to `mcmmo.perks.X` in the near future Version 2.1.41 Fixed NullPointerException errors when trying to grab PlayerProfiles for players who have not loaded diff --git a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java index cd41d6ac8..1e590e644 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java @@ -86,7 +86,7 @@ public class RepairCommand extends SkillCommand { canRepairString = Permissions.repairMaterialType(player, MaterialType.STRING); canRepairLeather = Permissions.repairMaterialType(player, MaterialType.LEATHER); canRepairWood = Permissions.repairMaterialType(player, MaterialType.WOOD); - arcaneBypass = Permissions.arcaneBypass(player); + arcaneBypass = (Permissions.arcaneBypass(player) || Permissions.hasRepairEnchantBypassPerk(player)); } @Override diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java index 9ad9a96a6..9120f83f7 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -139,7 +139,7 @@ public class RepairManager extends SkillManager { } // Handle the enchants - if (ArcaneForging.arcaneForgingEnchantLoss) { + if (ArcaneForging.arcaneForgingEnchantLoss && !Permissions.hasRepairEnchantBypassPerk(player)) { addEnchants(item); } diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java index 68471b948..5227f824c 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java @@ -182,6 +182,9 @@ public class SalvageManager extends SkillManager { }*/ public double getExtractFullEnchantChance() { + if(Permissions.hasSalvageEnchantBypassPerk(getPlayer())) + return 100.0D; + return AdvancedConfig.getInstance().getArcaneSalvageExtractFullEnchantsChance(getArcaneSalvageRank()); } @@ -205,6 +208,7 @@ public class SalvageManager extends SkillManager { for (Entry enchant : enchants.entrySet()) { if (!Salvage.arcaneSalvageEnchantLoss + || Permissions.hasSalvageEnchantBypassPerk(player) || RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getExtractFullEnchantChance(), getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE))) { enchantMeta.addStoredEnchant(enchant.getKey(), enchant.getValue(), true); } diff --git a/src/main/java/com/gmail/nossr50/util/Permissions.java b/src/main/java/com/gmail/nossr50/util/Permissions.java index cda3cf831..dbbeef94f 100644 --- a/src/main/java/com/gmail/nossr50/util/Permissions.java +++ b/src/main/java/com/gmail/nossr50/util/Permissions.java @@ -106,6 +106,11 @@ public final class Permissions { * PERKS */ + /* BYPASS PERKS */ + + public static boolean hasRepairEnchantBypassPerk(Permissible permissible) { return permissible.hasPermission("mcmmo.perks.bypass.repairenchant"); } + public static boolean hasSalvageEnchantBypassPerk(Permissible permissible) { return permissible.hasPermission("mcmmo.perks.bypass.salvageenchant"); } + public static boolean lucky(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.lucky." + skill.toString().toLowerCase()); } /* XP PERKS */ diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index c7fb456a8..a42dbfbfd 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1328,6 +1328,8 @@ permissions: default: false description: implies access to all mcmmo perks children: + mcmmo.perks.bypass.salvageenchant: true + mcmmo.perks.bypass.repairenchant: true mcmmo.perks.activationtime.all: true mcmmo.perks.cooldowns.all: true mcmmo.perks.lucky.all: true @@ -1344,6 +1346,23 @@ permissions: mcmmo.perks.activationtime.eightseconds: true mcmmo.perks.activationtime.fourseconds: true mcmmo.perks.activationtime.twelveseconds: true + mcmmo.perks.bypass.*: + default: false + description: Perks that bypass certain RNG elements and guarantee success + children: + mcmmo.perks.bypass.all: true + mcmmo.perks.bypass.all: + default: false + description: Perks that bypass certain RNG elements and guarantee success + children: + mcmmo.perks.bypass.repairenchant: true + mcmmo.perks.bypass.salvageenchant: true + mcmmo.perks.bypass.repairenchant: + default: false + description: Guarantees repairing without enchantment degradation + mcmmo.perks.bypass.salvageenchant: + default: false + description: Guarantees salvage will return the best legal enchantment book mcmmo.perks.activationtime.eightseconds: default: false description: Increases activation time by 8 seconds From 4b13cbeb431378d25225ca4a3531c81e205cb51e Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 13 Apr 2019 13:20:49 -0700 Subject: [PATCH 08/16] 2.1.42 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fec088a57..38a666d14 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.42-SNAPSHOT + 2.1.42 mcMMO https://github.com/mcMMO-Dev/mcMMO From ea9f79291e36c72cbb92b416ac315b8f262c508c Mon Sep 17 00:00:00 2001 From: "Robert A. C" Date: Sat, 13 Apr 2019 15:51:03 -0700 Subject: [PATCH 09/16] Update readme.md Adjusting the team information to represent the current state of the project --- README.md | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index efd8e3c37..c1447e0d0 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ I'm working on a brand new website for mcMMO You can check it out here http://www.mcmmo.org +Spigot Resource: https://www.spigotmc.org/resources/official-mcmmo-original-author-returns.64348/ I plan to post links to our new wiki (its still under development), downloads, and dev blogs there. @@ -16,26 +17,31 @@ Currently, you can obtain our builds via the Spigot resource page: http://spigot The goal of mcMMO is to take core Minecraft game mechanics and expand them into add an extensive and quality RPG experience. Everything in mcMMO has been carefully thought out and is constantly being improved upon. Currently, mcMMO adds fourteen unique skills to train and level in. Each of these skills is highly customizable through our configuration files, allowing server admins to tweak mcMMO to best suit the needs of his or her server. Know that the mcMMO team is dedicated to providing an ever-evolving experience, and that we carefully read all feedback and bug reports in order to evaluate and balance the mechanics of mcMMO in every update. ## About the Team -mcMMO is currently developed by a team of individuals from all over the world. +In December 2018 nossr50 returned as project lead for mcMMO once again to develop and improve mcMMO. +The mcMMO team currently has two members, nossr50 (lead) and t00thpick1 (classic maintainer). +mcMMO is currently developed almost entirely by nossr50, many thanks go out to the many developers who have worked on the project over the years. ### Project Lead & Founder [![nossr50](http://www.gravatar.com/avatar/f2ee41eedfd645fb4a3a2c8f6cb1b18c.png)](https://github.com/nossr50) -### Former Lead +Other mcMMO Projects + +### Classic Maintainer +[![t00thpick1](http://www.gravatar.com/avatar/ee23c7794a0c40120c3474287c7bce06.png)](https://github.com/t00thpick1) + +##Former Team Members + +### Former Lead & Awesome guy [![gmcferrin](http://www.gravatar.com/avatar/b64c52daf25d206b27650788b5813b7b.png)](https://github.com/gmcferrin) -### Developers +### Former team members [![bm01](http://www.gravatar.com/avatar/ec8146f5358177f12e9a252271bbc391.png)](https://github.com/bm01) [![Glitchfinder](http://www.gravatar.com/avatar/5aa4cce22f72ae9c002ecec30f061d00.png)](https://github.com/Glitchfinder) [![NuclearW](http://www.gravatar.com/avatar/90926bdcf1c8a75918df5ea5fa801ce6.png)](https://github.com/NuclearW) [![shatteredbeam](http://www.gravatar.com/avatar/cad3b5d7d39cf5387afb87f494389610.png)](https://github.com/shatteredbeam) [![TfT_02](http://www.gravatar.com/avatar/b8914f9970e1f6ffd5281ce4770e20a7.png)](https://github.com/TfT-02) -[![t00thpick1](http://www.gravatar.com/avatar/ee23c7794a0c40120c3474287c7bce06.png)](https://github.com/t00thpick1) [![riking](https://1.gravatar.com/avatar/aca9f37e569ac3a63929920035a91ba4.png)](https://github.com/riking) - -### Special thanks -[![EasyMFnE](https://www.gravatar.com/avatar/99c9a1fa3bbf957791ceac7b45daadb0.png)](https://github.com/EasyMFnE) -Added the Alchemy skill +[![TheYeti](https://avatars3.githubusercontent.com/u/594050?s=460&v=4)](https://github.com/TheYeti) ## Compiling @@ -46,5 +52,8 @@ The typical command used to build mcMMO is: `mvn clean package install` Required Libraries: * Bukkit * JUnit +* WorldGuard 7 +* bStats Bukkit http://spigot.mcmmo.org for more up to date information. +https://www.spigotmc.org/resources/official-mcmmo-original-author-returns.64348/ From e7e13d990a6bfe86996957d3cd335902ebc144ea Mon Sep 17 00:00:00 2001 From: "Robert A. C" Date: Sat, 13 Apr 2019 15:55:38 -0700 Subject: [PATCH 10/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c1447e0d0..3b662ffb5 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Other mcMMO Projects [![shatteredbeam](http://www.gravatar.com/avatar/cad3b5d7d39cf5387afb87f494389610.png)](https://github.com/shatteredbeam) [![TfT_02](http://www.gravatar.com/avatar/b8914f9970e1f6ffd5281ce4770e20a7.png)](https://github.com/TfT-02) [![riking](https://1.gravatar.com/avatar/aca9f37e569ac3a63929920035a91ba4.png)](https://github.com/riking) -[![TheYeti](https://avatars3.githubusercontent.com/u/594050?s=460&v=4)](https://github.com/TheYeti) +[![TheYeti](https://i.imgur.com/tzFrxdo.png)](https://github.com/TheYeti) ## Compiling From 908ac7c541de72eca2a0f8a34f836634e8065bfd Mon Sep 17 00:00:00 2001 From: "Robert A. C" Date: Sat, 13 Apr 2019 15:56:00 -0700 Subject: [PATCH 11/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3b662ffb5..e03a72b26 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Other mcMMO Projects ### Classic Maintainer [![t00thpick1](http://www.gravatar.com/avatar/ee23c7794a0c40120c3474287c7bce06.png)](https://github.com/t00thpick1) -##Former Team Members +## Former Team Members ### Former Lead & Awesome guy [![gmcferrin](http://www.gravatar.com/avatar/b64c52daf25d206b27650788b5813b7b.png)](https://github.com/gmcferrin) From 138b109ff5b2e6ef3195ef8909036e115f565cdc Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 13 Apr 2019 22:04:35 -0700 Subject: [PATCH 12/16] Correct display error when successfully salvaging enchantments --- Changelog.txt | 3 ++ pom.xml | 2 +- .../nossr50/listeners/BlockListener.java | 2 ++ .../skills/salvage/SalvageManager.java | 34 +++++++------------ 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 9dc8c1b07..39315d370 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,6 +7,9 @@ Key: ! Change - Removal +Version 2.1.43 + Fixed a bug that would result in players being told they they failed to salvage enchantments when in reality they succeeded. + Version 2.1.42 Fixed McMMOPlayerNotFoundException being thrown instead of null (API) UserManager.getPlayer() returns null again (oopsie) diff --git a/pom.xml b/pom.xml index 38a666d14..0c066e297 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.42 + 2.1.43-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 70dfa97c5..10d75d569 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -65,11 +65,13 @@ public class BlockListener implements Listener { if(is.getAmount() <= 0) continue; + //TODO: Ignore this abomination its rewritten in 2.2 if(!Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.MINING, is.getType()) && !Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.HERBALISM, is.getType()) && !Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.WOODCUTTING, is.getType())) continue; + //TODO: Should just store the amount of drops in the metadata itself and use a loop if(event.getBlock().getState().getMetadata(mcMMO.doubleDrops).size() > 0) { event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is); diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java index 5227f824c..d343e77c1 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java @@ -204,7 +204,7 @@ public class SalvageManager extends SkillManager { EnchantmentStorageMeta enchantMeta = (EnchantmentStorageMeta) book.getItemMeta(); boolean downgraded = false; - boolean arcaneFailure = false; + int arcaneFailureCount = 0; for (Entry enchant : enchants.entrySet()) { if (!Salvage.arcaneSalvageEnchantLoss @@ -217,36 +217,28 @@ public class SalvageManager extends SkillManager { && RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getExtractPartialEnchantChance(), getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE))) { enchantMeta.addStoredEnchant(enchant.getKey(), enchant.getValue() - 1, true); downgraded = true; - } - else { - arcaneFailure = true; - downgraded = true; + } else { + arcaneFailureCount++; } } - if(!arcaneFailure) + if(failedAllEnchants(arcaneFailureCount, enchants.entrySet().size())) { - Map newEnchants = enchantMeta.getStoredEnchants(); - - if (downgraded || newEnchants.size() < enchants.size()) { - NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Salvage.Skills.ArcanePartial"); - } - else { - NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Salvage.Skills.ArcanePartial"); - } - - book.setItemMeta(enchantMeta); - } else { - if(enchantMeta.getStoredEnchants().size() > 0) - { - NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Salvage.Skills.ArcaneFailed"); - } + NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Salvage.Skills.ArcaneFailed"); return null; + } else if(downgraded) + { + NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Salvage.Skills.ArcanePartial"); } + book.setItemMeta(enchantMeta); return book; } + private boolean failedAllEnchants(int arcaneFailureCount, int size) { + return arcaneFailureCount == size; + } + /** * Check if the player has tried to use an Anvil before. * @param actualize From 273dfbbdce06874ae1d0f8aa31a52853ba9137c5 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sun, 14 Apr 2019 04:23:28 -0700 Subject: [PATCH 13/16] 2.1.43 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0c066e297..57a2ee7af 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.43-SNAPSHOT + 2.1.43 mcMMO https://github.com/mcMMO-Dev/mcMMO From 5a56b27ea87e038844abee181532d25cd22678f6 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sun, 14 Apr 2019 04:55:37 -0700 Subject: [PATCH 14/16] Fix AlchemyBrew NPE --- Changelog.txt | 3 +++ pom.xml | 2 +- .../com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 39315d370..4ef569259 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,6 +7,9 @@ Key: ! Change - Removal +Version 2.1.44 + Fixed a NPE with Alchemy brewing + Version 2.1.43 Fixed a bug that would result in players being told they they failed to salvage enchantments when in reality they succeeded. diff --git a/pom.xml b/pom.xml index 57a2ee7af..33640d6d2 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.43 + 2.1.44-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO 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 96d1bc5e8..86517a2db 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java @@ -93,7 +93,7 @@ public final class AlchemyPotionBrewer { } private static List getValidIngredients(Player player) { - if(UserManager.getPlayer(player) != null) + if(UserManager.getPlayer(player) == null) { return PotionConfig.getInstance().getIngredients(1); } From 0f8c0f97d94ca311314c3c09437c2f2152ce9eb5 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sun, 14 Apr 2019 05:27:31 -0700 Subject: [PATCH 15/16] Fixing another NPE for brewing --- .../com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 86517a2db..f6b42c285 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java @@ -93,12 +93,12 @@ public final class AlchemyPotionBrewer { } private static List getValidIngredients(Player player) { - if(UserManager.getPlayer(player) == null) + if(player == null || UserManager.getPlayer(player) == null) { return PotionConfig.getInstance().getIngredients(1); } - return PotionConfig.getInstance().getIngredients((player == null || !Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CONCOCTIONS)) ? 1 : UserManager.getPlayer(player).getAlchemyManager().getTier()); + return PotionConfig.getInstance().getIngredients(!Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CONCOCTIONS) ? 1 : UserManager.getPlayer(player).getAlchemyManager().getTier()); } public static void finishBrewing(BlockState brewingStand, Player player, boolean forced) { From 31c1bd52bced0111f0980405087f8b40303880bf Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sun, 14 Apr 2019 05:39:23 -0700 Subject: [PATCH 16/16] 2.1.44 --- pom.xml | 2 +- src/main/java/com/gmail/nossr50/util/player/UserManager.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 33640d6d2..1ac897472 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.44-SNAPSHOT + 2.1.44 mcMMO https://github.com/mcMMO-Dev/mcMMO 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 2e220790e..cbf897794 100644 --- a/src/main/java/com/gmail/nossr50/util/player/UserManager.java +++ b/src/main/java/com/gmail/nossr50/util/player/UserManager.java @@ -103,7 +103,7 @@ public final class UserManager { */ public static McMMOPlayer getPlayer(Player player) { //Avoid Array Index out of bounds - if(player.hasMetadata(mcMMO.playerDataKey)) + if(player != null && player.hasMetadata(mcMMO.playerDataKey)) return (McMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value(); else return null;