コード例 #1
0
  public void deleteChunkLoader(ChunkLoader chunkLoader) {
    if (chunkLoader.isLoaded()) chunkLoader.delete();

    chunkLoader.getBlock().setType(Material.AIR);

    chunkLoaders.remove(chunkLoader);
    data.deleteChunkLoader(chunkLoader);
  }
コード例 #2
0
  public void updateChunkLoader(ChunkLoader chunkLoader) {
    data.saveChunkLoader(chunkLoader);

    Player player = getServer().getPlayer(chunkLoader.getOwner());
    if (player != null && player.isOnline())
      player.sendMessage(
          String.format(
              "%sSuccessfully updated your chunk loader. Chunks loaded are now %s",
              ChatColor.GOLD, chunkLoader.getSize()));
  }
コード例 #3
0
  public void loadWorldChunks() {
    List<ChunkLoader> chunks = data.getWorldChunks();
    int chunkCount = 0;

    for (ChunkLoader cl : chunks) {
      if (!cl.load()) continue;

      chunkCount += cl.getSize();
      chunkLoaders.add(cl);
    }

    getLogger()
        .info(
            String.format(
                "Loaded %s world chunk loaders, totalling %s chunks", chunks.size(), chunkCount));
  }
コード例 #4
0
  public void loadPersonalChunks(UUID uuid) {
    List<ChunkLoader> chunks = data.getPersonalChunks(uuid);
    int chunkCount = 0;

    for (ChunkLoader cl : chunks) {
      if (!cl.load()) continue;

      chunkCount += cl.getSize();
      getChunkLoaders().add(cl);
    }

    getLogger()
        .info(
            String.format(
                "Loaded %s personal chunk loaders, totalling %s chunks",
                chunks.size(), chunkCount));
  }
コード例 #5
0
  public void unloadPersonalChunks(UUID uuid) {
    List<ChunkLoader> chunks =
        chunkLoaders
            .stream()
            .filter(
                c ->
                    c.getOwner().equals(uuid) && c.getChunkType() == ChunkLoader.ChunkType.PERSONAL)
            .collect(Collectors.toList());

    int chunkCount = 0;

    for (ChunkLoader c : chunks) {
      chunkCount += c.getSize();
      c.unload();
    }

    getChunkLoaders().removeAll(chunks);

    getLogger()
        .info(
            String.format(
                "Unloaded %s personal chunk loaders, totalling %s chunks",
                chunks.size(), chunkCount));
  }
コード例 #6
0
 public IconMenu getChunkLoaderIconMenu(ChunkLoader chunkLoader) {
   return getChunkLoaderIconMenu(chunkLoader.getChunkType());
 }
コード例 #7
0
  public void addChunkLoader(ChunkLoader chunkLoader) {
    Block block =
        getServer()
            .getWorld(chunkLoader.getWorld())
            .getBlockAt(chunkLoader.getX(), chunkLoader.getY(), chunkLoader.getZ());

    ChunkLoader existing =
        chunkLoaders.stream().filter(c -> c.getBlock().equals(block)).findFirst().orElse(null);

    if (existing != null) existing.delete();

    chunkLoader.setBlock(block);

    block.setType(getChunkLoaderMaterial(chunkLoader.getChunkType()));

    getChunkLoaders().add(chunkLoader);

    chunkLoader.load();

    data.saveChunkLoader(chunkLoader);

    Player player = getServer().getPlayer(chunkLoader.getOwner());
    if (player != null && player.isOnline())
      player.sendMessage(
          String.format(
              "%sSuccessfully placed %s chunk loader with and ID of %s and %s chunks",
              ChatColor.GOLD,
              chunkLoader.getChunkType(),
              chunkLoader.getId(),
              chunkLoader.getSize()));
  }
コード例 #8
0
  /** copies a 32x32 chunk set from par2File to par1File, via AnvilConverterData */
  private void convertChunks(
      File par1File,
      File par2File,
      WorldChunkManager par3WorldChunkManager,
      int par4,
      int par5,
      IProgressUpdate par6IProgressUpdate) {
    try {
      String s = par2File.getName();
      RegionFile regionfile = new RegionFile(par2File);
      RegionFile regionfile1 =
          new RegionFile(
              new File(
                  par1File,
                  (new StringBuilder())
                      .append(s.substring(0, s.length() - ".mcr".length()))
                      .append(".mca")
                      .toString()));

      for (int i = 0; i < 32; i++) {
        for (int j = 0; j < 32; j++) {
          if (!regionfile.isChunkSaved(i, j) || regionfile1.isChunkSaved(i, j)) {
            continue;
          }

          DataInputStream datainputstream = regionfile.getChunkDataInputStream(i, j);

          if (datainputstream == null) {
            System.out.println("Failed to fetch input stream");
          } else {
            NBTTagCompound nbttagcompound = CompressedStreamTools.read(datainputstream);
            datainputstream.close();
            NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Level");
            AnvilConverterData anvilconverterdata = ChunkLoader.load(nbttagcompound1);
            NBTTagCompound nbttagcompound2 = new NBTTagCompound();
            NBTTagCompound nbttagcompound3 = new NBTTagCompound();
            nbttagcompound2.setTag("Level", nbttagcompound3);
            ChunkLoader.convertToAnvilFormat(
                anvilconverterdata, nbttagcompound3, par3WorldChunkManager);
            DataOutputStream dataoutputstream = regionfile1.getChunkDataOutputStream(i, j);
            CompressedStreamTools.write(nbttagcompound2, dataoutputstream);
            dataoutputstream.close();
          }
        }

        int k = (int) Math.round((100D * (double) (par4 * 1024)) / (double) (par5 * 1024));
        int l =
            (int)
                Math.round((100D * (double) ((i + 1) * 32 + par4 * 1024)) / (double) (par5 * 1024));

        if (l > k) {
          par6IProgressUpdate.setLoadingProgress(l);
        }
      }

      regionfile.close();
      regionfile1.close();
    } catch (IOException ioexception) {
      ioexception.printStackTrace();
    }
  }