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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -1,18 +1,23 @@
package me.yaruma.fightsystem.winconditions; package me.yaruma.fightsystem.winconditions;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.utils.Config; import me.yaruma.fightsystem.utils.Config;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
public class WinconditionTechKO { public class WinconditionTechKO {
public static HashSet<Location> teamRedWater = new HashSet<>(); public static HashSet<Location> teamRedWater = new HashSet<>();
public static HashSet<Location> teamBlueWater = new HashSet<>(); public static HashSet<Location> teamBlueWater = new HashSet<>();
public static int taskID;
public static void addWater() { public static void addWater() {
if(!Config.TechKO) return;
//Team Red //Team Red
for(int x = Config.TeamRedCornerX; x <= (x + Config.SchemsizeX); x++) { for(int x = Config.TeamRedCornerX; x <= (x + Config.SchemsizeX); x++) {
@ -39,14 +44,37 @@ public class WinconditionTechKO {
} }
} }
public static void removeWater(Location location) { public static void startAutoChecker() {
if(!Config.TechKO) if(!Config.TechKO) return;
return; taskID = Bukkit.getScheduler().scheduleAsyncRepeatingTask(FightSystem.getPlugin(), new Runnable() {
@Override
public void run() {
if(teamRedWater.contains(location)) //Team Red
teamRedWater.remove(location); Iterator itrRed = teamRedWater.iterator();
if(teamBlueWater.contains(location)) while (itrRed.hasNext()) {
teamBlueWater.remove(location); 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);
} }
} }