mirror of
https://github.com/TotalFreedomMC/OpenInv.git
synced 2024-12-23 00:15:08 +00:00
Lowercase permissions can wait for a major version bump
I don't want to double our permissions checks for backwards compatibility.
This commit is contained in:
parent
48c61eeb82
commit
cbb2b4d232
3 changed files with 67 additions and 41 deletions
35
README.MD
35
README.MD
|
@ -11,8 +11,8 @@ OpenInv is a [Bukkit plugin](https://dev.bukkit.org/bukkit-plugins/openinv/) whi
|
||||||
- Read-only mode! No edits allowed! Don't grant `OpenInv.editender`
|
- Read-only mode! No edits allowed! Don't grant `OpenInv.editender`
|
||||||
- Cross-world support! Don't grant `OpenInv.crossworld`
|
- Cross-world support! Don't grant `OpenInv.crossworld`
|
||||||
- No opening others! Don't grant `OpenInv.openenderall`
|
- No opening others! Don't grant `OpenInv.openenderall`
|
||||||
- **SilentChest**: Open containers without displaying an animation or making sound.
|
- **SilentContainer**: Open containers without displaying an animation or making sound.
|
||||||
- **AnyChest**: Open containers, even if blocked by ocelots or blocks.
|
- **AnyContainer**: Open containers, even if blocked by ocelots or blocks.
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
<table width=100%>
|
<table width=100%>
|
||||||
|
@ -42,14 +42,19 @@ OpenInv is a [Bukkit plugin](https://dev.bukkit.org/bukkit-plugins/openinv/) whi
|
||||||
<td>Lists all online players that have a certain item in their ender chest.</td>
|
<td>Lists all online players that have a certain item in their ender chest.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>/anychest [check]</td>
|
<td>/searchenchant <[enchantment] [MinLevel]></td>
|
||||||
<td>ac</td>
|
<td>searchenchants</td>
|
||||||
<td>Check or toggle the AnyChest function, allowing opening blocked containers.</td>
|
<td>Lists all online players with a specific enchantment.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>/silentchest [check]</td>
|
<td>/anycontainer [check]</td>
|
||||||
<td>sc</td>
|
<td>ac, anychest</td>
|
||||||
<td>Check or toggle the SilentChest function, allowing opening containers silently.</td>
|
<td>Check or toggle the AnyContainer function, allowing opening blocked containers.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>/silentcontainer [check]</td>
|
||||||
|
<td>sc, silentchest</td>
|
||||||
|
<td>Check or toggle the SilentContainer function, allowing opening containers silently.</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@ -103,13 +108,25 @@ OpenInv is a [Bukkit plugin](https://dev.bukkit.org/bukkit-plugins/openinv/) whi
|
||||||
<td>OpenInv.search</td>
|
<td>OpenInv.search</td>
|
||||||
<td>Required to use /searchinv and /searchender.</td>
|
<td>Required to use /searchinv and /searchender.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>OpenInv.searchenchant</td>
|
||||||
|
<td>Required to use /searchenchant.</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>OpenInv.anychest</td>
|
<td>OpenInv.anychest</td>
|
||||||
<td>Required to use /anychest.</td>
|
<td>Required to use /anychest.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>OpenInv.any.default</td>
|
||||||
|
<td>Cause AnyContainer to be enabled by default.</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>OpenInv.silent</td>
|
<td>OpenInv.silent</td>
|
||||||
<td>Required to use /silentchest.</td>
|
<td>Required to use /silentcontainer.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>OpenInv.silent.default</td>
|
||||||
|
<td>Cause SilentContainer to be enabled by default.</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
|
@ -4,35 +4,44 @@ import org.bukkit.permissions.Permissible;
|
||||||
|
|
||||||
public enum Permissions {
|
public enum Permissions {
|
||||||
|
|
||||||
OPENINV("OpenInv.openinv"),
|
OPENINV("openinv"),
|
||||||
OVERRIDE("OpenInv.override"),
|
OVERRIDE("override"),
|
||||||
EXEMPT("OpenInv.exempt"),
|
EXEMPT("exempt"),
|
||||||
CROSSWORLD("OpenInv.crossworld"),
|
CROSSWORLD("crossworld"),
|
||||||
SILENT("OpenInv.silent"),
|
SILENT("silent"),
|
||||||
ANYCHEST("OpenInv.anychest"),
|
ANYCHEST("anychest"),
|
||||||
ENDERCHEST("OpenInv.openender"),
|
ENDERCHEST("openender"),
|
||||||
ENDERCHEST_ALL("OpenInv.openenderall"),
|
ENDERCHEST_ALL("openenderall"),
|
||||||
SEARCH("OpenInv.search"),
|
SEARCH("search"),
|
||||||
EDITINV("OpenInv.editinv"),
|
EDITINV("editinv"),
|
||||||
EDITENDER("OpenInv.editender"),
|
EDITENDER("editender"),
|
||||||
OPENSELF("OpenInv.openself");
|
OPENSELF("openself");
|
||||||
|
|
||||||
private final String permission;
|
private final String[] permission;
|
||||||
|
|
||||||
private Permissions(String permission) {
|
Permissions(String... permission) {
|
||||||
this.permission = permission;
|
this.permission = new String[permission.length + 1];
|
||||||
|
this.permission[0] = "OpenInv";
|
||||||
|
System.arraycopy(permission, 0, permission, 1, permission.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(Permissible permissible) {
|
public boolean hasPermission(Permissible permissible) {
|
||||||
String[] parts = permission.split("\\.");
|
StringBuilder permissionBuilder = new StringBuilder();
|
||||||
String perm = "";
|
|
||||||
for (int i = 0; i < parts.length; i++) {
|
// Support wildcard nodes.
|
||||||
if (permissible.hasPermission(perm + "*")) {
|
for (int i = 0; i < permission.length; i++) {
|
||||||
|
if (permissible.hasPermission(permissionBuilder.toString() + "*")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
perm += parts[i] + ".";
|
permissionBuilder.append(permission[i]).append('.');
|
||||||
}
|
}
|
||||||
return permissible.hasPermission(permission);
|
|
||||||
|
// Delete trailing period.
|
||||||
|
if (permissionBuilder.length() > 0) {
|
||||||
|
permissionBuilder.deleteCharAt(permissionBuilder.length() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return permissible.hasPermission(permissionBuilder.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,10 @@ description: >
|
||||||
This plugin allows you to open a player's inventory as a chest and interact with it in real time.
|
This plugin allows you to open a player's inventory as a chest and interact with it in real time.
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
openinv.any.default:
|
OpenInv.any.default:
|
||||||
description: Permission for AnyContainer to default on prior to toggling.
|
description: Permission for AnyContainer to default on prior to toggling.
|
||||||
default: false
|
default: false
|
||||||
openinv.silent.default:
|
OpenInv.silent.default:
|
||||||
description: Permission for SilentContainer to default on prior to toggling.
|
description: Permission for SilentContainer to default on prior to toggling.
|
||||||
default: false
|
default: false
|
||||||
|
|
||||||
|
@ -18,42 +18,42 @@ commands:
|
||||||
openinv:
|
openinv:
|
||||||
aliases: [oi, inv, open]
|
aliases: [oi, inv, open]
|
||||||
description: Open a player's inventory
|
description: Open a player's inventory
|
||||||
permission: OpenInv.*;OpenInv.openinv;openinv.*;openinv.openinv
|
permission: OpenInv.*;OpenInv.openinv
|
||||||
usage: |-
|
usage: |-
|
||||||
/<command> [Player] - Open a player's inventory
|
/<command> [Player] - Open a player's inventory
|
||||||
openender:
|
openender:
|
||||||
aliases: [oe]
|
aliases: [oe]
|
||||||
description: Opens the enderchest of a player
|
description: Opens the enderchest of a player
|
||||||
permission: OpenInv.*;OpenInv.openender;openinv.*;openinv.openender
|
permission: OpenInv.*;OpenInv.openender
|
||||||
usage: |-
|
usage: |-
|
||||||
/<command> [Player] - Open a player's enderchest
|
/<command> [Player] - Open a player's enderchest
|
||||||
searchinv:
|
searchinv:
|
||||||
aliases: [si]
|
aliases: [si]
|
||||||
description: Search and list players having a specific item
|
description: Search and list players having a specific item
|
||||||
permission: OpenInv.*;OpenInv.search;openinv.*;openinv.search
|
permission: OpenInv.*;OpenInv.search
|
||||||
usage: |-
|
usage: |-
|
||||||
/<command> <Item> [MinAmount] - Item is the ID or the Bukkit Material, MinAmount is the minimum amount required
|
/<command> <Item> [MinAmount] - Item is the ID or the Bukkit Material, MinAmount is the minimum amount required
|
||||||
searchender:
|
searchender:
|
||||||
aliases: [se]
|
aliases: [se]
|
||||||
permission: OpenInv.*;OpenInv.search;openinv.*;openinv.search
|
permission: OpenInv.*;OpenInv.search
|
||||||
description: Searches and lists players having a specific item in their ender chest
|
description: Searches and lists players having a specific item in their ender chest
|
||||||
usage: |-
|
usage: |-
|
||||||
/<command> <item> [MinAmount] - Item is the ID or the Bukkit Material, MinAmount is the minimum amount required
|
/<command> <item> [MinAmount] - Item is the ID or the Bukkit Material, MinAmount is the minimum amount required
|
||||||
silentcontainer:
|
silentcontainer:
|
||||||
aliases: [sc, silent, silentchest]
|
aliases: [sc, silent, silentchest]
|
||||||
description: Toggle SilentContainer function, which stops sounds and animations when using containers.
|
description: Toggle SilentContainer function, which stops sounds and animations when using containers.
|
||||||
permission: OpenInv.*;OpenInv.silent;openinv.*;openinv.silent
|
permission: OpenInv.*;OpenInv.silent
|
||||||
usage: |-
|
usage: |-
|
||||||
/<command> [Check] - Check or toggle silent chest
|
/<command> [Check] - Check or toggle silent chest
|
||||||
anycontainer:
|
anycontainer:
|
||||||
aliases: [ac, anychest]
|
aliases: [ac, anychest]
|
||||||
description: Toggle AnyContainer function, which allows opening of blocked containers.
|
description: Toggle AnyContainer function, which allows opening of blocked containers.
|
||||||
permission: OpenInv.*;OpenInv.anychest;openinv.*;openinv.any
|
permission: OpenInv.*;OpenInv.anychest
|
||||||
usage: |-
|
usage: |-
|
||||||
/<command> [Check] - Checks or toggle anychest
|
/<command> [Check] - Checks or toggle anychest
|
||||||
searchenchant:
|
searchenchant:
|
||||||
aliases: [searchenchants]
|
aliases: [searchenchants]
|
||||||
description: Search and list players with a specific enchantment.
|
description: Search and list players with a specific enchantment.
|
||||||
permission: OpenInv.*;OpenInv.searchenchant;openinv.*;openinv.searchenchant
|
permission: OpenInv.*;OpenInv.searchenchant
|
||||||
usage: |-
|
usage: |-
|
||||||
/<command> <[enchantment] [MinLevel]> - Enchantment is the enchantment type, MinLevel is the minimum level. One is optional
|
/<command> <[enchantment] [MinLevel]> - Enchantment is the enchantment type, MinLevel is the minimum level. One is optional
|
||||||
|
|
Loading…
Reference in a new issue