Merge branch 'winconditionPumpkinTechKO' of SteamWar/FightSystem into master
Dieser Commit ist enthalten in:
Commit
9a248969d4
@ -86,6 +86,7 @@ public class Config {
|
|||||||
public static final boolean Entern;
|
public static final boolean Entern;
|
||||||
public static final boolean TechKO;
|
public static final boolean TechKO;
|
||||||
public static final boolean WaterTechKO;
|
public static final boolean WaterTechKO;
|
||||||
|
public static final boolean PumpkinTechKO;
|
||||||
|
|
||||||
//win condition parameters
|
//win condition parameters
|
||||||
public static final int TimeoutTime;
|
public static final int TimeoutTime;
|
||||||
@ -165,6 +166,7 @@ public class Config {
|
|||||||
Entern = config.getBoolean("WinConditions.Entern");
|
Entern = config.getBoolean("WinConditions.Entern");
|
||||||
TechKO = config.getBoolean("WinConditions.TechKO");
|
TechKO = config.getBoolean("WinConditions.TechKO");
|
||||||
WaterTechKO = config.getBoolean("WinConditions.WaterTechKO");
|
WaterTechKO = config.getBoolean("WinConditions.WaterTechKO");
|
||||||
|
PumpkinTechKO = config.getBoolean("WinConditions.PumpkinTechKO");
|
||||||
|
|
||||||
TimeoutTime = config.getInt("WinConditionParams.TimeoutTime");
|
TimeoutTime = config.getInt("WinConditionParams.TimeoutTime");
|
||||||
EnterPhaseBegin = config.getInt("WinConditionParams.EnterPhaseBegin");
|
EnterPhaseBegin = config.getInt("WinConditionParams.EnterPhaseBegin");
|
||||||
|
@ -45,6 +45,8 @@ WinConditions:
|
|||||||
Points: boolean
|
Points: boolean
|
||||||
Entern: boolean
|
Entern: boolean
|
||||||
TechKO: boolean
|
TechKO: boolean
|
||||||
|
WaterTechKO: boolean
|
||||||
|
PumpkinTechKO: boolean
|
||||||
WinConditionParams:
|
WinConditionParams:
|
||||||
TimeoutTime: 0
|
TimeoutTime: 0
|
||||||
EnterPhaseBegin: 0
|
EnterPhaseBegin: 0
|
||||||
|
@ -112,6 +112,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
|
|
||||||
new WinconditionAllDead();
|
new WinconditionAllDead();
|
||||||
new WinconditionCaptainDead();
|
new WinconditionCaptainDead();
|
||||||
|
new WinconditionPumpkinTechKO();
|
||||||
new WinconditionWaterTechKO();
|
new WinconditionWaterTechKO();
|
||||||
new WinconditionPercentSystem();
|
new WinconditionPercentSystem();
|
||||||
new WinconditionRelativePercent();
|
new WinconditionRelativePercent();
|
||||||
|
@ -5,10 +5,7 @@ import de.steamwar.fightsystem.FightSystem;
|
|||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightState;
|
import de.steamwar.fightsystem.fight.FightState;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.winconditions.WinconditionPercentSystem;
|
import de.steamwar.fightsystem.winconditions.*;
|
||||||
import de.steamwar.fightsystem.winconditions.WinconditionPoints;
|
|
||||||
import de.steamwar.fightsystem.winconditions.WinconditionRelativePercent;
|
|
||||||
import de.steamwar.fightsystem.winconditions.WinconditionWaterTechKO;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.scoreboard.DisplaySlot;
|
import org.bukkit.scoreboard.DisplaySlot;
|
||||||
import org.bukkit.scoreboard.Objective;
|
import org.bukkit.scoreboard.Objective;
|
||||||
@ -86,6 +83,9 @@ public class FightScoreboard {
|
|||||||
}else if(Config.Points){
|
}else if(Config.Points){
|
||||||
objective.getScore(Fight.getRedTeam().getPrefix() + "Punkte: " + WinconditionPoints.getRed().getPoints()).setScore(1);
|
objective.getScore(Fight.getRedTeam().getPrefix() + "Punkte: " + WinconditionPoints.getRed().getPoints()).setScore(1);
|
||||||
objective.getScore(Fight.getBlueTeam().getPrefix() + "Punkte: " + WinconditionPoints.getBlue().getPoints()).setScore(0);
|
objective.getScore(Fight.getBlueTeam().getPrefix() + "Punkte: " + WinconditionPoints.getBlue().getPoints()).setScore(0);
|
||||||
|
}else if(Config.PumpkinTechKO){
|
||||||
|
objective.getScore(Fight.getRedTeam().getPrefix() + "Kanonen: " + WinconditionPumpkinTechKO.getTeamRedPumpkins()).setScore(1);
|
||||||
|
objective.getScore(Fight.getBlueTeam().getPrefix() + "Kanonen: " + WinconditionPumpkinTechKO.getTeamBluePumpkins()).setScore(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,70 @@
|
|||||||
|
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.inventory.SWItem;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
public class WinconditionPumpkinTechKO {
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
|
public WinconditionPumpkinTechKO(){
|
||||||
|
if(!Config.PumpkinTechKO)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), WinconditionPumpkinTechKO::recursiveCheck, 0, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getTeamBluePumpkins() {
|
||||||
|
return teamBluePumpkins;
|
||||||
|
}
|
||||||
|
public static int getTeamRedPumpkins() {
|
||||||
|
return teamRedPumpkins;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void recursiveCheck(){
|
||||||
|
teamRedPumpkins = getPumpkins(Config.TeamRedCornerX,
|
||||||
|
Config.TeamRedCornerY,
|
||||||
|
Config.TeamRedCornerZ,
|
||||||
|
Config.TeamRedCornerX + Config.SchemsizeX,
|
||||||
|
Config.TeamRedCornerY + Config.SchemsizeY,
|
||||||
|
Config.TeamRedCornerZ + Config.SchemsizeZ);
|
||||||
|
teamBluePumpkins = getPumpkins(Config.TeamBlueCornerX,
|
||||||
|
Config.TeamBlueCornerY,
|
||||||
|
Config.TeamBlueCornerZ,
|
||||||
|
Config.TeamBlueCornerX + Config.SchemsizeX,
|
||||||
|
Config.TeamBlueCornerY + Config.SchemsizeY,
|
||||||
|
Config.TeamBlueCornerZ + Config.SchemsizeZ);
|
||||||
|
|
||||||
|
checkKO(Fight.getRedTeam(), teamRedPumpkins);
|
||||||
|
checkKO(Fight.getBlueTeam(), teamBluePumpkins);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getPumpkins(int minX, int minY, int minZ, int maxX, int maxY, int maxZ){
|
||||||
|
int pumpkins = 0;
|
||||||
|
for(int x = minX; x <= maxX; x++) {
|
||||||
|
for(int y = minY; y <= maxY; y++) {
|
||||||
|
for (int z = minZ; z <= maxZ; z++) {
|
||||||
|
if (WORLD.getBlockAt(x, y, z).getType() == PUMPKIN_LANTERN)
|
||||||
|
pumpkins++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pumpkins;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void checkKO(FightTeam team, int pumpkins){
|
||||||
|
if(pumpkins == 0){
|
||||||
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§eDas Team " + team.getColoredName() + " §eist Tech K.O.!");
|
||||||
|
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> FightSystem.setSpectateState(Fight.getOpposite(team)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren