mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-08-06 04:23:02 +00:00
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.
This commit is contained in:
parent
125ea7c701
commit
1dab4f95dd
2 changed files with 45 additions and 44 deletions
|
@ -112,3 +112,5 @@ v 1.9:
|
||||||
- Fixed a random null error upon a player portaling.
|
- Fixed a random null error upon a player portaling.
|
||||||
- Fixed infinite loop error on player join.
|
- Fixed infinite loop error on player join.
|
||||||
- Optimized code to only update the player logging in instead of all players online.
|
- 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.
|
|
@ -130,41 +130,48 @@ public class WorldsHolder {
|
||||||
|
|
||||||
// These worlds fully mirror their parent
|
// These worlds fully mirror their parent
|
||||||
for (Object o : mirrorList) {
|
for (Object o : mirrorList) {
|
||||||
try {
|
String world = o.toString().toLowerCase();
|
||||||
mirrorsGroup.remove(o.toString().toLowerCase());
|
if (world != serverDefaultWorldName) {
|
||||||
mirrorsUser.remove(o.toString().toLowerCase());
|
try {
|
||||||
} catch (Exception e) {
|
mirrorsGroup.remove(world);
|
||||||
}
|
mirrorsUser.remove(world);
|
||||||
mirrorsGroup.put(o.toString().toLowerCase(), getWorldData(source).getName());
|
} catch (Exception e) {
|
||||||
mirrorsUser.put(o.toString().toLowerCase(), getWorldData(source).getName());
|
}
|
||||||
|
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) {
|
} else if (mirrorsMap.get(source) instanceof MemorySection) {
|
||||||
MemorySection subSection = (MemorySection) mirrorsMap.get(source);
|
MemorySection subSection = (MemorySection) mirrorsMap.get(source);
|
||||||
|
|
||||||
for (String key : subSection.getKeys(true)) {
|
for (String key : subSection.getKeys(true)) {
|
||||||
//System.out.print("Key - " + key);
|
|
||||||
|
|
||||||
if (subSection.get(key) instanceof ArrayList) {
|
if (key.toLowerCase() != serverDefaultWorldName) {
|
||||||
ArrayList mirrorList = (ArrayList) subSection.get(key);
|
|
||||||
|
|
||||||
// These worlds have defined mirroring
|
if (subSection.get(key) instanceof ArrayList) {
|
||||||
for (Object o : mirrorList) {
|
ArrayList mirrorList = (ArrayList) subSection.get(key);
|
||||||
String type = o.toString().toLowerCase();
|
|
||||||
try {
|
|
||||||
if (type.equals("groups"))
|
|
||||||
mirrorsGroup.remove(key.toLowerCase());
|
|
||||||
|
|
||||||
if (type.equals("users"))
|
// These worlds have defined mirroring
|
||||||
mirrorsUser.remove(key.toLowerCase());
|
for (Object o : mirrorList) {
|
||||||
|
String type = o.toString().toLowerCase();
|
||||||
|
try {
|
||||||
|
if (type.equals("groups"))
|
||||||
|
mirrorsGroup.remove(key.toLowerCase());
|
||||||
|
|
||||||
} catch (Exception e) {
|
if (type.equals("users"))
|
||||||
}
|
mirrorsUser.remove(key.toLowerCase());
|
||||||
if (type.equals("groups"))
|
|
||||||
mirrorsGroup.put(key.toLowerCase(), getWorldData(source).getName());
|
|
||||||
|
|
||||||
if (type.equals("users"))
|
} catch (Exception e) {
|
||||||
mirrorsUser.put(key.toLowerCase(), getWorldData(source).getName());
|
}
|
||||||
}
|
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
|
* If the world is not on the worlds list, returns the default world
|
||||||
* holder.
|
* holder.
|
||||||
*
|
*
|
||||||
* (WHEN A WORLD IS CONFIGURED TO MIRROR, IT WILL BE ON THE LIST, BUT
|
* Mirrors return original world data.
|
||||||
* POINTING TO ANOTHER WORLD HOLDER)
|
|
||||||
*
|
|
||||||
* Mirrors prevails original data.
|
|
||||||
*
|
*
|
||||||
* @param worldName
|
* @param worldName
|
||||||
* @return OverloadedWorldHolder
|
* @return OverloadedWorldHolder
|
||||||
*/
|
*/
|
||||||
public OverloadedWorldHolder getWorldData(String worldName) {
|
public OverloadedWorldHolder getWorldData(String worldName) {
|
||||||
String worldNameLowered = worldName.toLowerCase();
|
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 (data == null) {
|
if (worldsData.containsKey(worldNameLowered))
|
||||||
GroupManager.logger.finest("Requested world " + worldName + " not found or badly mirrored. Returning default world...");
|
return worldsData.get(worldNameLowered);
|
||||||
data = getDefaultWorld();
|
|
||||||
}
|
GroupManager.logger.finest("Requested world " + worldName + " not found or badly mirrored. Returning default world...");
|
||||||
return data;
|
return getDefaultWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue