Refactoring a bunch of stuff, more refactoring to come

This commit is contained in:
nossr50 2020-08-17 21:15:27 -07:00
parent 0e9e1f5133
commit daada1a643
161 changed files with 1934 additions and 2575 deletions

View File

@ -42,9 +42,21 @@ Version 2.2.000
Added new locale string 'Crossbows.SubSkill.CrossbowsLimitBreak.Description' Added new locale string 'Crossbows.SubSkill.CrossbowsLimitBreak.Description'
Added new locale string 'Crossbows.SubSkill.CrossbowsLimitBreak.Stat' Added new locale string 'Crossbows.SubSkill.CrossbowsLimitBreak.Stat'
Player Power Levels no longer need to pass permission checks when summing skills
Minor improvements to how player data is serialized
SMP mod settings removed from config.yml (this is a legacy feature and didn't really do anything anymore)
Refactored & Optimized a bunch of code involving player and party data
Added XP bar settings for Tridents & Crossbows to experience.yml Added XP bar settings for Tridents & Crossbows to experience.yml
Changed some debug level logging to info level for convenience Changed some debug level logging to info level for convenience
XP Bar settings (set by /mmoxpbar command) are now saved per player
Database Changes
XP Bar settings (set by /mmoxpbar command) are now saved
Players can now be marked as exempt from leadboards
Party Chat Spy toggle is now saved
(FlatFile) Fixed a bug where last login was not being saved
Schema updated for the new skills and supers and things mentioned above
Notes: Notes:
These are the first new skills that I've written for mcMMO in about 9 years, I'll be listening closely to feedback and tweaking them often. These are the first new skills that I've written for mcMMO in about 9 years, I'll be listening closely to feedback and tweaking them often.
@ -1080,7 +1092,7 @@ Version 2.1.43
Version 2.1.42 Version 2.1.42
Fixed McMMOPlayerNotFoundException being thrown instead of null Fixed McMMOPlayerNotFoundException being thrown instead of null
(API) UserManager.getPlayer() returns null again (oopsie) (API) mcMMO.getUserManager().getPlayer() returns null again (oopsie)
Added new perk permission node `mcmmo.perks.bypass.salvageenchant` - guarantees full enchantment return for Salvage Added new perk permission node `mcmmo.perks.bypass.salvageenchant` - guarantees full enchantment return for Salvage
Added alternative permission node `mcmmo.perks.bypass.repairenchant` - guarantees full enchantment return for Repair Added alternative permission node `mcmmo.perks.bypass.repairenchant` - guarantees full enchantment return for Repair
Added new wildcard perk `mcmmo.perks.bypass.*` and `mcmmo.perks.bypass.all` (either of these will grant all new mcmmo.perks.bypass perk permissions) Added new wildcard perk `mcmmo.perks.bypass.*` and `mcmmo.perks.bypass.all` (either of these will grant all new mcmmo.perks.bypass perk permissions)
@ -1096,7 +1108,7 @@ Version 2.1.41
Fixed a display error preventing the remaining time on /mcrank from being shown if it was on cooldown Fixed a display error preventing the remaining time on /mcrank from being shown if it was on cooldown
Version 2.1.40 Version 2.1.40
(API) mcMMO will now return null in all cases for UserManager.getPlayerProfile() if they have not been loaded yet (API) mcMMO will now return null in all cases for mcMMO.getUserManager() if they have not been loaded yet
(API) Roll stores exploit data in AcrobaticsManager now (API) Roll stores exploit data in AcrobaticsManager now
Added new locale string "Profile.Loading.FailureNotice" Added new locale string "Profile.Loading.FailureNotice"
Added new locale string "Profile.Loading.FailurePlayer" Added new locale string "Profile.Loading.FailurePlayer"
@ -1661,7 +1673,7 @@ Version 1.5.01
= Fixed bug where pistons would mess with the block tracking = Fixed bug where pistons would mess with the block tracking
= Fixed bug where the Updater was running on the main thread. = Fixed bug where the Updater was running on the main thread.
= Fixed bug when players would use /ptp without being in a party = Fixed bug when players would use /ptp without being in a party
= Fixed bug where player didn't have a mcMMOPlayer object in AsyncPlayerChatEvent = Fixed bug where player didn't have a mmoPlayer object in AsyncPlayerChatEvent
= Fixed bug where dodge would check the wrong player skill level = Fixed bug where dodge would check the wrong player skill level
= Fixed bug which causes /party teleport to stop working = Fixed bug which causes /party teleport to stop working
= Fixed bug where SaveTimerTask would produce an IndexOutOfBoundsException = Fixed bug where SaveTimerTask would produce an IndexOutOfBoundsException

View File

@ -2,8 +2,8 @@ package com.gmail.nossr50.api;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.BleedTimerTask; import com.gmail.nossr50.runnables.skills.BleedTimerTask;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -11,38 +11,38 @@ public final class AbilityAPI {
private AbilityAPI() {} private AbilityAPI() {}
public static boolean berserkEnabled(Player player) { public static boolean berserkEnabled(Player player) {
return UserManager.getPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.BERSERK); return mcMMO.getUserManager().getPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.BERSERK);
} }
public static boolean gigaDrillBreakerEnabled(Player player) { public static boolean gigaDrillBreakerEnabled(Player player) {
return UserManager.getPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER); return mcMMO.getUserManager().getPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER);
} }
public static boolean greenTerraEnabled(Player player) { public static boolean greenTerraEnabled(Player player) {
return UserManager.getPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.GREEN_TERRA); return mcMMO.getUserManager().getPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.GREEN_TERRA);
} }
public static boolean serratedStrikesEnabled(Player player) { public static boolean serratedStrikesEnabled(Player player) {
return UserManager.getPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.SERRATED_STRIKES); return mcMMO.getUserManager().getPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.SERRATED_STRIKES);
} }
public static boolean skullSplitterEnabled(Player player) { public static boolean skullSplitterEnabled(Player player) {
return UserManager.getPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.SKULL_SPLITTER); return mcMMO.getUserManager().getPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.SKULL_SPLITTER);
} }
public static boolean superBreakerEnabled(Player player) { public static boolean superBreakerEnabled(Player player) {
return UserManager.getPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.SUPER_BREAKER); return mcMMO.getUserManager().getPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.SUPER_BREAKER);
} }
public static boolean treeFellerEnabled(Player player) { public static boolean treeFellerEnabled(Player player) {
return UserManager.getPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.TREE_FELLER); return mcMMO.getUserManager().getPlayer(player).getSuperAbilityManager().getAbilityMode(SuperAbilityType.TREE_FELLER);
} }
public static boolean isAnyAbilityEnabled(Player player) { public static boolean isAnyAbilityEnabled(Player player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
for (SuperAbilityType ability : SuperAbilityType.values()) { for (SuperAbilityType ability : SuperAbilityType.values()) {
if (mcMMOPlayer.getSuperAbilityManager().getAbilityMode(ability)) { if (mmoPlayer.getSuperAbilityManager().getAbilityMode(ability)) {
return true; return true;
} }
} }
@ -51,35 +51,35 @@ public final class AbilityAPI {
} }
public static void resetCooldowns(Player player) { public static void resetCooldowns(Player player) {
UserManager.getPlayer(player).resetCooldowns(); mcMMO.getUserManager().getPlayer(player).getPersistentPlayerData().resetCooldowns();
} }
public static void setBerserkCooldown(Player player, long cooldown) { public static void setBerserkCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.BERSERK, cooldown); mcMMO.getUserManager().getPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.BERSERK, cooldown);
} }
public static void setGigaDrillBreakerCooldown(Player player, long cooldown) { public static void setGigaDrillBreakerCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.GIGA_DRILL_BREAKER, cooldown); mcMMO.getUserManager().getPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.GIGA_DRILL_BREAKER, cooldown);
} }
public static void setGreenTerraCooldown(Player player, long cooldown) { public static void setGreenTerraCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.GREEN_TERRA, cooldown); mcMMO.getUserManager().getPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.GREEN_TERRA, cooldown);
} }
public static void setSerratedStrikesCooldown(Player player, long cooldown) { public static void setSerratedStrikesCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.SERRATED_STRIKES, cooldown); mcMMO.getUserManager().getPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.SERRATED_STRIKES, cooldown);
} }
public static void setSkullSplitterCooldown(Player player, long cooldown) { public static void setSkullSplitterCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.SKULL_SPLITTER, cooldown); mcMMO.getUserManager().getPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.SKULL_SPLITTER, cooldown);
} }
public static void setSuperBreakerCooldown(Player player, long cooldown) { public static void setSuperBreakerCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.SUPER_BREAKER, cooldown); mcMMO.getUserManager().getPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.SUPER_BREAKER, cooldown);
} }
public static void setTreeFellerCooldown(Player player, long cooldown) { public static void setTreeFellerCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.TREE_FELLER, cooldown); mcMMO.getUserManager().getPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.TREE_FELLER, cooldown);
} }
public static boolean isBleeding(LivingEntity entity) { public static boolean isBleeding(LivingEntity entity) {

View File

@ -4,8 +4,6 @@ import com.gmail.nossr50.chat.ChatManager;
import com.gmail.nossr50.chat.ChatManagerFactory; import com.gmail.nossr50.chat.ChatManagerFactory;
import com.gmail.nossr50.chat.PartyChatManager; import com.gmail.nossr50.chat.PartyChatManager;
import com.gmail.nossr50.datatypes.chat.ChatMode; import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -75,7 +73,7 @@ public final class ChatAPI {
* @return true if the player is using party chat, false otherwise * @return true if the player is using party chat, false otherwise
*/ */
public static boolean isUsingPartyChat(Player player) { public static boolean isUsingPartyChat(Player player) {
return UserManager.getPlayer(player).isChatEnabled(ChatMode.PARTY); return mcMMO.getUserManager().getPlayer(player).isChatEnabled(ChatMode.PARTY);
} }
/** /**
@ -85,7 +83,7 @@ public final class ChatAPI {
* @return true if the player is using party chat, false otherwise * @return true if the player is using party chat, false otherwise
*/ */
public static boolean isUsingPartyChat(String playerName) { public static boolean isUsingPartyChat(String playerName) {
return UserManager.getPlayer(playerName).isChatEnabled(ChatMode.PARTY); return mcMMO.getUserManager().getPlayer(playerName).isChatEnabled(ChatMode.PARTY);
} }
/** /**
@ -95,7 +93,7 @@ public final class ChatAPI {
* @return true if the player is using admin chat, false otherwise * @return true if the player is using admin chat, false otherwise
*/ */
public static boolean isUsingAdminChat(Player player) { public static boolean isUsingAdminChat(Player player) {
return UserManager.getPlayer(player).isChatEnabled(ChatMode.ADMIN); return mcMMO.getUserManager().getPlayer(player).isChatEnabled(ChatMode.ADMIN);
} }
/** /**
@ -105,7 +103,7 @@ public final class ChatAPI {
* @return true if the player is using admin chat, false otherwise * @return true if the player is using admin chat, false otherwise
*/ */
public static boolean isUsingAdminChat(String playerName) { public static boolean isUsingAdminChat(String playerName) {
return UserManager.getPlayer(playerName).isChatEnabled(ChatMode.ADMIN); return mcMMO.getUserManager().getPlayer(playerName).isChatEnabled(ChatMode.ADMIN);
} }
/** /**
@ -114,7 +112,7 @@ public final class ChatAPI {
* @param player The player to toggle party chat on. * @param player The player to toggle party chat on.
*/ */
public static void togglePartyChat(Player player) { public static void togglePartyChat(Player player) {
UserManager.getPlayer(player).toggleChat(ChatMode.PARTY); mcMMO.getUserManager().getPlayer(player).toggleChat(ChatMode.PARTY);
} }
/** /**
@ -123,7 +121,7 @@ public final class ChatAPI {
* @param playerName The name of the player to toggle party chat on. * @param playerName The name of the player to toggle party chat on.
*/ */
public static void togglePartyChat(String playerName) { public static void togglePartyChat(String playerName) {
UserManager.getPlayer(playerName).toggleChat(ChatMode.PARTY); mcMMO.getUserManager().getPlayer(playerName).toggleChat(ChatMode.PARTY);
} }
/** /**
@ -132,7 +130,7 @@ public final class ChatAPI {
* @param player The player to toggle admin chat on. * @param player The player to toggle admin chat on.
*/ */
public static void toggleAdminChat(Player player) { public static void toggleAdminChat(Player player) {
UserManager.getPlayer(player).toggleChat(ChatMode.ADMIN); mcMMO.getUserManager().getPlayer(player).toggleChat(ChatMode.ADMIN);
} }
/** /**
@ -141,12 +139,12 @@ public final class ChatAPI {
* @param playerName The name of the player to toggle party chat on. * @param playerName The name of the player to toggle party chat on.
*/ */
public static void toggleAdminChat(String playerName) { public static void toggleAdminChat(String playerName) {
UserManager.getPlayer(playerName).toggleChat(ChatMode.ADMIN); mcMMO.getUserManager().getPlayer(playerName).toggleChat(ChatMode.ADMIN);
} }
private static ChatManager getPartyChatManager(Plugin plugin, String party) { private static ChatManager getPartyChatManager(Plugin plugin, String party) {
ChatManager chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.PARTY); ChatManager chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.PARTY);
((PartyChatManager) chatManager).setParty(PartyManager.getParty(party)); ((PartyChatManager) chatManager).setParty(mcMMO.getPartyManager().getParty(party));
return chatManager; return chatManager;
} }

View File

@ -11,7 +11,6 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.child.FamilyTree; import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.CombatUtils;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -41,29 +40,29 @@ public final class ExperienceAPI {
* Start the task that gives combat XP. * Start the task that gives combat XP.
* Processes combat XP like mcMMO normally would, so mcMMO will check whether or not the entity should reward XP when giving out the XP * Processes combat XP like mcMMO normally would, so mcMMO will check whether or not the entity should reward XP when giving out the XP
* *
* @param mcMMOPlayer The attacking player * @param mmoPlayer The attacking player
* @param target The defending entity * @param target The defending entity
* @param primarySkillType The skill being used * @param primarySkillType The skill being used
* @param multiplier final XP result will be multiplied by this * @param multiplier final XP result will be multiplied by this
* @deprecated Draft API * @deprecated Draft API
*/ */
@Deprecated @Deprecated
public static void addCombatXP(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType, double multiplier) { public static void addCombatXP(McMMOPlayer mmoPlayer, LivingEntity target, PrimarySkillType primarySkillType, double multiplier) {
CombatUtils.processCombatXP(mcMMOPlayer, target, primarySkillType, multiplier); CombatUtils.processCombatXP(mmoPlayer, target, primarySkillType, multiplier);
} }
/** /**
* Start the task that gives combat XP. * Start the task that gives combat XP.
* Processes combat XP like mcMMO normally would, so mcMMO will check whether or not the entity should reward XP when giving out the XP * Processes combat XP like mcMMO normally would, so mcMMO will check whether or not the entity should reward XP when giving out the XP
* *
* @param mcMMOPlayer The attacking player * @param mmoPlayer The attacking player
* @param target The defending entity * @param target The defending entity
* @param primarySkillType The skill being used * @param primarySkillType The skill being used
* @deprecated Draft API * @deprecated Draft API
*/ */
@Deprecated @Deprecated
public static void addCombatXP(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType) { public static void addCombatXP(McMMOPlayer mmoPlayer, LivingEntity target, PrimarySkillType primarySkillType) {
CombatUtils.processCombatXP(mcMMOPlayer, target, primarySkillType); CombatUtils.processCombatXP(mmoPlayer, target, primarySkillType);
} }
/** /**
@ -136,11 +135,11 @@ public final class ExperienceAPI {
*/ */
public static void addRawXP(Player player, String skillType, float XP, String xpGainReason, boolean isUnshared) { public static void addRawXP(Player player, String skillType, float XP, String xpGainReason, boolean isUnshared) {
if (isUnshared) { if (isUnshared) {
getPlayer(player).beginUnsharedXpGain(getSkillType(skillType), XP, getXPGainReason(xpGainReason), XPGainSource.CUSTOM); getPlayer(player).getExperienceManager().beginUnsharedXpGain(player, getSkillType(skillType), XP, getXPGainReason(xpGainReason), XPGainSource.CUSTOM);
return; return;
} }
getPlayer(player).applyXpGain(getSkillType(skillType), XP, getXPGainReason(xpGainReason), XPGainSource.CUSTOM); getPlayer(player).getExperienceManager().applyXpGain(player, getSkillType(skillType), XP, getXPGainReason(xpGainReason), XPGainSource.CUSTOM);
} }
/** /**
@ -222,7 +221,7 @@ public final class ExperienceAPI {
* @throws InvalidXPGainReasonException if the given xpGainReason is not valid * @throws InvalidXPGainReasonException if the given xpGainReason is not valid
*/ */
public static void addMultipliedXP(Player player, String skillType, int XP, String xpGainReason) { public static void addMultipliedXP(Player player, String skillType, int XP, String xpGainReason) {
getPlayer(player).applyXpGain(getSkillType(skillType), (int) (XP * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()), getXPGainReason(xpGainReason), XPGainSource.CUSTOM); getPlayer(player).getExperienceManager().applyXpGain(player, getSkillType(skillType), (int) (XP * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()), getXPGainReason(xpGainReason), XPGainSource.CUSTOM);
} }
/** /**
@ -293,11 +292,11 @@ public final class ExperienceAPI {
PrimarySkillType skill = getSkillType(skillType); PrimarySkillType skill = getSkillType(skillType);
if (isUnshared) { if (isUnshared) {
getPlayer(player).beginUnsharedXpGain(skill, (int) (XP / skill.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()), getXPGainReason(xpGainReason), XPGainSource.CUSTOM); getPlayer(player).getExperienceManager().beginUnsharedXpGain(player, skill, (int) (XP / skill.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()), getXPGainReason(xpGainReason), XPGainSource.CUSTOM);
return; return;
} }
getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()), getXPGainReason(xpGainReason), XPGainSource.CUSTOM); getPlayer(player).getExperienceManager().applyXpGain(player, skill, (int) (XP / skill.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()), getXPGainReason(xpGainReason), XPGainSource.CUSTOM);
} }
/** /**
@ -371,11 +370,11 @@ public final class ExperienceAPI {
*/ */
public static void addXP(Player player, String skillType, int XP, String xpGainReason, boolean isUnshared) { public static void addXP(Player player, String skillType, int XP, String xpGainReason, boolean isUnshared) {
if (isUnshared) { if (isUnshared) {
getPlayer(player).beginUnsharedXpGain(getSkillType(skillType), XP, getXPGainReason(xpGainReason), XPGainSource.CUSTOM); getPlayer(player).getExperienceManager().beginUnsharedXpGain(player, getSkillType(skillType), XP, getXPGainReason(xpGainReason), XPGainSource.CUSTOM);
return; return;
} }
getPlayer(player).beginXpGain(getSkillType(skillType), XP, getXPGainReason(xpGainReason), XPGainSource.CUSTOM); getPlayer(player).getExperienceManager().beginXpGain(player, getSkillType(skillType), XP, getXPGainReason(xpGainReason), XPGainSource.CUSTOM);
} }
/** /**
@ -391,7 +390,7 @@ public final class ExperienceAPI {
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static int getXP(Player player, String skillType) { public static int getXP(Player player, String skillType) {
return getPlayer(player).getSkillXpLevel(getNonChildSkillType(skillType)); return getPlayer(player).getExperienceManager().getSkillXpLevel(getNonChildSkillType(skillType));
} }
/** /**
@ -409,7 +408,7 @@ public final class ExperienceAPI {
*/ */
@Deprecated @Deprecated
public static int getOfflineXP(String playerName, String skillType) { public static int getOfflineXP(String playerName, String skillType) {
return getOfflineProfile(playerName).getSkillXpLevel(getNonChildSkillType(skillType)); return getOfflineProfile(playerName).getExperienceManager().getSkillXpLevel(getNonChildSkillType(skillType));
} }
/** /**
@ -426,7 +425,7 @@ public final class ExperienceAPI {
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static int getOfflineXP(UUID uuid, String skillType) { public static int getOfflineXP(UUID uuid, String skillType) {
return getOfflineProfile(uuid).getSkillXpLevel(getNonChildSkillType(skillType)); return getOfflineProfile(uuid).getExperienceManager().getSkillXpLevel(getNonChildSkillType(skillType));
} }
/** /**
@ -442,7 +441,7 @@ public final class ExperienceAPI {
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static float getXPRaw(Player player, String skillType) { public static float getXPRaw(Player player, String skillType) {
return getPlayer(player).getSkillXpLevelRaw(getNonChildSkillType(skillType)); return getPlayer(player).getExperienceManager().getSkillXpLevelRaw(getNonChildSkillType(skillType));
} }
/** /**
@ -460,7 +459,7 @@ public final class ExperienceAPI {
*/ */
@Deprecated @Deprecated
public static float getOfflineXPRaw(String playerName, String skillType) { public static float getOfflineXPRaw(String playerName, String skillType) {
return getOfflineProfile(playerName).getSkillXpLevelRaw(getNonChildSkillType(skillType)); return getOfflineProfile(playerName).getExperienceManager().getSkillXpLevelRaw(getNonChildSkillType(skillType));
} }
/** /**
@ -477,7 +476,7 @@ public final class ExperienceAPI {
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static float getOfflineXPRaw(UUID uuid, String skillType) { public static float getOfflineXPRaw(UUID uuid, String skillType) {
return getOfflineProfile(uuid).getSkillXpLevelRaw(getNonChildSkillType(skillType)); return getOfflineProfile(uuid).getExperienceManager().getSkillXpLevelRaw(getNonChildSkillType(skillType));
} }
/** /**
@ -493,7 +492,7 @@ public final class ExperienceAPI {
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static int getXPToNextLevel(Player player, String skillType) { public static int getXPToNextLevel(Player player, String skillType) {
return getPlayer(player).getXpToLevel(getNonChildSkillType(skillType)); return getPlayer(player).getExperienceManager().getXpToLevel(getNonChildSkillType(skillType));
} }
/** /**
@ -511,7 +510,7 @@ public final class ExperienceAPI {
*/ */
@Deprecated @Deprecated
public static int getOfflineXPToNextLevel(String playerName, String skillType) { public static int getOfflineXPToNextLevel(String playerName, String skillType) {
return getOfflineProfile(playerName).getXpToLevel(getNonChildSkillType(skillType)); return getOfflineProfile(playerName).getExperienceManager().getXpToLevel(getNonChildSkillType(skillType));
} }
/** /**
@ -528,7 +527,7 @@ public final class ExperienceAPI {
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static int getOfflineXPToNextLevel(UUID uuid, String skillType) { public static int getOfflineXPToNextLevel(UUID uuid, String skillType) {
return getOfflineProfile(uuid).getXpToLevel(getNonChildSkillType(skillType)); return getOfflineProfile(uuid).getExperienceManager().getXpToLevel(getNonChildSkillType(skillType));
} }
/** /**
@ -546,9 +545,9 @@ public final class ExperienceAPI {
public static int getXPRemaining(Player player, String skillType) { public static int getXPRemaining(Player player, String skillType) {
PrimarySkillType skill = getNonChildSkillType(skillType); PrimarySkillType skill = getNonChildSkillType(skillType);
PlayerProfile profile = getPlayer(player).getProfile(); PlayerProfile profile = getPlayer(player);
return profile.getXpToLevel(skill) - profile.getSkillXpLevel(skill); return profile.getExperienceManager().getXpToLevel(skill) - profile.getExperienceManager().getSkillXpLevel(skill);
} }
/** /**
@ -569,7 +568,7 @@ public final class ExperienceAPI {
PrimarySkillType skill = getNonChildSkillType(skillType); PrimarySkillType skill = getNonChildSkillType(skillType);
PlayerProfile profile = getOfflineProfile(playerName); PlayerProfile profile = getOfflineProfile(playerName);
return profile.getXpToLevel(skill) - profile.getSkillXpLevel(skill); return profile.getExperienceManager().getXpToLevel(skill) - profile.getExperienceManager().getSkillXpLevel(skill);
} }
/** /**
@ -589,7 +588,7 @@ public final class ExperienceAPI {
PrimarySkillType skill = getNonChildSkillType(skillType); PrimarySkillType skill = getNonChildSkillType(skillType);
PlayerProfile profile = getOfflineProfile(uuid); PlayerProfile profile = getOfflineProfile(uuid);
return profile.getXpToLevel(skill) - profile.getSkillXpLevelRaw(skill); return profile.getExperienceManager().getXpToLevel(skill) - profile.getExperienceManager().getSkillXpLevelRaw(skill);
} }
/** /**
@ -604,7 +603,7 @@ public final class ExperienceAPI {
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
*/ */
public static void addLevel(Player player, String skillType, int levels) { public static void addLevel(Player player, String skillType, int levels) {
getPlayer(player).addLevels(getSkillType(skillType), levels); getPlayer(player).getExperienceManager().addLevels(getSkillType(skillType), levels);
} }
/** /**
@ -628,15 +627,15 @@ public final class ExperienceAPI {
Set<PrimarySkillType> parentSkills = FamilyTree.getParents(skill); Set<PrimarySkillType> parentSkills = FamilyTree.getParents(skill);
for (PrimarySkillType parentSkill : parentSkills) { for (PrimarySkillType parentSkill : parentSkills) {
profile.addLevels(parentSkill, (levels / parentSkills.size())); profile.getExperienceManager().addLevels(parentSkill, (levels / parentSkills.size()));
} }
profile.scheduleAsyncSave(); mcMMO.getUserManager().scheduleAsyncSave(profile.getPersistentPlayerData());
return; return;
} }
profile.addLevels(skill, levels); profile.getExperienceManager().addLevels(skill, levels);
profile.scheduleAsyncSave(); mcMMO.getUserManager().scheduleAsyncSave(profile.getPersistentPlayerData());
} }
/** /**
@ -659,15 +658,15 @@ public final class ExperienceAPI {
Set<PrimarySkillType> parentSkills = FamilyTree.getParents(skill); Set<PrimarySkillType> parentSkills = FamilyTree.getParents(skill);
for (PrimarySkillType parentSkill : parentSkills) { for (PrimarySkillType parentSkill : parentSkills) {
profile.addLevels(parentSkill, (levels / parentSkills.size())); profile.getExperienceManager().addLevels(parentSkill, (levels / parentSkills.size()));
} }
profile.scheduleAsyncSave(); mcMMO.getUserManager().scheduleAsyncSave(profile.getPersistentPlayerData());
return; return;
} }
profile.addLevels(skill, levels); profile.getExperienceManager().addLevels(skill, levels);
profile.scheduleAsyncSave(); mcMMO.getUserManager().scheduleAsyncSave(profile.getPersistentPlayerData());
} }
/** /**
@ -684,7 +683,7 @@ public final class ExperienceAPI {
*/ */
@Deprecated @Deprecated
public static int getLevel(Player player, String skillType) { public static int getLevel(Player player, String skillType) {
return getPlayer(player).getSkillLevel(getSkillType(skillType)); return getPlayer(player).getExperienceManager().getSkillLevel(getSkillType(skillType));
} }
/** /**
@ -699,7 +698,7 @@ public final class ExperienceAPI {
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
*/ */
public static int getLevel(Player player, PrimarySkillType skillType) { public static int getLevel(Player player, PrimarySkillType skillType) {
return getPlayer(player).getSkillLevel(skillType); return getPlayer(player).getExperienceManager().getSkillLevel(skillType);
} }
/** /**
@ -716,7 +715,7 @@ public final class ExperienceAPI {
*/ */
@Deprecated @Deprecated
public static int getLevelOffline(String playerName, String skillType) { public static int getLevelOffline(String playerName, String skillType) {
return getOfflineProfile(playerName).getSkillLevel(getSkillType(skillType)); return getOfflineProfile(playerName).getExperienceManager().getSkillLevel(getSkillType(skillType));
} }
/** /**
@ -732,7 +731,7 @@ public final class ExperienceAPI {
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
*/ */
public static int getLevelOffline(UUID uuid, String skillType) { public static int getLevelOffline(UUID uuid, String skillType) {
return getOfflineProfile(uuid).getSkillLevel(getSkillType(skillType)); return getOfflineProfile(uuid).getExperienceManager().getSkillLevel(getSkillType(skillType));
} }
/** /**
@ -744,7 +743,7 @@ public final class ExperienceAPI {
* @return the power level of the player * @return the power level of the player
*/ */
public static int getPowerLevel(Player player) { public static int getPowerLevel(Player player) {
return getPlayer(player).getPowerLevel(); return getPlayer(player).getExperienceManager().getPowerLevel();
} }
/** /**
@ -763,7 +762,7 @@ public final class ExperienceAPI {
PlayerProfile profile = getOfflineProfile(playerName); PlayerProfile profile = getOfflineProfile(playerName);
for (PrimarySkillType type : PrimarySkillType.NON_CHILD_SKILLS) { for (PrimarySkillType type : PrimarySkillType.NON_CHILD_SKILLS) {
powerLevel += profile.getSkillLevel(type); powerLevel += profile.getExperienceManager().getSkillLevel(type);
} }
return powerLevel; return powerLevel;
@ -784,7 +783,7 @@ public final class ExperienceAPI {
PlayerProfile profile = getOfflineProfile(uuid); PlayerProfile profile = getOfflineProfile(uuid);
for (PrimarySkillType type : PrimarySkillType.NON_CHILD_SKILLS) { for (PrimarySkillType type : PrimarySkillType.NON_CHILD_SKILLS) {
powerLevel += profile.getSkillLevel(type); powerLevel += profile.getExperienceManager().getSkillLevel(type);
} }
return powerLevel; return powerLevel;
@ -895,7 +894,7 @@ public final class ExperienceAPI {
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
*/ */
public static void setLevel(Player player, String skillType, int skillLevel) { public static void setLevel(Player player, String skillType, int skillLevel) {
getPlayer(player).modifySkill(getSkillType(skillType), skillLevel); getPlayer(player).getExperienceManager().modifySkill(getSkillType(skillType), skillLevel);
} }
/** /**
@ -912,7 +911,7 @@ public final class ExperienceAPI {
*/ */
@Deprecated @Deprecated
public static void setLevelOffline(String playerName, String skillType, int skillLevel) { public static void setLevelOffline(String playerName, String skillType, int skillLevel) {
getOfflineProfile(playerName).modifySkill(getSkillType(skillType), skillLevel); getOfflineProfile(playerName).getExperienceManager().modifySkill(getSkillType(skillType), skillLevel);
} }
/** /**
@ -928,7 +927,7 @@ public final class ExperienceAPI {
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
*/ */
public static void setLevelOffline(UUID uuid, String skillType, int skillLevel) { public static void setLevelOffline(UUID uuid, String skillType, int skillLevel) {
getOfflineProfile(uuid).modifySkill(getSkillType(skillType), skillLevel); getOfflineProfile(uuid).getExperienceManager().modifySkill(getSkillType(skillType), skillLevel);
} }
/** /**
@ -944,7 +943,7 @@ public final class ExperienceAPI {
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static void setXP(Player player, String skillType, int newValue) { public static void setXP(Player player, String skillType, int newValue) {
getPlayer(player).setSkillXpLevel(getNonChildSkillType(skillType), newValue); getPlayer(player).getExperienceManager().setSkillXpLevel(getNonChildSkillType(skillType), (float) newValue);
} }
/** /**
@ -962,7 +961,7 @@ public final class ExperienceAPI {
*/ */
@Deprecated @Deprecated
public static void setXPOffline(String playerName, String skillType, int newValue) { public static void setXPOffline(String playerName, String skillType, int newValue) {
getOfflineProfile(playerName).setSkillXpLevel(getNonChildSkillType(skillType), newValue); getOfflineProfile(playerName).getExperienceManager().setSkillXpLevel(getNonChildSkillType(skillType), newValue);
} }
/** /**
@ -979,7 +978,7 @@ public final class ExperienceAPI {
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static void setXPOffline(UUID uuid, String skillType, int newValue) { public static void setXPOffline(UUID uuid, String skillType, int newValue) {
getOfflineProfile(uuid).setSkillXpLevel(getNonChildSkillType(skillType), newValue); getOfflineProfile(uuid).getExperienceManager().setSkillXpLevel(getNonChildSkillType(skillType), newValue);
} }
/** /**
@ -995,7 +994,7 @@ public final class ExperienceAPI {
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static void removeXP(Player player, String skillType, int xp) { public static void removeXP(Player player, String skillType, int xp) {
getPlayer(player).removeXp(getNonChildSkillType(skillType), xp); getPlayer(player).getExperienceManager().removeXp(getNonChildSkillType(skillType), xp);
} }
/** /**
@ -1013,7 +1012,7 @@ public final class ExperienceAPI {
*/ */
@Deprecated @Deprecated
public static void removeXPOffline(String playerName, String skillType, int xp) { public static void removeXPOffline(String playerName, String skillType, int xp) {
getOfflineProfile(playerName).removeXp(getNonChildSkillType(skillType), xp); getOfflineProfile(playerName).getExperienceManager().removeXp(getNonChildSkillType(skillType), xp);
} }
/** /**
@ -1030,7 +1029,7 @@ public final class ExperienceAPI {
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static void removeXPOffline(UUID uuid, String skillType, int xp) { public static void removeXPOffline(UUID uuid, String skillType, int xp) {
getOfflineProfile(uuid).removeXp(getNonChildSkillType(skillType), xp); getOfflineProfile(uuid).getExperienceManager().removeXp(getNonChildSkillType(skillType), xp);
} }
/** /**
@ -1063,9 +1062,9 @@ public final class ExperienceAPI {
/** /**
* Will add the appropriate type of XP from the block to the player based on the material of the blocks given * Will add the appropriate type of XP from the block to the player based on the material of the blocks given
* @param blockStates the blocks to reward XP for * @param blockStates the blocks to reward XP for
* @param mcMMOPlayer the target player * @param mmoPlayer the target player
*/ */
public static void addXpFromBlocks(ArrayList<BlockState> blockStates, McMMOPlayer mcMMOPlayer) public static void addXpFromBlocks(ArrayList<BlockState> blockStates, McMMOPlayer mmoPlayer)
{ {
for(BlockState bs : blockStates) for(BlockState bs : blockStates)
{ {
@ -1073,7 +1072,7 @@ public final class ExperienceAPI {
{ {
if(ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0) if(ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0)
{ {
mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, bs.getType()), XPGainReason.PVE, XPGainSource.SELF); mmoPlayer.getExperienceManager().applyXpGain(mmoPlayer.getPlayer(), skillType, ExperienceConfig.getInstance().getXp(skillType, bs.getType()), XPGainReason.PVE, XPGainSource.SELF);
} }
} }
} }
@ -1082,16 +1081,16 @@ public final class ExperienceAPI {
/** /**
* Will add the appropriate type of XP from the block to the player based on the material of the blocks given if it matches the given skillType * Will add the appropriate type of XP from the block to the player based on the material of the blocks given if it matches the given skillType
* @param blockStates the blocks to reward XP for * @param blockStates the blocks to reward XP for
* @param mcMMOPlayer the target player * @param mmoPlayer the target player
* @param skillType target primary skill * @param skillType target primary skill
*/ */
public static void addXpFromBlocksBySkill(ArrayList<BlockState> blockStates, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType) public static void addXpFromBlocksBySkill(ArrayList<BlockState> blockStates, McMMOPlayer mmoPlayer, PrimarySkillType skillType)
{ {
for(BlockState bs : blockStates) for(BlockState bs : blockStates)
{ {
if(ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0) if(ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0)
{ {
mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, bs.getType()), XPGainReason.PVE, XPGainSource.SELF); mmoPlayer.getExperienceManager().applyXpGain(mmoPlayer.getPlayer(), skillType, ExperienceConfig.getInstance().getXp(skillType, bs.getType()), XPGainReason.PVE, XPGainSource.SELF);
} }
} }
} }
@ -1099,15 +1098,15 @@ public final class ExperienceAPI {
/** /**
* Will add the appropriate type of XP from the block to the player based on the material of the blocks given * Will add the appropriate type of XP from the block to the player based on the material of the blocks given
* @param blockState The target blockstate * @param blockState The target blockstate
* @param mcMMOPlayer The target player * @param mmoPlayer The target player
*/ */
public static void addXpFromBlock(BlockState blockState, McMMOPlayer mcMMOPlayer) public static void addXpFromBlock(BlockState blockState, McMMOPlayer mmoPlayer)
{ {
for(PrimarySkillType skillType : PrimarySkillType.values()) for(PrimarySkillType skillType : PrimarySkillType.values())
{ {
if(ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0) if(ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0)
{ {
mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, blockState.getType()), XPGainReason.PVE, XPGainSource.SELF); mmoPlayer.getExperienceManager().applyXpGain(mmoPlayer.getPlayer(), skillType, ExperienceConfig.getInstance().getXp(skillType, blockState.getType()), XPGainReason.PVE, XPGainSource.SELF);
} }
} }
} }
@ -1115,14 +1114,14 @@ public final class ExperienceAPI {
/** /**
* Will add the appropriate type of XP from the block to the player based on the material of the blocks given if it matches the given skillType * Will add the appropriate type of XP from the block to the player based on the material of the blocks given if it matches the given skillType
* @param blockState The target blockstate * @param blockState The target blockstate
* @param mcMMOPlayer The target player * @param mmoPlayer The target player
* @param skillType target primary skill * @param skillType target primary skill
*/ */
public static void addXpFromBlockBySkill(BlockState blockState, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType) public static void addXpFromBlockBySkill(BlockState blockState, McMMOPlayer mmoPlayer, PrimarySkillType skillType)
{ {
if(ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0) if(ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0)
{ {
mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, blockState.getType()), XPGainReason.PVE, XPGainSource.SELF); mmoPlayer.getExperienceManager().applyXpGain(mmoPlayer.getPlayer(), skillType, ExperienceConfig.getInstance().getXp(skillType, blockState.getType()), XPGainReason.PVE, XPGainSource.SELF);
} }
} }
@ -1132,22 +1131,22 @@ public final class ExperienceAPI {
private static void addOfflineXP(UUID playerUniqueId, PrimarySkillType skill, int XP) { private static void addOfflineXP(UUID playerUniqueId, PrimarySkillType skill, int XP) {
PlayerProfile profile = getOfflineProfile(playerUniqueId); PlayerProfile profile = getOfflineProfile(playerUniqueId);
profile.addXp(skill, XP); profile.getExperienceManager().addXp(skill, XP);
profile.save(true); mcMMO.getUserManager().scheduleAsyncSave(profile.getPersistentPlayerData());
} }
@Deprecated @Deprecated
private static void addOfflineXP(String playerName, PrimarySkillType skill, int XP) { private static void addOfflineXP(String playerName, PrimarySkillType skill, int XP) {
PlayerProfile profile = getOfflineProfile(playerName); PlayerProfile profile = getOfflineProfile(playerName);
profile.addXp(skill, XP); profile.getExperienceManager().addXp(skill, XP);
profile.scheduleAsyncSave(); mcMMO.getUserManager().scheduleAsyncSave(profile.getPersistentPlayerData());
} }
private static PlayerProfile getOfflineProfile(UUID uuid) { private static PlayerProfile getOfflineProfile(UUID uuid) {
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid); PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid);
if (!profile.isLoaded()) { if (profile == null) {
throw new InvalidPlayerException(); throw new InvalidPlayerException();
} }
@ -1159,7 +1158,7 @@ public final class ExperienceAPI {
UUID uuid = mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId(); UUID uuid = mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId();
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid); PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid);
if (!profile.isLoaded()) { if (profile == null) {
throw new InvalidPlayerException(); throw new InvalidPlayerException();
} }
@ -1214,10 +1213,10 @@ public final class ExperienceAPI {
*/ */
@Deprecated @Deprecated
private static McMMOPlayer getPlayer(Player player) throws McMMOPlayerNotFoundException { private static McMMOPlayer getPlayer(Player player) throws McMMOPlayerNotFoundException {
if (!UserManager.hasPlayerDataKey(player)) { if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
throw new McMMOPlayerNotFoundException(player); throw new McMMOPlayerNotFoundException(player);
} }
return UserManager.getPlayer(player); return mcMMO.getUserManager().getPlayer(player);
} }
} }

View File

@ -3,11 +3,8 @@ package com.gmail.nossr50.api;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyLeader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -29,7 +26,7 @@ public final class PartyAPI {
return null; return null;
} }
return UserManager.getPlayer(player).getParty().getName(); return mcMMO.getUserManager().getPlayer(player).getParty().getName();
} }
/** /**
@ -41,10 +38,10 @@ public final class PartyAPI {
* @return true if the player is in a party, false otherwise * @return true if the player is in a party, false otherwise
*/ */
public static boolean inParty(Player player) { public static boolean inParty(Player player) {
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
return false; return false;
return UserManager.getPlayer(player).inParty(); return mcMMO.getUserManager().getPlayer(player).inParty();
} }
/** /**
@ -57,7 +54,7 @@ public final class PartyAPI {
* @return true if the two players are in the same party, false otherwise * @return true if the two players are in the same party, false otherwise
*/ */
public static boolean inSameParty(Player playera, Player playerb) { public static boolean inSameParty(Player playera, Player playerb) {
return PartyManager.inSameParty(playera, playerb); return mcMMO.getPartyManager().inSameParty(playera, playerb);
} }
/** /**
@ -68,7 +65,7 @@ public final class PartyAPI {
* @return the list of parties. * @return the list of parties.
*/ */
public static List<Party> getParties() { public static List<Party> getParties() {
return PartyManager.getParties(); return mcMMO.getPartyManager().getParties();
} }
/** /**
@ -83,22 +80,22 @@ public final class PartyAPI {
@Deprecated @Deprecated
public static void addToParty(Player player, String partyName) { public static void addToParty(Player player, String partyName) {
//Check if player profile is loaded //Check if player profile is loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
return; return;
Party party = PartyManager.getParty(partyName); Party party = mcMMO.getPartyManager().getParty(partyName);
if (party == null) { if (party == null) {
party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName); party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
} else { } else {
if(PartyManager.isPartyFull(player, party)) if(mcMMO.getPartyManager().isPartyFull(player, party))
{ {
NotificationManager.sendPlayerInformation(player, NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull", party.toString()); NotificationManager.sendPlayerInformation(player, NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull", party.toString());
return; return;
} }
} }
PartyManager.addToParty(UserManager.getPlayer(player), party); mcMMO.getPartyManager().addToParty(mcMMO.getUserManager().getPlayer(player), party);
} }
/** /**
@ -123,16 +120,16 @@ public final class PartyAPI {
//TODO: bypasslimit not used? //TODO: bypasslimit not used?
public static void addToParty(Player player, String partyName, boolean bypassLimit) { public static void addToParty(Player player, String partyName, boolean bypassLimit) {
//Check if player profile is loaded //Check if player profile is loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
return; return;
Party party = PartyManager.getParty(partyName); Party party = mcMMO.getPartyManager().getParty(partyName);
if (party == null) { if (party == null) {
party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName); party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
} }
PartyManager.addToParty(UserManager.getPlayer(player), party); mcMMO.getPartyManager().addToParty(mcMMO.getUserManager().getPlayer(player), party);
} }
/** /**
@ -144,10 +141,10 @@ public final class PartyAPI {
*/ */
public static void removeFromParty(Player player) { public static void removeFromParty(Player player) {
//Check if player profile is loaded //Check if player profile is loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
return; return;
PartyManager.removeFromParty(UserManager.getPlayer(player)); mcMMO.getPartyManager().removeFromParty(mcMMO.getUserManager().getPlayer(player));
} }
/** /**
@ -159,7 +156,7 @@ public final class PartyAPI {
* @return the leader of the party * @return the leader of the party
*/ */
public static String getPartyLeader(String partyName) { public static String getPartyLeader(String partyName) {
return PartyManager.getPartyLeaderName(partyName); return mcMMO.getPartyManager().getPartyLeaderName(partyName);
} }
/** /**
@ -172,7 +169,7 @@ public final class PartyAPI {
*/ */
@Deprecated @Deprecated
public static void setPartyLeader(String partyName, String playerName) { public static void setPartyLeader(String partyName, String playerName) {
PartyManager.setPartyLeader(mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId(), PartyManager.getParty(partyName)); mcMMO.getPartyManager().setPartyLeader(mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId(), mcMMO.getPartyManager().getParty(partyName));
} }
/** /**
@ -187,7 +184,7 @@ public final class PartyAPI {
public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) { public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) {
List<OfflinePlayer> members = new ArrayList<>(); List<OfflinePlayer> members = new ArrayList<>();
for (UUID memberUniqueId : PartyManager.getAllMembers(player).keySet()) { for (UUID memberUniqueId : mcMMO.getPartyManager().getAllMembers(player).keySet()) {
OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberUniqueId); OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberUniqueId);
members.add(member); members.add(member);
} }
@ -204,7 +201,7 @@ public final class PartyAPI {
*/ */
@Deprecated @Deprecated
public static LinkedHashSet<String> getMembers(Player player) { public static LinkedHashSet<String> getMembers(Player player) {
return (LinkedHashSet<String>) PartyManager.getAllMembers(player).values(); return (LinkedHashSet<String>) mcMMO.getPartyManager().getAllMembers(player).values();
} }
/** /**
@ -216,7 +213,7 @@ public final class PartyAPI {
* @return all the player names and uuids in the player's party * @return all the player names and uuids in the player's party
*/ */
public static LinkedHashMap<UUID, String> getMembersMap(Player player) { public static LinkedHashMap<UUID, String> getMembersMap(Player player) {
return PartyManager.getAllMembers(player); return mcMMO.getPartyManager().getAllMembers(player);
} }
/** /**
@ -228,7 +225,7 @@ public final class PartyAPI {
* @return all online players in this party * @return all online players in this party
*/ */
public static List<Player> getOnlineMembers(String partyName) { public static List<Player> getOnlineMembers(String partyName) {
return PartyManager.getOnlineMembers(partyName); return mcMMO.getPartyManager().getOnlineMembers(partyName);
} }
/** /**
@ -240,7 +237,7 @@ public final class PartyAPI {
* @return all online players in the player's party * @return all online players in the player's party
*/ */
public static List<Player> getOnlineMembers(Player player) { public static List<Player> getOnlineMembers(Player player) {
return PartyManager.getOnlineMembers(player); return mcMMO.getPartyManager().getOnlineMembers(player);
} }
public static boolean hasAlly(String partyName) { public static boolean hasAlly(String partyName) {
@ -248,9 +245,9 @@ public final class PartyAPI {
} }
public static String getAllyName(String partyName) { public static String getAllyName(String partyName) {
Party ally = PartyManager.getParty(partyName).getAlly(); Party ally = mcMMO.getPartyManager().getParty(partyName).getAlly();
if (ally != null) { if (ally != null) {
return ally.getName(); return ally.getPartyName();
} }
return null; return null;

View File

@ -0,0 +1,4 @@
package com.gmail.nossr50.api.exceptions;
public class UnexpectedValueException extends RuntimeException {
}

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.chat.McMMOChatEvent; import com.gmail.nossr50.events.chat.McMMOChatEvent;
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent; import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -47,20 +46,20 @@ public abstract class ChatManager {
McMMOPartyChatEvent partyChatEvent = (McMMOPartyChatEvent) event; McMMOPartyChatEvent partyChatEvent = (McMMOPartyChatEvent) event;
//Find the people with permissions //Find the people with permissions
for(McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) for(McMMOPlayer mmoPlayer : mcMMO.getUserManager().getPlayers())
{ {
Player player = mcMMOPlayer.getPlayer(); Player player = mmoPlayer.getPlayer();
//Check for toggled players //Check for toggled players
if(mcMMOPlayer.isPartyChatSpying()) if(mmoPlayer.isPartyChatSpying())
{ {
Party adminParty = mcMMOPlayer.getParty(); Party adminParty = mmoPlayer.getParty();
//Only message admins not part of this party //Only message admins not part of this party
if(adminParty != null) if(adminParty != null)
{ {
//TODO: Incorporate JSON //TODO: Incorporate JSON
if(!adminParty.getName().equalsIgnoreCase(partyChatEvent.getParty())) if(!adminParty.getPartyName().equalsIgnoreCase(partyChatEvent.getParty()))
player.sendMessage(LocaleLoader.getString("Commands.AdminChatSpy.Chat", partyChatEvent.getParty(), message)); player.sendMessage(LocaleLoader.getString("Commands.AdminChatSpy.Chat", partyChatEvent.getParty(), message));
} else { } else {
player.sendMessage(LocaleLoader.getString("Commands.AdminChatSpy.Chat", partyChatEvent.getParty(), message)); player.sendMessage(LocaleLoader.getString("Commands.AdminChatSpy.Chat", partyChatEvent.getParty(), message));

View File

@ -19,7 +19,7 @@ public class PartyChatManager extends ChatManager {
@Override @Override
public void handleChat(String senderName, String displayName, String message, boolean isAsync) { public void handleChat(String senderName, String displayName, String message, boolean isAsync) {
handleChat(new McMMOPartyChatEvent(plugin, senderName, displayName, party.getName(), message, isAsync)); handleChat(new McMMOPartyChatEvent(plugin, senderName, displayName, party.getPartyName(), message, isAsync));
} }
@Override @Override

View File

@ -17,9 +17,9 @@ public class AbilityToggleCommand extends ToggleCommand {
} }
@Override @Override
protected void applyCommandAction(McMMOPlayer mcMMOPlayer) { protected void applyCommandAction(McMMOPlayer mmoPlayer) {
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Ability." + (mcMMOPlayer.getSuperAbilityManager().getAbilityActivationPermission() ? "Off" : "On"))); mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Ability." + (mmoPlayer.getSuperAbilityManager().getAbilityActivationPermission() ? "Off" : "On")));
mcMMOPlayer.getSuperAbilityManager().toggleAbilityActivationPermission(); mmoPlayer.getSuperAbilityManager().toggleAbilityActivationPermission();
} }
@Override @Override

View File

@ -1,11 +1,9 @@
package com.gmail.nossr50.commands; package com.gmail.nossr50.commands;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.database.FlatfileDatabaseManager; import com.gmail.nossr50.database.FlatFileDatabaseManager;
import com.gmail.nossr50.database.SQLDatabaseManager; import com.gmail.nossr50.database.SQLDatabaseManager;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -21,16 +19,16 @@ public class MHDCommand implements TabExecutor {
if (mcMMO.getDatabaseManager() instanceof SQLDatabaseManager) { if (mcMMO.getDatabaseManager() instanceof SQLDatabaseManager) {
SQLDatabaseManager m = (SQLDatabaseManager) mcMMO.getDatabaseManager(); SQLDatabaseManager m = (SQLDatabaseManager) mcMMO.getDatabaseManager();
m.resetMobHealthSettings(); m.resetMobHealthSettings();
for (McMMOPlayer player : UserManager.getPlayers()) { for (mmoPlayer player : mcMMO.getUserManager().getPlayers()) {
player.getProfile().setMobHealthbarType(Config.getInstance().getMobHealthbarDefault()); player.getProfile().setMobHealthbarType(Config.getInstance().getMobHealthbarDefault());
} }
sender.sendMessage("Mob health reset"); sender.sendMessage("Mob health reset");
return true; return true;
} }
if (mcMMO.getDatabaseManager() instanceof FlatfileDatabaseManager) { if (mcMMO.getDatabaseManager() instanceof FlatFileDatabaseManager) {
FlatfileDatabaseManager m = (FlatfileDatabaseManager) mcMMO.getDatabaseManager(); FlatFileDatabaseManager m = (FlatFileDatabaseManager) mcMMO.getDatabaseManager();
m.resetMobHealthSettings(); m.resetMobHealthSettings();
for (McMMOPlayer player : UserManager.getPlayers()) { for (mmoPlayer player : mcMMO.getUserManager().getPlayers()) {
player.getProfile().setMobHealthbarType(Config.getInstance().getMobHealthbarDefault()); player.getProfile().setMobHealthbarType(Config.getInstance().getMobHealthbarDefault());
} }
sender.sendMessage("Mob health reset"); sender.sendMessage("Mob health reset");

View File

@ -17,9 +17,9 @@ public class McgodCommand extends ToggleCommand {
} }
@Override @Override
protected void applyCommandAction(McMMOPlayer mcMMOPlayer) { protected void applyCommandAction(McMMOPlayer mmoPlayer) {
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.GodMode." + (mcMMOPlayer.getGodMode() ? "Disabled" : "Enabled"))); mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.GodMode." + (mmoPlayer.getGodMode() ? "Disabled" : "Enabled")));
mcMMOPlayer.toggleGodMode(); mmoPlayer.toggleGodMode();
} }
@Override @Override

View File

@ -2,8 +2,8 @@ package com.gmail.nossr50.commands;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -21,14 +21,14 @@ public class McnotifyCommand implements TabExecutor {
} }
if (args.length == 0) { if (args.length == 0) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer((Player) sender);
//Not Loaded yet //Not Loaded yet
if (mcMMOPlayer == null) if (mmoPlayer == null)
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
sender.sendMessage(LocaleLoader.getString("Commands.Notifications." + (mcMMOPlayer.useChatNotifications() ? "Off" : "On"))); sender.sendMessage(LocaleLoader.getString("Commands.Notifications." + (mmoPlayer.hasSkillChatNotifications() ? "Off" : "On")));
mcMMOPlayer.toggleChatNotifications(); mmoPlayer.toggleSkillChatNotifications();
return true; return true;
} }
return false; return false;

View File

@ -17,13 +17,13 @@ public class McrefreshCommand extends ToggleCommand {
} }
@Override @Override
protected void applyCommandAction(McMMOPlayer mcMMOPlayer) { protected void applyCommandAction(McMMOPlayer mmoPlayer) {
mcMMOPlayer.setRecentlyHurt(0); mmoPlayer.setRecentlyHurtTimestamp(0);
mcMMOPlayer.resetCooldowns(); mmoPlayer.resetCooldowns();
mcMMOPlayer.getSuperAbilityManager().unprimeAllAbilityTools(); mmoPlayer.getSuperAbilityManager().unprimeAllAbilityTools();
mcMMOPlayer.getSuperAbilityManager().resetSuperAbilities(); mmoPlayer.getSuperAbilityManager().resetSuperAbilities();
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Ability.Generic.Refresh")); mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
} }
@Override @Override

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -31,7 +30,7 @@ public abstract class ToggleCommand implements TabExecutor {
return true; return true;
} }
applyCommandAction(UserManager.getPlayer(sender.getName())); applyCommandAction(mcMMO.getUserManager().getPlayer(sender.getName()));
return true; return true;
case 1: case 1:
@ -41,17 +40,17 @@ public abstract class ToggleCommand implements TabExecutor {
} }
String playerName = CommandUtils.getMatchedPlayerName(args[0]); String playerName = CommandUtils.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(playerName);
if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) { if (!CommandUtils.checkPlayerExistence(sender, playerName, mmoPlayer)) {
return true; return true;
} }
if (CommandUtils.isOffline(sender, mcMMOPlayer.getPlayer())) { if (CommandUtils.isOffline(sender, mmoPlayer.getPlayer())) {
return true; return true;
} }
applyCommandAction(mcMMOPlayer); applyCommandAction(mmoPlayer);
sendSuccessMessage(sender, playerName); sendSuccessMessage(sender, playerName);
return true; return true;
@ -71,6 +70,6 @@ public abstract class ToggleCommand implements TabExecutor {
protected abstract boolean hasOtherPermission(CommandSender sender); protected abstract boolean hasOtherPermission(CommandSender sender);
protected abstract boolean hasSelfPermission(CommandSender sender); protected abstract boolean hasSelfPermission(CommandSender sender);
protected abstract void applyCommandAction(McMMOPlayer mcMMOPlayer); protected abstract void applyCommandAction(McMMOPlayer mmoPlayer);
protected abstract void sendSuccessMessage(CommandSender sender, String playerName); protected abstract void sendSuccessMessage(CommandSender sender, String playerName);
} }

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.admin;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -14,9 +13,9 @@ public class PlayerDebugCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if(sender instanceof Player) { if(sender instanceof Player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer((Player) sender);
mcMMOPlayer.toggleDebugMode(); //Toggle debug mode mmoPlayer.toggleDebugMode(); //Toggle debug mode
NotificationManager.sendPlayerInformationChatOnlyPrefixed(mcMMOPlayer.getPlayer(), "Commands.Mmodebug.Toggle", String.valueOf(mcMMOPlayer.isDebugMode())); NotificationManager.sendPlayerInformationChatOnlyPrefixed(mmoPlayer.getPlayer(), "Commands.Mmodebug.Toggle", String.valueOf(mmoPlayer.isDebugMode()));
return true; return true;
} else { } else {
return false; return false;

View File

@ -9,7 +9,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -32,7 +31,7 @@ public abstract class ChatCommand implements TabExecutor {
@Override @Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
McMMOPlayer mcMMOPlayer; McMMOPlayer mmoPlayer;
switch (args.length) { switch (args.length) {
case 0: case 0:
@ -44,13 +43,13 @@ public abstract class ChatCommand implements TabExecutor {
return true; return true;
} }
mcMMOPlayer = UserManager.getPlayer(sender.getName()); mmoPlayer = mcMMO.getUserManager().getPlayer(sender.getName());
if (mcMMOPlayer.isChatEnabled(chatMode)) { if (mmoPlayer.isChatEnabled(chatMode)) {
disableChatMode(mcMMOPlayer, sender); disableChatMode(mmoPlayer, sender);
} }
else { else {
enableChatMode(mcMMOPlayer, sender); enableChatMode(mmoPlayer, sender);
} }
return true; return true;
@ -64,7 +63,7 @@ public abstract class ChatCommand implements TabExecutor {
return true; return true;
} }
enableChatMode(UserManager.getPlayer(sender.getName()), sender); enableChatMode(mcMMO.getUserManager().getPlayer(sender.getName()), sender);
return true; return true;
} }
@ -76,7 +75,7 @@ public abstract class ChatCommand implements TabExecutor {
return true; return true;
} }
disableChatMode(UserManager.getPlayer(sender.getName()), sender); disableChatMode(mcMMO.getUserManager().getPlayer(sender.getName()), sender);
return true; return true;
} }
@ -114,28 +113,28 @@ public abstract class ChatCommand implements TabExecutor {
protected abstract void handleChatSending(CommandSender sender, String[] args); protected abstract void handleChatSending(CommandSender sender, String[] args);
private void enableChatMode(McMMOPlayer mcMMOPlayer, CommandSender sender) { private void enableChatMode(McMMOPlayer mmoPlayer, CommandSender sender) {
if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) { if (chatMode == ChatMode.PARTY && mmoPlayer.getParty() == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return; return;
} }
if (chatMode == ChatMode.PARTY && (mcMMOPlayer.getParty().getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.CHAT))) { if (chatMode == ChatMode.PARTY && (mmoPlayer.getParty().getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.CHAT))) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.1")); sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.1"));
return; return;
} }
mcMMOPlayer.enableChat(chatMode); mmoPlayer.enableChat(chatMode);
sender.sendMessage(chatMode.getEnabledMessage()); sender.sendMessage(chatMode.getEnabledMessage());
} }
private void disableChatMode(McMMOPlayer mcMMOPlayer, CommandSender sender) { private void disableChatMode(McMMOPlayer mmoPlayer, CommandSender sender) {
if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) { if (chatMode == ChatMode.PARTY && mmoPlayer.getParty() == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return; return;
} }
mcMMOPlayer.disableChat(chatMode); mmoPlayer.disableChat(chatMode);
sender.sendMessage(chatMode.getDisabledMessage()); sender.sendMessage(chatMode.getDisabledMessage());
} }
} }

View File

@ -18,9 +18,9 @@ public class McChatSpy extends ToggleCommand {
} }
@Override @Override
protected void applyCommandAction(McMMOPlayer mcMMOPlayer) { protected void applyCommandAction(McMMOPlayer mmoPlayer) {
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.AdminChatSpy." + (mcMMOPlayer.isPartyChatSpying() ? "Disabled" : "Enabled"))); mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.AdminChatSpy." + (mmoPlayer.isPartyChatSpying() ? "Disabled" : "Enabled")));
mcMMOPlayer.togglePartyChatSpying(); mmoPlayer.togglePartyChatSpying();
} }
@Override @Override

View File

@ -6,8 +6,6 @@ import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -23,10 +21,10 @@ public class PartyChatCommand extends ChatCommand {
if (sender instanceof Player) { if (sender instanceof Player) {
//Check if player profile is loaded //Check if player profile is loaded
if(UserManager.getPlayer((Player) sender) == null) if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
return; return;
party = UserManager.getPlayer((Player) sender).getParty(); party = mcMMO.getUserManager().getPlayer((Player) sender).getParty();
if (party == null) { if (party == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
@ -46,7 +44,7 @@ public class PartyChatCommand extends ChatCommand {
return; return;
} }
party = PartyManager.getParty(args[0]); party = mcMMO.getPartyManager().getParty(args[0]);
if (party == null) { if (party == null) {
sender.sendMessage(LocaleLoader.getString("Party.InvalidName")); sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));

View File

@ -8,7 +8,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.database.DatabaseConversionTask; import com.gmail.nossr50.runnables.database.DatabaseConversionTask;
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask; import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -50,8 +49,8 @@ public class ConvertDatabaseCommand implements CommandExecutor {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Start", previousType.toString(), newType.toString())); sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Start", previousType.toString(), newType.toString()));
UserManager.saveAll(); mcMMO.getUserManager().saveAllSync();
UserManager.clearAll(); mcMMO.getUserManager().clearAll();
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) { for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
PlayerProfile profile = oldDatabase.loadPlayerProfile(player.getUniqueId()); PlayerProfile profile = oldDatabase.loadPlayerProfile(player.getUniqueId());

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -22,7 +21,7 @@ public class McremoveCommand implements TabExecutor {
if (args.length == 1) { if (args.length == 1) {
String playerName = CommandUtils.getMatchedPlayerName(args[0]); String playerName = CommandUtils.getMatchedPlayerName(args[0]);
if (UserManager.getOfflinePlayer(playerName) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false))) { if (mcMMO.getUserManager().getOfflinePlayer(playerName) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false))) {
return true; return true;
} }

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -25,10 +24,10 @@ public class AddxpCommand extends ExperienceCommand {
protected void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value) { protected void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value) {
if (player != null) { if (player != null) {
//Check if player profile is loaded //Check if player profile is loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
return; return;
UserManager.getPlayer(player).applyXpGain(skill, value, XPGainReason.COMMAND, XPGainSource.COMMAND); mcMMO.getUserManager().getPlayer(player).applyXpGain(skill, value, XPGainReason.COMMAND, XPGainSource.COMMAND);
} }
else { else {
profile.addXp(skill, value); profile.addXp(skill, value);

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.database.FormulaConversionTask; import com.gmail.nossr50.runnables.database.FormulaConversionTask;
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask; import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -33,8 +32,8 @@ public class ConvertExperienceCommand implements CommandExecutor {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Start", previousType.toString(), newType.toString())); sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Start", previousType.toString(), newType.toString()));
UserManager.saveAll(); mcMMO.getUserManager().saveAllSync();
UserManager.clearAll(); mcMMO.getUserManager().clearAll();
new FormulaConversionTask(sender, newType).runTaskLater(mcMMO.p, 1); new FormulaConversionTask(sender, newType).runTaskLater(mcMMO.p, 1);

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -55,14 +54,14 @@ public abstract class ExperienceCommand implements TabExecutor {
} }
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(sender.getName()) == null) if(mcMMO.getUserManager().getPlayer(sender.getName()) == null)
{ {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill, Integer.parseInt(args[1])); editValues((Player) sender, mcMMO.getUserManager().getPlayer(sender.getName()), skill, Integer.parseInt(args[1]));
return true; return true;
case 3: case 3:
@ -90,10 +89,10 @@ public abstract class ExperienceCommand implements TabExecutor {
int value = Integer.parseInt(args[2]); int value = Integer.parseInt(args[2]);
String playerName = CommandUtils.getMatchedPlayerName(args[0]); String playerName = CommandUtils.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getOfflinePlayer(playerName);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. // If 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 (mcMMOPlayer == null) { if (mmoPlayer == null) {
UUID uuid = null; UUID uuid = null;
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName); OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName);
if (player != null) { if (player != null) {
@ -108,7 +107,7 @@ public abstract class ExperienceCommand implements TabExecutor {
editValues(null, profile, skill, value); editValues(null, profile, skill, value);
} }
else { else {
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, value); editValues(mmoPlayer.getPlayer(), mmoPlayer, skill, value);
} }
handleSenderMessage(sender, playerName, skill); handleSenderMessage(sender, playerName, skill);

View File

@ -9,7 +9,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -53,7 +52,7 @@ public class SkillresetCommand implements TabExecutor {
skill = PrimarySkillType.getSkill(args[1]); skill = PrimarySkillType.getSkill(args[1]);
} }
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill); editValues((Player) sender, mcMMO.getUserManager().getPlayer(sender.getName()), skill);
return true; return true;
case 2: case 2:
@ -74,10 +73,10 @@ public class SkillresetCommand implements TabExecutor {
} }
String playerName = CommandUtils.getMatchedPlayerName(args[0]); String playerName = CommandUtils.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getOfflinePlayer(playerName);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. // If 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 (mcMMOPlayer == null) { if (mmoPlayer == null) {
UUID uuid = null; UUID uuid = null;
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName); OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName);
if (player != null) { if (player != null) {
@ -92,7 +91,7 @@ public class SkillresetCommand implements TabExecutor {
editValues(null, profile, skill); editValues(null, profile, skill);
} }
else { else {
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill); editValues(mmoPlayer.getPlayer(), mmoPlayer, skill);
} }
handleSenderMessage(sender, playerName, skill); handleSenderMessage(sender, playerName, skill);

View File

@ -2,8 +2,6 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -17,25 +15,25 @@ public class PartyAcceptCommand implements CommandExecutor {
Player player = (Player) sender; Player player = (Player) sender;
//Check if player profile is loaded //Check if player profile is loaded
if (UserManager.getPlayer(player) == null) { if (mcMMO.getUserManager().getPlayer(player) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
if (!mcMMOPlayer.hasPartyInvite()) { if (!mmoPlayer.hasPartyInvite()) {
sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites")); sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
return true; return true;
} }
// Changing parties // Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) { if (!mcMMO.getPartyManager().changeOrJoinParty(mmoPlayer, mmoPlayer.getPartyInvite().getName())) {
return true; return true;
} }
PartyManager.joinInvitedParty(mcMMOPlayer); mcMMO.getPartyManager().joinInvitedParty(mmoPlayer);
return true; return true;
} }
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "accept")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "accept"));

View File

@ -3,9 +3,7 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -17,12 +15,12 @@ public class PartyChangeOwnerCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 2) {//Check if player profile is loaded if (args.length == 2) {//Check if player profile is loaded
if (UserManager.getPlayer((Player) sender) == null) { if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
Party playerParty = UserManager.getPlayer((Player) sender).getParty(); Party playerParty = mcMMO.getUserManager().getPlayer((Player) sender).getParty();
String targetName = CommandUtils.getMatchedPlayerName(args[1]); String targetName = CommandUtils.getMatchedPlayerName(args[1]);
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(targetName); OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(targetName);
@ -31,7 +29,7 @@ public class PartyChangeOwnerCommand implements CommandExecutor {
return true; return true;
} }
PartyManager.setPartyLeader(target.getUniqueId(), playerParty); mcMMO.getPartyManager().setPartyLeader(target.getUniqueId(), playerParty);
return true; return true;
} }
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -12,13 +11,13 @@ import org.jetbrains.annotations.NotNull;
public class PartyChangePasswordCommand implements CommandExecutor { public class PartyChangePasswordCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if(UserManager.getPlayer((Player) sender) == null) if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
{ {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
Party party = UserManager.getPlayer((Player) sender).getParty(); Party party = mcMMO.getUserManager().getPlayer((Player) sender).getParty();
switch (args.length) { switch (args.length) {
case 1: case 1:
@ -42,14 +41,14 @@ public class PartyChangePasswordCommand implements CommandExecutor {
} }
private void unprotectParty(Party party, CommandSender sender) { private void unprotectParty(Party party, CommandSender sender) {
party.setLocked(true); party.setPartyLock(true);
party.setPassword(null); party.setPartyPassword(null);
sender.sendMessage(LocaleLoader.getString("Party.Password.Removed")); sender.sendMessage(LocaleLoader.getString("Party.Password.Removed"));
} }
private void protectParty(Party party, CommandSender sender, String password) { private void protectParty(Party party, CommandSender sender, String password) {
party.setLocked(true); party.setPartyLock(true);
party.setPassword(password); party.setPartyPassword(password);
sender.sendMessage(LocaleLoader.getString("Party.Password.Set", password)); sender.sendMessage(LocaleLoader.getString("Party.Password.Set", password));
} }
} }

View File

@ -6,9 +6,9 @@ import com.gmail.nossr50.commands.party.teleport.PtpCommand;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -71,20 +71,20 @@ public class PartyCommand implements TabExecutor {
Player player = (Player) sender; Player player = (Player) sender;
if (!UserManager.hasPlayerDataKey(player)) { if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return true; return true;
} }
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
if (args.length < 1) { if (args.length < 1) {
if (!mcMMOPlayer.inParty()) { if (!mcMMO.getPartyManager().mmoPlayer.inParty()) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return printUsage(player); return printUsage(player);
} }
@ -118,7 +118,7 @@ public class PartyCommand implements TabExecutor {
} }
// Party member commands // Party member commands
if (!mcMMOPlayer.inParty()) { if (!mmoPlayer.inParty()) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return printUsage(player); return printUsage(player);
} }
@ -139,7 +139,7 @@ public class PartyCommand implements TabExecutor {
} }
// Party leader commands // Party leader commands
if (!mcMMOPlayer.getParty().getLeader().getUniqueId().equals(player.getUniqueId())) { if (!mmoPlayer.getParty().getLeader().getUniqueId().equals(player.getUniqueId())) {
sender.sendMessage(LocaleLoader.getString("Party.NotOwner")); sender.sendMessage(LocaleLoader.getString("Party.NotOwner"));
return true; return true;
} }
@ -206,13 +206,13 @@ public class PartyCommand implements TabExecutor {
Player player = (Player) sender; Player player = (Player) sender;
//Not Loaded //Not Loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return ImmutableList.of(); return ImmutableList.of();
} }
Party party = UserManager.getPlayer(player).getParty(); Party party = mcMMO.getUserManager().getPlayer(player).getParty();
playerNames = party.getOnlinePlayerNames(player); playerNames = party.getOnlinePlayerNames(player);
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size())); return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size()));

View File

@ -2,8 +2,6 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -17,25 +15,25 @@ public class PartyCreateCommand implements CommandExecutor {
case 2: case 2:
case 3: case 3:
Player player = (Player) sender; Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
// Check to see if the party exists, and if it does cancel creating a new party // Check to see if the party exists, and if it does cancel creating a new party
if (PartyManager.checkPartyExistence(player, args[1])) { if (mcMMO.getPartyManager().checkPartyExistence(player, args[1])) {
return true; return true;
} }
// Changing parties // Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, args[1])) { if (!mcMMO.getPartyManager().changeOrJoinParty(mmoPlayer, args[1])) {
return true; return true;
} }
PartyManager.createParty(mcMMOPlayer, args[1], getPassword(args)); mcMMO.getPartyManager().createParty(mmoPlayer, args[1], getPassword(args));
return true; return true;
default: default:

View File

@ -3,8 +3,6 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -15,23 +13,23 @@ public class PartyDisbandCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 1) { if (args.length == 1) {
if (UserManager.getPlayer((Player) sender) == null) { if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
Party playerParty = UserManager.getPlayer((Player) sender).getParty(); Party playerParty = mcMMO.getUserManager().getPlayer((Player) sender).getParty();
String partyName = playerParty.getName(); String partyName = playerParty.getPartyName();
for (Player member : playerParty.getOnlineMembers()) { for (Player member : playerParty.getPartyMembers()) {
if (!PartyManager.handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) { if (!mcMMO.getPartyManager().handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) {
return true; return true;
} }
member.sendMessage(LocaleLoader.getString("Party.Disband")); member.sendMessage(LocaleLoader.getString("Party.Disband"));
} }
PartyManager.disbandParty(playerParty); mcMMO.getPartyManager().disbandParty(playerParty);
return true; return true;
} }
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "disband")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "disband"));

View File

@ -6,8 +6,6 @@ import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.ShareMode; import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -24,19 +22,19 @@ public class PartyInfoCommand implements CommandExecutor {
switch (args.length) { switch (args.length) {
case 0: case 0:
case 1: case 1:
if(UserManager.getPlayer((Player) sender) == null) if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
{ {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
Player player = (Player) sender; Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
Party party = mcMMOPlayer.getParty(); Party party = mmoPlayer.getParty();
displayPartyHeader(player, party); displayPartyHeader(player, party);
displayShareModeInfo(player, party); displayShareModeInfo(player, party);
displayPartyFeatures(player, party); displayPartyFeatures(player, party);
displayMemberInfo(player, mcMMOPlayer, party); displayMemberInfo(player, mmoPlayer, party);
return true; return true;
default: default:
@ -49,7 +47,7 @@ public class PartyInfoCommand implements CommandExecutor {
player.sendMessage(LocaleLoader.getString("Commands.Party.Header")); player.sendMessage(LocaleLoader.getString("Commands.Party.Header"));
StringBuilder status = new StringBuilder(); StringBuilder status = new StringBuilder();
status.append(LocaleLoader.getString("Commands.Party.Status", party.getName(), LocaleLoader.getString("Party.Status." + (party.isLocked() ? "Locked" : "Unlocked")), party.getLevel())); status.append(LocaleLoader.getString("Commands.Party.Status", party.getPartyName(), LocaleLoader.getString("Party.Status." + (party.isLocked() ? "Locked" : "Unlocked")), party.getLevel()));
if (!party.hasReachedLevelCap()) { if (!party.hasReachedLevelCap()) {
status.append(" (").append(party.getXpToLevelPercentage()).append(")"); status.append(" (").append(party.getXpToLevelPercentage()).append(")");
@ -120,12 +118,12 @@ public class PartyInfoCommand implements CommandExecutor {
} }
} }
private void displayMemberInfo(Player player, McMMOPlayer mcMMOPlayer, Party party) { private void displayMemberInfo(Player player, McMMOPlayer mmoPlayer, Party party) {
/* /*
* Only show members of the party that this member can see * Only show members of the party that this member can see
*/ */
List<Player> nearMembers = PartyManager.getNearVisibleMembers(mcMMOPlayer); List<Player> nearMembers = mcMMO.getPartyManager().getNearVisibleMembers(mmoPlayer);
int membersOnline = party.getVisibleMembers(player).size(); int membersOnline = party.getVisibleMembers(player).size();
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header")); player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));

View File

@ -4,9 +4,7 @@ import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -18,7 +16,7 @@ public class PartyInviteCommand implements CommandExecutor {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 2) { if (args.length == 2) {
String targetName = CommandUtils.getMatchedPlayerName(args[1]); String targetName = CommandUtils.getMatchedPlayerName(args[1]);
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName); McMMOPlayer mcMMOTarget = mcMMO.getUserManager().getOfflinePlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false; return false;
@ -26,13 +24,13 @@ public class PartyInviteCommand implements CommandExecutor {
Player target = mcMMOTarget.getPlayer(); Player target = mcMMOTarget.getPlayer();
if (UserManager.getPlayer((Player) sender) == null) { if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
Player player = (Player) sender; Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
String playerName = player.getName(); String playerName = player.getName();
if (player.equals(target)) { if (player.equals(target)) {
@ -40,19 +38,19 @@ public class PartyInviteCommand implements CommandExecutor {
return true; return true;
} }
if (PartyManager.inSameParty(player, target)) { if (mcMMO.getPartyManager().inSameParty(player, target)) {
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName)); sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
return true; return true;
} }
if (!PartyManager.canInvite(mcMMOPlayer)) { if (!mcMMO.getPartyManager().canInvite(mmoPlayer)) {
player.sendMessage(LocaleLoader.getString("Party.Locked")); player.sendMessage(LocaleLoader.getString("Party.Locked"));
return true; return true;
} }
Party playerParty = mcMMOPlayer.getParty(); Party playerParty = mmoPlayer.getParty();
if (PartyManager.isPartyFull(target, playerParty)) { if (mcMMO.getPartyManager().isPartyFull(target, playerParty)) {
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite", target.getName(), playerParty.toString(), Config.getInstance().getPartyMaxSize())); player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite", target.getName(), playerParty.toString(), Config.getInstance().getPartyMaxSize()));
return true; return true;
} }
@ -60,7 +58,7 @@ public class PartyInviteCommand implements CommandExecutor {
mcMMOTarget.setPartyInvite(playerParty); mcMMOTarget.setPartyInvite(playerParty);
sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getName(), playerName)); target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getPartyName(), playerName));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1")); target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
return true; return true;
} }

View File

@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -20,13 +19,13 @@ import java.util.Locale;
public class PartyItemShareCommand implements CommandExecutor { public class PartyItemShareCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if(UserManager.getPlayer((Player) sender) == null) if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
{ {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
Party party = UserManager.getPlayer((Player) sender).getParty(); Party party = mcMMO.getUserManager().getPlayer((Player) sender).getParty();
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ITEM_SHARE)) { if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ITEM_SHARE)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.4")); sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.4"));
@ -80,7 +79,7 @@ public class PartyItemShareCommand implements CommandExecutor {
String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString()))); String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
for (Player member : party.getOnlineMembers()) { for (Player member : party.getPartyMembers()) {
member.sendMessage(changeModeMessage); member.sendMessage(changeModeMessage);
} }
} }
@ -90,7 +89,7 @@ public class PartyItemShareCommand implements CommandExecutor {
String toggleMessage = LocaleLoader.getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(type.toString()), toggle ? "enabled" : "disabled"); String toggleMessage = LocaleLoader.getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(type.toString()), toggle ? "enabled" : "disabled");
for (Player member : party.getOnlineMembers()) { for (Player member : party.getPartyMembers()) {
member.sendMessage(toggleMessage); member.sendMessage(toggleMessage);
} }
} }

View File

@ -3,9 +3,7 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -19,7 +17,7 @@ public class PartyJoinCommand implements CommandExecutor {
case 2: case 2:
case 3: case 3:
String targetName = CommandUtils.getMatchedPlayerName(args[1]); String targetName = CommandUtils.getMatchedPlayerName(args[1]);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName); McMMOPlayer mcMMOTarget = mcMMO.getUserManager().getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return true; return true;
@ -34,16 +32,16 @@ public class PartyJoinCommand implements CommandExecutor {
Player player = (Player) sender; Player player = (Player) sender;
if(UserManager.getPlayer((Player) sender) == null) if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
{ {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
Party targetParty = mcMMOTarget.getParty(); Party targetParty = mcMMOTarget.getParty();
if (player.equals(target) || (mcMMOPlayer.inParty() && mcMMOPlayer.getParty().equals(targetParty))) { if (player.equals(target) || (mmoPlayer.inParty() && mmoPlayer.getParty().equals(targetParty))) {
sender.sendMessage(LocaleLoader.getString("Party.Join.Self")); sender.sendMessage(LocaleLoader.getString("Party.Join.Self"));
return true; return true;
} }
@ -51,25 +49,25 @@ public class PartyJoinCommand implements CommandExecutor {
String password = getPassword(args); String password = getPassword(args);
// Make sure party passwords match // Make sure party passwords match
if (!PartyManager.checkPartyPassword(player, targetParty, password)) { if (!mcMMO.getPartyManager().checkPartyPassword(player, targetParty, password)) {
return true; return true;
} }
String partyName = targetParty.getName(); String partyName = targetParty.getPartyName();
// Changing parties // Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, partyName)) { if (!mcMMO.getPartyManager().changeOrJoinParty(mmoPlayer, partyName)) {
return true; return true;
} }
if(PartyManager.isPartyFull(player, targetParty)) if(mcMMO.getPartyManager().isPartyFull(player, targetParty))
{ {
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull", targetParty.toString())); player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull", targetParty.toString()));
return true; return true;
} }
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", partyName)); player.sendMessage(LocaleLoader.getString("Commands.Party.Join", partyName));
PartyManager.addToParty(mcMMOPlayer, targetParty); mcMMO.getPartyManager().addToParty(mmoPlayer, targetParty);
return true; return true;
default: default:

View File

@ -4,9 +4,7 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -18,12 +16,12 @@ public class PartyKickCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 2) { if (args.length == 2) {
if (UserManager.getPlayer((Player) sender) == null) { if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
Party playerParty = UserManager.getPlayer((Player) sender).getParty(); Party playerParty = mcMMO.getUserManager().getPlayer((Player) sender).getParty();
String targetName = CommandUtils.getMatchedPlayerName(args[1]); String targetName = CommandUtils.getMatchedPlayerName(args[1]);
if (!playerParty.hasMember(targetName)) { if (!playerParty.hasMember(targetName)) {
@ -35,17 +33,17 @@ public class PartyKickCommand implements CommandExecutor {
if (target.isOnline()) { if (target.isOnline()) {
Player onlineTarget = target.getPlayer(); Player onlineTarget = target.getPlayer();
String partyName = playerParty.getName(); String partyName = playerParty.getPartyName();
if (!PartyManager.handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) { if (!mcMMO.getPartyManager().handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) {
return true; return true;
} }
PartyManager.processPartyLeaving(UserManager.getPlayer(onlineTarget)); mcMMO.getPartyManager().processPartyLeaving(mcMMO.getUserManager().getPlayer(onlineTarget));
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName)); onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
} }
PartyManager.removeFromParty(target, playerParty); mcMMO.getPartyManager().removeFromParty(target, playerParty);
return true; return true;
} }
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "kick", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "kick", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -55,13 +54,13 @@ public class PartyLockCommand implements CommandExecutor {
} }
private void togglePartyLock(CommandSender sender, boolean lock) { private void togglePartyLock(CommandSender sender, boolean lock) {
if(UserManager.getPlayer((Player) sender) == null) if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
{ {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return; return;
} }
Party party = UserManager.getPlayer((Player) sender).getParty(); Party party = mcMMO.getUserManager().getPlayer((Player) sender).getParty();
if (!Permissions.partySubcommand(sender, lock ? PartySubcommandType.LOCK : PartySubcommandType.UNLOCK)) { if (!Permissions.partySubcommand(sender, lock ? PartySubcommandType.LOCK : PartySubcommandType.UNLOCK)) {
sender.sendMessage(LocaleLoader.getString("mcMMO.NoPermission")); sender.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
@ -73,7 +72,7 @@ public class PartyLockCommand implements CommandExecutor {
return; return;
} }
party.setLocked(lock); party.setPartyLock(lock);
sender.sendMessage(LocaleLoader.getString("Party." + (lock ? "Locked" : "Unlocked"))); sender.sendMessage(LocaleLoader.getString("Party." + (lock ? "Locked" : "Unlocked")));
} }
} }

View File

@ -4,8 +4,6 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -18,19 +16,19 @@ public class PartyQuitCommand implements CommandExecutor {
if (args.length == 1) { if (args.length == 1) {
Player player = (Player) sender; Player player = (Player) sender;
if (UserManager.getPlayer((Player) sender) == null) { if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
Party playerParty = mcMMOPlayer.getParty(); Party playerParty = mmoPlayer.getParty();
if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) { if (!mcMMO.getPartyManager().handlePartyChangeEvent(player, playerParty.getPartyName(), null, EventReason.LEFT_PARTY)) {
return true; return true;
} }
PartyManager.removeFromParty(mcMMOPlayer); mcMMO.getPartyManager().removeFromParty(mmoPlayer);
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave")); sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
return true; return true;
} }

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyMember;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -16,15 +16,15 @@ public class PartyRenameCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 2) { if (args.length == 2) {
if (UserManager.getPlayer((Player) sender) == null) { if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer((Player) sender);
Party playerParty = mcMMOPlayer.getParty(); Party playerParty = mmoPlayer.getParty();
String oldPartyName = playerParty.getName(); String oldPartyName = playerParty.getPartyName();
String newPartyName = args[1]; String newPartyName = args[1];
// This is to prevent party leaders from spamming other players with the rename message // This is to prevent party leaders from spamming other players with the rename message
@ -33,26 +33,26 @@ public class PartyRenameCommand implements CommandExecutor {
return true; return true;
} }
Player player = mcMMOPlayer.getPlayer(); Player player = mmoPlayer.getPlayer();
// Check to see if the party exists, and if it does cancel renaming the party // Check to see if the party exists, and if it does cancel renaming the party
if (PartyManager.checkPartyExistence(player, newPartyName)) { if (mcMMO.getPartyManager().checkPartyExistence(player, newPartyName)) {
return true; return true;
} }
String leaderName = playerParty.getLeader().getPlayerName(); String leaderName = playerParty.getLeader().getPlayerName();
for (Player member : playerParty.getOnlineMembers()) { for (PartyMember partyMember : playerParty.getPartyMembers()) {
if (!PartyManager.handlePartyChangeEvent(member, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) { if (!mcMMO.getPartyManager().handlePartyChangeEvent(partyMember, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) {
return true; return true;
} }
if (!member.getName().equalsIgnoreCase(leaderName)) { if (!partyMember.getName().equalsIgnoreCase(leaderName)) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leaderName, newPartyName)); partyMember.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leaderName, newPartyName));
} }
} }
playerParty.setName(newPartyName); playerParty.setPartyName(newPartyName);
sender.sendMessage(LocaleLoader.getString("Commands.Party.Rename", newPartyName)); sender.sendMessage(LocaleLoader.getString("Commands.Party.Rename", newPartyName));
return true; return true;

View File

@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -17,13 +16,13 @@ import org.jetbrains.annotations.NotNull;
public class PartyXpShareCommand implements CommandExecutor { public class PartyXpShareCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if(UserManager.getPlayer((Player) sender) == null) if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
{ {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
Party party = UserManager.getPlayer((Player) sender).getParty(); Party party = mcMMO.getUserManager().getPlayer((Player) sender).getParty();
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.XP_SHARE)) { if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.XP_SHARE)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.5")); sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.5"));
@ -50,7 +49,7 @@ public class PartyXpShareCommand implements CommandExecutor {
String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Xp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString()))); String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Xp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
for (Player member : party.getOnlineMembers()) { for (Player member : party.getPartyMembers()) {
member.sendMessage(changeModeMessage); member.sendMessage(changeModeMessage);
} }
} }

View File

@ -2,8 +2,6 @@ package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -14,24 +12,24 @@ public class PartyAllianceAcceptCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 2) { if (args.length == 2) {
if (UserManager.getPlayer((Player) sender) == null) { if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
Player player = (Player) sender; Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
if (!mcMMOPlayer.hasPartyAllianceInvite()) { if (!mmoPlayer.hasPartyAllianceInvite()) {
sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites")); sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
return true; return true;
} }
if (mcMMOPlayer.getParty().getAlly() != null) { if (mmoPlayer.getParty().getAlly() != null) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies")); player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies"));
return true; return true;
} }
PartyManager.acceptAllianceInvite(mcMMOPlayer); mcMMO.getPartyManager().acceptAllianceInvite(mmoPlayer);
return true; return true;
} }
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "accept")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "accept"));

View File

@ -5,9 +5,7 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -38,16 +36,16 @@ public class PartyAllianceCommand implements TabExecutor {
return true; return true;
} }
if(UserManager.getPlayer((Player) sender) == null) if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
{ {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
player = (Player) sender; player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
playerParty = mcMMOPlayer.getParty(); playerParty = mmoPlayer.getParty();
switch (args.length) { switch (args.length) {
case 1: case 1:
@ -64,7 +62,7 @@ public class PartyAllianceCommand implements TabExecutor {
targetParty = playerParty.getAlly(); targetParty = playerParty.getAlly();
displayPartyHeader(); displayPartyHeader();
displayMemberInfo(mcMMOPlayer); displayMemberInfo(mmoPlayer);
return true; return true;
case 2: case 2:
@ -94,7 +92,7 @@ public class PartyAllianceCommand implements TabExecutor {
targetParty = playerParty.getAlly(); targetParty = playerParty.getAlly();
displayPartyHeader(); displayPartyHeader();
displayMemberInfo(mcMMOPlayer); displayMemberInfo(mmoPlayer);
return true; return true;
default: default:
@ -125,11 +123,11 @@ public class PartyAllianceCommand implements TabExecutor {
private void displayPartyHeader() { private void displayPartyHeader() {
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Header")); player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Header"));
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Ally", playerParty.getName(), targetParty.getName())); player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Ally", playerParty.getPartyName(), targetParty.getPartyName()));
} }
private void displayMemberInfo(McMMOPlayer mcMMOPlayer) { private void displayMemberInfo(McMMOPlayer mmoPlayer) {
List<Player> nearMembers = PartyManager.getNearMembers(mcMMOPlayer); List<Player> nearMembers = mcMMO.getPartyManager().getNearMembers(mmoPlayer);
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Members.Header")); player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Members.Header"));
player.sendMessage(playerParty.createMembersList(player)); player.sendMessage(playerParty.createMembersList(player));
player.sendMessage(ChatColor.DARK_GRAY + "----------------------------"); player.sendMessage(ChatColor.DARK_GRAY + "----------------------------");

View File

@ -3,8 +3,6 @@ package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -15,20 +13,20 @@ public class PartyAllianceDisbandCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 2) { if (args.length == 2) {
if (UserManager.getPlayer((Player) sender) == null) { if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
Player player = (Player) sender; Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
Party party = mcMMOPlayer.getParty(); Party party = mmoPlayer.getParty();
if (party.getAlly() == null) { if (party.getAlly() == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.None")); sender.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.None"));
return true; return true;
} }
PartyManager.disbandAlliance(player, party, party.getAlly()); mcMMO.getPartyManager().disbandAlliance(player, party, party.getAlly());
return true; return true;
} }
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "disband")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "disband"));

View File

@ -3,9 +3,7 @@ package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -17,7 +15,7 @@ public class PartyAllianceInviteCommand implements CommandExecutor {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 3) { if (args.length == 3) {
String targetName = CommandUtils.getMatchedPlayerName(args[2]); String targetName = CommandUtils.getMatchedPlayerName(args[2]);
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName); McMMOPlayer mcMMOTarget = mcMMO.getUserManager().getOfflinePlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false; return false;
@ -25,13 +23,13 @@ public class PartyAllianceInviteCommand implements CommandExecutor {
Player target = mcMMOTarget.getPlayer(); Player target = mcMMOTarget.getPlayer();
if (UserManager.getPlayer((Player) sender) == null) { if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
Player player = (Player) sender; Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
String playerName = player.getName(); String playerName = player.getName();
if (player.equals(target)) { if (player.equals(target)) {
@ -44,7 +42,7 @@ public class PartyAllianceInviteCommand implements CommandExecutor {
return true; return true;
} }
if (PartyManager.inSameParty(player, target)) { if (mcMMO.getPartyManager().inSameParty(player, target)) {
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName)); sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
return true; return true;
} }
@ -54,7 +52,7 @@ public class PartyAllianceInviteCommand implements CommandExecutor {
return true; return true;
} }
Party playerParty = mcMMOPlayer.getParty(); Party playerParty = mmoPlayer.getParty();
if (playerParty.getAlly() != null) { if (playerParty.getAlly() != null) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies")); player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies"));
@ -64,7 +62,7 @@ public class PartyAllianceInviteCommand implements CommandExecutor {
mcMMOTarget.setPartyAllianceInvite(playerParty); mcMMOTarget.setPartyAllianceInvite(playerParty);
sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.0", playerParty.getName(), playerName)); target.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.0", playerParty.getPartyName(), playerName));
target.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.1")); target.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.1"));
return true; return true;
} }

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -17,7 +16,7 @@ public class PtpAcceptAnyCommand implements CommandExecutor {
return true; return true;
} }
PartyTeleportRecord ptpRecord = UserManager.getPlayer(sender.getName()).getPartyTeleportRecord(); PartyTeleportRecord ptpRecord = mcMMO.getUserManager().getPlayer(sender.getName()).getPartyTeleportRecord();
if (ptpRecord.isConfirmRequired()) { if (ptpRecord.isConfirmRequired()) {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled")); sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled"));

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -21,14 +20,14 @@ public class PtpAcceptCommand implements CommandExecutor {
return true; return true;
} }
if(UserManager.getPlayer((Player) sender) == null) if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
{ {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
Player player = (Player) sender; Player player = (Player) sender;
PartyTeleportRecord ptpRecord = UserManager.getPlayer(player).getPartyTeleportRecord(); PartyTeleportRecord ptpRecord = mcMMO.getUserManager().getPlayer(player).getPartyTeleportRecord();
if (!ptpRecord.hasRequest()) { if (!ptpRecord.hasRequest()) {
player.sendMessage(LocaleLoader.getString("Commands.ptp.NoRequests")); player.sendMessage(LocaleLoader.getString("Commands.ptp.NoRequests"));

View File

@ -8,13 +8,11 @@ import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.items.TeleportationWarmup; import com.gmail.nossr50.runnables.items.TeleportationWarmup;
import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardManager;
import com.gmail.nossr50.worldguard.WorldGuardUtils; import com.gmail.nossr50.worldguard.WorldGuardUtils;
@ -57,24 +55,24 @@ public class PtpCommand implements TabExecutor {
if(WorldBlacklist.isWorldBlacklisted(player.getWorld())) if(WorldBlacklist.isWorldBlacklisted(player.getWorld()))
return true; return true;
if (!UserManager.hasPlayerDataKey(player)) { if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return true; return true;
} }
if(UserManager.getPlayer((Player) sender) == null) if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
{ {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
if (!mcMMOPlayer.inParty()) { if (!mmoPlayer.inParty()) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return true; return true;
} }
Party party = mcMMOPlayer.getParty(); Party party = mmoPlayer.getParty();
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.TELEPORT)) { if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.TELEPORT)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.2")); sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.2"));
@ -90,7 +88,7 @@ public class PtpCommand implements TabExecutor {
return ptpAcceptAnyCommand.onCommand(sender, command, label, args); return ptpAcceptAnyCommand.onCommand(sender, command, label, args);
} }
long recentlyHurt = mcMMOPlayer.getRecentlyHurt(); long recentlyHurt = mmoPlayer.getRecentlyHurtTimestamp();
int hurtCooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown(); int hurtCooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown();
if (hurtCooldown > 0) { if (hurtCooldown > 0) {
@ -112,7 +110,7 @@ public class PtpCommand implements TabExecutor {
} }
int ptpCooldown = Config.getInstance().getPTPCommandCooldown(); int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
long ptpLastUse = mcMMOPlayer.getPartyTeleportRecord().getLastUse(); long ptpLastUse = mmoPlayer.getPartyTeleportRecord().getLastUse();
if (ptpCooldown > 0) { if (ptpCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(ptpLastUse * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player); int timeRemaining = SkillUtils.calculateTimeLeft(ptpLastUse * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player);
@ -135,19 +133,19 @@ public class PtpCommand implements TabExecutor {
List<String> matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<>(TELEPORT_SUBCOMMANDS.size())); List<String> matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<>(TELEPORT_SUBCOMMANDS.size()));
if (matches.size() == 0) { if (matches.size() == 0) {
if (UserManager.getPlayer((Player) sender) == null) { if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return ImmutableList.of(); return ImmutableList.of();
} }
Player player = (Player) sender; Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
if (!mcMMOPlayer.inParty()) { if (!mmoPlayer.inParty()) {
return ImmutableList.of(); return ImmutableList.of();
} }
List<String> playerNames = mcMMOPlayer.getParty().getOnlinePlayerNames(player); List<String> playerNames = mmoPlayer.getParty().getOnlinePlayerNames(player);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
} }
@ -161,7 +159,7 @@ public class PtpCommand implements TabExecutor {
return; return;
} }
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName); McMMOPlayer mcMMOTarget = mcMMO.getUserManager().getPlayer(targetName);
Player target = mcMMOTarget.getPlayer(); Player target = mcMMOTarget.getPlayer();
@ -198,7 +196,7 @@ public class PtpCommand implements TabExecutor {
} }
protected static boolean canTeleport(CommandSender sender, Player player, String targetName) { protected static boolean canTeleport(CommandSender sender, Player player, String targetName) {
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName); McMMOPlayer mcMMOTarget = mcMMO.getUserManager().getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false; return false;
@ -211,7 +209,7 @@ public class PtpCommand implements TabExecutor {
return false; return false;
} }
if (!PartyManager.inSameParty(player, target)) { if (!mcMMO.getPartyManager().inSameParty(player, target)) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName)); player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
return false; return false;
} }
@ -230,28 +228,28 @@ public class PtpCommand implements TabExecutor {
} }
protected static void handleTeleportWarmup(Player teleportingPlayer, Player targetPlayer) { protected static void handleTeleportWarmup(Player teleportingPlayer, Player targetPlayer) {
if(UserManager.getPlayer(targetPlayer) == null) if(mcMMO.getUserManager().getPlayer(targetPlayer) == null)
{ {
targetPlayer.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); targetPlayer.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return; return;
} }
if(UserManager.getPlayer(teleportingPlayer) == null) if(mcMMO.getUserManager().getPlayer(teleportingPlayer) == null)
{ {
teleportingPlayer.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); teleportingPlayer.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return; return;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(teleportingPlayer);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetPlayer); McMMOPlayer mcMMOTarget = mcMMO.getUserManager().getPlayer(targetPlayer);
long warmup = Config.getInstance().getPTPCommandWarmup(); long warmup = Config.getInstance().getPTPCommandWarmup();
mcMMOPlayer.actualizeTeleportCommenceLocation(teleportingPlayer); mmoPlayer.actualizeTeleportCommenceLocation(teleportingPlayer);
if (warmup > 0) { if (warmup > 0) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Teleport.Commencing", warmup)); teleportingPlayer.sendMessage(LocaleLoader.getString("Teleport.Commencing", warmup));
new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup); new TeleportationWarmup(mmoPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup);
} }
else { else {
EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer); EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -17,7 +16,7 @@ public class PtpToggleCommand implements CommandExecutor {
return true; return true;
} }
PartyTeleportRecord ptpRecord = UserManager.getPlayer(sender.getName()).getPartyTeleportRecord(); PartyTeleportRecord ptpRecord = mcMMO.getUserManager().getPlayer(sender.getName()).getPartyTeleportRecord();
if (ptpRecord.isEnabled()) { if (ptpRecord.isEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled")); sender.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled"));

View File

@ -8,7 +8,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -26,10 +25,10 @@ public class InspectCommand implements TabExecutor {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 1) { if (args.length == 1) {
String playerName = CommandUtils.getMatchedPlayerName(args[0]); String playerName = CommandUtils.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getOfflinePlayer(playerName);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. // If 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 (mcMMOPlayer == null) { if (mmoPlayer == null) {
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); // Temporary Profile PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); // Temporary Profile
if (!CommandUtils.isLoaded(sender, profile)) { if (!CommandUtils.isLoaded(sender, profile)) {
@ -62,7 +61,7 @@ public class InspectCommand implements TabExecutor {
} }
} else { } else {
Player target = mcMMOPlayer.getPlayer(); Player target = mmoPlayer.getPlayer();
if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) { if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) {
sender.sendMessage(LocaleLoader.getString("Inspect.Offline")); sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
@ -72,7 +71,7 @@ public class InspectCommand implements TabExecutor {
} }
if (Config.getInstance().getScoreboardsEnabled() && sender instanceof Player && Config.getInstance().getInspectUseBoard()) { if (Config.getInstance().getScoreboardsEnabled() && sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile()); ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mmoPlayer);
if (!Config.getInstance().getInspectUseChat()) { if (!Config.getInstance().getInspectUseChat()) {
return true; return true;
@ -83,7 +82,7 @@ public class InspectCommand implements TabExecutor {
CommandUtils.printGatheringSkills(target, sender); CommandUtils.printGatheringSkills(target, sender);
CommandUtils.printCombatSkills(target, sender); CommandUtils.printCombatSkills(target, sender);
CommandUtils.printMiscSkills(target, sender); CommandUtils.printMiscSkills(target, sender);
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel())); sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mmoPlayer.getPowerLevel()));
} }
return true; return true;

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -38,12 +37,12 @@ public class MccooldownCommand implements TabExecutor {
} }
} }
if (UserManager.getPlayer(player) == null) { if (mcMMO.getUserManager().getPlayer(player) == null) {
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header")); player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header"));
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote")); player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
@ -53,7 +52,7 @@ public class MccooldownCommand implements TabExecutor {
continue; continue;
} }
int seconds = mcMMOPlayer.calculateTimeRemaining(ability); int seconds = mmoPlayer.calculateTimeRemaining(ability);
if (seconds <= 0) { if (seconds <= 0) {
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getLocalizedName())); player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getLocalizedName()));

View File

@ -7,7 +7,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask; import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -53,10 +52,10 @@ public class McrankCommand implements TabExecutor {
} }
String playerName = CommandUtils.getMatchedPlayerName(args[0]); String playerName = CommandUtils.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getOfflinePlayer(playerName);
if (mcMMOPlayer != null) { if (mmoPlayer != null) {
Player player = mcMMOPlayer.getPlayer(); Player player = mmoPlayer.getPlayer();
playerName = player.getName(); playerName = player.getName();
if (CommandUtils.tooFar(sender, player, Permissions.mcrankFar(sender))) { if (CommandUtils.tooFar(sender, player, Permissions.mcrankFar(sender))) {
@ -83,9 +82,9 @@ public class McrankCommand implements TabExecutor {
private void display(CommandSender sender, String playerName) { private void display(CommandSender sender, String playerName) {
if (sender instanceof Player) { if (sender instanceof Player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName()); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(sender.getName());
if(mcMMOPlayer == null) if(mmoPlayer == null)
{ {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return; return;
@ -93,8 +92,8 @@ public class McrankCommand implements TabExecutor {
long cooldownMillis = Math.min(Config.getInstance().getDatabasePlayerCooldown(), 1750); long cooldownMillis = Math.min(Config.getInstance().getDatabasePlayerCooldown(), 1750);
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) { if (mmoPlayer.getDatabaseCommandATS() + cooldownMillis > System.currentTimeMillis()) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.CooldownMS", getCDSeconds(mcMMOPlayer, cooldownMillis))); sender.sendMessage(LocaleLoader.getString("Commands.Database.CooldownMS", getCDSeconds(mmoPlayer, cooldownMillis)));
return; return;
} }
@ -105,7 +104,7 @@ public class McrankCommand implements TabExecutor {
((Player) sender).setMetadata(mcMMO.databaseCommandKey, new FixedMetadataValue(mcMMO.p, null)); ((Player) sender).setMetadata(mcMMO.databaseCommandKey, new FixedMetadataValue(mcMMO.p, null));
} }
mcMMOPlayer.actualizeDatabaseATS(); mmoPlayer.actualizeDatabaseCommandATS();
} }
boolean useBoard = Config.getInstance().getScoreboardsEnabled() && (sender instanceof Player) && (Config.getInstance().getRankUseBoard()); boolean useBoard = Config.getInstance().getScoreboardsEnabled() && (sender instanceof Player) && (Config.getInstance().getRankUseBoard());
@ -114,7 +113,7 @@ public class McrankCommand implements TabExecutor {
new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p); new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
} }
private long getCDSeconds(McMMOPlayer mcMMOPlayer, long cooldownMillis) { private long getCDSeconds(McMMOPlayer mmoPlayer, long cooldownMillis) {
return ((mcMMOPlayer.getDatabaseATS() + cooldownMillis) - System.currentTimeMillis()); return ((mmoPlayer.getDatabaseCommandATS() + cooldownMillis) - System.currentTimeMillis());
} }
} }

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -26,7 +25,7 @@ public class McstatsCommand implements TabExecutor {
} }
if (args.length == 0) { if (args.length == 0) {
if (UserManager.getPlayer((Player) sender) == null) { if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
@ -51,9 +50,9 @@ public class McstatsCommand implements TabExecutor {
int powerLevelCap = Config.getInstance().getPowerLevelCap(); int powerLevelCap = Config.getInstance().getPowerLevelCap();
if (powerLevelCap != Integer.MAX_VALUE) { if (powerLevelCap != Integer.MAX_VALUE) {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap)); player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", mcMMO.getUserManager().getPlayer(player).getPowerLevel(), powerLevelCap));
} else { } else {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel())); player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMO.getUserManager().getPlayer(player).getPowerLevel()));
} }
return true; return true;

View File

@ -9,7 +9,6 @@ import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -85,11 +84,11 @@ public class MctopCommand implements TabExecutor {
return; return;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName()); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(sender.getName());
long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750); long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750);
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) { if (mmoPlayer.getDatabaseCommandATS() + cooldownMillis > System.currentTimeMillis()) {
double seconds = ((mcMMOPlayer.getDatabaseATS() + cooldownMillis) - System.currentTimeMillis()) / 1000.0D; double seconds = ((mmoPlayer.getDatabaseCommandATS() + cooldownMillis) - System.currentTimeMillis()) / 1000.0D;
if (seconds < 1) { if (seconds < 1) {
seconds = 1; seconds = 1;
} }
@ -105,7 +104,7 @@ public class MctopCommand implements TabExecutor {
((Player) sender).setMetadata(mcMMO.databaseCommandKey, new FixedMetadataValue(mcMMO.p, null)); ((Player) sender).setMetadata(mcMMO.databaseCommandKey, new FixedMetadataValue(mcMMO.p, null));
} }
mcMMOPlayer.actualizeDatabaseATS(); mmoPlayer.actualizeDatabaseCommandATS();
} }
display(page, skill, sender); display(page, skill, sender);

View File

@ -3,9 +3,8 @@ package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.experience.ExperienceBarManager; import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -24,7 +23,7 @@ public class XPBarCommand implements TabExecutor {
@Override @Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if(sender instanceof Player) { if(sender instanceof Player) {
McMMOPlayer mmoPlayer = UserManager.getPlayer((Player) sender); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer((Player) sender);
if(mmoPlayer == null) { if(mmoPlayer == null) {
NotificationManager.sendPlayerInformationChatOnlyPrefixed(mmoPlayer.getPlayer(), "Profile.PendingLoad"); NotificationManager.sendPlayerInformationChatOnlyPrefixed(mmoPlayer.getPlayer(), "Profile.PendingLoad");
return false; return false;
@ -35,10 +34,10 @@ public class XPBarCommand implements TabExecutor {
} else if(args.length < 2) { } else if(args.length < 2) {
String option = args[0]; String option = args[0];
if(option.equalsIgnoreCase(ExperienceBarManager.XPBarSettingTarget.RESET.toString())) { if(option.equalsIgnoreCase(MMOExperienceBarManager.XPBarSettingTarget.RESET.toString())) {
mmoPlayer.getExperienceBarManager().xpBarSettingToggle(ExperienceBarManager.XPBarSettingTarget.RESET, null); mmoPlayer.getExperienceBarManager().xpBarSettingToggle(MMOExperienceBarManager.XPBarSettingTarget.RESET, null);
return true; return true;
} else if(option.equalsIgnoreCase(ExperienceBarManager.XPBarSettingTarget.DISABLE.toString())) { } else if(option.equalsIgnoreCase(MMOExperienceBarManager.XPBarSettingTarget.DISABLE.toString())) {
mmoPlayer.getExperienceBarManager().disableAllBars(); mmoPlayer.getExperienceBarManager().disableAllBars();
return true; return true;
} else { } else {
@ -56,8 +55,8 @@ public class XPBarCommand implements TabExecutor {
//Target setting //Target setting
String option = args[0].toLowerCase(); String option = args[0].toLowerCase();
ExperienceBarManager.XPBarSettingTarget settingTarget = getSettingTarget(option); MMOExperienceBarManager.XPBarSettingTarget settingTarget = getSettingTarget(option);
if(settingTarget != null && settingTarget != ExperienceBarManager.XPBarSettingTarget.RESET) { if(settingTarget != null && settingTarget != MMOExperienceBarManager.XPBarSettingTarget.RESET) {
//Change setting //Change setting
mmoPlayer.getExperienceBarManager().xpBarSettingToggle(settingTarget, targetSkill); mmoPlayer.getExperienceBarManager().xpBarSettingToggle(settingTarget, targetSkill);
return true; return true;
@ -75,16 +74,16 @@ public class XPBarCommand implements TabExecutor {
} }
} }
private @Nullable ExperienceBarManager.XPBarSettingTarget getSettingTarget(String string) { private @Nullable MMOExperienceBarManager.XPBarSettingTarget getSettingTarget(String string) {
switch (string.toLowerCase()) { switch (string.toLowerCase()) {
case "hide": case "hide":
return ExperienceBarManager.XPBarSettingTarget.HIDE; return MMOExperienceBarManager.XPBarSettingTarget.HIDE;
case "show": case "show":
return ExperienceBarManager.XPBarSettingTarget.SHOW; return MMOExperienceBarManager.XPBarSettingTarget.SHOW;
case "reset": case "reset":
return ExperienceBarManager.XPBarSettingTarget.RESET; return MMOExperienceBarManager.XPBarSettingTarget.RESET;
case "disable": case "disable":
return ExperienceBarManager.XPBarSettingTarget.DISABLE; return MMOExperienceBarManager.XPBarSettingTarget.DISABLE;
} }
return null; return null;
@ -96,13 +95,13 @@ public class XPBarCommand implements TabExecutor {
case 1: case 1:
List<String> options = new ArrayList<>(); List<String> options = new ArrayList<>();
for(ExperienceBarManager.XPBarSettingTarget settingTarget : ExperienceBarManager.XPBarSettingTarget.values()) { for(MMOExperienceBarManager.XPBarSettingTarget settingTarget : MMOExperienceBarManager.XPBarSettingTarget.values()) {
options.add(StringUtils.getCapitalized(settingTarget.toString())); options.add(StringUtils.getCapitalized(settingTarget.toString()));
} }
return StringUtil.copyPartialMatches(args[0], options, new ArrayList<>(ExperienceBarManager.XPBarSettingTarget.values().length)); return StringUtil.copyPartialMatches(args[0], options, new ArrayList<>(MMOExperienceBarManager.XPBarSettingTarget.values().length));
case 2: case 2:
if(!args[0].equalsIgnoreCase(ExperienceBarManager.XPBarSettingTarget.RESET.toString())) if(!args[0].equalsIgnoreCase(MMOExperienceBarManager.XPBarSettingTarget.RESET.toString()))
return StringUtil.copyPartialMatches(args[1], PrimarySkillType.SKILL_NAMES, new ArrayList<>(PrimarySkillType.SKILL_NAMES.size())); return StringUtil.copyPartialMatches(args[1], PrimarySkillType.SKILL_NAMES, new ArrayList<>(PrimarySkillType.SKILL_NAMES.size()));
default: default:
return ImmutableList.of(); return ImmutableList.of();

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.alchemy.AlchemyManager; import com.gmail.nossr50.skills.alchemy.AlchemyManager;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -31,13 +30,13 @@ public class AlchemyCommand extends SkillCommand {
protected String[] calculateAbilityDisplayValues(Player player) { protected String[] calculateAbilityDisplayValues(Player player) {
//TODO: Needed? //TODO: Needed?
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return new String[] {"DATA NOT LOADED", "DATA NOT LOADED"}; return new String[] {"DATA NOT LOADED", "DATA NOT LOADED"};
} }
AlchemyManager alchemyManager = UserManager.getPlayer(player).getAlchemyManager(); AlchemyManager alchemyManager = mcMMO.getUserManager().getPlayer(player).getAlchemyManager();
String[] displayValues = new String[2]; String[] displayValues = new String[2];
boolean isLucky = Permissions.lucky(player, PrimarySkillType.ALCHEMY); boolean isLucky = Permissions.lucky(player, PrimarySkillType.ALCHEMY);
@ -59,7 +58,7 @@ public class AlchemyCommand extends SkillCommand {
// ALCHEMY_CONCOCTIONS // ALCHEMY_CONCOCTIONS
if (canConcoctions) { if (canConcoctions) {
AlchemyManager alchemyManager = UserManager.getPlayer(player).getAlchemyManager(); AlchemyManager alchemyManager = mcMMO.getUserManager().getPlayer(player).getAlchemyManager();
tier = alchemyManager.getTier(); tier = alchemyManager.getTier();
ingredientCount = alchemyManager.getIngredients().size(); ingredientCount = alchemyManager.getIngredients().size();
ingredientList = alchemyManager.getIngredientList(); ingredientList = alchemyManager.getIngredientList();

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.axes.Axes; import com.gmail.nossr50.skills.axes.Axes;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
@ -38,7 +37,7 @@ public class AxesCommand extends SkillCommand {
protected void dataCalculations(Player player, float skillValue) { protected void dataCalculations(Player player, float skillValue) {
// ARMOR IMPACT // ARMOR IMPACT
if (canImpact) { if (canImpact) {
impactDamage = UserManager.getPlayer(player).getAxesManager().getImpactDurabilityDamage(); impactDamage = mcMMO.getUserManager().getPlayer(player).getAxesManager().getImpactDurabilityDamage();
} }
// AXE MASTERY // AXE MASTERY

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.skills.crossbows.CrossbowManager; import com.gmail.nossr50.skills.crossbows.CrossbowManager;
import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -30,7 +29,7 @@ public class CrossbowsCommand extends SkillCommand {
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>(); List<String> messages = new ArrayList<>();
CrossbowManager crossbowManager = UserManager.getPlayer(player).getCrossbowManager(); CrossbowManager crossbowManager = mcMMO.getUserManager().getPlayer(player).getCrossbowManager();
if(canUseSubskill(player, SubSkillType.CROSSBOWS_SUPER_SHOTGUN)) { if(canUseSubskill(player, SubSkillType.CROSSBOWS_SUPER_SHOTGUN)) {
String additionalArrowCount = String.valueOf(crossbowManager.getSuperShotgunAdditionalArrowCount()); String additionalArrowCount = String.valueOf(crossbowManager.getSuperShotgunAdditionalArrowCount());

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.excavation.ExcavationManager; import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -45,7 +44,7 @@ public class ExcavationCommand extends SkillCommand {
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>(); List<String> messages = new ArrayList<>();
ExcavationManager excavationManager = UserManager.getPlayer(player).getExcavationManager(); ExcavationManager excavationManager = mcMMO.getUserManager().getPlayer(player).getExcavationManager();
if (canGigaDrill) { if (canGigaDrill) {
messages.add(getStatMessage(SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER, gigaDrillBreakerLength) messages.add(getStatMessage(SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER, gigaDrillBreakerLength)

View File

@ -10,7 +10,6 @@ import com.gmail.nossr50.skills.fishing.Fishing;
import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
@ -51,7 +50,7 @@ public class FishingCommand extends SkillCommand {
@Override @Override
protected void dataCalculations(Player player, float skillValue) { protected void dataCalculations(Player player, float skillValue) {
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager(); FishingManager fishingManager = mcMMO.getUserManager().getPlayer(player).getFishingManager();
// TREASURE HUNTER // TREASURE HUNTER
if (canTreasureHunt) { if (canTreasureHunt) {

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
@ -42,7 +41,7 @@ public class MiningCommand extends SkillCommand {
protected void dataCalculations(Player player, float skillValue) { protected void dataCalculations(Player player, float skillValue) {
// BLAST MINING // BLAST MINING
if (canBlast || canDemoExpert || canBiggerBombs) { if (canBlast || canDemoExpert || canBiggerBombs) {
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager(); MiningManager miningManager = mcMMO.getUserManager().getPlayer(player).getMiningManager();
blastMiningRank = miningManager.getBlastMiningTier(); blastMiningRank = miningManager.getBlastMiningTier();
bonusTNTDrops = miningManager.getDropMultiplier(); bonusTNTDrops = miningManager.getDropMultiplier();

View File

@ -11,7 +11,6 @@ import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.repair.repairables.Repairable; import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
@ -94,7 +93,7 @@ public class RepairCommand extends SkillCommand {
List<String> messages = new ArrayList<>(); List<String> messages = new ArrayList<>();
if (canArcaneForge) { if (canArcaneForge) {
RepairManager repairManager = UserManager.getPlayer(player).getRepairManager(); RepairManager repairManager = mcMMO.getUserManager().getPlayer(player).getRepairManager();
messages.add(getStatMessage(false, true, messages.add(getStatMessage(false, true,
SubSkillType.REPAIR_ARCANE_FORGING, SubSkillType.REPAIR_ARCANE_FORGING,

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.salvage.Salvage; import com.gmail.nossr50.skills.salvage.Salvage;
import com.gmail.nossr50.skills.salvage.SalvageManager; import com.gmail.nossr50.skills.salvage.SalvageManager;
import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -37,7 +36,7 @@ public class SalvageCommand extends SkillCommand {
@Override @Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>(); List<String> messages = new ArrayList<>();
SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager(); SalvageManager salvageManager = mcMMO.getUserManager().getPlayer(player).getSalvageManager();
if (canScrapCollector) { if (canScrapCollector) {
messages.add(getStatMessage(false, true, messages.add(getStatMessage(false, true,

View File

@ -12,7 +12,6 @@ import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.NotificationManager; 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.random.RandomChanceUtil;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.PerksUtils;
@ -59,7 +58,7 @@ public abstract class SkillCommand implements TabExecutor {
return true; return true;
} }
if(UserManager.getPlayer((Player) sender) == null) if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
{ {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
@ -67,11 +66,11 @@ public abstract class SkillCommand implements TabExecutor {
if (args.length == 0) { if (args.length == 0) {
Player player = (Player) sender; Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
boolean isLucky = Permissions.lucky(player, skill); boolean isLucky = Permissions.lucky(player, skill);
boolean hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0); boolean hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0);
float skillValue = mcMMOPlayer.getSkillLevel(skill); float skillValue = mmoPlayer.getSkillLevel(skill);
//Send the players a few blank lines to make finding the top of the skill command easier //Send the players a few blank lines to make finding the top of the skill command easier
if (AdvancedConfig.getInstance().doesSkillCommandSendBlankLines()) if (AdvancedConfig.getInstance().doesSkillCommandSendBlankLines())
@ -82,7 +81,7 @@ public abstract class SkillCommand implements TabExecutor {
permissionsCheck(player); permissionsCheck(player);
dataCalculations(player, skillValue); dataCalculations(player, skillValue);
sendSkillCommandHeader(player, mcMMOPlayer, (int) skillValue); sendSkillCommandHeader(player, mmoPlayer, (int) skillValue);
//Make JSON text components //Make JSON text components
List<TextComponent> subskillTextComponents = getTextComponents(player); List<TextComponent> subskillTextComponents = getTextComponents(player);
@ -135,7 +134,7 @@ public abstract class SkillCommand implements TabExecutor {
player.sendMessage(LocaleLoader.getString("Guides.Available", skillName, skillName.toLowerCase(Locale.ENGLISH))); player.sendMessage(LocaleLoader.getString("Guides.Available", skillName, skillName.toLowerCase(Locale.ENGLISH)));
} }
private void sendSkillCommandHeader(Player player, McMMOPlayer mcMMOPlayer, int skillValue) { private void sendSkillCommandHeader(Player player, McMMOPlayer mmoPlayer, int skillValue) {
ChatColor hd1 = ChatColor.DARK_AQUA; ChatColor hd1 = ChatColor.DARK_AQUA;
ChatColor c1 = ChatColor.GOLD; ChatColor c1 = ChatColor.GOLD;
ChatColor c2 = ChatColor.RED; ChatColor c2 = ChatColor.RED;
@ -153,7 +152,7 @@ public abstract class SkillCommand implements TabExecutor {
player.sendMessage(LocaleLoader.getString("Commands.XPGain.Overhaul", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString())))); player.sendMessage(LocaleLoader.getString("Commands.XPGain.Overhaul", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
//LEVEL //LEVEL
player.sendMessage(LocaleLoader.getString("Effects.Level.Overhaul", skillValue, mcMMOPlayer.getSkillXpLevel(skill), mcMMOPlayer.getXpToLevel(skill))); player.sendMessage(LocaleLoader.getString("Effects.Level.Overhaul", skillValue, mmoPlayer.getSkillXpLevel(skill), mmoPlayer.getXpToLevel(skill)));
} else { } else {
/* /*
@ -164,7 +163,7 @@ public abstract class SkillCommand implements TabExecutor {
Set<PrimarySkillType> parents = FamilyTree.getParents(skill); Set<PrimarySkillType> parents = FamilyTree.getParents(skill);
//TODO: Add JSON here //TODO: Add JSON here
/*player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level.Overhaul", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent)))*/ /*player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level.Overhaul", mmoPlayer.getSkillLevel(parent), mmoPlayer.getSkillXpLevel(parent), mmoPlayer.getXpToLevel(parent)))*/
ArrayList<PrimarySkillType> parentList = new ArrayList<>(parents); ArrayList<PrimarySkillType> parentList = new ArrayList<>(parents);
StringBuilder parentMessage = new StringBuilder(); StringBuilder parentMessage = new StringBuilder();
@ -173,10 +172,10 @@ public abstract class SkillCommand implements TabExecutor {
{ {
if(i+1 < parentList.size()) if(i+1 < parentList.size())
{ {
parentMessage.append(LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i)))); parentMessage.append(LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mmoPlayer.getSkillLevel(parentList.get(i))));
parentMessage.append(ChatColor.GRAY).append(", "); parentMessage.append(ChatColor.GRAY).append(", ");
} else { } else {
parentMessage.append(LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i)))); parentMessage.append(LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mmoPlayer.getSkillLevel(parentList.get(i))));
} }
} }
@ -192,7 +191,7 @@ public abstract class SkillCommand implements TabExecutor {
if (!skill.isChildSkill()) { if (!skill.isChildSkill()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName)); player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString())))); player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
player.sendMessage(LocaleLoader.getString("Effects.Level", skillValue, mcMMOPlayer.getSkillXpLevel(skill), mcMMOPlayer.getXpToLevel(skill))); player.sendMessage(LocaleLoader.getString("Effects.Level", skillValue, mmoPlayer.getSkillXpLevel(skill), mmoPlayer.getXpToLevel(skill)));
} else { } else {
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child"))); player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child")));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain.Child"))); player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain.Child")));
@ -202,7 +201,7 @@ public abstract class SkillCommand implements TabExecutor {
Set<PrimarySkillType> parents = FamilyTree.getParents(skill); Set<PrimarySkillType> parents = FamilyTree.getParents(skill);
for (PrimarySkillType parent : parents) { for (PrimarySkillType parent : parents) {
player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent))); player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level", mmoPlayer.getSkillLevel(parent), mmoPlayer.getSkillXpLevel(parent), mmoPlayer.getXpToLevel(parent)));
} }
} }
*/ */

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
@ -34,7 +33,7 @@ public class SmeltingCommand extends SkillCommand {
protected void dataCalculations(Player player, float skillValue) { protected void dataCalculations(Player player, float skillValue) {
// FUEL EFFICIENCY // FUEL EFFICIENCY
if (canFuelEfficiency) { if (canFuelEfficiency) {
burnTimeModifier = String.valueOf(UserManager.getPlayer(player).getSmeltingManager().getFuelEfficiencyMultiplier()); burnTimeModifier = String.valueOf(mcMMO.getUserManager().getPlayer(player).getSmeltingManager().getFuelEfficiencyMultiplier());
} }
// FLUX MINING // FLUX MINING
@ -81,7 +80,7 @@ public class SmeltingCommand extends SkillCommand {
if (canUnderstandTheArt) { if (canUnderstandTheArt) {
messages.add(getStatMessage(false, true, SubSkillType.SMELTING_UNDERSTANDING_THE_ART, messages.add(getStatMessage(false, true, SubSkillType.SMELTING_UNDERSTANDING_THE_ART,
String.valueOf(UserManager.getPlayer(player).getSmeltingManager().getVanillaXpMultiplier()))); String.valueOf(mcMMO.getUserManager().getPlayer(player).getSmeltingManager().getVanillaXpMultiplier())));
} }
return messages; return messages;

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
@ -44,7 +43,7 @@ public class SwordsCommand extends SkillCommand {
// SWORDS_RUPTURE // SWORDS_RUPTURE
if (canBleed) { if (canBleed) {
bleedLength = UserManager.getPlayer(player).getSwordsManager().getRuptureBleedTicks(); bleedLength = mcMMO.getUserManager().getPlayer(player).getSwordsManager().getRuptureBleedTicks();
String[] bleedStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.SWORDS_RUPTURE); String[] bleedStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.SWORDS_RUPTURE);
bleedChance = bleedStrings[0]; bleedChance = bleedStrings[0];
@ -70,7 +69,7 @@ public class SwordsCommand extends SkillCommand {
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>(); List<String> messages = new ArrayList<>();
int ruptureTicks = UserManager.getPlayer(player).getSwordsManager().getRuptureBleedTicks(); int ruptureTicks = mcMMO.getUserManager().getPlayer(player).getSwordsManager().getRuptureBleedTicks();
double ruptureDamagePlayers = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? AdvancedConfig.getInstance().getRuptureDamagePlayer() * 1.5D : AdvancedConfig.getInstance().getRuptureDamagePlayer(); double ruptureDamagePlayers = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? AdvancedConfig.getInstance().getRuptureDamagePlayer() * 1.5D : AdvancedConfig.getInstance().getRuptureDamagePlayer();
double ruptureDamageMobs = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? AdvancedConfig.getInstance().getRuptureDamageMobs() * 1.5D : AdvancedConfig.getInstance().getRuptureDamageMobs(); double ruptureDamageMobs = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? AdvancedConfig.getInstance().getRuptureDamageMobs() * 1.5D : AdvancedConfig.getInstance().getRuptureDamageMobs();
@ -98,7 +97,7 @@ public class SwordsCommand extends SkillCommand {
if(canUseSubskill(player, SubSkillType.SWORDS_STAB)) if(canUseSubskill(player, SubSkillType.SWORDS_STAB))
{ {
messages.add(getStatMessage(SubSkillType.SWORDS_STAB, messages.add(getStatMessage(SubSkillType.SWORDS_STAB,
String.valueOf(UserManager.getPlayer(player).getSwordsManager().getStabDamage()))); String.valueOf(mcMMO.getUserManager().getPlayer(player).getSwordsManager().getStabDamage())));
} }
if(canUseSubskill(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)) { if(canUseSubskill(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)) {

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
@ -61,7 +60,7 @@ public class UnarmedCommand extends SkillCommand {
// IRON ARM // IRON ARM
if (canIronArm) { if (canIronArm) {
ironArmBonus = UserManager.getPlayer(player).getUnarmedManager().getIronArmDamage(); ironArmBonus = mcMMO.getUserManager().getPlayer(player).getUnarmedManager().getIronArmDamage();
} }
// IRON GRIP // IRON GRIP

View File

@ -638,7 +638,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
/* GENERAL */ /* GENERAL */
public boolean canApplyLimitBreakPVE() { return config.getBoolean("Skills.General.LimitBreak.AllowPVE", false); } public boolean canApplyLimitBreakPVE() { return config.getBoolean("Skills.General.LimitBreak.AllowPVE", false); }
public int getStartingLevel() { return config.getInt("Skills.General.StartingLevel", 1); } public int getStartingLevel() { return config.getInt("Skills.General.StartingLevel", 0); }
public boolean allowPlayerTips() { public boolean allowPlayerTips() {
return config.getBoolean("Feedback.PlayerTips", true); return config.getBoolean("Feedback.PlayerTips", true);

View File

@ -1,7 +1,7 @@
package com.gmail.nossr50.config; package com.gmail.nossr50.config;
import com.gmail.nossr50.database.SQLDatabaseManager.PoolIdentifier; import com.gmail.nossr50.database.SQLDatabaseManager.PoolIdentifier;
import com.gmail.nossr50.datatypes.MobHealthbarType; import com.gmail.nossr50.datatypes.MobHealthBarType;
import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
@ -276,12 +276,12 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getMobHealthbarEnabled() { return config.getBoolean("Mob_Healthbar.Enabled", true); } public boolean getMobHealthbarEnabled() { return config.getBoolean("Mob_Healthbar.Enabled", true); }
/* Mob Healthbar */ /* Mob Healthbar */
public MobHealthbarType getMobHealthbarDefault() { public MobHealthBarType getMobHealthbarDefault() {
try { try {
return MobHealthbarType.valueOf(config.getString("Mob_Healthbar.Display_Type", "HEARTS").toUpperCase(Locale.ENGLISH).trim()); return MobHealthBarType.valueOf(config.getString("Mob_Healthbar.Display_Type", "HEARTS").toUpperCase(Locale.ENGLISH).trim());
} }
catch (IllegalArgumentException ex) { catch (IllegalArgumentException ex) {
return MobHealthbarType.HEARTS; return MobHealthBarType.HEARTS;
} }
} }
@ -374,12 +374,6 @@ public class Config extends AutoUpdateConfigLoader {
public int getHardcoreVampirismLevelThreshold() { return config.getInt("Hardcore.Vampirism.Level_Threshold", 0); } public int getHardcoreVampirismLevelThreshold() { return config.getInt("Hardcore.Vampirism.Level_Threshold", 0); }
/* SMP Mods */
public boolean getToolModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
public boolean getArmorModsEnabled() { return config.getBoolean("Mods.Armor_Mods_Enabled", false); }
public boolean getBlockModsEnabled() { return config.getBoolean("Mods.Block_Mods_Enabled", false); }
public boolean getEntityModsEnabled() { return config.getBoolean("Mods.Entity_Mods_Enabled", false); }
/* Items */ /* Items */
public int getChimaeraUseCost() { return config.getInt("Items.Chimaera_Wing.Use_Cost", 1); } public int getChimaeraUseCost() { return config.getInt("Items.Chimaera_Wing.Use_Cost", 1); }
public int getChimaeraRecipeCost() { return config.getInt("Items.Chimaera_Wing.Recipe_Cost", 5); } public int getChimaeraRecipeCost() { return config.getInt("Items.Chimaera_Wing.Recipe_Cost", 5); }

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50.database;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.database.DatabaseType; import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.database.PlayerStat; import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.player.MMODataSnapshot;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
@ -40,15 +41,14 @@ public interface DatabaseManager {
* Currently only used for SQL * Currently only used for SQL
* @param uuid target UUID to cleanup * @param uuid target UUID to cleanup
*/ */
void cleanupUser(UUID uuid); void removeCache(UUID uuid);
/** /**
* Save a user to the database. * Save a user to the database.
* *
* @param profile The profile of the player to save * @param mmoDataSnapshot Snapshot of player data to save
* @return true if successful, false on failure
*/ */
boolean saveUser(PlayerProfile profile); boolean saveUser(MMODataSnapshot mmoDataSnapshot);
/** /**
* Retrieve leaderboard info. * Retrieve leaderboard info.
@ -79,20 +79,6 @@ public interface DatabaseManager {
*/ */
void newUser(String playerName, UUID uuid); void newUser(String playerName, UUID uuid);
/**
* Load a player from the database.
*
* @deprecated replaced by {@link #loadPlayerProfile(String playerName, UUID uuid, boolean createNew)}
*
* @param playerName The name of the player to load from the database
* @param createNew Whether to create a new record if the player is not
* found
* @return The player's data, or an unloaded PlayerProfile if not found
* and createNew is false
*/
@Deprecated
PlayerProfile loadPlayerProfile(String playerName, boolean createNew);
/** /**
* Load a player from the database. * Load a player from the database.
* *
@ -101,18 +87,6 @@ public interface DatabaseManager {
*/ */
PlayerProfile loadPlayerProfile(UUID uuid); PlayerProfile loadPlayerProfile(UUID uuid);
/**
* Load a player from the database. Attempt to use uuid, fall back on playername
*
* @param playerName The name of the player to load from the database
* @param uuid The uuid of the player to load from the database
* @param createNew Whether to create a new record if the player is not
* found
* @return The player's data, or an unloaded PlayerProfile if not found
* and createNew is false
*/
PlayerProfile loadPlayerProfile(String playerName, UUID uuid, boolean createNew);
/** /**
* Get all users currently stored in the database. * Get all users currently stored in the database.
* *
@ -128,9 +102,9 @@ public interface DatabaseManager {
*/ */
void convertUsers(DatabaseManager destination); void convertUsers(DatabaseManager destination);
boolean saveUserUUID(String userName, UUID uuid); // boolean saveUserUUID(String userName, UUID uuid);
boolean saveUserUUIDs(Map<String, UUID> fetchedUUIDs); // boolean saveUserUUIDs(Map<String, UUID> fetchedUUIDs);
/** /**
* Retrieve the type of database in use. Custom databases should return CUSTOM. * Retrieve the type of database in use. Custom databases should return CUSTOM.

View File

@ -23,7 +23,7 @@ public class DatabaseManagerFactory {
mcMMO.p.getLogger().info("Falling back on " + (Config.getInstance().getUseMySQL() ? "SQL" : "Flatfile") + " database"); mcMMO.p.getLogger().info("Falling back on " + (Config.getInstance().getUseMySQL() ? "SQL" : "Flatfile") + " database");
} }
return Config.getInstance().getUseMySQL() ? new SQLDatabaseManager() : new FlatfileDatabaseManager(); return Config.getInstance().getUseMySQL() ? new SQLDatabaseManager() : new FlatFileDatabaseManager();
} }
/** /**
@ -60,7 +60,7 @@ public class DatabaseManagerFactory {
switch (type) { switch (type) {
case FLATFILE: case FLATFILE:
mcMMO.p.getLogger().info("Using FlatFile Database"); mcMMO.p.getLogger().info("Using FlatFile Database");
return new FlatfileDatabaseManager(); return new FlatFileDatabaseManager();
case SQL: case SQL:
mcMMO.p.getLogger().info("Using SQL Database"); mcMMO.p.getLogger().info("Using SQL Database");

View File

@ -1,337 +1,96 @@
package com.gmail.nossr50.datatypes.party; package com.gmail.nossr50.datatypes.party;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
public class Party { public class Party {
// private static final String ONLINE_PLAYER_PREFIX = "";
// private static final String ONLINE_PLAYER_PREFIX = "" + ChatColor.RESET;
private static final String ONLINE_PLAYER_PREFIX = ""; private static final String ONLINE_PLAYER_PREFIX = "";
// private static final String OFFLINE_PLAYER_PREFIX = "";
private static final String OFFLINE_PLAYER_PREFIX = "";
// private static final String OFFLINE_PLAYER_PREFIX = "" + ChatColor.RESET;
private final LinkedHashMap<UUID, String> members = new LinkedHashMap<>();
private final List<Player> onlineMembers = new ArrayList<>();
private PartyLeader leader; private final String partyName;
private String name; private String partyPassword;
private String password; private boolean partyLock;
private boolean locked;
private Party ally;
private int level;
private float xp;
private ShareMode xpShareMode = ShareMode.NONE; private final PartyMemberManager partyMemberManager;
private ShareMode itemShareMode = ShareMode.NONE; private final PartyItemShareManager partyItemShareManager;
private final PartyExperienceManager partyExperienceManager;
private final PartyAllianceManager partyAllianceManager;
private boolean shareLootDrops = true; public static final String PARTY_LEADER_PREFIX = ChatColor.GOLD
private boolean shareMiningDrops = true; + ""
private boolean shareHerbalismDrops = true; + ChatColor.RESET;
private boolean shareWoodcuttingDrops = true;
private boolean shareMiscDrops = true;
public Party(String name) { public Party(String partyName, HashSet<PartyMember> partyMembers, int partyLevel) throws RuntimeException {
this.name = name; if(partyMembers.isEmpty()) {
} throw new RuntimeException("No party members for the party named "+ partyName);
public Party(PartyLeader leader, String name) {
this.leader = leader;
this.name = name;
this.locked = true;
this.level = 0;
}
public Party(PartyLeader leader, String name, String password) {
this.leader = leader;
this.name = name;
this.password = password;
this.locked = true;
this.level = 0;
}
public Party(PartyLeader leader, String name, String password, boolean locked) {
this.leader = leader;
this.name = name;
this.password = password;
this.locked = locked;
this.level = 0;
}
public LinkedHashMap<UUID, String> getMembers() {
return members;
}
public List<Player> getOnlineMembers() {
return onlineMembers;
}
public List<Player> getVisibleMembers(Player player)
{
ArrayList<Player> visibleMembers = new ArrayList<>();
for(Player p : onlineMembers)
{
if(player.canSee(p))
visibleMembers.add(p);
} }
return visibleMembers; this.partyName = partyName;
this.partyLock = true;
this.partyLevel = partyLevel;
this.partyMemberManager = new PartyMemberManager(partyMembers);
this.partyItemShareManager = new PartyItemShareManager();
} }
public List<String> getOnlinePlayerNames(CommandSender sender) { public Party(Player partyLeader, String partyName, String partyPassword) {
Player player = sender instanceof Player ? (Player) sender : null; this.partyName = partyName;
List<String> onlinePlayerNames = new ArrayList<>(); this.partyPassword = partyPassword;
this.partyLock = true;
for (Player onlinePlayer : getOnlineMembers()) { this.partyLevel = 0;
if (player != null && player.canSee(onlinePlayer)) { this.partyMemberManager = new PartyMemberManager(partyLeader);
onlinePlayerNames.add(onlinePlayer.getName()); this.partyItemShareManager = new PartyItemShareManager();
}
}
return onlinePlayerNames;
} }
public boolean addOnlineMember(Player player) { public HashSet<PartyMember> getPartyMembers() {
return onlineMembers.add(player); return partyMemberManager.getPartyMembers();
} }
public boolean removeOnlineMember(Player player) { public String getPartyName() {
return onlineMembers.remove(player); return partyName;
} }
public String getName() { public String getPartyPassword() {
return name; return partyPassword;
}
public PartyLeader getLeader() {
return leader;
}
public String getPassword() {
return password;
} }
public boolean isLocked() { public boolean isLocked() {
return locked; return partyLock;
} }
public Party getAlly() { public Party getAlly() {
return ally; return ally;
} }
public List<String> getItemShareCategories() { public void setPartyName(String partyName) {
List<String> shareCategories = new ArrayList<>(); this.partyName = partyName;
}
for (ItemShareType shareType : ItemShareType.values()) { public void setLeader(UUID newPartyLeader) {
if (sharingDrops(shareType)) { this.partyMemberManager = ;
shareCategories.add(shareType.getLocaleString()); }
}
public void setPartyPassword(String partyPassword) {
this.partyPassword = partyPassword;
}
public void setPartyLock(boolean partyLock) {
this.partyLock = partyLock;
}
public boolean hasMember(Player player) {
for(PartyMember partyMember : getPartyMembers()) {
if(partyMember.getUniqueId().equals(player.getUniqueId()))
return true;
} }
return shareCategories; return false;
}
public void setName(String name) {
this.name = name;
}
public void setLeader(PartyLeader leader) {
this.leader = leader;
}
public void setPassword(String password) {
this.password = password;
}
public void setLocked(boolean locked) {
this.locked = locked;
}
public void setAlly(Party ally) {
this.ally = ally;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public float getXp() {
return xp;
}
public void setXp(float xp) {
this.xp = xp;
}
public void addXp(float xp) {
setXp(getXp() + xp);
}
protected float levelUp() {
float xpRemoved = getXpToLevel();
setLevel(getLevel() + 1);
setXp(getXp() - xpRemoved);
return xpRemoved;
}
public int getXpToLevel() {
FormulaType formulaType = ExperienceConfig.getInstance().getFormulaType();
return (mcMMO.getFormulaManager().getXPtoNextLevel(level, formulaType)) * (getOnlineMembers().size() + Config.getInstance().getPartyXpCurveMultiplier());
}
public String getXpToLevelPercentage() {
DecimalFormat percent = new DecimalFormat("##0.00%");
return percent.format(this.getXp() / getXpToLevel());
}
/**
* Applies an experience gain
*
* @param xp Experience amount to add
*/
public void applyXpGain(float xp) {
if (!EventUtils.handlePartyXpGainEvent(this, xp)) {
return;
}
if (getXp() < getXpToLevel()) {
return;
}
int levelsGained = 0;
float xpRemoved = 0;
while (getXp() >= getXpToLevel()) {
if (hasReachedLevelCap()) {
setXp(0);
return;
}
xpRemoved += levelUp();
levelsGained++;
}
if (!EventUtils.handlePartyLevelChangeEvent(this, levelsGained, xpRemoved)) {
return;
}
if (!Config.getInstance().getPartyInformAllMembers()) {
Player leader = mcMMO.p.getServer().getPlayer(this.leader.getUniqueId());
if (leader != null) {
leader.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, getLevel()));
if (Config.getInstance().getLevelUpSoundsEnabled()) {
SoundManager.sendSound(leader, leader.getLocation(), SoundType.LEVEL_UP);
}
}
return;
}
PartyManager.informPartyMembersLevelUp(this, levelsGained, getLevel());
}
public boolean hasReachedLevelCap() {
return Config.getInstance().getPartyLevelCap() < getLevel() + 1;
}
public void setXpShareMode(ShareMode xpShareMode) {
this.xpShareMode = xpShareMode;
}
public ShareMode getXpShareMode() {
return xpShareMode;
}
public void setItemShareMode(ShareMode itemShareMode) {
this.itemShareMode = itemShareMode;
}
public ShareMode getItemShareMode() {
return itemShareMode;
}
public boolean sharingDrops(ItemShareType shareType) {
switch (shareType) {
case HERBALISM:
return shareHerbalismDrops;
case LOOT:
return shareLootDrops;
case MINING:
return shareMiningDrops;
case MISC:
return shareMiscDrops;
case WOODCUTTING:
return shareWoodcuttingDrops;
default:
return false;
}
}
public void setSharingDrops(ItemShareType shareType, boolean enabled) {
switch (shareType) {
case HERBALISM:
shareHerbalismDrops = enabled;
break;
case LOOT:
shareLootDrops = enabled;
break;
case MINING:
shareMiningDrops = enabled;
break;
case MISC:
shareMiscDrops = enabled;
break;
case WOODCUTTING:
shareWoodcuttingDrops = enabled;
break;
default:
}
}
public boolean hasMember(String memberName) {
return this.getMembers().containsValue(memberName);
}
public boolean hasMember(UUID uuid) {
return this.getMembers().containsKey(uuid);
} }
/** /**
@ -342,189 +101,39 @@ public class Party {
* @return formatted list of party members from the POV of a player * @return formatted list of party members from the POV of a player
*/ */
public String createMembersList(Player player) { public String createMembersList(Player player) {
StringBuilder memberList = new StringBuilder();
List<UUID> onlineMembers = members.keySet().stream()
.filter(x -> Bukkit.getOfflinePlayer(x).isOnline())
.collect(Collectors.toList());
List<UUID> offlineMembers = members.keySet().stream()
.filter(x -> !Bukkit.getOfflinePlayer(x).isOnline())
.collect(Collectors.toList());
ArrayList<UUID> visiblePartyList = new ArrayList<>();
boolean isPartyLeaderOfflineOrHidden = false;
ArrayList<UUID> offlineOrHiddenPartyList = new ArrayList<>();
for(UUID onlineMember : onlineMembers)
{
Player onlinePlayer = Bukkit.getPlayer(onlineMember);
if(!isNotSamePerson(player.getUniqueId(), onlineMember)
|| onlinePlayer != null && player.canSee(onlinePlayer))
{
visiblePartyList.add(onlineMember);
} else {
//Party leader and cannot be seen by this player
if(isNotSamePerson(leader.getUniqueId(), player.getUniqueId()) && onlineMember == leader.getUniqueId())
isPartyLeaderOfflineOrHidden = true;
offlineOrHiddenPartyList.add(onlineMember);
}
}
if(offlineMembers.contains(leader.getUniqueId()))
isPartyLeaderOfflineOrHidden = true;
//Add all the actually offline members
offlineOrHiddenPartyList.addAll(offlineMembers);
/* BUILD THE PARTY LIST WITH FORMATTING */ /* BUILD THE PARTY LIST WITH FORMATTING */
String partyLeaderPrefix =
/*ChatColor.WHITE
+ "["
+*/ ChatColor.GOLD
+ ""
/*+ ChatColor.WHITE
+ "]"*/
+ ChatColor.RESET;
//First add the party leader
memberList.append(partyLeaderPrefix);
List<Player> nearbyPlayerList = getNearMembers(UserManager.getPlayer(player));
boolean useDisplayNames = Config.getInstance().getPartyDisplayNames(); boolean useDisplayNames = Config.getInstance().getPartyDisplayNames();
if(isPartyLeaderOfflineOrHidden) StringBuilder formattedPartyMemberList = new StringBuilder();
{
if(isNotSamePerson(player.getUniqueId(), leader.getUniqueId()))
applyOnlineAndRangeFormatting(memberList, false, false);
memberList.append(ChatColor.GRAY) PartyMember partyLeader = getLeader();
.append(leader.getPlayerName());
}
else {
if(isNotSamePerson(leader.getUniqueId(), player.getUniqueId()))
applyOnlineAndRangeFormatting(memberList, true, nearbyPlayerList.contains(Bukkit.getPlayer(leader.getUniqueId())));
if(useDisplayNames) { //First add the party leader
memberList.append(leader.getPlayerName()); memberList.append(PARTY_LEADER_PREFIX);
} else {
memberList.append(ChatColor.GOLD)
.append(Bukkit.getOfflinePlayer(leader.getUniqueId()));
}
}
//Space
memberList.append(" ");
//Now do online members
for(UUID onlinePlayerUUID : visiblePartyList)
{
if(onlinePlayerUUID == leader.getUniqueId())
continue;
if(isNotSamePerson(onlinePlayerUUID, player.getUniqueId()))
applyOnlineAndRangeFormatting(memberList, true, nearbyPlayerList.contains(Bukkit.getPlayer(onlinePlayerUUID)));
if(useDisplayNames)
{
memberList.append(Bukkit.getPlayer(onlinePlayerUUID).getDisplayName());
}
else
{
//Color allies green, players dark aqua
memberList.append(ChatColor.GREEN)
.append(Bukkit.getPlayer(onlinePlayerUUID).getName());
}
memberList.append(" ").append(ChatColor.RESET);
}
for(UUID offlineOrHiddenPlayer : offlineOrHiddenPartyList)
{
if(offlineOrHiddenPlayer == leader.getUniqueId())
continue;
applyOnlineAndRangeFormatting(memberList, false, false);
memberList.append(ChatColor.GRAY)
.append(Bukkit.getOfflinePlayer(offlineOrHiddenPlayer).getName())
.append(" ").append(ChatColor.RESET);
}
// for (Player otherPlayer : this.getVisibleMembers(player)) {
// String memberName = otherPlayer.getName();
//
// if (this.getLeader().getUniqueId().equals(otherPlayer.getUniqueId())) {
// memberList.append(ChatColor.GOLD);
//
// if (otherPlayer == null) {
// memberName = memberName.substring(0, 1) + ChatColor.GRAY + ChatColor.ITALIC + "" + memberName.substring(1);
// }
// }
// else if (otherPlayer != null) {
// memberList.append(ChatColor.WHITE);
// }
// else {
// memberList.append(ChatColor.GRAY);
// }
//
// if (player.getName().equalsIgnoreCase(otherPlayer.getName())) {
// memberList.append(ChatColor.ITALIC);
// }
//
// memberList.append(memberName).append(ChatColor.RESET).append(" ");
// }
return memberList.toString(); return memberList.toString();
} }
private boolean isNotSamePerson(UUID onlinePlayerUUID, UUID uniqueId) {
return onlinePlayerUUID != uniqueId;
}
private void applyOnlineAndRangeFormatting(StringBuilder stringBuilder, boolean isVisibleOrOnline, boolean isNear)
{
if(isVisibleOrOnline)
{
if(isNear)
{
stringBuilder.append(ChatColor.GREEN);
} else {
stringBuilder.append(ChatColor.GRAY);
}
// stringBuilder.append(ChatColor.BOLD);
stringBuilder.append(ONLINE_PLAYER_PREFIX);
} else {
stringBuilder.append(ChatColor.GRAY);
stringBuilder.append(OFFLINE_PLAYER_PREFIX);
}
stringBuilder.append(ChatColor.RESET);
}
/** /**
* Get the near party members. * Get the near party members.
* *
* @param mcMMOPlayer The player to check * @param mmoPlayer The player to check
* @return the near party members * @return the near party members
*/ */
public List<Player> getNearMembers(McMMOPlayer mcMMOPlayer) { public List<Player> getNearMembers(McMMOPlayer mmoPlayer) {
List<Player> nearMembers = new ArrayList<>(); List<Player> nearMembers = new ArrayList<>();
Party party = mcMMOPlayer.getParty(); Party party = mmoPlayer.getParty();
if (party != null) { if (party != null) {
Player player = mcMMOPlayer.getPlayer(); Player player = mmoPlayer.getPlayer();
double range = Config.getInstance().getPartyShareRange(); double range = Config.getInstance().getPartyShareRange();
for (Player member : party.getOnlineMembers()) { for (PartyMember partyMember : party.getPartyMembers()) {
if (!player.equals(member) && member.isValid() && Misc.isNear(player.getLocation(), member.getLocation(), range)) { if (!player.getUniqueId().equals(partyMember.getOfflinePlayer().getUniqueId())
nearMembers.add(member); && partyMember.getOfflinePlayer().isOnline()
&& partyMember.getOfflinePlayer().getPlayer() != null
&& Misc.isNear(player.getLocation(), partyMember.getOfflinePlayer().getPlayer().getLocation(), range)) {
nearMembers.add(partyMember.getOfflinePlayer().getPlayer());
} }
} }
} }
@ -533,21 +142,11 @@ public class Party {
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object o) {
if (obj == null) { }
return false;
}
if (!(obj instanceof Party)) { @Override
return false; public int hashCode() {
} return ;
Party other = (Party) obj;
if ((this.getName() == null) || (other.getName() == null)) {
return false;
}
return this.getName().equals(other.getName());
} }
} }

View File

@ -0,0 +1,26 @@
package com.gmail.nossr50.datatypes.party;
public class PartyAllianceManager {
private Party ally;
private Party allianceInvite;
public void setPartyAllianceInvite(Party allianceInvite) {
this.allianceInvite = allianceInvite;
}
public Party getPartyAllianceInvite() {
return allianceInvite;
}
public boolean hasPartyAllianceInvite() {
return (allianceInvite != null);
}
public void removePartyAllianceInvite() {
allianceInvite = null;
}
public void setAlly(Party ally) {
this.ally = ally;
}
}

View File

@ -0,0 +1,118 @@
package com.gmail.nossr50.datatypes.party;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.entity.Player;
import java.text.DecimalFormat;
public class PartyExperienceManager {
private int partyLevel;
private float partyExperience;
private ShareMode xpShareMode = ShareMode.NONE;
public void setXpShareMode(ShareMode xpShareMode) {
this.xpShareMode = xpShareMode;
}
public ShareMode getXpShareMode() {
return xpShareMode;
}
/**
* Applies an experience gain
*
* @param xp Experience amount to add
*/
public void applyXpGain(float xp) {
if (!EventUtils.handlePartyXpGainEvent(this, xp)) {
return;
}
if (getXp() < getXpToLevel()) {
return;
}
int levelsGained = 0;
float xpRemoved = 0;
while (getXp() >= getXpToLevel()) {
if (hasReachedLevelCap()) {
setXp(0);
return;
}
xpRemoved += levelUp();
levelsGained++;
}
if (!EventUtils.handlePartyLevelChangeEvent(this, levelsGained, xpRemoved)) {
return;
}
if (!Config.getInstance().getPartyInformAllMembers()) {
Player leader = mcMMO.p.getServer().getPlayer(this.leader.getUniqueId());
if (leader != null) {
leader.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, getLevel()));
if (Config.getInstance().getLevelUpSoundsEnabled()) {
SoundManager.sendSound(leader, leader.getLocation(), SoundType.LEVEL_UP);
}
}
return;
}
mcMMO.getPartyManager().informPartyMembersLevelUp(this, levelsGained, getLevel());
}
public boolean hasReachedLevelCap() {
return Config.getInstance().getPartyLevelCap() < getLevel() + 1;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public float getXp() {
return xp;
}
public void setXp(float xp) {
this.xp = xp;
}
public void addXp(float xp) {
setXp(getXp() + xp);
}
protected float levelUp() {
float xpRemoved = getXpToLevel();
setLevel(getLevel() + 1);
setXp(getXp() - xpRemoved);
return xpRemoved;
}
public int getXpToLevel() {
FormulaType formulaType = ExperienceConfig.getInstance().getFormulaType();
return (mcMMO.getFormulaManager().getXPtoNextLevel(level, formulaType)) * (getPartyMembers().size() + Config.getInstance().getPartyXpCurveMultiplier());
}
public String getXpToLevelPercentage() {
DecimalFormat percent = new DecimalFormat("##0.00%");
return percent.format(this.getXp() / getXpToLevel());
}
}

View File

@ -0,0 +1,51 @@
package com.gmail.nossr50.datatypes.party;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.UUID;
public class PartyInvite {
private final String partyName;
private Party invitingParty;
private final UUID inviterUUID;
private final UUID targetUUID;
public PartyInvite(@NotNull String partyName, @NotNull Party invitingParty, @NotNull UUID inviterUUID, @NotNull UUID targetUUID) {
this.partyName = partyName;
this.invitingParty = invitingParty;
this.inviterUUID = inviterUUID;
this.targetUUID = targetUUID;
}
/**
* The name of the Party who made this invite
* @return
*/
public String getPartyName() {
return partyName;
}
/**
* The UUID of the player who created this invite
* @return
*/
public @NotNull UUID getInviterUUID() {
return inviterUUID;
}
/**
* The target of this party invite
* @return the target player for this invite
*/
public @NotNull UUID getTargetPlayer() {
return targetUUID;
}
public @Nullable OfflinePlayer getTargetOfflinePlayer() {
return Bukkit.getOfflinePlayer(targetUUID);
}
}

View File

@ -0,0 +1,4 @@
package com.gmail.nossr50.datatypes.party;
public class PartyInviteManager {
}

View File

@ -0,0 +1,85 @@
package com.gmail.nossr50.datatypes.party;
import java.util.ArrayList;
import java.util.List;
public class PartyItemShareManager {
private ShareMode itemShareMode = ShareMode.NONE;
private boolean shareLootDrops = true;
private boolean shareMiningDrops = true;
private boolean shareHerbalismDrops = true;
private boolean shareWoodcuttingDrops = true;
private boolean shareMiscDrops = true;
public void setItemShareMode(ShareMode itemShareMode) {
this.itemShareMode = itemShareMode;
}
public ShareMode getItemShareMode() {
return itemShareMode;
}
public boolean sharingDrops(ItemShareType shareType) {
switch (shareType) {
case HERBALISM:
return shareHerbalismDrops;
case LOOT:
return shareLootDrops;
case MINING:
return shareMiningDrops;
case MISC:
return shareMiscDrops;
case WOODCUTTING:
return shareWoodcuttingDrops;
default:
return false;
}
}
public void setSharingDrops(ItemShareType shareType, boolean enabled) {
switch (shareType) {
case HERBALISM:
shareHerbalismDrops = enabled;
break;
case LOOT:
shareLootDrops = enabled;
break;
case MINING:
shareMiningDrops = enabled;
break;
case MISC:
shareMiscDrops = enabled;
break;
case WOODCUTTING:
shareWoodcuttingDrops = enabled;
break;
default:
}
}
public List<String> getItemShareCategories() {
List<String> shareCategories = new ArrayList<>();
for (ItemShareType shareType : ItemShareType.values()) {
if (sharingDrops(shareType)) {
shareCategories.add(shareType.getLocaleString());
}
}
return shareCategories;
}
}

View File

@ -1,21 +0,0 @@
package com.gmail.nossr50.datatypes.party;
import java.util.UUID;
public class PartyLeader {
private final UUID uuid;
private final String playerName;
public PartyLeader(UUID uuid, String playerName) {
this.uuid = uuid;
this.playerName = playerName;
}
public UUID getUniqueId() {
return uuid;
}
public String getPlayerName() {
return playerName;
}
}

View File

@ -0,0 +1,59 @@
package com.gmail.nossr50.datatypes.party;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.UUID;
public class PartyMember {
private final OfflinePlayer offlinePlayer;
private PartyMemberRank partyMemberRank;
private final PartyTeleportRecord partyTeleportRecord;
private int itemShareModifier;
public PartyMember(OfflinePlayer offlinePlayer, PartyMemberRank partyMemberRank) {
this.offlinePlayer = offlinePlayer;
this.partyMemberRank = partyMemberRank;
this.partyTeleportRecord = new PartyTeleportRecord();
}
public OfflinePlayer getOfflinePlayer() {
return offlinePlayer;
}
public PartyMemberRank getPartyMemberRank() {
return partyMemberRank;
}
public void setPartyMemberRank(PartyMemberRank partyMemberRank) {
this.partyMemberRank = partyMemberRank;
}
public @NotNull UUID getUniqueId() {
return offlinePlayer.getUniqueId();
}
@Nullable
public String getName() {
return offlinePlayer.getName();
}
public int getItemShareModifier() {
if (itemShareModifier < 10) {
setItemShareModifier(10);
}
return itemShareModifier;
}
public void setItemShareModifier(int modifier) {
itemShareModifier = Math.max(10, modifier);
}
public PartyTeleportRecord getPartyTeleportRecord() {
return partyTeleportRecord;
}
}

View File

@ -0,0 +1,71 @@
package com.gmail.nossr50.datatypes.party;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
public class PartyMemberManager {
private final @NotNull Map<String, PartyMember> partyMembers;
private @NotNull PartyMember partyLeaderRef;
private final @NotNull HashSet<PartyMember> partyOfficers;
public PartyMemberManager(@NotNull HashSet<PartyMember> partyMembers) {
this.partyMembers = partyMembers;
}
public PartyMemberManager(@NotNull Player partyLeader) {
addPartyMember(partyLeader, PartyMemberRank.LEADER);
}
public @NotNull Collection<PartyMember> getPartyMembers() {
return partyMembers.values();
}
private void registerSpecialPartyMembers() {
clearOfficers();
for(PartyMember partyMember : partyMembers) {
switch (partyMember.getPartyMemberRank()) {
case MEMBER:
break;
case OFFICER:
partyOfficers.add(partyMember);
break;
case LEADER:
partyLeaderRef = partyMember;
break;
}
}
}
private void clearOfficers() {
partyOfficers.clear();
}
public void addPartyMember(OfflinePlayer player, PartyMemberRank partyMemberRank) {
//TODO: Prevent adding multiple leaders
//TODO: Call event
partyMembers.add(new PartyMember(player, partyMemberRank));
}
public HashSet<PartyMember> getVisibleMembers(Player player)
{
HashSet<PartyMember> visibleMembers = new HashSet<>();
for(PartyMember partyMember : partyMembers)
{
if(partyMember.getOfflinePlayer().getPlayer() == null)
continue;
if(player.canSee(partyMember.getOfflinePlayer().getPlayer()))
visibleMembers.add(partyMember);
}
return visibleMembers;
}
}

View File

@ -0,0 +1,7 @@
package com.gmail.nossr50.datatypes.party;
public enum PartyMemberRank {
MEMBER,
OFFICER,
LEADER;
}

View File

@ -13,7 +13,6 @@ import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.RandomChanceSkill; import com.gmail.nossr50.util.random.RandomChanceSkill;
import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.PerksUtils;
@ -66,9 +65,9 @@ public class Roll extends AcrobaticsSubSkill {
return false; return false;
if (entityDamageEvent.getCause() == EntityDamageEvent.DamageCause.FALL) {//Grab the player if (entityDamageEvent.getCause() == EntityDamageEvent.DamageCause.FALL) {//Grab the player
McMMOPlayer mcMMOPlayer = EventUtils.getMcMMOPlayer(entityDamageEvent.getEntity()); McMMOPlayer mmoPlayer = EventUtils.getMcMMOPlayer(entityDamageEvent.getEntity());
if (mcMMOPlayer == null) if (mmoPlayer == null)
return false; return false;
/* /*
@ -76,7 +75,7 @@ public class Roll extends AcrobaticsSubSkill {
*/ */
Player player = (Player) ((EntityDamageEvent) event).getEntity(); Player player = (Player) ((EntityDamageEvent) event).getEntity();
if (canRoll(player)) { if (canRoll(player)) {
entityDamageEvent.setDamage(rollCheck(player, mcMMOPlayer, entityDamageEvent.getDamage())); entityDamageEvent.setDamage(rollCheck(player, mmoPlayer, entityDamageEvent.getDamage()));
if (entityDamageEvent.getFinalDamage() == 0) { if (entityDamageEvent.getFinalDamage() == 0) {
entityDamageEvent.setCancelled(true); entityDamageEvent.setCancelled(true);
@ -120,7 +119,7 @@ public class Roll extends AcrobaticsSubSkill {
String rollChance, rollChanceLucky, gracefulRollChance, gracefulRollChanceLucky; String rollChance, rollChanceLucky, gracefulRollChance, gracefulRollChanceLucky;
/* Values related to the player */ /* Values related to the player */
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile(); PlayerProfile playerProfile = mcMMO.getUserManager().getPlayer(player);
float skillValue = playerProfile.getSkillLevel(getPrimarySkill()); float skillValue = playerProfile.getSkillLevel(getPrimarySkill());
boolean isLucky = Permissions.lucky(player, getPrimarySkill()); boolean isLucky = Permissions.lucky(player, getPrimarySkill());
@ -187,12 +186,12 @@ public class Roll extends AcrobaticsSubSkill {
* @param damage The amount of damage initially dealt by the event * @param damage The amount of damage initially dealt by the event
* @return the modified event damage if the ability was successful, the original event damage otherwise * @return the modified event damage if the ability was successful, the original event damage otherwise
*/ */
private double rollCheck(Player player, McMMOPlayer mcMMOPlayer, double damage) { private double rollCheck(Player player, McMMOPlayer mmoPlayer, double damage) {
int skillLevel = mcMMOPlayer.getSkillLevel(getPrimarySkill()); int skillLevel = mmoPlayer.getSkillLevel(getPrimarySkill());
if (player.isSneaking()) { if (player.isSneaking()) {
return gracefulRollCheck(player, mcMMOPlayer, damage, skillLevel); return gracefulRollCheck(player, mmoPlayer, damage, skillLevel);
} }
double modifiedDamage = calculateModifiedRollDamage(damage, AdvancedConfig.getInstance().getRollDamageThreshold()); double modifiedDamage = calculateModifiedRollDamage(damage, AdvancedConfig.getInstance().getRollDamageThreshold());
@ -203,18 +202,18 @@ public class Roll extends AcrobaticsSubSkill {
SoundManager.sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS); SoundManager.sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS);
//player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text")); //player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
//if (!SkillUtils.cooldownExpired((long) mcMMOPlayer.getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) { //if (!SkillUtils.cooldownExpired((long) mmoPlayer.getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) {
if(!isExploiting(player) && mcMMOPlayer.getAcrobaticsManager().canGainRollXP()) if(!isExploiting(player) && mmoPlayer.getAcrobaticsManager().canGainRollXP())
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE); SkillUtils.applyXpGain(mmoPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE);
//} //}
addFallLocation(player); addFallLocation(player);
return modifiedDamage; return modifiedDamage;
} }
else if (!isFatal(player, damage)) { else if (!isFatal(player, damage)) {
//if (!SkillUtils.cooldownExpired((long) mcMMOPlayer.getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) { //if (!SkillUtils.cooldownExpired((long) mmoPlayer.getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) {
if(!isExploiting(player) && mcMMOPlayer.getAcrobaticsManager().canGainRollXP()) if(!isExploiting(player) && mmoPlayer.getAcrobaticsManager().canGainRollXP())
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, false), XPGainReason.PVE); SkillUtils.applyXpGain(mmoPlayer, getPrimarySkill(), calculateRollXP(player, damage, false), XPGainReason.PVE);
//} //}
} }
@ -222,8 +221,8 @@ public class Roll extends AcrobaticsSubSkill {
return damage; return damage;
} }
private int getActivationChance(McMMOPlayer mcMMOPlayer) { private int getActivationChance(McMMOPlayer mmoPlayer) {
return PerksUtils.handleLuckyPerks(mcMMOPlayer.getPlayer(), getPrimarySkill()); return PerksUtils.handleLuckyPerks(mmoPlayer.getPlayer(), getPrimarySkill());
} }
/** /**
@ -232,7 +231,7 @@ public class Roll extends AcrobaticsSubSkill {
* @param damage The amount of damage initially dealt by the event * @param damage The amount of damage initially dealt by the event
* @return the modified event damage if the ability was successful, the original event damage otherwise * @return the modified event damage if the ability was successful, the original event damage otherwise
*/ */
private double gracefulRollCheck(Player player, McMMOPlayer mcMMOPlayer, double damage, int skillLevel) { private double gracefulRollCheck(Player player, McMMOPlayer mmoPlayer, double damage, int skillLevel) {
double modifiedDamage = calculateModifiedRollDamage(damage, AdvancedConfig.getInstance().getRollDamageThreshold() * 2); double modifiedDamage = calculateModifiedRollDamage(damage, AdvancedConfig.getInstance().getRollDamageThreshold() * 2);
RandomChanceSkill rcs = new RandomChanceSkill(player, subSkillType); RandomChanceSkill rcs = new RandomChanceSkill(player, subSkillType);
@ -243,15 +242,15 @@ public class Roll extends AcrobaticsSubSkill {
{ {
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Ability.Proc"); NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Ability.Proc");
SoundManager.sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS,0.5F); SoundManager.sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS,0.5F);
if(!isExploiting(player) && mcMMOPlayer.getAcrobaticsManager().canGainRollXP()) if(!isExploiting(player) && mmoPlayer.getAcrobaticsManager().canGainRollXP())
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE); SkillUtils.applyXpGain(mmoPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE);
addFallLocation(player); addFallLocation(player);
return modifiedDamage; return modifiedDamage;
} }
else if (!isFatal(player, damage)) { else if (!isFatal(player, damage)) {
if(!isExploiting(player) && mcMMOPlayer.getAcrobaticsManager().canGainRollXP()) if(!isExploiting(player) && mmoPlayer.getAcrobaticsManager().canGainRollXP())
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, false), XPGainReason.PVE); SkillUtils.applyXpGain(mmoPlayer, getPrimarySkill(), calculateRollXP(player, damage, false), XPGainReason.PVE);
addFallLocation(player); addFallLocation(player);
} }
@ -270,19 +269,19 @@ public class Roll extends AcrobaticsSubSkill {
return false; return false;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
if (ItemUtils.hasItemInEitherHand(player, Material.ENDER_PEARL) || player.isInsideVehicle()) { if (ItemUtils.hasItemInEitherHand(player, Material.ENDER_PEARL) || player.isInsideVehicle()) {
if(mcMMOPlayer.isDebugMode()) { if(mmoPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage("Acrobatics XP Prevented: Ender Pearl or Inside Vehicle"); mmoPlayer.getPlayer().sendMessage("Acrobatics XP Prevented: Ender Pearl or Inside Vehicle");
} }
return true; return true;
} }
if(UserManager.getPlayer(player).getAcrobaticsManager().hasFallenInLocationBefore(getBlockLocation(player))) if(mcMMO.getUserManager().getPlayer(player).getAcrobaticsManager().hasFallenInLocationBefore(getBlockLocation(player)))
{ {
if(mcMMOPlayer.isDebugMode()) { if(mmoPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage("Acrobatics XP Prevented: Fallen in location before"); mmoPlayer.getPlayer().sendMessage("Acrobatics XP Prevented: Fallen in location before");
} }
return true; return true;
@ -421,7 +420,7 @@ public class Roll extends AcrobaticsSubSkill {
public void addFallLocation(Player player) public void addFallLocation(Player player)
{ {
UserManager.getPlayer(player).getAcrobaticsManager().addLocationToFallMap(getBlockLocation(player)); mcMMO.getUserManager().getPlayer(player).getAcrobaticsManager().addLocationToFallMap(getBlockLocation(player));
} }
public Location getBlockLocation(Player player) public Location getBlockLocation(Player player)

View File

@ -0,0 +1,9 @@
package com.gmail.nossr50.datatypes.validation;
public class NonNullRule<T> extends Rule<T> {
@Override
public void applyRule(T object) throws Exception {
if(object == null)
throw new NullPointerException();
}
}

View File

@ -0,0 +1,11 @@
package com.gmail.nossr50.datatypes.validation;
import com.gmail.nossr50.api.exceptions.UnexpectedValueException;
public class PositiveIntegerRule<T extends Number> extends Rule<T> {
@Override
public void applyRule(T number) throws Exception {
if(number.intValue() < 0)
throw new UnexpectedValueException();
}
}

View File

@ -0,0 +1,5 @@
package com.gmail.nossr50.datatypes.validation;
public abstract class Rule<T> {
public abstract void applyRule(T object) throws Exception;
}

View File

@ -0,0 +1,12 @@
package com.gmail.nossr50.datatypes.validation;
public interface Validates<T> {
/**
* Perform a validation check on this object
* Returns the value if validation passes
* @return the object
* @throws Exception if the object fails validation
* @param object
*/
T validate(T object) throws Exception;
}

View File

@ -0,0 +1,25 @@
package com.gmail.nossr50.datatypes.validation;
import java.util.ArrayList;
import java.util.List;
public class Validator<T> implements Validates<T> {
private List<Rule<T>> rulesList;
public Validator() {
this.rulesList = new ArrayList<>();
}
@Override
public T validate(T object) throws Exception {
for(Rule<T> rule : rulesList) {
rule.applyRule(object);
}
return object;
}
public void addRule(Rule<T> newRule) {
rulesList.add(newRule);
}
}

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.events.experience;
import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -22,14 +21,14 @@ public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements
protected McMMOPlayerExperienceEvent(Player player, PrimarySkillType skill) { protected McMMOPlayerExperienceEvent(Player player, PrimarySkillType skill) {
super(player); super(player);
this.skill = skill; this.skill = skill;
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill); this.skillLevel = mcMMO.getUserManager().getPlayer(player).getSkillLevel(skill);
this.xpGainReason = XPGainReason.UNKNOWN; this.xpGainReason = XPGainReason.UNKNOWN;
} }
protected McMMOPlayerExperienceEvent(Player player, PrimarySkillType skill, XPGainReason xpGainReason) { protected McMMOPlayerExperienceEvent(Player player, PrimarySkillType skill, XPGainReason xpGainReason) {
super(player); super(player);
this.skill = skill; this.skill = skill;
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill); this.skillLevel = mcMMO.getUserManager().getPlayer(player).getSkillLevel(skill);
this.xpGainReason = xpGainReason; this.xpGainReason = xpGainReason;
} }

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.events.skills; package com.gmail.nossr50.events.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerEvent;
@ -17,7 +16,7 @@ public abstract class McMMOPlayerSkillEvent extends PlayerEvent {
protected McMMOPlayerSkillEvent(Player player, PrimarySkillType skill) { protected McMMOPlayerSkillEvent(Player player, PrimarySkillType skill) {
super(player); super(player);
this.skill = skill; this.skill = skill;
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill); this.skillLevel = mcMMO.getUserManager().getPlayer(player).getSkillLevel(skill);
} }
/** /**

View File

@ -23,7 +23,6 @@ import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
@ -211,7 +210,7 @@ public class BlockListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) { if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return; return;
} }
@ -224,16 +223,16 @@ public class BlockListener implements Listener {
mcMMO.getPlaceStore().setTrue(blockState); mcMMO.getPlaceStore().setTrue(blockState);
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
if(mcMMOPlayer == null) if(mmoPlayer == null)
return; return;
if (blockState.getType() == Repair.anvilMaterial && PrimarySkillType.REPAIR.getPermissions(player)) { if (blockState.getType() == Repair.anvilMaterial && PrimarySkillType.REPAIR.getPermissions(player)) {
mcMMOPlayer.getRepairManager().placedAnvilCheck(); mmoPlayer.getRepairManager().placedAnvilCheck();
} }
else if (blockState.getType() == Salvage.anvilMaterial && PrimarySkillType.SALVAGE.getPermissions(player)) { else if (blockState.getType() == Salvage.anvilMaterial && PrimarySkillType.SALVAGE.getPermissions(player)) {
mcMMOPlayer.getSalvageManager().placedAnvilCheck(); mmoPlayer.getSalvageManager().placedAnvilCheck();
} }
} }
@ -250,7 +249,7 @@ public class BlockListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) { if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return; return;
} }
@ -317,25 +316,25 @@ public class BlockListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) { if (!mcMMO.getUserManager().hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return; return;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
//Check if profile is loaded //Check if profile is loaded
if(mcMMOPlayer == null) if(mmoPlayer == null)
return; return;
ItemStack heldItem = player.getInventory().getItemInMainHand(); ItemStack heldItem = player.getInventory().getItemInMainHand();
/* HERBALISM */ /* HERBALISM */
if (BlockUtils.affectedByGreenTerra(blockState)) { if (BlockUtils.affectedByGreenTerra(blockState)) {
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager(); HerbalismManager herbalismManager = mmoPlayer.getHerbalismManager();
/* Green Terra */ /* Green Terra */
if (herbalismManager.canActivateAbility()) { if (herbalismManager.canActivateAbility()) {
mcMMOPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.HERBALISM); mmoPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.HERBALISM);
} }
/* /*
@ -354,13 +353,13 @@ public class BlockListener implements Listener {
/* MINING */ /* MINING */
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && PrimarySkillType.MINING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) { else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && PrimarySkillType.MINING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
MiningManager miningManager = mcMMOPlayer.getMiningManager(); MiningManager miningManager = mmoPlayer.getMiningManager();
miningManager.miningBlockCheck(blockState); miningManager.miningBlockCheck(blockState);
} }
/* WOOD CUTTING */ /* WOOD CUTTING */
else if (BlockUtils.isLog(blockState) && ItemUtils.isAxe(heldItem) && PrimarySkillType.WOODCUTTING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) { else if (BlockUtils.isLog(blockState) && ItemUtils.isAxe(heldItem) && PrimarySkillType.WOODCUTTING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager(); WoodcuttingManager woodcuttingManager = mmoPlayer.getWoodcuttingManager();
if (woodcuttingManager.canUseTreeFeller(heldItem)) { if (woodcuttingManager.canUseTreeFeller(heldItem)) {
woodcuttingManager.processTreeFeller(blockState); woodcuttingManager.processTreeFeller(blockState);
} }
@ -371,10 +370,10 @@ public class BlockListener implements Listener {
/* EXCAVATION */ /* EXCAVATION */
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && PrimarySkillType.EXCAVATION.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) { else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && PrimarySkillType.EXCAVATION.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager(); ExcavationManager excavationManager = mmoPlayer.getExcavationManager();
excavationManager.excavationBlockCheck(blockState); excavationManager.excavationBlockCheck(blockState);
if (mcMMOPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER)) { if (mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER)) {
excavationManager.gigaDrillBreaker(blockState); excavationManager.gigaDrillBreaker(blockState);
} }
} }
@ -407,12 +406,12 @@ public class BlockListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) { if (!mcMMO.getUserManager().hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return; return;
} }
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
return; return;
} }
@ -421,7 +420,7 @@ public class BlockListener implements Listener {
ItemStack heldItem = player.getInventory().getItemInMainHand(); ItemStack heldItem = player.getInventory().getItemInMainHand();
if (ItemUtils.isSword(heldItem)) { if (ItemUtils.isSword(heldItem)) {
HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager(); HerbalismManager herbalismManager = mcMMO.getUserManager().getPlayer(player).getHerbalismManager();
if (herbalismManager.canUseHylianLuck()) { if (herbalismManager.canUseHylianLuck()) {
if (herbalismManager.processHylianLuck(blockState)) { if (herbalismManager.processHylianLuck(blockState)) {
@ -436,7 +435,7 @@ public class BlockListener implements Listener {
} }
} }
/*else if (!heldItem.containsEnchantment(Enchantment.SILK_TOUCH)) { /*else if (!heldItem.containsEnchantment(Enchantment.SILK_TOUCH)) {
SmeltingManager smeltingManager = UserManager.getPlayer(player).getSmeltingManager(); SmeltingManager smeltingManager = mcMMO.getUserManager().getPlayer(player).getSmeltingManager();
if (smeltingManager.canUseFluxMining(blockState)) { if (smeltingManager.canUseFluxMining(blockState)) {
if (smeltingManager.processFluxMining(blockState)) { if (smeltingManager.processFluxMining(blockState)) {
@ -471,14 +470,14 @@ public class BlockListener implements Listener {
if (event instanceof FakeBlockDamageEvent) { if (event instanceof FakeBlockDamageEvent) {
return; return;
} }
if (!UserManager.hasPlayerDataKey(player)) { if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return; return;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
//Profile not loaded //Profile not loaded
if(mcMMOPlayer == null) if(mmoPlayer == null)
{ {
return; return;
} }
@ -491,25 +490,25 @@ public class BlockListener implements Listener {
if (BlockUtils.canActivateAbilities(blockState)) { if (BlockUtils.canActivateAbilities(blockState)) {
ItemStack heldItem = player.getInventory().getItemInMainHand(); ItemStack heldItem = player.getInventory().getItemInMainHand();
if (mcMMOPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.GREEN_TERRA_TOOL) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) { if (mmoPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.GREEN_TERRA_TOOL) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
mcMMOPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.HERBALISM); mmoPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.HERBALISM);
} }
else if (mcMMOPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.SKULL_SPLITTER_TOOL) && ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState) && Permissions.treeFeller(player)) { else if (mmoPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.SKULL_SPLITTER_TOOL) && ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState) && Permissions.treeFeller(player)) {
mcMMOPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.WOODCUTTING); mmoPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.WOODCUTTING);
} }
else if (mcMMOPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.SUPER_BREAKER_TOOL) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) { else if (mmoPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.SUPER_BREAKER_TOOL) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
mcMMOPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.MINING); mmoPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.MINING);
} }
else if (mcMMOPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.GIGA_DRILL_BREAKER_TOOL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) { else if (mmoPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.GIGA_DRILL_BREAKER_TOOL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
mcMMOPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.EXCAVATION); mmoPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.EXCAVATION);
} }
else if (mcMMOPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.BERSERK_TOOL) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState) else if (mmoPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.BERSERK_TOOL) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState)
|| mcMMO.getMaterialMapStore().isGlass(blockState.getType()) || mcMMO.getMaterialMapStore().isGlass(blockState.getType())
|| blockState.getType() == Material.SNOW || blockState.getType() == Material.SNOW
|| BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) { || BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) {
mcMMOPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.UNARMED); mmoPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.UNARMED);
if(mcMMOPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.BERSERK)) { if(mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.BERSERK)) {
if (SuperAbilityType.BERSERK.blockCheck(blockState) && EventUtils.simulateBlockBreak(blockState.getBlock(), player, true)) { if (SuperAbilityType.BERSERK.blockCheck(blockState) && EventUtils.simulateBlockBreak(blockState.getBlock(), player, true)) {
event.setInstaBreak(true); event.setInstaBreak(true);
@ -528,7 +527,7 @@ public class BlockListener implements Listener {
* *
* We don't need to check permissions here because they've already been checked for the ability to even activate. * We don't need to check permissions here because they've already been checked for the ability to even activate.
*/ */
if (mcMMOPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.TREE_FELLER) && BlockUtils.isLog(blockState) && Config.getInstance().getTreeFellerSoundsEnabled()) { if (mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.TREE_FELLER) && BlockUtils.isLog(blockState) && Config.getInstance().getTreeFellerSoundsEnabled()) {
SoundManager.sendSound(player, blockState.getLocation(), SoundType.FIZZ); SoundManager.sendSound(player, blockState.getLocation(), SoundType.FIZZ);
} }
} }
@ -557,14 +556,14 @@ public class BlockListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) { if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return; return;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
return; return;
} }
@ -578,14 +577,14 @@ public class BlockListener implements Listener {
* *
* We don't need to check permissions here because they've already been checked for the ability to even activate. * We don't need to check permissions here because they've already been checked for the ability to even activate.
*/ */
if (mcMMOPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState)) { if (mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState)) {
if (mcMMOPlayer.getHerbalismManager().processGreenTerraBlockConversion(blockState)) { if (mmoPlayer.getHerbalismManager().processGreenTerraBlockConversion(blockState)) {
blockState.update(true); blockState.update(true);
} }
} }
else if (mcMMOPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.BERSERK) && (heldItem.getType() == Material.AIR || Config.getInstance().getUnarmedItemsAsUnarmed())) { else if (mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.BERSERK) && (heldItem.getType() == Material.AIR || Config.getInstance().getUnarmedItemsAsUnarmed())) {
if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState)) { if (mmoPlayer.getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState)) {
if (EventUtils.simulateBlockBreak(block, player, true) && mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) { if (EventUtils.simulateBlockBreak(block, player, true) && mmoPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
blockState.update(); blockState.update();
} }
} }
@ -599,7 +598,7 @@ public class BlockListener implements Listener {
} }
} }
} }
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isLeaves(blockState) && EventUtils.simulateBlockBreak(block, player, true)) { else if (mmoPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isLeaves(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
event.setInstaBreak(true); event.setInstaBreak(true);
SoundManager.sendSound(player, block.getLocation(), SoundType.POP); SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
} }
@ -608,10 +607,10 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onBlockDamageCleanup(BlockDamageEvent event) { public void onBlockDamageCleanup(BlockDamageEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
return; return;
} }
@ -620,7 +619,7 @@ public class BlockListener implements Listener {
ItemStack heldItem = player.getInventory().getItemInMainHand(); ItemStack heldItem = player.getInventory().getItemInMainHand();
cleanupAbilityTools(player, mcMMOPlayer, blockState, heldItem); cleanupAbilityTools(player, mmoPlayer, blockState, heldItem);
debugStickDump(player, blockState); debugStickDump(player, blockState);
} }
@ -629,19 +628,19 @@ public class BlockListener implements Listener {
//TODO: Convert into locale strings //TODO: Convert into locale strings
private void debugStickDump(Player player, BlockState blockState) { private void debugStickDump(Player player, BlockState blockState) {
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
return; return;
} }
if(UserManager.getPlayer(player).isDebugMode()) if(mcMMO.getUserManager().getPlayer(player).isDebugMode())
{ {
if(mcMMO.getPlaceStore().isTrue(blockState)) if(mcMMO.getPlaceStore().isTrue(blockState))
player.sendMessage("[mcMMO DEBUG] This block is not natural and does not reward treasures/XP"); player.sendMessage("[mcMMO DEBUG] This block is not natural and does not reward treasures/XP");
else else
{ {
player.sendMessage("[mcMMO DEBUG] This block is considered natural by mcMMO"); player.sendMessage("[mcMMO DEBUG] This block is considered natural by mcMMO");
UserManager.getPlayer(player).getExcavationManager().printExcavationDebug(player, blockState); mcMMO.getUserManager().getPlayer(player).getExcavationManager().printExcavationDebug(player, blockState);
} }
if(WorldGuardUtils.isWorldGuardLoaded()) if(WorldGuardUtils.isWorldGuardLoaded())
@ -680,13 +679,13 @@ public class BlockListener implements Listener {
} }
} }
private void cleanupAbilityTools(Player player, McMMOPlayer mcMMOPlayer, BlockState blockState, ItemStack heldItem) { private void cleanupAbilityTools(Player player, McMMOPlayer mmoPlayer, BlockState blockState, ItemStack heldItem) {
if (HiddenConfig.getInstance().useEnchantmentBuffs()) { if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER))) { if ((ItemUtils.isPickaxe(heldItem) && !mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER))) {
SkillUtils.removeAbilityBuff(heldItem); SkillUtils.removeAbilityBuff(heldItem);
} }
} else { } else {
if ((mcMMOPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.SUPER_BREAKER) && !BlockUtils.affectedBySuperBreaker(blockState)) || (mcMMOPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER) && !BlockUtils.affectedByGigaDrillBreaker(blockState))) { if ((mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.SUPER_BREAKER) && !BlockUtils.affectedBySuperBreaker(blockState)) || (mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER) && !BlockUtils.affectedByGigaDrillBreaker(blockState))) {
SkillUtils.handleAbilitySpeedDecrease(player); SkillUtils.handleAbilitySpeedDecrease(player);
} }
} }

View File

@ -13,7 +13,6 @@ import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent; import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.events.fake.FakeEntityTameEvent; import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.skills.archery.Archery; import com.gmail.nossr50.skills.archery.Archery;
import com.gmail.nossr50.skills.mining.BlastMining; import com.gmail.nossr50.skills.mining.BlastMining;
import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.mining.MiningManager;
@ -25,7 +24,6 @@ import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.NotificationManager; 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.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
@ -172,12 +170,12 @@ public class EntityListener implements Listener {
//Crossbow only //Crossbow only
if(isCrossbow) { if(isCrossbow) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
//Process launch event //Process launch event
if(Permissions.skillEnabled(player, PrimarySkillType.CROSSBOWS)) { if(Permissions.skillEnabled(player, PrimarySkillType.CROSSBOWS)) {
if(mcMMOPlayer != null) { if(mmoPlayer != null) {
mcMMOPlayer.getCrossbowManager().processProjectileLaunchEvent(event); mmoPlayer.getCrossbowManager().processProjectileLaunchEvent(event);
} }
} }
@ -430,9 +428,9 @@ public class EntityListener implements Listener {
} }
//Deflect checks //Deflect checks
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(defendingPlayer); final McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(defendingPlayer);
if (mcMMOPlayer != null) { if (mmoPlayer != null) {
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager(); UnarmedManager unarmedManager = mmoPlayer.getUnarmedManager();
if (unarmedManager.canDeflect()) { if (unarmedManager.canDeflect()) {
if (unarmedManager.deflectCheck()) { if (unarmedManager.deflectCheck()) {
@ -492,7 +490,7 @@ public class EntityListener implements Listener {
} }
public boolean checkParties(Cancellable event, Player defendingPlayer, Player attackingPlayer) { public boolean checkParties(Cancellable event, Player defendingPlayer, Player attackingPlayer) {
if (!UserManager.hasPlayerDataKey(defendingPlayer) || !UserManager.hasPlayerDataKey(attackingPlayer)) { if (!mcMMO.getUserManager().hasPlayerDataKey(defendingPlayer) || !mcMMO.getUserManager().hasPlayerDataKey(attackingPlayer)) {
return true; return true;
} }
@ -504,8 +502,8 @@ public class EntityListener implements Listener {
//Party Friendly Fire //Party Friendly Fire
if(!Config.getInstance().getPartyFriendlyFire()) if(!Config.getInstance().getPartyFriendlyFire())
if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer) if ((mcMMO.getPartyManager().inSameParty(defendingPlayer, attackingPlayer)
|| PartyManager.areAllies(defendingPlayer, attackingPlayer)) || mcMMO.getPartyManager().areAllies(defendingPlayer, attackingPlayer))
&& !(Permissions.friendlyFire(attackingPlayer) && !(Permissions.friendlyFire(attackingPlayer)
&& Permissions.friendlyFire(defendingPlayer))) { && Permissions.friendlyFire(defendingPlayer))) {
event.setCancelled(true); event.setCancelled(true);
@ -582,24 +580,24 @@ public class EntityListener implements Listener {
if (livingEntity instanceof Player) { if (livingEntity instanceof Player) {
Player player = (Player) entity; Player player = (Player) entity;
if (!UserManager.hasPlayerDataKey(player)) { if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return; return;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
//Profile not loaded //Profile not loaded
if(mcMMOPlayer == null) if(mmoPlayer == null)
return; return;
/* Check for invincibility */ /* Check for invincibility */
if (mcMMOPlayer.getGodMode()) { if (mmoPlayer.getGodMode()) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
if (event.getFinalDamage() >= 1) { if (event.getFinalDamage() >= 1) {
mcMMOPlayer.actualizeRecentlyHurt(); mmoPlayer.actualizeRecentlyHurtTimestamp();
} }
} }
@ -624,12 +622,12 @@ public class EntityListener implements Listener {
Wolf wolf = (Wolf) pet; Wolf wolf = (Wolf) pet;
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
return; return;
} }
TamingManager tamingManager = UserManager.getPlayer(player).getTamingManager(); TamingManager tamingManager = mcMMO.getUserManager().getPlayer(player).getTamingManager();
switch (cause) { switch (cause) {
case CONTACT: case CONTACT:
@ -822,12 +820,12 @@ public class EntityListener implements Listener {
// using this exact metadata // using this exact metadata
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString()); Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
if (!UserManager.hasPlayerDataKey(player)) { if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return; return;
} }
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
return; return;
} }
@ -839,7 +837,7 @@ public class EntityListener implements Listener {
return; return;
} }
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager(); MiningManager miningManager = mcMMO.getUserManager().getPlayer(player).getMiningManager();
if (miningManager.canUseBiggerBombs()) { if (miningManager.canUseBiggerBombs()) {
event.setRadius(miningManager.biggerBombs(event.getRadius())); event.setRadius(miningManager.biggerBombs(event.getRadius()));
@ -868,7 +866,7 @@ public class EntityListener implements Listener {
// using this exact metadata // using this exact metadata
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString()); Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
if (!UserManager.hasPlayerDataKey(player)) { if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return; return;
} }
@ -880,12 +878,12 @@ public class EntityListener implements Listener {
} }
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
return; return;
} }
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager(); MiningManager miningManager = mcMMO.getUserManager().getPlayer(player).getMiningManager();
if (miningManager.canUseBlastMining()) { if (miningManager.canUseBlastMining()) {
miningManager.blastMiningDropProcessing(event.getYield(), event); miningManager.blastMiningDropProcessing(event.getYield(), event);
@ -914,7 +912,7 @@ public class EntityListener implements Listener {
Player player = (Player) entity; Player player = (Player) entity;
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
return; return;
} }
@ -926,7 +924,7 @@ public class EntityListener implements Listener {
return; return;
} }
if (!UserManager.hasPlayerDataKey(player)) { if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return; return;
} }
@ -979,7 +977,7 @@ public class EntityListener implements Listener {
* 1000 * 1000
*/ */
if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) { if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) {
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel)); event.setFoodLevel(mcMMO.getUserManager().getPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel));
} }
return; return;
@ -991,7 +989,7 @@ public class EntityListener implements Listener {
*/ */
case POTATO: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ case POTATO: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) { if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) {
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel)); event.setFoodLevel(mcMMO.getUserManager().getPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel));
} }
return; return;
case COD: case COD:
@ -1001,7 +999,7 @@ public class EntityListener implements Listener {
case COOKED_SALMON: case COOKED_SALMON:
if (Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_FISHERMANS_DIET)) { if (Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_FISHERMANS_DIET)) {
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(newFoodLevel)); event.setFoodLevel(mcMMO.getUserManager().getPlayer(player).getFishingManager().handleFishermanDiet(newFoodLevel));
} }
return; return;
@ -1036,19 +1034,19 @@ public class EntityListener implements Listener {
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();
if (!UserManager.hasPlayerDataKey(player) || Misc.isNPCEntityExcludingVillagers(entity) || entity.hasMetadata(mcMMO.entityMetadataKey)) { if (!mcMMO.getUserManager().hasPlayerDataKey(player) || Misc.isNPCEntityExcludingVillagers(entity) || entity.hasMetadata(mcMMO.entityMetadataKey)) {
return; return;
} }
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
return; return;
} }
UserManager.getPlayer(player).getTamingManager().awardTamingXP(entity); mcMMO.getUserManager().getPlayer(player).getTamingManager().awardTamingXP(entity);
} }
/** /**
@ -1081,7 +1079,7 @@ public class EntityListener implements Listener {
Tameable tameable = (Tameable) entity; Tameable tameable = (Tameable) entity;
if (!UserManager.hasPlayerDataKey(player) || !CombatUtils.isFriendlyPet(player, tameable)) { if (!mcMMO.getUserManager().hasPlayerDataKey(player) || !CombatUtils.isFriendlyPet(player, tameable)) {
return; return;
} }

View File

@ -12,7 +12,6 @@ import com.gmail.nossr50.skills.alchemy.Alchemy;
import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer; import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardManager;
import com.gmail.nossr50.worldguard.WorldGuardUtils; import com.gmail.nossr50.worldguard.WorldGuardUtils;
@ -67,12 +66,12 @@ public class InventoryListener implements Listener {
} }
//Profile doesn't exist //Profile doesn't exist
if(UserManager.getOfflinePlayer(offlinePlayer) == null) if(mcMMO.getUserManager().getOfflinePlayer(offlinePlayer) == null)
{ {
return; return;
} }
event.setBurnTime(UserManager.getPlayer(player).getSmeltingManager().fuelEfficiency(event.getBurnTime())); event.setBurnTime(mcMMO.getUserManager().getPlayer(player).getSmeltingManager().fuelEfficiency(event.getBurnTime()));
} }
} }
@ -97,7 +96,7 @@ public class InventoryListener implements Listener {
if(offlinePlayer != null) { if(offlinePlayer != null) {
McMMOPlayer offlineProfile = UserManager.getOfflinePlayer(offlinePlayer); McMMOPlayer offlineProfile = mcMMO.getUserManager().getOfflinePlayer(offlinePlayer);
//Profile doesn't exist //Profile doesn't exist
if(offlineProfile != null) { if(offlineProfile != null) {
@ -129,18 +128,18 @@ public class InventoryListener implements Listener {
return; return;
} }
if (!UserManager.hasPlayerDataKey(player) || !Permissions.vanillaXpBoost(player, PrimarySkillType.SMELTING)) { if (!mcMMO.getUserManager().hasPlayerDataKey(player) || !Permissions.vanillaXpBoost(player, PrimarySkillType.SMELTING)) {
return; return;
} }
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
return; return;
} }
int xpToDrop = event.getExpToDrop(); int xpToDrop = event.getExpToDrop();
int exp = UserManager.getPlayer(player).getSmeltingManager().vanillaXPBoost(xpToDrop); int exp = mcMMO.getUserManager().getPlayer(player).getSmeltingManager().vanillaXPBoost(xpToDrop);
event.setExpToDrop(exp); event.setExpToDrop(exp);
} }
} }
@ -182,7 +181,7 @@ public class InventoryListener implements Listener {
HumanEntity whoClicked = event.getWhoClicked(); HumanEntity whoClicked = event.getWhoClicked();
if (!UserManager.hasPlayerDataKey(event.getWhoClicked()) || !Permissions.isSubSkillEnabled(whoClicked, SubSkillType.ALCHEMY_CONCOCTIONS)) { if (!mcMMO.getUserManager().hasPlayerDataKey(event.getWhoClicked()) || !Permissions.isSubSkillEnabled(whoClicked, SubSkillType.ALCHEMY_CONCOCTIONS)) {
return; return;
} }
@ -295,7 +294,7 @@ public class InventoryListener implements Listener {
HumanEntity whoClicked = event.getWhoClicked(); HumanEntity whoClicked = event.getWhoClicked();
if (!UserManager.hasPlayerDataKey(event.getWhoClicked()) || !Permissions.isSubSkillEnabled(whoClicked, SubSkillType.ALCHEMY_CONCOCTIONS)) { if (!mcMMO.getUserManager().hasPlayerDataKey(event.getWhoClicked()) || !Permissions.isSubSkillEnabled(whoClicked, SubSkillType.ALCHEMY_CONCOCTIONS)) {
return; return;
} }

View File

@ -22,7 +22,6 @@ import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.salvage.Salvage; import com.gmail.nossr50.skills.salvage.Salvage;
import com.gmail.nossr50.skills.salvage.SalvageManager; import com.gmail.nossr50.skills.salvage.SalvageManager;
import com.gmail.nossr50.util.*; import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
@ -87,17 +86,17 @@ public class PlayerListener implements Listener {
return; return;
} }
if (!UserManager.hasPlayerDataKey(player) || Config.getInstance().getXPAfterTeleportCooldown() <= 0 || event.getFrom().equals(event.getTo())) { if (!mcMMO.getUserManager().hasPlayerDataKey(player) || Config.getInstance().getXPAfterTeleportCooldown() <= 0 || event.getFrom().equals(event.getTo())) {
return; return;
} }
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
return; return;
} }
UserManager.getPlayer(player).actualizeTeleportATS(); mcMMO.getUserManager().getPlayer(player).actualizeTeleportATS();
} }
/** /**
* Handle PlayerDeathEvents at the lowest priority. * Handle PlayerDeathEvents at the lowest priority.
@ -197,20 +196,20 @@ public class PlayerListener implements Listener {
public void onPlayerWorldChange(PlayerChangedWorldEvent event) { public void onPlayerWorldChange(PlayerChangedWorldEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) { if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return; return;
} }
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
return; return;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
mcMMOPlayer.checkGodMode(); mmoPlayer.checkGodMode();
mcMMOPlayer.checkParty(); mmoPlayer.checkParty();
} }
/** /**
@ -268,17 +267,17 @@ public class PlayerListener implements Listener {
return; return;
} }
if (!UserManager.hasPlayerDataKey(player) || !PrimarySkillType.FISHING.getPermissions(player)) { if (!mcMMO.getUserManager().hasPlayerDataKey(player) || !PrimarySkillType.FISHING.getPermissions(player)) {
return; return;
} }
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
return; return;
} }
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager(); FishingManager fishingManager = mcMMO.getUserManager().getPlayer(player).getFishingManager();
switch (event.getState()) { switch (event.getState()) {
case CAUGHT_FISH: case CAUGHT_FISH:
@ -346,18 +345,18 @@ public class PlayerListener implements Listener {
return; return;
} }
if (!UserManager.hasPlayerDataKey(player) || !PrimarySkillType.FISHING.getPermissions(player)) { if (!mcMMO.getUserManager().hasPlayerDataKey(player) || !PrimarySkillType.FISHING.getPermissions(player)) {
return; return;
} }
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
return; return;
} }
Entity caught = event.getCaught(); Entity caught = event.getCaught();
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager(); FishingManager fishingManager = mcMMO.getUserManager().getPlayer(player).getFishingManager();
//Track the hook //Track the hook
if(ExperienceConfig.getInstance().isFishingExploitingPrevented()) if(ExperienceConfig.getInstance().isFishingExploitingPrevented())
@ -441,17 +440,17 @@ public class PlayerListener implements Listener {
return; return;
} }
if (!UserManager.hasPlayerDataKey(player)) { if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return; return;
} }
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
return; return;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
Item drop = event.getItem(); Item drop = event.getItem();
ItemStack dropStack = drop.getItemStack(); ItemStack dropStack = drop.getItemStack();
@ -469,8 +468,8 @@ public class PlayerListener implements Listener {
return; return;
} }
if (!drop.hasMetadata(mcMMO.droppedItemKey) && mcMMOPlayer.inParty() && ItemUtils.isSharable(dropStack)) { if (!drop.hasMetadata(mcMMO.droppedItemKey) && mmoPlayer.inParty() && ItemUtils.isSharable(dropStack)) {
event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer)); event.setCancelled(ShareHandler.handleItemShare(drop, mmoPlayer));
if (event.isCancelled()) { if (event.isCancelled()) {
SoundManager.sendSound(player, player.getLocation(), SoundType.POP); SoundManager.sendSound(player, player.getLocation(), SoundType.POP);
@ -503,20 +502,23 @@ public class PlayerListener implements Listener {
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) { if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return; return;
} }
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
return; return;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); //No need for null checks here
//There's an issue with using Async saves on player quit McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
//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 //TODO: There's an issue with using Async saves on player quit
mcMMOPlayer.logout(true); //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);
mcMMO.getUserManager().cleanupPlayer(mmoPlayer); //Handles cleaning up the player when their profile is no longer needed
} }
/** /**
@ -557,17 +559,17 @@ public class PlayerListener implements Listener {
public void onPlayerRespawn(PlayerRespawnEvent event) { public void onPlayerRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) { if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return; return;
} }
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
return; return;
} }
UserManager.getPlayer(player).actualizeRespawnATS(); mcMMO.getUserManager().getPlayer(player).actualizeRespawnATS();
} }
/** /**
@ -604,18 +606,18 @@ public class PlayerListener implements Listener {
} }
} }
if (event.getHand() != EquipmentSlot.HAND || !UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) { if (event.getHand() != EquipmentSlot.HAND || !mcMMO.getUserManager().hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return; return;
} }
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
return; return;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
MiningManager miningManager = mcMMOPlayer.getMiningManager(); MiningManager miningManager = mmoPlayer.getMiningManager();
ItemStack heldItem = player.getInventory().getItemInMainHand(); ItemStack heldItem = player.getInventory().getItemInMainHand();
switch (event.getAction()) { switch (event.getAction()) {
@ -628,7 +630,7 @@ public class PlayerListener implements Listener {
&& PrimarySkillType.REPAIR.getPermissions(player) && PrimarySkillType.REPAIR.getPermissions(player)
&& mcMMO.getRepairableManager().isRepairable(heldItem) && mcMMO.getRepairableManager().isRepairable(heldItem)
&& heldItem.getAmount() <= 1) { && heldItem.getAmount() <= 1) {
RepairManager repairManager = mcMMOPlayer.getRepairManager(); RepairManager repairManager = mmoPlayer.getRepairManager();
event.setCancelled(true); event.setCancelled(true);
// Make sure the player knows what he's doing when trying to repair an enchanted item // Make sure the player knows what he's doing when trying to repair an enchanted item
@ -643,7 +645,7 @@ public class PlayerListener implements Listener {
&& RankUtils.hasUnlockedSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR) && RankUtils.hasUnlockedSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR)
&& mcMMO.getSalvageableManager().isSalvageable(heldItem) && mcMMO.getSalvageableManager().isSalvageable(heldItem)
&& heldItem.getAmount() <= 1) { && heldItem.getAmount() <= 1) {
SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager(); SalvageManager salvageManager = mcMMO.getUserManager().getPlayer(player).getSalvageManager();
event.setCancelled(true); event.setCancelled(true);
// Make sure the player knows what he's doing when trying to salvage an enchanted item // Make sure the player knows what he's doing when trying to salvage an enchanted item
@ -673,7 +675,7 @@ public class PlayerListener implements Listener {
if (!Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) { if (!Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
/* REPAIR CHECKS */ /* REPAIR CHECKS */
if (type == Repair.anvilMaterial && PrimarySkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) { if (type == Repair.anvilMaterial && PrimarySkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
RepairManager repairManager = mcMMOPlayer.getRepairManager(); RepairManager repairManager = mmoPlayer.getRepairManager();
// Cancel repairing an enchanted item // Cancel repairing an enchanted item
if (repairManager.checkConfirmation(false)) { if (repairManager.checkConfirmation(false)) {
@ -683,7 +685,7 @@ public class PlayerListener implements Listener {
} }
/* SALVAGE CHECKS */ /* SALVAGE CHECKS */
else if (type == Salvage.anvilMaterial && PrimarySkillType.SALVAGE.getPermissions(player) && mcMMO.getSalvageableManager().isSalvageable(heldItem)) { else if (type == Salvage.anvilMaterial && PrimarySkillType.SALVAGE.getPermissions(player) && mcMMO.getSalvageableManager().isSalvageable(heldItem)) {
SalvageManager salvageManager = mcMMOPlayer.getSalvageManager(); SalvageManager salvageManager = mmoPlayer.getSalvageManager();
// Cancel salvaging an enchanted item // Cancel salvaging an enchanted item
if (salvageManager.checkConfirmation(false)) { if (salvageManager.checkConfirmation(false)) {
@ -720,17 +722,17 @@ public class PlayerListener implements Listener {
return; return;
} }
if (playerInteractEvent.getHand() != EquipmentSlot.HAND || !UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) { if (playerInteractEvent.getHand() != EquipmentSlot.HAND || !mcMMO.getUserManager().hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return; return;
} }
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
return; return;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
ItemStack heldItem = player.getInventory().getItemInMainHand(); ItemStack heldItem = player.getInventory().getItemInMainHand();
//Spam Fishing Detection //Spam Fishing Detection
@ -745,11 +747,11 @@ public class PlayerListener implements Listener {
player.setVelocity(player.getEyeLocation().getDirection().multiply(10)); player.setVelocity(player.getEyeLocation().getDirection().multiply(10));
} }
mcMMOPlayer.getFishingManager().setFishingRodCastTimestamp(); mmoPlayer.getFishingManager().setFishingRodCastTimestamp();
} }
} }
mcMMOPlayer.getAbilityActivationProcessor().processAbilityAndToolActivations(playerInteractEvent); mmoPlayer.getAbilityActivationProcessor().processAbilityAndToolActivations(playerInteractEvent);
} }
/** /**
@ -761,13 +763,13 @@ public class PlayerListener implements Listener {
public void onPlayerChat(AsyncPlayerChatEvent event) { public void onPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (Misc.isNPCEntityExcludingVillagers(player) || !UserManager.hasPlayerDataKey(player)) { if (Misc.isNPCEntityExcludingVillagers(player) || !mcMMO.getUserManager().hasPlayerDataKey(player)) {
return; return;
} }
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getOfflinePlayer(player);
if (mcMMOPlayer == null) { if (mmoPlayer == null) {
mcMMO.p.debug(player.getName() + "is chatting, but is currently not logged in to the server."); mcMMO.p.debug(player.getName() + "is chatting, but is currently not logged in to the server.");
mcMMO.p.debug("Party & Admin chat will not work properly for this player."); mcMMO.p.debug("Party & Admin chat will not work properly for this player.");
return; return;
@ -775,11 +777,11 @@ public class PlayerListener implements Listener {
ChatManager chatManager = null; ChatManager chatManager = null;
if (mcMMOPlayer.isChatEnabled(ChatMode.PARTY)) { if (mmoPlayer.isChatEnabled(ChatMode.PARTY)) {
Party party = mcMMOPlayer.getParty(); Party party = mmoPlayer.getParty();
if (party == null) { if (party == null) {
mcMMOPlayer.disableChat(ChatMode.PARTY); mmoPlayer.disableChat(ChatMode.PARTY);
player.sendMessage(LocaleLoader.getString("Commands.Party.None")); player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return; return;
} }
@ -787,7 +789,7 @@ public class PlayerListener implements Listener {
chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.PARTY); chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.PARTY);
((PartyChatManager) chatManager).setParty(party); ((PartyChatManager) chatManager).setParty(party);
} }
else if (mcMMOPlayer.isChatEnabled(ChatMode.ADMIN)) { else if (mmoPlayer.isChatEnabled(ChatMode.ADMIN)) {
chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN); chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN);
} }

View File

@ -39,14 +39,24 @@ public class SelfListener implements Listener {
{ {
int previousLevelGained = event.getSkillLevel() - i; int previousLevelGained = event.getSkillLevel() - i;
//Send player skill unlock notifications //Send player skill unlock notifications
UserManager.getPlayer(player).processUnlockNotifications(plugin, event.getSkill(), previousLevelGained); RankUtils.executeSkillUnlockNotifications(plugin, mcMMO.getUserManager().getPlayer(player), event.getSkill(), previousLevelGained);
} }
//Reset the delay timer for(int i = 0; i < event.getLevelsGained(); i++)
RankUtils.resetUnlockDelayTimer(); {
int previousLevelGained = event.getSkillLevel() - i;
//Send player skill unlock notifications
RankUtils.executeSkillUnlockNotifications(plugin, mcMMO.getUserManager().getPlayer(player), event.getSkill(), previousLevelGained);
}
if(Config.getInstance().getScoreboardsEnabled()) //Reset the delay timer
ScoreboardManager.handleLevelUp(player, skill); RankUtils.resetUnlockDelayTimer();
if(Config.getInstance().getScoreboardsEnabled())
ScoreboardManager.handleLevelUp(player, skill);
if(Config.getInstance().getScoreboardsEnabled())
ScoreboardManager.handleLevelUp(player, skill);
} }
} }
@ -72,12 +82,12 @@ public class SelfListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerXpGain(McMMOPlayerXpGainEvent event) { public void onPlayerXpGain(McMMOPlayerXpGainEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
PrimarySkillType primarySkillType = event.getSkill(); PrimarySkillType primarySkillType = event.getSkill();
if(mcMMOPlayer.isDebugMode()) { if(mmoPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage(event.getSkill().toString() + " XP Gained"); mmoPlayer.getPlayer().sendMessage(event.getSkill().toString() + " XP Gained");
mcMMOPlayer.getPlayer().sendMessage("Incoming Raw XP: "+event.getRawXpGained()); mmoPlayer.getPlayer().sendMessage("Incoming Raw XP: "+event.getRawXpGained());
} }
//WorldGuard XP Check //WorldGuard XP Check
@ -93,8 +103,8 @@ public class SelfListener implements Listener {
event.setRawXpGained(0); event.setRawXpGained(0);
event.setCancelled(true); event.setCancelled(true);
if(mcMMOPlayer.isDebugMode()) { if(mmoPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage("No WG XP Flag - New Raw XP: "+event.getRawXpGained()); mmoPlayer.getPlayer().sendMessage("No WG XP Flag - New Raw XP: "+event.getRawXpGained());
} }
} }
} }
@ -111,9 +121,9 @@ public class SelfListener implements Listener {
int earlyGameBonusXP = 0; int earlyGameBonusXP = 0;
//Give some bonus XP for low levels //Give some bonus XP for low levels
if(PlayerLevelUtils.qualifiesForEarlyGameBoost(mcMMOPlayer, primarySkillType)) if(PlayerLevelUtils.qualifiesForEarlyGameBoost(mmoPlayer, primarySkillType))
{ {
earlyGameBonusXP += (mcMMOPlayer.getXpToLevel(primarySkillType) * 0.05); earlyGameBonusXP += (mmoPlayer.getExperienceManager().getXpToLevel(primarySkillType) * 0.05);
event.setRawXpGained(event.getRawXpGained() + earlyGameBonusXP); event.setRawXpGained(event.getRawXpGained() + earlyGameBonusXP);
} }
} }
@ -121,8 +131,8 @@ public class SelfListener implements Listener {
int threshold = ExperienceConfig.getInstance().getDiminishedReturnsThreshold(primarySkillType); int threshold = ExperienceConfig.getInstance().getDiminishedReturnsThreshold(primarySkillType);
if (threshold <= 0 || !ExperienceConfig.getInstance().getDiminishedReturnsEnabled()) { if (threshold <= 0 || !ExperienceConfig.getInstance().getDiminishedReturnsEnabled()) {
if(mcMMOPlayer.isDebugMode()) { if(mmoPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage("Final Raw XP: "+event.getRawXpGained()); mmoPlayer.getPlayer().sendMessage("Final Raw XP: "+event.getRawXpGained());
} }
// Diminished returns is turned off // Diminished returns is turned off
return; return;
@ -142,10 +152,10 @@ public class SelfListener implements Listener {
float guaranteedMinimum = ExperienceConfig.getInstance().getDiminishedReturnsCap() * rawXp; float guaranteedMinimum = ExperienceConfig.getInstance().getDiminishedReturnsCap() * rawXp;
float modifiedThreshold = (float) (threshold / primarySkillType.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()); float modifiedThreshold = (float) (threshold / primarySkillType.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier());
float difference = (mcMMOPlayer.getProfile().getRegisteredXpGain(primarySkillType) - modifiedThreshold) / modifiedThreshold; float difference = (mmoPlayer.getExperienceManager().getRegisteredXpGain(primarySkillType) - modifiedThreshold) / modifiedThreshold;
if (difference > 0) { if (difference > 0) {
// System.out.println("Total XP Earned: " + mcMMOPlayer.getProfile().getRegisteredXpGain(primarySkillType) + " / Threshold value: " + threshold); // System.out.println("Total XP Earned: " + mmoPlayer.getProfile().getRegisteredXpGain(primarySkillType) + " / Threshold value: " + threshold);
// System.out.println(difference * 100 + "% over the threshold!"); // System.out.println(difference * 100 + "% over the threshold!");
// System.out.println("Previous: " + event.getRawXpGained()); // System.out.println("Previous: " + event.getRawXpGained());
// System.out.println("Adjusted XP " + (event.getRawXpGained() - (event.getRawXpGained() * difference))); // System.out.println("Adjusted XP " + (event.getRawXpGained() - (event.getRawXpGained() * difference)));
@ -169,8 +179,8 @@ public class SelfListener implements Listener {
} }
if(mcMMOPlayer.isDebugMode()) { if(mmoPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage("Final Raw XP: "+event.getRawXpGained()); mmoPlayer.getPlayer().sendMessage("Final Raw XP: "+event.getRawXpGained());
} }
} }

View File

@ -2,10 +2,6 @@ package com.gmail.nossr50;
import com.gmail.nossr50.config.*; import com.gmail.nossr50.config.*;
import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.mods.ArmorConfigManager;
import com.gmail.nossr50.config.mods.BlockConfigManager;
import com.gmail.nossr50.config.mods.EntityConfigManager;
import com.gmail.nossr50.config.mods.ToolConfigManager;
import com.gmail.nossr50.config.skills.alchemy.PotionConfig; import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
import com.gmail.nossr50.config.skills.repair.RepairConfigManager; import com.gmail.nossr50.config.skills.repair.RepairConfigManager;
import com.gmail.nossr50.config.skills.salvage.SalvageConfigManager; import com.gmail.nossr50.config.skills.salvage.SalvageConfigManager;
@ -81,6 +77,8 @@ public class mcMMO extends JavaPlugin {
private static PlayerLevelUtils playerLevelUtils; private static PlayerLevelUtils playerLevelUtils;
private static SmeltingTracker smeltingTracker; private static SmeltingTracker smeltingTracker;
private static SpawnedProjectileTracker spawnedProjectileTracker; private static SpawnedProjectileTracker spawnedProjectileTracker;
private static UserManager userManager;
private static PartyManager partyManager;
/* Blacklist */ /* Blacklist */
private static WorldBlacklist worldBlacklist; private static WorldBlacklist worldBlacklist;
@ -176,10 +174,6 @@ public class mcMMO extends JavaPlugin {
//Store this value so other plugins can check it //Store this value so other plugins can check it
isRetroModeEnabled = Config.getInstance().getIsRetroMode(); isRetroModeEnabled = Config.getInstance().getIsRetroMode();
if (getServer().getName().equals("Cauldron") || getServer().getName().equals("MCPC+")) {
checkModConfigs();
}
if (healthBarPluginEnabled) { if (healthBarPluginEnabled) {
getLogger().info("HealthBar plugin found, mcMMO's healthbars are automatically disabled."); getLogger().info("HealthBar plugin found, mcMMO's healthbars are automatically disabled.");
} }
@ -214,7 +208,7 @@ public class mcMMO extends JavaPlugin {
registerCoreSkills(); registerCoreSkills();
registerCustomRecipes(); registerCustomRecipes();
PartyManager.loadParties(); mcMMO.getPartyManager().loadParties();
formulaManager = new FormulaManager(); formulaManager = new FormulaManager();
holidayManager = new HolidayManager(); holidayManager = new HolidayManager();
@ -275,6 +269,9 @@ public class mcMMO extends JavaPlugin {
//Init spawned projectile tracker //Init spawned projectile tracker
spawnedProjectileTracker = new SpawnedProjectileTracker(); spawnedProjectileTracker = new SpawnedProjectileTracker();
//Init Player Data Manager
userManager = new UserManager();
} }
public static PlayerLevelUtils getPlayerLevelUtils() { public static PlayerLevelUtils getPlayerLevelUtils() {
@ -311,10 +308,10 @@ public class mcMMO extends JavaPlugin {
@Override @Override
public void onDisable() { public void onDisable() {
try { try {
UserManager.saveAll(); // Make sure to save player information if the server shuts down userManager.saveAllSync(); // Make sure to save player information if the server shuts down
UserManager.clearAll(); userManager.clearAll();
Alchemy.finishAllBrews(); // Finish all partially complete AlchemyBrewTasks to prevent vanilla brewing continuation on restart Alchemy.finishAllBrews(); // Finish all partially complete AlchemyBrewTasks to prevent vanilla brewing continuation on restart
PartyManager.saveParties(); // Save our parties mcMMO.getPartyManager().saveParties(); // Save our parties
//TODO: Needed? //TODO: Needed?
if(Config.getInstance().getScoreboardsEnabled()) if(Config.getInstance().getScoreboardsEnabled())
@ -515,25 +512,8 @@ public class mcMMO extends JavaPlugin {
List<Repairable> repairables = new ArrayList<>(); List<Repairable> repairables = new ArrayList<>();
if (Config.getInstance().getToolModsEnabled()) {
new ToolConfigManager(this);
}
if (Config.getInstance().getArmorModsEnabled()) {
new ArmorConfigManager(this);
}
if (Config.getInstance().getBlockModsEnabled()) {
new BlockConfigManager(this);
}
if (Config.getInstance().getEntityModsEnabled()) {
new EntityConfigManager(this);
}
// Load repair configs, make manager, and register them at this time // Load repair configs, make manager, and register them at this time
repairables.addAll(new RepairConfigManager(this).getLoadedRepairables()); repairables.addAll(new RepairConfigManager(this).getLoadedRepairables());
repairables.addAll(modManager.getLoadedRepairables());
repairableManager = new SimpleRepairableManager(repairables.size()); repairableManager = new SimpleRepairableManager(repairables.size());
repairableManager.registerRepairables(repairables); repairableManager.registerRepairables(repairables);
@ -635,28 +615,6 @@ public class mcMMO extends JavaPlugin {
} }
} }
private void checkModConfigs() {
if (!Config.getInstance().getToolModsEnabled()) {
getLogger().warning("Cauldron implementation found, but the custom tool config for mcMMO is disabled!");
getLogger().info("To enable, set Mods.Tool_Mods_Enabled to TRUE in config.yml.");
}
if (!Config.getInstance().getArmorModsEnabled()) {
getLogger().warning("Cauldron implementation found, but the custom armor config for mcMMO is disabled!");
getLogger().info("To enable, set Mods.Armor_Mods_Enabled to TRUE in config.yml.");
}
if (!Config.getInstance().getBlockModsEnabled()) {
getLogger().warning("Cauldron implementation found, but the custom block config for mcMMO is disabled!");
getLogger().info("To enable, set Mods.Block_Mods_Enabled to TRUE in config.yml.");
}
if (!Config.getInstance().getEntityModsEnabled()) {
getLogger().warning("Cauldron implementation found, but the custom entity config for mcMMO is disabled!");
getLogger().info("To enable, set Mods.Entity_Mods_Enabled to TRUE in config.yml.");
}
}
public InputStreamReader getResourceAsReader(String fileName) { public InputStreamReader getResourceAsReader(String fileName) {
InputStream in = getResource(fileName); InputStream in = getResource(fileName);
return in == null ? null : new InputStreamReader(in, Charsets.UTF_8); return in == null ? null : new InputStreamReader(in, Charsets.UTF_8);
@ -687,4 +645,12 @@ public class mcMMO extends JavaPlugin {
public static SpawnedProjectileTracker getSpawnedProjectileTracker() { public static SpawnedProjectileTracker getSpawnedProjectileTracker() {
return spawnedProjectileTracker; return spawnedProjectileTracker;
} }
public static UserManager getUserManager() {
return userManager;
}
public static PartyManager getPartyManager() {
return partyManager;
}
} }

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.database.UpgradeType;
import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.party.ItemShareType; import com.gmail.nossr50.datatypes.party.ItemShareType;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyLeader;
import com.gmail.nossr50.datatypes.party.ShareMode; import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
@ -18,26 +17,27 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.*;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID;
public final class PartyManager { public final class PartyManager {
private static final String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml"; private final @NotNull HashMap<String, Party> parties;
private static final List<Party> parties = new ArrayList<>(); private final @NotNull File partyFile;
private static final File partyFile = new File(partiesFilePath);
private PartyManager() {} public PartyManager() {
String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
partyFile = new File(partiesFilePath);
parties = new HashMap<>();
}
/** /**
* Check if a party with a given name already exists. * Check if a party with a given name already exists.
@ -46,7 +46,7 @@ public final class PartyManager {
* @param partyName The name of the party to check * @param partyName The name of the party to check
* @return true if a party with that name exists, false otherwise * @return true if a party with that name exists, false otherwise
*/ */
public static boolean checkPartyExistence(Player player, String partyName) { public boolean checkPartyExistence(Player player, String partyName) {
if (getParty(partyName) == null) { if (getParty(partyName) == null) {
return false; return false;
} }
@ -61,29 +61,29 @@ public final class PartyManager {
* @param targetParty the target party * @param targetParty the target party
* @return true if party is full and cannot be joined * @return true if party is full and cannot be joined
*/ */
public static boolean isPartyFull(Player player, Party targetParty) public boolean isPartyFull(Player player, Party targetParty)
{ {
return !Permissions.partySizeBypass(player) && Config.getInstance().getPartyMaxSize() >= 1 && targetParty.getOnlineMembers().size() >= Config.getInstance().getPartyMaxSize(); return !Permissions.partySizeBypass(player) && Config.getInstance().getPartyMaxSize() >= 1 && targetParty.getPartyMembers().size() >= Config.getInstance().getPartyMaxSize();
} }
/** /**
* Attempt to change parties or join a new party. * Attempt to change parties or join a new party.
* *
* @param mcMMOPlayer The player changing or joining parties * @param mmoPlayer The player changing or joining parties
* @param newPartyName The name of the party being joined * @param newPartyName The name of the party being joined
* @return true if the party was joined successfully, false otherwise * @return true if the party was joined successfully, false otherwise
*/ */
public static boolean changeOrJoinParty(McMMOPlayer mcMMOPlayer, String newPartyName) { public boolean changeOrJoinParty(McMMOPlayer mmoPlayer, String newPartyName) {
Player player = mcMMOPlayer.getPlayer(); Player player = mmoPlayer.getPlayer();
if (mcMMOPlayer.inParty()) { if (mmoPlayer.inParty()) {
Party oldParty = mcMMOPlayer.getParty(); Party oldParty = mmoPlayer.getParty();
if (!handlePartyChangeEvent(player, oldParty.getName(), newPartyName, EventReason.CHANGED_PARTIES)) { if (!handlePartyChangeEvent(player, oldParty.getPartyName(), newPartyName, EventReason.CHANGED_PARTIES)) {
return false; return false;
} }
removeFromParty(mcMMOPlayer); removeFromParty(mmoPlayer);
} }
else return handlePartyChangeEvent(player, null, newPartyName, EventReason.JOINED_PARTY); else return handlePartyChangeEvent(player, null, newPartyName, EventReason.JOINED_PARTY);
@ -97,21 +97,21 @@ public final class PartyManager {
* @param secondPlayer The second player * @param secondPlayer The second player
* @return true if they are in the same party, false otherwise * @return true if they are in the same party, false otherwise
*/ */
public static boolean inSameParty(Player firstPlayer, Player secondPlayer) { public boolean inSameParty(Player firstPlayer, Player secondPlayer) {
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(firstPlayer) == null) if(mcMMO.getUserManager().getPlayer(firstPlayer) == null)
{ {
return false; return false;
} }
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(secondPlayer) == null) if(mcMMO.getUserManager().getPlayer(secondPlayer) == null)
{ {
return false; return false;
} }
Party firstParty = UserManager.getPlayer(firstPlayer).getParty(); Party firstParty = mcMMO.getUserManager().getPlayer(firstPlayer).getParty();
Party secondParty = UserManager.getPlayer(secondPlayer).getParty(); Party secondParty = mcMMO.getUserManager().getPlayer(secondPlayer).getParty();
if (firstParty == null || secondParty == null) { if (firstParty == null || secondParty == null) {
return false; return false;
@ -120,21 +120,21 @@ public final class PartyManager {
return firstParty.equals(secondParty); return firstParty.equals(secondParty);
} }
public static boolean areAllies(Player firstPlayer, Player secondPlayer) { public boolean areAllies(Player firstPlayer, Player secondPlayer) {
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(firstPlayer) == null) if(mcMMO.getUserManager().getPlayer(firstPlayer) == null)
{ {
return false; return false;
} }
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(secondPlayer) == null) if(mcMMO.getUserManager().getPlayer(secondPlayer) == null)
{ {
return false; return false;
} }
Party firstParty = UserManager.getPlayer(firstPlayer).getParty(); Party firstParty = mcMMO.getUserManager().getPlayer(firstPlayer).getParty();
Party secondParty = UserManager.getPlayer(secondPlayer).getParty(); Party secondParty = mcMMO.getUserManager().getPlayer(secondPlayer).getParty();
if (firstParty == null || secondParty == null || firstParty.getAlly() == null || secondParty.getAlly() == null) { if (firstParty == null || secondParty == null || firstParty.getAlly() == null || secondParty.getAlly() == null) {
return false; return false;
@ -146,18 +146,18 @@ public final class PartyManager {
/** /**
* Get the near party members. * Get the near party members.
* *
* @param mcMMOPlayer The player to check * @param mmoPlayer The player to check
* @return the near party members * @return the near party members
*/ */
public static List<Player> getNearMembers(McMMOPlayer mcMMOPlayer) { public List<Player> getNearMembers(McMMOPlayer mmoPlayer) {
List<Player> nearMembers = new ArrayList<>(); List<Player> nearMembers = new ArrayList<>();
Party party = mcMMOPlayer.getParty(); Party party = mmoPlayer.getParty();
if (party != null) { if (party != null) {
Player player = mcMMOPlayer.getPlayer(); Player player = mmoPlayer.getPlayer();
double range = Config.getInstance().getPartyShareRange(); double range = Config.getInstance().getPartyShareRange();
for (Player member : party.getOnlineMembers()) { for (Player member : party.getPartyMembers()) {
if (!player.equals(member) && member.isValid() && Misc.isNear(player.getLocation(), member.getLocation(), range)) { if (!player.equals(member) && member.isValid() && Misc.isNear(player.getLocation(), member.getLocation(), range)) {
nearMembers.add(member); nearMembers.add(member);
} }
@ -167,12 +167,12 @@ public final class PartyManager {
return nearMembers; return nearMembers;
} }
public static List<Player> getNearVisibleMembers(McMMOPlayer mcMMOPlayer) { public List<Player> getNearVisibleMembers(McMMOPlayer mmoPlayer) {
List<Player> nearMembers = new ArrayList<>(); List<Player> nearMembers = new ArrayList<>();
Party party = mcMMOPlayer.getParty(); Party party = mmoPlayer.getParty();
if (party != null) { if (party != null) {
Player player = mcMMOPlayer.getPlayer(); Player player = mmoPlayer.getPlayer();
double range = Config.getInstance().getPartyShareRange(); double range = Config.getInstance().getPartyShareRange();
for (Player member : party.getVisibleMembers(player)) { for (Player member : party.getVisibleMembers(player)) {
@ -194,7 +194,7 @@ public final class PartyManager {
* @param player The player to check * @param player The player to check
* @return all the players in the player's party * @return all the players in the player's party
*/ */
public static LinkedHashMap<UUID, String> getAllMembers(Player player) { public LinkedHashMap<UUID, String> getAllMembers(Player player) {
Party party = getParty(player); Party party = getParty(player);
return party == null ? new LinkedHashMap<>() : party.getMembers(); return party == null ? new LinkedHashMap<>() : party.getMembers();
@ -206,7 +206,7 @@ public final class PartyManager {
* @param partyName The party to check * @param partyName The party to check
* @return all online players in this party * @return all online players in this party
*/ */
public static List<Player> getOnlineMembers(String partyName) { public List<Player> getOnlineMembers(String partyName) {
return getOnlineMembers(getParty(partyName)); return getOnlineMembers(getParty(partyName));
} }
@ -216,12 +216,12 @@ public final class PartyManager {
* @param player The player to check * @param player The player to check
* @return all online players in this party * @return all online players in this party
*/ */
public static List<Player> getOnlineMembers(Player player) { public List<Player> getOnlineMembers(Player player) {
return getOnlineMembers(getParty(player)); return getOnlineMembers(getParty(player));
} }
private static List<Player> getOnlineMembers(Party party) { private List<Player> getOnlineMembers(Party party) {
return party == null ? new ArrayList<>() : party.getOnlineMembers(); return party == null ? new ArrayList<>() : party.getPartyMembers();
} }
/** /**
@ -230,9 +230,9 @@ public final class PartyManager {
* @param partyName The party name * @param partyName The party name
* @return the existing party, null otherwise * @return the existing party, null otherwise
*/ */
public static Party getParty(String partyName) { public Party getParty(String partyName) {
for (Party party : parties) { for (Party party : parties) {
if (party.getName().equalsIgnoreCase(partyName)) { if (party.getPartyName().equalsIgnoreCase(partyName)) {
return party; return party;
} }
} }
@ -247,7 +247,7 @@ public final class PartyManager {
* @return the existing party, null otherwise * @return the existing party, null otherwise
*/ */
@Deprecated @Deprecated
public static Party getPlayerParty(String playerName) { public Party getPlayerParty(String playerName) {
for (Party party : parties) { for (Party party : parties) {
if (party.getMembers().containsKey(playerName)) { if (party.getMembers().containsKey(playerName)) {
return party; return party;
@ -263,7 +263,7 @@ public final class PartyManager {
* @param uuid The members uuid * @param uuid The members uuid
* @return the existing party, null otherwise * @return the existing party, null otherwise
*/ */
public static Party getPlayerParty(String playerName, UUID uuid) { public Party getPlayerParty(String playerName, UUID uuid) {
for (Party party : parties) { for (Party party : parties) {
LinkedHashMap<UUID, String> members = party.getMembers(); LinkedHashMap<UUID, String> members = party.getMembers();
if (members.containsKey(uuid) || members.containsValue(playerName)) { if (members.containsKey(uuid) || members.containsValue(playerName)) {
@ -286,16 +286,16 @@ public final class PartyManager {
* @param player The member * @param player The member
* @return the existing party, null otherwise * @return the existing party, null otherwise
*/ */
public static Party getParty(Player player) { public Party getParty(Player player) {
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(player) == null) if(mcMMO.getUserManager().getPlayer(player) == null)
{ {
return null; return null;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
return mcMMOPlayer.getParty(); return mmoPlayer.getParty();
} }
/** /**
@ -303,7 +303,7 @@ public final class PartyManager {
* *
* @return the list of parties. * @return the list of parties.
*/ */
public static List<Party> getParties() { public List<Party> getParties() {
return parties; return parties;
} }
@ -313,14 +313,14 @@ public final class PartyManager {
* @param player The player to remove * @param player The player to remove
* @param party The party * @param party The party
*/ */
public static void removeFromParty(OfflinePlayer player, Party party) { public void removeFromParty(OfflinePlayer player, Party party) {
LinkedHashMap<UUID, String> members = party.getMembers(); LinkedHashMap<UUID, String> members = party.getMembers();
String playerName = player.getName(); String playerName = player.getName();
members.remove(player.getUniqueId()); members.remove(player.getUniqueId());
if (player.isOnline()) { if (player.isOnline()) {
party.getOnlineMembers().remove(player.getPlayer()); party.getPartyMembers().remove(player.getPlayer());
} }
if (members.isEmpty()) { if (members.isEmpty()) {
@ -339,11 +339,11 @@ public final class PartyManager {
/** /**
* Remove a player from a party. * Remove a player from a party.
* *
* @param mcMMOPlayer The player to remove * @param mmoPlayer The player to remove
*/ */
public static void removeFromParty(McMMOPlayer mcMMOPlayer) { public void removeFromParty(McMMOPlayer mmoPlayer) {
removeFromParty(mcMMOPlayer.getPlayer(), mcMMOPlayer.getParty()); removeFromParty(mmoPlayer.getPlayer(), mmoPlayer.getParty());
processPartyLeaving(mcMMOPlayer); processPartyLeaving(mmoPlayer);
} }
/** /**
@ -351,16 +351,16 @@ public final class PartyManager {
* *
* @param party The party to remove * @param party The party to remove
*/ */
public static void disbandParty(Party party) { public void disbandParty(Party party) {
//TODO: Potential issues with unloaded profile? //TODO: Potential issues with unloaded profile?
for (Player member : party.getOnlineMembers()) { for (Player member : party.getPartyMembers()) {
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(member) == null) if(mcMMO.getUserManager().getPlayer(member) == null)
{ {
continue; continue;
} }
processPartyLeaving(UserManager.getPlayer(member)); processPartyLeaving(mcMMO.getUserManager().getPlayer(member));
} }
// Disband the alliance between the disbanded party and it's ally // Disband the alliance between the disbanded party and it's ally
@ -374,12 +374,12 @@ public final class PartyManager {
/** /**
* Create a new party * Create a new party
* *
* @param mcMMOPlayer The player to add to the party * @param mmoPlayer The player to add to the party
* @param partyName The party to add the player to * @param partyName The party to add the player to
* @param password The password for this party, null if there was no password * @param password The password for this party, null if there was no password
*/ */
public static void createParty(McMMOPlayer mcMMOPlayer, String partyName, String password) { public void createParty(McMMOPlayer mmoPlayer, String partyName, String password) {
Player player = mcMMOPlayer.getPlayer(); Player player = mmoPlayer.getPlayer();
Party party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName.replace(".", ""), password); Party party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName.replace(".", ""), password);
@ -389,8 +389,8 @@ public final class PartyManager {
parties.add(party); parties.add(party);
player.sendMessage(LocaleLoader.getString("Commands.Party.Create", party.getName())); player.sendMessage(LocaleLoader.getString("Commands.Party.Create", party.getPartyName()));
addToParty(mcMMOPlayer, party); addToParty(mmoPlayer, party);
} }
/** /**
@ -401,9 +401,9 @@ public final class PartyManager {
* @param password The password provided by the player * @param password The password provided by the player
* @return true if the player can join the party * @return true if the player can join the party
*/ */
public static boolean checkPartyPassword(Player player, Party party, String password) { public boolean checkPartyPassword(Player player, Party party, String password) {
if (party.isLocked()) { if (party.isLocked()) {
String partyPassword = party.getPassword(); String partyPassword = party.getPartyPassword();
if (partyPassword == null) { if (partyPassword == null) {
player.sendMessage(LocaleLoader.getString("Party.Locked")); player.sendMessage(LocaleLoader.getString("Party.Locked"));
@ -427,14 +427,14 @@ public final class PartyManager {
/** /**
* Accept a party invitation * Accept a party invitation
* *
* @param mcMMOPlayer The player to add to the party * @param mmoPlayer The player to add to the party
*/ */
public static void joinInvitedParty(McMMOPlayer mcMMOPlayer) { public void joinInvitedParty(McMMOPlayer mmoPlayer) {
Party invite = mcMMOPlayer.getPartyInvite(); Party invite = mmoPlayer.getPartyInvite();
// Check if the party still exists, it might have been disbanded // Check if the party still exists, it might have been disbanded
if (!parties.contains(invite)) { if (!parties.contains(invite)) {
NotificationManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.PARTY_MESSAGE, "Party.Disband"); NotificationManager.sendPlayerInformation(mmoPlayer.getPlayer(), NotificationType.PARTY_MESSAGE, "Party.Disband");
return; return;
} }
@ -443,23 +443,23 @@ public final class PartyManager {
*/ */
if(Config.getInstance().getPartyMaxSize() > 0 && invite.getMembers().size() >= Config.getInstance().getPartyMaxSize()) if(Config.getInstance().getPartyMaxSize() > 0 && invite.getMembers().size() >= Config.getInstance().getPartyMaxSize())
{ {
NotificationManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull.InviteAccept", invite.getName(), String.valueOf(Config.getInstance().getPartyMaxSize())); NotificationManager.sendPlayerInformation(mmoPlayer.getPlayer(), NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull.InviteAccept", invite.getPartyName(), String.valueOf(Config.getInstance().getPartyMaxSize()));
return; return;
} }
NotificationManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.PARTY_MESSAGE, "Commands.Party.Invite.Accepted", invite.getName()); NotificationManager.sendPlayerInformation(mmoPlayer.getPlayer(), NotificationType.PARTY_MESSAGE, "Commands.Party.Invite.Accepted", invite.getPartyName());
mcMMOPlayer.removePartyInvite(); mmoPlayer.removePartyInvite();
addToParty(mcMMOPlayer, invite); addToParty(mmoPlayer, invite);
} }
/** /**
* Accept a party alliance invitation * Accept a party alliance invitation
* *
* @param mcMMOPlayer The player who accepts the alliance invite * @param mmoPlayer The player who accepts the alliance invite
*/ */
public static void acceptAllianceInvite(McMMOPlayer mcMMOPlayer) { public void acceptAllianceInvite(McMMOPlayer mmoPlayer) {
Party invite = mcMMOPlayer.getPartyAllianceInvite(); Party invite = mmoPlayer.getPartyAllianceInvite();
Player player = mcMMOPlayer.getPlayer(); Player player = mmoPlayer.getPlayer();
// Check if the party still exists, it might have been disbanded // Check if the party still exists, it might have been disbanded
if (!parties.contains(invite)) { if (!parties.contains(invite)) {
@ -467,65 +467,64 @@ public final class PartyManager {
return; return;
} }
if (!handlePartyChangeAllianceEvent(player, mcMMOPlayer.getParty().getName(), invite.getName(), McMMOPartyAllianceChangeEvent.EventReason.FORMED_ALLIANCE)) { if (!handlePartyChangeAllianceEvent(player, mmoPlayer.getParty().getName(), invite.getPartyName(), McMMOPartyAllianceChangeEvent.EventReason.FORMED_ALLIANCE)) {
return; return;
} }
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.Accepted", invite.getName())); player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.Accepted", invite.getPartyName()));
mcMMOPlayer.removePartyAllianceInvite(); mmoPlayer.removePartyAllianceInvite();
createAlliance(mcMMOPlayer.getParty(), invite); createAlliance(mmoPlayer.getParty(), invite);
} }
public static void createAlliance(Party firstParty, Party secondParty) { public void createAlliance(Party firstParty, Party secondParty) {
firstParty.setAlly(secondParty); firstParty.setAlly(secondParty);
secondParty.setAlly(firstParty); secondParty.setAlly(firstParty);
for (Player member : firstParty.getOnlineMembers()) { for (Player member : firstParty.getPartyMembers()) {
member.sendMessage(LocaleLoader.getString("Party.Alliance.Formed", secondParty.getName())); member.sendMessage(LocaleLoader.getString("Party.Alliance.Formed", secondParty.getPartyName()));
} }
for (Player member : secondParty.getOnlineMembers()) { for (Player member : secondParty.getPartyMembers()) {
member.sendMessage(LocaleLoader.getString("Party.Alliance.Formed", firstParty.getName())); member.sendMessage(LocaleLoader.getString("Party.Alliance.Formed", firstParty.getPartyName()));
} }
} }
public static boolean disbandAlliance(Player player, Party firstParty, Party secondParty){ public boolean disbandAlliance(Player player, Party firstParty, Party secondParty){
if (!handlePartyChangeAllianceEvent(player, firstParty.getName(), secondParty.getName(), McMMOPartyAllianceChangeEvent.EventReason.DISBAND_ALLIANCE)) { if (!handlePartyChangeAllianceEvent(player, firstParty.getPartyName(), secondParty.getPartyName(), McMMOPartyAllianceChangeEvent.EventReason.DISBAND_ALLIANCE)) {
return false; return false;
} }
PartyManager.disbandAlliance(firstParty, secondParty); mcMMO.getPartyManager().disbandAlliance(firstParty, secondParty);
return true; return true;
} }
private static void disbandAlliance(Party firstParty, Party secondParty) { private void disbandAlliance(Party firstParty, Party secondParty) {
firstParty.setAlly(null); firstParty.setAlly(null);
secondParty.setAlly(null); secondParty.setAlly(null);
for (Player member : firstParty.getOnlineMembers()) { for (Player member : firstParty.getPartyMembers()) {
member.sendMessage(LocaleLoader.getString("Party.Alliance.Disband", secondParty.getName())); member.sendMessage(LocaleLoader.getString("Party.Alliance.Disband", secondParty.getPartyName()));
} }
for (Player member : secondParty.getOnlineMembers()) { for (Player member : secondParty.getPartyMembers()) {
member.sendMessage(LocaleLoader.getString("Party.Alliance.Disband", firstParty.getName())); member.sendMessage(LocaleLoader.getString("Party.Alliance.Disband", firstParty.getPartyName()));
} }
} }
/** /**
* Add a player to a party * Add a player to a party
* *
* @param mcMMOPlayer The player to add to the party * @param mmoPlayer The player to add to the party
* @param party The party * @param party The party
*/ */
public static void addToParty(McMMOPlayer mcMMOPlayer, Party party) { public void addToParty(McMMOPlayer mmoPlayer, Party party) {
Player player = mcMMOPlayer.getPlayer(); Player player = mmoPlayer.getPlayer();
String playerName = player.getName(); String playerName = player.getName();
informPartyMembersJoin(party, playerName); informPartyMembersJoin(party, playerName);
mcMMOPlayer.setParty(party);
party.getMembers().put(player.getUniqueId(), player.getName()); party.getMembers().put(player.getUniqueId(), player.getName());
party.getOnlineMembers().add(player); party.getPartyMembers().add(player);
} }
/** /**
@ -534,7 +533,7 @@ public final class PartyManager {
* @param partyName The party name * @param partyName The party name
* @return the leader of the party * @return the leader of the party
*/ */
public static String getPartyLeaderName(String partyName) { public String getPartyLeaderName(String partyName) {
Party party = getParty(partyName); Party party = getParty(partyName);
return party == null ? null : party.getLeader().getPlayerName(); return party == null ? null : party.getLeader().getPlayerName();
@ -546,11 +545,11 @@ public final class PartyManager {
* @param uuid The uuid of the player to set as leader * @param uuid The uuid of the player to set as leader
* @param party The party * @param party The party
*/ */
public static void setPartyLeader(UUID uuid, Party party) { public void setPartyLeader(UUID uuid, Party party) {
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(uuid); OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(uuid);
UUID leaderUniqueId = party.getLeader().getUniqueId(); UUID leaderUniqueId = party.getLeader().getUniqueId();
for (Player member : party.getOnlineMembers()) { for (Player member : party.getPartyMembers()) {
UUID memberUniqueId = member.getUniqueId(); UUID memberUniqueId = member.getUniqueId();
if (memberUniqueId.equals(player.getUniqueId())) { if (memberUniqueId.equals(player.getUniqueId())) {
@ -572,16 +571,16 @@ public final class PartyManager {
* *
* @return true if the player can invite * @return true if the player can invite
*/ */
public static boolean canInvite(McMMOPlayer mcMMOPlayer) { public boolean canInvite(McMMOPlayer mmoPlayer) {
Party party = mcMMOPlayer.getParty(); Party party = mmoPlayer.getParty();
return !party.isLocked() || party.getLeader().getUniqueId().equals(mcMMOPlayer.getPlayer().getUniqueId()); return !party.isLocked() || party.getLeader().getUniqueId().equals(mmoPlayer.getPlayer().getUniqueId());
} }
/** /**
* Load party file. * Load party file.
*/ */
public static void loadParties() { public void loadParties() {
if (!partyFile.exists()) { if (!partyFile.exists()) {
return; return;
} }
@ -602,8 +601,8 @@ public final class PartyManager {
String[] leaderSplit = partiesFile.getString(partyName + ".Leader").split("[|]"); String[] leaderSplit = partiesFile.getString(partyName + ".Leader").split("[|]");
party.setLeader(new PartyLeader(UUID.fromString(leaderSplit[0]), leaderSplit[1])); party.setLeader(new PartyLeader(UUID.fromString(leaderSplit[0]), leaderSplit[1]));
party.setPassword(partiesFile.getString(partyName + ".Password")); party.setPartyPassword(partiesFile.getString(partyName + ".Password"));
party.setLocked(partiesFile.getBoolean(partyName + ".Locked")); party.setPartyLock(partiesFile.getBoolean(partyName + ".Locked"));
party.setLevel(partiesFile.getInt(partyName + ".Level")); party.setLevel(partiesFile.getInt(partyName + ".Level"));
party.setXp(partiesFile.getInt(partyName + ".Xp")); party.setXp(partiesFile.getInt(partyName + ".Xp"));
@ -631,7 +630,7 @@ public final class PartyManager {
mcMMO.p.getLogger().info("Loaded (" + parties.size() + ") Parties..."); mcMMO.p.getLogger().info("Loaded (" + parties.size() + ") Parties...");
for (Party party : hasAlly) { for (Party party : hasAlly) {
party.setAlly(PartyManager.getParty(partiesFile.getString(party.getName() + ".Ally"))); party.setAlly(mcMMO.getPartyManager().getParty(partiesFile.getString(party.getPartyName() + ".Ally")));
} }
} catch (Exception e) { } catch (Exception e) {
@ -643,7 +642,7 @@ public final class PartyManager {
/** /**
* Save party file. * Save party file.
*/ */
public static void saveParties() { public void saveParties() {
if (partyFile.exists()) { if (partyFile.exists()) {
if (!partyFile.delete()) { if (!partyFile.delete()) {
mcMMO.p.getLogger().warning("Could not delete party file. Party saving failed!"); mcMMO.p.getLogger().warning("Could not delete party file. Party saving failed!");
@ -655,15 +654,15 @@ public final class PartyManager {
mcMMO.p.getLogger().info("Saving Parties... (" + parties.size() + ")"); mcMMO.p.getLogger().info("Saving Parties... (" + parties.size() + ")");
for (Party party : parties) { for (Party party : parties) {
String partyName = party.getName(); String partyName = party.getPartyName();
PartyLeader leader = party.getLeader(); PartyLeader leader = party.getLeader();
partiesFile.set(partyName + ".Leader", leader.getUniqueId().toString() + "|" + leader.getPlayerName()); partiesFile.set(partyName + ".Leader", leader.getUniqueId().toString() + "|" + leader.getPlayerName());
partiesFile.set(partyName + ".Password", party.getPassword()); partiesFile.set(partyName + ".Password", party.getPartyPassword());
partiesFile.set(partyName + ".Locked", party.isLocked()); partiesFile.set(partyName + ".Locked", party.isLocked());
partiesFile.set(partyName + ".Level", party.getLevel()); partiesFile.set(partyName + ".Level", party.getLevel());
partiesFile.set(partyName + ".Xp", (int) party.getXp()); partiesFile.set(partyName + ".Xp", (int) party.getXp());
partiesFile.set(partyName + ".Ally", (party.getAlly() != null) ? party.getAlly().getName() : ""); partiesFile.set(partyName + ".Ally", (party.getAlly() != null) ? party.getAlly().getPartyName() : "");
partiesFile.set(partyName + ".ExpShareMode", party.getXpShareMode().toString()); partiesFile.set(partyName + ".ExpShareMode", party.getXpShareMode().toString());
partiesFile.set(partyName + ".ItemShareMode", party.getItemShareMode().toString()); partiesFile.set(partyName + ".ItemShareMode", party.getItemShareMode().toString());
@ -693,7 +692,7 @@ public final class PartyManager {
} }
} }
private static void loadAndUpgradeParties() { private void loadAndUpgradeParties() {
YamlConfiguration partiesFile = YamlConfiguration.loadConfiguration(partyFile); YamlConfiguration partiesFile = YamlConfiguration.loadConfiguration(partyFile);
if (!partyFile.renameTo(new File(mcMMO.getFlatFileDirectory() + "parties.yml.converted"))) { if (!partyFile.renameTo(new File(mcMMO.getFlatFileDirectory() + "parties.yml.converted"))) {
@ -717,8 +716,8 @@ public final class PartyManager {
UUID leaderUniqueId = profile.getUniqueId(); UUID leaderUniqueId = profile.getUniqueId();
party.setLeader(new PartyLeader(leaderUniqueId, leaderName)); party.setLeader(new PartyLeader(leaderUniqueId, leaderName));
party.setPassword(partiesFile.getString(partyName + ".Password")); party.setPartyPassword(partiesFile.getString(partyName + ".Password"));
party.setLocked(partiesFile.getBoolean(partyName + ".Locked")); party.setPartyLock(partiesFile.getBoolean(partyName + ".Locked"));
party.setLevel(partiesFile.getInt(partyName + ".Level")); party.setLevel(partiesFile.getInt(partyName + ".Level"));
party.setXp(partiesFile.getInt(partyName + ".Xp")); party.setXp(partiesFile.getInt(partyName + ".Xp"));
@ -754,7 +753,7 @@ public final class PartyManager {
mcMMO.p.getLogger().info("Loaded (" + parties.size() + ") Parties..."); mcMMO.p.getLogger().info("Loaded (" + parties.size() + ") Parties...");
for (Party party : hasAlly) { for (Party party : hasAlly) {
party.setAlly(PartyManager.getParty(partiesFile.getString(party.getName() + ".Ally"))); party.setAlly(mcMMO.getPartyManager().getParty(partiesFile.getString(party.getPartyName() + ".Ally")));
} }
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS_PARTY); mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS_PARTY);
@ -769,7 +768,7 @@ public final class PartyManager {
* @param reason The reason for changing parties * @param reason The reason for changing parties
* @return true if the change event was successful, false otherwise * @return true if the change event was successful, false otherwise
*/ */
public static boolean handlePartyChangeEvent(Player player, String oldPartyName, String newPartyName, EventReason reason) { public boolean handlePartyChangeEvent(Player player, String oldPartyName, String newPartyName, EventReason reason) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, oldPartyName, newPartyName, reason); McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, oldPartyName, newPartyName, reason);
mcMMO.p.getServer().getPluginManager().callEvent(event); mcMMO.p.getServer().getPluginManager().callEvent(event);
@ -785,7 +784,7 @@ public final class PartyManager {
* @param reason The reason for changing allies * @param reason The reason for changing allies
* @return true if the change event was successful, false otherwise * @return true if the change event was successful, false otherwise
*/ */
public static boolean handlePartyChangeAllianceEvent(Player player, String oldAllyName, String newAllyName, McMMOPartyAllianceChangeEvent.EventReason reason) { public boolean handlePartyChangeAllianceEvent(Player player, String oldAllyName, String newAllyName, McMMOPartyAllianceChangeEvent.EventReason reason) {
McMMOPartyAllianceChangeEvent event = new McMMOPartyAllianceChangeEvent(player, oldAllyName, newAllyName, reason); McMMOPartyAllianceChangeEvent event = new McMMOPartyAllianceChangeEvent(player, oldAllyName, newAllyName, reason);
mcMMO.p.getServer().getPluginManager().callEvent(event); mcMMO.p.getServer().getPluginManager().callEvent(event);
@ -793,14 +792,14 @@ public final class PartyManager {
} }
/** /**
* Remove party data from the mcMMOPlayer. * Remove party data from the mmoPlayer.
* *
* @param mcMMOPlayer The player to remove party data from. * @param mmoPlayer The player to remove party data from.
*/ */
public static void processPartyLeaving(McMMOPlayer mcMMOPlayer) { public void processPartyLeaving(McMMOPlayer mmoPlayer) {
mcMMOPlayer.removeParty(); mmoPlayer.removeParty();
mcMMOPlayer.disableChat(ChatMode.PARTY); mmoPlayer.disableChat(ChatMode.PARTY);
mcMMOPlayer.setItemShareModifier(10); mmoPlayer.setItemShareModifier(10);
} }
/** /**
@ -810,9 +809,9 @@ public final class PartyManager {
* @param levelsGained The amount of levels gained * @param levelsGained The amount of levels gained
* @param level The current party level * @param level The current party level
*/ */
public static void informPartyMembersLevelUp(Party party, int levelsGained, int level) { public void informPartyMembersLevelUp(Party party, int levelsGained, int level) {
boolean levelUpSoundsEnabled = Config.getInstance().getLevelUpSoundsEnabled(); boolean levelUpSoundsEnabled = Config.getInstance().getLevelUpSoundsEnabled();
for (Player member : party.getOnlineMembers()) { for (Player member : party.getPartyMembers()) {
member.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, level)); member.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, level));
if (levelUpSoundsEnabled) { if (levelUpSoundsEnabled) {
@ -827,8 +826,8 @@ public final class PartyManager {
* @param party The concerned party * @param party The concerned party
* @param playerName The name of the player that joined * @param playerName The name of the player that joined
*/ */
private static void informPartyMembersJoin(Party party, String playerName) { private void informPartyMembersJoin(Party party, String playerName) {
for (Player member : party.getOnlineMembers()) { for (Player member : party.getPartyMembers()) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", playerName)); member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", playerName));
} }
} }
@ -839,8 +838,8 @@ public final class PartyManager {
* @param party The concerned party * @param party The concerned party
* @param playerName The name of the player that left * @param playerName The name of the player that left
*/ */
private static void informPartyMembersQuit(Party party, String playerName) { private void informPartyMembersQuit(Party party, String playerName) {
for (Player member : party.getOnlineMembers()) { for (Player member : party.getPartyMembers()) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", playerName)); member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", playerName));
} }
} }

View File

@ -10,7 +10,6 @@ import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -24,24 +23,24 @@ public final class ShareHandler {
* Distribute Xp amongst party members. * Distribute Xp amongst party members.
* *
* @param xp Xp without party sharing * @param xp Xp without party sharing
* @param mcMMOPlayer Player initiating the Xp gain * @param mmoPlayer Player initiating the Xp gain
* @param primarySkillType Skill being used * @param primarySkillType Skill being used
* @return True is the xp has been shared * @return True is the xp has been shared
*/ */
public static boolean handleXpShare(float xp, McMMOPlayer mcMMOPlayer, PrimarySkillType primarySkillType, XPGainReason xpGainReason) { public static boolean handleXpShare(float xp, McMMOPlayer mmoPlayer, PrimarySkillType primarySkillType, XPGainReason xpGainReason) {
Party party = mcMMOPlayer.getParty(); Party party = mmoPlayer.getParty();
if (party.getXpShareMode() != ShareMode.EQUAL) { if (party.getXpShareMode() != ShareMode.EQUAL) {
return false; return false;
} }
List<Player> nearMembers = PartyManager.getNearVisibleMembers(mcMMOPlayer); List<Player> nearMembers = mcMMO.getPartyManager().getNearVisibleMembers(mmoPlayer);
if (nearMembers.isEmpty()) { if (nearMembers.isEmpty()) {
return false; return false;
} }
nearMembers.add(mcMMOPlayer.getPlayer()); nearMembers.add(mmoPlayer.getPlayer());
int partySize = nearMembers.size(); int partySize = nearMembers.size();
double shareBonus = Math.min(Config.getInstance().getPartyShareBonusBase() + (partySize * Config.getInstance().getPartyShareBonusIncrease()), Config.getInstance().getPartyShareBonusCap()); double shareBonus = Math.min(Config.getInstance().getPartyShareBonusBase() + (partySize * Config.getInstance().getPartyShareBonusIncrease()), Config.getInstance().getPartyShareBonusCap());
@ -49,12 +48,12 @@ public final class ShareHandler {
for (Player member : nearMembers) { for (Player member : nearMembers) {
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(member) == null) if(mcMMO.getUserManager().getPlayer(member) == null)
{ {
continue; continue;
} }
UserManager.getPlayer(member).beginUnsharedXpGain(primarySkillType, splitXp, xpGainReason, XPGainSource.PARTY_MEMBERS); mcMMO.getUserManager().getPlayer(member).beginUnsharedXpGain(primarySkillType, splitXp, xpGainReason, XPGainSource.PARTY_MEMBERS);
} }
return true; return true;
@ -64,10 +63,10 @@ public final class ShareHandler {
* Distribute Items amongst party members. * Distribute Items amongst party members.
* *
* @param drop Item that will get shared * @param drop Item that will get shared
* @param mcMMOPlayer Player who picked up the item * @param mmoPlayer Player who picked up the item
* @return True if the item has been shared * @return True if the item has been shared
*/ */
public static boolean handleItemShare(Item drop, McMMOPlayer mcMMOPlayer) { public static boolean handleItemShare(Item drop, McMMOPlayer mmoPlayer) {
ItemStack itemStack = drop.getItemStack(); ItemStack itemStack = drop.getItemStack();
ItemShareType dropType = ItemShareType.getShareType(itemStack); ItemShareType dropType = ItemShareType.getShareType(itemStack);
@ -75,7 +74,7 @@ public final class ShareHandler {
return false; return false;
} }
Party party = mcMMOPlayer.getParty(); Party party = mmoPlayer.getParty();
if (!party.sharingDrops(dropType)) { if (!party.sharingDrops(dropType)) {
return false; return false;
@ -87,7 +86,7 @@ public final class ShareHandler {
return false; return false;
} }
List<Player> nearMembers = PartyManager.getNearMembers(mcMMOPlayer); List<Player> nearMembers = mcMMO.getPartyManager().getNearMembers(mmoPlayer);
if (nearMembers.isEmpty()) { if (nearMembers.isEmpty()) {
return false; return false;
@ -96,7 +95,7 @@ public final class ShareHandler {
Player winningPlayer = null; Player winningPlayer = null;
ItemStack newStack = itemStack.clone(); ItemStack newStack = itemStack.clone();
nearMembers.add(mcMMOPlayer.getPlayer()); nearMembers.add(mmoPlayer.getPlayer());
int partySize = nearMembers.size(); int partySize = nearMembers.size();
drop.remove(); drop.remove();
@ -110,10 +109,10 @@ public final class ShareHandler {
int highestRoll = 0; int highestRoll = 0;
for (Player member : nearMembers) { for (Player member : nearMembers) {
McMMOPlayer mcMMOMember = UserManager.getPlayer(member); McMMOPlayer mcMMOMember = mcMMO.getUserManager().getPlayer(member);
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(member) == null) if(mcMMO.getUserManager().getPlayer(member) == null)
{ {
continue; continue;
} }
@ -129,14 +128,14 @@ public final class ShareHandler {
highestRoll = diceRoll; highestRoll = diceRoll;
if (winningPlayer != null) { if (winningPlayer != null) {
McMMOPlayer mcMMOWinning = UserManager.getPlayer(winningPlayer); McMMOPlayer mcMMOWinning = mcMMO.getUserManager().getPlayer(winningPlayer);
mcMMOWinning.setItemShareModifier(mcMMOWinning.getItemShareModifier() + itemWeight); mcMMOWinning.setItemShareModifier(mcMMOWinning.getItemShareModifier() + itemWeight);
} }
winningPlayer = member; winningPlayer = member;
} }
McMMOPlayer mcMMOTarget = UserManager.getPlayer(winningPlayer); McMMOPlayer mcMMOTarget = mcMMO.getUserManager().getPlayer(winningPlayer);
mcMMOTarget.setItemShareModifier(mcMMOTarget.getItemShareModifier() - itemWeight); mcMMOTarget.setItemShareModifier(mcMMOTarget.getItemShareModifier() - itemWeight);
awardDrop(winningPlayer, newStack); awardDrop(winningPlayer, newStack);
} }

View File

@ -2,9 +2,6 @@ package com.gmail.nossr50.runnables;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
public class SaveTimerTask extends BukkitRunnable { public class SaveTimerTask extends BukkitRunnable {
@ -13,11 +10,12 @@ public class SaveTimerTask extends BukkitRunnable {
// All player data will be saved periodically through this // All player data will be saved periodically through this
int count = 1; int count = 1;
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) { //TODO: write a more efficient bulk save
new PlayerProfileSaveTask(mcMMOPlayer.getProfile(), false).runTaskLaterAsynchronously(mcMMO.p, count); for (McMMOPlayer mmoPlayer : mcMMO.getUserManager().getPlayers()) {
mcMMO.getUserManager().saveUserWithDelay(mmoPlayer.getPersistentPlayerData(), false, count);
count++; count++;
} }
PartyManager.saveParties(); mcMMO.getPartyManager().saveParties();
} }
} }

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.runnables.commands; package com.gmail.nossr50.runnables.commands;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
@ -11,9 +10,9 @@ public class NotifySquelchReminderTask extends BukkitRunnable {
@Override @Override
public void run() { public void run() {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
if(UserManager.getPlayer(player) != null) if(mcMMO.getUserManager().getPlayer(player) != null)
{ {
if(!UserManager.getPlayer(player).useChatNotifications()) if(!mcMMO.getUserManager().getPlayer(player).useChatNotifications())
{ {
player.sendMessage(LocaleLoader.getString("Reminder.Squelched")); player.sendMessage(LocaleLoader.getString("Reminder.Squelched"));
} }

View File

@ -9,7 +9,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
@ -27,11 +26,11 @@ public class FormulaConversionTask extends BukkitRunnable {
int convertedUsers = 0; int convertedUsers = 0;
long startMillis = System.currentTimeMillis(); long startMillis = System.currentTimeMillis();
for (String playerName : mcMMO.getDatabaseManager().getStoredUsers()) { for (String playerName : mcMMO.getDatabaseManager().getStoredUsers()) {
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); McMMOPlayer mmoPlayer = mcMMO.getUserManager().getOfflinePlayer(playerName);
PlayerProfile profile; PlayerProfile profile;
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. // 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 (mcMMOPlayer == null) { if (mmoPlayer == null) {
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false);
if (!profile.isLoaded()) { if (!profile.isLoaded()) {
@ -44,7 +43,7 @@ public class FormulaConversionTask extends BukkitRunnable {
profile.scheduleAsyncSave(); profile.scheduleAsyncSave();
} }
else { else {
profile = mcMMOPlayer.getProfile(); profile = mmoPlayer;
editValues(profile); editValues(profile);
} }
convertedUsers++; convertedUsers++;

View File

@ -13,10 +13,10 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
public class ChimaeraWingWarmup extends BukkitRunnable { public class ChimaeraWingWarmup extends BukkitRunnable {
private final McMMOPlayer mcMMOPlayer; private final McMMOPlayer mmoPlayer;
public ChimaeraWingWarmup(McMMOPlayer mcMMOPlayer) { public ChimaeraWingWarmup(McMMOPlayer mmoPlayer) {
this.mcMMOPlayer = mcMMOPlayer; this.mmoPlayer = mmoPlayer;
} }
@Override @Override
@ -25,12 +25,12 @@ public class ChimaeraWingWarmup extends BukkitRunnable {
} }
private void checkChimaeraWingTeleport() { private void checkChimaeraWingTeleport() {
Player player = mcMMOPlayer.getPlayer(); Player player = mmoPlayer.getPlayer();
Location previousLocation = mcMMOPlayer.getTeleportCommenceLocation(); Location previousLocation = mmoPlayer.getTeleportCommenceLocation();
if (player.getLocation().distanceSquared(previousLocation) > 1.0 || !player.getInventory().containsAtLeast(ChimaeraWing.getChimaeraWing(0), 1)) { if (player.getLocation().distanceSquared(previousLocation) > 1.0 || !player.getInventory().containsAtLeast(ChimaeraWing.getChimaeraWing(0), 1)) {
player.sendMessage(LocaleLoader.getString("Teleport.Cancelled")); player.sendMessage(LocaleLoader.getString("Teleport.Cancelled"));
mcMMOPlayer.setTeleportCommenceLocation(null); mmoPlayer.setTeleportCommenceLocation(null);
return; return;
} }
@ -41,7 +41,7 @@ public class ChimaeraWingWarmup extends BukkitRunnable {
return; return;
} }
long recentlyHurt = mcMMOPlayer.getRecentlyHurt(); long recentlyHurt = mmoPlayer.getRecentlyHurtTimestamp();
int hurtCooldown = Config.getInstance().getChimaeraRecentlyHurtCooldown(); int hurtCooldown = Config.getInstance().getChimaeraRecentlyHurtCooldown();
if (hurtCooldown > 0) { if (hurtCooldown > 0) {

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.runnables.items;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
@ -14,25 +13,25 @@ import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
public class TeleportationWarmup extends BukkitRunnable { public class TeleportationWarmup extends BukkitRunnable {
private final McMMOPlayer mcMMOPlayer; private final McMMOPlayer mmoPlayer;
private final McMMOPlayer mcMMOTarget; private final McMMOPlayer mcMMOTarget;
public TeleportationWarmup(McMMOPlayer mcMMOPlayer, McMMOPlayer mcMMOTarget) { public TeleportationWarmup(McMMOPlayer mmoPlayer, McMMOPlayer mcMMOTarget) {
this.mcMMOPlayer = mcMMOPlayer; this.mmoPlayer = mmoPlayer;
this.mcMMOTarget = mcMMOTarget; this.mcMMOTarget = mcMMOTarget;
} }
@Override @Override
public void run() { public void run() {
Player teleportingPlayer = mcMMOPlayer.getPlayer(); Player teleportingPlayer = mmoPlayer.getPlayer();
Player targetPlayer = mcMMOTarget.getPlayer(); Player targetPlayer = mcMMOTarget.getPlayer();
Location previousLocation = mcMMOPlayer.getTeleportCommenceLocation(); Location previousLocation = mmoPlayer.getTeleportCommenceLocation();
Location newLocation = mcMMOPlayer.getPlayer().getLocation(); Location newLocation = mmoPlayer.getPlayer().getLocation();
long recentlyHurt = mcMMOPlayer.getRecentlyHurt(); long recentlyHurt = mmoPlayer.getRecentlyHurtTimestamp();
mcMMOPlayer.setTeleportCommenceLocation(null); mmoPlayer.setTeleportCommenceLocation(null);
if (!PartyManager.inSameParty(teleportingPlayer, targetPlayer)) { if (!mcMMO.getPartyManager().inSameParty(teleportingPlayer, targetPlayer)) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetPlayer.getName())); teleportingPlayer.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetPlayer.getName()));
return; return;
} }

Some files were not shown because too many files have changed in this diff Show More