📦 Update minecraft-extras for Adventure 4.0.0
This commit is contained in:
parent
79bb017fd3
commit
6f0940ebd4
4 changed files with 24 additions and 14 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
dependencies {
|
dependencies {
|
||||||
api project(':cloud-core')
|
api project(':cloud-core')
|
||||||
api 'net.kyori:adventure-api:4.0.0-SNAPSHOT'
|
api 'net.kyori:adventure-api:4.0.0'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import cloud.commandframework.exceptions.InvalidCommandSenderException;
|
||||||
import cloud.commandframework.exceptions.InvalidSyntaxException;
|
import cloud.commandframework.exceptions.InvalidSyntaxException;
|
||||||
import cloud.commandframework.exceptions.NoPermissionException;
|
import cloud.commandframework.exceptions.NoPermissionException;
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
|
import net.kyori.adventure.identity.Identity;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
@ -186,6 +187,7 @@ public final class MinecraftExceptionHandler<C> {
|
||||||
manager.registerExceptionHandler(
|
manager.registerExceptionHandler(
|
||||||
InvalidSyntaxException.class,
|
InvalidSyntaxException.class,
|
||||||
(c, e) -> audienceMapper.apply(c).sendMessage(
|
(c, e) -> audienceMapper.apply(c).sendMessage(
|
||||||
|
Identity.nil(),
|
||||||
this.decorator.apply(this.componentBuilders.get(ExceptionType.INVALID_SYNTAX).apply(e))
|
this.decorator.apply(this.componentBuilders.get(ExceptionType.INVALID_SYNTAX).apply(e))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
@ -194,6 +196,7 @@ public final class MinecraftExceptionHandler<C> {
|
||||||
manager.registerExceptionHandler(
|
manager.registerExceptionHandler(
|
||||||
InvalidCommandSenderException.class,
|
InvalidCommandSenderException.class,
|
||||||
(c, e) -> audienceMapper.apply(c).sendMessage(
|
(c, e) -> audienceMapper.apply(c).sendMessage(
|
||||||
|
Identity.nil(),
|
||||||
this.decorator.apply(this.componentBuilders.get(ExceptionType.INVALID_SENDER).apply(e))
|
this.decorator.apply(this.componentBuilders.get(ExceptionType.INVALID_SENDER).apply(e))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
@ -202,6 +205,7 @@ public final class MinecraftExceptionHandler<C> {
|
||||||
manager.registerExceptionHandler(
|
manager.registerExceptionHandler(
|
||||||
NoPermissionException.class,
|
NoPermissionException.class,
|
||||||
(c, e) -> audienceMapper.apply(c).sendMessage(
|
(c, e) -> audienceMapper.apply(c).sendMessage(
|
||||||
|
Identity.nil(),
|
||||||
this.decorator.apply(this.componentBuilders.get(ExceptionType.NO_PERMISSION).apply(e))
|
this.decorator.apply(this.componentBuilders.get(ExceptionType.NO_PERMISSION).apply(e))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
@ -210,6 +214,7 @@ public final class MinecraftExceptionHandler<C> {
|
||||||
manager.registerExceptionHandler(
|
manager.registerExceptionHandler(
|
||||||
ArgumentParseException.class,
|
ArgumentParseException.class,
|
||||||
(c, e) -> audienceMapper.apply(c).sendMessage(
|
(c, e) -> audienceMapper.apply(c).sendMessage(
|
||||||
|
Identity.nil(),
|
||||||
this.decorator.apply(this.componentBuilders.get(ExceptionType.ARGUMENT_PARSING).apply(e))
|
this.decorator.apply(this.componentBuilders.get(ExceptionType.ARGUMENT_PARSING).apply(e))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import cloud.commandframework.CommandHelpHandler;
|
||||||
import cloud.commandframework.CommandManager;
|
import cloud.commandframework.CommandManager;
|
||||||
import cloud.commandframework.arguments.CommandArgument;
|
import cloud.commandframework.arguments.CommandArgument;
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
|
import net.kyori.adventure.identity.Identity;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
|
|
@ -268,14 +269,14 @@ public final class MinecraftHelp<C> {
|
||||||
) {
|
) {
|
||||||
final Audience audience = this.getAudience(sender);
|
final Audience audience = this.getAudience(sender);
|
||||||
if (helpTopic.isEmpty()) {
|
if (helpTopic.isEmpty()) {
|
||||||
audience.sendMessage(this.basicHeader(sender));
|
audience.sendMessage(Identity.nil(), this.basicHeader(sender));
|
||||||
audience.sendMessage(Component.text(
|
audience.sendMessage(Identity.nil(), Component.text(
|
||||||
this.messageProvider.apply(sender, MESSAGE_NO_RESULTS_FOR_QUERY) + ": \"",
|
this.messageProvider.apply(sender, MESSAGE_NO_RESULTS_FOR_QUERY) + ": \"",
|
||||||
this.colors.text
|
this.colors.text
|
||||||
)
|
)
|
||||||
.append(this.highlight(Component.text("/" + query, this.colors.highlight)))
|
.append(this.highlight(Component.text("/" + query, this.colors.highlight)))
|
||||||
.append(Component.text("\"", this.colors.text)));
|
.append(Component.text("\"", this.colors.text)));
|
||||||
audience.sendMessage(this.footer(sender));
|
audience.sendMessage(Identity.nil(), this.footer(sender));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new Pagination<CommandHelpHandler.VerboseHelpEntry<C>>(
|
new Pagination<CommandHelpHandler.VerboseHelpEntry<C>>(
|
||||||
|
|
@ -309,7 +310,8 @@ public final class MinecraftHelp<C> {
|
||||||
},
|
},
|
||||||
(currentPage, maxPages) -> this.paginatedFooter(sender, currentPage, maxPages, query),
|
(currentPage, maxPages) -> this.paginatedFooter(sender, currentPage, maxPages, query),
|
||||||
(attemptedPage, maxPages) -> this.pageOutOfRange(sender, attemptedPage, maxPages)
|
(attemptedPage, maxPages) -> this.pageOutOfRange(sender, attemptedPage, maxPages)
|
||||||
).render(helpTopic.getEntries(), page, this.maxResultsPerPage).forEach(audience::sendMessage);
|
).render(helpTopic.getEntries(), page, this.maxResultsPerPage).forEach(line ->
|
||||||
|
audience.sendMessage(Identity.nil(), line));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printMultiHelpTopic(
|
private void printMultiHelpTopic(
|
||||||
|
|
@ -344,7 +346,8 @@ public final class MinecraftHelp<C> {
|
||||||
},
|
},
|
||||||
(currentPage, maxPages) -> this.paginatedFooter(sender, currentPage, maxPages, query),
|
(currentPage, maxPages) -> this.paginatedFooter(sender, currentPage, maxPages, query),
|
||||||
(attemptedPage, maxPages) -> this.pageOutOfRange(sender, attemptedPage, maxPages)
|
(attemptedPage, maxPages) -> this.pageOutOfRange(sender, attemptedPage, maxPages)
|
||||||
).render(helpTopic.getChildSuggestions(), page, this.maxResultsPerPage).forEach(audience::sendMessage);
|
).render(helpTopic.getChildSuggestions(), page, this.maxResultsPerPage).forEach(line ->
|
||||||
|
audience.sendMessage(Identity.nil(), line));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printVerboseHelpTopic(
|
private void printVerboseHelpTopic(
|
||||||
|
|
@ -353,12 +356,12 @@ public final class MinecraftHelp<C> {
|
||||||
final CommandHelpHandler.@NonNull VerboseHelpTopic<C> helpTopic
|
final CommandHelpHandler.@NonNull VerboseHelpTopic<C> helpTopic
|
||||||
) {
|
) {
|
||||||
final Audience audience = this.getAudience(sender);
|
final Audience audience = this.getAudience(sender);
|
||||||
audience.sendMessage(this.basicHeader(sender));
|
audience.sendMessage(Identity.nil(), this.basicHeader(sender));
|
||||||
audience.sendMessage(this.showingResults(sender, query));
|
audience.sendMessage(Identity.nil(), this.showingResults(sender, query));
|
||||||
final String command = this.commandManager.getCommandSyntaxFormatter()
|
final String command = this.commandManager.getCommandSyntaxFormatter()
|
||||||
.apply(helpTopic.getCommand().getArguments(), null);
|
.apply(helpTopic.getCommand().getArguments(), null);
|
||||||
audience.sendMessage(
|
audience.sendMessage(
|
||||||
this.lastBranch()
|
Identity.nil(), this.lastBranch()
|
||||||
.append(Component.text(
|
.append(Component.text(
|
||||||
" " + this.messageProvider.apply(sender, MESSAGE_COMMAND) + ": ",
|
" " + this.messageProvider.apply(sender, MESSAGE_COMMAND) + ": ",
|
||||||
this.colors.primary
|
this.colors.primary
|
||||||
|
|
@ -370,7 +373,7 @@ public final class MinecraftHelp<C> {
|
||||||
: helpTopic.getDescription();
|
: helpTopic.getDescription();
|
||||||
final boolean hasArguments = helpTopic.getCommand().getArguments().size() > 1;
|
final boolean hasArguments = helpTopic.getCommand().getArguments().size() > 1;
|
||||||
audience.sendMessage(
|
audience.sendMessage(
|
||||||
Component.text(" ")
|
Identity.nil(), Component.text(" ")
|
||||||
.append(hasArguments ? this.branch() : this.lastBranch())
|
.append(hasArguments ? this.branch() : this.lastBranch())
|
||||||
.append(Component.text(
|
.append(Component.text(
|
||||||
" " + this.messageProvider.apply(sender, MESSAGE_DESCRIPTION) + ": ",
|
" " + this.messageProvider.apply(sender, MESSAGE_DESCRIPTION) + ": ",
|
||||||
|
|
@ -380,7 +383,7 @@ public final class MinecraftHelp<C> {
|
||||||
);
|
);
|
||||||
if (hasArguments) {
|
if (hasArguments) {
|
||||||
audience.sendMessage(
|
audience.sendMessage(
|
||||||
Component.text(" ")
|
Identity.nil(), Component.text(" ")
|
||||||
.append(this.lastBranch())
|
.append(this.lastBranch())
|
||||||
.append(Component.text(
|
.append(Component.text(
|
||||||
" " + this.messageProvider.apply(sender, MESSAGE_ARGUMENTS) + ":",
|
" " + this.messageProvider.apply(sender, MESSAGE_ARGUMENTS) + ":",
|
||||||
|
|
@ -415,10 +418,10 @@ public final class MinecraftHelp<C> {
|
||||||
.append(Component.text(description, this.colors.text));
|
.append(Component.text(description, this.colors.text));
|
||||||
}
|
}
|
||||||
|
|
||||||
audience.sendMessage(component);
|
audience.sendMessage(Identity.nil(), component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
audience.sendMessage(this.footer(sender));
|
audience.sendMessage(Identity.nil(), this.footer(sender));
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NonNull Component showingResults(
|
private @NonNull Component showingResults(
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ import cloud.commandframework.paper.PaperCommandManager;
|
||||||
import cloud.commandframework.types.tuples.Triplet;
|
import cloud.commandframework.types.tuples.Triplet;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import io.leangen.geantyref.TypeToken;
|
import io.leangen.geantyref.TypeToken;
|
||||||
|
import net.kyori.adventure.identity.Identity;
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
|
@ -438,7 +439,7 @@ public final class ExamplePlugin extends JavaPlugin {
|
||||||
private void commandClear(final @NonNull Player player) {
|
private void commandClear(final @NonNull Player player) {
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
this.bukkitAudiences.player(player)
|
this.bukkitAudiences.player(player)
|
||||||
.sendMessage(Component.text("Your inventory has been cleared", NamedTextColor.GOLD));
|
.sendMessage(Identity.nil(), Component.text("Your inventory has been cleared", NamedTextColor.GOLD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandMethod("example give <material> <amount>")
|
@CommandMethod("example give <material> <amount>")
|
||||||
|
|
@ -481,6 +482,7 @@ public final class ExamplePlugin extends JavaPlugin {
|
||||||
failureCaption = "regex.money") String money
|
failureCaption = "regex.money") String money
|
||||||
) {
|
) {
|
||||||
bukkitAudiences.sender(sender).sendMessage(
|
bukkitAudiences.sender(sender).sendMessage(
|
||||||
|
Identity.nil(),
|
||||||
Component.text().append(Component.text("You have been given ", NamedTextColor.AQUA))
|
Component.text().append(Component.text("You have been given ", NamedTextColor.AQUA))
|
||||||
.append(Component.text(money, NamedTextColor.GOLD))
|
.append(Component.text(money, NamedTextColor.GOLD))
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue