Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

Commit

Permalink
PWI patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Invvk committed Oct 31, 2021
1 parent 733226a commit a654ac5
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();

Expand All @@ -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);
}
}
Expand Down

0 comments on commit a654ac5

Please sign in to comment.