package me.nallar.collections;

import me.nallar.tickthreading.Log;
import net.minecraft.world.World;

public class ListSet extends SynchronizedList {
	@Override
	public synchronized boolean add(final Object o) {
		if (o instanceof World) {
			World world = (World) o;
			for (World world_ : (Iterable<World>) this) {
				if (world_ == world) {
					return false;
				} else if (world.provider.dimensionId == world_.provider.dimensionId) {
					Log.severe("Attempted to add " + Log.dumpWorld(world) + " to bukkit dimensions when " + Log.dumpWorld(world_) + " is already in it.", new Throwable());
					return false;
				}
			}
			return super.add(o);
		}
		return !this.contains(o) && super.add(o);
	}
}

@@ -27,16 +27,46 @@
 ons;%0D%0A%0D%0A
+import java.util.Iterator;%0D%0A%0D%0A
 import m
@@ -128,16 +128,59 @@
 .World;%0D
+%0Aimport net.minecraft.world.WorldProvider;%0D
 %0A%0D%0Apubli
@@ -352,124 +352,569 @@
 %0A%09%09%09
-for (W
+WorldProvider provider = world.provider;%0D%0A%09%09%09if (provider == null) %7B%0D%0A%09%09%09%09Log.severe(%22Tried to add w
 orld
+ %22 +
  world
-_ : (Iterable%3CWorld%3E) this) %7B%0D%0A%09%09%09%09if (world_ == world) %7B%0D%0A%09%09%09%09%09return false;%0D%0A%09%09%09%09%7D else if (world.
+ + %22 with null provider to bukkit dimensions.%22, new Throwable());%0D%0A%09%09%09%09return false;%0D%0A%09%09%09%7D%0D%0A%09%09%09Iterator%3CWorld%3E iterator = this.iterator();%0D%0A%09%09%09while (iterator.hasNext()) %7B%0D%0A%09%09%09%09World world_ = iterator.next();%0D%0A%09%09%09%09if (world_ == world) %7B%0D%0A%09%09%09%09%09return false;%0D%0A%09%09%09%09%7D else if (world_.provider == null) %7B%0D%0A%09%09%09%09%09Log.severe(%22World %22 + world_ + %22 with null provider still in bukkit dimensions.%22, new Throwable());%0D%0A%09%09%09%09%09iterator.remove();%0D%0A%09%09%09%09%7D else if (
 prov

Fix crash on login with broken bukkit dimensions list