The big refactoring #238
@ -289,13 +289,14 @@ public class Config {
|
||||
RedRotate = teamRedRotate;
|
||||
BlueRotate = teamBlueRotate;
|
||||
|
||||
int arenaYSize = schemsizeY + PreperationArea;
|
||||
|
||||
RedPasteRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ);
|
||||
BluePasteRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ);
|
||||
|
||||
RedExtendRegion = new Region(teamRedCornerX, underBorder, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea);
|
||||
BlueExtendRegion = new Region(blueCornerX, underBorder, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea);
|
||||
int upperArenaBorder = blueCornerY + schemsizeY + PreperationArea;
|
||||
ArenaRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX - arenaMinX, upperArenaBorder - underBorder, arenaMaxZ - arenaMinZ);
|
||||
RedExtendRegion = new Region(teamRedCornerX, underBorder, teamRedCornerZ, schemsizeX, arenaYSize, schemsizeZ, PreperationArea, PreperationArea);
|
||||
BlueExtendRegion = new Region(blueCornerX, underBorder, blueCornerZ, schemsizeX, arenaYSize, schemsizeZ, PreperationArea, PreperationArea);
|
||||
ArenaRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX - arenaMinX, arenaYSize, arenaMaxZ - arenaMinZ);
|
||||
|
||||
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
||||
if(EventKampfID >= 1){
|
||||
@ -380,7 +381,7 @@ public class Config {
|
||||
}
|
||||
|
||||
public static boolean test(){
|
||||
return ArenaMode.Test.contains(ArenaMode.TEST);
|
||||
return ArenaMode.Test.contains(mode);
|
||||
}
|
||||
public static boolean recording(){
|
||||
return mode == ArenaMode.EVENT;
|
||||
|
@ -40,9 +40,9 @@ public class ITechHider {
|
||||
if(ft == null){
|
||||
return Config.ArenaRegion.chunkOutside(chunkX, chunkZ);
|
||||
}else if(ft.isBlue()){
|
||||
return ft.canPlayerEntern(p) || Config.BlueExtendRegion.chunkOutside(chunkX, chunkZ);
|
||||
}else{
|
||||
return ft.canPlayerEntern(p) || Config.RedExtendRegion.chunkOutside(chunkX, chunkZ);
|
||||
}else{
|
||||
return ft.canPlayerEntern(p) || Config.BlueExtendRegion.chunkOutside(chunkX, chunkZ);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,9 +14,9 @@ public class Region {
|
||||
private final int maxY;
|
||||
private final int maxZ;
|
||||
|
||||
public Region(int minX, int minY, int minZ, int sizeX, int maxY, int sizeZ, int extendX, int extendZ) {
|
||||
public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ, int extendX, int extendZ) {
|
||||
this(minX - extendX, minY, minZ - extendZ,
|
||||
minX + sizeX + extendX, maxY, minZ + sizeZ + extendZ);
|
||||
sizeX + extendX * 2, sizeY, sizeZ + extendZ * 2);
|
||||
}
|
||||
|
||||
public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ) {
|
||||
@ -52,20 +52,24 @@ public class Region {
|
||||
return maxZ;
|
||||
}
|
||||
|
||||
public int getMinChunkX(){
|
||||
return ITechHider.posToChunk(minX);
|
||||
public double posToChunk(int pos){
|
||||
return pos / 16.0;
|
||||
}
|
||||
|
||||
public int getMaxChunkX(){
|
||||
return ITechHider.posToChunk(maxX);
|
||||
private int getMinChunkX(){
|
||||
return (int) Math.floor(posToChunk(minX));
|
||||
}
|
||||
|
||||
public int getMinChunkZ(){
|
||||
return ITechHider.posToChunk(minZ);
|
||||
private int getMaxChunkX(){
|
||||
return (int) Math.ceil(posToChunk(maxX));
|
||||
}
|
||||
|
||||
public int getMaxChunkZ(){
|
||||
return ITechHider.posToChunk(maxZ);
|
||||
private int getMinChunkZ(){
|
||||
return (int) Math.floor(posToChunk(minZ));
|
||||
}
|
||||
|
||||
private int getMaxChunkZ(){
|
||||
return (int) Math.ceil(posToChunk(maxZ));
|
||||
}
|
||||
|
||||
public boolean chunkOutside(int cX, int cZ) {
|
||||
@ -110,7 +114,7 @@ public class Region {
|
||||
}
|
||||
|
||||
public boolean playerInRegion(Location location){
|
||||
return in2dRegion(location) && minY < location.getY() && location.getY() + 1.8 < maxY;
|
||||
return in2dRegion(location) && minY <= location.getY() && location.getY() + 1.8 < maxY;
|
||||
}
|
||||
|
||||
public boolean in2dRegion(Block block){
|
||||
|
@ -96,9 +96,6 @@ public class Commands {
|
||||
}
|
||||
|
||||
static void toggleSkip(Player p){
|
||||
if(checkSetup(p))
|
||||
return;
|
||||
|
||||
FightTeam fightTeam = checkGetTeam(p);
|
||||
if(fightTeam == null || checkGetLeader(p) == null)
|
||||
return;
|
||||
@ -213,8 +210,10 @@ public class Commands {
|
||||
Kit k = null;
|
||||
if(Config.PersonalKits){
|
||||
PersonalKit kit = PersonalKit.get(SteamwarUser.get(p.getUniqueId()).getId(), Config.SchematicType.toDB(), kitName);
|
||||
if(kit != null)
|
||||
if(kit != null){
|
||||
kit.setInUse();
|
||||
k = new Kit(kit);
|
||||
}
|
||||
}else{
|
||||
k = Kit.getKitByName(kitName);
|
||||
}
|
||||
|
@ -60,10 +60,11 @@ public class FightSchematic extends StateDependent {
|
||||
this.team = team;
|
||||
this.region = team.getSchemRegion();
|
||||
this.rotate = rotate;
|
||||
register();
|
||||
}
|
||||
|
||||
public boolean hasSchematic(){
|
||||
return clipboard == null;
|
||||
return clipboard != null;
|
||||
}
|
||||
|
||||
public int getId(){
|
||||
@ -109,6 +110,10 @@ public class FightSchematic extends StateDependent {
|
||||
else
|
||||
RecordSystem.redSchem(schematic);
|
||||
|
||||
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::paste);
|
||||
}
|
||||
|
||||
private void paste(){
|
||||
FreezeWorld freezer = new FreezeWorld();
|
||||
DyeColor c = ColorConverter.chat2dye(team.getColor());
|
||||
|
||||
|
@ -140,15 +140,18 @@ public class FightTeam implements IFightTeam{
|
||||
}
|
||||
|
||||
public void reset(){
|
||||
skip = false;
|
||||
ready = false;
|
||||
schematic.reset();
|
||||
invited.clear();
|
||||
|
||||
Set<Player> playerSet = new HashSet<>(players.keySet());
|
||||
for(Player player : playerSet){
|
||||
if(!player.isOnline())
|
||||
if(!Bukkit.getOnlinePlayers().contains(player))
|
||||
removePlayer(player);
|
||||
}
|
||||
FightPlayer leaderBackup = leader;
|
||||
playerSet.removeIf(player -> !player.isOnline());
|
||||
playerSet.removeIf(player -> !Bukkit.getOnlinePlayers().contains(player));
|
||||
players.clear();
|
||||
leader = null;
|
||||
|
||||
@ -183,6 +186,7 @@ public class FightTeam implements IFightTeam{
|
||||
Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
|
||||
player.setHealth(20);
|
||||
player.setFoodLevel(20);
|
||||
player.getInventory().clear();
|
||||
BasicListener.setAttackSpeed(player);
|
||||
player.teleport(spawn);
|
||||
if(Kit.getAvailableKits(false).size() > 1 || Config.PersonalKits)
|
||||
@ -234,13 +238,12 @@ public class FightTeam implements IFightTeam{
|
||||
|
||||
private void setLeader(FightPlayer leader) {
|
||||
if (leader == null) {
|
||||
if (FightState.getFightState() == FightState.PRE_LEADER_SETUP){
|
||||
this.leader = null;
|
||||
}else if(!players.isEmpty()) {
|
||||
this.leader = null;
|
||||
if(!players.isEmpty()) {
|
||||
setLeader(players.values().iterator().next());
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §e" + this.leader.getPlayer().getName() + " §aist nun Leader von Team " + getColoredName() + "§a!");
|
||||
}else if(!ArenaMode.RankedEvent.contains(Config.mode)){
|
||||
FightSystem.setPreLeaderState();
|
||||
}else if(FightState.getFightState() != FightState.PRE_LEADER_SETUP && !ArenaMode.RankedEvent.contains(Config.mode)){
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), FightSystem::setPreLeaderState, 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -271,6 +274,10 @@ public class FightTeam implements IFightTeam{
|
||||
|
||||
if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
||||
inventory.setItem(0, new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§e" + Config.GameName + " wählen").build());
|
||||
|
||||
if(FightState.getFightState() == FightState.PRE_LEADER_SETUP && !Fight.getOpposite(this).isLeaderless()){
|
||||
FightSystem.setPreSchemState();
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<FightPlayer> getPlayers() {
|
||||
@ -284,7 +291,7 @@ public class FightTeam implements IFightTeam{
|
||||
public void pasteSchem(Schematic schematic){
|
||||
setSchem(schematic);
|
||||
|
||||
if(ArenaMode.Test.contains(Config.mode))
|
||||
if(Config.test())
|
||||
this.schematic.enable();
|
||||
else if(Fight.getOpposite(this).hasSchematic()){
|
||||
FightSystem.setPostSchemState();
|
||||
@ -385,6 +392,7 @@ public class FightTeam implements IFightTeam{
|
||||
private class KitLoader extends StateDependent {
|
||||
private KitLoader() {
|
||||
super(ArenaMode.All, FightState.Ingame);
|
||||
register();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -408,6 +416,7 @@ public class FightTeam implements IFightTeam{
|
||||
private class SpectateHandler extends StateDependent {
|
||||
private SpectateHandler() {
|
||||
super(ArenaMode.All, FightState.Spectate);
|
||||
register();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,6 +18,7 @@ public class FightWorld extends StateDependent {
|
||||
|
||||
public FightWorld() {
|
||||
super(ArenaMode.Restartable, FightState.Schem);
|
||||
register();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,7 +59,7 @@ public class ArenaBorder implements Listener {
|
||||
player.damage(2);
|
||||
else if(!Config.GroundWalkable)
|
||||
player.teleport(team.getSpawn());
|
||||
}else if(to.getY() + 1.8 <= Config.ArenaRegion.getMaxY()){
|
||||
}else if(to.getY() + 1.8 > Config.ArenaRegion.getMaxY()){
|
||||
reset(event);
|
||||
}
|
||||
}
|
||||
|
@ -21,9 +21,7 @@ package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
@ -50,11 +48,5 @@ public class NormalJoin implements Listener {
|
||||
Fight.getRedTeam().addMember(player);
|
||||
}
|
||||
}
|
||||
|
||||
FightPlayer redLeader = Fight.getRedTeam().getLeader();
|
||||
FightPlayer blueLeader = Fight.getBlueTeam().getLeader();
|
||||
if(redLeader != null && blueLeader != null && (Fight.getRedTeam().getLeader().getPlayer() == player || Fight.getBlueTeam().getLeader().getPlayer() == player)) {
|
||||
FightSystem.setPreSchemState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public class Recording implements Listener {
|
||||
despawnTeam(Fight.getBlueTeam());
|
||||
despawnTNT();
|
||||
}
|
||||
};
|
||||
}.register();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
|
@ -26,7 +26,6 @@ import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
@ -36,7 +35,7 @@ public class SetupQuit implements Listener {
|
||||
new StateDependentListener(ArenaMode.All, FightState.Setup, this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@EventHandler
|
||||
public void handlePlayerQuit(PlayerQuitEvent event) {
|
||||
event.setQuitMessage(null);
|
||||
|
||||
|
@ -11,6 +11,7 @@ public class OneShotStateDependent extends StateDependent{
|
||||
public OneShotStateDependent(Set<ArenaMode> mode, Set<FightState> states, Runnable runnable) {
|
||||
super(mode, states);
|
||||
this.runnable = runnable;
|
||||
register();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,6 +9,7 @@ import java.util.Set;
|
||||
public abstract class StateDependent implements IStateDependent {
|
||||
|
||||
private final Set<FightState> enabled;
|
||||
private final boolean register;
|
||||
|
||||
protected StateDependent(Winconditions wincondition, Set<FightState> states){
|
||||
this(Config.ActiveWinconditions.contains(wincondition), states);
|
||||
@ -20,8 +21,11 @@ public abstract class StateDependent implements IStateDependent {
|
||||
|
||||
protected StateDependent(boolean enabled, Set<FightState> states){
|
||||
this.enabled = states;
|
||||
this.register = enabled;
|
||||
}
|
||||
|
||||
if(enabled)
|
||||
public void register(){
|
||||
if(register)
|
||||
FightState.registerStateDependent(this);
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,7 @@ public class StateDependentCommand extends StateDependent {
|
||||
this.command = FightSystem.getPlugin().getCommand(name);
|
||||
assert command != null;
|
||||
disable();
|
||||
register();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,11 +33,13 @@ public class StateDependentCountdown extends StateDependent {
|
||||
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) {
|
||||
super(Config.ActiveWinconditions.contains(wincondition), states);
|
||||
this.countdown = countdown;
|
||||
register();
|
||||
}
|
||||
|
||||
public Countdown getCountdown(){
|
||||
|
@ -36,16 +36,19 @@ public class StateDependentListener extends StateDependent{
|
||||
public StateDependentListener(Winconditions wincondition, Set<FightState> states, Listener listener){
|
||||
super(Config.ActiveWinconditions.contains(wincondition), states);
|
||||
this.listener = listener;
|
||||
register();
|
||||
}
|
||||
|
||||
public StateDependentListener(boolean enabled, Set<FightState> states, Listener listener){
|
||||
super(enabled, states);
|
||||
this.listener = listener;
|
||||
register();
|
||||
}
|
||||
|
||||
public StateDependentListener(Set<ArenaMode> mode, Set<FightState> states, Listener listener) {
|
||||
super(mode, states);
|
||||
this.listener = listener;
|
||||
register();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,6 +45,7 @@ public class StateDependentTask extends StateDependent {
|
||||
this.runnable = runnable;
|
||||
this.delay = delay;
|
||||
this.period = period;
|
||||
register();
|
||||
}
|
||||
|
||||
public StateDependentTask(Set<ArenaMode> mode, Set<FightState> states, Runnable runnable, long delay, long period) {
|
||||
@ -52,6 +53,7 @@ public class StateDependentTask extends StateDependent {
|
||||
this.runnable = runnable;
|
||||
this.delay = delay;
|
||||
this.period = period;
|
||||
register();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,7 +38,7 @@ import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.IFightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.IStateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
@ -48,11 +48,10 @@ import java.util.*;
|
||||
|
||||
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
|
||||
|
||||
public class TechHider implements IStateDependent {
|
||||
public class TechHider extends StateDependent {
|
||||
|
||||
private static final boolean DISABLED = !Config.OnlyPublicSchematics && !Config.test() && Config.TechhiderActive;
|
||||
private static final boolean enabled = !Config.OnlyPublicSchematics && !Config.test() && Config.TechhiderActive;
|
||||
|
||||
private final Set<FightState> enabled;
|
||||
private final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
||||
private final Map<PacketContainer, PacketContainer> packetCache = new HashMap<>();
|
||||
private final Material obfuscateMaterial;
|
||||
@ -60,10 +59,7 @@ public class TechHider implements IStateDependent {
|
||||
private final int threadMultiplier;
|
||||
|
||||
public TechHider(){
|
||||
FightState.registerStateDependent(this);
|
||||
enabled = DISABLED
|
||||
? EnumSet.noneOf(FightState.class)
|
||||
: EnumSet.complementOf(EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP));
|
||||
super(enabled, FightState.Schem);
|
||||
|
||||
Set<Integer> hiddenBlockIds = VersionedCallable.call(
|
||||
new VersionedCallable<>(Collections::emptySet, 8),
|
||||
@ -76,7 +72,7 @@ public class TechHider implements IStateDependent {
|
||||
new VersionedCallable<>(TechHider_14::getObfuscateWith, 14),
|
||||
new VersionedCallable<>(TechHider_15::getObfuscateWith, 15));
|
||||
|
||||
obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith);
|
||||
obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith.toUpperCase());
|
||||
chunkHider = VersionedCallable.call(new VersionedCallable<>(() -> null, 8),
|
||||
new VersionedCallable<>(() -> TechHider_12.chunkHider(hiddenBlockIds, obfuscateWith), 12),
|
||||
new VersionedCallable<>(() -> TechHider_14.chunkHider(hiddenBlockIds, obfuscateWith), 14));
|
||||
@ -86,9 +82,6 @@ public class TechHider implements IStateDependent {
|
||||
else
|
||||
threadMultiplier = 1;
|
||||
|
||||
if(DISABLED)
|
||||
return;
|
||||
|
||||
Bukkit.getScheduler().runTaskTimer(IFightSystem.getPlugin(), packetCache::clear, 1, 1);
|
||||
|
||||
if(Core.getVersion() > 8){
|
||||
@ -111,11 +104,7 @@ public class TechHider implements IStateDependent {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<FightState> enabled() {
|
||||
return enabled;
|
||||
register();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -174,7 +163,7 @@ public class TechHider implements IStateDependent {
|
||||
boolean changed = false;
|
||||
for(MultiBlockChangeInfo mbci : changes){
|
||||
WrappedBlockData block = mbci.getData();
|
||||
if(Config.HiddenBlocks.contains(block.getType().name())){
|
||||
if(Config.HiddenBlocks.contains(block.getType().name().toLowerCase())){
|
||||
changed = true;
|
||||
block.setType(obfuscateMaterial);
|
||||
mbci.setData(block);
|
||||
@ -208,7 +197,7 @@ public class TechHider implements IStateDependent {
|
||||
e.setPacket(cached);
|
||||
StructureModifier<WrappedBlockData> blockStructure = cached.getBlockData();
|
||||
WrappedBlockData block = blockStructure.read(0);
|
||||
if(Config.HiddenBlocks.contains(block.getType().name())){
|
||||
if(Config.HiddenBlocks.contains(block.getType().name().toLowerCase())){
|
||||
block.setType(obfuscateMaterial);
|
||||
blockStructure.write(0, block);
|
||||
}
|
||||
@ -251,7 +240,7 @@ public class TechHider implements IStateDependent {
|
||||
e.setPacket(cached);
|
||||
StructureModifier<WrappedBlockData> blockStructure = cached.getBlockData();
|
||||
WrappedBlockData block = blockStructure.read(0);
|
||||
if(Config.HiddenBlocks.contains(block.getType().name())){
|
||||
if(Config.HiddenBlocks.contains(block.getType().name().toLowerCase())){
|
||||
block.setType(obfuscateMaterial);
|
||||
blockStructure.write(0, block);
|
||||
}
|
||||
@ -277,7 +266,7 @@ public class TechHider implements IStateDependent {
|
||||
};
|
||||
|
||||
public static List<ChunkPos> prepareChunkReload(Player p){
|
||||
if(DISABLED)
|
||||
if(enabled)
|
||||
return Collections.emptyList();
|
||||
List<ChunkPos> chunksToReload = new ArrayList<>();
|
||||
Config.ArenaRegion.forEachChunk((x, z) -> {
|
||||
@ -288,7 +277,7 @@ public class TechHider implements IStateDependent {
|
||||
}
|
||||
|
||||
public static void reloadChunks(Player p, List<ChunkPos> chunksToReload){
|
||||
if(DISABLED)
|
||||
if(enabled)
|
||||
return;
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||
for(ChunkPos chunk : chunksToReload){
|
||||
|
@ -44,7 +44,7 @@ public class EventTeamOffWincondition extends Wincondition{
|
||||
public void disable() {
|
||||
//Team off is a one time trigger
|
||||
}
|
||||
};
|
||||
}.register();
|
||||
}
|
||||
|
||||
private void teamOff(FightTeam team){
|
||||
|
@ -57,6 +57,8 @@ public abstract class Wincondition {
|
||||
}
|
||||
|
||||
public static Countdown getTimeOverCountdown(){
|
||||
if(timeOverCountdown == null)
|
||||
return null;
|
||||
return timeOverCountdown.getCountdown();
|
||||
}
|
||||
|
||||
|
@ -37,12 +37,14 @@ public class WinconditionPercentSystem extends Wincondition implements Listener,
|
||||
|
||||
public WinconditionPercentSystem() {
|
||||
super("Percent", "§cTeam ", " §chat den Gegnern");
|
||||
printableWinconditions.add(this);
|
||||
percentWincondition = this;
|
||||
teamMap.put(Fight.getBlueTeam(), new TeamPercent(Fight.getBlueTeam()));
|
||||
teamMap.put(Fight.getRedTeam(), new TeamPercent(Fight.getRedTeam()));
|
||||
|
||||
new StateDependentListener(Winconditions.PERCENT_SYSTEM, FightState.Running, this);
|
||||
if(Config.ActiveWinconditions.contains(Winconditions.PERCENT_SYSTEM)){
|
||||
printableWinconditions.add(this);
|
||||
percentWincondition = this;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
@ -46,7 +47,6 @@ public class WinconditionPoints extends Wincondition implements PrintableWincond
|
||||
|
||||
teamMap.put(Fight.getBlueTeam(), new TeamPoints(Fight.getBlueTeam()));
|
||||
teamMap.put(Fight.getRedTeam(), new TeamPoints(Fight.getRedTeam()));
|
||||
printableWinconditions.add(this);
|
||||
|
||||
new StateDependentListener(Winconditions.POINTS, FightState.Ingame, this);
|
||||
timeOverCountdown = new StateDependentCountdown(Winconditions.POINTS, FightState.Running, new TimeOverCountdown(this::timeOver));
|
||||
@ -60,7 +60,10 @@ public class WinconditionPoints extends Wincondition implements PrintableWincond
|
||||
public void disable() {
|
||||
teamMap.values().forEach(TeamPoints::disable);
|
||||
}
|
||||
};
|
||||
}.register();
|
||||
if(Config.ActiveWinconditions.contains(Winconditions.POINTS)){
|
||||
printableWinconditions.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected void timeOver() {
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
@ -40,9 +41,13 @@ public class WinconditionPumpkinTechKO extends Wincondition implements Printable
|
||||
|
||||
public WinconditionPumpkinTechKO(){
|
||||
super("PumpkinTechKO", "§cDas Team ", " §cist Tech K.O.!");
|
||||
new StateDependentTask(Winconditions.PUMPKIN_TECH_KO, FightState.Ingame, this::check, 0, 200);
|
||||
teamMap.put(Fight.getRedTeam(), new TeamPumpkin(Fight.getRedTeam()));
|
||||
teamMap.put(Fight.getBlueTeam(), new TeamPumpkin(Fight.getBlueTeam()));
|
||||
|
||||
new StateDependentTask(Winconditions.PUMPKIN_TECH_KO, FightState.Ingame, this::check, 0, 200);
|
||||
if(Config.ActiveWinconditions.contains(Winconditions.PUMPKIN_TECH_KO)){
|
||||
printableWinconditions.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void check(){
|
||||
|
@ -50,8 +50,6 @@ public class WinconditionRelativePercent extends Wincondition implements Printab
|
||||
super("RelativePercent", null);
|
||||
teamMap.put(Fight.getBlueTeam(), new TeamPercent(Fight.getBlueTeam()));
|
||||
teamMap.put(Fight.getRedTeam(), new TeamPercent(Fight.getRedTeam()));
|
||||
printableWinconditions.add(this);
|
||||
percentWincondition = this;
|
||||
new StateDependent(Winconditions.RELATIVE_PERCENT, FightState.Running){
|
||||
@Override
|
||||
public void enable() {
|
||||
@ -62,7 +60,11 @@ public class WinconditionRelativePercent extends Wincondition implements Printab
|
||||
public void disable() {
|
||||
teamMap.values().forEach(TeamPercent::disable);
|
||||
}
|
||||
};
|
||||
}.register();
|
||||
if(Config.ActiveWinconditions.contains(Winconditions.RELATIVE_PERCENT)){
|
||||
printableWinconditions.add(this);
|
||||
percentWincondition = this;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.listener.WaterRemover;
|
||||
@ -40,9 +41,11 @@ public class WinconditionWaterTechKO extends Wincondition implements PrintableWi
|
||||
super("WaterTechKO", "§cDas Team ", " §cwurde Tech K.O. gesetzt!");
|
||||
teamMap.put(Fight.getBlueTeam(), new TeamWater(Fight.getBlueTeam()));
|
||||
teamMap.put(Fight.getRedTeam(), new TeamWater(Fight.getRedTeam()));
|
||||
printableWinconditions.add(this);
|
||||
|
||||
new StateDependentTask(Winconditions.WATER_TECH_KO, FightState.Ingame, this::check, 200, 200);
|
||||
if(Config.ActiveWinconditions.contains(Winconditions.WATER_TECH_KO)){
|
||||
printableWinconditions.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void check() {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren