diff --git a/Changelog.txt b/Changelog.txt index 6f6da6c86..ad7f06c11 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -162,6 +162,30 @@ Version 2.2.0 Added API method to check if player parties are size capped Added API method to grab the level cap of a skill by its PrimarySkillType ENUM definition Added API method to check if a skill was being level capped + +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. + +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 + 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 (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/README.md b/README.md index efd8e3c37..e03a72b26 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://i.imgur.com/tzFrxdo.png)](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/ diff --git a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java index c8862f22b..217ad41d6 100644 --- a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java +++ b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java @@ -1181,6 +1181,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 0b3f28105..0c668ea2a 100644 --- a/src/main/java/com/gmail/nossr50/api/PartyAPI.java +++ b/src/main/java/com/gmail/nossr50/api/PartyAPI.java @@ -40,6 +40,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(); } @@ -78,6 +81,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) { @@ -120,7 +127,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) { @@ -138,6 +150,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 fb45b2417..2e2866e6b 100644 --- a/src/main/java/com/gmail/nossr50/commands/chat/PartyChatCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/chat/PartyChatCommand.java @@ -21,6 +21,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 b13cd4b8d..c320c621b 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 1b90615d1..7b87ff6d8 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java @@ -79,6 +79,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) { @@ -202,6 +208,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 250d1b922..550950aa2 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java @@ -22,6 +22,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 5ef7c8585..2d79c4fff 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 3ce064600..412a18f99 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() < PartyManager.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 40a54b407..dd2e87517 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java @@ -33,6 +33,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 5776deb92..cd8d832bd 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() < PartyManager.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 7bc7794b0..be4fa911b 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 @@ -36,6 +36,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 b9026d3dc..4cd0b2c08 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 c516f10ac..654f04f29 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 @@ -58,6 +58,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()) { @@ -130,6 +136,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); @@ -204,6 +216,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 9af78d275..4f290bdb4 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 e8efdebef..f7fad60d0 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -88,11 +88,19 @@ 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(MainConfig.getInstance().getDatabasePlayerCooldown(), 1750); if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) { - sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown")); + sender.sendMessage(LocaleLoader.getString("Commands.Database.CooldownMS", getCDSeconds(mcMMOPlayer, cooldownMillis))); return; } @@ -112,4 +120,8 @@ public class McrankCommand implements TabExecutor { new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p); } + + private long getCDSeconds(McMMOPlayer mcMMOPlayer, long cooldownMillis) { + return ((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 8a9c69052..440e54f29 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 (mcMMO.getScoreboardSettings().isScoreboardEnabled(ScoreboardManager.SidebarType.STATS_BOARD) && mcMMO.getScoreboardSettings().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 4bfff993b..b8df20ad4 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/RepairCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java index 1e198f40d..fdfbe56e0 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java @@ -84,7 +84,7 @@ public class RepairCommand extends SkillCommand { canRepairString = Permissions.repairMaterialType(player, ItemMaterialCategory.STRING); canRepairLeather = Permissions.repairMaterialType(player, ItemMaterialCategory.LEATHER); canRepairWood = Permissions.repairMaterialType(player, ItemMaterialCategory.WOOD); - arcaneBypass = Permissions.arcaneBypass(player); + arcaneBypass = (Permissions.arcaneBypass(player) || Permissions.hasRepairEnchantBypassPerk(player)); } @Override 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 b92527048..8547ab771 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 c52fab2de..94294b859 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -541,7 +541,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 612bb2c5c..5ea1ea2ee 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 @@ -67,6 +67,9 @@ public class Roll extends AcrobaticsSubSkill { //Grab the player McMMOPlayer mcMMOPlayer = EventUtils.getMcMMOPlayer(entityDamageEvent.getEntity()); + if(mcMMOPlayer == null) + break; + /* * Check for success */ diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index ecd56e6dc..3650fb2cf 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -64,11 +64,10 @@ public class BlockListener implements Listener { if(is.getAmount() <= 0) continue; - if(!MainConfig.getInstance().getDoubleDropsEnabled(PrimarySkillType.MINING, is.getType()) - && !MainConfig.getInstance().getDoubleDropsEnabled(PrimarySkillType.HERBALISM, is.getType()) - && !MainConfig.getInstance().getDoubleDropsEnabled(PrimarySkillType.WOODCUTTING, is.getType())) + if(!mcMMO.getConfigManager().getBonusDropManager().isBonusDropWhitelisted(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); @@ -283,11 +282,18 @@ public class BlockListener implements Listener { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - if (blockState.getType() == Repair.getInstance().getAnvilMaterial() && PrimarySkillType.REPAIR.getPermissions(player)) { - mcMMOPlayer.getRepairManager().placedAnvilCheck(); - } - else if (blockState.getType() == Salvage.anvilMaterial && PrimarySkillType.SALVAGE.getPermissions(player)) { - mcMMOPlayer.getSalvageManager().placedAnvilCheck(); + if (blockState.getType() == Repair.getInstance().getAnvilMaterial() + && PrimarySkillType.REPAIR.getPermissions(player)) { + if (mcMMOPlayer == null) + return; + + if (blockState.getType() == Repair.getInstance().getAnvilMaterial() + && PrimarySkillType.REPAIR.getPermissions(player)) { + mcMMOPlayer.getRepairManager().placedAnvilCheck(); + } else if (blockState.getType() == Salvage.anvilMaterial + && PrimarySkillType.SALVAGE.getPermissions(player)) { + mcMMOPlayer.getSalvageManager().placedAnvilCheck(); + } } } @@ -376,6 +382,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 */ @@ -455,6 +466,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(); @@ -520,6 +537,12 @@ public class BlockListener implements Listener { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + //Profile not loaded + if(mcMMOPlayer == null) + { + return; + } + /* * ABILITY PREPARATION CHECKS * @@ -594,6 +617,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(); @@ -629,6 +659,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(); @@ -639,6 +677,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 d63bbf87b..a10cee1e9 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -476,6 +476,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); @@ -507,6 +511,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) { @@ -685,6 +695,12 @@ public class EntityListener implements Listener { return; } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + /* WORLD GUARD MAIN FLAG CHECK */ if(WorldGuardUtils.isWorldGuardLoaded()) { @@ -732,6 +748,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()) { @@ -781,6 +803,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()) { @@ -885,10 +913,16 @@ public class EntityListener implements Listener { return; } - if(mcMMO.getConfigManager().getConfigExploitPrevention().doTamedEntitiesGiveXP()) entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); + //Profile not loaded + //TODO: Redundant + /*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 8a9f21141..c4926f5f3 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 5d2015f1d..6e0720561 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -82,8 +82,17 @@ public class PlayerListener implements Listener { return; } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + if(mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) UserManager.getPlayer(player).actualizeTeleportATS(); + + + UserManager.getPlayer(player).actualizeTeleportATS(); } /** @@ -188,6 +197,12 @@ public class PlayerListener implements Listener { return; } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); mcMMOPlayer.checkGodMode(); @@ -253,6 +268,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()) { @@ -326,6 +347,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(); @@ -423,6 +450,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(); @@ -474,6 +507,12 @@ public class PlayerListener implements Listener { return; } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); mcMMOPlayer.logout(false); } @@ -530,6 +569,12 @@ public class PlayerListener implements Listener { return; } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } + UserManager.getPlayer(player).actualizeRespawnATS(); } @@ -557,6 +602,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(); @@ -660,6 +711,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 84a5e0775..4dacf29d1 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -111,6 +111,17 @@ public final class PartyManager { if(!mcMMO.getConfigManager().getConfigParty().isPartySystemEnabled()) return false; + //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(); @@ -127,6 +138,17 @@ public final class PartyManager { if(!mcMMO.getConfigManager().getConfigParty().isPartySystemEnabled()) return false; + //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(); @@ -294,6 +316,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(); @@ -353,7 +381,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 49fa0277a..499a82763 100644 --- a/src/main/java/com/gmail/nossr50/party/ShareHandler.java +++ b/src/main/java/com/gmail/nossr50/party/ShareHandler.java @@ -50,6 +50,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); } @@ -107,6 +113,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 c40e5947a..c942fcb19 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java @@ -35,7 +35,11 @@ public class AlchemyBrewTask extends BukkitRunnable { brewSpeed = 1.0; brewTimer = 400; - 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 a777144ac..8343d2f4f 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java @@ -90,7 +90,12 @@ public final class AlchemyPotionBrewer { } private static List getValidIngredients(Player player) { - return PotionConfig.getInstance().getIngredients((player == null || !Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CONCOCTIONS)) ? 1 : UserManager.getPlayer(player).getAlchemyManager().getTier()); + if(player == null || UserManager.getPlayer(player) == null) + { + return PotionConfig.getInstance().getIngredients(1); + } + + 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) { @@ -139,6 +144,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 d09146639..55e949119 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..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; @@ -95,7 +94,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 +151,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/repair/RepairManager.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java index 8bd0443d4..c133e9546 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -147,8 +147,7 @@ public class RepairManager extends SkillManager { } // Handle the enchants -// if (ArcaneForging.arcaneForgingEnchantLoss) { - if (mcMMO.getConfigManager().getConfigRepair().getArcaneForging().isMayLoseEnchants()) { + if (mcMMO.getConfigManager().getConfigRepair().getArcaneForging().isMayLoseEnchants() && !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 425479234..151b31d85 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java @@ -179,6 +179,9 @@ public class SalvageManager extends SkillManager { }*/ public double getExtractFullEnchantChance() { + if(Permissions.hasSalvageEnchantBypassPerk(getPlayer())) + return 100.0D; + return AdvancedConfig.getInstance().getArcaneSalvageExtractFullEnchantsChance(getArcaneSalvageRank()); } @@ -198,10 +201,11 @@ 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 + || Permissions.hasSalvageEnchantBypassPerk(player) || RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getExtractFullEnchantChance(), getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE))) { enchantMeta.addStoredEnchant(enchant.getKey(), enchant.getValue(), true); } @@ -210,36 +214,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 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 6bdd8e028..13d5cc251 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java @@ -12,7 +12,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; @@ -71,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 3f91e2956..a335d4a59 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; @@ -225,7 +224,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 904b50e42..de5fb9cab 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 3a117c1bd..50263012f 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); @@ -240,6 +245,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); @@ -298,6 +306,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); @@ -344,6 +355,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 c1aee7145..22979214e 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 = MainConfig.getInstance().getHardcoreDeathStatPenaltyPercentage(); int levelThreshold = MainConfig.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 = MainConfig.getInstance().getHardcoreVampirismStatLeechPercentage(); int levelThreshold = MainConfig.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/Permissions.java b/src/main/java/com/gmail/nossr50/util/Permissions.java index d130d3f5a..610c09c8c 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/java/com/gmail/nossr50/util/commands/CommandUtils.java b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java index e240053c4..7c5352306 100644 --- a/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java +++ b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java @@ -228,6 +228,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 7e4a387db..d7e5ab4ab 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,9 +96,14 @@ public final class UserManager { return retrieveMcMMOPlayer(playerName, true); } + /** + * 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) { //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; 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 ed73cb31d..d19fb999c 100644 --- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java @@ -204,6 +204,9 @@ public class ScoreboardWrapper { // TODO is there any way to do the time that looks acceptable? // player.sendMessage(LocaleLoader.getString("Commands.ConfigScoreboard.Timer", StringUtils.capitalize(sidebarType.toString().toLowerCase()), ticks / 20F)); + if(UserManager.getPlayer(playerName) == null) + return; + PlayerProfile profile = UserManager.getPlayer(player).getProfile(); if (profile.getScoreboardTipsShown() >= mcMMO.getScoreboardSettings().getTipsAmount()) { @@ -434,6 +437,9 @@ public class ScoreboardWrapper { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + if(mcMMOPlayer == null) + return; + switch (sidebarType) { case SKILL_BOARD: 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 c2e649507..bde3af9a8 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -629,6 +629,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 24de72d0b..061d8a616 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 95a5ea7d3..e947b918d 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -160,6 +160,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 e2834a864..3150524bc 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -573,7 +573,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! @@ -1072,6 +1072,7 @@ Scoreboard.Misc.Cooldown=[[LIGHT_PURPLE]]Cooldown Scoreboard.Misc.Overall=[[GOLD]]Overall Scoreboard.Misc.Ability=Super 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}. diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 867745cd4..841ed55f2 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1281,6 +1281,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 @@ -1297,6 +1299,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