Newer
Older
void-pack-super-server / work / decompile-ee3ecae0 / net / minecraft / server / ChestLock.java
Simon Lindgren on 26 Mar 2020 799 bytes first commit
package net.minecraft.server;

import javax.annotation.concurrent.Immutable;

@Immutable
public class ChestLock {

    public static final ChestLock a = new ChestLock("");
    public final String key;

    public ChestLock(String s) {
        this.key = s;
    }

    public boolean a(ItemStack itemstack) {
        return this.key.isEmpty() || !itemstack.isEmpty() && itemstack.hasName() && this.key.equals(itemstack.getName().getString());
    }

    public void a(NBTTagCompound nbttagcompound) {
        if (!this.key.isEmpty()) {
            nbttagcompound.setString("Lock", this.key);
        }

    }

    public static ChestLock b(NBTTagCompound nbttagcompound) {
        return nbttagcompound.hasKeyOfType("Lock", 8) ? new ChestLock(nbttagcompound.getString("Lock")) : ChestLock.a;
    }
}