mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 22:26:46 +01:00
reworking party code
This commit is contained in:
parent
e057dfc482
commit
9e450adb0b
@ -390,7 +390,7 @@ public final class ExperienceAPI {
|
|||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static int getXP(Player player, String skillType) {
|
public static int getXP(Player player, String skillType) {
|
||||||
return getPlayer(player).getExperienceManager().getSkillXpLevel(getNonChildSkillType(skillType));
|
return getPlayer(player).getExperienceManager().getSkillXpValue(getNonChildSkillType(skillType));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -408,7 +408,7 @@ public final class ExperienceAPI {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static int getOfflineXP(String playerName, String skillType) {
|
public static int getOfflineXP(String playerName, String skillType) {
|
||||||
return getOfflineProfile(playerName).getExperienceManager().getSkillXpLevel(getNonChildSkillType(skillType));
|
return getOfflineProfile(playerName).getExperienceManager().getSkillXpValue(getNonChildSkillType(skillType));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -425,7 +425,7 @@ public final class ExperienceAPI {
|
|||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static int getOfflineXP(UUID uuid, String skillType) {
|
public static int getOfflineXP(UUID uuid, String skillType) {
|
||||||
return getOfflineProfile(uuid).getExperienceManager().getSkillXpLevel(getNonChildSkillType(skillType));
|
return getOfflineProfile(uuid).getExperienceManager().getSkillXpValue(getNonChildSkillType(skillType));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -547,7 +547,7 @@ public final class ExperienceAPI {
|
|||||||
|
|
||||||
PlayerProfile profile = getPlayer(player);
|
PlayerProfile profile = getPlayer(player);
|
||||||
|
|
||||||
return profile.getExperienceManager().getXpToLevel(skill) - profile.getExperienceManager().getSkillXpLevel(skill);
|
return profile.getExperienceManager().getXpToLevel(skill) - profile.getExperienceManager().getSkillXpValue(skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -568,7 +568,7 @@ public final class ExperienceAPI {
|
|||||||
PrimarySkillType skill = getNonChildSkillType(skillType);
|
PrimarySkillType skill = getNonChildSkillType(skillType);
|
||||||
PlayerProfile profile = getOfflineProfile(playerName);
|
PlayerProfile profile = getOfflineProfile(playerName);
|
||||||
|
|
||||||
return profile.getExperienceManager().getXpToLevel(skill) - profile.getExperienceManager().getSkillXpLevel(skill);
|
return profile.getExperienceManager().getXpToLevel(skill) - profile.getExperienceManager().getSkillXpValue(skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -894,7 +894,7 @@ public final class ExperienceAPI {
|
|||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
*/
|
*/
|
||||||
public static void setLevel(Player player, String skillType, int skillLevel) {
|
public static void setLevel(Player player, String skillType, int skillLevel) {
|
||||||
getPlayer(player).getExperienceManager().modifySkill(getSkillType(skillType), skillLevel);
|
getPlayer(player).getExperienceManager().setSkillLevel(getSkillType(skillType), skillLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -911,7 +911,7 @@ public final class ExperienceAPI {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void setLevelOffline(String playerName, String skillType, int skillLevel) {
|
public static void setLevelOffline(String playerName, String skillType, int skillLevel) {
|
||||||
getOfflineProfile(playerName).getExperienceManager().modifySkill(getSkillType(skillType), skillLevel);
|
getOfflineProfile(playerName).getExperienceManager().setSkillLevel(getSkillType(skillType), skillLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -927,7 +927,7 @@ public final class ExperienceAPI {
|
|||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
*/
|
*/
|
||||||
public static void setLevelOffline(UUID uuid, String skillType, int skillLevel) {
|
public static void setLevelOffline(UUID uuid, String skillType, int skillLevel) {
|
||||||
getOfflineProfile(uuid).getExperienceManager().modifySkill(getSkillType(skillType), skillLevel);
|
getOfflineProfile(uuid).getExperienceManager().setSkillLevel(getSkillType(skillType), skillLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -943,7 +943,7 @@ public final class ExperienceAPI {
|
|||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static void setXP(Player player, String skillType, int newValue) {
|
public static void setXP(Player player, String skillType, int newValue) {
|
||||||
getPlayer(player).getExperienceManager().setSkillXpLevel(getNonChildSkillType(skillType), (float) newValue);
|
getPlayer(player).getExperienceManager().setSkillXpValue(getNonChildSkillType(skillType), (float) newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -961,7 +961,7 @@ public final class ExperienceAPI {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void setXPOffline(String playerName, String skillType, int newValue) {
|
public static void setXPOffline(String playerName, String skillType, int newValue) {
|
||||||
getOfflineProfile(playerName).getExperienceManager().setSkillXpLevel(getNonChildSkillType(skillType), newValue);
|
getOfflineProfile(playerName).getExperienceManager().setSkillXpValue(getNonChildSkillType(skillType), newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -978,7 +978,7 @@ public final class ExperienceAPI {
|
|||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static void setXPOffline(UUID uuid, String skillType, int newValue) {
|
public static void setXPOffline(UUID uuid, String skillType, int newValue) {
|
||||||
getOfflineProfile(uuid).getExperienceManager().setSkillXpLevel(getNonChildSkillType(skillType), newValue);
|
getOfflineProfile(uuid).getExperienceManager().setSkillXpValue(getNonChildSkillType(skillType), newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +25,8 @@ public class PartyCreateCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check to see if the party exists, and if it does cancel creating a new party
|
// Check to see if the party exists, and if it does cancel creating a new party
|
||||||
if (mcMMO.getPartyManager().checkPartyExistence(player, args[1])) {
|
if (mcMMO.getPartyManager().checkPartyExistence(args[1])) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", args[1]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,8 @@ public class PartyRenameCommand implements CommandExecutor {
|
|||||||
Player player = mmoPlayer.getPlayer();
|
Player player = mmoPlayer.getPlayer();
|
||||||
|
|
||||||
// Check to see if the party exists, and if it does cancel renaming the party
|
// Check to see if the party exists, and if it does cancel renaming the party
|
||||||
if (mcMMO.getPartyManager().checkPartyExistence(player, newPartyName)) {
|
if (mcMMO.getPartyManager().checkPartyExistence(newPartyName)) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", newPartyName));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ public class ExperienceManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the power level of this player.
|
* Gets the power level of this player.
|
||||||
|
* A power level is the sum of all skill levels for this player
|
||||||
*
|
*
|
||||||
* @return the power level of the player
|
* @return the power level of the player
|
||||||
*/
|
*/
|
||||||
@ -48,26 +49,35 @@ public class ExperienceManager {
|
|||||||
return powerLevel;
|
return powerLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getSkillXpLevelRaw(PrimarySkillType skill) {
|
/**
|
||||||
return skillExperienceValuesMap.get(skill);
|
* Get the current value of raw XP for a skill
|
||||||
|
* @param primarySkillType target skill
|
||||||
|
* @return the value of raw XP for target skill
|
||||||
|
*/
|
||||||
|
public float getSkillXpLevelRaw(PrimarySkillType primarySkillType) {
|
||||||
|
return persistentPlayerDataRef.getSkillsExperienceMap().get(primarySkillType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSkillXpLevel(PrimarySkillType skill) {
|
/**
|
||||||
if(skill.isChildSkill()) {
|
* Get the value of XP a player has accumulated in target skill
|
||||||
|
* Child Skills will return 0 (Child Skills will be removed in a future update)
|
||||||
|
* @param primarySkillType target skill
|
||||||
|
* @return the value for XP the player has accumulated in target skill
|
||||||
|
*/
|
||||||
|
public int getSkillXpValue(PrimarySkillType primarySkillType) {
|
||||||
|
if(primarySkillType.isChildSkill()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int) Math.floor(getSkillXpLevelRaw(skill));
|
return (int) Math.floor(getSkillXpLevelRaw(primarySkillType));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSkillXpLevel(PrimarySkillType skill, float xpLevel) {
|
public void setSkillXpValue(PrimarySkillType skill, float xpLevel) {
|
||||||
if (skill.isChildSkill()) {
|
if (skill.isChildSkill()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
markProfileDirty();
|
persistentPlayerDataRef.getSkillsExperienceMap().put(skill, xpLevel);
|
||||||
|
|
||||||
skillsXp.put(skill, xpLevel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float levelUp(PrimarySkillType skill) {
|
public float levelUp(PrimarySkillType skill) {
|
||||||
@ -204,7 +214,7 @@ public class ExperienceManager {
|
|||||||
|
|
||||||
while (getSkillXpLevelRaw(primarySkillType) >= getXpToLevel(primarySkillType)) {
|
while (getSkillXpLevelRaw(primarySkillType) >= getXpToLevel(primarySkillType)) {
|
||||||
if (hasReachedLevelCap(primarySkillType)) {
|
if (hasReachedLevelCap(primarySkillType)) {
|
||||||
setSkillXpLevel(primarySkillType, 0);
|
setSkillXpValue(primarySkillType, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,13 +328,11 @@ public class ExperienceManager {
|
|||||||
* @param skill Type of skill to modify
|
* @param skill Type of skill to modify
|
||||||
* @param level New level value for the skill
|
* @param level New level value for the skill
|
||||||
*/
|
*/
|
||||||
public void modifySkill(PrimarySkillType skill, int level) {
|
public void setSkillLevel(PrimarySkillType skill, int level) {
|
||||||
if (skill.isChildSkill()) {
|
if (skill.isChildSkill()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
markProfileDirty();
|
|
||||||
|
|
||||||
//Don't allow levels to be negative
|
//Don't allow levels to be negative
|
||||||
if(level < 0)
|
if(level < 0)
|
||||||
level = 0;
|
level = 0;
|
||||||
@ -340,7 +348,7 @@ public class ExperienceManager {
|
|||||||
* @param levels Number of levels to add
|
* @param levels Number of levels to add
|
||||||
*/
|
*/
|
||||||
public void addLevels(PrimarySkillType skill, int levels) {
|
public void addLevels(PrimarySkillType skill, int levels) {
|
||||||
modifySkill(skill, skills.get(skill) + levels);
|
setSkillLevel(skill, skills.get(skill) + levels);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -435,7 +443,7 @@ public class ExperienceManager {
|
|||||||
return 1.0D;
|
return 1.0D;
|
||||||
}
|
}
|
||||||
|
|
||||||
double currentXP = getSkillXpLevel(primarySkillType);
|
double currentXP = getSkillXpValue(primarySkillType);
|
||||||
double maxXP = getXpToLevel(primarySkillType);
|
double maxXP = getXpToLevel(primarySkillType);
|
||||||
|
|
||||||
return (currentXP / maxXP);
|
return (currentXP / maxXP);
|
||||||
|
@ -43,17 +43,11 @@ public final class PartyManager {
|
|||||||
/**
|
/**
|
||||||
* Check if a party with a given name already exists.
|
* Check if a party with a given name already exists.
|
||||||
*
|
*
|
||||||
* @param player The player to notify
|
|
||||||
* @param partyName The name of the party to check
|
* @param partyName The name of the party to check
|
||||||
* @return true if a party with that name exists, false otherwise
|
* @return true if a party with that name exists, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean checkPartyExistence(Player player, String partyName) {
|
public boolean checkPartyExistence(String partyName) {
|
||||||
if (getParty(partyName) == null) {
|
return getParty(partyName) != null;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", partyName));
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,7 +58,8 @@ public final class PartyManager {
|
|||||||
*/
|
*/
|
||||||
public boolean isPartyFull(Player player, Party targetParty)
|
public boolean isPartyFull(Player player, Party targetParty)
|
||||||
{
|
{
|
||||||
return !Permissions.partySizeBypass(player) && Config.getInstance().getPartyMaxSize() >= 1 && targetParty.getPartyMembers().size() >= Config.getInstance().getPartyMaxSize();
|
return !Permissions.partySizeBypass(player)
|
||||||
|
&& targetParty.getPartyMembers().size() >= Config.getInstance().getPartyMaxSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,7 +72,7 @@ public final class PartyManager {
|
|||||||
public boolean changeOrJoinParty(McMMOPlayer mmoPlayer, String newPartyName) {
|
public boolean changeOrJoinParty(McMMOPlayer mmoPlayer, String newPartyName) {
|
||||||
Player player = mmoPlayer.getPlayer();
|
Player player = mmoPlayer.getPlayer();
|
||||||
|
|
||||||
if (mmoPlayer.inParty()) {
|
if (inParty(mmoPlayer)) {
|
||||||
Party oldParty = mmoPlayer.getParty();
|
Party oldParty = mmoPlayer.getParty();
|
||||||
|
|
||||||
if (!handlePartyChangeEvent(player, oldParty.getPartyName(), newPartyName, EventReason.CHANGED_PARTIES)) {
|
if (!handlePartyChangeEvent(player, oldParty.getPartyName(), newPartyName, EventReason.CHANGED_PARTIES)) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.util;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||||
import com.gmail.nossr50.datatypes.experience.XPGainSource;
|
import com.gmail.nossr50.datatypes.experience.XPGainSource;
|
||||||
@ -202,7 +201,7 @@ public class EventUtils {
|
|||||||
if (isCancelled) {
|
if (isCancelled) {
|
||||||
PlayerProfile profile = mcMMO.getUserManager().getPlayer(player);
|
PlayerProfile profile = mcMMO.getUserManager().getPlayer(player);
|
||||||
|
|
||||||
profile.modifySkill(skill, profile.getSkillLevel(skill) - (isLevelUp ? levelsChanged : -levelsChanged));
|
profile.getExperienceManager().setSkillLevel(skill, profile.getSkillLevel(skill) - (isLevelUp ? levelsChanged : -levelsChanged));
|
||||||
profile.addXp(skill, xpRemoved);
|
profile.addXp(skill, xpRemoved);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import com.gmail.nossr50.config.Config;
|
|||||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.player.NotificationManager;
|
import com.gmail.nossr50.util.player.NotificationManager;
|
||||||
import com.gmail.nossr50.worldguard.WorldGuardManager;
|
import com.gmail.nossr50.worldguard.WorldGuardManager;
|
||||||
import com.gmail.nossr50.worldguard.WorldGuardUtils;
|
import com.gmail.nossr50.worldguard.WorldGuardUtils;
|
||||||
@ -40,8 +41,8 @@ public final class HardcoreManager {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int playerSkillLevel = playerProfile.getSkillLevel(primarySkillType);
|
int playerSkillLevel = playerProfile.getExperienceManager().getSkillLevel(primarySkillType);
|
||||||
int playerSkillXpLevel = playerProfile.getSkillXpLevel(primarySkillType);
|
int playerSkillXpLevel = playerProfile.getExperienceManager().getSkillXpValue(primarySkillType);
|
||||||
|
|
||||||
if (playerSkillLevel <= 0 || playerSkillLevel <= levelThreshold) {
|
if (playerSkillLevel <= 0 || playerSkillLevel <= levelThreshold) {
|
||||||
levelChanged.put(primarySkillType.toString(), 0);
|
levelChanged.put(primarySkillType.toString(), 0);
|
||||||
@ -92,8 +93,8 @@ public final class HardcoreManager {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int killerSkillLevel = killerProfile.getSkillLevel(primarySkillType);
|
int killerSkillLevel = killerProfile.getExperienceManager().getSkillLevel(primarySkillType);
|
||||||
int victimSkillLevel = victimProfile.getSkillLevel(primarySkillType);
|
int victimSkillLevel = victimProfile.getExperienceManager().getSkillLevel(primarySkillType);
|
||||||
|
|
||||||
if (victimSkillLevel <= 0 || victimSkillLevel < killerSkillLevel / 2 || victimSkillLevel <= levelThreshold) {
|
if (victimSkillLevel <= 0 || victimSkillLevel < killerSkillLevel / 2 || victimSkillLevel <= levelThreshold) {
|
||||||
levelChanged.put(primarySkillType.toString(), 0);
|
levelChanged.put(primarySkillType.toString(), 0);
|
||||||
@ -101,7 +102,7 @@ public final class HardcoreManager {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int victimSkillXpLevel = victimProfile.getSkillXpLevel(primarySkillType);
|
int victimSkillXpLevel = victimProfile.getExperienceManager().getSkillXpValue(primarySkillType);
|
||||||
|
|
||||||
double statsStolen = victimSkillLevel * (vampirismStatLeechPercentage * 0.01D);
|
double statsStolen = victimSkillLevel * (vampirismStatLeechPercentage * 0.01D);
|
||||||
int levelsStolen = (int) statsStolen;
|
int levelsStolen = (int) statsStolen;
|
||||||
|
@ -446,7 +446,7 @@ public class ScoreboardWrapper {
|
|||||||
Validate.notNull(targetSkill);
|
Validate.notNull(targetSkill);
|
||||||
|
|
||||||
if (!targetSkill.isChildSkill()) {
|
if (!targetSkill.isChildSkill()) {
|
||||||
int currentXP = mmoPlayer.getExperienceManager().getSkillXpLevel(targetSkill);
|
int currentXP = mmoPlayer.getExperienceManager().getSkillXpValue(targetSkill);
|
||||||
|
|
||||||
sidebarObjective.getScore(ScoreboardManager.LABEL_CURRENT_XP).setScore(currentXP);
|
sidebarObjective.getScore(ScoreboardManager.LABEL_CURRENT_XP).setScore(currentXP);
|
||||||
sidebarObjective.getScore(ScoreboardManager.LABEL_REMAINING_XP).setScore(mmoPlayer.getExperienceManager().getXpToLevel(targetSkill) - currentXP);
|
sidebarObjective.getScore(ScoreboardManager.LABEL_REMAINING_XP).setScore(mmoPlayer.getExperienceManager().getXpToLevel(targetSkill) - currentXP);
|
||||||
|
Loading…
Reference in New Issue
Block a user