wip: further code cleanup
This commit is contained in:
@@ -2,6 +2,7 @@ package eu.mhsl.minecraft.pixelblocks;
|
||||
|
||||
import eu.mhsl.minecraft.pixelblocks.pixelblock.PixelBlock;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
@@ -11,16 +12,28 @@ import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PixelBlockItem {
|
||||
public static UUID unusedBlockID = UUID.fromString("98fdf0ae-c3ab-4ef7-ae25-efd518d600de");
|
||||
|
||||
public static @NotNull ItemStack getBlockAsItem(@NotNull PixelBlock block) {
|
||||
ItemStack itemStack = ItemStack.of(Material.GRAY_STAINED_GLASS);
|
||||
return PixelBlockItem.updateBlockAsItem(block, ItemStack.of(Material.GRAY_STAINED_GLASS));
|
||||
}
|
||||
|
||||
public static @NotNull ItemStack updateBlockAsItem(@NotNull PixelBlock block, @NotNull ItemStack itemStack) {
|
||||
String ownerName = Optional.ofNullable(Bukkit.getOfflinePlayer(block.ownerUUID).getName()).orElseGet(() -> block.ownerUUID.toString());
|
||||
|
||||
ItemMeta meta = itemStack.getItemMeta();
|
||||
meta.itemName(Component.text(block.blockUUID.toString()));
|
||||
meta.displayName(Component.text("Pixelblock von " + ownerName));
|
||||
meta.lore(List.of(
|
||||
Component.text(ownerName + " ist der Besitzer dieses Blocks."),
|
||||
Component.text("Klicke auf den gesetzten Block, um diesen zu bearbeiten!"),
|
||||
Component.text(block.blockUUID.toString()).color(NamedTextColor.DARK_GRAY)
|
||||
));
|
||||
meta.setEnchantmentGlintOverride(true);
|
||||
itemStack.setItemMeta(meta);
|
||||
|
||||
@@ -31,8 +44,12 @@ public class PixelBlockItem {
|
||||
ItemStack item = ItemStack.of(Material.GRAY_STAINED_GLASS);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.displayName(Component.text("Leerer Pixelblock"));
|
||||
meta.lore(List.of(
|
||||
Component.text("Der erste Spieler, welcher den Block platziert wird der Besitzer des Blocks."),
|
||||
Component.text("Klicke auf den gesetzten Block, um diesen zu bearbeiten!")
|
||||
));
|
||||
meta.setEnchantmentGlintOverride(true);
|
||||
meta.itemName(Component.text("Pixelblock"));
|
||||
meta.itemName(Component.text(unusedBlockID.toString()));
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
Reference in New Issue
Block a user