9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-24 01:19:32 +00:00

fix some bugs

This commit is contained in:
XiaoMoMi
2025-04-22 16:08:12 +08:00
parent de02457cd4
commit b4083f7dbf
5 changed files with 28 additions and 4 deletions

View File

@@ -77,6 +77,10 @@ public class BukkitPlaceholderManager implements PlaceholderManager {
return instance; return instance;
} }
public boolean hasPapi() {
return hasPapi;
}
@Override @Override
public boolean registerCustomPlaceholder(String placeholder, String original) { public boolean registerCustomPlaceholder(String placeholder, String original) {
if (this.customPlaceholderMap.containsKey(placeholder)) return false; if (this.customPlaceholderMap.containsKey(placeholder)) return false;

View File

@@ -18,6 +18,7 @@
package net.momirealms.customfishing.api.mechanic.misc.value; package net.momirealms.customfishing.api.mechanic.misc.value;
import net.momirealms.customfishing.api.mechanic.context.Context; import net.momirealms.customfishing.api.mechanic.context.Context;
import net.momirealms.customfishing.api.mechanic.misc.placeholder.BukkitPlaceholderManager;
import net.momirealms.customfishing.api.mechanic.misc.placeholder.PlaceholderAPIUtils; import net.momirealms.customfishing.api.mechanic.misc.placeholder.PlaceholderAPIUtils;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@@ -51,13 +52,17 @@ public interface TextValue<T> {
*/ */
default String render(Context<T> context, boolean parseRawPlaceholders) { default String render(Context<T> context, boolean parseRawPlaceholders) {
if (!(context.holder() instanceof OfflinePlayer player)) { if (!(context.holder() instanceof OfflinePlayer player)) {
if (!parseRawPlaceholders) { if (BukkitPlaceholderManager.getInstance().hasPapi() && parseRawPlaceholders) {
return render(context);
} else {
return PlaceholderAPIUtils.parse(null, render(context)); return PlaceholderAPIUtils.parse(null, render(context));
} else {
return render(context);
} }
} else { } else {
if (BukkitPlaceholderManager.getInstance().hasPapi() && parseRawPlaceholders) {
return PlaceholderAPIUtils.parse(player, render(context)); return PlaceholderAPIUtils.parse(player, render(context));
} else {
return render(context);
}
} }
} }

View File

@@ -110,6 +110,10 @@ public class VersionHelper {
return version >= 21.39; return version >= 21.39;
} }
public static boolean isVersionNewerThan1_21_5() {
return version >= 21.49;
}
public static boolean isFolia() { public static boolean isFolia() {
return folia; return folia;
} }

View File

@@ -21,6 +21,7 @@ import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
import net.momirealms.customfishing.api.mechanic.context.Context; import net.momirealms.customfishing.api.mechanic.context.Context;
import net.momirealms.customfishing.api.mechanic.context.ContextKeys; import net.momirealms.customfishing.api.mechanic.context.ContextKeys;
import net.momirealms.customfishing.api.mechanic.market.MarketGUIHolder; import net.momirealms.customfishing.api.mechanic.market.MarketGUIHolder;
import net.momirealms.customfishing.api.mechanic.misc.placeholder.PlaceholderAPIUtils;
import net.momirealms.customfishing.api.storage.data.EarningData; import net.momirealms.customfishing.api.storage.data.EarningData;
import net.momirealms.customfishing.api.storage.user.UserData; import net.momirealms.customfishing.api.storage.user.UserData;
import net.momirealms.customfishing.api.util.PlayerUtils; import net.momirealms.customfishing.api.util.PlayerUtils;

View File

@@ -17,14 +17,17 @@
package net.momirealms.customfishing.bukkit.util; package net.momirealms.customfishing.bukkit.util;
import com.saicone.rtag.RtagItem;
import com.saicone.rtag.item.ItemTagStream; import com.saicone.rtag.item.ItemTagStream;
import dev.dejvokep.boostedyaml.block.implementation.Section; import dev.dejvokep.boostedyaml.block.implementation.Section;
import net.momirealms.customfishing.api.mechanic.context.Context;
import net.momirealms.customfishing.api.mechanic.item.ItemEditor; import net.momirealms.customfishing.api.mechanic.item.ItemEditor;
import net.momirealms.customfishing.api.mechanic.item.tag.TagMap; import net.momirealms.customfishing.api.mechanic.item.tag.TagMap;
import net.momirealms.customfishing.api.mechanic.item.tag.TagValueType; import net.momirealms.customfishing.api.mechanic.item.tag.TagValueType;
import net.momirealms.customfishing.api.mechanic.misc.value.MathValue; import net.momirealms.customfishing.api.mechanic.misc.value.MathValue;
import net.momirealms.customfishing.api.mechanic.misc.value.TextValue; import net.momirealms.customfishing.api.mechanic.misc.value.TextValue;
import net.momirealms.customfishing.common.helper.GsonHelper; import net.momirealms.customfishing.common.helper.GsonHelper;
import net.momirealms.customfishing.common.helper.VersionHelper;
import net.momirealms.customfishing.common.util.ArrayUtils; import net.momirealms.customfishing.common.util.ArrayUtils;
import net.momirealms.customfishing.common.util.Pair; import net.momirealms.customfishing.common.util.Pair;
import org.bukkit.Material; import org.bukkit.Material;
@@ -110,6 +113,13 @@ public class ItemStackUtils {
public static void sectionToComponentEditor(Section section, List<ItemEditor> itemEditors) { public static void sectionToComponentEditor(Section section, List<ItemEditor> itemEditors) {
for (Map.Entry<String, Object> entry : section.getStringRouteMappedValues(false).entrySet()) { for (Map.Entry<String, Object> entry : section.getStringRouteMappedValues(false).entrySet()) {
String component = entry.getKey(); String component = entry.getKey();
if (VersionHelper.isVersionNewerThan1_21_5() && component.equals("minecraft:hide_tooltip")) {
itemEditors.add((item, context) -> {
item.setComponent("minecraft:tooltip_display", Map.of("hide_tooltip", true));
});
continue;
}
Object value = entry.getValue(); Object value = entry.getValue();
if (value instanceof Section inner) { if (value instanceof Section inner) {
Map<String, Object> innerMap = new HashMap<>(); Map<String, Object> innerMap = new HashMap<>();