本文整理汇总了Java中org.bukkit.entity.Creeper类的典型用法代码示例。如果您正苦于以下问题:Java Creeper类的具体用法?Java Creeper怎么用?Java Creeper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Creeper类属于org.bukkit.entity包,在下文中一共展示了Creeper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockBreak
import org.bukkit.entity.Creeper; //导入依赖的package包/类
/**
* Spawns a creeper or primed TNT when a player breaks an ore block, by chance.
*
* @param event The event
*/
@EventHandler(ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
Block block = event.getBlock();
if (ORES.contains(block.getType())) {
double chance = Math.random();
Location location = block.getLocation().add(0.5, 0.5, 0.5);
if (0.05 > chance) {
TNTPrimed tnt = location.getWorld().spawn(location, TNTPrimed.class);
tnt.setFuseTicks(80);
} else if (0.1 > chance) {
Creeper creeper = location.getWorld().spawn(location, Creeper.class);
creeper.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 2));
}
}
}
示例2: testBukkitClasses
import org.bukkit.entity.Creeper; //导入依赖的package包/类
@Test
public void testBukkitClasses() throws InputException {
Class[] inputTypes = {Class[].class};
String[] input = {"Zombie,Creeper,Pig"};
Object[] output = InputFormatter.getTypesFromInput(inputTypes, Arrays.asList(input), null);
// First let's make sure we didn't lose anything, or get anything
assertEquals(inputTypes.length, output.length);
// Next let's make sure everything is the right type
for (Object object : output) {
assertTrue(object instanceof Class[]);
}
// Finally, let's make sure the values are correct
Class[] classes = (Class[]) output[0];
assertEquals(classes[0], Zombie.class);
assertEquals(classes[1], Creeper.class);
assertEquals(classes[2], Pig.class);
}
示例3: onExplode
import org.bukkit.entity.Creeper; //导入依赖的package包/类
@EventHandler
public void onExplode(EntityExplodeEvent event) {
if(event.getEntity() instanceof Creeper) {
Entity e = event.getEntity();
if(e.hasMetadata("challenge")) {
event.blockList().clear();
String[] meta = e.getMetadata("challenge").get(0).asString().split(", ");
final String player = meta[1];
plugin.getChallenges().addKill(Bukkit.getPlayer(player));
Bukkit.getPlayer(player).setLevel(plugin.getChallenges().getKillsLeft(Bukkit.getPlayer(player)));
if(plugin.getChallenges().getKillsLeft(Bukkit.getPlayer(player)) == 0) {
plugin.getChallenges().finishChallenge(Bukkit.getPlayer(player), false);
}
}
}
}
示例4: onEntityBendingDeath
import org.bukkit.entity.Creeper; //导入依赖的package包/类
@EventHandler
public void onEntityBendingDeath(EntityBendingDeathEvent event) {
Entity v = event.getVictim();
Element e = CoreAbility.getAbility(event.getAbility()).getElement();
int xp;
if(v == null || e == null)
return;
if(v instanceof Player) {
xp = 25 + (int)(Math.random() * ((35 - 25) + 1));
}
else if(v instanceof Zombie || v instanceof Creeper || v instanceof Witch || v instanceof Skeleton || v instanceof Guardian || v instanceof Spider) {
xp = 13 + (int)(Math.random() * ((22 - 13) + 1));
}
else {
xp = 3 + (int)(Math.random() * ((8 - 3) + 1));
}
BendingExp.addExp(event.getAttacker(), e, xp);
}
示例5: on
import org.bukkit.entity.Creeper; //导入依赖的package包/类
@EventHandler
public void on(EntityDeathEvent event) {
if (!(event.getEntity() instanceof Creeper)) return;
Creeper creeper = (Creeper) event.getEntity();
// explode after 2 seconds ticks
ExplosionTask task = new ExplosionTask(creeper.getLocation(), creeper.isPowered() ? 6 : 3, false);
task.runTaskLater(plugin, 40);
// set up some layered smoke effects
for (int i = 0; i < 5; i++) {
// increase the count over time
ImpendingExplosionParticleTask smoke = new ImpendingExplosionParticleTask(creeper.getLocation(), 20 * (i+1));
smoke.runTaskLater(plugin, 10 + (i * 10));
}
}
示例6: CreeperMenu
import org.bukkit.entity.Creeper; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public CreeperMenu(Plot plot, Creeper creeper) {
super(plot, creeper);
//powered
ItemStack powered = new ItemStack(Material.REDSTONE);
ItemMeta poweredMeta = powered.getItemMeta();
poweredMeta.setDisplayName(ChatColor.GREEN + "Change whether this creeper is charged");
powered.setItemMeta(poweredMeta);
insertItem(powered, event -> {
creeper.setPowered(!creeper.isPowered());
event.setCancelled(true);
}, 0);
}
示例7: trigger
import org.bukkit.entity.Creeper; //导入依赖的package包/类
@Override
public void trigger(AlmightyNotchPlugin plugin, World world) {
PluginManager pluginManager = Bukkit.getPluginManager();
for (LivingEntity entity : world.getLivingEntities()) {
if (entity.getType() == EntityType.CREEPER) {
Creeper creeper = (Creeper) entity;
float power = creeper.isPowered() ? 6.0F : 3.0F;
ExplosionPrimeEvent event = new ExplosionPrimeEvent(creeper, power, false);
pluginManager.callEvent(event);
if (!event.isCancelled()) {
creeper.damage(creeper.getHealth());
world.createExplosion(creeper.getLocation(), power);
}
}
}
plugin.getMessenger().sendMessage(Bukkit.getServer(), getOccurMessage());
}
示例8: onEntityExplodeEvent
import org.bukkit.entity.Creeper; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onEntityExplodeEvent(EntityExplodeEvent event) {
AttackType attackType = AttackType.UNKNOWN;
Entity attacker = event.getEntity();
if (attacker instanceof TNTPrimed) {
attackType = AttackType.TNT;
} else if (attacker instanceof Creeper) {
attackType = AttackType.CREEPER;
} else if (attacker instanceof Fireball) {
if (((Fireball) attacker).getShooter() instanceof Ghast) {
attackType = AttackType.GHAST;
}
}
if (plugin.getChestSettings().allowDestroyBy(attackType)) {
return;
}
for (Iterator<Block> it = event.blockList().iterator(); it.hasNext();) {
Block block = it.next();
if (isProtected(block)) {
it.remove();
}
}
}
示例9: display
import org.bukkit.entity.Creeper; //导入依赖的package包/类
@Override
public void display()
{
Creeper creeper = this.baseLocation.getWorld().spawn(this.baseLocation.clone().add(0.0D, 5.0D, 0.0D), Creeper.class);
creeper.setPowered(true);
creeper.setMetadata("owner-id", new FixedMetadataValue(this.hub, this.player.getUniqueId().toString()));
this.lovingTask = this.hub.getServer().getScheduler().runTaskTimer(this.hub, () ->
{
if (!creeper.isDead())
ParticleEffect.HEART.display(0.25F, 0.5F, 0.25F, 1.0F, 6, creeper.getLocation(), 20.0D);
}, 5L, 5L);
}
示例10: explode
import org.bukkit.entity.Creeper; //导入依赖的package包/类
private void explode(Creeper creeper)
{
this.lovingTask.cancel();
Location flowerSpawnLocation = creeper.getLocation().clone().add(0.0D, 1.5D, 0.0D);
for (int i = 0; i < 64; i++)
{
ItemStack redDye = new ItemStack(Material.INK_SACK, 1, (short) 1);
Item item = this.player.getWorld().dropItemNaturally(flowerSpawnLocation, redDye);
item.setVelocity(new Vector(GadgetManager.RANDOM.nextInt(2) - 1, 1.5, GadgetManager.RANDOM.nextInt(2) - 1));
try
{
GadgetManager.AGE_FIELD.set((((CraftItem) item).getHandle()), 5500);
}
catch (IllegalAccessException e)
{
e.printStackTrace();
}
}
creeper.getWorld().strikeLightningEffect(creeper.getLocation());
creeper.getWorld().createExplosion(creeper.getLocation().getX(), (creeper.getLocation().getY() + 2.0D), creeper.getLocation().getZ(), 2.5F, false, false);
creeper.remove();
HeartEffect heartEffect = new HeartEffect(this.hub.getCosmeticManager().getParticleManager().getEffectManager());
heartEffect.particle = de.slikey.effectlib.util.ParticleEffect.HEART;
heartEffect.setLocation(flowerSpawnLocation.clone().add(0.0D, 1.5D, 0.0D));
heartEffect.start();
this.end();
}
示例11: convert
import org.bukkit.entity.Creeper; //导入依赖的package包/类
@Override
@Nullable
public ItemType convert(final Object o) {
final SkullType type;
if (o instanceof Skeleton || o instanceof SkeletonData) {
if (o instanceof SkeletonData ? ((SkeletonData) o).isWither() : ((Skeleton) o).getSkeletonType() == SkeletonType.WITHER) {
type = SkullType.WITHER;
} else {
type = SkullType.SKELETON;
}
} else if (o instanceof Zombie || o instanceof EntityData && Zombie.class.isAssignableFrom(((EntityData<?>) o).getType())) {
type = SkullType.ZOMBIE;
} else if (o instanceof OfflinePlayer || o instanceof PlayerData) {
type = SkullType.PLAYER;
} else if (o instanceof Creeper || o instanceof CreeperData) {
type = SkullType.CREEPER;
} else {
return null;
}
@SuppressWarnings("deprecation")
final ItemType i = new ItemType(Material.SKULL_ITEM.getId(), (short) type.ordinal());
if (o instanceof OfflinePlayer) {
final SkullMeta s = (SkullMeta) Bukkit.getItemFactory().getItemMeta(Material.SKULL_ITEM);
s.setOwner(((OfflinePlayer) o).getName());
i.setItemMeta(s);
}
return i;
}
示例12: onCreeperPower
import org.bukkit.entity.Creeper; //导入依赖的package包/类
@EventHandler(ignoreCancelled = false)
public void onCreeperPower(cn.nukkit.event.entity.CreeperPowerEvent event) {
if (canIgnore(CreeperPowerEvent.getHandlerList())) {
return;
}
PowerCause cause = PowerCause.valueOf(event.getCause().name()); // Dirty and fast conversion
CreeperPowerEvent bukkitEvent = new CreeperPowerEvent((Creeper) PokkitEntity.toBukkit(event.getEntity()), cause);
callCancellable(event, bukkitEvent);
}
示例13: onStart
import org.bukkit.entity.Creeper; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onStart(BloodMoonStartEvent event) {
World world = event.getWorld();
PluginConfig worldConfig = plugin.getConfig(world);
if (plugin.isFeatureEnabled(world, Feature.SUPER_CREEPERS) && worldConfig.getBoolean(Config.FEATURE_SUPER_CREEPERS_LIGHTNING)) {
for (LivingEntity entity : world.getLivingEntities()) {
if (entity.getType() == EntityType.CREEPER) {
((Creeper) entity).setPowered(true);
}
}
}
}
示例14: onStop
import org.bukkit.entity.Creeper; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onStop(BloodMoonEndEvent event) {
World world = event.getWorld();
PluginConfig worldConfig = plugin.getConfig(world);
if (plugin.isFeatureEnabled(world, Feature.SUPER_CREEPERS) && worldConfig.getBoolean(Config.FEATURE_SUPER_CREEPERS_LIGHTNING)) {
for (LivingEntity entity : world.getLivingEntities()) {
if (entity.getType() == EntityType.CREEPER) {
((Creeper) entity).setPowered(false);
}
}
}
}
示例15: onCreatureSpawn
import org.bukkit.entity.Creeper; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
LivingEntity entity = event.getEntity();
World world = entity.getWorld();
PluginConfig worldConfig = plugin.getConfig(world);
if (entity.getType() == EntityType.CREEPER && plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.SUPER_CREEPERS) && worldConfig.getBoolean(Config.FEATURE_SUPER_CREEPERS_LIGHTNING)) {
((Creeper) entity).setPowered(true);
}
}