mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-04-26 08:29:44 +00:00
Added Global Groups
Defined in groupmanager/globalgroups.yml. Create groups in the yml with a g: prefix, then inherit in the worlds groups files.
This commit is contained in:
parent
b1c6173995
commit
34ba8e89bc
8 changed files with 126 additions and 142 deletions
|
@ -56,3 +56,6 @@ v 1.5:
|
|||
If you add a node like Towny.admin GM will now correctly report on all child nodes.
|
||||
- Fixed GM loading world data files twice at startup.
|
||||
- Improved error reporting for invalid groups.yml
|
||||
- Added Global Groups
|
||||
Defined in groupmanager/globalgroups.yml.
|
||||
Create groups in the yml with a g: prefix, then inherit in the worlds groups files.
|
|
@ -2,147 +2,42 @@ groups:
|
|||
Default:
|
||||
default: true
|
||||
permissions:
|
||||
- essentials.help
|
||||
- essentials.helpop
|
||||
- essentials.list
|
||||
- essentials.motd
|
||||
- essentials.rules
|
||||
- essentials.spawn
|
||||
- groupmanager.notify.self
|
||||
inheritance: []
|
||||
- -bukkit.command.kill
|
||||
inheritance:
|
||||
- g:essentials_default
|
||||
- g:bukkit_default
|
||||
info:
|
||||
prefix: '&e'
|
||||
build: false
|
||||
suffix: ''
|
||||
Builder:
|
||||
default: false
|
||||
permissions:
|
||||
- essentials.afk
|
||||
- essentials.back
|
||||
- essentials.back.ondeath
|
||||
- essentials.balance
|
||||
- essentials.balance.others
|
||||
- essentials.balancetop
|
||||
- essentials.chat.color
|
||||
- essentials.chat.shout
|
||||
- essentials.chat.question
|
||||
- essentials.compass
|
||||
- essentials.depth
|
||||
- essentials.home
|
||||
- essentials.ignore
|
||||
- essentials.kit
|
||||
- essentials.kit.tools
|
||||
- essentials.mail
|
||||
- essentials.mail.send
|
||||
- essentials.me
|
||||
- essentials.msg
|
||||
- essentials.nick
|
||||
- essentials.pay
|
||||
- essentials.ping
|
||||
- essentials.powertool
|
||||
- essentials.protect
|
||||
- essentials.sethome
|
||||
- essentials.signs.use.*
|
||||
- essentials.signs.create.disposal
|
||||
- essentials.signs.create.mail
|
||||
- essentials.signs.create.protection
|
||||
- essentials.signs.create.trade
|
||||
- essentials.signs.break.disposal
|
||||
- essentials.signs.break.mail
|
||||
- essentials.signs.break.protection
|
||||
- essentials.signs.break.trade
|
||||
- essentials.suicide
|
||||
- essentials.time
|
||||
- essentials.tpa
|
||||
- essentials.tpaccept
|
||||
- essentials.tpahere
|
||||
- essentials.tpdeny
|
||||
- essentials.warp
|
||||
- essentials.warp.list
|
||||
- essentials.worth
|
||||
permissions: []
|
||||
inheritance:
|
||||
- default
|
||||
- g:essentials_builder
|
||||
info:
|
||||
prefix: '&2'
|
||||
build: true
|
||||
suffix: ''
|
||||
Moderator:
|
||||
default: false
|
||||
permissions:
|
||||
- essentials.ban
|
||||
- essentials.ban.notify
|
||||
- essentials.banip
|
||||
- essentials.broadcast
|
||||
- essentials.clearinventory
|
||||
- essentials.delwarp
|
||||
- essentials.eco.loan
|
||||
- essentials.ext
|
||||
- essentials.getpos
|
||||
- essentials.helpop.recieve
|
||||
- essentials.home.others
|
||||
- essentials.invsee
|
||||
- essentials.jails
|
||||
- essentials.jump
|
||||
- essentials.kick
|
||||
- essentials.kick.notify
|
||||
- essentials.kill
|
||||
- essentials.mute
|
||||
- essentials.nick.others
|
||||
- essentials.realname
|
||||
- essentials.setwarp
|
||||
- essentials.signs.create.*
|
||||
- essentials.signs.break.*
|
||||
- essentials.spawner
|
||||
- essentials.thunder
|
||||
- essentials.time
|
||||
- essentials.time.set
|
||||
- essentials.protect.alerts
|
||||
- essentials.protect.admin
|
||||
- essentials.protect.ownerinfo
|
||||
- essentials.ptime
|
||||
- essentials.ptime.others
|
||||
- essentials.togglejail
|
||||
- essentials.top
|
||||
- essentials.tp
|
||||
- essentials.tphere
|
||||
- essentials.tppos
|
||||
- essentials.tptoggle
|
||||
- essentials.unban
|
||||
- essentials.unbanip
|
||||
- essentials.weather
|
||||
- essentials.whois
|
||||
- essentials.world
|
||||
- groupmanager.listgroups
|
||||
- groupmanager.mandemote
|
||||
- groupmanager.manpromote
|
||||
- groupmanager.manselect
|
||||
- groupmanager.manuadd
|
||||
- groupmanager.manudel
|
||||
- groupmanager.manwhois
|
||||
- groupmanager.notify.other
|
||||
permissions: []
|
||||
inheritance:
|
||||
- builder
|
||||
- g:essentials_moderator
|
||||
- g:bukkit_moderator
|
||||
info:
|
||||
prefix: '&5'
|
||||
build: true
|
||||
suffix: ''
|
||||
Admin:
|
||||
default: false
|
||||
permissions:
|
||||
- -essentials.backup
|
||||
- -essentials.essentials
|
||||
- -essentials.setspawn
|
||||
- -essentials.reloadall
|
||||
- -essentials.plugin
|
||||
- essentials.*
|
||||
- groupmanager.mantogglevalidate
|
||||
- groupmanager.mansave
|
||||
- groupmanager.mangcheckp
|
||||
- groupmanager.manglistp
|
||||
- groupmanager.manucheckp
|
||||
- groupmanager.manulistp
|
||||
permissions: []
|
||||
inheritance:
|
||||
- moderator
|
||||
- g:essentials_admin
|
||||
- g:bukkit_admin
|
||||
info:
|
||||
prefix: '&c'
|
||||
build: true
|
||||
|
|
|
@ -47,7 +47,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
*/
|
||||
public class GroupManager extends JavaPlugin {
|
||||
|
||||
private File configFile;
|
||||
//private File configFile;
|
||||
private File backupFolder;
|
||||
private Runnable commiter;
|
||||
private ScheduledThreadPoolExecutor scheduler;
|
||||
|
@ -58,6 +58,9 @@ public class GroupManager extends JavaPlugin {
|
|||
private boolean isReady = false;
|
||||
private static boolean isLoaded = false;
|
||||
protected GMConfiguration config;
|
||||
|
||||
protected static GlobalGroups globalGroups;
|
||||
|
||||
private GMLoggerHandler ch;
|
||||
public static BukkitPermissions BukkitPermissions;
|
||||
private static WorldListener WorldEvents;
|
||||
|
@ -92,8 +95,12 @@ public class GroupManager extends JavaPlugin {
|
|||
GroupManager.logger.addHandler(ch);
|
||||
logger.setLevel(Level.ALL);
|
||||
if (worldsHolder == null) {
|
||||
// Create the backup folder, if it doesn't exist.
|
||||
prepareFileFields();
|
||||
// Load the config.yml
|
||||
prepareConfig();
|
||||
// Load the global groups
|
||||
globalGroups = new GlobalGroups(this);
|
||||
worldsHolder = new WorldsHolder(this);
|
||||
}
|
||||
|
||||
|
@ -138,7 +145,7 @@ public class GroupManager extends JavaPlugin {
|
|||
}
|
||||
|
||||
private void prepareFileFields() {
|
||||
configFile = new File(this.getDataFolder(), "config.yml");
|
||||
//configFile = new File(this.getDataFolder(), "config.yml");
|
||||
backupFolder = new File(this.getDataFolder(), "backup");
|
||||
if (!backupFolder.exists()) {
|
||||
getBackupFolder().mkdirs();
|
||||
|
@ -1537,6 +1544,9 @@ public class GroupManager extends JavaPlugin {
|
|||
for (Group g : dataHolder.getGroupList()) {
|
||||
auxString += g.getName() + ", ";
|
||||
}
|
||||
for (Group g : getGlobalGroups().getGroupList()) {
|
||||
auxString += g.getName() + ", ";
|
||||
}
|
||||
if (auxString.lastIndexOf(",") > 0) {
|
||||
auxString = auxString.substring(0, auxString.lastIndexOf(","));
|
||||
}
|
||||
|
@ -1796,4 +1806,9 @@ public class GroupManager extends JavaPlugin {
|
|||
public File getBackupFolder() {
|
||||
return backupFolder;
|
||||
}
|
||||
|
||||
public static GlobalGroups getGlobalGroups() {
|
||||
return globalGroups;
|
||||
|
||||
}
|
||||
}
|
|
@ -26,7 +26,11 @@ public abstract class DataUnit {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
public DataUnit(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Every group is matched only by their names and DataSources names.
|
||||
* @param o
|
||||
* @return true if they are equal. false if not.
|
||||
|
@ -64,7 +68,15 @@ public abstract class DataUnit {
|
|||
}
|
||||
|
||||
public void flagAsChanged() {
|
||||
GroupManager.logger.finest("DataSource: " + getDataSource().getName() + " - DataUnit: " + getName() + " flagged as changed!");
|
||||
WorldDataHolder testSource = getDataSource();
|
||||
String source = "";
|
||||
|
||||
if (testSource == null)
|
||||
source = "GlobalGroups";
|
||||
else
|
||||
source = testSource.getName();
|
||||
|
||||
GroupManager.logger.finest("DataSource: " + source + " - DataUnit: " + getName() + " flagged as changed!");
|
||||
// for(StackTraceElement st: Thread.currentThread().getStackTrace()){
|
||||
// GroupManager.logger.finest(st.toString());
|
||||
// }
|
||||
|
@ -76,7 +88,15 @@ public abstract class DataUnit {
|
|||
}
|
||||
|
||||
public void flagAsSaved() {
|
||||
GroupManager.logger.finest("DataSource: " + getDataSource().getName() + " - DataUnit: " + getName() + " flagged as saved!");
|
||||
WorldDataHolder testSource = getDataSource();
|
||||
String source = "";
|
||||
|
||||
if (testSource == null)
|
||||
source = "GlobalGroups";
|
||||
else
|
||||
source = testSource.getName();
|
||||
|
||||
GroupManager.logger.finest("DataSource: " + source + " - DataUnit: " + getName() + " flagged as saved!");
|
||||
changed = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ public class Group extends DataUnit implements Cloneable {
|
|||
private GroupVariables variables = new GroupVariables(this);
|
||||
|
||||
/**
|
||||
* Constructor for individual World Groups.
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
|
@ -34,6 +35,15 @@ public class Group extends DataUnit implements Cloneable {
|
|||
super(source, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for Global Groups.
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public Group(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone this group
|
||||
* @return a clone of this group
|
||||
|
|
|
@ -183,7 +183,10 @@ public class WorldDataHolder {
|
|||
* @return a group if it is found. null if not found.
|
||||
*/
|
||||
public Group getGroup(String groupName) {
|
||||
return groups.get(groupName.toLowerCase());
|
||||
if (groupName.startsWith("g:"))
|
||||
return GroupManager.getGlobalGroups().getGroup(groupName);
|
||||
else
|
||||
return groups.get(groupName.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -193,7 +196,10 @@ public class WorldDataHolder {
|
|||
* @return true if exists. false if not.
|
||||
*/
|
||||
public boolean groupExists(String groupName) {
|
||||
return groups.containsKey(groupName.toLowerCase());
|
||||
if (groupName.startsWith("g:"))
|
||||
return GroupManager.getGlobalGroups().hasGroup(groupName);
|
||||
else
|
||||
return groups.containsKey(groupName.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -215,6 +221,10 @@ public class WorldDataHolder {
|
|||
* @return true if had something to remove. false the group was default or non-existant
|
||||
*/
|
||||
public boolean removeGroup(String groupName) {
|
||||
if (groupName.startsWith("g:")) {
|
||||
return GroupManager.getGlobalGroups().removeGroup(groupName);
|
||||
}
|
||||
|
||||
if (defaultGroup != null && groupName.equalsIgnoreCase(defaultGroup.getName())) {
|
||||
return false;
|
||||
}
|
||||
|
@ -251,10 +261,16 @@ public class WorldDataHolder {
|
|||
* @return null if group already exists. or new Group
|
||||
*/
|
||||
public Group createGroup(String groupName) {
|
||||
if (this.groups.containsKey(groupName.toLowerCase())) {
|
||||
if (groupName.startsWith("g:")) {
|
||||
Group newGroup = new Group(groupName);
|
||||
return GroupManager.getGlobalGroups().addGroup(newGroup);
|
||||
}
|
||||
|
||||
if (this.groups.containsKey(groupName.toLowerCase())) {
|
||||
return null;
|
||||
}
|
||||
Group newGroup = new Group(this, groupName);
|
||||
|
||||
Group newGroup = new Group(this, groupName);
|
||||
this.addGroup(newGroup);
|
||||
haveGroupsChanged = true;
|
||||
return newGroup;
|
||||
|
|
|
@ -149,6 +149,8 @@ public class WorldsHolder {
|
|||
w.reload();
|
||||
alreadyDone.add(w);
|
||||
}
|
||||
// Load global groups
|
||||
GroupManager.getGlobalGroups().load();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -196,6 +198,10 @@ public class WorldsHolder {
|
|||
}
|
||||
alreadyDone.add(w);
|
||||
}
|
||||
// Write Global Groups
|
||||
if (GroupManager.getGlobalGroups().haveGroupsChanged()) {
|
||||
GroupManager.getGlobalGroups().writeGroups();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -94,21 +94,39 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
List<String> playerPermArray = new ArrayList<String>(ph.getUser(userName).getPermissionList());
|
||||
|
||||
for (String group : getGroups(userName)) {
|
||||
for (String perm : ph.getGroup(group).getPermissionList()) {
|
||||
if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-"+perm))) {
|
||||
playerPermArray.add(perm);
|
||||
|
||||
Map<String, Boolean> children = GroupManager.BukkitPermissions.getChildren(perm);
|
||||
if (children != null) {
|
||||
for (String child : children.keySet()) {
|
||||
if (children.get(child))
|
||||
if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-"+perm)))
|
||||
playerPermArray.add(child);
|
||||
}
|
||||
}
|
||||
if (group.startsWith("g:") && GroupManager.getGlobalGroups().hasGroup(group)) {
|
||||
for (String perm : GroupManager.getGlobalGroups().getGroupsPermissions(group)) {
|
||||
if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-"+perm))) {
|
||||
playerPermArray.add(perm);
|
||||
|
||||
Map<String, Boolean> children = GroupManager.BukkitPermissions.getChildren(perm);
|
||||
if (children != null) {
|
||||
for (String child : children.keySet()) {
|
||||
if (children.get(child))
|
||||
if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-"+perm)))
|
||||
playerPermArray.add(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
for (String perm : ph.getGroup(group).getPermissionList()) {
|
||||
if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-"+perm))) {
|
||||
playerPermArray.add(perm);
|
||||
|
||||
Map<String, Boolean> children = GroupManager.BukkitPermissions.getChildren(perm);
|
||||
if (children != null) {
|
||||
for (String child : children.keySet()) {
|
||||
if (children.get(child))
|
||||
if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-"+perm)))
|
||||
playerPermArray.add(child);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return playerPermArray;
|
||||
|
@ -935,6 +953,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
for (Group subg : ph.getUser(userName).subGroupListCopy()) {
|
||||
allGroups.addAll(listAllGroupsInherited(subg));
|
||||
}
|
||||
|
||||
String[] arr = new String[allGroups.size()];
|
||||
return allGroups.toArray(arr);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue