mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 14:46:45 +01:00
Several minor progress. Couple of bigger (inboxes and help)
This commit is contained in:
parent
1461804039
commit
50cfecb3fd
@ -27,12 +27,14 @@ package com.plotsquared.core.backup;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||
import com.plotsquared.core.player.ConsolePlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.schematic.Schematic;
|
||||
import com.plotsquared.core.util.SchematicHandler;
|
||||
import com.plotsquared.core.util.task.RunnableVal;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
@ -54,6 +56,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
*/
|
||||
public class PlayerBackupProfile implements BackupProfile {
|
||||
|
||||
static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
|
||||
|
||||
private final UUID owner;
|
||||
private final Plot plot;
|
||||
private final BackupManager backupManager;
|
||||
@ -182,7 +186,8 @@ public class PlayerBackupProfile implements BackupProfile {
|
||||
if (value) {
|
||||
future.complete(null);
|
||||
} else {
|
||||
future.completeExceptionally(new RuntimeException(Captions.SCHEMATIC_PASTE_FAILED.toString()));
|
||||
future.completeExceptionally(new RuntimeException(MINI_MESSAGE.stripTokens(
|
||||
TranslatableCaption.of("schematics.schematic_paste_failed").getComponent(ConsolePlayer.getConsole()))));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -30,7 +30,6 @@ import com.plotsquared.core.backup.BackupManager;
|
||||
import com.plotsquared.core.backup.BackupProfile;
|
||||
import com.plotsquared.core.backup.NullBackupProfile;
|
||||
import com.plotsquared.core.backup.PlayerBackupProfile;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
@ -71,7 +70,7 @@ public final class Backup extends Command {
|
||||
this.backupManager = backupManager;
|
||||
}
|
||||
|
||||
private static boolean sendMessage(PlotPlayer player, Captions message, Object... args) {
|
||||
private static boolean sendMessage(PlotPlayer<?> player) {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("commandconfig.command_syntax"),
|
||||
Template.of("value", "/plot backup <save | list | load>")
|
||||
@ -85,12 +84,12 @@ public final class Backup extends Command {
|
||||
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
if (args.length == 0 || !Arrays.asList("save", "list", "load")
|
||||
.contains(args[0].toLowerCase(Locale.ENGLISH))) {
|
||||
return CompletableFuture.completedFuture(sendMessage(player, Captions.BACKUP_USAGE));
|
||||
return CompletableFuture.completedFuture(sendMessage(player));
|
||||
}
|
||||
return super.execute(player, args, confirm, whenDone);
|
||||
}
|
||||
|
||||
@Override public Collection<Command> tab(PlotPlayer player, String[] args, boolean space) {
|
||||
@Override public Collection<Command> tab(PlotPlayer<?> player, String[] args, boolean space) {
|
||||
if (args.length == 1) {
|
||||
return Stream.of("save", "list", "load")
|
||||
.filter(value -> value.startsWith(args[0].toLowerCase(Locale.ENGLISH)))
|
||||
@ -128,7 +127,7 @@ public final class Backup extends Command {
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
permission = "plots.backup.save")
|
||||
public void save(final Command command, final PlotPlayer player, final String[] args,
|
||||
public void save(final Command command, final PlotPlayer<?> player, final String[] args,
|
||||
final RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
final RunnableVal2<Command, CommandResult> whenDone) {
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
@ -179,7 +178,7 @@ public final class Backup extends Command {
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
permission = "plots.backup.list")
|
||||
public void list(final Command command, final PlotPlayer player, final String[] args,
|
||||
public void list(final Command command, final PlotPlayer<?> player, final String[] args,
|
||||
final RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
final RunnableVal2<Command, CommandResult> whenDone) {
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
@ -246,7 +245,7 @@ public final class Backup extends Command {
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
permission = "plots.backup.load")
|
||||
public void load(final Command command, final PlotPlayer player, final String[] args,
|
||||
public void load(final Command command, final PlotPlayer<?> player, final String[] args,
|
||||
final RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
final RunnableVal2<Command, CommandResult> whenDone) {
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
|
@ -25,7 +25,6 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
@ -55,8 +54,8 @@ public class Biome extends SetCommand {
|
||||
} catch (final Exception ignore) {
|
||||
}
|
||||
if (biome == null) {
|
||||
String biomes = StringMan
|
||||
.join(BiomeType.REGISTRY.values(), Captions.BLOCK_LIST_SEPARATOR.toString());
|
||||
String biomes = StringMan.join(BiomeType.REGISTRY.values(),
|
||||
MINI_MESSAGE.serialize(MINI_MESSAGE.parse(TranslatableCaption.of("blocklist.block_list_separator").getComponent(player))));
|
||||
player.sendMessage(TranslatableCaption.of("biome.need_biome"));
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("commandconfig.subcommand_set_options_header"),
|
||||
|
@ -64,7 +64,7 @@ public class Continue extends SubCommand {
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_CONTINUE)) {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("permission.no_permission"),
|
||||
Template.of("node", Captions.NO_PLOT_PERMS.toString())
|
||||
Template.of("node", TranslatableCaption.of("permission.no_plot_perms").getComponent(player))
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
@ -40,6 +40,8 @@ import com.plotsquared.core.util.query.PlotQuery;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import com.plotsquared.core.uuid.UUIDMapping;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -139,27 +141,21 @@ public class Debug extends SubCommand {
|
||||
player.sendMessage(StaticCaption.of(msg.toString()));
|
||||
return true;
|
||||
}
|
||||
StringBuilder information = new StringBuilder();
|
||||
String header = Captions.DEBUG_HEADER.getTranslated();
|
||||
String line = Captions.DEBUG_LINE.getTranslated();
|
||||
String section = Captions.DEBUG_SECTION.getTranslated();
|
||||
TextComponent.Builder information = TextComponent.builder();
|
||||
Component header = MINI_MESSAGE.parse(TranslatableCaption.of("debug.debug_header").getComponent(player) + "\n");
|
||||
String line = TranslatableCaption.of("debug.debug_line").getComponent(player) + "\n";
|
||||
String section = TranslatableCaption.of("debug.debug_section").getComponent(player) + "\n";
|
||||
information.append(header);
|
||||
information.append(getSection(section, "PlotArea"));
|
||||
information.append(MINI_MESSAGE.parse(section, Template.of("val", "PlotArea")));
|
||||
information.append(MINI_MESSAGE
|
||||
.parse(line, Template.of("var", "Plot Worlds"), Template.of("val", StringMan.join(this.plotAreaManager.getAllPlotAreas(), ", "))));
|
||||
information.append(
|
||||
getLine(line, "Plot Worlds", StringMan.join(this.plotAreaManager.getAllPlotAreas(), ", ")));
|
||||
information.append(getLine(line, "Owned Plots", PlotQuery.newQuery().allPlots().count()));
|
||||
information.append(getSection(section, "Messages"));
|
||||
information.append(getLine(line, "Total Messages", Captions.values().length));
|
||||
information.append(getLine(line, "View all captions", "/plot debug msg"));
|
||||
MINI_MESSAGE.parse(line, Template.of("var", "Owned Plots"), Template.of("val", String.valueOf(PlotQuery.newQuery().allPlots().count()))));
|
||||
information.append(MINI_MESSAGE.parse(section, Template.of("val", "Messages")));
|
||||
information
|
||||
.append(MINI_MESSAGE.parse(line, Template.of("var", "Total Messages"), Template.of("val", String.valueOf(Captions.values().length))));
|
||||
information.append(MINI_MESSAGE.parse(line, Template.of("var", "View all captions"), Template.of("val", "/plot debug msg")));
|
||||
player.sendMessage(StaticCaption.of(information.toString()));
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getSection(String line, String val) {
|
||||
return line.replaceAll("%val%", val) + "\n";
|
||||
}
|
||||
|
||||
private String getLine(String line, String var, Object val) {
|
||||
return line.replaceAll("%var%", var).replaceAll("%val%", "" + val) + "\n";
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public final class FlagCommand extends Command {
|
||||
super(MainCommand.getInstance(), true);
|
||||
}
|
||||
|
||||
private static boolean sendMessage(PlotPlayer<?> player, Captions message, Object... args) {
|
||||
private static boolean sendMessage(PlotPlayer<?> player) {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("commandconfig.command_syntax"),
|
||||
Template.of("value", "/plot flag <set | remove | add | list | info> <flag> <value>")
|
||||
@ -167,7 +167,7 @@ public final class FlagCommand extends Command {
|
||||
return false;
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
|
||||
player.sendMessage(TranslatableCaption.of("working.plot_not_claimed"));
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions
|
||||
|
@ -25,14 +25,16 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.caption.StaticCaption;
|
||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.util.MathMan;
|
||||
import com.plotsquared.core.util.StringMan;
|
||||
import com.plotsquared.core.util.helpmenu.HelpMenu;
|
||||
import com.plotsquared.core.util.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@ -104,22 +106,21 @@ public class Help extends Command {
|
||||
}
|
||||
}
|
||||
if (cat == null && page == 0) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(Captions.HELP_HEADER.getTranslated());
|
||||
TextComponent.Builder builder = TextComponent.builder();
|
||||
builder.append(MINI_MESSAGE.parse(TranslatableCaption.of("help.help_header").getComponent(player)));
|
||||
for (CommandCategory c : CommandCategory.values()) {
|
||||
builder.append("\n").append(StringMan
|
||||
.replaceAll(Captions.HELP_INFO_ITEM.getTranslated(), "%category%",
|
||||
c.toString().toLowerCase(), "%category_desc%", c.toString()));
|
||||
builder.append("\n").append(MINI_MESSAGE
|
||||
.parse(TranslatableCaption.of("help.help_info_item").getComponent(player), Template.of("category", c.name().toLowerCase()),
|
||||
Template.of("category_desc", c.getComponent(player))));
|
||||
}
|
||||
builder.append("\n").append(
|
||||
Captions.HELP_INFO_ITEM.getTranslated().replaceAll("%category%", "all")
|
||||
.replaceAll("%category_desc%", "Display all commands"));
|
||||
builder.append("\n").append(Captions.HELP_FOOTER.getTranslated());
|
||||
player.sendMessage(StaticCaption.of(builder.toString()));
|
||||
builder.append("\n").append(MINI_MESSAGE
|
||||
.parse(TranslatableCaption.of("help.help_info_item").getComponent(player), Template.of("category", "all"),
|
||||
Template.of("category_desc", "Display all commands")));
|
||||
builder.append("\n").append(MINI_MESSAGE.parse(TranslatableCaption.of("help.help_footer").getComponent(player)));
|
||||
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()).render();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -26,10 +26,10 @@
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.player.MetaDataAccess;
|
||||
import com.plotsquared.core.configuration.caption.StaticCaption;
|
||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||
import com.plotsquared.core.player.MetaDataAccess;
|
||||
import com.plotsquared.core.player.MetaDataKey;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.comment.CommentInbox;
|
||||
@ -37,7 +37,8 @@ import com.plotsquared.core.plot.comment.CommentManager;
|
||||
import com.plotsquared.core.plot.comment.PlotComment;
|
||||
import com.plotsquared.core.util.StringMan;
|
||||
import com.plotsquared.core.util.task.RunnableVal;
|
||||
import com.plotsquared.core.player.MetaDataKey;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
|
||||
import java.util.List;
|
||||
@ -70,25 +71,31 @@ public class Inbox extends SubCommand {
|
||||
if (max > comments.length) {
|
||||
max = comments.length;
|
||||
}
|
||||
StringBuilder string = new StringBuilder();
|
||||
string.append(StringMan
|
||||
.replaceAll(Captions.COMMENT_LIST_HEADER_PAGED.getTranslated(), "%amount%",
|
||||
comments.length, "%cur", page + 1, "%max", totalPages + 1, "%word", "all") + '\n');
|
||||
TextComponent.Builder builder = TextComponent.builder();
|
||||
builder.append(MINI_MESSAGE.parse(TranslatableCaption.of("list.comment_list_header_paged").getComponent(player) + '\n',
|
||||
Template.of("amount", String.valueOf(comments.length)), Template.of("cur", String.valueOf(page + 1)),
|
||||
Template.of("max", String.valueOf(totalPages + 1)), Template.of("word", "all")));
|
||||
|
||||
// This might work xD
|
||||
for (int x = page * 12; x < max; x++) {
|
||||
PlotComment comment = comments[x];
|
||||
String color;
|
||||
Component commentColored;
|
||||
if (player.getName().equals(comment.senderName)) {
|
||||
color = "&a";
|
||||
commentColored = MINI_MESSAGE
|
||||
.parse(TranslatableCaption.of("list.comment_list_by_lister").getComponent(player), Template.of("comment", comment.comment));
|
||||
} else {
|
||||
color = "&7";
|
||||
commentColored = MINI_MESSAGE
|
||||
.parse(TranslatableCaption.of("list.comment_list_by_other").getComponent(player), Template.of("comment", comment.comment));
|
||||
}
|
||||
string.append("&8[&7#").append(x + 1).append("&8][&7").append(comment.world).append(';')
|
||||
.append(comment.id).append("&8][&6").append(comment.senderName).append("&8]")
|
||||
.append(color).append(comment.comment).append('\n');
|
||||
Template number = Template.of("number", String.valueOf(x));
|
||||
Template world = Template.of("world", comment.world);
|
||||
Template plot_id = Template.of("plot_id", comment.id.getX() + "" + comment.id.getY());
|
||||
Template commenter = Template.of("commenter", comment.senderName);
|
||||
Template commentTemplate = Template.of("comment", commentColored);
|
||||
builder.append(MINI_MESSAGE
|
||||
.parse(TranslatableCaption.of("list.comment_list_comment").getComponent(player), number, world, plot_id, commenter, commentTemplate));
|
||||
}
|
||||
player.sendMessage(StaticCaption.of(string.toString()));
|
||||
player.sendMessage(StaticCaption.of(MINI_MESSAGE.serialize(builder.build())));
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
|
@ -27,9 +27,10 @@ package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.backup.BackupManager;
|
||||
import com.plotsquared.core.configuration.caption.CaptionUtility;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.configuration.caption.CaptionUtility;
|
||||
import com.plotsquared.core.configuration.caption.StaticCaption;
|
||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
@ -187,9 +188,8 @@ public class Set extends SubCommand {
|
||||
if (plot != null) {
|
||||
newValues.addAll(Arrays.asList(plot.getManager().getPlotComponents(plot.getId())));
|
||||
}
|
||||
MainUtil.sendMessage(player,
|
||||
Captions.SUBCOMMAND_SET_OPTIONS_HEADER.getTranslated() + StringMan
|
||||
.join(newValues, Captions.BLOCK_LIST_SEPARATOR.formatted()));
|
||||
player.sendMessage(StaticCaption.of(TranslatableCaption.of("commandconfig.subcommand_set_options_header").getComponent(player) + StringMan
|
||||
.join(newValues, TranslatableCaption.of("blocklist.block_list_separator").getComponent(player))));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@
|
||||
"trim.trim_done": "<prefix><gold>Trim done.</gold>",
|
||||
"trim.trim_starting": "<prefix><gold>Collecting region data...</gold>",
|
||||
|
||||
"blocklist.block_list_separator": "<gold>,</gold><gray> ",
|
||||
"blocklist.block_list_separator": "</grey><gold>,</gold><gray> ",
|
||||
|
||||
"biome.need_biome": "<prefix><red>You need to specify a valid biome.</red>",
|
||||
"biome.biome_set_to": "<prefix><gold>Plot biome set to <gray><value></gray></gold>",
|
||||
@ -398,6 +398,9 @@
|
||||
"working.claimed": "<prefix><dark_aqua>You successfully claimed the plot.</dark_aqua>",
|
||||
|
||||
"list.comment_list_header_paged": "<gray>(Page </gray><gold><cur></gold><gray>/</gray><gold><max></gold><gray>) </gray><gold>List of <amount> comments</gold>",
|
||||
"list.comment_list_comment": "<dark_grey>[</dark_grey><grey>#<number></grey><dark_grey>[</dark_grey><grey><world>;<plot_id></grey><dark_grey>][</dark_grey><gold><commenter></gold><dark_grey>]</dark_grey><comment>\n",
|
||||
"list.comment_list_by_lister": "<green><comment></green>",
|
||||
"list.comment_list_by_other": "<grey><comment></grey>",
|
||||
"list.clickable": "<gray> (interactive)</gray>",
|
||||
"list.area_list_header_paged": "<gray>(Page </gray><gold><cur></gold><gray>/</gray><gold><max></gold><gray>) </gray><gold>List of <amount> areas</gold>",
|
||||
"list.plot_list_header_paged": "<gray>(Page </gray><gold><cur></gold><gray>/</gray><gold><max></gray><gray>) </gray><gold>List of <amount> plots</gold>",
|
||||
|
Loading…
Reference in New Issue
Block a user