From e3d1af010b72a767d84106be622dd8f29e8f2d44 Mon Sep 17 00:00:00 2001 From: Jikoo Date: Sun, 5 Nov 2017 20:00:22 -0500 Subject: [PATCH] Add permissions to alter the default state of Any/SilentChest (#76) --- .gitignore | 1 + .../main/java/com/lishid/openinv/OpenInv.java | 22 +++++++++++++++++-- .../plugin-core/src/main/resources/plugin.yml | 22 ++++++++++++++----- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 5fd7686..dff1661 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ **/.project **/.classpath **/.idea +**/.iml **/target **/bin **/out diff --git a/plugin/plugin-core/src/main/java/com/lishid/openinv/OpenInv.java b/plugin/plugin-core/src/main/java/com/lishid/openinv/OpenInv.java index 723e7a6..19489a2 100644 --- a/plugin/plugin-core/src/main/java/com/lishid/openinv/OpenInv.java +++ b/plugin/plugin-core/src/main/java/com/lishid/openinv/OpenInv.java @@ -271,7 +271,16 @@ public class OpenInv extends JavaPlugin implements IOpenInv { @Override public boolean getPlayerAnyChestStatus(final OfflinePlayer player) { - return this.getConfig().getBoolean("toggles.any-chest." + this.accessor.getPlayerDataManager().getPlayerDataID(player), false); + boolean defaultState = false; + + if (player.isOnline()) { + Player onlinePlayer = player.getPlayer(); + if (onlinePlayer != null) { + defaultState = onlinePlayer.hasPermission("openinv.anychest.default"); + } + } + + return this.getConfig().getBoolean("toggles.any-chest." + this.accessor.getPlayerDataManager().getPlayerDataID(player), defaultState); } @Override @@ -281,7 +290,16 @@ public class OpenInv extends JavaPlugin implements IOpenInv { @Override public boolean getPlayerSilentChestStatus(final OfflinePlayer player) { - return this.getConfig().getBoolean("toggles.silent-chest." + this.accessor.getPlayerDataManager().getPlayerDataID(player), false); + boolean defaultState = false; + + if (player.isOnline()) { + Player onlinePlayer = player.getPlayer(); + if (onlinePlayer != null) { + defaultState = onlinePlayer.hasPermission("openinv.silentchest.default"); + } + } + + return this.getConfig().getBoolean("toggles.silent-chest." + this.accessor.getPlayerDataManager().getPlayerDataID(player), defaultState); } @Override diff --git a/plugin/plugin-core/src/main/resources/plugin.yml b/plugin/plugin-core/src/main/resources/plugin.yml index 85dad27..afc4b56 100644 --- a/plugin/plugin-core/src/main/resources/plugin.yml +++ b/plugin/plugin-core/src/main/resources/plugin.yml @@ -5,6 +5,16 @@ author: lishid authors: [Jikoo, ShadowRanger] description: > This plugin allows you to open a player's inventory as a chest and interact with it in real time. + +permissions: + openinv: + anychest.default: + description: Permission for AnyContainer to default on prior to toggling. + default: false + silentchest.default: + description: Permission for SilentChest to default on prior to toggling. + default: false + commands: openinv: aliases: [oi, inv, open] @@ -31,15 +41,15 @@ commands: usage: |- / [MinAmount] - Item is the ID or the Bukkit Material, MinAmount is the minimum amount required silentchest: - aliases: [sc, silent] - description: Toggle silent chest function, which stops sounds and animations when using containers. + aliases: [sc, silent, silentcontainer] + description: Toggle SilentContainer function, which stops sounds and animations when using containers. permission: OpenInv.*;OpenInv.silent usage: |- / [Check] - Check or toggle silent chest - anychest: - aliases: [ac] - description: Toggle anychest function, which allows opening of blocked chests. - permission: OpenInv.*;OpenInv.anychest + anycontainer: + aliases: [ac, anychest] + description: Toggle AnyContainer function, which allows opening of blocked containers. + permission: OpenInv.*;OpenInv.anychest;OpenInv.anycontainer usage: |- / [Check] - Checks or toggle anychest searchenchant: