Skip to content

Commit

Permalink
Lores are stupid (#731)
Browse files Browse the repository at this point in the history
* add a quick "fix" which serializes and deserializes

* bump version

* update CHANGELOG.md

* don't override gradle.properties version
  • Loading branch information
ryderbelserion authored Jun 3, 2024
1 parent eb20e06 commit 0129642
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 12 deletions.
5 changes: 1 addition & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
## Changes:
* Updated the message in commands, instead of `misc.no-virtual-keys`, It will be using `misc.no-keys` message

## Fixes:
* Send the message to the command sender instead of the player when using `/crates forceopen`
* Updates how lore is handled when using /cc additem

## Other:
* [Feature Requests](https://github.com/Crazy-Crew/CrazyCrates/discussions/categories/features)
Expand Down
2 changes: 0 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ plugins {

val isSnapshot = false

rootProject.version = "3.0"

val content: String = rootProject.file("CHANGELOG.md").readText(Charsets.UTF_8)

subprojects.filter { it.name != "api" }.forEach {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ authors=["ryderbelserion", "BadBones69", "TDL"]
description=Create unlimited crates with multiple crate types to choose from!
website=https://modrinth.com/plugin/crazycrates

version=3.0
version=3.0.1
2 changes: 1 addition & 1 deletion paper/run/server.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Minecraft server properties
#Thu May 23 14:31:31 EDT 2024
#Mon Jun 03 12:01:59 EDT 2024
accepts-transfers=false
allow-flight=false
allow-nether=false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
import com.badbones69.crazycrates.tasks.crates.effects.SoundEffect;
import com.ryderbelserion.vital.core.config.objects.CustomFile;
import com.ryderbelserion.vital.core.util.AdvUtil;
import com.ryderbelserion.vital.core.util.StringUtil;
import com.ryderbelserion.vital.paper.builders.items.ItemBuilder;
import com.ryderbelserion.vital.paper.util.DyeUtil;
import com.ryderbelserion.vital.paper.util.ItemUtil;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.json.JSONComponentSerializer;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.Particle;
Expand Down Expand Up @@ -741,7 +744,15 @@ private void setItem(@Nullable final ItemStack itemStack, @NotNull final String
}

if (itemMeta.hasLore()) {
section.set(getPath(prizeName, "DisplayLore"), itemMeta.lore());
List<Component> lores = itemMeta.lore();

if (lores != null) {
List<String> lore = new ArrayList<>();

lores.forEach(line -> lore.add(JSONComponentSerializer.json().serialize(line)));

section.set(getPath(prizeName, "DisplayLore"), lore);
}
}

if (itemMeta.hasDisplayName()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.badbones69.crazycrates.api.enums.PersistentKeys;
import com.badbones69.crazycrates.api.utils.ItemUtils;
import com.ryderbelserion.vital.paper.builders.items.ItemBuilder;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.json.JSONComponentSerializer;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
Expand Down Expand Up @@ -203,20 +205,33 @@ public final boolean hasPermission(@NotNull final Player player) {
}

private @NotNull ItemBuilder display() {
final ItemBuilder builder = new ItemBuilder();
ItemBuilder builder = new ItemBuilder();

try {
final String material = this.section.getString("DisplayItem", "red_terracotta");
final int amount = this.section.getInt("DisplayAmount", 1);

builder.withType(material).setAmount(amount).setDisplayName(this.prizeName);

if (this.section.contains("DisplayLore")) {
// Temp fix until I update the ItemBuilder
List<Component> displayLore = new ArrayList<>();

this.section.getStringList("DisplayLore").forEach(line -> displayLore.add(JSONComponentSerializer.json().deserialize(line)));

ItemStack itemStack = builder.getStack();

itemStack.editMeta(itemMeta -> itemMeta.lore(displayLore));

builder = new ItemBuilder(itemStack);
} else {
builder.setDisplayLore(this.section.getStringList("Lore"));
}

builder.setGlowing(this.section.contains("Glowing") ? section.getBoolean("Glowing") : null);

builder.setDamage(this.section.getInt("DisplayDamage", 0));

builder.setDisplayLore(this.section.getStringList("Lore"));

builder.addPatterns(this.section.getStringList("Patterns"));

builder.setItemFlags(this.section.getStringList("Flags"));
Expand Down

0 comments on commit 0129642

Please sign in to comment.