SteamWar/FightSystem
Archiviert
13
1

code cleanup; reworked percent system

Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Yaruma3341 2019-04-14 01:23:46 +02:00
Ursprung 6bbe6ff5b3
Commit 5ce40e8149
3 geänderte Dateien mit 20 neuen und 19 gelöschten Zeilen

Datei anzeigen

@ -26,7 +26,6 @@ import java.io.File;
public class FightSystem extends JavaPlugin { public class FightSystem extends JavaPlugin {
public static final String PREFIX = "§6Arena§8» "; public static final String PREFIX = "§6Arena§8» ";
public static final String NOPERM = PREFIX + "§cDu darfst das nicht!";
private static FightSystem plugin; private static FightSystem plugin;
private Scoreboard scoreboard; private Scoreboard scoreboard;
@ -224,16 +223,6 @@ public class FightSystem extends JavaPlugin {
return fightTime; return fightTime;
} }
public double getDamageRed() {
double damageRed = 0D;
return damageRed;
}
public double getGetDamageBlue() {
double getDamageBlue = 0D;
return getDamageBlue;
}
public boolean isEntern() { public boolean isEntern() {
return entern; return entern;
} }

Datei anzeigen

@ -5,6 +5,7 @@ import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightPlayer; import me.yaruma.fightsystem.fight.FightPlayer;
import me.yaruma.fightsystem.fight.FightTeam; import me.yaruma.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.utils.Config; import me.yaruma.fightsystem.utils.Config;
import me.yaruma.fightsystem.winconditions.WinconditionPercentSystem;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.DisplaySlot;
@ -60,8 +61,8 @@ public class Scoreboard {
if (Config.Entern) if (Config.Entern)
objective.getScore("§7Entern: " + (FightSystem.getPlugin().isEntern() ? "§aja" : "§cnein")).setScore(2); objective.getScore("§7Entern: " + (FightSystem.getPlugin().isEntern() ? "§aja" : "§cnein")).setScore(2);
if (Config.PercentSystem){ if (Config.PercentSystem){
objective.getScore("§eSchaden ROT: §c" + FightSystem.getPlugin().getDamageRed() + "%").setScore(1); objective.getScore("§eSchaden ROT: §c" + (Math.round(100.0 * WinconditionPercentSystem.getRedPercent()) / 100) + "%").setScore(1);
objective.getScore("§eSchaden BLAU: §c" + FightSystem.getPlugin().getGetDamageBlue() + "%").setScore(0); objective.getScore("§eSchaden BLAU: §c" + (Math.round(100.0 * WinconditionPercentSystem.getBluePercent()) / 100) + "%").setScore(0);
} }
index = 0; index = 0;
} }

Datei anzeigen

@ -12,6 +12,9 @@ import org.bukkit.event.entity.EntityExplodeEvent;
public class WinconditionPercentSystem implements Listener { public class WinconditionPercentSystem implements Listener {
private static double bluePercent = 0D;
private static double redPercent = 0D;
private static int blueDestroyedBlocks; private static int blueDestroyedBlocks;
private static int redDestroyedBlocks; private static int redDestroyedBlocks;
@ -26,22 +29,24 @@ public class WinconditionPercentSystem implements Listener {
if(!Config.PercentSystem) return; if(!Config.PercentSystem) return;
Entity entity = event.getEntity(); Entity entity = event.getEntity();
//Team 1 / Rot //Team Blue
if(Region.isInRange(entity.getLocation(), Config.TeamBlueCornerX, Config.TeamBlueCornerY, Config.TeamBlueCornerZ, Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ, Config.BorderFromSchematic)){ if(Region.isInRange(entity.getLocation(), Config.TeamBlueCornerX, Config.TeamBlueCornerY, Config.TeamBlueCornerZ, Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ, Config.BorderFromSchematic)){
blueDestroyedBlocks = blueDestroyedBlocks + event.blockList().size(); blueDestroyedBlocks = blueDestroyedBlocks + event.blockList().size();
Bukkit.broadcastMessage("red"); double doubleBlueDestroyedBlocks = blueDestroyedBlocks;
double destroyPercent = blueDestroyedBlocks * 100 / schematicSize; double destroyPercent = doubleBlueDestroyedBlocks * 100 / schematicSize;
Bukkit.broadcastMessage(" " + destroyPercent); bluePercent = destroyPercent;
if(destroyPercent >= Config.PercentWin) { if(destroyPercent >= Config.PercentWin) {
FightSystem.getPlugin().setSpectateState(Fight.blueTeam); FightSystem.getPlugin().setSpectateState(Fight.blueTeam);
} }
return; return;
} }
//Team 2 / Blau //Team Red
if(Region.isInRange(entity.getLocation(), Config.TeamRedCornerX, Config.TeamRedCornerY, Config.TeamRedCornerZ, Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ, Config.BorderFromSchematic)) { if(Region.isInRange(entity.getLocation(), Config.TeamRedCornerX, Config.TeamRedCornerY, Config.TeamRedCornerZ, Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ, Config.BorderFromSchematic)) {
redDestroyedBlocks = redDestroyedBlocks + event.blockList().size(); redDestroyedBlocks = redDestroyedBlocks + event.blockList().size();
double destroyPercent = redDestroyedBlocks * 100 / schematicSize; double doubleRedDestroyedBlocks = redDestroyedBlocks;
double destroyPercent = doubleRedDestroyedBlocks * 100 / schematicSize;
redPercent = destroyPercent;
if(destroyPercent >= Config.PercentWin) { if(destroyPercent >= Config.PercentWin) {
FightSystem.getPlugin().setSpectateState(Fight.redTeam); FightSystem.getPlugin().setSpectateState(Fight.redTeam);
} }
@ -49,5 +54,11 @@ public class WinconditionPercentSystem implements Listener {
} }
} }
public static double getBluePercent() {
return bluePercent;
}
public static double getRedPercent() {
return redPercent;
}
} }