本文整理汇总了Java中org.bukkit.entity.Firework.remove方法的典型用法代码示例。如果您正苦于以下问题:Java Firework.remove方法的具体用法?Java Firework.remove怎么用?Java Firework.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Firework
的用法示例。
在下文中一共展示了Firework.remove方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makePacket
import org.bukkit.entity.Firework; //导入方法依赖的package包/类
/**
* Make a packet object
*
* @param location Location to play firework effect at
* @param fireworkEffect FireworkEffect to play
* @return Packet constructed by the parameters
*/
private static Object makePacket(Location location, FireworkEffect fireworkEffect) {
try {
Firework firework = location.getWorld().spawn(location, Firework.class);
FireworkMeta data = firework.getFireworkMeta();
data.clearEffects();
data.setPower(1);
data.addEffect(fireworkEffect);
firework.setFireworkMeta(data);
Object nmsFirework = ReflectionUtil.getHandle(firework);
firework.remove();
return PACKET_PLAY_OUT_ENTITY_STATUS.newInstance(nmsFirework, (byte) 17);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例2: playFirework
import org.bukkit.entity.Firework; //导入方法依赖的package包/类
public void playFirework(Location loc, FireworkEffect fe) throws Exception {
World world = loc.getWorld();
Firework fw = (Firework) world.spawn(loc, Firework.class);
Object nms_world = null;
Object nms_firework = null;
if (world_getHandle == null) {
world_getHandle = getMethod(world.getClass(), "getHandle");
firework_getHandle = getMethod(fw.getClass(), "getHandle");
}
nms_world = world_getHandle.invoke(world, (Object[]) null);
nms_firework = firework_getHandle.invoke(fw, (Object[]) null);
if (nms_world_broadcastEntityEffect == null) {
nms_world_broadcastEntityEffect = getMethod(nms_world.getClass(),
"broadcastEntityEffect");
}
FireworkMeta data = (FireworkMeta) fw.getFireworkMeta();
data.clearEffects();
data.setPower(1);
data.addEffect(fe);
fw.setFireworkMeta(data);
nms_world_broadcastEntityEffect.invoke(nms_world, new Object[] {
nms_firework, (byte) 17 });
fw.remove();
}
示例3: fire
import org.bukkit.entity.Firework; //导入方法依赖的package包/类
protected final Firework fire(Location location, IConsumableDetails details, Object userObject) {
final Firework firework = (Firework) location.getWorld().spawnEntity(location, EntityType.FIREWORK);
FireworkMeta meta = firework.getFireworkMeta();
final FireworkPlayerDetails fDetails = FireworkPlayerDetails.fromConsumableDetails(details, firework, userObject);
if (!onFire(fDetails, meta)) {
firework.remove();
return null;
}
firework.setFireworkMeta(meta);
final BukkitTask[] task = new BukkitTask[1];
task[0] = Bukkit.getScheduler().runTaskTimer(getPlugin(), new Runnable() {
@Override
public void run() {
if (firework.isDead()) {
onExplode(fDetails);
task[0].cancel();
}
firework.setTicksLived(Integer.MAX_VALUE);
}
}, 10 * (1 + meta.getPower()), 2);
return firework;
}
示例4: playEffect
import org.bukkit.entity.Firework; //导入方法依赖的package包/类
public static void playEffect(Location l, Color color) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
Firework fw = l.getWorld().spawn(l, Firework.class);
Object worldObject = ReflectionUtils.getMethod(l.getWorld().getClass(), "getHandle").invoke(l.getWorld(),(Object[]) null);
FireworkMeta meta = fw.getFireworkMeta();
meta.addEffect(FireworkEffect.builder().with(Type.BURST).flicker(false).trail(false).withColor(color).withFade(Color.WHITE).build());
fw.setFireworkMeta(meta);
ReflectionUtils.getMethod(worldObject.getClass(), "broadcastEntityEffect").invoke(worldObject, new Object[] {ReflectionUtils.getMethod(fw.getClass(), "getHandle").invoke(fw, (Object[]) null), (byte) 17});
fw.remove();
}
示例5: playFirework
import org.bukkit.entity.Firework; //导入方法依赖的package包/类
void playFirework(Location loc) throws Exception {
Firework fw = loc.getWorld().spawn(loc, Firework.class);
if (dataStore[0] == null)
dataStore[0] = getMethod(loc.getWorld().getClass(), "getHandle");
if (dataStore[2] == null)
dataStore[2] = getMethod(fw.getClass(), "getHandle");
dataStore[3] = ((Method) dataStore[0]).invoke(loc.getWorld(), (Object[]) null);
dataStore[4] = ((Method) dataStore[2]).invoke(fw, (Object[]) null);
if (dataStore[1] == null)
dataStore[1] = getMethod(dataStore[3].getClass(), "addParticle");
((Method) dataStore[1]).invoke(dataStore[3], "fireworksSpark", loc.getX(), loc.getY(), loc.getZ(), gen.nextGaussian() * 0.05D, -(loc.getZ() * 1.15D) * 0.5D, gen.nextGaussian() * 0.05D);
fw.remove();
}
示例6: playFirework
import org.bukkit.entity.Firework; //导入方法依赖的package包/类
/**
* Play a pretty firework at the location with the FireworkEffect when called
* @param world
* @param loc
* @param fe
* @throws Exception
*/
public static void playFirework(World world, Location loc, FireworkEffect fe) throws Exception {
// Bukkity load (CraftFirework)
Firework fw = (Firework) world.spawn(loc, Firework.class);
// the net.minecraft.server.World
Object nms_world = null;
Object nms_firework = null;
/*
* The reflection part, this gives us access to funky ways of messing around with things
*/
if(world_getHandle == null) {
// get the methods of the craftbukkit objects
world_getHandle = getMethod(world.getClass(), "getHandle");
firework_getHandle = getMethod(fw.getClass(), "getHandle");
}
// invoke with no arguments
nms_world = world_getHandle.invoke(world, (Object[]) null);
nms_firework = firework_getHandle.invoke(fw, (Object[]) null);
// null checks are fast, so having this seperate is ok
if(nms_world_broadcastEntityEffect == null) {
// get the method of the nms_world
nms_world_broadcastEntityEffect = getMethod(nms_world.getClass(), "broadcastEntityEffect");
}
/*
* Now we mess with the metadata, allowing nice clean spawning of a pretty firework (look, pretty lights!)
*/
// metadata load
FireworkMeta data = (FireworkMeta) fw.getFireworkMeta();
// clear existing
data.clearEffects();
// power of one
data.setPower(1);
// add the effect
data.addEffect(fe);
// set the meta
fw.setFireworkMeta(data);
/*
* Finally, we broadcast the entity effect then kill our fireworks object
*/
// invoke with arguments
nms_world_broadcastEntityEffect.invoke(nms_world, new Object[] {nms_firework, (byte) 17});
// remove from the game
fw.remove();
}
示例7: playFirework
import org.bukkit.entity.Firework; //导入方法依赖的package包/类
/**
* Play a pretty firework at the location with the FireworkEffect when called
* @param world
* @param loc
* @param fe
* @throws Exception
*/
public void playFirework(World world, Location loc, FireworkEffect fe) throws Exception {
// Bukkity load (CraftFirework)
Firework fw = (Firework) world.spawn(loc, Firework.class);
// the net.minecraft.server.World
Object nms_world = null;
Object nms_firework = null;
/*
* The reflection part, this gives us access to funky ways of messing around with things
*/
if(world_getHandle == null) {
// get the methods of the craftbukkit objects
world_getHandle = getMethod(world.getClass(), "getHandle");
firework_getHandle = getMethod(fw.getClass(), "getHandle");
}
// invoke with no arguments
nms_world = world_getHandle.invoke(world, (Object[]) null);
nms_firework = firework_getHandle.invoke(fw, (Object[]) null);
// null checks are fast, so having this seperate is ok
if(nms_world_broadcastEntityEffect == null) {
// get the method of the nms_world
nms_world_broadcastEntityEffect = getMethod(nms_world.getClass(), "broadcastEntityEffect");
}
/*
* Now we mess with the metadata, allowing nice clean spawning of a pretty firework (look, pretty lights!)
*/
// metadata load
FireworkMeta data = (FireworkMeta) fw.getFireworkMeta();
// clear existing
data.clearEffects();
// power of one
data.setPower(1);
// add the effect
data.addEffect(fe);
// set the meta
fw.setFireworkMeta(data);
/*
* Finally, we broadcast the entity effect then kill our fireworks object
*/
// invoke with arguments
nms_world_broadcastEntityEffect.invoke(nms_world, new Object[] {nms_firework, (byte) 17});
// remove from the game
// fw.
fw.remove();
}
示例8: playFirework
import org.bukkit.entity.Firework; //导入方法依赖的package包/类
/**
* Play a firework effect at the specified location.
*
* @param world the bukkit world the effect will be displayed
* @param loc the location in the world the effect will be displayed
* @param fe the {@link org.bukkit.FireworkEffect} what will be used
* @throws Exception the exception
*/
public void playFirework(World world, Location loc, FireworkEffect fe) throws Exception {
Firework fw = world.spawn(loc, Firework.class);
Object nmsWorld = null;
Object nmsFirework = null;
if (worldHandler == null) {
worldHandler = getMethod(world.getClass(), "getHandle");
fireworkHandler = getMethod(fw.getClass(), "getHandle");
}
nmsWorld = worldHandler.invoke(world, (Object[]) null);
nmsFirework = fireworkHandler.invoke(fw, (Object[]) null);
if (nmsWorldBroadcastEntityEffect == null) {
nmsWorldBroadcastEntityEffect = getMethod(nmsWorld.getClass(), "broadcastEntityEffect");
}
//Load firework metadata
FireworkMeta data = fw.getFireworkMeta();
//clear firework effects to allow reuse
data.clearEffects();
//Set power of firework to 1
data.setPower((random.nextInt(200) + 101) / 100);
//add the effect
data.addEffect(fe);
fw.setFireworkMeta(data);
/*
* Now broadcast the firework and kill the firework object
*
*/
nmsWorldBroadcastEntityEffect.invoke(nmsWorld, nmsFirework, (byte) 17);
//Remove the object from game
fw.remove();
}
示例9: playFirework
import org.bukkit.entity.Firework; //导入方法依赖的package包/类
public void playFirework(World world, Location loc, FireworkEffect fe) throws Exception {
// Bukkity load (CraftFirework)
Firework fw = (Firework) world.spawn(loc, Firework.class);
// the net.minecraft.server.World
Object nms_world = null;
Object nms_firework = null;
/*
* The reflection part, this gives us access to funky ways of messing
* around with things
*/
if (world_getHandle == null) {
// get the methods of the craftbukkit objects
world_getHandle = getMethod(world.getClass(), "getHandle");
firework_getHandle = getMethod(fw.getClass(), "getHandle");
}
// invoke with no arguments
nms_world = world_getHandle.invoke(world, (Object[]) null);
nms_firework = firework_getHandle.invoke(fw, (Object[]) null);
// null checks are fast, so having this seperate is ok
if (nms_world_broadcastEntityEffect == null) {
// get the method of the nms_world
nms_world_broadcastEntityEffect = getMethod(nms_world.getClass(), "broadcastEntityEffect");
}
/*
* Now we mess with the metadata, allowing nice clean spawning of a
* pretty firework (look, pretty lights!)
*/
// metadata load
FireworkMeta data = (FireworkMeta) fw.getFireworkMeta();
// clear existing
data.clearEffects();
// power of one
data.setPower(1);
// add the effect
data.addEffect(fe);
// set the meta
fw.setFireworkMeta(data);
/*
* Finally, we broadcast the entity effect then kill our fireworks
* object
*/
// invoke with arguments
nms_world_broadcastEntityEffect.invoke(nms_world, new Object[] { nms_firework, (byte) 17 });
// remove from the game
fw.remove();
}
示例10: playFirework
import org.bukkit.entity.Firework; //导入方法依赖的package包/类
/**
* Play a pretty firework at the location with the FireworkEffect when
* called
*
* @param world
* @param loc
* @param fe
* @throws Exception
*/
public void playFirework(World world, Location loc, FireworkEffect fe)
throws Exception {
// Bukkity load (CraftFirework)
Firework fw = (Firework) world.spawn(loc, Firework.class);
// the net.minecraft.server.World
Object nms_world = null;
Object nms_firework = null;
/*
* The reflection part, this gives us access to funky ways of messing
* around with things
*/
if (world_getHandle == null) {
// get the methods of the craftbukkit objects
world_getHandle = getMethod(world.getClass(), "getHandle");
firework_getHandle = getMethod(fw.getClass(), "getHandle");
}
// invoke with no arguments
nms_world = world_getHandle.invoke(world, (Object[]) null);
nms_firework = firework_getHandle.invoke(fw, (Object[]) null);
// null checks are fast, so having this seperate is ok
if (nms_world_broadcastEntityEffect == null) {
// get the method of the nms_world
nms_world_broadcastEntityEffect = getMethod(nms_world.getClass(),
"broadcastEntityEffect");
}
/*
* Now we mess with the metadata, allowing nice clean spawning of a
* pretty firework (look, pretty lights!)
*/
// metadata load
FireworkMeta data = (FireworkMeta) fw.getFireworkMeta();
// clear existing
data.clearEffects();
// power of one
data.setPower(1);
// add the effect
data.addEffect(fe);
// set the meta
fw.setFireworkMeta(data);
/*
* Finally, we broadcast the entity effect then kill our fireworks
* object
*/
// invoke with arguments
nms_world_broadcastEntityEffect.invoke(nms_world, new Object[] {
nms_firework, (byte) 17 });
// remove from the game
fw.remove();
}
示例11: sendParticleEffect
import org.bukkit.entity.Firework; //导入方法依赖的package包/类
public static void sendParticleEffect(final Location location, final int reinforcementValue, final int reinforcementValueCoefficient) {
World world = location.getWorld();
Firework firework = world.spawn(new Location(world, location.getBlockX() + 0.5d, location.getBlockY() + 0.5d, location.getBlockZ() + 0.5d), Firework.class);
FireworkMeta fireworkMeta = firework.getFireworkMeta();
fireworkMeta.clearEffects();
fireworkMeta.setPower(1);
Color color;
// Normalize the RV so that the change from RVC to 0 is gradual.
int numberOfColors = 6;
double fadeInterval = reinforcementValueCoefficient / numberOfColors;
int fadeStage = (int) Math.floor(reinforcementValue / fadeInterval);
switch (fadeStage) {
case 0:
// If the block is not reinforced, but has just been damaged as a reinforced block (presumably due to the grace period), then we play the "nearly broken" effect.
color = Color.RED;
break;
case 1:
color = Color.ORANGE;
break;
case 2:
color = Color.YELLOW;
break;
case 3:
color = Color.GREEN;
break;
case 4:
color = Color.BLUE;
break;
default:
color = Color.PURPLE;
break;
}
fireworkMeta.addEffects(FireworkEffect.builder().withColor(color).with(FireworkEffect.Type.BALL).build());
firework.setFireworkMeta(fireworkMeta);
try {
Object nms_world = getMethod(world.getClass(), "getHandle").invoke(world);
getMethod(nms_world.getClass(), "broadcastEntityEffect").invoke(nms_world, getMethod(firework.getClass(), "getHandle").invoke(firework), (byte) 17);
firework.remove();
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
}
}