2.7.0_Snapshot-3 | Perm Update

Removed permissiond regestration from plugin.yml and regestred via code.
- The Slot See and Use Permissions are now included in OP and commandgui.admin
This commit is contained in:
JaTiTV 2022-04-19 09:22:56 +02:00
parent 8e90aee0ca
commit 520df8dc97
4 changed files with 111 additions and 62 deletions

View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId>
<artifactId>CommandGUI_V2</artifactId>
<version>2.7.0_Snapshot-2</version>
<version>2.7.0_Snapshot-3</version>
<packaging>jar</packaging>
<name>CommandGUI</name>

View File

@ -31,9 +31,6 @@ public class Help {
if (sender.hasPermission("commandgui.command.info")) {
send.sender(sender, Prefix + " " + SelectMessages.HelpInfo);
}
// if (sender.hasPermission("commandgui.command.give")) {
// send.sender(sender, Prefix + " " + Select_msg.HelpGive);
// }
if (sender.hasPermission("commandgui.admin")) {
send.sender(sender, Prefix + " " + SelectMessages.HelpCreateDefaultGUI.replace("[directory]", Main.getPath()+ "\\GUIs\\default.yml"));
send.sender(sender, Prefix + " " + SelectMessages.HelpReload);

View File

@ -4,22 +4,76 @@ import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
import de.jatitv.commandguiv2.Spigot.objects.slots.Slot;
import net.t2code.lib.Spigot.Lib.register.Register;
import org.bukkit.Bukkit;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.Plugin;
public class RegisterPermissions {
private static final Plugin plugin = Main.plugin;
public static final String key = "commandgui.";
public static final String command = key + "command";
public static final String info = key + "command.info";
public static final String bypass = key + "bypass";
public static final String useitemToggle = key + "useitem.toggle";
public static final String useitem = key + "useitem";
public static final String getGuiItemAtLogin = key + "get.guiitem.at.login";
public static final String updatemsg = key + "updatemsgupdatemsg";
public static final String player = key + "player";
public static final String admin = key + "admin";
public static final PermissionDefault op = PermissionDefault.OP;
public static final PermissionDefault notOp = PermissionDefault.NOT_OP;
public static void onPermRegister() {
Register.permission(command, op, plugin);
Register.permissionDescription(command, "Required permission to open GUIs via command", plugin);
Register.permission(getGuiItemAtLogin, op, plugin);
Register.permissionDescription(getGuiItemAtLogin, "Only players with this permission will receive the GUI item", plugin);
Register.permission(useitem, op, plugin);
Register.permissionDescription(useitem, "Required permission to use the GUI Item", plugin);
Register.permission(useitemToggle, op, plugin);
Register.permissionDescription(useitemToggle, "Required permission to enable/disable the GUI Item for itself (if the function UseItem/AllowToggle is set to true)", plugin);
Register.permission(updatemsg, op, plugin);
Register.permissionDescription(updatemsg, "Players with this permission get the update message when joining if an update is available", plugin);
Register.permission(bypass, op, plugin);
Register.permissionDescription(bypass, "Bypass to open disabled GUIs", plugin);
Register.permission(info, notOp, plugin);
Register.permissionDescription(info, "Permission to view CommandGUI info", plugin);
Register.permission(player, op, command, true, plugin);
Register.permission(player, op, getGuiItemAtLogin, true, plugin);
Register.permission(player, op, useitem, true, plugin);
Register.permission(player, op, useitemToggle, true, plugin);
Register.permissionDescription(player, "All permissions from CommandGUI for Player", plugin);
Register.permission(admin, op, command, true, plugin);
Register.permission(admin, op, getGuiItemAtLogin, true, plugin);
Register.permission(admin, op, useitem, true, plugin);
Register.permission(admin, op, useitemToggle, true, plugin);
Register.permission(admin, op, updatemsg, true, plugin);
Register.permission(admin, op, bypass, true, plugin);
Register.permission(admin, op, info, true, plugin);
Register.permissionDescription(admin, "All permissions from CommandGUI", plugin);
for (Gui gui : Main.guiHashMap.values()) {
if (Bukkit.getPluginManager().getPermission("commandgui.command." + gui.Command_Command) == null) {
Bukkit.getPluginManager().addPermission(new Permission("commandgui.command." + gui.Command_Command));
}
Register.permission("commandgui.command." + gui.Command_Command, op, plugin);
Register.permission(admin, op, "commandgui.command." + gui.Command_Command, true, plugin);
for (Slot slot : gui.slots) {
if (Bukkit.getPluginManager().getPermission(slot.permissionToUse) == null) {
Bukkit.getPluginManager().addPermission(new Permission(slot.permissionToUse));
}
if (Bukkit.getPluginManager().getPermission(slot.permissionToSee) == null) {
Bukkit.getPluginManager().addPermission(new Permission(slot.permissionToSee));
}
Register.permission(slot.permissionToUse, op, plugin);
Register.permission(admin, op, slot.permissionToUse, true, plugin);
Register.permission(slot.permissionToSee, op, plugin);
Register.permission(admin, op, slot.permissionToSee, true, plugin);
}
}
}

View File

@ -19,56 +19,54 @@ commands:
commandguihelp:
description: CommandGUI Help
aliases: [cguihelp, guihelp]
# commandguiadmin:
# aliases: [cguiadmin, cguia]
commandgui-item:
aliases: [gui-item]
permissions:
commandgui.admin:
description: All permissions from CommandGUI
default: op
children:
commandgui.updatemsg: true
commandgui.command: true
commandgui.get.guiitem.at.login: true
commandgui.useitem: true
commandgui.useitem.toggle: true
commandgui.bypass: true
commandgui.command.info: true
commandgui.command.give: true
commandgui.player:
description: All permissions from CommandGUI
default: op
children:
commandgui.command: true
commandgui.get.guiitem.at.login: true
commandgui.useitem: true
commandgui.useitem.toggle: true
commandgui.updatemsg:
description: Players with this permission get the update message when joining if an update is available
default: op
commandgui.command:
description: Required permission to open GUIs via command
default: op
commandgui.get.guiitem.at.login:
description: Only players with this permission will receive the GUI item
default: op
commandgui.useitem:
description: Required permission to use the GUI Item
default: op
commandgui.useitem.toggle:
description: Required permission to enable/disable the GUI Item for itself (if the function UseItem/AllowToggle is set to true)
default: op
commandgui.bypass:
description: Bypass to open disabled GUIs
default: op
commandgui.command.info:
description: Permission to view CommandGUI info
default: not op
commandgui.command.give:
description: Kommend in V2.1.0
default: op
#permissions:
# commandgui.admin:
# description: All permissions from CommandGUI
# default: op
# children:
# commandgui.command: true
# commandgui.get.guiitem.at.login: true
# commandgui.useitem: true
# commandgui.useitem.toggle: true
# commandgui.updatemsg: true
# commandgui.bypass: true
# commandgui.command.info: true
# commandgui.command.give: true
#
# commandgui.player:
# description: All permissions from CommandGUI
# default: op
# children:
# commandgui.command: true
# commandgui.get.guiitem.at.login: true
# commandgui.useitem: true
# commandgui.useitem.toggle: true
#
# commandgui.updatemsg:
# description: Players with this permission get the update message when joining if an update is available
# default: op
# commandgui.command:
# description: Required permission to open GUIs via command
# default: op
# commandgui.get.guiitem.at.login:
# description: Only players with this permission will receive the GUI item
# default: op
# commandgui.useitem:
# description: Required permission to use the GUI Item
# default: op
# commandgui.useitem.toggle:
# description: Required permission to enable/disable the GUI Item for itself (if the function UseItem/AllowToggle is set to true)
# default: op
# commandgui.bypass:
# description: Bypass to open disabled GUIs
# default: op
# commandgui.command.info:
# description: Permission to view CommandGUI info
# default: not op
# commandgui.command.give:
# description: Kommend in V2.1.0
# default: op