From 6244c79b6309c5729a161bb46d3037cf2e6c5642 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 10 Nov 2019 17:28:09 +0100 Subject: [PATCH] Massive Refactoring + adding 1.14 support --- SpigotCore_12/pom.xml | 37 ++++++++++ .../steamwar/inventory/SWInventory_v12.java | 13 ++++ .../de/steamwar/inventory/SWItem_v12.java | 4 ++ SpigotCore_14/pom.xml | 37 ++++++++++ .../steamwar/inventory/SWInventory_v14.java | 13 ++++ .../src/de/steamwar/inventory/SWItem_v14.java | 48 +++++++++++++ SpigotCore_Main/pom.xml | 68 +++++++++++++++++++ .../src}/de/steamwar/core/CommandRemover.java | 0 .../src}/de/steamwar/core/Core.java | 0 .../steamwar/core/events/ChattingEvent.java | 4 +- .../core/events/PlayerJoinedEvent.java | 0 .../de/steamwar/inventory/InvCallback.java | 0 .../de/steamwar/inventory/SWInventory.java | 6 +- .../src}/de/steamwar/inventory/SWItem.java | 15 +++- .../src}/de/steamwar/inventory/SWListInv.java | 8 +-- .../src}/de/steamwar/sql/BauweltMember.java | 0 .../de/steamwar/sql/CheckedSchematic.java | 0 .../src}/de/steamwar/sql/Event.java | 0 .../src}/de/steamwar/sql/EventFight.java | 12 +--- .../src}/de/steamwar/sql/SQL.java | 0 .../src}/de/steamwar/sql/Schematic.java | 0 .../src}/de/steamwar/sql/SchematicMember.java | 0 .../src}/de/steamwar/sql/SchematicType.java | 0 .../src}/de/steamwar/sql/SteamwarUser.java | 0 .../src}/de/steamwar/sql/Team.java | 0 .../src}/de/steamwar/sql/UserGroup.java | 0 SpigotCore_Main/src/plugin.yml | 7 ++ pom.xml | 37 +++------- .../steamwar/inventory/SWInventory_v12.java | 11 --- .../steamwar/inventory/SWInventory_v14.java | 11 --- src/de/steamwar/inventory/SWItem_v14.java | 11 --- src/plugin.yml | 8 --- 32 files changed, 260 insertions(+), 90 deletions(-) create mode 100644 SpigotCore_12/pom.xml create mode 100644 SpigotCore_12/src/de/steamwar/inventory/SWInventory_v12.java rename {src => SpigotCore_12/src}/de/steamwar/inventory/SWItem_v12.java (74%) create mode 100644 SpigotCore_14/pom.xml create mode 100644 SpigotCore_14/src/de/steamwar/inventory/SWInventory_v14.java create mode 100644 SpigotCore_14/src/de/steamwar/inventory/SWItem_v14.java create mode 100644 SpigotCore_Main/pom.xml rename {src => SpigotCore_Main/src}/de/steamwar/core/CommandRemover.java (100%) rename {src => SpigotCore_Main/src}/de/steamwar/core/Core.java (100%) rename {src => SpigotCore_Main/src}/de/steamwar/core/events/ChattingEvent.java (63%) rename {src => SpigotCore_Main/src}/de/steamwar/core/events/PlayerJoinedEvent.java (100%) rename {src => SpigotCore_Main/src}/de/steamwar/inventory/InvCallback.java (100%) rename {src => SpigotCore_Main/src}/de/steamwar/inventory/SWInventory.java (93%) rename {src => SpigotCore_Main/src}/de/steamwar/inventory/SWItem.java (89%) rename {src => SpigotCore_Main/src}/de/steamwar/inventory/SWListInv.java (87%) rename {src => SpigotCore_Main/src}/de/steamwar/sql/BauweltMember.java (100%) rename {src => SpigotCore_Main/src}/de/steamwar/sql/CheckedSchematic.java (100%) rename {src => SpigotCore_Main/src}/de/steamwar/sql/Event.java (100%) rename {src => SpigotCore_Main/src}/de/steamwar/sql/EventFight.java (84%) rename {src => SpigotCore_Main/src}/de/steamwar/sql/SQL.java (100%) rename {src => SpigotCore_Main/src}/de/steamwar/sql/Schematic.java (100%) rename {src => SpigotCore_Main/src}/de/steamwar/sql/SchematicMember.java (100%) rename {src => SpigotCore_Main/src}/de/steamwar/sql/SchematicType.java (100%) rename {src => SpigotCore_Main/src}/de/steamwar/sql/SteamwarUser.java (100%) rename {src => SpigotCore_Main/src}/de/steamwar/sql/Team.java (100%) rename {src => SpigotCore_Main/src}/de/steamwar/sql/UserGroup.java (100%) create mode 100644 SpigotCore_Main/src/plugin.yml delete mode 100644 src/de/steamwar/inventory/SWInventory_v12.java delete mode 100644 src/de/steamwar/inventory/SWInventory_v14.java delete mode 100644 src/de/steamwar/inventory/SWItem_v14.java delete mode 100644 src/plugin.yml diff --git a/SpigotCore_12/pom.xml b/SpigotCore_12/pom.xml new file mode 100644 index 0000000..82c5e9d --- /dev/null +++ b/SpigotCore_12/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + + steamwar + SpigotCore + 2.0 + + + SpigotCore_12 + 2.0 + + + src + + + src + + **/*.java + **/*.kt + + + + + + + + steamwar + Spigot-1.12 + 1.0 + provided + + + \ No newline at end of file diff --git a/SpigotCore_12/src/de/steamwar/inventory/SWInventory_v12.java b/SpigotCore_12/src/de/steamwar/inventory/SWInventory_v12.java new file mode 100644 index 0000000..6e8e006 --- /dev/null +++ b/SpigotCore_12/src/de/steamwar/inventory/SWInventory_v12.java @@ -0,0 +1,13 @@ +package de.steamwar.inventory; + +import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftInventoryCustom; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; + +class SWInventory_v12 { + private SWInventory_v12(){} + + static Inventory get(Player player, int size, String title){ + return new CraftInventoryCustom(player, size, title); + } +} diff --git a/src/de/steamwar/inventory/SWItem_v12.java b/SpigotCore_12/src/de/steamwar/inventory/SWItem_v12.java similarity index 74% rename from src/de/steamwar/inventory/SWItem_v12.java rename to SpigotCore_12/src/de/steamwar/inventory/SWItem_v12.java index a34432c..fc6c33b 100644 --- a/src/de/steamwar/inventory/SWItem_v12.java +++ b/SpigotCore_12/src/de/steamwar/inventory/SWItem_v12.java @@ -8,4 +8,8 @@ class SWItem_v12 { static Material getMaterial(String material){ return Material.valueOf(material); } + + static Material getDye(){ + return Material.INK_SACK; + } } diff --git a/SpigotCore_14/pom.xml b/SpigotCore_14/pom.xml new file mode 100644 index 0000000..37ebf61 --- /dev/null +++ b/SpigotCore_14/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + + steamwar + SpigotCore + 2.0 + + + SpigotCore_14 + 2.0 + + + src + + + src + + **/*.java + **/*.kt + + + + + + + + steamwar + Spigot-1.14 + 1.0 + provided + + + \ No newline at end of file diff --git a/SpigotCore_14/src/de/steamwar/inventory/SWInventory_v14.java b/SpigotCore_14/src/de/steamwar/inventory/SWInventory_v14.java new file mode 100644 index 0000000..e24fa02 --- /dev/null +++ b/SpigotCore_14/src/de/steamwar/inventory/SWInventory_v14.java @@ -0,0 +1,13 @@ +package de.steamwar.inventory; + +import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftInventoryCustom; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; + +class SWInventory_v14 { + private SWInventory_v14() {} + + static Inventory get(Player player, int size, String title){ + return new CraftInventoryCustom(player, size, title); + } +} diff --git a/SpigotCore_14/src/de/steamwar/inventory/SWItem_v14.java b/SpigotCore_14/src/de/steamwar/inventory/SWItem_v14.java new file mode 100644 index 0000000..d881616 --- /dev/null +++ b/SpigotCore_14/src/de/steamwar/inventory/SWItem_v14.java @@ -0,0 +1,48 @@ +package de.steamwar.inventory; + +import org.bukkit.Material; + +class SWItem_v14 { + private SWItem_v14(){} + + static Material getMaterial(String material) { + return Material.valueOf("LEGACY_" + material); + } + + static Material getDye(int colorCode){ + switch(colorCode){ + case 1: + return Material.RED_DYE; + case 2: + return Material.GREEN_DYE; + case 3: + return Material.BROWN_DYE; + case 4: + return Material.LAPIS_LAZULI; + case 5: + return Material.PURPLE_DYE; + case 6: + return Material.CYAN_DYE; + case 7: + return Material.LIGHT_GRAY_DYE; + case 8: + return Material.GRAY_DYE; + case 9: + return Material.PINK_DYE; + case 10: + return Material.LIME_DYE; + case 11: + return Material.YELLOW_DYE; + case 12: + return Material.LIGHT_BLUE_DYE; + case 13: + return Material.MAGENTA_DYE; + case 14: + return Material.ORANGE_DYE; + case 15: + return Material.WHITE_DYE; + default: + return Material.BLACK_DYE; + } + } +} diff --git a/SpigotCore_Main/pom.xml b/SpigotCore_Main/pom.xml new file mode 100644 index 0000000..64c843d --- /dev/null +++ b/SpigotCore_Main/pom.xml @@ -0,0 +1,68 @@ + + + 4.0.0 + + + steamwar + SpigotCore + 2.0 + + + SpigotCore_Main + 2.0 + jar + + + src + + + src + + **/*.java + **/*.kt + + + + + + maven-assembly-plugin + + + package + + single + + + + + + jar-with-dependencies + + + + + + + + + steamwar + Spigot-1.12 + 1.0 + provided + + + steamwar + SpigotCore_12 + 2.0 + compile + + + steamwar + SpigotCore_14 + 2.0 + compile + + + \ No newline at end of file diff --git a/src/de/steamwar/core/CommandRemover.java b/SpigotCore_Main/src/de/steamwar/core/CommandRemover.java similarity index 100% rename from src/de/steamwar/core/CommandRemover.java rename to SpigotCore_Main/src/de/steamwar/core/CommandRemover.java diff --git a/src/de/steamwar/core/Core.java b/SpigotCore_Main/src/de/steamwar/core/Core.java similarity index 100% rename from src/de/steamwar/core/Core.java rename to SpigotCore_Main/src/de/steamwar/core/Core.java diff --git a/src/de/steamwar/core/events/ChattingEvent.java b/SpigotCore_Main/src/de/steamwar/core/events/ChattingEvent.java similarity index 63% rename from src/de/steamwar/core/events/ChattingEvent.java rename to SpigotCore_Main/src/de/steamwar/core/events/ChattingEvent.java index 17eff2f..fd95b2e 100644 --- a/src/de/steamwar/core/events/ChattingEvent.java +++ b/SpigotCore_Main/src/de/steamwar/core/events/ChattingEvent.java @@ -1,6 +1,5 @@ package de.steamwar.core.events; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.AsyncPlayerChatEvent; @@ -9,7 +8,6 @@ public class ChattingEvent implements Listener { @EventHandler private void onChat(AsyncPlayerChatEvent event) { - Player player = event.getPlayer(); - event.setFormat("§eLokal §r"+ player.getDisplayName() + "§8» §7" + event.getMessage()); + event.setFormat("§eLokal §r"+ event.getPlayer().getDisplayName() + "§8» §7" + event.getMessage()); } } diff --git a/src/de/steamwar/core/events/PlayerJoinedEvent.java b/SpigotCore_Main/src/de/steamwar/core/events/PlayerJoinedEvent.java similarity index 100% rename from src/de/steamwar/core/events/PlayerJoinedEvent.java rename to SpigotCore_Main/src/de/steamwar/core/events/PlayerJoinedEvent.java diff --git a/src/de/steamwar/inventory/InvCallback.java b/SpigotCore_Main/src/de/steamwar/inventory/InvCallback.java similarity index 100% rename from src/de/steamwar/inventory/InvCallback.java rename to SpigotCore_Main/src/de/steamwar/inventory/InvCallback.java diff --git a/src/de/steamwar/inventory/SWInventory.java b/SpigotCore_Main/src/de/steamwar/inventory/SWInventory.java similarity index 93% rename from src/de/steamwar/inventory/SWInventory.java rename to SpigotCore_Main/src/de/steamwar/inventory/SWInventory.java index 19607ea..74b346c 100644 --- a/src/de/steamwar/inventory/SWInventory.java +++ b/SpigotCore_Main/src/de/steamwar/inventory/SWInventory.java @@ -26,10 +26,10 @@ public class SWInventory implements Listener { player = p; switch(Core.getVersion()){ case 14: - inventory = new SWInventory_v14(p, size, t); + inventory = SWInventory_v14.get(p, size, t); break; default: - inventory = new SWInventory_v12(p, size, t); + inventory = SWInventory_v12.get(p, size, t); } } @@ -81,7 +81,7 @@ public class SWInventory implements Listener { e.setCancelled(true); if(callbacks.containsKey(e.getRawSlot())) - callbacks.get(e.getSlot()).clicked(e.getClick()); + callbacks.get(e.getRawSlot()).clicked(e.getClick()); } @EventHandler diff --git a/src/de/steamwar/inventory/SWItem.java b/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java similarity index 89% rename from src/de/steamwar/inventory/SWItem.java rename to SpigotCore_Main/src/de/steamwar/inventory/SWItem.java index 9feeb56..bcfdeac 100644 --- a/src/de/steamwar/inventory/SWItem.java +++ b/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java @@ -38,6 +38,15 @@ public class SWItem { } } + public static Material getDye(int colorCode){ + switch(Core.getVersion()){ + case 14: + return SWItem_v14.getDye(colorCode); + default: + return SWItem_v12.getDye(); + } + } + public SWItem(){ itemStack = new ItemStack(Material.AIR); itemMeta = itemStack.getItemMeta(); @@ -53,7 +62,11 @@ public class SWItem { } public SWItem(Material material, byte meta, String name, List lore, boolean enchanted, InvCallback c){ - itemStack = new ItemStack(material, 1, (short)0, meta); + try{ + itemStack = new ItemStack(material, 1, (short)0, meta); + }catch(IllegalArgumentException e){ + itemStack = new ItemStack(material, 1); + } itemMeta = itemStack.getItemMeta(); if(itemMeta != null){ diff --git a/src/de/steamwar/inventory/SWListInv.java b/SpigotCore_Main/src/de/steamwar/inventory/SWListInv.java similarity index 87% rename from src/de/steamwar/inventory/SWListInv.java rename to SpigotCore_Main/src/de/steamwar/inventory/SWListInv.java index 49671e8..72f6e8e 100644 --- a/src/de/steamwar/inventory/SWListInv.java +++ b/SpigotCore_Main/src/de/steamwar/inventory/SWListInv.java @@ -31,19 +31,19 @@ public class SWListInv extends SWInventory { setCallback(-999, (ClickType click) -> player.closeInventory()); if(elements.size() > 54){ if(page != 0) - setItem(45, SWItem.getMaterial("INK_SACK"), (byte)10, "§eSeite zurück", (ClickType click) -> { + setItem(45, SWItem.getDye(10), (byte)10, "§eSeite zurück", (ClickType click) -> { page--; open(); }); else - setItem(45, SWItem.getMaterial("INK_SACK"), (byte)8, "§7Seite zurück", (ClickType click) -> {}); + setItem(45, SWItem.getDye(8), (byte)8, "§7Seite zurück", (ClickType click) -> {}); if(page < elements.size()/45) - setItem(53, SWItem.getMaterial("INK_SACK"), (byte)10, "§eSeite vor", (ClickType click) -> { + setItem(53, SWItem.getDye(10), (byte)10, "§eSeite vor", (ClickType click) -> { page++; open(); }); else - setItem(53, SWItem.getMaterial("INK_SACK"), (byte)8, "§7Seite vor", (ClickType click) -> {}); + setItem(53, SWItem.getDye(8), (byte)8, "§7Seite vor", (ClickType click) -> {}); } int ipageLimit = elements.size() - page*45; diff --git a/src/de/steamwar/sql/BauweltMember.java b/SpigotCore_Main/src/de/steamwar/sql/BauweltMember.java similarity index 100% rename from src/de/steamwar/sql/BauweltMember.java rename to SpigotCore_Main/src/de/steamwar/sql/BauweltMember.java diff --git a/src/de/steamwar/sql/CheckedSchematic.java b/SpigotCore_Main/src/de/steamwar/sql/CheckedSchematic.java similarity index 100% rename from src/de/steamwar/sql/CheckedSchematic.java rename to SpigotCore_Main/src/de/steamwar/sql/CheckedSchematic.java diff --git a/src/de/steamwar/sql/Event.java b/SpigotCore_Main/src/de/steamwar/sql/Event.java similarity index 100% rename from src/de/steamwar/sql/Event.java rename to SpigotCore_Main/src/de/steamwar/sql/Event.java diff --git a/src/de/steamwar/sql/EventFight.java b/SpigotCore_Main/src/de/steamwar/sql/EventFight.java similarity index 84% rename from src/de/steamwar/sql/EventFight.java rename to SpigotCore_Main/src/de/steamwar/sql/EventFight.java index 7c39e0e..65a31cb 100644 --- a/src/de/steamwar/sql/EventFight.java +++ b/SpigotCore_Main/src/de/steamwar/sql/EventFight.java @@ -40,15 +40,9 @@ public class EventFight { return null; } - /*public void setErgebnis(FightTeam winner){ - if (winner == null) - ergebnis = 0; - else if (winner.isBlue()) - ergebnis = 1; - else - ergebnis = 2; - SQL.update("UPDATE EventFight SET Ergebnis = " + ergebnis + " WHERE FightID = " + fightID); - }*/ + public void setErgebnis(int winner){ + SQL.update("UPDATE EventFight SET Ergebnis = " + winner + " WHERE FightID = " + fightID); + } public int getTeamBlue() { return teamBlue; diff --git a/src/de/steamwar/sql/SQL.java b/SpigotCore_Main/src/de/steamwar/sql/SQL.java similarity index 100% rename from src/de/steamwar/sql/SQL.java rename to SpigotCore_Main/src/de/steamwar/sql/SQL.java diff --git a/src/de/steamwar/sql/Schematic.java b/SpigotCore_Main/src/de/steamwar/sql/Schematic.java similarity index 100% rename from src/de/steamwar/sql/Schematic.java rename to SpigotCore_Main/src/de/steamwar/sql/Schematic.java diff --git a/src/de/steamwar/sql/SchematicMember.java b/SpigotCore_Main/src/de/steamwar/sql/SchematicMember.java similarity index 100% rename from src/de/steamwar/sql/SchematicMember.java rename to SpigotCore_Main/src/de/steamwar/sql/SchematicMember.java diff --git a/src/de/steamwar/sql/SchematicType.java b/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java similarity index 100% rename from src/de/steamwar/sql/SchematicType.java rename to SpigotCore_Main/src/de/steamwar/sql/SchematicType.java diff --git a/src/de/steamwar/sql/SteamwarUser.java b/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java similarity index 100% rename from src/de/steamwar/sql/SteamwarUser.java rename to SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java diff --git a/src/de/steamwar/sql/Team.java b/SpigotCore_Main/src/de/steamwar/sql/Team.java similarity index 100% rename from src/de/steamwar/sql/Team.java rename to SpigotCore_Main/src/de/steamwar/sql/Team.java diff --git a/src/de/steamwar/sql/UserGroup.java b/SpigotCore_Main/src/de/steamwar/sql/UserGroup.java similarity index 100% rename from src/de/steamwar/sql/UserGroup.java rename to SpigotCore_Main/src/de/steamwar/sql/UserGroup.java diff --git a/SpigotCore_Main/src/plugin.yml b/SpigotCore_Main/src/plugin.yml new file mode 100644 index 0000000..4101be6 --- /dev/null +++ b/SpigotCore_Main/src/plugin.yml @@ -0,0 +1,7 @@ +name: SpigotCore +version: 1.0 +author: Lixfel +api-version: 1.13 + +main: de.steamwar.core.Core +commands: \ No newline at end of file diff --git a/pom.xml b/pom.xml index 30937db..44e9722 100644 --- a/pom.xml +++ b/pom.xml @@ -4,10 +4,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - de.steamwar + steamwar SpigotCore - 1.0 - jar + 2.0 + pom https://maven.apache.org @@ -22,16 +22,6 @@ - src - - - src - - **/*.java - **/*.kt - - - org.apache.maven.plugins @@ -45,20 +35,9 @@ - - - steamwar - Spigot-1.12 - 1.0 - provided - true - - - steamwar - Spigot-1.14 - 1.0 - provided - true - - + + SpigotCore_12 + SpigotCore_14 + SpigotCore_Main + \ No newline at end of file diff --git a/src/de/steamwar/inventory/SWInventory_v12.java b/src/de/steamwar/inventory/SWInventory_v12.java deleted file mode 100644 index 4704d7f..0000000 --- a/src/de/steamwar/inventory/SWInventory_v12.java +++ /dev/null @@ -1,11 +0,0 @@ -package de.steamwar.inventory; - -import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftInventoryCustom; -import org.bukkit.entity.Player; - -class SWInventory_v12 extends CraftInventoryCustom { - - SWInventory_v12(Player player, int size, String title) { - super(player, size, title); - } -} diff --git a/src/de/steamwar/inventory/SWInventory_v14.java b/src/de/steamwar/inventory/SWInventory_v14.java deleted file mode 100644 index 7b4b827..0000000 --- a/src/de/steamwar/inventory/SWInventory_v14.java +++ /dev/null @@ -1,11 +0,0 @@ -package de.steamwar.inventory; - -import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftInventoryCustom; -import org.bukkit.entity.Player; - -class SWInventory_v14 extends CraftInventoryCustom { - - SWInventory_v14(Player player, int size, String title) { - super(player, size, title); - } -} diff --git a/src/de/steamwar/inventory/SWItem_v14.java b/src/de/steamwar/inventory/SWItem_v14.java deleted file mode 100644 index 9525448..0000000 --- a/src/de/steamwar/inventory/SWItem_v14.java +++ /dev/null @@ -1,11 +0,0 @@ -package de.steamwar.inventory; - -import org.bukkit.Material; - -class SWItem_v14 { - private SWItem_v14(){} - - static Material getMaterial(String material){ - return Material.valueOf("LEGACY_" + material); - } -} diff --git a/src/plugin.yml b/src/plugin.yml deleted file mode 100644 index e8d0b15..0000000 --- a/src/plugin.yml +++ /dev/null @@ -1,8 +0,0 @@ -name: CoreSystem -version: 1.0 - -author: hunjy, Lixfel - -main: de.steamwar.core.Core - -commands: \ No newline at end of file