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


Java TextSerializers类代码示例

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


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

示例1: BlockCase

import org.spongepowered.api.text.serializer.TextSerializers; //导入依赖的package包/类
public BlockCase(ConfigurationNode node) {
    super(node);
    try {
        ConfigurationNode location_node = node.getNode("LOCATION");
        ConfigurationNode hologram_node = node.getNode("HOLOGRAM");
        ConfigurationNode start_preview_on_left_click_node = node.getNode("START_PREVIEW_ON_LEFT_CLICK");
        if (location_node.isVirtual()) {
            throw new RuntimeException("LOCATION node does not exist!");
        }
        location = Utils.parseLocation(location_node);
        if (!hologram_node.isVirtual()) {
            hologram = Optional.of(TextSerializers.FORMATTING_CODE.deserialize(hologram_node.getString()));
        }
        created_hologram = Utils.tryCreateHologram(location, hologram);
        start_preview_on_left_click = start_preview_on_left_click_node.getBoolean(false);
    } catch (Exception e) {
        GWMCrates.getInstance().getLogger().warn("Exception creating Block Case!", e);
    }
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:20,代码来源:BlockCase.java

示例2: execute

import org.spongepowered.api.text.serializer.TextSerializers; //导入依赖的package包/类
@Override public CommandResult execute(CommandSource commandSource, CommandContext commandContext) throws CommandException {
    if(commandContext.getOne("type").isPresent()) {
        String type = commandContext.<String>getOne("type").get();
        VirtualCrate virtualCrate = HuskyCrates.instance.getCrateUtilities().getVirtualCrate(type);
        int quantity = commandContext.getOne("quantity").isPresent() ? commandContext.<Integer>getOne("quantity").get() : 1;
        if (virtualCrate == null) {
            commandSource.sendMessage(Text.of("Invalid crate id: " + type + ". Please check your config."));
            return CommandResult.empty();
        }
        commandSource.sendMessage(Text.of("Gave everyone " + quantity + " vkeys."));
        virtualCrate.givePlayersVirtualKeys(Sponge.getServer().getOnlinePlayers(),quantity);
        for(Player e: Sponge.getServer().getOnlinePlayers()){
            if(commandSource != e) {
                e.sendMessage(Text.of(TextColors.GREEN,"You received " + quantity + " virtual keys for a ", TextSerializers.FORMATTING_CODE.deserialize(virtualCrate.displayName),"."));
            }
        }
    }else{
        commandSource.sendMessage(Text.of("Usage: /crate vkeyall <id> [count]"));
    }
    return CommandResult.success();
}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:22,代码来源:VirtualKeyAll.java

示例3: execute

import org.spongepowered.api.text.serializer.TextSerializers; //导入依赖的package包/类
@Override public CommandResult execute(CommandSource commandSource, CommandContext commandContext) throws CommandException {
    if (!(commandSource instanceof Player)) {
        commandSource.sendMessage(Text.of("You need to be in game or specify a player for this command to work."));
        return CommandResult.empty();
    }
    Player plr = (Player)commandSource;
    if(!plr.getItemInHand(HandTypes.MAIN_HAND).isPresent()){
        commandSource.sendMessage(Text.of("You must be holding an item to deposit a key."));
        return CommandResult.empty();
    }
    ItemStack key = plr.getItemInHand(HandTypes.MAIN_HAND).get();
    if(HuskyCrates.instance.crateUtilities.vcFromKey(key) == null){
        commandSource.sendMessage(Text.of(TextColors.RED,"Not a valid key."));
        return CommandResult.empty();
    }
    VirtualCrate virtualCrate = HuskyCrates.instance.crateUtilities.vcFromKey(plr.getItemInHand(HandTypes.MAIN_HAND).get());
    int keyCount = key.getQuantity();
    plr.setItemInHand(HandTypes.MAIN_HAND,null);
    virtualCrate.giveVirtualKeys(plr,keyCount);
    //commandSource.sendMessage(Text.of(TextColors.GREEN,"Successfully deposited " + keyCount + " ", TextSerializers.FORMATTING_CODE.deserialize(virtualCrate.displayName),TextColors.GREEN," Key(s)."));
    commandSource.sendMessage(TextSerializers.FORMATTING_CODE.deserialize(
            virtualCrate.getLangData().formatter(virtualCrate.getLangData().depositSuccess,null,plr,virtualCrate,null,null,keyCount)
    ));
    return CommandResult.success();
}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:26,代码来源:DepositKey.java

示例4: listRewards

import org.spongepowered.api.text.serializer.TextSerializers; //导入依赖的package包/类
public void listRewards(Player player, VirtualCrate vc){
    if(!vc.showRewardsOnLeft) return;
    /* Home */
    StateContainer test = new StateContainer();
    Page.PageBuilder rewards = Page.builder();
    rewards.setAutoPaging(true);
    rewards.setTitle(TextSerializers.FORMATTING_CODE.deserialize(vc.displayName + " Rewards"));
    rewards.setEmptyStack(ItemStack.builder()
            .itemType(ItemTypes.STAINED_GLASS_PANE)
            .add(Keys.DYE_COLOR, DyeColors.BLACK)
            .add(Keys.DISPLAY_NAME, Text.of(TextColors.DARK_GRAY, "HuskyCrates")).build());
    for(Object[] e : vc.getItemSet()){
        CrateReward rew = (CrateReward)e[1];
        ItemStack item = rew.getDisplayItem().copy();
        if(vc.showProbability) {
            ArrayList<Text> lore = (ArrayList<Text>) item.getOrElse(Keys.ITEM_LORE, new ArrayList<>());
            lore.add(Text.of());

            lore.add(Text.of(TextColors.GRAY, TextStyles.ITALIC, "Win Probability: " + BigDecimal.valueOf((rew.getChance() / vc.getMaxProb()) * 100d).setScale(1, RoundingMode.HALF_UP).toString() + "%"));
            item.offer(Keys.ITEM_LORE, lore);
        }
        rewards.addElement(new Element(item));
    }
    test.setInitialState(rewards.build("rewards"));
    test.launchFor(player);
}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:27,代码来源:HuskyCrates.java

示例5: getCrateKey

import org.spongepowered.api.text.serializer.TextSerializers; //导入依赖的package包/类
/***
 * Retrieve the crate item
 * @since 0.10.2
 * @return the ItemStack with the keys.
 */
public ItemStack getCrateKey(int quantity){
    ItemStack key = ItemStack.builder()
            .itemType(keyType)
            .quantity(quantity)
            .add(Keys.DISPLAY_NAME, TextSerializers.FORMATTING_CODE.deserialize(displayName + " Key")).build();
    ArrayList<Text> itemLore = new ArrayList<>();
    itemLore.add(Text.of(TextColors.WHITE, "A key for a ", TextSerializers.FORMATTING_CODE.deserialize(displayName), TextColors.WHITE, "."));
    itemLore.add(Text.of(TextColors.DARK_GRAY, "HuskyCrates"));
    key.offer(Keys.ITEM_LORE, itemLore);
    if(keyDamage != null){
        key = ItemStack.builder().fromContainer(key.toContainer().set(DataQuery.of("UnsafeDamage"),keyDamage)).build();
    }
    String keyUUID = registerKey(quantity);
    if(keyUUID == null){
        HuskyCrates.instance.logger.error("Throwing NullPointerException: Key failed to register.");
        throw new NullPointerException();
    }
    return ItemStack.builder().fromContainer(key.toContainer().set(DataQuery.of("UnsafeData","crateID"),id).set(DataQuery.of("UnsafeData","keyUUID"),keyUUID)).build();//

}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:26,代码来源:VirtualCrate.java

示例6: getCrateWand

import org.spongepowered.api.text.serializer.TextSerializers; //导入依赖的package包/类
/***
 * Retrieve the crate item
 * @since 1.2.1
 * @return the ItemStack with the keys.
 */
public ItemStack getCrateWand(){
    ItemStack key = ItemStack.builder()
            .itemType(ItemTypes.BLAZE_ROD)
            .add(Keys.DISPLAY_NAME, TextSerializers.FORMATTING_CODE.deserialize(displayName + " Wand")).build();
    ArrayList<Text> itemLore = new ArrayList<>();
    itemLore.add(Text.of(TextColors.WHITE, "A wand for a ", TextSerializers.FORMATTING_CODE.deserialize(displayName), TextColors.WHITE, "."));
    itemLore.add(Text.of(TextColors.DARK_GRAY, "HuskyCrates"));
    key.offer(Keys.ITEM_LORE, itemLore);
    if(keyDamage != null){
        key = ItemStack.builder().fromContainer(key.toContainer().set(DataQuery.of("UnsafeDamage"),keyDamage)).build();
    }

    return ItemStack.builder().fromContainer(key.toContainer().set(DataQuery.of("UnsafeData","crateID"),id)).build();//

}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:21,代码来源:VirtualCrate.java

示例7: open

import org.spongepowered.api.text.serializer.TextSerializers; //导入依赖的package包/类
public synchronized static void open(String dbHost, int dbPort, String dbUser, String dbPass, String dbName, String dbPrefix){
	SQLTYPE = AurionsVoteListener.GetInstance().SQLType;
	TableTotal = AurionsVoteListener.GetInstance().dbTableTotal;
	TableQueue = AurionsVoteListener.GetInstance().dbTableQueue;
	SQLFILE = AurionsVoteListener.GetInstance().SQLFile;
	ConfigDir = AurionsVoteListener.GetInstance().defaultConfig;
	if(SQLTYPE.equalsIgnoreCase("MySQL")){
		connection = MySqlTask.open(dbHost, dbPort, dbUser, dbPass, dbName, dbPrefix);
	}else if(SQLTYPE.equalsIgnoreCase("File")){
		connection = SQLTask.open(SQLFILE,ConfigDir.toString(),dbPrefix);
	}
	else{
		Sponge.getGame().getServer().getConsole().sendMessage(TextSerializers.formattingCode('�').deserialize("[AurionsVoteListener] �cPlease choose between mysql and file in the config file "));
	}
	
}
 
开发者ID:Mineaurion,项目名称:AurionVoteListener,代码行数:17,代码来源:SwitchSQL.java

示例8: toTemplate

import org.spongepowered.api.text.serializer.TextSerializers; //导入依赖的package包/类
private TextTemplate toTemplate(String text)
{
    List<TextRepresentable> parts = new LinkedList<>();
    Matcher matcher = PLACEHOLDER_PATTERN.matcher(text);
    int lastIndex = 0;
    while (matcher.find())
    {
        parts.add(TextSerializers.PLAIN.deserialize(text.substring(lastIndex, matcher.start())));
        parts.add(TextTemplate.arg(text.substring(matcher.start() + 1, matcher.end() - 1)).build());
        lastIndex = matcher.end();
    }
    if (lastIndex < text.length())
    {
        parts.add(Text.builder(text.substring(lastIndex)).build());
    }
    return TextTemplate.of(ARG_BOUNDARY, ARG_BOUNDARY, parts.toArray());
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:18,代码来源:VirtualChestPlaceholderManager.java

示例9: onClientLogin

import org.spongepowered.api.text.serializer.TextSerializers; //导入依赖的package包/类
@Listener(order = Order.FIRST)
@IsCancelled(Tristate.UNDEFINED)
public void onClientLogin(ClientConnectionEvent.Login e) {
    /* Called when the player starts logging into the server.
       At this point, the users data should be present and loaded.
       Listening on LOW priority to allow plugins to further modify data here. (auth plugins, etc.) */

    final GameProfile player = e.getProfile();

    if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
        this.plugin.getLog().info("Processing login event for " + player.getUniqueId() + " - " + player.getName());
    }

    final User user = this.plugin.getUserManager().getIfLoaded(this.plugin.getUuidCache().getUUID(player.getUniqueId()));

    /* User instance is null for whatever reason. Could be that it was unloaded between asyncpre and now. */
    if (user == null) {
        this.deniedLogin.add(player.getUniqueId());

        this.plugin.getLog().warn("User " + player.getUniqueId() + " - " + player.getName() + " doesn't have data pre-loaded. - denying login.");
        e.setCancelled(true);
        e.setMessageCancelled(false);
        //noinspection deprecation
        e.setMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager())));
    }
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:27,代码来源:SpongeConnectionListener.java

示例10: execute

import org.spongepowered.api.text.serializer.TextSerializers; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
	RankTag defaultTag = RankTag.getDefault().get();

	if (!args.hasAny("tag")) {
		src.sendMessage(Text.of(TextColors.GREEN, "Current Tag: ", TextColors.RESET, defaultTag.getTag()));
		src.sendMessage(Text.of(Text.of(TextColors.GREEN, "Update Tag: ", TextColors.YELLOW, "/tag rank default <tag>")));

		return CommandResult.success();
	}
	String tag = args.<String>getOne("tag").get();

	defaultTag.setTag(tag);

	src.sendMessage(Text.of(TextColors.DARK_GREEN, "Tag changed to ", TextSerializers.FORMATTING_CODE.deserialize(tag)));

	return CommandResult.success();
}
 
开发者ID:trentech,项目名称:SimpleTagsNations,代码行数:19,代码来源:CMDRankDefault.java

示例11: execute

import org.spongepowered.api.text.serializer.TextSerializers; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
	NationTag defaultTag = NationTag.getDefault().get();

	if (!args.hasAny("tag")) {
		src.sendMessage(Text.of(TextColors.GREEN, "Current Tag: ", TextColors.RESET, defaultTag.getTag()));
		src.sendMessage(Text.of(TextColors.GREEN, "Update Tag: ", TextColors.YELLOW, "/tag nation default <tag>"));

		return CommandResult.success();
	}
	String tag = args.<String>getOne("tag").get();

	defaultTag.setTag(tag);

	src.sendMessage(Text.of(TextColors.DARK_GREEN, "Tag changed to ", TextSerializers.FORMATTING_CODE.deserialize(tag)));

	return CommandResult.success();
}
 
开发者ID:trentech,项目名称:SimpleTagsNations,代码行数:19,代码来源:CMDNationDefault.java

示例12: onPlayerChat

import org.spongepowered.api.text.serializer.TextSerializers; //导入依赖的package包/类
@Listener(order = Order.LATE)
public void onPlayerChat(MessageChannelEvent.Chat e, @First Player p)
{
	Nation nation = DataHandler.getNationOfPlayer(p.getUniqueId());
	if (nation == null)
	{
		return;
	}
	MessageChannel chan = MessageChannel.TO_ALL;
	Optional<MessageChannel> channel = e.getChannel();
	if (channel.isPresent())
	{
		chan = channel.get();
	}
	
	if (chan.equals(MessageChannel.TO_ALL) && ConfigHandler.getNode("others", "enableNationTag").getBoolean(true))
	{
		e.setMessage(TextSerializers.FORMATTING_CODE.deserialize(ConfigHandler.getNode("others", "publicChatFormat").getString().replaceAll("\\{NATION\\}", nation.getTag()).replaceAll("\\{TITLE\\}", DataHandler.getCitizenTitle(p.getUniqueId()))), e.getMessage());
	}
	else if (chan instanceof NationMessageChannel)
	{
		e.setMessage(Text.of(TextSerializers.FORMATTING_CODE.deserialize(ConfigHandler.getNode("others", "nationChatFormat").getString().replaceAll("\\{NATION\\}", nation.getTag()).replaceAll("\\{TITLE\\}", DataHandler.getCitizenTitle(p.getUniqueId()))), TextColors.YELLOW, e.getMessage()));
		DataHandler.getSpyChannel().send(p, Text.of(TextSerializers.FORMATTING_CODE.deserialize(ConfigHandler.getNode("others", "nationSpyChatTag").getString()), TextColors.RESET, e.getMessage()));
	}
}
 
开发者ID:Arckenver,项目名称:Nations,代码行数:26,代码来源:ChatListener.java

示例13: deserialize

import org.spongepowered.api.text.serializer.TextSerializers; //导入依赖的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

示例14: append

import org.spongepowered.api.text.serializer.TextSerializers; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void append(LogEvent event) {
    String normalMessage = getLayout().toSerializable(event).toString();

    String strippedMessage = TextSerializers.LEGACY_FORMATTING_CODE.stripCodes(normalMessage); // strip formatting codes
    try {
        uma.getStreamManager().send("console", subscription -> {
            String message = strippedMessage;
            if (Objects.equals(subscription.getParameter("nostrip"), "true")) {
                message = normalMessage;
            }
            return new ConsoleEvent(message, event.getLevel().name(), event.getMillis());
        });
    } catch (Exception e) {
        // doesn't really matter
        e.printStackTrace();
    }
}
 
开发者ID:UniversalMinecraftAPI,项目名称:UniversalMinecraftAPI,代码行数:20,代码来源:Log4JConsoleStreamAppender.java

示例15: formatCustomEmoji

import org.spongepowered.api.text.serializer.TextSerializers; //导入依赖的package包/类
/**
 * @param texts The message that may contain custom emoji
 * @param config  The mention config to be used for formatting
 * @return The final message with custom emoji formatted
 */
private static List<Text> formatCustomEmoji(List<Text> texts, ChannelMinecraftEmojiConfig config) {
    for(Text text : texts){
        String serialized = TextSerializers.FORMATTING_CODE.serialize(text);
        Matcher matcher = customEmoji.matcher(serialized);
        while (matcher.find()) {
            String name = matcher.group(1);
            String id = matcher.group(2);

            Text.Builder builder = TextSerializers.FORMATTING_CODE.deserialize(config.template.replace("%n", name)).toBuilder();

            if (config.allowLink) {
                try {
                    builder = builder.onClick(TextActions.openUrl(new URL("https://cdn.discordapp.com/emojis/" + id + ".png")));
                } catch (MalformedURLException ignored) { }
            }

            if (StringUtils.isNotBlank(config.hoverTemplate))
                builder = builder.onHover(TextActions.showText(Text.of(config.hoverTemplate)));
            texts = replaceMention(texts, "<:"+name+":"+id+">", builder);
        }
    }
    return texts;
}
 
开发者ID:nguyenquyhy,项目名称:DiscordBridge,代码行数:29,代码来源:TextUtil.java


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