From 4a55af680d38ba79826da262877e6377132d3c6d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 27 Dec 2022 19:50:14 +0100 Subject: [PATCH] Hotfix CreatingLaufState and BlockBoundingBox Signed-off-by: yoyosource --- .../slaves/laufbau/BlockBoundingBox.java | 29 +++++++++++++------ .../laufbau/states/CreatingLaufState.java | 7 ++--- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java index deeb0196..9809ac37 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java @@ -19,6 +19,8 @@ package de.steamwar.bausystem.features.slaves.laufbau; +import com.sk89q.worldedit.blocks.SkullBlock; +import com.sk89q.worldedit.world.block.BaseBlock; import de.steamwar.bausystem.linkage.LinkageUtils; import de.steamwar.bausystem.utils.NMSWrapper; import de.steamwar.core.Core; @@ -28,6 +30,7 @@ import lombok.ToString; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.OfflinePlayer; +import org.bukkit.SkullType; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Skull; @@ -47,14 +50,21 @@ import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCu @Getter public class BlockBoundingBox { - private static List randomPlayerHead = new ArrayList<>(); + private static List randomPlayerHead = new ArrayList<>(); private static Random random = new Random(); static { + randomPlayerHead.add("zOnlyKroks"); + randomPlayerHead.add("YoyoNow"); + randomPlayerHead.add("Konstruktix"); + randomPlayerHead.add("Merling03"); + randomPlayerHead.add("Lord_Loading"); + /* randomPlayerHead.add(UUID.fromString("1623d4b1-b21c-41d3-93c2-eee2845b8497")); randomPlayerHead.add(UUID.fromString("f75632be-e3ec-4069-9bec-d13ac6891177")); randomPlayerHead.add(UUID.fromString("80382970-424b-4299-9296-d956beab9e7b")); randomPlayerHead.add(UUID.fromString("f395ce89-096d-48e9-b796-a2d88722c22b")); randomPlayerHead.add(UUID.fromString("db516394-d999-4b77-8d13-73cceec77dfe")); + */ } public static List elements = new ArrayList<>(); @@ -64,7 +74,7 @@ public class BlockBoundingBox { private double volume; public SWItem swItem; - public Consumer blockConsumer = null; + public Consumer blockConsumer = null; public BlockBoundingBox(BlockData blockData, List cuboidList, SWItem swItem) { this.blockData = blockData; @@ -74,7 +84,7 @@ public class BlockBoundingBox { elements.add(this); } - public BlockBoundingBox(BlockData blockData, List cuboidList, SWItem swItem, Consumer blockConsumer) { + public BlockBoundingBox(BlockData blockData, List cuboidList, SWItem swItem, Consumer blockConsumer) { this.blockData = blockData; this.cuboidList = cuboidList; this.swItem = swItem; @@ -272,14 +282,15 @@ public class BlockBoundingBox { new BlockBoundingBox(blockData, Arrays.asList(pixelCuboid(xPixel, yPixel, zPixel, dxPixel, dyPixel, dzPixel)), swItem); } - private static void addPixel(BlockData blockData, double xPixel, double yPixel, double zPixel, double dxPixel, double dyPixel, double dzPixel, SWItem swItem, Consumer blockConsumer) { + private static void addPixel(BlockData blockData, double xPixel, double yPixel, double zPixel, double dxPixel, double dyPixel, double dzPixel, SWItem swItem, Consumer blockConsumer) { new BlockBoundingBox(blockData, Arrays.asList(pixelCuboid(xPixel, yPixel, zPixel, dxPixel, dyPixel, dzPixel)), swItem, blockConsumer); } - private static void randomPlayerHead(Block block) { - OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(randomPlayerHead.get(random.nextInt(randomPlayerHead.size()))); - Skull skull = (Skull) block.getState(); - skull.setOwningPlayer(offlinePlayer); - skull.update(); + @SuppressWarnings("deprecation") + private static void randomPlayerHead(BaseBlock block) { + if (block instanceof SkullBlock) { + SkullBlock skullBlock = (SkullBlock) block; + skullBlock.setOwner(randomPlayerHead.get(random.nextInt(randomPlayerHead.size())).toString()); + } } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingLaufState.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingLaufState.java index 68a7d9d0..cc49c88e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingLaufState.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingLaufState.java @@ -29,7 +29,6 @@ import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; import de.steamwar.bausystem.region.Point; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.World; import org.bukkit.entity.Player; @@ -145,9 +144,9 @@ public class CreatingLaufState implements LaufbauState { return; } try { - editSession.setBlock(BukkitAdapter.asBlockVector(location), BukkitAdapter.adapt(highest.blockData)); - // location.getBlock().setBlockData(highest.blockData, false); - if (highest.blockConsumer != null) highest.blockConsumer.accept(location.getBlock()); + BaseBlock block = BukkitAdapter.adapt(highest.blockData).toBaseBlock(); + if (highest.blockConsumer != null) highest.blockConsumer.accept(block); + editSession.setBlock(BukkitAdapter.asBlockVector(location), block); } catch (MaxChangedBlocksException e) { e.printStackTrace(); // ignored