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


Java TextStyles类代码示例

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


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

示例1: listRewards

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

示例2: getSpacesString

import org.spongepowered.api.text.format.TextStyles; //导入依赖的package包/类
private Text getSpacesString(double numberOfSpaces) {
    Text.Builder spaces = Text.builder();
    if (Math.floor(numberOfSpaces) == 0) {
        return Text.EMPTY;
    }
    double x = numberOfSpaces - Math.floor(numberOfSpaces);
    int numberOfSpecialSpaces = (int) (x / 0.25);
    int numberOfNormalSpaces = (int) (Math.floor(numberOfSpaces) - numberOfSpecialSpaces);
    if (numberOfNormalSpaces < 0) {
        if (numberOfSpecialSpaces == 3) {
            numberOfSpecialSpaces = 0;
            numberOfNormalSpaces = (int) Math.ceil(numberOfSpaces);
        } else {
            numberOfSpecialSpaces += numberOfNormalSpaces;
            numberOfNormalSpaces = 0;
        }
    }
    for (int k = 0; k < numberOfNormalSpaces; k++) {
        spaces.append(Text.of(" "));
    }

    for (int l = 0; l < numberOfSpecialSpaces; l++) {
        spaces.append(Text.builder().style(TextStyles.BOLD).append(Text.of(" ")).build());
    }
    return spaces.toText();
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:27,代码来源:VerticalTable.java

示例3: getFormat

import org.spongepowered.api.text.format.TextStyles; //导入依赖的package包/类
private static TextStyle getFormat(char c) {
    switch (c) {
        case 'k':
            return TextStyles.OBFUSCATED;
        case 'l':
            return TextStyles.BOLD;
        case 'm':
            return TextStyles.STRIKETHROUGH;
        case 'n':
            return TextStyles.UNDERLINE;
        case 'o':
            return TextStyles.ITALIC;
        case 'r':
            return TextStyles.RESET;
        default:
            return null;
    }
}
 
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:19,代码来源:Colors.java

示例4: installMessageButton

import org.spongepowered.api.text.format.TextStyles; //导入依赖的package包/类
private void installMessageButton(ActivePlayerChatView view) {
    UUID playerId = view.getPlayer().getUniqueId();
    view.getPlayerList().addAddon(player -> {
        UUID otherId = player.getUniqueId();
        Text.Builder builder = Text.builder("Message");
        if (!otherId.equals(playerId)) {
            if (this.privateView.containsKey(otherId)) {
                builder.onClick(Utils.execClick(() -> newPrivateMessage(playerId, otherId)))
                        .onHover(TextActions.showText(Text.of("Send a private message")))
                        .color(TextColors.BLUE).style(TextStyles.UNDERLINE);
            } else {
                builder.color(TextColors.GRAY)
                        .onHover(TextActions.showText(Text.of("This player doesn't have Chat UI enabled")));
            }

        } else {
            builder.color(TextColors.GRAY)
                    .onHover(TextActions.showText(Text.of("Cannot send message to yourself")));
        }
        return builder.build();
    });
}
 
开发者ID:simon816,项目名称:ChatUI,代码行数:23,代码来源:PrivateMessageFeature.java

示例5: getTextStyle

import org.spongepowered.api.text.format.TextStyles; //导入依赖的package包/类
public static TextStyle getTextStyle(final String arg){
  	TextStyle style = TextStyles.NONE;
if (arg.equalsIgnoreCase("&k")){
	style = TextStyles.OBFUSCATED;
} else if (arg.equalsIgnoreCase("&l")){
	style = TextStyles.BOLD;
} else if (arg.equalsIgnoreCase("&m")){
	style = TextStyles.STRIKETHROUGH;
} else if (arg.equalsIgnoreCase("&n")){
	style = TextStyles.UNDERLINE;
} else if (arg.equalsIgnoreCase("&o")){
	style = TextStyles.ITALIC;
} else if (arg.equalsIgnoreCase("&r")){
	style = TextStyles.RESET;
}
return style;
  }
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:18,代码来源:EChat.java

示例6: onChangeBlock

import org.spongepowered.api.text.format.TextStyles; //导入依赖的package包/类
@Listener(order=Order.FIRST)
@IsCancelled(Tristate.UNDEFINED)
public void onChangeBlock(ChangeBlockEvent.Place event) {
	Optional<Player> optPlayer = event.getCause().get(NamedCause.SOURCE, Player.class);
	if (!optPlayer.isPresent()) return;
	
	Player player = optPlayer.get();
	if (!this.players.contains(player.getUniqueId())) return;
	
	event.setCancelled(true);
	
	event.getTransactions().forEach(transaction -> {
		player.sendMessage(Text.of(TextColors.GRAY, TextStyles.BOLD, "============================================"));
		player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Type: ", TextColors.BLUE, TextStyles.RESET, transaction.getOriginal().getState().getId()));
		player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Owner: ", TextColors.BLUE, TextStyles.RESET, transaction.getOriginal().getCreator()));
		player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Notifier: ", TextColors.BLUE, TextStyles.RESET, transaction.getOriginal().getNotifier()));
	});
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:19,代码来源:EAInfo.java

示例7: onInteractBlock

import org.spongepowered.api.text.format.TextStyles; //导入依赖的package包/类
@Listener(order=Order.FIRST)
@IsCancelled(Tristate.UNDEFINED)
public void onInteractBlock(InteractBlockEvent.Primary event) {
	Optional<Player> optPlayer = event.getCause().get(NamedCause.SOURCE, Player.class);
	if (!optPlayer.isPresent()) return;
	
	Player player = optPlayer.get();
	if (!this.players.contains(player.getUniqueId())) return;
	
	event.setCancelled(true);
	
	player.sendMessage(Text.of(TextColors.GRAY, TextStyles.BOLD, "============================================"));
	player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Type: ", TextColors.BLUE, TextStyles.RESET, event.getTargetBlock().getState().getId()));
	player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Owner: ", TextColors.BLUE, TextStyles.RESET, event.getTargetBlock().getCreator()));
	player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Notifier: ", TextColors.BLUE, TextStyles.RESET, event.getTargetBlock().getNotifier()));
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:17,代码来源:EAInfo.java

示例8: onInteractEntity

import org.spongepowered.api.text.format.TextStyles; //导入依赖的package包/类
@Listener(order=Order.FIRST)
@IsCancelled(Tristate.UNDEFINED)
public void onInteractEntity(InteractEntityEvent.Primary event) {
	Optional<Player> optPlayer = event.getCause().get(NamedCause.SOURCE, Player.class);
	if (!optPlayer.isPresent()) return;
	
	Player player = optPlayer.get();
	if (!this.players.contains(player.getUniqueId())) return;
	
	event.setCancelled(true);
	
	player.sendMessage(Text.of(TextColors.GRAY, TextStyles.BOLD, "============================================"));
	player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Entity Type: ", TextColors.BLUE, TextStyles.RESET, event.getTargetEntity().getType().getId()));
	player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Entity Owner: ", TextColors.BLUE, TextStyles.RESET, event.getTargetEntity().getCreator()));
	player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Entity Notifier: ", TextColors.BLUE, TextStyles.RESET, event.getTargetEntity().getNotifier()));
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:17,代码来源:EAInfo.java

示例9: getHistoryTPSIcon

import org.spongepowered.api.text.format.TextStyles; //导入依赖的package包/类
private Text getHistoryTPSIcon(final double tps, final int num) {
	Builder resultat = null;
	if (tps >= 20) {
		resultat = Text.builder("▇").color(TextColors.GREEN);
	} else if (tps >= 18) {
		resultat = Text.builder("▆").color(TextColors.GREEN);
	} else if (tps >= 14) {
		resultat = Text.builder("▅").color(TextColors.YELLOW);
	} else if (tps >= 10) {
		resultat = Text.builder("▃").color(TextColors.YELLOW);
	} else if (tps >= 5) {
		resultat = Text.builder("▂").color(TextColors.RED);
	} else {
		resultat = Text.builder("▁").color(TextColors.RED);
	}
	return resultat.style(TextStyles.BOLD)
			.onHover(TextActions.showText(EEMessages.LAG_HISTORY_TPS_HOVER.getFormat().toText(
						"{num}", String.valueOf(num),
						"{tps}", Text.builder(String.valueOf(tps)).color(getColorTPS(tps)).build())))
			.build();
}
 
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:22,代码来源:EELag.java

示例10: getLastColourAndStyle

import org.spongepowered.api.text.format.TextStyles; //导入依赖的package包/类
private static StyleTuple getLastColourAndStyle(Text text, StyleTuple current) {
    List<Text> texts = flatten(text);
    TextColor tc = TextColors.NONE;
    TextStyle ts = TextStyles.NONE;
    for (int i = texts.size() - 1; i > -1; i--) {
        // If we have both a Text Colour and a Text Style, then break out.
        if (tc != TextColors.NONE && ts != TextStyles.NONE) {
            break;
        }

        if (tc == TextColors.NONE) {
            tc = texts.get(i).getColor();
        }

        if (ts == TextStyles.NONE) {
            ts = texts.get(i).getStyle();
        }
    }

    if (current == null) {
        return new StyleTuple(tc, ts);
    }

    return new StyleTuple(tc != TextColors.NONE ? tc : current.colour, ts != TextStyles.NONE ? ts : current.style);
}
 
开发者ID:nguyenquyhy,项目名称:DiscordBridge,代码行数:26,代码来源:TextUtil.java

示例11: showClaims

import org.spongepowered.api.text.format.TextStyles; //导入依赖的package包/类
public static void showClaims(CommandSource src, List<Claim> claims, int height, boolean visualizeClaims) {
    final String worldName = src instanceof Player ? ((Player) src).getWorld().getName() : Sponge.getServer().getDefaultWorldName();
    final boolean canListOthers = src.hasPermission(GPPermissions.LIST_OTHER_CLAIMS);
    List<Text> claimsTextList = generateClaimTextList(new ArrayList<Text>(), claims, worldName, null, src, createShowClaimsConsumer(src, claims, height, visualizeClaims), canListOthers, false);

    if (visualizeClaims && src instanceof Player) {
        Player player = (Player) src;
        final GPPlayerData playerData = GriefPreventionPlugin.instance.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
        if (claims.size() > 1) {
            if (height != 0) {
                height = playerData.lastValidInspectLocation != null ? playerData.lastValidInspectLocation.getBlockY() : player.getProperty(EyeLocationProperty.class).get().getValue().getFloorY();
            }
            Visualization visualization = Visualization.fromClaims(claims, playerData.optionClaimCreateMode == 1 ? height : player.getProperty(EyeLocationProperty.class).get().getValue().getFloorY(), player.getLocation(), playerData, null);
            visualization.apply(player);
        } else {
            GPClaim gpClaim = (GPClaim) claims.get(0);
            gpClaim.getVisualizer().createClaimBlockVisuals(height, player.getLocation(), playerData);
            gpClaim.getVisualizer().apply(player);
        }
    }

    PaginationService paginationService = Sponge.getServiceManager().provide(PaginationService.class).get();
    PaginationList.Builder paginationBuilder = paginationService.builder()
            .title(Text.of(TextColors.RED,"Claim list")).padding(Text.of(TextStyles.STRIKETHROUGH, "-")).contents(claimsTextList);
    paginationBuilder.sendTo(src);
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:27,代码来源:CommandHelper.java

示例12: getClickableText

import org.spongepowered.api.text.format.TextStyles; //导入依赖的package包/类
public static Text getClickableText(CommandSource src, Subject subject, String subjectName, Set<Context> contexts, GPClaim claim, String flagPermission, Tristate flagValue, String source, FlagType type) {
    Text onClickText = Text.of("Click here to toggle flag value.");
    boolean hasPermission = true;
    if (type == FlagType.INHERIT) {
        onClickText = Text.of("This flag is inherited from parent claim ", claim.getName().orElse(claim.getFriendlyNameType()), " and ", TextStyles.UNDERLINE, "cannot", TextStyles.RESET, " be changed.");
        hasPermission = false;
    } else if (src instanceof Player) {
        Text denyReason = claim.allowEdit((Player) src);
        if (denyReason != null) {
            onClickText = denyReason;
            hasPermission = false;
        }
    }

    Text.Builder textBuilder = Text.builder()
    .append(Text.of(flagValue.toString().toLowerCase()))
    .onHover(TextActions.showText(Text.of(onClickText, "\n", getFlagTypeHoverText(type))));
    if (hasPermission) {
        textBuilder.onClick(TextActions.executeCallback(createFlagConsumer(src, subject, subjectName, contexts, claim, flagPermission, flagValue, source)));
    }
    return textBuilder.build();
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:23,代码来源:CommandHelper.java

示例13: onStart

import org.spongepowered.api.text.format.TextStyles; //导入依赖的package包/类
@Listener
public void onStart(GameInitializationEvent event) {
    this.logger.info("TestCommand plugin enabled!");

    Sponge.getCommandManager().register(this, CommandSpec.builder()
            .executor((src, args) -> {
                final Text message = Text.of(TextColors.GREEN, TextStyles.UNDERLINE, "Test", TextStyles.RESET, " 1234");
                if (src instanceof Player) {
                    ((Player) src).sendTitle(Title.builder().subtitle(message).build());
                } else {
                    src.sendMessage(message);
                }
                return CommandResult.success();
            })
            .build(), "test-command", "tc");
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:17,代码来源:TestCommandPlugin.java

示例14: executeAsync

import org.spongepowered.api.text.format.TextStyles; //导入依赖的package包/类
@Override
public void executeAsync(CommandSource src, CommandContext ctx)
{
	ArrayList<String> worlds = EssentialCmds.getEssentialCmds().getGame().getServer().getWorlds().stream().filter(world -> world.getProperties().isEnabled()).map(World::getName).collect(Collectors.toCollection(ArrayList::new));

	PaginationService paginationService = Sponge.getServiceManager().provide(PaginationService.class).get();
	ArrayList<Text> worldText = Lists.newArrayList();

	for (String name : worlds)
	{
		Text item = Text.builder(name)
			.onClick(TextActions.runCommand("/tpworld " + name))
			.onHover(TextActions.showText(Text.of(TextColors.WHITE, "Teleport to world ", TextColors.GOLD, name)))
			.color(TextColors.DARK_AQUA)
			.style(TextStyles.UNDERLINE)
			.build();

		worldText.add(item);
	}

	PaginationList.Builder paginationBuilder = paginationService.builder().contents(worldText).title(Text.of(TextColors.GREEN, "Showing Worlds")).padding(Text.of("-"));
	paginationBuilder.sendTo(src);
}
 
开发者ID:hsyyid,项目名称:EssentialCmds,代码行数:24,代码来源:WorldsBase.java

示例15: buildMessage

import org.spongepowered.api.text.format.TextStyles; //导入依赖的package包/类
private Text buildMessage(int index, String text) {
    String lineText = text;
    if (lineText.length() > 32) {
        lineText = lineText.substring(0, 32) + "...";
    }

    return Text.builder(plugin.translateColorCodes(lineText), "")
            .onHover(TextActions.showText(Text.of(text)))
            .onClick(TextActions
                    .runCommand('/' + PomData.ARTIFACT_ID + " broadcast " + (index + 1)))
            //do not add colors to the text message in order to show the actual results
            .append(Text
                    .builder(" ✖")
                    .color(TextColors.DARK_RED)
                    .onClick(TextActions
                            .runCommand('/' + PomData.ARTIFACT_ID + " remove " + (index + 1)))
                    .onHover(TextActions
                            .showText(Text.of(TextColors.RED, TextStyles.ITALIC, "Removes this message")))
                    .build())
            .build();
}
 
开发者ID:games647,项目名称:ActionBroadcaster,代码行数:22,代码来源:ListCommand.java


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