From a108a810ea955275debe75b61de0c19e872d004e Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 10 Nov 2019 17:29:59 +0100 Subject: [PATCH] Refitting vor new Core --- pom.xml | 2 +- src/de/steamwar/fightsystem/FightSystem.java | 12 +- .../fightsystem/commands/AkCommand.java | 12 +- src/de/steamwar/fightsystem/commands/GUI.java | 12 +- .../countdown/PreRunningCountdown.java | 2 +- .../steamwar/fightsystem/fight/FightTeam.java | 6 +- .../listener/EventJoinListener.java | 4 +- .../listener/PlayerDeathListener.java | 1 + src/de/steamwar/fightsystem/utils/Config.java | 11 +- .../steamwar/fightsystem/utils/TechHider.java | 130 ++++++++++-------- .../steamwar/fightsystem/utils/sql/Event.java | 61 -------- .../fightsystem/utils/sql/EventFight.java | 78 ----------- .../steamwar/fightsystem/utils/sql/Team.java | 75 ---------- src/plugin.yml | 2 +- 14 files changed, 109 insertions(+), 299 deletions(-) delete mode 100644 src/de/steamwar/fightsystem/utils/sql/Event.java delete mode 100644 src/de/steamwar/fightsystem/utils/sql/EventFight.java delete mode 100644 src/de/steamwar/fightsystem/utils/sql/Team.java diff --git a/pom.xml b/pom.xml index fdf949b..62edf11 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ steamwar SpigotCore - 1.0 + 2.0 provided diff --git a/src/de/steamwar/fightsystem/FightSystem.java b/src/de/steamwar/fightsystem/FightSystem.java index 9019fe9..e7b696c 100644 --- a/src/de/steamwar/fightsystem/FightSystem.java +++ b/src/de/steamwar/fightsystem/FightSystem.java @@ -12,8 +12,8 @@ import de.steamwar.fightsystem.utils.Config; import de.steamwar.fightsystem.utils.FightScoreboard; import de.steamwar.fightsystem.utils.TechHider; import de.steamwar.fightsystem.utils.WaterRemover; -import de.steamwar.fightsystem.utils.sql.EventFight; import de.steamwar.fightsystem.winconditions.*; +import de.steamwar.sql.EventFight; import javafx.util.Pair; import org.bukkit.Bukkit; import org.bukkit.GameMode; @@ -153,8 +153,14 @@ public class FightSystem extends JavaPlugin { Bukkit.broadcastMessage(PREFIX + "§aKein Team hat gewonnen!"); } - if(Config.event()) - eventFight.setErgebnis(winFightTeam); + if(Config.event()){ + if(winFightTeam == null) + eventFight.setErgebnis(0); + else if(winFightTeam.isBlue()) + eventFight.setErgebnis(1); + else + eventFight.setErgebnis(2); + } if(!Config.test()) new SpectateOverCountdown(); diff --git a/src/de/steamwar/fightsystem/commands/AkCommand.java b/src/de/steamwar/fightsystem/commands/AkCommand.java index 6ed582d..831ecf3 100644 --- a/src/de/steamwar/fightsystem/commands/AkCommand.java +++ b/src/de/steamwar/fightsystem/commands/AkCommand.java @@ -6,10 +6,10 @@ import de.steamwar.fightsystem.fight.FightState; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.kit.KitManager; import de.steamwar.fightsystem.utils.Config; -import de.warking.hunjy.MySQL.Schematic; -import de.warking.hunjy.MySQL.SchematicType; -import de.warking.hunjy.MySQL.UserGroup; -import de.warking.hunjy.MySQL.WarkingUser; +import de.steamwar.sql.Schematic; +import de.steamwar.sql.SchematicType; +import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.UserGroup; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ComponentBuilder; @@ -61,7 +61,7 @@ public class AkCommand implements CommandExecutor { break; case 2: if(args[0].equalsIgnoreCase("addkit")){ - if(WarkingUser.get(player.getUniqueId()).getUserGroup() != UserGroup.Developer){ + if(SteamwarUser.get(player.getUniqueId()).getUserGroup() != UserGroup.Developer){ Commands.sendHelp(player); return false; } @@ -99,7 +99,7 @@ public class AkCommand implements CommandExecutor { Schematic schem; if(args[2].equalsIgnoreCase("public")) { - schem = Schematic.getSchemFromDB(args[1], WarkingUser.get(0).getUUID()); + schem = Schematic.getSchemFromDB(args[1], SteamwarUser.get(0).getUUID()); } else if(args[2].equalsIgnoreCase("private")) { schem = Schematic.getSchemFromDB(args[1], player.getUniqueId()); } else diff --git a/src/de/steamwar/fightsystem/commands/GUI.java b/src/de/steamwar/fightsystem/commands/GUI.java index 41aba44..8e6dc3b 100644 --- a/src/de/steamwar/fightsystem/commands/GUI.java +++ b/src/de/steamwar/fightsystem/commands/GUI.java @@ -10,8 +10,8 @@ import de.steamwar.fightsystem.utils.Config; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; -import de.warking.hunjy.MySQL.Schematic; -import de.warking.hunjy.MySQL.WarkingUser; +import de.steamwar.sql.Schematic; +import de.steamwar.sql.SteamwarUser; import javafx.util.Pair; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -50,7 +50,7 @@ public class GUI { List> players = SWListInv.createPlayerList(p); players.removeIf(swItemUUIDPair -> Fight.getFightPlayer(Bukkit.getPlayer(swItemUUIDPair.getValue())) != null); SWListInv inv = new SWListInv<>(p, "Spieler einladen", (ClickType click, UUID player) -> { - Commands.invite(p, WarkingUser.get(player).getUserName()); + Commands.invite(p, SteamwarUser.get(player).getUserName()); p.closeInventory(); }, players); inv.setCallback(-999, (ClickType click) -> p.closeInventory()); @@ -64,7 +64,7 @@ public class GUI { return; players.removeIf(swItemUUIDPair -> !team.equals(Fight.getPlayerTeam(Bukkit.getPlayer(swItemUUIDPair.getValue())))); SWListInv inv = new SWListInv<>(p, "Spieler rauswerfen", (ClickType click, UUID player) -> { - Commands.kick(p, WarkingUser.get(player).getUserName()); + Commands.kick(p, SteamwarUser.get(player).getUserName()); p.closeInventory(); }, players); inv.setCallback(-999, (ClickType click) -> p.closeInventory()); @@ -109,9 +109,9 @@ public class GUI { if(publicSchems) schems = SWListInv.getSchemList(0, Config.SchematicType); else if(Config.test()) - schems = SWListInv.getSchemList(WarkingUser.get(p.getUniqueId()).getId(), null); + schems = SWListInv.getSchemList(SteamwarUser.get(p.getUniqueId()).getId(), null); else - schems = SWListInv.getSchemList(WarkingUser.get(p.getUniqueId()).getId(), Config.SchematicType); + schems = SWListInv.getSchemList(SteamwarUser.get(p.getUniqueId()).getId(), Config.SchematicType); SWListInv inv = new SWListInv<>(p, Config.GameName + "-Auswahl", (ClickType click, Schematic s) -> { FightTeam fightTeam = Fight.getPlayerTeam(p); if(fightTeam == null) diff --git a/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java b/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java index a4893db..238b5bb 100644 --- a/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java +++ b/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java @@ -17,6 +17,6 @@ public class PreRunningCountdown extends Countdown { @Override public void countdownFinished() { - FightSystem.getPlugin().setRunningState(); + FightSystem.setRunningState(); } } diff --git a/src/de/steamwar/fightsystem/fight/FightTeam.java b/src/de/steamwar/fightsystem/fight/FightTeam.java index 7b59dbf..aaf4729 100644 --- a/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -12,8 +12,8 @@ import com.sk89q.worldedit.world.World; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.kit.KitManager; import de.steamwar.fightsystem.utils.*; -import de.warking.hunjy.MySQL.Schematic; -import de.warking.hunjy.MySQL.WarkingUser; +import de.steamwar.sql.Schematic; +import de.steamwar.sql.SteamwarUser; import javafx.util.Pair; import org.bukkit.*; import org.bukkit.enchantments.Enchantment; @@ -218,7 +218,7 @@ public class FightTeam { } private void pasteSchematic(){ - File file = new File(Config.SchematicDirectory + WarkingUser.get(schematic.getSchemOwner()).getUUID().toString(), schematic.getSchemName() + ".schematic"); + File file = new File(Config.SchematicDirectory + SteamwarUser.get(schematic.getSchemOwner()).getUUID().toString(), schematic.getSchemName() + ".schematic"); com.boydti.fawe.object.schematic.Schematic schem; try { schem = FaweAPI.load(file); diff --git a/src/de/steamwar/fightsystem/listener/EventJoinListener.java b/src/de/steamwar/fightsystem/listener/EventJoinListener.java index 2673b56..cc0f0db 100644 --- a/src/de/steamwar/fightsystem/listener/EventJoinListener.java +++ b/src/de/steamwar/fightsystem/listener/EventJoinListener.java @@ -6,7 +6,7 @@ import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.fight.FightState; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.utils.Config; -import de.warking.hunjy.MySQL.WarkingUser; +import de.steamwar.sql.SteamwarUser; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; @@ -17,7 +17,7 @@ public class EventJoinListener extends BasicListener { @EventHandler public void handlePlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); - WarkingUser user = WarkingUser.get(player.getUniqueId()); + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); FightTeam team = null; if(user.getTeam() == Config.EventTeamBlueID) diff --git a/src/de/steamwar/fightsystem/listener/PlayerDeathListener.java b/src/de/steamwar/fightsystem/listener/PlayerDeathListener.java index 3146ccf..0005e36 100644 --- a/src/de/steamwar/fightsystem/listener/PlayerDeathListener.java +++ b/src/de/steamwar/fightsystem/listener/PlayerDeathListener.java @@ -22,6 +22,7 @@ public class PlayerDeathListener extends BasicListener { return; Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + fightTeam.getPrefix() + player.getName() + " §cist gestorben!"); + event.setDeathMessage(null); fightTeam.getFightPlayer(player).setOut(); player.setGameMode(GameMode.SPECTATOR); player.teleport(fightTeam.getSpawn()); diff --git a/src/de/steamwar/fightsystem/utils/Config.java b/src/de/steamwar/fightsystem/utils/Config.java index 9b136e9..5d69e44 100644 --- a/src/de/steamwar/fightsystem/utils/Config.java +++ b/src/de/steamwar/fightsystem/utils/Config.java @@ -2,10 +2,9 @@ package de.steamwar.fightsystem.utils; import com.sk89q.worldedit.Vector; import de.steamwar.fightsystem.FightSystem; -import de.steamwar.fightsystem.utils.sql.Event; -import de.steamwar.fightsystem.utils.sql.EventFight; -import de.steamwar.fightsystem.utils.sql.Team; -import de.warking.hunjy.MySQL.SchematicType; +import de.steamwar.sql.Event; +import de.steamwar.sql.EventFight; +import de.steamwar.sql.Team; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; @@ -45,7 +44,7 @@ public class Config { public static boolean OnlyPublicSchematics; public static String SchematicDirectory; - public static SchematicType SchematicType; + public static de.steamwar.sql.SchematicType SchematicType; public static boolean TeamRedRotate; public static boolean TeamBlueRotate; @@ -142,7 +141,7 @@ public class Config { OnlyPublicSchematics = config.getBoolean("Schematic.OnlyPublicSchematics"); SchematicDirectory = config.getString("Schematic.Directory"); - SchematicType = de.warking.hunjy.MySQL.SchematicType.fromDB(config.getString("Schematic.SchematicType")); + SchematicType = de.steamwar.sql.SchematicType.fromDB(config.getString("Schematic.SchematicType")); boolean Rotate = config.getBoolean("Schematic.Rotate"); TeamRedName = config.getString("Output.TeamRedName"); diff --git a/src/de/steamwar/fightsystem/utils/TechHider.java b/src/de/steamwar/fightsystem/utils/TechHider.java index 9b0a189..84b134e 100644 --- a/src/de/steamwar/fightsystem/utils/TechHider.java +++ b/src/de/steamwar/fightsystem/utils/TechHider.java @@ -30,7 +30,6 @@ import org.bukkit.entity.Player; import java.util.*; public class TechHider { - private TechHider(){} private static Map packetCache = new HashMap<>(); @@ -48,7 +47,7 @@ public class TechHider { private static int redMinZ; private static int redMaxZ; private static short obfuscateShift4; - private static final short BITMASK = 0x1FF; + //private static final short BITMASK = 0x1FF; private static Material obfuscateMaterial; private static boolean running = false; private static int threadMultiplier = 1; @@ -72,6 +71,7 @@ public class TechHider { redMaxZ = posToChunk(Config.TeamRedCornerZ + Config.SchemsizeZ) + 1; obfuscateShift4 = (short)(Config.ObfuscateWith << 4); + //noinspection deprecation obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith); if(Config.event()) @@ -109,7 +109,40 @@ public class TechHider { Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), packetCache::clear, 1, 1); - ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) { + chunkHider(); + multiBlockHider(); + blockHider(); + blockActionHider(); + } + + private static boolean bypass(Player p, int chunkX, int chunkZ){ + if(p == FightSystem.getEventLeiter()) + return true; + + FightTeam ft = Fight.getPlayerTeam(p); + if(ft == null){ + //Außerhalb der Arena + return arenaMinX > chunkX || + chunkX > arenaMaxX || + arenaMinZ > chunkZ || + chunkZ > arenaMaxZ; + }else if(ft.isBlue()){ + return FightSystem.isEntern() || + redMinX > chunkX || + chunkX > redMaxX || + redMinZ > chunkZ || + chunkZ > redMaxZ; + }else{ + return FightSystem.isEntern() || + blueMinX > chunkX || + chunkX > blueMaxX || + blueMinZ > chunkZ || + chunkZ > blueMaxZ; + } + } + + private static void chunkHider(){ + ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) { @Override public void onPacketSending(PacketEvent e) { PacketContainer packet = e.getPacket(); @@ -220,34 +253,10 @@ public class TechHider { byteArray.write(0, data); } } - }); - ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_CHANGE) { - @Override - public void onPacketSending(PacketEvent e) { - PacketContainer packet = e.getPacket(); - BlockPosition pos = packet.getBlockPositionModifier().read(0); + }).start(threadMultiplier * 4); + } - Player p = e.getPlayer(); - if(bypass(p, posToChunk(pos.getX()), posToChunk(pos.getZ()))) - return; - - PacketContainer cached = packetCache.get(packet); - if(cached != null){ - e.setPacket(cached); - return; - } - - cached = packet.deepClone(); - packetCache.put(packet, cached); - e.setPacket(cached); - StructureModifier blockStructure = cached.getBlockData(); - WrappedBlockData block = blockStructure.read(0); - if(Config.HiddenBlocks.contains(block.getType().getId())){ - block.setType(obfuscateMaterial); - blockStructure.write(0, block); - } - } - }); + private static void multiBlockHider(){ ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MULTI_BLOCK_CHANGE) { @Override public void onPacketSending(PacketEvent e) { @@ -272,6 +281,7 @@ public class TechHider { boolean changed = false; for(MultiBlockChangeInfo mbci : changes){ WrappedBlockData block = mbci.getData(); + //noinspection deprecation if(Config.HiddenBlocks.contains(block.getType().getId())){ changed = true; block.setType(obfuscateMaterial); @@ -284,6 +294,40 @@ public class TechHider { } } }); + } + + private static void blockHider(){ + ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_CHANGE) { + @Override + public void onPacketSending(PacketEvent e) { + PacketContainer packet = e.getPacket(); + BlockPosition pos = packet.getBlockPositionModifier().read(0); + + Player p = e.getPlayer(); + if(bypass(p, posToChunk(pos.getX()), posToChunk(pos.getZ()))) + return; + + PacketContainer cached = packetCache.get(packet); + if(cached != null){ + e.setPacket(cached); + return; + } + + cached = packet.deepClone(); + packetCache.put(packet, cached); + e.setPacket(cached); + StructureModifier blockStructure = cached.getBlockData(); + WrappedBlockData block = blockStructure.read(0); + //noinspection deprecation + if(Config.HiddenBlocks.contains(block.getType().getId())){ + block.setType(obfuscateMaterial); + blockStructure.write(0, block); + } + } + }); + } + + private static void blockActionHider(){ ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_ACTION) { @Override public void onPacketSending(PacketEvent e) { @@ -299,32 +343,6 @@ public class TechHider { }); } - private static boolean bypass(Player p, int chunkX, int chunkZ){ - if(p == FightSystem.getEventLeiter()) - return true; - - FightTeam ft = Fight.getPlayerTeam(p); - if(ft == null){ - //Außerhalb der Arena - return arenaMinX > chunkX || - chunkX > arenaMaxX || - arenaMinZ > chunkZ || - chunkZ > arenaMaxZ; - }else if(ft.isBlue()){ - return FightSystem.isEntern() || - redMinX > chunkX || - chunkX > redMaxX || - redMinZ > chunkZ || - chunkZ > redMaxZ; - }else{ - return FightSystem.isEntern() || - blueMinX > chunkX || - chunkX > blueMaxX || - blueMinZ > chunkZ || - chunkZ > blueMaxZ; - } - } - public static List> prepareChunkReload(Player p){ if(disabled()) return Collections.emptyList(); diff --git a/src/de/steamwar/fightsystem/utils/sql/Event.java b/src/de/steamwar/fightsystem/utils/sql/Event.java deleted file mode 100644 index c0875ec..0000000 --- a/src/de/steamwar/fightsystem/utils/sql/Event.java +++ /dev/null @@ -1,61 +0,0 @@ -package de.steamwar.fightsystem.utils.sql; - -import org.bukkit.Bukkit; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.logging.Level; - -import static de.warking.hunjy.Core.sql; - -public class Event { - - private final int eventID; - private final String eventName; - private final Timestamp start; - private final Timestamp end; - private final int maximumTeamMembers; - private final boolean publicSchemsOnly; - - private Event(int eventID, String eventName, Timestamp start, Timestamp end, int maximumTeamMembers, boolean publicSchemsOnly){ - this.eventID = eventID; - this.eventName = eventName; - this.start = start; - this.end = end; - this.maximumTeamMembers = maximumTeamMembers; - this.publicSchemsOnly = publicSchemsOnly; - } - - public static Event get(int eventID){ - ResultSet rs = sql.select("SELECT * FROM Event WHERE EventID = " + eventID); - try{ - if(!rs.next()) - throw new IllegalArgumentException(); - - return new Event(eventID, rs.getString("EventName"), rs.getTimestamp("Start"), rs.getTimestamp("End"), rs.getInt("MaximumTeamMembers"), rs.getBoolean("PublicSchemsOnly")); - }catch (SQLException e){ - Bukkit.getLogger().log(Level.SEVERE, "Failed to load Event", e); - throw new SecurityException(); - } - } - - public int getEventID() { - return eventID; - } - public String getEventName() { - return eventName; - } - public Timestamp getStart() { - return start; - } - public Timestamp getEnd() { - return end; - } - public int getMaximumTeamMembers() { - return maximumTeamMembers; - } - public boolean publicSchemsOnly() { - return publicSchemsOnly; - } -} diff --git a/src/de/steamwar/fightsystem/utils/sql/EventFight.java b/src/de/steamwar/fightsystem/utils/sql/EventFight.java deleted file mode 100644 index 237ab28..0000000 --- a/src/de/steamwar/fightsystem/utils/sql/EventFight.java +++ /dev/null @@ -1,78 +0,0 @@ -package de.steamwar.fightsystem.utils.sql; - -import de.steamwar.fightsystem.fight.FightTeam; -import de.warking.hunjy.Core; -import org.bukkit.Bukkit; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.logging.Level; - -public class EventFight { - private int eventID; - private int fightID; - private int teamBlue; - private int teamRed; - private int kampfleiter; - private int ergebnis; - - private EventFight(int eventID, int fightID, int teamBlue, int teamRed, int kampfleiter, int ergebnis){ - this.eventID = eventID; - this.fightID = fightID; - this.teamBlue = teamBlue; - this.teamRed = teamRed; - this.kampfleiter = kampfleiter; - this.ergebnis = ergebnis; - } - - public static EventFight get(int fightID){ - ResultSet rs = Core.sql.select("SELECT * FROM EventFight WHERE FightID = " + fightID); - try{ - rs.next(); - return new EventFight( - rs.getInt("EventID"), - fightID, - rs.getInt("TeamBlue"), - rs.getInt("TeamRed"), - rs.getInt("Kampfleiter"), - rs.getInt("Ergebnis")); - }catch (SQLException e){ - Bukkit.getLogger().log(Level.SEVERE, "Failed to load EventFight", e); - } - return null; - } - - public void setErgebnis(FightTeam winner){ - if (winner == null) - ergebnis = 0; - else if (winner.isBlue()) - ergebnis = 1; - else - ergebnis = 2; - Core.sql.update("UPDATE EventFight SET Ergebnis = " + ergebnis + " WHERE FightID = " + fightID); - } - - public int getTeamBlue() { - return teamBlue; - } - - public int getTeamRed() { - return teamRed; - } - - public int getEventID() { - return eventID; - } - - public int getFightID() { - return fightID; - } - - public int getKampfleiter() { - return kampfleiter; - } - - public int getErgebnis() { - return ergebnis; - } -} diff --git a/src/de/steamwar/fightsystem/utils/sql/Team.java b/src/de/steamwar/fightsystem/utils/sql/Team.java deleted file mode 100644 index 48909b4..0000000 --- a/src/de/steamwar/fightsystem/utils/sql/Team.java +++ /dev/null @@ -1,75 +0,0 @@ -package de.steamwar.fightsystem.utils.sql; - -import org.bukkit.Bukkit; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; - -import static de.warking.hunjy.Core.sql; - -public class Team { - private final int teamId; - private String teamKuerzel; - private String teamName; - private int teamLeader; - - private Team(int id, String kuerzel, String name, int leader){ - teamId = id; - teamKuerzel = kuerzel; - teamName = name; - teamLeader = leader; - } - - public static Team get(int id){ - return load(sql.select("SELECT * FROM Team WHERE TeamID = " + id)); - } - - private static Team load(ResultSet dbteam){ - try { - if(!dbteam.next()){ - return null; - } - int id = dbteam.getInt("TeamID"); - String kuerzel = dbteam.getString("TeamKuerzel"); - String name = dbteam.getString("TeamName"); - int leader = dbteam.getInt("TeamLeader"); - return new Team(id, kuerzel, name, leader); - } catch (SQLException e) { - Bukkit.getLogger().log(Level.SEVERE, "Could not load teammembers", e); - return null; - } - } - - public int getTeamId() { - return teamId; - } - - public String getTeamKuerzel() { - return teamKuerzel; - } - - public String getTeamName() { - return teamName; - } - - public int getTeamLeader() { - return teamLeader; - } - - public List getMembers(){ - try{ - ResultSet memberlist = sql.select("SELECT id FROM UserData WHERE Team = '" + teamId + "'"); - List members = new ArrayList<>(); - while(memberlist.next()){ - members.add(memberlist.getInt("id")); - } - return members; - }catch(SQLException e){ - Bukkit.getLogger().log(Level.SEVERE, "Could not load Teammembers", e); - } - return new ArrayList<>(); - } -} diff --git a/src/plugin.yml b/src/plugin.yml index d8819cd..2064fea 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -2,7 +2,7 @@ name: FightSystem version: 1.0 author: [Yaruma3341, Lixfel] main: de.steamwar.fightsystem.FightSystem -depend: [CoreSystem, WorldEdit, FastAsyncWorldEdit, ProtocolLib] +depend: [SpigotCore, WorldEdit, ProtocolLib] commands: ak: