Compare commits
91 Commits
Author | SHA1 | Date |
---|---|---|
Michel Roux | 75a9cad1e6 | |
Xéfir Destiny | 99fbed29e0 | |
Michel Roux | dfd4e1e1b4 | |
Michel Roux | a120301bef | |
Michel Roux | d443b464d4 | |
Michel Roux | a92b82e5da | |
Michel Roux | c43340ee15 | |
Michel Roux | d9311addab | |
Michel Roux | ad43193951 | |
Michel Roux | b6dedbd13a | |
Michel Roux | b92be6d2a9 | |
Michel Roux | 80c055d209 | |
Michel Roux | b9dcbbfc09 | |
Michel Roux | 4bac4a1d70 | |
Michel Roux | 79bc01d986 | |
Michel Roux | 8b8a304476 | |
Michel Roux | 9d8879f0b2 | |
Michel Roux | 31c7d8cd7f | |
Michel Roux | 6fc78f64f3 | |
Michel Roux | 46bc9963fa | |
Michel Roux | 63fae3590f | |
Michel Roux | 70f667447a | |
Michel Roux | 7c1376be8a | |
Michel Roux | 7aeed9877f | |
Michel Roux | 5e8c850ee7 | |
Michel Roux | 56af5a4866 | |
Michel Roux | b4eee29372 | |
Michel Roux | d08ff3f275 | |
Michel Roux | e50e394cb9 | |
Michel Roux | aea566ff30 | |
Michel Roux | 892b493c9f | |
Michel Roux | a561ac693b | |
Michel Roux | 187d68902e | |
Michel Roux | c5ac11a347 | |
Michel Roux | 0c3601e112 | |
Michel Roux | 8a648ad0ac | |
Michel Roux | 953e1bf4d7 | |
Michel Roux | 5f5552b6e4 | |
Michel Roux | 066fa619c9 | |
Michel Roux | 8d49e0ecc0 | |
Michel Roux | 0ad58581d8 | |
Michel Roux | f1817a636d | |
Michel Roux | b9de5e5353 | |
Michel Roux | d8f2fd5c3c | |
Michel Roux | de1fca795f | |
Michel Roux | de0492e0c1 | |
Michel Roux | cd8febf077 | |
Michel Roux | 434cdb2544 | |
Michel Roux | 971652f3ae | |
Michel Roux | 8dca7e2a9b | |
Michel Roux | 51fdc38f8c | |
Michel Roux | faa47d512d | |
Michel Roux | be092bd7f1 | |
Michel Roux | 645d93b800 | |
Michel Roux | 77436631a4 | |
Michel Roux | 346533098d | |
Michel Roux | bf82bc2995 | |
Michel Roux | cf7c8146e0 | |
Michel Roux | ce9af8af6d | |
Michel Roux | 742904822d | |
Michel Roux | 5adf541817 | |
Michel Roux | f43b2dedc0 | |
Michel Roux | d437044ea0 | |
Michel Roux | 5f04da827f | |
Michel Roux | a04f31c53c | |
Michel Roux | 15839ebd2e | |
Michel Roux | a1ea62ee7f | |
Michel Roux | 343a4cdc24 | |
Michel Roux | f39abd23b3 | |
Michel Roux | 15b4508421 | |
Michel Roux | 3015ba280b | |
Michel Roux | 5a3e6c3f32 | |
Michel Roux | 0b0847ea2c | |
Michel Roux | 886b5c3f63 | |
Michel Roux | 9a751bcd3a | |
Michel Roux | 16bd435ece | |
Michel Roux | db6469f486 | |
Michel Roux | 34a0238ab4 | |
Michel Roux | 4a30b95c0f | |
Michel Roux | f1dc7ad362 | |
Michel Roux | fc023cc670 | |
Michel Roux | 72b26bcdb4 | |
Michel Roux | b19fd41b39 | |
Michel Roux | 39c125d1a3 | |
Michel Roux | 225a0559f7 | |
Michel Roux | 3efbcdd730 | |
Michel Roux | 5d5f942f37 | |
Michel Roux | 0f4ab0c659 | |
Michel Roux | 35bbe58be3 | |
Michel Roux | 033bf3c0b1 | |
Michel Roux | 9edaca011d |
|
@ -0,0 +1,6 @@
|
|||
.classpath
|
||||
.project
|
||||
.settings
|
||||
/bin
|
||||
.git
|
||||
*.class
|
|
@ -1,2 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
|
90
README.md
90
README.md
|
@ -1,4 +1,88 @@
|
|||
SimplyPerms
|
||||
===========
|
||||
![](http://dev.bukkit.org/media/images/40/348/simplyperms3.png)
|
||||
|
||||
When powerful plugin made Permissions easy !
|
||||
### *When powerful plugin made Permissions easy !*
|
||||
|
||||
SimplyPerms is yet another Permissions plugin manager based on PermissionsBukkit ideas with some new really great features !
|
||||
|
||||
**WARNING : SimplyPerms is not compatible with PermissionsBukkit or other permissions plugins !**
|
||||
|
||||
## [Commands][2]
|
||||
|
||||
## [Permissions and authorizations][3]
|
||||
|
||||
## [Import from other plugins][4]
|
||||
|
||||
## Configuration
|
||||
|
||||
The configuration file is slightly the same than PermissionsBukkit.
|
||||
|
||||
Please refer to the [PermissionsBukkit documentation][5]
|
||||
An example configuration file [can be found here][6]
|
||||
For the database connection, [please refer to this page][7]
|
||||
|
||||
## Add-ons
|
||||
|
||||
### [SimplyWrap][10]
|
||||
|
||||
This make plugins based on PermissionsBukkit API compatible with SimplyPerms.
|
||||
|
||||
[You can download it here.][10]
|
||||
|
||||
*Not all PermissionsBukkit plugin will work with this ! Try and give me your feedbacks !*
|
||||
|
||||
### [SimplyRank][14]
|
||||
|
||||
This allow you to use the rank feature with SimplyPerms.
|
||||
|
||||
[You can download it here.][14]
|
||||
|
||||
With this you can allow someone to grant someone else on a specified group.
|
||||
|
||||
Commands :
|
||||
|
||||
* /rank [player] [group]
|
||||
* /ranker [player] [group]
|
||||
* /setrank [player] [group]
|
||||
|
||||
Permission :
|
||||
|
||||
* permissions.rank.[groupname]
|
||||
|
||||
## [Source code][11]
|
||||
|
||||
All my work is available in GitHub :
|
||||
**[SimplyPerms][11]** / *[SimplyWrap][12] / [SimplyRank][15]*
|
||||
|
||||
## Thanks
|
||||
|
||||
* [PermissionsBukkit][8] by SpaceManiac for core permissions code
|
||||
* [AntiGuest][9] by QuickWango for part of authorizations feature
|
||||
* [milkywayz][16] for the modified PermissionsBukkit to include rank feature
|
||||
|
||||
## Todo
|
||||
|
||||
* Document the database mecanism and setup
|
||||
* Import from other Permissions Plugins
|
||||
* **Feel free to ask me new features, improvements or bugs :D**
|
||||
|
||||
## [Donate][13]
|
||||
|
||||
I make my plugins with my free time and for free, if you like my work, [you can buy me a coffee][13] :D
|
||||
|
||||
[![](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)][13]
|
||||
|
||||
[2]: http://dev.bukkit.org/server-mods/simplyperms/pages/commands/
|
||||
[3]: http://dev.bukkit.org/server-mods/simplyperms/pages/permissions-and-authorizations/
|
||||
[4]: http://dev.bukkit.org/server-mods/simplyperms/pages/import-from-other-plugins/
|
||||
[5]: http://dev.bukkit.org/server-mods/permbukkit/pages/configuration/
|
||||
[6]: http://dev.bukkit.org/server-mods/simplyperms/pages/exemple-of-config-yml/
|
||||
[7]: http://dev.bukkit.org/server-mods/simplyperms/pages/database-connection/
|
||||
[8]: http://dev.bukkit.org/server-mods/permbukkit/
|
||||
[9]: http://dev.bukkit.org/server-mods/antiguest/
|
||||
[10]: https://github.com/downloads/Xefir/SimplyWrap/SimplyWrap.jar
|
||||
[11]: https://github.com/Xefir/SimplyPerms
|
||||
[12]: https://github.com/Xefir/SimplyWrap
|
||||
[13]: https://github.com/downloads/Xefir/SimplyPerms/donate.html
|
||||
[14]: https://github.com/downloads/Xefir/SimplyRank/SimplyRank.jar
|
||||
[15]: https://github.com/Xefir/SimplyRank
|
||||
[16]: https://github.com/milkywayz/PermissionsBukkit
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
||||
<title> </title>
|
||||
</head>
|
||||
<body onload="document.getElementById('form').submit()">
|
||||
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="form">
|
||||
<input type="hidden" name="cmd" value="_s-xclick">
|
||||
<input type="hidden" name="hosted_button_id" value="FQ8F4D7JZRPS2">
|
||||
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
||||
<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
|
@ -1,466 +0,0 @@
|
|||
package net.crystalyx.bukkit.simplyperms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.imports.ImportDB;
|
||||
import net.crystalyx.bukkit.simplyperms.imports.ImportFile;
|
||||
import net.crystalyx.bukkit.simplyperms.imports.ImportManager;
|
||||
import net.crystalyx.bukkit.simplyperms.imports.ImportPermBukkit;
|
||||
import net.crystalyx.bukkit.simplyperms.imports.ImportPrivileges;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
|
||||
public class SimplyCommands implements CommandExecutor {
|
||||
|
||||
private SimplyPlugin plugin;
|
||||
|
||||
public SimplyCommands(SimplyPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] split) {
|
||||
if (split.length < 1) {
|
||||
return !checkPerm(sender, "help") || usage(sender, command);
|
||||
}
|
||||
|
||||
String subcommand = split[0];
|
||||
if (subcommand.equals("reload")) {
|
||||
if (!checkPerm(sender, "reload")) return true;
|
||||
plugin.reloadConfig();
|
||||
plugin.refreshPermissions();
|
||||
sender.sendMessage(ChatColor.GREEN + "Configuration reloaded.");
|
||||
return true;
|
||||
} if (subcommand.equals("check")) {
|
||||
if (!checkPerm(sender, "check")) return true;
|
||||
if (split.length != 2 && split.length != 3) return usage(sender, command, subcommand);
|
||||
|
||||
String node = split[1];
|
||||
Permissible permissible;
|
||||
if (split.length == 2) {
|
||||
permissible = sender;
|
||||
} else {
|
||||
permissible = plugin.getServer().getPlayer(split[2]);
|
||||
}
|
||||
|
||||
String name = (permissible instanceof Player) ? ((Player) permissible).getName() : (permissible instanceof ConsoleCommandSender) ? "Console" : "Unknown";
|
||||
|
||||
if (permissible == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Player " + ChatColor.WHITE + split[2] + ChatColor.RED + " not found.");
|
||||
} else {
|
||||
boolean set = permissible.isPermissionSet(node), has = permissible.hasPermission(node);
|
||||
String sets = set ? " sets " : " defaults ";
|
||||
String perm = has ? " true" : " false";
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + name + ChatColor.GREEN + sets + ChatColor.WHITE + node + ChatColor.GREEN + " to " + ChatColor.WHITE + perm + ChatColor.GREEN + ".");
|
||||
}
|
||||
return true;
|
||||
} else if (subcommand.equals("info")) {
|
||||
if (!checkPerm(sender, "info")) return true;
|
||||
if (split.length != 2) return usage(sender, command, subcommand);
|
||||
|
||||
String node = split[1];
|
||||
Permission perm = plugin.getServer().getPluginManager().getPermission(node);
|
||||
|
||||
if (perm == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Permission " + ChatColor.WHITE + node + ChatColor.RED + " not found.");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GREEN + "Info on permission " + ChatColor.WHITE + perm.getName() + ChatColor.GREEN + ":");
|
||||
sender.sendMessage(ChatColor.GREEN + "Default: " + ChatColor.WHITE + perm.getDefault());
|
||||
if (perm.getDescription() != null && perm.getDescription().length() > 0) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Description: " + ChatColor.WHITE + perm.getDescription());
|
||||
}
|
||||
if (perm.getChildren() != null && perm.getChildren().size() > 0) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Children: " + ChatColor.WHITE + perm.getChildren().size());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if (subcommand.equals("dump")) {
|
||||
if (!checkPerm(sender, "dump")) return true;
|
||||
if (split.length < 1 || split.length > 3) return usage(sender, command, subcommand);
|
||||
|
||||
int page;
|
||||
Permissible permissible;
|
||||
if (split.length == 1) {
|
||||
permissible = sender;
|
||||
page = 1;
|
||||
} else if (split.length == 2) {
|
||||
try {
|
||||
permissible = sender;
|
||||
page = Integer.parseInt(split[1]);
|
||||
}
|
||||
catch (NumberFormatException ex) {
|
||||
permissible = plugin.getServer().getPlayer(split[1]);
|
||||
page = 1;
|
||||
}
|
||||
} else {
|
||||
permissible = plugin.getServer().getPlayer(split[1]);
|
||||
try {
|
||||
page = Integer.parseInt(split[2]);
|
||||
}
|
||||
catch (NumberFormatException ex) {
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (permissible == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Player " + ChatColor.WHITE + split[1] + ChatColor.RED + " not found.");
|
||||
} else {
|
||||
ArrayList<PermissionAttachmentInfo> dump = new ArrayList<PermissionAttachmentInfo>(permissible.getEffectivePermissions());
|
||||
Collections.sort(dump, new Comparator<PermissionAttachmentInfo>() {
|
||||
public int compare(PermissionAttachmentInfo a, PermissionAttachmentInfo b) {
|
||||
return a.getPermission().compareTo(b.getPermission());
|
||||
}
|
||||
});
|
||||
|
||||
int numpages = 1 + (dump.size() - 1) / 8;
|
||||
if (page > numpages) {
|
||||
page = numpages;
|
||||
} else if (page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
|
||||
ChatColor g = ChatColor.GREEN, w = ChatColor.WHITE, r = ChatColor.RED;
|
||||
|
||||
int start = 8 * (page - 1);
|
||||
sender.sendMessage(ChatColor.RED + "[==== " + ChatColor.GREEN + "Page " + page + " of " + numpages + ChatColor.RED + " ====]");
|
||||
for (int i = start; i < start + 8 && i < dump.size(); ++i) {
|
||||
PermissionAttachmentInfo info = dump.get(i);
|
||||
|
||||
if (info.getAttachment() == null) {
|
||||
sender.sendMessage(g + "Node " + w + info.getPermission() + g + "=" + w + info.getValue() + g + " (" + r + "default" + g + ")");
|
||||
} else {
|
||||
sender.sendMessage(g + "Node " + w + info.getPermission() + g + "=" + w + info.getValue() + g + " (" + w + info.getAttachment().getPlugin().getDescription().getName() + g + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if (subcommand.equals("group")) {
|
||||
if (split.length < 2) {
|
||||
return !checkPerm(sender, "group.help") || usage(sender, command, subcommand);
|
||||
}
|
||||
groupCommand(sender, command, split);
|
||||
return true;
|
||||
} else if (subcommand.equals("player")) {
|
||||
if (split.length < 2) {
|
||||
return !checkPerm(sender, "player.help") || usage(sender, command, subcommand);
|
||||
}
|
||||
playerCommand(sender, command, split);
|
||||
return true;
|
||||
} else if (subcommand.equals("import")) {
|
||||
if (!checkPerm(sender, "import")) return true;
|
||||
if (split.length != 2) return usage(sender, command, subcommand);
|
||||
String pluginName = split[1].toLowerCase();
|
||||
ImportManager manager;
|
||||
|
||||
if (pluginName.equals("permissionsbukkit")) {
|
||||
manager = new ImportPermBukkit(plugin);
|
||||
} else if (pluginName.equals("privileges")) {
|
||||
manager = new ImportPrivileges(plugin);
|
||||
} else if (pluginName.equals("file")) {
|
||||
manager = new ImportFile(plugin);
|
||||
} else if (plugin.getConfig().getString("db/type") != null
|
||||
&& pluginName.equals(plugin.getConfig().getString("db/type").toLowerCase())) {
|
||||
manager = new ImportDB(plugin);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Unknown import type !");
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
manager.run();
|
||||
plugin.refreshPermissions();
|
||||
sender.sendMessage(ChatColor.GREEN + "Operation success !");
|
||||
} catch (Exception e) {
|
||||
plugin.reloadConfig();
|
||||
sender.sendMessage(ChatColor.RED + "An error occurred ! Please check server log...");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return !checkPerm(sender, "help") || usage(sender, command);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean groupCommand(CommandSender sender, Command command, String[] split) {
|
||||
String subcommand = split[1];
|
||||
|
||||
if (subcommand.equals("list")) {
|
||||
if (!checkPerm(sender, "group.list")) return true;
|
||||
if (split.length != 2) return usage(sender, command, "group list");
|
||||
|
||||
String result = "", sep = "";
|
||||
for (String key : plugin.getNode("groups").getKeys(false)) {
|
||||
result += sep + key;
|
||||
sep = ", ";
|
||||
}
|
||||
sender.sendMessage(ChatColor.GREEN + "Groups: " + ChatColor.WHITE + result);
|
||||
return true;
|
||||
} else if (subcommand.equals("players")) {
|
||||
if (!checkPerm(sender, "group.players")) return true;
|
||||
if (split.length != 3) return usage(sender, command, "group players");
|
||||
String group = split[2];
|
||||
|
||||
if (plugin.getNode("groups/" + group) == null) {
|
||||
sender.sendMessage(ChatColor.RED + "No such group " + ChatColor.WHITE + group + ChatColor.RED + ".");
|
||||
return true;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
String text = "", sep = "";
|
||||
for (String user : plugin.config.getPlayers(group)) {
|
||||
++count;
|
||||
text += sep + user;
|
||||
sep = ", ";
|
||||
}
|
||||
sender.sendMessage(ChatColor.GREEN + "Users in " + ChatColor.WHITE + group + ChatColor.GREEN + " (" + ChatColor.WHITE + count + ChatColor.GREEN + "): " + ChatColor.WHITE + text);
|
||||
return true;
|
||||
} else if (subcommand.equals("setperm")) {
|
||||
if (!checkPerm(sender, "group.setperm")) return true;
|
||||
if (split.length != 4 && split.length != 5) return usage(sender, command, "group setperm");
|
||||
String group = split[2];
|
||||
String perm = split[3];
|
||||
boolean value = (split.length != 5) || Boolean.parseBoolean(split[4]);
|
||||
|
||||
String node = "permissions";
|
||||
if (plugin.getNode("groups/" + group) == null) {
|
||||
sender.sendMessage(ChatColor.RED + "No such group " + ChatColor.WHITE + group + ChatColor.RED + ".");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perm.contains(":")) {
|
||||
String world = perm.substring(0, perm.indexOf(':'));
|
||||
perm = perm.substring(perm.indexOf(':') + 1);
|
||||
node = "worlds/" + world;
|
||||
}
|
||||
if (plugin.getNode("groups/" + group + "/" + node) == null) {
|
||||
plugin.getConfig().createSection("groups/" + group + "/" + node);
|
||||
}
|
||||
|
||||
plugin.getNode("groups/" + group + "/" + node).set(perm, value);
|
||||
plugin.refreshPermissions();
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Group " + ChatColor.WHITE + group + ChatColor.GREEN + " now has " + ChatColor.WHITE + perm + ChatColor.GREEN + " = " + ChatColor.WHITE + value + ChatColor.GREEN + ".");
|
||||
return true;
|
||||
} else if (subcommand.equals("unsetperm")) {
|
||||
if (!checkPerm(sender, "group.unsetperm")) return true;
|
||||
if (split.length != 4) return usage(sender, command, "group unsetperm");
|
||||
String group = split[2].toLowerCase();
|
||||
String perm = split[3];
|
||||
|
||||
String node = "permissions";
|
||||
if (plugin.getNode("groups/" + group) == null) {
|
||||
sender.sendMessage(ChatColor.RED + "No such group " + ChatColor.WHITE + group + ChatColor.RED + ".");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perm.contains(":")) {
|
||||
String world = perm.substring(0, perm.indexOf(':'));
|
||||
perm = perm.substring(perm.indexOf(':') + 1);
|
||||
node = "worlds/" + world;
|
||||
}
|
||||
if (plugin.getNode("groups/" + group + "/" + node) == null) {
|
||||
plugin.getConfig().createSection("groups/" + group + "/" + node);
|
||||
}
|
||||
|
||||
ConfigurationSection sec = plugin.getNode("groups/" + group + "/" + node);
|
||||
if (!sec.contains(perm)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Group " + ChatColor.WHITE + group + ChatColor.GREEN + " did not have " + ChatColor.WHITE + perm + ChatColor.GREEN + " set.");
|
||||
return true;
|
||||
}
|
||||
sec.set(perm, null);
|
||||
plugin.refreshPermissions();
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Group " + ChatColor.WHITE + group + ChatColor.GREEN + " no longer has " + ChatColor.WHITE + perm + ChatColor.GREEN + " set.");
|
||||
return true;
|
||||
} else {
|
||||
return !checkPerm(sender, "group.help") || usage(sender, command);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean playerCommand(CommandSender sender, Command command, String[] split) {
|
||||
String subcommand = split[1];
|
||||
|
||||
if (subcommand.equals("groups")) {
|
||||
if (!checkPerm(sender, "player.groups")) return true;
|
||||
if (split.length != 3) return usage(sender, command, "player groups");
|
||||
String player = split[2].toLowerCase();
|
||||
|
||||
if (!plugin.config.isPlayerInDB(player)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.RED + " is in the default group.");
|
||||
return true;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
String text = "", sep = "";
|
||||
for (String group : plugin.config.getPlayerGroups(player)) {
|
||||
++count;
|
||||
text += sep + group;
|
||||
sep = ", ";
|
||||
}
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is in groups (" + ChatColor.WHITE + count + ChatColor.GREEN + "): " + ChatColor.WHITE + text);
|
||||
return true;
|
||||
} else if (subcommand.equals("setgroup")) {
|
||||
if (!checkPerm(sender, "player.setgroup")) return true;
|
||||
if (split.length != 4) return usage(sender, command, "player setgroup");
|
||||
String player = split[2].toLowerCase();
|
||||
String[] groups = split[3].split(",");
|
||||
|
||||
plugin.config.removePlayerGroups(player);
|
||||
for (String group : Arrays.asList(groups)) {
|
||||
plugin.config.addPlayerGroup(player, group);
|
||||
}
|
||||
|
||||
plugin.refreshPermissions();
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is now in " + ChatColor.WHITE + split[3] + ChatColor.GREEN + ".");
|
||||
return true;
|
||||
} else if (subcommand.equals("addgroup")) {
|
||||
if (!checkPerm(sender, "player.addgroup")) return true;
|
||||
if (split.length != 4) return usage(sender, command, "player addgroup");
|
||||
String player = split[2].toLowerCase();
|
||||
String group = split[3];
|
||||
|
||||
if (plugin.config.getPlayerGroups(player).contains(group)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " was already in " + ChatColor.WHITE + group + ChatColor.GREEN + ".");
|
||||
return true;
|
||||
}
|
||||
plugin.config.addPlayerGroup(player, group);
|
||||
|
||||
plugin.refreshPermissions();
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is now in " + ChatColor.WHITE + group + ChatColor.GREEN + ".");
|
||||
return true;
|
||||
} else if (subcommand.equals("removegroup")) {
|
||||
if (!checkPerm(sender, "player.removegroup")) return true;
|
||||
if (split.length != 4) return usage(sender, command, "player removegroup");
|
||||
String player = split[2].toLowerCase();
|
||||
String group = split[3];
|
||||
|
||||
if (!plugin.config.getPlayerGroups(player).contains(group)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " was not in " + ChatColor.WHITE + group + ChatColor.GREEN + ".");
|
||||
return true;
|
||||
}
|
||||
plugin.config.removePlayerGroup(player, group);
|
||||
|
||||
plugin.refreshPermissions();
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is no longer in " + ChatColor.WHITE + group + ChatColor.GREEN + ".");
|
||||
return true;
|
||||
} else if (subcommand.equals("remove")) {
|
||||
if (!checkPerm(sender, "player.remove")) return true;
|
||||
if (split.length != 3) return usage(sender, command, "player remove");
|
||||
String player = split[2].toLowerCase();
|
||||
|
||||
if (!plugin.config.isPlayerInDB(player)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " was not in config file.");
|
||||
return true;
|
||||
}
|
||||
|
||||
plugin.config.removePlayer(player);
|
||||
plugin.refreshPermissions();
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is no longer in config file.");
|
||||
return true;
|
||||
} else if (subcommand.equals("setperm")) {
|
||||
if (!checkPerm(sender, "player.setperm")) return true;
|
||||
if (split.length != 4 && split.length != 5) return usage(sender, command, "player setperm");
|
||||
String player = split[2].toLowerCase();
|
||||
String perm = split[3];
|
||||
boolean value = (split.length != 5) || Boolean.parseBoolean(split[4]);
|
||||
|
||||
String world = "";
|
||||
if (perm.contains(":")) {
|
||||
world = perm.substring(0, perm.indexOf(':'));
|
||||
perm = perm.substring(perm.indexOf(':') + 1);
|
||||
}
|
||||
|
||||
plugin.config.addPlayerPermission(player, world, perm, value);
|
||||
plugin.refreshPermissions();
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " now has " + ChatColor.WHITE + perm + ChatColor.GREEN + " = " + ChatColor.WHITE + value + ChatColor.GREEN + ".");
|
||||
return true;
|
||||
} else if (subcommand.equals("unsetperm")) {
|
||||
if (!checkPerm(sender, "player.unsetperm")) return true;
|
||||
if (split.length != 4) return usage(sender, command, "player unsetperm");
|
||||
String player = split[2].toLowerCase();
|
||||
String perm = split[3];
|
||||
|
||||
String world = "";
|
||||
if (perm.contains(":")) {
|
||||
world = perm.substring(0, perm.indexOf(':'));
|
||||
perm = perm.substring(perm.indexOf(':') + 1);
|
||||
}
|
||||
|
||||
Map<String, Boolean> list = plugin.config.getPlayerPermissions(player, world);
|
||||
if (!list.containsKey(perm)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " did not have " + ChatColor.WHITE + perm + ChatColor.GREEN + " set.");
|
||||
return true;
|
||||
}
|
||||
plugin.config.removePlayerPermission(player, world, perm);
|
||||
plugin.refreshPermissions();
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " no longer has " + ChatColor.WHITE + perm + ChatColor.GREEN + " set.");
|
||||
return true;
|
||||
} else {
|
||||
return !checkPerm(sender, "player.help") || usage(sender, command);
|
||||
}
|
||||
}
|
||||
|
||||
// -- utilities --
|
||||
|
||||
private boolean checkPerm(CommandSender sender, String subnode) {
|
||||
boolean ok = sender.hasPermission("permissions." + subnode);
|
||||
if (!ok) {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have permissions to do that.");
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
private boolean usage(CommandSender sender, Command command) {
|
||||
sender.sendMessage(ChatColor.RED + "[====" + ChatColor.GREEN + " /permissons " + ChatColor.RED + "====]");
|
||||
for (String line : command.getUsage().split("\\n")) {
|
||||
if ((line.startsWith("/<command> group") && !line.startsWith("/<command> group -")) ||
|
||||
(line.startsWith("/<command> player") && !line.startsWith("/<command> player -"))) {
|
||||
continue;
|
||||
}
|
||||
sender.sendMessage(formatLine(line));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean usage(CommandSender sender, Command command, String subcommand) {
|
||||
sender.sendMessage(ChatColor.RED + "[====" + ChatColor.GREEN + " /permissons " + subcommand + " " + ChatColor.RED + "====]");
|
||||
for (String line : command.getUsage().split("\\n")) {
|
||||
if (line.startsWith("/<command> " + subcommand)) {
|
||||
sender.sendMessage(formatLine(line));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private String formatLine(String line) {
|
||||
int i = line.indexOf(" - ");
|
||||
String usage = line.substring(0, i);
|
||||
String desc = line.substring(i + 3);
|
||||
|
||||
usage = usage.replace("<command>", "permissions");
|
||||
usage = usage.replaceAll("\\[[^]:]+\\]", ChatColor.AQUA + "$0" + ChatColor.GREEN);
|
||||
usage = usage.replaceAll("\\[[^]]+:\\]", ChatColor.AQUA + "$0" + ChatColor.LIGHT_PURPLE);
|
||||
usage = usage.replaceAll("<[^>]+>", ChatColor.LIGHT_PURPLE + "$0" + ChatColor.GREEN);
|
||||
|
||||
return ChatColor.GREEN + usage + " - " + ChatColor.WHITE + desc;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package net.crystalyx.bukkit.simplyperms;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class SimplyPlayer implements Listener {
|
||||
|
||||
private SimplyPlugin plugin;
|
||||
|
||||
public SimplyPlayer(SimplyPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
// Keep track of player's world
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onWorldChange(PlayerChangedWorldEvent event) {
|
||||
plugin.debug("Player " + event.getPlayer().getName() + " changed world, recalculating...");
|
||||
plugin.calculateAttachment(event.getPlayer());
|
||||
}
|
||||
|
||||
// Register players when needed
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerLogin(PlayerJoinEvent event) {
|
||||
plugin.debug("Player " + event.getPlayer().getName() + " joined, registering...");
|
||||
plugin.registerPlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
// Unregister players when needed
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerKick(PlayerKickEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
plugin.debug("Player " + event.getPlayer().getName() + " was kicked, unregistering...");
|
||||
plugin.unregisterPlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
plugin.debug("Player " + event.getPlayer().getName() + " quit, unregistering...");
|
||||
plugin.unregisterPlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,283 +0,0 @@
|
|||
package net.crystalyx.bukkit.simplyperms;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.io.ConfigFile;
|
||||
import net.crystalyx.bukkit.simplyperms.io.ConfigSQL;
|
||||
import net.crystalyx.bukkit.simplyperms.io.PermsConfig;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class SimplyPlugin extends JavaPlugin {
|
||||
|
||||
protected PermsConfig config;
|
||||
private SimplyPlayer playerListener = new SimplyPlayer(this);
|
||||
private SimplyCommands commandExecutor = new SimplyCommands(this);
|
||||
private HashMap<String, PermissionAttachment> permissions = new HashMap<String, PermissionAttachment>();
|
||||
|
||||
private File configFile;
|
||||
private YamlConfiguration YamlConfig;
|
||||
|
||||
// -- Basic stuff
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Take care of configuration
|
||||
configFile = new File(getDataFolder(), "config.yml");
|
||||
if (!configFile.exists()) {
|
||||
saveDefaultConfig();
|
||||
}
|
||||
reloadConfig();
|
||||
|
||||
// Register stuff
|
||||
getCommand("permissions").setExecutor(commandExecutor);
|
||||
getServer().getPluginManager().registerEvents(playerListener, this);
|
||||
registerEvents();
|
||||
|
||||
// Register everyone online right now
|
||||
for (Player p : getServer().getOnlinePlayers()) {
|
||||
registerPlayer(p);
|
||||
}
|
||||
|
||||
// How are you gentlemen
|
||||
getLogger().info("Enabled successfully, " + getServer().getOnlinePlayers().length + " players registered");
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileConfiguration getConfig() {
|
||||
return YamlConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
YamlConfig = new YamlConfiguration();
|
||||
YamlConfig.options().pathSeparator('/');
|
||||
try {
|
||||
YamlConfig.load(configFile);
|
||||
} catch (Exception e) {
|
||||
getLogger().severe("Unable to load configuration!");
|
||||
}
|
||||
|
||||
// Init DB
|
||||
initDatabase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Unregister everyone
|
||||
for (Player p : getServer().getOnlinePlayers()) {
|
||||
unregisterPlayer(p);
|
||||
}
|
||||
|
||||
// Good day to you! I said good day!
|
||||
getLogger().info("Disabled successfully, " + getServer().getOnlinePlayers().length + " players unregistered");
|
||||
}
|
||||
|
||||
private void initDatabase() {
|
||||
if (getConfig().getString("db/type") != null
|
||||
&& !getConfig().getString("db/type").equals("file")) {
|
||||
ConfigSQL configsql = new ConfigSQL(this);
|
||||
if (configsql.checkDatabase()) {
|
||||
config = configsql;
|
||||
} else {
|
||||
debug("Fail to connect to database !");
|
||||
config = new ConfigFile(this);
|
||||
}
|
||||
}
|
||||
else {
|
||||
config = new ConfigFile(this);
|
||||
}
|
||||
}
|
||||
|
||||
public SimplyAPI getAPI() {
|
||||
return new SimplyAPI(this);
|
||||
}
|
||||
|
||||
// -- Plugin stuff
|
||||
|
||||
protected void registerPlayer(Player player) {
|
||||
if (permissions.containsKey(player.getName())) {
|
||||
debug("Registering " + player.getName() + ": was already registered");
|
||||
unregisterPlayer(player);
|
||||
}
|
||||
PermissionAttachment attachment = player.addAttachment(this);
|
||||
permissions.put(player.getName(), attachment);
|
||||
calculateAttachment(player);
|
||||
}
|
||||
|
||||
protected void unregisterPlayer(Player player) {
|
||||
if (permissions.containsKey(player.getName())) {
|
||||
try {
|
||||
player.removeAttachment(permissions.get(player.getName()));
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
debug("Unregistering " + player.getName() + ": player did not have attachment");
|
||||
}
|
||||
permissions.remove(player.getName());
|
||||
} else {
|
||||
debug("Unregistering " + player.getName() + ": was not registered");
|
||||
}
|
||||
}
|
||||
|
||||
protected void refreshPermissions() {
|
||||
try {
|
||||
getConfig().save(configFile);
|
||||
reloadConfig();
|
||||
} catch (IOException e) {
|
||||
getLogger().warning("Failed to write changed config.yml: " + e.getMessage());
|
||||
}
|
||||
for (String player : permissions.keySet()) {
|
||||
PermissionAttachment attachment = permissions.get(player);
|
||||
for (String key : attachment.getPermissions().keySet()) {
|
||||
attachment.unsetPermission(key);
|
||||
}
|
||||
|
||||
calculateAttachment(getServer().getPlayer(player));
|
||||
}
|
||||
}
|
||||
|
||||
protected ConfigurationSection getNode(String node) {
|
||||
for (String entry : getConfig().getKeys(true)) {
|
||||
if (node.equalsIgnoreCase(entry) && getConfig().isConfigurationSection(entry)) {
|
||||
return getConfig().getConfigurationSection(entry);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected HashMap<String, Boolean> getAllPerms(String desc, String path) {
|
||||
HashMap<String, Boolean> result = new HashMap<String, Boolean>();
|
||||
ConfigurationSection node = getNode(path);
|
||||
|
||||
int failures = 0;
|
||||
String firstFailure = "";
|
||||
|
||||
Set<String> keys = node.getKeys(false);
|
||||
for (String key : keys) {
|
||||
if (node.isBoolean(key)) {
|
||||
result.put(key, node.getBoolean(key));
|
||||
} else {
|
||||
++failures;
|
||||
if (firstFailure.length() == 0) {
|
||||
firstFailure = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (failures == 1) {
|
||||
getLogger().warning("In " + desc + ": " + firstFailure + " is non-boolean.");
|
||||
} else if (failures > 1) {
|
||||
getLogger().warning("In " + desc + ": " + firstFailure + " is non-boolean (+" + (failures-1) + " more).");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void debug(String message) {
|
||||
if (getConfig().getBoolean("debug", false)) {
|
||||
getLogger().info("Debug: " + message);
|
||||
}
|
||||
}
|
||||
|
||||
protected void calculateAttachment(Player player) {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
PermissionAttachment attachment = permissions.get(player.getName());
|
||||
if (attachment == null) {
|
||||
debug("Calculating permissions on " + player.getName() + ": attachment was null");
|
||||
return;
|
||||
}
|
||||
|
||||
for (String key : attachment.getPermissions().keySet()) {
|
||||
attachment.unsetPermission(key);
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Boolean> entry : calculatePlayerPermissions(player.getName().toLowerCase(), player.getWorld().getName()).entrySet()) {
|
||||
attachment.setPermission(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
player.recalculatePermissions();
|
||||
}
|
||||
|
||||
// -- Private stuff
|
||||
|
||||
private Map<String, Boolean> calculatePlayerPermissions(String player, String world) {
|
||||
if (!config.isPlayerInDB(player)) {
|
||||
return calculateGroupPermissions("default", world);
|
||||
}
|
||||
|
||||
Map<String, Boolean> perms = new HashMap<String, Boolean>();
|
||||
List<String> groups = config.getPlayerGroups(player);
|
||||
if (groups.isEmpty()) groups.add("default");
|
||||
|
||||
for (Entry<String, Boolean> entry : config.getPlayerPermissions(player).entrySet()) {
|
||||
perms.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
for (Entry<String, Boolean> entry : config.getPlayerPermissions(player, world).entrySet()) {
|
||||
// No containskey; world overrides non-world
|
||||
perms.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
for (String group : groups) {
|
||||
for (Map.Entry<String, Boolean> entry : calculateGroupPermissions(group, world).entrySet()) {
|
||||
if (!perms.containsKey(entry.getKey())) { // User overrides group
|
||||
perms.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return perms;
|
||||
}
|
||||
|
||||
private Map<String, Boolean> calculateGroupPermissions(String group, String world) {
|
||||
if (getNode("groups/" + group) == null) {
|
||||
return new HashMap<String, Boolean>();
|
||||
}
|
||||
|
||||
Map<String, Boolean> perms = getNode("groups/" + group + "/permissions") == null ?
|
||||
new HashMap<String, Boolean>() :
|
||||
getAllPerms("group " + group, "groups/" + group + "/permissions");
|
||||
|
||||
|
||||
if (getNode("groups/" + group + "/worlds/" + world) != null) {
|
||||
for (Map.Entry<String, Boolean> entry : getAllPerms("group " + group, "groups/" + group + "/worlds/" + world).entrySet()) {
|
||||
// No containskey; world overrides non-world
|
||||
perms.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
for (String parent : getNode("groups/" + group).getStringList("inheritance")) {
|
||||
for (Map.Entry<String, Boolean> entry : calculateGroupPermissions(parent, world).entrySet()) {
|
||||
if (!perms.containsKey(entry.getKey())) { // Children override permissions
|
||||
perms.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return perms;
|
||||
}
|
||||
|
||||
private void registerEvents() {
|
||||
String path = getDescription().getMain().substring(0, getDescription().getMain().lastIndexOf('.'));
|
||||
for (String prevent : SimplyPrevents.preventions) {
|
||||
try {
|
||||
getServer().getPluginManager().registerEvents((SimplyPrevents) Class.forName(path + ".preventions." + prevent).getDeclaredConstructor(SimplyPlugin.class).newInstance(this), this);
|
||||
} catch (Exception e) {
|
||||
debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package net.crystalyx.bukkit.simplyperms.imports;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyAPI;
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
|
||||
import net.crystalyx.bukkit.simplyperms.io.ConfigFile;
|
||||
import net.crystalyx.bukkit.simplyperms.io.ConfigSQL;
|
||||
|
||||
public class ImportDB extends SimplyAPI implements ImportManager {
|
||||
|
||||
private SimplyPlugin plugin;
|
||||
|
||||
public ImportDB(SimplyPlugin plugin) {
|
||||
super(plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
try {
|
||||
ConfigFile importFile = new ConfigFile(plugin);
|
||||
ConfigSQL importSQL = new ConfigSQL(plugin);
|
||||
if (!importSQL.checkDatabase()) {
|
||||
throw new Exception("Could not connect to database !");
|
||||
}
|
||||
|
||||
for (String player : importSQL.getAllPlayers()) {
|
||||
for (String group : importSQL.getPlayerGroups(player)) {
|
||||
importFile.addPlayerGroup(player, group);
|
||||
}
|
||||
|
||||
for (Entry<String, Boolean> permission : importSQL.getPlayerPermissions(player).entrySet()) {
|
||||
importFile.addPlayerPermission(player, permission.getKey(), permission.getValue());
|
||||
}
|
||||
|
||||
for (String world : importSQL.getPlayerWorlds(player)) {
|
||||
for (Entry<String, Boolean> permission : importSQL.getPlayerPermissions(player, world).entrySet()) {
|
||||
importFile.addPlayerPermission(player, world, permission.getKey(), permission.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package net.crystalyx.bukkit.simplyperms.imports;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyAPI;
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
|
||||
import net.crystalyx.bukkit.simplyperms.io.ConfigFile;
|
||||
import net.crystalyx.bukkit.simplyperms.io.ConfigSQL;
|
||||
|
||||
public class ImportFile extends SimplyAPI implements ImportManager {
|
||||
|
||||
private SimplyPlugin plugin;
|
||||
|
||||
public ImportFile(SimplyPlugin plugin) {
|
||||
super(plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
try {
|
||||
ConfigFile importFile = new ConfigFile(plugin);
|
||||
ConfigSQL importSQL = new ConfigSQL(plugin);
|
||||
if (!importSQL.checkDatabase()) {
|
||||
throw new Exception("Could not connect to database !");
|
||||
}
|
||||
|
||||
for (String player : importFile.getAllPlayers()) {
|
||||
for (String group : importFile.getPlayerGroups(player)) {
|
||||
importSQL.addPlayerGroup(player, group);
|
||||
}
|
||||
|
||||
for (Entry<String, Boolean> permission : importFile.getPlayerPermissions(player).entrySet()) {
|
||||
importSQL.addPlayerPermission(player, permission.getKey(), permission.getValue());
|
||||
}
|
||||
|
||||
for (String world : importFile.getPlayerWorlds(player)) {
|
||||
for (Entry<String, Boolean> permission : importFile.getPlayerPermissions(player, world).entrySet()) {
|
||||
importSQL.addPlayerPermission(player, world, permission.getKey(), permission.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,144 +0,0 @@
|
|||
package net.crystalyx.bukkit.simplyperms.io;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
|
||||
|
||||
public class ConfigFile implements PermsConfig {
|
||||
|
||||
private SimplyPlugin plugin;
|
||||
|
||||
public ConfigFile(SimplyPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayer(String player) {
|
||||
plugin.getConfig().set("users/" + player, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayerGroups(String player) {
|
||||
plugin.getConfig().set("users/" + player + "/groups", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayerGroup(String player, String group) {
|
||||
List<String> groups = getPlayerGroups(player);
|
||||
groups.remove(group);
|
||||
plugin.getConfig().set("users/" + player + "/groups", (groups.isEmpty()) ? null : groups);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlayerGroup(String player, String group) {
|
||||
if (group.isEmpty() || group.equals("default")) return;
|
||||
List<String> groups = getPlayerGroups(player);
|
||||
if (!groups.contains(group)) groups.add(group);
|
||||
plugin.getConfig().set("users/" + player + "/groups", groups);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlayerPermission(String player, String permission, boolean value) {
|
||||
addPlayerPermission(player, "", permission, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlayerPermission(String player, String world, String permission, boolean value) {
|
||||
Map<String, Boolean> permissions = getPlayerPermissions(player, world);
|
||||
if (permissions.containsKey(permission)) permissions.remove(permission);
|
||||
permissions.put(permission, value);
|
||||
if (!world.isEmpty()) {
|
||||
plugin.getConfig().set("users/" + player + "/worlds/" + world, permissions);
|
||||
}
|
||||
else {
|
||||
plugin.getConfig().set("users/" + player + "/permissions", permissions);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayerPermissions(String player) {
|
||||
plugin.getConfig().set("users/" + player + "/permissions", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayerPermission(String player, String permission) {
|
||||
removePlayerPermission(player, "", permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayerPermission(String player, String world, String permission) {
|
||||
Map<String, Boolean> permissions = getPlayerPermissions(player, world);
|
||||
permissions.remove(permission);
|
||||
if (!world.isEmpty()) {
|
||||
plugin.getConfig().set("users/" + player + "/worlds/" + world, (permissions.isEmpty()) ? null : permissions);
|
||||
}
|
||||
else {
|
||||
plugin.getConfig().set("users/" + player + "/permissions", (permissions.isEmpty()) ? null : permissions);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPlayers(String group) {
|
||||
List<String> players = new ArrayList<String>();
|
||||
for (String player : getAllPlayers()) {
|
||||
for (String groupName : getPlayerGroups(player)) {
|
||||
if (groupName.equals(group)) {
|
||||
players.add(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPlayerGroups(String player) {
|
||||
return plugin.getConfig().getStringList("users/" + player + "/groups");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Boolean> getPlayerPermissions(String player) {
|
||||
return getPlayerPermissions(player, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Boolean> getPlayerPermissions(String player, String world) {
|
||||
Map<String, Boolean> finalPerms = new HashMap<String, Boolean>();
|
||||
String permNode = (!world.isEmpty()) ? "users/" + player + "/worlds/" + world : "users/" + player + "/permissions";
|
||||
if (plugin.getConfig().getConfigurationSection(permNode) != null) {
|
||||
for (Entry<String, Object> permPlayer : plugin.getConfig().getConfigurationSection(permNode).getValues(false).entrySet()) {
|
||||
finalPerms.put(permPlayer.getKey(), (Boolean) permPlayer.getValue());
|
||||
}
|
||||
}
|
||||
return finalPerms;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerInDB(String player) {
|
||||
return plugin.getConfig().getConfigurationSection("users/" + player) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPlayerWorlds(String player) {
|
||||
if (plugin.getConfig().getConfigurationSection("users/" + player + "/worlds") != null) {
|
||||
return new ArrayList<String>(plugin.getConfig().getConfigurationSection("users/" + player + "/worlds").getKeys(false));
|
||||
}
|
||||
else {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllPlayers() {
|
||||
if (plugin.getConfig().getConfigurationSection("users") != null) {
|
||||
return new ArrayList<String>(plugin.getConfig().getConfigurationSection("users").getKeys(false));
|
||||
}
|
||||
else {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package net.crystalyx.bukkit.simplyperms.io;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface PermsConfig {
|
||||
|
||||
public void removePlayer(String player);
|
||||
|
||||
public void removePlayerGroups(String player);
|
||||
|
||||
public void removePlayerGroup(String player, String group);
|
||||
|
||||
public void addPlayerGroup(String player, String group);
|
||||
|
||||
public void addPlayerPermission(String player, String permission, boolean value);
|
||||
|
||||
public void addPlayerPermission(String player, String world, String permission, boolean value);
|
||||
|
||||
public void removePlayerPermissions(String player);
|
||||
|
||||
public void removePlayerPermission(String player, String permission);
|
||||
|
||||
public void removePlayerPermission(String player, String world, String permission);
|
||||
|
||||
public List<String> getPlayers(String group);
|
||||
|
||||
public List<String> getPlayerGroups(String player);
|
||||
|
||||
public Map<String, Boolean> getPlayerPermissions(String player);
|
||||
|
||||
public Map<String, Boolean> getPlayerPermissions(String player, String world);
|
||||
|
||||
public boolean isPlayerInDB(String player);
|
||||
|
||||
public List<String> getPlayerWorlds(String player);
|
||||
|
||||
public List<String> getAllPlayers();
|
||||
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
package net.crystalyx.bukkit.simplyperms.preventions;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPrevents;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||
import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
|
||||
|
||||
public class Vehicle extends SimplyPrevents {
|
||||
|
||||
public Vehicle(SimplyPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void vehicleEnter(VehicleEnterEvent event) {
|
||||
Entity entered = event.getEntered();
|
||||
if (entered instanceof Player) {
|
||||
prevent(event, (Player) entered, "vehicle");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void vehicleDestroy(VehicleDestroyEvent event) {
|
||||
Entity attacker = event.getAttacker();
|
||||
if (attacker instanceof Player) {
|
||||
prevent(event, (Player) attacker, "vehicle");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void vehicleCollision(VehicleEntityCollisionEvent event) {
|
||||
Entity collider = event.getEntity();
|
||||
if (collider instanceof Player) {
|
||||
if (prevent(event, (Player) collider, "vehicle")) {
|
||||
event.setCollisionCancelled(true);
|
||||
event.setPickupCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void vehicle(PlayerInteractEvent event) {
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
Material clickedMaterial = event.getClickedBlock().getType();
|
||||
Player player = event.getPlayer();
|
||||
Material materialInHand = player.getItemInHand().getType();
|
||||
if (clickedMaterial == Material.RAILS
|
||||
|| clickedMaterial == Material.POWERED_RAIL
|
||||
|| clickedMaterial == Material.DETECTOR_RAIL) {
|
||||
if (materialInHand == Material.MINECART
|
||||
|| materialInHand == Material.POWERED_MINECART
|
||||
|| materialInHand == Material.STORAGE_MINECART) {
|
||||
prevent(event, player, "vehicle");
|
||||
}
|
||||
} else if (materialInHand == Material.BOAT) {
|
||||
prevent(event, player, "vehicle");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
99
plugin.yml
99
plugin.yml
|
@ -1,99 +0,0 @@
|
|||
name: SimplyPerms
|
||||
main: net.crystalyx.bukkit.simplyperms.SimplyPlugin
|
||||
author: Xefir Destiny
|
||||
website: http://www.crystalyx.net/
|
||||
version: 1.6.1
|
||||
commands:
|
||||
permissions:
|
||||
aliases: [ perms, perm, p ]
|
||||
description: Commands for manipulating permissions.
|
||||
usage: |
|
||||
/<command> reload - reload the configuration from disk.
|
||||
/<command> check <node> [player] - check if a player or the sender has a permission (any plugin).
|
||||
/<command> info <node> - prints information on a specific permission.
|
||||
/<command> dump [player] [page] - prints info about a player's (or the sender's) permissions.
|
||||
/<command> import <type> - Import data from database or others permissions plugins
|
||||
/<command> group - list group-related commands.
|
||||
/<command> group list - list all groups.
|
||||
/<command> group players <group> - list players in a group.
|
||||
/<command> group setperm <group> <[world:]node> [true|false] - set a permission on a group.
|
||||
/<command> group unsetperm <group> <[world:]node> - unset a permission on a group.
|
||||
/<command> player - list player-related commands.
|
||||
/<command> player groups <player> - list groups a player is in.
|
||||
/<command> player setgroup <player> <group,...> - set a player to be in only the given groups.
|
||||
/<command> player addgroup <player> <group> - add a player to a group.
|
||||
/<command> player removegroup <player> <group> - remove a player from a group.
|
||||
/<command> player remove <player> - remove a player from config file.
|
||||
/<command> player setperm <player> <[world:]node> [true|false] - set a permission on a player.
|
||||
/<command> player unsetperm <player> <[world:]node> - unset a permission on a player.
|
||||
permissions:
|
||||
permissions.*:
|
||||
default: op
|
||||
description: Allows use of all PermissionsBukkit administration commands.
|
||||
children:
|
||||
permissions.help: true
|
||||
permissions.reload: true
|
||||
permissions.check: true
|
||||
permissions.info: true
|
||||
permissions.dump: true
|
||||
permissions.import: true
|
||||
permissions.group.*: true
|
||||
permissions.player.*: true
|
||||
permissions.allow.*: true
|
||||
permissions.help:
|
||||
description: Allows viewing of usage for /permissions.
|
||||
permissions.reload:
|
||||
description: Allows use of /permissions reload.
|
||||
permissions.check:
|
||||
description: Allows use of /permissions check.
|
||||
permissions.info:
|
||||
description: Allows use of /permissions info.
|
||||
permissions.dump:
|
||||
description: Allows use of /permissions dump.
|
||||
permissions.import:
|
||||
description: Allows use of /permissions import.
|
||||
permissions.group.*:
|
||||
description: Allows use of all /permissions group commands.
|
||||
children:
|
||||
permissions.group.help: true
|
||||
permissions.group.list: true
|
||||
permissions.group.players: true
|
||||
permissions.group.setperm: true
|
||||
permissions.group.unsetperm: true
|
||||
permissions.group.help:
|
||||
description: Allows viewing of usage for /permissions group.
|
||||
permissions.group.list:
|
||||
description: Allows use of /permissions group list.
|
||||
permissions.group.players:
|
||||
description: Allows use of /permissions group players.
|
||||
permissions.group.setperm:
|
||||
description: Allows use of /permissions group setperm.
|
||||
permissions.group.unsetperm:
|
||||
description: Allows use of /permissions group unsetperm.
|
||||
permissions.player.*:
|
||||
description: Allows use of all /permissions player commands.
|
||||
children:
|
||||
permissions.player.help: true
|
||||
permissions.player.groups: true
|
||||
permissions.player.setgroup: true
|
||||
permissions.player.addgroup: true
|
||||
permissions.player.removegroup: true
|
||||
permissions.player.remove: true
|
||||
permissions.player.setperm: true
|
||||
permissions.player.unsetperm: true
|
||||
permissions.player.help:
|
||||
description: Allows viewing of usage for /permissions player.
|
||||
permissions.player.groups:
|
||||
description: Allows use of /permissions player groups.
|
||||
permissions.player.setgroup:
|
||||
description: Allows use of /permissions player setgroup.
|
||||
permissions.player.addgroup:
|
||||
description: Allows use of /permissions player addgroup.
|
||||
permissions.player.removegroup:
|
||||
description: Allows use of /permissions player removegroup.
|
||||
permissions.player.remove:
|
||||
description: Allows use of /permissions player remove.
|
||||
permissions.player.setperm:
|
||||
description: Allows use of /permissions player setperm.
|
||||
permissions.player.unsetperm:
|
||||
description: Allows use of /permissions player unsetperm.
|
|
@ -1,4 +1,5 @@
|
|||
debug: false
|
||||
default: default
|
||||
db:
|
||||
type: file
|
||||
database: minecraft
|
||||
|
@ -17,7 +18,7 @@ db:
|
|||
value: value
|
||||
date: date
|
||||
users:
|
||||
ConspiracyWizard:
|
||||
conspiracywizard:
|
||||
permissions:
|
||||
permissions.example: true
|
||||
groups:
|
|
@ -0,0 +1,238 @@
|
|||
package net.crystalyx.bukkit.simplyperms;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.io.PermsConfig;
|
||||
|
||||
public class SimplyAPI implements PermsConfig {
|
||||
|
||||
private SimplyPlugin plugin;
|
||||
|
||||
public SimplyAPI(SimplyPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayer(String player) {
|
||||
plugin.config.removePlayer(player);
|
||||
plugin.refreshPlayerPermissions(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayerGroups(String player) {
|
||||
plugin.config.removePlayerGroups(player);
|
||||
plugin.refreshPlayerPermissions(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayerGroup(String player, String group) {
|
||||
plugin.config.removePlayerGroup(player, group);
|
||||
plugin.refreshPlayerPermissions(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerGroup(String player, String group) {
|
||||
plugin.config.setPlayerGroup(player, group);
|
||||
plugin.refreshPlayerPermissions(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlayerGroup(String player, String group) {
|
||||
plugin.config.addPlayerGroup(player, group);
|
||||
plugin.refreshPlayerPermissions(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlayerPermission(String player, String permission, boolean value) {
|
||||
plugin.config.addPlayerPermission(player, permission, value);
|
||||
plugin.refreshPlayerPermissions(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlayerPermission(String player, String world, String permission, boolean value) {
|
||||
plugin.config.addPlayerPermission(player, world, permission, value);
|
||||
plugin.refreshPlayerPermissions(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayerPermissions(String player) {
|
||||
plugin.config.removePlayerPermissions(player);
|
||||
plugin.refreshPlayerPermissions(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayerPermission(String player, String permission) {
|
||||
plugin.config.removePlayerPermission(player, permission);
|
||||
plugin.refreshPlayerPermissions(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayerPermission(String player, String world, String permission) {
|
||||
plugin.config.removePlayerPermission(player, world, permission);
|
||||
plugin.refreshPlayerPermissions(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPlayers(String group) {
|
||||
return plugin.config.getPlayers(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPlayerGroups(String player) {
|
||||
return plugin.config.getPlayerGroups(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Boolean> getPlayerPermissions(String player) {
|
||||
return plugin.config.getPlayerPermissions(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Boolean> getPlayerPermissions(String player, String world) {
|
||||
return plugin.config.getPlayerPermissions(player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerInDB(String player) {
|
||||
return plugin.config.isPlayerInDB(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPlayerWorlds(String player) {
|
||||
return plugin.config.getPlayerWorlds(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllPlayers() {
|
||||
return plugin.config.getAllPlayers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllGroups() {
|
||||
return plugin.config.getAllGroups();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroupWorlds(String group) {
|
||||
return plugin.config.getGroupWorlds(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroupInheritance(String group) {
|
||||
return plugin.config.getGroupInheritance(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGroupInheritance(String group, String inherit) {
|
||||
plugin.config.addGroupInheritance(group, inherit);
|
||||
refreshPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGroupInheritance(String group, String inherit) {
|
||||
plugin.config.removeGroupInheritance(group, inherit);
|
||||
refreshPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGroupInheritances(String group) {
|
||||
plugin.config.removeGroupInheritances(group);
|
||||
refreshPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Boolean> getGroupPermissions(String group, String world) {
|
||||
return plugin.config.getGroupPermissions(group, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Boolean> getGroupPermissions(String group) {
|
||||
return plugin.config.getGroupPermissions(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGroupPermission(String group, String world, String permission, boolean value) {
|
||||
plugin.config.addGroupPermission(group, world, permission, value);
|
||||
refreshPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGroupPermission(String group, String permission, boolean value) {
|
||||
plugin.config.addGroupPermission(group, permission, value);
|
||||
refreshPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGroupPermission(String group, String world, String permission) {
|
||||
plugin.config.removeGroupPermission(group, world, permission);
|
||||
refreshPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGroupPermission(String group, String permission) {
|
||||
plugin.config.removeGroupPermission(group, permission);
|
||||
refreshPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGroupPermissions(String group) {
|
||||
plugin.config.removeGroupPermissions(group);
|
||||
refreshPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGroup(String group) {
|
||||
plugin.config.removeGroup(group);
|
||||
refreshPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getMessages() {
|
||||
return plugin.config.getMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage(String key) {
|
||||
return plugin.config.getMessage(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessage(String key, String message) {
|
||||
plugin.config.addMessage(key, message);
|
||||
plugin.refreshConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMessage(String key) {
|
||||
plugin.config.removeMessage(key);
|
||||
plugin.refreshConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultGroup() {
|
||||
return plugin.config.getDefaultGroup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultGroup(String group) {
|
||||
plugin.config.setDefaultGroup(group);
|
||||
refreshPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getDebug() {
|
||||
return plugin.config.getDebug();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDebug(boolean debug) {
|
||||
plugin.config.setDebug(debug);
|
||||
plugin.refreshConfig();
|
||||
}
|
||||
|
||||
public void refreshPermissions() {
|
||||
plugin.refreshPermissions();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,467 @@
|
|||
package net.crystalyx.bukkit.simplyperms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.imports.ImportDB;
|
||||
import net.crystalyx.bukkit.simplyperms.imports.ImportFile;
|
||||
import net.crystalyx.bukkit.simplyperms.imports.ImportManager;
|
||||
import net.crystalyx.bukkit.simplyperms.imports.ImportPermBukkit;
|
||||
import net.crystalyx.bukkit.simplyperms.imports.ImportPermEx;
|
||||
import net.crystalyx.bukkit.simplyperms.imports.ImportPrivileges;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
|
||||
public class SimplyCommands implements CommandExecutor {
|
||||
|
||||
private SimplyPlugin plugin;
|
||||
|
||||
public SimplyCommands(SimplyPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] split) {
|
||||
if (split.length < 1) {
|
||||
return !checkPerm(sender, "help") || usage(sender, command);
|
||||
}
|
||||
|
||||
String subcommand = split[0];
|
||||
if (subcommand.equals("reload")) {
|
||||
if (!checkPerm(sender, "reload")) return true;
|
||||
plugin.reloadConfig();
|
||||
plugin.refreshPermissions();
|
||||
sender.sendMessage(ChatColor.GREEN + "Configuration reloaded.");
|
||||
return true;
|
||||
} if (subcommand.equals("check")) {
|
||||
if (!checkPerm(sender, "check")) return true;
|
||||
if (split.length != 2 && split.length != 3) return usage(sender, command, subcommand);
|
||||
|
||||
String node = split[1];
|
||||
Permissible permissible;
|
||||
if (split.length == 2) {
|
||||
permissible = sender;
|
||||
} else {
|
||||
permissible = plugin.getServer().getPlayer(split[2]);
|
||||
}
|
||||
|
||||
String name = (permissible instanceof Player) ? ((Player) permissible).getName() : (permissible instanceof ConsoleCommandSender) ? "Console" : "Unknown";
|
||||
|
||||
if (permissible == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Player " + ChatColor.WHITE + split[2] + ChatColor.RED + " not found.");
|
||||
} else {
|
||||
boolean set = permissible.isPermissionSet(node), has = permissible.hasPermission(node);
|
||||
String sets = set ? " sets " : " defaults ";
|
||||
String perm = has ? " true" : " false";
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + name + ChatColor.GREEN + sets + ChatColor.WHITE + node + ChatColor.GREEN + " to " + ChatColor.WHITE + perm + ChatColor.GREEN + ".");
|
||||
}
|
||||
return true;
|
||||
} else if (subcommand.equals("info")) {
|
||||
if (!checkPerm(sender, "info")) return true;
|
||||
if (split.length != 2) return usage(sender, command, subcommand);
|
||||
|
||||
String node = split[1];
|
||||
Permission perm = plugin.getServer().getPluginManager().getPermission(node);
|
||||
|
||||
if (perm == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Permission " + ChatColor.WHITE + node + ChatColor.RED + " not found.");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GREEN + "Info on permission " + ChatColor.WHITE + perm.getName() + ChatColor.GREEN + ":");
|
||||
sender.sendMessage(ChatColor.GREEN + "Default: " + ChatColor.WHITE + perm.getDefault());
|
||||
if (perm.getDescription() != null && perm.getDescription().length() > 0) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Description: " + ChatColor.WHITE + perm.getDescription());
|
||||
}
|
||||
if (perm.getChildren() != null && perm.getChildren().size() > 0) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Children: " + ChatColor.WHITE + perm.getChildren().size());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if (subcommand.equals("dump")) {
|
||||
if (!checkPerm(sender, "dump")) return true;
|
||||
if (split.length < 1 || split.length > 3) return usage(sender, command, subcommand);
|
||||
|
||||
int page;
|
||||
Permissible permissible;
|
||||
if (split.length == 1) {
|
||||
permissible = sender;
|
||||
page = 1;
|
||||
} else if (split.length == 2) {
|
||||
try {
|
||||
permissible = sender;
|
||||
page = Integer.parseInt(split[1]);
|
||||
}
|
||||
catch (NumberFormatException ex) {
|
||||
permissible = plugin.getServer().getPlayer(split[1]);
|
||||
page = 1;
|
||||
}
|
||||
} else {
|
||||
permissible = plugin.getServer().getPlayer(split[1]);
|
||||
try {
|
||||
page = Integer.parseInt(split[2]);
|
||||
}
|
||||
catch (NumberFormatException ex) {
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (permissible == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Player " + ChatColor.WHITE + split[1] + ChatColor.RED + " not found.");
|
||||
} else {
|
||||
ArrayList<PermissionAttachmentInfo> dump = new ArrayList<PermissionAttachmentInfo>(permissible.getEffectivePermissions());
|
||||
Collections.sort(dump, new Comparator<PermissionAttachmentInfo>() {
|
||||
public int compare(PermissionAttachmentInfo a, PermissionAttachmentInfo b) {
|
||||
return a.getPermission().compareTo(b.getPermission());
|
||||
}
|
||||
});
|
||||
|
||||
int numpages = 1 + (dump.size() - 1) / 8;
|
||||
if (page > numpages) {
|
||||
page = numpages;
|
||||
} else if (page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
|
||||
ChatColor g = ChatColor.GREEN, w = ChatColor.WHITE, r = ChatColor.RED;
|
||||
|
||||
int start = 8 * (page - 1);
|
||||
sender.sendMessage(ChatColor.RED + "[==== " + ChatColor.GREEN + "Page " + page + " of " + numpages + ChatColor.RED + " ====]");
|
||||
for (int i = start; i < start + 8 && i < dump.size(); ++i) {
|
||||
PermissionAttachmentInfo info = dump.get(i);
|
||||
|
||||
if (info.getAttachment() == null) {
|
||||
sender.sendMessage(g + "Node " + w + info.getPermission() + g + "=" + w + info.getValue() + g + " (" + r + "default" + g + ")");
|
||||
} else {
|
||||
sender.sendMessage(g + "Node " + w + info.getPermission() + g + "=" + w + info.getValue() + g + " (" + w + info.getAttachment().getPlugin().getDescription().getName() + g + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if (subcommand.equals("group")) {
|
||||
if (split.length < 2) {
|
||||
return !checkPerm(sender, "group.help") || usage(sender, command, subcommand);
|
||||
}
|
||||
groupCommand(sender, command, split);
|
||||
return true;
|
||||
} else if (subcommand.equals("player")) {
|
||||
if (split.length < 2) {
|
||||
return !checkPerm(sender, "player.help") || usage(sender, command, subcommand);
|
||||
}
|
||||
playerCommand(sender, command, split);
|
||||
return true;
|
||||
} else if (subcommand.equals("import")) {
|
||||
if (!checkPerm(sender, "import")) return true;
|
||||
if (split.length != 2) return usage(sender, command, subcommand);
|
||||
String pluginName = split[1].toLowerCase();
|
||||
ImportManager manager;
|
||||
|
||||
if (pluginName.equals("permissionsbukkit")) {
|
||||
manager = new ImportPermBukkit(plugin);
|
||||
} else if (pluginName.equals("privileges")) {
|
||||
manager = new ImportPrivileges(plugin);
|
||||
} else if (pluginName.equals("permissionsex")) {
|
||||
manager = new ImportPermEx(plugin);
|
||||
} else if (pluginName.equals("file")) {
|
||||
manager = new ImportFile(plugin);
|
||||
} else if (plugin.getConfig().getString("db/type") != null
|
||||
&& pluginName.equals(plugin.getConfig().getString("db/type").toLowerCase())) {
|
||||
manager = new ImportDB(plugin);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Unknown import type !");
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
manager.run();
|
||||
sender.sendMessage(ChatColor.GREEN + "Operation success !");
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(ChatColor.RED + "An error occurred ! Please check server log...");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return !checkPerm(sender, "help") || usage(sender, command);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean groupCommand(CommandSender sender, Command command, String[] split) {
|
||||
String subcommand = split[1];
|
||||
|
||||
if (subcommand.equals("list")) {
|
||||
if (!checkPerm(sender, "group.list")) return true;
|
||||
if (split.length != 2) return usage(sender, command, "group list");
|
||||
|
||||
String result = "", sep = "";
|
||||
for (String key : plugin.getNode("groups").getKeys(false)) {
|
||||
result += sep + key;
|
||||
sep = ", ";
|
||||
}
|
||||
sender.sendMessage(ChatColor.GREEN + "Groups: " + ChatColor.WHITE + result);
|
||||
return true;
|
||||
} else if (subcommand.equals("players")) {
|
||||
if (!checkPerm(sender, "group.players")) return true;
|
||||
if (split.length != 3) return usage(sender, command, "group players");
|
||||
String group = split[2];
|
||||
|
||||
if (plugin.getNode("groups/" + group) == null) {
|
||||
sender.sendMessage(ChatColor.RED + "No such group " + ChatColor.WHITE + group + ChatColor.RED + ".");
|
||||
return true;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
String text = "", sep = "";
|
||||
for (String user : plugin.config.getPlayers(group)) {
|
||||
++count;
|
||||
text += sep + user;
|
||||
sep = ", ";
|
||||
}
|
||||
sender.sendMessage(ChatColor.GREEN + "Users in " + ChatColor.WHITE + group + ChatColor.GREEN + " (" + ChatColor.WHITE + count + ChatColor.GREEN + "): " + ChatColor.WHITE + text);
|
||||
return true;
|
||||
} else if (subcommand.equals("setperm")) {
|
||||
if (!checkPerm(sender, "group.setperm")) return true;
|
||||
if (split.length != 4 && split.length != 5) return usage(sender, command, "group setperm");
|
||||
String group = split[2];
|
||||
String perm = split[3];
|
||||
boolean value = (split.length != 5) || Boolean.parseBoolean(split[4]);
|
||||
|
||||
String node = "permissions";
|
||||
if (plugin.getNode("groups/" + group) == null) {
|
||||
sender.sendMessage(ChatColor.RED + "No such group " + ChatColor.WHITE + group + ChatColor.RED + ".");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perm.contains(":")) {
|
||||
String world = perm.substring(0, perm.indexOf(':'));
|
||||
perm = perm.substring(perm.indexOf(':') + 1);
|
||||
node = "worlds/" + world;
|
||||
}
|
||||
if (plugin.getNode("groups/" + group + "/" + node) == null) {
|
||||
plugin.getConfig().createSection("groups/" + group + "/" + node);
|
||||
}
|
||||
|
||||
plugin.getNode("groups/" + group + "/" + node).set(perm, value);
|
||||
plugin.refreshPermissions();
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Group " + ChatColor.WHITE + group + ChatColor.GREEN + " now has " + ChatColor.WHITE + perm + ChatColor.GREEN + " = " + ChatColor.WHITE + value + ChatColor.GREEN + ".");
|
||||
return true;
|
||||
} else if (subcommand.equals("unsetperm")) {
|
||||
if (!checkPerm(sender, "group.unsetperm")) return true;
|
||||
if (split.length != 4) return usage(sender, command, "group unsetperm");
|
||||
String group = split[2].toLowerCase();
|
||||
String perm = split[3];
|
||||
|
||||
String node = "permissions";
|
||||
if (plugin.getNode("groups/" + group) == null) {
|
||||
sender.sendMessage(ChatColor.RED + "No such group " + ChatColor.WHITE + group + ChatColor.RED + ".");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perm.contains(":")) {
|
||||
String world = perm.substring(0, perm.indexOf(':'));
|
||||
perm = perm.substring(perm.indexOf(':') + 1);
|
||||
node = "worlds/" + world;
|
||||
}
|
||||
if (plugin.getNode("groups/" + group + "/" + node) == null) {
|
||||
plugin.getConfig().createSection("groups/" + group + "/" + node);
|
||||
}
|
||||
|
||||
ConfigurationSection sec = plugin.getNode("groups/" + group + "/" + node);
|
||||
if (!sec.contains(perm)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Group " + ChatColor.WHITE + group + ChatColor.GREEN + " did not have " + ChatColor.WHITE + perm + ChatColor.GREEN + " set.");
|
||||
return true;
|
||||
}
|
||||
sec.set(perm, null);
|
||||
plugin.refreshPermissions();
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Group " + ChatColor.WHITE + group + ChatColor.GREEN + " no longer has " + ChatColor.WHITE + perm + ChatColor.GREEN + " set.");
|
||||
return true;
|
||||
} else {
|
||||
return !checkPerm(sender, "group.help") || usage(sender, command);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean playerCommand(CommandSender sender, Command command, String[] split) {
|
||||
String subcommand = split[1];
|
||||
|
||||
if (subcommand.equals("groups")) {
|
||||
if (!checkPerm(sender, "player.groups")) return true;
|
||||
if (split.length != 3) return usage(sender, command, "player groups");
|
||||
String player = split[2].toLowerCase();
|
||||
|
||||
if (!plugin.config.isPlayerInDB(player)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.RED + " is in the " + plugin.config.getDefaultGroup() + " group.");
|
||||
return true;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
String text = "", sep = "";
|
||||
for (String group : plugin.config.getPlayerGroups(player)) {
|
||||
++count;
|
||||
text += sep + group;
|
||||
sep = ", ";
|
||||
}
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is in groups (" + ChatColor.WHITE + count + ChatColor.GREEN + "): " + ChatColor.WHITE + text);
|
||||
return true;
|
||||
} else if (subcommand.equals("setgroup")) {
|
||||
if (!checkPerm(sender, "player.setgroup")) return true;
|
||||
if (split.length != 4) return usage(sender, command, "player setgroup");
|
||||
String player = split[2].toLowerCase();
|
||||
String[] groups = split[3].split(",");
|
||||
|
||||
plugin.config.removePlayerGroups(player);
|
||||
for (String group : Arrays.asList(groups)) {
|
||||
plugin.config.addPlayerGroup(player, group);
|
||||
}
|
||||
|
||||
plugin.refreshPlayerPermissions(player);
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is now in " + ChatColor.WHITE + split[3] + ChatColor.GREEN + ".");
|
||||
return true;
|
||||
} else if (subcommand.equals("addgroup")) {
|
||||
if (!checkPerm(sender, "player.addgroup")) return true;
|
||||
if (split.length != 4) return usage(sender, command, "player addgroup");
|
||||
String player = split[2].toLowerCase();
|
||||
String group = split[3];
|
||||
|
||||
if (plugin.config.getPlayerGroups(player).contains(group)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " was already in " + ChatColor.WHITE + group + ChatColor.GREEN + ".");
|
||||
return true;
|
||||
}
|
||||
plugin.config.addPlayerGroup(player, group);
|
||||
|
||||
plugin.refreshPlayerPermissions(player);
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is now in " + ChatColor.WHITE + group + ChatColor.GREEN + ".");
|
||||
return true;
|
||||
} else if (subcommand.equals("removegroup")) {
|
||||
if (!checkPerm(sender, "player.removegroup")) return true;
|
||||
if (split.length != 4) return usage(sender, command, "player removegroup");
|
||||
String player = split[2].toLowerCase();
|
||||
String group = split[3];
|
||||
|
||||
if (!plugin.config.getPlayerGroups(player).contains(group)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " was not in " + ChatColor.WHITE + group + ChatColor.GREEN + ".");
|
||||
return true;
|
||||
}
|
||||
plugin.config.removePlayerGroup(player, group);
|
||||
|
||||
plugin.refreshPlayerPermissions(player);
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is no longer in " + ChatColor.WHITE + group + ChatColor.GREEN + ".");
|
||||
return true;
|
||||
} else if (subcommand.equals("remove")) {
|
||||
if (!checkPerm(sender, "player.remove")) return true;
|
||||
if (split.length != 3) return usage(sender, command, "player remove");
|
||||
String player = split[2].toLowerCase();
|
||||
|
||||
if (!plugin.config.isPlayerInDB(player)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " was not in config file.");
|
||||
return true;
|
||||
}
|
||||
|
||||
plugin.config.removePlayer(player);
|
||||
plugin.refreshPlayerPermissions(player);
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is no longer in config file.");
|
||||
return true;
|
||||
} else if (subcommand.equals("setperm")) {
|
||||
if (!checkPerm(sender, "player.setperm")) return true;
|
||||
if (split.length != 4 && split.length != 5) return usage(sender, command, "player setperm");
|
||||
String player = split[2].toLowerCase();
|
||||
String perm = split[3];
|
||||
boolean value = (split.length != 5) || Boolean.parseBoolean(split[4]);
|
||||
|
||||
String world = "";
|
||||
if (perm.contains(":")) {
|
||||
world = perm.substring(0, perm.indexOf(':'));
|
||||
perm = perm.substring(perm.indexOf(':') + 1);
|
||||
}
|
||||
|
||||
plugin.config.addPlayerPermission(player, world, perm, value);
|
||||
plugin.refreshPlayerPermissions(player);
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " now has " + ChatColor.WHITE + perm + ChatColor.GREEN + " = " + ChatColor.WHITE + value + ChatColor.GREEN + ".");
|
||||
return true;
|
||||
} else if (subcommand.equals("unsetperm")) {
|
||||
if (!checkPerm(sender, "player.unsetperm")) return true;
|
||||
if (split.length != 4) return usage(sender, command, "player unsetperm");
|
||||
String player = split[2].toLowerCase();
|
||||
String perm = split[3];
|
||||
|
||||
String world = "";
|
||||
if (perm.contains(":")) {
|
||||
world = perm.substring(0, perm.indexOf(':'));
|
||||
perm = perm.substring(perm.indexOf(':') + 1);
|
||||
}
|
||||
|
||||
Map<String, Boolean> list = plugin.config.getPlayerPermissions(player, world);
|
||||
if (!list.containsKey(perm)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " did not have " + ChatColor.WHITE + perm + ChatColor.GREEN + " set.");
|
||||
return true;
|
||||
}
|
||||
plugin.config.removePlayerPermission(player, world, perm);
|
||||
plugin.refreshPlayerPermissions(player);
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " no longer has " + ChatColor.WHITE + perm + ChatColor.GREEN + " set.");
|
||||
return true;
|
||||
} else {
|
||||
return !checkPerm(sender, "player.help") || usage(sender, command);
|
||||
}
|
||||
}
|
||||
|
||||
// -- utilities --
|
||||
|
||||
private boolean checkPerm(CommandSender sender, String subnode) {
|
||||
boolean ok = sender.hasPermission("permissions." + subnode);
|
||||
if (!ok) {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have permissions to do that.");
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
private boolean usage(CommandSender sender, Command command) {
|
||||
sender.sendMessage(ChatColor.RED + "[====" + ChatColor.GREEN + " /permissons " + ChatColor.RED + "====]");
|
||||
for (String line : command.getUsage().split("\\n")) {
|
||||
if ((line.startsWith("/<command> group") && !line.startsWith("/<command> group -")) ||
|
||||
(line.startsWith("/<command> player") && !line.startsWith("/<command> player -"))) {
|
||||
continue;
|
||||
}
|
||||
sender.sendMessage(formatLine(line));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean usage(CommandSender sender, Command command, String subcommand) {
|
||||
sender.sendMessage(ChatColor.RED + "[====" + ChatColor.GREEN + " /permissons " + subcommand + " " + ChatColor.RED + "====]");
|
||||
for (String line : command.getUsage().split("\\n")) {
|
||||
if (line.startsWith("/<command> " + subcommand)) {
|
||||
sender.sendMessage(formatLine(line));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private String formatLine(String line) {
|
||||
int i = line.indexOf(" - ");
|
||||
String usage = line.substring(0, i);
|
||||
String desc = line.substring(i + 3);
|
||||
|
||||
usage = usage.replace("<command>", "permissions");
|
||||
usage = usage.replaceAll("\\[[^]:]+\\]", ChatColor.AQUA + "$0" + ChatColor.GREEN);
|
||||
usage = usage.replaceAll("\\[[^]]+:\\]", ChatColor.AQUA + "$0" + ChatColor.LIGHT_PURPLE);
|
||||
usage = usage.replaceAll("<[^>]+>", ChatColor.LIGHT_PURPLE + "$0" + ChatColor.GREEN);
|
||||
|
||||
return ChatColor.GREEN + usage + " - " + ChatColor.WHITE + desc;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package net.crystalyx.bukkit.simplyperms;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class SimplyPlayer implements Listener {
|
||||
|
||||
private SimplyPlugin plugin;
|
||||
|
||||
public SimplyPlayer(SimplyPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
// Keep track of player's world
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onWorldChange(PlayerChangedWorldEvent event) {
|
||||
plugin.debug("Player " + event.getPlayer().getName() + " changed world, recalculating...");
|
||||
plugin.calculateAttachment(event.getPlayer());
|
||||
}
|
||||
|
||||
// Register players when needed
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerLogin(PlayerJoinEvent event) {
|
||||
plugin.debug("Player " + event.getPlayer().getName() + " joined, registering...");
|
||||
plugin.registerPlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
// Unregister players when needed
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerKick(PlayerKickEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
plugin.debug("Player " + event.getPlayer().getName() + " was kicked, unregistering...");
|
||||
plugin.unregisterPlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
plugin.debug("Player " + event.getPlayer().getName() + " quit, unregistering...");
|
||||
plugin.unregisterPlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,266 @@
|
|||
package net.crystalyx.bukkit.simplyperms;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.io.ConfigFile;
|
||||
import net.crystalyx.bukkit.simplyperms.io.ConfigSQL;
|
||||
import net.crystalyx.bukkit.simplyperms.io.PermsConfig;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class SimplyPlugin extends JavaPlugin {
|
||||
|
||||
protected PermsConfig config;
|
||||
private SimplyPlayer playerListener = new SimplyPlayer(this);
|
||||
private SimplyCommands commandExecutor = new SimplyCommands(this);
|
||||
private HashMap<String, PermissionAttachment> permissions = new HashMap<String, PermissionAttachment>();
|
||||
|
||||
private File configFile;
|
||||
private YamlConfiguration YamlConfig;
|
||||
|
||||
// -- Basic stuff
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Disable PermissionsBukkit to avoid bugs
|
||||
if (getServer().getPluginManager().isPluginEnabled("PermissionsBukkit")) {
|
||||
for (Permission perm : getServer().getPluginManager().getPlugin("PermissionsBukkit").getDescription().getPermissions()) {
|
||||
getServer().getPluginManager().removePermission(perm);
|
||||
}
|
||||
getServer().getPluginManager().disablePlugin(getServer().getPluginManager().getPlugin("PermissionsBukkit"));
|
||||
}
|
||||
|
||||
// Take care of configuration
|
||||
configFile = new File(getDataFolder(), "config.yml");
|
||||
if (!configFile.exists()) {
|
||||
saveDefaultConfig();
|
||||
}
|
||||
reloadConfig();
|
||||
|
||||
// Register stuff
|
||||
getCommand("permissions").setExecutor(commandExecutor);
|
||||
getServer().getPluginManager().registerEvents(playerListener, this);
|
||||
registerEvents();
|
||||
|
||||
// Register everyone online right now
|
||||
for (Player p : getServer().getOnlinePlayers()) {
|
||||
registerPlayer(p);
|
||||
}
|
||||
|
||||
// How are you gentlemen
|
||||
getLogger().info("Enabled successfully, " + getServer().getOnlinePlayers().length + " players registered");
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileConfiguration getConfig() {
|
||||
return YamlConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
YamlConfig = new YamlConfiguration();
|
||||
YamlConfig.options().pathSeparator('/');
|
||||
try {
|
||||
YamlConfig.load(configFile);
|
||||
} catch (Exception e) {
|
||||
getLogger().severe("Unable to load configuration!");
|
||||
}
|
||||
|
||||
// Init DB
|
||||
initDatabase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Unregister everyone
|
||||
for (Player p : getServer().getOnlinePlayers()) {
|
||||
unregisterPlayer(p);
|
||||
}
|
||||
|
||||
// Good day to you! I said good day!
|
||||
getLogger().info("Disabled successfully, " + getServer().getOnlinePlayers().length + " players unregistered");
|
||||
}
|
||||
|
||||
private void initDatabase() {
|
||||
if (!getConfig().getString("db/type", "file").equals("file")) {
|
||||
ConfigSQL configsql = new ConfigSQL(this);
|
||||
if (configsql.checkDatabase()) {
|
||||
config = configsql;
|
||||
} else {
|
||||
getLogger().info("Fail to connect to database !");
|
||||
config = new ConfigFile(this);
|
||||
}
|
||||
}
|
||||
else {
|
||||
config = new ConfigFile(this);
|
||||
}
|
||||
}
|
||||
|
||||
public SimplyAPI getAPI() {
|
||||
return new SimplyAPI(this);
|
||||
}
|
||||
|
||||
public List<String> getKeys(YamlConfiguration config, String node) {
|
||||
if (config.isConfigurationSection(node)) {
|
||||
return new ArrayList<String>(config.getConfigurationSection(node).getKeys(false));
|
||||
}
|
||||
else {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
// -- Plugin stuff
|
||||
|
||||
protected void registerPlayer(Player player) {
|
||||
if (permissions.containsKey(player.getName())) {
|
||||
debug("Registering " + player.getName() + ": was already registered");
|
||||
unregisterPlayer(player);
|
||||
}
|
||||
PermissionAttachment attachment = player.addAttachment(this);
|
||||
permissions.put(player.getName(), attachment);
|
||||
calculateAttachment(player);
|
||||
}
|
||||
|
||||
protected void unregisterPlayer(Player player) {
|
||||
if (permissions.containsKey(player.getName())) {
|
||||
try {
|
||||
player.removeAttachment(permissions.get(player.getName()));
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
debug("Unregistering " + player.getName() + ": player did not have attachment");
|
||||
}
|
||||
permissions.remove(player.getName());
|
||||
} else {
|
||||
debug("Unregistering " + player.getName() + ": was not registered");
|
||||
}
|
||||
}
|
||||
|
||||
protected void refreshConfig() {
|
||||
try {
|
||||
getConfig().save(configFile);
|
||||
reloadConfig();
|
||||
} catch (IOException e) {
|
||||
getLogger().warning("Failed to write changed config.yml: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected void refreshPlayerPermissions(String player) {
|
||||
refreshConfig();
|
||||
if (getServer().getPlayer(player) == null) return;
|
||||
PermissionAttachment attachment = permissions.get(getServer().getPlayer(player).getName());
|
||||
for (String key : attachment.getPermissions().keySet()) {
|
||||
attachment.unsetPermission(key);
|
||||
}
|
||||
calculateAttachment(getServer().getPlayer(player));
|
||||
}
|
||||
|
||||
protected void refreshPermissions() {
|
||||
refreshConfig();
|
||||
for (String player : permissions.keySet()) {
|
||||
refreshPlayerPermissions(player);
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigurationSection getNode(String node) {
|
||||
for (String entry : getConfig().getKeys(true)) {
|
||||
if (node.equalsIgnoreCase(entry) && getConfig().isConfigurationSection(entry)) {
|
||||
return getConfig().getConfigurationSection(entry);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void debug(String message) {
|
||||
if (config.getDebug()) {
|
||||
getLogger().info("Debug: " + message);
|
||||
}
|
||||
}
|
||||
|
||||
protected void calculateAttachment(Player player) {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
PermissionAttachment attachment = permissions.get(player.getName());
|
||||
if (attachment == null) {
|
||||
debug("Calculating permissions on " + player.getName() + ": attachment was null");
|
||||
return;
|
||||
}
|
||||
|
||||
for (String key : attachment.getPermissions().keySet()) {
|
||||
attachment.unsetPermission(key);
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Boolean> entry : calculatePlayerPermissions(player.getName().toLowerCase(), player.getWorld().getName()).entrySet()) {
|
||||
attachment.setPermission(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
player.recalculatePermissions();
|
||||
}
|
||||
|
||||
// -- Private stuff
|
||||
|
||||
private Map<String, Boolean> calculatePlayerPermissions(String player, String world) {
|
||||
String default_group = config.getDefaultGroup();
|
||||
if (!config.isPlayerInDB(player)) {
|
||||
return calculateGroupPermissions(default_group, world);
|
||||
}
|
||||
|
||||
Map<String, Boolean> perms = config.getPlayerPermissions(player);
|
||||
List<String> groups = config.getPlayerGroups(player);
|
||||
if (groups.isEmpty()) groups.add(default_group);
|
||||
// No containskey; world overrides non-world
|
||||
perms.putAll(config.getPlayerPermissions(player, world));
|
||||
|
||||
for (String group : groups) {
|
||||
for (Map.Entry<String, Boolean> entry : calculateGroupPermissions(group, world).entrySet()) {
|
||||
if (!perms.containsKey(entry.getKey())) { // User overrides group
|
||||
perms.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return perms;
|
||||
}
|
||||
|
||||
private Map<String, Boolean> calculateGroupPermissions(String group, String world) {
|
||||
if (getNode("groups/" + group) == null) {
|
||||
return new HashMap<String, Boolean>();
|
||||
}
|
||||
|
||||
Map<String, Boolean> perms = config.getGroupPermissions(group);
|
||||
// No containskey; world overrides non-world
|
||||
perms.putAll(config.getGroupPermissions(group, world));
|
||||
|
||||
for (String parent : config.getGroupInheritance(group)) {
|
||||
for (Map.Entry<String, Boolean> entry : calculateGroupPermissions(parent, world).entrySet()) {
|
||||
if (!perms.containsKey(entry.getKey())) { // Children override permissions
|
||||
perms.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return perms;
|
||||
}
|
||||
|
||||
private void registerEvents() {
|
||||
String path = getDescription().getMain().substring(0, getDescription().getMain().lastIndexOf('.'));
|
||||
for (String prevent : SimplyPrevents.preventions) {
|
||||
try {
|
||||
getServer().getPluginManager().registerEvents((SimplyPrevents) Class.forName(path + ".preventions." + prevent).getDeclaredConstructor(SimplyPlugin.class).newInstance(this), this);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -13,7 +13,6 @@ public abstract class SimplyPrevents implements Listener {
|
|||
public static String[] preventions = {
|
||||
"Bow",
|
||||
"Changesign",
|
||||
"Chat",
|
||||
"Command",
|
||||
"Damage",
|
||||
"Fight",
|
||||
|
@ -21,7 +20,6 @@ public abstract class SimplyPrevents implements Listener {
|
|||
"Item",
|
||||
"Monster",
|
||||
"Sneak",
|
||||
"Vehicle",
|
||||
"animals.Shear",
|
||||
"animals.Tame",
|
||||
"bucket.Lavabucket",
|
||||
|
@ -29,14 +27,18 @@ public abstract class SimplyPrevents implements Listener {
|
|||
"bucket.Waterbucket",
|
||||
"build.Breakblock",
|
||||
"build.Placeblock",
|
||||
"chat.Chat",
|
||||
"chat.CapsLock",
|
||||
"chat.Flood",
|
||||
"chat.Macros",
|
||||
"craft.Brew",
|
||||
"craft.Chest",
|
||||
"craft.Dispenser",
|
||||
"craft.Enchant",
|
||||
"craft.Furnace",
|
||||
"craft.Workbench",
|
||||
"fire.FlintAndSteel",
|
||||
"fire.Fireball",
|
||||
"fire.FlintAndSteel",
|
||||
"interact.Bed",
|
||||
"interact.Button",
|
||||
"interact.Cake",
|
||||
|
@ -50,42 +52,35 @@ public abstract class SimplyPrevents implements Listener {
|
|||
"loot.Drop",
|
||||
"loot.Pickup",
|
||||
"projectile.Egg",
|
||||
"projectile.EnderPearl",
|
||||
"projectile.Potion",
|
||||
"projectile.Snowball",
|
||||
"spam.CapsLock",
|
||||
"spam.Flood"
|
||||
"vehicle.Collision",
|
||||
"vehicle.Destroy",
|
||||
"vehicle.Enter",
|
||||
"vehicle.Place"
|
||||
};
|
||||
|
||||
public SimplyPrevents(SimplyPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void sendMessage(Player player, String message) {
|
||||
public void sendMessage(Player player, String node) {
|
||||
Long next = throttleTimestamps.get(player);
|
||||
next = Long.valueOf(next == null ? 0 : next.longValue());
|
||||
long current = System.currentTimeMillis();
|
||||
|
||||
if (next.longValue() < current) {
|
||||
player.sendMessage(message);
|
||||
throttleTimestamps.put(player, Long.valueOf(current + 3000));
|
||||
if (!plugin.config.getMessage(node).isEmpty()) {
|
||||
player.sendMessage(plugin.config.getMessage(node));
|
||||
plugin.debug("Event '" + node + "' cancelled for " + player.getName());
|
||||
throttleTimestamps.put(player, Long.valueOf(current + 3000));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void deny(Cancellable event, Player player, String node) {
|
||||
event.setCancelled(true);
|
||||
if (plugin.getConfig().getString("messages/" + node) != null) {
|
||||
sendMessage(player, plugin.getConfig().getString("messages/" + node).replace('&', '\u00A7'));
|
||||
} else if (plugin.getConfig().getString("messages/all") != null) {
|
||||
sendMessage(player, plugin.getConfig().getString("messages/all").replace('&', '\u00A7'));
|
||||
}
|
||||
plugin.debug("Event '" + node + "' cancelled for " + player.getName());
|
||||
}
|
||||
|
||||
protected boolean prevent(Cancellable event, Player player, String node) {
|
||||
if (player.isPermissionSet("permissions.allow.*")
|
||||
&& player.hasPermission("permissions.allow.*")) {
|
||||
return false;
|
||||
} else if (node.contains(",")) {
|
||||
if (node.contains(",")) {
|
||||
for (String subNode : node.split(",")) {
|
||||
if (prevent(event, player, subNode)) {
|
||||
return true;
|
||||
|
@ -96,7 +91,8 @@ public abstract class SimplyPrevents implements Listener {
|
|||
} else if (node.contains(".")) {
|
||||
if (player.isPermissionSet("permissions.allow." + node)) {
|
||||
if (!player.hasPermission("permissions.allow." + node)) {
|
||||
deny(event, player, node);
|
||||
event.setCancelled(true);
|
||||
sendMessage(player, node);
|
||||
return true;
|
||||
}
|
||||
} else if (prevent(event, player, node.substring(0, node.indexOf('.')))) {
|
||||
|
@ -104,12 +100,14 @@ public abstract class SimplyPrevents implements Listener {
|
|||
}
|
||||
} else if (player.isPermissionSet("permissions.allow." + node)) {
|
||||
if (!player.hasPermission("permissions.allow." + node)) {
|
||||
deny(event, player, node);
|
||||
event.setCancelled(true);
|
||||
sendMessage(player, node);
|
||||
return true;
|
||||
}
|
||||
} else if (player.isPermissionSet("permissions.allow.*")
|
||||
&& !player.hasPermission("permissions.allow.*")) {
|
||||
deny(event, player, node);
|
||||
event.setCancelled(true);
|
||||
sendMessage(player, node);
|
||||
return true;
|
||||
}
|
||||
return false;
|
|
@ -0,0 +1,48 @@
|
|||
package net.crystalyx.bukkit.simplyperms.imports;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyAPI;
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
|
||||
import net.crystalyx.bukkit.simplyperms.io.ConfigFile;
|
||||
import net.crystalyx.bukkit.simplyperms.io.ConfigSQL;
|
||||
|
||||
public class ImportDB extends SimplyAPI implements ImportManager {
|
||||
|
||||
private SimplyPlugin plugin;
|
||||
|
||||
public ImportDB(SimplyPlugin plugin) {
|
||||
super(plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
try {
|
||||
ConfigFile importFile = new ConfigFile(plugin);
|
||||
ConfigSQL importSQL = new ConfigSQL(plugin);
|
||||
if (!importSQL.checkDatabase()) {
|
||||
throw new Exception("Could not connect to database !");
|
||||
}
|
||||
|
||||
for (String player : importSQL.getAllPlayers()) {
|
||||
for (String group : importSQL.getPlayerGroups(player)) {
|
||||
importFile.addPlayerGroup(player, group);
|
||||
}
|
||||
|
||||
for (Entry<String, Boolean> permission : importSQL.getPlayerPermissions(player).entrySet()) {
|
||||
importFile.addPlayerPermission(player, permission.getKey(), permission.getValue());
|
||||
}
|
||||
|
||||
for (String world : importSQL.getPlayerWorlds(player)) {
|
||||
for (Entry<String, Boolean> permission : importSQL.getPlayerPermissions(player, world).entrySet()) {
|
||||
importFile.addPlayerPermission(player, world, permission.getKey(), permission.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package net.crystalyx.bukkit.simplyperms.imports;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyAPI;
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
|
||||
import net.crystalyx.bukkit.simplyperms.io.ConfigFile;
|
||||
import net.crystalyx.bukkit.simplyperms.io.ConfigSQL;
|
||||
|
||||
public class ImportFile extends SimplyAPI implements ImportManager {
|
||||
|
||||
private SimplyPlugin plugin;
|
||||
|
||||
public ImportFile(SimplyPlugin plugin) {
|
||||
super(plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
try {
|
||||
ConfigFile importFile = new ConfigFile(plugin);
|
||||
ConfigSQL importSQL = new ConfigSQL(plugin);
|
||||
if (!importSQL.checkDatabase()) {
|
||||
throw new Exception("Could not connect to database !");
|
||||
}
|
||||
|
||||
for (String player : importFile.getAllPlayers()) {
|
||||
for (String group : importFile.getPlayerGroups(player)) {
|
||||
importSQL.addPlayerGroup(player, group);
|
||||
}
|
||||
|
||||
for (Entry<String, Boolean> permission : importFile.getPlayerPermissions(player).entrySet()) {
|
||||
importSQL.addPlayerPermission(player, permission.getKey(), permission.getValue());
|
||||
}
|
||||
|
||||
for (String world : importFile.getPlayerWorlds(player)) {
|
||||
for (Entry<String, Boolean> permission : importFile.getPlayerPermissions(player, world).entrySet()) {
|
||||
importSQL.addPlayerPermission(player, world, permission.getKey(), permission.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
0
net/crystalyx/bukkit/simplyperms/imports/ImportManager.java → src/net/crystalyx/bukkit/simplyperms/imports/ImportManager.java
Executable file → Normal file
0
net/crystalyx/bukkit/simplyperms/imports/ImportManager.java → src/net/crystalyx/bukkit/simplyperms/imports/ImportManager.java
Executable file → Normal file
26
net/crystalyx/bukkit/simplyperms/imports/ImportPermBukkit.java → src/net/crystalyx/bukkit/simplyperms/imports/ImportPermBukkit.java
Executable file → Normal file
26
net/crystalyx/bukkit/simplyperms/imports/ImportPermBukkit.java → src/net/crystalyx/bukkit/simplyperms/imports/ImportPermBukkit.java
Executable file → Normal file
|
@ -22,32 +22,36 @@ public class ImportPermBukkit extends SimplyAPI implements ImportManager {
|
|||
@Override
|
||||
public void run() throws Exception {
|
||||
try {
|
||||
permBukkit.load("plugins/PermissionsBukkit/config.yml");
|
||||
plugin.getConfig().set("debug", permBukkit.getBoolean("debug"));
|
||||
permBukkit.load("plugins/PermissionsBukkit/config.yml");
|
||||
setDebug(permBukkit.getBoolean("debug"));
|
||||
addMessage("build", permBukkit.getString("messages/build"));
|
||||
|
||||
for (String player : getKeys(permBukkit, "users")) {
|
||||
for (String player : plugin.getKeys(permBukkit, "users")) {
|
||||
for (String group : permBukkit.getStringList("users/" + player + "/groups")) {
|
||||
addPlayerGroup(player, group);
|
||||
}
|
||||
|
||||
for (Entry<String, Object> perm : permBukkit.getConfigurationSection("users/" + player + "/permissions").getValues(false).entrySet()) {
|
||||
addPlayerPermission(player, perm.getKey(), (Boolean) perm.getValue());
|
||||
|
||||
if (permBukkit.getConfigurationSection("users/" + player + "/permissions") != null) {
|
||||
for (Entry<String, Object> perm : permBukkit.getConfigurationSection("users/" + player + "/permissions").getValues(false).entrySet()) {
|
||||
addPlayerPermission(player, perm.getKey(), (Boolean) perm.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
for (String world : getKeys(permBukkit, "users/" + player + "/worlds")) {
|
||||
for (String world : plugin.getKeys(permBukkit, "users/" + player + "/worlds")) {
|
||||
for (Entry<String, Object> worldperm : permBukkit.getConfigurationSection("users/" + player + "/worlds/" + world).getValues(false).entrySet()) {
|
||||
addPlayerPermission(player, world, worldperm.getKey(), (Boolean) worldperm.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (String group : getKeys(permBukkit, "groups")) {
|
||||
for (Entry<String, Object> perms : permBukkit.getConfigurationSection("groups/" + group + "/permissions").getValues(false).entrySet()) {
|
||||
addGroupPermission(group, perms.getKey(), (Boolean) perms.getValue());
|
||||
for (String group : plugin.getKeys(permBukkit, "groups")) {
|
||||
if (permBukkit.getConfigurationSection("groups/" + group + "/permissions") != null) {
|
||||
for (Entry<String, Object> perms : permBukkit.getConfigurationSection("groups/" + group + "/permissions").getValues(false).entrySet()) {
|
||||
addGroupPermission(group, perms.getKey(), (Boolean) perms.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
for (String world : getKeys(permBukkit, "groups/" + group + "/worlds")) {
|
||||
for (String world : plugin.getKeys(permBukkit, "groups/" + group + "/worlds")) {
|
||||
for (Entry<String, Object> worldperm : permBukkit.getConfigurationSection("groups/" + group + "/worlds/" + world).getValues(false).entrySet()) {
|
||||
addGroupPermission(group, world, worldperm.getKey(), (Boolean) worldperm.getValue());
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package net.crystalyx.bukkit.simplyperms.imports;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyAPI;
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
|
||||
|
||||
public class ImportPermEx extends SimplyAPI implements ImportManager {
|
||||
|
||||
private SimplyPlugin plugin;
|
||||
private YamlConfiguration permEx;
|
||||
|
||||
public ImportPermEx(SimplyPlugin plugin) {
|
||||
super(plugin);
|
||||
this.plugin = plugin;
|
||||
this.permEx = new YamlConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
try {
|
||||
permEx.load("plugins/PermissionsEx/config.yml");
|
||||
setDebug(permEx.getBoolean("permissions.debug"));
|
||||
permEx.load("plugins/PermissionsEx/" + permEx.getString("permissions.backends.file.file"));
|
||||
|
||||
for (String player : plugin.getKeys(permEx, "users")) {
|
||||
for (String group : permEx.getStringList("users." + player + ".group")) {
|
||||
addPlayerGroup(player, group);
|
||||
}
|
||||
|
||||
for (String perm : permEx.getStringList("users." + player + ".permissions")) {
|
||||
addPlayerPermission(player, perm.replace("-", ""), !perm.startsWith("-"));
|
||||
}
|
||||
|
||||
for (String world : plugin.getKeys(permEx, "users." + player + ".permissions.worlds")) {
|
||||
for (String worldperm : permEx.getStringList("users." + player + ".permissions.worlds." + world)) {
|
||||
addPlayerPermission(player, world, worldperm.replace("-", ""), !worldperm.startsWith("-"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (String group : plugin.getKeys(permEx, "groups")) {
|
||||
for (String perm : permEx.getStringList("groups." + group + ".permissions")) {
|
||||
addGroupPermission(group, perm.replace("-", ""), !perm.startsWith("-"));
|
||||
}
|
||||
|
||||
for (String world : plugin.getKeys(permEx, "groups." + group + ".permissions.worlds")) {
|
||||
for (String worldperm : permEx.getStringList("groups." + group + ".permissions.worlds." + world)) {
|
||||
addGroupPermission(group, world, worldperm.replace("-", ""), !worldperm.startsWith("-"));
|
||||
}
|
||||
}
|
||||
|
||||
for (String inherit : permEx.getStringList("groups." + group + ".inheritance")) {
|
||||
addGroupInheritance(group, inherit);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
30
net/crystalyx/bukkit/simplyperms/imports/ImportPrivileges.java → src/net/crystalyx/bukkit/simplyperms/imports/ImportPrivileges.java
Executable file → Normal file
30
net/crystalyx/bukkit/simplyperms/imports/ImportPrivileges.java → src/net/crystalyx/bukkit/simplyperms/imports/ImportPrivileges.java
Executable file → Normal file
|
@ -20,40 +20,38 @@ public class ImportPrivileges extends SimplyAPI implements ImportManager {
|
|||
public void run() throws Exception {
|
||||
try {
|
||||
privileges.load("plugins/Privileges/config.yml");
|
||||
String defaultGroup = privileges.getString("default_group");
|
||||
plugin.getConfig().set("debug", privileges.getBoolean("debug"));
|
||||
setDefaultGroup(privileges.getString("default_group"));
|
||||
setDebug(privileges.getBoolean("debug"));
|
||||
|
||||
privileges.load("plugins/Privileges/users.yml");
|
||||
for (String player : getKeys(privileges, "users")) {
|
||||
for (String player : plugin.getKeys(privileges, "users")) {
|
||||
addPlayerGroup(player, privileges.getString("users." + player + ".group"));
|
||||
|
||||
for (String permission : privileges.getStringList("users." + player + ".permissions")) {
|
||||
addPlayerPermission(player, permission, !permission.contains("-"));
|
||||
addPlayerPermission(player, permission.replace("-", ""), !permission.startsWith("-"));
|
||||
}
|
||||
|
||||
for (String world : getKeys(privileges, "users." + player + ".worlds")) {
|
||||
|
||||
for (String world : plugin.getKeys(privileges, "users." + player + ".worlds")) {
|
||||
for (String worldpermission : privileges.getStringList("users." + player + ".worlds." + world)) {
|
||||
addPlayerPermission(player, world, worldpermission, !worldpermission.contains("-"));
|
||||
addPlayerPermission(player, world, worldpermission.replace("-", ""), !worldpermission.startsWith("-"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
privileges.load("plugins/Privileges/groups.yml");
|
||||
for (String group : getKeys(privileges, "groups")) {
|
||||
String simplyGroup = (group.equals(defaultGroup)) ? "default" : group;
|
||||
|
||||
for (String group : plugin.getKeys(privileges, "groups")) {
|
||||
for (String permission : privileges.getStringList("groups." + group + ".permissions")) {
|
||||
addGroupPermission(simplyGroup, permission, !permission.contains("-"));
|
||||
addGroupPermission(group, permission.replace("-", ""), !permission.startsWith("-"));
|
||||
}
|
||||
|
||||
for (String world : getKeys(privileges, "groups." + group + ".worlds")) {
|
||||
|
||||
for (String world : plugin.getKeys(privileges, "groups." + group + ".worlds")) {
|
||||
for (String worldpermission : privileges.getStringList("groups." + group + ".worlds." + world)) {
|
||||
addGroupPermission(simplyGroup, world, worldpermission, !worldpermission.contains("-"));
|
||||
addGroupPermission(group, world, worldpermission.replace("-", ""), !worldpermission.startsWith("-"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (String inherit : privileges.getStringList("groups." + group + ".inheritance")) {
|
||||
addGroupInheritance(simplyGroup, inherit);
|
||||
addGroupInheritance(group, inherit);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
|
@ -1,103 +1,164 @@
|
|||
package net.crystalyx.bukkit.simplyperms;
|
||||
package net.crystalyx.bukkit.simplyperms.io;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.io.PermsConfig;
|
||||
|
||||
public class SimplyAPI implements PermsConfig {
|
||||
public class ConfigFile implements PermsConfig {
|
||||
|
||||
private SimplyPlugin plugin;
|
||||
|
||||
public SimplyAPI(SimplyPlugin plugin) {
|
||||
public ConfigFile(SimplyPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayer(String player) {
|
||||
plugin.config.removePlayer(player);
|
||||
player = player.toLowerCase();
|
||||
plugin.getConfig().set("users/" + player, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayerGroups(String player) {
|
||||
plugin.config.removePlayerGroups(player);
|
||||
player = player.toLowerCase();
|
||||
plugin.getConfig().set("users/" + player + "/groups", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayerGroup(String player, String group) {
|
||||
plugin.config.removePlayerGroup(player, group);
|
||||
player = player.toLowerCase();
|
||||
List<String> groups = getPlayerGroups(player);
|
||||
groups.remove(group);
|
||||
plugin.getConfig().set("users/" + player + "/groups", (groups.isEmpty()) ? null : groups);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerGroup(String player, String group) {
|
||||
removePlayerGroups(player);
|
||||
addPlayerGroup(player, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlayerGroup(String player, String group) {
|
||||
plugin.config.addPlayerGroup(player, group);
|
||||
player = player.toLowerCase();
|
||||
if (group.isEmpty()) return;
|
||||
List<String> groups = getPlayerGroups(player);
|
||||
if (!groups.contains(group)) groups.add(group);
|
||||
plugin.getConfig().set("users/" + player + "/groups", groups);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlayerPermission(String player, String permission, boolean value) {
|
||||
plugin.config.addPlayerPermission(player, permission, value);
|
||||
addPlayerPermission(player, "", permission, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlayerPermission(String player, String world, String permission, boolean value) {
|
||||
plugin.config.addPlayerPermission(player, world, permission, value);
|
||||
player = player.toLowerCase();
|
||||
Map<String, Boolean> permissions = getPlayerPermissions(player, world);
|
||||
if (permissions.containsKey(permission)) permissions.remove(permission);
|
||||
permissions.put(permission, value);
|
||||
if (!world.isEmpty()) {
|
||||
plugin.getConfig().set("users/" + player + "/worlds/" + world, permissions);
|
||||
}
|
||||
else {
|
||||
plugin.getConfig().set("users/" + player + "/permissions", permissions);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayerPermissions(String player) {
|
||||
plugin.config.removePlayerPermissions(player);
|
||||
player = player.toLowerCase();
|
||||
plugin.getConfig().set("users/" + player + "/permissions", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayerPermission(String player, String permission) {
|
||||
plugin.config.removePlayerPermission(player, permission);
|
||||
removePlayerPermission(player, "", permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayerPermission(String player, String world, String permission) {
|
||||
plugin.config.removePlayerPermission(player, world, permission);
|
||||
player = player.toLowerCase();
|
||||
Map<String, Boolean> permissions = getPlayerPermissions(player, world);
|
||||
permissions.remove(permission);
|
||||
if (!world.isEmpty()) {
|
||||
plugin.getConfig().set("users/" + player + "/worlds/" + world, (permissions.isEmpty()) ? null : permissions);
|
||||
}
|
||||
else {
|
||||
plugin.getConfig().set("users/" + player + "/permissions", (permissions.isEmpty()) ? null : permissions);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPlayers(String group) {
|
||||
return plugin.config.getPlayers(group);
|
||||
List<String> players = new ArrayList<String>();
|
||||
for (String player : getAllPlayers()) {
|
||||
for (String groupName : getPlayerGroups(player)) {
|
||||
if (groupName.equals(group)) {
|
||||
players.add(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPlayerGroups(String player) {
|
||||
return plugin.config.getPlayerGroups(player);
|
||||
player = player.toLowerCase();
|
||||
return plugin.getConfig().getStringList("users/" + player + "/groups");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Boolean> getPlayerPermissions(String player) {
|
||||
return plugin.config.getPlayerPermissions(player);
|
||||
return getPlayerPermissions(player, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Boolean> getPlayerPermissions(String player, String world) {
|
||||
return plugin.config.getPlayerPermissions(player, world);
|
||||
player = player.toLowerCase();
|
||||
Map<String, Boolean> finalPerms = new LinkedHashMap<String, Boolean>();
|
||||
String permNode = (!world.isEmpty()) ? "users/" + player + "/worlds/" + world : "users/" + player + "/permissions";
|
||||
if (plugin.getNode(permNode) != null) {
|
||||
for (Entry<String, Object> permPlayer : plugin.getNode(permNode).getValues(false).entrySet()) {
|
||||
finalPerms.put(permPlayer.getKey(), Boolean.valueOf(permPlayer.getValue().toString()));
|
||||
}
|
||||
}
|
||||
return finalPerms;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerInDB(String player) {
|
||||
return plugin.config.isPlayerInDB(player);
|
||||
player = player.toLowerCase();
|
||||
return plugin.getNode("users/" + player) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPlayerWorlds(String player) {
|
||||
return plugin.config.getPlayerWorlds(player);
|
||||
player = player.toLowerCase();
|
||||
if (plugin.getNode("users/" + player + "/worlds") != null) {
|
||||
return new ArrayList<String>(plugin.getNode("users/" + player + "/worlds").getKeys(false));
|
||||
}
|
||||
else {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllPlayers() {
|
||||
return plugin.config.getAllPlayers();
|
||||
if (plugin.getNode("users") != null) {
|
||||
return new ArrayList<String>(plugin.getNode("users").getKeys(false));
|
||||
}
|
||||
else {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllGroups() {
|
||||
if (plugin.getNode("groups") != null) {
|
||||
return new ArrayList<String>(plugin.getNode("groups").getKeys(false));
|
||||
|
@ -107,8 +168,9 @@ public class SimplyAPI implements PermsConfig {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroupWorlds(String group) {
|
||||
if (group.isEmpty()) group = "default";
|
||||
if (group.isEmpty()) group = getDefaultGroup();
|
||||
if (plugin.getNode("groups/" + group + "/worlds") != null) {
|
||||
return new ArrayList<String>(plugin.getNode("groups/" + group + "/worlds").getKeys(false));
|
||||
}
|
||||
|
@ -117,48 +179,55 @@ public class SimplyAPI implements PermsConfig {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroupInheritance(String group) {
|
||||
if (group.isEmpty()) group = "default";
|
||||
if (group.isEmpty()) group = getDefaultGroup();
|
||||
return plugin.getConfig().getStringList("groups/" + group + "/inheritance");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGroupInheritance(String group, String inherit) {
|
||||
if (group.isEmpty()) group = "default";
|
||||
if (group.isEmpty()) group = getDefaultGroup();
|
||||
List<String> inheritances = getGroupInheritance(group);
|
||||
if (!inheritances.contains(inherit)) inheritances.add(inherit);
|
||||
plugin.getConfig().set("groups/" + group + "/inheritance", inheritances);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGroupInheritance(String group, String inherit) {
|
||||
if (group.isEmpty()) group = "default";
|
||||
if (group.isEmpty()) group = getDefaultGroup();
|
||||
List<String> inheritances = getGroupInheritance(group);
|
||||
inheritances.remove(inherit);
|
||||
plugin.getConfig().set("groups/" + group + "/inheritance", inheritances);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeGroupInheritances(String group) {
|
||||
if (group.isEmpty()) group = "default";
|
||||
if (group.isEmpty()) group = getDefaultGroup();
|
||||
plugin.getConfig().set("groups/" + group + "/inheritance", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Boolean> getGroupPermissions(String group, String world) {
|
||||
if (group.isEmpty()) group = "default";
|
||||
Map<String, Boolean> finalPerms = new HashMap<String, Boolean>();
|
||||
if (group.isEmpty()) group = getDefaultGroup();
|
||||
Map<String, Boolean> finalPerms = new LinkedHashMap<String, Boolean>();
|
||||
String permNode = (!world.isEmpty()) ? "groups/" + group + "/worlds/" + world : "groups/" + group + "/permissions";
|
||||
if (plugin.getNode(permNode) != null) {
|
||||
for (Entry<String, Object> permGroup : plugin.getNode(permNode).getValues(false).entrySet()) {
|
||||
finalPerms.put(permGroup.getKey(), (Boolean) permGroup.getValue());
|
||||
finalPerms.put(permGroup.getKey(), Boolean.valueOf(permGroup.getValue().toString()));
|
||||
}
|
||||
}
|
||||
return finalPerms;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Boolean> getGroupPermissions(String group) {
|
||||
return getGroupPermissions(group, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGroupPermission(String group, String world, String permission, boolean value) {
|
||||
if (group.isEmpty()) group = "default";
|
||||
if (group.isEmpty()) group = getDefaultGroup();
|
||||
Map<String, Boolean> permissions = getGroupPermissions(group, world);
|
||||
if (permissions.containsKey(permission)) permissions.remove(permission);
|
||||
permissions.put(permission, value);
|
||||
|
@ -170,12 +239,14 @@ public class SimplyAPI implements PermsConfig {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGroupPermission(String group, String permission, boolean value) {
|
||||
addGroupPermission(group, "", permission, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGroupPermission(String group, String world, String permission) {
|
||||
if (group.isEmpty()) group = "default";
|
||||
if (group.isEmpty()) group = getDefaultGroup();
|
||||
Map<String, Boolean> permissions = getGroupPermissions(group, world);
|
||||
permissions.remove(permission);
|
||||
if (!world.isEmpty()) {
|
||||
|
@ -186,55 +257,70 @@ public class SimplyAPI implements PermsConfig {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGroupPermission(String group, String permission) {
|
||||
removeGroupPermission(group, "", permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGroupPermissions(String group) {
|
||||
if (group.isEmpty()) group = "default";
|
||||
if (group.isEmpty()) group = getDefaultGroup();
|
||||
plugin.getConfig().set("groups/" + group + "/permissions", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGroup(String group) {
|
||||
if (group.isEmpty() || group.equals("default")) {
|
||||
plugin.debug("You can't delete default group !");
|
||||
return;
|
||||
}
|
||||
plugin.getConfig().set("groups/" + group, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getMessages() {
|
||||
if (plugin.getNode("messages") != null) {
|
||||
return plugin.getNode("messages").getValues(false);
|
||||
}
|
||||
else {
|
||||
return new HashMap<String, Object>();
|
||||
return new LinkedHashMap<String, Object>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage(String key) {
|
||||
return plugin.getConfig().getString("messages/" + key, plugin.getConfig().getString("messages/all", "")).replace('&', '\u00A7');
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessage(String key, String message) {
|
||||
Map<String, Object> messages = getMessages();
|
||||
if (!messages.containsKey(key)) messages.put(key, message);
|
||||
plugin.getConfig().set("messages", messages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMessage(String key) {
|
||||
Map<String, Object> messages = getMessages();
|
||||
messages.remove(key);
|
||||
plugin.getConfig().set("messages", messages);
|
||||
}
|
||||
|
||||
public void refreshPermissions() {
|
||||
plugin.refreshPermissions();
|
||||
@Override
|
||||
public String getDefaultGroup() {
|
||||
return plugin.getConfig().getString("default", "default");
|
||||
}
|
||||
|
||||
protected List<String> getKeys(YamlConfiguration config, String node) {
|
||||
if (config.getConfigurationSection(node) != null) {
|
||||
return new ArrayList<String>(config.getConfigurationSection(node).getKeys(false));
|
||||
}
|
||||
else {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
@Override
|
||||
public void setDefaultGroup(String group) {
|
||||
if (group.isEmpty()) group = "default";
|
||||
plugin.getConfig().set("default", group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getDebug() {
|
||||
return plugin.getConfig().getBoolean("debug", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDebug(boolean debug) {
|
||||
plugin.getConfig().set("debug", debug);
|
||||
}
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@ import java.sql.PreparedStatement;
|
|||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.sql.Connection;
|
||||
|
@ -15,6 +15,7 @@ import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
|
|||
public class ConfigSQL implements PermsConfig {
|
||||
|
||||
private SimplyPlugin plugin;
|
||||
private ConfigFile config;
|
||||
private Connection connection;
|
||||
private String table_players;
|
||||
private String table_groups;
|
||||
|
@ -24,9 +25,10 @@ public class ConfigSQL implements PermsConfig {
|
|||
private String column_world;
|
||||
private String column_value;
|
||||
private String column_date;
|
||||
|
||||
|
||||
public ConfigSQL(SimplyPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
config = new ConfigFile(plugin);
|
||||
table_players = plugin.getConfig().getString("db/table/players");
|
||||
table_groups = plugin.getConfig().getString("db/table/groups");
|
||||
column_playerid = plugin.getConfig().getString("db/column/playerid");
|
||||
|
@ -55,7 +57,7 @@ public class ConfigSQL implements PermsConfig {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean checkDatabase() {
|
||||
if (init()) {
|
||||
String date = (!column_date.isEmpty()) ? column_date + " DATETIME," : "";
|
||||
|
@ -77,7 +79,7 @@ public class ConfigSQL implements PermsConfig {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removePlayer(String player) {
|
||||
removePlayerPermissions(player);
|
||||
|
@ -88,7 +90,7 @@ public class ConfigSQL implements PermsConfig {
|
|||
public void removePlayerGroups(String player) {
|
||||
if (init()) {
|
||||
try {
|
||||
PreparedStatement sql = connection.prepareStatement("DELETE FROM " + table_groups + " WHERE " + column_playerid + " = ?");
|
||||
PreparedStatement sql = connection.prepareStatement("DELETE FROM " + table_groups + " WHERE " + column_playerid + " = LOWER(?)");
|
||||
sql.setString(1, player);
|
||||
sql.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
|
@ -101,7 +103,7 @@ public class ConfigSQL implements PermsConfig {
|
|||
public void removePlayerGroup(String player, String group) {
|
||||
if (init()) {
|
||||
try {
|
||||
PreparedStatement sql = connection.prepareStatement("DELETE FROM " + table_groups + " WHERE " + column_playerid + " = ? AND " + column_groupname + " = ?");
|
||||
PreparedStatement sql = connection.prepareStatement("DELETE FROM " + table_groups + " WHERE " + column_playerid + " = LOWER(?) AND " + column_groupname + " = ?");
|
||||
sql.setString(1, player);
|
||||
sql.setString(2, group);
|
||||
sql.executeUpdate();
|
||||
|
@ -111,6 +113,12 @@ public class ConfigSQL implements PermsConfig {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerGroup(String player, String group) {
|
||||
removePlayerGroups(player);
|
||||
addPlayerGroup(player, group);
|
||||
}
|
||||
|
||||
private void addPlayerGroup(String player, String group, boolean first) {
|
||||
if (init()) {
|
||||
try {
|
||||
|
@ -126,10 +134,10 @@ public class ConfigSQL implements PermsConfig {
|
|||
else {
|
||||
plugin.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addPlayerGroup(String player, String group) {
|
||||
addPlayerGroup(player, group, true);
|
||||
|
@ -152,7 +160,7 @@ public class ConfigSQL implements PermsConfig {
|
|||
else {
|
||||
plugin.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,12 +178,12 @@ public class ConfigSQL implements PermsConfig {
|
|||
public void removePlayerPermissions(String player) {
|
||||
if (init()) {
|
||||
try {
|
||||
PreparedStatement sql = connection.prepareStatement("DELETE FROM " + table_players + " WHERE " + column_playerid + " = ?");
|
||||
PreparedStatement sql = connection.prepareStatement("DELETE FROM " + table_players + " WHERE " + column_playerid + " = LOWER(?)");
|
||||
sql.setString(1, player);
|
||||
sql.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
plugin.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,14 +196,14 @@ public class ConfigSQL implements PermsConfig {
|
|||
public void removePlayerPermission(String player, String world, String permission) {
|
||||
if (init()) {
|
||||
try {
|
||||
PreparedStatement sql = connection.prepareStatement("DELETE FROM " + table_players + " WHERE " + column_playerid + " = ? AND " + column_world + " = ? AND " + column_permission + " = ?");
|
||||
PreparedStatement sql = connection.prepareStatement("DELETE FROM " + table_players + " WHERE " + column_playerid + " = LOWER(?) AND " + column_world + " = ? AND " + column_permission + " = ?");
|
||||
sql.setString(1, player);
|
||||
sql.setString(2, world);
|
||||
sql.setString(3, permission);
|
||||
sql.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
plugin.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -222,7 +230,7 @@ public class ConfigSQL implements PermsConfig {
|
|||
List<String> results = new ArrayList<String>();
|
||||
if (init()) {
|
||||
try {
|
||||
PreparedStatement sql = connection.prepareStatement("SELECT " + column_groupname + " FROM " + table_groups + " WHERE " + column_playerid + " = ?");
|
||||
PreparedStatement sql = connection.prepareStatement("SELECT " + column_groupname + " FROM " + table_groups + " WHERE " + column_playerid + " = LOWER(?)");
|
||||
sql.setString(1, player);
|
||||
ResultSet players = sql.executeQuery();
|
||||
while (players.next()) {
|
||||
|
@ -242,10 +250,10 @@ public class ConfigSQL implements PermsConfig {
|
|||
|
||||
@Override
|
||||
public Map<String, Boolean> getPlayerPermissions(String player, String world) {
|
||||
Map<String, Boolean> results = new HashMap<String, Boolean>();
|
||||
Map<String, Boolean> results = new LinkedHashMap<String, Boolean>();
|
||||
if (init()) {
|
||||
try {
|
||||
PreparedStatement sql = connection.prepareStatement("SELECT " + column_permission + ", " + column_value + " FROM " + table_players + " WHERE " + column_playerid + " = ? AND " + column_world + " = ?");
|
||||
PreparedStatement sql = connection.prepareStatement("SELECT " + column_permission + ", " + column_value + " FROM " + table_players + " WHERE " + column_playerid + " = LOWER(?) AND " + column_world + " = ?");
|
||||
sql.setString(1, player);
|
||||
sql.setString(2, world);
|
||||
ResultSet permissions = sql.executeQuery();
|
||||
|
@ -264,13 +272,13 @@ public class ConfigSQL implements PermsConfig {
|
|||
if (init()) {
|
||||
try {
|
||||
int count = 0;
|
||||
PreparedStatement sql = connection.prepareStatement("SELECT COUNT(" + column_playerid + ") FROM " + table_groups + " WHERE " + column_playerid + " = ?");
|
||||
PreparedStatement sql = connection.prepareStatement("SELECT COUNT(" + column_playerid + ") FROM " + table_groups + " WHERE " + column_playerid + " = LOWER(?)");
|
||||
sql.setString(1, player);
|
||||
ResultSet results = sql.executeQuery();
|
||||
if (results.next()) {
|
||||
count += results.getInt(1);
|
||||
}
|
||||
sql = connection.prepareStatement("SELECT COUNT(" + column_playerid + ") FROM " + table_players + " WHERE " + column_playerid + " = ?");
|
||||
sql = connection.prepareStatement("SELECT COUNT(" + column_playerid + ") FROM " + table_players + " WHERE " + column_playerid + " = LOWER(?)");
|
||||
sql.setString(1, player);
|
||||
results = sql.executeQuery();
|
||||
if (results.next()) {
|
||||
|
@ -280,7 +288,7 @@ public class ConfigSQL implements PermsConfig {
|
|||
} catch (SQLException e) {
|
||||
plugin.debug(e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -290,7 +298,7 @@ public class ConfigSQL implements PermsConfig {
|
|||
List<String> results = new ArrayList<String>();
|
||||
if (init()) {
|
||||
try {
|
||||
PreparedStatement sql = connection.prepareStatement("SELECT " + column_world + " FROM " + table_players + " WHERE " + column_playerid + " = ?");
|
||||
PreparedStatement sql = connection.prepareStatement("SELECT " + column_world + " FROM " + table_players + " WHERE " + column_playerid + " = LOWER(?)");
|
||||
sql.setString(1, player);
|
||||
ResultSet players = sql.executeQuery();
|
||||
while (players.next()) {
|
||||
|
@ -327,4 +335,114 @@ public class ConfigSQL implements PermsConfig {
|
|||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllGroups() {
|
||||
return config.getAllGroups();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroupWorlds(String group) {
|
||||
return config.getGroupWorlds(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroupInheritance(String group) {
|
||||
return config.getGroupInheritance(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGroupInheritance(String group, String inherit) {
|
||||
config.addGroupInheritance(group, inherit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGroupInheritance(String group, String inherit) {
|
||||
config.removeGroupInheritance(group, inherit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGroupInheritances(String group) {
|
||||
config.removeGroupInheritances(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Boolean> getGroupPermissions(String group, String world) {
|
||||
return config.getGroupPermissions(group, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Boolean> getGroupPermissions(String group) {
|
||||
return config.getGroupPermissions(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGroupPermission(String group, String world, String permission, boolean value) {
|
||||
config.addGroupPermission(group, world, permission, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGroupPermission(String group, String permission, boolean value) {
|
||||
config.addGroupPermission(group, permission, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGroupPermission(String group, String world, String permission) {
|
||||
config.removeGroupPermission(group, world, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGroupPermission(String group, String permission) {
|
||||
config.removeGroupPermission(group, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGroupPermissions(String group) {
|
||||
config.removeGroupPermissions(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGroup(String group) {
|
||||
config.removeGroup(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getMessages() {
|
||||
return config.getMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage(String key) {
|
||||
return config.getMessage(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessage(String key, String message) {
|
||||
config.addMessage(key, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMessage(String key) {
|
||||
config.removeMessage(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultGroup() {
|
||||
return config.getDefaultGroup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultGroup(String group) {
|
||||
config.setDefaultGroup(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getDebug() {
|
||||
return config.getDebug();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDebug(boolean debug) {
|
||||
config.setDebug(debug);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package net.crystalyx.bukkit.simplyperms.io;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface PermsConfig {
|
||||
|
||||
public void removePlayer(String player);
|
||||
|
||||
public void removePlayerGroups(String player);
|
||||
|
||||
public void removePlayerGroup(String player, String group);
|
||||
|
||||
public void setPlayerGroup(String player, String group);
|
||||
|
||||
public void addPlayerGroup(String player, String group);
|
||||
|
||||
public void addPlayerPermission(String player, String permission, boolean value);
|
||||
|
||||
public void addPlayerPermission(String player, String world, String permission, boolean value);
|
||||
|
||||
public void removePlayerPermissions(String player);
|
||||
|
||||
public void removePlayerPermission(String player, String permission);
|
||||
|
||||
public void removePlayerPermission(String player, String world, String permission);
|
||||
|
||||
public List<String> getPlayers(String group);
|
||||
|
||||
public List<String> getPlayerGroups(String player);
|
||||
|
||||
public Map<String, Boolean> getPlayerPermissions(String player);
|
||||
|
||||
public Map<String, Boolean> getPlayerPermissions(String player, String world);
|
||||
|
||||
public boolean isPlayerInDB(String player);
|
||||
|
||||
public List<String> getPlayerWorlds(String player);
|
||||
|
||||
public List<String> getAllPlayers();
|
||||
|
||||
public List<String> getAllGroups();
|
||||
|
||||
public List<String> getGroupWorlds(String group);
|
||||
|
||||
public List<String> getGroupInheritance(String group);
|
||||
|
||||
public void addGroupInheritance(String group, String inherit);
|
||||
|
||||
public void removeGroupInheritance(String group, String inherit);
|
||||
|
||||
public void removeGroupInheritances(String group);
|
||||
|
||||
public Map<String, Boolean> getGroupPermissions(String group, String world);
|
||||
|
||||
public Map<String, Boolean> getGroupPermissions(String group);
|
||||
|
||||
public void addGroupPermission(String group, String world, String permission, boolean value);
|
||||
|
||||
public void addGroupPermission(String group, String permission, boolean value);
|
||||
|
||||
public void removeGroupPermission(String group, String world, String permission);
|
||||
|
||||
public void removeGroupPermission(String group, String permission);
|
||||
|
||||
public void removeGroupPermissions(String group);
|
||||
|
||||
public void removeGroup(String group);
|
||||
|
||||
public Map<String, Object> getMessages();
|
||||
|
||||
public String getMessage(String key);
|
||||
|
||||
public void addMessage(String key, String message);
|
||||
|
||||
public void removeMessage(String key);
|
||||
|
||||
public String getDefaultGroup();
|
||||
|
||||
public void setDefaultGroup(String group);
|
||||
|
||||
public boolean getDebug();
|
||||
|
||||
public void setDebug(boolean debug);
|
||||
|
||||
}
|
0
net/crystalyx/bukkit/simplyperms/preventions/Bow.java → src/net/crystalyx/bukkit/simplyperms/preventions/Bow.java
Executable file → Normal file
0
net/crystalyx/bukkit/simplyperms/preventions/Bow.java → src/net/crystalyx/bukkit/simplyperms/preventions/Bow.java
Executable file → Normal file
0
net/crystalyx/bukkit/simplyperms/preventions/Changesign.java → src/net/crystalyx/bukkit/simplyperms/preventions/Changesign.java
Executable file → Normal file
0
net/crystalyx/bukkit/simplyperms/preventions/Changesign.java → src/net/crystalyx/bukkit/simplyperms/preventions/Changesign.java
Executable file → Normal file
2
net/crystalyx/bukkit/simplyperms/preventions/Command.java → src/net/crystalyx/bukkit/simplyperms/preventions/Command.java
Executable file → Normal file
2
net/crystalyx/bukkit/simplyperms/preventions/Command.java → src/net/crystalyx/bukkit/simplyperms/preventions/Command.java
Executable file → Normal file
|
@ -27,5 +27,5 @@ public class Command extends SimplyPrevents {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
2
net/crystalyx/bukkit/simplyperms/preventions/Damage.java → src/net/crystalyx/bukkit/simplyperms/preventions/Damage.java
Executable file → Normal file
2
net/crystalyx/bukkit/simplyperms/preventions/Damage.java → src/net/crystalyx/bukkit/simplyperms/preventions/Damage.java
Executable file → Normal file
|
@ -43,5 +43,5 @@ public class Damage extends SimplyPrevents {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
2
net/crystalyx/bukkit/simplyperms/preventions/Fight.java → src/net/crystalyx/bukkit/simplyperms/preventions/Fight.java
Executable file → Normal file
2
net/crystalyx/bukkit/simplyperms/preventions/Fight.java → src/net/crystalyx/bukkit/simplyperms/preventions/Fight.java
Executable file → Normal file
|
@ -29,5 +29,5 @@ public class Fight extends SimplyPrevents {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
2
net/crystalyx/bukkit/simplyperms/preventions/Hunger.java → src/net/crystalyx/bukkit/simplyperms/preventions/Hunger.java
Executable file → Normal file
2
net/crystalyx/bukkit/simplyperms/preventions/Hunger.java → src/net/crystalyx/bukkit/simplyperms/preventions/Hunger.java
Executable file → Normal file
|
@ -22,5 +22,5 @@ public class Hunger extends SimplyPrevents {
|
|||
prevent(event, (Player) entity, "hunger");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
2
net/crystalyx/bukkit/simplyperms/preventions/Item.java → src/net/crystalyx/bukkit/simplyperms/preventions/Item.java
Executable file → Normal file
2
net/crystalyx/bukkit/simplyperms/preventions/Item.java → src/net/crystalyx/bukkit/simplyperms/preventions/Item.java
Executable file → Normal file
|
@ -28,5 +28,5 @@ public class Item extends SimplyPrevents {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
2
net/crystalyx/bukkit/simplyperms/preventions/Monster.java → src/net/crystalyx/bukkit/simplyperms/preventions/Monster.java
Executable file → Normal file
2
net/crystalyx/bukkit/simplyperms/preventions/Monster.java → src/net/crystalyx/bukkit/simplyperms/preventions/Monster.java
Executable file → Normal file
|
@ -22,5 +22,5 @@ public class Monster extends SimplyPrevents {
|
|||
prevent(event, (Player) target, "monster");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
2
net/crystalyx/bukkit/simplyperms/preventions/Sneak.java → src/net/crystalyx/bukkit/simplyperms/preventions/Sneak.java
Executable file → Normal file
2
net/crystalyx/bukkit/simplyperms/preventions/Sneak.java → src/net/crystalyx/bukkit/simplyperms/preventions/Sneak.java
Executable file → Normal file
|
@ -24,5 +24,5 @@ public class Sneak extends SimplyPrevents {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@ import org.bukkit.event.EventPriority;
|
|||
import org.bukkit.event.player.PlayerShearEntityEvent;
|
||||
|
||||
public class Shear extends SimplyPrevents {
|
||||
|
||||
|
||||
public Shear(SimplyPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
@ -17,5 +17,5 @@ public class Shear extends SimplyPrevents {
|
|||
public void shear(PlayerShearEntityEvent event) {
|
||||
prevent(event, event.getPlayer(), "shear,animals,interact");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -20,5 +20,5 @@ public class Tame extends SimplyPrevents {
|
|||
prevent(event, (Player) event.getOwner(), "tame,animals,interact");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -28,5 +28,5 @@ public class Lavabucket extends SimplyPrevents {
|
|||
prevent(event, event.getPlayer(), "lavabucket,bucket,interact");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -20,5 +20,5 @@ public class Milking extends SimplyPrevents {
|
|||
prevent(event, event.getPlayer(), "milking,bucket,interact");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -28,5 +28,5 @@ public class Waterbucket extends SimplyPrevents {
|
|||
prevent(event, event.getPlayer(), "waterbucket,bucket,interact");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -24,5 +24,5 @@ public class Placeblock extends SimplyPrevents {
|
|||
public void paintingPlaceblock(PaintingPlaceEvent event) {
|
||||
prevent(event, event.getPlayer(), "placeblock." + Material.PAINTING.getId() + ",build." + Material.PAINTING.getId());
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package net.crystalyx.bukkit.simplyperms.preventions.spam;
|
||||
package net.crystalyx.bukkit.simplyperms.preventions.chat;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -20,11 +20,11 @@ public class CapsLock extends SimplyPrevents {
|
|||
for (Player player : super.plugin.getServer().getOnlinePlayers()) {
|
||||
message.replace(player.getName(), "");
|
||||
}
|
||||
String nocaps = message.replaceAll("[A-Z]*", "");
|
||||
String nocaps = message.replaceAll("[A-Z]*", "");
|
||||
if (message.length() > 5
|
||||
&& message.length() - nocaps.length() > message.length() / 2) {
|
||||
prevent(event, event.getPlayer(), "capslock,spam");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
4
net/crystalyx/bukkit/simplyperms/preventions/Chat.java → src/net/crystalyx/bukkit/simplyperms/preventions/chat/Chat.java
Executable file → Normal file
4
net/crystalyx/bukkit/simplyperms/preventions/Chat.java → src/net/crystalyx/bukkit/simplyperms/preventions/chat/Chat.java
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
|||
package net.crystalyx.bukkit.simplyperms.preventions;
|
||||
package net.crystalyx.bukkit.simplyperms.preventions.chat;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPrevents;
|
||||
|
@ -19,5 +19,5 @@ public class Chat extends SimplyPrevents {
|
|||
prevent(event, event.getPlayer(), "chat");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
4
net/crystalyx/bukkit/simplyperms/preventions/spam/Flood.java → src/net/crystalyx/bukkit/simplyperms/preventions/chat/Flood.java
Executable file → Normal file
4
net/crystalyx/bukkit/simplyperms/preventions/spam/Flood.java → src/net/crystalyx/bukkit/simplyperms/preventions/chat/Flood.java
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
|||
package net.crystalyx.bukkit.simplyperms.preventions.spam;
|
||||
package net.crystalyx.bukkit.simplyperms.preventions.chat;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
@ -13,7 +13,7 @@ import org.bukkit.event.player.PlayerChatEvent;
|
|||
public class Flood extends SimplyPrevents {
|
||||
|
||||
private HashMap<Player, Long> chatTimestamps = new HashMap<Player, Long>();
|
||||
|
||||
|
||||
public Flood(SimplyPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package net.crystalyx.bukkit.simplyperms.preventions.chat;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPrevents;
|
||||
|
||||
public class Macros extends SimplyPrevents {
|
||||
|
||||
private HashMap<Player, Long> commandsTimestamps = new HashMap<Player, Long>();
|
||||
|
||||
public Macros(SimplyPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void chat(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (isChatLocked(player)) {
|
||||
prevent(event, player, "macros,spam");
|
||||
} else {
|
||||
setChatLock(player);
|
||||
}
|
||||
}
|
||||
|
||||
private void setChatLock(Player player) {
|
||||
commandsTimestamps.put(player, Long.valueOf(System.currentTimeMillis() + 2000));
|
||||
}
|
||||
|
||||
private boolean isChatLocked(Player player) {
|
||||
Long nextPossible = commandsTimestamps.get(player);
|
||||
if (nextPossible == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
long currentTime = System.currentTimeMillis();
|
||||
return nextPossible.longValue() >= currentTime;
|
||||
}
|
||||
|
||||
}
|
2
net/crystalyx/bukkit/simplyperms/preventions/craft/Brew.java → src/net/crystalyx/bukkit/simplyperms/preventions/craft/Brew.java
Executable file → Normal file
2
net/crystalyx/bukkit/simplyperms/preventions/craft/Brew.java → src/net/crystalyx/bukkit/simplyperms/preventions/craft/Brew.java
Executable file → Normal file
|
@ -23,5 +23,5 @@ public class Brew extends SimplyPrevents {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -11,7 +11,7 @@ import org.bukkit.event.block.Action;
|
|||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class Chest extends SimplyPrevents {
|
||||
|
||||
|
||||
public Chest(SimplyPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
|
@ -23,5 +23,5 @@ public class Dispenser extends SimplyPrevents {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -23,5 +23,5 @@ public class Enchant extends SimplyPrevents {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -23,5 +23,5 @@ public class Furnace extends SimplyPrevents {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -23,5 +23,5 @@ public class Workbench extends SimplyPrevents {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -23,5 +23,5 @@ public class FlintAndSteel extends SimplyPrevents {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -10,7 +10,7 @@ import org.bukkit.event.block.Action;
|
|||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class Button extends SimplyPrevents {
|
||||
|
||||
|
||||
public Button(SimplyPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
@ -25,5 +25,5 @@ public class Button extends SimplyPrevents {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -10,7 +10,7 @@ import org.bukkit.event.block.Action;
|
|||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class Door extends SimplyPrevents {
|
||||
|
||||
|
||||
public Door(SimplyPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
@ -30,5 +30,5 @@ public class Door extends SimplyPrevents {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -17,5 +17,5 @@ public class Fish extends SimplyPrevents {
|
|||
public void fish(PlayerFishEvent event) {
|
||||
prevent(event, event.getPlayer(), "fish,interact");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -23,5 +23,5 @@ public class Jukebox extends SimplyPrevents {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -25,5 +25,5 @@ public class Lever extends SimplyPrevents {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -25,5 +25,5 @@ public class Noteblock extends SimplyPrevents {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -25,5 +25,5 @@ public class Pressureplate extends SimplyPrevents {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -25,5 +25,5 @@ public class Repeater extends SimplyPrevents {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
0
net/crystalyx/bukkit/simplyperms/preventions/loot/Drop.java → src/net/crystalyx/bukkit/simplyperms/preventions/loot/Drop.java
Executable file → Normal file
0
net/crystalyx/bukkit/simplyperms/preventions/loot/Drop.java → src/net/crystalyx/bukkit/simplyperms/preventions/loot/Drop.java
Executable file → Normal file
|
@ -17,5 +17,5 @@ public class Pickup extends SimplyPrevents {
|
|||
public void pickup(PlayerPickupItemEvent event) {
|
||||
prevent(event, event.getPlayer(), "pickup." + event.getItem().getItemStack().getTypeId() + ",loot." + event.getItem().getItemStack().getTypeId());
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package net.crystalyx.bukkit.simplyperms.preventions.projectile;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPrevents;
|
||||
|
||||
public class EnderPearl extends SimplyPrevents {
|
||||
|
||||
public EnderPearl(SimplyPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void egg(PlayerInteractEvent event) {
|
||||
if (event.getAction() == Action.RIGHT_CLICK_AIR
|
||||
|| event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (event.getPlayer().getItemInHand().getType() == Material.ENDER_PEARL) {
|
||||
prevent(event, event.getPlayer(), "enderpearl,projectile");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -25,5 +25,5 @@ public class Potion extends SimplyPrevents {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -24,5 +24,5 @@ public class Snowball extends SimplyPrevents {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package net.crystalyx.bukkit.simplyperms.preventions.vehicle;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPrevents;
|
||||
|
||||
public class Collision extends SimplyPrevents {
|
||||
|
||||
public Collision(SimplyPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void vehicleCollision(VehicleEntityCollisionEvent event) {
|
||||
Entity collider = event.getEntity();
|
||||
if (collider instanceof Player) {
|
||||
if (prevent(event, (Player) collider, "vehicle.collision")) {
|
||||
event.setCollisionCancelled(true);
|
||||
event.setPickupCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package net.crystalyx.bukkit.simplyperms.preventions.vehicle;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPrevents;
|
||||
|
||||
public class Destroy extends SimplyPrevents {
|
||||
|
||||
public Destroy(SimplyPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void vehicleDestroy(VehicleDestroyEvent event) {
|
||||
Entity attacker = event.getAttacker();
|
||||
if (attacker instanceof Player) {
|
||||
prevent(event, (Player) attacker, "vehicle.destroy");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package net.crystalyx.bukkit.simplyperms.preventions.vehicle;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPrevents;
|
||||
|
||||
public class Enter extends SimplyPrevents {
|
||||
|
||||
public Enter(SimplyPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void vehicleEnter(VehicleEnterEvent event) {
|
||||
Entity entered = event.getEntered();
|
||||
if (entered instanceof Player) {
|
||||
prevent(event, (Player) entered, "vehicle.enter");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package net.crystalyx.bukkit.simplyperms.preventions.vehicle;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPrevents;
|
||||
|
||||
public class Place extends SimplyPrevents {
|
||||
|
||||
public Place(SimplyPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void vehiclePlace(PlayerInteractEvent event) {
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
Material clickedMaterial = event.getClickedBlock().getType();
|
||||
Player player = event.getPlayer();
|
||||
Material materialInHand = player.getItemInHand().getType();
|
||||
if (clickedMaterial == Material.RAILS
|
||||
|| clickedMaterial == Material.POWERED_RAIL
|
||||
|| clickedMaterial == Material.DETECTOR_RAIL) {
|
||||
if (materialInHand == Material.MINECART
|
||||
|| materialInHand == Material.POWERED_MINECART
|
||||
|| materialInHand == Material.STORAGE_MINECART) {
|
||||
prevent(event, player, "vehicle.place");
|
||||
}
|
||||
} else if (materialInHand == Material.BOAT) {
|
||||
prevent(event, player, "vehicle.place");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,284 @@
|
|||
name: SimplyPerms
|
||||
main: net.crystalyx.bukkit.simplyperms.SimplyPlugin
|
||||
author: Xefir Destiny
|
||||
website: http://dev.bukkit.org/server-mods/simplyperms/
|
||||
version: 1.7.6
|
||||
dscription: When powerful plugin made Permissions easy !
|
||||
softdepend: [ PermissionsBukkit ]
|
||||
commands:
|
||||
permissions:
|
||||
aliases: [ perms, perm, p ]
|
||||
description: Commands for manipulating permissions.
|
||||
usage: |
|
||||
/<command> reload - reload the configuration from disk.
|
||||
/<command> check <node> [player] - check if a player or the sender has a permission (any plugin).
|
||||
/<command> info <node> - prints information on a specific permission.
|
||||
/<command> dump [player] [page] - prints info about a player's (or the sender's) permissions.
|
||||
/<command> import <type> - Import data from database or others permissions plugins
|
||||
/<command> group - list group-related commands.
|
||||
/<command> group list - list all groups.
|
||||
/<command> group players <group> - list players in a group.
|
||||
/<command> group setperm <group> <[world:]node> [true|false] - set a permission on a group.
|
||||
/<command> group unsetperm <group> <[world:]node> - unset a permission on a group.
|
||||
/<command> player - list player-related commands.
|
||||
/<command> player groups <player> - list groups a player is in.
|
||||
/<command> player setgroup <player> <group,...> - set a player to be in only the given groups.
|
||||
/<command> player addgroup <player> <group> - add a player to a group.
|
||||
/<command> player removegroup <player> <group> - remove a player from a group.
|
||||
/<command> player remove <player> - remove a player from config file.
|
||||
/<command> player setperm <player> <[world:]node> [true|false] - set a permission on a player.
|
||||
/<command> player unsetperm <player> <[world:]node> - unset a permission on a player.
|
||||
permissions:
|
||||
permissions.*:
|
||||
default: op
|
||||
description: Allows use of all PermissionsBukkit administration commands.
|
||||
children:
|
||||
permissions.help: true
|
||||
permissions.reload: true
|
||||
permissions.check: true
|
||||
permissions.info: true
|
||||
permissions.dump: true
|
||||
permissions.import: true
|
||||
permissions.group.*: true
|
||||
permissions.player.*: true
|
||||
permissions.allow.*: true
|
||||
permissions.help:
|
||||
description: Allows viewing of usage for /permissions.
|
||||
permissions.reload:
|
||||
description: Allows use of /permissions reload.
|
||||
permissions.check:
|
||||
description: Allows use of /permissions check.
|
||||
permissions.info:
|
||||
description: Allows use of /permissions info.
|
||||
permissions.dump:
|
||||
description: Allows use of /permissions dump.
|
||||
permissions.import:
|
||||
description: Allows use of /permissions import.
|
||||
permissions.group.*:
|
||||
description: Allows use of all /permissions group commands.
|
||||
children:
|
||||
permissions.group.help: true
|
||||
permissions.group.list: true
|
||||
permissions.group.players: true
|
||||
permissions.group.setperm: true
|
||||
permissions.group.unsetperm: true
|
||||
permissions.group.help:
|
||||
description: Allows viewing of usage for /permissions group.
|
||||
permissions.group.list:
|
||||
description: Allows use of /permissions group list.
|
||||
permissions.group.players:
|
||||
description: Allows use of /permissions group players.
|
||||
permissions.group.setperm:
|
||||
description: Allows use of /permissions group setperm.
|
||||
permissions.group.unsetperm:
|
||||
description: Allows use of /permissions group unsetperm.
|
||||
permissions.player.*:
|
||||
description: Allows use of all /permissions player commands.
|
||||
children:
|
||||
permissions.player.help: true
|
||||
permissions.player.groups: true
|
||||
permissions.player.setgroup: true
|
||||
permissions.player.addgroup: true
|
||||
permissions.player.removegroup: true
|
||||
permissions.player.remove: true
|
||||
permissions.player.setperm: true
|
||||
permissions.player.unsetperm: true
|
||||
permissions.player.help:
|
||||
description: Allows viewing of usage for /permissions player.
|
||||
permissions.player.groups:
|
||||
description: Allows use of /permissions player groups.
|
||||
permissions.player.setgroup:
|
||||
description: Allows use of /permissions player setgroup.
|
||||
permissions.player.addgroup:
|
||||
description: Allows use of /permissions player addgroup.
|
||||
permissions.player.removegroup:
|
||||
description: Allows use of /permissions player removegroup.
|
||||
permissions.player.remove:
|
||||
description: Allows use of /permissions player remove.
|
||||
permissions.player.setperm:
|
||||
description: Allows use of /permissions player setperm.
|
||||
permissions.player.unsetperm:
|
||||
description: Allows use of /permissions player unsetperm.
|
||||
permissions.allow.*:
|
||||
description: Allows player to do everything.
|
||||
default: true
|
||||
children:
|
||||
permissions.allow.bow: true
|
||||
permissions.allow.changesign: true
|
||||
permissions.allow.command: true
|
||||
permissions.allow.damage: true
|
||||
permissions.allow.fight: true
|
||||
permissions.allow.hunger: true
|
||||
permissions.allow.item: true
|
||||
permissions.allow.monster: true
|
||||
permissions.allow.sneak: true
|
||||
permissions.allow.build: true
|
||||
permissions.allow.chat: true
|
||||
permissions.allow.craft: true
|
||||
permissions.allow.interact: true
|
||||
permissions.allow.loot: true
|
||||
permissions.allow.projectile: true
|
||||
permissions.allow.vehicle: true
|
||||
permissions.allow.bow:
|
||||
description: Allows the player to shoot bows
|
||||
permissions.allow.changesign:
|
||||
description: Allows the player to change signs
|
||||
permissions.allow.chat:
|
||||
description: Allows the player to chat
|
||||
permissions.allow.command:
|
||||
description: Allows the player to use all commands
|
||||
permissions.allow.damage:
|
||||
description: Allows the player to be damaged by anything
|
||||
permissions.allow.fight:
|
||||
description: Allows the player to fight
|
||||
permissions.allow.hunger:
|
||||
description: Allows the player to die by hunger
|
||||
permissions.allow.item:
|
||||
description: Allows the player to do item related things
|
||||
permissions.allow.monster:
|
||||
description: Allows the player to get targeted by mosters
|
||||
permissions.allow.sneak:
|
||||
description: Allows the player to sneak except in creative mode
|
||||
permissions.allow.build:
|
||||
description: Allows the player to build
|
||||
children:
|
||||
permissions.allow.placeblock: true
|
||||
permissions.allow.breakblock: true
|
||||
permissions.allow.placeblock:
|
||||
decription: Allows the player to place blocks
|
||||
permissions.allow.breakblock:
|
||||
description: Allows the player to break blocks
|
||||
permissions.allow.craft:
|
||||
description: Allows the player to do crafting related things
|
||||
children:
|
||||
permissions.allow.brew: true
|
||||
permissions.allow.chest: true
|
||||
permissions.allow.dispenser: true
|
||||
permissions.allow.enchant: true
|
||||
permissions.allow.furnace: true
|
||||
permissions.allow.workbench: true
|
||||
permissions.allow.brew:
|
||||
description: Allows the player to brew
|
||||
permissions.allow.chest:
|
||||
description: Allows the player to use chests
|
||||
permissions.allow.dispenser:
|
||||
description: Allows the player to dispense
|
||||
permissions.allow.enchant:
|
||||
description: Allows the player to enchant
|
||||
permissions.allow.furnace:
|
||||
description: Allows the player to furnace
|
||||
permissions.allow.workbench:
|
||||
description: Allows the player to craft
|
||||
permissions.allow.interact:
|
||||
description: Allows the player to interact with the world
|
||||
children:
|
||||
permissions.allow.bed: true
|
||||
permissions.allow.button: true
|
||||
permissions.allow.cake: true
|
||||
permissions.allow.door: true
|
||||
permissions.allow.fish: true
|
||||
permissions.allow.jukebox: true
|
||||
permissions.allow.lever: true
|
||||
permissions.allow.noteblocks: true
|
||||
permissions.allow.pressureplate: true
|
||||
permissions.allow.repeater: true
|
||||
permissions.allow.animals: true
|
||||
permissions.allow.bucket: true
|
||||
permissions.allow.fire: true
|
||||
permissions.allow.bed:
|
||||
description: Allows the player to sleep in beds
|
||||
permissions.allow.button:
|
||||
description: Allows the player to push buttons
|
||||
permissions.allow.cake:
|
||||
description: Allows the player to eat cake
|
||||
permissions.allow.door:
|
||||
description: Allows the player to open and close doors
|
||||
permissions.allow.fish:
|
||||
description: Allows the player to fish
|
||||
permissions.allow.jukebox:
|
||||
description: Allows the player to use jukebox
|
||||
permissions.allow.lever:
|
||||
description: Allows the player to use levers
|
||||
permissions.allow.noteblocks:
|
||||
description: Allows the player to change noteblocks
|
||||
permissions.allow.pressureplate:
|
||||
description: Allows the player to trigger pressure plates
|
||||
permissions.allow.repeater:
|
||||
description: Allows the player to change repeater delays
|
||||
permissions.allow.animals:
|
||||
description: Allows the player to interact with animals
|
||||
children:
|
||||
permissions.allow.shear: true
|
||||
permissions.allow.tame: true
|
||||
permissions.allow.shear:
|
||||
description: Allows the player to shear animals
|
||||
permissions.allow.tame:
|
||||
description: Allows the player to tame animals
|
||||
permissions.allow.bucket:
|
||||
description: Allows the player to use buckets
|
||||
children:
|
||||
permissions.allow.waterbucket: true
|
||||
permissions.allow.lavabucket: true
|
||||
permissions.allow.milking: true
|
||||
permissions.allow.waterbucket:
|
||||
description: Allows the player to use water buckets
|
||||
permissions.allow.lavabucket:
|
||||
description: Allows the player to use lava buckets
|
||||
permissions.allow.milking:
|
||||
description: Allows the player to fill buckets with milk
|
||||
permissions.allow.fire:
|
||||
description: Allows the player to make fire
|
||||
children:
|
||||
permissions.allow.fireball: true
|
||||
permissions.allow.flintandsteel: true
|
||||
permissions.allow.fireball:
|
||||
description: Allows the player to use fireball
|
||||
permissions.allow.flintandsteel:
|
||||
description: Allows the player to use flint and steel
|
||||
permissions.allow.loot:
|
||||
description: Allows the player to drop and pickup items
|
||||
children:
|
||||
permissions.allow.drop: true
|
||||
permissions.allow.pickup: true
|
||||
permissions.allow.drop:
|
||||
description: Allows the player to drop items
|
||||
permissions.allow.pickup:
|
||||
description: Allows the player to pickup items
|
||||
permissions.allow.chat:
|
||||
description: Allows the player to chat
|
||||
children:
|
||||
permissions.allow.spam: true
|
||||
permissions.allow.spam:
|
||||
description: Allows the player to spam
|
||||
children:
|
||||
permissions.allow.capslock: true
|
||||
permissions.allow.flood: true
|
||||
permissions.allow.macros: true
|
||||
permissions.allow.capslock:
|
||||
description: ALLOWS THE PLAYER TO USE CAPSLOCK
|
||||
permissions.allow.flood:
|
||||
description: Allows the player to chat as fast as he wants
|
||||
permissions.allow.macros:
|
||||
description: Allows the player to spam commands
|
||||
permissions.allow.projectile:
|
||||
description: Allows the player to throw items
|
||||
children:
|
||||
permissions.allow.egg: true
|
||||
permissions.allow.potion: true
|
||||
permissions.allow.snowball: true
|
||||
permissions.allow.enderpearl: true
|
||||
permissions.allow.vehicle:
|
||||
description: Allows the player to use vehicles
|
||||
children:
|
||||
permissions.allow.vehicle.collision: true
|
||||
permissions.allow.vehicle.destroy: true
|
||||
permissions.allow.vehicle.enter: true
|
||||
permissions.allow.vehicle.place: true
|
||||
permissions.allow.vehicle.collision:
|
||||
description: Allows the player to collide with vehicles
|
||||
permissions.allow.vehicle.destroy:
|
||||
description: Allows the player to destroy vehicles
|
||||
permissions.allow.vehicle.enter:
|
||||
description: Allows the player to enter into vehicles
|
||||
permissions.allow.vehicle.place:
|
||||
description: Allows the player to place vehicles
|
Loading…
Reference in New Issue