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);
}
}
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);
}
}
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);
}
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);
}
}
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);
}
}
Aggregations