use of org.bukkit.craftbukkit.v1_16_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);
}
}
}
use of org.bukkit.craftbukkit.v1_16_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;
}
use of org.bukkit.craftbukkit.v1_16_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;
}
use of org.bukkit.craftbukkit.v1_16_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;
}
use of org.bukkit.craftbukkit.v1_16_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;
}
Aggregations