mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 04:17:44 +01:00
SPIGOT-2706: Implement support for Lock NBT Tag
Containers may now implement the Lockable interface.
This commit is contained in:
parent
8e5e90d5eb
commit
b6490dada5
@ -10,13 +10,12 @@ import org.bukkit.block.Beacon;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryBeacon;
|
||||
import org.bukkit.craftbukkit.potion.CraftPotionUtil;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class CraftBeacon extends CraftBlockState implements Beacon {
|
||||
public class CraftBeacon extends CraftContainer implements Beacon {
|
||||
private final CraftWorld world;
|
||||
private final TileEntityBeacon beacon;
|
||||
|
||||
@ -28,7 +27,7 @@ public class CraftBeacon extends CraftBlockState implements Beacon {
|
||||
}
|
||||
|
||||
public CraftBeacon(final Material material, final TileEntityBeacon te) {
|
||||
super(material);
|
||||
super(material, te);
|
||||
world = null;
|
||||
beacon = te;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryBrewer;
|
||||
import org.bukkit.inventory.BrewerInventory;
|
||||
|
||||
public class CraftBrewingStand extends CraftBlockState implements BrewingStand {
|
||||
public class CraftBrewingStand extends CraftContainer implements BrewingStand {
|
||||
private final TileEntityBrewingStand brewingStand;
|
||||
|
||||
public CraftBrewingStand(Block block) {
|
||||
@ -18,7 +18,7 @@ public class CraftBrewingStand extends CraftBlockState implements BrewingStand {
|
||||
}
|
||||
|
||||
public CraftBrewingStand(final Material material, final TileEntityBrewingStand te) {
|
||||
super(material);
|
||||
super(material, te);
|
||||
brewingStand = te;
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class CraftChest extends CraftBlockState implements Chest {
|
||||
public class CraftChest extends CraftContainer implements Chest {
|
||||
private final CraftWorld world;
|
||||
private final TileEntityChest chest;
|
||||
|
||||
@ -23,7 +23,7 @@ public class CraftChest extends CraftBlockState implements Chest {
|
||||
}
|
||||
|
||||
public CraftChest(final Material material, final TileEntityChest te) {
|
||||
super(material);
|
||||
super(material, te);
|
||||
chest = te;
|
||||
world = null;
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.ChestLock;
|
||||
import net.minecraft.server.TileEntity;
|
||||
import net.minecraft.server.TileEntityContainer;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Lockable;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
|
||||
public class CraftContainer extends CraftBlockState implements Lockable {
|
||||
|
||||
private final TileEntityContainer container;
|
||||
|
||||
public CraftContainer(Block block) {
|
||||
super(block);
|
||||
|
||||
container = (TileEntityContainer) ((CraftWorld) block.getWorld()).getTileEntityAt(block.getX(), block.getY(), block.getZ());
|
||||
}
|
||||
|
||||
public CraftContainer(final Material material, TileEntity tileEntity) {
|
||||
super(material);
|
||||
|
||||
container = (TileEntityContainer) tileEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocked() {
|
||||
return container.x_(); // PAIL: isLocked
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLock() {
|
||||
return container.y_().b(); // PAIL: getLock, getKey
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLock(String key) {
|
||||
container.a(key == null ? ChestLock.a : new ChestLock(key)); // PAIL: setLock
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ import org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.projectiles.BlockProjectileSource;
|
||||
|
||||
public class CraftDispenser extends CraftBlockState implements Dispenser {
|
||||
public class CraftDispenser extends CraftContainer implements Dispenser {
|
||||
private final CraftWorld world;
|
||||
private final TileEntityDispenser dispenser;
|
||||
|
||||
@ -26,7 +26,7 @@ public class CraftDispenser extends CraftBlockState implements Dispenser {
|
||||
}
|
||||
|
||||
public CraftDispenser(final Material material, final TileEntityDispenser te) {
|
||||
super(material);
|
||||
super(material, te);
|
||||
world = null;
|
||||
dispenser = te;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class CraftDropper extends CraftBlockState implements Dropper {
|
||||
public class CraftDropper extends CraftContainer implements Dropper {
|
||||
private final CraftWorld world;
|
||||
private final TileEntityDropper dropper;
|
||||
|
||||
@ -24,7 +24,7 @@ public class CraftDropper extends CraftBlockState implements Dropper {
|
||||
}
|
||||
|
||||
public CraftDropper(final Material material, TileEntityDropper te) {
|
||||
super(material);
|
||||
super(material, te);
|
||||
world = null;
|
||||
dropper = te;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace;
|
||||
import org.bukkit.inventory.FurnaceInventory;
|
||||
|
||||
public class CraftFurnace extends CraftBlockState implements Furnace {
|
||||
public class CraftFurnace extends CraftContainer implements Furnace {
|
||||
private final TileEntityFurnace furnace;
|
||||
|
||||
public CraftFurnace(final Block block) {
|
||||
@ -18,7 +18,7 @@ public class CraftFurnace extends CraftBlockState implements Furnace {
|
||||
}
|
||||
|
||||
public CraftFurnace(final Material material, final TileEntityFurnace te) {
|
||||
super(material);
|
||||
super(material, te);
|
||||
furnace = te;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class CraftHopper extends CraftBlockState implements Hopper {
|
||||
public class CraftHopper extends CraftContainer implements Hopper {
|
||||
private final TileEntityHopper hopper;
|
||||
|
||||
public CraftHopper(final Block block) {
|
||||
@ -18,7 +18,7 @@ public class CraftHopper extends CraftBlockState implements Hopper {
|
||||
}
|
||||
|
||||
public CraftHopper(final Material material, final TileEntityHopper te) {
|
||||
super(material);
|
||||
super(material, te);
|
||||
|
||||
hopper = te;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user