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


Java Texts类代码示例

本文整理汇总了Java中org.spongepowered.api.text.Texts的典型用法代码示例。如果您正苦于以下问题:Java Texts类的具体用法?Java Texts怎么用?Java Texts使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: execute

import org.spongepowered.api.text.Texts; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args)
        throws CommandException {
    List<User> annointedUsers = AnnointmentDataManager
            .getAllAnnointedUsers().collect(Collectors.toList());
    if (annointedUsers.isEmpty()) {
        src.sendMessage(
                Texts.of(TextColors.RED, "No one has been annointed."));
    } else {
        PaginationBuilder builder = Sponge.getServiceManager()
                .provideUnchecked(PaginationService.class).builder();
        builder.title(Texts.of(TextColors.GREEN,
                "Annointed Users [Name (UUID) [Flags]]"));
        builder.contents(annointedUsersToContents(annointedUsers));
        builder.sendTo(src);
    }
    return CommandResult.success();
}
 
开发者ID:kenzierocks,项目名称:Annointment,代码行数:19,代码来源:ListCommand.java

示例2: execute

import org.spongepowered.api.text.Texts; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args)
        throws CommandException {
    Optional<String> subcmd =
            args.<String> getOne(Texts.toPlain(LEFTOVERS_KEY));
    if (subcmd.isPresent()) {
        String[] parts = subcmd.get().split(" ", 2);
        Optional<CommandCallable> callable =
                Optional.ofNullable(HIDDEN_CHILDREN.get(parts[0]));
        if (callable.isPresent()) {
            return callable.get().process(src, parts.length > 1 ? parts[1] : "");
        }
    }
    src.sendMessage(Texts
            .of("Not a command: " + subcmd.orElse("literally nothing")));
    return CommandResult.success();
}
 
开发者ID:kenzierocks,项目名称:Annointment,代码行数:18,代码来源:MasterCommand.java

示例3: completePartOfGroup

import org.spongepowered.api.text.Texts; //导入依赖的package包/类
private static void completePartOfGroup(Object key, boolean result) {
    GROUP_COUNT_DOWNS.remove(key);
    // essentially an AND
    GROUP_OK.replace(key, Boolean.TRUE, result);
    if (GROUP_COUNT_DOWNS.count(key) == 0) {
        try {
            if (GROUP_OK.get(key)) {
                GROUP_SOURCE.get(key).sendMessage(Texts.of("Boom~"));
            } else {
                GROUP_SOURCE.get(key).sendMessage(
                        Texts.of("Couldn't send all explosions :["));
            }
        } finally {
            GROUP_OK.remove(key);
            GROUP_SOURCE.remove(key);
        }
    }
}
 
开发者ID:kenzierocks,项目名称:Annointment,代码行数:19,代码来源:EasterEggCommand.java

示例4: execute

import org.spongepowered.api.text.Texts; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args)
        throws CommandException {
    if (!(src instanceof LocatedSource)) {
        src.sendMessage(Texts
                .of("Must be an in-world source to use this command."));
        return CommandResult.success();
    }
    Cause cause = Cause.of(src,
            // SpawnCause.builder().type(SpawnTypes.PLUGIN).build(),
            APlugin.getInstance());
    Location<World> loc = ((LocatedSource) src).getLocation();
    int count = args.<Integer> getOne(TIMES).orElse(1);
    Object groupKey = new Object();
    startGroup(groupKey, count, src);
    IntStream.range(0, count)
            .forEach(x -> createExplosion(groupKey, x, cause, loc));
    return CommandResult.success();
}
 
开发者ID:kenzierocks,项目名称:Annointment,代码行数:20,代码来源:EasterEggCommand.java

示例5: getSpec

import org.spongepowered.api.text.Texts; //导入依赖的package包/类
/**
 * Gets the spec of this branch containing all sub branches as childs
 * @return A new CommandSpec for this branch
 */
public CommandSpec getSpec(Game game) {
	DirectiveExecutor executor = new DirectiveExecutor(this.executor);
	CommandSpec.Builder spec = CommandSpec.builder();
	spec.executor(executor);
	
	if (this.executor != null) {
		Directive directive = this.executor.getAnnotation(Directive.class);
		spec.description(Texts.of(directive.description()));
		if (directive.permission() != "") {
			spec.permission(directive.permission());
		}
		ArgumentType[] args = directive.arguments();
		String[] labels = directive.argumentLabels();
		CommandElement[] elements = new CommandElement[args.length];
		for (int i = 0; i < args.length; i++) {
			elements[i] = args[i].construct(labels[i], game);
		}
		spec.arguments(elements);
	}
	
	for (DirectiveTree entry : this.subDirectives) {
		spec.child(entry.getSpec(game), entry.getLabel());
	}
	return spec.build();
}
 
开发者ID:mcardy,项目名称:Directive,代码行数:30,代码来源:DirectiveTree.java

示例6: commandMana

import org.spongepowered.api.text.Texts; //导入依赖的package包/类
@Directive(names = { "mana" }, description = "Displays your mana", inGameOnly = true)
public static CommandResult commandMana(CommandSource src, CommandContext context) {
	User user = Zephyr.getUserManager().getUser(((Player) src).getUniqueId());

	TextBuilder builder = Texts.builder("Mana " + user.getMana() + " / " + user.getMaximumMana() + ": [").color(
			TextColors.GRAY);
	int percent = (int) (((float) user.getMana() / (float) user.getMaximumMana()) * 10);
	TextBuilder tempBuilder = Texts.builder();
	tempBuilder.color(TextColors.AQUA);
	for (int i = 1; i <= 10; i++) {
		tempBuilder.append(Texts.of("="));
		if (i == percent) {
			builder.append(tempBuilder.build());
			tempBuilder = Texts.builder();
		}
	}
	tempBuilder.color(TextColors.DARK_GRAY);
	builder.append(tempBuilder.build());
	builder.append(Texts.of("]")).color(TextColors.GRAY);

	src.sendMessage(builder.build());
	return CommandResult.success();
}
 
开发者ID:mcardy,项目名称:Zephyr,代码行数:24,代码来源:UserCommand.java

示例7: commandProgress

import org.spongepowered.api.text.Texts; //导入依赖的package包/类
@Directive(names = { "progress" }, description = "Displays your progress", inGameOnly = true)
public static CommandResult commandProgress(CommandSource src, CommandContext context) {
	User user = Zephyr.getUserManager().getUser(((Player) src).getUniqueId());

	TextBuilder builder = Texts.builder(
			"Progress " + user.getUserData().getLevelProgress() + " / " + user.getRequiredLevelProgress() + ": [")
			.color(TextColors.GRAY);
	float percent = ((float) user.getUserData().getLevelProgress() / (float) user.getRequiredLevelProgress()) * 10;
	TextBuilder tempBuilder = Texts.builder();
	tempBuilder.color(TextColors.GREEN);
	for (int i = 0; i < 10; i++) {
		tempBuilder.append(Texts.of("="));
		if (i == (int)percent) {
			builder.append(tempBuilder.build());
			tempBuilder = Texts.builder();
		}
	}
	tempBuilder.color(TextColors.DARK_GRAY);
	builder.append(tempBuilder.build());
	builder.append(Texts.of("] Level " + user.getUserData().getLevel())).color(TextColors.GRAY);

	src.sendMessage(builder.build());
	return CommandResult.success();
}
 
开发者ID:mcardy,项目名称:Zephyr,代码行数:25,代码来源:UserCommand.java

示例8: commandManaRestore

import org.spongepowered.api.text.Texts; //导入依赖的package包/类
@Directive(names = { "mana.restore" }, description = "Restores your mana", inGameOnly = true, argumentLabels = { "target" }, arguments = { ArgumentType.OPTIONAL_STRING })
public static CommandResult commandManaRestore(CommandSource src, CommandContext context) {
	User target = null;
	if (!context.getOne("target").isPresent()) {
		target = Zephyr.getUserManager().getUser(((Player) src).getUniqueId());
	} else {
		Player player = null;
		if ((player = ZephyrPlugin.getGame().getServer().getPlayer(context.<String> getOne("target").get()).get()) != null) {
			target = Zephyr.getUserManager().getUser(player.getUniqueId());
		} else {
			target = Zephyr.getUserManager().getUser(((Player) src).getUniqueId());
		}
	}

	target.setMana(target.getMaximumMana());
	target.<Player> getPlayer().sendMessage(Texts.builder("Mana restored!").color(TextColors.AQUA).build());

	return CommandResult.success();
}
 
开发者ID:mcardy,项目名称:Zephyr,代码行数:20,代码来源:UserCommand.java

示例9: getResults

import org.spongepowered.api.text.Texts; //导入依赖的package包/类
@Override
public CopyOnWriteArrayList<? extends SearchResult> getResults(String query) throws IOException {
    if (this.apiKey.isEmpty()) {
        throw new IOException("engines.google.auth.api-key in ./config/enquiry.conf must be set in order to search with Google!");
    }
    if (this.searchId.isEmpty()) {
        throw new IOException("engines.google.auth.search-id in ./config/enquiry.conf must be set in order to search with Google!");
    }
    final HttpRequest request = getRequest(query);
    if (request.code() != 200) {
        throw new IOException("An error occurred while attempting to get results from " + Texts.toPlain(this.getName()) + ", Error: " + request
                .code());
    } else if (request.isBodyEmpty()) {
        throw new IOException("An error occurred while attempting to get results from " + Texts.toPlain(this.getName()) + ", Error: Body is "
                + "empty.");
    }
    return new Gson().fromJson(request.body(), GoogleEngine.class).results;
}
 
开发者ID:InspireNXE,项目名称:Enquiry-Legacy,代码行数:19,代码来源:GoogleEngine.java

示例10: onServerAboutToStart

import org.spongepowered.api.text.Texts; //导入依赖的package包/类
@Subscribe
public void onServerAboutToStart(ServerAboutToStartEvent event) throws IOException {
    storage = new Storage(configuration, loader).load();

    final List<String> bingAliases = storage.getChildNode("engines.bing.options.aliases").getList(Types::asString);
    new BingEngine("bing", bingAliases.toArray(new String[bingAliases.size()])).register();

    final List<String> duckduckgoAliases = storage.getChildNode("engines.duckduckgo.options.aliases").getList(Types::asString);
    new DuckDuckGoEngine("duckduckgo", duckduckgoAliases.toArray(new String[duckduckgoAliases.size()])).register();

    final List<String> googleAliases = storage.getChildNode("engines.google.options.aliases").getList(Types::asString);
    new GoogleEngine("google", googleAliases.toArray(new String[googleAliases.size()])).register();

    // Fire SearchEngineRegistrationEvent to register search engines
    this.game.getEventManager().post(new SearchEngineRegistrationEvent(engines));

    // Register commands for registered engines
    final Map<List<String>, CommandSpec> children = Maps.newHashMap();
    for (SearchEngine engine : engines) {
        this.game.getCommandDispatcher().register(this, engine.getCommandSpec(), engine.getAliases());
        children.put(engine.getAliases(), engine.getCommandSpec());
        this.logger.info("Registered [" + Texts.toPlain(engine.getName()) + "] with aliases " + engine.getAliases());
    }
    this.game.getCommandDispatcher().register(this, CommandSpec.builder().children(children).build(), "enquiry", "eq");
}
 
开发者ID:InspireNXE,项目名称:Enquiry-Legacy,代码行数:26,代码来源:Enquiry.java

示例11: damageCheck

import org.spongepowered.api.text.Texts; //导入依赖的package包/类
/**
 * Attempts to damage the defending LivingEntity, this allows for various protection plugins to
 * cancel damage events.
 *
 * @param attacking  attempting to deal the damage
 * @param defenderLE entity being damaged
 *
 * @return true if the damage check was successful
 */
public static boolean damageCheck(Insentient attacking, Living defenderLE) {
    if (attacking.getEntity().get().equals(defenderLE)) {
        return false;
    }
    if (defenderLE instanceof Player && attacking instanceof Champion) {
        if (!attacking.getWorld().getProperties().isPVPEnabled()) {
            ((Champion) attacking).sendMessage(Texts.of(TextColors.RED, "PVP is disabled!"));
            return false;
        }
    }
    DamageEntityEvent event = SpongeEventFactory
            .createDamageEntityEvent(Cause.of(NamedCause.source(DamageSource.builder().type
                    (DamageTypes.MAGIC))),
                                     ImmutableList.<Tuple<DamageModifier, Function<? super Double, Double>>>of(),
                                     defenderLE, 0);
    Sponge.getEventManager().post(event);
    return event.isCancelled();
}
 
开发者ID:AfterKraft,项目名称:KraftRPG-API,代码行数:28,代码来源:SkillUtils.java

示例12: getArguments

import org.spongepowered.api.text.Texts; //导入依赖的package包/类
@Override
public CommandElement getArguments() {
    return GenericArguments.flags()
            .buildWith(GenericArguments.firstParsing(
                    GenericArguments.player(Texts.of(ADD)),
                    GenericArguments.string(Texts.of(ADD))));
}
 
开发者ID:kenzierocks,项目名称:Annointment,代码行数:8,代码来源:RemoveCommand.java

示例13: userToContents

import org.spongepowered.api.text.Texts; //导入依赖的package包/类
private Stream<Text> userToContents(User user) {
    Stream<Text> basicData = Stream.of(getUserName(user),
            Texts.of(getColorForUserOnlineStatus(user),
                    " (" + user.getUniqueId() + ")"));
    Stream<Text> flags = AnnointmentDataManager.getAnnointmentFlags(user)
            .stream().map(flag -> Texts.of(FOUR_SPACES + flag.toString()));
    return Stream.concat(basicData, flags);
}
 
开发者ID:kenzierocks,项目名称:Annointment,代码行数:9,代码来源:ListCommand.java

示例14: getUserName

import org.spongepowered.api.text.Texts; //导入依赖的package包/类
private Text getUserName(User user) {
    // online -> green name/uuid, offline -> red name/uuid
    return user.getPlayer().flatMap(x -> x.get(DisplayNameData.class))
            .flatMap(x -> x.displayName().getDirect())
            .orElse(Texts.of(user.getName())).toBuilder()
            .color(getColorForUserOnlineStatus(user)).style(TextStyles.BOLD)
            .build();
}
 
开发者ID:kenzierocks,项目名称:Annointment,代码行数:9,代码来源:ListCommand.java

示例15: onPlayerJoin

import org.spongepowered.api.text.Texts; //导入依赖的package包/类
@Subscribe
private void onPlayerJoin(PlayerJoinEvent event)
{
    if (this.msg != null) {
        event.getPlayer().sendMessage(Texts.of(this.msg));
    }
}
 
开发者ID:spbp,项目名称:api-plugin-boilerplate,代码行数:8,代码来源:SimpleNotificationService.java


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