mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
mcMMO now checks in all places for a loaded profile before executing processing on said profile
This commit is contained in:
parent
00cc5f0845
commit
33a68daa9c
@ -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
|
||||
|
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>2.1.40</version>
|
||||
<version>2.1.41-SNAPSHOT</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<scm>
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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)) {
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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]);
|
||||
|
||||
|
@ -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)) {
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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)) {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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<String> matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<String>(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);
|
||||
|
||||
|
@ -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"));
|
||||
|
@ -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()) {
|
||||
|
@ -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()) {
|
||||
|
@ -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];
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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))
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -93,6 +93,11 @@ public final class AlchemyPotionBrewer {
|
||||
}
|
||||
|
||||
private static List<ItemStack> 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);
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -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()) {
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -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()) {
|
||||
|
@ -54,6 +54,10 @@ public final class ChimaeraWing {
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
//Not loaded
|
||||
if(mcMMOPlayer == null)
|
||||
return;
|
||||
|
||||
if (mcMMOPlayer.getTeleportCommenceLocation() != null) {
|
||||
return;
|
||||
}
|
||||
|
@ -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<String, Integer> levelChanged, HashMap<String, Float> 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<String, Float> 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) {
|
||||
|
@ -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;
|
||||
|
@ -223,6 +223,9 @@ public final class CommandUtils {
|
||||
}
|
||||
|
||||
private static void printGroupedSkillData(Player inspect, CommandSender display, String header, List<PrimarySkillType> skillGroup) {
|
||||
if(UserManager.getPlayer(inspect) == null)
|
||||
return;
|
||||
|
||||
PlayerProfile profile = UserManager.getPlayer(inspect).getProfile();
|
||||
|
||||
List<String> displayData = new ArrayList<String>();
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -172,6 +172,9 @@ public class RankUtils {
|
||||
//Get our rank map
|
||||
HashMap<Integer, Integer> 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<Integer, Integer> rankMap = subSkillRanks.get(skillName);
|
||||
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
return 0;
|
||||
|
||||
//Skill level of parent skill
|
||||
int currentSkillLevel = UserManager.getPlayer(player).getSkillLevel(abstractSubSkill.getPrimarySkill());
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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}.
|
||||
|
Loading…
Reference in New Issue
Block a user