9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-29 20:09:14 +00:00
This commit is contained in:
XiaoMoMi
2024-07-27 17:06:42 +08:00
parent 4b8537016e
commit a36b92df6e
10 changed files with 33 additions and 13 deletions

View File

@@ -301,6 +301,23 @@ public class FishingGears {
wrapped.removeTag("CustomFishing", "hook_id");
wrapped.removeTag("CustomFishing", "hook_stack");
wrapped.removeTag("CustomFishing", "hook_max_damage");
List<String> durabilityLore = new ArrayList<>();
List<String> newLore = new ArrayList<>();
List<String> previousLore = wrapped.lore().orElse(new ArrayList<>());
for (String previous : previousLore) {
Component component = AdventureHelper.jsonToComponent(previous);
if (component instanceof ScoreComponent scoreComponent && scoreComponent.name().equals("cf")) {
if (scoreComponent.objective().equals("hook")) {
continue;
} else if (scoreComponent.objective().equals("durability")) {
durabilityLore.add(previous);
continue;
}
}
newLore.add(previous);
}
newLore.addAll(durabilityLore);
wrapped.lore(newLore);
BukkitCustomFishingPlugin.getInstance().getSenderFactory().getAudience(context.getHolder()).playSound(Sound.sound(Key.key("minecraft:entity.item.break"), Sound.Source.PLAYER, 1, 1));
} else {
wrapped.setTag(hookDamage, "CustomFishing", "hook_damage");