|
20 | 20 | package org.maxgamer.quickshop.shop; |
21 | 21 |
|
22 | 22 | import com.lishid.openinv.IOpenInv; |
| 23 | +import de.tr7zw.nbtapi.NBTCompound; |
| 24 | +import de.tr7zw.nbtapi.NBTList; |
23 | 25 | import de.tr7zw.nbtapi.NBTTileEntity; |
24 | 26 | import io.papermc.lib.PaperLib; |
25 | 27 | import lombok.EqualsAndHashCode; |
|
35 | 37 | import org.bukkit.block.BlockState; |
36 | 38 | import org.bukkit.block.Sign; |
37 | 39 | import org.bukkit.block.data.type.Chest; |
| 40 | +import org.bukkit.block.sign.Side; |
38 | 41 | import org.bukkit.configuration.ConfigurationSection; |
39 | 42 | import org.bukkit.configuration.file.YamlConfiguration; |
40 | 43 | import org.bukkit.enchantments.Enchantment; |
|
72 | 75 | import org.maxgamer.quickshop.api.shop.ShopType; |
73 | 76 | import org.maxgamer.quickshop.chat.platform.minedown.BungeeQuickChat; |
74 | 77 | import org.maxgamer.quickshop.economy.Trader; |
| 78 | +import org.maxgamer.quickshop.util.GameVersion; |
75 | 79 | import org.maxgamer.quickshop.util.MsgUtil; |
76 | 80 | import org.maxgamer.quickshop.util.PlayerFinder; |
77 | 81 | import org.maxgamer.quickshop.util.Util; |
@@ -847,9 +851,26 @@ public void setSignText(@NotNull List<ComponentPackage> lines) { |
847 | 851 | for (Sign sign : signs) { |
848 | 852 | if (this.plugin.getNbtapi() != null) { |
849 | 853 | NBTTileEntity tileSign = new NBTTileEntity(sign); |
| 854 | + NBTList<String> messageNBTList = null; |
| 855 | + if (plugin.getGameVersion().ordinal() >= GameVersion.v1_20_R1.ordinal()) { |
| 856 | + NBTCompound frontNBTCompound = tileSign.getCompound("front_text"); |
| 857 | + if (frontNBTCompound == null) { |
| 858 | + // It should never run into there, but just in case |
| 859 | + sign.getSide(Side.FRONT).setLine(0, "[Fix]"); |
| 860 | + sign.update(true); |
| 861 | + frontNBTCompound = tileSign.getCompound("front_text"); |
| 862 | + } |
| 863 | + messageNBTList = frontNBTCompound.getStringList("messages"); |
| 864 | + } |
850 | 865 | for (int i = 0; i < lines.size(); i++) { |
851 | 866 | try { |
852 | | - tileSign.setString("Text" + (i + 1), Util.componentsToJson(lines.get(i).getComponents())); |
| 867 | + if (plugin.getGameVersion().ordinal() >= GameVersion.v1_20_R1.ordinal()) { |
| 868 | + if (messageNBTList != null) { |
| 869 | + messageNBTList.set(i, Util.componentsToJson(lines.get(i).getComponents())); |
| 870 | + } |
| 871 | + } else { |
| 872 | + tileSign.setString("Text" + (i + 1), Util.componentsToJson(lines.get(i).getComponents())); |
| 873 | + } |
853 | 874 | } catch (Exception e) { |
854 | 875 | plugin.getLogger().log(Level.WARNING, "NBTAPI support is broken, dsiable and fallback... (You can safely ignore this)", e); |
855 | 876 | plugin.disableNBTAPI(); |
|
0 commit comments