當前位置: 首頁>>代碼示例>>Java>>正文


Java Creeper類代碼示例

本文整理匯總了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));
    }
  }
}
 
開發者ID:twizmwazin,項目名稱:OpenUHC,代碼行數:21,代碼來源:BlastMining.java

示例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);
}
 
開發者ID:zachbr,項目名稱:Debuggery,代碼行數:22,代碼來源:InputFormatterTest.java

示例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);
			}
		}
	}
}
 
開發者ID:benNek,項目名稱:AsgardAscension,代碼行數:17,代碼來源:ChallengeListener.java

示例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);
}
 
開發者ID:savior67,項目名稱:BendingExp,代碼行數:21,代碼來源:DeathByBendingListener.java

示例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));
    }
}
 
開發者ID:Eluinhost,項目名稱:UberHardcore,代碼行數:18,代碼來源:CreeperDeathHandler.java

示例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);
}
 
開發者ID:stefvanschie,項目名稱:buildinggame,代碼行數:19,代碼來源:CreeperMenu.java

示例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());
}
 
開發者ID:Amperial,項目名稱:AlmightyNotch,代碼行數:19,代碼來源:CreeperExplodeEvent.java

示例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();
        }
    }
}
 
開發者ID:rutgerkok,項目名稱:BlockLocker,代碼行數:24,代碼來源:BlockDestroyListener.java

示例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);
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:14,代碼來源:HolyCreeperDisplayer.java

示例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();
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:34,代碼來源:HolyCreeperDisplayer.java

示例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;
}
 
開發者ID:nfell2009,項目名稱:Skript,代碼行數:29,代碼來源:ExprSkull.java

示例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);
}
 
開發者ID:rutgerkok,項目名稱:Pokkit,代碼行數:13,代碼來源:EntityEvents.java

示例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);
            }
        }
    }
}
 
開發者ID:Samistine,項目名稱:BloodMoon,代碼行數:14,代碼來源:SuperCreepersListener.java

示例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);
            }
        }
    }
}
 
開發者ID:Samistine,項目名稱:BloodMoon,代碼行數:14,代碼來源:SuperCreepersListener.java

示例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);
    }
}
 
開發者ID:Samistine,項目名稱:BloodMoon,代碼行數:11,代碼來源:SuperCreepersListener.java


注:本文中的org.bukkit.entity.Creeper類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。