Exemplo n.º 1
0
  protected void b(ICommandListener icommandlistener, int i) {
    for (int j = 0; j < MinecraftServer.getServer().worldServer.length; ++j) {
      WorldServer worldserver = MinecraftServer.getServer().worldServer[j];

      worldserver.setDayTime(worldserver.getDayTime() + (long) i);
    }
  }
Exemplo n.º 2
0
  protected void saveChunks(boolean flag)
      throws ExceptionWorldConflict { // CraftBukkit - added throws
    if (!this.M) {
      // CraftBukkit start - fire WorldSaveEvent
      // WorldServer[] aworldserver = this.worldServer;
      int i = this.worlds.size();

      for (int j = 0; j < i; ++j) {
        WorldServer worldserver = this.worlds.get(j);

        if (worldserver != null) {
          if (!flag) {
            MinecraftServer.i.info(
                "Saving chunks for level \'"
                    + worldserver.getWorldData().getName()
                    + "\'/"
                    + worldserver.worldProvider.getName());
          }

          worldserver.save(true, (IProgressUpdate) null);
          worldserver.saveLevel();

          WorldSaveEvent event = new WorldSaveEvent(worldserver.getWorld());
          this.server.getPluginManager().callEvent(event);
          // CraftBukkit end
        }
      }
    }
  }
Exemplo n.º 3
0
  public Banker spawnBanker(String name, Location l, String id, String bankName) {
    if (bankers.containsKey(id)) {
      Log.warning("NPC with that id already exists, existing NPC returned");
      return bankers.get(id);
    } else {
      if (name.length()
          > 16) { // Check and nag if name is too long, spawn NPC anyway with shortened name.
        String tmp = name.substring(0, 16);
        Log.warning("NPCs can't have names longer than 16 characters,");
        Log.warning(name + " has been shortened to " + tmp);
        name = tmp;
      }
      WorldServer ws = getWorldServer(l.getWorld());
      NPCEntity npcEntity = new NPCEntity(this, ws, name, new ItemInWorldManager(ws));
      npcEntity.setPositionRotation(l.getX(), l.getY(), l.getZ(), l.getYaw(), l.getPitch());
      ws.addEntity(npcEntity); // the right way
      Banker npc = new Banker(npcEntity, bankName);
      npc.setYaw(l.getYaw());

      if (Bukkit.getPluginManager().isPluginEnabled("Spout")) {
        SpoutPlayer sp = npc.getSpoutPlayer();
        sp.setSkin("http://dl.dropbox.com/u/18216599/images/bankersskin.png");
        sp.setTitle(ChatColor.GOLD + "Banker\n" + ChatColor.WHITE + "[" + bankName + "]");
      }

      bankers.put(id, npc);
      return npc;
    }
  }
Exemplo n.º 4
0
  public void a(Packet7UseEntity packet7useentity) {
    // CraftBukkit start
    if (this.player.dead) {
      return;
    }
    // CraftBukkit end

    WorldServer worldserver = this.minecraftServer.a(this.player.dimension);
    Entity entity = worldserver.getEntity(packet7useentity.target);

    if (entity != null && this.player.e(entity) && this.player.g(entity) < 36.0D) {
      if (packet7useentity.c == 0) {
        // CraftBukkit start
        PlayerInteractEntityEvent piee =
            new PlayerInteractEntityEvent((Player) getPlayer(), entity.getBukkitEntity());
        server.getPluginManager().callEvent(piee);
        if (piee.isCancelled()) {
          return;
        }
        // CraftBukkit end
        this.player.c(entity);
      } else if (packet7useentity.c == 1) {
        this.player.d(entity);
      }
    }
  }
  public void getChunkAt(IChunkProvider ichunkprovider, int i, int j) {
    Chunk chunk = this.getOrCreateChunk(i, j);

    if (!chunk.done) {
      chunk.done = true;
      if (this.chunkProvider != null) {
        this.chunkProvider.getChunkAt(ichunkprovider, i, j);

        // CraftBukkit start
        BlockSand.instaFall = true;
        Random random = new Random();
        random.setSeed(world.getSeed());
        long xRand = random.nextLong() / 2L * 2L + 1L;
        long zRand = random.nextLong() / 2L * 2L + 1L;
        random.setSeed((long) i * xRand + (long) j * zRand ^ world.getSeed());

        org.bukkit.World world = this.world.getWorld();
        if (world != null) {
          for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) {
            populator.populate(world, random, chunk.bukkitChunk);
          }
        }
        BlockSand.instaFall = false;
        this.world
            .getServer()
            .getPluginManager()
            .callEvent(new org.bukkit.event.world.ChunkPopulateEvent(chunk.bukkitChunk));
        // CraftBukkit end

        chunk.e();
      }
    }
  }
Exemplo n.º 6
0
  protected void initialWorldChunkLoad() {
    boolean var1 = true;
    boolean var2 = true;
    boolean var3 = true;
    boolean var4 = true;
    int var5 = 0;
    this.setUserMessage("menu.generatingTerrain");
    byte var6 = 0;
    logger.info("Preparing start region for level " + var6);
    WorldServer var7 = this.worldServers[var6];
    BlockPos var8 = var7.getSpawnPoint();
    long var9 = getCurrentTimeMillis();

    for (int var11 = -192; var11 <= 192 && this.isServerRunning(); var11 += 16) {
      for (int var12 = -192; var12 <= 192 && this.isServerRunning(); var12 += 16) {
        long var13 = getCurrentTimeMillis();

        if (var13 - var9 > 1000L) {
          this.outputPercentRemaining("Preparing spawn area", var5 * 100 / 625);
          var9 = var13;
        }

        ++var5;
        var7.theChunkProviderServer.loadChunk(var8.getX() + var11 >> 4, var8.getZ() + var12 >> 4);
      }
    }

    this.clearCurrentTask();
  }
Exemplo n.º 7
0
  public void changeWorld(WorldServer srv) {
    ChunkCoordinates chunkcoordinates = srv.l();

    if (chunkcoordinates != null) {
      this.a.a(
          (double) chunkcoordinates.a,
          (double) chunkcoordinates.b,
          (double) chunkcoordinates.c,
          0.0F,
          0.0F,
          srv.getCanaryWorld().getType().getId(),
          srv.getCanaryWorld().getName());
    }

    // CanaryMod: Dimension switch hook.
    Location goingTo =
        this.simulatePortalUse(
            srv.q, MinecraftServer.D().getWorld(this.getCanaryWorld().getName(), srv.q));
    CancelableHook hook =
        new DimensionSwitch(this.getCanaryEntity(), this.getCanaryEntity().getLocation(), goingTo);

    Canary.hooks().callHook(hook);
    if (hook.isCanceled()) {
      return;
    } //

    this.b.ad().a(this, srv.getCanaryWorld().getName(), srv.getCanaryWorld().getType().getId());
    this.cp = -1;
    this.cm = -1;
    this.cn = -1;
  }
Exemplo n.º 8
0
  /** par1 indicates if a log message should be output. */
  protected void saveAllWorlds(boolean dontLog) {
    if (!this.worldIsBeingDeleted) {
      WorldServer[] var2 = this.worldServers;
      int var3 = var2.length;

      for (int var4 = 0; var4 < var3; ++var4) {
        WorldServer var5 = var2[var4];

        if (var5 != null) {
          if (!dontLog) {
            logger.info(
                "Saving chunks for level \'"
                    + var5.getWorldInfo().getWorldName()
                    + "\'/"
                    + var5.provider.getDimensionName());
          }

          try {
            var5.saveAllChunks(true, (IProgressUpdate) null);
          } catch (MinecraftException var7) {
            logger.warn(var7.getMessage());
          }
        }
      }
    }
  }
Exemplo n.º 9
0
  /** Saves all necessary data as preparation for stopping the server. */
  public void stopServer() {
    if (!this.worldIsBeingDeleted) {
      logger.info("Stopping server");

      if (this.getNetworkSystem() != null) {
        this.getNetworkSystem().terminateEndpoints();
      }

      if (this.serverConfigManager != null) {
        logger.info("Saving players");
        this.serverConfigManager.saveAllPlayerData();
        this.serverConfigManager.removeAllPlayers();
      }

      if (this.worldServers != null) {
        logger.info("Saving worlds");
        this.saveAllWorlds(false);

        for (int var1 = 0; var1 < this.worldServers.length; ++var1) {
          WorldServer var2 = this.worldServers[var1];
          var2.flush();
        }
      }

      if (this.usageSnooper.isSnooperRunning()) {
        this.usageSnooper.stopSnooper();
      }
    }
  }
Exemplo n.º 10
0
 public static HumanNPC spawnNPC(
     int UID,
     String name,
     World world,
     double x,
     double y,
     double z,
     float yaw,
     float pitch,
     CreatureNPCType type) {
   try {
     WorldServer ws = getWorldServer(world);
     MinecraftServer ms = getMinecraftServer(ws.getServer());
     CraftNPC eh =
         (CraftNPC)
             type.getEntityClass()
                 .getConstructors()[0]
                 .newInstance(ms, ws, name, new ItemInWorldManager(ws));
     ws.addEntity(eh);
     eh.setLocation(x, y, z, yaw, pitch);
     ws.players.remove(eh);
     return new HumanNPC(eh, UID, name);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return null;
 }
Exemplo n.º 11
0
  private void saveChunks() {
    log.info("Saving chunks");

    for (int i = 0; i < this.worldServer.length; ++i) {
      WorldServer worldserver = this.worldServer[i];

      worldserver.save(true, (IProgressUpdate) null);
      worldserver.saveLevel();
    }
  }
Exemplo n.º 12
0
  @Override
  public boolean teleport(Location location) {
    WorldServer oldWorld = ((CraftWorld) getWorld()).getHandle();
    WorldServer newWorld = ((CraftWorld) location.getWorld()).getHandle();
    ServerConfigurationManager manager = server.getHandle();
    EntityPlayer entity = getHandle();
    boolean teleportSuccess;

    if (oldWorld != newWorld) {

      EntityPlayer newEntity =
          new EntityPlayer(manager.c, newWorld, entity.name, new ItemInWorldManager(newWorld));

      newEntity.id = entity.id;
      newEntity.a = entity.a;
      newEntity.health = entity.health;
      newEntity.fireTicks = entity.fireTicks;
      newEntity.inventory = entity.inventory;
      newEntity.inventory.d = newEntity;
      newEntity.activeContainer = entity.activeContainer;
      newEntity.defaultContainer = entity.defaultContainer;
      newEntity.lastwarp = entity.lastwarp; // Buck - It
      newEntity.locX = location.getX();
      newEntity.locY = location.getY();
      newEntity.locZ = location.getZ();
      newEntity.displayName = entity.displayName;
      newEntity.compassTarget = entity.compassTarget;
      newEntity.fauxSleeping = entity.fauxSleeping;
      newWorld.u.c((int) location.getBlockX() >> 4, (int) location.getBlockZ() >> 4);

      teleportSuccess = newEntity.a.teleport(location);

      if (teleportSuccess) {
        manager.c.k.a(entity);
        manager.c.k.b(entity);
        oldWorld.manager.b(entity);
        manager.b.remove(entity);
        oldWorld.e(entity);

        newWorld.manager.a(newEntity);
        newWorld.a(newEntity);
        manager.b.add(newEntity);

        entity.a.e = newEntity;
        this.entity = newEntity;

        setCompassTarget(getCompassTarget());
      }

      return teleportSuccess;
    } else {
      return entity.a.teleport(location);
    }
  }
Exemplo n.º 13
0
 public static HumanNPC spawnNPC(HumanNPC npc, Location loc) {
   try {
     WorldServer ws = getWorldServer(loc.getWorld());
     ws.addEntity(npc.getHandle());
     npc.teleport(loc);
     ws.players.remove(npc.getHandle());
     return npc;
   } catch (Exception e) {
     e.printStackTrace();
   }
   return null;
 }
Exemplo n.º 14
0
  public void addServerStatsToSnooper(PlayerUsageSnooper playerSnooper) {
    playerSnooper.addClientStat("whitelist_enabled", Boolean.valueOf(false));
    playerSnooper.addClientStat("whitelist_count", Integer.valueOf(0));

    if (this.serverConfigManager != null) {
      playerSnooper.addClientStat("players_current", Integer.valueOf(this.getCurrentPlayerCount()));
      playerSnooper.addClientStat("players_max", Integer.valueOf(this.getMaxPlayers()));
      playerSnooper.addClientStat(
          "players_seen", Integer.valueOf(this.serverConfigManager.getAvailablePlayerDat().length));
    }

    playerSnooper.addClientStat("uses_auth", Boolean.valueOf(this.onlineMode));
    playerSnooper.addClientStat("gui_state", this.getGuiEnabled() ? "enabled" : "disabled");
    playerSnooper.addClientStat(
        "run_time",
        Long.valueOf(
            (getCurrentTimeMillis() - playerSnooper.getMinecraftStartTimeMillis()) / 60L * 1000L));
    playerSnooper.addClientStat(
        "avg_tick_ms", Integer.valueOf((int) (MathHelper.average(this.tickTimeArray) * 1.0E-6D)));
    int var2 = 0;

    if (this.worldServers != null) {
      for (int var3 = 0; var3 < this.worldServers.length; ++var3) {
        if (this.worldServers[var3] != null) {
          WorldServer var4 = this.worldServers[var3];
          WorldInfo var5 = var4.getWorldInfo();
          playerSnooper.addClientStat(
              "world[" + var2 + "][dimension]", Integer.valueOf(var4.provider.getDimensionId()));
          playerSnooper.addClientStat("world[" + var2 + "][mode]", var5.getGameType());
          playerSnooper.addClientStat("world[" + var2 + "][difficulty]", var4.getDifficulty());
          playerSnooper.addClientStat(
              "world[" + var2 + "][hardcore]", Boolean.valueOf(var5.isHardcoreModeEnabled()));
          playerSnooper.addClientStat(
              "world[" + var2 + "][generator_name]", var5.getTerrainType().getWorldTypeName());
          playerSnooper.addClientStat(
              "world[" + var2 + "][generator_version]",
              Integer.valueOf(var5.getTerrainType().getGeneratorVersion()));
          playerSnooper.addClientStat(
              "world[" + var2 + "][height]", Integer.valueOf(this.buildLimit));
          playerSnooper.addClientStat(
              "world[" + var2 + "][chunks_loaded]",
              Integer.valueOf(var4.getChunkProvider().getLoadedChunkCount()));
          ++var2;
        }
      }
    }

    playerSnooper.addClientStat("worlds", Integer.valueOf(var2));
  }
Exemplo n.º 15
0
 @SuppressWarnings("rawtypes")
 public static void sendChunkTiles(int cx, int cz, EntityPlayer player) {
   WorldServer worldserver = (WorldServer) player.world;
   List tileEntities =
       worldserver.getTileEntities(cx << 4, 0, cz << 4, (cx << 4) + 16, 128, (cz << 4) + 16);
   for (Object tileEntityObject : tileEntities) {
     if (tileEntityObject != null && tileEntityObject instanceof TileEntity) {
       TileEntity tileEntity = (TileEntity) tileEntityObject;
       Packet tilePacket = tileEntity.k();
       if (tilePacket != null) {
         MapChunkThread.sendPacket(player, tilePacket);
       }
     }
   }
 }
Exemplo n.º 16
0
  public void a(MojangStatisticsGenerator mojangstatisticsgenerator) {
    mojangstatisticsgenerator.a("whitelist_enabled", Boolean.valueOf(false));
    mojangstatisticsgenerator.a("whitelist_count", Integer.valueOf(0));
    if (this.v != null) {
      mojangstatisticsgenerator.a("players_current", Integer.valueOf(this.G()));
      mojangstatisticsgenerator.a("players_max", Integer.valueOf(this.H()));
      mojangstatisticsgenerator.a("players_seen", Integer.valueOf(this.v.getSeenPlayers().length));
    }

    mojangstatisticsgenerator.a("uses_auth", Boolean.valueOf(this.onlineMode));
    mojangstatisticsgenerator.a("gui_state", this.aq() ? "enabled" : "disabled");
    mojangstatisticsgenerator.a(
        "run_time", Long.valueOf((ax() - mojangstatisticsgenerator.g()) / 60L * 1000L));
    mojangstatisticsgenerator.a(
        "avg_tick_ms", Integer.valueOf((int) (MathHelper.a(this.g) * 1.0E-6D)));
    int i = 0;

    if (this.worldServer != null) {
      // CraftBukkit start
      for (int j = 0; j < this.worlds.size(); ++j) {
        WorldServer worldserver = this.worlds.get(j);
        if (worldserver != null) {
          // CraftBukkit end
          WorldData worlddata = worldserver.getWorldData();

          mojangstatisticsgenerator.a(
              "world[" + i + "][dimension]",
              Integer.valueOf(worldserver.worldProvider.getDimension()));
          mojangstatisticsgenerator.a("world[" + i + "][mode]", worlddata.getGameType());
          mojangstatisticsgenerator.a("world[" + i + "][difficulty]", worldserver.getDifficulty());
          mojangstatisticsgenerator.a(
              "world[" + i + "][hardcore]", Boolean.valueOf(worlddata.isHardcore()));
          mojangstatisticsgenerator.a(
              "world[" + i + "][generator_name]", worlddata.getType().name());
          mojangstatisticsgenerator.a(
              "world[" + i + "][generator_version]",
              Integer.valueOf(worlddata.getType().getVersion()));
          mojangstatisticsgenerator.a("world[" + i + "][height]", Integer.valueOf(this.F));
          mojangstatisticsgenerator.a(
              "world[" + i + "][chunks_loaded]",
              Integer.valueOf(worldserver.N().getLoadedChunks()));
          ++i;
        }
      }
    }

    mojangstatisticsgenerator.a("worlds", Integer.valueOf(i));
  }
Exemplo n.º 17
0
  /**
   * WARNING : directly calls
   * getActiveAnvilConverter().deleteWorldDirectory(theWorldServer[0].getSaveHandler().getWorldDirectoryName());
   */
  public void deleteWorldAndStopServer() {
    this.worldIsBeingDeleted = true;
    this.getActiveAnvilConverter().flushCache();

    for (int var1 = 0; var1 < this.worldServers.length; ++var1) {
      WorldServer var2 = this.worldServers[var1];

      if (var2 != null) {
        var2.flush();
      }
    }

    this.getActiveAnvilConverter()
        .deleteWorldDirectory(this.worldServers[0].getSaveHandler().getWorldDirectoryName());
    this.initiateShutdown();
  }
  public Chunk getOrCreateChunk(int i, int j) {
    // CraftBukkit start
    Chunk chunk = this.chunks.get(i, j);

    chunk =
        chunk == null
            ? (!this.world.isLoading && !this.forceChunkLoad
                ? this.emptyChunk
                : this.getChunkAt(i, j))
            : chunk;
    if (chunk == this.emptyChunk) return chunk;
    if (i != chunk.x || j != chunk.z) {
      MinecraftServer.log.severe(
          "Chunk ("
              + chunk.x
              + ", "
              + chunk.z
              + ") stored at  ("
              + i
              + ", "
              + j
              + ") in world '"
              + world.getWorld().getName()
              + "'");
      MinecraftServer.log.severe(chunk.getClass().getName());
      Throwable ex = new Throwable();
      ex.fillInStackTrace();
      ex.printStackTrace();
    }
    return chunk;
    // CraftBukkit end
  }
Exemplo n.º 19
0
  public Entity a(UUID uuid) {
    // CraftBukkit start
    for (int j = 0; j < worlds.size(); ++j) {
      WorldServer worldserver = worlds.get(j);
      // CraftBukkit end

      if (worldserver != null) {
        Entity entity = worldserver.getEntity(uuid);

        if (entity != null) {
          return entity;
        }
      }
    }

    return null;
  }
Exemplo n.º 20
0
  public void Z() {
    this.N = true;
    this.getConvertable().d();

    // CraftBukkit start
    for (int i = 0; i < this.worlds.size(); ++i) {
      WorldServer worldserver = this.worlds.get(i);
      // CraftBukkit end

      if (worldserver != null) {
        worldserver.saveLevel();
      }
    }

    this.getConvertable().e(this.worlds.get(0).getDataManager().g()); // CraftBukkit
    this.safeShutdown();
  }
Exemplo n.º 21
0
  public Entity getEntityFromUuid(UUID uuid) {
    WorldServer[] var2 = this.worldServers;
    int var3 = var2.length;

    for (int var4 = 0; var4 < var3; ++var4) {
      WorldServer var5 = var2[var4];

      if (var5 != null) {
        Entity var6 = var5.getEntityFromUuid(uuid);

        if (var6 != null) {
          return var6;
        }
      }
    }

    return null;
  }
  public Chunk getOrCreateChunk(int x, int z) {
    random.setSeed((long) x * 341873128712L + (long) z * 132897987541L);
    byte[] types = generator.generate(world.getWorld(), random, x, z);

    Chunk chunk = new Chunk(world, types, x, z);

    chunk.initLighting();

    return chunk;
  }
  void saveChunks() { // CraftBukkit - private -> default
    log.info("Saving chunks");

    // CraftBukkit start
    for (int i = 0; i < this.worlds.size(); ++i) {
      WorldServer worldserver = this.worlds.get(i);

      worldserver.save(true, (IProgressUpdate) null);
      worldserver.saveLevel();

      WorldSaveEvent event = new WorldSaveEvent(worldserver.getWorld());
      this.server.getPluginManager().callEvent(event);
    }

    WorldServer world = this.worlds.get(0);
    if (!world.savingDisabled) {
      this.serverConfigurationManager.savePlayers();
    }
    // CraftBukkit end
  }
Exemplo n.º 24
0
  public void setDifficultyForAllWorlds(EnumDifficulty difficulty) {
    for (int var2 = 0; var2 < this.worldServers.length; ++var2) {
      WorldServer var3 = this.worldServers[var2];

      if (var3 != null) {
        if (var3.getWorldInfo().isHardcoreModeEnabled()) {
          var3.getWorldInfo().setDifficulty(EnumDifficulty.HARD);
          var3.setAllowedSpawnTypes(true, true);
        } else if (this.isSinglePlayer()) {
          var3.getWorldInfo().setDifficulty(difficulty);
          var3.setAllowedSpawnTypes(var3.getDifficulty() != EnumDifficulty.PEACEFUL, true);
        } else {
          var3.getWorldInfo().setDifficulty(difficulty);
          var3.setAllowedSpawnTypes(this.allowSpawnMonsters(), this.canSpawnAnimals);
        }
      }
    }
  }
Exemplo n.º 25
0
  protected void saveChunks(boolean flag)
      throws ExceptionWorldConflict { // CraftBukkit - added throws
    if (!this.N) {

      // CraftBukkit start
      for (int j = 0; j < worlds.size(); ++j) {
        WorldServer worldserver = worlds.get(j);
        // CraftBukkit end
        if (worldserver != null) {
          if (!flag) {
            MinecraftServer.LOGGER.info(
                "Saving chunks for level \'"
                    + worldserver.getWorldData().getName()
                    + "\'/"
                    + worldserver.worldProvider.getName());
          }

          worldserver.save(true, (IProgressUpdate) null);
          worldserver.saveLevel();
        }
      }
    }
  }
Exemplo n.º 26
0
  public void a(EnumDifficulty enumdifficulty) {
    // CraftBukkit start
    for (int i = 0; i < this.worlds.size(); ++i) {
      WorldServer worldserver = this.worlds.get(i);
      // CraftBukkit end

      if (worldserver != null) {
        if (worldserver.getWorldData().isHardcore()) {
          worldserver.getWorldData().setDifficulty(EnumDifficulty.HARD);
          worldserver.setSpawnFlags(true, true);
        } else if (this.S()) {
          worldserver.getWorldData().setDifficulty(enumdifficulty);
          worldserver.setSpawnFlags(worldserver.getDifficulty() != EnumDifficulty.PEACEFUL, true);
        } else {
          worldserver.getWorldData().setDifficulty(enumdifficulty);
          worldserver.setSpawnFlags(this.getSpawnMonsters(), this.spawnAnimals);
        }
      }
    }
  }
Exemplo n.º 27
0
 /**
  * Checks if the player is on ground.
  *
  * @return true, if the player is on ground
  */
 public boolean isOnGround() {
   if (onGround == null) {
     final double d0 = 0.01D;
     onGround =
         BlockProperties.isOnGround(
             getBlockAccess(),
             minX - d0,
             minY - yOnGround,
             minZ - d0,
             maxX + d0,
             minY + 0.25,
             maxZ + d0);
     if (!onGround) {
       // TODO: Probably check other ids too before doing this ?
       final double d1 = 0.25D;
       final AxisAlignedBB box =
           useBox.b(
               minX - d1,
               minY - getyOnGround() - d1,
               minZ - d1,
               maxX + d1,
               minY + 0.25 + d1,
               maxZ + d1);
       @SuppressWarnings("rawtypes")
       final List list = worldServer.getEntities(entityPlayer, box);
       @SuppressWarnings("rawtypes")
       Iterator iterator = list.iterator();
       while (iterator.hasNext()) {
         final Entity entity = (Entity) iterator.next();
         final EntityType type = entity.getBukkitEntity().getType();
         if (type != EntityType.BOAT && type != EntityType.MINECART) continue;
         final AxisAlignedBB otherBox = entity.boundingBox;
         if (box.a > otherBox.d
             || box.d < otherBox.a
             || box.b > otherBox.e
             || box.e < otherBox.b
             || box.c > otherBox.f
             || box.f < otherBox.c) continue;
         else {
           onGround = true;
           break;
         }
       }
     }
   }
   return onGround;
 }
Exemplo n.º 28
0
  public void a(EnumDifficulty enumdifficulty) {
    // CraftBukkit start - Use worlds list for iteration
    for (int j = 0; j < this.worlds.size(); ++j) {
      WorldServer worldserver = this.worlds.get(j);
      // CraftBukkit end

      if (worldserver != null) {
        if (worldserver.getWorldData().isHardcore()) {
          worldserver.difficulty = EnumDifficulty.HARD;
          worldserver.setSpawnFlags(true, true);
        } else if (this.N()) {
          worldserver.difficulty = enumdifficulty;
          worldserver.setSpawnFlags(worldserver.difficulty != EnumDifficulty.PEACEFUL, true);
        } else {
          worldserver.difficulty = enumdifficulty;
          worldserver.setSpawnFlags(this.getSpawnMonsters(), this.spawnAnimals);
        }
      }
    }
  }
Exemplo n.º 29
0
  protected void k() {
    boolean flag = true;
    boolean flag1 = true;
    boolean flag2 = true;
    boolean flag3 = true;
    int i = 0;

    this.b("menu.generatingTerrain");
    byte b0 = 0;

    // CraftBukkit start - fire WorldLoadEvent and handle whether or not to keep the spawn in memory
    for (int m = 0; m < worlds.size(); m++) {
      WorldServer worldserver = this.worlds.get(m);
      LOGGER.info(
          "Preparing start region for level " + m + " (Seed: " + worldserver.getSeed() + ")");

      if (!worldserver.getWorld().getKeepSpawnInMemory()) {
        continue;
      }

      BlockPosition blockposition = worldserver.getSpawn();
      long j = ax();
      i = 0;

      for (int k = -192; k <= 192 && this.isRunning(); k += 16) {
        for (int l = -192; l <= 192 && this.isRunning(); l += 16) {
          long i1 = ax();

          if (i1 - j > 1000L) {
            this.a_("Preparing spawn area", i * 100 / 625);
            j = i1;
          }

          ++i;
          worldserver.chunkProviderServer.getChunkAt(
              blockposition.getX() + k >> 4, blockposition.getZ() + l >> 4);
        }
      }
    }

    for (WorldServer world : this.worlds) {
      this.server
          .getPluginManager()
          .callEvent(new org.bukkit.event.world.WorldLoadEvent(world.getWorld()));
    }
    // CraftBukkit end
    this.q();
  }
Exemplo n.º 30
0
  public void c(int i) {
    if (!this.world.isStatic && !this.dead) {
      this.world.methodProfiler.a("changeDimension");
      MinecraftServer minecraftserver = MinecraftServer.getServer();
      int j = this.dimension;
      WorldServer worldserver = minecraftserver.getWorldServer(j);
      WorldServer worldserver1 = minecraftserver.getWorldServer(i);

      this.dimension = i;
      if (j == 1 && i == 1) {
        worldserver1 = minecraftserver.getWorldServer(0);
        this.dimension = 0;
      }

      this.world.kill(this);
      this.dead = false;
      this.world.methodProfiler.a("reposition");
      minecraftserver.getPlayerList().changeWorld(this, j, worldserver, worldserver1);
      this.world.methodProfiler.c("reloading");
      Entity entity = EntityTypes.createEntityByName(EntityTypes.b(this), worldserver1);

      if (entity != null) {
        entity.n(this);
        if (j == 1 && i == 1) {
          BlockPosition blockposition = this.world.r(worldserver1.getSpawn());

          entity.setPositionRotation(blockposition, entity.yaw, entity.pitch);
        }

        worldserver1.addEntity(entity);
      }

      this.dead = true;
      this.world.methodProfiler.b();
      worldserver.j();
      worldserver1.j();
      this.world.methodProfiler.b();
    }
  }