mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
chore: fix minimessage messages, fix circular method reference
This commit is contained in:
parent
3afd087663
commit
b7743b06f0
@ -288,8 +288,8 @@ public class BlockEventListener implements Listener {
|
|||||||
pp.sendMessage(
|
pp.sendMessage(
|
||||||
TranslatableCaption.of("height.height_limit"),
|
TranslatableCaption.of("height.height_limit"),
|
||||||
TagResolver.builder()
|
TagResolver.builder()
|
||||||
.tag("minHeight", Tag.inserting(Component.text(area.getMinBuildHeight())))
|
.tag("minheight", Tag.inserting(Component.text(area.getMinBuildHeight())))
|
||||||
.tag("maxHeight", Tag.inserting(Component.text(area.getMaxBuildHeight())))
|
.tag("maxheight", Tag.inserting(Component.text(area.getMaxBuildHeight())))
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -388,8 +388,8 @@ public class BlockEventListener implements Listener {
|
|||||||
plotPlayer.sendMessage(
|
plotPlayer.sendMessage(
|
||||||
TranslatableCaption.of("height.height_limit"),
|
TranslatableCaption.of("height.height_limit"),
|
||||||
TagResolver.builder()
|
TagResolver.builder()
|
||||||
.tag("minHeight", Tag.inserting(Component.text(area.getMinBuildHeight())))
|
.tag("minheight", Tag.inserting(Component.text(area.getMinBuildHeight())))
|
||||||
.tag("maxHeight", Tag.inserting(Component.text(area.getMaxBuildHeight())))
|
.tag("maxheight", Tag.inserting(Component.text(area.getMaxBuildHeight())))
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1284,8 +1284,8 @@ public class BlockEventListener implements Listener {
|
|||||||
pp.sendMessage(
|
pp.sendMessage(
|
||||||
TranslatableCaption.of("height.height_limit"),
|
TranslatableCaption.of("height.height_limit"),
|
||||||
TagResolver.builder()
|
TagResolver.builder()
|
||||||
.tag("minHeight", Tag.inserting(Component.text(area.getMinBuildHeight())))
|
.tag("minheight", Tag.inserting(Component.text(area.getMinBuildHeight())))
|
||||||
.tag("maxHeight", Tag.inserting(Component.text(area.getMaxBuildHeight())))
|
.tag("maxheight", Tag.inserting(Component.text(area.getMaxBuildHeight())))
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -84,8 +84,10 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
|||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.standard.StandardTags;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.FluidCollisionMode;
|
import org.bukkit.FluidCollisionMode;
|
||||||
@ -741,18 +743,13 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
|||||||
builder.tag("world", Tag.inserting(Component.text(worldName)));
|
builder.tag("world", Tag.inserting(Component.text(worldName)));
|
||||||
builder.tag("plot_id", Tag.inserting(Component.text(id.toString())));
|
builder.tag("plot_id", Tag.inserting(Component.text(id.toString())));
|
||||||
builder.tag("sender", Tag.inserting(Component.text(sender)));
|
builder.tag("sender", Tag.inserting(Component.text(sender)));
|
||||||
// If we do/don't want colour, we need to be careful about how to go about it, as players could attempt either <gold></gold> or &6 etc.
|
|
||||||
// In both cases, we want to use a Component Template to ensure that the player cannot use any placeholders in their message on purpose
|
|
||||||
// or accidentally, as component templates are done at the end. We also need to deserialize from legacy color codes to a Component if
|
|
||||||
// allowing colour.
|
|
||||||
if (plotPlayer.hasPermission("plots.chat.color")) {
|
if (plotPlayer.hasPermission("plots.chat.color")) {
|
||||||
builder.tag(
|
builder.tag("msg", Tag.inserting(MiniMessage.miniMessage().deserialize(
|
||||||
"msg",
|
message,
|
||||||
Tag.inserting(BukkitUtil.LEGACY_COMPONENT_SERIALIZER.deserialize(ChatColor.translateAlternateColorCodes(
|
TagResolver.resolver(StandardTags.color(), StandardTags.gradient(),
|
||||||
'&',
|
StandardTags.rainbow(), StandardTags.decorations()
|
||||||
message
|
)
|
||||||
)))
|
)));
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
builder.tag("msg", Tag.inserting(Component.text(message)));
|
builder.tag("msg", Tag.inserting(Component.text(message)));
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,11 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
|
import com.plotsquared.core.configuration.caption.StaticCaption;
|
||||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
|
import com.plotsquared.core.util.StringMan;
|
||||||
import com.sk89q.worldedit.command.util.SuggestionHelper;
|
import com.sk89q.worldedit.command.util.SuggestionHelper;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||||
@ -56,22 +58,13 @@ public class Biome extends SetCommand {
|
|||||||
} catch (final Exception ignore) {
|
} catch (final Exception ignore) {
|
||||||
}
|
}
|
||||||
if (biome == null) {
|
if (biome == null) {
|
||||||
Component separator = MINI_MESSAGE.deserialize(
|
String separator = TranslatableCaption.of("blocklist.block_list_separator").getComponent(player);
|
||||||
TranslatableCaption.of("blocklist.block_list_separator").getComponent(player)
|
|
||||||
);
|
|
||||||
TextComponent.Builder biomes = Component.text();
|
|
||||||
final Collection<BiomeType> biomeTypes = BiomeType.REGISTRY.values();
|
|
||||||
int counter = 0;
|
|
||||||
for (final BiomeType biomeType : biomeTypes) {
|
|
||||||
if (counter++ > 0) {
|
|
||||||
biomes.append(separator);
|
|
||||||
}
|
|
||||||
biomes.append(Component.text(biomeType.toString()));
|
|
||||||
}
|
|
||||||
player.sendMessage(TranslatableCaption.of("biome.need_biome"));
|
player.sendMessage(TranslatableCaption.of("biome.need_biome"));
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("commandconfig.subcommand_set_options_header"),
|
StaticCaption.of(
|
||||||
TagResolver.resolver("values", Tag.inserting(biomes))
|
TranslatableCaption.of("commandconfig.subcommand_set_options_header_only").getComponent(player)
|
||||||
|
+ StringMan.join(BiomeType.REGISTRY.values(), separator)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ import com.plotsquared.core.plot.Plot;
|
|||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotCluster;
|
import com.plotsquared.core.plot.PlotCluster;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.util.ComponentMan;
|
import com.plotsquared.core.util.ComponentHelper;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.TabCompletions;
|
import com.plotsquared.core.util.TabCompletions;
|
||||||
import com.plotsquared.core.util.query.PlotQuery;
|
import com.plotsquared.core.util.query.PlotQuery;
|
||||||
@ -79,7 +79,7 @@ public class Cluster extends SubCommand {
|
|||||||
// return arguments
|
// return arguments
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("cluster.cluster_available_args"),
|
TranslatableCaption.of("cluster.cluster_available_args"),
|
||||||
TagResolver.resolver("list", Tag.inserting(ComponentMan.join(AVAILABLE_ARGS, SEPARATOR)))
|
TagResolver.resolver("list", Tag.inserting(ComponentHelper.join(AVAILABLE_ARGS, SEPARATOR)))
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -917,7 +917,7 @@ public class Cluster extends SubCommand {
|
|||||||
}
|
}
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("cluster.cluster_available_args"),
|
TranslatableCaption.of("cluster.cluster_available_args"),
|
||||||
TagResolver.resolver("list", Tag.inserting(ComponentMan.join(AVAILABLE_ARGS, SEPARATOR)))
|
TagResolver.resolver("list", Tag.inserting(ComponentHelper.join(AVAILABLE_ARGS, SEPARATOR)))
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import com.plotsquared.core.configuration.caption.Caption;
|
|||||||
import com.plotsquared.core.configuration.caption.LocaleHolder;
|
import com.plotsquared.core.configuration.caption.LocaleHolder;
|
||||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.ComponentLike;
|
import net.kyori.adventure.text.ComponentLike;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
@ -100,7 +101,7 @@ public enum CommandCategory implements Caption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull ComponentLike toComponent(@NonNull final LocaleHolder localeHolder) {
|
public @NonNull Component toComponent(@NonNull final LocaleHolder localeHolder) {
|
||||||
return MiniMessage.miniMessage().deserialize(getComponent(localeHolder));
|
return MiniMessage.miniMessage().deserialize(getComponent(localeHolder));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,8 @@ import com.plotsquared.core.uuid.UUIDMapping;
|
|||||||
import com.sk89q.worldedit.world.entity.EntityType;
|
import com.sk89q.worldedit.world.entity.EntityType;
|
||||||
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.format.NamedTextColor;
|
||||||
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
@ -125,10 +127,11 @@ public class Debug extends SubCommand {
|
|||||||
player.sendMessage(TranslatableCaption.of("debug.entity_categories"));
|
player.sendMessage(TranslatableCaption.of("debug.entity_categories"));
|
||||||
EntityCategory.REGISTRY.forEach(category -> {
|
EntityCategory.REGISTRY.forEach(category -> {
|
||||||
final StringBuilder builder =
|
final StringBuilder builder =
|
||||||
new StringBuilder("§7- §6").append(category.getId()).append("§7: §6");
|
new StringBuilder("<gray>-</gray> <gold>").append(category.getId()).append("</gold><gray>: <gold>");
|
||||||
for (final EntityType entityType : category.getAll()) {
|
for (final EntityType entityType : category.getAll()) {
|
||||||
builder.append(entityType.getId()).append(" ");
|
builder.append(entityType.getId()).append(" ");
|
||||||
}
|
}
|
||||||
|
builder.append("</gold>");
|
||||||
player.sendMessage(StaticCaption.of("<prefix>" + builder));
|
player.sendMessage(StaticCaption.of("<prefix>" + builder));
|
||||||
});
|
});
|
||||||
EntityType.REGISTRY.values().stream().sorted(Comparator.comparing(EntityType::getId))
|
EntityType.REGISTRY.values().stream().sorted(Comparator.comparing(EntityType::getId))
|
||||||
@ -148,7 +151,8 @@ public class Debug extends SubCommand {
|
|||||||
.getCaptionMap(TranslatableCaption.DEFAULT_NAMESPACE)
|
.getCaptionMap(TranslatableCaption.DEFAULT_NAMESPACE)
|
||||||
.getCaptions();
|
.getCaptions();
|
||||||
TextComponent.Builder information = Component.text();
|
TextComponent.Builder information = Component.text();
|
||||||
Component header = MINI_MESSAGE.deserialize(TranslatableCaption.of("debug.debug_header").getComponent(player) + "\n");
|
Component header = TranslatableCaption.of("debug.debug_header").toComponent(player)
|
||||||
|
.append(Component.newline());
|
||||||
String line = TranslatableCaption.of("debug.debug_line").getComponent(player) + "\n";
|
String line = TranslatableCaption.of("debug.debug_line").getComponent(player) + "\n";
|
||||||
String section = TranslatableCaption.of("debug.debug_section").getComponent(player) + "\n";
|
String section = TranslatableCaption.of("debug.debug_section").getComponent(player) + "\n";
|
||||||
information.append(header);
|
information.append(header);
|
||||||
|
@ -54,6 +54,7 @@ import com.plotsquared.core.util.task.RunnableVal2;
|
|||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
import com.plotsquared.core.util.task.RunnableVal3;
|
||||||
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.format.Style;
|
||||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
@ -607,23 +608,22 @@ public final class FlagCommand extends Command {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Map<String, ArrayList<String>> flags = new HashMap<>();
|
final Map<Component, ArrayList<String>> flags = new HashMap<>();
|
||||||
for (PlotFlag<?, ?> plotFlag : GlobalFlagContainer.getInstance().getRecognizedPlotFlags()) {
|
for (PlotFlag<?, ?> plotFlag : GlobalFlagContainer.getInstance().getRecognizedPlotFlags()) {
|
||||||
if (plotFlag instanceof InternalFlag) {
|
if (plotFlag instanceof InternalFlag) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final String category = MINI_MESSAGE.escapeTags(plotFlag.getFlagCategory().getComponent(player));
|
final Component category = plotFlag.getFlagCategory().toComponent(player);
|
||||||
final Collection<String> flagList =
|
final Collection<String> flagList = flags.computeIfAbsent(category, k -> new ArrayList<>());
|
||||||
flags.computeIfAbsent(category, k -> new ArrayList<>());
|
|
||||||
flagList.add(plotFlag.getName());
|
flagList.add(plotFlag.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final Map.Entry<String, ArrayList<String>> entry : flags.entrySet()) {
|
for (final Map.Entry<Component, ArrayList<String>> entry : flags.entrySet()) {
|
||||||
Collections.sort(entry.getValue());
|
Collections.sort(entry.getValue());
|
||||||
Component category =
|
Component category =
|
||||||
MINI_MESSAGE.deserialize(
|
MINI_MESSAGE.deserialize(
|
||||||
TranslatableCaption.of("flag.flag_list_categories").getComponent(player),
|
TranslatableCaption.of("flag.flag_list_categories").getComponent(player),
|
||||||
TagResolver.resolver("category", Tag.inserting(Component.text(entry.getKey())))
|
TagResolver.resolver("category", Tag.inserting(entry.getKey().style(Style.empty())))
|
||||||
);
|
);
|
||||||
TextComponent.Builder builder = Component.text().append(category);
|
TextComponent.Builder builder = Component.text().append(category);
|
||||||
final Iterator<String> flagIterator = entry.getValue().iterator();
|
final Iterator<String> flagIterator = entry.getValue().iterator();
|
||||||
|
@ -271,7 +271,7 @@ public class Inbox extends SubCommand {
|
|||||||
if (!comments.isEmpty()) {
|
if (!comments.isEmpty()) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("comment.comment_removed_success"),
|
TranslatableCaption.of("comment.comment_removed_success"),
|
||||||
TagResolver.resolver("value", Tag.inserting(Component.text(String.valueOf(comments))))
|
TagResolver.resolver("value", Tag.inserting(Component.text("*")))
|
||||||
);
|
);
|
||||||
plot.getPlotCommentContainer().removeComments(comments);
|
plot.getPlotCommentContainer().removeComments(comments);
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.configuration.caption;
|
package com.plotsquared.core.configuration.caption;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.ComponentLike;
|
import net.kyori.adventure.text.ComponentLike;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
@ -46,7 +47,8 @@ public interface Caption {
|
|||||||
*
|
*
|
||||||
* @param localeHolder Locale holder
|
* @param localeHolder Locale holder
|
||||||
* @return ComponentLike
|
* @return ComponentLike
|
||||||
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
@NonNull ComponentLike toComponent(@NonNull LocaleHolder localeHolder);
|
@NonNull Component toComponent(@NonNull LocaleHolder localeHolder);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,23 +27,49 @@ package com.plotsquared.core.configuration.caption;
|
|||||||
|
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A holder for a caption.
|
||||||
|
* Useful when constructing messages in multiple steps with {@link TagResolver}s.
|
||||||
|
*/
|
||||||
public class CaptionHolder {
|
public class CaptionHolder {
|
||||||
|
|
||||||
private Caption caption = StaticCaption.of("");
|
private Caption caption = StaticCaption.of("");
|
||||||
private TagResolver[] tagResolvers = new TagResolver[0];
|
private TagResolver[] tagResolvers = new TagResolver[0];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the {@link Caption} to send.
|
||||||
|
*
|
||||||
|
* @param caption The new caption.
|
||||||
|
*/
|
||||||
public void set(Caption caption) {
|
public void set(Caption caption) {
|
||||||
this.caption = caption;
|
this.caption = caption;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the {@link Caption} to send.
|
||||||
|
*
|
||||||
|
* @return The caption to send.
|
||||||
|
*/
|
||||||
public Caption get() {
|
public Caption get() {
|
||||||
return this.caption;
|
return this.caption;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the {@link TagResolver}s to use when resolving tags in the {@link Caption}.
|
||||||
|
*
|
||||||
|
* @return The tag resolvers to use.
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
public TagResolver[] getTagResolvers() {
|
public TagResolver[] getTagResolvers() {
|
||||||
return this.tagResolvers;
|
return this.tagResolvers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the {@link TagResolver}s to use when resolving tags in the {@link Caption}.
|
||||||
|
*
|
||||||
|
* @param tagResolvers The tag resolvers to use.
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
public void setTagResolvers(TagResolver... tagResolvers) {
|
public void setTagResolvers(TagResolver... tagResolvers) {
|
||||||
this.tagResolvers = tagResolvers;
|
this.tagResolvers = tagResolvers;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package com.plotsquared.core.configuration.caption;
|
package com.plotsquared.core.configuration.caption;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.ComponentLike;
|
import net.kyori.adventure.text.ComponentLike;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
@ -54,7 +55,7 @@ public final class StaticCaption implements Caption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull ComponentLike toComponent(@NonNull final LocaleHolder localeHolder) {
|
public @NonNull Component toComponent(@NonNull final LocaleHolder localeHolder) {
|
||||||
return MiniMessage.miniMessage().deserialize(this.value);
|
return MiniMessage.miniMessage().deserialize(this.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,8 +27,11 @@ package com.plotsquared.core.configuration.caption;
|
|||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.ComponentLike;
|
import net.kyori.adventure.text.ComponentLike;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -99,8 +102,14 @@ public final class TranslatableCaption implements NamespacedCaption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull ComponentLike toComponent(@NonNull final LocaleHolder localeHolder) {
|
public @NonNull Component toComponent(@NonNull final LocaleHolder localeHolder) {
|
||||||
return MiniMessage.miniMessage().deserialize(getComponent(localeHolder));
|
if (getKey().equals("core.prefix")) {
|
||||||
|
return MiniMessage.miniMessage().deserialize(getComponent(localeHolder));
|
||||||
|
}
|
||||||
|
return MiniMessage.miniMessage().deserialize(getComponent(localeHolder), TagResolver.resolver(
|
||||||
|
"prefix",
|
||||||
|
Tag.inserting(TranslatableCaption.of("core.prefix").toComponent(localeHolder))
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -65,6 +65,7 @@ import com.sk89q.worldedit.world.gamemode.GameMode;
|
|||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.ComponentLike;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import net.kyori.adventure.title.Title;
|
import net.kyori.adventure.title.Title;
|
||||||
|
@ -91,6 +91,12 @@ public abstract class PlotFlag<T, F extends PlotFlag<T, F>> {
|
|||||||
return flagName.toString();
|
return flagName.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the flag name as a Kyori {@link Component}
|
||||||
|
*
|
||||||
|
* @see #getFlagName(Class)
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
public static <T, F extends PlotFlag<T, F>> Component getFlagNameComponent(Class<F> flagClass) {
|
public static <T, F extends PlotFlag<T, F>> Component getFlagNameComponent(Class<F> flagClass) {
|
||||||
return Component.text(getFlagName(flagClass));
|
return Component.text(getFlagName(flagClass));
|
||||||
}
|
}
|
||||||
|
@ -31,16 +31,33 @@ import net.kyori.adventure.text.TextComponent;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public class ComponentMan {
|
/**
|
||||||
|
* A utility class for modifying components.
|
||||||
|
*
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
|
public class ComponentHelper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Joins multiple {@link Component}s into one final {@link ComponentLike}
|
||||||
|
*
|
||||||
|
* @param components The components to join
|
||||||
|
* @param delimiter The delimiter to use between the components
|
||||||
|
* @return The joined components
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
public static ComponentLike join(Collection<? extends ComponentLike> components, Component delimiter) {
|
public static ComponentLike join(Collection<? extends ComponentLike> components, Component delimiter) {
|
||||||
return join(components.toArray(ComponentLike[]::new), delimiter);
|
return join(components.toArray(ComponentLike[]::new), delimiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Component join(Component[] components, Component delimiter) {
|
/**
|
||||||
return join(components, delimiter);
|
* Joins multiple {@link ComponentLike}s into one final {@link ComponentLike}
|
||||||
}
|
*
|
||||||
|
* @param components The components to join
|
||||||
|
* @param delimiter The delimiter to use between the components
|
||||||
|
* @return The joined components
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
public static Component join(ComponentLike[] components, Component delimiter) {
|
public static Component join(ComponentLike[] components, Component delimiter) {
|
||||||
TextComponent.Builder builder = Component.text();
|
TextComponent.Builder builder = Component.text();
|
||||||
for (int i = 0, j = components.length; i < j; i++) {
|
for (int i = 0, j = components.length; i < j; i++) {
|
@ -29,7 +29,7 @@ import com.plotsquared.core.command.CommandCategory;
|
|||||||
import com.plotsquared.core.configuration.caption.StaticCaption;
|
import com.plotsquared.core.configuration.caption.StaticCaption;
|
||||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.util.ComponentMan;
|
import com.plotsquared.core.util.ComponentHelper;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||||
@ -63,7 +63,7 @@ public class HelpPage {
|
|||||||
TranslatableCaption.of("help.help_page_header").getComponent(player),
|
TranslatableCaption.of("help.help_page_header").getComponent(player),
|
||||||
pageHeaderResolver
|
pageHeaderResolver
|
||||||
)))
|
)))
|
||||||
.tag("help_objects", Tag.inserting(ComponentMan.join(this.helpObjects, Component.text("\n"))))
|
.tag("help_objects", Tag.inserting(ComponentHelper.join(this.helpObjects, Component.text("\n"))))
|
||||||
.tag("footer", Tag.inserting(TranslatableCaption.of("help.help_footer").toComponent(player)))
|
.tag("footer", Tag.inserting(TranslatableCaption.of("help.help_footer").toComponent(player)))
|
||||||
.build();
|
.build();
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
"worldedit.worldedit_bypass": "<prefix><gray><italic>To bypass your restrictions use </gray><dark_aqua><command></dark_aqua></italic>",
|
"worldedit.worldedit_bypass": "<prefix><gray><italic>To bypass your restrictions use </gray><dark_aqua><command></dark_aqua></italic>",
|
||||||
"worldedit.worldedit_bypassed": "<prefix><gray>Currently bypassing WorldEdit restriction.</gray>",
|
"worldedit.worldedit_bypassed": "<prefix><gray>Currently bypassing WorldEdit restriction.</gray>",
|
||||||
"gamemode.gamemode_was_bypassed": "<prefix><gold>You bypassed the gamemode (</gold><gray><gamemode></gray><gold>) <gold>set for </gold><gray><plot>.</gray>",
|
"gamemode.gamemode_was_bypassed": "<prefix><gold>You bypassed the gamemode (</gold><gray><gamemode></gray><gold>) <gold>set for </gold><gray><plot>.</gray>",
|
||||||
"height.height_limit": "<prefix><gold>This plot area has building height limits: Min height: </gold><gray><minHeight></gray><gold>, Max height: </gold><gray><maxHeight></gray>",
|
"height.height_limit": "<prefix><gold>This plot area has building height limits: Min height: </gold><gray><minheight></gray><gold>, Max height: </gold><gray><maxheight></gray>",
|
||||||
"notification.notify_enter": "<prefix><gray><player> entered your plot (</gray><gold><area>;<plot></gold><gray>).</gray>",
|
"notification.notify_enter": "<prefix><gray><player> entered your plot (</gray><gold><area>;<plot></gold><gray>).</gray>",
|
||||||
"notification.notify_leave": "<prefix><gray><player> left your plot (</gray><gold><area>;<plot></gold><gray>).</gray>",
|
"notification.notify_leave": "<prefix><gray><player> left your plot (</gray><gold><area>;<plot></gold><gray>).</gray>",
|
||||||
"swap.swap_overlap": "<prefix><red>The proposed areas are not allowed to overlap.</red>",
|
"swap.swap_overlap": "<prefix><red>The proposed areas are not allowed to overlap.</red>",
|
||||||
@ -510,7 +510,7 @@
|
|||||||
"flag.flag_info_name": "<gray>Name: <gold><flag></gold></gray>",
|
"flag.flag_info_name": "<gray>Name: <gold><flag></gold></gray>",
|
||||||
"flag.flag_info_category": "<gray>Category: </gray><gold><value></gold>",
|
"flag.flag_info_category": "<gray>Category: </gray><gold><value></gold>",
|
||||||
"flag.flag_info_description": "<gray>Description: </gray>",
|
"flag.flag_info_description": "<gray>Description: </gray>",
|
||||||
"flag.flag_info_example": "<gray>Example: <click:suggest_command:<command> <flag> <value>><gold><command> <flag> <value></click></gold></gray>",
|
"flag.flag_info_example": "<gray>Example: <click:suggest_command:'<command> <flag> <value>'><gold><command> <flag> <value></gold></click></gray>",
|
||||||
"flag.flag_info_default_value": "<gray>Default Value: <value></gray>",
|
"flag.flag_info_default_value": "<gray>Default Value: <value></gray>",
|
||||||
"flags.flag_category_string": "<gray>String Flags</gray>",
|
"flags.flag_category_string": "<gray>String Flags</gray>",
|
||||||
"flags.flag_category_integers": "<gray>Integer Flags</gray>",
|
"flags.flag_category_integers": "<gray>Integer Flags</gray>",
|
||||||
|
@ -14,7 +14,7 @@ snakeyaml = "1.30" # Version set by Bukkit
|
|||||||
# Adventure & MiniMessage
|
# Adventure & MiniMessage
|
||||||
adventure-api = "4.10.1"
|
adventure-api = "4.10.1"
|
||||||
adventure-text-minimessage = "4.10.1"
|
adventure-text-minimessage = "4.10.1"
|
||||||
adventure-platform-bukkit = "4.0.1"
|
adventure-platform-bukkit = "4.1.0"
|
||||||
|
|
||||||
# Plugins
|
# Plugins
|
||||||
worldedit = "7.2.10"
|
worldedit = "7.2.10"
|
||||||
|
Loading…
Reference in New Issue
Block a user