src/main/java/com/viper/autosortchest/Main.java aktualisiert
This commit is contained in:
@@ -1,9 +1,14 @@
|
|||||||
package com.viper.autosortchest;
|
package com.viper.autosortchest;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
|
import org.bukkit.block.DoubleChest;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.block.data.type.WallSign;
|
import org.bukkit.block.data.type.WallSign;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@@ -20,12 +25,10 @@ import org.bukkit.event.block.BlockBreakEvent;
|
|||||||
import org.bukkit.event.block.SignChangeEvent;
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -99,6 +102,27 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||||||
getLogger().info("AutoSortChest Plugin deaktiviert!");
|
getLogger().info("AutoSortChest Plugin deaktiviert!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- NEUE HILFSMETHODE FÜR DOPPELTRUHEN ---
|
||||||
|
private List<Block> getChestBlocks(Chest chest) {
|
||||||
|
List<Block> blocks = new ArrayList<>();
|
||||||
|
InventoryHolder holder = chest.getInventory().getHolder();
|
||||||
|
|
||||||
|
if (holder instanceof DoubleChest) {
|
||||||
|
DoubleChest doubleChest = (DoubleChest) holder;
|
||||||
|
// Finde beide Blöcke der Doppeltruhe
|
||||||
|
if (doubleChest.getLeftSide() instanceof Chest) {
|
||||||
|
blocks.add(((Chest) doubleChest.getLeftSide()).getBlock());
|
||||||
|
}
|
||||||
|
if (doubleChest.getRightSide() instanceof Chest) {
|
||||||
|
blocks.add(((Chest) doubleChest.getRightSide()).getBlock());
|
||||||
|
}
|
||||||
|
} else if (holder instanceof Chest) {
|
||||||
|
blocks.add(chest.getBlock());
|
||||||
|
}
|
||||||
|
return blocks;
|
||||||
|
}
|
||||||
|
// -----------------------------------------
|
||||||
|
|
||||||
private void savePlayerData() {
|
private void savePlayerData() {
|
||||||
if (playerData == null || playerDataFile == null) {
|
if (playerData == null || playerDataFile == null) {
|
||||||
getLogger().warning("Kann players.yml nicht speichern: playerData oder playerDataFile ist null");
|
getLogger().warning("Kann players.yml nicht speichern: playerData oder playerDataFile ist null");
|
||||||
@@ -434,13 +458,15 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Block> blocks = getChestBlocks((Chest) chestBlock.getState());
|
||||||
|
for (Block b : blocks) {
|
||||||
for (Block face : new Block[] {
|
for (Block face : new Block[] {
|
||||||
chestBlock.getRelative(1, 0, 0),
|
b.getRelative(1, 0, 0),
|
||||||
chestBlock.getRelative(-1, 0, 0),
|
b.getRelative(-1, 0, 0),
|
||||||
chestBlock.getRelative(0, 0, 1),
|
b.getRelative(0, 0, 1),
|
||||||
chestBlock.getRelative(0, 0, -1)
|
b.getRelative(0, 0, -1)
|
||||||
}) {
|
}) {
|
||||||
if (face.getState() instanceof Sign sign && isSignAttachedToChest(face, chestBlock)) {
|
if (face.getState() instanceof Sign sign && isSignAttachedToChest(face, b)) {
|
||||||
String[] lines = sign.getLines();
|
String[] lines = sign.getLines();
|
||||||
String line0 = ChatColor.stripColor((String) (lines[0] != null ? lines[0] : ""));
|
String line0 = ChatColor.stripColor((String) (lines[0] != null ? lines[0] : ""));
|
||||||
String line1 = ChatColor.stripColor((String) (lines[1] != null ? lines[1] : ""));
|
String line1 = ChatColor.stripColor((String) (lines[1] != null ? lines[1] : ""));
|
||||||
@@ -457,6 +483,7 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Zieltruhen
|
// Zieltruhen
|
||||||
String targetPath = path + ".target-chests";
|
String targetPath = path + ".target-chests";
|
||||||
@@ -484,13 +511,15 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||||||
Inventory inventory = chest.getInventory();
|
Inventory inventory = chest.getInventory();
|
||||||
boolean isFull = isInventoryFull(inventory);
|
boolean isFull = isInventoryFull(inventory);
|
||||||
|
|
||||||
|
List<Block> blocks = getChestBlocks(chest);
|
||||||
|
for (Block b : blocks) {
|
||||||
for (Block face : new Block[] {
|
for (Block face : new Block[] {
|
||||||
chestBlock.getRelative(1, 0, 0),
|
b.getRelative(1, 0, 0),
|
||||||
chestBlock.getRelative(-1, 0, 0),
|
b.getRelative(-1, 0, 0),
|
||||||
chestBlock.getRelative(0, 0, 1),
|
b.getRelative(0, 0, 1),
|
||||||
chestBlock.getRelative(0, 0, -1)
|
b.getRelative(0, 0, -1)
|
||||||
}) {
|
}) {
|
||||||
if (face.getState() instanceof Sign sign && isSignAttachedToChest(face, chestBlock)) {
|
if (face.getState() instanceof Sign sign && isSignAttachedToChest(face, b)) {
|
||||||
String[] lines = sign.getLines();
|
String[] lines = sign.getLines();
|
||||||
String line0 = ChatColor.stripColor((String) (lines[0] != null ? lines[0] : ""));
|
String line0 = ChatColor.stripColor((String) (lines[0] != null ? lines[0] : ""));
|
||||||
String line1 = ChatColor.stripColor((String) (lines[1] != null ? lines[1] : ""));
|
String line1 = ChatColor.stripColor((String) (lines[1] != null ? lines[1] : ""));
|
||||||
@@ -511,6 +540,7 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// --- NEU: Rest-Truhe aktualisieren ---
|
// --- NEU: Rest-Truhe aktualisieren ---
|
||||||
String restPath = path + ".rest-chest";
|
String restPath = path + ".rest-chest";
|
||||||
@@ -536,13 +566,15 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||||||
Inventory inventory = chest.getInventory();
|
Inventory inventory = chest.getInventory();
|
||||||
boolean isFull = isInventoryFull(inventory);
|
boolean isFull = isInventoryFull(inventory);
|
||||||
|
|
||||||
|
List<Block> blocks = getChestBlocks(chest);
|
||||||
|
for (Block b : blocks) {
|
||||||
for (Block face : new Block[] {
|
for (Block face : new Block[] {
|
||||||
chestBlock.getRelative(1, 0, 0),
|
b.getRelative(1, 0, 0),
|
||||||
chestBlock.getRelative(-1, 0, 0),
|
b.getRelative(-1, 0, 0),
|
||||||
chestBlock.getRelative(0, 0, 1),
|
b.getRelative(0, 0, 1),
|
||||||
chestBlock.getRelative(0, 0, -1)
|
b.getRelative(0, 0, -1)
|
||||||
}) {
|
}) {
|
||||||
if (face.getState() instanceof Sign sign && isSignAttachedToChest(face, chestBlock)) {
|
if (face.getState() instanceof Sign sign && isSignAttachedToChest(face, b)) {
|
||||||
String[] lines = sign.getLines();
|
String[] lines = sign.getLines();
|
||||||
String line0 = ChatColor.stripColor((String) (lines[0] != null ? lines[0] : ""));
|
String line0 = ChatColor.stripColor((String) (lines[0] != null ? lines[0] : ""));
|
||||||
String line1 = ChatColor.stripColor((String) (lines[1] != null ? lines[1] : ""));
|
String line1 = ChatColor.stripColor((String) (lines[1] != null ? lines[1] : ""));
|
||||||
@@ -560,6 +592,7 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -977,18 +1010,23 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||||||
Block chestBlock = clickedBlock;
|
Block chestBlock = clickedBlock;
|
||||||
Block signBlock = null;
|
Block signBlock = null;
|
||||||
|
|
||||||
// Suche Schild
|
// Suche Schild an beiden Hälften falls Doppeltruhe
|
||||||
|
List<Block> blocks = getChestBlocks((Chest) chestBlock.getState());
|
||||||
|
|
||||||
|
outerLoop:
|
||||||
|
for (Block b : blocks) {
|
||||||
for (Block face : new Block[] {
|
for (Block face : new Block[] {
|
||||||
chestBlock.getRelative(1, 0, 0),
|
b.getRelative(1, 0, 0),
|
||||||
chestBlock.getRelative(-1, 0, 0),
|
b.getRelative(-1, 0, 0),
|
||||||
chestBlock.getRelative(0, 0, 1),
|
b.getRelative(0, 0, 1),
|
||||||
chestBlock.getRelative(0, 0, -1)
|
b.getRelative(0, 0, -1)
|
||||||
}) {
|
}) {
|
||||||
if (face.getState() instanceof Sign sign && isSignAttachedToChest(face, chestBlock)) {
|
if (face.getState() instanceof Sign sign && isSignAttachedToChest(face, b)) {
|
||||||
String[] lines = sign.getLines();
|
String[] lines = sign.getLines();
|
||||||
if (lines.length >= 2 && ChatColor.stripColor((String) (lines[0] != null ? lines[0] : "")).equalsIgnoreCase("[asc]")) {
|
if (lines.length >= 2 && ChatColor.stripColor((String) (lines[0] != null ? lines[0] : "")).equalsIgnoreCase("[asc]")) {
|
||||||
signBlock = face;
|
signBlock = face;
|
||||||
break;
|
break outerLoop; // Schild gefunden
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1160,13 +1198,18 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||||||
|
|
||||||
// Fall 2: Truhe wird abgebaut
|
// Fall 2: Truhe wird abgebaut
|
||||||
if (block.getState() instanceof Chest chestBlock) {
|
if (block.getState() instanceof Chest chestBlock) {
|
||||||
|
// Prüfe beide Hälften auf Schilder
|
||||||
|
List<Block> blocks = getChestBlocks(chestBlock);
|
||||||
|
|
||||||
|
outerLoop:
|
||||||
|
for (Block b : blocks) {
|
||||||
for (Block face : new Block[] {
|
for (Block face : new Block[] {
|
||||||
block.getRelative(1, 0, 0),
|
b.getRelative(1, 0, 0),
|
||||||
block.getRelative(-1, 0, 0),
|
b.getRelative(-1, 0, 0),
|
||||||
block.getRelative(0, 0, 1),
|
b.getRelative(0, 0, 1),
|
||||||
block.getRelative(0, 0, -1)
|
b.getRelative(0, 0, -1)
|
||||||
}) {
|
}) {
|
||||||
if (face.getState() instanceof Sign sign && isSignAttachedToChest(face, block)) {
|
if (face.getState() instanceof Sign sign && isSignAttachedToChest(face, b)) {
|
||||||
String[] lines = sign.getLines();
|
String[] lines = sign.getLines();
|
||||||
if (lines.length >= 2 && ChatColor.stripColor((String) (lines[0] != null ? lines[0] : "")).equalsIgnoreCase("[asc]") &&
|
if (lines.length >= 2 && ChatColor.stripColor((String) (lines[0] != null ? lines[0] : "")).equalsIgnoreCase("[asc]") &&
|
||||||
(ChatColor.stripColor((String) (lines[1] != null ? lines[1] : "")).equalsIgnoreCase("input") ||
|
(ChatColor.stripColor((String) (lines[1] != null ? lines[1] : "")).equalsIgnoreCase("input") ||
|
||||||
@@ -1178,7 +1221,8 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||||||
if (isDebug()) {
|
if (isDebug()) {
|
||||||
getLogger().fine("Truhe mit [asc]-Schild erkannt bei " + block.getLocation() + ", Schild bei " + face.getLocation() + ", Besitzer: " + signOwner);
|
getLogger().fine("Truhe mit [asc]-Schild erkannt bei " + block.getLocation() + ", Schild bei " + face.getLocation() + ", Besitzer: " + signOwner);
|
||||||
}
|
}
|
||||||
break;
|
break outerLoop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1229,9 +1273,23 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClose(InventoryCloseEvent event) {
|
public void onInventoryClose(InventoryCloseEvent event) {
|
||||||
if (!(event.getInventory().getHolder() instanceof Chest chest)) return;
|
InventoryHolder holder = event.getInventory().getHolder();
|
||||||
|
List<Chest> chestsToCheck = new ArrayList<>();
|
||||||
|
|
||||||
|
// FIX: Double Chest Handling
|
||||||
|
if (holder instanceof Chest) {
|
||||||
|
chestsToCheck.add((Chest) holder);
|
||||||
|
} else if (holder instanceof DoubleChest) {
|
||||||
|
DoubleChest dc = (DoubleChest) holder;
|
||||||
|
if (dc.getLeftSide() instanceof Chest) chestsToCheck.add((Chest) dc.getLeftSide());
|
||||||
|
if (dc.getRightSide() instanceof Chest) chestsToCheck.add((Chest) dc.getRightSide());
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Player player = (Player) event.getPlayer();
|
Player player = (Player) event.getPlayer();
|
||||||
|
|
||||||
|
for (Chest chest : chestsToCheck) {
|
||||||
Block chestBlock = chest.getBlock();
|
Block chestBlock = chest.getBlock();
|
||||||
Block signBlock = null;
|
Block signBlock = null;
|
||||||
String signType = "target"; // default
|
String signType = "target"; // default
|
||||||
@@ -1255,16 +1313,17 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (signBlock == null) {
|
if (signBlock == null) {
|
||||||
if (isDebug()) getLogger().fine("Keine Zieltruhe/Rest-Truhe Schild an Truhe bei " + chestBlock.getLocation());
|
continue;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Sign sign = (Sign) signBlock.getState();
|
Sign sign = (Sign) signBlock.getState();
|
||||||
String[] lines = sign.getLines();
|
String[] lines = sign.getLines();
|
||||||
String signOwner = ChatColor.stripColor((String) (lines[3] != null ? lines[3] : ""));
|
String signOwner = ChatColor.stripColor((String) (lines[3] != null ? lines[3] : ""));
|
||||||
if (!signOwner.equalsIgnoreCase(player.getName())) {
|
|
||||||
if (isDebug()) getLogger().fine("Schild bei " + signBlock.getLocation() + " gehört nicht Spieler " + player.getName() + " (Besitzer: " + signOwner + ")");
|
// FIX: Auch öffentliche Truhen updaten, nicht nur Owner
|
||||||
return;
|
boolean isPublic = isChestPublic(sign);
|
||||||
|
if (!signOwner.equalsIgnoreCase(player.getName()) && !isPublic) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isFull = isInventoryFull(chest.getInventory());
|
boolean isFull = isInventoryFull(chest.getInventory());
|
||||||
@@ -1288,6 +1347,7 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// --- HILFSMETHODE zum Entfernen alter Einträge ---
|
// --- HILFSMETHODE zum Entfernen alter Einträge ---
|
||||||
private void removeOldTargetEntry(UUID uuid, Location loc, String newItemType) {
|
private void removeOldTargetEntry(UUID uuid, Location loc, String newItemType) {
|
||||||
@@ -1372,14 +1432,18 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||||||
String signOwner = "Unbekannt";
|
String signOwner = "Unbekannt";
|
||||||
Block signBlock = null;
|
Block signBlock = null;
|
||||||
|
|
||||||
// Sign Check erlaubt sowohl "ziel" als auch "rest"
|
// Sign Check erlaubt sowohl "ziel" als auch "rest" und prüft beide Hälften bei Doppeltruhen
|
||||||
|
List<Block> chestBlocks = getChestBlocks(targetChest);
|
||||||
|
|
||||||
|
outerLoop:
|
||||||
|
for (Block b : chestBlocks) {
|
||||||
for (Block face : new Block[] {
|
for (Block face : new Block[] {
|
||||||
targetChest.getBlock().getRelative(1, 0, 0),
|
b.getRelative(1, 0, 0),
|
||||||
targetChest.getBlock().getRelative(-1, 0, 0),
|
b.getRelative(-1, 0, 0),
|
||||||
targetChest.getBlock().getRelative(0, 0, 1),
|
b.getRelative(0, 0, 1),
|
||||||
targetChest.getBlock().getRelative(0, 0, -1)
|
b.getRelative(0, 0, -1)
|
||||||
}) {
|
}) {
|
||||||
if (face.getState() instanceof Sign sign && isSignAttachedToChest(face, targetChest.getBlock())) {
|
if (face.getState() instanceof Sign sign && isSignAttachedToChest(face, b)) {
|
||||||
String[] lines = sign.getLines();
|
String[] lines = sign.getLines();
|
||||||
String line0 = ChatColor.stripColor((String) (lines[0] != null ? lines[0] : ""));
|
String line0 = ChatColor.stripColor((String) (lines[0] != null ? lines[0] : ""));
|
||||||
String line1 = ChatColor.stripColor((String) (lines[1] != null ? lines[1] : ""));
|
String line1 = ChatColor.stripColor((String) (lines[1] != null ? lines[1] : ""));
|
||||||
@@ -1399,13 +1463,14 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||||||
if (isDebug()) {
|
if (isDebug()) {
|
||||||
getLogger().fine("Gültiges Zieltruhe-Schild gefunden bei " + face.getLocation() + " für Spieler " + player.getName());
|
getLogger().fine("Gültiges Zieltruhe-Schild gefunden bei " + face.getLocation() + " für Spieler " + player.getName());
|
||||||
}
|
}
|
||||||
break;
|
break outerLoop;
|
||||||
}
|
}
|
||||||
} else if (isDebug()) {
|
} else if (isDebug()) {
|
||||||
getLogger().fine("Zieltruhe-Schild bei " + face.getLocation() + " hat ungültige Zeilen oder Typ passt nicht: [asc]=" + line0 + ", typ=" + line1);
|
getLogger().fine("Zieltruhe-Schild bei " + face.getLocation() + " hat ungültige Zeilen oder Typ passt nicht: [asc]=" + line0 + ", typ=" + line1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!isValidTarget) {
|
if (!isValidTarget) {
|
||||||
if (canSendFullChestMessage(playerUUID, item.getType())) {
|
if (canSendFullChestMessage(playerUUID, item.getType())) {
|
||||||
@@ -1511,14 +1576,18 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||||||
boolean isPublic = false;
|
boolean isPublic = false;
|
||||||
String ownerName = "Unknown";
|
String ownerName = "Unknown";
|
||||||
|
|
||||||
// Schild suchen und Status prüfen
|
// FIX: Suche Schild an beiden Hälften bei Doppeltruhen
|
||||||
|
List<Block> chestBlocks = getChestBlocks(chest);
|
||||||
|
|
||||||
|
outerLoop:
|
||||||
|
for (Block b : chestBlocks) {
|
||||||
for (Block face : new Block[] {
|
for (Block face : new Block[] {
|
||||||
chest.getBlock().getRelative(1, 0, 0),
|
b.getRelative(1, 0, 0),
|
||||||
chest.getBlock().getRelative(-1, 0, 0),
|
b.getRelative(-1, 0, 0),
|
||||||
chest.getBlock().getRelative(0, 0, 1),
|
b.getRelative(0, 0, 1),
|
||||||
chest.getBlock().getRelative(0, 0, -1)
|
b.getRelative(0, 0, -1)
|
||||||
}) {
|
}) {
|
||||||
if (face.getState() instanceof Sign sign && isSignAttachedToChest(face, chest.getBlock())) {
|
if (face.getState() instanceof Sign sign && isSignAttachedToChest(face, b)) {
|
||||||
String[] lines = sign.getLines();
|
String[] lines = sign.getLines();
|
||||||
String line0 = ChatColor.stripColor((String) (lines[0] != null ? lines[0] : ""));
|
String line0 = ChatColor.stripColor((String) (lines[0] != null ? lines[0] : ""));
|
||||||
String line1 = ChatColor.stripColor((String) (lines[1] != null ? lines[1] : ""));
|
String line1 = ChatColor.stripColor((String) (lines[1] != null ? lines[1] : ""));
|
||||||
@@ -1530,7 +1599,8 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||||||
|
|
||||||
isPublic = line3Clean.toLowerCase().endsWith("[public]");
|
isPublic = line3Clean.toLowerCase().endsWith("[public]");
|
||||||
ownerName = line3Clean.replace(" [Public]", "").replace(" [public]", "").trim();
|
ownerName = line3Clean.replace(" [Public]", "").replace(" [public]", "").trim();
|
||||||
break;
|
break outerLoop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1642,13 +1712,18 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||||||
boolean isValidTarget = false;
|
boolean isValidTarget = false;
|
||||||
Block signBlock = null;
|
Block signBlock = null;
|
||||||
|
|
||||||
|
// FIX: Suche Schild an beiden Hälften
|
||||||
|
List<Block> chestBlocks = getChestBlocks(targetChest);
|
||||||
|
|
||||||
|
outerLoop:
|
||||||
|
for (Block b : chestBlocks) {
|
||||||
for (Block face : new Block[] {
|
for (Block face : new Block[] {
|
||||||
targetChest.getBlock().getRelative(1, 0, 0),
|
b.getRelative(1, 0, 0),
|
||||||
targetChest.getBlock().getRelative(-1, 0, 0),
|
b.getRelative(-1, 0, 0),
|
||||||
targetChest.getBlock().getRelative(0, 0, 1),
|
b.getRelative(0, 0, 1),
|
||||||
targetChest.getBlock().getRelative(0, 0, -1)
|
b.getRelative(0, 0, -1)
|
||||||
}) {
|
}) {
|
||||||
if (face.getState() instanceof Sign sign && isSignAttachedToChest(face, targetChest.getBlock())) {
|
if (face.getState() instanceof Sign sign && isSignAttachedToChest(face, b)) {
|
||||||
String[] lines = sign.getLines();
|
String[] lines = sign.getLines();
|
||||||
String line0 = ChatColor.stripColor((String) (lines[0] != null ? lines[0] : ""));
|
String line0 = ChatColor.stripColor((String) (lines[0] != null ? lines[0] : ""));
|
||||||
String line1 = ChatColor.stripColor((String) (lines[1] != null ? lines[1] : ""));
|
String line1 = ChatColor.stripColor((String) (lines[1] != null ? lines[1] : ""));
|
||||||
@@ -1663,7 +1738,8 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||||||
if (signOwnerName.equalsIgnoreCase(ownerName) || signOwnerName.equalsIgnoreCase("Unknown")) {
|
if (signOwnerName.equalsIgnoreCase(ownerName) || signOwnerName.equalsIgnoreCase("Unknown")) {
|
||||||
isValidTarget = true;
|
isValidTarget = true;
|
||||||
signBlock = face;
|
signBlock = face;
|
||||||
break;
|
break outerLoop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user