RedstoneWincondition #274
@ -70,6 +70,10 @@ public abstract class PercentWincondition extends Wincondition implements Printa
|
|||||||
private final Consumer<TeamPercent> explodeConsumer;
|
private final Consumer<TeamPercent> explodeConsumer;
|
||||||
|
|
||||||
public TeamPercent(PercentWincondition percentWincondition, FightTeam fightTeam, Winconditions wincondition, Predicate<Material> testType, Consumer<TeamPercent> explodeConsumer) {
|
public TeamPercent(PercentWincondition percentWincondition, FightTeam fightTeam, Winconditions wincondition, Predicate<Material> testType, Consumer<TeamPercent> explodeConsumer) {
|
||||||
YoyoNow markierte diese Unterhaltung als gelöst
Veraltet
|
|||||||
|
this(percentWincondition, fightTeam, wincondition, testType, explodeConsumer, () -> {});
|
||||||
|
}
|
||||||
|
|
||||||
|
public TeamPercent(PercentWincondition percentWincondition, FightTeam fightTeam, Winconditions wincondition, Predicate<Material> testType, Consumer<TeamPercent> explodeConsumer, Runnable afterEnable) {
|
||||||
this.fightTeam = fightTeam;
|
this.fightTeam = fightTeam;
|
||||||
this.testType = testType;
|
this.testType = testType;
|
||||||
this.explodeConsumer = explodeConsumer;
|
this.explodeConsumer = explodeConsumer;
|
||||||
@ -81,6 +85,7 @@ public abstract class PercentWincondition extends Wincondition implements Printa
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
currentBlocks = totalBlocks;
|
currentBlocks = totalBlocks;
|
||||||
|
afterEnable.run();
|
||||||
});
|
});
|
||||||
|
|
||||||
new StateDependentListener(wincondition, FightState.Running, this).register();
|
new StateDependentListener(wincondition, FightState.Running, this).register();
|
||||||
|
@ -25,11 +25,9 @@ import de.steamwar.fightsystem.countdown.TimeOverCountdown;
|
|||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
|
||||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -41,8 +39,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class WinconditionPoints extends Wincondition implements PrintableWincondition, Listener {
|
public class WinconditionPoints extends Wincondition implements PrintableWincondition, Listener {
|
||||||
|
|
||||||
private static final World world = Bukkit.getWorlds().get(0);
|
|
||||||
|
|
||||||
private final Map<FightTeam, TeamPoints> teamMap = new HashMap<>();
|
private final Map<FightTeam, TeamPoints> teamMap = new HashMap<>();
|
||||||
|
|
||||||
public WinconditionPoints(){
|
public WinconditionPoints(){
|
||||||
@ -52,9 +48,6 @@ public class WinconditionPoints extends Wincondition implements PrintableWincond
|
|||||||
teamMap.put(Fight.getRedTeam(), new TeamPoints(Fight.getRedTeam()));
|
teamMap.put(Fight.getRedTeam(), new TeamPoints(Fight.getRedTeam()));
|
||||||
|
|
||||||
new StateDependentListener(Winconditions.POINTS, FightState.Ingame, this);
|
new StateDependentListener(Winconditions.POINTS, FightState.Ingame, this);
|
||||||
new OneShotStateDependent(Winconditions.POINTS, FightState.Ingame, () -> {
|
|
||||||
teamMap.values().forEach(TeamPoints::enable);
|
|
||||||
}).register();
|
|
||||||
if(Config.ActiveWinconditions.contains(Winconditions.POINTS)){
|
if(Config.ActiveWinconditions.contains(Winconditions.POINTS)){
|
||||||
timeOverCountdown = new StateDependentCountdown(Winconditions.POINTS, FightState.Running, new TimeOverCountdown(this::timeOver));
|
timeOverCountdown = new StateDependentCountdown(Winconditions.POINTS, FightState.Running, new TimeOverCountdown(this::timeOver));
|
||||||
printableWinconditions.add(this);
|
printableWinconditions.add(this);
|
||||||
@ -109,6 +102,7 @@ public class WinconditionPoints extends Wincondition implements PrintableWincond
|
|||||||
return team.getPrefix() + "Punkte: " + teamMap.get(team).getPoints();
|
return team.getPrefix() + "Punkte: " + teamMap.get(team).getPoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean run = false;
|
||||||
private class TeamPoints {
|
private class TeamPoints {
|
||||||
private static final int MAX_POINTS = 2000;
|
private static final int MAX_POINTS = 2000;
|
||||||
|
|
||||||
@ -120,7 +114,10 @@ public class WinconditionPoints extends Wincondition implements PrintableWincond
|
|||||||
|
|
||||||
TeamPoints(FightTeam team){
|
TeamPoints(FightTeam team){
|
||||||
this.team = team;
|
this.team = team;
|
||||||
this.percent = new PercentWincondition.TeamPercent(null, team, Winconditions.POINTS, material -> true, teamPercent -> {});
|
this.percent = new PercentWincondition.TeamPercent(null, team, Winconditions.POINTS, material -> true, teamPercent -> {}, () -> {
|
||||||
|
if (run) teamMap.values().forEach(TeamPoints::enable);
|
||||||
|
run = !run;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enable() {
|
public void enable() {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren
Hier am Ende des Konstruktors würde ich gleich dieses TeamPercent in die teamMap einfügen, dann musst du das nicht an den ganzen anderen Stellen machen (und kannst es nicht vergessen)