Search in sources :

Example 21 with CraftServer

use of org.bukkit.craftbukkit.v1_13_R1.CraftServer in project Magma by magmafoundation.

the class CraftEventFactory method callBlockMultiPlaceEvent.

/**
 * Block place methods
 */
public static BlockMultiPlaceEvent callBlockMultiPlaceEvent(World world, EntityPlayer who, EnumHand hand, List<BlockState> blockStates, int clickedX, int clickedY, int clickedZ) {
    CraftWorld craftWorld = world.getWorld();
    CraftServer craftServer = world.getServer();
    Player player = (Player) who.getBukkitEntity();
    Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);
    boolean canBuild = true;
    for (BlockState blockState : blockStates) {
        if (!canBuild(craftWorld, player, blockState.getX(), blockState.getZ())) {
            canBuild = false;
            break;
        }
    }
    org.bukkit.inventory.ItemStack item;
    if (hand == EnumHand.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 : EntityPlayer(net.minecraft.entity.player.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) FakePlayer(net.minecraftforge.common.util.FakePlayer) CraftBlockState(org.bukkit.craftbukkit.v1_12_R1.block.CraftBlockState) BlockState(org.bukkit.block.BlockState) IBlockState(net.minecraft.block.state.IBlockState) Block(org.bukkit.block.Block) CraftBlock(org.bukkit.craftbukkit.v1_12_R1.block.CraftBlock) CraftServer(org.bukkit.craftbukkit.v1_12_R1.CraftServer) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld)

Example 22 with CraftServer

use of org.bukkit.craftbukkit.v1_13_R1.CraftServer in project Magma by magmafoundation.

the class CraftEventFactory method getPlayerBucketEvent.

private static PlayerEvent getPlayerBucketEvent(boolean isFilling, EntityPlayer who, int clickedX, int clickedY, int clickedZ, EnumFacing clickedFace, ItemStack itemstack, net.minecraft.item.Item item) {
    Player player = (who == null) ? null : (Player) who.getBukkitEntity();
    CraftItemStack itemInHand = CraftItemStack.asNewCraftStack(item);
    Material bucket = CraftMagicNumbers.getMaterial(itemstack == null ? Items.AIR : itemstack.getItem());
    CraftWorld craftWorld = (CraftWorld) player.getWorld();
    CraftServer craftServer = (CraftServer) player.getServer();
    Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);
    BlockFace blockFace = CraftBlock.notchToBlockFace(clickedFace);
    PlayerEvent event = null;
    if (isFilling) {
        event = new PlayerBucketFillEvent(player, blockClicked, blockFace, bucket, itemInHand);
        ((PlayerBucketFillEvent) event).setCancelled(!canBuild(craftWorld, player, clickedX, clickedZ));
    } else {
        event = new PlayerBucketEmptyEvent(player, blockClicked, blockFace, bucket, itemInHand);
        ((PlayerBucketEmptyEvent) event).setCancelled(!canBuild(craftWorld, player, clickedX, clickedZ));
    }
    craftServer.getPluginManager().callEvent(event);
    return event;
}
Also used : CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) EntityPlayer(net.minecraft.entity.player.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) FakePlayer(net.minecraftforge.common.util.FakePlayer) BlockFace(org.bukkit.block.BlockFace) Block(org.bukkit.block.Block) CraftBlock(org.bukkit.craftbukkit.v1_12_R1.block.CraftBlock) Material(org.bukkit.Material) CraftServer(org.bukkit.craftbukkit.v1_12_R1.CraftServer) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld)

Example 23 with CraftServer

use of org.bukkit.craftbukkit.v1_13_R1.CraftServer in project Magma by magmafoundation.

the class CraftEventFactory method callBlockPlaceEvent.

public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityPlayer who, EnumHand hand, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ) {
    CraftWorld craftWorld = world.getWorld();
    CraftServer craftServer = world.getServer();
    Player player = (Player) who.getBukkitEntity();
    Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);
    Block placedBlock = replacedBlockState.getBlock();
    boolean canBuild = canBuild(craftWorld, player, placedBlock.getX(), placedBlock.getZ());
    org.bukkit.inventory.ItemStack item;
    EquipmentSlot equipmentSlot;
    if (hand == EnumHand.MAIN_HAND) {
        item = player.getInventory().getItemInMainHand();
        equipmentSlot = EquipmentSlot.HAND;
    } else {
        item = player.getInventory().getItemInOffHand();
        equipmentSlot = EquipmentSlot.OFF_HAND;
    }
    BlockPlaceEvent event = new BlockPlaceEvent(placedBlock, replacedBlockState, blockClicked, item, player, canBuild, equipmentSlot);
    craftServer.getPluginManager().callEvent(event);
    return event;
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) FakePlayer(net.minecraftforge.common.util.FakePlayer) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) Block(org.bukkit.block.Block) CraftBlock(org.bukkit.craftbukkit.v1_12_R1.block.CraftBlock) CraftServer(org.bukkit.craftbukkit.v1_12_R1.CraftServer) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld)

Example 24 with CraftServer

use of org.bukkit.craftbukkit.v1_13_R1.CraftServer in project Magma by magmafoundation.

the class CraftEventFactory method callCreatureSpawnEvent.

/**
 * CreatureSpawnEvent
 */
public static CreatureSpawnEvent callCreatureSpawnEvent(EntityLivingBase entityliving, SpawnReason spawnReason) {
    LivingEntity entity = (LivingEntity) entityliving.getBukkitEntity();
    CraftServer craftServer = (CraftServer) entity.getServer();
    CreatureSpawnEvent event = new CreatureSpawnEvent(entity, spawnReason);
    craftServer.getPluginManager().callEvent(event);
    return event;
}
Also used : CraftLivingEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity) CraftServer(org.bukkit.craftbukkit.v1_12_R1.CraftServer)

Example 25 with CraftServer

use of org.bukkit.craftbukkit.v1_13_R1.CraftServer in project Magma by magmafoundation.

the class CraftEventFactory method callEntityTameEvent.

/**
 * EntityTameEvent
 */
public static EntityTameEvent callEntityTameEvent(EntityLiving entity, EntityPlayer 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((LivingEntity) bukkitEntity, bukkitTamer);
    craftServer.getPluginManager().callEvent(event);
    return event;
}
Also used : CraftServer(org.bukkit.craftbukkit.v1_12_R1.CraftServer) org.bukkit.entity(org.bukkit.entity) org.bukkit.event.entity(org.bukkit.event.entity)

Aggregations

GameProfile (com.mojang.authlib.GameProfile)49 CraftServer (org.bukkit.craftbukkit.v1_16_R3.CraftServer)38 Player (org.bukkit.entity.Player)29 CraftServer (org.bukkit.craftbukkit.v1_18_R2.CraftServer)23 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 ResourceLocation (net.minecraft.resources.ResourceLocation)20 NotNull (org.jetbrains.annotations.NotNull)18 ServerPlayer (net.minecraft.server.level.ServerPlayer)16 OfflinePlayer (org.bukkit.OfflinePlayer)16 CraftServer (org.bukkit.craftbukkit.v1_12_R1.CraftServer)16 Block (org.bukkit.block.Block)15 ServerLevel (net.minecraft.server.level.ServerLevel)14 Property (com.mojang.authlib.properties.Property)13 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)11 CraftBlock (org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock)10 CraftServer (org.bukkit.craftbukkit.v1_18_R1.CraftServer)8 PlayerProfile (com.denizenscript.denizen.nms.util.PlayerProfile)7 CraftPlayer (org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)7