diff --git a/FightSystem_10/src/de/steamwar/fightsystem/listener/DenyWorldInteraction_10.java b/FightSystem_10/src/de/steamwar/fightsystem/listener/DenyWorldInteraction_10.java new file mode 100644 index 0000000..5a805c9 --- /dev/null +++ b/FightSystem_10/src/de/steamwar/fightsystem/listener/DenyWorldInteraction_10.java @@ -0,0 +1,32 @@ +/* + 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 + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +package de.steamwar.fightsystem.listener; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerSwapHandItemsEvent; + +public class DenyWorldInteraction_10 implements Listener { + + @EventHandler + public void onSwapItems(PlayerSwapHandItemsEvent event) { + event.setCancelled(true); + } +} diff --git a/FightSystem_API/src/de/steamwar/fightsystem/utils/Region.java b/FightSystem_API/src/de/steamwar/fightsystem/utils/Region.java index e31673f..a4f9953 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/utils/Region.java +++ b/FightSystem_API/src/de/steamwar/fightsystem/utils/Region.java @@ -19,12 +19,10 @@ package de.steamwar.fightsystem.utils; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.block.Block; import java.util.function.ObjIntConsumer; -import java.util.logging.Level; public class Region { @@ -41,7 +39,6 @@ public class Region { } public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ) { - Bukkit.getLogger().log(Level.INFO, minX + " " + minY + " " + minZ + " " + sizeX + " " + sizeY + " " + sizeZ); this.minX = minX; this.minY = minY; this.minZ = minZ; diff --git a/FightSystem_API/src/de/steamwar/fightsystem/winconditions/Winconditions.java b/FightSystem_API/src/de/steamwar/fightsystem/winconditions/Winconditions.java index 0394ee7..604cc99 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/winconditions/Winconditions.java +++ b/FightSystem_API/src/de/steamwar/fightsystem/winconditions/Winconditions.java @@ -30,5 +30,6 @@ public enum Winconditions { POINTS, TIME_TECH_KO, WATER_TECH_KO, - PUMPKIN_TECH_KO + PUMPKIN_TECH_KO, + HELLS_BELLS } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java index b875bfc..481ba37 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java @@ -23,6 +23,7 @@ import de.steamwar.core.CommandRemover; import de.steamwar.core.Core; import de.steamwar.fightsystem.commands.*; import de.steamwar.fightsystem.countdown.*; +import de.steamwar.fightsystem.event.HellsBells; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightWorld; @@ -106,6 +107,9 @@ public class FightSystem extends JavaPlugin { new RankedPlayerLeftWincondition(); new WinconditionPercentTimeout(); + //noinspection InstantiationOfUtilityClass + new HellsBells(); + new NoPlayersOnlineCountdown(); new PreSchemCountdown(); new PostSchemCountdown(); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/event/HellsBells.java b/FightSystem_Main/src/de/steamwar/fightsystem/event/HellsBells.java new file mode 100644 index 0000000..27912ae --- /dev/null +++ b/FightSystem_Main/src/de/steamwar/fightsystem/event/HellsBells.java @@ -0,0 +1,265 @@ +/* + 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 + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +package de.steamwar.fightsystem.event; + +import de.steamwar.fightsystem.Config; +import de.steamwar.fightsystem.FightSystem; +import de.steamwar.fightsystem.countdown.Countdown; +import de.steamwar.fightsystem.countdown.SWSound; +import de.steamwar.fightsystem.states.FightState; +import de.steamwar.fightsystem.states.StateDependent; +import de.steamwar.fightsystem.winconditions.Winconditions; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.EntityType; +import org.bukkit.scheduler.BukkitTask; + +import java.util.Arrays; +import java.util.List; +import java.util.Random; +import java.util.concurrent.atomic.AtomicInteger; + + +public class HellsBells { + + public static final Random random = new Random(); + + private final World world = Bukkit.getWorlds().get(0); + private final int xLength = Config.RedPasteRegion.getMaxX() - Config.RedPasteRegion.getMinX(); + private final int zLength = Config.RedPasteRegion.getMaxZ() - Config.RedPasteRegion.getMinZ(); + private State current = State.PRE; + private int currentDrops = 0; + private HellsBellsCountdown currentCountdown; + private BukkitTask currentDropping; + private final List startMessages = Arrays.asList("§c!!Achtung!! Bomber im Anflug, noch ca. eine Minute bis zur Ankunft.", + "§cBomber im Anflug, ca. eine Minute bis zur Ankunft.", + "§cBomber auf dem Radar gesichtet, geschätzte Ankunftszeit: eine Minute.", + "§cUnbekanntes Flugobjekt gesichtet, trifft in ca. einer Minute ein.", + "§cFlugobjekt gesichtet. Ankunft in ca. einer Minute.", + "§cBomber erschienen, Ankunft ca. eine Minute."); + private final List stateSwapMessages = Arrays.asList("§aDie Bomben fallen nun schneller.", + "§aMehr Bomber im Anflug.", + "§aZusätzliche Bomber gesichtet.", + "§aDas Bombardement scheint sich zu erhöhen."); + + public void startCountdown() { + if (current == State.PRE) { + Bukkit.broadcastMessage(FightSystem.PREFIX + (startMessages.get(random.nextInt(startMessages.size())))); + current = current.getNext(); + } else if (current != State.LAST && currentDrops >= current.SWITCH_AFTER) { + Bukkit.broadcastMessage(FightSystem.PREFIX + (stateSwapMessages.get(random.nextInt(stateSwapMessages.size())))); + currentDrops = 0; + } + + currentDrops++; + currentCountdown = new HellsBellsCountdown(current.MIN_TIME + random.nextInt(current.MAX_TIME - current.MIN_TIME)); + currentCountdown.enable(); + } + + public void drop() { + Direction direction = Direction.getRandom(); + + AtomicInteger length = new AtomicInteger(10 + random.nextInt(direction.getLength(zLength, xLength) - 10)); + int width = 5 + random.nextInt(5); + int xOffset = getWidthStart(direction.getLength(xLength, zLength), direction.getLength(length.get(), width)); + int zOffset = getLengthStart(direction.getLength(zLength, xLength), direction.getLength(width, length.get())); + int yOffset = getHeightStart(); + + Point redStart; + Point blueStart; + + if (direction.isNorthOrWest()) { + redStart = new Point(Config.RedPasteRegion.getMaxX() - xOffset, Config.RedExtendRegion.getMaxY() + yOffset, Config.RedPasteRegion.getMaxZ() - zOffset); + blueStart = new Point(Config.BluePasteRegion.getMinX() + xOffset, Config.BlueExtendRegion.getMaxY() + yOffset, Config.BluePasteRegion.getMinZ() + zOffset); + } else { + redStart = new Point(Config.RedPasteRegion.getMinX() + xOffset, Config.RedExtendRegion.getMaxY() + yOffset, Config.RedPasteRegion.getMinZ() + zOffset); + blueStart = new Point(Config.BluePasteRegion.getMaxX() - xOffset, Config.BlueExtendRegion.getMaxY() + yOffset, Config.BluePasteRegion.getMaxZ() - zOffset); + } + + currentDropping = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), () -> { + for (int w = 0; w < width; w++) { + if (direction.isNorthOrWest()) { + world.spawnEntity(redStart.addAndToLocation(world, -1 * (direction.dx * length.get() + w * direction.other().dx), 0, -1 * (direction.dz * length.get() + w * direction.other().dz)), EntityType.PRIMED_TNT); + + world.spawnEntity(blueStart.addAndToLocation(world, direction.dx * length.get() + w * direction.other().dx, 0, direction.dz * length.get() + w * direction.other().dz), EntityType.PRIMED_TNT); + } else { + world.spawnEntity(redStart.addAndToLocation(world, direction.dx * length.get() + w * direction.other().dx, 0, direction.dz * length.get() + w * direction.other().dz), EntityType.PRIMED_TNT); + + world.spawnEntity(blueStart.addAndToLocation(world, -1 * (direction.dx * length.get() + w * direction.other().dx), 0, -1 * (direction.dz * length.get() + w * direction.other().dz)), EntityType.PRIMED_TNT); + } + } + if (length.addAndGet(-2) <= 0) { + currentDropping.cancel(); + } + }, 0L, 4L); + } + + private int getLengthStart(int regionSize, int length) { + return random.nextInt(regionSize - length); + } + + private int getWidthStart(int regionSize, int length) { + return random.nextInt(regionSize - length); + } + + private int getHeightStart() { + return 5 + random.nextInt(15); + } + + public HellsBells() { + new StateDependent(Winconditions.HELLS_BELLS, FightState.Running) { + @Override + public void enable() { + startCountdown(); + } + + @Override + public void disable() { + currentCountdown.disable(); + } + }.register(); + } + + private static class HellsBellsCountdown extends Countdown { + + public HellsBellsCountdown(int time) { + super(time, SWSound.BLOCK_NOTE_BASS, true); + } + + @Override + public String countdownCounting() { + return "bis die Bomben fallen"; + } + + @Override + public void countdownFinished() { + drop(); + + startCountdown(); + } + } + + private static class Point { + + private final int x; + private final int y; + private final int z; + + public Point(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + } + + public Location addAndToLocation(World world, int x, int y, int z) { + return new Location(world, this.x + x, this.y + y, this.z + z); //NOSONAR + } + } + + private enum State { + + PRE(60, 80, 1), + FIRST(40, 60, 5), + SECOND(30, 40, 6), + THIRD(20, 30, 6), + FOURTH(10, 20, 7), + LAST(5, 10, 0); + + + State(int minTime, int maxTime, int switchAfter) { + this.MIN_TIME = minTime; + this.MAX_TIME = maxTime; + this.SWITCH_AFTER = switchAfter; + } + + private final int MIN_TIME; //NOSONAR + private final int MAX_TIME; //NOSONAR + private final int SWITCH_AFTER; //NOSONAR + + + public State getNext() { + switch (this) { + case PRE: + return FIRST; + case FIRST: + return SECOND; + case SECOND: + return THIRD; + case THIRD: + return FOURTH; + case FOURTH: + case LAST: + return LAST; + default: + return PRE; + } + } + } + + private enum Direction { + NORTH(0, 0, 1), + SOUTH(0, 0, -1), + EAST(1, 0, 0), + WEST(-1, 0, 0); + + + int dx; + int dy; + int dz; + + Direction(int dx, int dy, int dz) { + this.dx = dx; + this.dy = dy; + this.dz = dz; + } + + public static Direction getRandom() { + return Direction.values()[random.nextInt(Direction.values().length)]; + } + + Direction other() { + switch (this) { + case NORTH: + return EAST; + case SOUTH: + return WEST; + case EAST: + return NORTH; + case WEST: + return SOUTH; + default: + return this; + } + } + + public int getLength(int length1, int length2) { + return isNorthOrSouth() ? length1 : length2; + } + + public boolean isNorthOrSouth() { + return this == NORTH || this == SOUTH; + } + + public boolean isNorthOrWest() { + return this == NORTH || this == WEST; + } + } +} \ No newline at end of file diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightSchematic.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightSchematic.java index fb63943..172a8b7 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightSchematic.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightSchematic.java @@ -118,7 +118,7 @@ public class FightSchematic extends StateDependent { private void paste(){ FreezeWorld freezer = new FreezeWorld(); - DyeColor c = ColorConverter.chat2dye(team.getColor()); + DyeColor c = ArenaMode.AntiPrepare.contains(Config.mode) ? ColorConverter.chat2dye(team.getColor()) : DyeColor.PINK; try { VersionedRunnable.call(new VersionedRunnable(() -> { @@ -126,25 +126,26 @@ public class FightSchematic extends StateDependent { FightTeam_8.replaceTeamColor(clipboard, c); FightTeam_8.pasteSchematic(clipboard, region, rotate); } catch (NoClipboardException | WorldEditException ex) { - throw new SecurityException("Error pasting arena in schematic", ex); + throw new SecurityException("Error pasting schematic", ex); } }, 8), new VersionedRunnable(() -> { try { FightTeam_12.replaceTeamColor(clipboard, c); FightTeam_8.pasteSchematic(clipboard, region, rotate); } catch (NoClipboardException | WorldEditException ex) { - throw new SecurityException("Error pasting arena in schematic", ex); + throw new SecurityException("Error pasting schematic", ex); } }, 12), new VersionedRunnable(() -> { try { FightTeam_14.replaceTeamColor(clipboard, c); FightTeam_14.pasteSchematic(clipboard, region, rotate); } catch (NoClipboardException | WorldEditException ex) { - throw new SecurityException("Error pasting arena in schematic", ex); + throw new SecurityException("Error pasting schematic", ex); } }, 14)); } catch (SecurityException securityException) { - team.broadcast(FightSystem.PREFIX + "§cFehler beim Pasten der Schematic"); + Bukkit.broadcastMessage(FightSystem.PREFIX + "§cFehler beim Pasten der Schematic"); + Bukkit.getScheduler().runTask(FightSystem.getPlugin(), FightSystem::setPreSchemState); throw securityException; } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java index bc0dfc7..f2a477f 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -94,6 +94,10 @@ public class FightTeam implements IFightTeam{ team.setAllowFriendlyFire(false); } + public UUID getDesignatedLeader(){ + return designatedLeader; + } + public Region getSchemRegion() { return schemRegion; } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArenaBorder.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArenaBorder.java index d0ceee8..5c39bd4 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArenaBorder.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArenaBorder.java @@ -51,8 +51,11 @@ public class ArenaBorder implements Listener { } FightTeam team = Fight.getPlayerTeam(player); - if(team == null || player.getGameMode() == GameMode.SPECTATOR) + if(team == null || player.getGameMode() == GameMode.SPECTATOR){ + if(to.getY() <= Config.ArenaRegion.getMinY()) + reset(event); return; + } if(to.getY() <= Config.ArenaRegion.getMinY()) { if(FightState.infight()) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowStopper.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowStopper.java index 696d0e7..35d8af1 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowStopper.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowStopper.java @@ -21,7 +21,6 @@ package de.steamwar.fightsystem.listener; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.states.FightState; -import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentTask; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -29,17 +28,15 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; -import org.bukkit.event.Listener; import org.bukkit.projectiles.ProjectileSource; import org.bukkit.util.Vector; -public class ArrowStopper implements Listener { +public class ArrowStopper { private static final Vector NULL_VECTOR = new Vector(0, 0, 0); private static final BlockFace[] BLOCK_FACES = {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH}; public ArrowStopper() { - new StateDependentListener(Config.TechhiderActive, FightState.Running, this); new StateDependentTask(Config.TechhiderActive, FightState.Running, this::run, 1, 1); } @@ -85,7 +82,7 @@ public class ArrowStopper implements Listener { } private boolean checkBlock(Block block) { - return Config.HiddenBlocks.contains(block.getType().name()); + return Config.HiddenBlocks.contains(block.getType().name().toLowerCase()); } private boolean invalidEntity(Arrow entity) { diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java index ca0d01c..78b5d50 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java @@ -19,6 +19,7 @@ package de.steamwar.fightsystem.listener; +import de.steamwar.core.Core; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; @@ -39,6 +40,11 @@ public class DenyWorldInteraction implements Listener { public DenyWorldInteraction() { new StateDependentListener(ArenaMode.Test, FightState.PreRunning, this); new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, this); + if(Core.getVersion() > 9){ + Listener listener = new DenyWorldInteraction_10(); + new StateDependentListener(ArenaMode.Test, FightState.PreRunning, listener); + new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, listener); + } } @EventHandler @@ -68,13 +74,13 @@ public class DenyWorldInteraction implements Listener { @EventHandler public void onInventoryClick(InventoryClickEvent event) { - if(PersonalKitCreator.notInKitCreator(event.getWhoClicked())) + if(!PersonalKitCreator.inKitCreator(event.getWhoClicked())) event.setCancelled(true); } @EventHandler public void onInventoryDrag(InventoryDragEvent event) { - if(PersonalKitCreator.notInKitCreator(event.getWhoClicked())) + if(!PersonalKitCreator.inKitCreator(event.getWhoClicked())) event.setCancelled(true); } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/HotbarGUI.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/HotbarGUI.java index 2827c50..94ff28a 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/HotbarGUI.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/HotbarGUI.java @@ -42,17 +42,17 @@ public class HotbarGUI implements Listener { public void handlePlayerInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); - if(!PersonalKitCreator.notInKitCreator(player)) + if(PersonalKitCreator.inKitCreator(player)) return; if(event.getItem() == null) return; + event.setCancelled(true); FightTeam fightTeam = Fight.getPlayerTeam(player); if(fightTeam == null) return; - event.setCancelled(true); ItemMeta itemMeta = event.getItem().getItemMeta(); String displayName = itemMeta.getDisplayName(); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java index 3007ee1..297834f 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java @@ -61,8 +61,8 @@ public class PersonalKitCreator implements Listener { BasicListener.toActionbar(player, TextComponent.fromLegacyText("§eInventar zum Anpassen des Kits öffnen§8!")); } - public static boolean notInKitCreator(HumanEntity player){ - return !openKitCreators.containsKey(player); + public static boolean inKitCreator(HumanEntity player){ + return openKitCreators.containsKey(player); } public static void closeIfInKitCreator(HumanEntity player){ diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/TeamArea.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/TeamArea.java index b397645..db88f9f 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/TeamArea.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/TeamArea.java @@ -82,7 +82,7 @@ public class TeamArea implements Listener { private void checkInInnerArea(Player player, Location to, FightTeam team){ if(team.getSchemRegion().playerInRegion(to) && Config.PreperationArea >= 5){ // Preventing false positives due to small extension player.kickPlayer(null); - Bukkit.getLogger().log(Level.SEVERE, player.getName() + " ist in einen Teambereich eingedrungen."); + Bukkit.getLogger().log(Level.INFO, player.getName() + " ist in einen Teambereich eingedrungen."); } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/FightStatistics.java b/FightSystem_Main/src/de/steamwar/fightsystem/utils/FightStatistics.java index ade520e..4e7928f 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/FightStatistics.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/utils/FightStatistics.java @@ -50,12 +50,8 @@ public class FightStatistics { public static void saveStats(FightTeam winner, String windescription){ String gameMode = Config.SchematicType.toDB(); - int blueLeader = 0; - int redLeader = 0; - if(Fight.getBlueTeam().getLeader() != null) - blueLeader = SteamwarUser.get(Fight.getBlueTeam().getLeader().getPlayer().getUniqueId()).getId(); - if(Fight.getRedTeam().getLeader() != null) - redLeader = SteamwarUser.get(Fight.getRedTeam().getLeader().getPlayer().getUniqueId()).getId(); + int blueLeader = getLeader(Fight.getBlueTeam()); + int redLeader = getLeader(Fight.getRedTeam()); int win = 0; double blueResult; @@ -109,11 +105,19 @@ public class FightStatistics { int newRedElo = (int) Math.round(redElo + K * (1 - blueResult - redWinExpectation)); Elo.setElo(blueLeader, gameMode, newBlueElo); Elo.setElo(redLeader, gameMode, newRedElo); - Bukkit.broadcastMessage(FightSystem.PREFIX + "§7ELO von " + Fight.getBlueTeam().getPrefix() + Fight.getBlueTeam().getLeader().getPlayer().getName() + "§8: §7" + blueElo + "§8»§e" + newBlueElo); - Bukkit.broadcastMessage(FightSystem.PREFIX + "§7ELO von " + Fight.getRedTeam().getPrefix() + Fight.getRedTeam().getLeader().getPlayer().getName() + "§8: §7" + redElo + "§8»§e" + newRedElo); + Bukkit.broadcastMessage(FightSystem.PREFIX + "§7ELO von " + Fight.getBlueTeam().getPrefix() + SteamwarUser.get(blueLeader).getUserName() + "§8: §7" + blueElo + "§8»§e" + newBlueElo); + Bukkit.broadcastMessage(FightSystem.PREFIX + "§7ELO von " + Fight.getRedTeam().getPrefix() + SteamwarUser.get(redLeader).getUserName() + "§8: §7" + redElo + "§8»§e" + newRedElo); } } + private static int getLeader(FightTeam team){ + if(team.getLeader() != null) + return SteamwarUser.get(team.getLeader().getPlayer().getUniqueId()).getId(); + else if(team.getDesignatedLeader() != null) + return SteamwarUser.get(team.getDesignatedLeader()).getId(); + return 0; + } + private static void savePlayerStats(FightPlayer fp, int fightId){ SteamwarUser user = SteamwarUser.get(fp.getPlayer().getUniqueId()); de.steamwar.sql.FightPlayer.create(fightId, user.getId(), fp.getTeam().isBlue(), fp.getKit().getName(), fp.getKills(), !fp.isLiving());