Add logging and rollback support for jukebox transactions

This commit is contained in:
Intelli 2022-12-15 15:25:53 -07:00
parent 272ecae858
commit 9da1343f7f
10 changed files with 93 additions and 18 deletions

View file

@ -28,6 +28,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Chest;
import org.bukkit.block.CommandBlock;
import org.bukkit.block.Jukebox;
import org.bukkit.block.ShulkerBox;
import org.bukkit.block.banner.Pattern;
import org.bukkit.block.data.BlockData;
@ -719,6 +720,10 @@ public class Util extends Queue {
ItemFrame entity = (ItemFrame) container;
contents = Util.getItemFrameItem(entity);
}
else if (type == Material.JUKEBOX) {
Jukebox blockState = (Jukebox) ((Block) container).getState();
contents = Util.getJukeboxItem(blockState);
}
else {
Block block = (Block) container;
Inventory inventory = Util.getContainerInventory(block.getState(), true);
@ -796,6 +801,17 @@ public class Util extends Queue {
return contents;
}
public static ItemStack[] getJukeboxItem(Jukebox blockState) {
ItemStack[] contents = null;
try {
contents = new ItemStack[] { blockState.getRecord() };
}
catch (Exception e) {
e.printStackTrace();
}
return contents;
}
public static int getEntityId(EntityType type) {
return getEntityId(type.name(), true);
}