use of com.builtbroken.mc.lib.access.AccessGroup in project Engine by VoltzEngine-Project.
the class CommandRemoveGroup method handleConsoleCommand.
@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
if (args.length > 0) {
String name = args[0];
if (GroupProfileHandler.GLOBAL.getAccessProfile().getGroup(name) != null) {
AccessGroup group = new AccessGroup(name);
if (GroupProfileHandler.GLOBAL.getAccessProfile().removeGroup(group) != null) {
if (group.getExtendGroup() != null) {
int i = 0;
for (AccessGroup g : GroupProfileHandler.GLOBAL.getAccessProfile().getGroups()) {
if (g.getExtendGroup().getName().equalsIgnoreCase(group.getName())) {
i++;
g.setToExtend(group.getExtendGroup());
}
}
sender.addChatMessage(new ChatComponentText(i + " groups updated"));
}
sender.addChatMessage(new ChatComponentText("Group \'" + name + "\' removed"));
} else {
sender.addChatMessage(new ChatComponentText("Error removing group"));
}
} else {
sender.addChatMessage(new ChatComponentText("Group \'" + name + "\' not found"));
}
} else {
sender.addChatMessage(new ChatComponentText("Missing group name"));
}
return true;
}
use of com.builtbroken.mc.lib.access.AccessGroup in project Engine by VoltzEngine-Project.
the class GroupProfileHandler method generateNew.
public void generateNew() {
profile = new AccessProfile();
// Create owner group - Power to do everything, AKA /OP
AccessGroup owner_group = new AccessGroup("Owner");
owner_group.addNode(PermissionsRegistry.ALL);
// Create admin group - Power to Ban, Make Regions, and adjust settings
AccessGroup admin_group = new AccessGroup("Admin");
admin_group.addNode("root.minecraft.difficulty");
admin_group.addNode("root.minecraft.setworldspawn");
admin_group.addNode("root.minecraft.give");
admin_group.addNode("root.minecraft.gamemode");
admin_group.addNode("root.minecraft.summon");
admin_group.addNode("root.minecraft.spawnpoint");
// Create mod group - Power to kick, temp-ban, and silence users
AccessGroup mod_group = new AccessGroup("Moderator");
mod_group.addNode("root.minecraft.whitelist");
mod_group.addNode("root.minecraft.ban-ip");
mod_group.addNode("root.minecraft.pardon-ip");
mod_group.addNode("root.minecraft.time");
mod_group.addNode("root.minecraft.save-all");
mod_group.addNode("root.minecraft.pardon");
mod_group.addNode("root.minecraft.ban");
mod_group.addNode("root.minecraft.weather");
mod_group.addNode("root.minecraft.toggledownfall");
mod_group.addNode("root.minecraft.tp");
// Create dev group - sub version of user just for show
AccessGroup dev_group = new AccessGroup("Dev");
dev_group.addNode("root.minecraft.debug");
// Create media group - sub version of user just for show
AccessGroup media_group = new AccessGroup("Media");
media_group.addNode("root.minecraft.seed");
// Create user group - default group
AccessGroup user_group = new AccessGroup("User");
user_group.addNode("root.minecraft.help");
user_group.addNode("root.minecraft.me");
user_group.addNode("root.minecraft.tell");
// Extend groups
owner_group.setToExtend(admin_group);
admin_group.setToExtend(mod_group);
mod_group.setToExtend(user_group);
dev_group.setToExtend(user_group);
media_group.setToExtend(user_group);
// Add groups to profile
profile.addGroup(owner_group);
profile.addGroup(admin_group);
profile.addGroup(mod_group);
profile.addGroup(dev_group);
profile.addGroup(user_group);
}
use of com.builtbroken.mc.lib.access.AccessGroup in project Engine by VoltzEngine-Project.
the class CommandNewGroup method handleConsoleCommand.
@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
if (args.length > 0) {
String name = args[0];
if (GroupProfileHandler.GLOBAL.getAccessProfile().getGroup(name) == null) {
AccessGroup toExtend = null;
if (args.length > 1 && args[1].equalsIgnoreCase("extend")) {
if (args.length > 2) {
String extendName = args[2];
toExtend = GroupProfileHandler.GLOBAL.getAccessProfile().getGroup(extendName);
}
if (toExtend == null) {
sender.addChatMessage(new ChatComponentText("Error: Unknown group to extend"));
return true;
}
}
AccessGroup group = new AccessGroup(name);
if (toExtend != null) {
group.setToExtend(toExtend);
}
if (GroupProfileHandler.GLOBAL.getAccessProfile().addGroup(group)) {
sender.addChatMessage(new ChatComponentText("Group added"));
} else {
sender.addChatMessage(new ChatComponentText("Error adding group"));
}
} else {
sender.addChatMessage(new ChatComponentText("A Group by that name already exists"));
}
} else {
sender.addChatMessage(new ChatComponentText("Missing group name"));
}
return true;
}
use of com.builtbroken.mc.lib.access.AccessGroup in project Engine by VoltzEngine-Project.
the class CommandGroups method handleConsoleCommand.
@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
if (args[0].equalsIgnoreCase("list")) {
sender.addChatMessage(new ChatComponentText("==== Groups ===="));
for (AccessGroup group : GroupProfileHandler.GLOBAL.getAccessProfile().getGroups()) {
sender.addChatMessage(new ChatComponentText(" Group[" + group.getName() + (group.getExtendGroupName() != null ? " extends " + group.getExtendGroupName() : "") + "] Members: " + group.getMembers().size()));
}
sender.addChatMessage(new ChatComponentText("================"));
}
return true;
}
use of com.builtbroken.mc.lib.access.AccessGroup in project Engine by VoltzEngine-Project.
the class RegionManager method generateDefaultAccessProfile.
public static AccessProfile generateDefaultAccessProfile() {
AccessProfile profile = new AccessProfile();
// Create owner group
AccessGroup owner_group = new AccessGroup("owner");
owner_group.addNode(Permissions.profile.toString());
// Create admin group
AccessGroup admin_group = new AccessGroup("admin");
owner_group.addNode(Permissions.group.toString());
// Create user group
AccessGroup user_group = new AccessGroup("user");
user_group.addNode(rightClick.toString());
user_group.addNode(leftClick.toString());
user_group.addNode(break_block.toString());
// Set groups to extend each other
admin_group.setToExtend(user_group);
owner_group.setToExtend(admin_group);
// Add groups to profile
profile.addGroup(user_group);
profile.addGroup(admin_group);
profile.addGroup(owner_group);
return profile;
}
Aggregations