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


Java TextColors類代碼示例

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


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

示例1: execute

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

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

示例3: execute

import org.spongepowered.api.text.format.TextColors; //導入依賴的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");
	
	LookupResult lookup = LookupResultManager.instance().getLookupResult(p);
	if (lookup == null) {
		src.sendMessage(Text.of(TextColors.DARK_AQUA, "[AS] ", TextColors.YELLOW, "You have no lookup history!"));
		return CommandResult.empty();
	}
	
	FilterSet filterSet = new FilterSet(plugin, p, false);
	filterSet.forceLookupType(lookup.getLookupType());
	FilterParser.parse(filters, filterSet, p);
	lookup.filterResult(filterSet);
	
	lookup.showPage(p, 1);
	return CommandResult.success();
}
 
開發者ID:Karanum,項目名稱:AdamantineShield,代碼行數:25,代碼來源:CommandFilter.java

示例4: execute

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

示例5: onServerInitialization

import org.spongepowered.api.text.format.TextColors; //導入依賴的package包/類
@Listener
public void onServerInitialization(GameInitializationEvent event)
{
    eagleFactions = this;

   //Sponge.getServer().getConsole().sendMessage(Text.of(TextColors.AQUA, "EagleFactions is loading..."));
   Sponge.getServer().getConsole().sendMessage(Text.of(TextColors.AQUA, "Preparing wings..."));

   SetupConfigs();

   Sponge.getServer().getConsole().sendMessage(Text.of(TextColors.AQUA, "Configs loaded..."));

   InitializeCommands();

   Sponge.getServer().getConsole().sendMessage(Text.of(TextColors.AQUA, "Commands loaded..."));

   RegisterListeners();

    //Display some info text in the console.
    Sponge.getServer().getConsole().sendMessage(Text.of(TextColors.GREEN,"=========================================="));
    Sponge.getServer().getConsole().sendMessage(Text.of(TextColors.AQUA, "EagleFactions", TextColors.WHITE, " is ready to use!"));
    Sponge.getServer().getConsole().sendMessage(Text.of(TextColors.WHITE,"Thank you for choosing this plugin!"));
    Sponge.getServer().getConsole().sendMessage(Text.of(TextColors.WHITE,"Current version: " + PluginInfo.Version));
    Sponge.getServer().getConsole().sendMessage(Text.of(TextColors.WHITE,"Have a great time with EagleFactions! :D"));
    Sponge.getServer().getConsole().sendMessage(Text.of(TextColors.GREEN,"=========================================="));
}
 
開發者ID:Aquerr,項目名稱:EagleFactions,代碼行數:27,代碼來源:EagleFactions.java

示例6: execute

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

	Player player = (Player) src;
	Region region = new Region(player.getLocation());
	LoadedRegion.ChunkType type = args.<LoadedRegion.ChunkType>getOne("type").orElse(LoadedRegion.ChunkType.WORLD);
	LoadedRegion loadedRegion = new LoadedRegion(region, player, type);

	if (dataStore.isRegionLoaded(loadedRegion))
		throw new CommandException(Text.of(TextColors.RED, "You've already allocated this region."));

	loadedRegion.assignTicket();
	if (loadedRegion.isValid())
		throw new CommandException(Text.of(TextColors.RED, "Failed to allocate a loading ticket and force region."));

	dataStore.addPlayerRegion(player, loadedRegion);
	loadedRegion.forceChunks();
	database.saveRegionData(loadedRegion);

	player.sendMessage(Text.of(TextColors.GREEN, "Successfully loaded the region."));

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

示例7: execServer

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

示例8: parseValue

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

示例9: onBlockSecondaryInteract

import org.spongepowered.api.text.format.TextColors; //導入依賴的package包/類
@Listener
public void onBlockSecondaryInteract(InteractBlockEvent.Secondary.MainHand e, @First Player p) {		
	if (!plugin.getInspectManager().isInspector(p))
		return;
	
	//TODO: Figure out why shearing sheep causes weird shit to happen
	
	e.setCancelled(true);
	BlockSnapshot block = e.getTargetBlock();
	if (block == null || !block.getLocation().isPresent())
		return;
	
	Location<World> loc = block.getLocation().get();
	
	p.sendMessage(Text.of(TextColors.BLUE, "Querying database, please wait..."));
	if (loc.getTileEntity().isPresent() && loc.getTileEntity().get() instanceof TileEntityCarrier) {
		Sponge.getScheduler().createAsyncExecutor(plugin).execute(() -> {
			plugin.getInspectManager().inspectContainer(p, block.getWorldUniqueId(), loc.getBlockPosition()); });
	} else {
		Sponge.getScheduler().createAsyncExecutor(plugin).execute(() -> {
			plugin.getInspectManager().inspect(p, block.getWorldUniqueId(), loc.getBlockPosition().add(e.getTargetSide().asBlockOffset())); });
	}
}
 
開發者ID:Karanum,項目名稱:AdamantineShield,代碼行數:24,代碼來源:PlayerInspectListener.java

示例10: execute

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

示例11: execute

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

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

示例14: parseValue

import org.spongepowered.api.text.format.TextColors; //導入依賴的package包/類
@Nullable
@Override
protected Object parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException {
    String arg = args.next().toLowerCase();

    // Try
    GameRegistry registry = Sponge.getRegistry();
    Optional<? extends CatalogType> catalogType = registry.getType(this.type, arg);
    if (!catalogType.isPresent() && !arg.contains(":")) {
        catalogType = registry.getType(this.type, "minecraft:" + arg);
        if (!catalogType.isPresent()) {
            catalogType = registry.getType(this.type, "happytrails:" + arg);
        }
    }

    final String trimmedId = catalogType
        .map(trail -> trail.getId().contains(":") ? trail.getId().split(":")[1] : trail.getId())
        .orElse("");
    if (catalogType.isPresent() && source.hasPermission(this.permissionPrefix + trimmedId)) {
        return catalogType.get();
    }

    throw args.createError(Text.of(TextColors.RED, ""));
}
 
開發者ID:gabizou,項目名稱:HappyTrails,代碼行數:25,代碼來源:TrailCommands.java

示例15: getCrateKey

import org.spongepowered.api.text.format.TextColors; //導入依賴的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.format.TextColors類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。