more work on parties and user data

This commit is contained in:
nossr50 2020-12-08 15:34:16 -08:00
parent 0bb65e66e8
commit 3cb63202a3
54 changed files with 341 additions and 323 deletions

View File

@ -11,35 +11,35 @@ public final class AbilityAPI {
private AbilityAPI() {}
public static boolean berserkEnabled(Player player) {
return mcMMO.getUserManager().queryMcMMOPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.BERSERK);
return mcMMO.getUserManager().queryPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.BERSERK);
}
public static boolean gigaDrillBreakerEnabled(Player player) {
return mcMMO.getUserManager().queryMcMMOPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER);
return mcMMO.getUserManager().queryPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER);
}
public static boolean greenTerraEnabled(Player player) {
return mcMMO.getUserManager().queryMcMMOPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.GREEN_TERRA);
return mcMMO.getUserManager().queryPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.GREEN_TERRA);
}
public static boolean serratedStrikesEnabled(Player player) {
return mcMMO.getUserManager().queryMcMMOPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.SERRATED_STRIKES);
return mcMMO.getUserManager().queryPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.SERRATED_STRIKES);
}
public static boolean skullSplitterEnabled(Player player) {
return mcMMO.getUserManager().queryMcMMOPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.SKULL_SPLITTER);
return mcMMO.getUserManager().queryPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.SKULL_SPLITTER);
}
public static boolean superBreakerEnabled(Player player) {
return mcMMO.getUserManager().queryMcMMOPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.SUPER_BREAKER);
return mcMMO.getUserManager().queryPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.SUPER_BREAKER);
}
public static boolean treeFellerEnabled(Player player) {
return mcMMO.getUserManager().queryMcMMOPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.TREE_FELLER);
return mcMMO.getUserManager().queryPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.TREE_FELLER);
}
public static boolean isAnyAbilityEnabled(Player player) {
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
for (SuperAbilityType ability : SuperAbilityType.values()) {
if (mmoPlayer.getSuperAbilityManager().getAbilityMode(ability)) {
@ -51,35 +51,35 @@ public final class AbilityAPI {
}
public static void resetCooldowns(Player player) {
mcMMO.getUserManager().queryMcMMOPlayer(player).getPersistentPlayerData().resetCooldowns();
mcMMO.getUserManager().queryPlayer(player).getPersistentPlayerData().resetCooldowns();
}
public static void setBerserkCooldown(Player player, long cooldown) {
mcMMO.getUserManager().queryMcMMOPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.BERSERK, cooldown);
mcMMO.getUserManager().queryPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.BERSERK, cooldown);
}
public static void setGigaDrillBreakerCooldown(Player player, long cooldown) {
mcMMO.getUserManager().queryMcMMOPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.GIGA_DRILL_BREAKER, cooldown);
mcMMO.getUserManager().queryPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.GIGA_DRILL_BREAKER, cooldown);
}
public static void setGreenTerraCooldown(Player player, long cooldown) {
mcMMO.getUserManager().queryMcMMOPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.GREEN_TERRA, cooldown);
mcMMO.getUserManager().queryPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.GREEN_TERRA, cooldown);
}
public static void setSerratedStrikesCooldown(Player player, long cooldown) {
mcMMO.getUserManager().queryMcMMOPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.SERRATED_STRIKES, cooldown);
mcMMO.getUserManager().queryPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.SERRATED_STRIKES, cooldown);
}
public static void setSkullSplitterCooldown(Player player, long cooldown) {
mcMMO.getUserManager().queryMcMMOPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.SKULL_SPLITTER, cooldown);
mcMMO.getUserManager().queryPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.SKULL_SPLITTER, cooldown);
}
public static void setSuperBreakerCooldown(Player player, long cooldown) {
mcMMO.getUserManager().queryMcMMOPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.SUPER_BREAKER, cooldown);
mcMMO.getUserManager().queryPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.SUPER_BREAKER, cooldown);
}
public static void setTreeFellerCooldown(Player player, long cooldown) {
mcMMO.getUserManager().queryMcMMOPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.TREE_FELLER, cooldown);
mcMMO.getUserManager().queryPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.TREE_FELLER, cooldown);
}
public static boolean isBleeding(LivingEntity entity) {

View File

@ -20,7 +20,7 @@ public final class ChatAPI {
*/
@Deprecated
public static boolean isUsingPartyChat(@NotNull Player player) {
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
if(mmoPlayer != null)
return mmoPlayer.getChatChannel() == ChatChannel.PARTY;
@ -63,7 +63,7 @@ public final class ChatAPI {
*/
@Deprecated
public static boolean isUsingAdminChat(@NotNull Player player) {
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
if(mmoPlayer != null)
return mmoPlayer.getChatChannel() == ChatChannel.ADMIN;
@ -114,7 +114,7 @@ public final class ChatAPI {
*/
@Deprecated
public static void togglePartyChat(Player player) throws NullPointerException {
mcMMO.p.getChatManager().setOrToggleChatChannel(Objects.requireNonNull(mcMMO.getUserManager().queryMcMMOPlayer(player)), ChatChannel.PARTY);
mcMMO.p.getChatManager().setOrToggleChatChannel(Objects.requireNonNull(mcMMO.getUserManager().queryPlayer(player)), ChatChannel.PARTY);
}
/**
@ -145,7 +145,7 @@ public final class ChatAPI {
*/
@Deprecated
public static void toggleAdminChat(Player player) throws NullPointerException {
mcMMO.p.getChatManager().setOrToggleChatChannel(Objects.requireNonNull(mcMMO.getUserManager().queryMcMMOPlayer(player)), ChatChannel.ADMIN);
mcMMO.p.getChatManager().setOrToggleChatChannel(Objects.requireNonNull(mcMMO.getUserManager().queryPlayer(player)), ChatChannel.ADMIN);
}
/**

View File

@ -1217,6 +1217,6 @@ public final class ExperienceAPI {
throw new McMMOPlayerNotFoundException(player);
}
return mcMMO.getUserManager().queryMcMMOPlayer(player);
return mcMMO.getUserManager().queryPlayer(player);
}
}

View File

@ -26,7 +26,7 @@ public final class PartyAPI {
return null;
}
return mcMMO.getUserManager().queryMcMMOPlayer(player).getParty().getName();
return mcMMO.getUserManager().queryPlayer(player).getParty().getName();
}
/**
@ -38,10 +38,10 @@ public final class PartyAPI {
* @return true if the player is in a party, false otherwise
*/
public static boolean inParty(Player player) {
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
return false;
return mcMMO.getUserManager().queryMcMMOPlayer(player).inParty();
return mcMMO.getUserManager().queryPlayer(player).inParty();
}
/**
@ -80,7 +80,7 @@ public final class PartyAPI {
@Deprecated
public static void addToParty(Player player, String partyName) {
//Check if player profile is loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
return;
Party party = mcMMO.getPartyManager().getParty(partyName);
@ -95,7 +95,7 @@ public final class PartyAPI {
}
}
mcMMO.getPartyManager().addToParty(mcMMO.getUserManager().queryMcMMOPlayer(player), party);
mcMMO.getPartyManager().addToParty(mcMMO.getUserManager().queryPlayer(player), party);
}
/**
@ -120,7 +120,7 @@ public final class PartyAPI {
//TODO: bypasslimit not used?
public static void addToParty(Player player, String partyName, boolean bypassLimit) {
//Check if player profile is loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
return;
Party party = mcMMO.getPartyManager().getParty(partyName);
@ -129,7 +129,7 @@ public final class PartyAPI {
party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
}
mcMMO.getPartyManager().addToParty(mcMMO.getUserManager().queryMcMMOPlayer(player), party);
mcMMO.getPartyManager().addToParty(mcMMO.getUserManager().queryPlayer(player), party);
}
/**
@ -141,10 +141,10 @@ public final class PartyAPI {
*/
public static void removeFromParty(Player player) {
//Check if player profile is loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
return;
mcMMO.getPartyManager().removeFromParty(mcMMO.getUserManager().queryMcMMOPlayer(player));
mcMMO.getPartyManager().removeFromParty(mcMMO.getUserManager().queryPlayer(player));
}
/**

View File

@ -21,7 +21,7 @@ public class McnotifyCommand implements TabExecutor {
}
if (args.length == 0) {
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer((Player) sender);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer((Player) sender);
//Not Loaded yet
if (mmoPlayer == null)

View File

@ -22,7 +22,7 @@ public class DatabaseRemovePlayerCommand implements TabExecutor {
if (args.length == 1) {
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
if (mcMMO.getUserManager().getOfflinePlayer(playerName) == null
if (mcMMO.getUserManager().queryPlayerName(playerName) == null
&& CommandUtils.hasNoProfile(sender, mcMMO.getDatabaseManager().queryPlayerDataByUUID(playerName, false))) {
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
return true;

View File

@ -91,7 +91,7 @@ public abstract class ExperienceCommand implements TabExecutor {
int value = Integer.parseInt(args[2]);
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getOfflinePlayer(playerName);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayerName(playerName);
// If the mmoPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mmoPlayer == null) {

View File

@ -73,7 +73,7 @@ public class SkillresetCommand implements TabExecutor {
}
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getOfflinePlayer(playerName);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayerName(playerName);
// If the mmoPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mmoPlayer == null) {

View File

@ -16,12 +16,12 @@ public class PartyAcceptCommand implements CommandExecutor {
Player player = (Player) sender;
//Check if player profile is loaded
if (mcMMO.getUserManager().queryMcMMOPlayer(player) == null) {
if (mcMMO.getUserManager().queryPlayer(player) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
if (!mmoPlayer.hasPartyInvite()) {

View File

@ -12,13 +12,13 @@ import org.jetbrains.annotations.NotNull;
public class PartyChangePasswordCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if(mcMMO.getUserManager().queryMcMMOPlayer((Player) sender) == null)
if(mcMMO.getUserManager().queryPlayer((Player) sender) == null)
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
Party party = mcMMO.getUserManager().queryMcMMOPlayer((Player) sender).getParty();
Party party = mcMMO.getUserManager().queryPlayer((Player) sender).getParty();
switch (args.length) {
case 1:

View File

@ -69,13 +69,13 @@ public class PartyCommand implements TabExecutor {
return true;
}
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
if (args.length < 1) {
if (!mcMMO.getPartyManager().mmoPlayer.inParty()) {
@ -187,13 +187,13 @@ public class PartyCommand implements TabExecutor {
Player player = (Player) sender;
//Not Loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return ImmutableList.of();
}
Party party = mcMMO.getUserManager().queryMcMMOPlayer(player).getParty();
Party party = mcMMO.getUserManager().queryPlayer(player).getParty();
playerNames = party.getOnlinePlayerNames(player);
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size()));

View File

@ -16,9 +16,9 @@ public class PartyCreateCommand implements CommandExecutor {
case 2:
case 3:
Player player = (Player) sender;
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;

View File

@ -15,12 +15,12 @@ public class PartyDisbandCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 1) {
if (mcMMO.getUserManager().queryMcMMOPlayer((Player) sender) == null) {
if (mcMMO.getUserManager().queryPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
Party playerParty = mcMMO.getUserManager().queryMcMMOPlayer((Player) sender).getParty();
Party playerParty = mcMMO.getUserManager().queryPlayer((Player) sender).getParty();
String partyName = playerParty.getPartyName();
for (PartyMember member : playerParty.getPartyMembers()) {

View File

@ -21,13 +21,13 @@ public class PartyInfoCommand implements CommandExecutor {
switch (args.length) {
case 0:
case 1:
if(mcMMO.getUserManager().queryMcMMOPlayer((Player) sender) == null)
if(mcMMO.getUserManager().queryPlayer((Player) sender) == null)
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
Party party = mmoPlayer.getParty();
displayPartyHeader(player, party);

View File

@ -17,7 +17,7 @@ public class PartyInviteCommand implements CommandExecutor {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 2) {
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
McMMOPlayer mcMMOTarget = mcMMO.getUserManager().getOfflinePlayer(targetName);
McMMOPlayer mcMMOTarget = mcMMO.getUserManager().queryPlayerName(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;
@ -25,13 +25,13 @@ public class PartyInviteCommand implements CommandExecutor {
Player target = mcMMOTarget.getPlayer();
if (mcMMO.getUserManager().queryMcMMOPlayer((Player) sender) == null) {
if (mcMMO.getUserManager().queryPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
String playerName = player.getName();
if (player.equals(target)) {

View File

@ -16,12 +16,12 @@ public class PartyKickCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 2) {
if (mcMMO.getUserManager().queryMcMMOPlayer((Player) sender) == null) {
if (mcMMO.getUserManager().queryPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
Party playerParty = mcMMO.getUserManager().queryMcMMOPlayer((Player) sender).getParty();
Party playerParty = mcMMO.getUserManager().queryPlayer((Player) sender).getParty();
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
if (!playerParty.hasMember(targetName)) {
@ -39,7 +39,7 @@ public class PartyKickCommand implements CommandExecutor {
return true;
}
mcMMO.getPartyManager().processPartyLeaving(mcMMO.getUserManager().queryMcMMOPlayer(onlineTarget));
mcMMO.getPartyManager().processPartyLeaving(mcMMO.getUserManager().queryPlayer(onlineTarget));
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
}

View File

@ -16,12 +16,12 @@ public class PartyRenameCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 2) {
if (mcMMO.getUserManager().queryMcMMOPlayer((Player) sender) == null) {
if (mcMMO.getUserManager().queryPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer((Player) sender);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer((Player) sender);
Party playerParty = mmoPlayer.getParty();
String oldPartyName = playerParty.getPartyName();

View File

@ -17,13 +17,13 @@ import org.jetbrains.annotations.NotNull;
public class PartyXpShareCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if(mcMMO.getUserManager().queryMcMMOPlayer((Player) sender) == null)
if(mcMMO.getUserManager().queryPlayer((Player) sender) == null)
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
Party party = mcMMO.getUserManager().queryMcMMOPlayer((Player) sender).getParty();
Party party = mcMMO.getUserManager().queryPlayer((Player) sender).getParty();
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.XP_SHARE)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.5"));

View File

@ -1,12 +1,17 @@
package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyMember;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class PtpAcceptAnyCommand implements CommandExecutor {
@ -17,7 +22,36 @@ public class PtpAcceptAnyCommand implements CommandExecutor {
return true;
}
PartyTeleportRecord ptpRecord = mcMMO.getUserManager().getPlayer(sender.getName()).getPartyTeleportRecord();
if(sender instanceof ConsoleCommandSender)
return false;
Player playerSender = (Player) sender;
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(playerSender);
if(mmoPlayer == null) {
playerSender.sendMessage(LocaleLoader.getString("Commands.NotLoaded"));
return false;
}
Party party = mcMMO.getPartyManager().getParty(playerSender);
if(party == null) {
//TODO: Localize error message
playerSender.sendMessage("You don't have a party!");
return false;
}
PartyMember partyMember = party.getPartyMember(playerSender.getUniqueId());
if(partyMember == null) {
mcMMO.p.getLogger().severe("PartyMember ref didn't exist for player named "+playerSender.getName() + ", this should never happen!");
return false;
}
PartyTeleportRecord ptpRecord = partyMember.getPartyTeleportRecord();
if(ptpRecord == null) {
}
if (ptpRecord.isConfirmRequired()) {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled"));

View File

@ -21,14 +21,14 @@ public class PtpAcceptCommand implements CommandExecutor {
return true;
}
if(mcMMO.getUserManager().queryMcMMOPlayer((Player) sender) == null)
if(mcMMO.getUserManager().queryPlayer((Player) sender) == null)
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
PartyTeleportRecord ptpRecord = mcMMO.getUserManager().queryMcMMOPlayer(player).getPartyTeleportRecord();
PartyTeleportRecord ptpRecord = mcMMO.getUserManager().queryPlayer(player).getPartyTeleportRecord();
if (!ptpRecord.hasRequest()) {
player.sendMessage(LocaleLoader.getString("Commands.ptp.NoRequests"));

View File

@ -59,13 +59,13 @@ public class PtpCommand implements TabExecutor {
return true;
}
if(mcMMO.getUserManager().queryMcMMOPlayer((Player) sender) == null)
if(mcMMO.getUserManager().queryPlayer((Player) sender) == null)
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
if (!mmoPlayer.inParty()) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
@ -133,13 +133,13 @@ public class PtpCommand implements TabExecutor {
List<String> matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<>(TELEPORT_SUBCOMMANDS.size()));
if (matches.size() == 0) {
if (mcMMO.getUserManager().queryMcMMOPlayer((Player) sender) == null) {
if (mcMMO.getUserManager().queryPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return ImmutableList.of();
}
Player player = (Player) sender;
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
if (!mmoPlayer.inParty()) {
return ImmutableList.of();
@ -228,20 +228,20 @@ public class PtpCommand implements TabExecutor {
}
protected static void handleTeleportWarmup(Player teleportingPlayer, Player targetPlayer) {
if(mcMMO.getUserManager().queryMcMMOPlayer(targetPlayer) == null)
if(mcMMO.getUserManager().queryPlayer(targetPlayer) == null)
{
targetPlayer.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return;
}
if(mcMMO.getUserManager().queryMcMMOPlayer(teleportingPlayer) == null)
if(mcMMO.getUserManager().queryPlayer(teleportingPlayer) == null)
{
teleportingPlayer.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(teleportingPlayer);
McMMOPlayer mcMMOTarget = mcMMO.getUserManager().queryMcMMOPlayer(targetPlayer);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(teleportingPlayer);
McMMOPlayer mcMMOTarget = mcMMO.getUserManager().queryPlayer(targetPlayer);
long warmup = Config.getInstance().getPTPCommandWarmup();

View File

@ -25,7 +25,7 @@ public class InspectCommand implements TabExecutor {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 1) {
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getOfflinePlayer(playerName);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayerName(playerName);
// If the mmoPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mmoPlayer == null) {

View File

@ -52,7 +52,7 @@ public class McrankCommand implements TabExecutor {
}
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getOfflinePlayer(playerName);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayerName(playerName);
if (mmoPlayer != null) {
Player player = mmoPlayer.getPlayer();

View File

@ -33,7 +33,7 @@ public class AlchemyCommand extends SkillCommand {
protected String[] calculateAbilityDisplayValues(@NotNull Player player) {
//TODO: Needed?
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
if(mmoPlayer == null)
{
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));

View File

@ -59,7 +59,7 @@ public abstract class SkillCommand implements TabExecutor {
return true;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer((Player) sender);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer((Player) sender);
if(mmoPlayer == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.database;
import com.gmail.nossr50.api.exceptions.ProfileRetrievalException;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.MobHealthBarType;
@ -13,10 +12,11 @@ import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.database.UUIDUpdateAsyncTask;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.text.StringUtils;
import com.google.common.collect.ImmutableMap;
import com.neetgames.mcmmo.exceptions.ProfileRetrievalException;
import org.apache.commons.lang.NullArgumentException;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;

View File

@ -2,10 +2,13 @@ package com.gmail.nossr50.datatypes.party;
import com.gmail.nossr50.chat.SamePartyPredicate;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.function.Predicate;
public class Party {
@ -68,6 +71,14 @@ public class Party {
return Objects.hash(samePartyPredicate, persistentPartyData, partyMemberManager, partyExperienceManager);
}
public @Nullable PartyMember getPartyMember(@NotNull Player player) {
return getPartyMember(player.getUniqueId());
}
public @Nullable PartyMember getPartyMember(@NotNull UUID playerUUID) {
return partyMemberManager.getPartyMember(playerUUID);
}
public @NotNull Predicate<CommandSender> getSamePartyPredicate() {
return samePartyPredicate;
}

View File

@ -1,20 +1,27 @@
package com.gmail.nossr50.datatypes.party;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.dirtydata.DirtySet;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.Misc;
import com.neetgames.mcmmo.exceptions.InvalidPlayerException;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
public class PartyMemberManager {
private final @NotNull PersistentPartyData persistentPartyData;
private final @NotNull HashMap<UUID, PartyMember> partyMemberMap;
private @Nullable PartyMember partyLeaderRef;
public PartyMemberManager(@NotNull PersistentPartyData persistentPartyData) {
this.persistentPartyData = persistentPartyData;
this.partyMemberMap = new HashMap<>();
initPartyLeaderRef();
}
/**
@ -22,10 +29,21 @@ public class PartyMemberManager {
*
* @return all party members
*/
public @NotNull Set<PartyMember> getPartyMembers() {
public @NotNull DirtySet<PartyMember> getPartyMembers() {
return persistentPartyData.getPartyMembers();
}
/**
* Grab a specific {@link PartyMember} by {@link UUID}
*
* @param playerUUID target UUID
* @return the party member if they exist, otherwise null
*/
public @Nullable PartyMember getPartyMember(@NotNull UUID playerUUID) {
return partyMemberMap.get(playerUUID);
}
/**
* Add a {@link PartyMember} to this {@link Party} with a designated rank
* If you are adding a {@link PartyMemberRank} of Leader, any existing party leaders will be demoted to a regular member of the party
@ -36,7 +54,9 @@ public class PartyMemberManager {
public void addPartyMember(@NotNull UUID playerUUID, @NotNull PartyMemberRank partyMemberRank) {
//TODO: Prevent adding multiple leaders
//TODO: Call event
persistentPartyData.getPartyMembers().add(new PartyMember(playerUUID, partyMemberRank));
PartyMember partyMember = new PartyMember(playerUUID, partyMemberRank);
persistentPartyData.getPartyMembers().add(partyMember);
partyMemberMap.put(playerUUID, partyMember);
}
/**
@ -66,16 +86,49 @@ public class PartyMemberManager {
*
* @param playerUUID the UUID of the new party leader
*/
public void changeLeader(@NotNull UUID playerUUID) {
public void changeLeader(@NotNull UUID playerUUID) throws RuntimeException {
if(hasMember(playerUUID)) {
//TODO: implementation
for(PartyMember partyMember : getPartyMembers()) {
if (partyMember.getPartyMemberRank() == PartyMemberRank.LEADER) {
partyMember.setPartyMemberRank(PartyMemberRank.MEMBER);
}
}
partyLeaderRef = partyMemberMap.get(playerUUID);
partyLeaderRef.setPartyMemberRank(PartyMemberRank.LEADER);
} else {
throw new RuntimeException();
}
}
private void initPartyLeaderRef() {
for(PartyMember partyMember : getPartyMembers()) {
if(partyMember.getPartyMemberRank() == PartyMemberRank.LEADER) {
partyLeaderRef = partyMember;
break;
}
}
}
/**
* Retrieves a party leader, if one doesn't exist a "random" player is forcibly promoted to leader
* Random being the first player in the set
*
* @return the party leader
*/
public @NotNull PartyMember getPartyLeader() {
if(partyLeaderRef == null) {
//The first player in a party is now the leader
partyLeaderRef = (PartyMember) getPartyMembers().unwrapSet().toArray()[0];
partyLeaderRef.setPartyMemberRank(PartyMemberRank.LEADER);
}
return partyLeaderRef;
}
public boolean hasMember(@NotNull UUID playerUUID) {
for(PartyMember partyMember : persistentPartyData.getPartyMembers()) {
if(partyMember.getUniqueId().equals(playerUUID))
return true;
}
return false;
return partyMemberMap.containsKey(playerUUID);
}
public boolean hasMember(@NotNull Player player) {
@ -110,7 +163,7 @@ public class PartyMemberManager {
* @param mmoPlayer The player to check
* @return the near party members
*/
public List<Player> getNearMembers(McMMOPlayer mmoPlayer) {
public @NotNull List<Player> getNearMembers(@NotNull McMMOPlayer mmoPlayer) {
List<Player> nearMembers = new ArrayList<>();
Party party = mmoPlayer.getParty();
@ -130,8 +183,4 @@ public class PartyMemberManager {
return nearMembers;
}
public @NotNull PartyMember getPartyLeader() {
return persistentPartyData.getPartyLeader();
}
}

View File

@ -16,44 +16,14 @@ public class PersistentPartyData {
private final @NotNull MutableBoolean dirtyFlag; //Dirty values in this class will change this flag as needed
private final @NotNull DirtyData<MutableString> partyName;
private final @NotNull DirtySet<PartyMember> partyMembers; //TODO: Add cache for subsets
private @Nullable PartyMember partyLeaderRef;
public PersistentPartyData(@NotNull String partyName,
@NotNull Set<PartyMember> partyMembers) throws RuntimeException {
dirtyFlag = new MutableBoolean(false);
this.partyName = new DirtyData<>(new MutableString(partyName), dirtyFlag);
this.partyMembers = new DirtySet<>(new HashSet<>(partyMembers), dirtyFlag);
initPartyLeaderRef();
}
private void initPartyLeaderRef() {
for(PartyMember partyMember : getPartyMembers()) {
if(partyMember.getPartyMemberRank() == PartyMemberRank.LEADER) {
partyLeaderRef = partyMember;
break;
}
}
}
/**
* Retrieves a party leader, if one doesn't exist a "random" player is forcibly promoted to leader
* Random being the first player in the set
*
* @see #partyMembers
* @return the party leader
*/
public @NotNull PartyMember getPartyLeader() {
if(partyLeaderRef == null) {
//The first player in a party is now the leader
partyLeaderRef = (PartyMember) getPartyMembers().unwrapSet().toArray()[0];
partyLeaderRef.setPartyMemberRank(PartyMemberRank.LEADER);
}
return partyLeaderRef;
}
public @NotNull String getPartyName() {
return partyName.getData().getImmutableCopy();
}
@ -71,11 +41,11 @@ public class PersistentPartyData {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PersistentPartyData that = (PersistentPartyData) o;
return partyName.equals(that.partyName) && partyMembers.equals(that.partyMembers) && Objects.equals(partyLeaderRef, that.partyLeaderRef);
return dirtyFlag.equals(that.dirtyFlag) && partyName.equals(that.partyName) && partyMembers.equals(that.partyMembers);
}
@Override
public int hashCode() {
return Objects.hash(partyName, partyMembers, partyLeaderRef);
return Objects.hash(dirtyFlag, partyName, partyMembers);
}
}

View File

@ -119,7 +119,7 @@ public class Roll extends AcrobaticsSubSkill {
String rollChance, rollChanceLucky, gracefulRollChance, gracefulRollChanceLucky;
/* Values related to the player */
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
float skillValue = mmoPlayer.getExperienceManager().getSkillLevel(getPrimarySkill());
boolean isLucky = Permissions.lucky(player, getPrimarySkill());
@ -269,7 +269,7 @@ public class Roll extends AcrobaticsSubSkill {
return false;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
if (ItemUtils.hasItemInEitherHand(player, Material.ENDER_PEARL) || player.isInsideVehicle()) {
if(mmoPlayer.isDebugMode()) {
@ -278,7 +278,7 @@ public class Roll extends AcrobaticsSubSkill {
return true;
}
if(mcMMO.getUserManager().queryMcMMOPlayer(player).getAcrobaticsManager().hasFallenInLocationBefore(getBlockLocation(player)))
if(mcMMO.getUserManager().queryPlayer(player).getAcrobaticsManager().hasFallenInLocationBefore(getBlockLocation(player)))
{
if(mmoPlayer.isDebugMode()) {
mmoPlayer.getPlayer().sendMessage("Acrobatics XP Prevented: Fallen in location before");
@ -420,7 +420,7 @@ public class Roll extends AcrobaticsSubSkill {
public void addFallLocation(Player player)
{
mcMMO.getUserManager().queryMcMMOPlayer(player).getAcrobaticsManager().addLocationToFallMap(getBlockLocation(player));
mcMMO.getUserManager().queryPlayer(player).getAcrobaticsManager().addLocationToFallMap(getBlockLocation(player));
}
public Location getBlockLocation(Player player)

View File

@ -216,7 +216,7 @@ public class BlockListener implements Listener {
return;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
if(mmoPlayer == null)
return;
@ -312,7 +312,7 @@ public class BlockListener implements Listener {
return;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
//Check if profile is loaded
if(mmoPlayer == null) {
@ -410,7 +410,7 @@ public class BlockListener implements Listener {
}
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
return;
}
@ -419,7 +419,7 @@ public class BlockListener implements Listener {
ItemStack heldItem = player.getInventory().getItemInMainHand();
if (ItemUtils.isSword(heldItem)) {
HerbalismManager herbalismManager = mcMMO.getUserManager().queryMcMMOPlayer(player).getHerbalismManager();
HerbalismManager herbalismManager = mcMMO.getUserManager().queryPlayer(player).getHerbalismManager();
if (herbalismManager.canUseHylianLuck()) {
if (herbalismManager.processHylianLuck(blockState)) {
@ -473,7 +473,7 @@ public class BlockListener implements Listener {
return;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
//Profile not loaded
if(mmoPlayer == null)
@ -559,10 +559,10 @@ public class BlockListener implements Listener {
return;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
return;
}
@ -606,10 +606,10 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockDamageCleanup(BlockDamageEvent event) {
Player player = event.getPlayer();
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
return;
}
@ -627,19 +627,19 @@ public class BlockListener implements Listener {
//TODO: Convert into locale strings
private void debugStickDump(Player player, BlockState blockState) {
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
return;
}
if(mcMMO.getUserManager().queryMcMMOPlayer(player).isDebugMode())
if(mcMMO.getUserManager().queryPlayer(player).isDebugMode())
{
if(mcMMO.getPlaceStore().isTrue(blockState))
player.sendMessage("[mcMMO DEBUG] This block is not natural and does not reward treasures/XP");
else
{
player.sendMessage("[mcMMO DEBUG] This block is considered natural by mcMMO");
mcMMO.getUserManager().queryMcMMOPlayer(player).getExcavationManager().printExcavationDebug(player, blockState);
mcMMO.getUserManager().queryPlayer(player).getExcavationManager().printExcavationDebug(player, blockState);
}
if(WorldGuardUtils.isWorldGuardLoaded())

View File

@ -192,7 +192,7 @@ public class EntityListener implements Listener {
//Crossbow only
if (isCrossbow) {
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
//Process launch event
if (Permissions.skillEnabled(player, PrimarySkillType.CROSSBOWS)) {
@ -460,7 +460,7 @@ public class EntityListener implements Listener {
}
//Deflect checks
final McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(defendingPlayer);
final McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(defendingPlayer);
if (mmoPlayer != null) {
UnarmedManager unarmedManager = mmoPlayer.getUnarmedManager();
@ -617,7 +617,7 @@ public class EntityListener implements Listener {
return;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
//Profile not loaded
if(mmoPlayer == null)
@ -655,12 +655,12 @@ public class EntityListener implements Listener {
Wolf wolf = (Wolf) pet;
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
return;
}
TamingManager tamingManager = mcMMO.getUserManager().queryMcMMOPlayer(player).getTamingManager();
TamingManager tamingManager = mcMMO.getUserManager().queryPlayer(player).getTamingManager();
switch (cause) {
case CONTACT:
@ -843,7 +843,7 @@ public class EntityListener implements Listener {
}
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
return;
}
@ -855,7 +855,7 @@ public class EntityListener implements Listener {
return;
}
MiningManager miningManager = mcMMO.getUserManager().queryMcMMOPlayer(player).getMiningManager();
MiningManager miningManager = mcMMO.getUserManager().queryPlayer(player).getMiningManager();
if (miningManager.canUseBiggerBombs()) {
event.setRadius(miningManager.biggerBombs(event.getRadius()));
@ -896,12 +896,12 @@ public class EntityListener implements Listener {
}
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
return;
}
MiningManager miningManager = mcMMO.getUserManager().queryMcMMOPlayer(player).getMiningManager();
MiningManager miningManager = mcMMO.getUserManager().queryPlayer(player).getMiningManager();
if (miningManager.canUseBlastMining()) {
miningManager.blastMiningDropProcessing(event.getYield(), event);
@ -930,7 +930,7 @@ public class EntityListener implements Listener {
Player player = (Player) entity;
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
return;
}
@ -995,7 +995,7 @@ public class EntityListener implements Listener {
* 1000
*/
if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) {
event.setFoodLevel(mcMMO.getUserManager().queryMcMMOPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel));
event.setFoodLevel(mcMMO.getUserManager().queryPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel));
}
return;
@ -1007,7 +1007,7 @@ public class EntityListener implements Listener {
*/
case POTATO: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) {
event.setFoodLevel(mcMMO.getUserManager().queryMcMMOPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel));
event.setFoodLevel(mcMMO.getUserManager().queryPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel));
}
return;
case COD:
@ -1017,7 +1017,7 @@ public class EntityListener implements Listener {
case COOKED_SALMON:
if (Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_FISHERMANS_DIET)) {
event.setFoodLevel(mcMMO.getUserManager().queryMcMMOPlayer(player).getFishingManager().handleFishermanDiet(newFoodLevel));
event.setFoodLevel(mcMMO.getUserManager().queryPlayer(player).getFishingManager().handleFishermanDiet(newFoodLevel));
}
return;
@ -1052,7 +1052,7 @@ public class EntityListener implements Listener {
LivingEntity livingEntity = event.getEntity();
if (mcMMO.getUserManager().queryMcMMOPlayer(player) == null
if (mcMMO.getUserManager().queryPlayer(player) == null
|| Misc.isNPCEntityExcludingVillagers(livingEntity)
|| persistentDataLayer.hasMobFlag(MobMetaFlagType.EGG_MOB, livingEntity)
|| persistentDataLayer.hasMobFlag(MobMetaFlagType.MOB_SPAWNER_MOB, livingEntity)) {
@ -1062,12 +1062,12 @@ public class EntityListener implements Listener {
persistentDataLayer.flagMetadata(MobMetaFlagType.PLAYER_TAMED_MOB, livingEntity);
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
return;
}
mcMMO.getUserManager().queryMcMMOPlayer(player).getTamingManager().awardTamingXP(livingEntity);
mcMMO.getUserManager().queryPlayer(player).getTamingManager().awardTamingXP(livingEntity);
}
/**

View File

@ -66,13 +66,13 @@ public class InventoryListener implements Listener {
}
//Profile doesn't exist
if(mcMMO.getUserManager().queryMcMMOPlayer(offlinePlayer) == null)
if(mcMMO.getUserManager().queryOfflineMcMMOPlayer(offlinePlayer) == null)
{
return;
}
boolean debugMode = player.isOnline() && mcMMO.getUserManager().queryMcMMOPlayer(player).isDebugMode();
boolean debugMode = player.isOnline() && mcMMO.getUserManager().queryPlayer(player).isDebugMode();
if(debugMode) {
player.sendMessage("FURNACE FUEL EFFICIENCY DEBUG REPORT");
@ -81,7 +81,7 @@ public class InventoryListener implements Listener {
player.sendMessage("Burn Length before Fuel Efficiency is applied - "+event.getBurnTime());
}
event.setBurnTime(mcMMO.getUserManager().queryMcMMOPlayer(player).getSmeltingManager().fuelEfficiency(event.getBurnTime()));
event.setBurnTime(mcMMO.getUserManager().queryPlayer(player).getSmeltingManager().fuelEfficiency(event.getBurnTime()));
if(debugMode) {
player.sendMessage("New Furnace Burn Length (after applying fuel efficiency) "+event.getBurnTime());
@ -111,7 +111,7 @@ public class InventoryListener implements Listener {
if(offlinePlayer != null) {
McMMOPlayer offlineProfile = mcMMO.getUserManager().queryMcMMOPlayer(offlinePlayer);
McMMOPlayer offlineProfile = mcMMO.getUserManager().queryOfflineMcMMOPlayer(offlinePlayer);
//Profile doesn't exist
if(offlineProfile != null) {
@ -148,13 +148,13 @@ public class InventoryListener implements Listener {
}
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
return;
}
int xpToDrop = event.getExpToDrop();
int exp = mcMMO.getUserManager().queryMcMMOPlayer(player).getSmeltingManager().vanillaXPBoost(xpToDrop);
int exp = mcMMO.getUserManager().queryPlayer(player).getSmeltingManager().vanillaXPBoost(xpToDrop);
event.setExpToDrop(exp);
}
}

View File

@ -87,12 +87,12 @@ public class PlayerListener implements Listener {
}
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
return;
}
mcMMO.getUserManager().queryMcMMOPlayer(player).actualizeTeleportATS();
mcMMO.getUserManager().queryPlayer(player).actualizeTeleportATS();
}
/**
* Handle PlayerDeathEvents at the lowest priority.
@ -197,12 +197,12 @@ public class PlayerListener implements Listener {
}
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
return;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
mmoPlayer.checkGodMode();
mmoPlayer.checkParty();
@ -268,12 +268,12 @@ public class PlayerListener implements Listener {
}
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
return;
}
FishingManager fishingManager = mcMMO.getUserManager().queryMcMMOPlayer(player).getFishingManager();
FishingManager fishingManager = mcMMO.getUserManager().queryPlayer(player).getFishingManager();
switch (event.getState()) {
case CAUGHT_FISH:
@ -346,13 +346,13 @@ public class PlayerListener implements Listener {
}
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
return;
}
Entity caught = event.getCaught();
FishingManager fishingManager = mcMMO.getUserManager().queryMcMMOPlayer(player).getFishingManager();
FishingManager fishingManager = mcMMO.getUserManager().queryPlayer(player).getFishingManager();
//Track the hook
if(ExperienceConfig.getInstance().isFishingExploitingPrevented())
@ -441,12 +441,12 @@ public class PlayerListener implements Listener {
}
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
return;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
Item drop = event.getItem();
ItemStack dropStack = drop.getItemStack();
@ -503,13 +503,13 @@ public class PlayerListener implements Listener {
}
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
return;
}
//No need for null checks here
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
//TODO: There's an issue with using Async saves on player quit
//TODO: Basically there are conditions in which an async task does not execute fast enough to save the data if the server shutdown shortly after this task was scheduled
mcMMO.getUserManager().saveUserWithDelay(mmoPlayer.getPersistentPlayerData(), false, 20);
@ -560,12 +560,12 @@ public class PlayerListener implements Listener {
}
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
return;
}
mcMMO.getUserManager().queryMcMMOPlayer(player).actualizeRespawnATS();
mcMMO.getUserManager().queryPlayer(player).actualizeRespawnATS();
}
/**
@ -607,12 +607,12 @@ public class PlayerListener implements Listener {
}
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
return;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
MiningManager miningManager = mmoPlayer.getMiningManager();
ItemStack heldItem = player.getInventory().getItemInMainHand();
@ -641,7 +641,7 @@ public class PlayerListener implements Listener {
&& RankUtils.hasUnlockedSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR)
&& mcMMO.getSalvageableManager().isSalvageable(heldItem)
&& heldItem.getAmount() <= 1) {
SalvageManager salvageManager = mcMMO.getUserManager().queryMcMMOPlayer(player).getSalvageManager();
SalvageManager salvageManager = mcMMO.getUserManager().queryPlayer(player).getSalvageManager();
event.setCancelled(true);
// Make sure the player knows what he's doing when trying to salvage an enchanted item
@ -723,12 +723,12 @@ public class PlayerListener implements Listener {
}
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
return;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
ItemStack heldItem = player.getInventory().getItemInMainHand();
//Spam Fishing Detection
@ -763,7 +763,7 @@ public class PlayerListener implements Listener {
return;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
if (mmoPlayer == null) {
mcMMO.p.debug(player.getName() + "is chatting, but is currently not logged in to the server.");

View File

@ -38,14 +38,14 @@ public class SelfListener implements Listener {
{
int previousLevelGained = event.getSkillLevel() - i;
//Send player skill unlock notifications
RankUtils.executeSkillUnlockNotifications(plugin, mcMMO.getUserManager().queryMcMMOPlayer(player), event.getSkill(), previousLevelGained);
RankUtils.executeSkillUnlockNotifications(plugin, mcMMO.getUserManager().queryPlayer(player), event.getSkill(), previousLevelGained);
}
for(int i = 0; i < event.getLevelsGained(); i++)
{
int previousLevelGained = event.getSkillLevel() - i;
//Send player skill unlock notifications
RankUtils.executeSkillUnlockNotifications(plugin, mcMMO.getUserManager().queryMcMMOPlayer(player), event.getSkill(), previousLevelGained);
RankUtils.executeSkillUnlockNotifications(plugin, mcMMO.getUserManager().queryPlayer(player), event.getSkill(), previousLevelGained);
}
//Reset the delay timer
@ -81,7 +81,7 @@ public class SelfListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerXpGain(McMMOPlayerXpGainEvent event) {
Player player = event.getPlayer();
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
PrimarySkillType primarySkillType = event.getSkill();
if(mmoPlayer.isDebugMode()) {

View File

@ -139,19 +139,19 @@ public final class PartyManager {
*/
public boolean inSameParty(Player firstPlayer, Player secondPlayer) {
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(firstPlayer) == null)
if(mcMMO.getUserManager().queryPlayer(firstPlayer) == null)
{
return false;
}
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(secondPlayer) == null)
if(mcMMO.getUserManager().queryPlayer(secondPlayer) == null)
{
return false;
}
Party firstParty = mcMMO.getUserManager().queryMcMMOPlayer(firstPlayer).getParty();
Party secondParty = mcMMO.getUserManager().queryMcMMOPlayer(secondPlayer).getParty();
Party firstParty = mcMMO.getUserManager().queryPlayer(firstPlayer).getParty();
Party secondParty = mcMMO.getUserManager().queryPlayer(secondPlayer).getParty();
if (firstParty == null || secondParty == null) {
return false;
@ -305,12 +305,12 @@ public final class PartyManager {
*/
public Party getParty(Player player) {
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
{
return null;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
return mmoPlayer.getParty();
}
@ -372,12 +372,12 @@ public final class PartyManager {
//TODO: Potential issues with unloaded profile?
for (Player member : party.getPartyMembers()) {
//Profile not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(member) == null)
if(mcMMO.getUserManager().queryPlayer(member) == null)
{
continue;
}
processPartyLeaving(mcMMO.getUserManager().queryMcMMOPlayer(member));
processPartyLeaving(mcMMO.getUserManager().queryPlayer(member));
}
// Disband the alliance between the disbanded party and it's ally

View File

@ -48,7 +48,7 @@ public final class ShareHandler {
float splitXp = (float) (xp / partySize * shareBonus);
for (Player otherMember : nearMembers) {
McMMOPlayer partyMember = mcMMO.getUserManager().queryMcMMOPlayer(otherMember);
McMMOPlayer partyMember = mcMMO.getUserManager().queryPlayer(otherMember);
//Profile not loaded
if(partyMember == null) {

View File

@ -26,7 +26,7 @@ public class FormulaConversionTask extends BukkitRunnable {
int convertedUsers = 0;
long startMillis = System.currentTimeMillis();
for (String playerName : mcMMO.getDatabaseManager().getStoredUsers()) {
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getOfflinePlayer(playerName);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayerName(playerName);
PlayerProfile profile;
// If the mmoPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.

View File

@ -39,9 +39,9 @@ public class AlchemyBrewTask extends BukkitRunnable {
if (player != null
&& !Misc.isNPCEntityExcludingVillagers(player)
&& Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CATALYSIS)
&& mcMMO.getUserManager().queryMcMMOPlayer(player) != null) {
&& mcMMO.getUserManager().queryPlayer(player) != null) {
double catalysis = mcMMO.getUserManager().queryMcMMOPlayer(player).getAlchemyManager().calculateBrewSpeed(Permissions.lucky(player, PrimarySkillType.ALCHEMY));
double catalysis = mcMMO.getUserManager().queryPlayer(player).getAlchemyManager().calculateBrewSpeed(Permissions.lucky(player, PrimarySkillType.ALCHEMY));
McMMOPlayerCatalysisEvent event = new McMMOPlayerCatalysisEvent(player, catalysis);
mcMMO.p.getServer().getPluginManager().callEvent(event);

View File

@ -92,12 +92,12 @@ public final class AlchemyPotionBrewer {
}
private static List<ItemStack> getValidIngredients(Player player) {
if(player == null || mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(player == null || mcMMO.getUserManager().queryPlayer(player) == null)
{
return PotionConfig.getInstance().getIngredients(1);
}
return PotionConfig.getInstance().getIngredients(!Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CONCOCTIONS) ? 1 : mcMMO.getUserManager().queryMcMMOPlayer(player).getAlchemyManager().getTier());
return PotionConfig.getInstance().getIngredients(!Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CONCOCTIONS) ? 1 : mcMMO.getUserManager().queryPlayer(player).getAlchemyManager().getTier());
}
public static void finishBrewing(BlockState brewingStand, Player player, boolean forced) {
@ -148,7 +148,7 @@ public final class AlchemyPotionBrewer {
//TODO: hmm
if (mcMMO.getUserManager().hasPlayerDataKey(player)) {
mcMMO.getUserManager().queryMcMMOPlayer(player).getAlchemyManager().handlePotionBrewSuccesses(potionStage, 1);
mcMMO.getUserManager().queryPlayer(player).getAlchemyManager().handlePotionBrewSuccesses(potionStage, 1);
}
}
}

View File

@ -102,12 +102,12 @@ public class BlastMining {
return false;
}
if(mcMMO.getUserManager().queryMcMMOPlayer(defender) == null)
if(mcMMO.getUserManager().queryPlayer(defender) == null)
{
return false;
}
MiningManager miningManager = mcMMO.getUserManager().queryMcMMOPlayer(defender).getMiningManager();
MiningManager miningManager = mcMMO.getUserManager().queryPlayer(defender).getMiningManager();
if (!miningManager.canUseDemolitionsExpertise()) {
return false;

View File

@ -106,13 +106,13 @@ public class UnarmedManager extends SkillManager {
return;
}
if(mcMMO.getUserManager().queryMcMMOPlayer(defender) == null)
if(mcMMO.getUserManager().queryPlayer(defender) == null)
return;
Item item = Misc.spawnItem(defender.getLocation(), defender.getInventory().getItemInMainHand(), ItemSpawnReason.UNARMED_DISARMED_ITEM);
if (item != null && AdvancedConfig.getInstance().getDisarmProtected()) {
item.setMetadata(mcMMO.disarmedItemKey, mcMMO.getUserManager().queryMcMMOPlayer(defender).getPlayerMetadata());
item.setMetadata(mcMMO.disarmedItemKey, mcMMO.getUserManager().queryPlayer(defender).getPlayerMetadata());
}
defender.getInventory().setItemInMainHand(new ItemStack(Material.AIR));

View File

@ -51,7 +51,7 @@ public final class ChimaeraWing {
return;
}
mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
//Not loaded
if(mmoPlayer == null)

View File

@ -96,7 +96,7 @@ public final class EventUtils {
*/
public static McMMOPlayer getMcMMOPlayer(@NotNull Entity entity)
{
return mcMMO.getUserManager().queryMcMMOPlayer((Player)entity);
return mcMMO.getUserManager().queryPlayer((Player)entity);
}
/**
@ -144,7 +144,7 @@ public final class EventUtils {
return true;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
if(mmoPlayer == null)
{
@ -222,7 +222,7 @@ public final class EventUtils {
boolean isCancelled = event.isCancelled();
if (isCancelled) {
PlayerProfile profile = mcMMO.getUserManager().queryMcMMOPlayer(player);
PlayerProfile profile = mcMMO.getUserManager().queryPlayer(player);
profile.getExperienceManager().setSkillLevel(skill, profile.getSkillLevel(skill) - (isLevelUp ? levelsChanged : -levelsChanged));
profile.addXp(skill, xpRemoved);
@ -238,7 +238,7 @@ public final class EventUtils {
boolean isCancelled = event.isCancelled();
if (isCancelled) {
PlayerProfile profile = mcMMO.getUserManager().queryMcMMOPlayer(player);
PlayerProfile profile = mcMMO.getUserManager().queryPlayer(player);
profile.modifySkill(skill, profile.getSkillLevel(skill) - (isLevelUp ? levelsChanged : -levelsChanged));
profile.addXp(skill, xpRemoved);
@ -273,7 +273,7 @@ public final class EventUtils {
}
public static void handlePartyTeleportEvent(Player teleportingPlayer, Player targetPlayer) {
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(teleportingPlayer);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(teleportingPlayer);
if(mmoPlayer == null)
return;
@ -328,15 +328,15 @@ public final class EventUtils {
boolean isCancelled = event.isCancelled();
if (!isCancelled) {
mcMMO.getUserManager().queryMcMMOPlayer(player).addXp(skill, event.getRawXpGained());
mcMMO.getUserManager().queryMcMMOPlayer(player).registerXpGain(skill, event.getRawXpGained());
mcMMO.getUserManager().queryPlayer(player).addXp(skill, event.getRawXpGained());
mcMMO.getUserManager().queryPlayer(player).registerXpGain(skill, event.getRawXpGained());
}
return !isCancelled;
}
public static boolean handleStatsLossEvent(Player player, HashMap<String, Integer> levelChanged, HashMap<String, Float> experienceChanged) {
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
return true;
McMMOPlayerStatLossEvent event = new McMMOPlayerStatLossEvent(player, levelChanged, experienceChanged);
@ -347,7 +347,7 @@ public final class EventUtils {
if (!isCancelled) {
levelChanged = event.getLevelChanged();
experienceChanged = event.getExperienceChanged();
PlayerProfile playerProfile = mcMMO.getUserManager().queryMcMMOPlayer(player);
PlayerProfile playerProfile = mcMMO.getUserManager().queryPlayer(player);
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
String skillName = primarySkillType.toString();
@ -386,17 +386,17 @@ public final class EventUtils {
HashMap<String, Integer> levelChangedVictim = eventVictim.getLevelChanged();
HashMap<String, Float> experienceChangedVictim = eventVictim.getExperienceChanged();
McMMOPlayer killerPlayer = mcMMO.getUserManager().queryMcMMOPlayer(killer);
McMMOPlayer killerPlayer = mcMMO.getUserManager().queryPlayer(killer);
//Not loaded
if(killerPlayer == null)
return true;
//Not loaded
if(mcMMO.getUserManager().queryMcMMOPlayer(victim) == null)
if(mcMMO.getUserManager().queryPlayer(victim) == null)
return true;
PlayerProfile victimProfile = mcMMO.getUserManager().queryMcMMOPlayer(victim);
PlayerProfile victimProfile = mcMMO.getUserManager().queryPlayer(victim);
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
String skillName = primarySkillType.toString();

View File

@ -25,10 +25,10 @@ public final class HardcoreManager {
double statLossPercentage = Config.getInstance().getHardcoreDeathStatPenaltyPercentage();
int levelThreshold = Config.getInstance().getHardcoreDeathStatPenaltyLevelThreshold();
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
return;
PlayerProfile playerProfile = mcMMO.getUserManager().queryMcMMOPlayer(player);
PlayerProfile playerProfile = mcMMO.getUserManager().queryPlayer(player);
int totalLevelsLost = 0;
HashMap<String, Integer> levelChanged = new HashMap<>();
@ -76,11 +76,11 @@ public final class HardcoreManager {
double vampirismStatLeechPercentage = Config.getInstance().getHardcoreVampirismStatLeechPercentage();
int levelThreshold = Config.getInstance().getHardcoreVampirismLevelThreshold();
if(mcMMO.getUserManager().queryMcMMOPlayer(killer) == null || mcMMO.getUserManager().queryMcMMOPlayer(victim) == null)
if(mcMMO.getUserManager().queryPlayer(killer) == null || mcMMO.getUserManager().queryPlayer(victim) == null)
return;
PlayerProfile killerProfile = mcMMO.getUserManager().queryMcMMOPlayer(killer);
PlayerProfile victimProfile = mcMMO.getUserManager().queryMcMMOPlayer(victim);
PlayerProfile killerProfile = mcMMO.getUserManager().queryPlayer(killer);
PlayerProfile victimProfile = mcMMO.getUserManager().queryPlayer(victim);
int totalLevelsStolen = 0;
HashMap<String, Integer> levelChanged = new HashMap<>();

View File

@ -368,7 +368,7 @@ public final class HolidayManager {
if(!Config.getInstance().isAprilFoolsAllowed())
return;
final McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
final McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
if (mmoPlayer == null) return;
int levelTotal = Misc.getRandom().nextInt(1 + mmoPlayer.getSkillLevel(PrimarySkillType.MINING)) + 1;

View File

@ -215,10 +215,10 @@ public final class CommandUtils {
}
private static void printGroupedSkillData(Player inspect, CommandSender display, String header, List<PrimarySkillType> skillGroup) {
if(mcMMO.getUserManager().queryMcMMOPlayer(inspect) == null)
if(mcMMO.getUserManager().queryPlayer(inspect) == null)
return;
PlayerProfile profile = mcMMO.getUserManager().queryMcMMOPlayer(inspect);
PlayerProfile profile = mcMMO.getUserManager().queryPlayer(inspect);
List<String> displayData = new ArrayList<>();
displayData.add(header);

View File

@ -36,7 +36,7 @@ public class NotificationManager {
*/
public static void sendPlayerInformation(Player player, NotificationType notificationType, String key)
{
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null || !mcMMO.getUserManager().queryMcMMOPlayer(player).hasSkillChatNotifications())
if(mcMMO.getUserManager().queryPlayer(player) == null || !mcMMO.getUserManager().queryPlayer(player).hasSkillChatNotifications())
return;
McMMOMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? McMMOMessageType.ACTION_BAR : McMMOMessageType.SYSTEM;
@ -50,10 +50,10 @@ public class NotificationManager {
public static boolean doesPlayerUseNotifications(Player player)
{
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null)
if(mcMMO.getUserManager().queryPlayer(player) == null)
return false;
else
return mcMMO.getUserManager().queryMcMMOPlayer(player).hasSkillChatNotifications();
return mcMMO.getUserManager().queryPlayer(player).hasSkillChatNotifications();
}
/**
@ -72,7 +72,7 @@ public class NotificationManager {
public static void sendPlayerInformationChatOnly(Player player, String key, String... values)
{
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null || !mcMMO.getUserManager().queryMcMMOPlayer(player).hasSkillChatNotifications())
if(mcMMO.getUserManager().queryPlayer(player) == null || !mcMMO.getUserManager().queryPlayer(player).hasSkillChatNotifications())
return;
String preColoredString = LocaleLoader.getString(key, (Object[]) values);
@ -81,7 +81,7 @@ public class NotificationManager {
public static void sendPlayerInformationChatOnlyPrefixed(Player player, String key, String... values)
{
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null || !mcMMO.getUserManager().queryMcMMOPlayer(player).hasSkillChatNotifications())
if(mcMMO.getUserManager().queryPlayer(player) == null || !mcMMO.getUserManager().queryPlayer(player).hasSkillChatNotifications())
return;
String preColoredString = LocaleLoader.getString(key, (Object[]) values);
@ -91,7 +91,7 @@ public class NotificationManager {
public static void sendPlayerInformation(Player player, NotificationType notificationType, String key, String... values)
{
if(mcMMO.getUserManager().queryMcMMOPlayer(player) == null || !mcMMO.getUserManager().queryMcMMOPlayer(player).hasSkillChatNotifications())
if(mcMMO.getUserManager().queryPlayer(player) == null || !mcMMO.getUserManager().queryPlayer(player).hasSkillChatNotifications())
return;
McMMOMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? McMMOMessageType.ACTION_BAR : McMMOMessageType.SYSTEM;

View File

@ -4,6 +4,7 @@ import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.MMODataSnapshot;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PersistentPlayerData;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.player.PersistentPlayerDataSaveTask;
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
@ -42,20 +43,43 @@ public final class UserManager {
playerDataSet.add(mmoPlayer); //for sync saves on shutdown
}
/**
* Cleanup player data
*
* @param mmoPlayer target player
*/
public void cleanupPlayer(@NotNull McMMOPlayer mmoPlayer) {
playerDataSet.remove(mmoPlayer);
}
/**
* 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 @Nullable McMMOPlayer queryPlayer(@Nullable Player player) {
if(player == null)
return null;
if(player.hasMetadata(mcMMO.playerDataKey))
return (McMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value();
else
return null;
}
/**
* Remove a user.
*
* @param player The Player object
*/
public void remove(@NotNull Player player) {
McMMOPlayer mmoPlayer = queryMcMMOPlayer(player);
mmoPlayer.cleanup();
player.removeMetadata(mcMMO.playerDataKey, mcMMO.p);
McMMOPlayer mmoPlayer = queryPlayer(player);
if(mmoPlayer != null) {
mmoPlayer.cleanup();
}
player.removeMetadata(mcMMO.playerDataKey, mcMMO.p);
playerDataSet.remove(mmoPlayer); //Clear sync save tracking
}
@ -75,83 +99,13 @@ public final class UserManager {
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
if (hasPlayerDataKey(player)) {
playerCollection.add(queryMcMMOPlayer(player));
playerCollection.add(queryPlayer(player));
}
}
return playerCollection;
}
/**
* Get the McMMOPlayer of a player by name.
*
* @param playerName The name of the player whose McMMOPlayer to retrieve
* @return the player's McMMOPlayer object
*/
public @Nullable McMMOPlayer queryMcMMOPlayer(@NotNull UUID playerUUID) {
return retrieveMcMMOPlayer(playerName, false);
}
/**
* Attempts to find a player in the database by name alone
* @param playerName target player name
* @return will return a valid McMMOPlayer if one is found, otherwise returns null
*/
public @Nullable OfflinePlayer findPlayer(@NotNull String playerName) {
}
public @Nullable McMMOPlayer queryMcMMOPlayer(@NotNull OfflinePlayer offlinePlayer) {
return queryMcMMOPlayer(offlinePlayer.getUniqueId());
}
/**
* Used to grab a player by name alone
* @param playerName
* @return
*/
@Deprecated
public @Nullable McMMOPlayer queryMcMMOPlayer(@NotNull String playerName) {
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerName);
if(offlinePlayer != null) {
return retrieveMcMMOPlayer(offlinePlayer);
} else {
return null;
}
}
public @Nullable McMMOPlayer getOfflinePlayer(String playerName) {
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 @Nullable McMMOPlayer queryMcMMOPlayer(@NotNull Player player) {
//Avoid Array Index out of bounds
if(player != null && player.hasMetadata(mcMMO.playerDataKey))
return (McMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value();
else
return null;
}
private @Nullable McMMOPlayer retrieveMcMMOPlayer(@NotNull String playerName, boolean offlineValid) {
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
if (player == null) {
if (!offlineValid) {
mcMMO.p.getLogger().warning("A valid mmoPlayer object could not be found for " + playerName + ".");
}
return null;
}
return queryMcMMOPlayer(player);
}
public boolean hasPlayerDataKey(Entity entity) {
return entity != null && entity.hasMetadata(mcMMO.playerDataKey);
}

View File

@ -205,7 +205,7 @@ public class ScoreboardWrapper {
if(mcMMO.getUserManager().getPlayer(playerName) == null)
return;
PlayerProfile profile = mcMMO.getUserManager().queryMcMMOPlayer(player);
PlayerProfile profile = mcMMO.getUserManager().queryPlayer(player);
if (profile.getScoreboardTipsShown() >= Config.getInstance().getTipsAmount()) {
return;
@ -433,7 +433,7 @@ public class ScoreboardWrapper {
return;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
if(mmoPlayer == null)
return;

View File

@ -75,7 +75,7 @@ public final class CombatUtils {
return;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
//Make sure the profiles been loaded
if(mmoPlayer == null) {
@ -125,7 +125,7 @@ public final class CombatUtils {
return;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
//Make sure the profiles been loaded
if(mmoPlayer == null) {
@ -161,7 +161,7 @@ public final class CombatUtils {
double finalDamage = initialDamage;
Map<DamageModifier, Double> modifiers = getModifiers(event);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
//Make sure the profiles been loaded
if(mmoPlayer == null) {
@ -212,7 +212,7 @@ public final class CombatUtils {
double initialDamage = event.getDamage();
double finalDamage = initialDamage;
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
//Make sure the profiles been loaded
if(mmoPlayer == null) {
@ -253,7 +253,7 @@ public final class CombatUtils {
double finalDamage = initialDamage;
if(master != null && master.isOnline() && master.isValid()) {
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(master);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(master);
//Make sure the profiles been loaded
if(mmoPlayer == null) {
@ -285,7 +285,7 @@ public final class CombatUtils {
private static void processArcheryCombat(@NotNull LivingEntity target, @NotNull Player player, @NotNull EntityDamageByEntityEvent event, @NotNull Projectile arrow) {
double initialDamage = event.getDamage();
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
//Make sure the profiles been loaded
if(mmoPlayer == null) {
@ -334,7 +334,7 @@ public final class CombatUtils {
private static void processCrossbowCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event, Projectile arrow) {
double initialDamage = event.getDamage();
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
//Make sure the profiles been loaded
if(mmoPlayer == null) {
@ -346,7 +346,7 @@ public final class CombatUtils {
double finalDamage = event.getDamage();
if (target instanceof Player && PrimarySkillType.UNARMED.getPVPEnabled()) {
UnarmedManager unarmedManager = mcMMO.getUserManager().queryMcMMOPlayer((Player) target).getUnarmedManager();
UnarmedManager unarmedManager = mcMMO.getUserManager().queryPlayer((Player) target).getUnarmedManager();
if (unarmedManager.canDeflect()) {
event.setCancelled(unarmedManager.deflectCheck());
@ -393,7 +393,7 @@ public final class CombatUtils {
return;
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
AcrobaticsManager acrobaticsManager = mmoPlayer.getAcrobaticsManager();
if (acrobaticsManager.canDodge(target)) {
@ -424,7 +424,7 @@ public final class CombatUtils {
if (target instanceof Tameable) {
if (heldItem.getType() == Material.BONE) {
TamingManager tamingManager = mcMMO.getUserManager().queryMcMMOPlayer(player).getTamingManager();
TamingManager tamingManager = mcMMO.getUserManager().queryPlayer(player).getTamingManager();
if (tamingManager.canUseBeastLore()) {
tamingManager.beastLore(target);
@ -514,7 +514,7 @@ public final class CombatUtils {
}
if (target.getType() != EntityType.CREEPER && !Misc.isNPCEntityExcludingVillagers(player) && PrimarySkillType.TAMING.getPermissions(player)) {
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
if(mmoPlayer == null) {
return;
@ -769,7 +769,7 @@ public final class CombatUtils {
NotificationManager.sendPlayerInformation((Player)entity, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.SS.Struck");
}
mcMMO.getUserManager().queryMcMMOPlayer(attacker).getSwordsManager().ruptureCheck(target);
mcMMO.getUserManager().queryPlayer(attacker).getSwordsManager().ruptureCheck(target);
break;
case AXES:
@ -895,10 +895,10 @@ public final class CombatUtils {
Player defender = (Player) entity;
//TODO: NPC Interaction?
if(mcMMO.getUserManager().queryMcMMOPlayer(defender) == null)
if(mcMMO.getUserManager().queryPlayer(defender) == null)
return true;
if (!defender.getWorld().getPVP() || defender == player || mcMMO.getUserManager().queryMcMMOPlayer(defender).getGodMode()) {
if (!defender.getWorld().getPVP() || defender == player || mcMMO.getUserManager().queryPlayer(defender).getGodMode()) {
return false;
}

View File

@ -50,7 +50,7 @@ public final class PerksUtils {
double modifier = 1.0F;
if (Permissions.customXpBoost(player, skill)) {
if(mcMMO.getUserManager().queryMcMMOPlayer(player) != null && mcMMO.getUserManager().queryMcMMOPlayer(player).isDebugMode()) {
if(mcMMO.getUserManager().queryPlayer(player) != null && mcMMO.getUserManager().queryPlayer(player).isDebugMode()) {
player.sendMessage(ChatColor.GOLD + "[DEBUG] " + ChatColor.DARK_GRAY + "XP Perk Multiplier IS CUSTOM! ");
}
@ -77,7 +77,7 @@ public final class PerksUtils {
float modifiedXP = (float) (xp * modifier);
if(mcMMO.getUserManager().queryMcMMOPlayer(player) != null && mcMMO.getUserManager().queryMcMMOPlayer(player).isDebugMode()) {
if(mcMMO.getUserManager().queryPlayer(player) != null && mcMMO.getUserManager().queryPlayer(player).isDebugMode()) {
player.sendMessage(ChatColor.GOLD + "[DEBUG] " + ChatColor.RESET + "XP Perk Multiplier - " + ChatColor.GOLD + modifier);
player.sendMessage(ChatColor.GOLD + "[DEBUG] " + ChatColor.RESET + "Original XP before perk boosts " + ChatColor.RED + (double) xp);
player.sendMessage(ChatColor.GOLD + "[DEBUG] " + ChatColor.RESET + "XP AFTER PERKS " + ChatColor.DARK_RED + modifiedXP);

View File

@ -186,7 +186,7 @@ public final class SkillUtils {
}
}
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
//Not Loaded
if(mmoPlayer == null)

View File

@ -21,7 +21,7 @@ public class SmeltingTracker {
private void changeFurnaceOwnership(Furnace furnace, Player player) {
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
/*
Debug output
@ -52,7 +52,7 @@ public class SmeltingTracker {
OfflinePlayer furnaceOwner = getFurnaceOwner(furnace);
if(furnaceOwner != null && furnaceOwner.isOnline()) {
McMMOPlayer furnaceOwnerProfile = mcMMO.getUserManager().queryMcMMOPlayer(furnaceOwner.getPlayer());
McMMOPlayer furnaceOwnerProfile = mcMMO.getUserManager().queryPlayer(furnaceOwner.getPlayer());
if(furnaceOwnerProfile != null) {
if(furnaceOwnerProfile.isDebugMode()) {