From 94c4d8107e95f57089e2f805b30ddf09755e7732 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 13 Feb 2021 09:31:16 +0100 Subject: [PATCH] Fixing Some PR Stuff --- .../bausystem/commands/CommandDebugStick_15.java | 5 +---- .../bausystem/commands/CommandDetonator.java | 6 +----- .../steamwar/bausystem/commands/CommandFreeze.java | 4 ++-- .../de/steamwar/bausystem/commands/CommandGUI.java | 12 ++++++------ .../steamwar/bausystem/commands/CommandSkull.java | 6 +----- .../de/steamwar/bausystem/commands/CommandTNT.java | 6 ------ .../world/{ScriptBook.java => PredefinedBook.java} | 13 ++++++------- 7 files changed, 17 insertions(+), 35 deletions(-) rename BauSystem_Main/src/de/steamwar/bausystem/world/{ScriptBook.java => PredefinedBook.java} (91%) diff --git a/BauSystem_15/src/de/steamwar/bausystem/commands/CommandDebugStick_15.java b/BauSystem_15/src/de/steamwar/bausystem/commands/CommandDebugStick_15.java index 88e5b3b..ec1560c 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/commands/CommandDebugStick_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/commands/CommandDebugStick_15.java @@ -27,9 +27,6 @@ class CommandDebugStick_15 { private CommandDebugStick_15(){} static void giveStick(Player player){ - if(player.getInventory().getItemInMainHand().getType() == Material.AIR) - player.getInventory().setItemInMainHand(new ItemStack(Material.DEBUG_STICK)); - else - player.getInventory().addItem(new ItemStack(Material.DEBUG_STICK)); + player.getInventory().setItemInMainHand(new ItemStack(Material.DEBUG_STICK, 1)); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java index 4446023..52bc21e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java @@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.world.Detonator; import de.steamwar.bausystem.world.Welt; -import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -63,10 +62,7 @@ public class CommandDetonator implements CommandExecutor { case "wand": case "detonator": case "item": - if(player.getInventory().getItemInMainHand().getType() == Material.AIR) - player.getInventory().setItemInMainHand(Detonator.WAND); - else - player.getInventory().addItem(Detonator.WAND); + player.getInventory().setItemInMainHand(Detonator.WAND); player.updateInventory(); Detonator.getDetonator(player); break; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java index 0ba82ad..f770e21 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java @@ -1,6 +1,6 @@ -/* +/* This file is a part of the SteamWar software. - + Copyright (C) 2020 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java index a13bc31..bea3c47 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java @@ -138,7 +138,7 @@ public class CommandGUI implements CommandExecutor, Listener { inv.setItem(4, skull); } - inv.setItem(6, Material.BOOK, "§7Script Bücher", Arrays.asList("§7Aktuell §e" + ScriptBook.getBookCount() + " §7Bücher"), true, clickType -> { + inv.setItem(6, Material.BOOK, "§7Script Bücher", Arrays.asList("§7Aktuell §e" + PredefinedBook.getBookCount() + " §7Bücher"), true, clickType -> { player.closeInventory(); scriptBooksGUI(player); }); @@ -355,12 +355,12 @@ public class CommandGUI implements CommandExecutor, Listener { } private static void scriptBooksGUI(Player player) { - List> entries = new ArrayList<>(); - List books = ScriptBook.getBooks(); - books.forEach(scriptBook -> entries.add(new SWListInv.SWListEntry<>(new SWItem(scriptBook.getBookMat(), scriptBook.getName(), scriptBook.getLore(), false, clickType -> {}), scriptBook))); - SWListInv inv = new SWListInv<>(player, "Script Bücher", entries, (clickType, scriptBook) -> { + List> entries = new ArrayList<>(); + List books = PredefinedBook.getBooks(); + books.forEach(predefinedBook -> entries.add(new SWListInv.SWListEntry<>(new SWItem(predefinedBook.getBookMat(), predefinedBook.getName(), predefinedBook.getLore(), false, clickType -> {}), predefinedBook))); + SWListInv inv = new SWListInv<>(player, "Script Bücher", entries, (clickType, predefinedBook) -> { player.closeInventory(); - player.getInventory().addItem(scriptBook.toItemStack()); + player.getInventory().addItem(predefinedBook.toItemStack()); }); inv.open(); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java index 4a4cbf4..0208ca7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java @@ -21,7 +21,6 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.inventory.SWItem; -import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,10 +46,7 @@ public class CommandSkull implements CommandExecutor { assert sm != null; sm.setDisplayName("§e" + args[0] + "§8s Kopf"); is.setItemMeta(sm); - if(p.getInventory().getItemInMainHand().getType() == Material.AIR) - p.getInventory().setItemInMainHand(is); - else - p.getInventory().addItem(is); + p.getInventory().setItemInMainHand(is); return false; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java index 658e8a4..d528f37 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java @@ -34,12 +34,6 @@ import org.bukkit.event.entity.EntityExplodeEvent; public class CommandTNT implements CommandExecutor, Listener { - private static TNTMode tntMode = Region.buildAreaEnabled() ? TNTMode.ONLY_TB : TNTMode.OFF; - - public static TNTMode getTntMode() { - return tntMode; - } - public enum TNTMode { ON("§aan"), ONLY_TB("§7Kein §eBaurahmen"), diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptBook.java b/BauSystem_Main/src/de/steamwar/bausystem/world/PredefinedBook.java similarity index 91% rename from BauSystem_Main/src/de/steamwar/bausystem/world/ScriptBook.java rename to BauSystem_Main/src/de/steamwar/bausystem/world/PredefinedBook.java index cc1d03d..22fd13f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptBook.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/PredefinedBook.java @@ -1,7 +1,6 @@ package de.steamwar.bausystem.world; import de.steamwar.bausystem.BauSystem; -import de.steamwar.core.VersionedCallable; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; @@ -14,22 +13,22 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; -public class ScriptBook { +public class PredefinedBook { private static final FileConfiguration configuration; - private static List bookCache; + private static List bookCache; static { configuration = YamlConfiguration.loadConfiguration(new File(BauSystem.getPlugin().getDataFolder(), "books.yml")); } - public static List getBooks() { + public static List getBooks() { if(bookCache != null) return bookCache; - List books = new ArrayList<>(); + List books = new ArrayList<>(); for (String book:configuration.getKeys(false)) { ConfigurationSection section = Objects.requireNonNull(configuration.getConfigurationSection(book)); - books.add(new ScriptBook(section)); + books.add(new PredefinedBook(section)); } bookCache = books; return books; @@ -44,7 +43,7 @@ public class ScriptBook { private String author; private String name; - ScriptBook(ConfigurationSection section) { + PredefinedBook(ConfigurationSection section) { this.lines = section.getStringList("lines"); this.lore = section.getStringList("lore"); this.author = section.getString("author", "§8Steam§eWar");