mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 14:16:45 +01:00
More work on gutting out the new skill system & reducing compiler errors
This commit is contained in:
parent
b20beed836
commit
ef06546721
@ -355,10 +355,10 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
/* Hardcore Mode */
|
/* Hardcore Mode */
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean getHardcoreStatLossEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(primarySkillType.toString()), false); }
|
public boolean getHardcoreStatLossEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(primarySkillType.toString()), false); }
|
||||||
public boolean getHardcoreStatLossEnabled(@NotNull RootSkill rootSkill) { return config.getBoolean("Hardcore.Death_Stat_Loss.Enabled." + rootSkill.getRawSkillName(), false); }
|
public boolean getHardcoreStatLossEnabled(@NotNull PrimarySkillType primarySkillType) { return config.getBoolean("Hardcore.Death_Stat_Loss.Enabled." + primarySkillType.getRawSkillName(), false); }
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setHardcoreStatLossEnabled(PrimarySkillType primarySkillType, boolean enabled) { config.set("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(primarySkillType.toString()), enabled); }
|
public void setHardcoreStatLossEnabled(PrimarySkillType primarySkillType, boolean enabled) { config.set("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(primarySkillType.toString()), enabled); }
|
||||||
public void setHardcoreStatLossEnabled(@NotNull RootSkill rootSkill, boolean enabled) { config.set("Hardcore.Death_Stat_Loss.Enabled." + rootSkill.getRawSkillName(), enabled); }
|
public void setHardcoreStatLossEnabled(@NotNull PrimarySkillType primarySkillType, boolean enabled) { config.set("Hardcore.Death_Stat_Loss.Enabled." + primarySkillType.getRawSkillName(), enabled); }
|
||||||
|
|
||||||
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss.Penalty_Percentage", 75.0D); }
|
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss.Penalty_Percentage", 75.0D); }
|
||||||
public void setHardcoreDeathStatPenaltyPercentage(double value) { config.set("Hardcore.Death_Stat_Loss.Penalty_Percentage", value); }
|
public void setHardcoreDeathStatPenaltyPercentage(double value) { config.set("Hardcore.Death_Stat_Loss.Penalty_Percentage", value); }
|
||||||
@ -367,10 +367,10 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean getHardcoreVampirismEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(primarySkillType.toString()), false); }
|
public boolean getHardcoreVampirismEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(primarySkillType.toString()), false); }
|
||||||
public boolean getHardcoreVampirismEnabled(@NotNull RootSkill rootSkill) { return config.getBoolean("Hardcore.Vampirism.Enabled." + rootSkill.getRawSkillName(), false); }
|
public boolean getHardcoreVampirismEnabled(@NotNull PrimarySkillType primarySkillType) { return config.getBoolean("Hardcore.Vampirism.Enabled." + primarySkillType.getRawSkillName(), false); }
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setHardcoreVampirismEnabled(PrimarySkillType primarySkillType, boolean enabled) { config.set("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(primarySkillType.toString()), enabled); }
|
public void setHardcoreVampirismEnabled(PrimarySkillType primarySkillType, boolean enabled) { config.set("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(primarySkillType.toString()), enabled); }
|
||||||
public void setHardcoreVampirismEnabled(@NotNull RootSkill rootSkill, boolean enabled) { config.set("Hardcore.Vampirism.Enabled." + rootSkill.getRawSkillName(), enabled); }
|
public void setHardcoreVampirismEnabled(@NotNull PrimarySkillType primarySkillType, boolean enabled) { config.set("Hardcore.Vampirism.Enabled." + primarySkillType.getRawSkillName(), enabled); }
|
||||||
|
|
||||||
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism.Leech_Percentage", 5.0D); }
|
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism.Leech_Percentage", 5.0D); }
|
||||||
public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism.Leech_Percentage", value); }
|
public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism.Leech_Percentage", value); }
|
||||||
@ -562,9 +562,9 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
return (cap <= 0) ? Integer.MAX_VALUE : cap;
|
return (cap <= 0) ? Integer.MAX_VALUE : cap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLevelCap(@NotNull RootSkill rootSkill) {
|
public int getLevelCap(@NotNull PrimarySkillType primarySkillType) {
|
||||||
|
|
||||||
int cap = config.getInt("Skills." + StringUtils.getCapitalized(rootSkill.getRawSkillName()) + ".Level_Cap", 0);
|
int cap = config.getInt("Skills." + StringUtils.getCapitalized(primarySkillType.getRawSkillName()) + ".Level_Cap", 0);
|
||||||
return (cap <= 0) ? Integer.MAX_VALUE : cap;
|
return (cap <= 0) ? Integer.MAX_VALUE : cap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -584,10 +584,10 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
/* PVP & PVE Settings */
|
/* PVP & PVE Settings */
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean getPVPEnabled(PrimarySkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVP", true); }
|
public boolean getPVPEnabled(PrimarySkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVP", true); }
|
||||||
public boolean getPVPEnabled(RootSkill skill) { return config.getBoolean("Skills." + skill.getRawSkillName() + ".Enabled_For_PVP", true); }
|
public boolean getPVPEnabled(PrimarySkillType skill) { return config.getBoolean("Skills." + skill.getRawSkillName() + ".Enabled_For_PVP", true); }
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean getPVEEnabled(PrimarySkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVE", true); }
|
public boolean getPVEEnabled(PrimarySkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVE", true); }
|
||||||
public boolean getPVEEnabled(RootSkill skill) { return config.getBoolean("Skills." + skill.getRawSkillName() + ".Enabled_For_PVE", true); }
|
public boolean getPVEEnabled(PrimarySkillType skill) { return config.getBoolean("Skills." + skill.getRawSkillName() + ".Enabled_For_PVE", true); }
|
||||||
|
|
||||||
//public float getMasterVolume() { return (float) config.getDouble("Sounds.MasterVolume", 1.0); }
|
//public float getMasterVolume() { return (float) config.getDouble("Sounds.MasterVolume", 1.0); }
|
||||||
|
|
||||||
|
@ -331,11 +331,11 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
public boolean getAddExtraDetails() { return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained.ExtraDetails", false);}
|
public boolean getAddExtraDetails() { return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained.ExtraDetails", false);}
|
||||||
public boolean isExperienceBarsEnabled() { return config.getBoolean("Experience_Bars.Enable", true); }
|
public boolean isExperienceBarsEnabled() { return config.getBoolean("Experience_Bars.Enable", true); }
|
||||||
public boolean isExperienceBarEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".Enable", true);}
|
public boolean isExperienceBarEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".Enable", true);}
|
||||||
public boolean isExperienceBarEnabled(@NotNull RootSkill rootSkill) { return config.getBoolean("Experience_Bars."+StringUtils.getCapitalized(rootSkill.getRawSkillName())+".Enable", true);}
|
public boolean isExperienceBarEnabled(@NotNull PrimarySkillType primarySkillType) { return config.getBoolean("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.getRawSkillName())+".Enable", true);}
|
||||||
|
|
||||||
public BarColor getExperienceBarColor(@NotNull RootSkill rootSkill)
|
public BarColor getExperienceBarColor(@NotNull PrimarySkillType primarySkillType)
|
||||||
{
|
{
|
||||||
String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(rootSkill.getRawSkillName())+".Color");
|
String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.getRawSkillName())+".Color");
|
||||||
|
|
||||||
for(BarColor barColor : BarColor.values())
|
for(BarColor barColor : BarColor.values())
|
||||||
{
|
{
|
||||||
@ -374,8 +374,8 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
return BarStyle.SOLID;
|
return BarStyle.SOLID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BarStyle getExperienceBarStyle(@NotNull RootSkill rootSkill) {
|
public BarStyle getExperienceBarStyle(@NotNull PrimarySkillType primarySkillType) {
|
||||||
String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(rootSkill.getRawSkillName())+".BarStyle");
|
String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.getRawSkillName())+".BarStyle");
|
||||||
|
|
||||||
for(BarStyle barStyle : BarStyle.values())
|
for(BarStyle barStyle : BarStyle.values())
|
||||||
{
|
{
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
package com.gmail.nossr50.database;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.player.MMODataBuilder;
|
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.neetgames.mcmmo.exceptions.ProfileRetrievalException;
|
|
||||||
import org.apache.commons.lang.NullArgumentException;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
public abstract class AbstractDatabaseManager implements DatabaseManager {
|
|
||||||
@Override
|
|
||||||
public @Nullable PlayerProfile initPlayerProfile(@NotNull Player player) throws Exception {
|
|
||||||
//First we attempt to load the player data
|
|
||||||
try {
|
|
||||||
PlayerProfile playerProfile = queryPlayerDataByUUID(player.getUniqueId(), player.getName());
|
|
||||||
if(playerProfile != null) {
|
|
||||||
return playerProfile;
|
|
||||||
}
|
|
||||||
//If we fail to load the player data due to either missing data for the player or corrupted/invalid data, we create a new profile for this player
|
|
||||||
} catch (ProfileRetrievalException | NullArgumentException e) {
|
|
||||||
mcMMO.p.getLogger().info("Making new player data in DB for user name:"+player.getName().toString()+", uuid:" + player.getUniqueId().toString());
|
|
||||||
//Add data for this player into DB with default values
|
|
||||||
//TODO: have this use the PersistentPlayerData object created below to initialize defaults
|
|
||||||
insertNewUser(player.getName(), player.getUniqueId());
|
|
||||||
//Construct player data object
|
|
||||||
MMODataBuilder MMODataBuilder = new MMODataBuilder();
|
|
||||||
//Return player profile
|
|
||||||
return new PlayerProfile(MMODataBuilder.buildNewPlayerData(player.getUniqueId(), player.getName()));
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null; //Some critical failure happened
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,6 +6,7 @@ import com.gmail.nossr50.datatypes.database.DatabaseType;
|
|||||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
|
import com.neetgames.mcmmo.player.MMOPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -49,10 +50,10 @@ public interface DatabaseManager {
|
|||||||
/**
|
/**
|
||||||
* Save a user to the database.
|
* Save a user to the database.
|
||||||
*
|
*
|
||||||
* @param profile The profile of the player to save
|
* @param mmoPlayer The player to save
|
||||||
* @return true if successful, false on failure
|
* @return true if successful, false on failure
|
||||||
*/
|
*/
|
||||||
boolean saveUser(PlayerProfile profile);
|
boolean saveUser(@NotNull MMOPlayer mmoPlayer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve leaderboard info.
|
* Retrieve leaderboard info.
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.database.DatabaseType;
|
|||||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||||
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||||
import com.gmail.nossr50.datatypes.player.*;
|
import com.gmail.nossr50.datatypes.player.*;
|
||||||
import com.gmail.nossr50.datatypes.skills.CoreSkills;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
@ -15,12 +14,7 @@ import com.gmail.nossr50.util.skills.SkillUtils;
|
|||||||
import com.neetgames.mcmmo.MobHealthBarType;
|
import com.neetgames.mcmmo.MobHealthBarType;
|
||||||
import com.neetgames.mcmmo.UniqueDataType;
|
import com.neetgames.mcmmo.UniqueDataType;
|
||||||
import com.neetgames.mcmmo.exceptions.InvalidSkillException;
|
import com.neetgames.mcmmo.exceptions.InvalidSkillException;
|
||||||
import com.neetgames.mcmmo.exceptions.ProfileRetrievalException;
|
|
||||||
import com.neetgames.mcmmo.player.MMOPlayerData;
|
|
||||||
import com.neetgames.mcmmo.skill.RootSkill;
|
|
||||||
import com.neetgames.mcmmo.skill.SkillBossBarState;
|
import com.neetgames.mcmmo.skill.SkillBossBarState;
|
||||||
import com.neetgames.mcmmo.skill.SuperSkill;
|
|
||||||
import org.apache.commons.lang.NullArgumentException;
|
|
||||||
import org.apache.tomcat.jdbc.pool.DataSource;
|
import org.apache.tomcat.jdbc.pool.DataSource;
|
||||||
import org.apache.tomcat.jdbc.pool.PoolProperties;
|
import org.apache.tomcat.jdbc.pool.PoolProperties;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -32,7 +26,7 @@ import java.sql.*;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
public final class SQLDatabaseManager extends AbstractDatabaseManager {
|
public final class SQLDatabaseManager implements DatabaseManager {
|
||||||
private static final String ALL_QUERY_VERSION = "total";
|
private static final String ALL_QUERY_VERSION = "total";
|
||||||
public static final String MOBHEALTHBAR_VARCHAR = "VARCHAR(50)";
|
public static final String MOBHEALTHBAR_VARCHAR = "VARCHAR(50)";
|
||||||
public static final String UUID_VARCHAR = "VARCHAR(36)";
|
public static final String UUID_VARCHAR = "VARCHAR(36)";
|
||||||
@ -281,8 +275,8 @@ public final class SQLDatabaseManager extends AbstractDatabaseManager {
|
|||||||
statement.setInt(14, dataSnapshot.getSkillLevel(PrimarySkillType.TRIDENTS));
|
statement.setInt(14, dataSnapshot.getSkillLevel(PrimarySkillType.TRIDENTS));
|
||||||
statement.setInt(15, dataSnapshot.getSkillLevel(PrimarySkillType.CROSSBOWS));
|
statement.setInt(15, dataSnapshot.getSkillLevel(PrimarySkillType.CROSSBOWS));
|
||||||
int total = 0;
|
int total = 0;
|
||||||
for (RootSkill rootSkill : PrimarySkillType.getNonChildSkills())
|
for (PrimarySkillType primarySkillType : PrimarySkillType.getNonChildSkills())
|
||||||
total += dataSnapshot.getSkillLevel(rootSkill);
|
total += dataSnapshot.getSkillLevel(primarySkillType);
|
||||||
statement.setInt(16, total);
|
statement.setInt(16, total);
|
||||||
statement.setInt(17, id);
|
statement.setInt(17, id);
|
||||||
success &= (statement.executeUpdate() != 0);
|
success &= (statement.executeUpdate() != 0);
|
||||||
@ -414,17 +408,17 @@ public final class SQLDatabaseManager extends AbstractDatabaseManager {
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull List<PlayerStat> readLeaderboard(@Nullable RootSkill rootSkill, int pageNumber, int statsPerPage) throws InvalidSkillException {
|
public @NotNull List<PlayerStat> readLeaderboard(@Nullable PrimarySkillType primarySkillType, int pageNumber, int statsPerPage) throws InvalidSkillException {
|
||||||
List<PlayerStat> stats = new ArrayList<>();
|
List<PlayerStat> stats = new ArrayList<>();
|
||||||
|
|
||||||
//Fix for a plugin that people are using that is throwing SQL errors
|
//Fix for a plugin that people are using that is throwing SQL errors
|
||||||
if(rootSkill != null && PrimarySkillType.isChildSkill(rootSkill)) {
|
if(primarySkillType != null && PrimarySkillType.isChildSkill(primarySkillType)) {
|
||||||
mcMMO.p.getLogger().severe("A plugin hooking into mcMMO is being naughty with our database commands, update all plugins that hook into mcMMO and contact their devs!");
|
mcMMO.p.getLogger().severe("A plugin hooking into mcMMO is being naughty with our database commands, update all plugins that hook into mcMMO and contact their devs!");
|
||||||
throw new InvalidSkillException("A plugin hooking into mcMMO that you are using is attempting to read leaderboard skills for child skills, child skills do not have leaderboards! This is NOT an mcMMO error!");
|
throw new InvalidSkillException("A plugin hooking into mcMMO that you are using is attempting to read leaderboard skills for child skills, child skills do not have leaderboards! This is NOT an mcMMO error!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String query = rootSkill == null ? ALL_QUERY_VERSION : rootSkill.getRawSkillName().toLowerCase(Locale.ENGLISH);
|
String query = primarySkillType == null ? ALL_QUERY_VERSION : primarySkillType.getRawSkillName().toLowerCase(Locale.ENGLISH);
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
@ -469,8 +463,8 @@ public final class SQLDatabaseManager extends AbstractDatabaseManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
connection = getConnection(PoolIdentifier.MISC);
|
connection = getConnection(PoolIdentifier.MISC);
|
||||||
for (RootSkill rootSkill : PrimarySkillType.getNonChildSkills()) {
|
for (PrimarySkillType primarySkillType : PrimarySkillType.getNonChildSkills()) {
|
||||||
String skillName = rootSkill.getRawSkillName().toLowerCase(Locale.ENGLISH);
|
String skillName = primarySkillType.getRawSkillName().toLowerCase(Locale.ENGLISH);
|
||||||
// Get count of all users with higher skill level than player
|
// Get count of all users with higher skill level than player
|
||||||
String sql = "SELECT COUNT(*) AS 'rank' FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
|
String sql = "SELECT COUNT(*) AS 'rank' FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
|
||||||
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
||||||
@ -497,7 +491,7 @@ public final class SQLDatabaseManager extends AbstractDatabaseManager {
|
|||||||
|
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
||||||
skills.put(rootSkill, rank + resultSet.getRow());
|
skills.put(primarySkillType, rank + resultSet.getRow());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -639,7 +633,7 @@ public final class SQLDatabaseManager extends AbstractDatabaseManager {
|
|||||||
public @NotNull PlayerProfile loadPlayerProfile(@NotNull UUID uuid, @Nullable String playerName) {
|
public @NotNull PlayerProfile loadPlayerProfile(@NotNull UUID uuid, @Nullable String playerName) {
|
||||||
return loadPlayerFromDB(uuid, playerName);
|
return loadPlayerFromDB(uuid, playerName);
|
||||||
@Override
|
@Override
|
||||||
public @Nullable MMOPlayerData queryPlayerDataByPlayer(@NotNull Player player) throws ProfileRetrievalException, NullArgumentException {
|
public @Nullable PlayerData queryPlayerDataByPlayer(@NotNull Player player) throws ProfileRetrievalException, NullArgumentException {
|
||||||
return loadPlayerProfile(player, player.getName(), player.getUniqueId());
|
return loadPlayerProfile(player, player.getName(), player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -648,11 +642,11 @@ public final class SQLDatabaseManager extends AbstractDatabaseManager {
|
|||||||
throw new RuntimeException("Error looking up player, both UUID and playerName are null and one must not be.");
|
throw new RuntimeException("Error looking up player, both UUID and playerName are null and one must not be.");
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public @Nullable MMOPlayerData queryPlayerDataByUUID(@NotNull UUID uuid, @NotNull String playerName) throws ProfileRetrievalException, NullArgumentException {
|
public @Nullable PlayerData queryPlayerDataByUUID(@NotNull UUID uuid, @NotNull String playerName) throws ProfileRetrievalException, NullArgumentException {
|
||||||
return loadPlayerProfile(null, playerName, uuid);
|
return loadPlayerProfile(null, playerName, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private @Nullable MMOPlayerData loadPlayerProfile(@Nullable Player player, @NotNull String playerName, @Nullable UUID playerUUID) {
|
private @Nullable PlayerData loadPlayerProfile(@Nullable Player player, @NotNull String playerName, @Nullable UUID playerUUID) {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
@ -675,7 +669,7 @@ public final class SQLDatabaseManager extends AbstractDatabaseManager {
|
|||||||
|
|
||||||
if (resultSet.next()) {
|
if (resultSet.next()) {
|
||||||
try {
|
try {
|
||||||
MMOPlayerData mmoPlayerData = loadFromResult(playerName, resultSet);
|
PlayerData mmoPlayerData = loadFromResult(playerName, resultSet);
|
||||||
String name = resultSet.getString(42); // TODO: Magic Number, make sure it stays updated
|
String name = resultSet.getString(42); // TODO: Magic Number, make sure it stays updated
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
statement.close();
|
statement.close();
|
||||||
@ -741,7 +735,7 @@ public final class SQLDatabaseManager extends AbstractDatabaseManager {
|
|||||||
resultSet = statement.executeQuery();
|
resultSet = statement.executeQuery();
|
||||||
resultSet.next();
|
resultSet.next();
|
||||||
//TODO: Optimize, probably needless to make a snapshot here, brain tired
|
//TODO: Optimize, probably needless to make a snapshot here, brain tired
|
||||||
MMOPlayerData mmoPlayerData = loadFromResult(playerName, resultSet);
|
PlayerData mmoPlayerData = loadFromResult(playerName, resultSet);
|
||||||
MMODataSnapshot mmoDataSnapshot = mcMMO.getUserManager().createPlayerDataSnapshot(mmoPlayerData);
|
MMODataSnapshot mmoDataSnapshot = mcMMO.getUserManager().createPlayerDataSnapshot(mmoPlayerData);
|
||||||
destination.saveUser(mmoDataSnapshot);
|
destination.saveUser(mmoDataSnapshot);
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
@ -1057,12 +1051,12 @@ public final class SQLDatabaseManager extends AbstractDatabaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getTruncateSkills()) {
|
if (Config.getInstance().getTruncateSkills()) {
|
||||||
for (RootSkill rootSkill : PrimarySkillType.getNonChildSkills()) {
|
for (PrimarySkillType primarySkillType : PrimarySkillType.getNonChildSkills()) {
|
||||||
int cap = Config.getInstance().getLevelCap(rootSkill);
|
int cap = Config.getInstance().getLevelCap(primarySkillType);
|
||||||
if (cap != Integer.MAX_VALUE) {
|
if (cap != Integer.MAX_VALUE) {
|
||||||
statement = connection.prepareStatement("UPDATE `" + tablePrefix + "skills` SET `"
|
statement = connection.prepareStatement("UPDATE `" + tablePrefix + "skills` SET `"
|
||||||
+ rootSkill.getRawSkillName().toLowerCase(Locale.ENGLISH) + "` = " + cap + " WHERE `"
|
+ primarySkillType.getRawSkillName().toLowerCase(Locale.ENGLISH) + "` = " + cap + " WHERE `"
|
||||||
+ rootSkill.getRawSkillName().toLowerCase(Locale.ENGLISH) + "` > " + cap);
|
+ primarySkillType.getRawSkillName().toLowerCase(Locale.ENGLISH) + "` > " + cap);
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
tryClose(statement);
|
tryClose(statement);
|
||||||
}
|
}
|
||||||
@ -1226,13 +1220,13 @@ public final class SQLDatabaseManager extends AbstractDatabaseManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private @Nullable MMOPlayerData loadFromResult(@NotNull String playerName, @NotNull ResultSet result) throws SQLException {
|
private @Nullable PlayerData loadFromResult(@NotNull String playerName, @NotNull ResultSet result) throws SQLException {
|
||||||
MMODataBuilder MMODataBuilder = new MMODataBuilder();
|
MMODataBuilder MMODataBuilder = new MMODataBuilder();
|
||||||
Map<PrimarySkillType, Integer> skills = new HashMap<>(); // Skill & Level
|
Map<PrimarySkillType, Integer> skills = new HashMap<>(); // Skill & Level
|
||||||
Map<PrimarySkillType, Float> skillsXp = new HashMap<>(); // Skill & XP
|
Map<PrimarySkillType, Float> skillsXp = new HashMap<>(); // Skill & XP
|
||||||
Map<SuperSkill, Integer> skillsDATS = new HashMap<>(); // Ability & Cooldown
|
Map<SuperAbilityType, Integer> skillsDATS = new HashMap<>(); // Ability & Cooldown
|
||||||
Map<UniqueDataType, Integer> uniqueData = new EnumMap<UniqueDataType, Integer>(UniqueDataType.class); //Chimaera wing cooldown and other misc info
|
Map<UniqueDataType, Integer> uniqueData = new EnumMap<UniqueDataType, Integer>(UniqueDataType.class); //Chimaera wing cooldown and other misc info
|
||||||
Map<RootSkill, SkillBossBarState> xpBarStateMap = new HashMap<RootSkill, SkillBossBarState>();
|
Map<PrimarySkillType, SkillBossBarState> xpBarStateMap = new HashMap<PrimarySkillType, SkillBossBarState>();
|
||||||
|
|
||||||
MobHealthBarType mobHealthbarType;
|
MobHealthBarType mobHealthbarType;
|
||||||
UUID uuid;
|
UUID uuid;
|
||||||
@ -1500,8 +1494,8 @@ public final class SQLDatabaseManager extends AbstractDatabaseManager {
|
|||||||
if (resultSet.getRow() != PrimarySkillType.getNonChildSkills().size()) {
|
if (resultSet.getRow() != PrimarySkillType.getNonChildSkills().size()) {
|
||||||
mcMMO.p.getLogger().info("Indexing tables, this may take a while on larger databases");
|
mcMMO.p.getLogger().info("Indexing tables, this may take a while on larger databases");
|
||||||
|
|
||||||
for (RootSkill rootSkill : PrimarySkillType.getNonChildSkills()) {
|
for (PrimarySkillType primarySkillType : PrimarySkillType.getNonChildSkills()) {
|
||||||
String skill_name = rootSkill.getRawSkillName().toLowerCase(Locale.ENGLISH);
|
String skill_name = primarySkillType.getRawSkillName().toLowerCase(Locale.ENGLISH);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "skills` ADD INDEX `idx_" + skill_name + "` (`" + skill_name + "`) USING BTREE");
|
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "skills` ADD INDEX `idx_" + skill_name + "` (`" + skill_name + "`) USING BTREE");
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.gmail.nossr50.datatypes.experience;
|
package com.gmail.nossr50.datatypes.experience;
|
||||||
|
|
||||||
import com.neetgames.mcmmo.experience.ExperienceHandler;
|
import com.neetgames.mcmmo.experience.ExperienceHandler;
|
||||||
|
//TODO: T&C Write implementation, this should be the exact same way OnlineExperienceProcessor handles stuff but without sending player messages or sounds and stuff like that
|
||||||
|
//TODO: Is this needed? Maybe just make OnlineExperienceProcessor handle both in a clean way
|
||||||
public class OfflineExperienceProcessor {
|
public class OfflineExperienceProcessor {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ package com.gmail.nossr50.datatypes.experience;
|
|||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.player.PlayerData;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.neetgames.mcmmo.party.Party;
|
import com.neetgames.mcmmo.party.Party;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@ -29,83 +31,75 @@ public class OnlineExperienceProcessor {
|
|||||||
|
|
||||||
private boolean isUsingUnarmed = false;
|
private boolean isUsingUnarmed = false;
|
||||||
|
|
||||||
private final @NotNull MMOPlayerData mmoPlayerData;
|
private final @NotNull PlayerData mmoPlayerData;
|
||||||
private final @NotNull MMOPlayer mmoPlayer;
|
private final @NotNull MMOPlayer mmoPlayer;
|
||||||
private final @NotNull Player playerRef;
|
private final @NotNull Player playerRef;
|
||||||
|
|
||||||
public OnlineExperienceProcessor(@NotNull MMOPlayer mmoPlayer, @NotNull Player playerRef) {
|
public OnlineExperienceProcessor(@NotNull MMOPlayer mmoPlayer, @NotNull Player playerRef) {
|
||||||
this.mmoPlayer = mmoPlayer;
|
this.mmoPlayer = mmoPlayer;
|
||||||
this.playerRef = playerRef;
|
this.playerRef = playerRef;
|
||||||
this.mmoPlayerData = mmoPlayer.getMMOPlayerData();
|
this.mmoPlayerData = mmoPlayer.getMMOPlayerDataImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getPowerLevel() {
|
public int getPowerLevel() {
|
||||||
int powerLevel = 0;
|
int powerLevel = 0;
|
||||||
|
|
||||||
Map<PrimarySkillType, Integer> rootSkillLevelMap = mmoPlayerData.getDirtySkillLevelMap().unwrapMap();
|
Map<PrimarySkillType, Integer> primarySkillTypeLevelMap = mmoPlayerData.getDirtySkillLevelMap().unwrapMap();
|
||||||
|
|
||||||
for (RootSkill rootSkill : rootSkillLevelMap.keySet()) {
|
for (PrimarySkillType primarySkillType : primarySkillTypeLevelMap.keySet()) {
|
||||||
powerLevel += rootSkillLevelMap.get(rootSkill);
|
powerLevel += primarySkillTypeLevelMap.get(primarySkillType);
|
||||||
}
|
}
|
||||||
|
|
||||||
return powerLevel;
|
return powerLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public float getSkillXpLevelRaw(@NotNull PrimarySkillType primarySkillType) {
|
||||||
public float getSkillXpLevelRaw(@NotNull RootSkill rootSkill) {
|
return mmoPlayerData.getSkillsExperienceMap().get(primarySkillType);
|
||||||
return mmoPlayerData.getSkillsExperienceMap().get(rootSkill);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public int getSkillXpValue(@NotNull PrimarySkillType primarySkillType) {
|
||||||
public int getSkillXpValue(@NotNull RootSkill rootSkill) {
|
if(PrimarySkillType.isChildSkill(primarySkillType)) {
|
||||||
if(PrimarySkillType.isChildSkill(rootSkill)) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int) Math.floor(getSkillXpLevelRaw(rootSkill));
|
return (int) Math.floor(getSkillXpLevelRaw(primarySkillType));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setSkillXpValue(@NotNull PrimarySkillType primarySkillType, float xpLevel) {
|
||||||
public void setSkillXpValue(@NotNull RootSkill rootSkill, float xpLevel) {
|
if (PrimarySkillType.isChildSkill(primarySkillType)) {
|
||||||
if (PrimarySkillType.isChildSkill(rootSkill)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mmoPlayerData.getSkillsExperienceMap().put(rootSkill, xpLevel);
|
mmoPlayerData.getSkillsExperienceMap().put(primarySkillType, xpLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public float levelUp(@NotNull PrimarySkillType primarySkillType) {
|
||||||
public float levelUp(@NotNull RootSkill rootSkill) {
|
float xpRemoved = getExperienceToNextLevel(primarySkillType);
|
||||||
float xpRemoved = getExperienceToNextLevel(rootSkill);
|
|
||||||
|
|
||||||
setSkillLevel(rootSkill, getSkillLevel(rootSkill) + 1);
|
setSkillLevel(primarySkillType, getSkillLevel(primarySkillType) + 1);
|
||||||
setSkillXpValue(rootSkill, getSkillXpValue(rootSkill) - xpRemoved);
|
setSkillXpValue(primarySkillType, getSkillXpValue(primarySkillType) - xpRemoved);
|
||||||
|
|
||||||
return xpRemoved;
|
return xpRemoved;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean hasReachedLevelCap(@NotNull PrimarySkillType primarySkillType) {
|
||||||
public boolean hasReachedLevelCap(@NotNull RootSkill rootSkill) {
|
|
||||||
if(hasReachedPowerLevelCap())
|
if(hasReachedPowerLevelCap())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return getSkillLevel(rootSkill) >= Config.getInstance().getLevelCap(rootSkill);
|
return getSkillLevel(primarySkillType) >= Config.getInstance().getLevelCap(primarySkillType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasReachedPowerLevelCap() {
|
public boolean hasReachedPowerLevelCap() {
|
||||||
return this.getPowerLevel() >= Config.getInstance().getPowerLevelCap();
|
return this.getPowerLevel() >= Config.getInstance().getPowerLevelCap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void beginXpGain(@NotNull PrimarySkillType primarySkillType, float xp, @NotNull XPGainReason xpGainReason, @NotNull XPGainSource xpGainSource) {
|
||||||
public void beginXpGain(@NotNull RootSkill rootSkill, float xp, @NotNull XPGainReason xpGainReason, @NotNull XPGainSource xpGainSource) {
|
|
||||||
if (xp <= 0.0) {
|
if (xp <= 0.0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PrimarySkillType.isChildSkill(rootSkill)) {
|
if (PrimarySkillType.isChildSkill(primarySkillType)) {
|
||||||
Set<RootSkill> parentSkills = FamilyTree.getParentSkills(rootSkill);
|
Set<RootSkill> parentSkills = FamilyTree.getParentSkills(primarySkillType);
|
||||||
float splitXp = xp / parentSkills.size();
|
float splitXp = xp / parentSkills.size();
|
||||||
|
|
||||||
for (RootSkill parentSkill : parentSkills) {
|
for (RootSkill parentSkill : parentSkills) {
|
||||||
@ -118,49 +112,45 @@ public class OnlineExperienceProcessor {
|
|||||||
//TODO: The logic here is so stupid... rewrite later
|
//TODO: The logic here is so stupid... rewrite later
|
||||||
|
|
||||||
// Return if the experience has been shared
|
// Return if the experience has been shared
|
||||||
if (mmoPlayer.getParty() != null && ShareHandler.handleXpShare(xp, mmoPlayer, mmoPlayer.getParty(), rootSkill, ShareHandler.getSharedXpGainReason(xpGainReason))) {
|
if (mmoPlayer.getParty() != null && ShareHandler.handleXpShare(xp, mmoPlayer, mmoPlayer.getParty(), primarySkillType, ShareHandler.getSharedXpGainReason(xpGainReason))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
beginUnsharedXpGain(rootSkill, xp, xpGainReason, xpGainSource);
|
beginUnsharedXpGain(primarySkillType, xp, xpGainReason, xpGainSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void beginUnsharedXpGain(@NotNull PrimarySkillType primarySkillType, float xp, @NotNull XPGainReason xpGainReason, @NotNull XPGainSource xpGainSource) {
|
||||||
public void beginUnsharedXpGain(@NotNull RootSkill rootSkill, float xp, @NotNull XPGainReason xpGainReason, @NotNull XPGainSource xpGainSource) {
|
|
||||||
if(Misc.adaptPlayer(mmoPlayer).getGameMode() == GameMode.CREATIVE)
|
if(Misc.adaptPlayer(mmoPlayer).getGameMode() == GameMode.CREATIVE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ExperienceUtils.applyXpGain(mmoPlayer, rootSkill, modifyXpGain(rootSkill, xp), xpGainReason, xpGainSource);
|
ExperienceUtils.applyXpGain(mmoPlayer, primarySkillType, modifyXpGain(primarySkillType, xp), xpGainReason, xpGainSource);
|
||||||
|
|
||||||
Party party = mmoPlayer.getParty();
|
Party party = mmoPlayer.getParty();
|
||||||
|
|
||||||
if (party != null) {
|
if (party != null) {
|
||||||
if (!Config.getInstance().getPartyXpNearMembersNeeded() || !mcMMO.getPartyManager().getNearMembers(mmoPlayer).isEmpty()) {
|
if (!Config.getInstance().getPartyXpNearMembersNeeded() || !mcMMO.getPartyManager().getNearMembers(mmoPlayer).isEmpty()) {
|
||||||
party.getPartyExperienceManager().applyXpGain(modifyXpGain(rootSkill, xp));
|
party.getPartyExperienceManager().applyXpGain(modifyXpGain(primarySkillType, xp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public int getSkillLevel(@NotNull PrimarySkillType primarySkillType) {
|
||||||
public int getSkillLevel(@NotNull RootSkill rootSkill) {
|
return PrimarySkillType.isChildSkill(primarySkillType) ? getChildSkillLevel(primarySkillType) : getSkillLevel(primarySkillType);
|
||||||
return PrimarySkillType.isChildSkill(rootSkill) ? getChildSkillLevel(rootSkill) : getSkillLevel(rootSkill);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public int getExperienceToNextLevel(@NotNull PrimarySkillType primarySkillType) {
|
||||||
public int getExperienceToNextLevel(@NotNull RootSkill rootSkill) {
|
if(PrimarySkillType.isChildSkill(primarySkillType)) {
|
||||||
if(PrimarySkillType.isChildSkill(rootSkill)) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int level = (ExperienceConfig.getInstance().getCumulativeCurveEnabled()) ? getPowerLevel() : getSkillLevel(rootSkill);
|
int level = (ExperienceConfig.getInstance().getCumulativeCurveEnabled()) ? getPowerLevel() : getSkillLevel(primarySkillType);
|
||||||
FormulaType formulaType = ExperienceConfig.getInstance().getFormulaType();
|
FormulaType formulaType = ExperienceConfig.getInstance().getFormulaType();
|
||||||
|
|
||||||
return mcMMO.getFormulaManager().getXPtoNextLevel(level, formulaType);
|
return mcMMO.getFormulaManager().getXPtoNextLevel(level, formulaType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public int getChildSkillLevel(@NotNull PrimarySkillType primarySkillType) {
|
||||||
public int getChildSkillLevel(@NotNull RootSkill rootSkill) {
|
Set<RootSkill> parents = FamilyTree.getParentSkills(primarySkillType);
|
||||||
Set<RootSkill> parents = FamilyTree.getParentSkills(rootSkill);
|
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
|
|
||||||
for (RootSkill parentIdentity : parents) {
|
for (RootSkill parentIdentity : parents) {
|
||||||
@ -170,8 +160,7 @@ public class OnlineExperienceProcessor {
|
|||||||
return sum / parents.size();
|
return sum / parents.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void removeXp(@NotNull PrimarySkillType skill, int xp) {
|
||||||
public void removeXp(@NotNull RootSkill skill, int xp) {
|
|
||||||
if (skill.isChildSkill()) {
|
if (skill.isChildSkill()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -179,8 +168,7 @@ public class OnlineExperienceProcessor {
|
|||||||
setSkillXpValue(skill, getSkillXpValue(skill) - xp);
|
setSkillXpValue(skill, getSkillXpValue(skill) - xp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void removeXp(PrimarySkillType skill, float xp) {
|
||||||
public void removeXp(RootSkill skill, float xp) {
|
|
||||||
if (skill.isChildSkill()) {
|
if (skill.isChildSkill()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -188,9 +176,8 @@ public class OnlineExperienceProcessor {
|
|||||||
setSkillXpValue(skill, getSkillXpValue(skill) - xp);
|
setSkillXpValue(skill, getSkillXpValue(skill) - xp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setSkillLevel(@NotNull PrimarySkillType primarySkillType, int level) {
|
||||||
public void setSkillLevel(@NotNull RootSkill rootSkill, int level) {
|
if (primarySkillType.isChildSkill()) {
|
||||||
if (rootSkill.isChildSkill()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,19 +185,17 @@ public class OnlineExperienceProcessor {
|
|||||||
if(level < 0)
|
if(level < 0)
|
||||||
level = 0;
|
level = 0;
|
||||||
|
|
||||||
setSkillLevel(rootSkill, level);
|
setSkillLevel(primarySkillType, level);
|
||||||
setSkillXpValue(rootSkill, 0F);
|
setSkillXpValue(primarySkillType, 0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void addLevels(@NotNull PrimarySkillType primarySkillType, int levels) {
|
||||||
public void addLevels(@NotNull RootSkill rootSkill, int levels) {
|
setSkillLevel(primarySkillType, getSkillLevel(primarySkillType) + levels);
|
||||||
setSkillLevel(rootSkill, getSkillLevel(rootSkill) + levels);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void addXp(@NotNull PrimarySkillType primarySkillType, float xp) {
|
||||||
public void addXp(@NotNull RootSkill rootSkill, float xp) {
|
if (primarySkillType.isChildSkill()) {
|
||||||
if (rootSkill.isChildSkill()) {
|
Set<RootSkill> parentSkills = FamilyTree.getParents(primarySkillType);
|
||||||
Set<RootSkill> parentSkills = FamilyTree.getParents(rootSkill);
|
|
||||||
float dividedXP = (xp / parentSkills.size());
|
float dividedXP = (xp / parentSkills.size());
|
||||||
|
|
||||||
for (RootSkill parentSkill : parentSkills) {
|
for (RootSkill parentSkill : parentSkills) {
|
||||||
@ -218,28 +203,25 @@ public class OnlineExperienceProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setSkillXpValue(rootSkill, getSkillXpValue(rootSkill) + xp);
|
setSkillXpValue(primarySkillType, getSkillXpValue(primarySkillType) + xp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public float getRegisteredXpGain(@NotNull PrimarySkillType primarySkillType) {
|
||||||
public float getRegisteredXpGain(@NotNull RootSkill rootSkill) {
|
|
||||||
float xp = 0F;
|
float xp = 0F;
|
||||||
|
|
||||||
if (get(rootSkill) != null) { //??
|
if (get(primarySkillType) != null) { //??
|
||||||
xp = rollingSkillsXp.get(rootSkill);
|
xp = rollingSkillsXp.get(primarySkillType);
|
||||||
}
|
}
|
||||||
|
|
||||||
return xp;
|
return xp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void registerXpGain(@NotNull PrimarySkillType primarySkillType, float xp) {
|
||||||
public void registerXpGain(@NotNull RootSkill rootSkill, float xp) {
|
gainedSkillsXp.add(new SkillXpGain(primarySkillType, xp));
|
||||||
gainedSkillsXp.add(new SkillXpGain(rootSkill, xp));
|
rollingSkillsXp.put(primarySkillType, getRegisteredXpGain(primarySkillType) + xp);
|
||||||
rollingSkillsXp.put(rootSkill, getRegisteredXpGain(rootSkill) + xp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void purgeExpiredXpGains() {
|
public void purgeExpiredXpGains() {
|
||||||
SkillXpGain gain;
|
SkillXpGain gain;
|
||||||
while ((gain = gainedSkillsXp.poll()) != null) {
|
while ((gain = gainedSkillsXp.poll()) != null) {
|
||||||
@ -247,44 +229,40 @@ public class OnlineExperienceProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private float modifyXpGain(@NotNull PrimarySkillType primarySkillType, float xp) {
|
||||||
private float modifyXpGain(@NotNull RootSkill rootSkill, float xp) {
|
if ((primarySkillType.getMaxLevel() <= getSkillLevel(primarySkillType)) || (Config.getInstance().getPowerLevelCap() <= getPowerLevel())) {
|
||||||
if ((rootSkill.getMaxLevel() <= getSkillLevel(rootSkill)) || (Config.getInstance().getPowerLevelCap() <= getPowerLevel())) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
xp = (float) (xp / rootSkill.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier());
|
xp = (float) (xp / primarySkillType.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier());
|
||||||
|
|
||||||
return PerksUtils.handleXpPerks(Misc.adaptPlayer(mmoPlayer), xp, rootSkill);
|
return PerksUtils.handleXpPerks(Misc.adaptPlayer(mmoPlayer), xp, primarySkillType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public double getProgressInCurrentSkillLevel(@NotNull PrimarySkillType primarySkillType) throws UnknownSkillException
|
||||||
public double getProgressInCurrentSkillLevel(@NotNull RootSkill rootSkill) throws UnknownSkillException
|
|
||||||
{
|
{
|
||||||
if(PrimarySkillType.isChildSkill(rootSkill)) {
|
if(PrimarySkillType.isChildSkill(primarySkillType)) {
|
||||||
return 1.0D;
|
return 1.0D;
|
||||||
}
|
}
|
||||||
|
|
||||||
double currentXP = getSkillXpValue(rootSkill);
|
double currentXP = getSkillXpValue(primarySkillType);
|
||||||
double maxXP = getExperienceToNextLevel(rootSkill);
|
double maxXP = getExperienceToNextLevel(primarySkillType);
|
||||||
|
|
||||||
return (currentXP / maxXP);
|
return (currentXP / maxXP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setUsingUnarmed(boolean bool) {
|
public void setUsingUnarmed(boolean bool) {
|
||||||
isUsingUnarmed = bool;
|
isUsingUnarmed = bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void applyXpGain(@NotNull PrimarySkillType primarySkillType, float xp, @NotNull XPGainReason xpGainReason, @NotNull XPGainSource xpGainSource) {
|
||||||
public void applyXpGain(@NotNull RootSkill rootSkill, float xp, @NotNull XPGainReason xpGainReason, @NotNull XPGainSource xpGainSource) {
|
|
||||||
//Only check for permissions if the player is online, otherwise just assume a command is being executed by an admin or some other means and add the XP
|
//Only check for permissions if the player is online, otherwise just assume a command is being executed by an admin or some other means and add the XP
|
||||||
if (!Permissions.skillEnabled(mmoPlayer.getPlayer(), PrimarySkillType.getSkill(rootSkill))) {
|
if (!Permissions.skillEnabled(mmoPlayer.getPlayer(), PrimarySkillType.getSkill(primarySkillType))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PrimarySkillType.isChildSkill(rootSkill)) {
|
if (PrimarySkillType.isChildSkill(primarySkillType)) {
|
||||||
Set<RootSkill> parentSkills = FamilyTree.getParentSkills(rootSkill);
|
Set<RootSkill> parentSkills = FamilyTree.getParentSkills(primarySkillType);
|
||||||
|
|
||||||
for (RootSkill parentSkill : parentSkills) {
|
for (RootSkill parentSkill : parentSkills) {
|
||||||
applyXpGain(parentSkill, xp / parentSkills.size(), xpGainReason, xpGainSource);
|
applyXpGain(parentSkill, xp / parentSkills.size(), xpGainReason, xpGainSource);
|
||||||
@ -293,16 +271,15 @@ public class OnlineExperienceProcessor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EventUtils.handleXpGainEvent(Misc.adaptPlayer(mmoPlayer), rootSkill, xp, xpGainReason)) {
|
if (!EventUtils.handleXpGainEvent(Misc.adaptPlayer(mmoPlayer), primarySkillType, xp, xpGainReason)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setUsingUnarmed(rootSkill == PrimarySkillType.UNARMED);
|
setUsingUnarmed(primarySkillType == PrimarySkillType.UNARMED);
|
||||||
updateLevelStats(rootSkill, xpGainReason, xpGainSource);
|
updateLevelStats(primarySkillType, xpGainReason, xpGainSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void processPostXpEvent(@NotNull PrimarySkillType primarySkillType, @NotNull XPGainSource xpGainSource)
|
||||||
public void processPostXpEvent(@NotNull RootSkill rootSkill, @NotNull XPGainSource xpGainSource)
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Everything in this method requires an online player, so if they aren't online we don't waste our time
|
* Everything in this method requires an online player, so if they aren't online we don't waste our time
|
||||||
@ -313,8 +290,8 @@ public class OnlineExperienceProcessor {
|
|||||||
//Check if they've reached the power level cap just now
|
//Check if they've reached the power level cap just now
|
||||||
if(hasReachedPowerLevelCap()) {
|
if(hasReachedPowerLevelCap()) {
|
||||||
NotificationManager.sendPlayerInformationChatOnly(Misc.adaptPlayer(mmoPlayer), "LevelCap.PowerLevel", String.valueOf(Config.getInstance().getPowerLevelCap()));
|
NotificationManager.sendPlayerInformationChatOnly(Misc.adaptPlayer(mmoPlayer), "LevelCap.PowerLevel", String.valueOf(Config.getInstance().getPowerLevelCap()));
|
||||||
} else if(hasReachedLevelCap(rootSkill)) {
|
} else if(hasReachedLevelCap(primarySkillType)) {
|
||||||
NotificationManager.sendPlayerInformationChatOnly(Misc.adaptPlayer(mmoPlayer), "LevelCap.Skill", String.valueOf(Config.getInstance().getLevelCap(rootSkill)), rootSkill.getRawSkillName());
|
NotificationManager.sendPlayerInformationChatOnly(Misc.adaptPlayer(mmoPlayer), "LevelCap.Skill", String.valueOf(Config.getInstance().getLevelCap(primarySkillType)), primarySkillType.getRawSkillName());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Updates from Party sources
|
//Updates from Party sources
|
||||||
@ -325,33 +302,32 @@ public class OnlineExperienceProcessor {
|
|||||||
if(xpGainSource == XPGainSource.PASSIVE && !ExperienceConfig.getInstance().isPassiveGainsExperienceBarsEnabled())
|
if(xpGainSource == XPGainSource.PASSIVE && !ExperienceConfig.getInstance().isPassiveGainsExperienceBarsEnabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mmoPlayer.updateXPBar(rootSkill);
|
mmoPlayer.updateXPBar(primarySkillType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void updateLevelStats(@NotNull PrimarySkillType primarySkillType, @NotNull XPGainReason xpGainReason, @NotNull XPGainSource xpGainSource) {
|
||||||
public void updateLevelStats(@NotNull RootSkill rootSkill, @NotNull XPGainReason xpGainReason, @NotNull XPGainSource xpGainSource) {
|
if(hasReachedLevelCap(primarySkillType))
|
||||||
if(hasReachedLevelCap(rootSkill))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (getSkillXpLevelRaw(rootSkill) < getExperienceToNextLevel(rootSkill)) {
|
if (getSkillXpLevelRaw(primarySkillType) < getExperienceToNextLevel(primarySkillType)) {
|
||||||
processPostXpEvent(rootSkill, xpGainSource);
|
processPostXpEvent(primarySkillType, xpGainSource);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int levelsGained = 0;
|
int levelsGained = 0;
|
||||||
float xpRemoved = 0;
|
float xpRemoved = 0;
|
||||||
|
|
||||||
while (getSkillXpLevelRaw(rootSkill) >= getExperienceToNextLevel(rootSkill)) {
|
while (getSkillXpLevelRaw(primarySkillType) >= getExperienceToNextLevel(primarySkillType)) {
|
||||||
if (hasReachedLevelCap(rootSkill)) {
|
if (hasReachedLevelCap(primarySkillType)) {
|
||||||
setSkillXpValue(rootSkill, 0);
|
setSkillXpValue(primarySkillType, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
xpRemoved += levelUp(rootSkill);
|
xpRemoved += levelUp(primarySkillType);
|
||||||
levelsGained++;
|
levelsGained++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EventUtils.tryLevelChangeEvent(Misc.adaptPlayer(mmoPlayer), rootSkill, levelsGained, xpRemoved, true, xpGainReason)) {
|
if (EventUtils.tryLevelChangeEvent(Misc.adaptPlayer(mmoPlayer), primarySkillType, levelsGained, xpRemoved, true, xpGainReason)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,9 +339,9 @@ public class OnlineExperienceProcessor {
|
|||||||
* Check to see if the player unlocked any new skills
|
* Check to see if the player unlocked any new skills
|
||||||
*/
|
*/
|
||||||
|
|
||||||
NotificationManager.sendPlayerLevelUpNotification(mmoPlayer, rootSkill, levelsGained, getSkillLevel(rootSkill));
|
NotificationManager.sendPlayerLevelUpNotification(mmoPlayer, primarySkillType, levelsGained, getSkillLevel(primarySkillType));
|
||||||
|
|
||||||
//UPDATE XP BARS
|
//UPDATE XP BARS
|
||||||
processPostXpEvent(rootSkill, xpGainSource);
|
processPostXpEvent(primarySkillType, xpGainSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,18 +2,17 @@ package com.gmail.nossr50.datatypes.player;
|
|||||||
|
|
||||||
import com.gmail.nossr50.datatypes.experience.OfflineExperienceProcessor;
|
import com.gmail.nossr50.datatypes.experience.OfflineExperienceProcessor;
|
||||||
import com.gmail.nossr50.datatypes.experience.OnlineExperienceProcessor;
|
import com.gmail.nossr50.datatypes.experience.OnlineExperienceProcessor;
|
||||||
import com.neetgames.mcmmo.experience.ExperienceHandler;
|
import com.neetgames.mcmmo.experience.ExperienceProcessor;
|
||||||
import com.neetgames.mcmmo.player.MMOPlayer;
|
import com.neetgames.mcmmo.player.MMOPlayer;
|
||||||
import com.neetgames.mcmmo.player.MMOPlayerData;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public abstract class AbstractMMOPlayer implements MMOPlayer {
|
public abstract class AbstractMMOPlayer implements MMOPlayer {
|
||||||
/* All of the persistent data for a player that gets saved and loaded from DB */
|
/* All of the persistent data for a player that gets saved and loaded from DB */
|
||||||
protected final @NotNull MMOPlayerData mmoPlayerData; //All persistent data is kept here
|
protected final @NotNull PlayerData mmoPlayerData; //All persistent data is kept here
|
||||||
|
|
||||||
/* Managers */
|
/* Managers */
|
||||||
protected final @NotNull ExperienceHandler experienceHandler;
|
protected final @NotNull ExperienceProcessor experienceProcessor;
|
||||||
protected final @NotNull CooldownManager cooldownManager;
|
protected final @NotNull CooldownManager cooldownManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,9 +21,9 @@ public abstract class AbstractMMOPlayer implements MMOPlayer {
|
|||||||
*
|
*
|
||||||
* @param mmoPlayerData player data
|
* @param mmoPlayerData player data
|
||||||
*/
|
*/
|
||||||
public AbstractMMOPlayer(@NotNull Player player, @NotNull MMOPlayerDataImpl mmoPlayerData) {
|
public AbstractMMOPlayer(@NotNull Player player, @NotNull PlayerData mmoPlayerData) {
|
||||||
this.mmoPlayerData = mmoPlayerData;
|
this.mmoPlayerData = mmoPlayerData;
|
||||||
this.experienceHandler = new OnlineExperienceProcessor(mmoPlayerData);
|
this.experienceProcessor = new OnlineExperienceProcessor(mmoPlayerData);
|
||||||
this.cooldownManager = new CooldownManager(mmoPlayerData);
|
this.cooldownManager = new CooldownManager(mmoPlayerData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,9 +32,9 @@ public abstract class AbstractMMOPlayer implements MMOPlayer {
|
|||||||
*
|
*
|
||||||
* @param mmoPlayerData player data
|
* @param mmoPlayerData player data
|
||||||
*/
|
*/
|
||||||
public AbstractMMOPlayer(@NotNull MMOPlayerDataImpl mmoPlayerData) {
|
public AbstractMMOPlayer(@NotNull PlayerData mmoPlayerData) {
|
||||||
this.mmoPlayerData = mmoPlayerData;
|
this.mmoPlayerData = mmoPlayerData;
|
||||||
this.experienceHandler = new OfflineExperienceProcessor(mmoPlayerData);
|
this.experienceProcessor = new OfflineExperienceProcessor(mmoPlayerData);
|
||||||
this.cooldownManager = new CooldownManager(mmoPlayerData);
|
this.cooldownManager = new CooldownManager(mmoPlayerData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,9 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class CooldownManager {
|
public class CooldownManager {
|
||||||
private final @NotNull MMOPlayerDataImpl playerDataRef;
|
private final @NotNull PlayerData playerDataRef;
|
||||||
|
|
||||||
public CooldownManager(@NotNull MMOPlayerDataImpl playerDataRef) {
|
public CooldownManager(@NotNull PlayerData playerDataRef) {
|
||||||
this.playerDataRef = playerDataRef;
|
this.playerDataRef = playerDataRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package com.gmail.nossr50.datatypes.player;
|
package com.gmail.nossr50.datatypes.player;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
|
import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
|
||||||
import com.neetgames.mcmmo.UniqueDataType;
|
import com.neetgames.mcmmo.UniqueDataType;
|
||||||
import com.neetgames.mcmmo.player.MMOPlayerData;
|
|
||||||
import com.neetgames.mcmmo.skill.RootSkill;
|
|
||||||
import com.neetgames.mcmmo.skill.SkillBossBarState;
|
import com.neetgames.mcmmo.skill.SkillBossBarState;
|
||||||
import com.neetgames.mcmmo.skill.SuperSkill;
|
|
||||||
import org.apache.commons.lang.NullArgumentException;
|
import org.apache.commons.lang.NullArgumentException;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -29,9 +27,9 @@ public class MMODataBuilder {
|
|||||||
/* Skill Data */
|
/* Skill Data */
|
||||||
private @Nullable Map<PrimarySkillType, Integer> skillLevelValues;
|
private @Nullable Map<PrimarySkillType, Integer> skillLevelValues;
|
||||||
private @Nullable Map<PrimarySkillType, Float> skillExperienceValues;
|
private @Nullable Map<PrimarySkillType, Float> skillExperienceValues;
|
||||||
private @Nullable Map<SuperSkill, Integer> abilityDeactivationTimestamps; // Ability & Cooldown
|
private @Nullable Map<SuperAbilityType, Integer> abilityDeactivationTimestamps; // Ability & Cooldown
|
||||||
private @Nullable Map<UniqueDataType, Integer> uniquePlayerData; //Misc data that doesn't fit into other categories (chimaera wing, etc..)
|
private @Nullable Map<UniqueDataType, Integer> uniquePlayerData; //Misc data that doesn't fit into other categories (chimaera wing, etc..)
|
||||||
private @Nullable Map<RootSkill, SkillBossBarState> barStateMap;
|
private @Nullable Map<PrimarySkillType, SkillBossBarState> barStateMap;
|
||||||
|
|
||||||
/* Special Flags */
|
/* Special Flags */
|
||||||
private boolean partyChatSpying;
|
private boolean partyChatSpying;
|
||||||
@ -40,28 +38,28 @@ public class MMODataBuilder {
|
|||||||
/* Scoreboards */
|
/* Scoreboards */
|
||||||
private int scoreboardTipsShown;
|
private int scoreboardTipsShown;
|
||||||
|
|
||||||
public @NotNull MMOPlayerData buildNewPlayerData(@NotNull Player player) {
|
public @NotNull PlayerData buildNewPlayerData(@NotNull Player player) {
|
||||||
/*
|
/*
|
||||||
* New Profile with default values
|
* New Profile with default values
|
||||||
*/
|
*/
|
||||||
return buildNewPlayerData(player.getUniqueId(), player.getName());
|
return buildNewPlayerData(player.getUniqueId(), player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable MMOPlayerData buildNewPlayerData(@NotNull OfflinePlayer offlinePlayer) {
|
public @Nullable PlayerData buildNewPlayerData(@NotNull OfflinePlayer offlinePlayer) {
|
||||||
if(offlinePlayer.getName() != null)
|
if(offlinePlayer.getName() != null)
|
||||||
return buildNewPlayerData(offlinePlayer.getUniqueId(), offlinePlayer.getName());
|
return buildNewPlayerData(offlinePlayer.getUniqueId(), offlinePlayer.getName());
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull MMOPlayerData buildNewPlayerData(@NotNull UUID playerUUID, @NotNull String playerName) {
|
public @NotNull PlayerData buildNewPlayerData(@NotNull UUID playerUUID, @NotNull String playerName) {
|
||||||
/*
|
/*
|
||||||
* New Profile with default values
|
* New Profile with default values
|
||||||
*/
|
*/
|
||||||
return new MMOPlayerDataImpl(playerUUID, playerName);
|
return new PlayerData(playerUUID, playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull MMOPlayerData build() throws Exception {
|
public @NotNull PlayerData build() throws Exception {
|
||||||
if(playerUUID == null)
|
if(playerUUID == null)
|
||||||
throw new NullArgumentException("playerUUID");
|
throw new NullArgumentException("playerUUID");
|
||||||
|
|
||||||
@ -93,19 +91,22 @@ public class MMODataBuilder {
|
|||||||
|
|
||||||
validateBarStateMapEntries(barStateMap);
|
validateBarStateMapEntries(barStateMap);
|
||||||
|
|
||||||
return new MMOPlayerDataImpl(playerUUID, playerName, partyChatSpying, skillLevelValues, skillExperienceValues, abilityDeactivationTimestamps, uniquePlayerData, barStateMap, scoreboardTipsShown, lastLogin, leaderBoardExemption);
|
return new PlayerData(playerUUID, playerName, partyChatSpying, skillLevelValues, skillExperienceValues, abilityDeactivationTimestamps, uniquePlayerData, barStateMap, scoreboardTipsShown, lastLogin, leaderBoardExemption);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateBarStateMapEntries(@NotNull Map<RootSkill, SkillBossBarState> map) {
|
private void validateBarStateMapEntries(@NotNull Map<PrimarySkillType, SkillBossBarState> map) {
|
||||||
Map<RootSkill, SkillBossBarState> barMapDefaults = MMOExperienceBarManager.generateDefaultBarStateMap();
|
Map<PrimarySkillType, SkillBossBarState> barMapDefaults = MMOExperienceBarManager.generateDefaultBarStateMap();
|
||||||
|
|
||||||
for(RootSkill key : mcMMO.p.getSkillRegister().getRootSkills()) {
|
for(PrimarySkillType key : PrimarySkillType.values()) {
|
||||||
map.putIfAbsent(key, barMapDefaults.get(key));
|
map.putIfAbsent(key, barMapDefaults.get(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateExperienceValueMapEntries(@NotNull Map<PrimarySkillType, Float> map) {
|
private void validateExperienceValueMapEntries(@NotNull Map<PrimarySkillType, Float> map) {
|
||||||
for(RootSkill key : mcMMO.p.getSkillRegister().getRootSkills()) {
|
for(PrimarySkillType key : PrimarySkillType.values()) {
|
||||||
|
if(key.isChildSkill())
|
||||||
|
continue;
|
||||||
|
|
||||||
map.putIfAbsent(key, 0F);
|
map.putIfAbsent(key, 0F);
|
||||||
|
|
||||||
if(map.get(key) < 0F) {
|
if(map.get(key) < 0F) {
|
||||||
@ -126,8 +127,8 @@ public class MMODataBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateAbilityCooldownMapEntries(@NotNull Map<SuperSkill, Integer> map) {
|
private void validateAbilityCooldownMapEntries(@NotNull Map<SuperAbilityType, Integer> map) {
|
||||||
for(SuperSkill key : mcMMO.p.getSkillRegister().getSuperSkills()) {
|
for(SuperAbilityType key : SuperAbilityType.values()) {
|
||||||
map.putIfAbsent(key, 0);
|
map.putIfAbsent(key, 0);
|
||||||
|
|
||||||
if(map.get(key) < 0) {
|
if(map.get(key) < 0) {
|
||||||
@ -138,7 +139,11 @@ public class MMODataBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void validateSkillLevelMapEntries(@NotNull Map<PrimarySkillType, Integer> map) {
|
private void validateSkillLevelMapEntries(@NotNull Map<PrimarySkillType, Integer> map) {
|
||||||
for(RootSkill key : mcMMO.p.getSkillRegister().getRootSkills()) {
|
for(PrimarySkillType key : PrimarySkillType.values()) {
|
||||||
|
|
||||||
|
if(key.isChildSkill())
|
||||||
|
continue;
|
||||||
|
|
||||||
map.putIfAbsent(key, 0);
|
map.putIfAbsent(key, 0);
|
||||||
|
|
||||||
if(map.get(key) < 0) {
|
if(map.get(key) < 0) {
|
||||||
@ -193,11 +198,11 @@ public class MMODataBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable Map<SuperSkill, Integer> getAbilityDeactivationTimestamps() {
|
public @Nullable Map<SuperAbilityType, Integer> getAbilityDeactivationTimestamps() {
|
||||||
return abilityDeactivationTimestamps;
|
return abilityDeactivationTimestamps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull MMODataBuilder setAbilityDeactivationTimestamps(@NotNull Map<SuperSkill, Integer> abilityDeactivationTimestamps) {
|
public @NotNull MMODataBuilder setAbilityDeactivationTimestamps(@NotNull Map<SuperAbilityType, Integer> abilityDeactivationTimestamps) {
|
||||||
this.abilityDeactivationTimestamps = abilityDeactivationTimestamps;
|
this.abilityDeactivationTimestamps = abilityDeactivationTimestamps;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -211,11 +216,11 @@ public class MMODataBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable Map<RootSkill, SkillBossBarState> getBarStateMap() {
|
public @Nullable Map<PrimarySkillType, SkillBossBarState> getBarStateMap() {
|
||||||
return barStateMap;
|
return barStateMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull MMODataBuilder setBarStateMap(@NotNull Map<RootSkill, SkillBossBarState> barStateMap) {
|
public @NotNull MMODataBuilder setBarStateMap(@NotNull Map<PrimarySkillType, SkillBossBarState> barStateMap) {
|
||||||
this.barStateMap = barStateMap;
|
this.barStateMap = barStateMap;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,8 @@ package com.gmail.nossr50.datatypes.player;
|
|||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.neetgames.mcmmo.MobHealthBarType;
|
|
||||||
import com.neetgames.mcmmo.UniqueDataType;
|
import com.neetgames.mcmmo.UniqueDataType;
|
||||||
import com.neetgames.mcmmo.player.MMOPlayerData;
|
import com.neetgames.mcmmo.player.MMOPlayerDataImpl;
|
||||||
import com.neetgames.mcmmo.skill.RootSkill;
|
import com.neetgames.mcmmo.skill.RootSkill;
|
||||||
import com.neetgames.mcmmo.skill.SkillBossBarState;
|
import com.neetgames.mcmmo.skill.SkillBossBarState;
|
||||||
import com.neetgames.mcmmo.skill.SuperSkill;
|
import com.neetgames.mcmmo.skill.SuperSkill;
|
||||||
@ -36,7 +35,7 @@ public class MMODataSnapshot {
|
|||||||
private final int scoreboardTipsShown;
|
private final int scoreboardTipsShown;
|
||||||
|
|
||||||
|
|
||||||
public MMODataSnapshot(@NotNull MMOPlayerData mmoPlayerData) {
|
public MMODataSnapshot(@NotNull PlayerData mmoPlayerData) {
|
||||||
playerName = mmoPlayerData.getPlayerName();
|
playerName = mmoPlayerData.getPlayerName();
|
||||||
playerUUID = mmoPlayerData.getPlayerUUID();
|
playerUUID = mmoPlayerData.getPlayerUUID();
|
||||||
lastLogin = mmoPlayerData.getLastLogin();
|
lastLogin = mmoPlayerData.getLastLogin();
|
||||||
@ -94,12 +93,12 @@ public class MMODataSnapshot {
|
|||||||
return scoreboardTipsShown;
|
return scoreboardTipsShown;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSkillLevel(@NotNull RootSkill rootSkill) {
|
public int getSkillLevel(@NotNull PrimarySkillType primarySkillType) {
|
||||||
return skillLevelValues.getOrDefault(rootSkill, 0);
|
return skillLevelValues.getOrDefault(primarySkillType, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSkillXpLevel(@NotNull RootSkill rootSkill) {
|
public int getSkillXpLevel(@NotNull PrimarySkillType primarySkillType) {
|
||||||
return (skillExperienceValues.getOrDefault(rootSkill, 0F)).intValue();
|
return (skillExperienceValues.getOrDefault(primarySkillType, 0F)).intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getAbilityDATS(@NotNull SuperAbilityType superAbilityType) {
|
public long getAbilityDATS(@NotNull SuperAbilityType superAbilityType) {
|
||||||
|
@ -5,7 +5,6 @@ import com.gmail.nossr50.config.ChatConfig;
|
|||||||
import com.gmail.nossr50.config.WorldBlacklist;
|
import com.gmail.nossr50.config.WorldBlacklist;
|
||||||
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||||
import com.gmail.nossr50.datatypes.skills.CoreRootSkill;
|
import com.gmail.nossr50.datatypes.skills.CoreRootSkill;
|
||||||
import com.gmail.nossr50.datatypes.skills.CoreSkills;
|
|
||||||
import com.neetgames.mcmmo.party.Party;
|
import com.neetgames.mcmmo.party.Party;
|
||||||
import com.gmail.nossr50.party.PartyTeleportRecord;
|
import com.gmail.nossr50.party.PartyTeleportRecord;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
@ -34,10 +33,7 @@ import com.gmail.nossr50.util.Permissions;
|
|||||||
import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
|
import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
|
||||||
import com.gmail.nossr50.util.input.AbilityActivationProcessor;
|
import com.gmail.nossr50.util.input.AbilityActivationProcessor;
|
||||||
import com.gmail.nossr50.util.input.SuperSkillManagerImpl;
|
import com.gmail.nossr50.util.input.SuperSkillManagerImpl;
|
||||||
import com.neetgames.mcmmo.player.MMOPlayerData;
|
|
||||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||||
import com.neetgames.mcmmo.player.SuperSkillManager;
|
|
||||||
import com.neetgames.mcmmo.skill.RootSkill;
|
|
||||||
import net.kyori.adventure.identity.Identified;
|
import net.kyori.adventure.identity.Identified;
|
||||||
import net.kyori.adventure.identity.Identity;
|
import net.kyori.adventure.identity.Identity;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -58,7 +54,7 @@ public class McMMOPlayer extends PlayerProfile implements OnlineMMOPlayer, Ident
|
|||||||
|
|
||||||
//Used in our chat systems for chat messages
|
//Used in our chat systems for chat messages
|
||||||
private final @NotNull PlayerAuthor playerAuthor;
|
private final @NotNull PlayerAuthor playerAuthor;
|
||||||
private final @NotNull Map<RootSkill, SkillManager> skillManagers = new HashMap<>();
|
private final @NotNull Map<PrimarySkillType, SkillManager> skillManagers = new HashMap<>();
|
||||||
private final @NotNull MMOExperienceBarManager experienceBarManager;
|
private final @NotNull MMOExperienceBarManager experienceBarManager;
|
||||||
|
|
||||||
private @Nullable PartyTeleportRecord ptpRecord;
|
private @Nullable PartyTeleportRecord ptpRecord;
|
||||||
@ -93,7 +89,7 @@ public class McMMOPlayer extends PlayerProfile implements OnlineMMOPlayer, Ident
|
|||||||
* New
|
* New
|
||||||
* Player
|
* Player
|
||||||
*/
|
*/
|
||||||
super(new MMOPlayerDataImpl(player.getUniqueId(), player.getName()));
|
super(new PlayerData(player.getUniqueId(), player.getName()));
|
||||||
|
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
identity = Identity.identity(uuid);
|
identity = Identity.identity(uuid);
|
||||||
@ -126,7 +122,7 @@ public class McMMOPlayer extends PlayerProfile implements OnlineMMOPlayer, Ident
|
|||||||
* @param player target player
|
* @param player target player
|
||||||
* @param mmoPlayerData existing player data
|
* @param mmoPlayerData existing player data
|
||||||
*/
|
*/
|
||||||
public McMMOPlayer(@NotNull Player player, @NotNull MMOPlayerData mmoPlayerData) {
|
public McMMOPlayer(@NotNull Player player, @NotNull PlayerData mmoPlayerData) {
|
||||||
/*
|
/*
|
||||||
* Existing
|
* Existing
|
||||||
* Player
|
* Player
|
||||||
@ -587,8 +583,8 @@ public class McMMOPlayer extends PlayerProfile implements OnlineMMOPlayer, Ident
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateXPBar(@NotNull RootSkill rootSkill) {
|
public void updateXPBar(@NotNull PrimarySkillType primarySkillType) {
|
||||||
experienceBarManager.updateExperienceBar(rootSkill, mcMMO.p);
|
experienceBarManager.updateExperienceBar(primarySkillType, mcMMO.p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -603,8 +599,7 @@ public class McMMOPlayer extends PlayerProfile implements OnlineMMOPlayer, Ident
|
|||||||
return playerPartyRef;
|
return playerPartyRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public @NotNull SuperSkillManagerImpl getSuperSkillManager() {
|
||||||
public @NotNull SuperSkillManager getSuperSkillManager() {
|
|
||||||
return superSkillManagerImpl;
|
return superSkillManagerImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
package com.gmail.nossr50.datatypes.player;
|
package com.gmail.nossr50.datatypes.player;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.datatypes.skills.CoreSkills;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||||
import com.gmail.nossr50.datatypes.validation.NonNullRule;
|
import com.gmail.nossr50.datatypes.validation.NonNullRule;
|
||||||
import com.gmail.nossr50.datatypes.validation.PositiveIntegerRule;
|
import com.gmail.nossr50.datatypes.validation.PositiveIntegerRule;
|
||||||
import com.gmail.nossr50.datatypes.validation.Validator;
|
import com.gmail.nossr50.datatypes.validation.Validator;
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
|
import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.neetgames.mcmmo.UniqueDataType;
|
import com.neetgames.mcmmo.UniqueDataType;
|
||||||
import com.neetgames.mcmmo.exceptions.UnexpectedValueException;
|
import com.neetgames.mcmmo.exceptions.UnexpectedValueException;
|
||||||
import com.neetgames.mcmmo.skill.*;
|
import com.neetgames.mcmmo.skill.*;
|
||||||
import com.neetgames.mcmmo.player.MMOPlayerData;
|
|
||||||
import com.neetgames.neetlib.dirtydata.DirtyData;
|
import com.neetgames.neetlib.dirtydata.DirtyData;
|
||||||
import com.neetgames.neetlib.dirtydata.DirtyMap;
|
import com.neetgames.neetlib.dirtydata.DirtyMap;
|
||||||
import com.neetgames.neetlib.mutableprimitives.MutableBoolean;
|
import com.neetgames.neetlib.mutableprimitives.MutableBoolean;
|
||||||
@ -25,7 +24,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class MMOPlayerDataImpl implements MMOPlayerData {
|
public class PlayerData {
|
||||||
|
|
||||||
private final @NotNull MutableBoolean dirtyFlag; //Dirty values in this class will change this flag as needed
|
private final @NotNull MutableBoolean dirtyFlag; //Dirty values in this class will change this flag as needed
|
||||||
|
|
||||||
@ -39,9 +38,9 @@ public class MMOPlayerDataImpl implements MMOPlayerData {
|
|||||||
/* Skill Data */
|
/* Skill Data */
|
||||||
private final @NotNull DirtyMap<PrimarySkillType, Integer> skillLevelValues;
|
private final @NotNull DirtyMap<PrimarySkillType, Integer> skillLevelValues;
|
||||||
private final @NotNull DirtyMap<PrimarySkillType, Float> skillExperienceValues;
|
private final @NotNull DirtyMap<PrimarySkillType, Float> skillExperienceValues;
|
||||||
private final @NotNull DirtyMap<SuperSkill, Integer> abilityDeactivationTimestamps; // Ability & Cooldown
|
private final @NotNull DirtyMap<SuperAbilityType, Integer> abilityDeactivationTimestamps; // Ability & Cooldown
|
||||||
private final @NotNull DirtyMap<UniqueDataType, Integer> uniquePlayerData; //Misc data that doesn't fit into other categories (chimaera wing, etc..)
|
private final @NotNull DirtyMap<UniqueDataType, Integer> uniquePlayerData; //Misc data that doesn't fit into other categories (chimaera wing, etc..)
|
||||||
private final @NotNull DirtyMap<RootSkill, SkillBossBarState> barStateMap;
|
private final @NotNull DirtyMap<PrimarySkillType, SkillBossBarState> barStateMap;
|
||||||
|
|
||||||
/* Special Flags */
|
/* Special Flags */
|
||||||
private final @NotNull DirtyData<MutableBoolean> partyChatSpying;
|
private final @NotNull DirtyData<MutableBoolean> partyChatSpying;
|
||||||
@ -58,7 +57,7 @@ public class MMOPlayerDataImpl implements MMOPlayerData {
|
|||||||
* @param playerName target player's name
|
* @param playerName target player's name
|
||||||
* @throws NullArgumentException thrown when never null arguments are null
|
* @throws NullArgumentException thrown when never null arguments are null
|
||||||
*/
|
*/
|
||||||
public MMOPlayerDataImpl(@NotNull UUID playerUUID, @NotNull String playerName) throws NullArgumentException {
|
public PlayerData(@NotNull UUID playerUUID, @NotNull String playerName) throws NullArgumentException {
|
||||||
/*
|
/*
|
||||||
* New Data
|
* New Data
|
||||||
*/
|
*/
|
||||||
@ -73,15 +72,19 @@ public class MMOPlayerDataImpl implements MMOPlayerData {
|
|||||||
|
|
||||||
this.scoreboardTipsShown = new DirtyData<>(new MutableInteger(0), dirtyFlag);
|
this.scoreboardTipsShown = new DirtyData<>(new MutableInteger(0), dirtyFlag);
|
||||||
|
|
||||||
for(SuperSkill superSkill : mcMMO.p.getSkillRegister().getSuperSkills()) {
|
for(SuperAbilityType superSkill : SuperAbilityType.values()) {
|
||||||
abilityDeactivationTimestamps.put(superSkill, 0);
|
abilityDeactivationTimestamps.put(superSkill, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Core skills
|
//Core skills
|
||||||
//TODO: Don't store values for disabled skills
|
//TODO: Don't store values for disabled skills
|
||||||
for(RootSkill rootSkill : PrimarySkillType.getCoreRootSkills()) {
|
for(PrimarySkillType primarySkillType : PrimarySkillType.values()) {
|
||||||
skillLevelValues.put(rootSkill, AdvancedConfig.getInstance().getStartingLevel());
|
|
||||||
skillExperienceValues.put(rootSkill, 0F);
|
if(primarySkillType.isChildSkill())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
skillLevelValues.put(primarySkillType, AdvancedConfig.getInstance().getStartingLevel());
|
||||||
|
skillExperienceValues.put(primarySkillType, 0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Unique Player Data
|
//Unique Player Data
|
||||||
@ -109,17 +112,17 @@ public class MMOPlayerDataImpl implements MMOPlayerData {
|
|||||||
* @param lastLogin target player's last login
|
* @param lastLogin target player's last login
|
||||||
* @param leaderBoardExclusion target player's leaderboard exemption status
|
* @param leaderBoardExclusion target player's leaderboard exemption status
|
||||||
*/
|
*/
|
||||||
public MMOPlayerDataImpl(@NotNull UUID playerUUID,
|
public PlayerData(@NotNull UUID playerUUID,
|
||||||
@NotNull String playerName,
|
@NotNull String playerName,
|
||||||
boolean partyChatSpying,
|
boolean partyChatSpying,
|
||||||
@NotNull Map<PrimarySkillType, Integer> skillLevelValues,
|
@NotNull Map<PrimarySkillType, Integer> skillLevelValues,
|
||||||
@NotNull Map<PrimarySkillType, Float> skillExperienceValues,
|
@NotNull Map<PrimarySkillType, Float> skillExperienceValues,
|
||||||
@NotNull Map<SuperSkill, Integer> abilityDeactivationTimestamps,
|
@NotNull Map<SuperAbilityType, Integer> abilityDeactivationTimestamps,
|
||||||
@NotNull Map<UniqueDataType, Integer> uniquePlayerData,
|
@NotNull Map<UniqueDataType, Integer> uniquePlayerData,
|
||||||
@NotNull Map<RootSkill, SkillBossBarState> barStateMap,
|
@NotNull Map<PrimarySkillType, SkillBossBarState> barStateMap,
|
||||||
int scoreboardTipsShown,
|
int scoreboardTipsShown,
|
||||||
long lastLogin,
|
long lastLogin,
|
||||||
boolean leaderBoardExclusion) throws Exception {
|
boolean leaderBoardExclusion) throws Exception {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Skills Data
|
* Skills Data
|
||||||
@ -156,15 +159,18 @@ public class MMOPlayerDataImpl implements MMOPlayerData {
|
|||||||
* @throws UnexpectedValueException when values are outside of expected norms
|
* @throws UnexpectedValueException when values are outside of expected norms
|
||||||
* @throws Exception when values are outside of expected norms
|
* @throws Exception when values are outside of expected norms
|
||||||
*/
|
*/
|
||||||
private void validateRootSkillMap(Map<? extends RootSkill, ? extends Number> map) throws UnexpectedValueException, Exception {
|
private void validateRootSkillMap(Map<PrimarySkillType, ? extends Number> map) throws UnexpectedValueException, Exception {
|
||||||
//TODO: Check for missing/unregistered
|
//TODO: Check for missing/unregistered
|
||||||
Validator<Number> validator = new Validator<>();
|
Validator<Number> validator = new Validator<>();
|
||||||
|
|
||||||
validator.addRule(new PositiveIntegerRule<>());
|
validator.addRule(new PositiveIntegerRule<>());
|
||||||
validator.addRule(new NonNullRule<>());
|
validator.addRule(new NonNullRule<>());
|
||||||
|
|
||||||
for(RootSkill rootSkill : mcMMO.p.getSkillRegister().getRootSkills()) {
|
for(PrimarySkillType primarySkillType : PrimarySkillType.values()) {
|
||||||
validator.validate(map.get(rootSkill));
|
if(primarySkillType.isChildSkill())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
validator.validate(map.get(primarySkillType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,56 +181,49 @@ public class MMOPlayerDataImpl implements MMOPlayerData {
|
|||||||
* @throws UnexpectedValueException when values are outside of expected norms
|
* @throws UnexpectedValueException when values are outside of expected norms
|
||||||
* @throws Exception when values are outside of expected norms
|
* @throws Exception when values are outside of expected norms
|
||||||
*/
|
*/
|
||||||
private void validateSuperSkillMap(Map<? extends SuperSkill, ? extends Number> map) throws UnexpectedValueException, Exception {
|
private void validateSuperSkillMap(Map<? extends SuperAbilityType, ? extends Number> map) throws UnexpectedValueException, Exception {
|
||||||
//TODO: Check for missing/unregistered
|
//TODO: Check for missing/unregistered
|
||||||
Validator<Number> validator = new Validator<>();
|
Validator<Number> validator = new Validator<>();
|
||||||
|
|
||||||
validator.addRule(new PositiveIntegerRule<>());
|
validator.addRule(new PositiveIntegerRule<>());
|
||||||
validator.addRule(new NonNullRule<>());
|
validator.addRule(new NonNullRule<>());
|
||||||
|
|
||||||
for(SuperSkill superSkill : mcMMO.p.getSkillRegister().getSuperSkills()) {
|
for(SuperAbilityType superSkill : SuperAbilityType.values()) {
|
||||||
validator.validate(map.get(superSkill));
|
validator.validate(map.get(superSkill));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public void setSkillLevel(@NotNull RootSkill rootSkill, int i) {
|
public void setSkillLevel(@NotNull PrimarySkillType primarySkillType, int i) {
|
||||||
skillLevelValues.put(rootSkill, i);
|
skillLevelValues.put(primarySkillType, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSkillLevel(@NotNull RootSkill rootSkill) {
|
public int getSkillLevel(@NotNull PrimarySkillType primarySkillType) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isDirtyProfile() {
|
public boolean isDirtyProfile() {
|
||||||
return dirtyFlag.getImmutableCopy();
|
return dirtyFlag.getImmutableCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void resetDirtyFlag() {
|
public void resetDirtyFlag() {
|
||||||
dirtyFlag.setBoolean(false);
|
dirtyFlag.setBoolean(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull String getPlayerName() {
|
public @NotNull String getPlayerName() {
|
||||||
return playerName.getData().getImmutableCopy();
|
return playerName.getData().getImmutableCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull UUID getPlayerUUID() {
|
public @NotNull UUID getPlayerUUID() {
|
||||||
return playerUUID;
|
return playerUUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPartyChatSpying() { return partyChatSpying.getData().getImmutableCopy(); }
|
public boolean isPartyChatSpying() { return partyChatSpying.getData().getImmutableCopy(); }
|
||||||
|
|
||||||
@Override
|
|
||||||
public void togglePartyChatSpying() {
|
public void togglePartyChatSpying() {
|
||||||
partyChatSpying.getData().setBoolean(!partyChatSpying.getData().getImmutableCopy());
|
partyChatSpying.getData().setBoolean(!partyChatSpying.getData().getImmutableCopy());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPartyChatSpying(boolean bool) {
|
public void setPartyChatSpying(boolean bool) {
|
||||||
this.partyChatSpying.getData().setBoolean(bool);
|
this.partyChatSpying.getData().setBoolean(bool);
|
||||||
}
|
}
|
||||||
@ -233,124 +232,101 @@ public class MMOPlayerDataImpl implements MMOPlayerData {
|
|||||||
* Scoreboards
|
* Scoreboards
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getScoreboardTipsShown() {
|
public int getScoreboardTipsShown() {
|
||||||
return scoreboardTipsShown.getData(false).getImmutableCopy();
|
return scoreboardTipsShown.getData(false).getImmutableCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setScoreboardTipsShown(int newValue) {
|
public void setScoreboardTipsShown(int newValue) {
|
||||||
scoreboardTipsShown.getData(true).setInt(newValue);
|
scoreboardTipsShown.getData(true).setInt(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getChimaeraWingDATS() {
|
public int getChimaeraWingDATS() {
|
||||||
return uniquePlayerData.get((UniqueDataType.CHIMAERA_WING_DATS));
|
return uniquePlayerData.get((UniqueDataType.CHIMAERA_WING_DATS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setChimaeraWingDATS(int DATS) {
|
public void setChimaeraWingDATS(int DATS) {
|
||||||
uniquePlayerData.put(UniqueDataType.CHIMAERA_WING_DATS, DATS);
|
uniquePlayerData.put(UniqueDataType.CHIMAERA_WING_DATS, DATS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setUniqueData(@NotNull UniqueDataType uniqueDataType, int newData) {
|
public void setUniqueData(@NotNull UniqueDataType uniqueDataType, int newData) {
|
||||||
uniquePlayerData.put(uniqueDataType, newData);
|
uniquePlayerData.put(uniqueDataType, newData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getUniqueData(@NotNull UniqueDataType uniqueDataType) { return uniquePlayerData.get(uniqueDataType); }
|
public long getUniqueData(@NotNull UniqueDataType uniqueDataType) { return uniquePlayerData.get(uniqueDataType); }
|
||||||
|
|
||||||
@Override
|
public long getAbilityDATS(@NotNull SuperAbilityType superSkill) {
|
||||||
public long getAbilityDATS(@NotNull SuperSkill superSkill) {
|
|
||||||
return abilityDeactivationTimestamps.get(superSkill);
|
return abilityDeactivationTimestamps.get(superSkill);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAbilityDATS(@NotNull SuperSkill superSkill, long DATS) {
|
public void setAbilityDATS(@NotNull SuperAbilityType superSkill, long DATS) {
|
||||||
abilityDeactivationTimestamps.put(superSkill, (int) (DATS * .001D));
|
abilityDeactivationTimestamps.put(superSkill, (int) (DATS * .001D));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void resetCooldowns() {
|
public void resetCooldowns() {
|
||||||
abilityDeactivationTimestamps.replaceAll((a, v) -> 0);
|
abilityDeactivationTimestamps.replaceAll((a, v) -> 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public @NotNull Map<PrimarySkillType, SkillBossBarState> getBarStateMap() {
|
||||||
public @NotNull Map<RootSkill, SkillBossBarState> getBarStateMap() {
|
|
||||||
return barStateMap;
|
return barStateMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public @NotNull DirtyMap<PrimarySkillType, SkillBossBarState> getDirtyBarStateMap() {
|
||||||
public @NotNull DirtyMap<RootSkill, SkillBossBarState> getDirtyBarStateMap() {
|
|
||||||
return barStateMap;
|
return barStateMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull DirtyMap<PrimarySkillType, Integer> getDirtySkillLevelMap() {
|
public @NotNull DirtyMap<PrimarySkillType, Integer> getDirtySkillLevelMap() {
|
||||||
return skillLevelValues;
|
return skillLevelValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull DirtyMap<PrimarySkillType, Float> getDirtyExperienceValueMap() {
|
public @NotNull DirtyMap<PrimarySkillType, Float> getDirtyExperienceValueMap() {
|
||||||
return skillExperienceValues;
|
return skillExperienceValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull DirtyData<MutableBoolean> getDirtyPartyChatSpying() {
|
public @NotNull DirtyData<MutableBoolean> getDirtyPartyChatSpying() {
|
||||||
return partyChatSpying;
|
return partyChatSpying;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull Map<PrimarySkillType, Integer> getSkillLevelsMap() {
|
public @NotNull Map<PrimarySkillType, Integer> getSkillLevelsMap() {
|
||||||
return skillLevelValues;
|
return skillLevelValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull Map<PrimarySkillType, Float> getSkillsExperienceMap() {
|
public @NotNull Map<PrimarySkillType, Float> getSkillsExperienceMap() {
|
||||||
return skillExperienceValues;
|
return skillExperienceValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public @NotNull Map<SuperAbilityType, Integer> getAbilityDeactivationTimestamps() {
|
||||||
public @NotNull Map<SuperSkill, Integer> getAbilityDeactivationTimestamps() {
|
|
||||||
return abilityDeactivationTimestamps;
|
return abilityDeactivationTimestamps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull Map<UniqueDataType, Integer> getUniquePlayerData() {
|
public @NotNull Map<UniqueDataType, Integer> getUniquePlayerData() {
|
||||||
return uniquePlayerData;
|
return uniquePlayerData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDirtyProfile() {
|
public void setDirtyProfile() {
|
||||||
this.dirtyFlag.setBoolean(true);
|
this.dirtyFlag.setBoolean(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getLastLogin() {
|
public long getLastLogin() {
|
||||||
return lastLogin.getData().getImmutableCopy();
|
return lastLogin.getData().getImmutableCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLastLogin(long newValue) {
|
public void setLastLogin(long newValue) {
|
||||||
lastLogin.getData().setLong(newValue);
|
lastLogin.getData().setLong(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isLeaderBoardExcluded() {
|
public boolean isLeaderBoardExcluded() {
|
||||||
return leaderBoardExclusion.getData().getImmutableCopy();
|
return leaderBoardExclusion.getData().getImmutableCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLeaderBoardExclusion(boolean bool) {
|
public void setLeaderBoardExclusion(boolean bool) {
|
||||||
leaderBoardExclusion.getData(true).setBoolean(bool);
|
leaderBoardExclusion.getData(true).setBoolean(bool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull ImmutableMap<PrimarySkillType, Integer> copyPrimarySkillLevelsMap() {
|
public @NotNull ImmutableMap<PrimarySkillType, Integer> copyPrimarySkillLevelsMap() {
|
||||||
return ImmutableMap.copyOf(getSkillLevelsMap());
|
return ImmutableMap.copyOf(getSkillLevelsMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull ImmutableMap<PrimarySkillType, Float> copyPrimarySkillExperienceValuesMap() {
|
public @NotNull ImmutableMap<PrimarySkillType, Float> copyPrimarySkillExperienceValuesMap() {
|
||||||
return ImmutableMap.copyOf(getSkillsExperienceMap());
|
return ImmutableMap.copyOf(getSkillsExperienceMap());
|
||||||
}
|
}
|
@ -1,9 +1,7 @@
|
|||||||
package com.gmail.nossr50.datatypes.player;
|
package com.gmail.nossr50.datatypes.player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.neetgames.mcmmo.exceptions.UnknownSkillException;
|
import com.neetgames.mcmmo.exceptions.UnknownSkillException;
|
||||||
import com.neetgames.mcmmo.experience.ExperienceHandler;
|
|
||||||
import com.neetgames.mcmmo.player.MMOPlayerData;
|
|
||||||
import com.neetgames.mcmmo.skill.RootSkill;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -11,12 +9,12 @@ import java.util.UUID;
|
|||||||
public class PlayerProfile extends AbstractMMOPlayer {
|
public class PlayerProfile extends AbstractMMOPlayer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize an {@link PlayerProfile} for {@link MMOPlayerDataImpl}
|
* Initialize an {@link PlayerProfile} for {@link PlayerData}
|
||||||
* This will be used for existing data
|
* This will be used for existing data
|
||||||
*
|
*
|
||||||
* @param mmoPlayerData target persistent player data
|
* @param mmoPlayerData target persistent player data
|
||||||
*/
|
*/
|
||||||
public PlayerProfile(@NotNull MMOPlayerData mmoPlayerData) {
|
public PlayerProfile(@NotNull PlayerData mmoPlayerData) {
|
||||||
super(mmoPlayerData);
|
super(mmoPlayerData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,27 +30,27 @@ public class PlayerProfile extends AbstractMMOPlayer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPowerLevel() {
|
public int getPowerLevel() {
|
||||||
return experienceHandler.getPowerLevel();
|
return experienceProcessor.getPowerLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSkillLevel(@NotNull RootSkill rootSkill) throws UnknownSkillException {
|
public int getSkillLevel(@NotNull PrimarySkillType primarySkillType) throws UnknownSkillException {
|
||||||
return experienceHandler.getSkillLevel(rootSkill);
|
return experienceProcessor.getSkillLevel(primarySkillType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSkillExperience(@NotNull RootSkill rootSkill) throws UnknownSkillException {
|
public int getSkillExperience(@NotNull PrimarySkillType primarySkillType) throws UnknownSkillException {
|
||||||
return experienceHandler.getSkillXpValue(rootSkill);
|
return experienceProcessor.getSkillXpValue(primarySkillType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getExperienceToNextLevel(@NotNull RootSkill rootSkill) throws UnknownSkillException {
|
public int getExperienceToNextLevel(@NotNull PrimarySkillType primarySkillType) throws UnknownSkillException {
|
||||||
return experienceHandler.getExperienceToNextLevel(rootSkill);
|
return experienceProcessor.getExperienceToNextLevel(primarySkillType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getProgressInCurrentSkillLevel(@NotNull RootSkill rootSkill) throws UnknownSkillException {
|
public double getProgressInCurrentSkillLevel(@NotNull PrimarySkillType primarySkillType) throws UnknownSkillException {
|
||||||
return experienceHandler.getProgressInCurrentSkillLevel(rootSkill);
|
return experienceProcessor.getProgressInCurrentSkillLevel(primarySkillType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -62,11 +60,11 @@ public class PlayerProfile extends AbstractMMOPlayer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ExperienceHandler getExperienceHandler() {
|
public @NotNull ExperienceHandler getExperienceHandler() {
|
||||||
return experienceHandler;
|
return experienceProcessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull MMOPlayerData getMMOPlayerData() {
|
public @NotNull PlayerData getMMOPlayerDataImpl() {
|
||||||
return mmoPlayerData;
|
return mmoPlayerData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@
|
|||||||
// private static final @NotNull HackySkillMappings hackySkillMappings = new HackySkillMappings();
|
// private static final @NotNull HackySkillMappings hackySkillMappings = new HackySkillMappings();
|
||||||
//
|
//
|
||||||
// static {
|
// static {
|
||||||
// HashSet<CoreRootSkill> rootSkillSet = new HashSet<>();
|
// HashSet<CoreRootSkill> primarySkillTypeSet = new HashSet<>();
|
||||||
// HashSet<CoreRootSkill> childSkillSet = new HashSet<>();
|
// HashSet<CoreRootSkill> childSkillSet = new HashSet<>();
|
||||||
// HashSet<CoreSkill> subSkillSet = new HashSet<>();
|
// HashSet<CoreSkill> subSkillSet = new HashSet<>();
|
||||||
// HashSet<SuperSkill> superSkillSet = new HashSet<>();
|
// HashSet<SuperSkill> superSkillSet = new HashSet<>();
|
||||||
@ -167,25 +167,25 @@
|
|||||||
// childSkillSet.add(SMELTING);
|
// childSkillSet.add(SMELTING);
|
||||||
// childSkillSet.add(SALVAGE);
|
// childSkillSet.add(SALVAGE);
|
||||||
//
|
//
|
||||||
// rootSkillSet.add(ACROBATICS);
|
// primarySkillTypeSet.add(ACROBATICS);
|
||||||
// rootSkillSet.add(ALCHEMY);
|
// primarySkillTypeSet.add(ALCHEMY);
|
||||||
// rootSkillSet.add(ARCHERY);
|
// primarySkillTypeSet.add(ARCHERY);
|
||||||
// rootSkillSet.add(AXES);
|
// primarySkillTypeSet.add(AXES);
|
||||||
// rootSkillSet.add(EXCAVATION);
|
// primarySkillTypeSet.add(EXCAVATION);
|
||||||
// rootSkillSet.add(FISHING);
|
// primarySkillTypeSet.add(FISHING);
|
||||||
// rootSkillSet.add(HERBALISM);
|
// primarySkillTypeSet.add(HERBALISM);
|
||||||
// rootSkillSet.add(MINING);
|
// primarySkillTypeSet.add(MINING);
|
||||||
// rootSkillSet.add(REPAIR);
|
// primarySkillTypeSet.add(REPAIR);
|
||||||
// rootSkillSet.add(SALVAGE);
|
// primarySkillTypeSet.add(SALVAGE);
|
||||||
// rootSkillSet.add(SMELTING);
|
// primarySkillTypeSet.add(SMELTING);
|
||||||
// rootSkillSet.add(SWORDS);
|
// primarySkillTypeSet.add(SWORDS);
|
||||||
// rootSkillSet.add(TAMING);
|
// primarySkillTypeSet.add(TAMING);
|
||||||
// rootSkillSet.add(UNARMED);
|
// primarySkillTypeSet.add(UNARMED);
|
||||||
// rootSkillSet.add(WOODCUTTING);
|
// primarySkillTypeSet.add(WOODCUTTING);
|
||||||
// rootSkillSet.add(TRIDENTS);
|
// primarySkillTypeSet.add(TRIDENTS);
|
||||||
// rootSkillSet.add(CROSSBOWS);
|
// primarySkillTypeSet.add(CROSSBOWS);
|
||||||
//
|
//
|
||||||
// CORE_ROOT_SKILLS = ImmutableSet.copyOf(rootSkillSet);
|
// CORE_ROOT_SKILLS = ImmutableSet.copyOf(primarySkillTypeSet);
|
||||||
// CORE_CHILD_SKILLS = ImmutableSet.copyOf(childSkillSet);
|
// CORE_CHILD_SKILLS = ImmutableSet.copyOf(childSkillSet);
|
||||||
// CORE_NON_CHILD_SKILLS = ImmutableSet.copyOf(generateNonChildSkillSet());
|
// CORE_NON_CHILD_SKILLS = ImmutableSet.copyOf(generateNonChildSkillSet());
|
||||||
// CORE_SUB_SKILLS = ImmutableSet.copyOf(subSkillSet);
|
// CORE_SUB_SKILLS = ImmutableSet.copyOf(subSkillSet);
|
||||||
@ -242,11 +242,11 @@
|
|||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * Whether or not a skill is considered a child skill
|
// * Whether or not a skill is considered a child skill
|
||||||
// * @param rootSkill target skill
|
// * @param primarySkillType target skill
|
||||||
// * @return true if the skill identity belongs to a core "child" root skill
|
// * @return true if the skill identity belongs to a core "child" root skill
|
||||||
// */
|
// */
|
||||||
// public static boolean isChildSkill(@NotNull RootSkill rootSkill) {
|
// public static boolean isChildSkill(@NotNull PrimarySkillType primarySkillType) {
|
||||||
// return CORE_CHILD_SKILLS.contains(rootSkill);
|
// return CORE_CHILD_SKILLS.contains(primarySkillType);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// @Deprecated
|
// @Deprecated
|
||||||
@ -259,12 +259,12 @@
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// @Deprecated
|
// @Deprecated
|
||||||
// public static @NotNull PrimarySkillType getSkill(@NotNull RootSkill rootSkill) {
|
// public static @NotNull PrimarySkillType getSkill(@NotNull PrimarySkillType primarySkillType) {
|
||||||
// if(!hackySkillMappings.init) {
|
// if(!hackySkillMappings.init) {
|
||||||
// hackySkillMappings.initMappings();
|
// hackySkillMappings.initMappings();
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// return hackySkillMappings.rootToPrimaryMap.get(rootSkill);
|
// return hackySkillMappings.rootToPrimaryMap.get(primarySkillType);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// @Deprecated
|
// @Deprecated
|
||||||
|
@ -24,14 +24,14 @@
|
|||||||
// private final @NotNull Set<Skill> registeredSkills;
|
// private final @NotNull Set<Skill> registeredSkills;
|
||||||
// private final @NotNull Set<SuperSkill> superSkills;
|
// private final @NotNull Set<SuperSkill> superSkills;
|
||||||
// private final @NotNull Set<RankedSkill> rankedSkills;
|
// private final @NotNull Set<RankedSkill> rankedSkills;
|
||||||
// private final @NotNull Set<RootSkill> rootSkills; //Can include not-official root skills
|
// private final @NotNull Set<RootSkill> primarySkillTypes; //Can include not-official root skills
|
||||||
// private final @NotNull Set<CoreRootSkill> coreRootSkills; //Only includes official root skills
|
// private final @NotNull Set<CoreRootSkill> coreRootSkills; //Only includes official root skills
|
||||||
// private final @NotNull Set<CoreSkill> coreSkills; //Only includes official core skills
|
// private final @NotNull Set<CoreSkill> coreSkills; //Only includes official core skills
|
||||||
//
|
//
|
||||||
// public SkillRegisterImpl() {
|
// public SkillRegisterImpl() {
|
||||||
// skillNameMap = new HashMap<>();
|
// skillNameMap = new HashMap<>();
|
||||||
// registeredSkills = new HashSet<>();
|
// registeredSkills = new HashSet<>();
|
||||||
// rootSkills = new HashSet<>();
|
// primarySkillTypes = new HashSet<>();
|
||||||
// superSkills = new HashSet<>();
|
// superSkills = new HashSet<>();
|
||||||
// rankedSkills = new HashSet<>();
|
// rankedSkills = new HashSet<>();
|
||||||
// coreRootSkills = new HashSet<>();
|
// coreRootSkills = new HashSet<>();
|
||||||
@ -72,7 +72,7 @@
|
|||||||
//
|
//
|
||||||
// @Override
|
// @Override
|
||||||
// public @NotNull Set<RootSkill> getRootSkills() {
|
// public @NotNull Set<RootSkill> getRootSkills() {
|
||||||
// return rootSkills;
|
// return primarySkillTypes;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// @Override
|
// @Override
|
||||||
@ -117,7 +117,7 @@
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// if(skill instanceof RootSkill) {
|
// if(skill instanceof RootSkill) {
|
||||||
// rootSkills.remove(skill);
|
// primarySkillTypes.remove(skill);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// if (skill instanceof SuperSkill) {
|
// if (skill instanceof SuperSkill) {
|
||||||
@ -149,7 +149,7 @@
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// if(skill instanceof RootSkill) {
|
// if(skill instanceof RootSkill) {
|
||||||
// rootSkills.add((RootSkill) skill);
|
// primarySkillTypes.add((RootSkill) skill);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// if (skill instanceof SuperSkill) {
|
// if (skill instanceof SuperSkill) {
|
||||||
@ -194,11 +194,11 @@
|
|||||||
// * @see SkillIdentity#getFullyQualifiedName()
|
// * @see SkillIdentity#getFullyQualifiedName()
|
||||||
// */
|
// */
|
||||||
// public @Nullable RootSkill matchRootSkill(@NotNull String skillName) {
|
// public @Nullable RootSkill matchRootSkill(@NotNull String skillName) {
|
||||||
// for (RootSkill rootSkill : rootSkills) {
|
// for (PrimarySkillType primarySkillType : primarySkillTypes) {
|
||||||
// if (rootSkill.getSkillIdentity().getFullyQualifiedName().equalsIgnoreCase(skillName)
|
// if (primarySkillType.getSkillIdentity().getFullyQualifiedName().equalsIgnoreCase(skillName)
|
||||||
// || skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(rootSkill.getRawSkillName()) + ".SkillName"))
|
// || skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(primarySkillType.getRawSkillName()) + ".SkillName"))
|
||||||
// || rootSkill.getRawSkillName().equalsIgnoreCase(skillName)) {
|
// || primarySkillType.getRawSkillName().equalsIgnoreCase(skillName)) {
|
||||||
// return rootSkill;
|
// return primarySkillType;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.runnables.commands;
|
package com.gmail.nossr50.runnables.commands;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.neetgames.mcmmo.skill.RootSkill;
|
import com.neetgames.mcmmo.skill.RootSkill;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
@ -14,11 +15,11 @@ import java.util.List;
|
|||||||
|
|
||||||
public class MctopCommandAsyncTask extends BukkitRunnable {
|
public class MctopCommandAsyncTask extends BukkitRunnable {
|
||||||
private final @NotNull CommandSender sender;
|
private final @NotNull CommandSender sender;
|
||||||
private final @Nullable RootSkill rootSkill;
|
private final @Nullable PrimarySkillType primarySkillType;
|
||||||
private final int page;
|
private final int page;
|
||||||
private final boolean useBoard, useChat;
|
private final boolean useBoard, useChat;
|
||||||
|
|
||||||
public MctopCommandAsyncTask(int page, @Nullable RootSkill rootSkill, @NotNull CommandSender sender, boolean useBoard, boolean useChat) {
|
public MctopCommandAsyncTask(int page, @Nullable PrimarySkillType primarySkillType, @NotNull CommandSender sender, boolean useBoard, boolean useChat) {
|
||||||
Validate.isTrue(useBoard || useChat, "Attempted to start a rank retrieval with both board and chat off");
|
Validate.isTrue(useBoard || useChat, "Attempted to start a rank retrieval with both board and chat off");
|
||||||
Validate.notNull(sender, "Attempted to start a rank retrieval with no recipient");
|
Validate.notNull(sender, "Attempted to start a rank retrieval with no recipient");
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ public class MctopCommandAsyncTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.page = page;
|
this.page = page;
|
||||||
this.rootSkill = rootSkill;
|
this.primarySkillType = primarySkillType;
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.useBoard = useBoard;
|
this.useBoard = useBoard;
|
||||||
this.useChat = useChat;
|
this.useChat = useChat;
|
||||||
@ -35,8 +36,8 @@ public class MctopCommandAsyncTask extends BukkitRunnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final List<PlayerStat> userStats = mcMMO.getDatabaseManager().readLeaderboard(rootSkill, page, 10);
|
final List<PlayerStat> userStats = mcMMO.getDatabaseManager().readLeaderboard(primarySkillType, page, 10);
|
||||||
|
|
||||||
new MctopCommandDisplayTask(userStats, page, rootSkill, sender, useBoard, useChat).runTaskLater(mcMMO.p, 1);
|
new MctopCommandDisplayTask(userStats, page, primarySkillType, sender, useBoard, useChat).runTaskLater(mcMMO.p, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.runnables.commands;
|
|||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||||
import com.gmail.nossr50.datatypes.skills.CoreSkills;
|
import com.gmail.nossr50.datatypes.skills.CoreSkills;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
@ -22,14 +23,14 @@ import java.util.List;
|
|||||||
public class MctopCommandDisplayTask extends BukkitRunnable {
|
public class MctopCommandDisplayTask extends BukkitRunnable {
|
||||||
private final List<PlayerStat> userStats;
|
private final List<PlayerStat> userStats;
|
||||||
private final CommandSender sender;
|
private final CommandSender sender;
|
||||||
private final @Nullable RootSkill rootSkill;
|
private final @Nullable PrimarySkillType primarySkillType;
|
||||||
private final int page;
|
private final int page;
|
||||||
private final boolean useBoard, useChat;
|
private final boolean useBoard, useChat;
|
||||||
|
|
||||||
MctopCommandDisplayTask(@NotNull List<PlayerStat> userStats, int page, @Nullable RootSkill rootSkill, @NotNull CommandSender sender, boolean useBoard, boolean useChat) {
|
MctopCommandDisplayTask(@NotNull List<PlayerStat> userStats, int page, @Nullable PrimarySkillType primarySkillType, @NotNull CommandSender sender, boolean useBoard, boolean useChat) {
|
||||||
this.userStats = userStats;
|
this.userStats = userStats;
|
||||||
this.page = page;
|
this.page = page;
|
||||||
this.rootSkill = rootSkill;
|
this.primarySkillType = primarySkillType;
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.useBoard = useBoard;
|
this.useBoard = useBoard;
|
||||||
this.useChat = useChat;
|
this.useChat = useChat;
|
||||||
@ -53,7 +54,7 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void displayChat() {
|
private void displayChat() {
|
||||||
if (rootSkill == null) {
|
if (primarySkillType == null) {
|
||||||
if(sender instanceof Player) {
|
if(sender instanceof Player) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||||
}
|
}
|
||||||
@ -63,10 +64,10 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(sender instanceof Player) {
|
if(sender instanceof Player) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getName()));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", primarySkillType.getName()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(ChatColor.stripColor(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getName())));
|
sender.sendMessage(ChatColor.stripColor(LocaleLoader.getString("Commands.Skill.Leaderboard", primarySkillType.getName())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,11 +89,11 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void displayBoard() {
|
private void displayBoard() {
|
||||||
if (rootSkill == null) {
|
if (primarySkillType == null) {
|
||||||
ScoreboardManager.showTopPowerScoreboard((Player) sender, page, userStats);
|
ScoreboardManager.showTopPowerScoreboard((Player) sender, page, userStats);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ScoreboardManager.showTopScoreboard((Player) sender, PrimarySkillType.getSkill(rootSkill), page, userStats);
|
ScoreboardManager.showTopScoreboard((Player) sender, primarySkillType, page, userStats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,13 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
|
|
||||||
public class ExperienceBarHideTask extends BukkitRunnable {
|
public class ExperienceBarHideTask extends BukkitRunnable {
|
||||||
public final OnlineMMOPlayer mmoPlayer;
|
public final OnlineMMOPlayer mmoPlayer;
|
||||||
public final RootSkill rootSkill;
|
public final PrimarySkillType primarySkillType;
|
||||||
public final MMOExperienceBarManager MMOExperienceBarManagerRef;
|
public final MMOExperienceBarManager MMOExperienceBarManagerRef;
|
||||||
|
|
||||||
public ExperienceBarHideTask(MMOExperienceBarManager MMOExperienceBarManagerRef, OnlineMMOPlayer mmoPlayer, RootSkill rootSkill) {
|
public ExperienceBarHideTask(MMOExperienceBarManager MMOExperienceBarManagerRef, OnlineMMOPlayer mmoPlayer, PrimarySkillType primarySkillType) {
|
||||||
this.MMOExperienceBarManagerRef = MMOExperienceBarManagerRef;
|
this.MMOExperienceBarManagerRef = MMOExperienceBarManagerRef;
|
||||||
this.mmoPlayer = mmoPlayer;
|
this.mmoPlayer = mmoPlayer;
|
||||||
this.rootSkill = rootSkill;
|
this.primarySkillType = primarySkillType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,7 +32,7 @@ public class ExperienceBarHideTask extends BukkitRunnable {
|
|||||||
if(MMOExperienceBarManagerRef == null || mmoPlayer == null)
|
if(MMOExperienceBarManagerRef == null || mmoPlayer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MMOExperienceBarManagerRef.hideExperienceBar(rootSkill);
|
MMOExperienceBarManagerRef.hideExperienceBar(primarySkillType);
|
||||||
MMOExperienceBarManagerRef.clearTask(rootSkill);
|
MMOExperienceBarManagerRef.clearTask(primarySkillType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@ public class FamilyTree {
|
|||||||
private static @Nullable Set<RootSkill> smeltingParents;
|
private static @Nullable Set<RootSkill> smeltingParents;
|
||||||
private static @Nullable Set<RootSkill> salvageParents;
|
private static @Nullable Set<RootSkill> salvageParents;
|
||||||
|
|
||||||
public static @NotNull Set<RootSkill> getParentSkills(@NotNull RootSkill rootSkill) throws UnknownSkillException {
|
public static @NotNull Set<RootSkill> getParentSkills(@NotNull PrimarySkillType primarySkillType) throws UnknownSkillException {
|
||||||
if(PrimarySkillType.isChildSkill(rootSkill)) {
|
if(PrimarySkillType.isChildSkill(primarySkillType)) {
|
||||||
if(smeltingParents == null || salvageParents == null) {
|
if(smeltingParents == null || salvageParents == null) {
|
||||||
smeltingParents = new HashSet<>();
|
smeltingParents = new HashSet<>();
|
||||||
salvageParents = new HashSet<>();
|
salvageParents = new HashSet<>();
|
||||||
@ -31,12 +31,12 @@ public class FamilyTree {
|
|||||||
salvageParents.add(PrimarySkillType.REPAIR);
|
salvageParents.add(PrimarySkillType.REPAIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rootSkill.equals(PrimarySkillType.SALVAGE)) {
|
if(primarySkillType.equals(PrimarySkillType.SALVAGE)) {
|
||||||
return salvageParents;
|
return salvageParents;
|
||||||
} else if (rootSkill.equals(PrimarySkillType.SMELTING)) {
|
} else if (primarySkillType.equals(PrimarySkillType.SMELTING)) {
|
||||||
return smeltingParents;
|
return smeltingParents;
|
||||||
} else {
|
} else {
|
||||||
mcMMO.p.getLogger().severe("root skill argument is not a child skill! " + rootSkill.toString());
|
mcMMO.p.getLogger().severe("root skill argument is not a child skill! " + primarySkillType.toString());
|
||||||
throw new UnknownSkillException();
|
throw new UnknownSkillException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ public final class Permissions {
|
|||||||
public static boolean hasSalvageEnchantBypassPerk(Permissible permissible) { return permissible.hasPermission("mcmmo.perks.bypass.salvageenchant"); }
|
public static boolean hasSalvageEnchantBypassPerk(Permissible permissible) { return permissible.hasPermission("mcmmo.perks.bypass.salvageenchant"); }
|
||||||
|
|
||||||
public static boolean lucky(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.lucky." + skill.toString().toLowerCase(Locale.ENGLISH)); }
|
public static boolean lucky(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.lucky." + skill.toString().toLowerCase(Locale.ENGLISH)); }
|
||||||
public static boolean lucky(Permissible permissible, RootSkill rootSkill) { return permissible.hasPermission("mcmmo.perks.lucky." + rootSkill.getRawSkillName().toLowerCase(Locale.ENGLISH)); }
|
public static boolean lucky(Permissible permissible, PrimarySkillType primarySkillType) { return permissible.hasPermission("mcmmo.perks.lucky." + primarySkillType.getRawSkillName().toLowerCase(Locale.ENGLISH)); }
|
||||||
|
|
||||||
/* XP PERKS */
|
/* XP PERKS */
|
||||||
public static boolean quadrupleXp(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.xp.quadruple." + skill.toString().toLowerCase(Locale.ENGLISH)); }
|
public static boolean quadrupleXp(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.xp.quadruple." + skill.toString().toLowerCase(Locale.ENGLISH)); }
|
||||||
@ -145,7 +145,7 @@ public final class Permissions {
|
|||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static boolean skillEnabled(Permissible permissible, PrimarySkillType skill) {return permissible.hasPermission("mcmmo.skills." + skill.toString().toLowerCase(Locale.ENGLISH)); }
|
public static boolean skillEnabled(Permissible permissible, PrimarySkillType skill) {return permissible.hasPermission("mcmmo.skills." + skill.toString().toLowerCase(Locale.ENGLISH)); }
|
||||||
public static boolean skillEnabled(@NotNull Permissible permissible, @NotNull RootSkill rootSkill) {return permissible.hasPermission("mcmmo.skills." + rootSkill.getRawSkillName().toLowerCase(Locale.ENGLISH)); }
|
public static boolean skillEnabled(@NotNull Permissible permissible, @NotNull PrimarySkillType primarySkillType) {return permissible.hasPermission("mcmmo.skills." + primarySkillType.getRawSkillName().toLowerCase(Locale.ENGLISH)); }
|
||||||
public static boolean vanillaXpBoost(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.ability." + skill.toString().toLowerCase(Locale.ENGLISH) + ".vanillaxpboost"); }
|
public static boolean vanillaXpBoost(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.ability." + skill.toString().toLowerCase(Locale.ENGLISH) + ".vanillaxpboost"); }
|
||||||
public static boolean isSubSkillEnabled(Permissible permissible, SubSkillType subSkillType) { return permissible.hasPermission(subSkillType.getPermissionNodeAddress()); }
|
public static boolean isSubSkillEnabled(Permissible permissible, SubSkillType subSkillType) { return permissible.hasPermission(subSkillType.getPermissionNodeAddress()); }
|
||||||
public static boolean isSubSkillEnabled(Permissible permissible, AbstractSubSkill abstractSubSkill) { return permissible.hasPermission(abstractSubSkill.getPermissionNode()); }
|
public static boolean isSubSkillEnabled(Permissible permissible, AbstractSubSkill abstractSubSkill) { return permissible.hasPermission(abstractSubSkill.getPermissionNode()); }
|
||||||
|
@ -22,7 +22,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class ExperienceBarWrapper {
|
public class ExperienceBarWrapper {
|
||||||
|
|
||||||
private final @NotNull RootSkill rootSkill; //Primary Skill
|
private final @NotNull PrimarySkillType primarySkillType; //Primary Skill
|
||||||
private @NotNull BossBar bossBar;
|
private @NotNull BossBar bossBar;
|
||||||
protected final @NotNull McMMOPlayer mmoPlayer;
|
protected final @NotNull McMMOPlayer mmoPlayer;
|
||||||
private int lastLevelUpdated;
|
private int lastLevelUpdated;
|
||||||
@ -33,14 +33,14 @@ public class ExperienceBarWrapper {
|
|||||||
protected String niceSkillName;
|
protected String niceSkillName;
|
||||||
protected String title;
|
protected String title;
|
||||||
|
|
||||||
public ExperienceBarWrapper(@NotNull RootSkill rootSkill, @NotNull McMMOPlayer mmoPlayer) {
|
public ExperienceBarWrapper(@NotNull PrimarySkillType primarySkillType, @NotNull McMMOPlayer mmoPlayer) {
|
||||||
this.mmoPlayer = mmoPlayer;
|
this.mmoPlayer = mmoPlayer;
|
||||||
this.rootSkill = rootSkill;
|
this.primarySkillType = primarySkillType;
|
||||||
title = "";
|
title = "";
|
||||||
lastLevelUpdated = 0;
|
lastLevelUpdated = 0;
|
||||||
|
|
||||||
//These vars are stored to help reduce operations involving strings
|
//These vars are stored to help reduce operations involving strings
|
||||||
niceSkillName = StringUtils.getCapitalized(rootSkill.toString());
|
niceSkillName = StringUtils.getCapitalized(primarySkillType.toString());
|
||||||
|
|
||||||
//Create the bar
|
//Create the bar
|
||||||
initBar();
|
initBar();
|
||||||
@ -59,7 +59,7 @@ public class ExperienceBarWrapper {
|
|||||||
private String getTitleTemplate() {
|
private String getTitleTemplate() {
|
||||||
//If they are using extra details
|
//If they are using extra details
|
||||||
|
|
||||||
if(ExperienceConfig.getInstance().isEarlyGameBoostEnabled() && PlayerLevelUtils.qualifiesForEarlyGameBoost(mmoPlayer, rootSkill)) {
|
if(ExperienceConfig.getInstance().isEarlyGameBoostEnabled() && PlayerLevelUtils.qualifiesForEarlyGameBoost(mmoPlayer, primarySkillType)) {
|
||||||
return LocaleLoader.getString("XPBar.Template.EarlyGameBoost");
|
return LocaleLoader.getString("XPBar.Template.EarlyGameBoost");
|
||||||
} else if(ExperienceConfig.getInstance().getAddExtraDetails())
|
} else if(ExperienceConfig.getInstance().getAddExtraDetails())
|
||||||
return LocaleLoader.getString("XPBar.Complex.Template", LocaleLoader.getString("XPBar."+niceSkillName, getLevel()), getCurrentXP(), getMaxXP(), getPowerLevel(), getPercentageOfLevel());
|
return LocaleLoader.getString("XPBar.Complex.Template", LocaleLoader.getString("XPBar."+niceSkillName, getLevel()), getCurrentXP(), getMaxXP(), getPowerLevel(), getPercentageOfLevel());
|
||||||
@ -68,16 +68,16 @@ public class ExperienceBarWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getLevel() {
|
private int getLevel() {
|
||||||
return mmoPlayer.getSkillLevel(rootSkill);
|
return mmoPlayer.getSkillLevel(primarySkillType);
|
||||||
}
|
}
|
||||||
private int getCurrentXP() {
|
private int getCurrentXP() {
|
||||||
return mmoPlayer.getSkillExperience(rootSkill);
|
return mmoPlayer.getSkillExperience(primarySkillType);
|
||||||
}
|
}
|
||||||
private int getMaxXP() {
|
private int getMaxXP() {
|
||||||
return mmoPlayer.getExperienceToNextLevel(rootSkill);
|
return mmoPlayer.getExperienceToNextLevel(primarySkillType);
|
||||||
}
|
}
|
||||||
private int getPowerLevel() { return mmoPlayer.getPowerLevel(); }
|
private int getPowerLevel() { return mmoPlayer.getPowerLevel(); }
|
||||||
private int getPercentageOfLevel() { return (int) (mmoPlayer.getProgressInCurrentSkillLevel(rootSkill) * 100); }
|
private int getPercentageOfLevel() { return (int) (mmoPlayer.getProgressInCurrentSkillLevel(primarySkillType) * 100); }
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return bossBar.getTitle();
|
return bossBar.getTitle();
|
||||||
@ -114,10 +114,10 @@ public class ExperienceBarWrapper {
|
|||||||
bossBar.setProgress(v);
|
bossBar.setProgress(v);
|
||||||
|
|
||||||
//Check player level
|
//Check player level
|
||||||
if(ExperienceConfig.getInstance().isEarlyGameBoostEnabled() && PlayerLevelUtils.qualifiesForEarlyGameBoost(mmoPlayer, rootSkill)) {
|
if(ExperienceConfig.getInstance().isEarlyGameBoostEnabled() && PlayerLevelUtils.qualifiesForEarlyGameBoost(mmoPlayer, primarySkillType)) {
|
||||||
setColor(BarColor.YELLOW);
|
setColor(BarColor.YELLOW);
|
||||||
} else {
|
} else {
|
||||||
setColor(ExperienceConfig.getInstance().getExperienceBarColor(rootSkill));
|
setColor(ExperienceConfig.getInstance().getExperienceBarColor(primarySkillType));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Every time progress updates we need to check for a title update
|
//Every time progress updates we need to check for a title update
|
||||||
@ -157,7 +157,7 @@ public class ExperienceBarWrapper {
|
|||||||
|
|
||||||
private void createBossBar()
|
private void createBossBar()
|
||||||
{
|
{
|
||||||
bossBar = Bukkit.getServer().createBossBar(title, ExperienceConfig.getInstance().getExperienceBarColor(rootSkill), ExperienceConfig.getInstance().getExperienceBarStyle(rootSkill));
|
bossBar = Bukkit.getServer().createBossBar(title, ExperienceConfig.getInstance().getExperienceBarColor(primarySkillType), ExperienceConfig.getInstance().getExperienceBarStyle(primarySkillType));
|
||||||
bossBar.addPlayer(mmoPlayer.getPlayer());
|
bossBar.addPlayer(mmoPlayer.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.util.experience;
|
|||||||
|
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.datatypes.skills.CoreSkills;
|
import com.gmail.nossr50.datatypes.skills.CoreSkills;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
@ -23,12 +24,12 @@ public class MMOExperienceBarManager {
|
|||||||
|
|
||||||
int delaySeconds = 3;
|
int delaySeconds = 3;
|
||||||
|
|
||||||
private @NotNull final Map<RootSkill, SkillBossBarState> barStateMapRef;
|
private @NotNull final Map<PrimarySkillType, SkillBossBarState> barStateMapRef;
|
||||||
|
|
||||||
private @NotNull final Map<RootSkill, ExperienceBarWrapper> experienceBars;
|
private @NotNull final Map<PrimarySkillType, ExperienceBarWrapper> experienceBars;
|
||||||
private @NotNull final Map<RootSkill, ExperienceBarHideTask> experienceBarHideTaskHashMap;
|
private @NotNull final Map<PrimarySkillType, ExperienceBarHideTask> experienceBarHideTaskHashMap;
|
||||||
|
|
||||||
public MMOExperienceBarManager(@NotNull McMMOPlayer mmoPlayer, @NotNull Map<RootSkill, SkillBossBarState> barStateMapRef)
|
public MMOExperienceBarManager(@NotNull McMMOPlayer mmoPlayer, @NotNull Map<PrimarySkillType, SkillBossBarState> barStateMapRef)
|
||||||
{
|
{
|
||||||
this.mmoPlayer = mmoPlayer;
|
this.mmoPlayer = mmoPlayer;
|
||||||
this.barStateMapRef = barStateMapRef;
|
this.barStateMapRef = barStateMapRef;
|
||||||
@ -45,8 +46,8 @@ public class MMOExperienceBarManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void syncBarStates() {
|
private void syncBarStates() {
|
||||||
for(Map.Entry<RootSkill, SkillBossBarState> entry : barStateMapRef.entrySet()) {
|
for(Map.Entry<PrimarySkillType, SkillBossBarState> entry : barStateMapRef.entrySet()) {
|
||||||
RootSkill key = entry.getKey();
|
PrimarySkillType key = entry.getKey();
|
||||||
SkillBossBarState barState = entry.getValue();
|
SkillBossBarState barState = entry.getValue();
|
||||||
|
|
||||||
switch(barState) {
|
switch(barState) {
|
||||||
@ -64,130 +65,130 @@ public class MMOExperienceBarManager {
|
|||||||
barStateMapRef.putAll(generateDefaultBarStateMap());
|
barStateMapRef.putAll(generateDefaultBarStateMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateExperienceBar(@NotNull RootSkill rootSkill, @NotNull Plugin plugin)
|
public void updateExperienceBar(@NotNull PrimarySkillType primarySkillType, @NotNull Plugin plugin)
|
||||||
{
|
{
|
||||||
if(isBarDisabled(rootSkill))
|
if(isBarDisabled(primarySkillType))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//Init Bar
|
//Init Bar
|
||||||
if(experienceBars.get(rootSkill) == null)
|
if(experienceBars.get(primarySkillType) == null)
|
||||||
experienceBars.put(rootSkill, new ExperienceBarWrapper(rootSkill, mmoPlayer));
|
experienceBars.put(primarySkillType, new ExperienceBarWrapper(primarySkillType, mmoPlayer));
|
||||||
|
|
||||||
//Get Bar
|
//Get Bar
|
||||||
ExperienceBarWrapper experienceBarWrapper = experienceBars.get(rootSkill);
|
ExperienceBarWrapper experienceBarWrapper = experienceBars.get(primarySkillType);
|
||||||
|
|
||||||
//Update Progress
|
//Update Progress
|
||||||
experienceBarWrapper.setProgress(mmoPlayer.getExperienceHandler().getProgressInCurrentSkillLevel(rootSkill));
|
experienceBarWrapper.setProgress(mmoPlayer.getExperienceHandler().getProgressInCurrentSkillLevel(primarySkillType));
|
||||||
|
|
||||||
//Show Bar
|
//Show Bar
|
||||||
experienceBarWrapper.showExperienceBar();
|
experienceBarWrapper.showExperienceBar();
|
||||||
|
|
||||||
//Setup Hide Bar Task
|
//Setup Hide Bar Task
|
||||||
if(experienceBarHideTaskHashMap.get(rootSkill) != null)
|
if(experienceBarHideTaskHashMap.get(primarySkillType) != null)
|
||||||
{
|
{
|
||||||
experienceBarHideTaskHashMap.get(rootSkill).cancel();
|
experienceBarHideTaskHashMap.get(primarySkillType).cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
scheduleHideTask(rootSkill, plugin);
|
scheduleHideTask(primarySkillType, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isBarDisabled(@NotNull RootSkill rootSkill) {
|
private boolean isBarDisabled(@NotNull PrimarySkillType primarySkillType) {
|
||||||
return barStateMapRef.get(rootSkill) == SkillBossBarState.DISABLED
|
return barStateMapRef.get(primarySkillType) == SkillBossBarState.DISABLED
|
||||||
//Config checks
|
//Config checks
|
||||||
|| !ExperienceConfig.getInstance().isExperienceBarsEnabled()
|
|| !ExperienceConfig.getInstance().isExperienceBarsEnabled()
|
||||||
|| !ExperienceConfig.getInstance().isExperienceBarEnabled(rootSkill);
|
|| !ExperienceConfig.getInstance().isExperienceBarEnabled(primarySkillType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isBarAlwaysVisible(@NotNull RootSkill rootSkill) {
|
private boolean isBarAlwaysVisible(@NotNull PrimarySkillType primarySkillType) {
|
||||||
return barStateMapRef.get(rootSkill) == SkillBossBarState.ALWAYS_ON;
|
return barStateMapRef.get(primarySkillType) == SkillBossBarState.ALWAYS_ON;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scheduleHideTask(@NotNull RootSkill rootSkill, @NotNull Plugin plugin) {
|
private void scheduleHideTask(@NotNull PrimarySkillType primarySkillType, @NotNull Plugin plugin) {
|
||||||
if(isBarAlwaysVisible(rootSkill))
|
if(isBarAlwaysVisible(primarySkillType))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ExperienceBarHideTask experienceBarHideTask = new ExperienceBarHideTask(this, mmoPlayer, rootSkill);
|
ExperienceBarHideTask experienceBarHideTask = new ExperienceBarHideTask(this, mmoPlayer, primarySkillType);
|
||||||
experienceBarHideTask.runTaskLater(plugin, 20 * delaySeconds);
|
experienceBarHideTask.runTaskLater(plugin, 20 * delaySeconds);
|
||||||
experienceBarHideTaskHashMap.put(rootSkill, experienceBarHideTask);
|
experienceBarHideTaskHashMap.put(primarySkillType, experienceBarHideTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideExperienceBar(@NotNull RootSkill rootSkill)
|
public void hideExperienceBar(@NotNull PrimarySkillType primarySkillType)
|
||||||
{
|
{
|
||||||
if(experienceBars.containsKey(rootSkill))
|
if(experienceBars.containsKey(primarySkillType))
|
||||||
experienceBars.get(rootSkill).hideExperienceBar();
|
experienceBars.get(primarySkillType).hideExperienceBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearTask(@NotNull RootSkill rootSkill)
|
public void clearTask(@NotNull PrimarySkillType primarySkillType)
|
||||||
{
|
{
|
||||||
experienceBarHideTaskHashMap.remove(rootSkill);
|
experienceBarHideTaskHashMap.remove(primarySkillType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disableAllBars() {
|
public void disableAllBars() {
|
||||||
for(RootSkill rootSkill : mcMMO.p.getSkillRegister().getRootSkills()) {
|
for(PrimarySkillType primarySkillType : mcMMO.p.getSkillRegister().getRootSkills()) {
|
||||||
xpBarSettingToggle(SkillBossBarSetting.HIDE, rootSkill);
|
xpBarSettingToggle(SkillBossBarSetting.HIDE, primarySkillType);
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationManager.sendPlayerInformationChatOnlyPrefixed(Misc.adaptPlayer(mmoPlayer), "Commands.XPBar.DisableAll");
|
NotificationManager.sendPlayerInformationChatOnlyPrefixed(Misc.adaptPlayer(mmoPlayer), "Commands.XPBar.DisableAll");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void xpBarSettingToggle(@NotNull SkillBossBarSetting skillBossBarSetting, @NotNull RootSkill rootSkill) {
|
public void xpBarSettingToggle(@NotNull SkillBossBarSetting skillBossBarSetting, @NotNull PrimarySkillType primarySkillType) {
|
||||||
switch(skillBossBarSetting) {
|
switch(skillBossBarSetting) {
|
||||||
case SHOW:
|
case SHOW:
|
||||||
barStateMapRef.put(rootSkill, SkillBossBarState.ALWAYS_ON);
|
barStateMapRef.put(primarySkillType, SkillBossBarState.ALWAYS_ON);
|
||||||
|
|
||||||
//Remove lingering tasks
|
//Remove lingering tasks
|
||||||
if(experienceBarHideTaskHashMap.containsKey(rootSkill)) {
|
if(experienceBarHideTaskHashMap.containsKey(primarySkillType)) {
|
||||||
experienceBarHideTaskHashMap.get(rootSkill).cancel();
|
experienceBarHideTaskHashMap.get(primarySkillType).cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateExperienceBar(rootSkill, mcMMO.p);
|
updateExperienceBar(primarySkillType, mcMMO.p);
|
||||||
break;
|
break;
|
||||||
case HIDE:
|
case HIDE:
|
||||||
barStateMapRef.put(rootSkill, SkillBossBarState.DISABLED);
|
barStateMapRef.put(primarySkillType, SkillBossBarState.DISABLED);
|
||||||
|
|
||||||
//Remove lingering tasks
|
//Remove lingering tasks
|
||||||
if(experienceBarHideTaskHashMap.containsKey(rootSkill)) {
|
if(experienceBarHideTaskHashMap.containsKey(primarySkillType)) {
|
||||||
experienceBarHideTaskHashMap.get(rootSkill).cancel();
|
experienceBarHideTaskHashMap.get(primarySkillType).cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
hideExperienceBar(rootSkill);
|
hideExperienceBar(primarySkillType);
|
||||||
break;
|
break;
|
||||||
case RESET:
|
case RESET:
|
||||||
resetBarSettings();
|
resetBarSettings();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
informPlayer(skillBossBarSetting, rootSkill);
|
informPlayer(skillBossBarSetting, primarySkillType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetBarSettings() {
|
private void resetBarSettings() {
|
||||||
barStateMapRef.putAll(generateDefaultBarStateMap());
|
barStateMapRef.putAll(generateDefaultBarStateMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void informPlayer(@NotNull SkillBossBarSetting settingTarget, @NotNull RootSkill rootSkill) {
|
private void informPlayer(@NotNull SkillBossBarSetting settingTarget, @NotNull PrimarySkillType primarySkillType) {
|
||||||
//Inform player of setting change
|
//Inform player of setting change
|
||||||
if(settingTarget != SkillBossBarSetting.RESET) {
|
if(settingTarget != SkillBossBarSetting.RESET) {
|
||||||
NotificationManager.sendPlayerInformationChatOnlyPrefixed(Misc.adaptPlayer(mmoPlayer), "Commands.XPBar.SettingChanged", rootSkill.getRawSkillName(), settingTarget.toString());
|
NotificationManager.sendPlayerInformationChatOnlyPrefixed(Misc.adaptPlayer(mmoPlayer), "Commands.XPBar.SettingChanged", primarySkillType.getName(), settingTarget.toString());
|
||||||
} else {
|
} else {
|
||||||
NotificationManager.sendPlayerInformationChatOnlyPrefixed(Misc.adaptPlayer(mmoPlayer), "Commands.XPBar.Reset");
|
NotificationManager.sendPlayerInformationChatOnlyPrefixed(Misc.adaptPlayer(mmoPlayer), "Commands.XPBar.Reset");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull Map<RootSkill, SkillBossBarState> generateDefaultBarStateMap() {
|
public static @NotNull Map<PrimarySkillType, SkillBossBarState> generateDefaultBarStateMap() {
|
||||||
HashMap<RootSkill, SkillBossBarState> barStateMap = new HashMap<>();
|
HashMap<PrimarySkillType, SkillBossBarState> barStateMap = new HashMap<>();
|
||||||
|
|
||||||
setBarStateDefaults(barStateMap);
|
setBarStateDefaults(barStateMap);
|
||||||
|
|
||||||
return barStateMap;
|
return barStateMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setBarStateDefaults(@NotNull Map<RootSkill, SkillBossBarState> barStateHashMap) {
|
public static void setBarStateDefaults(@NotNull Map<PrimarySkillType, SkillBossBarState> barStateHashMap) {
|
||||||
for(RootSkill rootSkill : PrimarySkillType.getCoreRootSkills()) {
|
for(PrimarySkillType primarySkillType : PrimarySkillType.values()) {
|
||||||
|
|
||||||
if(PrimarySkillType.isChildSkill(rootSkill)) {
|
if(!primarySkillType.isChildSkill()) {
|
||||||
barStateHashMap.put(rootSkill, SkillBossBarState.DISABLED);
|
barStateHashMap.put(primarySkillType, SkillBossBarState.DISABLED);
|
||||||
} else {
|
} else {
|
||||||
barStateHashMap.put(rootSkill, SkillBossBarState.NORMAL);
|
barStateHashMap.put(primarySkillType, SkillBossBarState.NORMAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import com.gmail.nossr50.config.AdvancedConfig;
|
|||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.neetgames.mcmmo.player.MMOPlayerData;
|
import com.neetgames.mcmmo.player.MMOPlayerDataImpl;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityToolType;
|
import com.gmail.nossr50.datatypes.skills.AbilityToolType;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||||
@ -38,9 +38,9 @@ public class SuperSkillManagerImpl implements SuperSkillManager {
|
|||||||
private boolean abilityActivationPermission = true;
|
private boolean abilityActivationPermission = true;
|
||||||
|
|
||||||
private final Map<AbilityToolType, Boolean> toolMode = new HashMap<>();
|
private final Map<AbilityToolType, Boolean> toolMode = new HashMap<>();
|
||||||
private final MMOPlayerData mmoPlayerData;
|
private final MMOPlayerDataImpl mmoPlayerData;
|
||||||
|
|
||||||
public SuperSkillManagerImpl(@NotNull McMMOPlayer mmoPlayer, @NotNull MMOPlayerData mmoPlayerData) {
|
public SuperSkillManagerImpl(@NotNull McMMOPlayer mmoPlayer, @NotNull MMOPlayerDataImpl mmoPlayerData) {
|
||||||
this.mmoPlayer = mmoPlayer;
|
this.mmoPlayer = mmoPlayer;
|
||||||
this.mmoPlayerData = mmoPlayerData;
|
this.mmoPlayerData = mmoPlayerData;
|
||||||
this.player = Misc.adaptPlayer(mmoPlayer);
|
this.player = Misc.adaptPlayer(mmoPlayer);
|
||||||
|
@ -160,17 +160,17 @@ public class NotificationManager {
|
|||||||
/**
|
/**
|
||||||
* Handles sending level up notifications to a mmoPlayer
|
* Handles sending level up notifications to a mmoPlayer
|
||||||
* @param mmoPlayer target mmoPlayer
|
* @param mmoPlayer target mmoPlayer
|
||||||
* @param rootSkill skill that leveled up
|
* @param primarySkillType skill that leveled up
|
||||||
* @param newLevel new level of that skill
|
* @param newLevel new level of that skill
|
||||||
*/
|
*/
|
||||||
public static void sendPlayerLevelUpNotification(@NotNull OnlineMMOPlayer mmoPlayer, @NotNull RootSkill rootSkill, int levelsGained, int newLevel)
|
public static void sendPlayerLevelUpNotification(@NotNull OnlineMMOPlayer mmoPlayer, @NotNull PrimarySkillType primarySkillType, int levelsGained, int newLevel)
|
||||||
{
|
{
|
||||||
if(!mmoPlayer.hasSkillChatNotifications())
|
if(!mmoPlayer.hasSkillChatNotifications())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
McMMOMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(NotificationType.LEVEL_UP_MESSAGE) ? McMMOMessageType.ACTION_BAR : McMMOMessageType.SYSTEM;
|
McMMOMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(NotificationType.LEVEL_UP_MESSAGE) ? McMMOMessageType.ACTION_BAR : McMMOMessageType.SYSTEM;
|
||||||
|
|
||||||
Component levelUpTextComponent = TextComponentFactory.getNotificationLevelUpTextComponent(PrimarySkillType.getSkill(rootSkill), levelsGained, newLevel);
|
Component levelUpTextComponent = TextComponentFactory.getNotificationLevelUpTextComponent(PrimarySkillType.getSkill(primarySkillType), levelsGained, newLevel);
|
||||||
McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(Misc.adaptPlayer(mmoPlayer), NotificationType.LEVEL_UP_MESSAGE, destination, levelUpTextComponent);
|
McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(Misc.adaptPlayer(mmoPlayer), NotificationType.LEVEL_UP_MESSAGE, destination, levelUpTextComponent);
|
||||||
|
|
||||||
sendNotification(Misc.adaptPlayer(mmoPlayer), customEvent);
|
sendNotification(Misc.adaptPlayer(mmoPlayer), customEvent);
|
||||||
|
@ -11,10 +11,10 @@ public class PlayerLevelUtils {
|
|||||||
* Check if a player is currently qualifying for the early game boosted XP
|
* Check if a player is currently qualifying for the early game boosted XP
|
||||||
* Will return false only if a player is above the boost level cutoff, it does not check config settings to see if the early game boost is on
|
* Will return false only if a player is above the boost level cutoff, it does not check config settings to see if the early game boost is on
|
||||||
* @param mmoPlayer target player
|
* @param mmoPlayer target player
|
||||||
* @param rootSkill target skill
|
* @param primarySkillType target skill
|
||||||
* @return if the player would qualify for the XP boost if its enabled
|
* @return if the player would qualify for the XP boost if its enabled
|
||||||
*/
|
*/
|
||||||
public static boolean qualifiesForEarlyGameBoost(@NotNull OnlineMMOPlayer mmoPlayer, @NotNull RootSkill rootSkill) {
|
public static boolean qualifiesForEarlyGameBoost(@NotNull OnlineMMOPlayer mmoPlayer, @NotNull PrimarySkillType primarySkillType) {
|
||||||
return mmoPlayer.getSkillLevel(rootSkill) < 1;
|
return mmoPlayer.getSkillLevel(primarySkillType) < 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -488,8 +488,8 @@ public class TextComponentFactory {
|
|||||||
componentBuilder.append(Component.newline());
|
componentBuilder.append(Component.newline());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getSubSkillTextComponents(@NotNull OnlineMMOPlayer mmoPlayer, @NotNull List<Component> textComponents, @NotNull RootSkill rootSkill) {
|
public static void getSubSkillTextComponents(@NotNull OnlineMMOPlayer mmoPlayer, @NotNull List<Component> textComponents, @NotNull PrimarySkillType primarySkillType) {
|
||||||
return getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.getSkill(rootSkill));
|
return getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.getSkill(primarySkillType));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getSubSkillTextComponents(@NotNull OnlineMMOPlayer mmoPlayer, @NotNull List<Component> textComponents, @NotNull PrimarySkillType parentSkill) {
|
public static void getSubSkillTextComponents(@NotNull OnlineMMOPlayer mmoPlayer, @NotNull List<Component> textComponents, @NotNull PrimarySkillType parentSkill) {
|
||||||
|
Loading…
Reference in New Issue
Block a user