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


Java Text類代碼示例

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


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

示例1: 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

示例2: execute

import org.spongepowered.api.text.Text; //導入依賴的package包/類
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
	if (!(src instanceof Player)) {
		src.sendMessage(Text.of(TextColors.RED, "The inspector can only be toggled by players"));
		return CommandResult.empty();
	}
	
	Player p = (Player) src;
	if (plugin.getInspectManager().toggleInspector(p)) {
		p.sendMessage(Text.of(TextColors.DARK_AQUA, "[AS] ", TextColors.YELLOW, "Inspector mode has been ", TextColors.GREEN, "enabled"));
	} else {
		p.sendMessage(Text.of(TextColors.DARK_AQUA, "[AS] ", TextColors.YELLOW, "Inspector mode has been ", TextColors.RED, "disabled"));
	}
	
	return CommandResult.success();
}
 
開發者ID:Karanum,項目名稱:AdamantineShield,代碼行數:17,代碼來源:CommandInspect.java

示例3: printCorrectPerm

import org.spongepowered.api.text.Text; //導入依賴的package包/類
private void printCorrectPerm(int cost, Player player)
{
    if (cost != 0)
    {
        if (player.hasPermission("pixelupgrade.command.other.checkegg"))
            player.sendMessage(Text.of("§4Usage: §c/" + commandAlias + " [optional target] <slot, 1-6> {-c to confirm}"));
        else
            player.sendMessage(Text.of("§4Usage: §c/" + commandAlias + " <slot> {-c to confirm} §7(no perms for target)"));
    }
    else
    {
        if (player.hasPermission("pixelupgrade.command.other.checkegg"))
            player.sendMessage(Text.of("§4Usage: §c/" + commandAlias + " [optional target] <slot, 1-6>"));
        else
            player.sendMessage(Text.of("§4Usage: §c/" + commandAlias + " <slot> §7(no perms for target)"));
    }
}
 
開發者ID:xPXpanD,項目名稱:PixelUpgrade,代碼行數:18,代碼來源:CheckEgg.java

示例4: execute

import org.spongepowered.api.text.Text; //導入依賴的package包/類
@Override
public CommandResult execute(CommandSource source, CommandContext context) throws CommandException
{
    try
    {
        MainConfig.getConfig().load();
        FactionsConfig.getConfig().load();

        source.sendMessage(Text.of(PluginInfo.PluginPrefix, "Configs have been reloaded!"));
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }

    return CommandResult.success();
}
 
開發者ID:Aquerr,項目名稱:EagleFactions,代碼行數:18,代碼來源:ReloadCommand.java

示例5: onServerStart

import org.spongepowered.api.text.Text; //導入依賴的package包/類
@Listener
public void onServerStart(GameStartedServerEvent event) {
	instance = this;
	
	ConfigBuilder.configPath = Paths.get(configDir.toString(), "config.json");
	
	RText.impl(new RTextSponge());
	RColour.impl(new RColourSponge());
	Travellers.impl(new SpongeTravellers());
	
	CommandSpec camCommandSpec = CommandSpec.builder()
			.arguments(GenericArguments.optional(GenericArguments.remainingJoinedStrings(Text.of("cmd"))))
			.executor(new SpongeCommandManager())
			.build();

	Sponge.getCommandManager().register(this, camCommandSpec, "cam", "camerastudio");
}
 
開發者ID:redstone,項目名稱:RCameraStudio,代碼行數:18,代碼來源:RCameraStudioSponge.java

示例6: inspectContainer

import org.spongepowered.api.text.Text; //導入依賴的package包/類
public synchronized void inspectContainer(Player p, UUID world, Vector3i pos) {
	Connection c = db.getConnection();
	ContainerLookupResult lookup = null;
	
	try {
		PreparedStatement ps = c.prepareStatement(QueryHelper.INSPECT_CONTAINER_QUERY);
		ps.setInt(1, pos.getX());
		ps.setInt(2, pos.getY());
		ps.setInt(3, pos.getZ());
		ps.setString(4, world.toString());
		ResultSet result = ps.executeQuery();
		
		lookup = new ContainerLookupResult(result);
		LookupResultManager.instance().setLookupResult(p, lookup);
		
		result.close();
		c.close();
	} catch (SQLException e) {
		e.printStackTrace();
		p.sendMessage(Text.of(TextColors.DARK_AQUA, "[AC] ", TextColors.RED, "A database error has occurred! Contact your server administrator!"));
		return;
	}
	
	lookup.showPage(p, 1);
}
 
開發者ID:Karanum,項目名稱:AdamantineShield,代碼行數:26,代碼來源:InspectManager.java

示例7: getCatalogType

import org.spongepowered.api.text.Text; //導入依賴的package包/類
private static CatalogType getCatalogType(String id, LookupType lookupType) throws CommandException {
	switch (lookupType) {
		case BLOCK_LOOKUP:
			Optional<BlockType> block = Sponge.getRegistry().getType(BlockType.class, id);
			if (block.isPresent())
				return block.get();
			throw new CommandException(Text.of(TextColors.RED, "Unknown block id: " + id));
		case ITEM_LOOKUP:
			Optional<ItemType> item = Sponge.getRegistry().getType(ItemType.class, id);
			if (item.isPresent())
				return item.get();
			throw new CommandException(Text.of(TextColors.RED, "Unknown item id: " + id));
		default:
			throw new CommandException(Text.of(TextColors.RED, "Could not determine lookup type!"));
	}
}
 
開發者ID:Karanum,項目名稱:AdamantineShield,代碼行數:17,代碼來源:FilterParser.java

示例8: sendChat

import org.spongepowered.api.text.Text; //導入依賴的package包/類
private void sendChat(Player player, Text message) {
    Text rawMessage = Text.of(message);
    MessageChannelEvent.Chat event = SpongeEventFactory.createMessageChannelEventChat(
            Cause.source(player).named(NamedCause.notifier(player)).build(),
            player.getMessageChannel(),
            Optional.of(player.getMessageChannel()),
            new MessageEvent.MessageFormatter(
                    Text.builder(player.getName()).build(), rawMessage
            ),
            rawMessage,
            false
    );
    if (!Sponge.getEventManager().post(event)) {
        MessageEvent.MessageFormatter formatter = event.getFormatter();
        player.getMessageChannel().send(player, chatTemplate.apply(
                ImmutableMap.of(MessageEvent.PARAM_MESSAGE_HEADER, formatter.getHeader(),
                        MessageEvent.PARAM_MESSAGE_BODY, formatter.getBody(),
                        MessageEvent.PARAM_MESSAGE_FOOTER, formatter.getFooter())).build());
    }
}
 
開發者ID:iLefty,項目名稱:mcClans,代碼行數:21,代碼來源:ClanChatCommands.java

示例9: execServer

import org.spongepowered.api.text.Text; //導入依賴的package包/類
private CommandResult execServer(CommandSource src, CommandContext args) {
	if (dataStore.getCollatedRegions().isEmpty())
		src.sendMessage(Text.of(TextColors.RED, "There are no loaded regions to display"));

	dataStore.getCollatedRegions().forEach(region -> {
		Optional<Player> oPlayer = server.getPlayer(region.getOwner());
		String owner = (oPlayer.isPresent()) ? oPlayer.get().getName() : region.getOwner().toString();

		src.sendMessage(
			Text.of(
				TextColors.GREEN, owner, " ",
				TextColors.GOLD, region.getChunks().size(),
				TextColors.GREEN, " [", (region.getType() == LoadedRegion.ChunkType.WORLD) ? 'W' : 'P', "]",
				TextColors.WHITE, " chunks 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, ")"
			)
		);
	});

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

示例10: allyChatCommand

import org.spongepowered.api.text.Text; //導入依賴的package包/類
@Command(name = "ally", description = "Писать в чат альянса", isPlayerOnly = true, isClanOnly = true, clanPermission = "allychat", spongePermission = "mcclans.user.chat.ally")
public void allyChatCommand(Player player, ClanPlayerImpl clanPlayer, @Multiline @Parameter(name = "message") Optional<String> optionalMessage) {
    if (optionalMessage.isPresent()) {
        String message = optionalMessage.get();
        if (clanPlayer.getTempChatState() == null) {
            if (clanPlayer.getIgnoreAllyChat()) {
                Messages.sendYouNeedToUnignoreAllyChatBeforeTalking(player);
            } else {
                clanPlayer.setTempChatState(PlayerChatState.ALLY);
                AllyMessageChannelImpl.getFor(clanPlayer).send(player, Text.of(message));
                clanPlayer.setTempChatState(null);
            }
        }
    } else {
        PlayerChatState chatState = clanPlayer.getChatState();
        if (chatState.equals(PlayerChatState.ALLY)) {
            clanPlayer.setChatState(PlayerChatState.GLOBAL);
            Messages.sendNowTalkingInGlobal(player);
        } else {
            clanPlayer.setChatState(PlayerChatState.ALLY);
            Messages.sendNowTalkingInAllyChat(player);
        }
    }
}
 
開發者ID:iLefty,項目名稱:mcClans,代碼行數:25,代碼來源:ClanChatCommands.java

示例11: execute

import org.spongepowered.api.text.Text; //導入依賴的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

示例12: execute

import org.spongepowered.api.text.Text; //導入依賴的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

示例13: execute

import org.spongepowered.api.text.Text; //導入依賴的package包/類
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
	if (!(src instanceof Player)) {
		src.sendMessage(Text.of(TextColors.RED, "Lookups can only be performed by players"));
		return CommandResult.empty();
	}
	
	Player p = (Player) src;
	Collection<String> filters = args.getAll("filter");
	
	FilterSet filterSet = new FilterSet(plugin, p, true);
	FilterParser.parse(filters, filterSet, p);
	
	new RollbackJob(plugin, p, filterSet, true);
	return CommandResult.success();
}
 
開發者ID:Karanum,項目名稱:AdamantineShield,代碼行數:17,代碼來源:CommandUndo.java

示例14: generateAllyList

import org.spongepowered.api.text.Text; //導入依賴的package包/類
private Text generateAllyList(ClanImpl clan) {
    Text.Builder allyList = Text.builder();
    if (clan.getAlliesImpl().isEmpty()) {
        allyList.color(TextColors.GRAY).append(Text.of("None")).build();
    } else {
        boolean first = true;
        for (ClanImpl ally : clan.getAlliesImpl()) {
            if (!first) {
                allyList.append(Text.of(", ")).build();
            }
            first = false;
            allyList.append(ally.getTagColored()).build();
        }
    }
    return allyList.build();
}
 
開發者ID:iLefty,項目名稱:mcClans,代碼行數:17,代碼來源:ClanCommands.java

示例15: getCrateKey

import org.spongepowered.api.text.Text; //導入依賴的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


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