Search in sources :

Example 26 with CraftServer

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

the class CraftCreeper method setPowered.

public void setPowered(boolean powered) {
    CraftServer server = this.server;
    Creeper entity = (Creeper) this.getHandle().getBukkitEntity();
    if (powered) {
        CreeperPowerEvent event = new CreeperPowerEvent(entity, CreeperPowerEvent.PowerCause.SET_ON);
        server.getPluginManager().callEvent(event);
        if (!event.isCancelled()) {
            getHandle().setPowered(true);
        }
    } else {
        CreeperPowerEvent event = new CreeperPowerEvent(entity, CreeperPowerEvent.PowerCause.SET_OFF);
        server.getPluginManager().callEvent(event);
        if (!event.isCancelled()) {
            getHandle().setPowered(false);
        }
    }
}
Also used : EntityCreeper(net.minecraft.entity.monster.EntityCreeper) Creeper(org.bukkit.entity.Creeper) CreeperPowerEvent(org.bukkit.event.entity.CreeperPowerEvent) CraftServer(org.bukkit.craftbukkit.v1_12_R1.CraftServer)

Example 27 with CraftServer

use of org.bukkit.craftbukkit.v1_8_R1.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 28 with CraftServer

use of org.bukkit.craftbukkit.v1_8_R1.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 29 with CraftServer

use of org.bukkit.craftbukkit.v1_8_R1.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 30 with CraftServer

use of org.bukkit.craftbukkit.v1_8_R1.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)

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