本文整理汇总了Java中org.spongepowered.api.text.format.TextFormat类的典型用法代码示例。如果您正苦于以下问题:Java TextFormat类的具体用法?Java TextFormat怎么用?Java TextFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextFormat类属于org.spongepowered.api.text.format包,在下文中一共展示了TextFormat类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getLastFormat
import org.spongepowered.api.text.format.TextFormat; //导入依赖的package包/类
/**
* Get the last TextFormat object for a text and it's children.
*/
public static TextFormat getLastFormat(Text text) {
if (text.getChildren().isEmpty()) {
return text.getFormat();
}
return text.getChildren().stream().map(t -> t.getFormat()).reduce((t, t2) -> t.merge(t2))
.orElse(text.getFormat());
}
开发者ID:rojo8399,项目名称:PlaceholderAPI,代码行数:11,代码来源:TextUtils.java
示例2: addDefaultAddons
import org.spongepowered.api.text.format.TextFormat; //导入依赖的package包/类
private void addDefaultAddons(Player player) {
TextFormat link = TextFormat.of(TextColors.BLUE, TextStyles.UNDERLINE);
if (player.hasPermission(PERM_KICK)) {
addAddon(listPlayer -> Text.builder("Kick").format(link).onClick(Utils.execClick(view -> listPlayer.kick())).build());
}
if (player.hasPermission(PERM_BAN)) {
addAddon(listPlayer -> Text.builder("Ban").format(link)
.onClick(Utils.execClick(view -> Sponge.getServiceManager().provideUnchecked(BanService.class).addBan(Ban.of(listPlayer.getProfile()))))
.build());
}
}
开发者ID:simon816,项目名称:ChatUI,代码行数:12,代码来源:PlayerList.java
示例3: Format
import org.spongepowered.api.text.format.TextFormat; //导入依赖的package包/类
public Format(Format parent, Text text) {
this.format = TextFormat.of(text.getColor() == TextColors.NONE ? parent.format.getColor() : text.getColor(),
inheritStyle(parent.format.getStyle(), text.getStyle()));
this.onClick = text.getClickAction().orElse(parent.onClick);
this.onHover = text.getHoverAction().orElse(parent.onHover);
this.onShiftClick = text.getShiftClickAction().orElse(parent.onShiftClick);
}
开发者ID:simon816,项目名称:ChatUI,代码行数:8,代码来源:TextSplitter.java
示例4: getLastFormat
import org.spongepowered.api.text.format.TextFormat; //导入依赖的package包/类
public static TextFormat getLastFormat(Text.Builder text) {
if (text.getChildren().isEmpty()) {
return text.getFormat();
} else {
return EChat.getLastFormat(text.getChildren().get(text.getChildren().size() - 1));
}
}
开发者ID:EverCraft,项目名称:EverAPI,代码行数:8,代码来源:EChat.java
示例5: registerDefaults
import org.spongepowered.api.text.format.TextFormat; //导入依赖的package包/类
@EarlyRegistration
@Override
public void registerDefaults() {
try {
// Make sure that the color is updated properly
final Field colorField = TextFormat.class.getDeclaredField("color");
final Field styleField = TextFormat.class.getDeclaredField("style");
ReflectionHelper.setField(colorField, TextFormat.NONE, TextColors.NONE);
ReflectionHelper.setField(styleField, TextFormat.NONE, TextStyles.NONE);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:14,代码来源:TextFormatRegistryModule.java
示例6: LanternAdvancement
import org.spongepowered.api.text.format.TextFormat; //导入依赖的package包/类
LanternAdvancement(LanternAdvancementBuilder builder) {
super(CauseStack.current().first(PluginContainer.class).get().getId(), builder.id,
builder.name == null ? (builder.displayInfo != null ?
builder.displayInfo.getTitle().toPlain() : builder.id) : builder.name);
this.layoutElement = builder.displayInfo == null ? null : new LanternTreeLayoutElement(this);
this.displayInfo = builder.displayInfo;
this.criterion = builder.criterion;
this.parent = builder.parent;
if (this.parent != null) {
((LanternAdvancement) this.parent).children.add(this);
}
// Cache the client criteria
this.clientCriteria = LanternPlayerAdvancements.createCriteria(builder.criterion);
final ImmutableList.Builder<Text> toastBuilder = ImmutableList.builder();
if (builder.displayInfo == null) {
this.text = Text.of(getName());
toastBuilder.add(Text.of("Achieved: ", this.text));
} else {
final AdvancementType type = builder.displayInfo.getType();
final TextFormat format = type.getTextFormat();
toastBuilder.add(Text.builder(tr("advancements.toast." + type.getName().toLowerCase()))
.format(format).build());
final Text title = builder.displayInfo.getTitle();
toastBuilder.add(title);
final Text description = builder.displayInfo.getDescription();
final Text.Builder hoverBuilder = Text.builder()
.append(title.toBuilder().format(format).build());
if (!description.isEmpty()) {
hoverBuilder.append(Text.NEW_LINE, description);
}
this.text = Text.builder()
.append(Text.of("["))
.append(Text.of(title.toBuilder().onHover(TextActions.showText(hoverBuilder.build()))))
.append(Text.of("]"))
.format(format)
.build();
}
this.toast = toastBuilder.build();
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:40,代码来源:LanternAdvancement.java
示例7: list
import org.spongepowered.api.text.format.TextFormat; //导入依赖的package包/类
@Command(desc = "Lists all worlds")
@Alias("listworlds")
public void list(CommandSource context)
{
i18n.send(context, POSITIVE, "The following worlds do exist:");
String tNotLoaded = i18n.getTranslation(context.getLocale(), "not loaded");
String tNotEnabled = i18n.getTranslation(context.getLocale(), "not enabled");
Sponge.getServer().getAllWorldProperties().stream().sorted((o1, o2) -> o1.getWorldName().compareTo(o2.getWorldName())).forEach(prop ->
{
Text.Builder builder = Text.of(" - ", GOLD, prop.getWorldName(), " ", DARK_AQUA, prop.getDimensionType().getName()).toBuilder();
Text infoText = Text.of(YELLOW, "(?)").toBuilder().onClick(TextActions.runCommand("/worlds info " + prop.getWorldName()))
.onHover(TextActions.showText(i18n.translate(context, TextFormat.NONE, "Click to show world info")))
.build();
if (!Sponge.getServer().getWorld(prop.getWorldName()).isPresent())
{
builder.append(Text.of(" "));
if (prop.isEnabled())
{
builder.append(Text.of(RED, tNotLoaded)).append(Text.of(" "))
.append(Text.of(YELLOW, "(", i18n.translate(context, TextFormat.NONE, "load"), ")").toBuilder()
.onClick(TextActions.runCommand("/worlds load " + prop.getWorldName())).build());
}
else
{
builder.append(Text.of(RED, tNotEnabled));
}
}
builder.append(Text.of(" ")).append(infoText);
context.sendMessage(builder.build());
});
}
开发者ID:CubeEngine,项目名称:modules-main,代码行数:34,代码来源:WorldsCommands.java
示例8: openFilter
import org.spongepowered.api.text.format.TextFormat; //导入依赖的package包/类
private void openFilter(Player player, DuctData ductData, Direction dir, Location<World> loc)
{
if (!player.hasPermission(viewFilterPerm.getId()))
{
i18n.send(ChatTypes.ACTION_BAR, player, NEGATIVE, "You are not allowed to edit filters");
return;
}
List<ItemStack> list = ductData.get(dir).get();
DuctFilterCarrier carrier = new DuctFilterCarrier(ductData, loc, dir);
boolean canEdit = player.hasPermission(editFilterPerm.getId());
Inventory inventory = Inventory.builder()
.property(InventoryTitle.PROPERTY_NAME,
InventoryTitle.of(canEdit ? i18n.translate(player, TextFormat.NONE, "ItemDuct Filters") :
i18n.translate(player, TextFormat.NONE, "View ItemDuct Filters")))
.withCarrier(carrier)
.build(plugin);
carrier.init(((CarriedInventory<?>) inventory));
for (ItemStack itemStack : list)
{
inventory.offer(itemStack);
}
Sponge.getCauseStackManager().pushCause(player);
if (canEdit)
{
player.openInventory(inventory);
}
else
{
igf.prepareInv(inventory, player.getUniqueId()).blockPutInAll().blockTakeOutAll().submitInventory(Itemduct.class, true);
}
player.getProgress(module.filters).grant();
}
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:36,代码来源:ItemDuctFilterListener.java
示例9: fix
import org.spongepowered.api.text.format.TextFormat; //导入依赖的package包/类
private static Text fix(Text to, TextFormat l) {
return to.toBuilder().format(l.merge(to.getFormat())).build();
}
开发者ID:rojo8399,项目名称:PlaceholderAPI,代码行数:4,代码来源:TextUtils.java
示例10: getTextFormat
import org.spongepowered.api.text.format.TextFormat; //导入依赖的package包/类
public static TextFormat getTextFormat(final String arg){
return EChat.getLastFormat(EChat.of(arg + "\uE000"));
}
开发者ID:EverCraft,项目名称:EverAPI,代码行数:4,代码来源:EChat.java
示例11: registerDefaults
import org.spongepowered.api.text.format.TextFormat; //导入依赖的package包/类
@Override
public void registerDefaults() {
register(new LanternAdvancementType("minecraft", "task", 0, TextFormat.of(TextColors.YELLOW)));
register(new LanternAdvancementType("minecraft", "challenge", 1, TextFormat.of(TextColors.LIGHT_PURPLE)));
register(new LanternAdvancementType("minecraft", "goal", 2, TextFormat.of(TextColors.YELLOW)));
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:7,代码来源:AdvancementTypeRegistryModule.java
示例12: LanternAdvancementType
import org.spongepowered.api.text.format.TextFormat; //导入依赖的package包/类
public LanternAdvancementType(String pluginId, String name, int internalId, TextFormat textFormat) {
super(pluginId, name, internalId);
this.textFormat = textFormat;
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:LanternAdvancementType.java
示例13: getTextFormat
import org.spongepowered.api.text.format.TextFormat; //导入依赖的package包/类
@Override
public TextFormat getTextFormat() {
return this.textFormat;
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:LanternAdvancementType.java
示例14: create
import org.spongepowered.api.text.format.TextFormat; //导入依赖的package包/类
@Command(desc = "Creates a new world")
public void create(CommandSource context,
String name,
@Default @Named({"dimension", "dim"}) DimensionType dimension,
@Named("seed") String seed,
@Default @Named({"type"}) GeneratorType type,
@Default @Label("generate") @Named({"structure", "struct"}) boolean generateStructures,
@Default @Named({"gamemode", "mode"}) GameMode gamemode,
@Default @Named({"difficulty", "diff"}) Difficulty difficulty,
@org.cubeengine.butler.parametric.Optional @Label("name") @Named({"generator","gen"}) WorldGeneratorModifier generator,
@Flag boolean recreate,
@Flag boolean noload,
@Flag boolean spawnInMemory)
{
Optional<World> world = Sponge.getServer().getWorld(name);
if (world.isPresent())
{
if (recreate)
{
i18n.send(context, NEGATIVE, "You have to unload a world before recreating it!");
return;
}
i18n.send(context, NEGATIVE, "A world named {world} already exists and is loaded!", world.get());
return;
}
Optional<WorldProperties> worldProperties = Sponge.getServer().getWorldProperties(name);
if (worldProperties.isPresent())
{
if (!recreate)
{
i18n.send(context, NEGATIVE, "A world named {name#world} already exists but is not loaded!", name);
return;
}
worldProperties.get().setEnabled(false);
String newName = name + "_" + new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new Date());
Sponge.getServer().renameWorld(worldProperties.get(), newName);
i18n.send(context, POSITIVE, "Old world moved to {name#folder}", newName);
}
WorldArchetype.Builder builder = WorldArchetype.builder().from(WorldArchetypes.OVERWORLD);
builder.keepsSpawnLoaded(spawnInMemory);
builder.loadsOnStartup(!noload);
if (seed != null)
{
try
{
builder.seed(Long.parseLong(seed));
}
catch (NumberFormatException ignore)
{
builder.seed(seed.hashCode());
}
}
builder.generator(type);
builder.dimension(dimension);
builder.usesMapFeatures(generateStructures);
builder.gameMode(gamemode);
if (generator != null)
{
builder.generatorModifiers(generator);
}
builder.difficulty(difficulty);
try
{
WorldProperties properties = Sponge.getServer().createWorldProperties(name, builder.build("org.cubeengine.customworld:" + UUID.randomUUID().toString(), name));
i18n.send(context, POSITIVE, "World {name} successfully created!", name);
i18n.send(context, NEUTRAL, "This world is not yet loaded! Click {txt#here} to load.",
i18n.translate(context, TextFormat.NONE, "here").toBuilder().onClick(TextActions.runCommand("/worlds load " + name)).build());
}
catch (IOException e)
{
i18n.send(context, NEGATIVE, "Could not create world!");
throw new IllegalStateException(e); // TODO handle exception better
}
}
开发者ID:CubeEngine,项目名称:modules-main,代码行数:77,代码来源:WorldsCommands.java
示例15: info
import org.spongepowered.api.text.format.TextFormat; //导入依赖的package包/类
@Command(desc = "Show info about a world")
public void info(CommandSource context, @Default WorldProperties world, @Flag boolean showGameRules)
{
context.sendMessage(Text.EMPTY);
i18n.send(context, POSITIVE, "World information for {world}:", world);
if (!world.isEnabled())
{
i18n.send(context, NEUTRAL, "This world is disabled.");
}
else if (!Sponge.getServer().getWorld(world.getUniqueId()).isPresent())
{
Text load = Text.of("(", i18n.translate(context, TextFormat.NONE, "load"), ")").toBuilder()
.onClick(TextActions.runCommand("/worlds load " + world.getWorldName())).build();
i18n.send(context, NEGATIVE, "This world is not loaded. {txt#load}", load);
}
if (!world.isInitialized())
{
i18n.send(context, NEUTRAL, "This world has not been initialized.");
}
i18n.send(context, NEUTRAL, "Gamemode: {input}", world.getGameMode().getTranslation());
i18n.send(context, NEUTRAL, "DimensionType: {input}", world.getDimensionType().getName());
if (world.usesMapFeatures())
{
i18n.send(context, NEUTRAL, "WorldType: {input} with structures", world.getGeneratorType().getName());
}
else
{
i18n.send(context, NEUTRAL, "WorldType: {input} no structures", world.getGeneratorType().getName());
}
i18n.send(context, NEUTRAL, "Difficulty {input}", world.getDifficulty().getTranslation());
if (world.isHardcore())
{
i18n.send(context, NEUTRAL, "Hardcoremode active");
}
if (!world.isPVPEnabled())
{
i18n.send(context, NEUTRAL, "PVP disabled");
}
if (!world.areCommandsAllowed() && Sponge.getPlatform().getType() == Type.CLIENT)
{
i18n.send(context, NEUTRAL, "Commands are not allowed");
}
i18n.send(context, NEUTRAL, "Seed: {long}", world.getSeed());
if (!world.getGeneratorModifiers().isEmpty())
{
i18n.send(context, NEUTRAL, "Generation is modified by:");
for (WorldGeneratorModifier modifier : world.getGeneratorModifiers())
{
context.sendMessage(Text.of(YELLOW, " - ", GOLD, modifier.getName()).toBuilder().onHover(TextActions.showText(Text.of(GOLD, modifier.getId()))).build());
}
}
if (!world.loadOnStartup())
{
i18n.send(context, NEUTRAL, "This world will not load automatically on startup!");
}
Vector3i spawn = world.getSpawnPosition();
i18n.send(context, NEUTRAL, "This worlds spawn is at {vector}", new Vector3i(spawn.getX(), spawn.getY(), spawn.getZ()));
if (showGameRules && !world.getGameRules().isEmpty()) // Show gamerules
{
i18n.send(context, NEUTRAL, "The following game-rules are set:");
for (Entry<String, String> entry : world.getGameRules().entrySet())
{
context.sendMessage(Text.of(YELLOW, entry.getKey(), ": ", GOLD, entry.getValue()));
}
}
}
开发者ID:CubeEngine,项目名称:modules-main,代码行数:69,代码来源:WorldsCommands.java
示例16: list
import org.spongepowered.api.text.format.TextFormat; //导入依赖的package包/类
@Alias(value = "listurole")
@Command(desc = "Lists roles of a user")
public void list(CommandSource ctx, @Default User player)
{
List<SubjectReference> parents = player.getSubjectData().getParents(GLOBAL_CONTEXT);
List<SubjectReference> transientParents = player.getTransientSubjectData().getParents(GLOBAL_CONTEXT);
Text translation = i18n.translate(ctx, NEUTRAL, "Roles of {user}:", player);
if (ctx.hasPermission("cubeengine.roles.command.roles.user.assign"))
{
translation = translation.toBuilder().append(Text.of(" ")).append(
i18n.translate(ctx, POSITIVE, "(+)").toBuilder().onClick(TextActions.executeCallback(
sender -> {
i18n.send(sender, POSITIVE, "Click on the role you want to add to {user}.", player);
for (Subject subject : service.getGroupSubjects().getLoadedSubjects())
{
// TODO perm check for each role
if (!parents.contains(subject.asSubjectReference()) && subject instanceof FileSubject)
{
sender.sendMessage(Text.of(YELLOW, " - ", subject.getIdentifier()).toBuilder().onClick(
TextActions.runCommand("/roles user assign " + player.getName() + " " + subject.getIdentifier())).build());
}
}
})).onHover(showText(i18n.translate(ctx, POSITIVE, "Click to add role"))).build()).build();
}
ctx.sendMessage(translation);
if (ctx.hasPermission("cubeengine.roles.command.roles.user.remove"))
{
Text removeText1 = i18n.translate(ctx, NEGATIVE, "Click to remove role.");
parents.stream().map(p -> {
try{
return p.resolve().get();
}
catch (ExecutionException | InterruptedException e) {
throw new IllegalStateException(e);
}
}).forEach(parent -> {
// TODO perm check for each role
Text removeText = Text.of(RED, "(-)").toBuilder().onClick(TextActions.executeCallback(sender -> {
i18n.send(sender, NEGATIVE, "Do you really want to remove {role} from {user}?", parent, player);
ctx.sendMessage(i18n.translate(sender, TextFormat.NONE, "Confirm").toBuilder().color(DARK_GREEN).onClick(
TextActions.runCommand("/roles user remove " + player.getName() + " " + parent.getIdentifier())).build());
})).onHover(showText(removeText1)).build();
ctx.sendMessage(Text.of("- ", GOLD, parent.getIdentifier(), " ", removeText));
});
}
else
{
parents.forEach(parent -> ctx.sendMessage(Text.of("- ", GOLD, parent.getSubjectIdentifier())));
}
String transientText = i18n.getTranslation(ctx, "transient");
transientParents.forEach(parent -> ctx.sendMessage(Text.of("- ", GOLD, parent.getSubjectIdentifier(), GRAY, " (", YELLOW, transientText, GRAY, ")")));
}
开发者ID:CubeEngine,项目名称:modules-main,代码行数:58,代码来源:UserInformationCommands.java
示例17: executeShowInfo
import org.spongepowered.api.text.format.TextFormat; //导入依赖的package包/类
public void executeShowInfo(MarketSignData data, Player player, Location<World> loc)
{
boolean inEditMode = isInEditMode(loc);
if (inEditMode)
{
player.sendMessage(Text.of());
i18n.send(player, NONE, "-- {text:Sign Market:color=PURPLE} - {text:Edit Mode:color=PURPLE} --");
}
else
{
player.sendMessage(Text.of());
i18n.send(player, NONE, "--------- {text:Sign Market} ---------");
}
if (data.getSignType() == null)
{
player.sendMessage(Text.of(DARK_PURPLE, "new Sign"));
return;
}
int amount = data.getAmount() == null ? 0 : data.getAmount();
Text amountText = Text.of(String.valueOf(amount));
if (amount == 0)
{
amountText = Text.of(TextColors.RED, "??");
}
if (data.getSignType() == SignType.BUY)
{
i18n.send(player, NONE, "{text:Buy:color=DARK_BLUE}: {txt#amount} for {txt#price} from {user#owner}",
amountText, formatPrice(data), getOwnerName(data));
}
else
{
i18n.send(player, NONE, "{text:Sell:color=DARK_BLUE}: {txt#amount} for {txt#price} to {user#owner}",
amountText, formatPrice(data), getOwnerName(data));
}
if (data.getItem() == null)
{
if (inEditMode)
{
i18n.send(player, TextFormat.of(TextColors.DARK_PURPLE), "No Item");
}
else
{
i18n.send(player, TextFormat.of(TextColors.DARK_RED), "No Item");
}
}
else
{
Text itemText = getItemText(data, inEditMode).toBuilder().color(GOLD).onHover(TextActions.showItem(data.getItem().createSnapshot())).build();
player.sendMessage(itemText);
}
if (data.getStock() != null)
{
if (data.getDemand() == null && data.getSize() != null && data.getSize() == -1)
{
i18n.send(player, NEUTRAL, "In stock: {amount}/{text:Infinite}", data.getStock());
}
else if (data.getItem() == null || data.getAmount() == null || data.getAmount() == 0)
{
i18n.send(player, NEUTRAL, "In stock: {amount}/{text:Unknown:color=RED}", data.getStock());
}
else
{
i18n.send(player, NEUTRAL, "In stock: {amount}/{amount#max}", data.getStock(), data.getMax());
}
}
}
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:71,代码来源:MarketSignManager.java
示例18: hasStyle
import org.spongepowered.api.text.format.TextFormat; //导入依赖的package包/类
private static boolean hasStyle(final Text text) {
return text.getFormat() != TextFormat.NONE || text.getHoverAction().isPresent() || text.getClickAction().isPresent() || text.getShiftClickAction().isPresent();
}
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:4,代码来源:TextSimplifier.java
注:本文中的org.spongepowered.api.text.format.TextFormat类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论