-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check stack count before opening shulker box #1
Comments
Thanks for the request What happens if someone stacks empty shulker boxes while this plugin has an open shulker box?
I hope that makes sense, what do you think about this? |
I think, you fixed it, other shulker boxes cannot be left-clicked while opening a shulker box, but this leads me to another possibility: the player picks up an empty shulker box item after opening , they will be merged plugin: https://www.spigotmc.org/resources/simple-stack-stack-any-items-to-64.83044/ |
Maybe there needs to be a way to "lock" open shulker boxes, I think it would be possible to prevent stacking by adding NBTs with random data to them Edit: This can be judged as a different item by the SimpleStack plugin (only the Unique Item List function) // import
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
// add
ItemMeta meta = shulkerItem.getItemMeta();
PersistentDataContainer data = meta.getPersistentDataContainer();
NamespacedKey nbtKey = new NamespacedKey(plugin, "__shulkerbox_plugin");
if(!data.has(nbtKey, PersistentDataType.STRING)){
data.set(nbtKey, PersistentDataType.STRING, String.valueOf(System.currentTimeMillis()));
shulkerItem.setItemMeta(meta);
}
// del
PersistentDataContainer data = meta.getPersistentDataContainer();
NamespacedKey nbtKey = new NamespacedKey(plugin, "__shulkerbox_plugin");
if(data.has(nbtKey, PersistentDataType.STRING)){
data.remove(nbtKey);
} |
Yes, setting random NBT data on the shulker box should prevent it from stacking with other boxes and causing issues So the goal is:
Now during a shulker box being opened it should be impossible for identical shulker boxes to stack with it Is there a way this could fail if the server crashes while someone has a shulker box open, and this leaves the NBT tag on the box forever? If so, should we just override that data when it's next opened and that will fix any glitched boxes? Also, do you know a good way to set NBT data on item stacks without using |
I am studying how to operate nbt, there may be a better nbt library. I may update the code on another branch: https://github.com/ApliNi/Shulkerbox |
Some servers make empty shulker boxes stackable via stacking plugins, need to check the stack count before opening them.
I do this in other plugins
The text was updated successfully, but these errors were encountered: