mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-26 00:35:17 +01:00
Fixed exp resetting on death
This commit is contained in:
parent
dbe5aa5fab
commit
160c5d5699
@ -8,7 +8,9 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.enchantment.EnchantItemEvent;
|
import org.bukkit.event.enchantment.EnchantItemEvent;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.player.PlayerExpChangeEvent;
|
import org.bukkit.event.player.PlayerExpChangeEvent;
|
||||||
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
|
||||||
public class VanillaExperienceOverride implements Listener {
|
public class VanillaExperienceOverride implements Listener {
|
||||||
|
|
||||||
@ -16,10 +18,20 @@ public class VanillaExperienceOverride implements Listener {
|
|||||||
* When picking up exp orbs or any action like that
|
* When picking up exp orbs or any action like that
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void a(PlayerExpChangeEvent event) {
|
public void cancelChange(PlayerExpChangeEvent event) {
|
||||||
event.setAmount(0);
|
event.setAmount(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
public void cancelDrop(PlayerDeathEvent event) {
|
||||||
|
event.setDroppedExp(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
public void cancelChange(PlayerRespawnEvent event) {
|
||||||
|
Bukkit.getScheduler().runTask(MMOCore.plugin, () -> PlayerData.get(event.getPlayer()).refreshVanillaExp());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is not supported by the expChangeEvent. Since the event is
|
* This event is not supported by the expChangeEvent. Since the event is
|
||||||
* actually called before applying the enchant and consuming levels, we must
|
* actually called before applying the enchant and consuming levels, we must
|
||||||
@ -28,7 +40,7 @@ public class VanillaExperienceOverride implements Listener {
|
|||||||
* {@link EnchantItemEvent#setExpLevelCost(int)} does NOT work
|
* {@link EnchantItemEvent#setExpLevelCost(int)} does NOT work
|
||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void b(EnchantItemEvent event) {
|
public void cancelChange(EnchantItemEvent event) {
|
||||||
Player player = event.getEnchanter();
|
Player player = event.getEnchanter();
|
||||||
Bukkit.getScheduler().runTask(MMOCore.plugin, () -> player.setLevel(PlayerData.get(player).getLevel()));
|
Bukkit.getScheduler().runTask(MMOCore.plugin, () -> player.setLevel(PlayerData.get(player).getLevel()));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user