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())); }
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())); }