SteamWar/FightSystem
Archiviert
13
1
Dieses Repository wurde am 2024-08-05 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
FightSystem/src/me/yaruma/fightsystem/winconditions/WinconditionPercentSystem.java

59 Zeilen
2.9 KiB
Java

package me.yaruma.fightsystem.winconditions;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.manager.FileManager;
import me.yaruma.fightsystem.utils.Region;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
public class WinconditionPercentSystem implements Listener {
private static int team1DestroyedBlocks;
private static int team2DestroyedBlocks;
private final FightSystem instance = FightSystem.getPlugin();
private final FileManager fileManager = instance.getFileManager();
private static final int schematicSize =
Math.abs(
FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.x") *
FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.y") *
FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.z"));
@EventHandler
public void handleEntityExplode(EntityExplodeEvent event) {
Bukkit.broadcastMessage("boom");
if(!Methods.isEnabled("WinConditions.PercentSystem")) return;
Bukkit.broadcastMessage("enabled");
Entity entity = event.getEntity();
//Team 1 / Rot
if(Region.isInRegion(entity.getLocation(), instance.getTeam1cornerX(), instance.getTeam1cornerY(), instance.getTeam1cornerZ(), instance.getTeam1cornerX() + instance.getSchemsizeX(), instance.getTeam1cornerY() + instance.getSchemsizeY(), instance.getTeam1cornerZ() + instance.getSchemsizeZ(), fileManager.getIntegerFromConfig("Arena.BorderFromSchematic"))) {
team1DestroyedBlocks = team1DestroyedBlocks + event.blockList().size();
Bukkit.broadcastMessage("red");
double destroyPercent = team1DestroyedBlocks * 100 / schematicSize;
Bukkit.broadcastMessage(" " + destroyPercent);
if(destroyPercent >= fileManager.getIntegerFromConfig("WinConditionParams.PercentWin")) {
instance.setSpectateState(Fight.blueTeam);
}
return;
}
//Team 2 / Blau
if(Region.isInRegion(entity.getLocation(), instance.getTeam2cornerX(), instance.getTeam2cornerY(), instance.getTeam2cornerZ(), instance.getTeam2cornerX() + instance.getSchemsizeX(), instance.getTeam2cornerY() + instance.getSchemsizeY(), instance.getTeam2cornerZ() + instance.getSchemsizeZ(), fileManager.getIntegerFromConfig("Arena.BorderFromSchematic"))) {
team2DestroyedBlocks = team2DestroyedBlocks + event.blockList().size();
double destroyPercent = team2DestroyedBlocks * 100 / schematicSize;
if(destroyPercent >= fileManager.getIntegerFromConfig("WinConditionParams.PercentWin")) {
instance.setSpectateState(Fight.redTeam);
}
return;
}
}
}