Add logging and rollback support for jukebox transactions
This commit is contained in:
parent
272ecae858
commit
9da1343f7f
10 changed files with 93 additions and 18 deletions
|
|
@ -30,8 +30,10 @@ import org.bukkit.attribute.AttributeModifier;
|
|||
import org.bukkit.block.Banner;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.block.Jukebox;
|
||||
import org.bukkit.block.ShulkerBox;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.block.data.Bisected;
|
||||
|
|
@ -1142,7 +1144,14 @@ public class Rollback extends Queue {
|
|||
}
|
||||
|
||||
if (BlockGroup.CONTAINERS.contains(block.getType())) {
|
||||
container = Util.getContainerInventory(block.getState(), false);
|
||||
BlockState blockState = block.getState();
|
||||
if (blockState instanceof Jukebox) {
|
||||
container = blockState;
|
||||
}
|
||||
else {
|
||||
container = Util.getContainerInventory(blockState, false);
|
||||
}
|
||||
|
||||
containerType = block.getType();
|
||||
}
|
||||
else if (BlockGroup.CONTAINERS.contains(Material.ARMOR_STAND) || BlockGroup.CONTAINERS.contains(Material.ITEM_FRAME)) {
|
||||
|
|
@ -1631,6 +1640,21 @@ public class Rollback extends Queue {
|
|||
frame.setItem(itemstack);
|
||||
}
|
||||
}
|
||||
else if (type != null && type.equals(Material.JUKEBOX)) {
|
||||
Jukebox jukebox = (Jukebox) container;
|
||||
if (jukebox != null) {
|
||||
if (action == 1 && Tag.ITEMS_MUSIC_DISCS.isTagged(itemstack.getType())) {
|
||||
itemstack.setAmount(1);
|
||||
}
|
||||
else {
|
||||
itemstack.setType(Material.AIR);
|
||||
itemstack.setAmount(0);
|
||||
}
|
||||
|
||||
jukebox.setRecord(itemstack);
|
||||
jukebox.update();
|
||||
}
|
||||
}
|
||||
else {
|
||||
Inventory inventory = (Inventory) container;
|
||||
if (inventory != null) {
|
||||
|
|
|
|||
|
|
@ -45,6 +45,9 @@ public class ContainerLogger extends Queue {
|
|||
contents = Util.getItemFrameItem(itemFrame);
|
||||
faceData = itemFrame.getFacing().name();
|
||||
}
|
||||
else if (type == Material.JUKEBOX) {
|
||||
contents = new ItemStack[] { ((ItemStack[]) container)[1] };
|
||||
}
|
||||
else {
|
||||
Inventory inventory = (Inventory) container;
|
||||
if (inventory != null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue