SteamWar/FightSystem
Archiviert
13
1

Code cleanup, Utilize Lombok #414

Zusammengeführt
Lixfel hat 1 Commits von lombok nach master 2024-01-24 12:11:04 +01:00 zusammengeführt
23 geänderte Dateien mit 75 neuen und 222 gelöschten Zeilen

Datei anzeigen

@ -39,7 +39,7 @@ public class CraftbukkitWrapper10 implements CraftbukkitWrapper {
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!FightWorld.isPaper()) {
if (!FightWorld.isPAPER()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();

Datei anzeigen

@ -39,7 +39,7 @@ public class CraftbukkitWrapper12 implements CraftbukkitWrapper {
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!FightWorld.isPaper()) {
if (!FightWorld.isPAPER()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();

Datei anzeigen

@ -38,7 +38,7 @@ public class CraftbukkitWrapper14 implements CraftbukkitWrapper {
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!FightWorld.isPaper()) {
if (!FightWorld.isPAPER()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();

Datei anzeigen

@ -38,7 +38,7 @@ public class CraftbukkitWrapper15 implements CraftbukkitWrapper {
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!FightWorld.isPaper()) {
if (!FightWorld.isPAPER()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();

Datei anzeigen

@ -39,7 +39,7 @@ public class CraftbukkitWrapper9 implements CraftbukkitWrapper {
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!FightWorld.isPaper()) {
if (!FightWorld.isPAPER()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();

Datei anzeigen

@ -39,15 +39,18 @@ import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.record.LiveRecorder;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.*;
import de.steamwar.fightsystem.winconditions.*;
import de.steamwar.message.Message;
import de.steamwar.sql.SchematicNode;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public class FightSystem extends JavaPlugin {
@Getter
private static FightSystem plugin;
private Message message;
@ -97,7 +100,7 @@ public class FightSystem extends JavaPlugin {
new RunningWorldInteraction();
new PersonalKitCreator();
new ArrowStopper();
new ArrowPickup();
new StateDependentListener(ArenaMode.All, FightState.All, BountifulWrapper.impl.newDenyArrowPickupListener());
new BlockFadeListener();
new LeaveableArena();
new ClickAnalyzer();
@ -194,15 +197,6 @@ public class FightSystem extends JavaPlugin {
FightState.setFightState(FightState.SPECTATE);
}
public static FightSystem getPlugin() {
return plugin;
}
public static void broadcast(String msg, Object... params) {
getMessage().broadcast(msg, params);
GlobalRecorder.getInstance().system(msg, params);
}
public static Message getMessage() {
return plugin.message;
}

Datei anzeigen

@ -1,42 +0,0 @@
/*
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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.SimpleCommandMap;
import java.lang.reflect.Field;
public class CommandInjector {
private CommandInjector(){}
private static final String PACKAGE_NAME = Bukkit.getServer().getClass().getPackage().getName();
private static final String VERSION = PACKAGE_NAME.substring(PACKAGE_NAME.lastIndexOf('.') + 1);
public static void injectCommand(Command cmd) throws Exception {
Class serverClass = Class.forName("org.bukkit.craftbukkit." + VERSION + ".CraftServer");
Field f1 = serverClass.getDeclaredField("commandMap");
f1.setAccessible(true);
SimpleCommandMap commandMap = (SimpleCommandMap) f1.get(Bukkit.getServer());
commandMap.register("BauSystem", cmd);
}
}

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.fightsystem.commands;
import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
@ -28,12 +29,20 @@ import de.steamwar.fightsystem.fight.Kit;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.sql.PersonalKit;
import de.steamwar.sql.SteamwarUser;
import lombok.experimental.UtilityClass;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.entity.Player;
@UtilityClass
public class Commands {
private Commands(){}
private static final Reflection.FieldAccessor<SimpleCommandMap> commandMap = Reflection.getField("{obc}.CraftServer", "commandMap", SimpleCommandMap.class);
public static void injectCommand(Command cmd) {
commandMap.get(Bukkit.getServer()).register("FightSystem", cmd);
}
private static void errNoTeam(Player p){
FightSystem.getMessage().sendPrefixless("NO_TEAM", p, ChatMessageType.ACTION_BAR);

Datei anzeigen

@ -47,10 +47,10 @@ public class GamemodeCommand extends BukkitCommand {
try {
CommandRemover.removeAll("gamemode");
CommandInjector.injectCommand(this);
} catch (Exception e) {
FightSystem.getPlugin().getLogger().log(Level.SEVERE, "Failed to replace commands", e);
}
Commands.injectCommand(this);
}
@Override

Datei anzeigen

@ -27,6 +27,7 @@ import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.record.GlobalRecorder;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Sound;
@ -39,7 +40,9 @@ import java.util.HashSet;
public class Fight {
private Fight(){}
@Getter
private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExtendRegion, Config.RedRotate, false, Config.RedLeader);
@Getter
private static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.BlueRotate, true, Config.BlueLeader);
private static final Collection<FightTeam> teams = new HashSet<>();
static {
@ -76,14 +79,6 @@ public class Fight {
return getPlayerTeam(player) != null;
}
public static FightTeam getRedTeam() {
return redTeam;
}
public static FightTeam getBlueTeam() {
return blueTeam;
}
public static Collection<FightTeam> teams() {
return teams;
}

Datei anzeigen

@ -26,6 +26,8 @@ import de.steamwar.fightsystem.countdown.EnternCountdown;
import de.steamwar.fightsystem.events.TeamDeathEvent;
import de.steamwar.sql.PersonalKit;
import de.steamwar.sql.SteamwarUser;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -36,9 +38,13 @@ public class FightPlayer {
private final int id;
private LivingEntity entity;
@Getter
private final FightTeam team;
private boolean isOut;
@Setter
@Getter
private Kit kit;
@Getter
private int kills;
private EnternCountdown enternCountdown = null;
@ -113,22 +119,6 @@ public class FightPlayer {
return leader != null && leader.getEntity() == entity;
}
public Kit getKit() {
return kit;
}
public void setKit(Kit kit) {
this.kit = kit;
}
public FightTeam getTeam(){
return team;
}
public int getKills(){
return kills;
}
public void addKill(){
kills++;
}

Datei anzeigen

@ -44,7 +44,6 @@ import de.steamwar.techhider.ProtocolUtils;
import lombok.Getter;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.*;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.NameTagVisibility;
@ -58,7 +57,7 @@ public class FightTeam {
private static void setKitButton(HotbarKit kit, boolean leader) {
if (Kit.getAvailableKits(leader).size() > 1 || Config.PersonalKits)
kit.setItem(1, "CHOOSE_KIT", new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), player -> GUI.kitSelection(player, ""));
kit.setItem(1, "CHOOSE_KIT", new ItemBuilder(Material.LEATHER_CHESTPLATE).enchant().build(), player -> GUI.kitSelection(player, ""));
else
kit.setItem(1, null, null, null);
}
@ -66,30 +65,30 @@ public class FightTeam {
private static final HotbarKit memberKit = new HotbarKit();
static {
setKitButton(memberKit, false);
memberKit.setItem(7, "RESPAWN", new ItemBuilder(Material.BEACON).removeAllAttributes().build(), player -> player.teleport(Objects.requireNonNull(Fight.getPlayerTeam(player)).getSpawn()));
memberKit.setItem(7, "RESPAWN", new ItemBuilder(Material.BEACON).build(), player -> player.teleport(Objects.requireNonNull(Fight.getPlayerTeam(player)).getSpawn()));
}
private static final HotbarKit notReadyKit = new HotbarKit(memberKit);
static {
setKitButton(notReadyKit, true);
if(!ArenaMode.RankedEvent.contains(Config.mode)){
notReadyKit.setItem(2, "REQUESTS", new ItemBuilder(Material.PAPER).removeAllAttributes().build(), GUI::chooseJoinRequests);
notReadyKit.setItem(3, "REMOVE_PLAYERS", new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).removeAllAttributes().build(), GUI::chooseRemove);
notReadyKit.setItem(2, "REQUESTS", new ItemBuilder(Material.PAPER).build(), GUI::chooseJoinRequests);
notReadyKit.setItem(3, "REMOVE_PLAYERS", new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).build(), GUI::chooseRemove);
}
if(Config.test())
notReadyKit.setItem(5, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), GUI::preSchemDialog);
notReadyKit.setItem(5, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).enchant().build(), GUI::preSchemDialog);
notReadyKit.setItem(4, "TEAM_NOT_READY", new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(true));
notReadyKit.setItem(4, "TEAM_NOT_READY", new ItemBuilder(SWItem.getDye(10), (short) 10).enchant().build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(true));
}
private static final HotbarKit chooseSchemKit = new HotbarKit(notReadyKit);
static {
chooseSchemKit.setItem(4, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), GUI::preSchemDialog);
chooseSchemKit.setItem(4, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).enchant().build(), GUI::preSchemDialog);
}
private static final HotbarKit readyKit = new HotbarKit(memberKit);
static {
readyKit.setItem(1, null, null, null);
readyKit.setItem(4, "TEAM_READY", new ItemBuilder(SWItem.getDye(8), (short) 8).removeAllAttributes().addEnchantment(Enchantment.DURABILITY,1 ).build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(false));
readyKit.setItem(4, "TEAM_READY", new ItemBuilder(SWItem.getDye(8), (short) 8).enchant().build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(false));
}
@Getter

Datei anzeigen

@ -26,6 +26,7 @@ import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
import de.steamwar.fightsystem.utils.FlatteningWrapper;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
@ -39,11 +40,8 @@ import java.util.Objects;
public class FightWorld extends StateDependent {
private static final boolean paper = Bukkit.getVersion().contains("git-Paper");
public static boolean isPaper(){
return paper;
}
@Getter
private static final boolean PAPER = Bukkit.getVersion().contains("git-Paper");
public FightWorld() {
super(ArenaMode.Restartable.contains(Config.mode) || Config.replayserver(), FightState.Schem);

Datei anzeigen

@ -51,7 +51,7 @@ public class HotbarKit extends Kit {
public static final HotbarKit SPECTATOR_KIT = new HotbarKit();
static {
for(int i = 0; i < 9; i++)
SPECTATOR_KIT.setItem(i, "JOIN_REQUEST", new ItemBuilder(Material.PAPER).removeAllAttributes().build(), GUI::joinRequest);
SPECTATOR_KIT.setItem(i, "JOIN_REQUEST", new ItemBuilder(Material.PAPER).build(), GUI::joinRequest);
}
private static final int HOTBAR_SIZE = 9;

Datei anzeigen

@ -30,6 +30,7 @@ import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import de.steamwar.sql.PersonalKit;
import de.steamwar.sql.SteamwarUser;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
@ -69,11 +70,19 @@ public class Kit {
}
}
@Getter
private final String name;
@Getter
private final ItemStack[] inventory;
@Getter
private final ItemStack[] armor;
@Getter
private final Collection<PotionEffect> effects;
/* In which stage is entern allowed? */
@Getter
private final int enterStage;
/* Is this kit allowed to set/handle tnt? */
@Getter
private final boolean tnt;
private final boolean leaderAllowed;
private final boolean memberAllowed;
@ -140,10 +149,6 @@ public class Kit {
return kits;
}
public String getName() {
return name;
}
public boolean canUseKit(boolean leader){
if (leader) {
return leaderAllowed;
@ -156,10 +161,6 @@ public class Kit {
return !memberAllowed;
}
public ItemStack[] getInventory() {
return inventory;
}
public boolean contains(ItemStack stack) {
for(ItemStack i : inventory) {
if(similar(i, stack))
@ -172,24 +173,6 @@ public class Kit {
return false;
}
public ItemStack[] getArmor() {
return armor;
}
public Collection<PotionEffect> getEffects() {
return effects;
}
/* Is this kit allowed to set/handle tnt? */
public boolean isTnt(){
return tnt;
}
/* In which stage is entern allowed? */
public int getEnterStage() {
return enterStage;
}
public void toPersonalKit(PersonalKit kit) {
kit.setContainer(inventory, armor);
}

Datei anzeigen

@ -1,32 +0,0 @@
/*
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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.BountifulWrapper;
public class ArrowPickup {
public ArrowPickup() {
new StateDependentListener(ArenaMode.All, FightState.All, BountifulWrapper.impl.newDenyArrowPickupListener());
}
}

Datei anzeigen

@ -22,19 +22,17 @@ package de.steamwar.fightsystem.record;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import lombok.Getter;
import java.io.*;
import java.util.zip.GZIPOutputStream;
public class FileRecorder extends StateDependent implements Recorder {
@Getter
private static final File file = new File(Config.world.getWorldFolder(), "recording.recording");
private DataOutputStream outputStream;
public static File getFile() {
return file;
}
public FileRecorder(){
super(Config.ReplayID == 0, FightState.Recording);
register();

Datei anzeigen

@ -19,6 +19,8 @@
package de.steamwar.fightsystem.states;
import lombok.Getter;
import java.util.*;
public enum FightState {
@ -48,12 +50,9 @@ public enum FightState {
public static final Set<FightState> AntiSpectate = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(SPECTATE)));
private static final Map<IStateDependent, Boolean> stateDependentFeatures = new HashMap<>();
@Getter
private static FightState fightState = PRE_LEADER_SETUP;
public static FightState getFightState() {
return fightState;
}
public static void registerStateDependent(IStateDependent stateDependent){
if(stateDependent.enabled().isEmpty())
return;

Datei anzeigen

@ -35,6 +35,7 @@ import de.steamwar.network.packets.common.FightEndsPacket;
import de.steamwar.sql.Replay;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import lombok.Getter;
import org.bukkit.Bukkit;
import java.sql.Timestamp;
@ -46,6 +47,7 @@ import static de.steamwar.sql.Fight.create;
public class FightStatistics {
@Getter
private static boolean unranked = false;
public static void unrank() {
@ -53,10 +55,6 @@ public class FightStatistics {
FightUI.addSubtitle("UI_UNRANKED");
}
public static boolean isUnranked() {
return unranked;
}
private Timestamp starttime = Timestamp.from(Instant.now());
public FightStatistics() {

Datei anzeigen

@ -31,6 +31,7 @@ import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.fightsystem.winconditions.Wincondition;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -43,10 +44,8 @@ import java.util.stream.Collectors;
public class FightUI {
@Getter
private static FightUI instance;
public static FightUI getInstance() {
return instance;
}
public FightUI() {
new StateDependentTask(ArenaMode.AntiReplay, FightState.All, this::update, 20, 20);

Datei anzeigen

@ -25,51 +25,26 @@ import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.List;
public class ItemBuilder {
private final ItemStack item;
private final ItemMeta meta;
public ItemBuilder(Material matrial) {
item = new ItemStack(matrial);
meta = item.getItemMeta();
}
public ItemBuilder(Material matrial, int amount) {
item = new ItemStack(matrial, amount);
public ItemBuilder(Material material) {
item = new ItemStack(material);
meta = item.getItemMeta();
meta.addItemFlags(ItemFlag.values());
}
@SuppressWarnings("deprecation")
public ItemBuilder(Material matrial, short subid) {
item = new ItemStack(matrial, 1, subid);
public ItemBuilder(Material material, short subid) {
item = new ItemStack(material, 1, subid);
meta = item.getItemMeta();
meta.addItemFlags(ItemFlag.values());
}
public ItemBuilder removeAllAttributes() {
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
meta.addItemFlags(ItemFlag.HIDE_DESTROYS);
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
meta.addItemFlags(ItemFlag.HIDE_PLACED_ON);
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
return this;
}
public ItemBuilder setDisplayName(String name) {
meta.setDisplayName(name);
return this;
}
public ItemBuilder addLore(List<String> lore) {
meta.setLore(lore);
return this;
}
public ItemBuilder addEnchantment(Enchantment enchantment, int level) {
meta.addEnchant(enchantment, level, true);
public ItemBuilder enchant() {
meta.addEnchant(Enchantment.DURABILITY, 1, true);
return this;
}
@ -77,5 +52,4 @@ public class ItemBuilder {
item.setItemMeta(meta);
return item;
}
}

Datei anzeigen

@ -19,7 +19,11 @@
package de.steamwar.fightsystem.utils;
import lombok.Getter;
@Getter
public class Message {
private final String msg;
private final Object[] params;
@ -27,12 +31,4 @@ public class Message {
this.msg = msg;
this.params = params;
}
public String getMsg() {
return msg;
}
public Object[] getParams() {
return params;
}
}

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import lombok.Getter;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -34,8 +35,10 @@ import java.util.stream.Collectors;
public abstract class Wincondition {
@Getter
protected static WinconditionPercent percentWincondition = null;
protected static StateDependentCountdown timeOverCountdown = null;
@Getter
protected static final List<PrintableWincondition> printableWinconditions = new ArrayList<>();
private final String windescription;
@ -61,14 +64,6 @@ public abstract class Wincondition {
return Fight.getPlayerTeam((LivingEntity) player);
}
public static List<PrintableWincondition> getPrintableWinconditions(){
return printableWinconditions;
}
public static WinconditionPercent getPercentWincondition() {
return percentWincondition;
}
protected void comparisonWin(ToDoubleFunction<FightTeam> evaluate, String winMessage, String tieMessage) {
double max = Fight.teams().stream().mapToDouble(evaluate).max().orElseThrow(() -> new SecurityException("No teams present"));
List<FightTeam> teams = Fight.teams().stream().filter(team -> evaluate.applyAsDouble(team) == max).collect(Collectors.toList());