summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupManager/src/org/anjocaido
diff options
context:
space:
mode:
Diffstat (limited to 'EssentialsGroupManager/src/org/anjocaido')
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java3
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java92
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java73
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java2
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMGroupEvent.java5
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMSystemEvent.java3
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMUserEvent.java5
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java30
8 files changed, 116 insertions, 97 deletions
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java
index d830696e7..98ff075dd 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java
@@ -57,9 +57,6 @@ public class GMConfiguration {
public boolean isOpOverride() {
return GMconfig.getBoolean("settings.config.opOverrides", true);
}
- public boolean isBukkitPermsOverride() {
- return GMconfig.getBoolean("settings.config.bukkit_perms_override", false);
- }
public boolean isToggleValidate() {
return GMconfig.getBoolean("settings.config.validate_toggle", true);
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
index b87d1de8c..b0d46ca1a 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
@@ -25,7 +25,10 @@ import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.anjocaido.groupmanager.dataholder.worlds.WorldsHolder;
+import org.anjocaido.groupmanager.events.GMSystemEvent;
import org.anjocaido.groupmanager.events.GMWorldListener;
+import org.anjocaido.groupmanager.events.GroupManagerEventHandler;
+import org.anjocaido.groupmanager.events.GMGroupEvent.Action;
import org.anjocaido.groupmanager.utils.GMLoggerHandler;
import org.anjocaido.groupmanager.utils.PermissionCheckResult;
import org.anjocaido.groupmanager.utils.Tasks;
@@ -395,6 +398,10 @@ public class GroupManager extends JavaPlugin {
sender.sendMessage(ChatColor.RED + "Group not found!");
return false;
}
+ if (auxGroup.isGlobal()) {
+ sender.sendMessage(ChatColor.RED + "Players may not be members of GlobalGroups directly.");
+ return false;
+ }
// VALIDANDO PERMISSAO
if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
@@ -1016,6 +1023,11 @@ public class GroupManager extends JavaPlugin {
sender.sendMessage(ChatColor.RED + "Group 2 does not exists!");
return false;
}
+ if (auxGroup.isGlobal()) {
+ sender.sendMessage(ChatColor.RED + "GlobalGroups do NOT support inheritance.");
+ return false;
+ }
+
// VALIDANDO PERMISSAO
if (permissionHandler.searchGroupInInheritance(auxGroup, auxGroup2.getName(), null)) {
sender.sendMessage(ChatColor.RED + "Group " + auxGroup.getName() + " already inherits " + auxGroup2.getName() + " (might not be directly)");
@@ -1049,6 +1061,11 @@ public class GroupManager extends JavaPlugin {
sender.sendMessage(ChatColor.RED + "Group 2 does not exists!");
return false;
}
+ if (auxGroup.isGlobal()) {
+ sender.sendMessage(ChatColor.RED + "GlobalGroups do NOT support inheritance.");
+ return false;
+ }
+
// VALIDANDO PERMISSAO
if (!permissionHandler.searchGroupInInheritance(auxGroup, auxGroup2.getName(), null)) {
sender.sendMessage(ChatColor.RED + "Group " + auxGroup.getName() + " does not inherits " + auxGroup2.getName() + ".");
@@ -1219,6 +1236,10 @@ public class GroupManager extends JavaPlugin {
sender.sendMessage(ChatColor.RED + "Group does not exists!");
return false;
}
+ if (auxGroup.isGlobal()) {
+ sender.sendMessage(ChatColor.RED + "GlobalGroups do NOT support Info Nodes.");
+ return false;
+ }
// VALIDANDO PERMISSAO
// PARECE OK
auxString = "";
@@ -1248,6 +1269,10 @@ public class GroupManager extends JavaPlugin {
sender.sendMessage(ChatColor.RED + "Group does not exists!");
return false;
}
+ if (auxGroup.isGlobal()) {
+ sender.sendMessage(ChatColor.RED + "GlobalGroups do NOT support Info Nodes.");
+ return false;
+ }
// VALIDANDO PERMISSAO
if (!auxGroup.getVariables().hasVar(args[1])) {
sender.sendMessage(ChatColor.RED + "The group doesn't have directly that variable!");
@@ -1273,6 +1298,10 @@ public class GroupManager extends JavaPlugin {
sender.sendMessage(ChatColor.RED + "Group does not exists!");
return false;
}
+ if (auxGroup.isGlobal()) {
+ sender.sendMessage(ChatColor.RED + "GlobalGroups do NOT support Info Nodes.");
+ return false;
+ }
// VALIDANDO PERMISSAO
// PARECE OK
auxString = "";
@@ -1310,6 +1339,10 @@ public class GroupManager extends JavaPlugin {
sender.sendMessage(ChatColor.RED + "Group does not exists!");
return false;
}
+ if (auxGroup.isGlobal()) {
+ sender.sendMessage(ChatColor.RED + "GlobalGroups do NOT support Info Nodes.");
+ return false;
+ }
// VALIDANDO PERMISSAO
auxGroup2 = permissionHandler.nextGroupWithVariable(auxGroup, args[1], null);
if (auxGroup2 == null) {
@@ -1492,7 +1525,9 @@ public class GroupManager extends JavaPlugin {
return true;
case manload:
- // THIS CASE DONT NEED SENDER
+ /**
+ * Attempt to reload a specific world
+ */
if (args.length > 0) {
auxString = "";
for (int i = 0; i < args.length; i++) {
@@ -1502,51 +1537,34 @@ public class GroupManager extends JavaPlugin {
}
}
- isLoaded = false; // Disable Bukkit Perms update
+ isLoaded = false; // Disable Bukkit Perms update and event triggers
globalGroups.load();
worldsHolder.loadWorld(auxString);
- sender.sendMessage("The request to world '" + auxString + "' was sent.");
+ sender.sendMessage("The request to reload world '" + auxString + "' was attempted.");
isLoaded = true;
BukkitPermissions.updateAllPlayers();
- return true;
- }
- // VALIDANDO ESTADO DO SENDER
- if (dataHolder == null || permissionHandler == null) {
- if (!setDefaultWorldHandler(sender))
- return true;
- }
- // WORKING
- config.load();
- globalGroups.load();
- worldsHolder.mirrorSetUp();
-
- isLoaded = false;
-
- if (args.length > 0) {
- auxString = "";
- for (int i = 0; i < args.length; i++) {
- auxString += args[i];
- if ((i + 1) < args.length) {
- auxString += " ";
- }
- }
- worldsHolder.loadWorld(auxString);
- sender.sendMessage("The request to world '" + auxString + "' was sent.");
} else {
- worldsHolder.reloadAll();
- sender.sendMessage(ChatColor.YELLOW + " All worlds were reloaded.");
+
+ /**
+ * Reload all settings and data as no world was specified.
+ */
+ onDisable();
+ onEnable();
}
-
- isLoaded = true;
-
- BukkitPermissions.updateAllPlayers();
+
+ /**
+ * Fire an event as none will have been triggered in the reload.
+ */
+ if (GroupManager.isLoaded())
+ GroupManagerEventHandler.callEvent(GMSystemEvent.Action.RELOADED);
return true;
+
case listgroups:
// VALIDANDO ESTADO DO SENDER
if (dataHolder == null || permissionHandler == null) {
@@ -1590,6 +1608,10 @@ public class GroupManager extends JavaPlugin {
sender.sendMessage(ChatColor.RED + "Group not found!");
return false;
}
+ if (auxGroup.isGlobal()) {
+ sender.sendMessage(ChatColor.RED + "Players may not be members of GlobalGroups directly.");
+ return false;
+ }
// VALIDANDO PERMISSAO
if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher.");
@@ -1646,6 +1668,10 @@ public class GroupManager extends JavaPlugin {
sender.sendMessage(ChatColor.RED + "Group not found!");
return false;
}
+ if (auxGroup.isGlobal()) {
+ sender.sendMessage(ChatColor.RED + "Players may not be members of GlobalGroups directly.");
+ return false;
+ }
// VALIDANDO PERMISSAO
if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher.");
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java
index 5a39600b6..396240ec6 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java
@@ -48,6 +48,15 @@ public class Group extends DataUnit implements Cloneable {
public Group(String name) {
super(name);
}
+
+ /**
+ * Is this a GlobalGroup
+ *
+ * @return
+ */
+ public boolean isGlobal() {
+ return (getDataSource() == null);
+ }
/**
* Clone this group
@@ -57,7 +66,7 @@ public class Group extends DataUnit implements Cloneable {
public Group clone() {
Group clone;
- if (getDataSource() == null) {
+ if (isGlobal()) {
clone = new Group(this.getName());
} else {
clone = new Group(getDataSource(), this.getName());
@@ -85,7 +94,7 @@ public class Group extends DataUnit implements Cloneable {
Group clone = dataSource.createGroup(this.getName());
// Don't add inheritance for GlobalGroups
- if (getDataSource() != null) {
+ if (!isGlobal()) {
clone.inherits = new ArrayList<String>(this.getInherits());
}
for (String perm : this.getPermissionList()) {
@@ -110,26 +119,30 @@ public class Group extends DataUnit implements Cloneable {
* @param inherit the inherits to set
*/
public void addInherits(Group inherit) {
- if (!this.getDataSource().groupExists(inherit.getName())) {
- getDataSource().addGroup(inherit);
- }
- if (!inherits.contains(inherit.getName().toLowerCase())) {
- inherits.add(inherit.getName().toLowerCase());
- }
- flagAsChanged();
- if (GroupManager.isLoaded()) {
- GroupManager.BukkitPermissions.updateAllPlayers();
- GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
- }
+ if (!isGlobal()) {
+ if (!this.getDataSource().groupExists(inherit.getName())) {
+ getDataSource().addGroup(inherit);
+ }
+ if (!inherits.contains(inherit.getName().toLowerCase())) {
+ inherits.add(inherit.getName().toLowerCase());
+ }
+ flagAsChanged();
+ if (GroupManager.isLoaded()) {
+ GroupManager.BukkitPermissions.updateAllPlayers();
+ GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
+ }
+ }
}
public boolean removeInherits(String inherit) {
- if (this.inherits.contains(inherit.toLowerCase())) {
- this.inherits.remove(inherit.toLowerCase());
- flagAsChanged();
- GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
- return true;
- }
+ if (!isGlobal()) {
+ if (this.inherits.contains(inherit.toLowerCase())) {
+ this.inherits.remove(inherit.toLowerCase());
+ flagAsChanged();
+ GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
+ return true;
+ }
+ }
return false;
}
@@ -145,15 +158,17 @@ public class Group extends DataUnit implements Cloneable {
* @param varList
*/
public void setVariables(Map<String, Object> varList) {
- GroupVariables temp = new GroupVariables(this, varList);
- variables.clearVars();
- for (String key : temp.getVarKeyList()) {
- variables.addVar(key, temp.getVarObject(key));
- }
- flagAsChanged();
- if (GroupManager.isLoaded()) {
- GroupManager.BukkitPermissions.updateAllPlayers();
- GroupManagerEventHandler.callEvent(this, Action.GROUP_INFO_CHANGED);
- }
+ if (!isGlobal()) {
+ GroupVariables temp = new GroupVariables(this, varList);
+ variables.clearVars();
+ for (String key : temp.getVarKeyList()) {
+ variables.addVar(key, temp.getVarObject(key));
+ }
+ flagAsChanged();
+ if (GroupManager.isLoaded()) {
+ GroupManager.BukkitPermissions.updateAllPlayers();
+ GroupManagerEventHandler.callEvent(this, Action.GROUP_INFO_CHANGED);
+ }
+ }
}
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
index 8115b1a75..e766b6c78 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
@@ -856,7 +856,7 @@ public class WorldDataHolder {
PluginManager pm = server.getPluginManager();
Plugin[] plugins = pm.getPlugins();
for (int i = 0; i < plugins.length; i++) {
- plugins[i].getConfiguration().load();
+ //plugins[i].getConfiguration().load();
try {
plugins[i].getClass().getMethod("setupPermissions").invoke(plugins[i]);
} catch (Exception ex) {
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMGroupEvent.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMGroupEvent.java
index fdb740646..fc9b8433b 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMGroupEvent.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMGroupEvent.java
@@ -16,7 +16,6 @@ public class GMGroupEvent extends Event {
/**
*
*/
- private static final long serialVersionUID = -5294917600434510451L;
private static final HandlerList handlers = new HandlerList();
@Override
@@ -37,7 +36,7 @@ public class GMGroupEvent extends Event {
protected Action action;
public GMGroupEvent(Group group, Action action) {
- super(action.toString());
+ super();
this.group = group;
this.action = action;
@@ -45,7 +44,7 @@ public class GMGroupEvent extends Event {
}
public GMGroupEvent(String groupName, Action action) {
- super(action.toString());
+ super();
this.groupName = groupName;
this.action = action;
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMSystemEvent.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMSystemEvent.java
index 1ff605d5c..210960876 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMSystemEvent.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMSystemEvent.java
@@ -15,7 +15,6 @@ public class GMSystemEvent extends Event {
/**
*
*/
- private static final long serialVersionUID = -8786811924448821548L;
private static final HandlerList handlers = new HandlerList();
@Override
@@ -32,7 +31,7 @@ public class GMSystemEvent extends Event {
protected Action action;
public GMSystemEvent(Action action) {
- super(action.toString());
+ super();
this.action = action;
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMUserEvent.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMUserEvent.java
index d40a7d63e..206de8c86 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMUserEvent.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMUserEvent.java
@@ -16,7 +16,6 @@ public class GMUserEvent extends Event {
/**
*
*/
- private static final long serialVersionUID = -5294917600434510451L;
private static final HandlerList handlers = new HandlerList();
@Override
@@ -37,7 +36,7 @@ public class GMUserEvent extends Event {
protected Action action;
public GMUserEvent(User user, Action action) {
- super(action.toString());
+ super();
this.user = user;
this.action = action;
@@ -45,7 +44,7 @@ public class GMUserEvent extends Event {
}
public GMUserEvent(String userName, Action action) {
- super(action.toString());
+ super();
this.userName = userName;
this.action = action;
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
index 1409f774d..0b6148900 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
@@ -37,10 +37,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
-import org.bukkit.event.player.PlayerPortalEvent;
import org.bukkit.event.player.PlayerQuitEvent;
-import org.bukkit.event.player.PlayerRespawnEvent;
-import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.permissions.Permission;
@@ -346,6 +343,12 @@ public class BukkitPermissions {
this.updatePermissions(player, null);
}
+ /**
+ * Player events tracked to cause Superperms updates
+ *
+ * @author ElgarL
+ *
+ */
protected class PlayerEvents implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
@@ -361,30 +364,11 @@ public class BukkitPermissions {
}
@EventHandler(priority = EventPriority.LOWEST)
- public void onPlayerChangeWorld(PlayerChangedWorldEvent event) { // will portal into another world
+ public void onPlayerChangeWorld(PlayerChangedWorldEvent event) { // has changed worlds
updatePermissions(event.getPlayer(), event.getPlayer().getWorld().getName());
}
@EventHandler(priority = EventPriority.LOWEST)
- public void onPlayerPortal(PlayerPortalEvent event) { // will portal into another world
- if ((event.getTo() != null) && (!event.getFrom().getWorld().equals(event.getTo().getWorld()))) { // only if world actually changed
- updatePermissions(event.getPlayer(), event.getTo().getWorld().getName());
- }
- }
-
- @EventHandler(priority = EventPriority.LOWEST)
- public void onPlayerRespawn(PlayerRespawnEvent event) { // can be respawned in another world
- updatePermissions(event.getPlayer(), event.getRespawnLocation().getWorld().getName());
- }
-
- @EventHandler(priority = EventPriority.LOWEST)
- public void onPlayerTeleport(PlayerTeleportEvent event) { // can be teleported into another world
- if ((event.getTo() != null) && (event.getPlayer() != null) && (!event.getFrom().getWorld().equals(event.getTo().getWorld()))) { // only if world actually changed
- updatePermissions(event.getPlayer(), event.getTo().getWorld().getName());
- }
- }
-
- @EventHandler(priority = EventPriority.LOWEST)
public void onPlayerQuit(PlayerQuitEvent event) {
if (!GroupManager.isLoaded())
return;