mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-27 00:45:40 +01:00
Deprecated exp dispensers
This commit is contained in:
parent
75a4b944b6
commit
c6a45d5120
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>net.Indyuce</groupId>
|
<groupId>net.Indyuce</groupId>
|
||||||
<artifactId>MMOCore</artifactId>
|
<artifactId>MMOCore</artifactId>
|
||||||
<version>1.9.2</version>
|
<version>1.9.3</version>
|
||||||
<name>MMOCore</name>
|
<name>MMOCore</name>
|
||||||
<description>Offer your players a brand new RPG experience!!</description>
|
<description>Offer your players a brand new RPG experience!!</description>
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import io.lumine.mythic.lib.api.MMOLineConfig;
|
|||||||
import io.lumine.mythic.lib.api.util.PostLoadObject;
|
import io.lumine.mythic.lib.api.util.PostLoadObject;
|
||||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.player.profess.event.EventTrigger;
|
import net.Indyuce.mmocore.api.player.profess.event.EventTrigger;
|
||||||
import net.Indyuce.mmocore.api.player.profess.resource.ManaDisplayOptions;
|
import net.Indyuce.mmocore.api.player.profess.resource.ManaDisplayOptions;
|
||||||
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
||||||
@ -15,19 +16,18 @@ import net.Indyuce.mmocore.api.player.profess.resource.ResourceRegeneration;
|
|||||||
import net.Indyuce.mmocore.api.player.stats.StatType;
|
import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||||
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
||||||
|
import net.Indyuce.mmocore.experience.EXPSource;
|
||||||
import net.Indyuce.mmocore.loot.chest.particle.CastingParticle;
|
import net.Indyuce.mmocore.loot.chest.particle.CastingParticle;
|
||||||
import net.Indyuce.mmocore.experience.ExpCurve;
|
import net.Indyuce.mmocore.experience.ExpCurve;
|
||||||
import net.Indyuce.mmocore.experience.ExperienceObject;
|
import net.Indyuce.mmocore.experience.ExperienceObject;
|
||||||
import net.Indyuce.mmocore.experience.droptable.ExperienceTable;
|
import net.Indyuce.mmocore.experience.droptable.ExperienceTable;
|
||||||
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
|
|
||||||
import net.Indyuce.mmocore.experience.dispenser.ClassExperienceDispenser;
|
|
||||||
import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
|
import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
|
||||||
import net.Indyuce.mmocore.player.playerclass.ClassTrigger;
|
import net.Indyuce.mmocore.player.playerclass.ClassTrigger;
|
||||||
import net.Indyuce.mmocore.player.playerclass.ClassTriggerType;
|
import net.Indyuce.mmocore.player.playerclass.ClassTriggerType;
|
||||||
import net.Indyuce.mmocore.skill.ClassSkill;
|
import net.Indyuce.mmocore.skill.ClassSkill;
|
||||||
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
@ -156,10 +156,9 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (config.contains("main-exp-sources")) {
|
if (config.contains("main-exp-sources")) {
|
||||||
ExperienceDispenser dispenser = new ClassExperienceDispenser(this);
|
|
||||||
for (String key : config.getStringList("main-exp-sources"))
|
for (String key : config.getStringList("main-exp-sources"))
|
||||||
try {
|
try {
|
||||||
ExperienceSource<?> source = MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), dispenser);
|
ExperienceSource<?> source = MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), this);
|
||||||
MMOCore.plugin.experience.registerSource(source);
|
MMOCore.plugin.experience.registerSource(source);
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load exp source '" + key + "' from class '"
|
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load exp source '" + key + "' from class '"
|
||||||
@ -299,6 +298,18 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
|
|||||||
return options.containsKey(option) ? options.get(option) : option.getDefault();
|
return options.containsKey(option) ? options.get(option) : option.getDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void giveExperience(PlayerData playerData, double experience, @Nullable Location hologramLocation, EXPSource source) {
|
||||||
|
hologramLocation = !MMOCore.plugin.getConfig().getBoolean("display-main-class-exp-holograms") ? null
|
||||||
|
: hologramLocation;
|
||||||
|
playerData.giveExperience(experience, source, hologramLocation, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldHandle(PlayerData playerData) {
|
||||||
|
return equals(playerData.getProfess());
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public ClassTrigger getClassTrigger(ClassTriggerType type) {
|
public ClassTrigger getClassTrigger(ClassTriggerType type) {
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package net.Indyuce.mmocore.api.quest.trigger;
|
package net.Indyuce.mmocore.api.quest.trigger;
|
||||||
|
|
||||||
|
import net.Indyuce.mmocore.experience.SimpleExperienceObject;
|
||||||
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
|
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
|
||||||
import net.Indyuce.mmocore.experience.dispenser.ProfessionExperienceDispenser;
|
|
||||||
import net.Indyuce.mmocore.experience.dispenser.SimpleExperienceDispenser;
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
@ -28,9 +27,9 @@ public class ExperienceTrigger extends Trigger {
|
|||||||
if (config.contains("profession")) {
|
if (config.contains("profession")) {
|
||||||
String id = config.getString("profession").toLowerCase().replace("_", "-");
|
String id = config.getString("profession").toLowerCase().replace("_", "-");
|
||||||
Validate.isTrue(MMOCore.plugin.professionManager.has(id), "Could not find profession");
|
Validate.isTrue(MMOCore.plugin.professionManager.has(id), "Could not find profession");
|
||||||
dispenser = new ProfessionExperienceDispenser(MMOCore.plugin.professionManager.get(id));
|
dispenser = MMOCore.plugin.professionManager.get(id);
|
||||||
} else
|
} else
|
||||||
dispenser = new SimpleExperienceDispenser();
|
dispenser = new SimpleExperienceObject();
|
||||||
amount = new RandomAmount(config.getString("amount"));
|
amount = new RandomAmount(config.getString("amount"));
|
||||||
source = config.contains("source") ? EXPSource.valueOf(config.getString("source").toUpperCase()) : EXPSource.QUEST;
|
source = config.contains("source") ? EXPSource.valueOf(config.getString("source").toUpperCase()) : EXPSource.QUEST;
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,21 @@
|
|||||||
package net.Indyuce.mmocore.experience;
|
package net.Indyuce.mmocore.experience;
|
||||||
|
|
||||||
|
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
|
||||||
import net.Indyuce.mmocore.experience.droptable.ExperienceTable;
|
import net.Indyuce.mmocore.experience.droptable.ExperienceTable;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Either a profession or a class
|
* General implementation for professions and classes.
|
||||||
|
* <p>
|
||||||
|
* An experience object is a type of object that can
|
||||||
|
* level up. It has an experience curve and table and
|
||||||
|
* can receive EXP
|
||||||
*
|
*
|
||||||
* @author jules
|
* @author jules
|
||||||
*/
|
*/
|
||||||
public interface ExperienceObject {
|
public interface ExperienceObject extends ExperienceDispenser {
|
||||||
|
|
||||||
String getKey();
|
String getKey();
|
||||||
|
|
||||||
|
@ -3,14 +3,15 @@ package net.Indyuce.mmocore.experience;
|
|||||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||||
import io.lumine.mythic.lib.api.util.PostLoadObject;
|
import io.lumine.mythic.lib.api.util.PostLoadObject;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
||||||
import net.Indyuce.mmocore.experience.droptable.ExperienceTable;
|
import net.Indyuce.mmocore.experience.droptable.ExperienceTable;
|
||||||
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
|
|
||||||
import net.Indyuce.mmocore.experience.dispenser.ProfessionExperienceDispenser;
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -63,16 +64,14 @@ public class Profession extends PostLoadObject implements ExperienceObject {
|
|||||||
|
|
||||||
maxLevel = config.getInt("max-level");
|
maxLevel = config.getInt("max-level");
|
||||||
|
|
||||||
if (config.contains("exp-sources")) {
|
if (config.contains("exp-sources"))
|
||||||
ExperienceDispenser dispenser = new ProfessionExperienceDispenser(this);
|
|
||||||
for (String key : config.getStringList("exp-sources"))
|
for (String key : config.getStringList("exp-sources"))
|
||||||
try {
|
try {
|
||||||
MMOCore.plugin.experience.registerSource(MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), dispenser));
|
MMOCore.plugin.experience.registerSource(MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), this));
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
MMOCore.plugin.getLogger().log(Level.WARNING,
|
||||||
"Could not register exp source '" + key + "' from profession '" + id + "': " + exception.getMessage());
|
"Could not register exp source '" + key + "' from profession '" + id + "': " + exception.getMessage());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -124,6 +123,18 @@ public class Profession extends PostLoadObject implements ExperienceObject {
|
|||||||
return Objects.requireNonNull(expTable, "Profession has no exp table");
|
return Objects.requireNonNull(expTable, "Profession has no exp table");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void giveExperience(PlayerData playerData, double experience, @Nullable Location hologramLocation, EXPSource source) {
|
||||||
|
hologramLocation = !getOption(Profession.ProfessionOption.EXP_HOLOGRAMS) ? null
|
||||||
|
: hologramLocation;
|
||||||
|
playerData.getCollectionSkills().giveExperience(this, experience, EXPSource.SOURCE, hologramLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldHandle(PlayerData playerData) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static enum ProfessionOption {
|
public static enum ProfessionOption {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package net.Indyuce.mmocore.experience.dispenser;
|
package net.Indyuce.mmocore.experience;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.experience.EXPSource;
|
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class SimpleExperienceDispenser implements ExperienceDispenser {
|
public class SimpleExperienceObject implements ExperienceDispenser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void giveExperience(PlayerData playerData, double experience, @Nullable Location hologramLocation, EXPSource source) {
|
public void giveExperience(PlayerData playerData, double experience, @Nullable Location hologramLocation, EXPSource source) {
|
@ -1,28 +0,0 @@
|
|||||||
package net.Indyuce.mmocore.experience.dispenser;
|
|
||||||
|
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
|
||||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
|
||||||
import net.Indyuce.mmocore.experience.EXPSource;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
public class ClassExperienceDispenser implements ExperienceDispenser {
|
|
||||||
private final PlayerClass profess;
|
|
||||||
|
|
||||||
public ClassExperienceDispenser(PlayerClass profess) {
|
|
||||||
this.profess = profess;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void giveExperience(PlayerData playerData, double experience, @Nullable Location hologramLocation, EXPSource source) {
|
|
||||||
hologramLocation = !MMOCore.plugin.getConfig().getBoolean("display-main-class-exp-holograms") ? null
|
|
||||||
: hologramLocation;
|
|
||||||
playerData.giveExperience(experience, source, hologramLocation, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldHandle(PlayerData playerData) {
|
|
||||||
return playerData.getProfess().equals(profess);
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,15 +12,14 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
* experience given in a specific profession. Also being used to
|
* experience given in a specific profession. Also being used to
|
||||||
* monitor EXP holograms.
|
* monitor EXP holograms.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public interface ExperienceDispenser {
|
public interface ExperienceDispenser {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when experience is gained in main class/profession
|
* Called when experience is gained in main class/profession
|
||||||
*
|
*
|
||||||
* @param playerData Player gaining the experience
|
* @param playerData Player gaining the experience
|
||||||
* @param experience Experience gained. Note that it is a double
|
* @param experience Experience gained
|
||||||
* because it gets converted to an integer at
|
|
||||||
* the very last moment in MMOCore
|
|
||||||
* @param hologramLocation Location of displayed hologram. When set to null
|
* @param hologramLocation Location of displayed hologram. When set to null
|
||||||
* and if exp holograms are enabled it will take the
|
* and if exp holograms are enabled it will take the
|
||||||
* player's location instead.
|
* player's location instead.
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
package net.Indyuce.mmocore.experience.dispenser;
|
|
||||||
|
|
||||||
import net.Indyuce.mmocore.experience.EXPSource;
|
|
||||||
import net.Indyuce.mmocore.experience.Profession;
|
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
public class ProfessionExperienceDispenser implements ExperienceDispenser {
|
|
||||||
private final Profession profession;
|
|
||||||
|
|
||||||
public ProfessionExperienceDispenser(Profession profession) {
|
|
||||||
this.profession = profession;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void giveExperience(PlayerData playerData, double experience, @Nullable Location hologramLocation, EXPSource source) {
|
|
||||||
hologramLocation = !profession.getOption(Profession.ProfessionOption.EXP_HOLOGRAMS) ? null
|
|
||||||
: hologramLocation;
|
|
||||||
playerData.getCollectionSkills().giveExperience(profession, experience, EXPSource.SOURCE, hologramLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldHandle(PlayerData playerData) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user