当前位置: 首页>>代码示例>>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;未经允许,请勿转载。