当前位置: 首页>>代码示例>>Java>>正文


Java EntityType类代码示例

本文整理汇总了Java中org.bukkit.entity.EntityType的典型用法代码示例。如果您正苦于以下问题:Java EntityType类的具体用法?Java EntityType怎么用?Java EntityType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EntityType类属于org.bukkit.entity包,在下文中一共展示了EntityType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: spawnVillager

import org.bukkit.entity.EntityType; //导入依赖的package包/类
/**
 * Spawns a Villager of the given VillagerType at the provided Location
 * 
 * @param type - the Type of the Villager you wish to Spawn
 * @param location - the Location at which you want the Villager to be
 * @return Villager - the Villager that you had set at the provided Location if you wish to use it
 */
public Villager spawnVillager(VillagerType type, Location location) {
	if (!location.getChunk().isLoaded()) {
		location.getChunk().load();
	}
	Villager villager = (Villager) location.getWorld().spawnEntity(location, EntityType.VILLAGER);
	villager.setAdult();
	villager.setAgeLock(true);
	villager.setProfession(Profession.FARMER);
	villager.setRemoveWhenFarAway(false);
	villager.setCustomName(type.getColor() + type.getName());
	villager.setCustomNameVisible(true);
	villager.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, -6, true), true);
	villager.teleport(location, TeleportCause.PLUGIN);
	villager.setHealth(20.0D);
	return villager;
}
 
开发者ID:HuliPvP,项目名称:Chambers,代码行数:24,代码来源:VillagerManager.java

示例2: onPlayerInteract

import org.bukkit.entity.EntityType; //导入依赖的package包/类
/**
 * Handle interaction with armor stands V1.8
 * Note - some armor stand protection is done in IslandGuard.java, e.g. against projectiles.
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onPlayerInteract(final PlayerInteractAtEntityEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.8 " + e.getEventName());
    }
    if (!Util.inWorld(e.getPlayer())) {
        return;
    }
    if (e.getRightClicked() != null && e.getRightClicked().getType().equals(EntityType.ARMOR_STAND)) {
        if (actionAllowed(e.getPlayer(), e.getRightClicked().getLocation(), SettingsFlag.ARMOR_STAND)) {
            return;
        }
        e.setCancelled(true);
        Util.sendMessage(e.getPlayer(), plugin.getLocale(e.getPlayer().getUniqueId()).get("island.protected"));
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:23,代码来源:IslandGuard1_8.java

示例3: play

import org.bukkit.entity.EntityType; //导入依赖的package包/类
@Override
public void play(PAUser u) {
    if (isInCooldown(u, getName())) return;

    final ArmorStand as = (ArmorStand) spawnEntity(u.getLoc(), EntityType.ARMOR_STAND);
    as.setGravity(false);
    as.setSmall(true);
    as.setVisible(false);
    as.setHelmet(new ItemStack(Material.SEA_LANTERN));
    as.setPassenger(u.getPlayer());

    as.teleport(as.getLocation().add(0, 5, 0));

    bt = plugin.getServer().getScheduler().runTaskTimer(plugin, ()-> {
        as.teleport(as.getLocation().add(0, 0.2, 0));

        if (count <= 0) {
            remove(u, as);
            bt.cancel();
            return;
        }
        count--;
    }, 0, 20);
}
 
开发者ID:cadox8,项目名称:PA,代码行数:25,代码来源:AntiGravity.java

示例4: onMobDeath

import org.bukkit.entity.EntityType; //导入依赖的package包/类
@EventHandler
public void onMobDeath(EntityDeathEvent event) {
	if(event.getEntity() instanceof Entity){
		Entity e = (Entity) event.getEntity();
		if(e.hasMetadata("challenge")){
			event.getDrops().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(e.getType().equals(EntityType.MAGMA_CUBE) || e.getType().equals(EntityType.SLIME)) {
				e.remove();
			}
			if(plugin.getChallenges().getKillsLeft(Bukkit.getPlayer(player)) == 0){
				plugin.getChallenges().finishChallenge(Bukkit.getPlayer(player), false);
			}
		}
	}
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:20,代码来源:ChallengeListener.java

示例5: spawnCompanion

import org.bukkit.entity.EntityType; //导入依赖的package包/类
/**
 * Spawns a random companion for the player with a random name at the location given
 * @param player
 * @param location
 */
protected void spawnCompanion(Player player, Location location) {
    // Older versions of the server require custom names to only apply to Living Entities
    //Bukkit.getLogger().info("DEBUG: spawning compantion at " + location);
    if (!islandCompanion.isEmpty() && location != null) {
        Random rand = new Random();
        int randomNum = rand.nextInt(islandCompanion.size());
        EntityType type = islandCompanion.get(randomNum);
        if (type != null) {
            LivingEntity companion = (LivingEntity) location.getWorld().spawnEntity(location, type);
            if (!companionNames.isEmpty()) {
                randomNum = rand.nextInt(companionNames.size());
                String name = companionNames.get(randomNum).replace("[player]", player.getName());
                //plugin.getLogger().info("DEBUG: name is " + name);
                companion.setCustomName(name);
                companion.setCustomNameVisible(true);
            }
        }
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:25,代码来源:Schematic.java

示例6: onProjectileLaunch

import org.bukkit.entity.EntityType; //导入依赖的package包/类
/**
 * Launch 2 more arrows when one is launched
 *
 * @param event Event
 */
@EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event)
{
    if (event.getEntity().getType() != EntityType.ARROW || !(event.getEntity().getShooter() instanceof Player) || event.getEntity().hasMetadata("TAM"))
        return;

    final Vector velocity = event.getEntity().getVelocity();

    for(int i = 0; i < 2; i++)
    {
        this.plugin.getServer().getScheduler().runTaskLater(this.plugin, () ->
        {
            EntityArrow entityArrow = new EntityArrow(((CraftWorld)event.getEntity().getWorld()).getHandle(), ((CraftLivingEntity)event.getEntity().getShooter()).getHandle(), 1F);
            entityArrow.shoot(((CraftLivingEntity)event.getEntity().getShooter()).getHandle().pitch, ((CraftLivingEntity)event.getEntity().getShooter()).getHandle().yaw, 0.0F, 3.0F, 1.0F);
            entityArrow.getBukkitEntity().setMetadata("TAM", new FixedMetadataValue(this.plugin, true));
            entityArrow.getBukkitEntity().setVelocity(velocity);
            ((CraftWorld)event.getEntity().getWorld()).getHandle().addEntity(entityArrow);
        }, 5L * (i + 1));
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:26,代码来源:ThreeArrowModule.java

示例7: onPlayerInteractEntity

import org.bukkit.entity.EntityType; //导入依赖的package包/类
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
    Player player = event.getPlayer();
    Entity entity = event.getRightClicked();
    try {
        int balance = ScrapsUtil.getScraps(player);
        if (entity.getType().equals(EntityType.VILLAGER)) {
            event.setCancelled(true);
            String npc = entity.getName();
            if (MerchantManager.getAllNPCs().contains(npc)) {
                ItemStack selling = MerchantManager.getItem(npc);
                int price = MerchantManager.getPrice(npc);
                if (balance >= price) {
                    player.getInventory().addItem(selling);
                    player.sendMessage(MerchantManager.getSuccessMessage(npc));
                    ScrapsUtil.removeScraps(player, price);
                } else {
                    player.sendMessage(MerchantManager.getDenialMessage(npc));
                }
            }
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
 
开发者ID:Warvale,项目名称:Locked,代码行数:26,代码来源:MerchantListener.java

示例8: leave

import org.bukkit.entity.EntityType; //导入依赖的package包/类
@EventHandler
public void leave(final PlayerQuitEvent event) {
    if(GameState.current() != GameState.LOBBY && event.getPlayer().getGameMode() != GameMode.SPECTATOR){
        event.setQuitMessage(colour("&6" + event.getPlayer().getName() + " has quit! " +
                "They have " + UHC.getInstance().getMainConfig().getDisconnectGracePeriodSeconds() + "s to reconnect."));

        bukkitRunnable(() -> disqualified(event.getPlayer().getUniqueId(), event.getPlayer().getName(),
                event.getPlayer().getLocation(), event.getPlayer().getInventory())).runTaskLater(UHC.getInstance(),
                TimeUnit.MILLISECONDS.convert(UHC.getInstance().getMainConfig().getDisconnectGracePeriodSeconds(), TimeUnit.SECONDS));

        //Zombie Spawning
        Zombie zombie = (Zombie) event.getPlayer().getWorld().spawnEntity(event.getPlayer().getLocation(), EntityType.ZOMBIE);
        zombie.setCustomName(event.getPlayer().getName());
        zombie.setCustomNameVisible(true);
        //TODO Make no AI and invulnerable cough cough Proxi cough cough
        deadRepresentatives.put(event.getPlayer().getUniqueId(), zombie);
    }
}
 
开发者ID:Project-Coalesce,项目名称:UHC,代码行数:19,代码来源:JoinQuitHandlers.java

示例9: load

import org.bukkit.entity.EntityType; //导入依赖的package包/类
/**
 * Load the plugin's settings.
 *
 * @author HomieDion
 * @since 1.1.0
 */
public void load() {
	// Variables
	final Sunscreen plugin = Sunscreen.getInstance();
	final CustomConfig config = new CustomConfig("config.yml", plugin);
	final Logger log = plugin.getLogger();

	// Add the disabled worlds
	for (final String world : config.getStringList("disabled_worlds")) {
		worlds.add(world);
		log.info(String.format("%s will not use this plugin.", world));
	}

	// Loop all entities
	for (final EntityType type : EntityType.values()) {
		// Loop all values of the list
		for (final String line : config.getStringList("mobs")) {
			// If the names match
			if (type.name().equalsIgnoreCase(line)) {
				mobs.add(type);
				log.info(String.format("%s will not burn in the sun.", type.name()));
				break;
			}
		}
	}
}
 
开发者ID:homiedion,项目名称:Sunscreen,代码行数:32,代码来源:PluginSettings.java

示例10: onProjectileHit

import org.bukkit.entity.EntityType; //导入依赖的package包/类
@EventHandler
public void onProjectileHit(ProjectileHitEvent event)
{
    if (event.getEntity().getType() != EntityType.SNOWBALL || !event.getEntity().hasMetadata("paintball-ball") || !event.getEntity().getMetadata("paintball-ball").get(0).asString().equals(this.uuid.toString()))
        return;

    for (Block block : getNearbyBlocks(event.getEntity().getLocation(), 2))
    {
        if (block.getType() == Material.AIR || block.getType() == Material.SIGN || block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)
            continue;

        if (this.isBlockGloballyUsed(block.getLocation()))
            continue;

        SimpleBlock simpleBlock = new SimpleBlock(Material.STAINED_CLAY, DyeColor.values()[new Random().nextInt(DyeColor.values().length)].getWoolData());
        this.addBlockToUse(block.getLocation(), simpleBlock);

        block.setType(simpleBlock.getType());
        block.setData(simpleBlock.getData());
    }

    event.getEntity().remove();
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:24,代码来源:PaintballDisplayer.java

示例11: getSpawnEgg

import org.bukkit.entity.EntityType; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
// This is kind of a dumb way to do this.. But I'm too lazy to fix my reflection
public org.bukkit.inventory.ItemStack getSpawnEgg(org.bukkit.inventory.ItemStack i, String entityTag){
	EntityType type = null;
	try{
		type = EntityType.valueOf(entityTag.toUpperCase());
	}catch(Exception ex){
		switch (entityTag){
			case "mooshroom":
				type = EntityType.MUSHROOM_COW;
				break;
			case "zombie_pigman":
				type = EntityType.PIG_ZOMBIE;
				break;
			default:
				type = EntityType.BAT;
				System.out.println("Bad tag: " + entityTag);
				break;
		}
	}
	return new ItemStack(i.getType(), i.getAmount(), type.getTypeId());
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:24,代码来源:SpawnUtil.java

示例12: ClickCheckItem

import org.bukkit.entity.EntityType; //导入依赖的package包/类
@EventHandler
public void ClickCheckItem(InventoryClickEvent evt){
    if(ConfigPatch.AntiLongStringCrashenable == true){
        if(evt.getWhoClicked().getType() != EntityType.PLAYER){
            return;
        }
        Player player = (Player) evt.getWhoClicked();
        ItemStack item = evt.getCursor();
        if(item != null){
            if(item.hasItemMeta() && item.getItemMeta().getDisplayName() != null){
                if(item.getItemMeta().getDisplayName().length() >= 127){
                    evt.setCancelled(true);
                    evt.setCurrentItem(null);
                    AzureAPI.log(player, ConfigPatch.AntiLongStringCrashWarnMessage);
                }
            }
        }
    }
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:20,代码来源:AntiLongStringCrash.java

示例13: getNearbyPlayers

import org.bukkit.entity.EntityType; //导入依赖的package包/类
public static List<Player> getNearbyPlayers(Location location, double distance) {
    List<Player> nearbyPlayers = new ArrayList<>();
    for (LivingEntity entity : location.getWorld().getLivingEntities()) {
        if (entity.getType() == EntityType.PLAYER && entity.getLocation().distance(location) <= distance) {
            nearbyPlayers.add((Player) entity);
        }
    }

    return nearbyPlayers;
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:11,代码来源:LocationUtils.java

示例14: getRandomFirework

import org.bukkit.entity.EntityType; //导入依赖的package包/类
public static Firework getRandomFirework(Location loc) {
    FireworkMeta fireworkMeta = (FireworkMeta) (new ItemStack(Material.FIREWORK)).getItemMeta();
    Firework firework = (Firework) loc.getWorld().spawnEntity(loc, EntityType.FIREWORK);

    fireworkMeta.setPower(GizmoConfig.FIREWORK_POWER);
    fireworkMeta.addEffect(FireworkEffect.builder()
            .with(RocketUtils.randomFireworkType())
            .withColor(RocketUtils.randomColor())
            .trail(GizmoConfig.FIREWORK_TRAIL)
            .build());

    firework.setFireworkMeta(fireworkMeta);
    return firework;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:15,代码来源:RocketUtils.java

示例15: worldEntities

import org.bukkit.entity.EntityType; //导入依赖的package包/类
private List<Entity> worldEntities(World w, EntityType entityType) {
    List<Entity> entities = new ArrayList<>();

    w.getEntities().forEach(e -> {
        if (e.getType() == entityType) {
            entities.add(e);
        }
    });
    return entities;
}
 
开发者ID:cadox8,项目名称:PA,代码行数:11,代码来源:KillAllCMD.java


注:本文中的org.bukkit.entity.EntityType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。