Search in sources :

Example 91 with BuildWorld

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

the class BlockPhysicsListener method onLeavesDecay.

@EventHandler
public void onLeavesDecay(LeavesDecayEvent 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 92 with BuildWorld

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

the class BlockPhysicsListener method onBlockGrow.

@EventHandler
public void onBlockGrow(BlockGrowEvent 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 93 with BuildWorld

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

the class BlockPlaceListener method onCustomBlockPlace.

@EventHandler
public void onCustomBlockPlace(BlockPlaceEvent event) {
    if (event.isCancelled()) {
        return;
    }
    Player player = event.getPlayer();
    String worldName = player.getWorld().getName();
    BuildWorld buildWorld = worldManager.getBuildWorld(worldName);
    boolean isBuildWorld = buildWorld != null;
    ItemStack itemStack = player.getItemInHand();
    XMaterial xMaterial = XMaterial.matchXMaterial(itemStack);
    if (xMaterial != XMaterial.PLAYER_HEAD) {
        return;
    }
    boolean hadToDisablePhysics = false;
    if (isBuildWorld && !buildWorld.isPhysics()) {
        hadToDisablePhysics = true;
        buildWorld.setPhysics(true);
    }
    plugin.getCustomBlocks().setBlock(event, plugin.getString("blocks_full_oak_barch"), plugin.getString("blocks_full_spruce_barch"), plugin.getString("blocks_full_birch_barch"), plugin.getString("blocks_full_jungle_barch"), plugin.getString("blocks_full_acacia_barch"), plugin.getString("blocks_full_dark_oak_barch"), plugin.getString("blocks_red_mushroom"), plugin.getString("blocks_brown_mushroom"), plugin.getString("blocks_full_mushroom_stem"), plugin.getString("blocks_mushroom_stem"), plugin.getString("blocks_mushroom_block"), plugin.getString("blocks_smooth_stone"), plugin.getString("blocks_double_stone_slab"), plugin.getString("blocks_smooth_sandstone"), plugin.getString("blocks_smooth_red_sandstone"), plugin.getString("blocks_powered_redstone_lamp"), plugin.getString("blocks_burning_furnace"), plugin.getString("blocks_command_block"), plugin.getString("blocks_barrier"), plugin.getString("blocks_mob_spawner"), plugin.getString("blocks_nether_portal"), plugin.getString("blocks_end_portal"), plugin.getString("blocks_dragon_egg"));
    if (isBuildWorld && hadToDisablePhysics) {
        buildWorld.setPhysics(false);
    }
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) Player(org.bukkit.entity.Player) ItemStack(org.bukkit.inventory.ItemStack) XMaterial(com.cryptomorin.xseries.XMaterial) EventHandler(org.bukkit.event.EventHandler)

Example 94 with BuildWorld

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

the class ExplosionsCommand method toggleExplosions.

private void toggleExplosions(Player player, World bukkitWorld) {
    if (bukkitWorld == null) {
        player.sendMessage(plugin.getString("explosions_unknown_world"));
        return;
    }
    BuildWorld buildWorld = worldManager.getBuildWorld(bukkitWorld.getName());
    if (buildWorld == null) {
        player.sendMessage(plugin.getString("explosions_world_not_imported"));
        return;
    }
    if (!buildWorld.isExplosions()) {
        buildWorld.setExplosions(true);
        player.sendMessage(plugin.getString("explosions_activated").replace("%world%", buildWorld.getName()));
    } else {
        buildWorld.setExplosions(false);
        player.sendMessage(plugin.getString("explosions_deactivated").replace("%world%", buildWorld.getName()));
    }
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld)

Example 95 with BuildWorld

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

the class NoAICommand method toggleAI.

private void toggleAI(Player player, World bukkitWorld) {
    if (bukkitWorld == null) {
        player.sendMessage(plugin.getString("noai_unknown_world"));
        return;
    }
    BuildWorld buildWorld = worldManager.getBuildWorld(bukkitWorld.getName());
    if (buildWorld == null) {
        player.sendMessage(plugin.getString("noai_world_not_imported"));
        return;
    }
    if (buildWorld.isMobAI()) {
        buildWorld.setMobAI(false);
        player.sendMessage(plugin.getString("noai_activated").replace("%world%", buildWorld.getName()));
    } else {
        buildWorld.setMobAI(true);
        player.sendMessage(plugin.getString("noai_deactivated").replace("%world%", buildWorld.getName()));
    }
    boolean mobAI = buildWorld.isMobAI();
    for (Entity entity : bukkitWorld.getEntities()) {
        if (entity instanceof LivingEntity) {
            ManageEntityAI.setAIEnabled(entity, mobAI);
        }
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity)

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