當前位置: 首頁>>代碼示例>>Java>>正文


Java Text.of方法代碼示例

本文整理匯總了Java中org.spongepowered.api.text.Text.of方法的典型用法代碼示例。如果您正苦於以下問題:Java Text.of方法的具體用法?Java Text.of怎麽用?Java Text.of使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.spongepowered.api.text.Text的用法示例。


在下文中一共展示了Text.of方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import org.spongepowered.api.text.Text; //導入方法依賴的package包/類
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
	long time = (long) args.getOne("time").get();
	long before = new Date().getTime() - time;
	
	if (src instanceof Player) {
		Text text = Text.of(TextColors.BLUE, "[AS] ", TextColors.RED, 
				"This operation will remove log entries from the database! Are you sure? ",
				Text.builder("<Yes, proceed!>").color(TextColors.GOLD)
						.onClick(TextActions.executeCallback(cbs -> {
							doPurge(cbs, before);
						}
				)));
		src.sendMessage(text);
	} else {
		doPurge(src, before);
	}
	return CommandResult.success();
}
 
開發者ID:Karanum,項目名稱:AdamantineShield,代碼行數:20,代碼來源:CommandPurge.java

示例2: execute

import org.spongepowered.api.text.Text; //導入方法依賴的package包/類
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    final Optional<User> optionalUser = args.getOne("player");

    if (!optionalUser.isPresent()) {
        throw new CommandException(Text.of(TextColors.RED, "You must specify an existing user."));
    }

    final Optional<InetAddress> optionalIP = args.getOne("ip");

    if (!optionalIP.isPresent()) {
        throw new CommandException(Text.of(TextColors.RED, "You must specify a proper IP address."));
    }

    final User user = optionalUser.get();
    final InetAddress ip = optionalIP.get();

    Sponge.getScheduler().createAsyncExecutor(IPLog.getPlugin()).execute(() -> IPLog.getPlugin().getStorage().purgeConnection(ip, user.getUniqueId()));

    src.sendMessage(Text.of(TextColors.YELLOW, "You have successfully removed the specified connection from the database."));

    return CommandResult.success();
}
 
開發者ID:ichorpowered,項目名稱:iplog,代碼行數:24,代碼來源:PurgeCommand.java

示例3: parseValue

import org.spongepowered.api.text.Text; //導入方法依賴的package包/類
/**
 * Attempt to extract a value for this element from the given arguments.
 * This method is expected to have no side-effects for the source, meaning
 * that executing it will not change the state of the {@link CommandSource}
 * in any way.
 *
 * @param source The source to parse for
 * @param args   the arguments
 * @return The extracted value
 * @throws ArgumentParseException if unable to extract a value
 */
@Override
@Nullable
@NonnullByDefault
protected Object parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException {
	String type = args.next().toLowerCase();

	if (LoadedRegion.ChunkType.asMap().containsKey(type)) {
		if (source.hasPermission(String.format("%s.%s", Permissions.COMMAND_CREATE, type)))
			return LoadedRegion.ChunkType.asMap().get(type);
		else
			throw new ArgumentParseException(Text.of(TextColors.RED, String.format("You do not have permission to create %s chunks", type)), type, 0);
	} else {
		throw new ArgumentParseException(Text.of(TextColors.RED, "Chunk type does not exist."), type, 0);
	}
}
 
開發者ID:DevOnTheRocks,項目名稱:StickyChunk,代碼行數:27,代碼來源:ChunkTypeArgument.java

示例4: execute

import org.spongepowered.api.text.Text; //導入方法依賴的package包/類
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    final Player player_args = args.<Player>getOne("player").orElse(null);
    if (src.hasPermission(VTPermissions.COMMAND_BACKPACKLOCK)) {
        if (player_args != null) {
            if (args.hasAny("l") || args.hasAny("u")) {
                if (args.hasAny("l")) {
                    if (!Tools.backpackchecklock(player_args, this.vt)) {
                        this.bplock(player_args, src);
                    }
                }
                if (args.hasAny("u")) {
                    if (Tools.backpackchecklock(player_args, this.vt)) {
                        this.bpunlock(player_args, src);
                    }
                }
            } else {
                if (Tools.backpackchecklock(player_args, this.vt)) {
                    this.bpunlock(player_args, src);
                } else {
                    this.bplock(player_args, src);
                }
            }
        }
    } else {
        throw new CommandPermissionException(Text.of("You don't have permission to use this command."));
    }
    return CommandResult.success();
}
 
開發者ID:poqdavid,項目名稱:VirtualTool,代碼行數:30,代碼來源:BackpackLockCMD.java

示例5: printRoster

import org.spongepowered.api.text.Text; //導入方法依賴的package包/類
private void printRoster(CommandSource commandSource, ClanImpl clan, int page) {
    List<ClanPlayerImpl> members = clan.getMembersImpl();
    java.util.Collections.sort(members, new MemberComparator());

    HorizontalTable<ClanPlayerImpl> table = new HorizontalTable<>("Clan roster " + clan.getName(), 10,
            new TableAdapter<ClanPlayerImpl>() {

                @Override
                public void fillRow(Row row, ClanPlayerImpl member, int index) {
                    Optional<Player> playerOpt = Sponge.getServer().getPlayer(member.getUUID());
                    row.setValue("Player", Text.of(member.getName()));
                    row.setValue("Rank", Text.builder(member.getRank().getName()).color(TextColors.BLUE).build()); // todo get rank colored from Rank
                    Text lastOnlineMessage;
                    if (playerOpt.isPresent() && playerOpt.get().isOnline()) {
                        lastOnlineMessage = Text.builder("Online").color(TextColors.GREEN).build();
                    } else {
                        lastOnlineMessage = Text.of(member.getLastOnline().getDifferenceInText());
                    }
                    row.setValue("Last Online", lastOnlineMessage);

                }
            });
    table.defineColumn("Player", 30);
    table.defineColumn("Rank", 20);
    table.defineColumn("Last Online", 30);

    table.draw(members, page, commandSource);
}
 
開發者ID:iLefty,項目名稱:mcClans,代碼行數:29,代碼來源:ClanCommands.java

示例6: execute

import org.spongepowered.api.text.Text; //導入方法依賴的package包/類
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    if (src instanceof Player) {
        if (src.hasPermission(VTPermissions.COMMAND_ANVIL)) {
            final VirtualAnvil VA = new VirtualAnvil(Tools.getPlayerE(src, this.vt));

            return inv.Open(src, VA, "minecraft:anvil", "Virtual Anvil");
        } else {
            throw new CommandPermissionException(Text.of("You don't have permission to use this command."));
        }
    } else {
        throw new CommandException(Text.of("You can't use this command if you are not a player!"));
    }

}
 
開發者ID:poqdavid,項目名稱:VirtualTool,代碼行數:16,代碼來源:AnvilCMD.java

示例7: sendYourClanHasBeenInvitedToBecomeAlliesWithClan

import org.spongepowered.api.text.Text; //導入方法依賴的package包/類
public static void sendYourClanHasBeenInvitedToBecomeAlliesWithClan(ClanPlayerImpl clanPlayer, String clanName, Text coloredClanTag) {
    Text message1 = Text.of("");
    Text message2 = Text.join(
            Text.builder("Ваш клан был приглашен стать союзником ").color(BASIC_CHAT_COLOR).build(),
            coloredClanTag,
            Text.builder(" " + clanName).color(BASIC_HIGHLIGHT).build()
    );
    Text message3 = Text.join(
            Text.builder("Чтобы принять - ").color(BASIC_CHAT_COLOR).build(),
            Text.builder("/clan ally accept").color(BASIC_HIGHLIGHT).build(),
            Text.builder(" чтобы отклонить - ").color(BASIC_CHAT_COLOR).build(),
            Text.builder("/clan ally decline").color(BASIC_HIGHLIGHT).build()
    );
    clanPlayer.sendMessage(Text.of(message1, message2, message3));
}
 
開發者ID:iLefty,項目名稱:mcClans,代碼行數:16,代碼來源:Messages.java

示例8: execute

import org.spongepowered.api.text.Text; //導入方法依賴的package包/類
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    if (src instanceof Player) {
        if (src.hasPermission(VTPermissions.COMMAND_ENDERCHEST)) {
            return inv.Open(src, args, "enderchest");
        } else {
            throw new CommandPermissionException(Text.of("You don't have permission to use this command."));
        }
    } else {
        throw new CommandException(Text.of("You can't use this command if you are not a player!"));
    }
}
 
開發者ID:poqdavid,項目名稱:VirtualTool,代碼行數:13,代碼來源:EnderChestCMD.java

示例9: formatHelpText

import org.spongepowered.api.text.Text; //導入方法依賴的package包/類
private static Text formatHelpText(String command, String description, Text extendedDescription) {
    return Text.of(Text.builder(command)
        .color(TextColors.GREEN)
        .onClick(TextActions.suggestCommand(command))
        .onHover(TextActions.showText(extendedDescription))
        .build(),Text.of(TextColors.GRAY, " - ", description));
}
 
開發者ID:ichorpowered,項目名稱:iplog,代碼行數:8,代碼來源:HelpCommand.java

示例10: getUsage

import org.spongepowered.api.text.Text; //導入方法依賴的package包/類
@Override
public Text getUsage(CommandSource source) {
    return Text.of();
}
 
開發者ID:GreWeMa,項目名稱:gwm_Crates,代碼行數:5,代碼來源:GWMCratesCommand.java

示例11: getHelpEntry

import org.spongepowered.api.text.Text; //導入方法依賴的package包/類
public static Text getHelpEntry() {
	return Text.of(TextColors.AQUA, "/ashield nextpage", TextColors.WHITE, " - Switches to next result page");
}
 
開發者ID:Karanum,項目名稱:AdamantineShield,代碼行數:4,代碼來源:CommandNextPage.java

示例12: execute

import org.spongepowered.api.text.Text; //導入方法依賴的package包/類
/**
 * Callback for the execution of a command.
 *
 * @param src  The commander who is executing this command
 * @param args The parsed command arguments for this command
 * @return the result of executing this command
 * @throws CommandException If a user-facing error occurs while executing this command
 */
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
	if (!(src instanceof Player))
		return execServer(src, args);

	User user = args.<User>getOne(USER).orElse((Player) src);
	List<Text> listText = Lists.newArrayList();
	ArrayList<LoadedRegion> loadedRegions = dataStore.getPlayerRegions(user);

	Text header = Text.of(
		"Listing ",
		TextColors.GOLD, loadedRegions.size(),
		TextColors.RESET, " region(s) across ",
		TextColors.GOLD, dataStore.getPlayerRegionWorlds(user).size(),
		TextColors.RESET, " worlds"
	);

	if (loadedRegions.isEmpty())
		header = Text.of(TextColors.RED, "There are no loaded regions to display");

	loadedRegions.forEach(region -> listText.add(Text.of(
		TextColors.GOLD, region.getChunks().size(),
		TextColors.GREEN, Text.of(" [", (region.getType() == LoadedRegion.ChunkType.WORLD) ? 'W' : 'P', "]")
			.toBuilder().onHover(TextActions.showText(Text.of(TextColors.GREEN,
				(region.getType() == LoadedRegion.ChunkType.WORLD) ? "World" : "Personal"
			))),
		TextColors.WHITE, (region.getChunks().size() > 1) ? " chunks in world " : " chunk in world ",
		TextColors.GOLD, region.getWorld().getName(),
		TextColors.WHITE, " from (", TextColors.LIGHT_PURPLE, region.getRegion().getFrom().getX(), TextColors.WHITE,
		", ", TextColors.LIGHT_PURPLE, region.getRegion().getFrom().getZ(), TextColors.WHITE, ")",
		TextColors.WHITE, " to (", TextColors.LIGHT_PURPLE, region.getRegion().getTo().getX(), TextColors.WHITE,
		", ", TextColors.LIGHT_PURPLE, region.getRegion().getTo().getZ(), TextColors.WHITE, ")"
	)));

	PaginationList.builder()
		.title(Text.of(TextColors.GOLD, "Loaded Regions"))
		.padding(Text.of(TextColors.GOLD, TextStyles.STRIKETHROUGH, "-"))
		.header(header)
		.contents(listText)
		.sendTo(src);

	return CommandResult.success();
}
 
開發者ID:DevOnTheRocks,項目名稱:StickyChunk,代碼行數:51,代碼來源:CommandList.java

示例13: getHelpEntry

import org.spongepowered.api.text.Text; //導入方法依賴的package包/類
public static Text getHelpEntry() {
	return Text.of(TextColors.AQUA, "/ashield help", TextColors.WHITE, " - Shows command help");
}
 
開發者ID:Karanum,項目名稱:AdamantineShield,代碼行數:4,代碼來源:CommandMain.java

示例14: execute

import org.spongepowered.api.text.Text; //導入方法依賴的package包/類
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    final Optional<User> optionalUser = args.getOne("player");

    if (!optionalUser.isPresent()) {
        throw new CommandException(Text.of(TextColors.RED, "You must specify an existing user."));
    }

    final User user = optionalUser.get();

    Sponge.getScheduler().createAsyncExecutor(IPLog.getPlugin()).execute(() -> {
        final Set<UUID> users = IPLog.getPlugin().getStorage().getAliases(user.getUniqueId());
        if (src instanceof User) {
            UUID sender = ((User) src).getUniqueId();
            if (sender.equals(user.getUniqueId())) {
                users.remove(sender);
            }
        }
        if (users.size() == 0) {
            src.sendMessage(Text.of(TextColors.RED, "There are no aliases associated with the specified user."));
            return;
        }

        Sponge.getScheduler().createSyncExecutor(IPLog.getPlugin()).execute(() -> {
            final UserStorageService userStorageService = Sponge.getServiceManager().provide(UserStorageService.class).get();
            Sponge.getServiceManager().provide(PaginationService.class).get().builder()
                    .title(Text.of(TextColors.DARK_GREEN, "Aliases of ", TextColors.GREEN, user.getName()))
                    .contents(users.stream()
                            .map(userStorageService::get)
                            .filter(Optional::isPresent)
                            .map(Optional::get)
                            .map(User::getName)
                            .map(Text::of)
                            .map(username -> Text.of(TextColors.DARK_GREEN, username))
                            .collect(Collectors.toList()))
                    .linesPerPage(14)
                    .padding(Text.of(TextColors.GRAY, "="))
                    .sendTo(src);
        });
    });

    return CommandResult.success();
}
 
開發者ID:ichorpowered,項目名稱:iplog,代碼行數:44,代碼來源:AliasCommand.java

示例15: getHelpEntry

import org.spongepowered.api.text.Text; //導入方法依賴的package包/類
public static Text getHelpEntry() {
	return Text.of(TextColors.AQUA, "/ashield inspect", TextColors.WHITE, " - Toggles the inspector");
}
 
開發者ID:Karanum,項目名稱:AdamantineShield,代碼行數:4,代碼來源:CommandInspect.java


注:本文中的org.spongepowered.api.text.Text.of方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。