Add new config option (HonorKeepInventoryOnDeath)

This commit is contained in:
GeorgH93 2020-06-07 21:55:47 +02:00
parent daa98edb6d
commit 34b1aa9cb2
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
4 changed files with 17 additions and 4 deletions

View File

@ -17,6 +17,9 @@ BackpackTitle: "&bBackpack"
# Defines if the content of the backpack get dropped on the death of a player.
# If enabled, it can be disabled for individual players with the "backpack.keepOnDeath" permission.
DropOnDeath: true
# If this option is enabled the backpack will not drop if the keepInventory flag for the death event is set.
# This should add compatibility with plugins protecting the players inventory on death (like SaveRod). But might prevent the backpack form dropping on death with some plugins.
HonorKeepInventoryOnDeath: false
# Defines the max amount of columns for a backpack.
# The size of the user's backpack will be defined by the permission, permissions for bigger backpacks than this value will be ignored.
# Can be set to anything > 0. Backpacks with more than 6 columns will have a broken UI! Sizes bigger than 9 may not work with all permission plugins.
@ -212,4 +215,4 @@ Misc:
UseBungeeCord: false
# Config file version. Don't touch it!
Version: 31
Version: 32

View File

@ -36,7 +36,7 @@
public class Config extends Configuration implements DatabaseConnectionConfiguration
{
private static final int CONFIG_VERSION = 31, UPGRADE_THRESHOLD = CONFIG_VERSION, PRE_V2_VERSION = 20;
private static final int CONFIG_VERSION = 32, UPGRADE_THRESHOLD = CONFIG_VERSION, PRE_V2_VERSION = 20;
public Config(JavaPlugin plugin)
{
@ -165,6 +165,11 @@ public boolean getDropOnDeath()
return getConfigE().getBoolean("DropOnDeath", true);
}
public boolean getHonorKeepInventoryOnDeath()
{
return getConfigE().getBoolean("HonorKeepInventoryOnDeath", false);
}
public int getBackpackMaxSize()
{
int size = getConfigE().getInt("MaxSize", 6);

View File

@ -26,18 +26,23 @@
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PlayerDeathEvent;
public class DropOnDeath extends MinepacksListener
{
private final boolean honorKeepOnDeath;
public DropOnDeath(Minepacks plugin)
{
super(plugin);
honorKeepOnDeath = plugin.getConfiguration().getHonorKeepInventoryOnDeath();
}
@EventHandler
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onDeath(PlayerDeathEvent event)
{
if(honorKeepOnDeath && event.getKeepInventory()) return;
final Player player = event.getEntity();
if(plugin.isDisabled(player) != WorldBlacklistMode.None) return;
if (!player.hasPermission(Permissions.KEEP_ON_DEATH))

View File

@ -7,7 +7,7 @@
<packaging>pom</packaging>
<properties>
<revision>2.3.8</revision>
<revision>2.3.9-RC1</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>