Exemple #1
0
  // TODO set up number of stages ?
  public SpoutWorld(
      String name,
      SpoutEngine engine,
      long seed,
      long age,
      WorldGenerator generator,
      UUID uid,
      StringMap itemMap,
      StringMap lightingMap) {
    this.engine = engine;
    if (!StringSanitizer.isAlphaNumericUnderscore(name)) {
      name = Long.toHexString(System.currentTimeMillis());
      getEngine()
          .getLogger()
          .severe("World name " + name + " is not valid, using " + name + " instead");
    }
    this.name = name;
    this.uid = uid;
    this.itemMap = itemMap;
    this.lightingMap = lightingMap;
    this.seed = seed;

    this.generator = generator;
    regions = new RegionSource(this, snapshotManager);

    worldDirectory = new File(engine.getWorldFolder(), name);
    worldDirectory.mkdirs();

    regionFileManager = new RegionFileManager(worldDirectory);

    heightMapBAAs = new TSyncIntPairObjectHashMap<BAAWrapper>();

    this.hashcode = new HashCodeBuilder(27, 971).append(uid).toHashCode();

    for (int i = 0; i < columnLockMap.length; i++) {
      columnLockMap[i] = new ReentrantLock();
    }

    parallelTaskManager = new SpoutParallelTaskManager(engine.getScheduler(), this);

    lightingManagers =
        new UnprotectedCopyOnUpdateArray<LightingManager<?>>(LightingManager.class, true);

    this.age = new SnapshotableLong(snapshotManager, age);
    taskManager = new SpoutTaskManager(getEngine().getScheduler(), null, this, age);
    spawnLocation.set(new Transform(new Point(this, 1, 100, 1), Quaternion.IDENTITY, Vector3.ONE));
    selfReference = new WeakReference<SpoutWorld>(this);

    getEngine().getScheduler().addAsyncManager(this);
  }
Exemple #2
0
 public void removePlayer(Player player) {
   players.remove(player);
   engine.getEventManager().callDelayedEvent(new EntityExitWorldEvent(this, player));
 }
Exemple #3
0
 public void addPlayer(Player player) {
   players.add(player);
   engine.getEventManager().callDelayedEvent(new EntityEnterWorldEvent(this, player));
 }