use of org.bukkit.craftbukkit.v1_18_R2.CraftServer in project LoliServer by Loli-Server.
the class CraftEventFactory method callBlockMultiPlaceEvent.
/**
* Block place methods
*/
public static BlockMultiPlaceEvent callBlockMultiPlaceEvent(ServerWorld world, PlayerEntity who, Hand hand, List<BlockState> blockStates, int clickedX, int clickedY, int clickedZ) {
CraftWorld craftWorld = world.getWorld();
CraftServer craftServer = world.getCBServer();
Player player = (Player) who.getBukkitEntity();
Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);
boolean canBuild = true;
for (int i = 0; i < blockStates.size(); i++) {
if (!canBuild(world, player, blockStates.get(i).getX(), blockStates.get(i).getZ())) {
canBuild = false;
break;
}
}
org.bukkit.inventory.ItemStack item;
if (hand == Hand.MAIN_HAND) {
item = player.getInventory().getItemInMainHand();
} else {
item = player.getInventory().getItemInOffHand();
}
BlockMultiPlaceEvent event = new BlockMultiPlaceEvent(blockStates, blockClicked, item, player, canBuild);
craftServer.getPluginManager().callEvent(event);
return event;
}
use of org.bukkit.craftbukkit.v1_18_R2.CraftServer in project LoliServer by Loli-Server.
the class CraftEventFactory method canBuild.
// helper methods
private static boolean canBuild(World world, Player player, int x, int z) {
int spawnSize = Bukkit.getServer().getSpawnRadius();
if (world.dimension() != World.OVERWORLD)
return true;
if (spawnSize <= 0)
return true;
if (((CraftServer) Bukkit.getServer()).getHandle().getOps().isEmpty())
return true;
if (player.isOp())
return true;
BlockPos chunkcoordinates = getSharedSpawnPos(world);
int distanceFromSpawn = Math.max(Math.abs(x - chunkcoordinates.getX()), Math.abs(z - chunkcoordinates.getZ()));
return distanceFromSpawn > spawnSize;
}
use of org.bukkit.craftbukkit.v1_18_R2.CraftServer in project LoliServer by Loli-Server.
the class CraftEventFactory method callCreatureSpawnEvent.
/**
* CreatureSpawnEvent
*/
public static CreatureSpawnEvent callCreatureSpawnEvent(LivingEntity livingEntity, CreatureSpawnEvent.SpawnReason spawnReason) {
org.bukkit.entity.LivingEntity entity = (org.bukkit.entity.LivingEntity) livingEntity.getBukkitEntity();
CraftServer craftServer = (CraftServer) entity.getServer();
CreatureSpawnEvent event = new CreatureSpawnEvent(entity, spawnReason);
craftServer.getPluginManager().callEvent(event);
return event;
}
use of org.bukkit.craftbukkit.v1_18_R2.CraftServer in project LoliServer by Loli-Server.
the class CraftEventFactory method callItemSpawnEvent.
/**
* ItemSpawnEvent
*/
public static ItemSpawnEvent callItemSpawnEvent(ItemEntity entityitem) {
Item entity = (Item) entityitem.getBukkitEntity();
CraftServer craftServer = (CraftServer) entity.getServer();
ItemSpawnEvent event = new ItemSpawnEvent(entity);
craftServer.getPluginManager().callEvent(event);
return event;
}
use of org.bukkit.craftbukkit.v1_18_R2.CraftServer in project LoliServer by Loli-Server.
the class CraftEventFactory method callEntityTameEvent.
/**
* EntityTameEvent
*/
public static EntityTameEvent callEntityTameEvent(MobEntity entity, PlayerEntity tamer) {
org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity();
org.bukkit.entity.AnimalTamer bukkitTamer = (tamer != null ? tamer.getBukkitEntity() : null);
CraftServer craftServer = (CraftServer) bukkitEntity.getServer();
entity.persistenceRequired = true;
EntityTameEvent event = new EntityTameEvent((org.bukkit.entity.LivingEntity) bukkitEntity, bukkitTamer);
craftServer.getPluginManager().callEvent(event);
return event;
}
Aggregations