Search in sources :

Example 31 with CraftServer

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;
}
Also used : CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) BlockMultiPlaceEvent(org.bukkit.event.block.BlockMultiPlaceEvent) Block(org.bukkit.block.Block) CraftBlock(org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock) CraftServer(org.bukkit.craftbukkit.v1_16_R3.CraftServer) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Example 32 with CraftServer

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;
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) CraftServer(org.bukkit.craftbukkit.v1_16_R3.CraftServer)

Example 33 with CraftServer

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;
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) CraftLivingEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftLivingEntity) CraftServer(org.bukkit.craftbukkit.v1_16_R3.CraftServer) org.bukkit.event.entity(org.bukkit.event.entity) org.bukkit.entity(org.bukkit.entity)

Example 34 with CraftServer

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;
}
Also used : CraftServer(org.bukkit.craftbukkit.v1_16_R3.CraftServer)

Example 35 with CraftServer

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;
}
Also used : CraftServer(org.bukkit.craftbukkit.v1_16_R3.CraftServer) org.bukkit.event.entity(org.bukkit.event.entity) org.bukkit.entity(org.bukkit.entity)

Aggregations

GameProfile (com.mojang.authlib.GameProfile)49 CraftServer (org.bukkit.craftbukkit.v1_16_R3.CraftServer)38 Player (org.bukkit.entity.Player)33 CraftServer (org.bukkit.craftbukkit.v1_18_R2.CraftServer)23 ResourceLocation (net.minecraft.resources.ResourceLocation)22 MinecraftServer (net.minecraft.server.MinecraftServer)22 CraftPlayer (org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer)21 CraftServer (org.bukkit.craftbukkit.v1_17_R1.CraftServer)21 ServerPlayer (net.minecraft.server.level.ServerPlayer)20 Block (org.bukkit.block.Block)19 NotNull (org.jetbrains.annotations.NotNull)18 OfflinePlayer (org.bukkit.OfflinePlayer)16 CraftServer (org.bukkit.craftbukkit.v1_12_R1.CraftServer)16 ServerLevel (net.minecraft.server.level.ServerLevel)14 Property (com.mojang.authlib.properties.Property)13 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)11 CraftPlayer (org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer)10 BlockFace (org.bukkit.block.BlockFace)8 CraftServer (org.bukkit.craftbukkit.v1_18_R1.CraftServer)8 PlayerProfile (com.denizenscript.denizen.nms.util.PlayerProfile)7