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


Java PaginationList.Builder方法代码示例

本文整理汇总了Java中org.spongepowered.api.service.pagination.PaginationList.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java PaginationList.Builder方法的具体用法?Java PaginationList.Builder怎么用?Java PaginationList.Builder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.spongepowered.api.service.pagination.PaginationList的用法示例。


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

示例1: execute

import org.spongepowered.api.service.pagination.PaginationList; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource source, CommandContext context) throws CommandException
{
    HashSet<Faction> factionsList = new HashSet<>(FactionLogic.getFactions());
    List<Text> helpList = new ArrayList<>();

    for(Faction faction: factionsList)
    {
        String tag = "";
        if(faction.Tag != null && !faction.Tag.equals("")) tag = "[" + faction.Tag + "] ";

        Text factionHelp = Text.builder()
                .append(Text.builder()
                        .append(Text.of(TextColors.AQUA, "- " + tag + faction.Name + " (" + faction.Power + "/" + PowerService.getFactionMaxPower(faction) + ")"))
                        .build())
                .build();

        helpList.add(factionHelp);
    }

    PaginationService paginationService = Sponge.getServiceManager().provide(PaginationService.class).get();
    PaginationList.Builder paginationBuilder = paginationService.builder().title(Text.of(TextColors.GREEN, "Factions List")).padding(Text.of("-")).contents(helpList);
    paginationBuilder.sendTo(source);

    return CommandResult.success();
}
 
开发者ID:Aquerr,项目名称:EagleFactions,代码行数:27,代码来源:ListCommand.java

示例2: sendAllNews

import org.spongepowered.api.service.pagination.PaginationList; //导入方法依赖的package包/类
@Override
    public void sendAllNews(MessageReceiver msgReceiver) throws CommandException {
//        CommandExceptions.doOrThrow("NewsService.sendAllNews()", () -> {
            Iterable<News> newsList = newsRegistry.getAllNews();
            if (Iterables.isEmpty(newsList)) {
                msgReceiver.sendMessage(Texts.inRed("Sorry, no news."));
                return;
            } else {
                PaginationService paginationService = Sponge.getServiceManager().provide(PaginationService.class).get();
                PaginationList.Builder paginationBuilder = paginationService.builder();
                paginationBuilder.title(Text.of("NEWS"));
                paginationBuilder.contents(Iterables.transform(newsList, news -> news2text(news)));
                paginationBuilder.sendTo(msgReceiver);
            }
//        });
    }
 
开发者ID:vorburger,项目名称:ch.vorburger.minecraft.osgi,代码行数:17,代码来源:NewsServiceImpl.java

示例3: sendPlayerInfo

import org.spongepowered.api.service.pagination.PaginationList; //导入方法依赖的package包/类
@Override
public void sendPlayerInfo(IActiveCharacter character, List<CharacterBase> target) {
	PaginationService paginationService = game.getServiceManager().provide(PaginationService.class).get();
	PaginationList.Builder builder = paginationService.builder();
	builder.padding(Text.builder("=").color(TextColors.GREEN).build());
	List<Text> content = new ArrayList<>();
	for (CharacterBase characterBase : target) {
		String name = characterBase.getName();
		int level = character.getPrimaryClass().getLevel();
		String name1 = character.getRace().getName();
		Text.Builder b = Text.builder();
		b.append(Text.builder(" [").color(TextColors.DARK_GRAY).build())
				.append(Text.builder("SELECT").color(TextColors.GREEN).build())
				.append(Text.builder("] - ").color(TextColors.DARK_GRAY).build());
		b.append(Text.of(name));
		if (character.getPrimaryClass() != ExtendedNClass.Default) {
			b.append(Text.builder(" ").build()).append(Text.of(level));
		}
		if (character.getRace() != Race.Default) {
			b.append(Text.of(name1));
		}
		content.add(b.build());
	}
	builder.contents(content);
	builder.sendTo(character.getPlayer());
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:27,代码来源:VanilaMessaging.java

示例4: showClaims

import org.spongepowered.api.service.pagination.PaginationList; //导入方法依赖的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

示例5: listBuilder

import org.spongepowered.api.service.pagination.PaginationList; //导入方法依赖的package包/类
private PaginationList.Builder listBuilder(WorldProperties world,
                                           Map<String, List<Graveyard>> graveyardMap, Graveyards plugin) {

    List<Text> graveyardInfo = new ArrayList<>();
    graveyardMap.forEach((name, list) -> {
        graveyardInfo.add(Text.of(TextColors.GREEN, name, ":"));
        graveyardInfo.addAll(list.stream().map(graveyard -> Text.of("  ", graveyard.getName(), ": ",
                graveyard.getLocation().toString())).collect(Collectors.toList()));
    });

    PaginationService pagServ = plugin.getGame().getServiceManager().provide(PaginationService.class).get();
    PaginationList.Builder builder = pagServ.builder();
    builder.contents(graveyardInfo)
            .title(Text
                    .builder("Graveyards in ")
                    .color(TextColors.GREEN)
                    .append(Text.builder(world.getWorldName())
                            .color(TextColors.DARK_GREEN).build()).build())
            .padding(Text.of("-"));
    return builder;
}
 
开发者ID:Zerthick,项目名称:Graveyards,代码行数:22,代码来源:GraveyardListExecutor.java

示例6: sendListOfRunes

import org.spongepowered.api.service.pagination.PaginationList; //导入方法依赖的package包/类
@Override
public void sendListOfRunes(IActiveCharacter character) {
	PaginationService paginationService = Sponge.getServiceManager().provide(PaginationService.class).get();
	PaginationList.Builder builder = paginationService.builder();

	List<Text> content = new ArrayList<>();
	List<Rune> r = new ArrayList<>(rwService.getRunes().values());
	Collections.sort(r, (o1, o2) -> (int) (o1.getSpawnchance() - o2.getSpawnchance()));
	for (Rune rune : r) {
		LiteralText.Builder b = Text.builder(rune.getName()).color(TextColors.GOLD);
		if (rune.getLore() != null) {
			b.append(Text.of(" - " + rune.getLore(), TextColors.WHITE, TextStyles.ITALIC));
		}
		content.add(b.build());
	}
	builder.contents(content);
	builder.linesPerPage(10);
	builder.padding(Text.builder("=").color(TextColors.DARK_GRAY).build());
	builder.sendTo(character.getPlayer());


}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:23,代码来源:VanilaMessaging.java

示例7: sendPaginatedMessage

import org.spongepowered.api.service.pagination.PaginationList; //导入方法依赖的package包/类
private void sendPaginatedMessage(Node node, CommandSource source) {
    PaginationService paginationService = Sponge.getServiceManager().provide(PaginationService.class).get();
    PaginationList.Builder builder = paginationService.builder();
    List<Text> contents = node.getSubcategories().stream()
            .map(category -> Text.builder("> " + category.getName()).color(TextColors.GRAY).onClick(TextActions.executeCallback(commandSource -> {
                if (commandSource instanceof Player) {
                    sendPaginatedMessage(node.getChild(category), source);
                }
            })).build()).collect(Collectors.toList());
    for (Package p : node.getPackages()) {
        contents.add(Text.builder(p.getName()).color(TextColors.WHITE).append(Text.builder(" - ").color(TextColors.GRAY).build())
                .append(Text.builder("$x".replace("$", plugin.getServerInformation().getAccount().getCurrency().getSymbol())
                        .replace("x", "" + p.getEffectivePrice())).color(TextColors.GREEN).build())
                .onClick(TextActions.executeCallback(commandSource -> {
                    if (commandSource instanceof Player) {
                        plugin.getPlatform().executeAsync(new SendCheckoutLinkTask(plugin, p.getId(), (Player) commandSource));
                    }
                })).build());
    }
    builder.title(Text.builder(plugin.getI18n().get("sponge_listing")).color(TextColors.AQUA).build()).contents(contents).padding(Text.of("-")).sendTo(source);
}
 
开发者ID:BuycraftPlugin,项目名称:BuycraftX,代码行数:22,代码来源:ListPackagesCmd.java

示例8: showPlayerInfo

import org.spongepowered.api.service.pagination.PaginationList; //导入方法依赖的package包/类
private void showPlayerInfo(CommandSource source, Player player)
{
    if(player.hasPlayedBefore())
    {
        List<Text> playerInfo = new ArrayList<Text>();

        String playerFactionName = FactionLogic.getFactionName(player.getUniqueId());
        if(playerFactionName == null) playerFactionName = "";

        Date lastPlayed = Date.from(player.getJoinData().lastPlayed().get());
        SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
        String formattedDate = formatter.format(lastPlayed);

        //TODO: Show if player is online or offline.

        Text info = Text.builder()
                .append(Text.of(TextColors.AQUA, "Name: ", TextColors.GOLD, PlayerService.getPlayerName(player.getUniqueId()).get() + "\n"))
                .append(Text.of(TextColors.AQUA, "Last Played: ", TextColors.GOLD, formattedDate + "\n"))
                .append(Text.of(TextColors.AQUA, "Faction: ", TextColors.GOLD, playerFactionName + "\n"))
                .append(Text.of(TextColors.AQUA, "Power: ", TextColors.GOLD, PowerService.getPlayerPower(player.getUniqueId()) + "/" + PowerService.getPlayerMaxPower(player.getUniqueId())))
                .build();

        playerInfo.add(info);

        PaginationService paginationService = Sponge.getServiceManager().provide(PaginationService.class).get();
        PaginationList.Builder paginationBuilder = paginationService.builder().title(Text.of(TextColors.GREEN, "Player Info")).padding(Text.of("=")).contents(playerInfo);
        paginationBuilder.sendTo(source);
    }
    else
    {
        player.sendMessage (Text.of (PluginInfo.ErrorPrefix, TextColors.RED, "This player has not played on this server!"));
    }
}
 
开发者ID:Aquerr,项目名称:EagleFactions,代码行数:34,代码来源:PlayerCommand.java

示例9: execute

import org.spongepowered.api.service.pagination.PaginationList; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource source, CommandContext context) throws CommandException
{
    List<Faction> factionsList = new ArrayList<>(FactionLogic.getFactions());
    List<Text> helpList = new ArrayList<>();
    int index = 0;

    factionsList.sort((o1, o2) -> o2.Power.compareTo(o1.Power));

    //This should show only top 10 factions on the server.

    for(Faction faction: factionsList)
    {
        if(faction.Name.equalsIgnoreCase("safezone") || faction.Name.equalsIgnoreCase("warzone")) continue;
        if(index == 11) break;

        index++;
        String tag = "";
        if(faction.Tag != null && !faction.Tag.equals("")) tag = "[" + faction.Tag + "] ";

        Text factionHelp = Text.builder()
                .append(Text.builder()
                        .append(Text.of(TextColors.AQUA, index + ". " + tag + faction.Name + " (" + faction.Power + "/" + PowerService.getFactionMaxPower(faction) + ")"))
                        .build())
                .build();

        helpList.add(factionHelp);
    }

    PaginationService paginationService = Sponge.getServiceManager().provide(PaginationService.class).get();
    PaginationList.Builder paginationBuilder = paginationService.builder().title(Text.of(TextColors.GREEN, "Factions List")).padding(Text.of("-")).contents(helpList);
    paginationBuilder.sendTo(source);

    return CommandResult.success();
}
 
开发者ID:Aquerr,项目名称:EagleFactions,代码行数:36,代码来源:TopCommand.java

示例10: showChildrenList

import org.spongepowered.api.service.pagination.PaginationList; //导入方法依赖的package包/类
public static Consumer<CommandSource> showChildrenList(List<Text> childrenTextList, CommandSource src, Consumer<CommandSource> returnCommand, GPClaim parent) {
    return consumer -> {
        Text claimListReturnCommand = Text.builder().append(Text.of(
                TextColors.WHITE, "\n[", TextColors.AQUA, "Return to claimslist", TextColors.WHITE, "]\n"))
            .onClick(TextActions.executeCallback(returnCommand)).build();

        List<Text> textList = new ArrayList<>();
        textList.add(claimListReturnCommand);
        textList.addAll(childrenTextList);
        PaginationService paginationService = Sponge.getServiceManager().provide(PaginationService.class).get();
        PaginationList.Builder paginationBuilder = paginationService.builder()
                .title(Text.of(parent.getName().orElse(parent.getFriendlyNameType()), " Child Claims")).padding(Text.of(TextStyles.STRIKETHROUGH, "-")).contents(textList);
        paginationBuilder.sendTo(src);
    };
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:16,代码来源:CommandHelper.java

示例11: createBankTransactionsConsumer

import org.spongepowered.api.service.pagination.PaginationList; //导入方法依赖的package包/类
public static Consumer<CommandSource> createBankTransactionsConsumer(CommandSource src, GPClaim claim, boolean checkTown, boolean returnToClaimInfo) {
    return settings -> {
        final String name = "Bank Transactions";
        List<String> bankTransactions = new ArrayList<>(claim.getData().getEconomyData().getBankTransactionLog());
        Collections.reverse(bankTransactions);
        List<Text> textList = new ArrayList<>();
        textList.add(Text.builder().append(Text.of(
                TextColors.WHITE, "\n[", TextColors.AQUA, "Return to bank info", TextColors.WHITE, "]\n"))
            .onClick(TextActions.executeCallback(consumer -> { displayClaimBankInfo(src, claim, checkTown, returnToClaimInfo); })).build());
        Gson gson = new Gson();
        for (String transaction : bankTransactions) {
            GPBankTransaction bankTransaction = gson.fromJson(transaction, GPBankTransaction.class);
            final Duration duration = Duration.between(bankTransaction.timestamp, Instant.now().truncatedTo(ChronoUnit.SECONDS)) ;
            final long s = duration.getSeconds();
            final User user = GriefPreventionPlugin.getOrCreateUser(bankTransaction.source);
            final String timeLeft = String.format("%dh %02dm %02ds", s / 3600, (s % 3600) / 60, (s % 60)) + " ago";
            textList.add(Text.of(getTransactionColor(bankTransaction.type), bankTransaction.type.name(), 
                    TextColors.BLUE, " | ", TextColors.WHITE, bankTransaction.amount, 
                    TextColors.BLUE, " | ", TextColors.GRAY, timeLeft,
                    user == null ? "" : Text.of(TextColors.BLUE, " | ", TextColors.LIGHT_PURPLE, user.getName())));
        }
        textList.add(Text.builder().append(Text.of(
                TextColors.WHITE, "\n[", TextColors.AQUA, "Return to bank info", TextColors.WHITE, "]\n"))
            .onClick(TextActions.executeCallback(CommandHelper.createCommandConsumer(src, "claimbank", ""))).build());
        PaginationService paginationService = Sponge.getServiceManager().provide(PaginationService.class).get();
        PaginationList.Builder paginationBuilder = paginationService.builder()
                .title(Text.of(TextColors.AQUA, name)).padding(Text.of(TextStyles.STRIKETHROUGH, "-")).contents(textList);
        paginationBuilder.sendTo(src);
    };
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:31,代码来源:CommandHelper.java

示例12: executeAsync

import org.spongepowered.api.service.pagination.PaginationList; //导入方法依赖的package包/类
@Override
public void executeAsync(CommandSource src, CommandContext ctx)
{
	if (src instanceof Player)
	{
		Player player = (Player) src;
		List<Mail> mail = Utils.getMail(player);

		if (mail.isEmpty())
		{
			player.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You have no new mail!"));
			return;
		}

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

		for (Mail newM : mail)
		{
			String name = "New mail from " + newM.getSenderName();
			Text item = Text.builder(name).onClick(TextActions.runCommand("/readmail " + (mail.indexOf(newM)))).onHover(TextActions.showText(Text.of(TextColors.WHITE, "Read mail from ", TextColors.GOLD, newM.getSenderName()))).color(TextColors.DARK_AQUA).style(TextStyles.UNDERLINE).build();

			mailText.add(item);
		}

		PaginationList.Builder paginationBuilder = paginationService.builder().contents(mailText).title(Text.of(TextColors.GREEN, "Showing Mail")).padding(Text.of("-"));
		paginationBuilder.sendTo(src);
	}
	else
	{
		src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Must be an in-game player to use /mailist!"));
	}
}
 
开发者ID:hsyyid,项目名称:EssentialCmds,代码行数:34,代码来源:MailListExecutor.java

示例13: createSettingsConsumer

import org.spongepowered.api.service.pagination.PaginationList; //导入方法依赖的package包/类
public static Consumer<CommandSource> createSettingsConsumer(CommandSource src, Claim claim, List<Text> textList, ClaimType type) {
    return settings -> {
        String name = type == ClaimType.TOWN ? "Town Settings" : "Admin Settings";
        PaginationService paginationService = Sponge.getServiceManager().provide(PaginationService.class).get();
        PaginationList.Builder paginationBuilder = paginationService.builder()
                .title(Text.of(TextColors.AQUA, name)).padding(Text.of(TextStyles.STRIKETHROUGH, "-")).contents(textList);
        paginationBuilder.sendTo(src);
    };
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:10,代码来源:CommandClaimInfo.java

示例14: sendStatus

import org.spongepowered.api.service.pagination.PaginationList; //导入方法依赖的package包/类
@Override
public void sendStatus(IActiveCharacter character) {
	CharacterBase base = character.getCharacterBase();

	PaginationService paginationService = Sponge.getServiceManager().provide(PaginationService.class).get();
	PaginationList.Builder builder = paginationService.builder();
	builder.title(Text.of(character.getName(), Color.YELLOW));
	builder.padding(Text.of("═", Color.GRAY));

	List<Text> content = new ArrayList<>();
	Set<CharacterClass> characterClasses = base.getCharacterClasses();
	for (CharacterClass cc : characterClasses) {
		Text t = Text.builder().append(Text.of(Utils.capitalizeFirst(cc.getName()), Color.GREEN))
				.append(Text.of(" - ", TextColors.GRAY))
				.append(Text.of(cc.getSkillPoints(), TextColors.BLUE))
				.append(Text.of(String.format("(%s)", cc.getUsedSkillPoints()), TextColors.GRAY))

				.toText();
		content.add(t);
	}
	content.add(Text.builder().append(Text.of("Attribute points: ", TextColors.GREEN))
			.append(Text.of(character.getCharacterBase().getAttributePoints(), TextColors.AQUA))
			.append(Text.of(String.format("(%s)", character.getCharacterBase().getUsedAttributePoints(), TextColors.GRAY))).toText());

	builder.contents(content);
	builder.sendTo(character.getPlayer());
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:28,代码来源:VanilaMessaging.java

示例15: from

import org.spongepowered.api.service.pagination.PaginationList; //导入方法依赖的package包/类
@Override
public PaginationList.Builder from(PaginationList list) {
    this.reset();
    this.contents = list.getContents();
    this.title = list.getTitle().orElse(null);
    this.header = list.getHeader().orElse(null);
    this.footer = list.getFooter().orElse(null);
    this.paginationSpacer = list.getPadding();
    this.paginationList = null;
    return this;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:12,代码来源:LanternPaginationBuilder.java


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