Files
src
build.gradle
settings.gradle
Code
6 225
src/main/java/com/kodari/textureddoor/TexturedDoorPlugin.java
package com.kodari.textureddoor;
import com.cryptomorin.xseries.XMaterial;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;
public final class TexturedDoorPlugin extends JavaPlugin {
private NamespacedKey doorItemKey;
private NamespacedKey doorIdKey;
@Override
public void onEnable() {
doorItemKey = new NamespacedKey(this, "door_item");
doorIdKey = new NamespacedKey(this, "door_id");
getServer().getPluginManager().registerEvents(new DoorListener(this), this);
getCommand("textureddoor").setExecutor(new DoorCommand(this));
}
public NamespacedKey getDoorItemKey() {
return doorItemKey;
}
public NamespacedKey getDoorIdKey() {
return doorIdKey;
}
public ItemStack createDoorItem() {
ItemStack item = XMaterial.matchXMaterial("PAPER")
.map(XMaterial::parseItem)
.orElseThrow(() -> new IllegalStateException("Could not create the door item."));
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§fBlank Door");
meta.setLore(java.util.List.of("§7Place it, then right-click it", "§7while holding any block."));
meta.getPersistentDataContainer().set(doorItemKey, PersistentDataType.BYTE, (byte) 1);
item.setItemMeta(meta);
return item;
}
}