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

Java SkullTypes类代码示例

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

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



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

示例1: of

import org.spongepowered.api.data.type.SkullTypes; //导入依赖的package包/类
/**
 * Gets a SkinRecord that has been assigned to this {@link ItemStack}.
 *
 * @param itemStack The {@link ItemStack} to get the {@link SkinRecord} of
 * @return The {@link SkinRecord}, if found, or {@link Optional#empty()} instead.
 */
public static Optional<SkinRecord> of(ItemStack itemStack) {
    if(itemStack.getItem() != ItemTypes.SKULL
            || itemStack.get(Keys.SKULL_TYPE).orElse(SkullTypes.SKELETON) != SkullTypes.PLAYER)
        return Optional.empty();

    return itemStack.get(Keys.REPRESENTED_PLAYER).flatMap(profile -> {
        Collection<ProfileProperty> properties = profile.getPropertyMap().get(PROPERTY_TEXTURES);

        if(properties.size() != 1)
            return Optional.empty();

        ProfileProperty property = properties.iterator().next();
        Optional<String> signature = property.getSignature();

        if(!signature.isPresent())
            return Optional.empty();

        return Optional.of(new SkinRecord(profile.getUniqueId(), property.getValue(), signature.get()));
    });
}
 
开发者ID:Limeth,项目名称:MineskinSponge,代码行数:27,代码来源:SkinRecord.java


示例2: headchange

import org.spongepowered.api.data.type.SkullTypes; //导入依赖的package包/类
@Command(alias = "skullchange", desc = "Changes a skull to a players skin.")
@Restricted(value = Player.class, msg = "This will you only give headaches!")
public void headchange(Player context, @Optional String name) throws ExecutionException, InterruptedException
{
    ItemStack item = context.getItemInHand(HandTypes.MAIN_HAND).orElse(null);
    if (item == null || item.getType() != SKULL)
    {
        i18n.send(context, NEGATIVE, "You are not holding a head.");
        return;
    }

    item.offer(Keys.SKULL_TYPE, SkullTypes.PLAYER);
    item.offer(Keys.REPRESENTED_PLAYER, Sponge.getServer().getGameProfileManager().get(name).get());

    context.setItemInHand(HandTypes.MAIN_HAND, item);
    i18n.send(context, POSITIVE, "You now hold {user}'s head in your hands!", name);
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:18,代码来源:ItemModifyCommands.java


示例3: getNullGameProfile

import org.spongepowered.api.data.type.SkullTypes; //导入依赖的package包/类
private static GameProfile getNullGameProfile()
{
    // noinspection ConstantConditions
    return ItemStack.builder()
            .itemType(ItemTypes.SKULL).quantity(1)
            .keyValue(Keys.SKULL_TYPE, SkullTypes.PLAYER).build()
            .getOrCreate(RepresentedPlayerData.class).get().owner().get();
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:9,代码来源:VirtualChestItemStackSerializer.java


示例4: createPlayerHead

import org.spongepowered.api.data.type.SkullTypes; //导入依赖的package包/类
public static ItemStack createPlayerHead(GameProfile profile) {
	ItemStack skull = ItemStack.of(ItemTypes.SKULL, 1);
	skull.offer(Keys.SKULL_TYPE, SkullTypes.PLAYER);
	skull.offer(Keys.REPRESENTED_PLAYER, profile);
	return ItemStack.builder()
	        .itemType(ItemTypes.SKULL)
	        .keyValue(Keys.SKULL_TYPE, SkullTypes.PLAYER)
	        .keyValue(Keys.REPRESENTED_PLAYER, profile)
	        .build();
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:11,代码来源:UtilsItemStack.java


示例5: onEvent

import org.spongepowered.api.data.type.SkullTypes; //导入依赖的package包/类
@Listener
public void onEvent(DestructEntityEvent.Death event, @First Player killer) {
    if (!(event.getTargetEntity() instanceof Player)) {
        return;
    }
    Player dead = (Player) event.getTargetEntity();
    ItemStack itemStack = ItemStack.builder()
            .itemType(ItemTypes.SKULL)
            .quantity(1)
            .add(Keys.SKULL_TYPE, SkullTypes.PLAYER)
            .add(Keys.REPRESENTED_PLAYER, dead.getProfile())
            .build();
    killer.getInventory().offer(itemStack);
}
 
开发者ID:liachmodded,项目名称:UHC-Reloaded,代码行数:15,代码来源:HumanoidDropHeadHandler.java


示例6: SkullTypeRegistryModule

import org.spongepowered.api.data.type.SkullTypes; //导入依赖的package包/类
private SkullTypeRegistryModule() {
    super(SkullTypes.class);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:4,代码来源:SkullTypeRegistryModule.java


示例7: run

import org.spongepowered.api.data.type.SkullTypes; //导入依赖的package包/类
@Override
public void run() {
    for (Map.Entry<RecentPurchaseSignPosition, RecentPayment> entry : paymentMap.entrySet()) {
        Location<World> location = SpongeSerializedBlockLocation.toSponge(entry.getKey().getLocation());

        Optional<TileEntity> entity = location.getTileEntity();
        if (entity.isPresent() && entity.get().supports(SignData.class)) {
            SignData signData = entity.get().getOrCreate(SignData.class).get();
            ListValue<Text> lines = signData.lines();

            if (entry.getValue() != null) {
                lines.set(0, Text.EMPTY);
                lines.set(1, Text.of(entry.getValue().getPlayer().getName()));

                NumberFormat format = NumberFormat.getCurrencyInstance(Locale.US);
                format.setCurrency(Currency.getInstance(entry.getValue().getCurrency().getIso4217()));

                lines.set(2, Text.of(format.format(entry.getValue().getAmount())));
                lines.set(3, Text.EMPTY);
            } else {
                for (int i = 0; i < 4; i++) {
                    lines.set(i, Text.EMPTY);
                }
            }

            entity.get().offer(lines);

            Location<World> supportedBy = location.getRelative(Direction.UP);

            Optional<Skull> skullOptional = findSkull(supportedBy);
            if (skullOptional.isPresent()) {
                Skull skull = skullOptional.get();
                if (!skull.supports(Keys.REPRESENTED_PLAYER)) {
                    skull.offer(Keys.SKULL_TYPE, SkullTypes.PLAYER);
                }
                GameProfile profile = entry.getValue() != null ?
                        resolvedProfiles.getOrDefault(entry.getValue().getPlayer().getName(), resolvedProfiles.get("MHF_Question")) :
                        resolvedProfiles.get("MHF_Question");
                if (profile != null) {
                    skull.offer(Keys.REPRESENTED_PLAYER, profile);
                }
            }
        } else {
            plugin.getLogger().error("Location " + entry.getKey() + " doesn't have a tile entity! (Sign missing?)");
        }
    }
}
 
开发者ID:BuycraftPlugin,项目名称:BuycraftX,代码行数:48,代码来源:SignUpdateApplication.java


示例8: apply

import org.spongepowered.api.data.type.SkullTypes; //导入依赖的package包/类
/**
 * Applies this skin to the specified {@link ItemStack}.
 *
 * @param itemStack The {@link ItemStack} to apply the skin to
 */
public void apply(ItemStack itemStack) {
    itemStack.offer(Keys.SKULL_TYPE, SkullTypes.PLAYER);
    itemStack.offer(Keys.REPRESENTED_PLAYER, getProfile());
}
 
开发者ID:Limeth,项目名称:MineskinSponge,代码行数:10,代码来源:SkinRecord.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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