From 1c3b48e7908c4ad9956774249a7d79151379ddf1 Mon Sep 17 00:00:00 2001 From: ThiagoROX <51332006+SrBedrock@users.noreply.github.com> Date: Thu, 26 Sep 2024 09:22:06 -0300 Subject: [PATCH 1/2] Adicionado tag --- .../localization/text/SimpleTextManager.java | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/localization/text/SimpleTextManager.java b/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/localization/text/SimpleTextManager.java index cf18a9fc4c..413782fb21 100644 --- a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/localization/text/SimpleTextManager.java +++ b/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/localization/text/SimpleTextManager.java @@ -29,6 +29,7 @@ import net.kyori.adventure.text.Component; import net.kyori.adventure.text.ComponentLike; import net.kyori.adventure.text.format.TextColor; +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 net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; @@ -62,6 +63,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.StringJoiner; import java.util.UUID; @@ -202,33 +204,38 @@ private void initTagResolvers() { File configFile = new File(plugin.getDataFolder(), "color-scheme.yml"); if (!configFile.exists()) { try { - Files.copy(plugin.getJavaPlugin().getResource("color-scheme.yml"), configFile.toPath()); + Files.copy(Objects.requireNonNull(plugin.getJavaPlugin().getResource("color-scheme.yml")), configFile.toPath()); } catch (IOException e) { plugin.logger().warn("Failed to copy color-scheme.yml to plugin folder!", e); } } + FileConfiguration colorSchemeYaml = YamlConfiguration.loadConfiguration(configFile); ConfigurationSection colorSchemeSection = colorSchemeYaml.getConfigurationSection("color-scheme"); - if (colorSchemeSection == null) { - tagResolvers = new TagResolver[0]; - return; - } + List resolvers = new ArrayList<>(); resolvers.add(TagResolver.standard()); - resolvers.add(TagResolver.resolver("color_scheme", (argumentQueue, context) -> { - if (!argumentQueue.hasNext()) { - return null; - } - Tag.Argument argument = argumentQueue.pop(); - String code = argument.value(); - String hex = colorSchemeSection.getString(code, "#ffffff"); - TextColor textColor = TextColor.fromHexString(hex); - if (textColor == null) { - return null; - } - Log.debug("Registered color scheme " + code + " with hex " + hex); - return Tag.styling(textColor); - })); + + if (colorSchemeSection != null) { + resolvers.add(TagResolver.resolver("color_scheme", (argumentQueue, context) -> { + if (!argumentQueue.hasNext()) { + return null; + } + Tag.Argument argument = argumentQueue.pop(); + String code = argument.value(); + String hex = colorSchemeSection.getString(code, "#ffffff"); + TextColor textColor = TextColor.fromHexString(hex); + if (textColor == null) { + return null; + } + Log.debug("Registered color scheme " + code + " with hex " + hex); + return Tag.styling(textColor); + })); + } + + String prefix = colorSchemeYaml.getString("prefix", "[[Loja]"); + resolvers.add(TagResolver.resolver("prefix", (argumentQueue, context) -> Tag.inserting(MiniMessage.miniMessage().deserialize(prefix)))); + this.tagResolvers = resolvers.toArray(new TagResolver[0]); } From dece6db40abb86ce8d7b2995384b2b94b7fac61e Mon Sep 17 00:00:00 2001 From: ThiagoROX <51332006+SrBedrock@users.noreply.github.com> Date: Thu, 26 Sep 2024 09:22:26 -0300 Subject: [PATCH 2/2] Resolvido problema ao bloquear loja pelo painel --- .../quickshop/shop/controlpanel/SimpleShopControlPanel.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/shop/controlpanel/SimpleShopControlPanel.java b/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/shop/controlpanel/SimpleShopControlPanel.java index 775eaa86f4..a1329e2bb4 100644 --- a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/shop/controlpanel/SimpleShopControlPanel.java +++ b/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/shop/controlpanel/SimpleShopControlPanel.java @@ -54,11 +54,14 @@ public class SimpleShopControlPanel implements ShopControlPanel { .hoverEvent(HoverEvent.showText(hoverText)) .clickEvent(ClickEvent.clickEvent(ClickEvent.Action.RUN_COMMAND, clickCommand))); } + + // Freeze if (plugin.perm().hasPermission(sender, "quickshop.other.freeze") || (plugin.perm().hasPermission(sender, "quickshop.togglefreeze") && shop.playerAuthorize(sender.getUniqueId(), BuiltInShopPermission.SET_SHOPTYPE))) { - final Component text = plugin.text().of(sender, "controlpanel.freeze").forLocale(); + String path = shop.isFrozen() ? "controlpanel.unfreeze" : "controlpanel.freeze"; + final Component text = plugin.text().of(sender, path).forLocale(); final Component hoverText = plugin.text().of(sender, "controlpanel.freeze-hover").forLocale(); final String clickCommand = MsgUtil.fillArgs("/{0} {1} {2}", plugin.getMainCommand(), plugin.getCommandPrefix("silentfreeze"), shop.getRuntimeRandomUniqueId().toString()); components.add(text