• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java EntityType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getForAll

import org.spongepowered.api.entity.EntityType; //导入依赖的package包/类
@Override
public Optional<EntityTemplate> getForAll(String identifier) {
	Preconditions.checkNotNull(identifier);
	
	EntityTemplate entity = this.entities.get(identifier.toLowerCase());
	if (entity != null) {
		return Optional.of(entity);
	}
	
	Optional<EntityType> type = this.plugin.getGame().getRegistry().getType(EntityType.class, identifier);
	if (type.isPresent()) {
		return Optional.of(EntityTemplate.of(type.get()));
	}
	
	return Optional.empty();
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:17,代码来源:EEntityService.java


示例2: tabCompleter

import org.spongepowered.api.entity.EntityType; //导入依赖的package包/类
@Override
public Collection<String> tabCompleter(final CommandSource source, final List<String> args) throws CommandException {
	if (args.size() == 1) {
		List<String> suggests = new ArrayList<String>();
		this.plugin.getGame().getRegistry().getAllForMinecraft(EntityType.class).stream()
			.filter(entity -> !entity.equals(EntityTypes.UNKNOWN) && 
					(Creature.class.isAssignableFrom(entity.getEntityClass()) || Hostile.class.isAssignableFrom(entity.getEntityClass())))
			.forEach(entity -> suggests.add(entity.getId().replaceAll("minecraft:", "")));
		this.plugin.getGame().getRegistry().getAllOf(EntityType.class).stream()
			.filter(entity -> !entity.equals(EntityTypes.UNKNOWN) && 
					(Creature.class.isAssignableFrom(entity.getEntityClass()) || Hostile.class.isAssignableFrom(entity.getEntityClass())))
			.forEach(entity -> suggests.add(entity.getId()));
		this.plugin.getEverAPI().getManagerService().getEntity().getAll()
				.forEach(entity -> suggests.add(entity.getId()));
		
		return suggests;
	} else if (args.size() == 2){
		Arrays.asList("1", String.valueOf(this.limit));
	}
	return Arrays.asList();
}
 
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:22,代码来源:EESpawnMob.java


示例3: commandButcherType

import org.spongepowered.api.entity.EntityType; //导入依赖的package包/类
private CompletableFuture<Boolean> commandButcherType(EPlayer player, EntityType type, int radius) {
	Collection<Entity> list = player.getWorld().getEntities(entity -> 
		entity.getType().equals(type) && entity.getLocation().getPosition().distance(player.getLocation().getPosition()) <= radius);
	
	if (!list.isEmpty()){
		list.forEach(entity -> entity.remove());
		EEMessages.BUTCHER_TYPE_RADIUS.sender()
			.replace("{radius}", String.valueOf(radius))
			.replace("{count}", String.valueOf(list.size()))
			.replace("{entity}", getButtomEntity(type))
			.sendTo(player);
		return CompletableFuture.completedFuture(true);
	} else {
		EEMessages.BUTCHER_NOENTITY.sendTo(player);
		return CompletableFuture.completedFuture(false);
	}
}
 
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:18,代码来源:EEButcherType.java


示例4: onEntityDamage

import org.spongepowered.api.entity.EntityType; //导入依赖的package包/类
@Listener
public void onEntityDamage(DamageEntityEvent event, @Root EntityDamageSource dmgSource) {
    if(dmgSource.getSource() instanceof Player) {
        Player player = (Player)dmgSource.getSource();
        EntityType entityType = event.getTargetEntity().getType();
        String entityId = entityType.getId();

        PermHandler ph = PermHandler.getInstance();

        if (!ph.checkPerm(player, "protectionperms.entity.damage." + entityId + ".deal")) {
            event.setCancelled(true);
            player.sendMessage(ChatTypes.ACTION_BAR,
                    Text.of(TextColors.RED, "You don't have permission to damage " + entityType.getName() + "s!"));
        }
    }
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:17,代码来源:DamageEntityListener.java


示例5: onInteractEntitySecondaryMain

import org.spongepowered.api.entity.EntityType; //导入依赖的package包/类
@Listener
public void onInteractEntitySecondaryMain(InteractEntityEvent.Secondary event, @Root Player player) {
    Optional<ItemStack> itemStackOptional = player.getItemInHand(event.getHandType());
    if(itemStackOptional.isPresent()) {

        EntityType entityType = event.getTargetEntity().getType();
        String entityId = entityType.getId();

        ItemType itemType = itemStackOptional.get().getType();
        String itemId = itemType.getId();

        PermHandler ph = PermHandler.getInstance();

        if (!ph.checkPerm(player, "protectionperms.item.use." + itemId + ".on." + entityId + ".primary")) {
            event.setCancelled(true);
            player.sendMessage(ChatTypes.ACTION_BAR,
                    Text.of(TextColors.RED, "You don't have permission to secondary use " + itemType.getName() + " on " + entityType.getName() + "s!"));
        }
    }
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:21,代码来源:SecondaryEntityListener.java


示例6: onInteractEntityPrimaryMain

import org.spongepowered.api.entity.EntityType; //导入依赖的package包/类
@Listener
public void onInteractEntityPrimaryMain(InteractEntityEvent.Primary event, @Root Player player) {
    Optional<ItemStack> itemStackOptional = player.getItemInHand(event.getHandType());
    if(itemStackOptional.isPresent()) {

        EntityType entityType = event.getTargetEntity().getType();
        String entityId = entityType.getId();

        ItemType itemType = itemStackOptional.get().getType();
        String itemId = itemType.getId();

        PermHandler ph = PermHandler.getInstance();

        if (!ph.checkPerm(player, "protectionperms.item.use." + itemId + ".on." + entityId + ".primary")) {
            event.setCancelled(true);
            player.sendMessage(ChatTypes.ACTION_BAR,
                    Text.of(TextColors.RED, "You don't have permission to primary use " + itemType.getName() + " on " + entityType.getName() + "s!"));
        }
    }
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:21,代码来源:PrimaryEntityListener.java


示例7: deserialize

import org.spongepowered.api.entity.EntityType; //导入依赖的package包/类
@Override
public NPCguard deserialize(TypeToken<?> arg0, ConfigurationNode cfg) throws ObjectMappingException {
	NPCguard npc = new NPCguard(UUID.fromString(cfg.getNode("uuid").getString()));
	InvPrep ip = new InvPrep();
	
	ip.items = cfg.getNode("items").getValue(tokenListStockItem);
	if (ip.items==null) ip.items = new LinkedList<>();
	npc.setPreparator(ip);
    npc.setLoc(cfg.getNode("location").getValue(tokenLocationWorld));
    npc.setRot(new Vector3d(0.0, cfg.getNode("rotation").getDouble(0.0), 0.0 ));
    npc.setNpcType((EntityType)FieldResolver.getFinalStaticByName(EntityTypes.class, cfg.getNode("entitytype").getString("VILLAGER")));
    npc.setVariant(cfg.getNode("variant").getString("NONE"));
	npc.setDisplayName(TextSerializers.FORMATTING_CODE.deserialize(cfg.getNode("displayName").getString("VillagerShop")));
	String tmp = cfg.getNode("playershop").getString(null);
	if (tmp != null && !tmp.isEmpty())
		npc.playershopholder=UUID.fromString(tmp);
	npc.playershopcontainer=cfg.getNode("stocklocation").getValue(tokenLocationWorld);
	return npc;
}
 
开发者ID:DosMike,项目名称:VillagerShops,代码行数:20,代码来源:NPCguardSerializer.java


示例8: execute

import org.spongepowered.api.entity.EntityType; //导入依赖的package包/类
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException
{
	int amount = ctx.<Integer> getOne("amount").get();
	EntityType type = ctx.<EntityType> getOne("mob").get();

	if (src instanceof Player)
	{
		Player player = (Player) src;

		if (!Living.class.isAssignableFrom(type.getEntityClass()))
		{
			player.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "The mob type you inputted is not a living entity."));
			return CommandResult.success();
		}

		this.spawnEntity(getSpawnLocFromPlayerLoc(player).add(0, 1, 0), player, type, amount);
		player.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Spawned mob(s)!"));
	}
	else
	{
		src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Must be an in-game player to use /mobspawn!"));
	}

	return CommandResult.success();
}
 
开发者ID:hsyyid,项目名称:EssentialCmds,代码行数:26,代码来源:MobSpawnExecutor.java


示例9: execute

import org.spongepowered.api.entity.EntityType; //导入依赖的package包/类
@Override
@Nonnull
public CommandResult execute(@Nonnull CommandSource src, @Nonnull CommandContext args)
        throws CommandException {

    SurvivalGame survivalGame = (SurvivalGame) getOrThrow(args, CommandKeys.SURVIVAL_GAME);
    Vector3d vector1 = (Vector3d) getOrThrow(args, CommandKeys.VECTOR1);
    Vector3d vector2 = (Vector3d) getOrThrow(args, CommandKeys.VECTOR2);
    EntityType entityType = (EntityType) getOrThrow(args, CommandKeys.ENTITY_TYPE);
    Integer spawnRatePerMinute = (Integer) getOrThrow(args, CommandKeys.SPAWN_RATE_PER_MINUTE);

    MobSpawnArea mobSpawnArea = new MobSpawnArea();
    mobSpawnArea.addBoundaryVector(vector1);
    mobSpawnArea.addBoundaryVector(vector2);
    mobSpawnArea.setEntityType(entityType);
    mobSpawnArea.setSpawnRatePerMinute(spawnRatePerMinute);

    survivalGame.getConfig().getMobSpawnAreas().add(mobSpawnArea);

    sendSuccess(src, "Added mob-spawn-area");
    return CommandResult.success();
}
 
开发者ID:m0pt0pmatt,项目名称:SurvivalGames,代码行数:23,代码来源:AddMobSpawnAreaCommand.java


示例10: onEntityMovement

import org.spongepowered.api.entity.EntityType; //导入依赖的package包/类
@Listener
public void onEntityMovement(MoveEntityEvent e) {
	Transform<World> f = e.getFromTransform();
	Transform<World> t = e.getToTransform();
	if (f.getLocation().getBlockX() == t.getLocation().getBlockX() &&
			t.getLocation().getBlockZ() == f.getLocation().getBlockZ()) {
		return;
	}
	int x = t.getLocation().getBlockX();
	int z = t.getLocation().getBlockZ();
	if (x == (x >> 4) << 4 && z == (z >> 4) << 4) {
		EntityType type = e.getTargetEntity().getType();
		if (type == EntityTypes.PLAYER) {
			Citizen citizen = playerService.getCitizen(e.getTargetEntity().getUniqueId());
			ClaimedArea nextArea = worldService.getClaimedArea(t.getLocation());
			worldService.handleChunkChange(citizen, nextArea);
		}
	}
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:20,代码来源:Movement.java


示例11: initialize

import org.spongepowered.api.entity.EntityType; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void initialize() {
    Player player = getPlayer();
    CreatingJob parent = getParent();
    JobManager jobManager = JobsLite.getJobManager();
    if (jobManager.createJob((String) parent.getData(DataTypes.NAME).getValue(), (String) parent.getData(DataTypes.DISPLAY_NAME).getValue(),
            (Integer) parent.getData(DataTypes.MAX_LEVEL).getValue(), (TextColor) parent.getData(DataTypes.COLOR).getValue(),
            (Boolean) parent.getData(DataTypes.SILK_TOUCH).getValue(), (Boolean) parent.getData(DataTypes.WORLD_GEN).getValue(),
            (Boolean) parent.getData(DataTypes.BLOCK_DATA).getValue(),
            (HashMap<BlockState, Reward>) parent.getData(DataTypes.BREAK_REWARDS).getValue(),
            (HashMap<BlockState, Reward>) parent.getData(DataTypes.PLACE_REWARDS).getValue(),
            (HashMap<EntityType, Reward>) parent.getData(DataTypes.KILL_REWARDS).getValue())) {
        getParent().cancel();
        player.sendMessage(messages.getMessage("creation.success"));
    } else {
        player.sendMessage(messages.getMessage("creation.fail"));
    }
}
 
开发者ID:Flibio,项目名称:JobsLite,代码行数:19,代码来源:FinalTask.java


示例12: spawn

import org.spongepowered.api.entity.EntityType; //导入依赖的package包/类
private Optional<Entity> spawn(EntityType entityType, Entity causeAndLocation) {
	Location<World> location = causeAndLocation.getLocation();
	EntityUniverse entityUniverse = location.getExtent();
	Optional<Entity> optionalEntity = entityUniverse.createEntity(entityType, location.getPosition());
	if (optionalEntity.isPresent()) {
		Entity newEntity = optionalEntity.get();
		Cause cause = Cause.source(EntitySpawnCause.builder().entity(causeAndLocation).type(SpawnTypes.PLUGIN).build()).build();
		boolean isSpawned = entityUniverse.spawnEntity(newEntity, cause);
		if (!isSpawned) {
			logger.error("Could not spawn new Entity: " + entityType.getName());
			return Optional.empty();
		}
		return Optional.of(newEntity);
	} else {
		logger.error("Could not create new Entity: " + entityType.getName());
		return Optional.empty();
	}
}
 
开发者ID:vorburger,项目名称:SwissKnightMinecraft,代码行数:19,代码来源:LearningPlugin.java


示例13: onMobDamage

import org.spongepowered.api.entity.EntityType; //导入依赖的package包/类
private void onMobDamage(DamageEntityEvent event, Entity target)
{
    Entity entitySource = getEntitySource(event);
    Player playerSource = null;
    if (entitySource instanceof Player)
    {
        playerSource = ((Player) entitySource);
    }

    List<Region> regionsAt = manager.getRegionsAt(target.getLocation());

    Tristate defaultTo = this.checkSetting(event, playerSource, regionsAt, () -> entityDamageAll, s -> s.entityDamage.all, UNDEFINED);

    if (entitySource instanceof Living)
    {
        defaultTo = this.checkSetting(event, playerSource, regionsAt, () -> entityDamageLiving, s -> s.entityDamage.byLiving, defaultTo);
    }
    if (entitySource != null)
    {
        EntityType type = entitySource.getType();
        this.checkSetting(event, null, regionsAt, () -> null, s -> s.entityDamage.byEntity.getOrDefault(type, UNDEFINED), defaultTo);
    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:24,代码来源:SettingsListener.java


示例14: invasion

import org.spongepowered.api.entity.EntityType; //导入依赖的package包/类
@Command(desc = "Spawns a mob next to every player on the server")
public void invasion(CommandSource context, String mob)
{
    EntityType entityType = em.mob(mob, context.getLocale());
    if (entityType == null)
    {
        i18n.send(context, MessageType.NEGATIVE, "EntityType {input} not found", mob);
        return;
    }
    Sponge.getCauseStackManager().pushCause(context);
    for (Player player : Sponge.getServer().getOnlinePlayers())
    {
        Optional<BlockRayHit<World>> end =
            BlockRay.from(player).stopFilter(BlockRay.onlyAirFilter())
                .distanceLimit(module.getConfig().command.invasion.distance).build().end();
        if (end.isPresent())
        {
            Location<World> location = end.get().getLocation();
            Entity entity = location.getExtent().createEntity(entityType, location.getPosition());
            location.getExtent().spawnEntity(entity);
        }
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:24,代码来源:InvasionCommand.java


示例15: reload

import org.spongepowered.api.entity.EntityType; //导入依赖的package包/类
public static void reload() {
    effects.clear();
    ModuleConfig config = Modules.BLOOD.get().getConfig().get();
    for (EntityType type : Sponge.getRegistry().getAllOf(CatalogTypes.ENTITY_TYPE)) {
        CommentedConfigurationNode node = config.get().getNode("types", type.getId());
        try {
            BloodEffect effect = node.getValue(TypeToken.of(BloodEffect.class));
            if (effect == null) {
                continue;
            }
            effects.put(type, effect);
        } catch (ObjectMappingException e) {
            ErrorLogger.log(e, "Failed to deserialize bloodeffect for " + type.getId() + " (" + e.getMessage() + ")");
        }
    }
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:17,代码来源:BloodEffects.java


示例16: getTypeId

import org.spongepowered.api.entity.EntityType; //导入依赖的package包/类
public static int getTypeId(EntityType type) {
    if(type instanceof SpongeEntityType) {
        return ((SpongeEntityType)type).entityTypeId;
    } else {
        throw new RuntimeException("Invalid EntityType");
    }
}
 
开发者ID:Guichaguri,项目名称:PacketControl,代码行数:8,代码来源:PacketUtils.java


示例17: setEntityType

import org.spongepowered.api.entity.EntityType; //导入依赖的package包/类
@Override
public void setEntityType(EntityType type) {
    this.spongeType = type;

    if(type == EntityTypes.LIGHTNING) {
        this.type = 1;
    } else {
        this.type = PacketUtils.getTypeId(type);
    }
}
 
开发者ID:Guichaguri,项目名称:PacketControl,代码行数:11,代码来源:MixinPacketSpawnGlobalEntity.java


示例18: checkEntityType

import org.spongepowered.api.entity.EntityType; //导入依赖的package包/类
public static boolean checkEntityType(EntityType etype, ScriptEvent.ScriptEventData data, Action<String> error, String tname) {
    if (!data.switches.containsKey(tname)) {
        return true;
    }
    for (AbstractTagObject ato : ListTag.getFor(error, data.switches.get(tname)).getInternal()) {
        if (EntityTypeTag.getFor(error, ato).getInternal().equals(etype)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:12,代码来源:D2SpongeEventHelper.java


示例19: getFor

import org.spongepowered.api.entity.EntityType; //导入依赖的package包/类
public static EntityTypeTag getFor(Action<String> error, String text) {
    Optional<EntityType> optItemType = Sponge.getRegistry().getType(EntityType.class, text);
    if (!optItemType.isPresent()) {
        error.run("Invalid EntityTypeTag input!");
        return null;
    }
    return new EntityTypeTag(optItemType.get());
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:9,代码来源:EntityTypeTag.java


示例20: EFireType

import org.spongepowered.api.entity.EntityType; //导入依赖的package包/类
public EFireType(String identifier, String name, Set<EntityType> entities, Set<BlockType> blocks, Set<ItemType> items) {
	this.identifier = identifier.toLowerCase();
	this.name = name.toUpperCase();
	
	this.entities = entities;
	this.blocks = blocks;
	this.items = items;
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:9,代码来源:EFireType.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AnnotationModel类代码示例发布时间:2022-05-21
下一篇:
Java OnTabSelectListener类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap