mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Finish up core and bukkit json
This commit is contained in:
@ -60,13 +60,6 @@ import java.util.Map;
|
||||
*/
|
||||
public interface PlotPlatform<P> extends LocaleHolder {
|
||||
|
||||
/**
|
||||
* Logs a message to console.
|
||||
*
|
||||
* @param message the message to log
|
||||
*/
|
||||
void log(String message);
|
||||
|
||||
/**
|
||||
* Gets the directory which contains PlotSquared files. The directory may not exist.
|
||||
*
|
||||
|
@ -217,7 +217,7 @@ public final class FlagCommand extends Command {
|
||||
.contains(args[0].toLowerCase(Locale.ENGLISH))) {
|
||||
new HelpMenu(player).setCategory(CommandCategory.SETTINGS)
|
||||
.setCommands(this.getCommands()).generateMaxPages()
|
||||
.generatePage(0, getParent().toString()).render();
|
||||
.generatePage(0, getParent().toString(), player).render();
|
||||
return CompletableFuture.completedFuture(true);
|
||||
}
|
||||
return super.execute(player, args, confirm, whenDone);
|
||||
|
@ -120,7 +120,8 @@ public class Help extends Command {
|
||||
player.sendMessage(StaticCaption.of(MINI_MESSAGE.serialize(builder.asComponent())));
|
||||
return true;
|
||||
}
|
||||
new HelpMenu(player).setCategory(catEnum).getCommands().generateMaxPages().generatePage(page - 1, getParent().toString()).render();
|
||||
new HelpMenu(player).setCategory(catEnum).getCommands().generateMaxPages().generatePage(page - 1, getParent().toString(), player)
|
||||
.render();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class HelpMenu {
|
||||
return this;
|
||||
}
|
||||
|
||||
public HelpMenu generatePage(int currentPage, String label) {
|
||||
public HelpMenu generatePage(int currentPage, String label, PlotPlayer<?> audience) {
|
||||
if (currentPage > this.maxPage) {
|
||||
currentPage = this.maxPage;
|
||||
}
|
||||
@ -77,7 +77,7 @@ public class HelpMenu {
|
||||
this.page = new HelpPage(this.commandCategory, currentPage, this.maxPage);
|
||||
int max = Math.min((currentPage * PER_PAGE) + (PER_PAGE - 1), this.commands.size());
|
||||
for (int i = currentPage * PER_PAGE; i < max; i++) {
|
||||
this.page.addHelpItem(new HelpObject(this.commands.get(i), label));
|
||||
this.page.addHelpItem(new HelpObject(this.commands.get(i), label, audience));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -27,19 +27,24 @@ package com.plotsquared.core.util.helpmenu;
|
||||
|
||||
import com.plotsquared.core.command.Argument;
|
||||
import com.plotsquared.core.command.Command;
|
||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.util.StringMan;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
|
||||
public class HelpObject {
|
||||
|
||||
static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
|
||||
|
||||
private final String _rendered;
|
||||
|
||||
public HelpObject(final Command command, final String label) {
|
||||
_rendered = StringMan.replaceAll(Captions.HELP_ITEM.getTranslated(), "%usage%",
|
||||
command.getUsage().replaceAll("\\{label\\}", label), "[%alias%]",
|
||||
!command.getAliases().isEmpty() ?
|
||||
"(" + StringMan.join(command.getAliases(), "|") + ")" :
|
||||
"", "%desc%", command.getDescription(), "%arguments%",
|
||||
buildArgumentList(command.getRequiredArguments()), "{label}", label);
|
||||
public HelpObject(final Command command, final String label, final PlotPlayer<?> audience) {
|
||||
_rendered = MINI_MESSAGE.serialize(MINI_MESSAGE.parse(TranslatableCaption.of("help.help_item").getComponent(audience),
|
||||
Template.of("usage", command.getUsage().replaceAll("\\{label\\}", label)),
|
||||
Template.of("alias", command.getAliases().isEmpty() ? StringMan.join(command.getAliases(), "|") : ""),
|
||||
Template.of("desc", command.getDescription()), Template.of("arguments", buildArgumentList(command.getRequiredArguments())),
|
||||
Template.of("label", label)));
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
|
Reference in New Issue
Block a user