Record the creation world on WoodCutting output #75

Merged
unimatrix merged 3 commits from fix/woodcutter-origin-20261204 into main 2026-12-04 21:09:07 +01:00
Showing only changes of commit 2e339864b9 - Show all commits

Include WoodCutting producer patch source
All checks were successful
DuneRealms Plugin CI / plugins (push) Successful in 9m2s

unimatrixgit 2026-12-04 20:32:29 +01:00

View file

@ -0,0 +1,23 @@
package io.gitlab.jumperdenfer.features;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.entity.Item;
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataType;
class WoodCuttingFeature {
private static Item dropProducedPlanks(World world, Location position, ItemStack planks) {
var meta = planks.getItemMeta();
if (meta != null) {
var data = meta.getPersistentDataContainer();
var origin = new NamespacedKey("dunerealms", "origin_world");
if (!data.has(origin) && !data.has(new NamespacedKey("dunerealms", "preview_only"))) {
data.set(origin, PersistentDataType.STRING, world.getName());
planks.setItemMeta(meta);
}
}
return world.dropItem(position, planks);
}
}