SteamWar/FightSystem
Archiviert
13
1
Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Yaruma3341 2019-04-14 01:07:38 +02:00
Ursprung 808cd32c8e
Commit 6bbe6ff5b3
4 geänderte Dateien mit 40 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -179,6 +179,8 @@ public class FightSystem extends JavaPlugin {
WinconditionTimeout.timeout();
WinconditionEntern.entern();
WinconditionTechKO.startAutoChecker();
Bukkit.broadcastMessage(PREFIX + "§aArena freigegeben!");
}
@ -187,6 +189,7 @@ public class FightSystem extends JavaPlugin {
return;
this.fightState = FightState.SPECTATE;
Countdown.cancelAllTimers();
Bukkit.getScheduler().cancelTask(WinconditionTechKO.taskID);
setAllPlayersGM(GameMode.SPECTATOR);
Bukkit.broadcastMessage(" ");

Datei anzeigen

@ -12,6 +12,7 @@ import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.kit.KitManager;
import me.yaruma.fightsystem.utils.Config;
import me.yaruma.fightsystem.utils.ItemBuilder;
import me.yaruma.fightsystem.winconditions.WinconditionTechKO;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
@ -151,6 +152,7 @@ public class FightTeam {
}
schem.paste(w, v, false, true, aT).flushQueue();
teleportToSpawn();
WinconditionTechKO.addWater();
}
public void setSchematic(Schematic schematic){

Datei anzeigen

@ -70,7 +70,6 @@ public class WaterRemover {
Bukkit.getScheduler().runTask((Plugin)FightSystem.getPlugin(), () -> {
for (Block block : blocksToRemove) {
block.setType(Material.AIR);
WinconditionTechKO.removeWater(block.getLocation());
}
});
}

Datei anzeigen

@ -1,18 +1,23 @@
package me.yaruma.fightsystem.winconditions;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.utils.Config;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import java.util.HashSet;
import java.util.Iterator;
public class WinconditionTechKO {
public static HashSet<Location> teamRedWater = new HashSet<>();
public static HashSet<Location> teamBlueWater = new HashSet<>();
public static int taskID;
public static void addWater() {
if(!Config.TechKO) return;
//Team Red
for(int x = Config.TeamRedCornerX; x <= (x + Config.SchemsizeX); x++) {
@ -39,14 +44,37 @@ public class WinconditionTechKO {
}
}
public static void removeWater(Location location) {
if(!Config.TechKO)
return;
public static void startAutoChecker() {
if(!Config.TechKO) return;
taskID = Bukkit.getScheduler().scheduleAsyncRepeatingTask(FightSystem.getPlugin(), new Runnable() {
@Override
public void run() {
if(teamRedWater.contains(location))
teamRedWater.remove(location);
if(teamBlueWater.contains(location))
teamBlueWater.remove(location);
//Team Red
Iterator itrRed = teamRedWater.iterator();
while (itrRed.hasNext()) {
Location location = (Location) itrRed.next();
if(location.getBlock().getType() != Material.WATER && location.getBlock().getType() != Material.STATIONARY_WATER)
itrRed.remove();
}
if(teamRedWater.isEmpty()) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "6Das Team " + Config.TeamRedPrefix + Config.TeamRedName + " §6ist Tech K.O. !");
FightSystem.getPlugin().setSpectateState(Fight.getBlueTeam());
}
//Team Blue
Iterator itrBlue = teamRedWater.iterator();
while (itrRed.hasNext()) {
Location location = (Location) itrRed.next();
if(location.getBlock().getType() != Material.WATER && location.getBlock().getType() != Material.STATIONARY_WATER)
itrRed.remove();
}
if(teamBlueWater.isEmpty()) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "6Das Team " + Config.TeamBluePrefix + Config.TeamBlueName + " §6ist Tech K.O. !");
FightSystem.getPlugin().setSpectateState(Fight.getRedTeam());
}
}
}, 0, 20*20);
}
}