Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 20:40:08 +01:00
Implement new cause versions of BlockIgniteEvent. Addresses BUKKIT-3609, BUKKIT-3656, BUKKIT-3657
Dieser Commit ist enthalten in:
Ursprung
2e6cfdb3cc
Commit
a7a5f273e3
@ -3,7 +3,7 @@ package net.minecraft.server;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
import org.bukkit.event.block.BlockIgniteEvent;
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||||
import org.bukkit.event.block.BlockBurnEvent;
|
import org.bukkit.event.block.BlockBurnEvent;
|
||||||
import org.bukkit.event.block.BlockSpreadEvent;
|
import org.bukkit.event.block.BlockSpreadEvent;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
@ -111,9 +111,6 @@ public class BlockFire extends Block {
|
|||||||
// CraftBukkit start - call to stop spread of fire
|
// CraftBukkit start - call to stop spread of fire
|
||||||
org.bukkit.Server server = world.getServer();
|
org.bukkit.Server server = world.getServer();
|
||||||
org.bukkit.World bworld = world.getWorld();
|
org.bukkit.World bworld = world.getWorld();
|
||||||
|
|
||||||
BlockIgniteEvent.IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.SPREAD;
|
|
||||||
org.bukkit.block.Block fromBlock = bworld.getBlockAt(i, j, k);
|
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
for (int i1 = i - 1; i1 <= i + 1; ++i1) {
|
for (int i1 = i - 1; i1 <= i + 1; ++i1) {
|
||||||
@ -143,13 +140,8 @@ public class BlockFire extends Block {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CraftBukkit start - call to stop spread of fire
|
// CraftBukkit start - call to stop spread of fire
|
||||||
org.bukkit.block.Block block = bworld.getBlockAt(i1, k1, j1);
|
if (world.getTypeId(i1, k1, j1) != Block.FIRE.id) {
|
||||||
|
if (CraftEventFactory.callBlockIgniteEvent(world, i1, k1, j1, i, j, k).isCancelled()) {
|
||||||
if (block.getTypeId() != Block.FIRE.id) {
|
|
||||||
BlockIgniteEvent event = new BlockIgniteEvent(block, igniteCause, null);
|
|
||||||
server.getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +149,7 @@ public class BlockFire extends Block {
|
|||||||
blockState.setTypeId(this.id);
|
blockState.setTypeId(this.id);
|
||||||
blockState.setData(new org.bukkit.material.MaterialData(this.id, (byte) k2));
|
blockState.setData(new org.bukkit.material.MaterialData(this.id, (byte) k2));
|
||||||
|
|
||||||
BlockSpreadEvent spreadEvent = new BlockSpreadEvent(blockState.getBlock(), fromBlock, blockState);
|
BlockSpreadEvent spreadEvent = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(i, j, k), blockState);
|
||||||
server.getPluginManager().callEvent(spreadEvent);
|
server.getPluginManager().callEvent(spreadEvent);
|
||||||
|
|
||||||
if (!spreadEvent.isCancelled()) {
|
if (!spreadEvent.isCancelled()) {
|
||||||
|
@ -2,10 +2,7 @@ package net.minecraft.server;
|
|||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
// CraftBukkit start
|
import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
||||||
import org.bukkit.event.block.BlockIgniteEvent;
|
|
||||||
// CraftBukkit end
|
|
||||||
|
|
||||||
public class BlockStationary extends BlockFluids {
|
public class BlockStationary extends BlockFluids {
|
||||||
|
|
||||||
@ -42,9 +39,10 @@ public class BlockStationary extends BlockFluids {
|
|||||||
int i1;
|
int i1;
|
||||||
int j1;
|
int j1;
|
||||||
|
|
||||||
// CraftBukkit start - prevent lava putting something on fire
|
// CraftBukkit start - prevent lava putting something on fire, remember igniter block coords
|
||||||
org.bukkit.World bworld = world.getWorld();
|
int x = i;
|
||||||
BlockIgniteEvent.IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.LAVA;
|
int y = j;
|
||||||
|
int z = k;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
for (i1 = 0; i1 < l; ++i1) {
|
for (i1 = 0; i1 < l; ++i1) {
|
||||||
@ -55,9 +53,8 @@ public class BlockStationary extends BlockFluids {
|
|||||||
if (j1 == 0) {
|
if (j1 == 0) {
|
||||||
if (this.m(world, i - 1, j, k) || this.m(world, i + 1, j, k) || this.m(world, i, j, k - 1) || this.m(world, i, j, k + 1) || this.m(world, i, j - 1, k) || this.m(world, i, j + 1, k)) {
|
if (this.m(world, i - 1, j, k) || this.m(world, i + 1, j, k) || this.m(world, i, j, k - 1) || this.m(world, i, j, k + 1) || this.m(world, i, j - 1, k) || this.m(world, i, j + 1, k)) {
|
||||||
// CraftBukkit start - prevent lava putting something on fire
|
// CraftBukkit start - prevent lava putting something on fire
|
||||||
org.bukkit.block.Block block = bworld.getBlockAt(i, j, k);
|
if (world.getTypeId(i, j, k) != Block.FIRE.id) {
|
||||||
if (block.getTypeId() != Block.FIRE.id) {
|
if (CraftEventFactory.callBlockIgniteEvent(world, i, j, k, x, y, z).isCancelled()) {
|
||||||
if (CraftEventFactory.callEvent(new BlockIgniteEvent(block, igniteCause, null)).isCancelled()) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,9 +77,8 @@ public class BlockStationary extends BlockFluids {
|
|||||||
k = j1 + random.nextInt(3) - 1;
|
k = j1 + random.nextInt(3) - 1;
|
||||||
if (world.isEmpty(i, j + 1, k) && this.m(world, i, j, k)) {
|
if (world.isEmpty(i, j + 1, k) && this.m(world, i, j, k)) {
|
||||||
// CraftBukkit start - prevent lava putting something on fire
|
// CraftBukkit start - prevent lava putting something on fire
|
||||||
org.bukkit.block.Block block = bworld.getBlockAt(i, j + 1, k);
|
if (world.getTypeId(i, j + 1, k) != Block.FIRE.id) {
|
||||||
if (block.getTypeId() != Block.FIRE.id) {
|
if (CraftEventFactory.callBlockIgniteEvent(world, i, j + 1, k, x, y, z).isCancelled()) {
|
||||||
if (CraftEventFactory.callEvent(new BlockIgniteEvent(block, igniteCause, null)).isCancelled()) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||||
import org.bukkit.event.block.BlockDispenseEvent;
|
import org.bukkit.event.block.BlockDispenseEvent;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
@ -43,10 +44,14 @@ final class DispenseBehaviorFlintAndSteel extends DispenseBehaviorItem {
|
|||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
if (world.isEmpty(i, j, k)) {
|
if (world.isEmpty(i, j, k)) {
|
||||||
world.setTypeIdUpdate(i, j, k, Block.FIRE.id);
|
// CraftBukkit - ignition by dispensing flint and steel
|
||||||
if (itemstack.isDamaged(1, world.random)) {
|
if (!CraftEventFactory.callBlockIgniteEvent(world, i, j, k, isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ()).isCancelled()) {
|
||||||
itemstack.count = 0;
|
world.setTypeIdUpdate(i, j, k, Block.FIRE.id);
|
||||||
|
if (itemstack.isDamaged(1, world.random)) {
|
||||||
|
itemstack.count = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// CraftBukkit end
|
||||||
} else if (world.getTypeId(i, j, k) == Block.TNT.id) {
|
} else if (world.getTypeId(i, j, k) == Block.TNT.id) {
|
||||||
Block.TNT.postBreak(world, i, j, k, 1);
|
Block.TNT.postBreak(world, i, j, k, 1);
|
||||||
world.setAir(i, j, k);
|
world.setAir(i, j, k);
|
||||||
|
@ -33,7 +33,11 @@ public class EntityEnderCrystal extends Entity {
|
|||||||
int k = MathHelper.floor(this.locZ);
|
int k = MathHelper.floor(this.locZ);
|
||||||
|
|
||||||
if (this.world.getTypeId(i, j, k) != Block.FIRE.id) {
|
if (this.world.getTypeId(i, j, k) != Block.FIRE.id) {
|
||||||
this.world.setTypeIdUpdate(i, j, k, Block.FIRE.id);
|
// CraftBukkit start
|
||||||
|
if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.world, i, j, k, this).isCancelled()) {
|
||||||
|
this.world.setTypeIdUpdate(i, j, k, Block.FIRE.id);
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package net.minecraft.server;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.event.block.BlockIgniteEvent; // CraftBukkit
|
import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||||
|
|
||||||
public class EntityLightning extends EntityWeather {
|
public class EntityLightning extends EntityWeather {
|
||||||
|
|
||||||
@ -11,7 +11,6 @@ public class EntityLightning extends EntityWeather {
|
|||||||
private int c;
|
private int c;
|
||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
private org.bukkit.craftbukkit.CraftWorld cworld;
|
|
||||||
public boolean isEffect = false;
|
public boolean isEffect = false;
|
||||||
|
|
||||||
public EntityLightning(World world, double d0, double d1, double d2) {
|
public EntityLightning(World world, double d0, double d1, double d2) {
|
||||||
@ -25,7 +24,6 @@ public class EntityLightning extends EntityWeather {
|
|||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
this.isEffect = isEffect;
|
this.isEffect = isEffect;
|
||||||
this.cworld = world.getWorld();
|
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
this.setPositionRotation(d0, d1, d2, 0.0F, 0.0F);
|
this.setPositionRotation(d0, d1, d2, 0.0F, 0.0F);
|
||||||
@ -41,10 +39,7 @@ public class EntityLightning extends EntityWeather {
|
|||||||
|
|
||||||
if (world.getTypeId(i, j, k) == 0 && Block.FIRE.canPlace(world, i, j, k)) {
|
if (world.getTypeId(i, j, k) == 0 && Block.FIRE.canPlace(world, i, j, k)) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
BlockIgniteEvent event = new BlockIgniteEvent(this.cworld.getBlockAt(i, j, k), BlockIgniteEvent.IgniteCause.LIGHTNING, null);
|
if (!CraftEventFactory.callBlockIgniteEvent(world, i, j, k, this).isCancelled()) {
|
||||||
world.getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
|
||||||
world.setTypeIdUpdate(i, j, k, Block.FIRE.id);
|
world.setTypeIdUpdate(i, j, k, Block.FIRE.id);
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
@ -57,11 +52,8 @@ public class EntityLightning extends EntityWeather {
|
|||||||
|
|
||||||
if (world.getTypeId(j, k, l) == 0 && Block.FIRE.canPlace(world, j, k, l)) {
|
if (world.getTypeId(j, k, l) == 0 && Block.FIRE.canPlace(world, j, k, l)) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
BlockIgniteEvent event = new BlockIgniteEvent(this.cworld.getBlockAt(j, k, l), BlockIgniteEvent.IgniteCause.LIGHTNING, null);
|
if (!CraftEventFactory.callBlockIgniteEvent(world, j, k, l, this).isCancelled()) {
|
||||||
world.getServer().getPluginManager().callEvent(event);
|
world.setTypeIdUpdate(i, j, k, Block.FIRE.id);
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
|
||||||
world.setTypeIdUpdate(j, k, l, Block.FIRE.id);
|
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
@ -92,11 +84,8 @@ public class EntityLightning extends EntityWeather {
|
|||||||
|
|
||||||
if (this.world.getTypeId(i, j, k) == 0 && Block.FIRE.canPlace(this.world, i, j, k)) {
|
if (this.world.getTypeId(i, j, k) == 0 && Block.FIRE.canPlace(this.world, i, j, k)) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
BlockIgniteEvent event = new BlockIgniteEvent(this.cworld.getBlockAt(i, j, k), BlockIgniteEvent.IgniteCause.LIGHTNING, null);
|
if (!CraftEventFactory.callBlockIgniteEvent(world, i, j, k, this).isCancelled()) {
|
||||||
this.world.getServer().getPluginManager().callEvent(event);
|
world.setTypeIdUpdate(i, j, k, Block.FIRE.id);
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
|
||||||
this.world.setTypeIdUpdate(i, j, k, Block.FIRE.id);
|
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
import org.bukkit.event.block.BlockIgniteEvent;
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||||
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
@ -67,11 +67,7 @@ public class EntitySmallFireball extends EntityFireball {
|
|||||||
|
|
||||||
if (this.world.isEmpty(i, j, k)) {
|
if (this.world.isEmpty(i, j, k)) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
|
if (!CraftEventFactory.callBlockIgniteEvent(world, i, j, k, this).isCancelled()) {
|
||||||
BlockIgniteEvent event = new BlockIgniteEvent(block, BlockIgniteEvent.IgniteCause.FIREBALL, null);
|
|
||||||
world.getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
|
||||||
this.world.setTypeIdUpdate(i, j, k, Block.FIRE.id);
|
this.world.setTypeIdUpdate(i, j, k, Block.FIRE.id);
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
@ -290,7 +290,10 @@ public class Explosion {
|
|||||||
int i1 = this.world.getTypeId(i, j - 1, k);
|
int i1 = this.world.getTypeId(i, j - 1, k);
|
||||||
|
|
||||||
if (l == 0 && Block.s[i1] && this.j.nextInt(3) == 0) {
|
if (l == 0 && Block.s[i1] && this.j.nextInt(3) == 0) {
|
||||||
this.world.setTypeIdUpdate(i, j, k, Block.FIRE.id);
|
// CraftBukkit start - ignition by explosion.
|
||||||
|
if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.world, i, j, k, this).isCancelled()) {
|
||||||
|
this.world.setTypeIdUpdate(i, j, k, Block.FIRE.id);
|
||||||
|
} // CraftBukkit end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
// CraftBukkit start
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.block.BlockIgniteEvent;
|
|
||||||
// CraftBukkit end
|
|
||||||
|
|
||||||
public class ItemFireball extends Item {
|
public class ItemFireball extends Item {
|
||||||
|
|
||||||
public ItemFireball(int i) {
|
public ItemFireball(int i) {
|
||||||
@ -47,13 +42,7 @@ public class ItemFireball extends Item {
|
|||||||
|
|
||||||
if (i1 == 0) {
|
if (i1 == 0) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
org.bukkit.block.Block blockClicked = world.getWorld().getBlockAt(i, j, k);
|
if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, i, j, k, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, entityhuman).isCancelled()) {
|
||||||
Player thePlayer = (Player) entityhuman.getBukkitEntity();
|
|
||||||
|
|
||||||
BlockIgniteEvent eventIgnite = new BlockIgniteEvent(blockClicked, BlockIgniteEvent.IgniteCause.FIREBALL, thePlayer);
|
|
||||||
world.getServer().getPluginManager().callEvent(eventIgnite);
|
|
||||||
|
|
||||||
if (eventIgnite.isCancelled()) {
|
|
||||||
if (!entityhuman.abilities.canInstantlyBuild) {
|
if (!entityhuman.abilities.canInstantlyBuild) {
|
||||||
--itemstack.count;
|
--itemstack.count;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
// CraftBukkit start
|
import org.bukkit.craftbukkit.block.CraftBlockState; // CraftBukkit
|
||||||
import org.bukkit.craftbukkit.block.CraftBlockState;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.block.BlockIgniteEvent;
|
|
||||||
// CraftBukkit end
|
|
||||||
|
|
||||||
public class ItemFlintAndSteel extends Item {
|
public class ItemFlintAndSteel extends Item {
|
||||||
|
|
||||||
@ -49,13 +45,7 @@ public class ItemFlintAndSteel extends Item {
|
|||||||
|
|
||||||
if (i1 == 0) {
|
if (i1 == 0) {
|
||||||
// CraftBukkit start - store the clicked block
|
// CraftBukkit start - store the clicked block
|
||||||
org.bukkit.block.Block blockClicked = world.getWorld().getBlockAt(i, j, k);
|
if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, i, j, k, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) {
|
||||||
Player thePlayer = (Player) entityhuman.getBukkitEntity();
|
|
||||||
|
|
||||||
BlockIgniteEvent eventIgnite = new BlockIgniteEvent(blockClicked, BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, thePlayer);
|
|
||||||
world.getServer().getPluginManager().callEvent(eventIgnite);
|
|
||||||
|
|
||||||
if (eventIgnite.isCancelled()) {
|
|
||||||
itemstack.damage(1, entityhuman);
|
itemstack.damage(1, entityhuman);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import net.minecraft.server.EntityItem;
|
|||||||
import net.minecraft.server.EntityLiving;
|
import net.minecraft.server.EntityLiving;
|
||||||
import net.minecraft.server.EntityPlayer;
|
import net.minecraft.server.EntityPlayer;
|
||||||
import net.minecraft.server.EntityPotion;
|
import net.minecraft.server.EntityPotion;
|
||||||
|
import net.minecraft.server.Explosion;
|
||||||
import net.minecraft.server.InventoryCrafting;
|
import net.minecraft.server.InventoryCrafting;
|
||||||
import net.minecraft.server.Item;
|
import net.minecraft.server.Item;
|
||||||
import net.minecraft.server.ItemStack;
|
import net.minecraft.server.ItemStack;
|
||||||
@ -41,6 +42,7 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
|||||||
import org.bukkit.entity.AnimalTamer;
|
import org.bukkit.entity.AnimalTamer;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Creeper;
|
import org.bukkit.entity.Creeper;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.LightningStrike;
|
import org.bukkit.entity.LightningStrike;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Pig;
|
import org.bukkit.entity.Pig;
|
||||||
@ -51,6 +53,7 @@ import org.bukkit.entity.ThrownExpBottle;
|
|||||||
import org.bukkit.entity.ThrownPotion;
|
import org.bukkit.entity.ThrownPotion;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.block.*;
|
import org.bukkit.event.block.*;
|
||||||
|
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
|
||||||
import org.bukkit.event.entity.*;
|
import org.bukkit.event.entity.*;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
@ -551,4 +554,64 @@ public class CraftEventFactory {
|
|||||||
PlayerItemBreakEvent event = new PlayerItemBreakEvent((Player) human.getBukkitEntity(), item);
|
PlayerItemBreakEvent event = new PlayerItemBreakEvent((Player) human.getBukkitEntity(), item);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, int igniterX, int igniterY, int igniterZ) {
|
||||||
|
org.bukkit.World bukkitWorld = world.getWorld();
|
||||||
|
Block igniter = bukkitWorld.getBlockAt(igniterX, igniterY, igniterZ);
|
||||||
|
IgniteCause cause;
|
||||||
|
switch (igniter.getType()) {
|
||||||
|
case LAVA:
|
||||||
|
cause = IgniteCause.LAVA;
|
||||||
|
break;
|
||||||
|
case DISPENSER:
|
||||||
|
cause = IgniteCause.FLINT_AND_STEEL;
|
||||||
|
break;
|
||||||
|
case FIRE: // Fire or any other unknown block counts as SPREAD.
|
||||||
|
default:
|
||||||
|
cause = IgniteCause.SPREAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), cause, igniter);
|
||||||
|
world.getServer().getPluginManager().callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, Entity igniter) {
|
||||||
|
org.bukkit.World bukkitWorld = world.getWorld();
|
||||||
|
org.bukkit.entity.Entity bukkitIgniter = igniter.getBukkitEntity();
|
||||||
|
IgniteCause cause;
|
||||||
|
switch (bukkitIgniter.getType()) {
|
||||||
|
case ENDER_CRYSTAL:
|
||||||
|
cause = IgniteCause.ENDER_CRYSTAL;
|
||||||
|
break;
|
||||||
|
case LIGHTNING:
|
||||||
|
cause = IgniteCause.LIGHTNING;
|
||||||
|
break;
|
||||||
|
case SMALL_FIREBALL:
|
||||||
|
case FIREBALL:
|
||||||
|
cause = IgniteCause.FIREBALL;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
cause = IgniteCause.FLINT_AND_STEEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), cause, bukkitIgniter);
|
||||||
|
world.getServer().getPluginManager().callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, Explosion explosion) {
|
||||||
|
org.bukkit.World bukkitWorld = world.getWorld();
|
||||||
|
org.bukkit.entity.Entity igniter = explosion.source == null ? null : explosion.source.getBukkitEntity();
|
||||||
|
|
||||||
|
BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), IgniteCause.EXPLOSION, igniter);
|
||||||
|
world.getServer().getPluginManager().callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, IgniteCause cause, Entity igniter) {
|
||||||
|
BlockIgniteEvent event = new BlockIgniteEvent(world.getWorld().getBlockAt(x, y, z), cause, igniter.getBukkitEntity());
|
||||||
|
world.getServer().getPluginManager().callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren