summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--EssentialsGroupManager/src/Changelog.txt8
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java6
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java26
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java89
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java12
-rw-r--r--EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java12
6 files changed, 86 insertions, 67 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt
index b58f520a8..70f778247 100644
--- a/EssentialsGroupManager/src/Changelog.txt
+++ b/EssentialsGroupManager/src/Changelog.txt
@@ -111,4 +111,10 @@ v 1.9:
- Update GroupManagerBridge for new event system.
- Fixed a random null error upon a player portaling.
- Fixed infinite loop error on player join.
- - Optimized code to only update the player logging in instead of all players online. \ No newline at end of file
+ - Optimized code to only update the player logging in instead of all players online.
+ - Added recursive loop detection for World mirroring (you may not set the main world as a mirror of another).
+ - Fixed fetching world data so it no longer returns the mirrored world for groups. Each world data holder now points to the correct data set, so can be returned as an object.
+ - Changed addSubGroup() to only add the group if it doesn't already exist (no need to update an already existing group).
+ - addSubGroup now returns a boolean for success/failure.
+ - '/manuaddsub' now correctly reports if it was able to add the sub group.
+ - Allow negation to the * permission node when populating superperms. \ No newline at end of file
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
index d8f5418ed..c0ed77adc 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
@@ -489,8 +489,10 @@ public class GroupManager extends JavaPlugin {
return false;
}
// PARECE OK
- auxUser.addSubGroup(auxGroup);
- sender.sendMessage(ChatColor.YELLOW + "You added subgroup '" + auxGroup.getName() + "' to player '" + auxUser.getName() + "'.");
+ if (auxUser.addSubGroup(auxGroup))
+ sender.sendMessage(ChatColor.YELLOW + "You added subgroup '" + auxGroup.getName() + "' to player '" + auxUser.getName() + "'.");
+ else
+ sender.sendMessage(ChatColor.RED + "The subgroup '" + auxGroup.getName() + "' is already available to '" + auxUser.getName() + "'.");
targetPlayer = this.getServer().getPlayer(auxUser.getName());
if (targetPlayer != null)
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java
index fd66bcfa2..6e9b7ad21 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java
@@ -147,22 +147,26 @@ public class User extends DataUnit implements Cloneable {
}
}
- public void addSubGroup(Group subGroup) {
+ public boolean addSubGroup(Group subGroup) {
+ // Don't allow adding a subgroup if it's already set as the primary.
if (this.group.equalsIgnoreCase(subGroup.getName())) {
- return;
+ return false;
}
if (!this.getDataSource().groupExists(subGroup.getName())) {
getDataSource().addGroup(subGroup);
+
+ flagAsChanged();
+ if (GroupManager.isLoaded()) {
+ if (!GroupManager.BukkitPermissions.isPlayer_join())
+ GroupManager.BukkitPermissions.updatePlayer(getBukkitPlayer());
+ GroupManagerEventHandler.callEvent(this, Action.USER_SUBGROUP_CHANGED);
+ }
+ return true;
}
- subGroup = getDataSource().getGroup(subGroup.getName());
- removeSubGroup(subGroup);
- subGroups.add(subGroup.getName());
- flagAsChanged();
- if (GroupManager.isLoaded()) {
- if (!GroupManager.BukkitPermissions.isPlayer_join())
- GroupManager.BukkitPermissions.updatePlayer(getBukkitPlayer());
- GroupManagerEventHandler.callEvent(this, Action.USER_SUBGROUP_CHANGED);
- }
+ //subGroup = getDataSource().getGroup(subGroup.getName());
+ //removeSubGroup(subGroup);
+ //subGroups.add(subGroup.getName());
+ return false;
}
public int subGroupsSize() {
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
index 1a765c7b4..320fe3e26 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
@@ -130,41 +130,48 @@ public class WorldsHolder {
// These worlds fully mirror their parent
for (Object o : mirrorList) {
- try {
- mirrorsGroup.remove(o.toString().toLowerCase());
- mirrorsUser.remove(o.toString().toLowerCase());
- } catch (Exception e) {
- }
- mirrorsGroup.put(o.toString().toLowerCase(), getWorldData(source).getName());
- mirrorsUser.put(o.toString().toLowerCase(), getWorldData(source).getName());
+ String world = o.toString().toLowerCase();
+ if (world != serverDefaultWorldName) {
+ try {
+ mirrorsGroup.remove(world);
+ mirrorsUser.remove(world);
+ } catch (Exception e) {
+ }
+ mirrorsGroup.put(world, getWorldData(source).getName());
+ mirrorsUser.put(world, getWorldData(source).getName());
+ } else
+ GroupManager.logger.log(Level.WARNING, "Mirroring error with " + o.toString() + ". Recursive loop detected!");
}
} else if (mirrorsMap.get(source) instanceof MemorySection) {
MemorySection subSection = (MemorySection) mirrorsMap.get(source);
for (String key : subSection.getKeys(true)) {
- //System.out.print("Key - " + key);
- if (subSection.get(key) instanceof ArrayList) {
- ArrayList mirrorList = (ArrayList) subSection.get(key);
-
- // These worlds have defined mirroring
- for (Object o : mirrorList) {
- String type = o.toString().toLowerCase();
- try {
- if (type.equals("groups"))
- mirrorsGroup.remove(key.toLowerCase());
-
- if (type.equals("users"))
- mirrorsUser.remove(key.toLowerCase());
-
- } catch (Exception e) {
- }
- if (type.equals("groups"))
- mirrorsGroup.put(key.toLowerCase(), getWorldData(source).getName());
-
- if (type.equals("users"))
- mirrorsUser.put(key.toLowerCase(), getWorldData(source).getName());
- }
+ if (key.toLowerCase() != serverDefaultWorldName) {
+
+ if (subSection.get(key) instanceof ArrayList) {
+ ArrayList mirrorList = (ArrayList) subSection.get(key);
+
+ // These worlds have defined mirroring
+ for (Object o : mirrorList) {
+ String type = o.toString().toLowerCase();
+ try {
+ if (type.equals("groups"))
+ mirrorsGroup.remove(key.toLowerCase());
+
+ if (type.equals("users"))
+ mirrorsUser.remove(key.toLowerCase());
+
+ } catch (Exception e) {
+ }
+ if (type.equals("groups"))
+ mirrorsGroup.put(key.toLowerCase(), getWorldData(source).getName());
+
+ if (type.equals("users"))
+ mirrorsUser.put(key.toLowerCase(), getWorldData(source).getName());
+ }
+ } else
+ GroupManager.logger.log(Level.WARNING, "Mirroring error with " + key + ". Recursive loop detected!");
@@ -312,27 +319,19 @@ public class WorldsHolder {
* If the world is not on the worlds list, returns the default world
* holder.
*
- * (WHEN A WORLD IS CONFIGURED TO MIRROR, IT WILL BE ON THE LIST, BUT
- * POINTING TO ANOTHER WORLD HOLDER)
- *
- * Mirrors prevails original data.
+ * Mirrors return original world data.
*
* @param worldName
* @return OverloadedWorldHolder
*/
public OverloadedWorldHolder getWorldData(String worldName) {
String worldNameLowered = worldName.toLowerCase();
- // If a mirror change to the real world to load.
- if (mirrorsGroup.containsKey(worldNameLowered)) {
- worldNameLowered = mirrorsGroup.get(worldNameLowered);
- }
- OverloadedWorldHolder data = worldsData.get(worldNameLowered);
+
+ if (worldsData.containsKey(worldNameLowered))
+ return worldsData.get(worldNameLowered);
- if (data == null) {
- GroupManager.logger.finest("Requested world " + worldName + " not found or badly mirrored. Returning default world...");
- data = getDefaultWorld();
- }
- return data;
+ GroupManager.logger.finest("Requested world " + worldName + " not found or badly mirrored. Returning default world...");
+ return getDefaultWorld();
}
/**
@@ -541,7 +540,7 @@ public class WorldsHolder {
* @return true if world is loaded or mirrored. false if not listed
*/
public boolean isInList(String worldName) {
- if (worldsData.containsKey(worldName.toLowerCase()) || mirrorsGroup.containsKey(worldName.toLowerCase())) {
+ if (worldsData.containsKey(worldName.toLowerCase()) || mirrorsGroup.containsKey(worldName.toLowerCase()) || mirrorsUser.containsKey(worldName.toLowerCase())) {
return true;
}
return false;
@@ -554,7 +553,7 @@ public class WorldsHolder {
* @return true if it has its own holder. false if not.
*/
public boolean hasOwnData(String worldName) {
- if (worldsData.containsKey(worldName.toLowerCase())) {
+ if (worldsData.containsKey(worldName.toLowerCase()) && (!mirrorsGroup.containsKey(worldName.toLowerCase()) || !mirrorsUser.containsKey(worldName.toLowerCase()))) {
return true;
}
return false;
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
index 51c6dded5..e326ff624 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
@@ -150,12 +150,14 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
Set<String> permArray = new HashSet<String>();
- for (String perm : perms) {
-
- // Allow * node to populate ALL perms in Bukkit.
- if (perm.equalsIgnoreCase("*"))
- permArray.addAll(GroupManager.BukkitPermissions.getAllRegisteredPermissions(includeChildren));
+ // Allow * node to populate ALL perms in Bukkit.
+ if (perms.contains("*")) {
+ permArray.addAll(GroupManager.BukkitPermissions.getAllRegisteredPermissions(includeChildren));
+ perms.remove("*");
+ }
+ for (String perm : perms) {
+
boolean negated = false;
if (perm.startsWith("-"))
negated = true;
diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
index 2814714a2..7ec9ee043 100644
--- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
+++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
@@ -2,6 +2,7 @@ package com.earth2me.essentials.spawn;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials;
+import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.User;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -27,7 +28,7 @@ public class EssentialsSpawnPlayerListener implements Listener
}
public void onPlayerRespawn(final PlayerRespawnEvent event)
- {
+ {
final User user = ess.getUser(event.getPlayer());
if (ess.getSettings().getRespawnAtHome())
@@ -58,7 +59,7 @@ public class EssentialsSpawnPlayerListener implements Listener
{
LOGGER.log(Level.FINE, "Old player join");
return;
- }
+ }
if (!"none".equalsIgnoreCase(ess.getSettings().getNewbieSpawn()))
{
ess.scheduleSyncDelayedTask(new NewPlayerTeleport(user), 1L);
@@ -68,7 +69,7 @@ public class EssentialsSpawnPlayerListener implements Listener
{
ess.broadcastMessage(user, ess.getSettings().getAnnounceNewPlayerFormat(user));
}
-
+
LOGGER.log(Level.FINE, "New player join");
}
@@ -85,6 +86,11 @@ public class EssentialsSpawnPlayerListener implements Listener
@Override
public void run()
{
+ if (user.getBase() instanceof OfflinePlayer)
+ {
+ return;
+ }
+
try
{
Location spawn = spawns.getSpawn(ess.getSettings().getNewbieSpawn());