mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-27 00:45:40 +01:00
New disp name option for killmob exp source
This commit is contained in:
parent
bd1b40f1da
commit
95ea032dfa
@ -1,12 +1,13 @@
|
||||
package net.Indyuce.mmocore.experience.source;
|
||||
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import io.lumine.mythic.lib.api.event.PlayerKillEntityEvent;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
|
||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
|
||||
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
|
||||
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.NamespacedKey;
|
||||
@ -16,19 +17,26 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class KillMobExperienceSource extends SpecificExperienceSource<Entity> {
|
||||
public final EntityType type;
|
||||
private final EntityType type;
|
||||
|
||||
@Nullable
|
||||
private final String displayName;
|
||||
|
||||
public KillMobExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
|
||||
super(dispenser, config);
|
||||
|
||||
config.validate("type");
|
||||
config.validateKeys("type");
|
||||
displayName = config.contains("name") ? MythicLib.plugin.parseColors(config.getString("name")) : null;
|
||||
type = EntityType.valueOf(config.getString("type").toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExperienceSourceManager<KillMobExperienceSource> newManager() {
|
||||
return new ExperienceSourceManager<KillMobExperienceSource>() {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void a(PlayerKillEntityEvent event) {
|
||||
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> {
|
||||
@ -46,6 +54,6 @@ public class KillMobExperienceSource extends SpecificExperienceSource<Entity> {
|
||||
|
||||
@Override
|
||||
public boolean matchesParameter(PlayerData player, Entity obj) {
|
||||
return obj.getType() == type;
|
||||
return obj.getType() == type && (displayName == null || displayName.equals(obj.getCustomName()));
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class SpecificExperienceSource<T> extends ExperienceSource<T> {
|
||||
private final RandomAmount amount;
|
||||
double counter = 0;
|
||||
|
||||
/**
|
||||
* Used to register experience sources with SPECIFIC experience outputs.
|
||||
@ -20,21 +19,22 @@ public abstract class SpecificExperienceSource<T> extends ExperienceSource<T> {
|
||||
public SpecificExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
|
||||
super(dispenser);
|
||||
|
||||
config.validate("amount");
|
||||
config.validateKeys("amount");
|
||||
amount = new RandomAmount(config.getString("amount"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used for FromExperienceSource
|
||||
*
|
||||
* @param dispenser
|
||||
*/
|
||||
public SpecificExperienceSource(ExperienceDispenser dispenser) {
|
||||
super(dispenser);
|
||||
|
||||
amount = new RandomAmount(0, 0);
|
||||
}
|
||||
|
||||
|
||||
public RandomAmount getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user