Search in sources :

Example 1 with MapManager

use of pl.themolka.arcade.map.MapManager in project Arcade2 by ShootGame.

the class ArcadePlugin method loadMaps.

private void loadMaps() {
    this.maps = new MapManager(this);
    this.maps.setWorldContainer(this.settings.getWorldContainer().toFile());
    MapContainerFillEvent fillEvent = new MapContainerFillEvent(this);
    this.getEventBus().publish(fillEvent);
    MapManager maps = this.getMaps();
    for (MapContainerLoader loader : fillEvent.getMapLoaderList()) {
        maps.addMapLoader(loader);
    }
    maps.getContainer().register(maps.getLoaderListContainer());
    this.getLogger().info("Loaded " + maps.getContainer().getMaps().size() + " map(s) into the plugin.");
}
Also used : MapContainerLoader(pl.themolka.arcade.map.MapContainerLoader) MapContainerFillEvent(pl.themolka.arcade.map.MapContainerFillEvent) MapManager(pl.themolka.arcade.map.MapManager)

Example 2 with MapManager

use of pl.themolka.arcade.map.MapManager in project Arcade2 by ShootGame.

the class SimpleGameManager method createGame.

@Override
public Game createGame(ArcadeMap map) throws DOMException, IOException {
    MapManager maps = this.plugin.getMaps();
    this.plugin.getLogger().info("Accessing the '" + map.getMapInfo().getDirectory().getName() + "' directory...");
    File[] copied = maps.copyFiles(map);
    StringBuilder copiedFiles = new StringBuilder();
    for (int i = 0; i < copied.length; i++) {
        File file = copied[i];
        copiedFiles.append(file.getName());
        if (file.isDirectory()) {
            copiedFiles.append("[d]");
        } else if (file.isFile()) {
            copiedFiles.append("[f]");
        }
        if (i != copied.length - 1) {
            copiedFiles.append(", ");
        }
    }
    this.plugin.getLogger().info("Copied " + copied.length + " map files - " + copiedFiles.toString() + ".");
    this.plugin.getLogger().info("Generating new unique world '" + map.getWorldName() + "' for map '" + map.getMapInfo().getName() + "'...");
    World world = maps.createWorld(map);
    Game game = new Game(this.plugin, this.gameId++, map, world);
    map.setGame(game);
    // Don't forget to setup the world object!
    map.getManifest().getWorld().getSpawn().setWorld(world);
    for (ArcadePlayer player : this.plugin.getPlayers()) {
        GamePlayer gamePlayer = player.getGamePlayer();
        gamePlayer.getBossBarFacet().removeAll();
        player.setGamePlayer(new GamePlayer(game, player));
        game.getPlayers().playerJoin(player.getGamePlayer());
    }
    this.resetPlayers(game);
    return game;
}
Also used : ArcadePlayer(pl.themolka.arcade.session.ArcadePlayer) MapManager(pl.themolka.arcade.map.MapManager) CraftWorld(org.bukkit.craftbukkit.CraftWorld) World(org.bukkit.World) File(java.io.File)

Aggregations

MapManager (pl.themolka.arcade.map.MapManager)2 File (java.io.File)1 World (org.bukkit.World)1 CraftWorld (org.bukkit.craftbukkit.CraftWorld)1 MapContainerFillEvent (pl.themolka.arcade.map.MapContainerFillEvent)1 MapContainerLoader (pl.themolka.arcade.map.MapContainerLoader)1 ArcadePlayer (pl.themolka.arcade.session.ArcadePlayer)1