SteamWar/FightSystem
Archiviert
13
1

Merge branch 'codeCleanup' into 'master'

Code cleanup

See merge request Yaruma3341/fightsystem!6
Dieser Commit ist enthalten in:
Yaruma3341 2019-02-23 17:46:23 +01:00
Commit 884be9beb3
13 geänderte Dateien mit 204 neuen und 221 gelöschten Zeilen

Datei anzeigen

@ -6,15 +6,14 @@ import me.yaruma.fightsystem.commands.AkCommand;
import me.yaruma.fightsystem.fight.*;
import me.yaruma.fightsystem.listener.*;
import me.yaruma.fightsystem.manager.FileManager;
import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.FinishNoPlayersOnline;
import me.yaruma.fightsystem.utils.countdown.FinishSetupOver;
import me.yaruma.fightsystem.utils.countdown.FinishSpectateOver;
import me.yaruma.fightsystem.utils.WorldEdit;
import me.yaruma.fightsystem.utils.countdown.*;
import me.yaruma.fightsystem.utils.scoreboard.Scoreboard;
import me.yaruma.fightsystem.winconditions.WinconditionAllDead;
import me.yaruma.fightsystem.winconditions.WinconditionCaptainDead;
import me.yaruma.fightsystem.winconditions.WinconditionPercentSystem;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
@ -225,51 +224,84 @@ public class FightSystem extends JavaPlugin {
}
public void setPreRunningState() {
if(this.fightState == FightState.SETUP) {
this.fightState = FightState.PRE_RUNNING;
if(this.fightState != FightState.SETUP)
return;
this.fightState = FightState.PRE_RUNNING;
int time = fileManager.getIntegerFromConfig("Times.PreFightDuration");
Countdown countdown = new Countdown(time, new FinishPreRunning());
countdown.startTimer(this);
for(FightPlayer allFightPlayers : Fight.getBlueTeam().getPlayers()) {
allFightPlayers.getPlayer().getInventory().clear();
}
for(FightPlayer allFightPlayers : Fight.getRedTeam().getPlayers()) {
allFightPlayers.getPlayer().getInventory().clear();
}
instance.getFightManager().teleportAllToFightSpawn();
WorldEdit.replace(Fight.getBlueTeam().getLeader().getPlayer(), team1cornerX, team1cornerY, team1cornerZ, team1cornerX + schemsizeX, team1cornerY + schemsizeY, team1cornerZ + schemsizeZ);
WorldEdit.replace(Fight.getRedTeam().getLeader().getPlayer(), team2cornerX, team2cornerY, team2cornerZ, team2cornerX + schemsizeX, team2cornerY + schemsizeY, team2cornerZ + schemsizeZ);
}
private void setAllPlayersGM(GameMode gm){
for(FightPlayer fightPlayer: Fight.getBlueTeam().getPlayers()){
fightPlayer.getPlayer().setGameMode(gm);
}
for(FightPlayer fightPlayer: Fight.getRedTeam().getPlayers()){
fightPlayer.getPlayer().setGameMode(gm);
}
}
public void setRunningState() {
if(this.fightState == FightState.PRE_RUNNING) {
this.fightState = FightState.RUNNING;
if(this.fightState != FightState.PRE_RUNNING)
return;
this.fightState = FightState.RUNNING;
setAllPlayersGM(GameMode.SURVIVAL);
if(fileManager.getBooleanFromConfig("WinConditions.Timeout")) {
int time = fileManager.getIntegerFromConfig("WinConditionParams.TimeoutTime");
Countdown countdown = new Countdown(time, new FinishTimeOver());
countdown.startTimer(FightSystem.getPlugin());
}
Bukkit.broadcastMessage("§aArena freigegeben!");
}
public void setSpectateState(FightTeam winFightTeam) {
if(this.fightState == FightState.RUNNING) {
this.fightState = FightState.SPECTATE;
if(this.fightState != FightState.RUNNING):
return;
this.fightState = FightState.SPECTATE;
Bukkit.broadcastMessage(" ");
setAllPlayersGM(GameMode.SPECTATOR);
entern = true;
Bukkit.broadcastMessage(" ");
if(winFightTeam != null) {
if(winFightTeam != null) {
Bukkit.broadcastMessage(PREFIX + "§aDas Team von §6" + winFightTeam.getLeader().getPlayer().getName() + " §ahat gewonnen!");
plugin.getFightManager().teleportAllToFightSpawn();
Bukkit.broadcastMessage(PREFIX + "§aDas Team von §6" + winFightTeam.getLeader().getPlayer().getName() + " §ahat gewonnen!");
plugin.getFightManager().teleportAllToFightSpawn();
for(FightPlayer fightPlayer : winFightTeam.getPlayers()) {
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Win"));
}
for(FightPlayer fightPlayer : Fight.getOpposite(winFightTeam).getPlayers()) {
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Lose"));
}
} else {
//Keine Message! Wird in FinishTimeOver gesendet!
for(FightPlayer fightPlayer : winFightTeam.getPlayers()) {
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Undecided"));
}
for(FightPlayer fightPlayer : Fight.getOpposite(winFightTeam).getPlayers()) {
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Undecided"));
}
for(FightPlayer fightPlayer : winFightTeam.getPlayers()) {
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Win"));
}
Countdown cancelAllCountdowns = new Countdown();
cancelAllCountdowns.cancelAllTimers(FightSystem.getPlugin());
Countdown countdown = new Countdown(20*60, new FinishSpectateOver());
countdown.startTimer(FightSystem.getPlugin());
for(FightPlayer fightPlayer : Fight.getOpposite(winFightTeam).getPlayers()) {
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Lose"));
}
} else {
//Keine Message! Wird in FinishTimeOver gesendet!
for(FightPlayer fightPlayer : winFightTeam.getPlayers()) {
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Undecided"));
}
for(FightPlayer fightPlayer : Fight.getOpposite(winFightTeam).getPlayers()) {
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Undecided"));
}
}
Countdown cancelAllCountdowns = new Countdown();
cancelAllCountdowns.cancelAllTimers(FightSystem.getPlugin());
Countdown countdown = new Countdown(20*60, new FinishSpectateOver());
countdown.startTimer(FightSystem.getPlugin());
}
public int getMoneyToPay(String moneyPath) {

Datei anzeigen

@ -10,48 +10,34 @@ public class Fight {
public static FightTeam getPlayerTeam(Player player) {
if(redTeam.isPlayerInTeam(player)) {
if(redTeam.isPlayerInTeam(player))
return redTeam;
}
if(blueTeam.isPlayerInTeam(player)) {
if(blueTeam.isPlayerInTeam(player))
return blueTeam;
}
return null;
}
public static FightTeam getOpposite(FightTeam fightTeam) {
if(fightTeam == redTeam) {
if(fightTeam == redTeam)
return blueTeam;
}
if(fightTeam == blueTeam) {
if(fightTeam == blueTeam)
return redTeam;
}
return null;
}
public static FightTeam getInvitedTeam(Player player){
if(redTeam.getInvited().contains(player)) {
if(redTeam.getInvited().contains(player))
return redTeam;
}else if(blueTeam.getInvited().contains(player)) {
else if(blueTeam.getInvited().contains(player))
return blueTeam;
}
return null;
}
public void broadcast(String message) {
blueTeam.broadcast(message);
redTeam.broadcast(message);
}
public static FightPlayer getFightPlayer(Player player) {
if(redTeam.isPlayerInTeam(player)) {
FightPlayer fightPlayer = redTeam.getFightPlayer(player);
return fightPlayer;
}
if(blueTeam.isPlayerInTeam(player)) {
FightPlayer fightPlayer = blueTeam.getFightPlayer(player);
return fightPlayer;
}
if(redTeam.isPlayerInTeam(player))
return redTeam.getFightPlayer(player);
if(blueTeam.isPlayerInTeam(player))
return blueTeam.getFightPlayer(player);
return null;
}

Datei anzeigen

@ -8,17 +8,15 @@ public class FightPlayer {
private boolean isOut;
public boolean equals(Object obj) {
if (!(obj instanceof Player)) {
if (!(obj instanceof Player))
return false;
}
Player comp = (Player)obj;
return this.player.getUniqueId().equals(comp.getUniqueId());
}
public void sendMessage(String message) {
if (this.player.isOnline()) {
if (this.player != null && this.player.isOnline())
this.player.sendMessage(message);
}
}
public FightPlayer(Player player, boolean isOut) {
@ -39,10 +37,7 @@ public class FightPlayer {
}
public boolean isLeader() {
if(Fight.getPlayerTeam(player).getLeader().getPlayer() == player) {
return true;
} else
return false;
return Fight.getPlayerTeam(player).getLeader().getPlayer() == player;
}

Datei anzeigen

@ -24,88 +24,71 @@ public class FightTeam {
public FightTeam(Player leader, FightSystem plugin) {
this.plugin = plugin;
this.leader = new FightPlayer(leader, false);
this.players = new ArrayList<>();
this.invited = new ArrayList<>();
players = new ArrayList<>();
invited = new ArrayList<>();
}
public FightPlayer getFightPlayer(Player player) {
if(this.leader.getPlayer().equals(player)) {
return this.leader;
}
for(FightPlayer fightPlayer : this.players) {
if(!fightPlayer.getPlayer().equals(player)) continue;
return fightPlayer;
if(leader.getPlayer().equals(player))
return leader;
for(FightPlayer fightPlayer : players) {
if(fightPlayer.getPlayer().equals(player))
return fightPlayer;
}
return null;
}
public void setPlayerOut(Player player) {
this.getFightPlayer(player).setOut(true);
getFightPlayer(player).setOut(true);
}
public boolean allPlayersOut() {
boolean allout = true;
if(!this.leader.isOut()) {
allout = false;
return false;
}
for(FightPlayer fightPlayer : this.players) {
if(fightPlayer.isOut()) continue;
allout = false;
if(!fightPlayer.isOut())
return false;
}
return allout;
return true;
}
public boolean isPlayerInTeam(Player player) {
for(FightPlayer fightPlayer : this.players) {
if(!fightPlayer.getPlayer().equals(player)) continue;
return true;
if(fightPlayer.getPlayer().equals(player))
return true;
}
if(this.leader.getPlayer() == null) return false;
if(this.leader.getPlayer().equals(player)) {
return true;
}
return false;
return leader.getPlayer() != null && leader.getPlayer().equals(player);
}
public boolean isPlayerLeader(Player player) {
if(this.leader.getPlayer().equals(player)) {
return true;
}
return false;
return leader.getPlayer().equals(player);
}
public boolean isPlayerMember(Player player) {
for(FightPlayer fightPlayer : this.players) {
if(!fightPlayer.getPlayer().equals(player)) continue;
return true;
}
return false;
return isPlayerInTeam(player) && !isPlayerLeader(player);
}
public void broadcast(String message) {
this.leader.sendMessage(message);
for(FightPlayer fightPlayer : this.players) {
leader.sendMessage(message);
for(FightPlayer fightPlayer : players) {
fightPlayer.sendMessage(message);
}
}
public void addMember(Player player) {
FightPlayer fightPlayer = new FightPlayer(player, false);
this.players.add(fightPlayer);
this.invited.remove(player);
players.add(fightPlayer);
invited.remove(player);
}
public void removePlayer(Player player) {
FightPlayer fightPlayer = Fight.getPlayerTeam(player).getFightPlayer(player);
this.players.remove(fightPlayer);
players.remove(fightPlayer);
}
public boolean hasTeamLeader() {
if(this.leader != null) {
return true;
} else
return false;
return leader.getPlayer() != null;
}
public FightPlayer getLeader() {
@ -145,18 +128,6 @@ public class FightTeam {
broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit!");
if(Fight.getOpposite(fightTeam).isReady()) {
instance.setPreRunningState();
int time = instance.getFileManager().getIntegerFromConfig("Times.PreFightDuration");
Countdown countdown = new Countdown(time, new FinishPreRunning());
countdown.startTimer(instance);
for(FightPlayer allFightPlayers : fightTeam.getPlayers()) {
allFightPlayers.getPlayer().getInventory().clear();
}
for(FightPlayer allFightPlayers : Fight.getOpposite(fightTeam).getPlayers()) {
allFightPlayers.getPlayer().getInventory().clear();
}
instance.getFightManager().teleportAllToFightSpawn();
WorldEdit.replace(fightTeam.getLeader().getPlayer(), instance.getTeam1cornerX(), instance.getTeam1cornerY(), instance.getTeam1cornerZ(), instance.getTeam1cornerX() + instance.getSchemsizeX(), instance.getTeam1cornerY() + instance.getSchemsizeY(), instance.getTeam1cornerZ() + instance.getSchemsizeZ());
WorldEdit.replace(Fight.getOpposite(fightTeam).getLeader().getPlayer(), instance.getTeam2cornerX(), instance.getTeam2cornerY(), instance.getTeam2cornerZ(), instance.getTeam2cornerX() + instance.getSchemsizeX(), instance.getTeam2cornerY() + instance.getSchemsizeY(), instance.getTeam2cornerZ() + instance.getSchemsizeZ());
}
} else {
fightTeam.getLeader().getPlayer().getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());

Datei anzeigen

@ -14,19 +14,15 @@ public class BlockBreakListener implements Listener {
public void handleBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
if(Fight.getPlayerTeam(player) == null) {
if(Fight.getPlayerTeam(player) == null)
event.setCancelled(true);
return;
}
if(FightSystem.getPlugin().getFightState() != FightState.RUNNING) {
else if(FightSystem.getPlugin().getFightState() != FightState.RUNNING) {
event.setCancelled(true);
if(FightSystem.getPlugin().getFightState() == FightState.RUNNING || FightSystem.getPlugin().getFightState() == FightState.PRE_RUNNING) {
player.sendMessage(FightSystem.PREFIX + "§cDu darfst erst nach Fightbeginn Blöcke setzen!");
if(FightSystem.getPlugin().getFightState() == FightState.PRE_RUNNING) {
player.sendMessage(FightSystem.PREFIX + "§cDu darfst erst nach Fightbeginn Blöcke abbauen!");
} else
player.sendMessage(FightSystem.PREFIX + "§cDu darfst keine Blöcke mehr setzen!");
return;
player.sendMessage(FightSystem.PREFIX + "§cDu darfst keine Blöcke mehr abbauen!");
}
}
}

Datei anzeigen

@ -14,19 +14,14 @@ public class BlockPlaceListener implements Listener {
public void handleBlockPlace(BlockPlaceEvent event) {
Player player = event.getPlayer();
if(Fight.getPlayerTeam(player) == null) {
if(Fight.getPlayerTeam(player) == null)
event.setCancelled(true);
return;
}
if(FightSystem.getPlugin().getFightState() != FightState.RUNNING) {
else if(FightSystem.getPlugin().getFightState() != FightState.RUNNING) {
event.setCancelled(true);
if(FightSystem.getPlugin().getFightState() == FightState.PRE_RUNNING) {
player.sendMessage(FightSystem.PREFIX + "§cDu darfst erst nach Fightbeginn Blöcke setzen!");
} else
player.sendMessage(FightSystem.PREFIX + "§cDu darfst keine Blöcke mehr setzen!");
return;
}
}
}

Datei anzeigen

@ -22,17 +22,13 @@ public class PlayerDeathListener implements Listener {
fightTeam.getFightPlayer(player).setOut(true);
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §cist gestorben!");
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 " + fightTeam.getLeader().getPlayer().getName() + " §csind gestorben!");
instance.setSpectateState(oppositeFightTeam);
return;
} else {
if(Fight.getPlayerTeam(player) == Fight.redTeam) {
if(Fight.getPlayerTeam(player) == Fight.redTeam){
player.teleport(instance.getFightManager().getRedTeleportLocation());
return;
}
if(Fight.getPlayerTeam(player) == Fight.blueTeam) {
player.teleport(instance.getFightManager().getRedTeleportLocation());
return;
}else{
player.teleport(instance.getFightManager().getBlueTeleportLocation());
}
}
}

Datei anzeigen

@ -28,37 +28,32 @@ public class PlayerInteractListener implements Listener {
@EventHandler
public void handlePlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
Material material = event.getItem().getType();
ItemMeta itemMeta = event.getItem().getItemMeta();
String displayName = itemMeta.getDisplayName();
if(instance.getFightState() == FightState.SETUP &&
event.getItem() != null &&
Fight.getPlayerTeam(player) != null) {
Material material = event.getItem().getType();
ItemMeta itemMeta = event.getItem().getItemMeta();
String displayName = itemMeta.getDisplayName();
if(instance.getFightState() == FightState.SETUP) {
if(Fight.getPlayerTeam(player) == null) return;
FightPlayer fightPlayer = Fight.getPlayerTeam(player).getFightPlayer(player);
if(fightPlayer.isLeader()) {
if(fightPlayer.isLeader() && material == Material.INK_SACK) {
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(material == null) return;
if(material == Material.INK_SACK) {
FightTeam fightTeam = Fight.getPlayerTeam(player);
switch (displayName) {
case "§cNicht bereit":
fightTeam.setReady(true);
break;
case "§aBereit":
fightTeam.setReady(false);
break;
case "§4Abbrechen":
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team von §a" + fightTeam.getLeader().getPlayer().getName() + " §6hat den Kampf abgebrochen! \n Server stoppt in 30 Sekunden...");
Countdown countdown = new Countdown(20*30, new FinishNoPlayersOnline());
countdown.startTimer(instance);
break;
default:
event.setCancelled(true);
break;
}
switch (displayName) {
case "§cNicht bereit":
fightTeam.setReady(true);
break;
case "§aBereit":
fightTeam.setReady(false);
break;
case "§4Abbrechen":
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team von §a" + fightTeam.getLeader().getPlayer().getName() + " §6hat den Kampf abgebrochen! \n Server stoppt in 30 Sekunden...");
Countdown countdown = new Countdown(20*30, new FinishNoPlayersOnline());
countdown.startTimer(instance);
break;
default:
event.setCancelled(true);
break;
}
}
}

Datei anzeigen

@ -47,32 +47,30 @@ public class PlayerJoinListener implements Listener {
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(Fight.getPlayerTeam(player) != null) {
if(fightTeam != null) {
FightPlayer fightPlayer = fightTeam.getFightPlayer(player);
if(instance.getFightState() == FightState.SETUP) {
if(fightTeam == Fight.redTeam) {
if(fightTeam == Fight.redTeam)
player.teleport(instance.getFightManager().getRedTeleportLocation());
} else
else
player.teleport(instance.getFightManager().getBlueTeleportLocation());
player.setGameMode(GameMode.SURVIVAL);
player.setGameMode(GameMode.ADVENTURE);
if(fightPlayer.isLeader()) SetupItems.giveSetupItems(player);
if(fightPlayer.isOut()) {
fightPlayer.setOut(false);
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §6" + fightPlayer.getPlayer().getName() + " §aist dem Kampf wieder beigetreten!");
}
fightPlayer.setOut(false);
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §6" + fightPlayer.getPlayer().getName() + " §aist dem Kampf wieder beigetreten!");
} else {
player.setGameMode(GameMode.SPECTATOR);
if(fightTeam == Fight.redTeam) {
player.teleport(FightSystem.getPlugin().getTeam1SpawnLoc());
} else
player.teleport(FightSystem.getPlugin().getTeam2SpawnLoc());
if(fightTeam == Fight.redTeam)
player.teleport(instance.getFightManager().getRedTeleportLocation());
else
player.teleport(instance.getFightManager().getBlueTeleportLocation());
}
}
if(Fight.getRedTeam().getLeader().getPlayer() != null && Fight.getBlueTeam().getLeader().getPlayer() != null) {
if(Fight.getRedTeam().hasTeamLeader() && Fight.getBlueTeam().hasTeamLeader()) {
int setupDuration = fileManager.getIntegerFromConfig("Times.SetupDuration");
Countdown countdown = new Countdown(setupDuration, new FinishSetupOver());
countdown.startTimer(instance);

Datei anzeigen

@ -2,6 +2,7 @@ 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 me.yaruma.fightsystem.manager.FileManager;
import me.yaruma.fightsystem.utils.Region;
@ -21,36 +22,44 @@ public class PlayerMoveListener implements Listener {
Player player = event.getPlayer();
Location to = event.getTo();
Location from = event.getFrom();
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(Fight.getPlayerTeam(player) == null) {
if(Region.isInRegion(to, instance.getTeam1cornerX(), instance.getTeam1cornerY(), instance.getTeam1cornerZ(), instance.getTeam1cornerX() + instance.getSchemsizeX(), instance.getTeam1cornerY() + instance.getSchemsizeY(), instance.getTeam1cornerZ() + instance.getSchemsizeZ(), fileManager.getIntegerFromConfig("Arena.BorderFromSchematic")) || Region.isInRegion(to, instance.getTeam2cornerX(), instance.getTeam2cornerY(), instance.getTeam2cornerZ(), instance.getTeam2cornerX() + instance.getSchemsizeX(), instance.getTeam2cornerY() + instance.getSchemsizeY(), instance.getTeam2cornerZ() + instance.getSchemsizeZ(), fileManager.getIntegerFromConfig("Arena.BorderFromSchematic"))) {
player.teleport(from);
player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht weiter zu den Kämpfern!");
}
//Check in Arena
if(!Region.isIn2DRegion(to, instance.ArenaMinX, instance.ArenaMinZ, instance.ArenaMaxX, instance.ArenaMaxZ)){
player.teleport(from);
player.sendMessage(FightSystem.PREFIX + "§cDu darfst die Arena nicht verlassen!");
return;
}
if(!instance.isEntern()) {
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(Region.isInRegion(to, instance.getTeam1cornerX(), instance.getTeam1cornerY(), instance.getTeam1cornerZ(), instance.getTeam1cornerX() + instance.getSchemsizeX(), instance.getTeam1cornerY() + instance.getSchemsizeY(), instance.getTeam1cornerZ() + instance.getSchemsizeZ(), fileManager.getIntegerFromConfig("Arena.BorderFromSchematic"))) {
if(fightTeam == Fight.blueTeam) {
player.teleport(from);
player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht zu Team " + fileManager.getStringFromConfig("Output.TeamRedColor") + fileManager.getStringFromConfig("Output.TeamRedName") + " §c!");
}
} else if(Region.isInRegion(to, instance.getTeam2cornerX(), instance.getTeam2cornerY(), instance.getTeam2cornerZ(), instance.getTeam2cornerX() + instance.getSchemsizeX(), instance.getTeam2cornerY() + instance.getSchemsizeY(), instance.getTeam2cornerZ() + instance.getSchemsizeZ(), fileManager.getIntegerFromConfig("Arena.BorderFromSchematic"))) {
if(fightTeam == Fight.redTeam) {
player.teleport(from);
player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht zu Team " + fileManager.getStringFromConfig("Output.TeamBlueColor") + fileManager.getStringFromConfig("Output.TeamBlueName") + " §c!");
}
}
//Check under Arena
if(to.getBlockY() <= fileManager.getIntegerFromConfig("Arena.underArenaBorder")) {
if(fightTeam == null){
player.teleport(from);
player.sendMessage(FightSystem.PREFIX + "§cDu darfst die Arena nicht verlassen!");
}else if(instance.getCurrentFightState() == FightState.RUNNING)
player.damage(2);
else if(fightTeam == Fight.redTeam)
player.teleport(instance.getFightManager().getRedTeleportLocation());
else
player.teleport(instance.getFightManager().getBlueTeleportLocation());
return;
}
if(to.getBlockY() <= fileManager.getIntegerFromConfig("Arena.underArenaBorder")) {
player.damage(2);
//Check TeamAreas
boolean inBlueArea = Region.isIn2DRange(to, instance.getTeam1cornerX(), instance.getTeam1cornerZ(), instance.getSchemsizeX(), instance.getSchemsizeZ(), fileManager.getIntegerFromConfig("Arena.BorderFromSchematic"));
boolean inRedArea = Region.isIn2DRange(to, instance.getTeam2cornerX(), instance.getTeam2cornerZ(), instance.getSchemsizeX(), instance.getSchemsizeZ(), fileManager.getIntegerFromConfig("Arena.BorderFromSchematic"));
if(inBlueArea || inRedArea) {
if(fightTeam == null){
player.teleport(from);
player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht weiter zu den Kämpfern!");
}
}else if(fightTeam != null && !instance.isEntern()){
player.teleport(from);
if (fightTeam == Fight.blueTeam)
player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht zu Team " + fileManager.getStringFromConfig("Output.TeamRedColor") + fileManager.getStringFromConfig("Output.TeamRedName") + " §c!");
else
player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht zu Team " + fileManager.getStringFromConfig("Output.TeamBlueColor") + fileManager.getStringFromConfig("Output.TeamBlueName") + " §c!");
}
}
}

Datei anzeigen

@ -28,7 +28,6 @@ public class PlayerQuitListener implements Listener {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von §6" + fightTeam.getLeader().getPlayer() + " §chaben den Kampf verlassen! \n §4Stoppe Server in 30 Sekunden...");
Countdown countdown = new Countdown(30*20, new FinishNoPlayersOnline());
countdown.startTimer(FightSystem.getPlugin());
return;
} else {
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!");
FightSystem.getPlugin().setSpectateState(Fight.getOpposite(fightTeam));

Datei anzeigen

@ -5,13 +5,31 @@ import org.bukkit.entity.Player;
public class Region {
public static boolean isInRegion(Location location, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int border) {
if(location.getBlockX() >= (minX - border) && location.getBlockX() <= (maxX + border) && location.getBlockY() >= (minY - border) && location.getBlockY() <= (maxY + border) && location.getBlockZ() >= (minZ - border) && location.getBlockZ() <= (maxX + border)) {
return true;
} else
return false;
public static boolean isInRange(Location location, int minX, int minY, int minZ, int xRange, int yRange, int zRange, int margin) {
return isInRegion(location, minX, minY, minZ, minX + xRange, minY + yRange, minZ + zRange, margin);
}
public static boolean isInRegion(Location location, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int margin) {
return isIn2DRegion(location, minX, minZ, maxX, maxZ, margin) && inRange(location.getBlockY(), minY, maxY, margin);
}
public static boolean isIn2DRange(Location location, int minX, int minZ, int xRange, int zRange, int margin){
return isIn2DRegion(location, minX, minZ, minX + xRange, minZ + zRange, margin);
}
public static boolean isIn2DRegion(Location location, int minX, int minZ, int maxX, int maxZ, int margin){
return inRange(location.getBlockX(), minX, maxX, margin) && inRange(location.getBlockZ(), minZ, maxZ, margin);
}
public static boolean isIn2DRegion(Location location, int minX, int minZ, int maxX, int maxZ){
return inRange(location.getBlockX(), minX, maxX, margin) && inRange(location.getBlockZ(), minZ, maxZ, margin);
}
public static boolean inRange(double value, int min, int max, int margin){
return inRange(value, min-margin, max+margin);
}
public static boolean inRange(double value, int min, int max){
return min <= value && value <= max;
}
}

Datei anzeigen

@ -16,12 +16,5 @@ public class FinishPreRunning implements CountdownCallback {
@Override
public void countdownFinished() {
FightSystem.getPlugin().setRunningState();
if(fileManager.getBooleanFromConfig("WinConditions.Timeout")) {
int time = fileManager.getIntegerFromConfig("WinConditionParams.TimeoutTime");
Countdown countdown = new Countdown(time, new FinishTimeOver());
countdown.startTimer(FightSystem.getPlugin());
}
Bukkit.broadcastMessage("§aArena freigegeben!");
}
}