Fix ShowItem incompatibility as well as update adventure

This commit is contained in:
Phoenix616 2020-12-04 14:53:27 +01:00
parent af32b041ff
commit 4e40823d23
No known key found for this signature in database
GPG Key ID: 40E2321E71738EB0
2 changed files with 7 additions and 4 deletions

View File

@ -98,7 +98,7 @@
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-gson</artifactId>
<version>4.2.0</version>
<version>4.3.0</version>
<scope>compile</scope>
<exclusions>
<exclusion>

View File

@ -10,6 +10,9 @@ import de.themoep.ShowItem.api.ShowItem;
import de.themoep.minedown.adventure.Replacer;
import info.somethingodd.OddItem.OddItem;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.ComponentBuilder;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.configuration.file.YamlConstructor;
@ -537,10 +540,10 @@ public class MaterialUtil {
return false;
}
Component itemComponent = Component.empty();
TextComponent.Builder itemComponent = Component.text();
for (ItemStack item : InventoryUtil.mergeSimilarStacks(stock)) {
try {
itemComponent.append(showItem.getItemConverter().createComponent(item, Level.FINE).toTextComponent(player));
itemComponent.append(GsonComponentSerializer.gson().deserialize(showItem.getItemConverter().createComponent(item, Level.FINE).toJsonString(player)));
} catch (Exception e) {
ChestShop.getPlugin().getLogger().log(Level.WARNING, "Error while trying to send message '" + message + "' to player " + player.getName() + ": " + e.getMessage());
return false;
@ -551,7 +554,7 @@ public class MaterialUtil {
newMap.put("material", "item");
Component component = new Replacer()
.placeholderSuffix("")
.replace("item",itemComponent)
.replace("item",itemComponent.build())
.replaceIn(message.getComponent(player, true, newMap, replacements));
if (player != null) {
ChestShop.getAudiences().player(player).sendMessage(component);