This commit is contained in:
5vl 2021-01-21 21:01:05 +01:00
parent 6a0d9df988
commit d0dc458251
2 changed files with 16 additions and 21 deletions

View File

@ -18,36 +18,28 @@ public final class permissions extends JavaPlugin {
} }
HashMap<UUID, PermissionAttachment> attachments = new HashMap<>(); HashMap<UUID, PermissionAttachment> attachments = new HashMap<>();
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (label.equalsIgnoreCase("perm")) { if (label.equalsIgnoreCase("perm")) {
Player ps = Bukkit.getPlayer(args[0]); PermissionAttachment attachment = Bukkit.getPlayer(args[0]).addAttachment(this);
PermissionAttachment attachment = ps.addAttachment(this);
Player p = (Player) sender; Player p = (Player) sender;
if (sender instanceof Player) { if (p.hasPermission("perm.perm")) {
if (p.hasPermission("perm.setperm")) { if (args.length < 3) {
if (args.length > 2) { p.sendMessage("Usage: /perm <player> <permission> <true/false>");
attachment.setPermission(args[1], Boolean.parseBoolean(args[2])); }
} else { else if (args.length == 3) {
p.sendMessage("Please specify correct arguments: /perm <player> <permission> <true/false>"); attachment.setPermission(args[1], Boolean.parseBoolean(args[2]));
} p.sendMessage(ChatColor.WHITE + "Successfully set permission " + ChatColor.YELLOW + args[1] + ChatColor.WHITE + " to " + ChatColor.YELLOW + args[2] + ChatColor.WHITE + " for player " + ChatColor.YELLOW + args[0]);
} else { }
p.sendMessage(ChatColor.RED + "You do not have permission to execute this command."); else {
p.sendMessage("Usage: /perm <player> <permission> <true/false>");
} }
} }
else { else {
if (args.length > 2) { p.sendMessage(ChatColor.RED + "You do not have permission to execute this command.");
attachment.setPermission(args[1], Boolean.parseBoolean(args[2]));
} else {
System.out.println("Please specify correct arguments: /perm <player> <permission> <true/false>");
}
} }
} }
return false; return false;
} }
@Override
public void onDisable() {
// Plugin shutdown logic
}
} }

View File

@ -5,3 +5,6 @@ api-version: 1.16
authors: [ 5vl ] authors: [ 5vl ]
description: A permission plguin made by 5vl. description: A permission plguin made by 5vl.
website: https://github.com/5vl/PermissionPlugin website: https://github.com/5vl/PermissionPlugin
commands:
perm:
description: With this command you can set permissions.