Search in sources :

Example 1 with MagicWorld

use of com.elmakers.mine.bukkit.world.MagicWorld in project MagicPlugin by elBukkit.

the class MagicController method getMaxHeight.

@Override
public int getMaxHeight(World world) {
    MagicWorld magicWorld = getMagicWorld(world.getName());
    int maxHeight = CompatibilityLib.getCompatibilityUtils().getMaxHeight(world);
    if (magicWorld != null) {
        maxHeight = magicWorld.getMaxHeight(maxHeight);
    }
    return maxHeight;
}
Also used : MagicWorld(com.elmakers.mine.bukkit.world.MagicWorld)

Example 2 with MagicWorld

use of com.elmakers.mine.bukkit.world.MagicWorld in project MagicPlugin by elBukkit.

the class MagicController method getMinHeight.

@Override
public int getMinHeight(World world) {
    MagicWorld magicWorld = getMagicWorld(world.getName());
    int minHeight = CompatibilityLib.getCompatibilityUtils().getMinHeight(world);
    if (magicWorld != null) {
        minHeight = magicWorld.getMinHeight(minHeight);
    }
    return minHeight;
}
Also used : MagicWorld(com.elmakers.mine.bukkit.world.MagicWorld)

Example 3 with MagicWorld

use of com.elmakers.mine.bukkit.world.MagicWorld in project MagicPlugin by elBukkit.

the class BlockController method onWorldSaveEvent.

@EventHandler
public void onWorldSaveEvent(WorldSaveEvent event) {
    World world = event.getWorld();
    MagicWorld magicWorld = controller.getMagicWorld(world.getName());
    boolean undo = undoOnWorldSave;
    if (undo && magicWorld != null && !magicWorld.isCancelSpellsOnSave()) {
        undo = false;
    }
    if (undo) {
        undoPending(world, "save");
    }
    Collection<Player> players = world.getPlayers();
    for (Player player : players) {
        Mage mage = controller.getRegisteredMage(player);
        if (mage != null) {
            controller.saveMage(mage, true);
        }
    }
}
Also used : Player(org.bukkit.entity.Player) Mage(com.elmakers.mine.bukkit.api.magic.Mage) World(org.bukkit.World) MagicWorld(com.elmakers.mine.bukkit.world.MagicWorld) MagicWorld(com.elmakers.mine.bukkit.world.MagicWorld) EventHandler(org.bukkit.event.EventHandler)

Example 4 with MagicWorld

use of com.elmakers.mine.bukkit.world.MagicWorld in project MagicPlugin by elBukkit.

the class WorldPlayerListener method onBlockPlace.

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
    Block block = event.getBlock();
    MagicWorld magicWorld = controller.getWorld(block.getWorld().getName());
    if (magicWorld == null)
        return;
    BlockResult result = magicWorld.processBlockPlace(block, event.getPlayer());
    if (result == BlockResult.CANCEL) {
        event.setCancelled(true);
    }
}
Also used : BlockResult(com.elmakers.mine.bukkit.world.BlockResult) Block(org.bukkit.block.Block) MagicWorld(com.elmakers.mine.bukkit.world.MagicWorld) EventHandler(org.bukkit.event.EventHandler)

Example 5 with MagicWorld

use of com.elmakers.mine.bukkit.world.MagicWorld in project MagicPlugin by elBukkit.

the class WorldPlayerListener method onPlayerChangeWorld.

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerChangeWorld(PlayerChangedWorldEvent event) {
    Player player = event.getPlayer();
    Mage mage = controller.getMagicController().getMage(player);
    MagicWorld fromWorld = controller.getWorld(event.getFrom().getName());
    MagicWorld toWorld = controller.getWorld(player.getWorld().getName());
    if (fromWorld != null) {
        fromWorld.playerLeft(mage, toWorld);
    }
    if (toWorld != null) {
        toWorld.playerEntered(mage, fromWorld);
    }
}
Also used : Player(org.bukkit.entity.Player) Mage(com.elmakers.mine.bukkit.magic.Mage) MagicWorld(com.elmakers.mine.bukkit.world.MagicWorld) EventHandler(org.bukkit.event.EventHandler)

Aggregations

MagicWorld (com.elmakers.mine.bukkit.world.MagicWorld)8 EventHandler (org.bukkit.event.EventHandler)5 Player (org.bukkit.entity.Player)3 BlockResult (com.elmakers.mine.bukkit.world.BlockResult)2 Block (org.bukkit.block.Block)2 LivingEntity (org.bukkit.entity.LivingEntity)2 Plugin (org.bukkit.plugin.Plugin)2 Mage (com.elmakers.mine.bukkit.api.magic.Mage)1 Mage (com.elmakers.mine.bukkit.magic.Mage)1 World (org.bukkit.World)1 Entity (org.bukkit.entity.Entity)1