mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 06:36:45 +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.experience.CustomXPPerk;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.google.common.reflect.TypeResolver;
|
import com.google.common.reflect.TypeResolver;
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
import ninja.leaping.configurate.ConfigurationNode;
|
import ninja.leaping.configurate.ConfigurationNode;
|
||||||
@ -25,6 +26,9 @@ public class CustomXPPerkSerializer implements TypeSerializer<CustomXPPerk> {
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
PrimarySkillType primarySkillType = matchIgnoreCase(configurationNode.getValue(TypeToken.of(String.class)));
|
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));
|
float boostValue = configurationNode.getNode("XP-Multiplier").getValue(TypeToken.of(Float.class));
|
||||||
customXPPerk.setCustomXPValue(primarySkillType, boostValue);
|
customXPPerk.setCustomXPValue(primarySkillType, boostValue);
|
||||||
} catch (InvalidSkillException e) {
|
} catch (InvalidSkillException e) {
|
||||||
@ -40,7 +44,21 @@ public class CustomXPPerkSerializer implements TypeSerializer<CustomXPPerk> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(@NonNull TypeToken<?> type, @Nullable CustomXPPerk obj, @NonNull ConfigurationNode value) throws ObjectMappingException {
|
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
|
private PrimarySkillType matchIgnoreCase(String string) throws InvalidSkillException
|
||||||
|
@ -777,15 +777,8 @@ public class McMMOPlayer {
|
|||||||
|
|
||||||
xp = (float) (xp / primarySkillType.getXpModifier() * mcMMO.getConfigManager().getExperienceMapManager().getGlobalXpMult());
|
xp = (float) (xp / primarySkillType.getXpModifier() * mcMMO.getConfigManager().getExperienceMapManager().getGlobalXpMult());
|
||||||
|
|
||||||
/*if (MainConfig.getInstance().getToolModsEnabled()) {
|
//Multiply by the players personal XP rate
|
||||||
CustomTool tool = mcMMO.getModManager().getTool(player.getInventory().getItemInMainHand());
|
return xp * personalXPModifiers.get(primarySkillType);
|
||||||
|
|
||||||
if (tool != null) {
|
|
||||||
xp *= tool.getXpMultiplier();
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
return xp * mcMMO.getPlayerLevelUtils().getPlayersPersonalXPRate(this, primarySkillType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkGodMode() {
|
public void checkGodMode() {
|
||||||
|
@ -86,10 +86,10 @@ public final class Motd {
|
|||||||
*/
|
*/
|
||||||
public static void displayXpPerks(Player player) {
|
public static void displayXpPerks(Player player) {
|
||||||
for (PrimarySkillType skill : PrimarySkillType.values()) {
|
for (PrimarySkillType skill : PrimarySkillType.values()) {
|
||||||
if (PerksUtils.handleXpPerks(player, 1, skill) > 1) {
|
// 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")));
|
// player.sendMessage(PERK_PREFIX + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.XP.Name"), LocaleLoader.getString("Perks.XP.Desc")));
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user