Fixed keep-inventory & keep-exp has no effect is set to false

This commit is contained in:
isokissa3 2019-03-13 01:00:31 +02:00
parent c4b229e137
commit c2a0b0fd32

View file

@ -53,19 +53,27 @@ public class PlayerListener implements Listener
ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation()); ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation());
Boolean keepInventory = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.KEEP_INVENTORY); Boolean keepInventory = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.KEEP_INVENTORY);
if (Boolean.TRUE.equals(keepInventory)) if (keepInventory != null)
{
event.setKeepInventory(keepInventory);
if (keepInventory)
{ {
event.setKeepInventory(true);
event.getDrops().clear(); event.getDrops().clear();
} }
}
Boolean keepExp = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.KEEP_EXP); Boolean keepExp = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.KEEP_EXP);
if (Boolean.TRUE.equals(keepExp)) if (keepExp != null)
{
event.setKeepLevel(keepExp);
if (keepExp)
{ {
event.setKeepLevel(true);
event.setDroppedExp(0); event.setDroppedExp(0);
} }
} }
}
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event) public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)