forked from SteamWar/SteamWar
Migrate FightSystem modes and countdowns to GameCore
- Move shared arena-mode abstractions into GameCore - Adapt fight countdowns and APIs to the shared model - Add SteamWar issue audit workflow and SQL language settings
This commit is contained in:
@@ -29,6 +29,7 @@ java {
|
||||
dependencies {
|
||||
compileOnly(libs.classindex)
|
||||
annotationProcessor(libs.classindex)
|
||||
compileOnly(project(":GameCore", "default"))
|
||||
compileOnly(project(":SpigotCore", "default"))
|
||||
|
||||
compileOnly(libs.netty)
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 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;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
public enum ArenaMode {
|
||||
NORMAL,
|
||||
EVENT,
|
||||
TEST,
|
||||
CHECK,
|
||||
PREPARE,
|
||||
REPLAY;
|
||||
|
||||
public static final Set<ArenaMode> All = Collections.unmodifiableSet(EnumSet.allOf(ArenaMode.class));
|
||||
|
||||
public static final Set<ArenaMode> Normal = Collections.unmodifiableSet(EnumSet.of(NORMAL));
|
||||
public static final Set<ArenaMode> Check = Collections.unmodifiableSet(EnumSet.of(CHECK));
|
||||
public static final Set<ArenaMode> Event = Collections.unmodifiableSet(EnumSet.of(EVENT));
|
||||
public static final Set<ArenaMode> Test = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK));
|
||||
public static final Set<ArenaMode> Prepare = Collections.unmodifiableSet(EnumSet.of(PREPARE));
|
||||
public static final Set<ArenaMode> Replay = Collections.unmodifiableSet(EnumSet.of(REPLAY, TEST));
|
||||
|
||||
public static final Set<ArenaMode> AntiReplay = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(REPLAY)));
|
||||
public static final Set<ArenaMode> AntiTest = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK)));
|
||||
public static final Set<ArenaMode> AntiEvent = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT)));
|
||||
public static final Set<ArenaMode> AntiTestCheckPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE)));
|
||||
public static final Set<ArenaMode> AntiPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PREPARE)));
|
||||
public static final Set<ArenaMode> VariableTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT, REPLAY, CHECK)));
|
||||
public static final Set<ArenaMode> ManualTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT, REPLAY)));
|
||||
public static final Set<ArenaMode> RankedEvent = Collections.unmodifiableSet(EnumSet.of(EVENT, REPLAY));
|
||||
public static final Set<ArenaMode> Restartable = Collections.unmodifiableSet(EnumSet.of(NORMAL, TEST));
|
||||
public static final Set<ArenaMode> NotRestartable = Collections.unmodifiableSet(EnumSet.of(EVENT, REPLAY));
|
||||
public static final Set<ArenaMode> SoloLeader = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK, PREPARE));
|
||||
public static final Set<ArenaMode> NotOnBau = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE, REPLAY)));
|
||||
public static final Set<ArenaMode> SeriousFight = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, REPLAY)));
|
||||
}
|
||||
@@ -22,6 +22,8 @@ package de.steamwar.fightsystem;
|
||||
import de.steamwar.data.GameModeConfigUtils;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.gamecore.config.GameRuntimeProperties;
|
||||
import de.steamwar.sql.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@@ -44,6 +46,7 @@ public class Config {
|
||||
}
|
||||
|
||||
public static final World world = Bukkit.getWorlds().get(0);
|
||||
public static final GameRuntimeProperties RuntimeProperties = GameRuntimeProperties.load();
|
||||
|
||||
public static final GameModeConfig<Material, Winconditions> GameModeConfig;
|
||||
|
||||
@@ -99,11 +102,11 @@ public class Config {
|
||||
public static final int ReplayID;
|
||||
|
||||
static {
|
||||
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
|
||||
PrepareSchemID = Integer.parseInt(System.getProperty("prepareSchemID", "0"));
|
||||
ReplayID = Integer.parseInt(System.getProperty("replay", "0"));
|
||||
CheckSchemID = RuntimeProperties.getCheckSchematicId();
|
||||
PrepareSchemID = RuntimeProperties.getPrepareSchematicId();
|
||||
ReplayID = RuntimeProperties.getReplayId();
|
||||
|
||||
String configFile = System.getProperty("config", "config.yml");
|
||||
String configFile = RuntimeProperties.getConfigFile();
|
||||
if (!new File(FightSystem.getPlugin().getDataFolder(), configFile).exists()) {
|
||||
FightSystem.getPlugin().saveDefaultConfig();
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Arenaconfig fehlt!");
|
||||
@@ -209,7 +212,7 @@ public class Config {
|
||||
|
||||
BlueInsetRegion = new Region(BluePasteRegion.getMinX() + GameModeConfig.Schematic.Inset.x, BluePasteRegion.getMinY() + GameModeConfig.Schematic.Inset.bottom, BluePasteRegion.getMinZ() + GameModeConfig.Schematic.Inset.z, BluePasteRegion.getMaxX() - GameModeConfig.Schematic.Inset.x, BluePasteRegion.getMaxY() - GameModeConfig.Schematic.Inset.top, BluePasteRegion.getMaxZ() - GameModeConfig.Schematic.Inset.z);
|
||||
|
||||
int eventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
||||
int eventKampfID = RuntimeProperties.getFightId();
|
||||
if (eventKampfID >= 1) {
|
||||
EventKampf = EventFight.byId(eventKampfID);
|
||||
if (EventKampf == null) {
|
||||
@@ -264,32 +267,9 @@ public class Config {
|
||||
SpectatePort = -ReplayID;
|
||||
}
|
||||
|
||||
String blueLeader = System.getProperty("blueLeader", null);
|
||||
String redLeader = System.getProperty("redLeader", null);
|
||||
if (blueLeader != null) {
|
||||
BlueLeader = UUID.fromString(blueLeader);
|
||||
} else {
|
||||
BlueLeader = null;
|
||||
}
|
||||
if (redLeader != null) {
|
||||
RedLeader = UUID.fromString(redLeader);
|
||||
} else {
|
||||
RedLeader = null;
|
||||
}
|
||||
|
||||
if (CheckSchemID != 0) {
|
||||
mode = ArenaMode.CHECK;
|
||||
} else if (PrepareSchemID != 0) {
|
||||
mode = ArenaMode.PREPARE;
|
||||
} else if (eventKampfID >= 1) {
|
||||
mode = ArenaMode.EVENT;
|
||||
} else if (eventKampfID == -1) {
|
||||
mode = ArenaMode.TEST;
|
||||
} else if (ReplayID != 0) {
|
||||
mode = ArenaMode.REPLAY;
|
||||
} else {
|
||||
mode = ArenaMode.NORMAL;
|
||||
}
|
||||
BlueLeader = RuntimeProperties.getBlueLeader();
|
||||
RedLeader = RuntimeProperties.getRedLeader();
|
||||
mode = ArenaMode.from(RuntimeProperties);
|
||||
}
|
||||
|
||||
public static boolean test() {
|
||||
@@ -297,7 +277,7 @@ public class Config {
|
||||
}
|
||||
|
||||
public static boolean replayserver() {
|
||||
return ReplayID < 0;
|
||||
return RuntimeProperties.isReplayServer();
|
||||
}
|
||||
|
||||
public static boolean blueNegZ() {
|
||||
|
||||
@@ -36,6 +36,7 @@ import de.steamwar.fightsystem.utils.FightUI;
|
||||
import de.steamwar.fightsystem.utils.HullHider;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import de.steamwar.fightsystem.utils.TechHiderWrapper;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.linkage.AbstractLinker;
|
||||
import de.steamwar.linkage.SpigotLinker;
|
||||
import de.steamwar.message.Message;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
package de.steamwar.fightsystem.ai;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.ai;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Kit;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.ai.AIManager;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.record.PacketProcessor;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightWorld;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 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.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
import de.steamwar.fightsystem.utils.FightUI;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Countdown {
|
||||
|
||||
private static final List<Countdown> currentCountdowns = new ArrayList<>();
|
||||
|
||||
protected final Message appendix;
|
||||
|
||||
private final int totalTime;
|
||||
protected final Sound sound;
|
||||
private final boolean level;
|
||||
|
||||
protected int time;
|
||||
private BukkitTask task = null;
|
||||
|
||||
public abstract void countdownFinished();
|
||||
|
||||
protected Countdown(int time, Message appendix, SWSound sound, boolean level) {
|
||||
this.totalTime = time;
|
||||
this.time = time;
|
||||
this.appendix = appendix;
|
||||
this.sound = sound != null ? sound.getSound() : null;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public void enable() {
|
||||
time = totalTime;
|
||||
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::count, 20, 20);
|
||||
currentCountdowns.add(this);
|
||||
show();
|
||||
}
|
||||
|
||||
public void disable() {
|
||||
if (task != null) {
|
||||
task.cancel();
|
||||
currentCountdowns.remove(this);
|
||||
task = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void skip() {
|
||||
if (currentCountdowns.isEmpty()) return;
|
||||
|
||||
int smallestTime = currentCountdowns.get(0).time;
|
||||
for (Countdown countdown : currentCountdowns) {
|
||||
if (countdown.time < smallestTime) smallestTime = countdown.time;
|
||||
}
|
||||
|
||||
for (Countdown countdown : new ArrayList<>(currentCountdowns)) {
|
||||
countdown.time -= smallestTime;
|
||||
countdown.show();
|
||||
}
|
||||
|
||||
FightUI.addSubtitle("UI_SKIP");
|
||||
}
|
||||
|
||||
public static void sendCountdownMessage(Player p, String message, int displaytime, Message appendix) {
|
||||
FightSystem.getMessage().sendPrefixless(message, p, ChatMessageType.ACTION_BAR, displaytime, FightSystem.getMessage().parse(appendix.getMsg(), p, appendix.getParams()));
|
||||
}
|
||||
|
||||
protected void broadcast(String message, int divisor) {
|
||||
if (this.sound != null && divisor == 1) {
|
||||
Fight.playSound(this.sound, 100.0F, 1.0F);
|
||||
}
|
||||
|
||||
GlobalRecorder.getInstance().countdown(message, time / divisor, appendix);
|
||||
Bukkit.getOnlinePlayers().forEach(p -> sendCountdownMessage(p, message, time / divisor, appendix));
|
||||
}
|
||||
|
||||
public int getTimeLeft() {
|
||||
return time;
|
||||
}
|
||||
|
||||
private void count() {
|
||||
time--;
|
||||
show();
|
||||
}
|
||||
|
||||
private void show() {
|
||||
switch (time) {
|
||||
case 900:
|
||||
case 600:
|
||||
case 300:
|
||||
case 180:
|
||||
case 120:
|
||||
broadcast("COUNTDOWN_MINUTES", 60);
|
||||
break;
|
||||
case 60:
|
||||
case 30:
|
||||
case 20:
|
||||
case 15:
|
||||
case 10:
|
||||
case 5:
|
||||
case 4:
|
||||
case 3:
|
||||
case 2:
|
||||
broadcast("COUNTDOWN_SECONDS", 1);
|
||||
break;
|
||||
case 1:
|
||||
broadcast("COUNTDOWN_SECOND", 1);
|
||||
break;
|
||||
case 0:
|
||||
if (this.sound != null) {
|
||||
Fight.playSound(this.sound, 100.0F, 2.0F);
|
||||
}
|
||||
|
||||
disable();
|
||||
countdownFinished();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
if (this.level) {
|
||||
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.setLevel(time));
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
-10
@@ -27,10 +27,12 @@ import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import de.steamwar.gamecore.countdown.Countdown;
|
||||
import de.steamwar.gamecore.countdown.StandardCountdown;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class EnternCountdown extends Countdown {
|
||||
public class EnternCountdown extends StandardCountdown {
|
||||
|
||||
private static int calcTime(FightPlayer fp, Countdown countdown) {
|
||||
int time = Config.GameModeConfig.EnterStages.get(fp.getKit().getEnterStage());
|
||||
@@ -46,13 +48,17 @@ public class EnternCountdown extends Countdown {
|
||||
private final FightPlayer fightPlayer;
|
||||
|
||||
public EnternCountdown(FightPlayer fp, Countdown countdown) {
|
||||
super(calcTime(fp, countdown), new Message("ENTERN_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
|
||||
super(
|
||||
FightSystem.getPlugin(),
|
||||
calcTime(fp, countdown),
|
||||
FightCountdownAdapter.playerPresentation(fp, new Message("ENTERN_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING)
|
||||
);
|
||||
fightPlayer = fp;
|
||||
enable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
protected void countdownFinished() {
|
||||
Bukkit.getPluginManager().callEvent(new BoardingEvent(fightPlayer));
|
||||
FightSystem.getMessage().sendPrefixless("ENTERN_ALLOWED", fightPlayer.getEntity(), ChatMessageType.ACTION_BAR);
|
||||
fightPlayer.ifPlayer(player -> {
|
||||
@@ -61,11 +67,4 @@ public class EnternCountdown extends Countdown {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void broadcast(String message, int divisor) {
|
||||
fightPlayer.ifPlayer(player -> {
|
||||
player.playSound(player.getLocation(), sound, 100.0f, 1.0f);
|
||||
sendCountdownMessage(player, message, time / divisor, appendix);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+7
-6
@@ -19,25 +19,26 @@
|
||||
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.gamecore.countdown.StandardCountdown;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.gamecore.state.StateDependentCountdown;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import de.steamwar.linkage.Linked;
|
||||
|
||||
@Linked
|
||||
public class EventSpectateCountdown extends Countdown {
|
||||
public class EventSpectateCountdown extends StandardCountdown {
|
||||
|
||||
public EventSpectateCountdown() {
|
||||
super(Config.GameModeConfig.Times.SpectatorDuration, new Message("SHUTDOWN_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
|
||||
new StateDependentCountdown(ArenaMode.NotRestartable.contains(Config.mode) && !Config.replayserver(), FightState.Spectate, this);
|
||||
super(FightSystem.getPlugin(), Config.GameModeConfig.Times.SpectatorDuration, FightCountdownAdapter.presentation(new Message("SHUTDOWN_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false));
|
||||
new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.NotRestartable.contains(Config.mode) && !Config.replayserver(), FightState.Spectate, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
protected void countdownFinished() {
|
||||
FightSystem.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 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.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import de.steamwar.gamecore.countdown.CountdownMessageSink;
|
||||
import de.steamwar.gamecore.countdown.CountdownPresentation;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Binds FightSystem's transports to GameCore's presentation engine.
|
||||
*/
|
||||
public final class FightCountdownAdapter {
|
||||
private FightCountdownAdapter() {
|
||||
}
|
||||
|
||||
public static CountdownPresentation presentation(Message appendix, SWSound sound, boolean level) {
|
||||
return presentation(
|
||||
appendix,
|
||||
sound,
|
||||
level,
|
||||
(message, displayTime) -> {
|
||||
GlobalRecorder.getInstance().countdown(message.getKey(), displayTime, appendix);
|
||||
Bukkit.getOnlinePlayers().forEach(player ->
|
||||
sendCountdownMessage(player, message.getKey(), displayTime, appendix)
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public static CountdownPresentation presentation(
|
||||
Message appendix,
|
||||
SWSound sound,
|
||||
boolean level,
|
||||
CountdownMessageSink messageSink
|
||||
) {
|
||||
return new CountdownPresentation(
|
||||
messageSink,
|
||||
sound != null
|
||||
? pitch -> Fight.playSound(sound.getSound(), 100.0F, pitch)
|
||||
: null,
|
||||
level
|
||||
? timeLeft -> Bukkit.getOnlinePlayers().forEach(player -> player.setLevel(timeLeft))
|
||||
: null
|
||||
);
|
||||
}
|
||||
|
||||
public static CountdownPresentation playerPresentation(
|
||||
FightPlayer fightPlayer,
|
||||
Message appendix,
|
||||
SWSound sound
|
||||
) {
|
||||
return new CountdownPresentation(
|
||||
(message, displayTime) -> fightPlayer.ifPlayer(player ->
|
||||
sendCountdownMessage(player, message.getKey(), displayTime, appendix)
|
||||
),
|
||||
pitch -> fightPlayer.ifPlayer(player ->
|
||||
player.playSound(player.getLocation(), sound.getSound(), 100.0F, pitch)
|
||||
),
|
||||
pitch -> Fight.playSound(sound.getSound(), 100.0F, pitch),
|
||||
null,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
public static void sendCountdownMessage(Player player, String message, int displayTime, Message appendix) {
|
||||
FightSystem.getMessage().sendPrefixless(
|
||||
message,
|
||||
player,
|
||||
ChatMessageType.ACTION_BAR,
|
||||
displayTime,
|
||||
FightSystem.getMessage().parse(appendix.getMsg(), player, appendix.getParams())
|
||||
);
|
||||
}
|
||||
}
|
||||
+8
-6
@@ -19,27 +19,29 @@
|
||||
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.gamecore.state.StateDependentCountdown;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.gamecore.countdown.StandardCountdown;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@Linked
|
||||
public class NoPlayersOnlineCountdown extends Countdown {
|
||||
public class NoPlayersOnlineCountdown extends StandardCountdown {
|
||||
|
||||
public NoPlayersOnlineCountdown() {
|
||||
super(Config.GameModeConfig.Times.NoPlayersOnlineDuration, new Message("SHUTDOWN_COUNTDOWN"), null, false);
|
||||
super(FightSystem.getPlugin(), Config.GameModeConfig.Times.NoPlayersOnlineDuration, FightCountdownAdapter.presentation(new Message("SHUTDOWN_COUNTDOWN"), null, false));
|
||||
|
||||
if (!Config.GameModeConfig.Arena.Leaveable) {
|
||||
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this);
|
||||
new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.AntiReplay.contains(Config.mode), FightState.PreLeaderSetup, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
protected void countdownFinished() {
|
||||
Bukkit.getServer().shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
+8
-6
@@ -19,27 +19,29 @@
|
||||
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.gamecore.state.StateDependentCountdown;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.gamecore.countdown.StandardCountdown;
|
||||
import de.steamwar.linkage.Linked;
|
||||
|
||||
@Linked
|
||||
public class PostSchemCountdown extends Countdown {
|
||||
public class PostSchemCountdown extends StandardCountdown {
|
||||
|
||||
public PostSchemCountdown() {
|
||||
super(Config.GameModeConfig.Times.SetupDuration, new Message("POST_SCHEM_COUNTDOWN"), null, false);
|
||||
super(FightSystem.getPlugin(), Config.GameModeConfig.Times.SetupDuration, FightCountdownAdapter.presentation(new Message("POST_SCHEM_COUNTDOWN"), null, false));
|
||||
if (Config.mode == ArenaMode.PREPARE && Config.GameModeConfig.Schematic.UnlimitedPrepare) {
|
||||
return;
|
||||
}
|
||||
|
||||
new StateDependentCountdown(ArenaMode.SeriousFight, FightState.PostSchemSetup, this);
|
||||
new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.SeriousFight.contains(Config.mode), FightState.PostSchemSetup, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
protected void countdownFinished() {
|
||||
FightState.setFightState(FightState.PRE_RUNNING);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-6
@@ -19,24 +19,26 @@
|
||||
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.gamecore.state.StateDependentCountdown;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import de.steamwar.gamecore.countdown.StandardCountdown;
|
||||
import de.steamwar.linkage.Linked;
|
||||
|
||||
@Linked
|
||||
public class PreRunningCountdown extends Countdown {
|
||||
public class PreRunningCountdown extends StandardCountdown {
|
||||
|
||||
public PreRunningCountdown() {
|
||||
super(Config.GameModeConfig.Times.PreFightDuration, new Message("PRE_RUNNING_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, true);
|
||||
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreRunning, this);
|
||||
super(FightSystem.getPlugin(), Config.GameModeConfig.Times.PreFightDuration, FightCountdownAdapter.presentation(new Message("PRE_RUNNING_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, true));
|
||||
new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.AntiReplay.contains(Config.mode), FightState.PreRunning, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
protected void countdownFinished() {
|
||||
FightState.setFightState(FightState.RUNNING);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-6
@@ -19,24 +19,26 @@
|
||||
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.gamecore.state.StateDependentCountdown;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import de.steamwar.gamecore.countdown.StandardCountdown;
|
||||
import de.steamwar.linkage.Linked;
|
||||
|
||||
@Linked
|
||||
public class PreSchemCountdown extends Countdown {
|
||||
public class PreSchemCountdown extends StandardCountdown {
|
||||
|
||||
public PreSchemCountdown() {
|
||||
super(Config.GameModeConfig.Times.PreSchemPasteDuration, new Message("PRE_SCHEM_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
|
||||
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreSchemSetup, this);
|
||||
super(FightSystem.getPlugin(), Config.GameModeConfig.Times.PreSchemPasteDuration, FightCountdownAdapter.presentation(new Message("PRE_SCHEM_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false));
|
||||
new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.AntiReplay.contains(Config.mode), FightState.PreSchemSetup, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
protected void countdownFinished() {
|
||||
FightState.setFightState(FightState.POST_SCHEM_SETUP);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-6
@@ -19,24 +19,26 @@
|
||||
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.gamecore.state.StateDependentCountdown;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import de.steamwar.gamecore.countdown.StandardCountdown;
|
||||
import de.steamwar.linkage.Linked;
|
||||
|
||||
@Linked
|
||||
public class SpectateOverCountdown extends Countdown {
|
||||
public class SpectateOverCountdown extends StandardCountdown {
|
||||
|
||||
public SpectateOverCountdown() {
|
||||
super(Config.test() ? 3600 : Config.GameModeConfig.Times.SpectatorDuration, new Message("SPECTATE_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
|
||||
new StateDependentCountdown(ArenaMode.Restartable.contains(Config.mode) || Config.replayserver(), FightState.Spectate, this);
|
||||
super(FightSystem.getPlugin(), Config.test() ? 3600 : Config.GameModeConfig.Times.SpectatorDuration, FightCountdownAdapter.presentation(new Message("SPECTATE_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false));
|
||||
new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.Restartable.contains(Config.mode) || Config.replayserver(), FightState.Spectate, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
protected void countdownFinished() {
|
||||
FightState.setFightState(FightState.PRE_LEADER_SETUP);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-3
@@ -20,20 +20,22 @@
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import de.steamwar.gamecore.countdown.StandardCountdown;
|
||||
|
||||
public class TimeOverCountdown extends Countdown {
|
||||
public class TimeOverCountdown extends StandardCountdown {
|
||||
|
||||
private final Runnable timeOver;
|
||||
|
||||
public TimeOverCountdown(Runnable timeOver) {
|
||||
super(Config.GameModeConfig.WinConditionParams.TimeoutTime, new Message("RUNNING_COUNTDOWN"), SWSound.BLOCK_NOTE_BASS, false);
|
||||
super(FightSystem.getPlugin(), Config.GameModeConfig.WinConditionParams.TimeoutTime, FightCountdownAdapter.presentation(new Message("RUNNING_COUNTDOWN"), SWSound.BLOCK_NOTE_BASS, false));
|
||||
this.timeOver = timeOver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
protected void countdownFinished() {
|
||||
timeOver.run();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,13 +21,14 @@ 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.FightCountdownAdapter;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||
import de.steamwar.gamecore.countdown.StandardCountdown;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -139,14 +140,14 @@ public class HellsBells {
|
||||
}.register();
|
||||
}
|
||||
|
||||
private class HellsBellsCountdown extends Countdown {
|
||||
private class HellsBellsCountdown extends StandardCountdown {
|
||||
|
||||
public HellsBellsCountdown(int time) {
|
||||
super(time, new Message("HELLS_BELLS_COUNTDOWN"), SWSound.BLOCK_NOTE_BASS, true);
|
||||
super(FightSystem.getPlugin(), time, FightCountdownAdapter.presentation(new Message("HELLS_BELLS_COUNTDOWN"), SWSound.BLOCK_NOTE_BASS, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
protected void countdownFinished() {
|
||||
drop();
|
||||
startCountdown();
|
||||
}
|
||||
@@ -240,4 +241,4 @@ public class HellsBells {
|
||||
return this == NORTH || this == WEST;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ 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.FightCountdownAdapter;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
@@ -29,6 +29,7 @@ import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||
import de.steamwar.gamecore.countdown.StandardCountdown;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Fireball;
|
||||
@@ -154,14 +155,14 @@ public class Meteor implements Listener {
|
||||
}.register();
|
||||
}
|
||||
|
||||
private class MeteorCountdown extends Countdown {
|
||||
private class MeteorCountdown extends StandardCountdown {
|
||||
|
||||
public MeteorCountdown(int time) {
|
||||
super(time, new Message("METEOR_COUNTDOWN"), SWSound.BLOCK_NOTE_BASS, true);
|
||||
super(FightSystem.getPlugin(), time, FightCountdownAdapter.presentation(new Message("METEOR_COUNTDOWN"), SWSound.BLOCK_NOTE_BASS, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
protected void countdownFinished() {
|
||||
drop();
|
||||
startCountdown();
|
||||
}
|
||||
@@ -212,4 +213,4 @@ public class Meteor implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
package de.steamwar.fightsystem.event;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
|
||||
@@ -19,9 +19,10 @@
|
||||
|
||||
package de.steamwar.fightsystem.fight;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
import de.steamwar.gamecore.team.TeamRegistry;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Registry;
|
||||
@@ -29,7 +30,7 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class Fight {
|
||||
private Fight() {
|
||||
@@ -39,31 +40,14 @@ public class Fight {
|
||||
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 {
|
||||
teams.add(redTeam);
|
||||
teams.add(blueTeam);
|
||||
}
|
||||
private static final TeamRegistry<FightTeam, LivingEntity> teamRegistry = new TeamRegistry<>(List.of(redTeam, blueTeam));
|
||||
|
||||
public static FightTeam getPlayerTeam(LivingEntity player) {
|
||||
if (redTeam.isPlayerInTeam(player)) {
|
||||
return redTeam;
|
||||
}
|
||||
if (blueTeam.isPlayerInTeam(player)) {
|
||||
return blueTeam;
|
||||
}
|
||||
return null;
|
||||
return teamRegistry.findTeam(player);
|
||||
}
|
||||
|
||||
public static FightTeam getOpposite(FightTeam fightTeam) {
|
||||
if (fightTeam == redTeam) {
|
||||
return blueTeam;
|
||||
} else if (fightTeam == blueTeam) {
|
||||
return redTeam;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException();
|
||||
return teamRegistry.opposite(fightTeam);
|
||||
}
|
||||
|
||||
public static FightPlayer getFightPlayer(LivingEntity player) {
|
||||
@@ -81,7 +65,11 @@ public class Fight {
|
||||
}
|
||||
|
||||
public static Collection<FightTeam> teams() {
|
||||
return teams;
|
||||
return teamRegistry.getTeams();
|
||||
}
|
||||
|
||||
public static boolean allTeamsReady() {
|
||||
return teamRegistry.allReady();
|
||||
}
|
||||
|
||||
public static FightTeam getUnrotated() {
|
||||
@@ -95,13 +83,7 @@ public class Fight {
|
||||
}
|
||||
|
||||
public static FightTeam getTeamByName(String name) {
|
||||
if (redTeam.getName().equalsIgnoreCase(name)) {
|
||||
return redTeam;
|
||||
}
|
||||
if (blueTeam.getName().equalsIgnoreCase(name)) {
|
||||
return blueTeam;
|
||||
}
|
||||
return null;
|
||||
return teamRegistry.findById(name);
|
||||
}
|
||||
|
||||
public static boolean publicOnly() {
|
||||
|
||||
@@ -21,7 +21,7 @@ package de.steamwar.fightsystem.fight;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.ai.AI;
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
import de.steamwar.gamecore.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.countdown.EnternCountdown;
|
||||
import de.steamwar.fightsystem.events.TeamDeathEvent;
|
||||
import de.steamwar.sql.PersonalKit;
|
||||
|
||||
@@ -22,7 +22,7 @@ package de.steamwar.fightsystem.fight;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
package de.steamwar.fightsystem.fight;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.ai.AIManager;
|
||||
import de.steamwar.fightsystem.commands.GUI;
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
import de.steamwar.gamecore.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.events.TeamLeaveEvent;
|
||||
import de.steamwar.fightsystem.events.TeamSpawnEvent;
|
||||
import de.steamwar.fightsystem.listener.FightScoreboard;
|
||||
@@ -57,7 +57,7 @@ import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
||||
public class FightTeam {
|
||||
public class FightTeam implements de.steamwar.gamecore.team.GameTeam<LivingEntity> {
|
||||
|
||||
private static void setKitButton(HotbarKit kit, boolean leader) {
|
||||
if (Kit.getAvailableKits(leader).size() > 1 || Config.GameModeConfig.Kits.PersonalKits) {
|
||||
@@ -404,6 +404,31 @@ public class FightTeam {
|
||||
return players.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String teamId() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<LivingEntity> members() {
|
||||
return players.values().stream().map(FightPlayer::getEntity).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LivingEntity leader() {
|
||||
return leader == null ? null : leader.getEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ready() {
|
||||
return ready;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(LivingEntity member) {
|
||||
return isPlayerInTeam(member);
|
||||
}
|
||||
|
||||
public void pasteSchem() {
|
||||
testPasteAction();
|
||||
}
|
||||
@@ -455,7 +480,7 @@ public class FightTeam {
|
||||
if (ready) {
|
||||
broadcast("TEAM_READY");
|
||||
leader.ifPlayer(readyKit::loadToPlayer);
|
||||
if (Fight.getOpposite(this).isReady() || ArenaMode.SoloLeader.contains(Config.mode)) {
|
||||
if (Fight.allTeamsReady() || ArenaMode.SoloLeader.contains(Config.mode)) {
|
||||
FightState.setFightState(FightState.PRE_RUNNING);
|
||||
}
|
||||
} else {
|
||||
@@ -471,7 +496,9 @@ public class FightTeam {
|
||||
if (Fight.getOpposite(this).skip || Config.test()) {
|
||||
skip = false;
|
||||
Fight.getOpposite(this).skip = false;
|
||||
Countdown.skip();
|
||||
if (Countdown.skipActive()) {
|
||||
FightUI.addSubtitle("UI_SKIP");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
broadcast("SKIP_NOT_READY");
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.fight;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.listener.Recording;
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.fight;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.events.TeamDeathEvent;
|
||||
import de.steamwar.fightsystem.events.TeamLeaveEvent;
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.linkage.Linked;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.scoreboard.SWScoreboard;
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
|
||||
+1
-1
@@ -19,10 +19,10 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.PistonMoveReaction;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.events.TeamDeathEvent;
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
|
||||
@@ -22,7 +22,7 @@ package de.steamwar.fightsystem.listener;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import de.steamwar.core.ProtocolWrapper;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.events.BoardingEvent;
|
||||
import de.steamwar.fightsystem.events.TeamDeathEvent;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
|
||||
+3
-3
@@ -24,10 +24,10 @@ import de.steamwar.core.WorldEditWrapper;
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.entity.RPlayer;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.countdown.FightCountdownAdapter;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.fight.FightWorld;
|
||||
@@ -393,7 +393,7 @@ public class PacketProcessor implements Listener {
|
||||
int displaytime = source.readInt();
|
||||
Message appendix = readMessage();
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(p -> Countdown.sendCountdownMessage(p, message, displaytime, appendix));
|
||||
Bukkit.getOnlinePlayers().forEach(p -> FightCountdownAdapter.sendCountdownMessage(p, message, displaytime, appendix));
|
||||
}
|
||||
|
||||
private void oldArenaInfo() throws IOException {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.record;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
|
||||
@@ -1,27 +1,12 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 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.states;
|
||||
|
||||
import lombok.Getter;
|
||||
import de.steamwar.gamecore.state.GameStateMachine;
|
||||
import de.steamwar.gamecore.state.IStateDependent;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public enum FightState {
|
||||
PRE_LEADER_SETUP,
|
||||
@@ -31,63 +16,58 @@ public enum FightState {
|
||||
RUNNING,
|
||||
SPECTATE;
|
||||
|
||||
public static final Set<FightState> All = Collections.unmodifiableSet(EnumSet.allOf(FightState.class));
|
||||
public static final Set<FightState> All = immutable(EnumSet.allOf(FightState.class));
|
||||
public static final Set<FightState> PreLeaderSetup = immutable(EnumSet.of(PRE_LEADER_SETUP));
|
||||
public static final Set<FightState> PreSchemSetup = immutable(EnumSet.of(PRE_SCHEM_SETUP));
|
||||
public static final Set<FightState> PostSchemSetup = immutable(EnumSet.of(POST_SCHEM_SETUP));
|
||||
public static final Set<FightState> PreRunning = immutable(EnumSet.of(PRE_RUNNING));
|
||||
public static final Set<FightState> Running = immutable(EnumSet.of(RUNNING));
|
||||
public static final Set<FightState> Spectate = immutable(EnumSet.of(SPECTATE));
|
||||
public static final Set<FightState> Setup = immutable(EnumSet.of(PRE_LEADER_SETUP, PRE_SCHEM_SETUP, POST_SCHEM_SETUP));
|
||||
public static final Set<FightState> Ingame = immutable(EnumSet.of(PRE_RUNNING, RUNNING));
|
||||
public static final Set<FightState> TeamFix = immutable(EnumSet.of(PRE_RUNNING, RUNNING, SPECTATE));
|
||||
public static final Set<FightState> Schem = complement(PRE_LEADER_SETUP, PRE_SCHEM_SETUP);
|
||||
public static final Set<FightState> Recording = complement(PRE_LEADER_SETUP, PRE_SCHEM_SETUP, SPECTATE);
|
||||
public static final Set<FightState> AntiRunning = complement(RUNNING);
|
||||
public static final Set<FightState> AntiIngame = complement(PRE_RUNNING, RUNNING);
|
||||
public static final Set<FightState> AntiSpectate = complement(SPECTATE);
|
||||
|
||||
public static final Set<FightState> PreLeaderSetup = Collections.unmodifiableSet(EnumSet.of(PRE_LEADER_SETUP));
|
||||
public static final Set<FightState> PreSchemSetup = Collections.unmodifiableSet(EnumSet.of(PRE_SCHEM_SETUP));
|
||||
public static final Set<FightState> PostSchemSetup = Collections.unmodifiableSet(EnumSet.of(POST_SCHEM_SETUP));
|
||||
public static final Set<FightState> PreRunning = Collections.unmodifiableSet(EnumSet.of(PRE_RUNNING));
|
||||
public static final Set<FightState> Running = Collections.unmodifiableSet(EnumSet.of(RUNNING));
|
||||
public static final Set<FightState> Spectate = Collections.unmodifiableSet(EnumSet.of(SPECTATE));
|
||||
public static final GameStateMachine<FightState> lifecycle = new GameStateMachine<>(PRE_LEADER_SETUP);
|
||||
|
||||
public static final Set<FightState> Setup = Collections.unmodifiableSet(EnumSet.of(PRE_LEADER_SETUP, PRE_SCHEM_SETUP, POST_SCHEM_SETUP));
|
||||
public static final Set<FightState> Ingame = Collections.unmodifiableSet(EnumSet.of(PRE_RUNNING, RUNNING));
|
||||
public static final Set<FightState> TeamFix = Collections.unmodifiableSet(EnumSet.of(PRE_RUNNING, RUNNING, SPECTATE));
|
||||
public static final Set<FightState> Schem = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PRE_LEADER_SETUP, PRE_SCHEM_SETUP)));
|
||||
public static final Set<FightState> Recording = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PRE_LEADER_SETUP, PRE_SCHEM_SETUP, SPECTATE)));
|
||||
public static final Set<FightState> AntiRunning = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(RUNNING)));
|
||||
public static final Set<FightState> AntiIngame = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PRE_RUNNING, RUNNING)));
|
||||
public static final Set<FightState> AntiSpectate = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(SPECTATE)));
|
||||
|
||||
@Getter
|
||||
private static final Map<IStateDependent, Boolean> stateDependentFeatures = new HashMap<>();
|
||||
@Getter
|
||||
private static FightState fightState = PRE_LEADER_SETUP;
|
||||
|
||||
public static void registerStateDependent(IStateDependent stateDependent) {
|
||||
if (stateDependent.enabled().isEmpty()) return;
|
||||
boolean enabled = stateDependent.enabled().contains(fightState);
|
||||
stateDependentFeatures.put(stateDependent, enabled);
|
||||
if (enabled) stateDependent.enable();
|
||||
public static void registerStateDependent(IStateDependent<FightState> stateDependent) {
|
||||
lifecycle.registerStateDependent(stateDependent);
|
||||
}
|
||||
|
||||
public static void setFightState(FightState state) {
|
||||
fightState = state;
|
||||
lifecycle.transitionTo(state);
|
||||
}
|
||||
|
||||
for (Map.Entry<IStateDependent, Boolean> feature : stateDependentFeatures.entrySet()) {
|
||||
//Enable feature if should be enabled and currently disabled
|
||||
if (feature.getKey().enabled().contains(fightState) && !feature.getValue()) {
|
||||
feature.getKey().enable();
|
||||
feature.setValue(true);
|
||||
}
|
||||
public static FightState getFightState() {
|
||||
return lifecycle.getCurrentState();
|
||||
}
|
||||
|
||||
//Disable feature if should be disabled and currently enabled
|
||||
if (!feature.getKey().enabled().contains(fightState) && feature.getValue()) {
|
||||
feature.getKey().disable();
|
||||
feature.setValue(false);
|
||||
}
|
||||
}
|
||||
public static Map<IStateDependent<FightState>, Boolean> getStateDependentFeatures() {
|
||||
return lifecycle.getStateDependentFeatures();
|
||||
}
|
||||
|
||||
public static boolean setup() {
|
||||
return Setup.contains(fightState);
|
||||
return Setup.contains(getFightState());
|
||||
}
|
||||
|
||||
public static boolean ingame() {
|
||||
return Ingame.contains(fightState);
|
||||
return Ingame.contains(getFightState());
|
||||
}
|
||||
|
||||
public static boolean infight() {
|
||||
return fightState == RUNNING;
|
||||
return getFightState() == RUNNING;
|
||||
}
|
||||
|
||||
private static Set<FightState> complement(FightState first, FightState... remaining) {
|
||||
EnumSet<FightState> excluded = EnumSet.of(first, remaining);
|
||||
return immutable(EnumSet.complementOf(excluded));
|
||||
}
|
||||
|
||||
private static Set<FightState> immutable(EnumSet<FightState> states) {
|
||||
return Collections.unmodifiableSet(states);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-37
@@ -1,40 +1,5 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 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.states;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface IStateDependent {
|
||||
|
||||
/**
|
||||
* @return returns a set containing
|
||||
*/
|
||||
Set<FightState> enabled();
|
||||
|
||||
/**
|
||||
* Enables the state dependent object
|
||||
*/
|
||||
void enable();
|
||||
|
||||
/**
|
||||
* Disables the state dependent object
|
||||
*/
|
||||
void disable();
|
||||
@Deprecated
|
||||
public interface IStateDependent extends de.steamwar.gamecore.state.IStateDependent<FightState> {
|
||||
}
|
||||
|
||||
+6
-44
@@ -1,59 +1,21 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 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.states;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class OneShotStateDependent extends StateDependent {
|
||||
|
||||
private final Runnable runnable;
|
||||
|
||||
public OneShotStateDependent(Set<ArenaMode> mode, Set<FightState> states, Runnable runnable) {
|
||||
super(mode, states);
|
||||
this.runnable = runnable;
|
||||
register();
|
||||
@Deprecated
|
||||
public class OneShotStateDependent extends de.steamwar.gamecore.state.OneShotStateDependent<FightState> implements IStateDependent {
|
||||
public OneShotStateDependent(Set<de.steamwar.gamecore.ArenaMode> modes, Set<FightState> states, Runnable runnable) {
|
||||
super(FightState.lifecycle, modes, Config.mode, states, runnable);
|
||||
}
|
||||
|
||||
public OneShotStateDependent(Winconditions wincondition, Set<FightState> states, Runnable runnable) {
|
||||
super(Config.GameModeConfig.WinConditions.contains(wincondition), states);
|
||||
this.runnable = runnable;
|
||||
register();
|
||||
this(Config.GameModeConfig.WinConditions.contains(wincondition), states, runnable);
|
||||
}
|
||||
|
||||
public OneShotStateDependent(boolean active, Set<FightState> states, Runnable runnable) {
|
||||
super(active, states);
|
||||
this.runnable = runnable;
|
||||
register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
runnable.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
//Do nothing, oneshot
|
||||
super(FightState.lifecycle, active, states, runnable);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-38
@@ -1,54 +1,21 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 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.states;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class StateDependent implements IStateDependent {
|
||||
|
||||
private final Set<FightState> enabled;
|
||||
private final boolean register;
|
||||
|
||||
@Deprecated
|
||||
public abstract class StateDependent extends de.steamwar.gamecore.state.StateDependent<FightState> implements IStateDependent {
|
||||
protected StateDependent(Winconditions wincondition, Set<FightState> states) {
|
||||
this(Config.GameModeConfig.WinConditions.contains(wincondition), states);
|
||||
}
|
||||
|
||||
protected StateDependent(Set<ArenaMode> mode, Set<FightState> states) {
|
||||
this(mode.contains(Config.mode), states);
|
||||
protected StateDependent(Set<de.steamwar.gamecore.ArenaMode> modes, Set<FightState> states) {
|
||||
super(FightState.lifecycle, modes, Config.mode, states);
|
||||
}
|
||||
|
||||
protected StateDependent(boolean enabled, Set<FightState> states) {
|
||||
this.enabled = states;
|
||||
this.register = enabled;
|
||||
}
|
||||
|
||||
public void register() {
|
||||
if (register) FightState.registerStateDependent(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<FightState> enabled() {
|
||||
return enabled;
|
||||
super(FightState.lifecycle, enabled, states);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-44
@@ -1,58 +1,20 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 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.states;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class StateDependentCommand extends StateDependent {
|
||||
|
||||
private static final CommandExecutor unavailable = (sender, cmd, s, strings) -> {
|
||||
@Deprecated
|
||||
public class StateDependentCommand extends de.steamwar.gamecore.state.StateDependentCommand<FightState> implements IStateDependent {
|
||||
private static final CommandExecutor unavailable = (sender, cmd, label, args) -> {
|
||||
FightSystem.getMessage().sendPrefixless("COMMAND_CURRENTLY_UNAVAILABLE", sender, ChatMessageType.ACTION_BAR);
|
||||
return false;
|
||||
};
|
||||
|
||||
private final PluginCommand command;
|
||||
private final CommandExecutor executor;
|
||||
|
||||
public StateDependentCommand(Set<ArenaMode> mode, Set<FightState> states, String name, CommandExecutor executor) {
|
||||
super(mode, states);
|
||||
this.executor = executor;
|
||||
this.command = FightSystem.getPlugin().getCommand(name);
|
||||
assert command != null;
|
||||
disable();
|
||||
register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
command.setExecutor(executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
command.setExecutor(unavailable);
|
||||
public StateDependentCommand(Set<de.steamwar.gamecore.ArenaMode> modes, Set<FightState> states, String name, CommandExecutor executor) {
|
||||
super(FightState.lifecycle, modes.contains(Config.mode), states, FightSystem.getPlugin(), name, executor, unavailable);
|
||||
}
|
||||
}
|
||||
|
||||
-70
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 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.states;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class StateDependentCountdown extends StateDependent {
|
||||
|
||||
private static Countdown mainCountdown = null;
|
||||
|
||||
public static Countdown getMainCountdown() {
|
||||
return mainCountdown;
|
||||
}
|
||||
|
||||
private final Countdown countdown;
|
||||
|
||||
public StateDependentCountdown(Set<ArenaMode> mode, Set<FightState> states, Countdown countdown) {
|
||||
super(mode, states);
|
||||
this.countdown = countdown;
|
||||
register();
|
||||
}
|
||||
|
||||
public StateDependentCountdown(Winconditions wincondition, Set<FightState> states, Countdown countdown) {
|
||||
this(Config.GameModeConfig.WinConditions.contains(wincondition), states, countdown);
|
||||
}
|
||||
|
||||
public StateDependentCountdown(boolean active, Set<FightState> states, Countdown countdown) {
|
||||
super(active, states);
|
||||
this.countdown = countdown;
|
||||
register();
|
||||
}
|
||||
|
||||
public Countdown getCountdown() {
|
||||
return countdown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
mainCountdown = countdown;
|
||||
countdown.enable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
countdown.disable();
|
||||
if (mainCountdown == countdown) mainCountdown = null;
|
||||
}
|
||||
}
|
||||
+7
-47
@@ -1,63 +1,23 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 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.states;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class StateDependentListener extends StateDependent {
|
||||
|
||||
private final Listener listener;
|
||||
|
||||
@Deprecated
|
||||
public class StateDependentListener extends de.steamwar.gamecore.state.StateDependentListener<FightState> implements IStateDependent {
|
||||
public StateDependentListener(Winconditions wincondition, Set<FightState> states, Listener listener) {
|
||||
super(Config.GameModeConfig.WinConditions.contains(wincondition), states);
|
||||
this.listener = listener;
|
||||
register();
|
||||
this(Config.GameModeConfig.WinConditions.contains(wincondition), states, listener);
|
||||
}
|
||||
|
||||
public StateDependentListener(boolean enabled, Set<FightState> states, Listener listener) {
|
||||
super(enabled, states);
|
||||
this.listener = listener;
|
||||
register();
|
||||
public StateDependentListener(boolean active, Set<FightState> states, Listener listener) {
|
||||
super(FightState.lifecycle, active, states, FightSystem.getPlugin(), listener);
|
||||
}
|
||||
|
||||
public StateDependentListener(Set<ArenaMode> mode, Set<FightState> states, Listener listener) {
|
||||
super(mode, states);
|
||||
this.listener = listener;
|
||||
register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
Bukkit.getPluginManager().registerEvents(listener, FightSystem.getPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
HandlerList.unregisterAll(listener);
|
||||
public StateDependentListener(Set<de.steamwar.gamecore.ArenaMode> modes, Set<FightState> states, Listener listener) {
|
||||
super(FightState.lifecycle, modes, Config.mode, states, FightSystem.getPlugin(), listener);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-53
@@ -1,69 +1,22 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 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.states;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class StateDependentTask extends StateDependent {
|
||||
|
||||
private final Runnable runnable;
|
||||
private final long delay;
|
||||
private final long period;
|
||||
|
||||
private BukkitTask task = null;
|
||||
|
||||
@Deprecated
|
||||
public class StateDependentTask extends de.steamwar.gamecore.state.StateDependentTask<FightState> implements IStateDependent {
|
||||
public StateDependentTask(Winconditions wincondition, Set<FightState> states, Runnable runnable, long delay, long period) {
|
||||
this(Config.GameModeConfig.WinConditions.contains(wincondition), states, runnable, delay, period);
|
||||
}
|
||||
|
||||
public StateDependentTask(boolean enabled, Set<FightState> states, Runnable runnable, long delay, long period) {
|
||||
super(enabled, states);
|
||||
this.runnable = runnable;
|
||||
this.delay = delay;
|
||||
this.period = period;
|
||||
register();
|
||||
public StateDependentTask(boolean active, Set<FightState> states, Runnable runnable, long delay, long period) {
|
||||
super(FightState.lifecycle, active, states, FightSystem.getPlugin(), runnable, delay, period);
|
||||
}
|
||||
|
||||
public StateDependentTask(Set<ArenaMode> mode, Set<FightState> states, Runnable runnable, long delay, long period) {
|
||||
super(mode, states);
|
||||
this.runnable = runnable;
|
||||
this.delay = delay;
|
||||
this.period = period;
|
||||
register();
|
||||
public StateDependentTask(Set<de.steamwar.gamecore.ArenaMode> modes, Set<FightState> states, Runnable runnable, long delay, long period) {
|
||||
super(FightState.lifecycle, modes, Config.mode, states, FightSystem.getPlugin(), runnable, delay, period);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), runnable, delay, period);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,11 +19,12 @@
|
||||
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.gamecore.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.gamecore.state.StateDependentCountdown;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.network.NetworkSender;
|
||||
@@ -41,6 +42,7 @@ public class BungeeFightInfo {
|
||||
}
|
||||
|
||||
private void send() {
|
||||
Countdown mainCountdown = StateDependentCountdown.getMainCountdown(FightState.lifecycle);
|
||||
NetworkSender.send(new FightInfoPacket(
|
||||
Config.world.getName(),
|
||||
Config.GameModeConfig.Schematic.Type.toDB(),
|
||||
@@ -48,7 +50,7 @@ public class BungeeFightInfo {
|
||||
Fight.getBlueTeam().getColoredName(),
|
||||
Fight.getRedTeam().getColoredName(),
|
||||
FightState.getFightState().name(),
|
||||
StateDependentCountdown.getMainCountdown() != null ? StateDependentCountdown.getMainCountdown().getTimeLeft() : 0,
|
||||
mainCountdown != null ? mainCountdown.getTimeLeft() : 0,
|
||||
Fight.getBlueTeam().getLeader() != null ? Fight.getBlueTeam().getLeader().getUser().getId() : 0,
|
||||
Fight.getRedTeam().getLeader() != null ? Fight.getRedTeam().getLeader().getUser().getId() : 0,
|
||||
Fight.getBlueTeam().getSchematic(),
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
import de.steamwar.gamecore.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import de.steamwar.core.TPSWatcher;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.gamecore.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
@@ -28,7 +29,7 @@ import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.gamecore.state.StateDependentCountdown;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import de.steamwar.fightsystem.winconditions.Wincondition;
|
||||
import de.steamwar.linkage.Linked;
|
||||
@@ -71,7 +72,8 @@ public class FightUI {
|
||||
totalHearts = 1.0;
|
||||
}
|
||||
|
||||
int timeLeft = StateDependentCountdown.getMainCountdown() != null ? StateDependentCountdown.getMainCountdown().getTimeLeft() : 0;
|
||||
Countdown mainCountdown = StateDependentCountdown.getMainCountdown(FightState.lifecycle);
|
||||
int timeLeft = mainCountdown != null ? mainCountdown.getTimeLeft() : 0;
|
||||
String time = "§7" + (timeLeft / 60) + "§8:§7" + (timeLeft % 60 < 10 ? "0" : "") + (timeLeft % 60);
|
||||
String bluePlayers = blue.getPrefix() + blue.getAlivePlayers() + "§8/§7" + blue.getPlayerCount();
|
||||
String redPlayers = red.getPrefix() + red.getAlivePlayers() + "§8/§7" + red.getPlayerCount();
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.gamecore.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
|
||||
+16
-10
@@ -20,10 +20,12 @@
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
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 de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.gamecore.state.StateDependentCountdown;
|
||||
import de.steamwar.gamecore.countdown.Countdown;
|
||||
import de.steamwar.gamecore.wincondition.GameResult;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@@ -31,13 +33,12 @@ import org.bukkit.entity.LivingEntity;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.ToDoubleFunction;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class Wincondition {
|
||||
public abstract class Wincondition implements de.steamwar.gamecore.wincondition.WinCondition<FightTeam> {
|
||||
|
||||
@Getter
|
||||
protected static WinconditionBasePercent percentWincondition = null;
|
||||
protected static StateDependentCountdown timeOverCountdown = null;
|
||||
protected static StateDependentCountdown<FightState> timeOverCountdown = null;
|
||||
@Getter
|
||||
protected static final List<PrintableWincondition> printableWinconditions = new ArrayList<>();
|
||||
|
||||
@@ -47,6 +48,11 @@ public abstract class Wincondition {
|
||||
this.windescription = windescription;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String id() {
|
||||
return windescription;
|
||||
}
|
||||
|
||||
public static Countdown getTimeOverCountdown() {
|
||||
if (timeOverCountdown == null) return null;
|
||||
return timeOverCountdown.getCountdown();
|
||||
@@ -63,12 +69,12 @@ public abstract class Wincondition {
|
||||
}
|
||||
|
||||
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());
|
||||
if (teams.size() > 1) {
|
||||
win(null, tieMessage);
|
||||
GameResult<FightTeam> result = de.steamwar.gamecore.wincondition.WinConditions.winnerByScore(Fight.teams(), evaluate);
|
||||
if (result instanceof GameResult.Winner<FightTeam> winner) {
|
||||
FightTeam team = winner.getWinner();
|
||||
win(team, winMessage, team.getColoredName());
|
||||
} else {
|
||||
win(teams.get(0), winMessage, teams.get(0).getColoredName());
|
||||
win(null, tieMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-2
@@ -23,7 +23,7 @@ import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.gamecore.state.StateDependentCountdown;
|
||||
|
||||
import java.util.function.ToDoubleFunction;
|
||||
|
||||
@@ -32,7 +32,12 @@ public abstract class WinconditionComparisonTimeout extends Wincondition {
|
||||
public WinconditionComparisonTimeout(Winconditions wincondition, String windescription, String winMessage, ToDoubleFunction<FightTeam> evaluate) {
|
||||
super(windescription);
|
||||
if (Config.GameModeConfig.WinConditions.contains(wincondition)) {
|
||||
timeOverCountdown = new StateDependentCountdown(wincondition, FightState.Running, new TimeOverCountdown(() -> comparisonWin(evaluate, winMessage, "WIN_TIME_OVER")));
|
||||
timeOverCountdown = new StateDependentCountdown<>(
|
||||
FightState.lifecycle,
|
||||
true,
|
||||
FightState.Running,
|
||||
new TimeOverCountdown(() -> comparisonWin(evaluate, winMessage, "WIN_TIME_OVER"))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-2
@@ -24,7 +24,7 @@ import de.steamwar.fightsystem.countdown.TimeOverCountdown;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.gamecore.state.StateDependentCountdown;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.linkage.Linked;
|
||||
@@ -54,7 +54,12 @@ public class WinconditionPoints extends WinconditionBasePercent implements Liste
|
||||
new StateDependentListener(Winconditions.POINTS, FightState.Ingame, this);
|
||||
|
||||
if (Config.GameModeConfig.WinConditions.contains(Winconditions.POINTS)) {
|
||||
timeOverCountdown = new StateDependentCountdown(Winconditions.POINTS, FightState.Running, new TimeOverCountdown(this::timeOver));
|
||||
timeOverCountdown = new StateDependentCountdown<>(
|
||||
FightState.lifecycle,
|
||||
true,
|
||||
FightState.Running,
|
||||
new TimeOverCountdown(this::timeOver)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-4
@@ -20,7 +20,10 @@
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.countdown.FightCountdownAdapter;
|
||||
import de.steamwar.gamecore.countdown.Countdown;
|
||||
import de.steamwar.gamecore.countdown.StandardCountdown;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
@@ -109,17 +112,17 @@ public class WinconditionTimeTechKO extends Wincondition implements Listener {
|
||||
});
|
||||
}
|
||||
|
||||
private class TechKOCountdown extends Countdown {
|
||||
private class TechKOCountdown extends StandardCountdown {
|
||||
private final FightTeam team;
|
||||
|
||||
public TechKOCountdown(FightTeam team, int countdownTime) {
|
||||
super(countdownTime, new Message("TECHKO_COUNTDOWN", team.getColoredName()), SWSound.BLOCK_NOTE_PLING, false);
|
||||
super(FightSystem.getPlugin(), countdownTime, FightCountdownAdapter.presentation(new Message("TECHKO_COUNTDOWN", team.getColoredName()), SWSound.BLOCK_NOTE_PLING, false));
|
||||
this.team = team;
|
||||
super.enable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
protected void countdownFinished() {
|
||||
win(Fight.getOpposite(team), "WIN_TECHKO", team.getColoredName());
|
||||
}
|
||||
}
|
||||
|
||||
+7
-4
@@ -20,7 +20,10 @@
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.countdown.FightCountdownAdapter;
|
||||
import de.steamwar.gamecore.countdown.Countdown;
|
||||
import de.steamwar.gamecore.countdown.StandardCountdown;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
@@ -100,16 +103,16 @@ public class WinconditionTimedDamageTechKO extends Wincondition implements Print
|
||||
});
|
||||
}
|
||||
|
||||
private class TechKOCountdown extends Countdown {
|
||||
private class TechKOCountdown extends StandardCountdown {
|
||||
private final FightTeam team;
|
||||
|
||||
public TechKOCountdown(FightTeam team, int countdownTime) {
|
||||
super(countdownTime, new Message("TECHKO_COUNTDOWN", team.getColoredName()), SWSound.BLOCK_NOTE_PLING, false);
|
||||
super(FightSystem.getPlugin(), countdownTime, FightCountdownAdapter.presentation(new Message("TECHKO_COUNTDOWN", team.getColoredName()), SWSound.BLOCK_NOTE_PLING, false));
|
||||
this.team = team;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
protected void countdownFinished() {
|
||||
win(Fight.getOpposite(team), "WIN_TECHKO", team.getColoredName());
|
||||
}
|
||||
}
|
||||
|
||||
+7
-2
@@ -22,7 +22,7 @@ package de.steamwar.fightsystem.winconditions;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.gamecore.state.StateDependentCountdown;
|
||||
import de.steamwar.linkage.Linked;
|
||||
|
||||
@Linked
|
||||
@@ -31,7 +31,12 @@ public class WinconditionTimeout extends Wincondition {
|
||||
public WinconditionTimeout() {
|
||||
super("Timeout");
|
||||
if (Config.GameModeConfig.WinConditions.contains(Winconditions.TIMEOUT)) {
|
||||
timeOverCountdown = new StateDependentCountdown(Winconditions.TIMEOUT, FightState.Running, new TimeOverCountdown(this::timeOver));
|
||||
timeOverCountdown = new StateDependentCountdown<>(
|
||||
FightState.lifecycle,
|
||||
true,
|
||||
FightState.Running,
|
||||
new TimeOverCountdown(this::timeOver)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ main: de.steamwar.fightsystem.FightSystem
|
||||
softdepend:
|
||||
- SpigotCore
|
||||
depend:
|
||||
- GameCore
|
||||
- WorldEdit
|
||||
api-version: "1.13"
|
||||
|
||||
@@ -28,4 +29,4 @@ commands:
|
||||
tpslimit:
|
||||
tpswarp:
|
||||
techhiderbug:
|
||||
unrank:
|
||||
unrank:
|
||||
|
||||
Reference in New Issue
Block a user