Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 12:30:06 +01:00
SPIGOT-2706: Implement support for Lock NBT Tag
Containers may now implement the Lockable interface.
Dieser Commit ist enthalten in:
Ursprung
8e5e90d5eb
Commit
b6490dada5
@ -10,13 +10,12 @@ import org.bukkit.block.Beacon;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.craftbukkit.CraftWorld;
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftInventoryBeacon;
|
import org.bukkit.craftbukkit.inventory.CraftInventoryBeacon;
|
||||||
import org.bukkit.craftbukkit.potion.CraftPotionUtil;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
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 CraftWorld world;
|
||||||
private final TileEntityBeacon beacon;
|
private final TileEntityBeacon beacon;
|
||||||
|
|
||||||
@ -28,7 +27,7 @@ public class CraftBeacon extends CraftBlockState implements Beacon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CraftBeacon(final Material material, final TileEntityBeacon te) {
|
public CraftBeacon(final Material material, final TileEntityBeacon te) {
|
||||||
super(material);
|
super(material, te);
|
||||||
world = null;
|
world = null;
|
||||||
beacon = te;
|
beacon = te;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import org.bukkit.craftbukkit.CraftWorld;
|
|||||||
import org.bukkit.craftbukkit.inventory.CraftInventoryBrewer;
|
import org.bukkit.craftbukkit.inventory.CraftInventoryBrewer;
|
||||||
import org.bukkit.inventory.BrewerInventory;
|
import org.bukkit.inventory.BrewerInventory;
|
||||||
|
|
||||||
public class CraftBrewingStand extends CraftBlockState implements BrewingStand {
|
public class CraftBrewingStand extends CraftContainer implements BrewingStand {
|
||||||
private final TileEntityBrewingStand brewingStand;
|
private final TileEntityBrewingStand brewingStand;
|
||||||
|
|
||||||
public CraftBrewingStand(Block block) {
|
public CraftBrewingStand(Block block) {
|
||||||
@ -18,7 +18,7 @@ public class CraftBrewingStand extends CraftBlockState implements BrewingStand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CraftBrewingStand(final Material material, final TileEntityBrewingStand te) {
|
public CraftBrewingStand(final Material material, final TileEntityBrewingStand te) {
|
||||||
super(material);
|
super(material, te);
|
||||||
brewingStand = te;
|
brewingStand = te;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import org.bukkit.craftbukkit.inventory.CraftInventory;
|
|||||||
import org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest;
|
import org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest;
|
||||||
import org.bukkit.inventory.Inventory;
|
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 CraftWorld world;
|
||||||
private final TileEntityChest chest;
|
private final TileEntityChest chest;
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ public class CraftChest extends CraftBlockState implements Chest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CraftChest(final Material material, final TileEntityChest te) {
|
public CraftChest(final Material material, final TileEntityChest te) {
|
||||||
super(material);
|
super(material, te);
|
||||||
chest = te;
|
chest = te;
|
||||||
world = null;
|
world = null;
|
||||||
}
|
}
|
||||||
|
41
src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java
Normale Datei
41
src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java
Normale Datei
@ -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.inventory.Inventory;
|
||||||
import org.bukkit.projectiles.BlockProjectileSource;
|
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 CraftWorld world;
|
||||||
private final TileEntityDispenser dispenser;
|
private final TileEntityDispenser dispenser;
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ public class CraftDispenser extends CraftBlockState implements Dispenser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CraftDispenser(final Material material, final TileEntityDispenser te) {
|
public CraftDispenser(final Material material, final TileEntityDispenser te) {
|
||||||
super(material);
|
super(material, te);
|
||||||
world = null;
|
world = null;
|
||||||
dispenser = te;
|
dispenser = te;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import org.bukkit.craftbukkit.CraftWorld;
|
|||||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||||
import org.bukkit.inventory.Inventory;
|
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 CraftWorld world;
|
||||||
private final TileEntityDropper dropper;
|
private final TileEntityDropper dropper;
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ public class CraftDropper extends CraftBlockState implements Dropper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CraftDropper(final Material material, TileEntityDropper te) {
|
public CraftDropper(final Material material, TileEntityDropper te) {
|
||||||
super(material);
|
super(material, te);
|
||||||
world = null;
|
world = null;
|
||||||
dropper = te;
|
dropper = te;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import org.bukkit.craftbukkit.CraftWorld;
|
|||||||
import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace;
|
import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace;
|
||||||
import org.bukkit.inventory.FurnaceInventory;
|
import org.bukkit.inventory.FurnaceInventory;
|
||||||
|
|
||||||
public class CraftFurnace extends CraftBlockState implements Furnace {
|
public class CraftFurnace extends CraftContainer implements Furnace {
|
||||||
private final TileEntityFurnace furnace;
|
private final TileEntityFurnace furnace;
|
||||||
|
|
||||||
public CraftFurnace(final Block block) {
|
public CraftFurnace(final Block block) {
|
||||||
@ -18,7 +18,7 @@ public class CraftFurnace extends CraftBlockState implements Furnace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CraftFurnace(final Material material, final TileEntityFurnace te) {
|
public CraftFurnace(final Material material, final TileEntityFurnace te) {
|
||||||
super(material);
|
super(material, te);
|
||||||
furnace = te;
|
furnace = te;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import org.bukkit.craftbukkit.CraftWorld;
|
|||||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
public class CraftHopper extends CraftBlockState implements Hopper {
|
public class CraftHopper extends CraftContainer implements Hopper {
|
||||||
private final TileEntityHopper hopper;
|
private final TileEntityHopper hopper;
|
||||||
|
|
||||||
public CraftHopper(final Block block) {
|
public CraftHopper(final Block block) {
|
||||||
@ -18,7 +18,7 @@ public class CraftHopper extends CraftBlockState implements Hopper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CraftHopper(final Material material, final TileEntityHopper te) {
|
public CraftHopper(final Material material, final TileEntityHopper te) {
|
||||||
super(material);
|
super(material, te);
|
||||||
|
|
||||||
hopper = te;
|
hopper = te;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren