use of org.spongepowered.api.text.serializer.TextParseException in project LanternServer by LanternPowered.
the class CommandTitle method completeSpec.
@Override
public void completeSpec(PluginContainer pluginContainer, CommandSpec.Builder specBuilder) {
specBuilder.arguments(GenericArguments.playerOrSource(Text.of("player"))).child(CommandSpec.builder().executor((src, args) -> {
args.<Player>getOne("player").get().clearTitle();
src.sendMessage(t("commands.title.success"));
return CommandResult.success();
}).build(), "clear").child(CommandSpec.builder().arguments(GenericArguments2.remainingString(Text.of("title"))).executor((src, args) -> {
Text title;
try {
title = TextSerializers.JSON.deserialize(args.<String>getOne("title").get());
} catch (TextParseException e) {
throw new CommandException(t("commands.tellraw.jsonException", e.getMessage()));
}
args.<Player>getOne("player").get().sendTitle(Title.builder().title(title).build());
src.sendMessage(t("commands.title.success"));
return CommandResult.success();
}).build(), "title").child(CommandSpec.builder().arguments(GenericArguments2.remainingString(Text.of("title"))).executor((src, args) -> {
Text title;
try {
title = TextSerializers.JSON.deserialize(args.<String>getOne("title").get());
} catch (TextParseException e) {
throw new CommandException(t("commands.tellraw.jsonException", e.getMessage()));
}
args.<Player>getOne("player").get().sendTitle(Title.builder().subtitle(title).build());
src.sendMessage(t("commands.title.success"));
return CommandResult.success();
}).build(), "subtitle").child(CommandSpec.builder().executor((src, args) -> {
args.<Player>getOne("player").get().resetTitle();
src.sendMessage(t("commands.title.success"));
return CommandResult.success();
}).build(), "reset").child(CommandSpec.builder().arguments(GenericArguments.integer(Text.of("fadeIn")), GenericArguments.integer(Text.of("stay")), GenericArguments.integer(Text.of("fadeOut"))).executor((src, args) -> {
args.<Player>getOne("player").get().sendTitle(Title.builder().fadeIn(args.<Integer>getOne("fadeIn").get()).stay(args.<Integer>getOne("stay").get()).fadeOut(args.<Integer>getOne("fadeOut").get()).build());
src.sendMessage(t("commands.title.success"));
return CommandResult.success();
}).build(), "times");
}
Aggregations