Search in sources :

Example 11 with BuildWorld

use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by einTosti.

the class BlockPhysicsListener method onEntityChangeBlock.

@EventHandler
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
    Block block = event.getBlock();
    BuildWorld buildWorld = worldManager.getBuildWorld(block.getWorld().getName());
    if (buildWorld == null || buildWorld.isPhysics()) {
        return;
    }
    if (event.getEntityType().equals(EntityType.FALLING_BLOCK)) {
        event.setCancelled(true);
        event.getBlock().getState().update(false, false);
    }
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) Block(org.bukkit.block.Block) EventHandler(org.bukkit.event.EventHandler)

Example 12 with BuildWorld

use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by einTosti.

the class BlockPhysicsListener method onBlockForm.

@EventHandler
public void onBlockForm(BlockFormEvent event) {
    Block block = event.getBlock();
    BuildWorld buildWorld = worldManager.getBuildWorld(block.getWorld().getName());
    if (buildWorld != null && !buildWorld.isPhysics()) {
        event.setCancelled(true);
    }
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) Block(org.bukkit.block.Block) EventHandler(org.bukkit.event.EventHandler)

Example 13 with BuildWorld

use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by einTosti.

the class BlockPhysicsListener method onBlockPhysics.

@EventHandler
public void onBlockPhysics(BlockPhysicsEvent event) {
    Block block = event.getBlock();
    World bukkitWorld = block.getWorld();
    BuildWorld buildWorld = worldManager.getBuildWorld(bukkitWorld.getName());
    if (buildWorld == null || buildWorld.isPhysics()) {
        return;
    }
    XMaterial xMaterial = XMaterial.matchXMaterial(block.getType());
    BlockFace[] surroundingBlocks = new BlockFace[] { BlockFace.UP, BlockFace.DOWN, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST };
    switch(xMaterial) {
        case REDSTONE_BLOCK:
            for (BlockFace blockFace : surroundingBlocks) {
                if (isCustomRedstoneLamp(block.getRelative(blockFace))) {
                    event.setCancelled(false);
                    return;
                }
            }
            break;
        case REDSTONE_LAMP:
            for (BlockFace blockFace : surroundingBlocks) {
                if (block.getRelative(blockFace).getType() == XMaterial.REDSTONE_BLOCK.parseMaterial()) {
                    event.setCancelled(false);
                    return;
                }
            }
            break;
    }
    event.setCancelled(true);
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) BlockFace(org.bukkit.block.BlockFace) Block(org.bukkit.block.Block) World(org.bukkit.World) BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) XMaterial(com.cryptomorin.xseries.XMaterial) EventHandler(org.bukkit.event.EventHandler)

Example 14 with BuildWorld

use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by einTosti.

the class EditSessionListener method onEditSession.

@Subscribe
public void onEditSession(EditSessionEvent event) {
    Actor actor = event.getActor();
    if (actor == null || !actor.isPlayer()) {
        return;
    }
    Player player = Bukkit.getPlayer(actor.getName());
    if (player == null) {
        return;
    }
    BuildWorld buildWorld = worldManager.getBuildWorld(player.getWorld().getName());
    if (buildWorld == null) {
        return;
    }
    if (event.getStage() == EditSession.Stage.BEFORE_CHANGE) {
        disableArchivedWorlds(buildWorld, player, event);
        checkBuilders(buildWorld, player, event);
    }
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) Player(org.bukkit.entity.Player) Actor(com.sk89q.worldedit.extension.platform.Actor) Subscribe(com.sk89q.worldedit.util.eventbus.Subscribe)

Example 15 with BuildWorld

use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by einTosti.

the class EntitySpawnListener method onEntitySpawn.

@EventHandler
public void onEntitySpawn(EntitySpawnEvent event) {
    World bukkitWorld = event.getLocation().getWorld();
    if (bukkitWorld == null) {
        return;
    }
    BuildWorld buildWorld = worldManager.getBuildWorld(bukkitWorld.getName());
    if (buildWorld == null || buildWorld.isMobAI()) {
        return;
    }
    Entity entity = event.getEntity();
    if (entity instanceof LivingEntity) {
        ManageEntityAI.setAIEnabled(entity, false);
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) World(org.bukkit.World) BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) EventHandler(org.bukkit.event.EventHandler)

Aggregations

BuildWorld (com.eintosti.buildsystem.object.world.BuildWorld)143 EventHandler (org.bukkit.event.EventHandler)58 Player (org.bukkit.entity.Player)52 World (org.bukkit.World)40 Block (org.bukkit.block.Block)20 ItemStack (org.bukkit.inventory.ItemStack)18 XMaterial (com.cryptomorin.xseries.XMaterial)16 PlayerChatInput (com.eintosti.buildsystem.util.external.PlayerChatInput)16 UUID (java.util.UUID)14 Location (org.bukkit.Location)14 File (java.io.File)12 ArrayList (java.util.ArrayList)9 BuildSystem (com.eintosti.buildsystem.BuildSystem)6 Builder (com.eintosti.buildsystem.object.world.Builder)6 List (java.util.List)6 Bukkit (org.bukkit.Bukkit)6 Material (org.bukkit.Material)6 ChunkGenerator (org.bukkit.generator.ChunkGenerator)6 Inventory (org.bukkit.inventory.Inventory)6 ItemMeta (org.bukkit.inventory.meta.ItemMeta)6