mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-31 21:06:38 +00:00
unapply on death settings
This commit is contained in:
@@ -27,6 +27,7 @@ public class Settings {
|
||||
private static final String DYE_MENU_NAME = "title";
|
||||
private static final String DEBUG_ENABLE_PETH = "debug-mode";
|
||||
private static final String TICK_PERIOD_PATH = "tick-period";
|
||||
private static final String UNAPPLY_DEATH_PATH = "unapply-on-death";
|
||||
|
||||
private static String defaultMenu;
|
||||
private static String dyeMenuName;
|
||||
@@ -37,6 +38,7 @@ public class Settings {
|
||||
private static boolean requireEmptyPants;
|
||||
private static boolean requireEmptyBoots;
|
||||
private static boolean debugMode;
|
||||
private static boolean unapplyOnDeath;
|
||||
private static int lookDownPitch;
|
||||
private static int viewDistance;
|
||||
private static int tickPeriod;
|
||||
@@ -64,6 +66,7 @@ public class Settings {
|
||||
requireEmptyChestPlate = cosmeticSettings.node(REQUIRE_EMPTY_CHEST_PLATE_PATH).getBoolean();
|
||||
requireEmptyPants = cosmeticSettings.node(REQUIRE_EMPTY_PANTS_PATH).getBoolean();
|
||||
requireEmptyBoots = cosmeticSettings.node(REQUIRE_EMPTY_BOOTS_PATH).getBoolean();
|
||||
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
|
||||
|
||||
tickPeriod = cosmeticSettings.node(TICK_PERIOD_PATH).getInt(-1);
|
||||
lookDownPitch = cosmeticSettings.node(LOOK_DOWN_PITCH_PATH).getInt();
|
||||
@@ -177,4 +180,7 @@ public class Settings {
|
||||
public static int getTickPeriod() {
|
||||
return tickPeriod;
|
||||
}
|
||||
public static boolean getUnapplyOnDeath() {
|
||||
return unapplyOnDeath;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
@@ -208,6 +209,16 @@ public class PlayerGameListener implements Listener {
|
||||
}, 2);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getEntity());
|
||||
if (user == null) return;
|
||||
|
||||
if (Settings.getUnapplyOnDeath() && !event.getEntity().hasPermission("hmccosmetics.unapplydeath.bypass")) {
|
||||
user.removeCosmetics();
|
||||
}
|
||||
}
|
||||
|
||||
private void registerInventoryClickListener() {
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) {
|
||||
@Override
|
||||
|
||||
@@ -136,6 +136,13 @@ public class CosmeticUser {
|
||||
addPlayerCosmetic(cosmetic);
|
||||
}
|
||||
|
||||
public void removeCosmetics() {
|
||||
for (Cosmetic cosmetic : getCosmetic()) {
|
||||
removeCosmeticSlot(cosmetic.getSlot());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void removeCosmeticSlot(CosmeticSlot slot) {
|
||||
// API
|
||||
PlayerCosmeticRemoveEvent event = new PlayerCosmeticRemoveEvent(this, getCosmetic(slot));
|
||||
|
||||
Reference in New Issue
Block a user