From a654ac51e5de1eb2318fed9fa3854323170374b2 Mon Sep 17 00:00:00 2001 From: Derek <70810073+Invvk@users.noreply.github.com> Date: Sun, 31 Oct 2021 03:27:37 -0700 Subject: [PATCH] PWI patch --- .../github/invvk/wgef/listeners/DeathListener.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/WGEF-Core/src/main/java/io/github/invvk/wgef/listeners/DeathListener.java b/WGEF-Core/src/main/java/io/github/invvk/wgef/listeners/DeathListener.java index 2990883..5ebcfb5 100644 --- a/WGEF-Core/src/main/java/io/github/invvk/wgef/listeners/DeathListener.java +++ b/WGEF-Core/src/main/java/io/github/invvk/wgef/listeners/DeathListener.java @@ -4,8 +4,10 @@ import io.github.invvk.wgef.WGEFPlugin; import io.github.invvk.wgef.abstraction.WGEFUtils; import io.github.invvk.wgef.abstraction.flags.WGEFlags; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.PlayerDeathEvent; @@ -17,7 +19,7 @@ public DeathListener(WGEFPlugin plugin) { this.plugin = plugin; } - @EventHandler + @EventHandler(priority = EventPriority.LOW) public void onPlayerDeathEvent(PlayerDeathEvent event) { Player player = event.getEntity(); @@ -31,12 +33,20 @@ public void onPlayerDeathEvent(PlayerDeathEvent event) { event.getDrops().clear(); } } + } + @EventHandler(priority = EventPriority.LOWEST) + public void onDeath(PlayerDeathEvent event) { + final Player player = event.getEntity(); + ApplicableRegionSet regions = this.plugin.getFork().getRegionContainer().createQuery().getApplicableRegions(player.getLocation()); Boolean keepExp = WGEFUtils.queryValue(player, player.getWorld(), regions.getRegions(), WGEFlags.KEEP_EXP); if (keepExp != null) { event.setKeepLevel(keepExp); - if (keepExp) { + if (Bukkit.getPluginManager().getPlugin("PerWorldInventory") != null) { + event.setNewExp(event.getDroppedExp()); + event.setNewLevel(player.getLevel()); + } event.setDroppedExp(0); } }