Search in sources :

Example 1 with ArcadeMap

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

the class ObserverListeners method onPlayerVoidTeleport.

@Handler(priority = Priority.NORMAL)
public void onPlayerVoidTeleport(PlayerMoveEvent event) {
    Player bukkit = event.getBukkitPlayer();
    if (!event.isCanceled() && this.isObserving(bukkit)) {
        ArcadeMap map = this.game.getGame().getMap();
        int y = event.getTo().getBlockY();
        // Teleport observers when they are in the void.
        if (y < 0 - BORDER_Y || y > map.getWorld().getMaxHeight() + BORDER_Y) {
            event.getPlayer().getBukkit().teleport(map.getManifest().getWorld().getSpawn(), TELEPORT_CAUSE);
        }
    }
}
Also used : Player(org.bukkit.entity.Player) GamePlayer(pl.themolka.arcade.game.GamePlayer) ArcadeMap(pl.themolka.arcade.map.ArcadeMap) Handler(net.engio.mbassy.listener.Handler) EventHandler(org.bukkit.event.EventHandler)

Example 2 with ArcadeMap

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

the class SimpleGameManager method createGame.

@Override
public Game createGame(OfflineMap map) throws DOMException, IOException {
    File file = map.getSettings();
    DOMEngine engine = this.plugin.getDomEngines().forFile(file);
    Parser<MapManifest> parser;
    try {
        parser = this.plugin.getParsers().forType(MapManifest.class);
    } catch (ParserNotSupportedException ex) {
        throw new RuntimeException("No " + MapManifest.class.getSimpleName() + " parser installed");
    }
    Document document = engine.read(file);
    this.plugin.getDomPreprocessor().preprocess(document);
    ArcadeMap realMap = new ArcadeMap(map, parser.parse(document).orFail());
    WorldNameGenerator worldNameGenerator = new WorldNameGenerator(map);
    realMap.setWorldName(worldNameGenerator.nextWorldName());
    return this.createGame(realMap);
}
Also used : DOMEngine(pl.themolka.arcade.dom.engine.DOMEngine) WorldNameGenerator(pl.themolka.arcade.map.WorldNameGenerator) ArcadeMap(pl.themolka.arcade.map.ArcadeMap) MapManifest(pl.themolka.arcade.map.MapManifest) Document(pl.themolka.arcade.dom.Document) File(java.io.File) ParserNotSupportedException(pl.themolka.arcade.parser.ParserNotSupportedException)

Aggregations

ArcadeMap (pl.themolka.arcade.map.ArcadeMap)2 File (java.io.File)1 Handler (net.engio.mbassy.listener.Handler)1 Player (org.bukkit.entity.Player)1 EventHandler (org.bukkit.event.EventHandler)1 Document (pl.themolka.arcade.dom.Document)1 DOMEngine (pl.themolka.arcade.dom.engine.DOMEngine)1 GamePlayer (pl.themolka.arcade.game.GamePlayer)1 MapManifest (pl.themolka.arcade.map.MapManifest)1 WorldNameGenerator (pl.themolka.arcade.map.WorldNameGenerator)1 ParserNotSupportedException (pl.themolka.arcade.parser.ParserNotSupportedException)1