3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 04:20:08 +01:00

SPIGOT-2706: Implement support for Lock NBT Tag

Containers may now implement the Lockable interface.
Dieser Commit ist enthalten in:
Senmori 2016-10-21 16:35:55 +11:00 committet von md_5
Ursprung 8e5e90d5eb
Commit b6490dada5
8 geänderte Dateien mit 55 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -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;
}

Datei anzeigen

@ -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;
}

Datei anzeigen

@ -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;
}

Datei anzeigen

@ -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
}
}

Datei anzeigen

@ -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;
}

Datei anzeigen

@ -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;
}

Datei anzeigen

@ -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;
}

Datei anzeigen

@ -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;
}