mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-12-28 05:37:44 +01:00
Fixed XP dupe bug with killmob exp source
This commit is contained in:
parent
1195cd030d
commit
29d6557553
@ -1,10 +1,13 @@
|
||||
package net.Indyuce.mmocore.api.experience.source;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.event.EntityKillEntityEvent;
|
||||
import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmocore.api.experience.source.type.SpecificExperienceSource;
|
||||
@ -25,17 +28,22 @@ public class KillMobExperienceSource extends SpecificExperienceSource<Entity> {
|
||||
@Override
|
||||
public ExperienceManager<KillMobExperienceSource> newManager() {
|
||||
return new ExperienceManager<KillMobExperienceSource>() {
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void a(EntityKillEntityEvent event) {
|
||||
if (event.getEntity() instanceof Player && !event.getEntity().hasMetadata("NPC")) {
|
||||
if(event.getTarget().hasMetadata("spawner_spawned")) return;
|
||||
PlayerData data = PlayerData.get((Player) event.getEntity());
|
||||
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!event.getTarget().isDead()) return;
|
||||
if (event.getEntity() instanceof Player && !event.getEntity().hasMetadata("NPC")) {
|
||||
if(event.getTarget().hasMetadata("spawner_spawned")) return;
|
||||
PlayerData data = PlayerData.get((Player) event.getEntity());
|
||||
|
||||
for (KillMobExperienceSource source : getSources())
|
||||
if (source.matches(data, event.getTarget()))
|
||||
source.giveExperience(data, event.getTarget().getLocation());
|
||||
}
|
||||
for (KillMobExperienceSource source : getSources())
|
||||
if (source.matches(data, event.getTarget()))
|
||||
source.giveExperience(data, event.getTarget().getLocation());
|
||||
}
|
||||
}
|
||||
}, 2);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs.load;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmocore.api.experience.source.type.SpecificExperienceSource;
|
||||
import net.Indyuce.mmocore.api.load.MMOLineConfig;
|
||||
@ -23,16 +25,20 @@ public class KillMythicMobExperienceSource extends SpecificExperienceSource<Stri
|
||||
@Override
|
||||
public ExperienceManager<KillMythicMobExperienceSource> newManager() {
|
||||
return new ExperienceManager<KillMythicMobExperienceSource>() {
|
||||
|
||||
@EventHandler
|
||||
public void a(MythicMobDeathEvent event) {
|
||||
if (!(event.getKiller() instanceof Player))
|
||||
return;
|
||||
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!event.getEntity().isDead()) return;
|
||||
if (!(event.getKiller() instanceof Player)) return;
|
||||
|
||||
PlayerData data = PlayerData.get((Player) event.getKiller());
|
||||
for (KillMythicMobExperienceSource source : getSources())
|
||||
if (source.matches(data, event.getMobType().getInternalName()))
|
||||
source.giveExperience(data, event.getEntity().getLocation());
|
||||
PlayerData data = PlayerData.get((Player) event.getKiller());
|
||||
for (KillMythicMobExperienceSource source : getSources())
|
||||
if (source.matches(data, event.getMobType().getInternalName()))
|
||||
source.giveExperience(data, event.getEntity().getLocation());
|
||||
}
|
||||
}, 2);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user