本文整理汇总了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()));
});
}
示例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);
}
示例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();
}
示例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();
}
示例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);
}
示例6: SkullTypeRegistryModule
import org.spongepowered.api.data.type.SkullTypes; //导入依赖的package包/类
private SkullTypeRegistryModule() {
super(SkullTypes.class);
}
示例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?)");
}
}
}
示例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());
}