forked from Upstream/mmocore
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;
|
package net.Indyuce.mmocore.api.experience.source;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
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.event.EntityKillEntityEvent;
|
||||||
import net.Indyuce.mmocore.api.experience.Profession;
|
import net.Indyuce.mmocore.api.experience.Profession;
|
||||||
import net.Indyuce.mmocore.api.experience.source.type.SpecificExperienceSource;
|
import net.Indyuce.mmocore.api.experience.source.type.SpecificExperienceSource;
|
||||||
@ -25,9 +28,12 @@ public class KillMobExperienceSource extends SpecificExperienceSource<Entity> {
|
|||||||
@Override
|
@Override
|
||||||
public ExperienceManager<KillMobExperienceSource> newManager() {
|
public ExperienceManager<KillMobExperienceSource> newManager() {
|
||||||
return new ExperienceManager<KillMobExperienceSource>() {
|
return new ExperienceManager<KillMobExperienceSource>() {
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
@EventHandler
|
|
||||||
public void a(EntityKillEntityEvent event) {
|
public void a(EntityKillEntityEvent event) {
|
||||||
|
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.getEntity() instanceof Player && !event.getEntity().hasMetadata("NPC")) {
|
||||||
if(event.getTarget().hasMetadata("spawner_spawned")) return;
|
if(event.getTarget().hasMetadata("spawner_spawned")) return;
|
||||||
PlayerData data = PlayerData.get((Player) event.getEntity());
|
PlayerData data = PlayerData.get((Player) event.getEntity());
|
||||||
@ -37,6 +43,8 @@ public class KillMobExperienceSource extends SpecificExperienceSource<Entity> {
|
|||||||
source.giveExperience(data, event.getTarget().getLocation());
|
source.giveExperience(data, event.getTarget().getLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}, 2);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package net.Indyuce.mmocore.comp.mythicmobs.load;
|
package net.Indyuce.mmocore.comp.mythicmobs.load;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent;
|
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.Profession;
|
||||||
import net.Indyuce.mmocore.api.experience.source.type.SpecificExperienceSource;
|
import net.Indyuce.mmocore.api.experience.source.type.SpecificExperienceSource;
|
||||||
import net.Indyuce.mmocore.api.load.MMOLineConfig;
|
import net.Indyuce.mmocore.api.load.MMOLineConfig;
|
||||||
@ -23,17 +25,21 @@ public class KillMythicMobExperienceSource extends SpecificExperienceSource<Stri
|
|||||||
@Override
|
@Override
|
||||||
public ExperienceManager<KillMythicMobExperienceSource> newManager() {
|
public ExperienceManager<KillMythicMobExperienceSource> newManager() {
|
||||||
return new ExperienceManager<KillMythicMobExperienceSource>() {
|
return new ExperienceManager<KillMythicMobExperienceSource>() {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void a(MythicMobDeathEvent event) {
|
public void a(MythicMobDeathEvent event) {
|
||||||
if (!(event.getKiller() instanceof Player))
|
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, new Runnable() {
|
||||||
return;
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!event.getEntity().isDead()) return;
|
||||||
|
if (!(event.getKiller() instanceof Player)) return;
|
||||||
|
|
||||||
PlayerData data = PlayerData.get((Player) event.getKiller());
|
PlayerData data = PlayerData.get((Player) event.getKiller());
|
||||||
for (KillMythicMobExperienceSource source : getSources())
|
for (KillMythicMobExperienceSource source : getSources())
|
||||||
if (source.matches(data, event.getMobType().getInternalName()))
|
if (source.matches(data, event.getMobType().getInternalName()))
|
||||||
source.giveExperience(data, event.getEntity().getLocation());
|
source.giveExperience(data, event.getEntity().getLocation());
|
||||||
}
|
}
|
||||||
|
}, 2);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user