SteamWar/FightSystem
Archiviert
13
1

Not stable version

Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Yaruma3341 2019-02-25 18:42:51 +01:00
Ursprung 5af0a9dd1a
Commit 30eace7a05
15 geänderte Dateien mit 38 neuen und 36 gelöschten Zeilen

Datei anzeigen

@ -57,6 +57,8 @@ public class FightSystem extends JavaPlugin {
public int team2cornerY;
public int team2cornerZ;
public int underArenaBorder;
public int fightTime = 0;
public double damageRed = 0D;
@ -96,6 +98,8 @@ public class FightSystem extends JavaPlugin {
World world = Bukkit.getWorld(fileManager.getStringFromConfig("Arena.WorldName"));
underArenaBorder = fileManager.getIntegerFromConfig("Arena.underArenaBorder");
//Rotate team1corner to edge (min. x, min. y, min. z)
if(schemsizeX < 0){
schemsizeX = -schemsizeX;
@ -184,7 +188,7 @@ public class FightSystem extends JavaPlugin {
if(fileManager.getBooleanFromConfig("WinConditions.AllDead")) pm.registerEvents(new WinconditionAllDead(), plugin);
if(fileManager.getBooleanFromConfig("WinConditions.CaptainDead")) pm.registerEvents(new WinconditionCaptainDead(), plugin);
if(fileManager.getBooleanFromConfig("WinConditions.AllDead")) pm.registerEvents(new WinconditionAllDead(), plugin);
if(fileManager.getBooleanFromConfig("WinConditions.PercentWin")) pm.registerEvents(new WinconditionPercentSystem(), plugin);
if(fileManager.getBooleanFromConfig("WinConditions.PercentSystem")) pm.registerEvents(new WinconditionPercentSystem(), plugin);
getCommand("ak").setExecutor(new AkCommand());
}
@ -283,7 +287,6 @@ public class FightSystem extends JavaPlugin {
Countdown.cancelAllTimers();
setAllPlayersGM(GameMode.SPECTATOR);
entern = true;
Bukkit.broadcastMessage(" ");
if(winFightTeam != null) {
@ -309,8 +312,7 @@ public class FightSystem extends JavaPlugin {
}
}
Countdown cancelAllCountdowns = new Countdown();
cancelAllCountdowns.cancelAllTimers();
Countdown.cancelAllTimers();
Countdown countdown = new Countdown(20*60, new FinishSpectateOver());
countdown.startTimer(FightSystem.getPlugin());
}
@ -396,6 +398,10 @@ public class FightSystem extends JavaPlugin {
return team2cornerZ;
}
public int getUnderArenaBorder() {
return underArenaBorder;
}
public int getFightTime() {
return fightTime;
}

Datei anzeigen

@ -3,11 +3,8 @@ package me.yaruma.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightState;
import me.yaruma.fightsystem.fight.FightTeam;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -34,6 +31,7 @@ public class EntityDamageByEntityListener implements Listener {
}
} else
event.setCancelled(true);
return;
}
if(event.getDamager() instanceof Arrow) {
@ -48,6 +46,7 @@ public class EntityDamageByEntityListener implements Listener {
damagerArrow.setFireTicks(0);
player.setFireTicks(0);
}
return;
}
}
}

Datei anzeigen

@ -12,6 +12,7 @@ public class EntityDamageListener implements Listener {
@EventHandler
public void handleEntityDamage(EntityDamageEvent event) {
if(!(event.getEntity() instanceof Player)) return;
Player player = (Player) event.getEntity();
if(Fight.getPlayerTeam(player) != null) {
if(FightSystem.getPlugin().getFightState() != FightState.RUNNING) event.setCancelled(true);

Datei anzeigen

@ -18,7 +18,6 @@ public class PlayerDeathListener implements Listener {
Player player = event.getEntity().getPlayer();
if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player);
FightTeam oppositeFightTeam = Fight.getOpposite(fightTeam);
fightTeam.getFightPlayer(player).setOut(true);
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §cist gestorben!");
}

Datei anzeigen

@ -60,6 +60,7 @@ public class PlayerJoinListener implements Listener {
if(fightPlayer.isLeader()) SetupItems.giveSetupItems(player);
if(fightPlayer.isOut()) {
fightPlayer.setOut(false);
Countdown.cancelTimerType(CountdownType.NO_PLAYERS_ONLINE);
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §6" + fightPlayer.getPlayer().getName() + " §aist dem Kampf wieder beigetreten!");
} else
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §6" + fightPlayer.getPlayer().getName() + " §aist dem Kampf beigetreten!");

Datei anzeigen

@ -32,7 +32,7 @@ public class PlayerMoveListener implements Listener {
}
//Check under Arena
if(to.getBlockY() <= fileManager.getIntegerFromConfig("Arena.underArenaBorder")) {
if(to.getBlockY() <= instance.underArenaBorder) {
if(fightTeam == null){
player.teleport(from);
player.sendMessage(FightSystem.PREFIX + "§cDu darfst die Arena nicht verlassen!");

Datei anzeigen

@ -17,12 +17,13 @@ public class PlayerQuitListener implements Listener {
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
event.setQuitMessage(null);
Player player = event.getPlayer();
if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player);
fightTeam.getFightPlayer(player).setOut(true);
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §chat den Fight verlassen!");
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §chat den Kampf verlassen!");
if(fightTeam.allPlayersOut() && FightSystem.getPlugin().getFightState() == FightState.SETUP) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von §6" + fightTeam.getLeader().getPlayer() + " §chaben den Kampf verlassen! \n §4Stoppe Server in 30 Sekunden...");

Datei anzeigen

@ -18,9 +18,9 @@ public class PlayerRespawnListener implements Listener {
player.teleport(instance.getSpecSpawnLoc());
} else {
if(Fight.getPlayerTeam(player) == Fight.redTeam)
event.setRespawnLocation(instance.getTeam1SpawnLoc());
instance.getTeam1SpawnLoc();
else
event.setRespawnLocation(instance.getTeam2SpawnLoc());
instance.getTeam2SpawnLoc();
}
}

Datei anzeigen

@ -38,7 +38,7 @@ public class WorldEdit {
try {
int tnt = editSession.replaceBlocks(cuboidSelection.getRegionSelector().getRegion(), targetObsidian, new BaseBlock(46));
int slime = editSession.replaceBlocks(cuboidSelection.getRegionSelector().getRegion(), targetObsidian, new BaseBlock(7));
int slime = editSession.replaceBlocks(cuboidSelection.getRegionSelector().getRegion(), targetBedrock, new BaseBlock(165));
editSession.flushQueue();
} catch (Exception ex){

Datei anzeigen

@ -14,10 +14,6 @@ public class Countdown {
private CountdownCallback countdownCallback;
private int taskID;
public Countdown() {
}
public Countdown(int time, CountdownCallback countdownCallback) {
this.time = time;
this.countdownCallback = countdownCallback;

Datei anzeigen

@ -7,12 +7,12 @@ public class FinishTimeOver implements CountdownCallback {
@Override
public String countdownCounting() {
return "bis die Zeit abgelaufen ist!";
return "bis der Kampf vorbei ist!";
}
@Override
public void countdownFinished() {
Bukkit.broadcastMessage("§aZeit abgelaufen!");
Bukkit.broadcastMessage("§aZeit abgelaufen! Der Kampf ist vorbei...");
FightSystem.getPlugin().setSpectateState(null);
}

Datei anzeigen

@ -52,10 +52,10 @@ public class Scoreboard {
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.setDisplayName("§6Fight Info");
objective.getScore("§7Zeit: §a" + FightSystem.getPlugin().getFightTime()).setScore(0);
if(Methods.isEnabled("Fight.Entern")) objective.getScore("§7Entern: " + (FightSystem.getPlugin().isEntern() ? "§aja" : "§cnein")).setScore(1);
if(Methods.isEnabled("WinConditions.PercentSystem")) objective.getScore("§eSchaden ROT: §c" + FightSystem.getPlugin().getDamageRed() + "%").setScore(2);
if(Methods.isEnabled("WinConditions.PercentSystem")) objective.getScore("§eSchaden BLAU: §c" + FightSystem.getPlugin().getGetDamageBlue() + "%").setScore(3);
objective.getScore("§7Zeit: §a" + FightSystem.getPlugin().getFightTime()).setScore(3);
if(Methods.isEnabled("Fight.Entern")) objective.getScore("§7Entern: " + (FightSystem.getPlugin().isEntern() ? "§aja" : "§cnein")).setScore(2);
if(Methods.isEnabled("WinConditions.PercentSystem")) objective.getScore("§eSchaden ROT: §c" + FightSystem.getPlugin().getDamageRed() + "%").setScore(1);
if(Methods.isEnabled("WinConditions.PercentSystem")) objective.getScore("§eSchaden BLAU: §c" + FightSystem.getPlugin().getGetDamageBlue() + "%").setScore(0);
index = 0;
}
player.setScoreboard(scoreboard);
@ -65,10 +65,10 @@ public class Scoreboard {
private FightTeam getIndexDisplay(int index) {
if(index == 0) {
return Fight.blueTeam;
return Fight.redTeam;
}
if(index == 1) {
return Fight.redTeam;
return Fight.blueTeam;
}
if(index == 2) {
return null;

Datei anzeigen

@ -5,7 +5,7 @@ import me.yaruma.fightsystem.FightSystem;
public class Methods {
public static boolean isEnabled(String conditionPath) {
return FightSystem.getPlugin().getFileManager().getBooleanFromConfig(conditionPath) ? true : false;
return FightSystem.getPlugin().getFileManager().getBooleanFromConfig(conditionPath);
}

Datei anzeigen

@ -24,7 +24,7 @@ public class WinconditionAllDead implements Listener {
FightTeam oppositeFightTeam = Fight.getOpposite(fightTeam);
if(fightTeam.allPlayersOut()) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von " + fightTeam.getLeader().getPlayer().getName() + " §csind gestorben!");
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von " + fightTeam.getLeader().getPlayer().getName() + " §csind gestorben oder haben den Kampf verlassen!");
instance.setSpectateState(oppositeFightTeam);
return;
}
@ -39,7 +39,7 @@ public class WinconditionAllDead implements Listener {
FightTeam oppositeFightTeam = Fight.getOpposite(fightTeam);
if(fightTeam.allPlayersOut()) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von §6" + fightTeam.getLeader().getPlayer() + " §csind tot oder haben den Kampf verlassen! \n §60 Sekunden Zeit zum Begutachten!");
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von §6" + fightTeam.getLeader().getPlayer().getName() + " §csind gestorben oder haben den Kampf verlassen!");
instance.setSpectateState(oppositeFightTeam);
return;
}

Datei anzeigen

@ -4,8 +4,7 @@ import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.manager.FileManager;
import me.yaruma.fightsystem.utils.Region;
import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.FinishSpectateOver;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -27,29 +26,29 @@ public class WinconditionPercentSystem implements Listener {
@EventHandler
public void handleEntityExplode(EntityExplodeEvent event) {
if(!Methods.isEnabled("WinConditions.PercentWin")) return;
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);
Countdown countdown = new Countdown(fileManager.getIntegerFromConfig("Times.SpectatorDuration"), new FinishSpectateOver());
countdown.startTimer(instance);
}
return;
}
//Team 2 / Blau
if(Region.isInRegion(entity.getLocation(), instance.getTeam2cornerX(), instance.getTeam1cornerY(), instance.getTeam2cornerZ(), instance.getTeam2cornerX() + instance.getSchemsizeX(), instance.getTeam2cornerY() + instance.getSchemsizeY(), instance.getTeam2cornerZ() + instance.getSchemsizeZ(), fileManager.getIntegerFromConfig("Arena.BorderFromSchematic"))) {
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);
Countdown countdown = new Countdown(fileManager.getIntegerFromConfig("Times.SpectatorDuration"), new FinishSpectateOver());
countdown.startTimer(instance);
}
return;
}