From 40e2bf0ee80db7b8bec704fd8cf6b02867e2d911 Mon Sep 17 00:00:00 2001 From: Heliosares Date: Sat, 22 Oct 2022 08:39:54 -0400 Subject: [PATCH] 1.2-pre2 Add option to change when a:inventory is logged --- pom.xml | 2 +- src/dev/heliosares/auxprotect/core/APConfig.java | 3 +++ .../heliosares/auxprotect/database/EntryAction.java | 10 ++++++++++ .../auxprotect/spigot/listeners/EntityListener.java | 13 +++++++++++-- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index e93acc7..7a1d8f8 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 AuxProtect AuxProtect - 1.2-pre1 + 1.2-pre2 AuxProtect ${project.artifactId}-${project.version} diff --git a/src/dev/heliosares/auxprotect/core/APConfig.java b/src/dev/heliosares/auxprotect/core/APConfig.java index 7895d0d..e078a1b 100644 --- a/src/dev/heliosares/auxprotect/core/APConfig.java +++ b/src/dev/heliosares/auxprotect/core/APConfig.java @@ -60,7 +60,10 @@ public class APConfig { skipV6Migration = config.getBoolean("skipv6migration"); for (EntryAction action : EntryAction.values()) { boolean enabled = config.getBoolean("Actions." + action.toString().toLowerCase() + ".Enabled", true); + boolean priority = config.getBoolean("Actions." + action.toString().toLowerCase() + ".LowestPriority", + false); action.setEnabled(enabled); + action.setLowestpriority(priority); } overrideCommands = config.getBoolean("OverrideCommands"); } diff --git a/src/dev/heliosares/auxprotect/database/EntryAction.java b/src/dev/heliosares/auxprotect/database/EntryAction.java index 5392c15..78dd541 100644 --- a/src/dev/heliosares/auxprotect/database/EntryAction.java +++ b/src/dev/heliosares/auxprotect/database/EntryAction.java @@ -107,6 +107,7 @@ public class EntryAction { public final int idPos; public final String name; private boolean enabled; + private boolean lowestpriority; private String overridePText; private String overrideNText; @@ -256,4 +257,13 @@ public class EntryAction { EntryAction other = (EntryAction) other_; return this.id == other.id && this.idPos == other.idPos; } + + public boolean isLowestpriority() { + return lowestpriority; + } + + public void setLowestpriority(boolean lowestpriority) { + this.lowestpriority = lowestpriority; + } + } diff --git a/src/dev/heliosares/auxprotect/spigot/listeners/EntityListener.java b/src/dev/heliosares/auxprotect/spigot/listeners/EntityListener.java index d35b11d..16968b0 100644 --- a/src/dev/heliosares/auxprotect/spigot/listeners/EntityListener.java +++ b/src/dev/heliosares/auxprotect/spigot/listeners/EntityListener.java @@ -218,9 +218,18 @@ public class EntityListener implements Listener { plugin.add(entry); } + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onPlayerDeathLowest(PlayerDeathEvent e) { + if (EntryAction.INVENTORY.isLowestpriority()) { + plugin.getAPPlayer(e.getEntity()).logInventory("death"); + } + } + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onPlayerDeath(PlayerDeathEvent e) { - plugin.getAPPlayer(e.getEntity()).logInventory("death"); + public void onPlayerDeathMonitor(PlayerDeathEvent e) { + if (!EntryAction.INVENTORY.isLowestpriority()) { + plugin.getAPPlayer(e.getEntity()).logInventory("death"); + } } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)