Relative Prozensystem Wincondition und SG.eu-Punktesystem Wincondition #75
@ -80,6 +80,8 @@ public class Config {
|
||||
public static final boolean AllDead;
|
||||
public static final boolean CaptainDead;
|
||||
public static final boolean PercentSystem;
|
||||
public static final boolean RelativePercent;
|
||||
public static final boolean Points;
|
||||
public static final boolean Entern;
|
||||
public static final boolean TechKO;
|
||||
public static final boolean WaterTechKO;
|
||||
@ -88,6 +90,7 @@ public class Config {
|
||||
public static final int TimeoutTime;
|
||||
public static final int EnterPhaseBegin;
|
||||
public static final double PercentWin;
|
||||
public static final List<String> IgnoredBlocks;
|
||||
|
||||
//default kits
|
||||
public static final String MemberDefault;
|
||||
@ -155,6 +158,8 @@ public class Config {
|
||||
AllDead = config.getBoolean("WinConditions.AllDead");
|
||||
CaptainDead = config.getBoolean("WinConditions.CaptainDead");
|
||||
PercentSystem = config.getBoolean("WinConditions.PercentSystem");
|
||||
RelativePercent = config.getBoolean("WinConditions.RelativePercent");
|
||||
Points = config.getBoolean("WinConditions.Points");
|
||||
Entern = config.getBoolean("WinConditions.Entern");
|
||||
TechKO = config.getBoolean("WinConditions.TechKO");
|
||||
WaterTechKO = config.getBoolean("WinConditions.WaterTechKO");
|
||||
@ -162,6 +167,7 @@ public class Config {
|
||||
TimeoutTime = config.getInt("WinConditionParams.TimeoutTime");
|
||||
EnterPhaseBegin = config.getInt("WinConditionParams.EnterPhaseBegin");
|
||||
PercentWin = config.getDouble("WinConditionParams.PercentWin");
|
||||
IgnoredBlocks = Collections.unmodifiableList(config.getStringList("WinConditionParams.IgnoredBlocks"));
|
||||
|
||||
MemberDefault = config.getString("Kits.MemberDefault");
|
||||
LeaderDefault = config.getString("Kits.LeaderDefault");
|
||||
|
@ -40,12 +40,19 @@ WinConditions:
|
||||
AllDead: boolean
|
||||
CaptainDead: boolean
|
||||
PercentSystem: boolean
|
||||
RelativePercent: boolean
|
||||
Points: boolean
|
||||
Entern: boolean
|
||||
TechKO: boolean
|
||||
WinConditionParams:
|
||||
TimeoutTime: 0
|
||||
EnterPhaseBegin: 0
|
||||
PercentWin: 0.0
|
||||
IgnoredBlocks:
|
||||
- AIR
|
||||
- WATER
|
||||
- TNT
|
||||
- OBSIDIAN
|
||||
Money:
|
||||
Win: 0
|
||||
Lose: 0
|
||||
@ -55,6 +62,7 @@ Kits:
|
||||
LeaderDefault: default
|
||||
Techhider:
|
||||
ObfuscateWith: 1
|
||||
ObfuscateWithTag: STONE
|
||||
HiddenBlocks:
|
||||
- 7
|
||||
- 8
|
||||
|
@ -113,7 +113,6 @@ public class FightSystem extends JavaPlugin {
|
||||
new WinconditionAllDead();
|
||||
new WinconditionCaptainDead();
|
||||
new WinconditionWaterTechKO();
|
||||
new WinconditionPercentSystem();
|
||||
|
||||
if(Config.event()){
|
||||
new EventTeamOffWincondition();
|
||||
@ -131,6 +130,9 @@ public class FightSystem extends JavaPlugin {
|
||||
new WinconditionTechKO();
|
||||
new WinconditionTimeout();
|
||||
new WinconditionEntern();
|
||||
new WinconditionPercentSystem();
|
||||
new WinconditionRelativePercent();
|
||||
new WinconditionPoints();
|
||||
|
||||
WaterRemover.init();
|
||||
|
||||
|
@ -86,6 +86,18 @@ public class FightTeam implements IFightTeam{
|
||||
}
|
||||
}
|
||||
|
||||
public final int getCornerX() {
|
||||
return cornerX;
|
||||
}
|
||||
|
||||
public final int getCornerY() {
|
||||
return cornerY;
|
||||
}
|
||||
|
||||
public final int getCornerZ() {
|
||||
return cornerZ;
|
||||
}
|
||||
|
||||
public boolean canbeLeader(Player p){
|
||||
return !hasTeamLeader() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId()));
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.winconditions.WinconditionPercentSystem;
|
||||
import de.steamwar.fightsystem.winconditions.WinconditionRelativePercent;
|
||||
import de.steamwar.fightsystem.winconditions.WinconditionWaterTechKO;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
@ -71,6 +72,9 @@ public class FightScoreboard {
|
||||
}else if(Config.WaterTechKO){
|
||||
objective.getScore(Fight.getRedTeam().getPrefix() + "Wasser: " + WinconditionWaterTechKO.getTeamRedWater()).setScore(1);
|
||||
objective.getScore(Fight.getBlueTeam().getPrefix() + "Wasser: " + WinconditionWaterTechKO.getTeamBlueWater()).setScore(0);
|
||||
}else if(Config.RelativePercent){
|
||||
objective.getScore(Fight.getRedTeam().getPrefix() + "Schaden: " + WinconditionRelativePercent.getRed().getPrintablePercent() + "%").setScore(1);
|
||||
objective.getScore(Fight.getBlueTeam().getPrefix() + "Schaden: " + WinconditionRelativePercent.getBlue().getPrintablePercent() + "%").setScore(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,52 @@
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
|
||||
public class WinconditionPoints {
|
||||
|
||||
private static TeamPoints blue;
|
||||
private static TeamPoints red;
|
||||
|
||||
public WinconditionPoints(){
|
||||
if(!Config.Points)
|
||||
return;
|
||||
|
||||
blue = new TeamPoints(Fight.getRedTeam(), WinconditionRelativePercent.getBlue(), WinconditionRelativePercent.getRed());
|
||||
red = new TeamPoints(Fight.getBlueTeam(), WinconditionRelativePercent.getRed(), WinconditionRelativePercent.getBlue());
|
||||
}
|
||||
|
||||
public TeamPoints getRed(){
|
||||
return red;
|
||||
}
|
||||
|
||||
public TeamPoints getBlue(){
|
||||
return blue;
|
||||
}
|
||||
|
||||
public static class TeamPoints extends PlayerWincondition {
|
||||
private final FightTeam enemy;
|
||||
private final WinconditionRelativePercent.TeamPercent enemyPercent;
|
||||
private final double factor;
|
||||
|
||||
private int points;
|
||||
|
||||
TeamPoints(FightTeam enemy, WinconditionRelativePercent.TeamPercent ownPercent, WinconditionRelativePercent.TeamPercent enemyPercent){
|
||||
this.enemy = enemy;
|
||||
this.enemyPercent = enemyPercent;
|
||||
init(true);
|
||||
points = 0;
|
||||
|
||||
if(enemyPercent.getBlockCount() < ownPercent.getBlockCount())
|
||||
factor = 20;
|
||||
else{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public int getPoints(){
|
||||
return points;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
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 org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class WinconditionRelativePercent{
|
||||
|
||||
private static final Set<Material> ignoredBlocks;
|
||||
private static TeamPercent blue;
|
||||
private static TeamPercent red;
|
||||
|
||||
static{
|
||||
Set<Material> ignored = new HashSet<>();
|
||||
for(String s : Config.IgnoredBlocks)
|
||||
ignored.add(Material.valueOf(s));
|
||||
ignoredBlocks = Collections.unmodifiableSet(ignored);
|
||||
}
|
||||
|
||||
public WinconditionRelativePercent(){
|
||||
if(!Config.RelativePercent && !Config.Points)
|
||||
return;
|
||||
|
||||
blue = new TeamPercent(Fight.getBlueTeam());
|
||||
red = new TeamPercent(Fight.getRedTeam());
|
||||
}
|
||||
|
||||
public static TeamPercent getBlue(){
|
||||
return blue;
|
||||
}
|
||||
|
||||
public static TeamPercent getRed(){
|
||||
return red;
|
||||
}
|
||||
|
||||
public static class TeamPercent {
|
||||
private static final World world = Bukkit.getWorlds().get(0);
|
||||
private final FightTeam team;
|
||||
private final int blockCount;
|
||||
|
||||
private int currentBlocks;
|
||||
|
||||
TeamPercent(FightTeam team){
|
||||
this.team = team;
|
||||
this.blockCount = currentBlocks();
|
||||
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), () -> {
|
||||
currentBlocks = currentBlocks();
|
||||
checkPercentDefeat();
|
||||
}, 400, 400);
|
||||
}
|
||||
|
||||
public double getPrintablePercent(){
|
||||
return Math.round(10000.0 * getPercent()) / 100.0;
|
||||
}
|
||||
|
||||
public final int getBlockCount(){
|
||||
return blockCount;
|
||||
}
|
||||
|
||||
public int getCurrentBlocks(){
|
||||
return currentBlocks;
|
||||
}
|
||||
|
||||
private double getPercent(){
|
||||
int blocksDestroyed = blockCount - currentBlocks;
|
||||
return blocksDestroyed > 0 ? blocksDestroyed / (double) blockCount : 0;
|
||||
}
|
||||
|
||||
private int currentBlocks(){
|
||||
int blocks = 0;
|
||||
for(int x = team.getCornerX(); x < team.getCornerX() + Config.SchemsizeX; x++){
|
||||
for(int y = team.getCornerY(); y < team.getCornerY() + Config.SchemsizeY; y++){
|
||||
for(int z = team.getCornerZ(); z < team.getCornerZ() + Config.SchemsizeZ; z++){
|
||||
if(!ignoredBlocks.contains(world.getBlockAt(x,y,z).getType()))
|
||||
blocks++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
private void checkPercentDefeat(){
|
||||
if(!Config.RelativePercent)
|
||||
return;
|
||||
if(getPercent() >= Config.PercentWin){
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Schiff von " + team.getColoredName() + " §cwurde zu stark beschädigt!");
|
||||
FightSystem.setSpectateState(Fight.getOpposite(team));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren