Finishing setup split (untested)
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
126a9b3ab4
Commit
049c51f2a9
@ -20,7 +20,10 @@ import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class FightSystem extends JavaPlugin {
|
||||
|
||||
@ -30,6 +33,7 @@ public class FightSystem extends JavaPlugin {
|
||||
private static FightState fightState = FightState.PRE_LEADER_SETUP;
|
||||
private static Map<StateDependent, Boolean> stateDependentFeatures = new HashMap<>();
|
||||
private static int fightTime = 0;
|
||||
private static Countdown mainCountdown;
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
@ -41,6 +45,8 @@ public class FightSystem extends JavaPlugin {
|
||||
public void onEnable() {
|
||||
Fight.init();
|
||||
KitManager.loadAllKits();
|
||||
TechHider.init();
|
||||
FightScoreboard.init();
|
||||
|
||||
new EntityDamageListener();
|
||||
new EntityExplodeListener();
|
||||
@ -52,63 +58,11 @@ public class FightSystem extends JavaPlugin {
|
||||
new PlayerStateListener();
|
||||
new ProjectileLaunchListener();
|
||||
new InFightDamageListener();
|
||||
|
||||
if(!Config.test()){
|
||||
new FreezeWorldStateListener();
|
||||
TechHider.init();
|
||||
}
|
||||
|
||||
FightScoreboard.init();
|
||||
|
||||
getCommand("leave").setExecutor(new LeaveCommand());
|
||||
getCommand("kit").setExecutor(new KitCommand());
|
||||
getCommand("remove").setExecutor(new RemoveCommand());
|
||||
getCommand("accept").setExecutor(new AcceptCommand());
|
||||
getCommand("decline").setExecutor(new DeclineCommand());
|
||||
getCommand("invite").setExecutor(new InviteCommand());
|
||||
getCommand("ready").setExecutor(new ReadyCommand());
|
||||
getCommand("ak").setExecutor(new AkCommand());
|
||||
getCommand("leader").setExecutor(new LeaderCommand());
|
||||
getCommand("lockschem").setExecutor(new LockschemCommand());
|
||||
|
||||
if(Config.event()) {
|
||||
new EventJoinListener();
|
||||
|
||||
getCommand("invite").setExecutor(new EventDummyCommand());
|
||||
getCommand("ready").setExecutor(new EventDummyCommand());
|
||||
getCommand("ak").setExecutor(new EventDummyCommand());
|
||||
getCommand("leader").setExecutor(new EventDummyCommand());
|
||||
|
||||
new EventStartCountdown();
|
||||
}else if(Config.test()){
|
||||
new TestListener();
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(this, Fight.getBlueTeam()::pasteDummy, 0);
|
||||
Bukkit.getScheduler().runTaskLater(this, Fight.getRedTeam()::pasteDummy, 0);
|
||||
|
||||
new NoPlayersOnlineCountdown();
|
||||
}else{
|
||||
new NormalJoinListener();
|
||||
|
||||
new NoPlayersOnlineCountdown();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setPreRunningState() {
|
||||
if(fightState != FightState.PRE_LEADER_SETUP) //TODO
|
||||
return;
|
||||
setFightState(FightState.PRE_RUNNING);
|
||||
Countdown.cancelAllTimers();
|
||||
|
||||
loadKits(Fight.getBlueTeam());
|
||||
loadKits(Fight.getRedTeam());
|
||||
setAllPlayersGM(GameMode.SURVIVAL);
|
||||
Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!");
|
||||
|
||||
new PreRunningCountdown();
|
||||
|
||||
Fight.replaceSync();
|
||||
|
||||
new WinconditionAllDead();
|
||||
new WinconditionCaptainDead();
|
||||
new WinconditionPumpkinTechKO();
|
||||
@ -116,35 +70,117 @@ public class FightSystem extends JavaPlugin {
|
||||
new WinconditionPercentSystem();
|
||||
new WinconditionRelativePercent();
|
||||
new WinconditionPoints();
|
||||
new WinconditionTimeout();
|
||||
new WinconditionHeartRatioTimeout();
|
||||
new WinconditionTechKO();
|
||||
|
||||
if(Config.event()){
|
||||
new EventTeamOffWincondition();
|
||||
Objects.requireNonNull(getCommand("leave")).setExecutor(new LeaveCommand());
|
||||
Objects.requireNonNull(getCommand("kit")).setExecutor(new KitCommand());
|
||||
Objects.requireNonNull(getCommand("remove")).setExecutor(new RemoveCommand());
|
||||
Objects.requireNonNull(getCommand("accept")).setExecutor(new AcceptCommand());
|
||||
Objects.requireNonNull(getCommand("decline")).setExecutor(new DeclineCommand());
|
||||
Objects.requireNonNull(getCommand("invite")).setExecutor(new InviteCommand());
|
||||
Objects.requireNonNull(getCommand("ready")).setExecutor(new ReadyCommand());
|
||||
Objects.requireNonNull(getCommand("ak")).setExecutor(new AkCommand());
|
||||
Objects.requireNonNull(getCommand("leader")).setExecutor(new LeaderCommand());
|
||||
Objects.requireNonNull(getCommand("lockschem")).setExecutor(new LockschemCommand());
|
||||
|
||||
mainCountdown = new NoPlayersOnlineCountdown();
|
||||
|
||||
if(Config.event()) {
|
||||
Objects.requireNonNull(getCommand("invite")).setExecutor(new EventDummyCommand());
|
||||
Objects.requireNonNull(getCommand("ready")).setExecutor(new EventDummyCommand());
|
||||
Objects.requireNonNull(getCommand("ak")).setExecutor(new EventDummyCommand());
|
||||
Objects.requireNonNull(getCommand("leader")).setExecutor(new EventDummyCommand());
|
||||
|
||||
setPreSchemState();
|
||||
}else if(Config.test()){
|
||||
Bukkit.getScheduler().runTaskLater(this, Fight.getBlueTeam()::pasteDummy, 0);
|
||||
Bukkit.getScheduler().runTaskLater(this, Fight.getRedTeam()::pasteDummy, 0);
|
||||
|
||||
setPreSchemState();
|
||||
setPostSchemState();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setPreSchemState() {
|
||||
if(fightState != FightState.PRE_LEADER_SETUP)
|
||||
throw new SecurityException(fightState.name());
|
||||
setFightState(FightState.PRE_SCHEM_SETUP);
|
||||
|
||||
mainCountdown = new SetupOverCountdown();
|
||||
}
|
||||
|
||||
public static void setPostSchemState() {
|
||||
if(fightState != FightState.PRE_SCHEM_SETUP)
|
||||
throw new SecurityException(fightState.name());
|
||||
setFightState(FightState.POST_SCHEM_SETUP);
|
||||
|
||||
if(!Config.test()){
|
||||
TechHider.start();
|
||||
Fight.getBlueTeam().pasteSchematic();
|
||||
Fight.getRedTeam().pasteSchematic();
|
||||
}
|
||||
|
||||
if(Config.event())
|
||||
mainCountdown = new EventStartCountdown();
|
||||
else if(Config.test())
|
||||
mainCountdown = null;
|
||||
else
|
||||
mainCountdown = new SetupOverCountdown();
|
||||
}
|
||||
|
||||
public static void setPreRunningState() {
|
||||
if(fightState != FightState.POST_SCHEM_SETUP)
|
||||
throw new SecurityException(fightState.name());
|
||||
setFightState(FightState.PRE_RUNNING);
|
||||
|
||||
loadKits(Fight.getBlueTeam());
|
||||
loadKits(Fight.getRedTeam());
|
||||
setAllPlayersGM(GameMode.SURVIVAL);
|
||||
Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!");
|
||||
|
||||
mainCountdown = new PreRunningCountdown();
|
||||
|
||||
Fight.replaceSync();
|
||||
|
||||
if(Config.event())
|
||||
new EventTeamOffWincondition();
|
||||
}
|
||||
|
||||
public static void setRunningState() {
|
||||
if(fightState != FightState.PRE_RUNNING)
|
||||
return;
|
||||
throw new SecurityException(fightState.name());
|
||||
setFightState(FightState.RUNNING);
|
||||
Countdown.cancelAllTimers();
|
||||
|
||||
setAllPlayersGM(GameMode.SURVIVAL);
|
||||
|
||||
new WinconditionTimeout();
|
||||
new WinconditionHeartRatioTimeout();
|
||||
new WinconditionEntern();
|
||||
new WinconditionTechKO();
|
||||
if(Config.Entern)
|
||||
new EnternCountdown();
|
||||
|
||||
WaterRemover.init();
|
||||
|
||||
Bukkit.broadcastMessage(PREFIX + "§aArena freigegeben!");
|
||||
}
|
||||
|
||||
public static void setEntern() {
|
||||
if(fightState != FightState.RUNNING)
|
||||
throw new SecurityException(fightState.name());
|
||||
setFightState(FightState.ENTERN);
|
||||
|
||||
final List<Pair<Integer, Integer>> chunksBlue = TechHider.prepareChunkReload(Fight.getBlueTeam().getPlayers().iterator().next().getPlayer());
|
||||
final List<Pair<Integer, Integer>> chunksRed = TechHider.prepareChunkReload(Fight.getRedTeam().getPlayers().iterator().next().getPlayer());
|
||||
IFightSystem.setEntern(true);
|
||||
for(FightPlayer player : Fight.getBlueTeam().getPlayers()){
|
||||
TechHider.reloadChunks(player.getPlayer(), chunksBlue);
|
||||
}
|
||||
for(FightPlayer player : Fight.getRedTeam().getPlayers()){
|
||||
TechHider.reloadChunks(player.getPlayer(), chunksRed);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setSpectateState(FightTeam winFightTeam) {
|
||||
if(fightState != FightState.RUNNING && fightState != FightState.PRE_RUNNING)
|
||||
return;
|
||||
if(!fightState.ingame())
|
||||
throw new SecurityException(fightState.name());
|
||||
setFightState(FightState.SPECTATE);
|
||||
Countdown.cancelAllTimers();
|
||||
|
||||
setAllPlayersGM(GameMode.SPECTATOR);
|
||||
Fight.getBlueTeam().teleportToSpawn();
|
||||
@ -176,18 +212,6 @@ public class FightSystem extends JavaPlugin {
|
||||
FightSystem.fightTime = fightTime;
|
||||
}
|
||||
|
||||
public static void setEntern(boolean entern) {
|
||||
final List<Pair<Integer, Integer>> chunksBlue = TechHider.prepareChunkReload(Fight.getBlueTeam().getPlayers().iterator().next().getPlayer());
|
||||
final List<Pair<Integer, Integer>> chunksRed = TechHider.prepareChunkReload(Fight.getRedTeam().getPlayers().iterator().next().getPlayer());
|
||||
IFightSystem.setEntern(entern);
|
||||
for(FightPlayer player : Fight.getBlueTeam().getPlayers()){
|
||||
TechHider.reloadChunks(player.getPlayer(), chunksBlue);
|
||||
}
|
||||
for(FightPlayer player : Fight.getRedTeam().getPlayers()){
|
||||
TechHider.reloadChunks(player.getPlayer(), chunksRed);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setEventLeiter(Player el){
|
||||
IFightSystem.setEventLeiter(el);
|
||||
}
|
||||
@ -216,16 +240,17 @@ public class FightSystem extends JavaPlugin {
|
||||
return fightTime;
|
||||
}
|
||||
|
||||
public static boolean isEntern() {
|
||||
return IFightSystem.isEntern();
|
||||
}
|
||||
|
||||
public static void shutdown(String reason){
|
||||
IFightSystem.shutdown(reason);
|
||||
}
|
||||
|
||||
public static void registerStateDependent(StateDependent stateDependent){
|
||||
stateDependentFeatures.put(stateDependent, false);
|
||||
if(stateDependent.enabled().isEmpty())
|
||||
return;
|
||||
boolean enabled = stateDependent.enabled().contains(fightState);
|
||||
stateDependentFeatures.put(stateDependent, enabled);
|
||||
if(enabled)
|
||||
stateDependent.enable();
|
||||
}
|
||||
|
||||
private static void loadKits(FightTeam team){
|
||||
@ -250,6 +275,8 @@ public class FightSystem extends JavaPlugin {
|
||||
|
||||
private static void setFightState(FightState state){
|
||||
fightState = state;
|
||||
if(mainCountdown != null)
|
||||
mainCountdown.disable();
|
||||
postStateChange();
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ public class AkCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
KitManager.saveInventory(args[1], player);
|
||||
} else if(args[0].equalsIgnoreCase("schemlist") && FightSystem.getFightState() == FightState.SETUP) {
|
||||
} else if(args[0].equalsIgnoreCase("schemlist") && FightSystem.getFightState() == FightState.PRE_SCHEM_SETUP) {
|
||||
try {
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||
if(fightTeam != null && fightTeam.getFightPlayer(player).isLeader()) {
|
||||
|
@ -3,7 +3,6 @@ package de.steamwar.fightsystem.commands;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.kit.Kit;
|
||||
import de.steamwar.fightsystem.kit.KitManager;
|
||||
@ -18,7 +17,7 @@ public class Commands {
|
||||
}
|
||||
|
||||
static boolean checkSetup(Player p){
|
||||
if(FightSystem.getFightState() != FightState.SETUP){
|
||||
if(FightSystem.getFightState().setup()){
|
||||
p.sendMessage(FightSystem.PREFIX + "§cDer Kampf hat bereits begonnen!");
|
||||
return true;
|
||||
}
|
||||
|
@ -9,17 +9,12 @@ import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public abstract class Countdown {
|
||||
|
||||
private static final ArrayList<Countdown> countdowns = new ArrayList<>();
|
||||
|
||||
private int time;
|
||||
private final int taskID;
|
||||
private final BukkitTask task;
|
||||
private final Sound sound;
|
||||
private final boolean level;
|
||||
|
||||
@ -30,10 +25,8 @@ public abstract class Countdown {
|
||||
this.time = time;
|
||||
this.sound = getSound(sound);
|
||||
this.level = level;
|
||||
countdowns.add(this);
|
||||
|
||||
BukkitScheduler bukkitScheduler = Bukkit.getServer().getScheduler();
|
||||
this.taskID = bukkitScheduler.scheduleSyncRepeatingTask(FightSystem.getPlugin(), this::count, 0, 20);
|
||||
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::count, 0, 20);
|
||||
}
|
||||
|
||||
public static Sound getSound(SWSound sound){
|
||||
@ -56,16 +49,8 @@ public abstract class Countdown {
|
||||
}
|
||||
}
|
||||
|
||||
public static void cancelAllTimers() {
|
||||
while (!countdowns.isEmpty()) {
|
||||
countdowns.get(0).cancelTimer();
|
||||
}
|
||||
}
|
||||
|
||||
public static void cancelTimerType(Class<? extends Countdown> type) {
|
||||
for(int i = countdowns.size() - 1; i >= 0; i--)
|
||||
if(type.isInstance(countdowns.get(i)))
|
||||
countdowns.get(i).cancelTimer();
|
||||
public void disable() {
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
private void broadcast(String message){
|
||||
@ -95,7 +80,7 @@ public abstract class Countdown {
|
||||
if(this.sound != null)
|
||||
Fight.playSound(this.sound, 100.0F, 2.0F);
|
||||
|
||||
cancelTimer();
|
||||
disable();
|
||||
countdownFinished();
|
||||
break;
|
||||
default:
|
||||
@ -108,15 +93,6 @@ public abstract class Countdown {
|
||||
}
|
||||
|
||||
void onTime(int time){
|
||||
//Unused
|
||||
}
|
||||
|
||||
public void cancelTimer() {
|
||||
try {
|
||||
Bukkit.getScheduler().cancelTask(this.taskID);
|
||||
} catch (AssertionError ex) {
|
||||
FightSystem.getPlugin().getLogger().log(Level.SEVERE, "Could not cancel timer", ex);
|
||||
}
|
||||
countdowns.remove(this);
|
||||
//Implemented in some countdowns
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public class EnternCountdown extends Countdown {
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
FightSystem.setEntern(true);
|
||||
FightSystem.setEntern();
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aEntern ist nun erlaubt!");
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,10 @@ package de.steamwar.fightsystem.fight;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.IFightSystem;
|
||||
import de.steamwar.fightsystem.kit.KitManager;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.utils.ColorConverter;
|
||||
import de.steamwar.fightsystem.utils.FightScoreboard;
|
||||
import de.steamwar.fightsystem.utils.ItemBuilder;
|
||||
@ -28,10 +28,7 @@ import org.bukkit.scoreboard.NameTagVisibility;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class FightTeam implements IFightTeam{
|
||||
@ -83,28 +80,6 @@ public class FightTeam implements IFightTeam{
|
||||
team.setAllowFriendlyFire(false);
|
||||
}
|
||||
|
||||
private void setTeamColor(Team team, ChatColor color){
|
||||
switch(Core.getVersion()){
|
||||
case 15:
|
||||
FightTeam_15.setTeamColor(team, color);
|
||||
break;
|
||||
case 14:
|
||||
FightTeam_14.setTeamColor(team, color);
|
||||
break;
|
||||
case 10:
|
||||
FightTeam_10.setTeamColor(team, color);
|
||||
break;
|
||||
case 9:
|
||||
FightTeam_9.setTeamColor(team, color);
|
||||
break;
|
||||
case 8:
|
||||
FightTeam_8.setTeamColor(team, color);
|
||||
break;
|
||||
default:
|
||||
FightTeam_12.setTeamColor(team, color);
|
||||
}
|
||||
}
|
||||
|
||||
public final int getCornerX() {
|
||||
return cornerX;
|
||||
}
|
||||
@ -183,24 +158,14 @@ public class FightTeam implements IFightTeam{
|
||||
|
||||
public void removePlayer(Player player) {
|
||||
FightPlayer fightPlayer = getFightPlayer(player);
|
||||
if(fightPlayer == null)
|
||||
return;
|
||||
|
||||
final List<Pair<Integer, Integer>> chunksToReload = TechHider.prepareChunkReload(player);
|
||||
players.remove(fightPlayer);
|
||||
team.removeEntry(player.getName());
|
||||
fightPlayer.getPlayer().getInventory().clear();
|
||||
if(fightPlayer.equals(leader) && FightSystem.getFightState() == FightState.SETUP){
|
||||
this.leader = null;
|
||||
if(!players.isEmpty()) {
|
||||
setLeader(players.iterator().next());
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §e" + leader.getPlayer().getName() + " §aist nun Leader von Team " + getColoredName() + "§a!");
|
||||
}else if(!Config.event()){
|
||||
FightSystem.shutdown(FightSystem.PREFIX + "§cTeam " + getColoredName() + " §chat keine Spieler mehr.\n Arena schließt...");
|
||||
}else{
|
||||
|
||||
if(fightPlayer.equals(leader) && FightSystem.getFightState().setup())
|
||||
setLeader(null);
|
||||
}
|
||||
}
|
||||
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
player.teleport(Config.SpecSpawn);
|
||||
@ -222,8 +187,15 @@ public class FightTeam implements IFightTeam{
|
||||
|
||||
public void setLeader(FightPlayer leader) {
|
||||
this.leader = leader;
|
||||
if (leader == null)
|
||||
if (leader == null){
|
||||
if(!players.isEmpty()) {
|
||||
setLeader(players.iterator().next());
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §e" + this.leader.getPlayer().getName() + " §aist nun Leader von Team " + getColoredName() + "§a!");
|
||||
}else if(!Config.event()){
|
||||
FightSystem.shutdown(FightSystem.PREFIX + "§cTeam " + getColoredName() + " §chat keine Spieler mehr.\n Arena schließt...");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
leader.setKit(KitManager.getKitByName(Config.LeaderDefault));
|
||||
Inventory inventory = leader.getPlayer().getInventory();
|
||||
@ -231,11 +203,14 @@ public class FightTeam implements IFightTeam{
|
||||
inventory.setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
|
||||
else
|
||||
inventory.setItem(1, new ItemBuilder(Material.AIR).build());
|
||||
|
||||
if(!Config.event()){
|
||||
inventory.setItem(2, new ItemBuilder(Material.PAPER).removeAllAttributs().setDisplayName("§eSpieler einladen").build());
|
||||
inventory.setItem(3, new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).removeAllAttributs().setDisplayName("§cSpieler rauswerfen").build());
|
||||
inventory.setItem(4, new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
|
||||
}
|
||||
|
||||
if(!Config.test() && FightSystem.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());
|
||||
}
|
||||
|
||||
@ -247,28 +222,35 @@ public class FightTeam implements IFightTeam{
|
||||
return ready;
|
||||
}
|
||||
|
||||
private void pasteSchematic(){
|
||||
public void pasteSchematic(){
|
||||
FreezeWorld freezer = new FreezeWorld();
|
||||
DyeColor c = ColorConverter.chat2dye(color);
|
||||
EditSession e;
|
||||
try {
|
||||
switch(Core.getVersion()){
|
||||
case 15:
|
||||
e = FightTeam_15.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate);
|
||||
FightTeam_15.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
||||
break;
|
||||
case 14:
|
||||
e = FightTeam_14.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate);
|
||||
FightTeam_14.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
||||
break;
|
||||
case 10:
|
||||
e = FightTeam_10.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate);
|
||||
FightTeam_10.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
||||
break;
|
||||
case 9:
|
||||
e = FightTeam_9.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate);
|
||||
FightTeam_9.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
||||
break;
|
||||
case 8:
|
||||
e = FightTeam_8.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate);
|
||||
FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
||||
break;
|
||||
default:
|
||||
e = FightTeam_12.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate);
|
||||
FightTeam_12.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
||||
}
|
||||
} catch (Schematic.WrongVersionException ex) {
|
||||
broadcast(FightSystem.PREFIX + "§cDie gewählte Schematic kann nicht in dieser Version geladen werden");
|
||||
@ -278,41 +260,16 @@ public class FightTeam implements IFightTeam{
|
||||
broadcast(FightSystem.PREFIX + "§cFehler beim Pasten der Schematic");
|
||||
throw new SecurityException("Error pasting arena in schematic", ex);
|
||||
}
|
||||
replaceTeamColor(e);
|
||||
HandlerList.unregisterAll(freezer);
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), this::teleportToSpawn,40);
|
||||
}
|
||||
|
||||
private void replaceTeamColor(EditSession e){
|
||||
DyeColor c = ColorConverter.chat2dye(color);
|
||||
|
||||
switch(Core.getVersion()){
|
||||
case 15:
|
||||
FightTeam_15.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
||||
break;
|
||||
case 14:
|
||||
FightTeam_14.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
||||
break;
|
||||
case 10:
|
||||
FightTeam_10.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
||||
break;
|
||||
case 9:
|
||||
FightTeam_9.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
||||
break;
|
||||
case 8:
|
||||
FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
||||
break;
|
||||
default:
|
||||
FightTeam_12.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
||||
}
|
||||
}
|
||||
|
||||
public void pasteDummy(){
|
||||
List<Schematic> publics = Schematic.getSchemsOfType(0, Config.SchematicType);
|
||||
if(publics.isEmpty())
|
||||
return;
|
||||
|
||||
schematic = publics.get(0);
|
||||
schematic = publics.get(new Random().nextInt(publics.size()));
|
||||
pasteSchematic();
|
||||
}
|
||||
|
||||
@ -326,9 +283,7 @@ public class FightTeam implements IFightTeam{
|
||||
if(Config.test())
|
||||
pasteSchematic();
|
||||
else if(Fight.getOpposite(this).hasSchematic()){
|
||||
TechHider.start();
|
||||
pasteSchematic();
|
||||
Fight.getOpposite(this).pasteSchematic();
|
||||
FightSystem.setPostSchemState();
|
||||
}
|
||||
}
|
||||
|
||||
@ -348,35 +303,14 @@ public class FightTeam implements IFightTeam{
|
||||
if(ready) {
|
||||
l.getInventory().setItem(4, new ItemBuilder(SWItem.getDye(8), (short) 8).removeAllAttributs().addEnchantment(Enchantment.DURABILITY,1 ).setDisplayName("§aBereit").build());
|
||||
broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit!");
|
||||
if(Fight.getOpposite(this).isReady() || Config.test()) {
|
||||
if(Fight.getOpposite(this).isReady() || Config.test())
|
||||
FightSystem.setPreRunningState();
|
||||
}
|
||||
} else {
|
||||
l.getInventory().setItem(4, new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
|
||||
broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit!");
|
||||
}
|
||||
}
|
||||
|
||||
void replaceSync(boolean replace, Material target, Material replacement) {
|
||||
if(!replace)
|
||||
return;
|
||||
|
||||
World world = Bukkit.getWorlds().get(0);
|
||||
Location minPoint = new Location(world, cornerX, cornerY, cornerZ);
|
||||
Location maxPoint = new Location(world, (cornerX + Config.SchemsizeX), (cornerY + Config.SchemsizeY), (cornerZ + Config.SchemsizeZ));
|
||||
|
||||
for(int x = minPoint.getBlockX(); x <= maxPoint.getBlockX(); x++) {
|
||||
for(int z = minPoint.getBlockZ(); z <= maxPoint.getBlockZ(); z++) {
|
||||
for(int y = minPoint.getBlockY(); y <= maxPoint.getBlockY(); y++) {
|
||||
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
if(block.getType() == target)
|
||||
block.setType(replacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Set<Player> getInvited() {
|
||||
return invited;
|
||||
}
|
||||
@ -416,6 +350,48 @@ public class FightTeam implements IFightTeam{
|
||||
return currentHearts / maximumHearts;
|
||||
}
|
||||
|
||||
void replaceSync(boolean replace, Material target, Material replacement) {
|
||||
if(!replace)
|
||||
return;
|
||||
|
||||
World world = Bukkit.getWorlds().get(0);
|
||||
Location minPoint = new Location(world, cornerX, cornerY, cornerZ);
|
||||
Location maxPoint = new Location(world, (cornerX + Config.SchemsizeX), (cornerY + Config.SchemsizeY), (cornerZ + Config.SchemsizeZ));
|
||||
|
||||
for(int x = minPoint.getBlockX(); x <= maxPoint.getBlockX(); x++) {
|
||||
for(int z = minPoint.getBlockZ(); z <= maxPoint.getBlockZ(); z++) {
|
||||
for(int y = minPoint.getBlockY(); y <= maxPoint.getBlockY(); y++) {
|
||||
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
if(block.getType() == target)
|
||||
block.setType(replacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setTeamColor(Team team, ChatColor color){
|
||||
switch(Core.getVersion()){
|
||||
case 15:
|
||||
FightTeam_15.setTeamColor(team, color);
|
||||
break;
|
||||
case 14:
|
||||
FightTeam_14.setTeamColor(team, color);
|
||||
break;
|
||||
case 10:
|
||||
FightTeam_10.setTeamColor(team, color);
|
||||
break;
|
||||
case 9:
|
||||
FightTeam_9.setTeamColor(team, color);
|
||||
break;
|
||||
case 8:
|
||||
FightTeam_8.setTeamColor(team, color);
|
||||
break;
|
||||
default:
|
||||
FightTeam_12.setTeamColor(team, color);
|
||||
}
|
||||
}
|
||||
|
||||
private static class FreezeWorld implements Listener {
|
||||
private FreezeWorld(){
|
||||
Bukkit.getPluginManager().registerEvents(this, IFightSystem.getPlugin());
|
||||
|
@ -17,7 +17,7 @@ import java.util.EnumSet;
|
||||
public class EventJoinListener extends BasicListener {
|
||||
|
||||
public EventJoinListener() {
|
||||
super(EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP));
|
||||
super(Config.event() ? EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP) : EnumSet.noneOf(FightState.class));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -1,5 +1,6 @@
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -17,7 +18,7 @@ import java.util.EnumSet;
|
||||
public class FreezeWorldStateListener extends BasicListener {
|
||||
|
||||
public FreezeWorldStateListener() {
|
||||
super(EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP, FightState.PRE_RUNNING, FightState.SPECTATE));
|
||||
super(Config.test() ? EnumSet.noneOf(FightState.class) : EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP, FightState.PRE_RUNNING, FightState.SPECTATE));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -1,8 +1,7 @@
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.countdown.NoPlayersOnlineCountdown;
|
||||
import de.steamwar.fightsystem.countdown.SetupOverCountdown;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
@ -15,7 +14,7 @@ import java.util.EnumSet;
|
||||
public class NormalJoinListener extends BasicListener {
|
||||
|
||||
public NormalJoinListener() {
|
||||
super(EnumSet.of(FightState.PRE_LEADER_SETUP));
|
||||
super(Config.event() || Config.test() ? EnumSet.noneOf(FightState.class) : EnumSet.of(FightState.PRE_LEADER_SETUP));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -33,8 +32,7 @@ public class NormalJoinListener extends BasicListener {
|
||||
|
||||
if(Fight.getRedTeam().hasTeamLeader() && Fight.getBlueTeam().hasTeamLeader()
|
||||
&& (Fight.getRedTeam().getLeader().getPlayer() == player || Fight.getBlueTeam().getLeader().getPlayer() == player)) {
|
||||
Countdown.cancelTimerType(NoPlayersOnlineCountdown.class);
|
||||
new SetupOverCountdown();
|
||||
FightSystem.setPreSchemState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.GameMode;
|
||||
@ -13,12 +13,18 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class PlayerMoveListener extends BasicListener {
|
||||
|
||||
private static final String DENY_ARENA = "§cDu darfst die Arena nicht verlassen";
|
||||
private static final String DENY_TEAM = "§cDu darfst nicht zu den Teams";
|
||||
private static final String DENY_ENTERN = "§cDu darfst nicht entern";
|
||||
|
||||
public PlayerMoveListener() {
|
||||
super(EnumSet.allOf(FightState.class));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void teamAreas(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
@ -28,6 +34,7 @@ public class PlayerMoveListener extends BasicListener {
|
||||
Location to = event.getTo();
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||
|
||||
assert to != null;
|
||||
boolean inArenaY = to.getY() + 1.8 <= Config.upperArenaBorder;
|
||||
|
||||
boolean inBlueArea = inArenaY && Region.isIn2DRange(to, Config.TeamBlueCornerX, Config.TeamBlueCornerZ, Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic);
|
||||
@ -37,7 +44,7 @@ public class PlayerMoveListener extends BasicListener {
|
||||
if(fightTeam == null)
|
||||
reset(event, DENY_TEAM);
|
||||
}else if(fightTeam != null && (
|
||||
!FightSystem.isEntern() || player.getGameMode() == GameMode.SPECTATOR)){
|
||||
FightSystem.getFightState() != FightState.ENTERN || player.getGameMode() == GameMode.SPECTATOR)){
|
||||
reset(event, DENY_ENTERN);
|
||||
}
|
||||
}
|
||||
@ -48,6 +55,7 @@ public class PlayerMoveListener extends BasicListener {
|
||||
Location to = event.getTo();
|
||||
|
||||
//Check in Arena
|
||||
assert to != null;
|
||||
if(!Region.isIn2DRegion(to, Config.ArenaMinX, Config.ArenaMinZ, Config.ArenaMaxX, Config.ArenaMaxZ)){
|
||||
reset(event, DENY_ARENA);
|
||||
return;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.countdown.NoPlayersOnlineCountdown;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
@ -15,8 +15,12 @@ import java.util.EnumSet;
|
||||
|
||||
public class TestListener extends BasicListener {
|
||||
|
||||
private NoPlayersOnlineCountdown countdown;
|
||||
|
||||
public TestListener() {
|
||||
super(EnumSet.allOf(FightState.class));
|
||||
super(Config.test() ? EnumSet.allOf(FightState.class) : EnumSet.noneOf(FightState.class));
|
||||
if(Config.test())
|
||||
countdown = new NoPlayersOnlineCountdown();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -28,7 +32,10 @@ public class TestListener extends BasicListener {
|
||||
player.sendMessage(FightSystem.PREFIX + "§7Werde zum Teamleader mit §8/§eleader");
|
||||
}
|
||||
|
||||
Countdown.cancelTimerType(NoPlayersOnlineCountdown.class);
|
||||
if(countdown != null){
|
||||
countdown.disable();
|
||||
countdown = null;
|
||||
}
|
||||
|
||||
PermissionAttachment attachment = player.addAttachment(FightSystem.getPlugin());
|
||||
attachment.setPermission("fawe.permpack.basic", true);
|
||||
|
@ -1,8 +1,8 @@
|
||||
package de.steamwar.fightsystem.states;
|
||||
|
||||
public enum FightState {
|
||||
PRE_LEADER_SETUP(true, true, false, false), //Can be skipped
|
||||
PRE_SCHEM_SETUP(true, true, false, false), //Can be skipped
|
||||
PRE_LEADER_SETUP(true, true, false, false),
|
||||
PRE_SCHEM_SETUP(true, true, false, false),
|
||||
POST_SCHEM_SETUP(true, true, false, false),
|
||||
PRE_RUNNING(false, false, true, false),
|
||||
RUNNING(false, false, true, true),
|
||||
|
@ -71,7 +71,7 @@ public class FightScoreboard {
|
||||
objective.getScore("§7Zeit: §a" + fightTime + "s").setScore(3);
|
||||
}
|
||||
if (Config.Entern)
|
||||
objective.getScore("§7Entern: " + (FightSystem.isEntern() ? "§aja" : "§cnein")).setScore(2);
|
||||
objective.getScore("§7Entern: " + (FightSystem.getFightState() == FightState.ENTERN ? "§aja" : "§cnein")).setScore(2);
|
||||
|
||||
if(fullScoreboard.contains(FightSystem.getFightState())){
|
||||
if (Config.PercentSystem){
|
||||
|
@ -1,17 +1,31 @@
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class EventTeamOffWincondition {
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class EventTeamOffWincondition extends Wincondition {
|
||||
|
||||
public EventTeamOffWincondition(){
|
||||
super(Config.event(), EnumSet.of(FightState.PRE_RUNNING));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
teamOff(Fight.getBlueTeam());
|
||||
teamOff(Fight.getRedTeam());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
//Team off is a on time trigger
|
||||
}
|
||||
|
||||
private void teamOff(FightTeam team){
|
||||
if(team.allPlayersOut()){
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + team.getColoredName() + " §6ist Offline!");
|
||||
|
@ -1,15 +1,33 @@
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
abstract class ListenerWincondition implements Listener {
|
||||
import java.util.Set;
|
||||
|
||||
void init(boolean condition){
|
||||
if(!condition)
|
||||
return;
|
||||
abstract class ListenerWincondition extends Wincondition implements Listener {
|
||||
|
||||
ListenerWincondition(boolean condition, Set<FightState> enabled){
|
||||
//If the condition is not met, never enable
|
||||
super(condition, enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the state dependent object
|
||||
*/
|
||||
@Override
|
||||
public void enable(){
|
||||
Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin());
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the state dependent object
|
||||
*/
|
||||
@Override
|
||||
public void disable(){
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,19 @@
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
abstract class PlayerWincondition extends ListenerWincondition {
|
||||
|
||||
boolean isTarget(Player player){
|
||||
if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING)
|
||||
return false;
|
||||
PlayerWincondition(boolean condition) {
|
||||
super(condition, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING, FightState.ENTERN));
|
||||
}
|
||||
|
||||
boolean isTarget(Player player){
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||
if(fightTeam == null)
|
||||
return false;
|
||||
|
@ -0,0 +1,23 @@
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
abstract class Wincondition implements StateDependent {
|
||||
|
||||
private final Set<FightState> enabled;
|
||||
|
||||
Wincondition(boolean condition, Set<FightState> enabled){
|
||||
this.enabled = enabled;
|
||||
if(condition)
|
||||
FightSystem.registerStateDependent(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<FightState> enabled(){
|
||||
return enabled;
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
public class WinconditionAllDead extends PlayerWincondition {
|
||||
|
||||
public WinconditionAllDead(){
|
||||
init(Config.AllDead);
|
||||
super(Config.AllDead);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -13,7 +13,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
public class WinconditionCaptainDead extends PlayerWincondition {
|
||||
|
||||
public WinconditionCaptainDead(){
|
||||
init(Config.CaptainDead);
|
||||
super(Config.CaptainDead);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -1,13 +0,0 @@
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.countdown.EnternCountdown;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
|
||||
public class WinconditionEntern {
|
||||
public WinconditionEntern() {
|
||||
if(!Config.Entern)
|
||||
return;
|
||||
|
||||
new EnternCountdown();
|
||||
}
|
||||
}
|
@ -4,14 +4,21 @@ import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
|
||||
public class WinconditionHeartRatioTimeout {
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class WinconditionHeartRatioTimeout extends Wincondition {
|
||||
|
||||
private TimeOverCountdown countdown;
|
||||
|
||||
public WinconditionHeartRatioTimeout() {
|
||||
if(!Config.HeartRatioTimeout)
|
||||
return;
|
||||
super(Config.HeartRatioTimeout, EnumSet.of(FightState.RUNNING, FightState.ENTERN));
|
||||
}
|
||||
|
||||
new TimeOverCountdown(() -> {
|
||||
@Override
|
||||
public void enable() {
|
||||
countdown = new TimeOverCountdown(() -> {
|
||||
double blueHeartRatio = Fight.getBlueTeam().getHeartRatio();
|
||||
double redHeartRatio = Fight.getRedTeam().getHeartRatio();
|
||||
|
||||
@ -23,4 +30,9 @@ public class WinconditionHeartRatioTimeout {
|
||||
FightSystem.setSpectateState(null);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable(){
|
||||
countdown.disable();
|
||||
}
|
||||
}
|
@ -1,14 +1,16 @@
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class WinconditionPercentSystem extends ListenerWincondition {
|
||||
|
||||
private static double bluePercent = 0D;
|
||||
@ -17,12 +19,10 @@ public class WinconditionPercentSystem extends ListenerWincondition {
|
||||
private static int blueDestroyedBlocks;
|
||||
private static int redDestroyedBlocks;
|
||||
|
||||
private static int schematicSize;
|
||||
private static final int schematicSize = Math.abs(Config.SchemsizeX * Config.SchemsizeY * Config.SchemsizeZ);
|
||||
|
||||
public WinconditionPercentSystem() {
|
||||
init(Config.PercentSystem);
|
||||
|
||||
schematicSize = Math.abs(Config.SchemsizeX * Config.SchemsizeY * Config.SchemsizeZ);
|
||||
super(Config.PercentSystem, EnumSet.of(FightState.RUNNING, FightState.ENTERN));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -5,6 +5,7 @@ import de.steamwar.fightsystem.FightSystem;
|
||||
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 org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -15,15 +16,38 @@ public class WinconditionPoints extends PlayerWincondition {
|
||||
|
||||
private static TeamPoints blue;
|
||||
private static TeamPoints red;
|
||||
private TimeOverCountdown countdown;
|
||||
|
||||
public WinconditionPoints(){
|
||||
if(!Config.Points)
|
||||
return;
|
||||
super(Config.Points);
|
||||
}
|
||||
|
||||
init(true);
|
||||
public static TeamPoints getRed(){
|
||||
return red;
|
||||
}
|
||||
|
||||
public static TeamPoints getBlue(){
|
||||
return blue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
super.enable();
|
||||
blue = new TeamPoints(Fight.getRedTeam(), WinconditionRelativePercent.getBlue(), WinconditionRelativePercent.getRed());
|
||||
red = new TeamPoints(Fight.getBlueTeam(), WinconditionRelativePercent.getRed(), WinconditionRelativePercent.getBlue());
|
||||
new TimeOverCountdown(this::fightEnds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
super.disable();
|
||||
countdown.disable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateChange(FightState state){
|
||||
if(state == FightState.RUNNING){
|
||||
countdown = new TimeOverCountdown(this::fightEnds);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -54,14 +78,6 @@ public class WinconditionPoints extends PlayerWincondition {
|
||||
|
||||
}
|
||||
|
||||
public static TeamPoints getRed(){
|
||||
return red;
|
||||
}
|
||||
|
||||
public static TeamPoints getBlue(){
|
||||
return blue;
|
||||
}
|
||||
|
||||
private void fightEnds(){
|
||||
if(red.getPoints() > blue.getPoints())
|
||||
FightSystem.setSpectateState(blue.enemy);
|
||||
@ -78,7 +94,7 @@ public class WinconditionPoints extends PlayerWincondition {
|
||||
return red;
|
||||
}
|
||||
|
||||
public static class TeamPoints extends PlayerWincondition {
|
||||
public static class TeamPoints {
|
||||
private final FightTeam enemy;
|
||||
private final WinconditionRelativePercent.TeamPercent enemyPercent;
|
||||
private final double factor;
|
||||
@ -89,13 +105,12 @@ public class WinconditionPoints extends PlayerWincondition {
|
||||
TeamPoints(FightTeam enemy, WinconditionRelativePercent.TeamPercent ownPercent, WinconditionRelativePercent.TeamPercent enemyPercent){
|
||||
this.enemy = enemy;
|
||||
this.enemyPercent = enemyPercent;
|
||||
init(true);
|
||||
points = 0;
|
||||
|
||||
if(enemyPercent.getBlockCount() < ownPercent.getBlockCount())
|
||||
this.factor = 10000; //Original mit 20 (20% = 0.2 ergeben 2000 Punkte
|
||||
else{
|
||||
double f = 10000 * ownPercent.getBlockCount() / enemyPercent.getBlockCount();
|
||||
double f = 10000.0 * ownPercent.getBlockCount() / enemyPercent.getBlockCount();
|
||||
|
||||
if(f > 10000)
|
||||
f = 10000;
|
||||
|
@ -4,23 +4,25 @@ import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public class WinconditionPumpkinTechKO {
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class WinconditionPumpkinTechKO extends Wincondition {
|
||||
|
||||
private static int teamRedPumpkins = -1;
|
||||
private static int teamBluePumpkins = -1;
|
||||
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||
private static final Material PUMPKIN_LANTERN = SWItem.getMaterial("JACK_O_LANTERN");
|
||||
private BukkitTask task;
|
||||
|
||||
public WinconditionPumpkinTechKO(){
|
||||
if(!Config.PumpkinTechKO)
|
||||
return;
|
||||
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), WinconditionPumpkinTechKO::recursiveCheck, 0, 200);
|
||||
super(Config.PumpkinTechKO, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING, FightState.ENTERN));
|
||||
}
|
||||
|
||||
public static int getTeamBluePumpkins() {
|
||||
@ -30,6 +32,16 @@ public class WinconditionPumpkinTechKO {
|
||||
return teamRedPumpkins;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
task = Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), WinconditionPumpkinTechKO::recursiveCheck, 0, 200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
private static void recursiveCheck(){
|
||||
teamRedPumpkins = getPumpkins(Config.TeamRedCornerX,
|
||||
Config.TeamRedCornerY,
|
||||
|
@ -4,15 +4,18 @@ import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class WinconditionRelativePercent{
|
||||
public class WinconditionRelativePercent extends Wincondition{
|
||||
|
||||
private static final Set<Material> ignoredBlocks;
|
||||
private static TeamPercent blue;
|
||||
@ -26,11 +29,7 @@ public class WinconditionRelativePercent{
|
||||
}
|
||||
|
||||
public WinconditionRelativePercent(){
|
||||
if(!Config.RelativePercent && !Config.Points)
|
||||
return;
|
||||
|
||||
blue = new TeamPercent(Fight.getBlueTeam());
|
||||
red = new TeamPercent(Fight.getRedTeam());
|
||||
super(Config.RelativePercent || Config.Points, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING));
|
||||
}
|
||||
|
||||
public static TeamPercent getBlue(){
|
||||
@ -41,19 +40,32 @@ public class WinconditionRelativePercent{
|
||||
return red;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
blue = new TeamPercent(Fight.getBlueTeam());
|
||||
red = new TeamPercent(Fight.getRedTeam());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
blue.task.cancel();
|
||||
red.task.cancel();
|
||||
}
|
||||
|
||||
public static class TeamPercent {
|
||||
private static final World world = Bukkit.getWorlds().get(0);
|
||||
private final FightTeam team;
|
||||
private final int blockCount;
|
||||
private final BukkitTask task;
|
||||
|
||||
private int currentBlocks;
|
||||
|
||||
TeamPercent(FightTeam team){
|
||||
private TeamPercent(FightTeam team){
|
||||
this.team = team;
|
||||
this.blockCount = currentBlocks();
|
||||
this.currentBlocks = blockCount;
|
||||
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), () -> {
|
||||
task = Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), () -> {
|
||||
currentBlocks = currentBlocks();
|
||||
checkPercentDefeat();
|
||||
}, 400, 400);
|
||||
@ -73,7 +85,7 @@ public class WinconditionRelativePercent{
|
||||
}
|
||||
|
||||
private int currentBlocks(){
|
||||
if(FightSystem.isEntern())
|
||||
if(FightSystem.getFightState() == FightState.ENTERN || FightSystem.getFightState() == FightState.SPECTATE)
|
||||
return currentBlocks;
|
||||
|
||||
int blocks = 0;
|
||||
|
@ -1,46 +1,61 @@
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.countdown.TechKOCountdown;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class WinconditionTechKO implements Listener {
|
||||
public class WinconditionTechKO extends ListenerWincondition {
|
||||
|
||||
private static final int TECH_KO_TIME_IN_S = 90;
|
||||
private static final int TECH_KO_HALF_TIME = TECH_KO_TIME_IN_S*10;
|
||||
public static final int TECH_KO_COUNTDOWN_TIME = TECH_KO_HALF_TIME/20;
|
||||
|
||||
private World world;
|
||||
private World world = Bukkit.getWorlds().get(0);
|
||||
private Map<Integer, Boolean> map = new HashMap<>(400);
|
||||
private double toggle;
|
||||
private int smallerZtime;
|
||||
private int biggerZtime;
|
||||
private double toggle = Config.SpecSpawn.getZ();
|
||||
private int smallerZtime = TECH_KO_HALF_TIME;
|
||||
private int biggerZtime = TECH_KO_HALF_TIME;
|
||||
private TechKOCountdown smallerZcountdown = null;
|
||||
private TechKOCountdown biggerZcountdown = null;
|
||||
private BukkitTask task;
|
||||
|
||||
//Works only for z-Axis fight direction for performance reasons
|
||||
/**
|
||||
* Works only for z-Axis fight direction for performance reasons
|
||||
*/
|
||||
public WinconditionTechKO(){
|
||||
if(!Config.TechKO)
|
||||
return;
|
||||
super(Config.TechKO, EnumSet.of(FightState.RUNNING, FightState.SPECTATE));
|
||||
}
|
||||
|
||||
world = Bukkit.getWorlds().get(0);
|
||||
toggle = Config.SpecSpawn.getZ();
|
||||
smallerZtime=TECH_KO_HALF_TIME;
|
||||
biggerZtime=TECH_KO_HALF_TIME;
|
||||
@Override
|
||||
public void enable() {
|
||||
super.enable();
|
||||
task = Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), this::run, 1, 1);
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), this::run, 1, 1);
|
||||
Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin());
|
||||
@Override
|
||||
public void disable() {
|
||||
super.disable();
|
||||
smallerZcountdown.disable();
|
||||
biggerZcountdown.disable();
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDead(EntityExplodeEvent event){
|
||||
map.remove(event.getEntity().getEntityId());
|
||||
}
|
||||
|
||||
private void run(){
|
||||
@ -57,14 +72,14 @@ public class WinconditionTechKO implements Listener {
|
||||
}
|
||||
|
||||
if(smallerZtime == TECH_KO_HALF_TIME && smallerZcountdown != null){
|
||||
smallerZcountdown.cancelTimer();
|
||||
smallerZcountdown.disable();
|
||||
smallerZcountdown = null;
|
||||
}else if(smallerZtime == 0){
|
||||
smallerZcountdown = new TechKOCountdown(smallerTeam());
|
||||
}
|
||||
|
||||
if(biggerZtime == TECH_KO_HALF_TIME && biggerZcountdown != null){
|
||||
biggerZcountdown.cancelTimer();
|
||||
biggerZcountdown.disable();
|
||||
biggerZcountdown = null;
|
||||
}else if(biggerZtime == 0){
|
||||
biggerZcountdown = new TechKOCountdown(biggerTeam());
|
||||
@ -87,9 +102,4 @@ public class WinconditionTechKO implements Listener {
|
||||
else
|
||||
return Fight.getRedTeam();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDead(EntityExplodeEvent event){
|
||||
map.remove(event.getEntity().getEntityId());
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,27 @@
|
||||
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.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class WinconditionTimeout extends Wincondition {
|
||||
|
||||
private TimeOverCountdown countdown;
|
||||
|
||||
public class WinconditionTimeout {
|
||||
public WinconditionTimeout() {
|
||||
if(!Config.Timeout)
|
||||
return;
|
||||
super(Config.Timeout, EnumSet.of(FightState.RUNNING, FightState.ENTERN));
|
||||
}
|
||||
|
||||
new TimeOverCountdown(() -> FightSystem.setSpectateState(null));
|
||||
@Override
|
||||
public void enable() {
|
||||
countdown = new TimeOverCountdown(() -> FightSystem.setSpectateState(null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
countdown.disable();
|
||||
}
|
||||
}
|
||||
|
@ -10,21 +10,34 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class WinconditionWaterTechKO {
|
||||
public class WinconditionWaterTechKO extends Wincondition {
|
||||
|
||||
private static final Set<Location> teamRedWater = new HashSet<>();
|
||||
private static final Set<Location> teamBlueWater = new HashSet<>();
|
||||
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||
|
||||
public WinconditionWaterTechKO() {
|
||||
if(!Config.WaterTechKO)
|
||||
return;
|
||||
private BukkitTask task;
|
||||
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), this::addWater, 200, 200);
|
||||
public WinconditionWaterTechKO() {
|
||||
super(Config.WaterTechKO, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING, FightState.SPECTATE));
|
||||
}
|
||||
|
||||
public static int getTeamBlueWater() {
|
||||
return teamBlueWater.size();
|
||||
}
|
||||
|
||||
public static int getTeamRedWater() {
|
||||
return teamRedWater.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
checkForWater(teamRedWater,
|
||||
Config.TeamRedCornerX,
|
||||
Config.TeamRedCornerY,
|
||||
@ -39,6 +52,19 @@ public class WinconditionWaterTechKO {
|
||||
Config.TeamBlueCornerX + Config.SchemsizeX,
|
||||
Config.TeamBlueCornerY + Config.SchemsizeY,
|
||||
Config.TeamBlueCornerZ + Config.SchemsizeZ);
|
||||
task = Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), this::addWater, 200, 200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
private void checkEmpty(FightTeam team, Set<Location> teamWater){
|
||||
if(teamWater.isEmpty()){
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§eDas Team " + team.getColoredName() + " §eist Tech K.O.!");
|
||||
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> FightSystem.setSpectateState(Fight.getOpposite(team)));
|
||||
}
|
||||
}
|
||||
|
||||
private void addWater() {
|
||||
@ -77,19 +103,4 @@ public class WinconditionWaterTechKO {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkEmpty(FightTeam team, Set<Location> teamWater){
|
||||
if(teamWater.isEmpty()){
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§eDas Team " + team.getColoredName() + " §eist Tech K.O.!");
|
||||
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> FightSystem.setSpectateState(Fight.getOpposite(team)));
|
||||
}
|
||||
}
|
||||
|
||||
public static int getTeamBlueWater() {
|
||||
return teamBlueWater.size();
|
||||
}
|
||||
|
||||
public static int getTeamRedWater() {
|
||||
return teamRedWater.size();
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren