summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupManager
diff options
context:
space:
mode:
Diffstat (limited to 'EssentialsGroupManager')
-rw-r--r--EssentialsGroupManager/src/Changelog.txt5
-rw-r--r--EssentialsGroupManager/src/groups.yml129
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java19
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java26
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java10
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java24
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java6
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java49
8 files changed, 126 insertions, 142 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt
index c9c43f8a4..7659e092b 100644
--- a/EssentialsGroupManager/src/Changelog.txt
+++ b/EssentialsGroupManager/src/Changelog.txt
@@ -55,4 +55,7 @@ v 1.5:
- Fixed GM to recognize Superperm child nodes.
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 \ No newline at end of file
+ - 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. \ No newline at end of file
diff --git a/EssentialsGroupManager/src/groups.yml b/EssentialsGroupManager/src/groups.yml
index 6db09bdf2..ac4abeb4a 100644
--- a/EssentialsGroupManager/src/groups.yml
+++ b/EssentialsGroupManager/src/groups.yml
@@ -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
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
index a450b4bee..b74a29977 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
@@ -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;
+
+ }
} \ No newline at end of file
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java
index 7b027a94d..6f2fdd3b3 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java
@@ -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;
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java
index 84d4fceed..09eabb43f 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java
@@ -27,12 +27,22 @@ public class Group extends DataUnit implements Cloneable {
private GroupVariables variables = new GroupVariables(this);
/**
+ * Constructor for individual World Groups.
*
* @param name
*/
public Group(WorldDataHolder source, String name) {
super(source, name);
}
+
+ /**
+ * Constructor for Global Groups.
+ *
+ * @param name
+ */
+ public Group(String name) {
+ super(name);
+ }
/**
* Clone this group
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
index c8dc8cbd1..c8aa15cec 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
@@ -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;
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
index 7c40e19f5..f5b55a25a 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
@@ -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();
+ }
}
/**
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
index 203ac95a9..99f6fb5c3 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
@@ -93,22 +93,40 @@ 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);
- }
- }
-
+ for (String group : getGroups(userName)) {
+ 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);
}