mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 06:36:45 +01:00
Add + Wire up Combat XP Multipliers
This commit is contained in:
parent
2e3f9b4a96
commit
d8841c6ae7
@ -126,21 +126,6 @@ public class ExperienceConfig extends ConfigValidated {
|
|||||||
* XP SETTINGS
|
* XP SETTINGS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Combat XP Multipliers */
|
|
||||||
public double getCombatXP(EntityType entity) {
|
|
||||||
return getDoubleValue(EXPERIENCE, COMBAT, MULTIPLIER, StringUtils.getEntityConfigName(entity));
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getAnimalsXP(EntityType entity) {
|
|
||||||
return getDoubleValue(EXPERIENCE, COMBAT, MULTIPLIER, StringUtils.getEntityConfigName(entity));
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasCombatXP(EntityType entity) {
|
|
||||||
return hasNode(EXPERIENCE, COMBAT, MULTIPLIER, StringUtils.getEntityConfigName(entity));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Materials */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the raw XP given for breaking this block, this does not include modifiers
|
* Gets the raw XP given for breaking this block, this does not include modifiers
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.config.hocon.experience;
|
package com.gmail.nossr50.config.hocon.experience;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.experience.SpecialXPKey;
|
||||||
import ninja.leaping.configurate.objectmapping.Setting;
|
import ninja.leaping.configurate.objectmapping.Setting;
|
||||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||||
|
|
||||||
@ -9,7 +10,7 @@ import java.util.HashMap;
|
|||||||
public class ConfigExperienceCombat {
|
public class ConfigExperienceCombat {
|
||||||
|
|
||||||
private static final HashMap<String, Float> COMBAT_EXPERIENCE_DEFAULT;
|
private static final HashMap<String, Float> COMBAT_EXPERIENCE_DEFAULT;
|
||||||
private static final HashMap<String, Float> SPECIAL_COMBAT_EXPERIENCE_DEFAULT;
|
private static final HashMap<SpecialXPKey, Float> SPECIAL_COMBAT_EXPERIENCE_DEFAULT;
|
||||||
private static final boolean PVP_XP_ENABLED_DEFAULT = false;
|
private static final boolean PVP_XP_ENABLED_DEFAULT = false;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@ -75,17 +76,23 @@ public class ConfigExperienceCombat {
|
|||||||
|
|
||||||
//SPECIAL
|
//SPECIAL
|
||||||
SPECIAL_COMBAT_EXPERIENCE_DEFAULT = new HashMap<>();
|
SPECIAL_COMBAT_EXPERIENCE_DEFAULT = new HashMap<>();
|
||||||
SPECIAL_COMBAT_EXPERIENCE_DEFAULT.put("animals", 1.0F); //TODO: this seems like a dumb config option
|
SPECIAL_COMBAT_EXPERIENCE_DEFAULT.put(SpecialXPKey.ANIMALS, 1.0F); //TODO: this seems like a dumb config option
|
||||||
SPECIAL_COMBAT_EXPERIENCE_DEFAULT.put("spawned", 0.0F);
|
SPECIAL_COMBAT_EXPERIENCE_DEFAULT.put(SpecialXPKey.SPAWNED, 0.0F);
|
||||||
SPECIAL_COMBAT_EXPERIENCE_DEFAULT.put("pvp", 1.0F);
|
SPECIAL_COMBAT_EXPERIENCE_DEFAULT.put(SpecialXPKey.PVP, 1.0F);
|
||||||
SPECIAL_COMBAT_EXPERIENCE_DEFAULT.put("player-bred-mobs", 1.0F);
|
SPECIAL_COMBAT_EXPERIENCE_DEFAULT.put(SpecialXPKey.PETS, 1.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Setting(value = "Combat-XP-Multipliers")
|
@Setting(value = "Combat-XP-Multipliers")
|
||||||
private HashMap<String, Float> combatExperienceMap = COMBAT_EXPERIENCE_DEFAULT;
|
private HashMap<String, Float> combatExperienceMap = COMBAT_EXPERIENCE_DEFAULT;
|
||||||
|
|
||||||
@Setting(value = "Special-Combat-XP-Multipliers")
|
@Setting(value = "Special-Combat-XP-Multipliers", comment = "Special XP settings which apply to a mobs matching certain criteria" +
|
||||||
private HashMap<String, Float> specialCombatExperienceMap = SPECIAL_COMBAT_EXPERIENCE_DEFAULT;
|
"\nAnimals - Non-hostile mobs, anything not considered a Monster" +
|
||||||
|
"\nSpawned - Unnatural mobs, can be from mob spawners, eggs, or otherwise" +
|
||||||
|
"\nPVP - XP gains relating to hitting other players" +
|
||||||
|
"\nPets - Either tamed or from breeding" +
|
||||||
|
"\nThese all default to 1.0 except for spawned, which defaults to 0.0" +
|
||||||
|
"\nIf you want spawned mobs to give XP simply turn the value for spawned above 0.0")
|
||||||
|
private HashMap<SpecialXPKey, Float> specialCombatExperienceMap = SPECIAL_COMBAT_EXPERIENCE_DEFAULT;
|
||||||
|
|
||||||
@Setting(value = "PVP-XP", comment = "If true, players will gain XP from PVP interactions." +
|
@Setting(value = "PVP-XP", comment = "If true, players will gain XP from PVP interactions." +
|
||||||
"\nBe careful turning this on as this can potentially allow for unwanted behaviour from players." +
|
"\nBe careful turning this on as this can potentially allow for unwanted behaviour from players." +
|
||||||
@ -100,23 +107,7 @@ public class ConfigExperienceCombat {
|
|||||||
return combatExperienceMap;
|
return combatExperienceMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getSpawnedMobXPMult() {
|
public HashMap<SpecialXPKey, Float> getSpecialCombatExperienceMap() {
|
||||||
return specialCombatExperienceMap.get("mobspawners");
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getPVPXPMult() {
|
|
||||||
return specialCombatExperienceMap.get("pvp");
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getAnimalsXPMult() {
|
|
||||||
return specialCombatExperienceMap.get("animals");
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getPlayerBredMobsXPMult() {
|
|
||||||
return specialCombatExperienceMap.get("player-bred-mobs");
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<String, Float> getSpecialCombatExperienceMap() {
|
|
||||||
return specialCombatExperienceMap;
|
return specialCombatExperienceMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.config.hocon.experience;
|
package com.gmail.nossr50.config.hocon.experience;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.experience.SpecialXPKey;
|
||||||
import ninja.leaping.configurate.objectmapping.Setting;
|
import ninja.leaping.configurate.objectmapping.Setting;
|
||||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||||
|
|
||||||
@ -47,10 +48,6 @@ public class ConfigExperienceSkills {
|
|||||||
* BOILER PLATE GETTERS
|
* BOILER PLATE GETTERS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public float getPlayerBredMobsXPMult() {
|
|
||||||
return experienceCombat.getPlayerBredMobsXPMult();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConfigExperienceAcrobatics getExperienceAcrobatics() {
|
public ConfigExperienceAcrobatics getExperienceAcrobatics() {
|
||||||
return experienceAcrobatics;
|
return experienceAcrobatics;
|
||||||
}
|
}
|
||||||
@ -171,7 +168,7 @@ public class ConfigExperienceSkills {
|
|||||||
return experienceCombat.getCombatExperienceMap();
|
return experienceCombat.getCombatExperienceMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, Float> getSpecialCombatExperienceMap() {
|
public HashMap<SpecialXPKey, Float> getSpecialCombatExperienceMap() {
|
||||||
return experienceCombat.getSpecialCombatExperienceMap();
|
return experienceCombat.getSpecialCombatExperienceMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,16 +195,4 @@ public class ConfigExperienceSkills {
|
|||||||
public int getShakeXP() {
|
public int getShakeXP() {
|
||||||
return experienceFishing.getShakeXP();
|
return experienceFishing.getShakeXP();
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getSpawnedMobXPMult() {
|
|
||||||
return experienceCombat.getSpawnedMobXPMult();
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getPVPXPMult() {
|
|
||||||
return experienceCombat.getPVPXPMult();
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getAnimalsXPMult() {
|
|
||||||
return experienceCombat.getAnimalsXPMult();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.gmail.nossr50.datatypes.experience;
|
||||||
|
|
||||||
|
public enum SpecialXPKey {
|
||||||
|
ANIMALS, //Non-hostile mobs
|
||||||
|
SPAWNED, //Unnatural, can be from mob spawners, eggs, etc
|
||||||
|
PVP, //Players attacking players
|
||||||
|
PETS //Player owned
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.util.experience;
|
package com.gmail.nossr50.util.experience;
|
||||||
|
|
||||||
import com.gmail.nossr50.api.exceptions.UndefinedSkillBehaviour;
|
import com.gmail.nossr50.api.exceptions.UndefinedSkillBehaviour;
|
||||||
|
import com.gmail.nossr50.datatypes.experience.SpecialXPKey;
|
||||||
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 org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -19,12 +20,13 @@ public class ExperienceMapManager {
|
|||||||
private HashMap<String, Integer> excavationFullyQualifiedBlockXpMap;
|
private HashMap<String, Integer> excavationFullyQualifiedBlockXpMap;
|
||||||
private HashMap<EntityType, Float> tamingExperienceMap;
|
private HashMap<EntityType, Float> tamingExperienceMap;
|
||||||
private HashMap<EntityType, Float> combatXPMultiplierMap;
|
private HashMap<EntityType, Float> combatXPMultiplierMap;
|
||||||
private HashMap<EntityType, Float> specialCombatXPMultiplierMap; //Applies to "groups" of things for convenience
|
private HashMap<SpecialXPKey, Float> specialCombatXPMultiplierMap; //Applies to "groups" of things for convenience
|
||||||
|
|
||||||
private double globalXpMult;
|
private double globalXpMult;
|
||||||
|
|
||||||
public ExperienceMapManager() {
|
public ExperienceMapManager() {
|
||||||
initExperienceMaps();
|
initExperienceMaps();
|
||||||
|
registerDefaultValues();
|
||||||
|
|
||||||
//Register with unloader
|
//Register with unloader
|
||||||
}
|
}
|
||||||
@ -39,6 +41,12 @@ public class ExperienceMapManager {
|
|||||||
tamingExperienceMap = new HashMap<>();
|
tamingExperienceMap = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerDefaultValues()
|
||||||
|
{
|
||||||
|
fillCombatXPMultiplierMap(mcMMO.getConfigManager().getConfigExperience().getCombatExperienceMap());
|
||||||
|
buildBlockXPMaps();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills the combat XP multiplier map with values from a platform generic map
|
* Fills the combat XP multiplier map with values from a platform generic map
|
||||||
* Platform safe map, is just a map which uses strings to define target entities/etc
|
* Platform safe map, is just a map which uses strings to define target entities/etc
|
||||||
@ -46,6 +54,7 @@ public class ExperienceMapManager {
|
|||||||
* @param platformSafeMap the platform safe map
|
* @param platformSafeMap the platform safe map
|
||||||
*/
|
*/
|
||||||
public void fillCombatXPMultiplierMap(HashMap<String, Float> platformSafeMap) {
|
public void fillCombatXPMultiplierMap(HashMap<String, Float> platformSafeMap) {
|
||||||
|
mcMMO.p.getLogger().info("Registering combat XP values...");
|
||||||
for(String entityString : platformSafeMap.keySet())
|
for(String entityString : platformSafeMap.keySet())
|
||||||
{
|
{
|
||||||
//Iterate over all EntityType(s)
|
//Iterate over all EntityType(s)
|
||||||
@ -69,6 +78,12 @@ public class ExperienceMapManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void copySpecialCombatXPMultiplierMap(HashMap<SpecialXPKey, Float> map)
|
||||||
|
{
|
||||||
|
mcMMO.p.getLogger().info("Registering special combat XP values...");
|
||||||
|
specialCombatXPMultiplierMap = map;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds fully qualified name to xp value maps of blocks for XP lookups
|
* Builds fully qualified name to xp value maps of blocks for XP lookups
|
||||||
* This method servers two purposes
|
* This method servers two purposes
|
||||||
@ -312,4 +327,34 @@ public class ExperienceMapManager {
|
|||||||
public int getExcavationXp(Material material) {
|
public int getExcavationXp(Material material) {
|
||||||
return excavationFullyQualifiedBlockXpMap.get(material.getKey());
|
return excavationFullyQualifiedBlockXpMap.get(material.getKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the XP multiplier value for a special XP group
|
||||||
|
* @param specialXPKey target special XP group
|
||||||
|
* @return XP multiplier for target special XP group
|
||||||
|
*/
|
||||||
|
public float getSpecialCombatXP(SpecialXPKey specialXPKey)
|
||||||
|
{
|
||||||
|
return specialCombatXPMultiplierMap.get(specialXPKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the combat XP multiplier for this entity type
|
||||||
|
* @param entityType target entity type
|
||||||
|
* @return the combat XP multiplier for this entity
|
||||||
|
*/
|
||||||
|
public float getCombatXPMultiplier(EntityType entityType)
|
||||||
|
{
|
||||||
|
return combatXPMultiplierMap.get(entityType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true/false if a EntityType has a defined XP multiplier (from the config typically)
|
||||||
|
* @param entityType target entity type
|
||||||
|
* @return true if entity type has XP
|
||||||
|
*/
|
||||||
|
public boolean hasCombatXP(EntityType entityType)
|
||||||
|
{
|
||||||
|
return combatXPMultiplierMap.get(entityType) != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.util.skills;
|
|||||||
|
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
import com.gmail.nossr50.core.MetadataConstants;
|
import com.gmail.nossr50.core.MetadataConstants;
|
||||||
|
import com.gmail.nossr50.datatypes.experience.SpecialXPKey;
|
||||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||||
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;
|
||||||
@ -532,7 +533,7 @@ public final class CombatUtils {
|
|||||||
* @param primarySkillType The skill being used
|
* @param primarySkillType The skill being used
|
||||||
*/
|
*/
|
||||||
private static void startGainXp(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType, double multiplier) {
|
private static void startGainXp(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType, double multiplier) {
|
||||||
double baseXP = 0;
|
float baseXPMultiplier = 0;
|
||||||
XPGainReason xpGainReason;
|
XPGainReason xpGainReason;
|
||||||
|
|
||||||
if (target instanceof Player) {
|
if (target instanceof Player) {
|
||||||
@ -544,7 +545,7 @@ public final class CombatUtils {
|
|||||||
Player defender = (Player) target;
|
Player defender = (Player) target;
|
||||||
|
|
||||||
if (defender.isOnline() && SkillUtils.cooldownExpired(mcMMOPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS)) {
|
if (defender.isOnline() && SkillUtils.cooldownExpired(mcMMOPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS)) {
|
||||||
baseXP = 20 * mcMMO.getConfigManager().getConfigExperience().getPVPXPMult();
|
baseXPMultiplier = 20 * mcMMO.getConfigManager().getConfigExperience().getPVPXPMult();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*if (mcMMO.getModManager().isCustomEntity(target)) {
|
/*if (mcMMO.getModManager().isCustomEntity(target)) {
|
||||||
@ -552,45 +553,44 @@ public final class CombatUtils {
|
|||||||
}*/
|
}*/
|
||||||
//else if (target instanceof Animals) {
|
//else if (target instanceof Animals) {
|
||||||
if (target instanceof Animals) {
|
if (target instanceof Animals) {
|
||||||
EntityType type = target.getType();
|
baseXPMultiplier = mcMMO.getDynamicSettingsManager().getExperienceMapManager().getSpecialCombatXP(SpecialXPKey.ANIMALS);
|
||||||
baseXP = mcMMO.getConfigManager().getConfigExperience().getAnimalsXPMult();
|
|
||||||
} else if (target instanceof Monster) {
|
} else if (target instanceof Monster) {
|
||||||
EntityType type = target.getType();
|
EntityType type = target.getType();
|
||||||
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
|
baseXPMultiplier = mcMMO.getDynamicSettingsManager().getExperienceMapManager().getCombatXPMultiplier(type);
|
||||||
} else {
|
} else {
|
||||||
EntityType type = target.getType();
|
EntityType type = target.getType();
|
||||||
|
|
||||||
if (ExperienceConfig.getInstance().hasCombatXP(type)) {
|
if (mcMMO.getDynamicSettingsManager().getExperienceMapManager().hasCombatXP(type)) {
|
||||||
|
//Exploit stuff
|
||||||
if (type == EntityType.IRON_GOLEM) {
|
if (type == EntityType.IRON_GOLEM) {
|
||||||
if (!((IronGolem) target).isPlayerCreated()) {
|
if (!((IronGolem) target).isPlayerCreated()) {
|
||||||
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
|
baseXPMultiplier = mcMMO.getDynamicSettingsManager().getExperienceMapManager().getCombatXPMultiplier(type);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
|
baseXPMultiplier = mcMMO.getDynamicSettingsManager().getExperienceMapManager().getCombatXPMultiplier(type);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
baseXP = 1.0;
|
baseXPMultiplier = 1.0f;
|
||||||
//mcMMO.getModManager().addCustomEntity(target);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target.hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY)) {
|
if (target.hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY)) {
|
||||||
baseXP *= mcMMO.getConfigManager().getConfigExperience().getSpawnedMobXPMult();
|
baseXPMultiplier *= mcMMO.getConfigManager().getConfigExperience().getSpawnedMobXPMult();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target.hasMetadata(MetadataConstants.BRED_ANIMAL_TRACKING_METAKEY)) {
|
if (target.hasMetadata(MetadataConstants.BRED_ANIMAL_TRACKING_METAKEY)) {
|
||||||
baseXP *= mcMMO.getConfigManager().getConfigExperience().getPlayerBredMobsXPMult();
|
baseXPMultiplier *= mcMMO.getConfigManager().getConfigExperience().getPlayerBredMobsXPMult();
|
||||||
}
|
}
|
||||||
|
|
||||||
xpGainReason = XPGainReason.PVE;
|
xpGainReason = XPGainReason.PVE;
|
||||||
|
|
||||||
baseXP *= 10;
|
baseXPMultiplier *= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
baseXP *= multiplier;
|
baseXPMultiplier *= multiplier;
|
||||||
|
|
||||||
if (baseXP != 0) {
|
if (baseXPMultiplier != 0) {
|
||||||
new AwardCombatXpTask(mcMMOPlayer, primarySkillType, baseXP, target, xpGainReason).runTaskLater(mcMMO.p, 0);
|
new AwardCombatXpTask(mcMMOPlayer, primarySkillType, baseXPMultiplier, target, xpGainReason).runTaskLater(mcMMO.p, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user