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.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
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:
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
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 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)
@ -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
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
Added new locale string "Profile.Loading.FailureNotice"
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 the Updater was running on the main thread.
= 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 which causes /party teleport to stop working
= 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.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -11,38 +11,38 @@ public final class AbilityAPI {
private AbilityAPI() {}
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) {
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) {
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) {
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) {
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) {
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) {
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) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
for (SuperAbilityType ability : SuperAbilityType.values()) {
if (mcMMOPlayer.getSuperAbilityManager().getAbilityMode(ability)) {
if (mmoPlayer.getSuperAbilityManager().getAbilityMode(ability)) {
return true;
}
}
@ -51,35 +51,35 @@ public final class AbilityAPI {
}
public static void resetCooldowns(Player player) {
UserManager.getPlayer(player).resetCooldowns();
mcMMO.getUserManager().getPlayer(player).getPersistentPlayerData().resetCooldowns();
}
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) {
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) {
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) {
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) {
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) {
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) {
UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.TREE_FELLER, cooldown);
mcMMO.getUserManager().getPlayer(player).getPersistentPlayerData().setAbilityDATS(SuperAbilityType.TREE_FELLER, cooldown);
}
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.PartyChatManager;
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.plugin.Plugin;
@ -75,7 +73,7 @@ public final class ChatAPI {
* @return true if the player is using party chat, false otherwise
*/
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
*/
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
*/
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
*/
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.
*/
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.
*/
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.
*/
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.
*/
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) {
ChatManager chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.PARTY);
((PartyChatManager) chatManager).setParty(PartyManager.getParty(party));
((PartyChatManager) chatManager).setParty(mcMMO.getPartyManager().getParty(party));
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.mcMMO;
import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import org.bukkit.block.BlockState;
import org.bukkit.entity.LivingEntity;
@ -41,29 +40,29 @@ public final class ExperienceAPI {
* 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
*
* @param mcMMOPlayer The attacking player
* @param mmoPlayer The attacking player
* @param target The defending entity
* @param primarySkillType The skill being used
* @param multiplier final XP result will be multiplied by this
* @deprecated Draft API
*/
@Deprecated
public static void addCombatXP(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType, double multiplier) {
CombatUtils.processCombatXP(mcMMOPlayer, target, primarySkillType, multiplier);
public static void addCombatXP(McMMOPlayer mmoPlayer, LivingEntity target, PrimarySkillType primarySkillType, double multiplier) {
CombatUtils.processCombatXP(mmoPlayer, target, primarySkillType, multiplier);
}
/**
* 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
*
* @param mcMMOPlayer The attacking player
* @param mmoPlayer The attacking player
* @param target The defending entity
* @param primarySkillType The skill being used
* @deprecated Draft API
*/
@Deprecated
public static void addCombatXP(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType) {
CombatUtils.processCombatXP(mcMMOPlayer, target, primarySkillType);
public static void addCombatXP(McMMOPlayer mmoPlayer, LivingEntity target, PrimarySkillType 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) {
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;
}
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
*/
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);
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;
}
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) {
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;
}
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
*/
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
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
*/
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
*/
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
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
*/
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
*/
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
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
*/
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) {
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);
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);
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
*/
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);
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;
}
profile.addLevels(skill, levels);
profile.scheduleAsyncSave();
profile.getExperienceManager().addLevels(skill, levels);
mcMMO.getUserManager().scheduleAsyncSave(profile.getPersistentPlayerData());
}
/**
@ -659,15 +658,15 @@ public final class ExperienceAPI {
Set<PrimarySkillType> parentSkills = FamilyTree.getParents(skill);
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;
}
profile.addLevels(skill, levels);
profile.scheduleAsyncSave();
profile.getExperienceManager().addLevels(skill, levels);
mcMMO.getUserManager().scheduleAsyncSave(profile.getPersistentPlayerData());
}
/**
@ -684,7 +683,7 @@ public final class ExperienceAPI {
*/
@Deprecated
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
*/
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
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
*/
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
*/
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);
for (PrimarySkillType type : PrimarySkillType.NON_CHILD_SKILLS) {
powerLevel += profile.getSkillLevel(type);
powerLevel += profile.getExperienceManager().getSkillLevel(type);
}
return powerLevel;
@ -784,7 +783,7 @@ public final class ExperienceAPI {
PlayerProfile profile = getOfflineProfile(uuid);
for (PrimarySkillType type : PrimarySkillType.NON_CHILD_SKILLS) {
powerLevel += profile.getSkillLevel(type);
powerLevel += profile.getExperienceManager().getSkillLevel(type);
}
return powerLevel;
@ -895,7 +894,7 @@ public final class ExperienceAPI {
* @throws InvalidSkillException if the given skill is not valid
*/
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
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
*/
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
*/
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
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
*/
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
*/
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
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
*/
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
* @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)
{
@ -1073,7 +1072,7 @@ public final class ExperienceAPI {
{
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
* @param blockStates the blocks to reward XP for
* @param mcMMOPlayer the target player
* @param mmoPlayer the target player
* @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)
{
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
* @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())
{
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
* @param blockState The target blockstate
* @param mcMMOPlayer The target player
* @param mmoPlayer The target player
* @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)
{
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) {
PlayerProfile profile = getOfflineProfile(playerUniqueId);
profile.addXp(skill, XP);
profile.save(true);
profile.getExperienceManager().addXp(skill, XP);
mcMMO.getUserManager().scheduleAsyncSave(profile.getPersistentPlayerData());
}
@Deprecated
private static void addOfflineXP(String playerName, PrimarySkillType skill, int XP) {
PlayerProfile profile = getOfflineProfile(playerName);
profile.addXp(skill, XP);
profile.scheduleAsyncSave();
profile.getExperienceManager().addXp(skill, XP);
mcMMO.getUserManager().scheduleAsyncSave(profile.getPersistentPlayerData());
}
private static PlayerProfile getOfflineProfile(UUID uuid) {
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid);
if (!profile.isLoaded()) {
if (profile == null) {
throw new InvalidPlayerException();
}
@ -1159,7 +1158,7 @@ public final class ExperienceAPI {
UUID uuid = mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId();
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid);
if (!profile.isLoaded()) {
if (profile == null) {
throw new InvalidPlayerException();
}
@ -1214,10 +1213,10 @@ public final class ExperienceAPI {
*/
@Deprecated
private static McMMOPlayer getPlayer(Player player) throws McMMOPlayerNotFoundException {
if (!UserManager.hasPlayerDataKey(player)) {
if (!mcMMO.getUserManager().hasPlayerDataKey(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.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyLeader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
@ -29,7 +26,7 @@ public final class PartyAPI {
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
*/
public static boolean inParty(Player player) {
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
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
*/
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.
*/
public static List<Party> getParties() {
return PartyManager.getParties();
return mcMMO.getPartyManager().getParties();
}
/**
@ -83,22 +80,22 @@ public final class PartyAPI {
@Deprecated
public static void addToParty(Player player, String partyName) {
//Check if player profile is loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
return;
Party party = PartyManager.getParty(partyName);
Party party = mcMMO.getPartyManager().getParty(partyName);
if (party == null) {
party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
} else {
if(PartyManager.isPartyFull(player, party))
if(mcMMO.getPartyManager().isPartyFull(player, party))
{
NotificationManager.sendPlayerInformation(player, NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull", party.toString());
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?
public static void addToParty(Player player, String partyName, boolean bypassLimit) {
//Check if player profile is loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
return;
Party party = PartyManager.getParty(partyName);
Party party = mcMMO.getPartyManager().getParty(partyName);
if (party == null) {
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) {
//Check if player profile is loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
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
*/
public static String getPartyLeader(String partyName) {
return PartyManager.getPartyLeaderName(partyName);
return mcMMO.getPartyManager().getPartyLeaderName(partyName);
}
/**
@ -172,7 +169,7 @@ public final class PartyAPI {
*/
@Deprecated
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) {
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);
members.add(member);
}
@ -204,7 +201,7 @@ public final class PartyAPI {
*/
@Deprecated
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
*/
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
*/
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
*/
public static List<Player> getOnlineMembers(Player player) {
return PartyManager.getOnlineMembers(player);
return mcMMO.getPartyManager().getOnlineMembers(player);
}
public static boolean hasAlly(String partyName) {
@ -248,9 +245,9 @@ public final class PartyAPI {
}
public static String getAllyName(String partyName) {
Party ally = PartyManager.getParty(partyName).getAlly();
Party ally = mcMMO.getPartyManager().getParty(partyName).getAlly();
if (ally != null) {
return ally.getName();
return ally.getPartyName();
}
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.McMMOPartyChatEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@ -47,20 +46,20 @@ public abstract class ChatManager {
McMMOPartyChatEvent partyChatEvent = (McMMOPartyChatEvent) event;
//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
if(mcMMOPlayer.isPartyChatSpying())
if(mmoPlayer.isPartyChatSpying())
{
Party adminParty = mcMMOPlayer.getParty();
Party adminParty = mmoPlayer.getParty();
//Only message admins not part of this party
if(adminParty != null)
{
//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));
} else {
player.sendMessage(LocaleLoader.getString("Commands.AdminChatSpy.Chat", partyChatEvent.getParty(), message));

View File

@ -19,7 +19,7 @@ public class PartyChatManager extends ChatManager {
@Override
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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -31,7 +30,7 @@ public abstract class ToggleCommand implements TabExecutor {
return true;
}
applyCommandAction(UserManager.getPlayer(sender.getName()));
applyCommandAction(mcMMO.getUserManager().getPlayer(sender.getName()));
return true;
case 1:
@ -41,17 +40,17 @@ public abstract class ToggleCommand implements TabExecutor {
}
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;
}
if (CommandUtils.isOffline(sender, mcMMOPlayer.getPlayer())) {
if (CommandUtils.isOffline(sender, mmoPlayer.getPlayer())) {
return true;
}
applyCommandAction(mcMMOPlayer);
applyCommandAction(mmoPlayer);
sendSuccessMessage(sender, playerName);
return true;
@ -71,6 +70,6 @@ public abstract class ToggleCommand implements TabExecutor {
protected abstract boolean hasOtherPermission(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);
}

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.admin;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -14,9 +13,9 @@ public class PlayerDebugCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if(sender instanceof Player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
mcMMOPlayer.toggleDebugMode(); //Toggle debug mode
NotificationManager.sendPlayerInformationChatOnlyPrefixed(mcMMOPlayer.getPlayer(), "Commands.Mmodebug.Toggle", String.valueOf(mcMMOPlayer.isDebugMode()));
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer((Player) sender);
mmoPlayer.toggleDebugMode(); //Toggle debug mode
NotificationManager.sendPlayerInformationChatOnlyPrefixed(mmoPlayer.getPlayer(), "Commands.Mmodebug.Toggle", String.valueOf(mmoPlayer.isDebugMode()));
return true;
} else {
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.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -32,7 +31,7 @@ public abstract class ChatCommand implements TabExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
McMMOPlayer mcMMOPlayer;
McMMOPlayer mmoPlayer;
switch (args.length) {
case 0:
@ -44,13 +43,13 @@ public abstract class ChatCommand implements TabExecutor {
return true;
}
mcMMOPlayer = UserManager.getPlayer(sender.getName());
mmoPlayer = mcMMO.getUserManager().getPlayer(sender.getName());
if (mcMMOPlayer.isChatEnabled(chatMode)) {
disableChatMode(mcMMOPlayer, sender);
if (mmoPlayer.isChatEnabled(chatMode)) {
disableChatMode(mmoPlayer, sender);
}
else {
enableChatMode(mcMMOPlayer, sender);
enableChatMode(mmoPlayer, sender);
}
return true;
@ -64,7 +63,7 @@ public abstract class ChatCommand implements TabExecutor {
return true;
}
enableChatMode(UserManager.getPlayer(sender.getName()), sender);
enableChatMode(mcMMO.getUserManager().getPlayer(sender.getName()), sender);
return true;
}
@ -76,7 +75,7 @@ public abstract class ChatCommand implements TabExecutor {
return true;
}
disableChatMode(UserManager.getPlayer(sender.getName()), sender);
disableChatMode(mcMMO.getUserManager().getPlayer(sender.getName()), sender);
return true;
}
@ -114,28 +113,28 @@ public abstract class ChatCommand implements TabExecutor {
protected abstract void handleChatSending(CommandSender sender, String[] args);
private void enableChatMode(McMMOPlayer mcMMOPlayer, CommandSender sender) {
if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) {
private void enableChatMode(McMMOPlayer mmoPlayer, CommandSender sender) {
if (chatMode == ChatMode.PARTY && mmoPlayer.getParty() == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
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"));
return;
}
mcMMOPlayer.enableChat(chatMode);
mmoPlayer.enableChat(chatMode);
sender.sendMessage(chatMode.getEnabledMessage());
}
private void disableChatMode(McMMOPlayer mcMMOPlayer, CommandSender sender) {
if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) {
private void disableChatMode(McMMOPlayer mmoPlayer, CommandSender sender) {
if (chatMode == ChatMode.PARTY && mmoPlayer.getParty() == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return;
}
mcMMOPlayer.disableChat(chatMode);
mmoPlayer.disableChat(chatMode);
sender.sendMessage(chatMode.getDisabledMessage());
}
}

View File

@ -18,9 +18,9 @@ public class McChatSpy extends ToggleCommand {
}
@Override
protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.AdminChatSpy." + (mcMMOPlayer.isPartyChatSpying() ? "Disabled" : "Enabled")));
mcMMOPlayer.togglePartyChatSpying();
protected void applyCommandAction(McMMOPlayer mmoPlayer) {
mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.AdminChatSpy." + (mmoPlayer.isPartyChatSpying() ? "Disabled" : "Enabled")));
mmoPlayer.togglePartyChatSpying();
}
@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.PartyFeature;
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.entity.Player;
@ -23,10 +21,10 @@ public class PartyChatCommand extends ChatCommand {
if (sender instanceof Player) {
//Check if player profile is loaded
if(UserManager.getPlayer((Player) sender) == null)
if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
return;
party = UserManager.getPlayer((Player) sender).getParty();
party = mcMMO.getUserManager().getPlayer((Player) sender).getParty();
if (party == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
@ -46,7 +44,7 @@ public class PartyChatCommand extends ChatCommand {
return;
}
party = PartyManager.getParty(args[0]);
party = mcMMO.getPartyManager().getParty(args[0]);
if (party == null) {
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.runnables.database.DatabaseConversionTask;
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
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()));
UserManager.saveAll();
UserManager.clearAll();
mcMMO.getUserManager().saveAllSync();
mcMMO.getUserManager().clearAll();
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
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.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
@ -22,7 +21,7 @@ public class McremoveCommand implements TabExecutor {
if (args.length == 1) {
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;
}

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.CommandSender;
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) {
if (player != null) {
//Check if player profile is loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
return;
UserManager.getPlayer(player).applyXpGain(skill, value, XPGainReason.COMMAND, XPGainSource.COMMAND);
mcMMO.getUserManager().getPlayer(player).applyXpGain(skill, value, XPGainReason.COMMAND, XPGainSource.COMMAND);
}
else {
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.runnables.database.FormulaConversionTask;
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
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()));
UserManager.saveAll();
UserManager.clearAll();
mcMMO.getUserManager().saveAllSync();
mcMMO.getUserManager().clearAll();
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.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
@ -55,14 +54,14 @@ public abstract class ExperienceCommand implements TabExecutor {
}
//Profile not loaded
if(UserManager.getPlayer(sender.getName()) == null)
if(mcMMO.getUserManager().getPlayer(sender.getName()) == null)
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill, Integer.parseInt(args[1]));
editValues((Player) sender, mcMMO.getUserManager().getPlayer(sender.getName()), skill, Integer.parseInt(args[1]));
return true;
case 3:
@ -90,10 +89,10 @@ public abstract class ExperienceCommand implements TabExecutor {
int value = Integer.parseInt(args[2]);
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 (mcMMOPlayer == null) {
// If the mmoPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mmoPlayer == null) {
UUID uuid = null;
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName);
if (player != null) {
@ -108,7 +107,7 @@ public abstract class ExperienceCommand implements TabExecutor {
editValues(null, profile, skill, value);
}
else {
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, value);
editValues(mmoPlayer.getPlayer(), mmoPlayer, skill, value);
}
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.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
@ -53,7 +52,7 @@ public class SkillresetCommand implements TabExecutor {
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;
case 2:
@ -74,10 +73,10 @@ public class SkillresetCommand implements TabExecutor {
}
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 (mcMMOPlayer == null) {
// If the mmoPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mmoPlayer == null) {
UUID uuid = null;
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName);
if (player != null) {
@ -92,7 +91,7 @@ public class SkillresetCommand implements TabExecutor {
editValues(null, profile, skill);
}
else {
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill);
editValues(mmoPlayer.getPlayer(), mmoPlayer, 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.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -17,25 +15,25 @@ public class PartyAcceptCommand implements CommandExecutor {
Player player = (Player) sender;
//Check if player profile is loaded
if (UserManager.getPlayer(player) == null) {
if (mcMMO.getUserManager().getPlayer(player) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
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"));
return true;
}
// Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) {
if (!mcMMO.getPartyManager().changeOrJoinParty(mmoPlayer, mmoPlayer.getPartyInvite().getName())) {
return true;
}
PartyManager.joinInvitedParty(mcMMOPlayer);
mcMMO.getPartyManager().joinInvitedParty(mmoPlayer);
return true;
}
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.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -17,12 +15,12 @@ public class PartyChangeOwnerCommand implements CommandExecutor {
@Override
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 (UserManager.getPlayer((Player) sender) == null) {
if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
Party playerParty = mcMMO.getUserManager().getPlayer((Player) sender).getParty();
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(targetName);
@ -31,7 +29,7 @@ public class PartyChangeOwnerCommand implements CommandExecutor {
return true;
}
PartyManager.setPartyLeader(target.getUniqueId(), playerParty);
mcMMO.getPartyManager().setPartyLeader(target.getUniqueId(), playerParty);
return true;
}
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.locale.LocaleLoader;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -12,13 +11,13 @@ import org.jetbrains.annotations.NotNull;
public class PartyChangePasswordCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if(UserManager.getPlayer((Player) sender) == null)
if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
Party party = UserManager.getPlayer((Player) sender).getParty();
Party party = mcMMO.getUserManager().getPlayer((Player) sender).getParty();
switch (args.length) {
case 1:
@ -42,14 +41,14 @@ public class PartyChangePasswordCommand implements CommandExecutor {
}
private void unprotectParty(Party party, CommandSender sender) {
party.setLocked(true);
party.setPassword(null);
party.setPartyLock(true);
party.setPartyPassword(null);
sender.sendMessage(LocaleLoader.getString("Party.Password.Removed"));
}
private void protectParty(Party party, CommandSender sender, String password) {
party.setLocked(true);
party.setPassword(password);
party.setPartyLock(true);
party.setPartyPassword(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.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -71,20 +71,20 @@ public class PartyCommand implements TabExecutor {
Player player = (Player) sender;
if (!UserManager.hasPlayerDataKey(player)) {
if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return true;
}
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
if (args.length < 1) {
if (!mcMMOPlayer.inParty()) {
if (!mcMMO.getPartyManager().mmoPlayer.inParty()) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return printUsage(player);
}
@ -118,7 +118,7 @@ public class PartyCommand implements TabExecutor {
}
// Party member commands
if (!mcMMOPlayer.inParty()) {
if (!mmoPlayer.inParty()) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return printUsage(player);
}
@ -139,7 +139,7 @@ public class PartyCommand implements TabExecutor {
}
// 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"));
return true;
}
@ -206,13 +206,13 @@ public class PartyCommand implements TabExecutor {
Player player = (Player) sender;
//Not Loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return ImmutableList.of();
}
Party party = UserManager.getPlayer(player).getParty();
Party party = mcMMO.getUserManager().getPlayer(player).getParty();
playerNames = party.getOnlinePlayerNames(player);
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.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -17,25 +15,25 @@ public class PartyCreateCommand implements CommandExecutor {
case 2:
case 3:
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"));
return true;
}
// 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;
}
// Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, args[1])) {
if (!mcMMO.getPartyManager().changeOrJoinParty(mmoPlayer, args[1])) {
return true;
}
PartyManager.createParty(mcMMOPlayer, args[1], getPassword(args));
mcMMO.getPartyManager().createParty(mmoPlayer, args[1], getPassword(args));
return true;
default:

View File

@ -3,8 +3,6 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
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.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -15,23 +13,23 @@ public class PartyDisbandCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 1) {
if (UserManager.getPlayer((Player) sender) == null) {
if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
String partyName = playerParty.getName();
Party playerParty = mcMMO.getUserManager().getPlayer((Player) sender).getParty();
String partyName = playerParty.getPartyName();
for (Player member : playerParty.getOnlineMembers()) {
if (!PartyManager.handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) {
for (Player member : playerParty.getPartyMembers()) {
if (!mcMMO.getPartyManager().handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) {
return true;
}
member.sendMessage(LocaleLoader.getString("Party.Disband"));
}
PartyManager.disbandParty(playerParty);
mcMMO.getPartyManager().disbandParty(playerParty);
return true;
}
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.player.McMMOPlayer;
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.command.Command;
import org.bukkit.command.CommandExecutor;
@ -24,19 +22,19 @@ public class PartyInfoCommand implements CommandExecutor {
switch (args.length) {
case 0:
case 1:
if(UserManager.getPlayer((Player) sender) == null)
if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
Party party = mcMMOPlayer.getParty();
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
Party party = mmoPlayer.getParty();
displayPartyHeader(player, party);
displayShareModeInfo(player, party);
displayPartyFeatures(player, party);
displayMemberInfo(player, mcMMOPlayer, party);
displayMemberInfo(player, mmoPlayer, party);
return true;
default:
@ -49,7 +47,7 @@ public class PartyInfoCommand implements CommandExecutor {
player.sendMessage(LocaleLoader.getString("Commands.Party.Header"));
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()) {
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
*/
List<Player> nearMembers = PartyManager.getNearVisibleMembers(mcMMOPlayer);
List<Player> nearMembers = mcMMO.getPartyManager().getNearVisibleMembers(mmoPlayer);
int membersOnline = party.getVisibleMembers(player).size();
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.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
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) {
if (args.length == 2) {
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
McMMOPlayer mcMMOTarget = mcMMO.getUserManager().getOfflinePlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;
@ -26,13 +24,13 @@ public class PartyInviteCommand implements CommandExecutor {
Player target = mcMMOTarget.getPlayer();
if (UserManager.getPlayer((Player) sender) == null) {
if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
String playerName = player.getName();
if (player.equals(target)) {
@ -40,19 +38,19 @@ public class PartyInviteCommand implements CommandExecutor {
return true;
}
if (PartyManager.inSameParty(player, target)) {
if (mcMMO.getPartyManager().inSameParty(player, target)) {
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
return true;
}
if (!PartyManager.canInvite(mcMMOPlayer)) {
if (!mcMMO.getPartyManager().canInvite(mmoPlayer)) {
player.sendMessage(LocaleLoader.getString("Party.Locked"));
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()));
return true;
}
@ -60,7 +58,7 @@ public class PartyInviteCommand implements CommandExecutor {
mcMMOTarget.setPartyInvite(playerParty);
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"));
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.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -20,13 +19,13 @@ import java.util.Locale;
public class PartyItemShareCommand implements CommandExecutor {
@Override
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"));
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)) {
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())));
for (Player member : party.getOnlineMembers()) {
for (Player member : party.getPartyMembers()) {
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");
for (Player member : party.getOnlineMembers()) {
for (Player member : party.getPartyMembers()) {
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.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -19,7 +17,7 @@ public class PartyJoinCommand implements CommandExecutor {
case 2:
case 3:
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
McMMOPlayer mcMMOTarget = mcMMO.getUserManager().getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return true;
@ -34,16 +32,16 @@ public class PartyJoinCommand implements CommandExecutor {
Player player = (Player) sender;
if(UserManager.getPlayer((Player) sender) == null)
if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
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"));
return true;
}
@ -51,25 +49,25 @@ public class PartyJoinCommand implements CommandExecutor {
String password = getPassword(args);
// Make sure party passwords match
if (!PartyManager.checkPartyPassword(player, targetParty, password)) {
if (!mcMMO.getPartyManager().checkPartyPassword(player, targetParty, password)) {
return true;
}
String partyName = targetParty.getName();
String partyName = targetParty.getPartyName();
// Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, partyName)) {
if (!mcMMO.getPartyManager().changeOrJoinParty(mmoPlayer, partyName)) {
return true;
}
if(PartyManager.isPartyFull(player, targetParty))
if(mcMMO.getPartyManager().isPartyFull(player, targetParty))
{
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull", targetParty.toString()));
return true;
}
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", partyName));
PartyManager.addToParty(mcMMOPlayer, targetParty);
mcMMO.getPartyManager().addToParty(mmoPlayer, targetParty);
return true;
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.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -18,12 +16,12 @@ public class PartyKickCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 2) {
if (UserManager.getPlayer((Player) sender) == null) {
if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
Party playerParty = mcMMO.getUserManager().getPlayer((Player) sender).getParty();
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
if (!playerParty.hasMember(targetName)) {
@ -35,17 +33,17 @@ public class PartyKickCommand implements CommandExecutor {
if (target.isOnline()) {
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;
}
PartyManager.processPartyLeaving(UserManager.getPlayer(onlineTarget));
mcMMO.getPartyManager().processPartyLeaving(mcMMO.getUserManager().getPlayer(onlineTarget));
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
}
PartyManager.removeFromParty(target, playerParty);
mcMMO.getPartyManager().removeFromParty(target, playerParty);
return true;
}
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.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -55,13 +54,13 @@ public class PartyLockCommand implements CommandExecutor {
}
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"));
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)) {
sender.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
@ -73,7 +72,7 @@ public class PartyLockCommand implements CommandExecutor {
return;
}
party.setLocked(lock);
party.setPartyLock(lock);
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.events.party.McMMOPartyChangeEvent.EventReason;
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.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -18,19 +16,19 @@ public class PartyQuitCommand implements CommandExecutor {
if (args.length == 1) {
Player player = (Player) sender;
if (UserManager.getPlayer((Player) sender) == null) {
if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
Party playerParty = mcMMOPlayer.getParty();
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
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;
}
PartyManager.removeFromParty(mcMMOPlayer);
mcMMO.getPartyManager().removeFromParty(mmoPlayer);
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
return true;
}

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands.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.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -16,15 +16,15 @@ public class PartyRenameCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 2) {
if (UserManager.getPlayer((Player) sender) == null) {
if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
Party playerParty = mcMMOPlayer.getParty();
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer((Player) sender);
Party playerParty = mmoPlayer.getParty();
String oldPartyName = playerParty.getName();
String oldPartyName = playerParty.getPartyName();
String newPartyName = args[1];
// 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;
}
Player player = mcMMOPlayer.getPlayer();
Player player = mmoPlayer.getPlayer();
// 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;
}
String leaderName = playerParty.getLeader().getPlayerName();
for (Player member : playerParty.getOnlineMembers()) {
if (!PartyManager.handlePartyChangeEvent(member, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) {
for (PartyMember partyMember : playerParty.getPartyMembers()) {
if (!mcMMO.getPartyManager().handlePartyChangeEvent(partyMember, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) {
return true;
}
if (!member.getName().equalsIgnoreCase(leaderName)) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leaderName, newPartyName));
if (!partyMember.getName().equalsIgnoreCase(leaderName)) {
partyMember.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leaderName, newPartyName));
}
}
playerParty.setName(newPartyName);
playerParty.setPartyName(newPartyName);
sender.sendMessage(LocaleLoader.getString("Commands.Party.Rename", newPartyName));
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.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -17,13 +16,13 @@ import org.jetbrains.annotations.NotNull;
public class PartyXpShareCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if(UserManager.getPlayer((Player) sender) == null)
if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
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)) {
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())));
for (Player member : party.getOnlineMembers()) {
for (Player member : party.getPartyMembers()) {
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.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -14,24 +12,24 @@ public class PartyAllianceAcceptCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 2) {
if (UserManager.getPlayer((Player) sender) == null) {
if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
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"));
return true;
}
if (mcMMOPlayer.getParty().getAlly() != null) {
if (mmoPlayer.getParty().getAlly() != null) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies"));
return true;
}
PartyManager.acceptAllianceInvite(mcMMOPlayer);
mcMMO.getPartyManager().acceptAllianceInvite(mmoPlayer);
return true;
}
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.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@ -38,16 +36,16 @@ public class PartyAllianceCommand implements TabExecutor {
return true;
}
if(UserManager.getPlayer((Player) sender) == null)
if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
playerParty = mcMMOPlayer.getParty();
playerParty = mmoPlayer.getParty();
switch (args.length) {
case 1:
@ -64,7 +62,7 @@ public class PartyAllianceCommand implements TabExecutor {
targetParty = playerParty.getAlly();
displayPartyHeader();
displayMemberInfo(mcMMOPlayer);
displayMemberInfo(mmoPlayer);
return true;
case 2:
@ -94,7 +92,7 @@ public class PartyAllianceCommand implements TabExecutor {
targetParty = playerParty.getAlly();
displayPartyHeader();
displayMemberInfo(mcMMOPlayer);
displayMemberInfo(mmoPlayer);
return true;
default:
@ -125,11 +123,11 @@ public class PartyAllianceCommand implements TabExecutor {
private void displayPartyHeader() {
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) {
List<Player> nearMembers = PartyManager.getNearMembers(mcMMOPlayer);
private void displayMemberInfo(McMMOPlayer mmoPlayer) {
List<Player> nearMembers = mcMMO.getPartyManager().getNearMembers(mmoPlayer);
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Members.Header"));
player.sendMessage(playerParty.createMembersList(player));
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.player.McMMOPlayer;
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.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -15,20 +13,20 @@ public class PartyAllianceDisbandCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 2) {
if (UserManager.getPlayer((Player) sender) == null) {
if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
Party party = mcMMOPlayer.getParty();
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
Party party = mmoPlayer.getParty();
if (party.getAlly() == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.None"));
return true;
}
PartyManager.disbandAlliance(player, party, party.getAlly());
mcMMO.getPartyManager().disbandAlliance(player, party, party.getAlly());
return true;
}
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.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
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) {
if (args.length == 3) {
String targetName = CommandUtils.getMatchedPlayerName(args[2]);
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
McMMOPlayer mcMMOTarget = mcMMO.getUserManager().getOfflinePlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;
@ -25,13 +23,13 @@ public class PartyAllianceInviteCommand implements CommandExecutor {
Player target = mcMMOTarget.getPlayer();
if (UserManager.getPlayer((Player) sender) == null) {
if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
String playerName = player.getName();
if (player.equals(target)) {
@ -44,7 +42,7 @@ public class PartyAllianceInviteCommand implements CommandExecutor {
return true;
}
if (PartyManager.inSameParty(player, target)) {
if (mcMMO.getPartyManager().inSameParty(player, target)) {
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
return true;
}
@ -54,7 +52,7 @@ public class PartyAllianceInviteCommand implements CommandExecutor {
return true;
}
Party playerParty = mcMMOPlayer.getParty();
Party playerParty = mmoPlayer.getParty();
if (playerParty.getAlly() != null) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies"));
@ -64,7 +62,7 @@ public class PartyAllianceInviteCommand implements CommandExecutor {
mcMMOTarget.setPartyAllianceInvite(playerParty);
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"));
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.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -17,7 +16,7 @@ public class PtpAcceptAnyCommand implements CommandExecutor {
return true;
}
PartyTeleportRecord ptpRecord = UserManager.getPlayer(sender.getName()).getPartyTeleportRecord();
PartyTeleportRecord ptpRecord = mcMMO.getUserManager().getPlayer(sender.getName()).getPartyTeleportRecord();
if (ptpRecord.isConfirmRequired()) {
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.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.World;
import org.bukkit.command.Command;
@ -21,14 +20,14 @@ public class PtpAcceptCommand implements CommandExecutor {
return true;
}
if(UserManager.getPlayer((Player) sender) == null)
if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
PartyTeleportRecord ptpRecord = UserManager.getPlayer(player).getPartyTeleportRecord();
PartyTeleportRecord ptpRecord = mcMMO.getUserManager().getPlayer(player).getPartyTeleportRecord();
if (!ptpRecord.hasRequest()) {
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.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.items.TeleportationWarmup;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
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.worldguard.WorldGuardManager;
import com.gmail.nossr50.worldguard.WorldGuardUtils;
@ -57,24 +55,24 @@ public class PtpCommand implements TabExecutor {
if(WorldBlacklist.isWorldBlacklisted(player.getWorld()))
return true;
if (!UserManager.hasPlayerDataKey(player)) {
if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return true;
}
if(UserManager.getPlayer((Player) sender) == null)
if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
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"));
return true;
}
Party party = mcMMOPlayer.getParty();
Party party = mmoPlayer.getParty();
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.TELEPORT)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.2"));
@ -90,7 +88,7 @@ public class PtpCommand implements TabExecutor {
return ptpAcceptAnyCommand.onCommand(sender, command, label, args);
}
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
long recentlyHurt = mmoPlayer.getRecentlyHurtTimestamp();
int hurtCooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown();
if (hurtCooldown > 0) {
@ -112,7 +110,7 @@ public class PtpCommand implements TabExecutor {
}
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
long ptpLastUse = mcMMOPlayer.getPartyTeleportRecord().getLastUse();
long ptpLastUse = mmoPlayer.getPartyTeleportRecord().getLastUse();
if (ptpCooldown > 0) {
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()));
if (matches.size() == 0) {
if (UserManager.getPlayer((Player) sender) == null) {
if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return ImmutableList.of();
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
if (!mcMMOPlayer.inParty()) {
if (!mmoPlayer.inParty()) {
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()));
}
@ -161,7 +159,7 @@ public class PtpCommand implements TabExecutor {
return;
}
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
McMMOPlayer mcMMOTarget = mcMMO.getUserManager().getPlayer(targetName);
Player target = mcMMOTarget.getPlayer();
@ -198,7 +196,7 @@ public class PtpCommand implements TabExecutor {
}
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)) {
return false;
@ -211,7 +209,7 @@ public class PtpCommand implements TabExecutor {
return false;
}
if (!PartyManager.inSameParty(player, target)) {
if (!mcMMO.getPartyManager().inSameParty(player, target)) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
return false;
}
@ -230,28 +228,28 @@ public class PtpCommand implements TabExecutor {
}
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"));
return;
}
if(UserManager.getPlayer(teleportingPlayer) == null)
if(mcMMO.getUserManager().getPlayer(teleportingPlayer) == null)
{
teleportingPlayer.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetPlayer);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(teleportingPlayer);
McMMOPlayer mcMMOTarget = mcMMO.getUserManager().getPlayer(targetPlayer);
long warmup = Config.getInstance().getPTPCommandWarmup();
mcMMOPlayer.actualizeTeleportCommenceLocation(teleportingPlayer);
mmoPlayer.actualizeTeleportCommenceLocation(teleportingPlayer);
if (warmup > 0) {
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 {
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.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -17,7 +16,7 @@ public class PtpToggleCommand implements CommandExecutor {
return true;
}
PartyTeleportRecord ptpRecord = UserManager.getPlayer(sender.getName()).getPartyTeleportRecord();
PartyTeleportRecord ptpRecord = mcMMO.getUserManager().getPlayer(sender.getName()).getPartyTeleportRecord();
if (ptpRecord.isEnabled()) {
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.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList;
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) {
if (args.length == 1) {
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 (mcMMOPlayer == null) {
// If the mmoPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mmoPlayer == null) {
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); // Temporary Profile
if (!CommandUtils.isLoaded(sender, profile)) {
@ -62,7 +61,7 @@ public class InspectCommand implements TabExecutor {
}
} else {
Player target = mcMMOPlayer.getPlayer();
Player target = mmoPlayer.getPlayer();
if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) {
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()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile());
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mmoPlayer);
if (!Config.getInstance().getInspectUseChat()) {
return true;
@ -83,7 +82,7 @@ public class InspectCommand implements TabExecutor {
CommandUtils.printGatheringSkills(target, sender);
CommandUtils.printCombatSkills(target, sender);
CommandUtils.printMiscSkills(target, sender);
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mmoPlayer.getPowerLevel()));
}
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.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList;
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"));
return true;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header"));
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
@ -53,7 +52,7 @@ public class MccooldownCommand implements TabExecutor {
continue;
}
int seconds = mcMMOPlayer.calculateTimeRemaining(ability);
int seconds = mmoPlayer.calculateTimeRemaining(ability);
if (seconds <= 0) {
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.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -53,10 +52,10 @@ public class McrankCommand implements TabExecutor {
}
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getOfflinePlayer(playerName);
if (mcMMOPlayer != null) {
Player player = mcMMOPlayer.getPlayer();
if (mmoPlayer != null) {
Player player = mmoPlayer.getPlayer();
playerName = player.getName();
if (CommandUtils.tooFar(sender, player, Permissions.mcrankFar(sender))) {
@ -83,9 +82,9 @@ public class McrankCommand implements TabExecutor {
private void display(CommandSender sender, String playerName) {
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"));
return;
@ -93,8 +92,8 @@ public class McrankCommand implements TabExecutor {
long cooldownMillis = Math.min(Config.getInstance().getDatabasePlayerCooldown(), 1750);
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.CooldownMS", getCDSeconds(mcMMOPlayer, cooldownMillis)));
if (mmoPlayer.getDatabaseCommandATS() + cooldownMillis > System.currentTimeMillis()) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.CooldownMS", getCDSeconds(mmoPlayer, cooldownMillis)));
return;
}
@ -105,7 +104,7 @@ public class McrankCommand implements TabExecutor {
((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());
@ -114,7 +113,7 @@ public class McrankCommand implements TabExecutor {
new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
}
private long getCDSeconds(McMMOPlayer mcMMOPlayer, long cooldownMillis) {
return ((mcMMOPlayer.getDatabaseATS() + cooldownMillis) - System.currentTimeMillis());
private long getCDSeconds(McMMOPlayer mmoPlayer, long cooldownMillis) {
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.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
@ -26,7 +25,7 @@ public class McstatsCommand implements TabExecutor {
}
if (args.length == 0) {
if (UserManager.getPlayer((Player) sender) == null) {
if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
@ -51,9 +50,9 @@ public class McstatsCommand implements TabExecutor {
int powerLevelCap = Config.getInstance().getPowerLevelCap();
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 {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMO.getUserManager().getPlayer(player).getPowerLevel()));
}
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.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -85,11 +84,11 @@ public class MctopCommand implements TabExecutor {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(sender.getName());
long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750);
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
double seconds = ((mcMMOPlayer.getDatabaseATS() + cooldownMillis) - System.currentTimeMillis()) / 1000.0D;
if (mmoPlayer.getDatabaseCommandATS() + cooldownMillis > System.currentTimeMillis()) {
double seconds = ((mmoPlayer.getDatabaseCommandATS() + cooldownMillis) - System.currentTimeMillis()) / 1000.0D;
if (seconds < 1) {
seconds = 1;
}
@ -105,7 +104,7 @@ public class MctopCommand implements TabExecutor {
((Player) sender).setMetadata(mcMMO.databaseCommandKey, new FixedMetadataValue(mcMMO.p, null));
}
mcMMOPlayer.actualizeDatabaseATS();
mmoPlayer.actualizeDatabaseCommandATS();
}
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.skills.PrimarySkillType;
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.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
@ -24,7 +23,7 @@ public class XPBarCommand implements TabExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if(sender instanceof Player) {
McMMOPlayer mmoPlayer = UserManager.getPlayer((Player) sender);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer((Player) sender);
if(mmoPlayer == null) {
NotificationManager.sendPlayerInformationChatOnlyPrefixed(mmoPlayer.getPlayer(), "Profile.PendingLoad");
return false;
@ -35,10 +34,10 @@ public class XPBarCommand implements TabExecutor {
} else if(args.length < 2) {
String option = args[0];
if(option.equalsIgnoreCase(ExperienceBarManager.XPBarSettingTarget.RESET.toString())) {
mmoPlayer.getExperienceBarManager().xpBarSettingToggle(ExperienceBarManager.XPBarSettingTarget.RESET, null);
if(option.equalsIgnoreCase(MMOExperienceBarManager.XPBarSettingTarget.RESET.toString())) {
mmoPlayer.getExperienceBarManager().xpBarSettingToggle(MMOExperienceBarManager.XPBarSettingTarget.RESET, null);
return true;
} else if(option.equalsIgnoreCase(ExperienceBarManager.XPBarSettingTarget.DISABLE.toString())) {
} else if(option.equalsIgnoreCase(MMOExperienceBarManager.XPBarSettingTarget.DISABLE.toString())) {
mmoPlayer.getExperienceBarManager().disableAllBars();
return true;
} else {
@ -56,8 +55,8 @@ public class XPBarCommand implements TabExecutor {
//Target setting
String option = args[0].toLowerCase();
ExperienceBarManager.XPBarSettingTarget settingTarget = getSettingTarget(option);
if(settingTarget != null && settingTarget != ExperienceBarManager.XPBarSettingTarget.RESET) {
MMOExperienceBarManager.XPBarSettingTarget settingTarget = getSettingTarget(option);
if(settingTarget != null && settingTarget != MMOExperienceBarManager.XPBarSettingTarget.RESET) {
//Change setting
mmoPlayer.getExperienceBarManager().xpBarSettingToggle(settingTarget, targetSkill);
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()) {
case "hide":
return ExperienceBarManager.XPBarSettingTarget.HIDE;
return MMOExperienceBarManager.XPBarSettingTarget.HIDE;
case "show":
return ExperienceBarManager.XPBarSettingTarget.SHOW;
return MMOExperienceBarManager.XPBarSettingTarget.SHOW;
case "reset":
return ExperienceBarManager.XPBarSettingTarget.RESET;
return MMOExperienceBarManager.XPBarSettingTarget.RESET;
case "disable":
return ExperienceBarManager.XPBarSettingTarget.DISABLE;
return MMOExperienceBarManager.XPBarSettingTarget.DISABLE;
}
return null;
@ -96,13 +95,13 @@ public class XPBarCommand implements TabExecutor {
case 1:
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()));
}
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:
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()));
default:
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.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
@ -31,13 +30,13 @@ public class AlchemyCommand extends SkillCommand {
protected String[] calculateAbilityDisplayValues(Player player) {
//TODO: Needed?
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
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];
boolean isLucky = Permissions.lucky(player, PrimarySkillType.ALCHEMY);
@ -59,7 +58,7 @@ public class AlchemyCommand extends SkillCommand {
// ALCHEMY_CONCOCTIONS
if (canConcoctions) {
AlchemyManager alchemyManager = UserManager.getPlayer(player).getAlchemyManager();
AlchemyManager alchemyManager = mcMMO.getUserManager().getPlayer(player).getAlchemyManager();
tier = alchemyManager.getTier();
ingredientCount = alchemyManager.getIngredients().size();
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.util.Permissions;
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.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
@ -38,7 +37,7 @@ public class AxesCommand extends SkillCommand {
protected void dataCalculations(Player player, float skillValue) {
// ARMOR IMPACT
if (canImpact) {
impactDamage = UserManager.getPlayer(player).getAxesManager().getImpactDurabilityDamage();
impactDamage = mcMMO.getUserManager().getPlayer(player).getAxesManager().getImpactDurabilityDamage();
}
// 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.skills.crossbows.CrossbowManager;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import net.md_5.bungee.api.chat.TextComponent;
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) {
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)) {
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.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
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) {
List<String> messages = new ArrayList<>();
ExcavationManager excavationManager = UserManager.getPlayer(player).getExcavationManager();
ExcavationManager excavationManager = mcMMO.getUserManager().getPlayer(player).getExcavationManager();
if (canGigaDrill) {
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.util.Permissions;
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.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
@ -51,7 +50,7 @@ public class FishingCommand extends SkillCommand {
@Override
protected void dataCalculations(Player player, float skillValue) {
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
FishingManager fishingManager = mcMMO.getUserManager().getPlayer(player).getFishingManager();
// TREASURE HUNTER
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.util.Permissions;
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.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
@ -42,7 +41,7 @@ public class MiningCommand extends SkillCommand {
protected void dataCalculations(Player player, float skillValue) {
// BLAST MINING
if (canBlast || canDemoExpert || canBiggerBombs) {
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
MiningManager miningManager = mcMMO.getUserManager().getPlayer(player).getMiningManager();
blastMiningRank = miningManager.getBlastMiningTier();
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.util.Permissions;
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.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
@ -94,7 +93,7 @@ public class RepairCommand extends SkillCommand {
List<String> messages = new ArrayList<>();
if (canArcaneForge) {
RepairManager repairManager = UserManager.getPlayer(player).getRepairManager();
RepairManager repairManager = mcMMO.getUserManager().getPlayer(player).getRepairManager();
messages.add(getStatMessage(false, true,
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.SalvageManager;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
@ -37,7 +36,7 @@ public class SalvageCommand extends SkillCommand {
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager();
SalvageManager salvageManager = mcMMO.getUserManager().getPlayer(player).getSalvageManager();
if (canScrapCollector) {
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.commands.CommandUtils;
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.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.PerksUtils;
@ -59,7 +58,7 @@ public abstract class SkillCommand implements TabExecutor {
return true;
}
if(UserManager.getPlayer((Player) sender) == null)
if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
@ -67,11 +66,11 @@ public abstract class SkillCommand implements TabExecutor {
if (args.length == 0) {
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
boolean isLucky = Permissions.lucky(player, skill);
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
if (AdvancedConfig.getInstance().doesSkillCommandSendBlankLines())
@ -82,7 +81,7 @@ public abstract class SkillCommand implements TabExecutor {
permissionsCheck(player);
dataCalculations(player, skillValue);
sendSkillCommandHeader(player, mcMMOPlayer, (int) skillValue);
sendSkillCommandHeader(player, mmoPlayer, (int) skillValue);
//Make JSON text components
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)));
}
private void sendSkillCommandHeader(Player player, McMMOPlayer mcMMOPlayer, int skillValue) {
private void sendSkillCommandHeader(Player player, McMMOPlayer mmoPlayer, int skillValue) {
ChatColor hd1 = ChatColor.DARK_AQUA;
ChatColor c1 = ChatColor.GOLD;
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()))));
//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 {
/*
@ -164,7 +163,7 @@ public abstract class SkillCommand implements TabExecutor {
Set<PrimarySkillType> parents = FamilyTree.getParents(skill);
//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);
StringBuilder parentMessage = new StringBuilder();
@ -173,10 +172,10 @@ public abstract class SkillCommand implements TabExecutor {
{
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(", ");
} 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()) {
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("Effects.Level", skillValue, mcMMOPlayer.getSkillXpLevel(skill), mcMMOPlayer.getXpToLevel(skill)));
player.sendMessage(LocaleLoader.getString("Effects.Level", skillValue, mmoPlayer.getSkillXpLevel(skill), mmoPlayer.getXpToLevel(skill)));
} else {
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.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);
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.util.Permissions;
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.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
@ -34,7 +33,7 @@ public class SmeltingCommand extends SkillCommand {
protected void dataCalculations(Player player, float skillValue) {
// FUEL EFFICIENCY
if (canFuelEfficiency) {
burnTimeModifier = String.valueOf(UserManager.getPlayer(player).getSmeltingManager().getFuelEfficiencyMultiplier());
burnTimeModifier = String.valueOf(mcMMO.getUserManager().getPlayer(player).getSmeltingManager().getFuelEfficiencyMultiplier());
}
// FLUX MINING
@ -81,7 +80,7 @@ public class SmeltingCommand extends SkillCommand {
if (canUnderstandTheArt) {
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;

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
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.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
@ -44,7 +43,7 @@ public class SwordsCommand extends SkillCommand {
// SWORDS_RUPTURE
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);
bleedChance = bleedStrings[0];
@ -70,7 +69,7 @@ public class SwordsCommand extends SkillCommand {
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
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 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))
{
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)) {

View File

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

View File

@ -638,7 +638,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
/* GENERAL */
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() {
return config.getBoolean("Feedback.PlayerTips", true);

View File

@ -1,7 +1,7 @@
package com.gmail.nossr50.config;
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.skills.PrimarySkillType;
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); }
/* Mob Healthbar */
public MobHealthbarType getMobHealthbarDefault() {
public MobHealthBarType getMobHealthbarDefault() {
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) {
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); }
/* 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 */
public int getChimaeraUseCost() { return config.getInt("Items.Chimaera_Wing.Use_Cost", 1); }
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.datatypes.database.DatabaseType;
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.skills.PrimarySkillType;
@ -40,15 +41,14 @@ public interface DatabaseManager {
* Currently only used for SQL
* @param uuid target UUID to cleanup
*/
void cleanupUser(UUID uuid);
void removeCache(UUID uuid);
/**
* Save a user to the database.
*
* @param profile The profile of the player to save
* @return true if successful, false on failure
* @param mmoDataSnapshot Snapshot of player data to save
*/
boolean saveUser(PlayerProfile profile);
boolean saveUser(MMODataSnapshot mmoDataSnapshot);
/**
* Retrieve leaderboard info.
@ -79,20 +79,6 @@ public interface DatabaseManager {
*/
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.
*
@ -101,18 +87,6 @@ public interface DatabaseManager {
*/
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.
*
@ -128,9 +102,9 @@ public interface DatabaseManager {
*/
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.

View File

@ -23,7 +23,7 @@ public class DatabaseManagerFactory {
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) {
case FLATFILE:
mcMMO.p.getLogger().info("Using FlatFile Database");
return new FlatfileDatabaseManager();
return new FlatFileDatabaseManager();
case SQL:
mcMMO.p.getLogger().info("Using SQL Database");

View File

@ -1,337 +1,96 @@
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.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.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.command.CommandSender;
import org.bukkit.entity.Player;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
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 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 String name;
private String password;
private boolean locked;
private Party ally;
private int level;
private float xp;
private final String partyName;
private String partyPassword;
private boolean partyLock;
private ShareMode xpShareMode = ShareMode.NONE;
private ShareMode itemShareMode = ShareMode.NONE;
private final PartyMemberManager partyMemberManager;
private final PartyItemShareManager partyItemShareManager;
private final PartyExperienceManager partyExperienceManager;
private final PartyAllianceManager partyAllianceManager;
private boolean shareLootDrops = true;
private boolean shareMiningDrops = true;
private boolean shareHerbalismDrops = true;
private boolean shareWoodcuttingDrops = true;
private boolean shareMiscDrops = true;
public static final String PARTY_LEADER_PREFIX = ChatColor.GOLD
+ ""
+ ChatColor.RESET;
public Party(String name) {
this.name = name;
}
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);
public Party(String partyName, HashSet<PartyMember> partyMembers, int partyLevel) throws RuntimeException {
if(partyMembers.isEmpty()) {
throw new RuntimeException("No party members for the party named "+ partyName);
}
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) {
Player player = sender instanceof Player ? (Player) sender : null;
List<String> onlinePlayerNames = new ArrayList<>();
for (Player onlinePlayer : getOnlineMembers()) {
if (player != null && player.canSee(onlinePlayer)) {
onlinePlayerNames.add(onlinePlayer.getName());
}
}
return onlinePlayerNames;
public Party(Player partyLeader, String partyName, String partyPassword) {
this.partyName = partyName;
this.partyPassword = partyPassword;
this.partyLock = true;
this.partyLevel = 0;
this.partyMemberManager = new PartyMemberManager(partyLeader);
this.partyItemShareManager = new PartyItemShareManager();
}
public boolean addOnlineMember(Player player) {
return onlineMembers.add(player);
public HashSet<PartyMember> getPartyMembers() {
return partyMemberManager.getPartyMembers();
}
public boolean removeOnlineMember(Player player) {
return onlineMembers.remove(player);
public String getPartyName() {
return partyName;
}
public String getName() {
return name;
}
public PartyLeader getLeader() {
return leader;
}
public String getPassword() {
return password;
public String getPartyPassword() {
return partyPassword;
}
public boolean isLocked() {
return locked;
return partyLock;
}
public Party getAlly() {
return ally;
}
public List<String> getItemShareCategories() {
List<String> shareCategories = new ArrayList<>();
public void setPartyName(String partyName) {
this.partyName = partyName;
}
for (ItemShareType shareType : ItemShareType.values()) {
if (sharingDrops(shareType)) {
shareCategories.add(shareType.getLocaleString());
}
public void setLeader(UUID newPartyLeader) {
this.partyMemberManager = ;
}
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;
}
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);
return false;
}
/**
@ -342,189 +101,39 @@ public class Party {
* @return formatted list of party members from the POV of a 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 */
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();
if(isPartyLeaderOfflineOrHidden)
{
if(isNotSamePerson(player.getUniqueId(), leader.getUniqueId()))
applyOnlineAndRangeFormatting(memberList, false, false);
StringBuilder formattedPartyMemberList = new StringBuilder();
memberList.append(ChatColor.GRAY)
.append(leader.getPlayerName());
}
else {
if(isNotSamePerson(leader.getUniqueId(), player.getUniqueId()))
applyOnlineAndRangeFormatting(memberList, true, nearbyPlayerList.contains(Bukkit.getPlayer(leader.getUniqueId())));
PartyMember partyLeader = getLeader();
if(useDisplayNames) {
memberList.append(leader.getPlayerName());
} 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(" ");
// }
//First add the party leader
memberList.append(PARTY_LEADER_PREFIX);
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.
*
* @param mcMMOPlayer The player to check
* @param mmoPlayer The player to check
* @return the near party members
*/
public List<Player> getNearMembers(McMMOPlayer mcMMOPlayer) {
public List<Player> getNearMembers(McMMOPlayer mmoPlayer) {
List<Player> nearMembers = new ArrayList<>();
Party party = mcMMOPlayer.getParty();
Party party = mmoPlayer.getParty();
if (party != null) {
Player player = mcMMOPlayer.getPlayer();
Player player = mmoPlayer.getPlayer();
double range = Config.getInstance().getPartyShareRange();
for (Player member : party.getOnlineMembers()) {
if (!player.equals(member) && member.isValid() && Misc.isNear(player.getLocation(), member.getLocation(), range)) {
nearMembers.add(member);
for (PartyMember partyMember : party.getPartyMembers()) {
if (!player.getUniqueId().equals(partyMember.getOfflinePlayer().getUniqueId())
&& 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
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
public boolean equals(Object o) {
}
if (!(obj instanceof Party)) {
return false;
}
Party other = (Party) obj;
if ((this.getName() == null) || (other.getName() == null)) {
return false;
}
return this.getName().equals(other.getName());
@Override
public int hashCode() {
return ;
}
}

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.Permissions;
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.RandomChanceUtil;
import com.gmail.nossr50.util.skills.PerksUtils;
@ -66,9 +65,9 @@ public class Roll extends AcrobaticsSubSkill {
return false;
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;
/*
@ -76,7 +75,7 @@ public class Roll extends AcrobaticsSubSkill {
*/
Player player = (Player) ((EntityDamageEvent) event).getEntity();
if (canRoll(player)) {
entityDamageEvent.setDamage(rollCheck(player, mcMMOPlayer, entityDamageEvent.getDamage()));
entityDamageEvent.setDamage(rollCheck(player, mmoPlayer, entityDamageEvent.getDamage()));
if (entityDamageEvent.getFinalDamage() == 0) {
entityDamageEvent.setCancelled(true);
@ -120,7 +119,7 @@ public class Roll extends AcrobaticsSubSkill {
String rollChance, rollChanceLucky, gracefulRollChance, gracefulRollChanceLucky;
/* Values related to the player */
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
PlayerProfile playerProfile = mcMMO.getUserManager().getPlayer(player);
float skillValue = playerProfile.getSkillLevel(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
* @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()) {
return gracefulRollCheck(player, mcMMOPlayer, damage, skillLevel);
return gracefulRollCheck(player, mmoPlayer, damage, skillLevel);
}
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);
//player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
//if (!SkillUtils.cooldownExpired((long) mcMMOPlayer.getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) {
if(!isExploiting(player) && mcMMOPlayer.getAcrobaticsManager().canGainRollXP())
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE);
//if (!SkillUtils.cooldownExpired((long) mmoPlayer.getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) {
if(!isExploiting(player) && mmoPlayer.getAcrobaticsManager().canGainRollXP())
SkillUtils.applyXpGain(mmoPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE);
//}
addFallLocation(player);
return modifiedDamage;
}
else if (!isFatal(player, damage)) {
//if (!SkillUtils.cooldownExpired((long) mcMMOPlayer.getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) {
if(!isExploiting(player) && mcMMOPlayer.getAcrobaticsManager().canGainRollXP())
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, false), XPGainReason.PVE);
//if (!SkillUtils.cooldownExpired((long) mmoPlayer.getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) {
if(!isExploiting(player) && mmoPlayer.getAcrobaticsManager().canGainRollXP())
SkillUtils.applyXpGain(mmoPlayer, getPrimarySkill(), calculateRollXP(player, damage, false), XPGainReason.PVE);
//}
}
@ -222,8 +221,8 @@ public class Roll extends AcrobaticsSubSkill {
return damage;
}
private int getActivationChance(McMMOPlayer mcMMOPlayer) {
return PerksUtils.handleLuckyPerks(mcMMOPlayer.getPlayer(), getPrimarySkill());
private int getActivationChance(McMMOPlayer mmoPlayer) {
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
* @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);
RandomChanceSkill rcs = new RandomChanceSkill(player, subSkillType);
@ -243,15 +242,15 @@ public class Roll extends AcrobaticsSubSkill {
{
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Ability.Proc");
SoundManager.sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS,0.5F);
if(!isExploiting(player) && mcMMOPlayer.getAcrobaticsManager().canGainRollXP())
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE);
if(!isExploiting(player) && mmoPlayer.getAcrobaticsManager().canGainRollXP())
SkillUtils.applyXpGain(mmoPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE);
addFallLocation(player);
return modifiedDamage;
}
else if (!isFatal(player, damage)) {
if(!isExploiting(player) && mcMMOPlayer.getAcrobaticsManager().canGainRollXP())
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, false), XPGainReason.PVE);
if(!isExploiting(player) && mmoPlayer.getAcrobaticsManager().canGainRollXP())
SkillUtils.applyXpGain(mmoPlayer, getPrimarySkill(), calculateRollXP(player, damage, false), XPGainReason.PVE);
addFallLocation(player);
}
@ -270,19 +269,19 @@ public class Roll extends AcrobaticsSubSkill {
return false;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
if (ItemUtils.hasItemInEitherHand(player, Material.ENDER_PEARL) || player.isInsideVehicle()) {
if(mcMMOPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage("Acrobatics XP Prevented: Ender Pearl or Inside Vehicle");
if(mmoPlayer.isDebugMode()) {
mmoPlayer.getPlayer().sendMessage("Acrobatics XP Prevented: Ender Pearl or Inside Vehicle");
}
return true;
}
if(UserManager.getPlayer(player).getAcrobaticsManager().hasFallenInLocationBefore(getBlockLocation(player)))
if(mcMMO.getUserManager().getPlayer(player).getAcrobaticsManager().hasFallenInLocationBefore(getBlockLocation(player)))
{
if(mcMMOPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage("Acrobatics XP Prevented: Fallen in location before");
if(mmoPlayer.isDebugMode()) {
mmoPlayer.getPlayer().sendMessage("Acrobatics XP Prevented: Fallen in location before");
}
return true;
@ -421,7 +420,7 @@ public class Roll extends AcrobaticsSubSkill {
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)

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

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.events.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
@ -17,7 +16,7 @@ public abstract class McMMOPlayerSkillEvent extends PlayerEvent {
protected McMMOPlayerSkillEvent(Player player, PrimarySkillType skill) {
super(player);
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.ItemUtils;
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.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
@ -211,7 +210,7 @@ public class BlockListener implements Listener {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return;
}
@ -224,16 +223,16 @@ public class BlockListener implements Listener {
mcMMO.getPlaceStore().setTrue(blockState);
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
if(mcMMOPlayer == null)
if(mmoPlayer == null)
return;
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)) {
mcMMOPlayer.getSalvageManager().placedAnvilCheck();
mmoPlayer.getSalvageManager().placedAnvilCheck();
}
}
@ -250,7 +249,7 @@ public class BlockListener implements Listener {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return;
}
@ -317,25 +316,25 @@ public class BlockListener implements Listener {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
if (!mcMMO.getUserManager().hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
//Check if profile is loaded
if(mcMMOPlayer == null)
if(mmoPlayer == null)
return;
ItemStack heldItem = player.getInventory().getItemInMainHand();
/* HERBALISM */
if (BlockUtils.affectedByGreenTerra(blockState)) {
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
HerbalismManager herbalismManager = mmoPlayer.getHerbalismManager();
/* Green Terra */
if (herbalismManager.canActivateAbility()) {
mcMMOPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.HERBALISM);
mmoPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.HERBALISM);
}
/*
@ -354,13 +353,13 @@ public class BlockListener implements Listener {
/* MINING */
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);
}
/* WOOD CUTTING */
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)) {
woodcuttingManager.processTreeFeller(blockState);
}
@ -371,10 +370,10 @@ public class BlockListener implements Listener {
/* EXCAVATION */
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);
if (mcMMOPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER)) {
if (mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER)) {
excavationManager.gigaDrillBreaker(blockState);
}
}
@ -407,12 +406,12 @@ public class BlockListener implements Listener {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
if (!mcMMO.getUserManager().hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return;
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
return;
}
@ -421,7 +420,7 @@ public class BlockListener implements Listener {
ItemStack heldItem = player.getInventory().getItemInMainHand();
if (ItemUtils.isSword(heldItem)) {
HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager();
HerbalismManager herbalismManager = mcMMO.getUserManager().getPlayer(player).getHerbalismManager();
if (herbalismManager.canUseHylianLuck()) {
if (herbalismManager.processHylianLuck(blockState)) {
@ -436,7 +435,7 @@ public class BlockListener implements Listener {
}
}
/*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.processFluxMining(blockState)) {
@ -471,14 +470,14 @@ public class BlockListener implements Listener {
if (event instanceof FakeBlockDamageEvent) {
return;
}
if (!UserManager.hasPlayerDataKey(player)) {
if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
//Profile not loaded
if(mcMMOPlayer == null)
if(mmoPlayer == null)
{
return;
}
@ -491,25 +490,25 @@ public class BlockListener implements Listener {
if (BlockUtils.canActivateAbilities(blockState)) {
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)) {
mcMMOPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.HERBALISM);
if (mmoPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.GREEN_TERRA_TOOL) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
mmoPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.HERBALISM);
}
else if (mcMMOPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.SKULL_SPLITTER_TOOL) && ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState) && Permissions.treeFeller(player)) {
mcMMOPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.WOODCUTTING);
else if (mmoPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.SKULL_SPLITTER_TOOL) && ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState) && Permissions.treeFeller(player)) {
mmoPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.WOODCUTTING);
}
else if (mcMMOPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.SUPER_BREAKER_TOOL) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
mcMMOPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.MINING);
else if (mmoPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.SUPER_BREAKER_TOOL) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
mmoPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.MINING);
}
else if (mcMMOPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.GIGA_DRILL_BREAKER_TOOL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
mcMMOPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.EXCAVATION);
else if (mmoPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.GIGA_DRILL_BREAKER_TOOL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
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())
|| blockState.getType() == Material.SNOW
|| 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)) {
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.
*/
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);
}
}
@ -557,14 +556,14 @@ public class BlockListener implements Listener {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
//Profile not loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
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.
*/
if (mcMMOPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState)) {
if (mcMMOPlayer.getHerbalismManager().processGreenTerraBlockConversion(blockState)) {
if (mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState)) {
if (mmoPlayer.getHerbalismManager().processGreenTerraBlockConversion(blockState)) {
blockState.update(true);
}
}
else if (mcMMOPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.BERSERK) && (heldItem.getType() == Material.AIR || Config.getInstance().getUnarmedItemsAsUnarmed())) {
if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState)) {
if (EventUtils.simulateBlockBreak(block, player, true) && mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
else if (mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.BERSERK) && (heldItem.getType() == Material.AIR || Config.getInstance().getUnarmedItemsAsUnarmed())) {
if (mmoPlayer.getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState)) {
if (EventUtils.simulateBlockBreak(block, player, true) && mmoPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
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);
SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
}
@ -608,10 +607,10 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockDamageCleanup(BlockDamageEvent event) {
Player player = event.getPlayer();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
//Profile not loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
return;
}
@ -620,7 +619,7 @@ public class BlockListener implements Listener {
ItemStack heldItem = player.getInventory().getItemInMainHand();
cleanupAbilityTools(player, mcMMOPlayer, blockState, heldItem);
cleanupAbilityTools(player, mmoPlayer, blockState, heldItem);
debugStickDump(player, blockState);
}
@ -629,19 +628,19 @@ public class BlockListener implements Listener {
//TODO: Convert into locale strings
private void debugStickDump(Player player, BlockState blockState) {
//Profile not loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
return;
}
if(UserManager.getPlayer(player).isDebugMode())
if(mcMMO.getUserManager().getPlayer(player).isDebugMode())
{
if(mcMMO.getPlaceStore().isTrue(blockState))
player.sendMessage("[mcMMO DEBUG] This block is not natural and does not reward treasures/XP");
else
{
player.sendMessage("[mcMMO DEBUG] This block is considered natural by mcMMO");
UserManager.getPlayer(player).getExcavationManager().printExcavationDebug(player, blockState);
mcMMO.getUserManager().getPlayer(player).getExcavationManager().printExcavationDebug(player, blockState);
}
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 ((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);
}
} 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);
}
}

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.FakeEntityTameEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.skills.archery.Archery;
import com.gmail.nossr50.skills.mining.BlastMining;
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.Permissions;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
@ -172,12 +170,12 @@ public class EntityListener implements Listener {
//Crossbow only
if(isCrossbow) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
//Process launch event
if(Permissions.skillEnabled(player, PrimarySkillType.CROSSBOWS)) {
if(mcMMOPlayer != null) {
mcMMOPlayer.getCrossbowManager().processProjectileLaunchEvent(event);
if(mmoPlayer != null) {
mmoPlayer.getCrossbowManager().processProjectileLaunchEvent(event);
}
}
@ -430,9 +428,9 @@ public class EntityListener implements Listener {
}
//Deflect checks
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(defendingPlayer);
if (mcMMOPlayer != null) {
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
final McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(defendingPlayer);
if (mmoPlayer != null) {
UnarmedManager unarmedManager = mmoPlayer.getUnarmedManager();
if (unarmedManager.canDeflect()) {
if (unarmedManager.deflectCheck()) {
@ -492,7 +490,7 @@ public class EntityListener implements Listener {
}
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;
}
@ -504,8 +502,8 @@ public class EntityListener implements Listener {
//Party Friendly Fire
if(!Config.getInstance().getPartyFriendlyFire())
if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer)
|| PartyManager.areAllies(defendingPlayer, attackingPlayer))
if ((mcMMO.getPartyManager().inSameParty(defendingPlayer, attackingPlayer)
|| mcMMO.getPartyManager().areAllies(defendingPlayer, attackingPlayer))
&& !(Permissions.friendlyFire(attackingPlayer)
&& Permissions.friendlyFire(defendingPlayer))) {
event.setCancelled(true);
@ -582,24 +580,24 @@ public class EntityListener implements Listener {
if (livingEntity instanceof Player) {
Player player = (Player) entity;
if (!UserManager.hasPlayerDataKey(player)) {
if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
//Profile not loaded
if(mcMMOPlayer == null)
if(mmoPlayer == null)
return;
/* Check for invincibility */
if (mcMMOPlayer.getGodMode()) {
if (mmoPlayer.getGodMode()) {
event.setCancelled(true);
return;
}
if (event.getFinalDamage() >= 1) {
mcMMOPlayer.actualizeRecentlyHurt();
mmoPlayer.actualizeRecentlyHurtTimestamp();
}
}
@ -624,12 +622,12 @@ public class EntityListener implements Listener {
Wolf wolf = (Wolf) pet;
//Profile not loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
return;
}
TamingManager tamingManager = UserManager.getPlayer(player).getTamingManager();
TamingManager tamingManager = mcMMO.getUserManager().getPlayer(player).getTamingManager();
switch (cause) {
case CONTACT:
@ -822,12 +820,12 @@ public class EntityListener implements Listener {
// using this exact metadata
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
if (!UserManager.hasPlayerDataKey(player)) {
if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return;
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
return;
}
@ -839,7 +837,7 @@ public class EntityListener implements Listener {
return;
}
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
MiningManager miningManager = mcMMO.getUserManager().getPlayer(player).getMiningManager();
if (miningManager.canUseBiggerBombs()) {
event.setRadius(miningManager.biggerBombs(event.getRadius()));
@ -868,7 +866,7 @@ public class EntityListener implements Listener {
// using this exact metadata
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
if (!UserManager.hasPlayerDataKey(player)) {
if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return;
}
@ -880,12 +878,12 @@ public class EntityListener implements Listener {
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
return;
}
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
MiningManager miningManager = mcMMO.getUserManager().getPlayer(player).getMiningManager();
if (miningManager.canUseBlastMining()) {
miningManager.blastMiningDropProcessing(event.getYield(), event);
@ -914,7 +912,7 @@ public class EntityListener implements Listener {
Player player = (Player) entity;
//Profile not loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
return;
}
@ -926,7 +924,7 @@ public class EntityListener implements Listener {
return;
}
if (!UserManager.hasPlayerDataKey(player)) {
if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return;
}
@ -979,7 +977,7 @@ public class EntityListener implements Listener {
* 1000
*/
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;
@ -991,7 +989,7 @@ public class EntityListener implements Listener {
*/
case POTATO: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) {
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel));
event.setFoodLevel(mcMMO.getUserManager().getPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel));
}
return;
case COD:
@ -1001,7 +999,7 @@ public class EntityListener implements Listener {
case COOKED_SALMON:
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;
@ -1036,19 +1034,19 @@ public class EntityListener implements Listener {
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;
}
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
//Profile not loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
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;
if (!UserManager.hasPlayerDataKey(player) || !CombatUtils.isFriendlyPet(player, tameable)) {
if (!mcMMO.getUserManager().hasPlayerDataKey(player) || !CombatUtils.isFriendlyPet(player, tameable)) {
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.util.ItemUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.worldguard.WorldGuardManager;
import com.gmail.nossr50.worldguard.WorldGuardUtils;
@ -67,12 +66,12 @@ public class InventoryListener implements Listener {
}
//Profile doesn't exist
if(UserManager.getOfflinePlayer(offlinePlayer) == null)
if(mcMMO.getUserManager().getOfflinePlayer(offlinePlayer) == null)
{
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) {
McMMOPlayer offlineProfile = UserManager.getOfflinePlayer(offlinePlayer);
McMMOPlayer offlineProfile = mcMMO.getUserManager().getOfflinePlayer(offlinePlayer);
//Profile doesn't exist
if(offlineProfile != null) {
@ -129,18 +128,18 @@ public class InventoryListener implements Listener {
return;
}
if (!UserManager.hasPlayerDataKey(player) || !Permissions.vanillaXpBoost(player, PrimarySkillType.SMELTING)) {
if (!mcMMO.getUserManager().hasPlayerDataKey(player) || !Permissions.vanillaXpBoost(player, PrimarySkillType.SMELTING)) {
return;
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
return;
}
int xpToDrop = event.getExpToDrop();
int exp = UserManager.getPlayer(player).getSmeltingManager().vanillaXPBoost(xpToDrop);
int exp = mcMMO.getUserManager().getPlayer(player).getSmeltingManager().vanillaXPBoost(xpToDrop);
event.setExpToDrop(exp);
}
}
@ -182,7 +181,7 @@ public class InventoryListener implements Listener {
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;
}
@ -295,7 +294,7 @@ public class InventoryListener implements Listener {
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;
}

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.SalvageManager;
import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
@ -87,17 +86,17 @@ public class PlayerListener implements Listener {
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;
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
return;
}
UserManager.getPlayer(player).actualizeTeleportATS();
mcMMO.getUserManager().getPlayer(player).actualizeTeleportATS();
}
/**
* Handle PlayerDeathEvents at the lowest priority.
@ -197,20 +196,20 @@ public class PlayerListener implements Listener {
public void onPlayerWorldChange(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return;
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
mcMMOPlayer.checkGodMode();
mcMMOPlayer.checkParty();
mmoPlayer.checkGodMode();
mmoPlayer.checkParty();
}
/**
@ -268,17 +267,17 @@ public class PlayerListener implements Listener {
return;
}
if (!UserManager.hasPlayerDataKey(player) || !PrimarySkillType.FISHING.getPermissions(player)) {
if (!mcMMO.getUserManager().hasPlayerDataKey(player) || !PrimarySkillType.FISHING.getPermissions(player)) {
return;
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
return;
}
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
FishingManager fishingManager = mcMMO.getUserManager().getPlayer(player).getFishingManager();
switch (event.getState()) {
case CAUGHT_FISH:
@ -346,18 +345,18 @@ public class PlayerListener implements Listener {
return;
}
if (!UserManager.hasPlayerDataKey(player) || !PrimarySkillType.FISHING.getPermissions(player)) {
if (!mcMMO.getUserManager().hasPlayerDataKey(player) || !PrimarySkillType.FISHING.getPermissions(player)) {
return;
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
return;
}
Entity caught = event.getCaught();
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
FishingManager fishingManager = mcMMO.getUserManager().getPlayer(player).getFishingManager();
//Track the hook
if(ExperienceConfig.getInstance().isFishingExploitingPrevented())
@ -441,17 +440,17 @@ public class PlayerListener implements Listener {
return;
}
if (!UserManager.hasPlayerDataKey(player)) {
if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return;
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
Item drop = event.getItem();
ItemStack dropStack = drop.getItemStack();
@ -469,8 +468,8 @@ public class PlayerListener implements Listener {
return;
}
if (!drop.hasMetadata(mcMMO.droppedItemKey) && mcMMOPlayer.inParty() && ItemUtils.isSharable(dropStack)) {
event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer));
if (!drop.hasMetadata(mcMMO.droppedItemKey) && mmoPlayer.inParty() && ItemUtils.isSharable(dropStack)) {
event.setCancelled(ShareHandler.handleItemShare(drop, mmoPlayer));
if (event.isCancelled()) {
SoundManager.sendSound(player, player.getLocation(), SoundType.POP);
@ -503,20 +502,23 @@ public class PlayerListener implements Listener {
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return;
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
//There's an issue with using Async saves on player quit
//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
mcMMOPlayer.logout(true);
//No need for null checks here
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
//TODO: There's an issue with using Async saves on player quit
//TODO: Basically there are conditions in which an async task does not execute fast enough to save the data if the server shutdown shortly after this task was scheduled
mcMMO.getUserManager().saveUserWithDelay(mmoPlayer.getPersistentPlayerData(), false, 20);
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) {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
return;
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
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;
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
MiningManager miningManager = mcMMOPlayer.getMiningManager();
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
MiningManager miningManager = mmoPlayer.getMiningManager();
ItemStack heldItem = player.getInventory().getItemInMainHand();
switch (event.getAction()) {
@ -628,7 +630,7 @@ public class PlayerListener implements Listener {
&& PrimarySkillType.REPAIR.getPermissions(player)
&& mcMMO.getRepairableManager().isRepairable(heldItem)
&& heldItem.getAmount() <= 1) {
RepairManager repairManager = mcMMOPlayer.getRepairManager();
RepairManager repairManager = mmoPlayer.getRepairManager();
event.setCancelled(true);
// 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)
&& mcMMO.getSalvageableManager().isSalvageable(heldItem)
&& heldItem.getAmount() <= 1) {
SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager();
SalvageManager salvageManager = mcMMO.getUserManager().getPlayer(player).getSalvageManager();
event.setCancelled(true);
// 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()) {
/* REPAIR CHECKS */
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
if (repairManager.checkConfirmation(false)) {
@ -683,7 +685,7 @@ public class PlayerListener implements Listener {
}
/* SALVAGE CHECKS */
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
if (salvageManager.checkConfirmation(false)) {
@ -720,17 +722,17 @@ public class PlayerListener implements Listener {
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;
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == null)
{
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
ItemStack heldItem = player.getInventory().getItemInMainHand();
//Spam Fishing Detection
@ -745,11 +747,11 @@ public class PlayerListener implements Listener {
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) {
Player player = event.getPlayer();
if (Misc.isNPCEntityExcludingVillagers(player) || !UserManager.hasPlayerDataKey(player)) {
if (Misc.isNPCEntityExcludingVillagers(player) || !mcMMO.getUserManager().hasPlayerDataKey(player)) {
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("Party & Admin chat will not work properly for this player.");
return;
@ -775,11 +777,11 @@ public class PlayerListener implements Listener {
ChatManager chatManager = null;
if (mcMMOPlayer.isChatEnabled(ChatMode.PARTY)) {
Party party = mcMMOPlayer.getParty();
if (mmoPlayer.isChatEnabled(ChatMode.PARTY)) {
Party party = mmoPlayer.getParty();
if (party == null) {
mcMMOPlayer.disableChat(ChatMode.PARTY);
mmoPlayer.disableChat(ChatMode.PARTY);
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return;
}
@ -787,7 +789,7 @@ public class PlayerListener implements Listener {
chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.PARTY);
((PartyChatManager) chatManager).setParty(party);
}
else if (mcMMOPlayer.isChatEnabled(ChatMode.ADMIN)) {
else if (mmoPlayer.isChatEnabled(ChatMode.ADMIN)) {
chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN);
}

View File

@ -39,14 +39,24 @@ public class SelfListener implements Listener {
{
int previousLevelGained = event.getSkillLevel() - i;
//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
RankUtils.resetUnlockDelayTimer();
for(int i = 0; i < event.getLevelsGained(); i++)
{
int previousLevelGained = event.getSkillLevel() - i;
//Send player skill unlock notifications
RankUtils.executeSkillUnlockNotifications(plugin, mcMMO.getUserManager().getPlayer(player), event.getSkill(), previousLevelGained);
}
if(Config.getInstance().getScoreboardsEnabled())
ScoreboardManager.handleLevelUp(player, skill);
//Reset the delay timer
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)
public void onPlayerXpGain(McMMOPlayerXpGainEvent event) {
Player player = event.getPlayer();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
PrimarySkillType primarySkillType = event.getSkill();
if(mcMMOPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage(event.getSkill().toString() + " XP Gained");
mcMMOPlayer.getPlayer().sendMessage("Incoming Raw XP: "+event.getRawXpGained());
if(mmoPlayer.isDebugMode()) {
mmoPlayer.getPlayer().sendMessage(event.getSkill().toString() + " XP Gained");
mmoPlayer.getPlayer().sendMessage("Incoming Raw XP: "+event.getRawXpGained());
}
//WorldGuard XP Check
@ -93,8 +103,8 @@ public class SelfListener implements Listener {
event.setRawXpGained(0);
event.setCancelled(true);
if(mcMMOPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage("No WG XP Flag - New Raw XP: "+event.getRawXpGained());
if(mmoPlayer.isDebugMode()) {
mmoPlayer.getPlayer().sendMessage("No WG XP Flag - New Raw XP: "+event.getRawXpGained());
}
}
}
@ -111,9 +121,9 @@ public class SelfListener implements Listener {
int earlyGameBonusXP = 0;
//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);
}
}
@ -121,8 +131,8 @@ public class SelfListener implements Listener {
int threshold = ExperienceConfig.getInstance().getDiminishedReturnsThreshold(primarySkillType);
if (threshold <= 0 || !ExperienceConfig.getInstance().getDiminishedReturnsEnabled()) {
if(mcMMOPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage("Final Raw XP: "+event.getRawXpGained());
if(mmoPlayer.isDebugMode()) {
mmoPlayer.getPlayer().sendMessage("Final Raw XP: "+event.getRawXpGained());
}
// Diminished returns is turned off
return;
@ -142,10 +152,10 @@ public class SelfListener implements Listener {
float guaranteedMinimum = ExperienceConfig.getInstance().getDiminishedReturnsCap() * rawXp;
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) {
// 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("Previous: " + event.getRawXpGained());
// System.out.println("Adjusted XP " + (event.getRawXpGained() - (event.getRawXpGained() * difference)));
@ -169,8 +179,8 @@ public class SelfListener implements Listener {
}
if(mcMMOPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage("Final Raw XP: "+event.getRawXpGained());
if(mmoPlayer.isDebugMode()) {
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.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.repair.RepairConfigManager;
import com.gmail.nossr50.config.skills.salvage.SalvageConfigManager;
@ -81,6 +77,8 @@ public class mcMMO extends JavaPlugin {
private static PlayerLevelUtils playerLevelUtils;
private static SmeltingTracker smeltingTracker;
private static SpawnedProjectileTracker spawnedProjectileTracker;
private static UserManager userManager;
private static PartyManager partyManager;
/* Blacklist */
private static WorldBlacklist worldBlacklist;
@ -176,10 +174,6 @@ public class mcMMO extends JavaPlugin {
//Store this value so other plugins can check it
isRetroModeEnabled = Config.getInstance().getIsRetroMode();
if (getServer().getName().equals("Cauldron") || getServer().getName().equals("MCPC+")) {
checkModConfigs();
}
if (healthBarPluginEnabled) {
getLogger().info("HealthBar plugin found, mcMMO's healthbars are automatically disabled.");
}
@ -214,7 +208,7 @@ public class mcMMO extends JavaPlugin {
registerCoreSkills();
registerCustomRecipes();
PartyManager.loadParties();
mcMMO.getPartyManager().loadParties();
formulaManager = new FormulaManager();
holidayManager = new HolidayManager();
@ -275,6 +269,9 @@ public class mcMMO extends JavaPlugin {
//Init spawned projectile tracker
spawnedProjectileTracker = new SpawnedProjectileTracker();
//Init Player Data Manager
userManager = new UserManager();
}
public static PlayerLevelUtils getPlayerLevelUtils() {
@ -311,10 +308,10 @@ public class mcMMO extends JavaPlugin {
@Override
public void onDisable() {
try {
UserManager.saveAll(); // Make sure to save player information if the server shuts down
UserManager.clearAll();
userManager.saveAllSync(); // Make sure to save player information if the server shuts down
userManager.clearAll();
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?
if(Config.getInstance().getScoreboardsEnabled())
@ -515,25 +512,8 @@ public class mcMMO extends JavaPlugin {
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
repairables.addAll(new RepairConfigManager(this).getLoadedRepairables());
repairables.addAll(modManager.getLoadedRepairables());
repairableManager = new SimpleRepairableManager(repairables.size());
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) {
InputStream in = getResource(fileName);
return in == null ? null : new InputStreamReader(in, Charsets.UTF_8);
@ -687,4 +645,12 @@ public class mcMMO extends JavaPlugin {
public static SpawnedProjectileTracker getSpawnedProjectileTracker() {
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.party.ItemShareType;
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.player.McMMOPlayer;
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.Permissions;
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.SoundType;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.*;
import java.util.Map.Entry;
import java.util.UUID;
public final class PartyManager {
private static final String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
private static final List<Party> parties = new ArrayList<>();
private static final File partyFile = new File(partiesFilePath);
private final @NotNull HashMap<String, Party> parties;
private final @NotNull File partyFile;
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.
@ -46,7 +46,7 @@ public final class PartyManager {
* @param partyName The name of the party to check
* @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) {
return false;
}
@ -61,29 +61,29 @@ public final class PartyManager {
* @param targetParty the target party
* @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.
*
* @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
* @return true if the party was joined successfully, false otherwise
*/
public static boolean changeOrJoinParty(McMMOPlayer mcMMOPlayer, String newPartyName) {
Player player = mcMMOPlayer.getPlayer();
public boolean changeOrJoinParty(McMMOPlayer mmoPlayer, String newPartyName) {
Player player = mmoPlayer.getPlayer();
if (mcMMOPlayer.inParty()) {
Party oldParty = mcMMOPlayer.getParty();
if (mmoPlayer.inParty()) {
Party oldParty = mmoPlayer.getParty();
if (!handlePartyChangeEvent(player, oldParty.getName(), newPartyName, EventReason.CHANGED_PARTIES)) {
if (!handlePartyChangeEvent(player, oldParty.getPartyName(), newPartyName, EventReason.CHANGED_PARTIES)) {
return false;
}
removeFromParty(mcMMOPlayer);
removeFromParty(mmoPlayer);
}
else return handlePartyChangeEvent(player, null, newPartyName, EventReason.JOINED_PARTY);
@ -97,21 +97,21 @@ public final class PartyManager {
* @param secondPlayer The second player
* @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
if(UserManager.getPlayer(firstPlayer) == null)
if(mcMMO.getUserManager().getPlayer(firstPlayer) == null)
{
return false;
}
//Profile not loaded
if(UserManager.getPlayer(secondPlayer) == null)
if(mcMMO.getUserManager().getPlayer(secondPlayer) == null)
{
return false;
}
Party firstParty = UserManager.getPlayer(firstPlayer).getParty();
Party secondParty = UserManager.getPlayer(secondPlayer).getParty();
Party firstParty = mcMMO.getUserManager().getPlayer(firstPlayer).getParty();
Party secondParty = mcMMO.getUserManager().getPlayer(secondPlayer).getParty();
if (firstParty == null || secondParty == null) {
return false;
@ -120,21 +120,21 @@ public final class PartyManager {
return firstParty.equals(secondParty);
}
public static boolean areAllies(Player firstPlayer, Player secondPlayer) {
public boolean areAllies(Player firstPlayer, Player secondPlayer) {
//Profile not loaded
if(UserManager.getPlayer(firstPlayer) == null)
if(mcMMO.getUserManager().getPlayer(firstPlayer) == null)
{
return false;
}
//Profile not loaded
if(UserManager.getPlayer(secondPlayer) == null)
if(mcMMO.getUserManager().getPlayer(secondPlayer) == null)
{
return false;
}
Party firstParty = UserManager.getPlayer(firstPlayer).getParty();
Party secondParty = UserManager.getPlayer(secondPlayer).getParty();
Party firstParty = mcMMO.getUserManager().getPlayer(firstPlayer).getParty();
Party secondParty = mcMMO.getUserManager().getPlayer(secondPlayer).getParty();
if (firstParty == null || secondParty == null || firstParty.getAlly() == null || secondParty.getAlly() == null) {
return false;
@ -146,18 +146,18 @@ public final class PartyManager {
/**
* Get the near party members.
*
* @param mcMMOPlayer The player to check
* @param mmoPlayer The player to check
* @return the near party members
*/
public static List<Player> getNearMembers(McMMOPlayer mcMMOPlayer) {
public List<Player> getNearMembers(McMMOPlayer mmoPlayer) {
List<Player> nearMembers = new ArrayList<>();
Party party = mcMMOPlayer.getParty();
Party party = mmoPlayer.getParty();
if (party != null) {
Player player = mcMMOPlayer.getPlayer();
Player player = mmoPlayer.getPlayer();
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)) {
nearMembers.add(member);
}
@ -167,12 +167,12 @@ public final class PartyManager {
return nearMembers;
}
public static List<Player> getNearVisibleMembers(McMMOPlayer mcMMOPlayer) {
public List<Player> getNearVisibleMembers(McMMOPlayer mmoPlayer) {
List<Player> nearMembers = new ArrayList<>();
Party party = mcMMOPlayer.getParty();
Party party = mmoPlayer.getParty();
if (party != null) {
Player player = mcMMOPlayer.getPlayer();
Player player = mmoPlayer.getPlayer();
double range = Config.getInstance().getPartyShareRange();
for (Player member : party.getVisibleMembers(player)) {
@ -194,7 +194,7 @@ public final class PartyManager {
* @param player The player to check
* @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);
return party == null ? new LinkedHashMap<>() : party.getMembers();
@ -206,7 +206,7 @@ public final class PartyManager {
* @param partyName The party to check
* @return all online players in this party
*/
public static List<Player> getOnlineMembers(String partyName) {
public List<Player> getOnlineMembers(String partyName) {
return getOnlineMembers(getParty(partyName));
}
@ -216,12 +216,12 @@ public final class PartyManager {
* @param player The player to check
* @return all online players in this party
*/
public static List<Player> getOnlineMembers(Player player) {
public List<Player> getOnlineMembers(Player player) {
return getOnlineMembers(getParty(player));
}
private static List<Player> getOnlineMembers(Party party) {
return party == null ? new ArrayList<>() : party.getOnlineMembers();
private List<Player> getOnlineMembers(Party party) {
return party == null ? new ArrayList<>() : party.getPartyMembers();
}
/**
@ -230,9 +230,9 @@ public final class PartyManager {
* @param partyName The party name
* @return the existing party, null otherwise
*/
public static Party getParty(String partyName) {
public Party getParty(String partyName) {
for (Party party : parties) {
if (party.getName().equalsIgnoreCase(partyName)) {
if (party.getPartyName().equalsIgnoreCase(partyName)) {
return party;
}
}
@ -247,7 +247,7 @@ public final class PartyManager {
* @return the existing party, null otherwise
*/
@Deprecated
public static Party getPlayerParty(String playerName) {
public Party getPlayerParty(String playerName) {
for (Party party : parties) {
if (party.getMembers().containsKey(playerName)) {
return party;
@ -263,7 +263,7 @@ public final class PartyManager {
* @param uuid The members uuid
* @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) {
LinkedHashMap<UUID, String> members = party.getMembers();
if (members.containsKey(uuid) || members.containsValue(playerName)) {
@ -286,16 +286,16 @@ public final class PartyManager {
* @param player The member
* @return the existing party, null otherwise
*/
public static Party getParty(Player player) {
public Party getParty(Player player) {
//Profile not loaded
if(UserManager.getPlayer(player) == null)
if(mcMMO.getUserManager().getPlayer(player) == 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.
*/
public static List<Party> getParties() {
public List<Party> getParties() {
return parties;
}
@ -313,14 +313,14 @@ public final class PartyManager {
* @param player The player to remove
* @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();
String playerName = player.getName();
members.remove(player.getUniqueId());
if (player.isOnline()) {
party.getOnlineMembers().remove(player.getPlayer());
party.getPartyMembers().remove(player.getPlayer());
}
if (members.isEmpty()) {
@ -339,11 +339,11 @@ public final class PartyManager {
/**
* Remove a player from a party.
*
* @param mcMMOPlayer The player to remove
* @param mmoPlayer The player to remove
*/
public static void removeFromParty(McMMOPlayer mcMMOPlayer) {
removeFromParty(mcMMOPlayer.getPlayer(), mcMMOPlayer.getParty());
processPartyLeaving(mcMMOPlayer);
public void removeFromParty(McMMOPlayer mmoPlayer) {
removeFromParty(mmoPlayer.getPlayer(), mmoPlayer.getParty());
processPartyLeaving(mmoPlayer);
}
/**
@ -351,16 +351,16 @@ public final class PartyManager {
*
* @param party The party to remove
*/
public static void disbandParty(Party party) {
public void disbandParty(Party party) {
//TODO: Potential issues with unloaded profile?
for (Player member : party.getOnlineMembers()) {
for (Player member : party.getPartyMembers()) {
//Profile not loaded
if(UserManager.getPlayer(member) == null)
if(mcMMO.getUserManager().getPlayer(member) == null)
{
continue;
}
processPartyLeaving(UserManager.getPlayer(member));
processPartyLeaving(mcMMO.getUserManager().getPlayer(member));
}
// Disband the alliance between the disbanded party and it's ally
@ -374,12 +374,12 @@ public final class PartyManager {
/**
* 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 password The password for this party, null if there was no password
*/
public static void createParty(McMMOPlayer mcMMOPlayer, String partyName, String password) {
Player player = mcMMOPlayer.getPlayer();
public void createParty(McMMOPlayer mmoPlayer, String partyName, String password) {
Player player = mmoPlayer.getPlayer();
Party party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName.replace(".", ""), password);
@ -389,8 +389,8 @@ public final class PartyManager {
parties.add(party);
player.sendMessage(LocaleLoader.getString("Commands.Party.Create", party.getName()));
addToParty(mcMMOPlayer, party);
player.sendMessage(LocaleLoader.getString("Commands.Party.Create", party.getPartyName()));
addToParty(mmoPlayer, party);
}
/**
@ -401,9 +401,9 @@ public final class PartyManager {
* @param password The password provided by the player
* @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()) {
String partyPassword = party.getPassword();
String partyPassword = party.getPartyPassword();
if (partyPassword == null) {
player.sendMessage(LocaleLoader.getString("Party.Locked"));
@ -427,14 +427,14 @@ public final class PartyManager {
/**
* 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) {
Party invite = mcMMOPlayer.getPartyInvite();
public void joinInvitedParty(McMMOPlayer mmoPlayer) {
Party invite = mmoPlayer.getPartyInvite();
// Check if the party still exists, it might have been disbanded
if (!parties.contains(invite)) {
NotificationManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.PARTY_MESSAGE, "Party.Disband");
NotificationManager.sendPlayerInformation(mmoPlayer.getPlayer(), NotificationType.PARTY_MESSAGE, "Party.Disband");
return;
}
@ -443,23 +443,23 @@ public final class PartyManager {
*/
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;
}
NotificationManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.PARTY_MESSAGE, "Commands.Party.Invite.Accepted", invite.getName());
mcMMOPlayer.removePartyInvite();
addToParty(mcMMOPlayer, invite);
NotificationManager.sendPlayerInformation(mmoPlayer.getPlayer(), NotificationType.PARTY_MESSAGE, "Commands.Party.Invite.Accepted", invite.getPartyName());
mmoPlayer.removePartyInvite();
addToParty(mmoPlayer, invite);
}
/**
* 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) {
Party invite = mcMMOPlayer.getPartyAllianceInvite();
Player player = mcMMOPlayer.getPlayer();
public void acceptAllianceInvite(McMMOPlayer mmoPlayer) {
Party invite = mmoPlayer.getPartyAllianceInvite();
Player player = mmoPlayer.getPlayer();
// Check if the party still exists, it might have been disbanded
if (!parties.contains(invite)) {
@ -467,65 +467,64 @@ public final class PartyManager {
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;
}
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.Accepted", invite.getName()));
mcMMOPlayer.removePartyAllianceInvite();
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.Accepted", invite.getPartyName()));
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);
secondParty.setAlly(firstParty);
for (Player member : firstParty.getOnlineMembers()) {
member.sendMessage(LocaleLoader.getString("Party.Alliance.Formed", secondParty.getName()));
for (Player member : firstParty.getPartyMembers()) {
member.sendMessage(LocaleLoader.getString("Party.Alliance.Formed", secondParty.getPartyName()));
}
for (Player member : secondParty.getOnlineMembers()) {
member.sendMessage(LocaleLoader.getString("Party.Alliance.Formed", firstParty.getName()));
for (Player member : secondParty.getPartyMembers()) {
member.sendMessage(LocaleLoader.getString("Party.Alliance.Formed", firstParty.getPartyName()));
}
}
public static boolean disbandAlliance(Player player, Party firstParty, Party secondParty){
if (!handlePartyChangeAllianceEvent(player, firstParty.getName(), secondParty.getName(), McMMOPartyAllianceChangeEvent.EventReason.DISBAND_ALLIANCE)) {
public boolean disbandAlliance(Player player, Party firstParty, Party secondParty){
if (!handlePartyChangeAllianceEvent(player, firstParty.getPartyName(), secondParty.getPartyName(), McMMOPartyAllianceChangeEvent.EventReason.DISBAND_ALLIANCE)) {
return false;
}
PartyManager.disbandAlliance(firstParty, secondParty);
mcMMO.getPartyManager().disbandAlliance(firstParty, secondParty);
return true;
}
private static void disbandAlliance(Party firstParty, Party secondParty) {
private void disbandAlliance(Party firstParty, Party secondParty) {
firstParty.setAlly(null);
secondParty.setAlly(null);
for (Player member : firstParty.getOnlineMembers()) {
member.sendMessage(LocaleLoader.getString("Party.Alliance.Disband", secondParty.getName()));
for (Player member : firstParty.getPartyMembers()) {
member.sendMessage(LocaleLoader.getString("Party.Alliance.Disband", secondParty.getPartyName()));
}
for (Player member : secondParty.getOnlineMembers()) {
member.sendMessage(LocaleLoader.getString("Party.Alliance.Disband", firstParty.getName()));
for (Player member : secondParty.getPartyMembers()) {
member.sendMessage(LocaleLoader.getString("Party.Alliance.Disband", firstParty.getPartyName()));
}
}
/**
* 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
*/
public static void addToParty(McMMOPlayer mcMMOPlayer, Party party) {
Player player = mcMMOPlayer.getPlayer();
public void addToParty(McMMOPlayer mmoPlayer, Party party) {
Player player = mmoPlayer.getPlayer();
String playerName = player.getName();
informPartyMembersJoin(party, playerName);
mcMMOPlayer.setParty(party);
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
* @return the leader of the party
*/
public static String getPartyLeaderName(String partyName) {
public String getPartyLeaderName(String partyName) {
Party party = getParty(partyName);
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 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);
UUID leaderUniqueId = party.getLeader().getUniqueId();
for (Player member : party.getOnlineMembers()) {
for (Player member : party.getPartyMembers()) {
UUID memberUniqueId = member.getUniqueId();
if (memberUniqueId.equals(player.getUniqueId())) {
@ -572,16 +571,16 @@ public final class PartyManager {
*
* @return true if the player can invite
*/
public static boolean canInvite(McMMOPlayer mcMMOPlayer) {
Party party = mcMMOPlayer.getParty();
public boolean canInvite(McMMOPlayer mmoPlayer) {
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.
*/
public static void loadParties() {
public void loadParties() {
if (!partyFile.exists()) {
return;
}
@ -602,8 +601,8 @@ public final class PartyManager {
String[] leaderSplit = partiesFile.getString(partyName + ".Leader").split("[|]");
party.setLeader(new PartyLeader(UUID.fromString(leaderSplit[0]), leaderSplit[1]));
party.setPassword(partiesFile.getString(partyName + ".Password"));
party.setLocked(partiesFile.getBoolean(partyName + ".Locked"));
party.setPartyPassword(partiesFile.getString(partyName + ".Password"));
party.setPartyLock(partiesFile.getBoolean(partyName + ".Locked"));
party.setLevel(partiesFile.getInt(partyName + ".Level"));
party.setXp(partiesFile.getInt(partyName + ".Xp"));
@ -631,7 +630,7 @@ public final class PartyManager {
mcMMO.p.getLogger().info("Loaded (" + parties.size() + ") Parties...");
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) {
@ -643,7 +642,7 @@ public final class PartyManager {
/**
* Save party file.
*/
public static void saveParties() {
public void saveParties() {
if (partyFile.exists()) {
if (!partyFile.delete()) {
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() + ")");
for (Party party : parties) {
String partyName = party.getName();
String partyName = party.getPartyName();
PartyLeader leader = party.getLeader();
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 + ".Level", party.getLevel());
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 + ".ItemShareMode", party.getItemShareMode().toString());
@ -693,7 +692,7 @@ public final class PartyManager {
}
}
private static void loadAndUpgradeParties() {
private void loadAndUpgradeParties() {
YamlConfiguration partiesFile = YamlConfiguration.loadConfiguration(partyFile);
if (!partyFile.renameTo(new File(mcMMO.getFlatFileDirectory() + "parties.yml.converted"))) {
@ -717,8 +716,8 @@ public final class PartyManager {
UUID leaderUniqueId = profile.getUniqueId();
party.setLeader(new PartyLeader(leaderUniqueId, leaderName));
party.setPassword(partiesFile.getString(partyName + ".Password"));
party.setLocked(partiesFile.getBoolean(partyName + ".Locked"));
party.setPartyPassword(partiesFile.getString(partyName + ".Password"));
party.setPartyLock(partiesFile.getBoolean(partyName + ".Locked"));
party.setLevel(partiesFile.getInt(partyName + ".Level"));
party.setXp(partiesFile.getInt(partyName + ".Xp"));
@ -754,7 +753,7 @@ public final class PartyManager {
mcMMO.p.getLogger().info("Loaded (" + parties.size() + ") Parties...");
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);
@ -769,7 +768,7 @@ public final class PartyManager {
* @param reason The reason for changing parties
* @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);
mcMMO.p.getServer().getPluginManager().callEvent(event);
@ -785,7 +784,7 @@ public final class PartyManager {
* @param reason The reason for changing allies
* @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);
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) {
mcMMOPlayer.removeParty();
mcMMOPlayer.disableChat(ChatMode.PARTY);
mcMMOPlayer.setItemShareModifier(10);
public void processPartyLeaving(McMMOPlayer mmoPlayer) {
mmoPlayer.removeParty();
mmoPlayer.disableChat(ChatMode.PARTY);
mmoPlayer.setItemShareModifier(10);
}
/**
@ -810,9 +809,9 @@ public final class PartyManager {
* @param levelsGained The amount of levels gained
* @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();
for (Player member : party.getOnlineMembers()) {
for (Player member : party.getPartyMembers()) {
member.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, level));
if (levelUpSoundsEnabled) {
@ -827,8 +826,8 @@ public final class PartyManager {
* @param party The concerned party
* @param playerName The name of the player that joined
*/
private static void informPartyMembersJoin(Party party, String playerName) {
for (Player member : party.getOnlineMembers()) {
private void informPartyMembersJoin(Party party, String playerName) {
for (Player member : party.getPartyMembers()) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", playerName));
}
}
@ -839,8 +838,8 @@ public final class PartyManager {
* @param party The concerned party
* @param playerName The name of the player that left
*/
private static void informPartyMembersQuit(Party party, String playerName) {
for (Player member : party.getOnlineMembers()) {
private void informPartyMembersQuit(Party party, String playerName) {
for (Player member : party.getPartyMembers()) {
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.skills.PrimarySkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -24,24 +23,24 @@ public final class ShareHandler {
* Distribute Xp amongst party members.
*
* @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
* @return True is the xp has been shared
*/
public static boolean handleXpShare(float xp, McMMOPlayer mcMMOPlayer, PrimarySkillType primarySkillType, XPGainReason xpGainReason) {
Party party = mcMMOPlayer.getParty();
public static boolean handleXpShare(float xp, McMMOPlayer mmoPlayer, PrimarySkillType primarySkillType, XPGainReason xpGainReason) {
Party party = mmoPlayer.getParty();
if (party.getXpShareMode() != ShareMode.EQUAL) {
return false;
}
List<Player> nearMembers = PartyManager.getNearVisibleMembers(mcMMOPlayer);
List<Player> nearMembers = mcMMO.getPartyManager().getNearVisibleMembers(mmoPlayer);
if (nearMembers.isEmpty()) {
return false;
}
nearMembers.add(mcMMOPlayer.getPlayer());
nearMembers.add(mmoPlayer.getPlayer());
int partySize = nearMembers.size();
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) {
//Profile not loaded
if(UserManager.getPlayer(member) == null)
if(mcMMO.getUserManager().getPlayer(member) == null)
{
continue;
}
UserManager.getPlayer(member).beginUnsharedXpGain(primarySkillType, splitXp, xpGainReason, XPGainSource.PARTY_MEMBERS);
mcMMO.getUserManager().getPlayer(member).beginUnsharedXpGain(primarySkillType, splitXp, xpGainReason, XPGainSource.PARTY_MEMBERS);
}
return true;
@ -64,10 +63,10 @@ public final class ShareHandler {
* Distribute Items amongst party members.
*
* @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
*/
public static boolean handleItemShare(Item drop, McMMOPlayer mcMMOPlayer) {
public static boolean handleItemShare(Item drop, McMMOPlayer mmoPlayer) {
ItemStack itemStack = drop.getItemStack();
ItemShareType dropType = ItemShareType.getShareType(itemStack);
@ -75,7 +74,7 @@ public final class ShareHandler {
return false;
}
Party party = mcMMOPlayer.getParty();
Party party = mmoPlayer.getParty();
if (!party.sharingDrops(dropType)) {
return false;
@ -87,7 +86,7 @@ public final class ShareHandler {
return false;
}
List<Player> nearMembers = PartyManager.getNearMembers(mcMMOPlayer);
List<Player> nearMembers = mcMMO.getPartyManager().getNearMembers(mmoPlayer);
if (nearMembers.isEmpty()) {
return false;
@ -96,7 +95,7 @@ public final class ShareHandler {
Player winningPlayer = null;
ItemStack newStack = itemStack.clone();
nearMembers.add(mcMMOPlayer.getPlayer());
nearMembers.add(mmoPlayer.getPlayer());
int partySize = nearMembers.size();
drop.remove();
@ -110,10 +109,10 @@ public final class ShareHandler {
int highestRoll = 0;
for (Player member : nearMembers) {
McMMOPlayer mcMMOMember = UserManager.getPlayer(member);
McMMOPlayer mcMMOMember = mcMMO.getUserManager().getPlayer(member);
//Profile not loaded
if(UserManager.getPlayer(member) == null)
if(mcMMO.getUserManager().getPlayer(member) == null)
{
continue;
}
@ -129,14 +128,14 @@ public final class ShareHandler {
highestRoll = diceRoll;
if (winningPlayer != null) {
McMMOPlayer mcMMOWinning = UserManager.getPlayer(winningPlayer);
McMMOPlayer mcMMOWinning = mcMMO.getUserManager().getPlayer(winningPlayer);
mcMMOWinning.setItemShareModifier(mcMMOWinning.getItemShareModifier() + itemWeight);
}
winningPlayer = member;
}
McMMOPlayer mcMMOTarget = UserManager.getPlayer(winningPlayer);
McMMOPlayer mcMMOTarget = mcMMO.getUserManager().getPlayer(winningPlayer);
mcMMOTarget.setItemShareModifier(mcMMOTarget.getItemShareModifier() - itemWeight);
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.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;
public class SaveTimerTask extends BukkitRunnable {
@ -13,11 +10,12 @@ public class SaveTimerTask extends BukkitRunnable {
// All player data will be saved periodically through this
int count = 1;
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
new PlayerProfileSaveTask(mcMMOPlayer.getProfile(), false).runTaskLaterAsynchronously(mcMMO.p, count);
//TODO: write a more efficient bulk save
for (McMMOPlayer mmoPlayer : mcMMO.getUserManager().getPlayers()) {
mcMMO.getUserManager().saveUserWithDelay(mmoPlayer.getPersistentPlayerData(), false, count);
count++;
}
PartyManager.saveParties();
mcMMO.getPartyManager().saveParties();
}
}

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.runnables.commands;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@ -11,9 +10,9 @@ public class NotifySquelchReminderTask extends BukkitRunnable {
@Override
public void run() {
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"));
}

View File

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

View File

@ -13,10 +13,10 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
public class ChimaeraWingWarmup extends BukkitRunnable {
private final McMMOPlayer mcMMOPlayer;
private final McMMOPlayer mmoPlayer;
public ChimaeraWingWarmup(McMMOPlayer mcMMOPlayer) {
this.mcMMOPlayer = mcMMOPlayer;
public ChimaeraWingWarmup(McMMOPlayer mmoPlayer) {
this.mmoPlayer = mmoPlayer;
}
@Override
@ -25,12 +25,12 @@ public class ChimaeraWingWarmup extends BukkitRunnable {
}
private void checkChimaeraWingTeleport() {
Player player = mcMMOPlayer.getPlayer();
Location previousLocation = mcMMOPlayer.getTeleportCommenceLocation();
Player player = mmoPlayer.getPlayer();
Location previousLocation = mmoPlayer.getTeleportCommenceLocation();
if (player.getLocation().distanceSquared(previousLocation) > 1.0 || !player.getInventory().containsAtLeast(ChimaeraWing.getChimaeraWing(0), 1)) {
player.sendMessage(LocaleLoader.getString("Teleport.Cancelled"));
mcMMOPlayer.setTeleportCommenceLocation(null);
mmoPlayer.setTeleportCommenceLocation(null);
return;
}
@ -41,7 +41,7 @@ public class ChimaeraWingWarmup extends BukkitRunnable {
return;
}
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
long recentlyHurt = mmoPlayer.getRecentlyHurtTimestamp();
int hurtCooldown = Config.getInstance().getChimaeraRecentlyHurtCooldown();
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.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
@ -14,25 +13,25 @@ import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class TeleportationWarmup extends BukkitRunnable {
private final McMMOPlayer mcMMOPlayer;
private final McMMOPlayer mmoPlayer;
private final McMMOPlayer mcMMOTarget;
public TeleportationWarmup(McMMOPlayer mcMMOPlayer, McMMOPlayer mcMMOTarget) {
this.mcMMOPlayer = mcMMOPlayer;
public TeleportationWarmup(McMMOPlayer mmoPlayer, McMMOPlayer mcMMOTarget) {
this.mmoPlayer = mmoPlayer;
this.mcMMOTarget = mcMMOTarget;
}
@Override
public void run() {
Player teleportingPlayer = mcMMOPlayer.getPlayer();
Player teleportingPlayer = mmoPlayer.getPlayer();
Player targetPlayer = mcMMOTarget.getPlayer();
Location previousLocation = mcMMOPlayer.getTeleportCommenceLocation();
Location newLocation = mcMMOPlayer.getPlayer().getLocation();
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
Location previousLocation = mmoPlayer.getTeleportCommenceLocation();
Location newLocation = mmoPlayer.getPlayer().getLocation();
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()));
return;
}

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