mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-25 18:17:46 +01:00
Unlimited custom XP perks part 2
This commit is contained in:
parent
40598a0e96
commit
ca7cf5cc58
@ -4,6 +4,7 @@ import com.gmail.nossr50.api.exceptions.InvalidSkillException;
|
||||
import com.gmail.nossr50.datatypes.experience.CustomXPPerk;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.google.common.reflect.TypeResolver;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
@ -25,6 +26,9 @@ public class CustomXPPerkSerializer implements TypeSerializer<CustomXPPerk> {
|
||||
{
|
||||
try {
|
||||
PrimarySkillType primarySkillType = matchIgnoreCase(configurationNode.getValue(TypeToken.of(String.class)));
|
||||
if(primarySkillType.isChildSkill())
|
||||
continue; //Child skills gross
|
||||
|
||||
float boostValue = configurationNode.getNode("XP-Multiplier").getValue(TypeToken.of(Float.class));
|
||||
customXPPerk.setCustomXPValue(primarySkillType, boostValue);
|
||||
} catch (InvalidSkillException e) {
|
||||
@ -40,7 +44,21 @@ public class CustomXPPerkSerializer implements TypeSerializer<CustomXPPerk> {
|
||||
|
||||
@Override
|
||||
public void serialize(@NonNull TypeToken<?> type, @Nullable CustomXPPerk obj, @NonNull ConfigurationNode value) throws ObjectMappingException {
|
||||
String name = obj.getPerkName();
|
||||
|
||||
value.getNode("name").setValue(name);
|
||||
|
||||
for(PrimarySkillType primarySkillType : PrimarySkillType.values())
|
||||
{
|
||||
float xpMultValue = obj.getXPMultiplierValue(primarySkillType);
|
||||
|
||||
//Ignore default values
|
||||
if(xpMultValue == 1.0F)
|
||||
continue;
|
||||
|
||||
//Set value
|
||||
value.getNode("name").getNode(StringUtils.getCapitalized(primarySkillType.toString())).setValue(xpMultValue);
|
||||
}
|
||||
}
|
||||
|
||||
private PrimarySkillType matchIgnoreCase(String string) throws InvalidSkillException
|
||||
|
@ -777,15 +777,8 @@ public class McMMOPlayer {
|
||||
|
||||
xp = (float) (xp / primarySkillType.getXpModifier() * mcMMO.getConfigManager().getExperienceMapManager().getGlobalXpMult());
|
||||
|
||||
/*if (MainConfig.getInstance().getToolModsEnabled()) {
|
||||
CustomTool tool = mcMMO.getModManager().getTool(player.getInventory().getItemInMainHand());
|
||||
|
||||
if (tool != null) {
|
||||
xp *= tool.getXpMultiplier();
|
||||
}
|
||||
}*/
|
||||
|
||||
return xp * mcMMO.getPlayerLevelUtils().getPlayersPersonalXPRate(this, primarySkillType);
|
||||
//Multiply by the players personal XP rate
|
||||
return xp * personalXPModifiers.get(primarySkillType);
|
||||
}
|
||||
|
||||
public void checkGodMode() {
|
||||
|
@ -86,10 +86,10 @@ public final class Motd {
|
||||
*/
|
||||
public static void displayXpPerks(Player player) {
|
||||
for (PrimarySkillType skill : PrimarySkillType.values()) {
|
||||
if (PerksUtils.handleXpPerks(player, 1, skill) > 1) {
|
||||
player.sendMessage(PERK_PREFIX + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.XP.Name"), LocaleLoader.getString("Perks.XP.Desc")));
|
||||
return;
|
||||
}
|
||||
// if (PerksUtils.handleXpPerks(player, 1, skill) > 1) {
|
||||
// player.sendMessage(PERK_PREFIX + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.XP.Name"), LocaleLoader.getString("Perks.XP.Desc")));
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user