Nouvelle indentation
This commit is contained in:
parent
35bbe58be3
commit
0f4ab0c659
@ -135,7 +135,7 @@ public class SimplyAPI implements PermsConfig {
|
|||||||
inheritances.remove(inherit);
|
inheritances.remove(inherit);
|
||||||
plugin.getConfig().set("groups/" + group + "/inheritance", inheritances);
|
plugin.getConfig().set("groups/" + group + "/inheritance", inheritances);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeGroupInheritances(String group) {
|
public void removeGroupInheritances(String group) {
|
||||||
if (group.isEmpty()) group = getDefaultGroup();
|
if (group.isEmpty()) group = getDefaultGroup();
|
||||||
plugin.getConfig().set("groups/" + group + "/inheritance", null);
|
plugin.getConfig().set("groups/" + group + "/inheritance", null);
|
||||||
|
@ -34,458 +34,458 @@ public class SimplyCommands implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] split) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] split) {
|
||||||
if (split.length < 1) {
|
if (split.length < 1) {
|
||||||
return !checkPerm(sender, "help") || usage(sender, command);
|
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")) {
|
String subcommand = split[0];
|
||||||
manager = new ImportPermBukkit(plugin);
|
if (subcommand.equals("reload")) {
|
||||||
} else if (pluginName.equals("privileges")) {
|
if (!checkPerm(sender, "reload")) return true;
|
||||||
manager = new ImportPrivileges(plugin);
|
plugin.reloadConfig();
|
||||||
} else if (pluginName.equals("permissionsex")) {
|
plugin.refreshPermissions();
|
||||||
manager = new ImportPermEx(plugin);
|
sender.sendMessage(ChatColor.GREEN + "Configuration reloaded.");
|
||||||
} else if (pluginName.equals("file")) {
|
return true;
|
||||||
manager = new ImportFile(plugin);
|
} if (subcommand.equals("check")) {
|
||||||
} else if (plugin.getConfig().getString("db/type") != null
|
if (!checkPerm(sender, "check")) return true;
|
||||||
&& pluginName.equals(plugin.getConfig().getString("db/type").toLowerCase())) {
|
if (split.length != 2 && split.length != 3) return usage(sender, command, subcommand);
|
||||||
manager = new ImportDB(plugin);
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(ChatColor.RED + "Unknown import type !");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
String node = split[1];
|
||||||
manager.run();
|
Permissible permissible;
|
||||||
plugin.refreshPermissions();
|
if (split.length == 2) {
|
||||||
sender.sendMessage(ChatColor.GREEN + "Operation success !");
|
permissible = sender;
|
||||||
} catch (Exception e) {
|
} else {
|
||||||
plugin.reloadConfig();
|
permissible = plugin.getServer().getPlayer(split[2]);
|
||||||
sender.sendMessage(ChatColor.RED + "An error occurred ! Please check server log...");
|
}
|
||||||
e.printStackTrace();
|
|
||||||
}
|
String name = (permissible instanceof Player) ? ((Player) permissible).getName() : (permissible instanceof ConsoleCommandSender) ? "Console" : "Unknown";
|
||||||
return true;
|
|
||||||
} else {
|
if (permissible == null) {
|
||||||
return !checkPerm(sender, "help") || usage(sender, command);
|
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();
|
||||||
|
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) {
|
private boolean groupCommand(CommandSender sender, Command command, String[] split) {
|
||||||
String subcommand = split[1];
|
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 (split.length >= 4 && !checkPerm(sender, "group.setperm", Arrays.asList(split[3].split(",")))) 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);
|
if (subcommand.equals("list")) {
|
||||||
plugin.refreshPermissions();
|
if (!checkPerm(sender, "group.list")) return true;
|
||||||
|
if (split.length != 2) return usage(sender, command, "group list");
|
||||||
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 (split.length >= 4 && !checkPerm(sender, "group.unsetperm", Arrays.asList(split[3].split(",")))) 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);
|
String result = "", sep = "";
|
||||||
if (!sec.contains(perm)) {
|
for (String key : plugin.getNode("groups").getKeys(false)) {
|
||||||
sender.sendMessage(ChatColor.GREEN + "Group " + ChatColor.WHITE + group + ChatColor.GREEN + " did not have " + ChatColor.WHITE + perm + ChatColor.GREEN + " set.");
|
result += sep + key;
|
||||||
return true;
|
sep = ", ";
|
||||||
}
|
}
|
||||||
sec.set(perm, null);
|
sender.sendMessage(ChatColor.GREEN + "Groups: " + ChatColor.WHITE + result);
|
||||||
plugin.refreshPermissions();
|
return true;
|
||||||
|
} else if (subcommand.equals("players")) {
|
||||||
sender.sendMessage(ChatColor.GREEN + "Group " + ChatColor.WHITE + group + ChatColor.GREEN + " no longer has " + ChatColor.WHITE + perm + ChatColor.GREEN + " set.");
|
if (!checkPerm(sender, "group.players")) return true;
|
||||||
return true;
|
if (split.length != 3) return usage(sender, command, "group players");
|
||||||
} else {
|
String group = split[2];
|
||||||
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 (split.length == 4 && !checkPerm(sender, "player.setgroup", Arrays.asList(split[3].split(",")))) 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);
|
if (plugin.getNode("groups/" + group) == null) {
|
||||||
for (String group : Arrays.asList(groups)) {
|
sender.sendMessage(ChatColor.RED + "No such group " + ChatColor.WHITE + group + ChatColor.RED + ".");
|
||||||
plugin.config.addPlayerGroup(player, group);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.refreshPermissions();
|
int count = 0;
|
||||||
|
String text = "", sep = "";
|
||||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is now in " + ChatColor.WHITE + split[3] + ChatColor.GREEN + ".");
|
for (String user : plugin.config.getPlayers(group)) {
|
||||||
return true;
|
++count;
|
||||||
} else if (subcommand.equals("addgroup")) {
|
text += sep + user;
|
||||||
if (split.length == 4 && !checkPerm(sender, "player.addgroup", Arrays.asList(split[3]))) return true;
|
sep = ", ";
|
||||||
if (split.length != 4) return usage(sender, command, "player addgroup");
|
}
|
||||||
String player = split[2].toLowerCase();
|
sender.sendMessage(ChatColor.GREEN + "Users in " + ChatColor.WHITE + group + ChatColor.GREEN + " (" + ChatColor.WHITE + count + ChatColor.GREEN + "): " + ChatColor.WHITE + text);
|
||||||
String group = split[3];
|
return true;
|
||||||
|
} else if (subcommand.equals("setperm")) {
|
||||||
if (plugin.config.getPlayerGroups(player).contains(group)) {
|
if (split.length >= 4 && !checkPerm(sender, "group.setperm", Arrays.asList(split[3].split(",")))) return true;
|
||||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " was already in " + ChatColor.WHITE + group + ChatColor.GREEN + ".");
|
if (split.length != 4 && split.length != 5) return usage(sender, command, "group setperm");
|
||||||
return true;
|
String group = split[2];
|
||||||
}
|
String perm = split[3];
|
||||||
plugin.config.addPlayerGroup(player, group);
|
boolean value = (split.length != 5) || Boolean.parseBoolean(split[4]);
|
||||||
|
|
||||||
plugin.refreshPermissions();
|
String node = "permissions";
|
||||||
|
if (plugin.getNode("groups/" + group) == null) {
|
||||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is now in " + ChatColor.WHITE + group + ChatColor.GREEN + ".");
|
sender.sendMessage(ChatColor.RED + "No such group " + ChatColor.WHITE + group + ChatColor.RED + ".");
|
||||||
return true;
|
return true;
|
||||||
} else if (subcommand.equals("removegroup")) {
|
}
|
||||||
if (split.length == 4 && !checkPerm(sender, "player.removegroup", Arrays.asList(split[3]))) 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)) {
|
if (perm.contains(":")) {
|
||||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " was not in " + ChatColor.WHITE + group + ChatColor.GREEN + ".");
|
String world = perm.substring(0, perm.indexOf(':'));
|
||||||
return true;
|
perm = perm.substring(perm.indexOf(':') + 1);
|
||||||
}
|
node = "worlds/" + world;
|
||||||
plugin.config.removePlayerGroup(player, group);
|
}
|
||||||
|
if (plugin.getNode("groups/" + group + "/" + node) == null) {
|
||||||
|
plugin.getConfig().createSection("groups/" + group + "/" + node);
|
||||||
|
}
|
||||||
|
|
||||||
plugin.refreshPermissions();
|
plugin.getNode("groups/" + group + "/" + node).set(perm, value);
|
||||||
|
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 + "Group " + ChatColor.WHITE + group + ChatColor.GREEN + " now has " + ChatColor.WHITE + perm + ChatColor.GREEN + " = " + ChatColor.WHITE + value + ChatColor.GREEN + ".");
|
||||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " was not in config file.");
|
return true;
|
||||||
return true;
|
} else if (subcommand.equals("unsetperm")) {
|
||||||
}
|
if (split.length >= 4 && !checkPerm(sender, "group.unsetperm", Arrays.asList(split[3].split(",")))) return true;
|
||||||
|
if (split.length != 4) return usage(sender, command, "group unsetperm");
|
||||||
|
String group = split[2].toLowerCase();
|
||||||
|
String perm = split[3];
|
||||||
|
|
||||||
plugin.config.removePlayer(player);
|
String node = "permissions";
|
||||||
plugin.refreshPermissions();
|
if (plugin.getNode("groups/" + group) == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "No such group " + ChatColor.WHITE + group + ChatColor.RED + ".");
|
||||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is no longer in config file.");
|
return true;
|
||||||
return true;
|
}
|
||||||
} else if (subcommand.equals("setperm")) {
|
|
||||||
if (split.length >= 4 && !checkPerm(sender, "player.setperm", Arrays.asList(split[3].split(",")))) 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(":")) {
|
||||||
if (perm.contains(":")) {
|
String world = perm.substring(0, perm.indexOf(':'));
|
||||||
world = perm.substring(0, perm.indexOf(':'));
|
perm = perm.substring(perm.indexOf(':') + 1);
|
||||||
perm = perm.substring(perm.indexOf(':') + 1);
|
node = "worlds/" + world;
|
||||||
}
|
}
|
||||||
|
if (plugin.getNode("groups/" + group + "/" + node) == null) {
|
||||||
|
plugin.getConfig().createSection("groups/" + group + "/" + node);
|
||||||
|
}
|
||||||
|
|
||||||
plugin.config.addPlayerPermission(player, world, perm, value);
|
ConfigurationSection sec = plugin.getNode("groups/" + group + "/" + node);
|
||||||
plugin.refreshPermissions();
|
if (!sec.contains(perm)) {
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Group " + ChatColor.WHITE + group + ChatColor.GREEN + " did not have " + ChatColor.WHITE + perm + ChatColor.GREEN + " set.");
|
||||||
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " now has " + ChatColor.WHITE + perm + ChatColor.GREEN + " = " + ChatColor.WHITE + value + ChatColor.GREEN + ".");
|
return true;
|
||||||
return true;
|
}
|
||||||
} else if (subcommand.equals("unsetperm")) {
|
sec.set(perm, null);
|
||||||
if (split.length >= 4 && !checkPerm(sender, "player.unsetperm", Arrays.asList(split[3].split(",")))) return true;
|
plugin.refreshPermissions();
|
||||||
if (split.length != 4) return usage(sender, command, "player unsetperm");
|
|
||||||
String player = split[2].toLowerCase();
|
|
||||||
String perm = split[3];
|
|
||||||
|
|
||||||
String world = "";
|
sender.sendMessage(ChatColor.GREEN + "Group " + ChatColor.WHITE + group + ChatColor.GREEN + " no longer has " + ChatColor.WHITE + perm + ChatColor.GREEN + " set.");
|
||||||
if (perm.contains(":")) {
|
return true;
|
||||||
world = perm.substring(0, perm.indexOf(':'));
|
} else {
|
||||||
perm = perm.substring(perm.indexOf(':') + 1);
|
return !checkPerm(sender, "group.help") || usage(sender, command);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, Boolean> list = plugin.config.getPlayerPermissions(player, world);
|
private boolean playerCommand(CommandSender sender, Command command, String[] split) {
|
||||||
if (!list.containsKey(perm)) {
|
String subcommand = split[1];
|
||||||
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 checkPerm(CommandSender sender, String node, List<String> subnodes) {
|
|
||||||
boolean ok = sender.hasPermission("permissions." + node);
|
|
||||||
if (!ok) {
|
|
||||||
for (String subnode : subnodes) {
|
|
||||||
String testnode = "";
|
|
||||||
for (String sub : subnode.split(".")) {
|
|
||||||
testnode += sub;
|
|
||||||
if (sender.hasPermission("permissions." + node + "." + testnode)) {
|
|
||||||
ok = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ok) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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");
|
if (subcommand.equals("groups")) {
|
||||||
usage = usage.replaceAll("\\[[^]:]+\\]", ChatColor.AQUA + "$0" + ChatColor.GREEN);
|
if (!checkPerm(sender, "player.groups")) return true;
|
||||||
usage = usage.replaceAll("\\[[^]]+:\\]", ChatColor.AQUA + "$0" + ChatColor.LIGHT_PURPLE);
|
if (split.length != 3) return usage(sender, command, "player groups");
|
||||||
usage = usage.replaceAll("<[^>]+>", ChatColor.LIGHT_PURPLE + "$0" + ChatColor.GREEN);
|
String player = split[2].toLowerCase();
|
||||||
|
|
||||||
return ChatColor.GREEN + usage + " - " + ChatColor.WHITE + desc;
|
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 (split.length == 4 && !checkPerm(sender, "player.setgroup", Arrays.asList(split[3].split(",")))) 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 (split.length == 4 && !checkPerm(sender, "player.addgroup", Arrays.asList(split[3]))) 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 (split.length == 4 && !checkPerm(sender, "player.removegroup", Arrays.asList(split[3]))) 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 (split.length >= 4 && !checkPerm(sender, "player.setperm", Arrays.asList(split[3].split(",")))) 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 (split.length >= 4 && !checkPerm(sender, "player.unsetperm", Arrays.asList(split[3].split(",")))) 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 checkPerm(CommandSender sender, String node, List<String> subnodes) {
|
||||||
|
boolean ok = sender.hasPermission("permissions." + node);
|
||||||
|
if (!ok) {
|
||||||
|
for (String subnode : subnodes) {
|
||||||
|
String testnode = "";
|
||||||
|
for (String sub : subnode.split(".")) {
|
||||||
|
testnode += sub;
|
||||||
|
if (sender.hasPermission("permissions." + node + "." + testnode)) {
|
||||||
|
ok = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,40 +11,40 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
public class SimplyPlayer implements Listener {
|
public class SimplyPlayer implements Listener {
|
||||||
|
|
||||||
private SimplyPlugin plugin;
|
private SimplyPlugin plugin;
|
||||||
|
|
||||||
public SimplyPlayer(SimplyPlugin plugin) {
|
public SimplyPlayer(SimplyPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep track of player's world
|
// 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.LOWEST)
|
||||||
|
public void onWorldChange(PlayerChangedWorldEvent event) {
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
plugin.debug("Player " + event.getPlayer().getName() + " changed world, recalculating...");
|
||||||
public void onPlayerKick(PlayerKickEvent event) {
|
plugin.calculateAttachment(event.getPlayer());
|
||||||
if (event.isCancelled()) return;
|
}
|
||||||
plugin.debug("Player " + event.getPlayer().getName() + " was kicked, unregistering...");
|
|
||||||
plugin.unregisterPlayer(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
// Register players when needed
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
|
||||||
plugin.debug("Player " + event.getPlayer().getName() + " quit, unregistering...");
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
plugin.unregisterPlayer(event.getPlayer());
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,14 +23,14 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
public class SimplyPlugin extends JavaPlugin {
|
public class SimplyPlugin extends JavaPlugin {
|
||||||
|
|
||||||
protected PermsConfig config;
|
protected PermsConfig config;
|
||||||
private SimplyPlayer playerListener = new SimplyPlayer(this);
|
private SimplyPlayer playerListener = new SimplyPlayer(this);
|
||||||
private SimplyCommands commandExecutor = new SimplyCommands(this);
|
private SimplyCommands commandExecutor = new SimplyCommands(this);
|
||||||
private HashMap<String, PermissionAttachment> permissions = new HashMap<String, PermissionAttachment>();
|
private HashMap<String, PermissionAttachment> permissions = new HashMap<String, PermissionAttachment>();
|
||||||
|
|
||||||
private File configFile;
|
private File configFile;
|
||||||
private YamlConfiguration YamlConfig;
|
private YamlConfiguration YamlConfig;
|
||||||
|
|
||||||
// -- Basic stuff
|
// -- Basic stuff
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
// Unregister existing PermissionsBukkit nodes
|
// Unregister existing PermissionsBukkit nodes
|
||||||
@ -47,55 +47,55 @@ public class SimplyPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Take care of configuration
|
// Take care of configuration
|
||||||
configFile = new File(getDataFolder(), "config.yml");
|
configFile = new File(getDataFolder(), "config.yml");
|
||||||
if (!configFile.exists()) {
|
if (!configFile.exists()) {
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
}
|
}
|
||||||
reloadConfig();
|
reloadConfig();
|
||||||
|
|
||||||
// Register stuff
|
// Register stuff
|
||||||
getCommand("permissions").setExecutor(commandExecutor);
|
getCommand("permissions").setExecutor(commandExecutor);
|
||||||
getServer().getPluginManager().registerEvents(playerListener, this);
|
getServer().getPluginManager().registerEvents(playerListener, this);
|
||||||
registerEvents();
|
registerEvents();
|
||||||
|
|
||||||
// Register everyone online right now
|
// Register everyone online right now
|
||||||
for (Player p : getServer().getOnlinePlayers()) {
|
for (Player p : getServer().getOnlinePlayers()) {
|
||||||
registerPlayer(p);
|
registerPlayer(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
// How are you gentlemen
|
// How are you gentlemen
|
||||||
getLogger().info("Enabled successfully, " + getServer().getOnlinePlayers().length + " players registered");
|
getLogger().info("Enabled successfully, " + getServer().getOnlinePlayers().length + " players registered");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileConfiguration getConfig() {
|
public FileConfiguration getConfig() {
|
||||||
return YamlConfig;
|
return YamlConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reloadConfig() {
|
public void reloadConfig() {
|
||||||
YamlConfig = new YamlConfiguration();
|
YamlConfig = new YamlConfiguration();
|
||||||
YamlConfig.options().pathSeparator('/');
|
YamlConfig.options().pathSeparator('/');
|
||||||
try {
|
try {
|
||||||
YamlConfig.load(configFile);
|
YamlConfig.load(configFile);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
getLogger().severe("Unable to load configuration!");
|
getLogger().severe("Unable to load configuration!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init DB
|
// Init DB
|
||||||
initDatabase();
|
initDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
// Unregister everyone
|
// Unregister everyone
|
||||||
for (Player p : getServer().getOnlinePlayers()) {
|
for (Player p : getServer().getOnlinePlayers()) {
|
||||||
unregisterPlayer(p);
|
unregisterPlayer(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Good day to you! I said good day!
|
// Good day to you! I said good day!
|
||||||
getLogger().info("Disabled successfully, " + getServer().getOnlinePlayers().length + " players unregistered");
|
getLogger().info("Disabled successfully, " + getServer().getOnlinePlayers().length + " players unregistered");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initDatabase() {
|
private void initDatabase() {
|
||||||
@ -118,172 +118,172 @@ public class SimplyPlugin extends JavaPlugin {
|
|||||||
return new SimplyAPI(this);
|
return new SimplyAPI(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- Plugin stuff
|
// -- 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) {
|
protected void registerPlayer(Player player) {
|
||||||
if (permissions.containsKey(player.getName())) {
|
if (permissions.containsKey(player.getName())) {
|
||||||
try {
|
debug("Registering " + player.getName() + ": was already registered");
|
||||||
player.removeAttachment(permissions.get(player.getName()));
|
unregisterPlayer(player);
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException ex) {
|
PermissionAttachment attachment = player.addAttachment(this);
|
||||||
debug("Unregistering " + player.getName() + ": player did not have attachment");
|
permissions.put(player.getName(), attachment);
|
||||||
}
|
calculateAttachment(player);
|
||||||
permissions.remove(player.getName());
|
}
|
||||||
} else {
|
|
||||||
debug("Unregistering " + player.getName() + ": was not registered");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void refreshPermissions() {
|
protected void unregisterPlayer(Player player) {
|
||||||
try {
|
if (permissions.containsKey(player.getName())) {
|
||||||
getConfig().save(configFile);
|
try {
|
||||||
reloadConfig();
|
player.removeAttachment(permissions.get(player.getName()));
|
||||||
} catch (IOException e) {
|
}
|
||||||
getLogger().warning("Failed to write changed config.yml: " + e.getMessage());
|
catch (IllegalArgumentException ex) {
|
||||||
}
|
debug("Unregistering " + player.getName() + ": player did not have attachment");
|
||||||
for (String player : permissions.keySet()) {
|
}
|
||||||
PermissionAttachment attachment = permissions.get(player);
|
permissions.remove(player.getName());
|
||||||
for (String key : attachment.getPermissions().keySet()) {
|
} else {
|
||||||
attachment.unsetPermission(key);
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public 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;
|
||||||
|
}
|
||||||
|
|
||||||
calculateAttachment(getServer().getPlayer(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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
public void debug(String message) {
|
||||||
if (getConfig().getBoolean("debug", false)) {
|
if (getConfig().getBoolean("debug", false)) {
|
||||||
getLogger().info("Debug: " + message);
|
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()) {
|
protected void calculateAttachment(Player player) {
|
||||||
attachment.setPermission(entry.getKey(), entry.getValue());
|
if (player == null) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
PermissionAttachment attachment = permissions.get(player.getName());
|
||||||
|
if (attachment == null) {
|
||||||
|
debug("Calculating permissions on " + player.getName() + ": attachment was null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
player.recalculatePermissions();
|
for (String key : attachment.getPermissions().keySet()) {
|
||||||
}
|
attachment.unsetPermission(key);
|
||||||
|
}
|
||||||
|
|
||||||
// -- Private stuff
|
for (Map.Entry<String, Boolean> entry : calculatePlayerPermissions(player.getName().toLowerCase(), player.getWorld().getName()).entrySet()) {
|
||||||
|
attachment.setPermission(entry.getKey(), entry.getValue());
|
||||||
private Map<String, Boolean> calculatePlayerPermissions(String player, String world) {
|
}
|
||||||
String default_group = getConfig().getString("default", "default");
|
|
||||||
if (!config.isPlayerInDB(player)) {
|
|
||||||
return calculateGroupPermissions(default_group, world);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Boolean> perms = new HashMap<String, Boolean>();
|
player.recalculatePermissions();
|
||||||
List<String> groups = config.getPlayerGroups(player);
|
}
|
||||||
if (groups.isEmpty()) groups.add(default_group);
|
|
||||||
|
|
||||||
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()) {
|
// -- Private stuff
|
||||||
// No containskey; world overrides non-world
|
|
||||||
perms.put(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String group : groups) {
|
private Map<String, Boolean> calculatePlayerPermissions(String player, String world) {
|
||||||
for (Map.Entry<String, Boolean> entry : calculateGroupPermissions(group, world).entrySet()) {
|
String default_group = getConfig().getString("default", "default");
|
||||||
if (!perms.containsKey(entry.getKey())) { // User overrides group
|
if (!config.isPlayerInDB(player)) {
|
||||||
perms.put(entry.getKey(), entry.getValue());
|
return calculateGroupPermissions(default_group, world);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return perms;
|
Map<String, Boolean> perms = new HashMap<String, Boolean>();
|
||||||
}
|
List<String> groups = config.getPlayerGroups(player);
|
||||||
|
if (groups.isEmpty()) groups.add(default_group);
|
||||||
|
|
||||||
private Map<String, Boolean> calculateGroupPermissions(String group, String world) {
|
for (Entry<String, Boolean> entry : config.getPlayerPermissions(player).entrySet()) {
|
||||||
if (getNode("groups/" + group) == null) {
|
perms.put(entry.getKey(), entry.getValue());
|
||||||
return new HashMap<String, Boolean>();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Boolean> perms = getNode("groups/" + group + "/permissions") == null ?
|
for (Entry<String, Boolean> entry : config.getPlayerPermissions(player, world).entrySet()) {
|
||||||
new HashMap<String, Boolean>() :
|
// No containskey; world overrides non-world
|
||||||
getAllPerms("group " + group, "groups/" + group + "/permissions");
|
perms.put(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
if (getNode("groups/" + group + "/worlds/" + world) != null) {
|
for (String group : groups) {
|
||||||
for (Map.Entry<String, Boolean> entry : getAllPerms("group " + group, "groups/" + group + "/worlds/" + world).entrySet()) {
|
for (Map.Entry<String, Boolean> entry : calculateGroupPermissions(group, world).entrySet()) {
|
||||||
// No containskey; world overrides non-world
|
if (!perms.containsKey(entry.getKey())) { // User overrides group
|
||||||
perms.put(entry.getKey(), entry.getValue());
|
perms.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (String parent : getNode("groups/" + group).getStringList("inheritance")) {
|
return perms;
|
||||||
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 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() {
|
private void registerEvents() {
|
||||||
String path = getDescription().getMain().substring(0, getDescription().getMain().lastIndexOf('.'));
|
String path = getDescription().getMain().substring(0, getDescription().getMain().lastIndexOf('.'));
|
||||||
@ -294,6 +294,6 @@ public class SimplyPlugin extends JavaPlugin {
|
|||||||
debug(e.getMessage());
|
debug(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ public abstract class SimplyPrevents implements Listener {
|
|||||||
throttleTimestamps.put(player, Long.valueOf(current + 3000));
|
throttleTimestamps.put(player, Long.valueOf(current + 3000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deny(Cancellable event, Player player, String node) {
|
private void deny(Cancellable event, Player player, String node) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if (plugin.getConfig().getString("messages/" + node) != null) {
|
if (plugin.getConfig().getString("messages/" + node) != null) {
|
||||||
|
@ -18,31 +18,31 @@ public class ImportDB extends SimplyAPI implements ImportManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() throws Exception {
|
public void run() throws Exception {
|
||||||
try {
|
try {
|
||||||
ConfigFile importFile = new ConfigFile(plugin);
|
ConfigFile importFile = new ConfigFile(plugin);
|
||||||
ConfigSQL importSQL = new ConfigSQL(plugin);
|
ConfigSQL importSQL = new ConfigSQL(plugin);
|
||||||
if (!importSQL.checkDatabase()) {
|
if (!importSQL.checkDatabase()) {
|
||||||
throw new Exception("Could not connect to database !");
|
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()) {
|
for (String player : importSQL.getAllPlayers()) {
|
||||||
importFile.addPlayerPermission(player, permission.getKey(), permission.getValue());
|
for (String group : importSQL.getPlayerGroups(player)) {
|
||||||
}
|
importFile.addPlayerGroup(player, group);
|
||||||
|
}
|
||||||
|
|
||||||
for (String world : importSQL.getPlayerWorlds(player)) {
|
for (Entry<String, Boolean> permission : importSQL.getPlayerPermissions(player).entrySet()) {
|
||||||
for (Entry<String, Boolean> permission : importSQL.getPlayerPermissions(player, world).entrySet()) {
|
importFile.addPlayerPermission(player, permission.getKey(), permission.getValue());
|
||||||
importFile.addPlayerPermission(player, world, permission.getKey(), permission.getValue());
|
}
|
||||||
}
|
|
||||||
}
|
for (String world : importSQL.getPlayerWorlds(player)) {
|
||||||
}
|
for (Entry<String, Boolean> permission : importSQL.getPlayerPermissions(player, world).entrySet()) {
|
||||||
} catch (Exception e) {
|
importFile.addPlayerPermission(player, world, permission.getKey(), permission.getValue());
|
||||||
throw e;
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,31 +18,31 @@ public class ImportFile extends SimplyAPI implements ImportManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() throws Exception {
|
public void run() throws Exception {
|
||||||
try {
|
try {
|
||||||
ConfigFile importFile = new ConfigFile(plugin);
|
ConfigFile importFile = new ConfigFile(plugin);
|
||||||
ConfigSQL importSQL = new ConfigSQL(plugin);
|
ConfigSQL importSQL = new ConfigSQL(plugin);
|
||||||
if (!importSQL.checkDatabase()) {
|
if (!importSQL.checkDatabase()) {
|
||||||
throw new Exception("Could not connect to database !");
|
throw new Exception("Could not connect to database !");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String player : importFile.getAllPlayers()) {
|
for (String player : importFile.getAllPlayers()) {
|
||||||
for (String group : importFile.getPlayerGroups(player)) {
|
for (String group : importFile.getPlayerGroups(player)) {
|
||||||
importSQL.addPlayerGroup(player, group);
|
importSQL.addPlayerGroup(player, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Entry<String, Boolean> permission : importFile.getPlayerPermissions(player).entrySet()) {
|
for (Entry<String, Boolean> permission : importFile.getPlayerPermissions(player).entrySet()) {
|
||||||
importSQL.addPlayerPermission(player, permission.getKey(), permission.getValue());
|
importSQL.addPlayerPermission(player, permission.getKey(), permission.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String world : importFile.getPlayerWorlds(player)) {
|
for (String world : importFile.getPlayerWorlds(player)) {
|
||||||
for (Entry<String, Boolean> permission : importFile.getPlayerPermissions(player, world).entrySet()) {
|
for (Entry<String, Boolean> permission : importFile.getPlayerPermissions(player, world).entrySet()) {
|
||||||
importSQL.addPlayerPermission(player, world, permission.getKey(), permission.getValue());
|
importSQL.addPlayerPermission(player, world, permission.getKey(), permission.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ public class ImportPermBukkit extends SimplyAPI implements ImportManager {
|
|||||||
@Override
|
@Override
|
||||||
public void run() throws Exception {
|
public void run() throws Exception {
|
||||||
try {
|
try {
|
||||||
permBukkit.load("plugins/PermissionsBukkit/config.yml");
|
permBukkit.load("plugins/PermissionsBukkit/config.yml");
|
||||||
plugin.getConfig().set("debug", permBukkit.getBoolean("debug"));
|
plugin.getConfig().set("debug", permBukkit.getBoolean("debug"));
|
||||||
addMessage("build", permBukkit.getString("messages/build"));
|
addMessage("build", permBukkit.getString("messages/build"));
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ public class ImportPermBukkit extends SimplyAPI implements ImportManager {
|
|||||||
for (String group : permBukkit.getStringList("users/" + player + "/groups")) {
|
for (String group : permBukkit.getStringList("users/" + player + "/groups")) {
|
||||||
addPlayerGroup(player, group);
|
addPlayerGroup(player, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Entry<String, Object> perm : permBukkit.getConfigurationSection("users/" + player + "/permissions").getValues(false).entrySet()) {
|
for (Entry<String, Object> perm : permBukkit.getConfigurationSection("users/" + player + "/permissions").getValues(false).entrySet()) {
|
||||||
addPlayerPermission(player, perm.getKey(), (Boolean) perm.getValue());
|
addPlayerPermission(player, perm.getKey(), (Boolean) perm.getValue());
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ public class ImportPermEx extends SimplyAPI implements ImportManager {
|
|||||||
|
|
||||||
private SimplyPlugin plugin;
|
private SimplyPlugin plugin;
|
||||||
private YamlConfiguration permEx;
|
private YamlConfiguration permEx;
|
||||||
|
|
||||||
public ImportPermEx(SimplyPlugin plugin) {
|
public ImportPermEx(SimplyPlugin plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@ -22,12 +22,12 @@ public class ImportPermEx extends SimplyAPI implements ImportManager {
|
|||||||
permEx.load("plugins/PermissionsEx/config.yml");
|
permEx.load("plugins/PermissionsEx/config.yml");
|
||||||
plugin.getConfig().set("debug", permEx.getBoolean("permissions.debug"));
|
plugin.getConfig().set("debug", permEx.getBoolean("permissions.debug"));
|
||||||
permEx.load("plugins/PermissionsEx/" + permEx.getString("permissions.backends.file.file"));
|
permEx.load("plugins/PermissionsEx/" + permEx.getString("permissions.backends.file.file"));
|
||||||
|
|
||||||
for (String player : getKeys(permEx, "users")) {
|
for (String player : getKeys(permEx, "users")) {
|
||||||
for (String group : permEx.getStringList("users." + player + ".group")) {
|
for (String group : permEx.getStringList("users." + player + ".group")) {
|
||||||
addPlayerGroup(player, group);
|
addPlayerGroup(player, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String perm : permEx.getStringList("users." + player + ".permissions")) {
|
for (String perm : permEx.getStringList("users." + player + ".permissions")) {
|
||||||
addPlayerPermission(player, perm.replace("-", ""), !perm.startsWith("-"));
|
addPlayerPermission(player, perm.replace("-", ""), !perm.startsWith("-"));
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class ImportPrivileges extends SimplyAPI implements ImportManager {
|
|||||||
for (String permission : privileges.getStringList("users." + player + ".permissions")) {
|
for (String permission : privileges.getStringList("users." + player + ".permissions")) {
|
||||||
addPlayerPermission(player, permission.replace("-", ""), !permission.startsWith("-"));
|
addPlayerPermission(player, permission.replace("-", ""), !permission.startsWith("-"));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String world : getKeys(privileges, "users." + player + ".worlds")) {
|
for (String world : getKeys(privileges, "users." + player + ".worlds")) {
|
||||||
for (String worldpermission : privileges.getStringList("users." + player + ".worlds." + world)) {
|
for (String worldpermission : privileges.getStringList("users." + player + ".worlds." + world)) {
|
||||||
addPlayerPermission(player, world, worldpermission.replace("-", ""), !worldpermission.startsWith("-"));
|
addPlayerPermission(player, world, worldpermission.replace("-", ""), !worldpermission.startsWith("-"));
|
||||||
@ -43,13 +43,13 @@ public class ImportPrivileges extends SimplyAPI implements ImportManager {
|
|||||||
for (String permission : privileges.getStringList("groups." + group + ".permissions")) {
|
for (String permission : privileges.getStringList("groups." + group + ".permissions")) {
|
||||||
addGroupPermission(group, permission.replace("-", ""), !permission.startsWith("-"));
|
addGroupPermission(group, permission.replace("-", ""), !permission.startsWith("-"));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String world : getKeys(privileges, "groups." + group + ".worlds")) {
|
for (String world : getKeys(privileges, "groups." + group + ".worlds")) {
|
||||||
for (String worldpermission : privileges.getStringList("groups." + group + ".worlds." + world)) {
|
for (String worldpermission : privileges.getStringList("groups." + group + ".worlds." + world)) {
|
||||||
addGroupPermission(group, world, worldpermission.replace("-", ""), !worldpermission.startsWith("-"));
|
addGroupPermission(group, world, worldpermission.replace("-", ""), !worldpermission.startsWith("-"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String inherit : privileges.getStringList("groups." + group + ".inheritance")) {
|
for (String inherit : privileges.getStringList("groups." + group + ".inheritance")) {
|
||||||
addGroupInheritance(group, inherit);
|
addGroupInheritance(group, inherit);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ public class ConfigSQL implements PermsConfig {
|
|||||||
private String column_world;
|
private String column_world;
|
||||||
private String column_value;
|
private String column_value;
|
||||||
private String column_date;
|
private String column_date;
|
||||||
|
|
||||||
public ConfigSQL(SimplyPlugin plugin) {
|
public ConfigSQL(SimplyPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
table_players = plugin.getConfig().getString("db/table/players");
|
table_players = plugin.getConfig().getString("db/table/players");
|
||||||
@ -55,7 +55,7 @@ public class ConfigSQL implements PermsConfig {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkDatabase() {
|
public boolean checkDatabase() {
|
||||||
if (init()) {
|
if (init()) {
|
||||||
String date = (!column_date.isEmpty()) ? column_date + " DATETIME," : "";
|
String date = (!column_date.isEmpty()) ? column_date + " DATETIME," : "";
|
||||||
@ -77,7 +77,7 @@ public class ConfigSQL implements PermsConfig {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removePlayer(String player) {
|
public void removePlayer(String player) {
|
||||||
removePlayerPermissions(player);
|
removePlayerPermissions(player);
|
||||||
@ -126,10 +126,10 @@ public class ConfigSQL implements PermsConfig {
|
|||||||
else {
|
else {
|
||||||
plugin.debug(e.getMessage());
|
plugin.debug(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPlayerGroup(String player, String group) {
|
public void addPlayerGroup(String player, String group) {
|
||||||
addPlayerGroup(player, group, true);
|
addPlayerGroup(player, group, true);
|
||||||
@ -152,7 +152,7 @@ public class ConfigSQL implements PermsConfig {
|
|||||||
else {
|
else {
|
||||||
plugin.debug(e.getMessage());
|
plugin.debug(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ public class ConfigSQL implements PermsConfig {
|
|||||||
sql.executeUpdate();
|
sql.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
plugin.debug(e.getMessage());
|
plugin.debug(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ public class ConfigSQL implements PermsConfig {
|
|||||||
sql.executeUpdate();
|
sql.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
plugin.debug(e.getMessage());
|
plugin.debug(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,7 +280,7 @@ public class ConfigSQL implements PermsConfig {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
plugin.debug(e.getMessage());
|
plugin.debug(e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ public interface PermsConfig {
|
|||||||
public void addPlayerGroup(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 permission, boolean value);
|
||||||
|
|
||||||
public void addPlayerPermission(String player, String world, String permission, boolean value);
|
public void addPlayerPermission(String player, String world, String permission, boolean value);
|
||||||
|
|
||||||
public void removePlayerPermissions(String player);
|
public void removePlayerPermissions(String player);
|
||||||
@ -34,7 +34,7 @@ public interface PermsConfig {
|
|||||||
public boolean isPlayerInDB(String player);
|
public boolean isPlayerInDB(String player);
|
||||||
|
|
||||||
public List<String> getPlayerWorlds(String player);
|
public List<String> getPlayerWorlds(String player);
|
||||||
|
|
||||||
public List<String> getAllPlayers();
|
public List<String> getAllPlayers();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,5 @@ public class Chat extends SimplyPrevents {
|
|||||||
prevent(event, event.getPlayer(), "chat");
|
prevent(event, event.getPlayer(), "chat");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,5 +27,5 @@ public class Command extends SimplyPrevents {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,5 +43,5 @@ public class Damage extends SimplyPrevents {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,5 +29,5 @@ public class Fight extends SimplyPrevents {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,5 +22,5 @@ public class Hunger extends SimplyPrevents {
|
|||||||
prevent(event, (Player) entity, "hunger");
|
prevent(event, (Player) entity, "hunger");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,5 +28,5 @@ public class Item extends SimplyPrevents {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,5 +22,5 @@ public class Monster extends SimplyPrevents {
|
|||||||
prevent(event, (Player) target, "monster");
|
prevent(event, (Player) target, "monster");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,5 +24,5 @@ public class Sneak extends SimplyPrevents {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -66,5 +66,5 @@ public class Vehicle extends SimplyPrevents {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.player.PlayerShearEntityEvent;
|
import org.bukkit.event.player.PlayerShearEntityEvent;
|
||||||
|
|
||||||
public class Shear extends SimplyPrevents {
|
public class Shear extends SimplyPrevents {
|
||||||
|
|
||||||
public Shear(SimplyPlugin plugin) {
|
public Shear(SimplyPlugin plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
}
|
}
|
||||||
@ -17,5 +17,5 @@ public class Shear extends SimplyPrevents {
|
|||||||
public void shear(PlayerShearEntityEvent event) {
|
public void shear(PlayerShearEntityEvent event) {
|
||||||
prevent(event, event.getPlayer(), "shear,animals,interact");
|
prevent(event, event.getPlayer(), "shear,animals,interact");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,5 +20,5 @@ public class Tame extends SimplyPrevents {
|
|||||||
prevent(event, (Player) event.getOwner(), "tame,animals,interact");
|
prevent(event, (Player) event.getOwner(), "tame,animals,interact");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,5 +28,5 @@ public class Lavabucket extends SimplyPrevents {
|
|||||||
prevent(event, event.getPlayer(), "lavabucket,bucket,interact");
|
prevent(event, event.getPlayer(), "lavabucket,bucket,interact");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,5 +20,5 @@ public class Milking extends SimplyPrevents {
|
|||||||
prevent(event, event.getPlayer(), "milking,bucket,interact");
|
prevent(event, event.getPlayer(), "milking,bucket,interact");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,5 +28,5 @@ public class Waterbucket extends SimplyPrevents {
|
|||||||
prevent(event, event.getPlayer(), "waterbucket,bucket,interact");
|
prevent(event, event.getPlayer(), "waterbucket,bucket,interact");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,5 +24,5 @@ public class Placeblock extends SimplyPrevents {
|
|||||||
public void paintingPlaceblock(PaintingPlaceEvent event) {
|
public void paintingPlaceblock(PaintingPlaceEvent event) {
|
||||||
prevent(event, event.getPlayer(), "placeblock." + Material.PAINTING.getId() + ",build." + Material.PAINTING.getId());
|
prevent(event, event.getPlayer(), "placeblock." + Material.PAINTING.getId() + ",build." + Material.PAINTING.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
public class Chest extends SimplyPrevents {
|
public class Chest extends SimplyPrevents {
|
||||||
|
|
||||||
public Chest(SimplyPlugin plugin) {
|
public Chest(SimplyPlugin plugin) {
|
||||||
super(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;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
public class Button extends SimplyPrevents {
|
public class Button extends SimplyPrevents {
|
||||||
|
|
||||||
public Button(SimplyPlugin plugin) {
|
public Button(SimplyPlugin plugin) {
|
||||||
super(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;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
public class Door extends SimplyPrevents {
|
public class Door extends SimplyPrevents {
|
||||||
|
|
||||||
public Door(SimplyPlugin plugin) {
|
public Door(SimplyPlugin plugin) {
|
||||||
super(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) {
|
public void fish(PlayerFishEvent event) {
|
||||||
prevent(event, event.getPlayer(), "fish,interact");
|
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 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,5 +17,5 @@ public class Pickup extends SimplyPrevents {
|
|||||||
public void pickup(PlayerPickupItemEvent event) {
|
public void pickup(PlayerPickupItemEvent event) {
|
||||||
prevent(event, event.getPlayer(), "pickup." + event.getItem().getItemStack().getTypeId() + ",loot." + event.getItem().getItemStack().getTypeId());
|
prevent(event, event.getPlayer(), "pickup." + event.getItem().getItemStack().getTypeId() + ",loot." + event.getItem().getItemStack().getTypeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,5 +25,5 @@ public class Potion extends SimplyPrevents {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,5 +24,5 @@ public class Snowball extends SimplyPrevents {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,11 @@ public class CapsLock extends SimplyPrevents {
|
|||||||
for (Player player : super.plugin.getServer().getOnlinePlayers()) {
|
for (Player player : super.plugin.getServer().getOnlinePlayers()) {
|
||||||
message.replace(player.getName(), "");
|
message.replace(player.getName(), "");
|
||||||
}
|
}
|
||||||
String nocaps = message.replaceAll("[A-Z]*", "");
|
String nocaps = message.replaceAll("[A-Z]*", "");
|
||||||
if (message.length() > 5
|
if (message.length() > 5
|
||||||
&& message.length() - nocaps.length() > message.length() / 2) {
|
&& message.length() - nocaps.length() > message.length() / 2) {
|
||||||
prevent(event, event.getPlayer(), "capslock,spam");
|
prevent(event, event.getPlayer(), "capslock,spam");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import org.bukkit.event.player.PlayerChatEvent;
|
|||||||
public class Flood extends SimplyPrevents {
|
public class Flood extends SimplyPrevents {
|
||||||
|
|
||||||
private HashMap<Player, Long> chatTimestamps = new HashMap<Player, Long>();
|
private HashMap<Player, Long> chatTimestamps = new HashMap<Player, Long>();
|
||||||
|
|
||||||
public Flood(SimplyPlugin plugin) {
|
public Flood(SimplyPlugin plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user