SteamWar/FightSystem
Archiviert
13
1

Region System erweitert und Überarbeitung der Config

Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Yaruma3341 2019-02-15 23:23:07 +01:00
Ursprung 15d25dfea9
Commit 02792c325f
5 geänderte Dateien mit 59 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -2,7 +2,6 @@ Times:
SetupDuration: 0
PreFightDuration: 0
FightDuration: 0
EnterPhaseBegin: 0
SpectatorDuration: 0
Arena:
@ -23,7 +22,7 @@ Arena:
x: 0
z: 0
underArenaBorder: 0
BorderFromWarGear: 0
BorderFromSchematic: 0
Output:
TeamRedColor: &c
@ -34,9 +33,11 @@ Output:
TeamChatDetection: +
ActiveWinConditions:
- Timeout
- AllDead
- CaptainDead
Timeout: boolean
AllDead: boolean
CaptainDead: boolean
Entern: boolean
WinConditionParams:
TimeoutTime: 0
EnterPhaseBegin: 0

Datei anzeigen

@ -48,6 +48,10 @@ public class FightSystem extends JavaPlugin {
public int team1cornerY;
public int team1cornerZ;
public int team2cornerX;
public int team2cornerY;
public int team2cornerZ;
public void onEnable() {
plugin = this;
@ -70,6 +74,10 @@ public class FightSystem extends JavaPlugin {
int schem2BorderX = fileManager.getIntegerFromConfig("Arena.Schem2Border.x");
int schem2BorderZ = fileManager.getIntegerFromConfig("Arena.Schem2Border.z");
team2cornerX = team1toTeam2distanceX + team1cornerX;
team2cornerY = team1toTeam2distanceY + team1cornerY;
team2cornerZ = team1toTeam2distanceZ + schemsizeZ + 1 + team1cornerZ;
coordinates.computePositions(schemsizeX, schemsizeY, schemsizeZ, team1cornerX, team1cornerY, team1cornerZ, team1toTeam2distanceX, team1toTeam2distanceY, team1toTeam2distanceZ, schem2BorderX, schem2BorderZ);
@ -101,6 +109,7 @@ public class FightSystem extends JavaPlugin {
pm.registerEvents(new PlayerChatListener(), plugin);
pm.registerEvents(new BlockPlaceListener(), plugin);
pm.registerEvents(new BlockBreakListener(), plugin);
pm.registerEvents(new PlayerMoveListener(), plugin);
getCommand("ak").setExecutor(new AkCommand());
}
@ -222,6 +231,18 @@ public class FightSystem extends JavaPlugin {
return team1cornerZ;
}
public int getTeam2cornerX() {
return team2cornerX;
}
public int getTeam2cornerY() {
return team2cornerY;
}
public int getTeam2cornerZ() {
return team2cornerZ;
}
public void setTeam1SpawnLoc(Location team1SpawnLoc) {
Team1SpawnLoc = team1SpawnLoc;
}

Datei anzeigen

@ -11,6 +11,8 @@ import org.bukkit.event.entity.PlayerDeathEvent;
public class PlayerDeathListener implements Listener {
FightSystem instance = FightSystem.getPlugin();
@EventHandler
public void handlePlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity();
@ -20,11 +22,21 @@ public class PlayerDeathListener implements Listener {
fightTeam.getFightPlayer(player).setOut(true);
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §cist gestorben!");
if(fightTeam.allPlayersOut()) {
FightSystem.getPlugin().setSpectateState();
instance.setSpectateState();
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von " + fightTeam.getLeader().getPlayer().getName() + " §csind gestorben!");
Bukkit.broadcastMessage(" ");
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDas Team von §6" + oppositeFightTeam.getLeader().getPlayer().getName() + " §ahat gewonnen!");
FightSystem.getPlugin().getFightManager().teleportAllToFightSpawn();
instance.getFightManager().teleportAllToFightSpawn();
return;
} else {
if(Fight.getPlayerTeam(player) == Fight.redTeam) {
player.teleport(instance.getFightManager().getRedTeleportLocation());
return;
}
if(Fight.getPlayerTeam(player) == Fight.blueTeam) {
player.teleport(instance.getFightManager().getRedTeleportLocation());
return;
}
}
}

Datei anzeigen

@ -3,6 +3,7 @@ package me.yaruma.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.manager.FileManager;
import me.yaruma.fightsystem.utils.Region;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -13,6 +14,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
public class PlayerMoveListener implements Listener {
FightSystem instance = FightSystem.getPlugin();
FileManager fileManager = FightSystem.getPlugin().getFileManager();
@EventHandler
public void handlePlayerMove(PlayerMoveEvent event) {
@ -20,11 +22,23 @@ public class PlayerMoveListener implements Listener {
Location to = event.getTo();
Location from = event.getFrom();
if(!Region.isInRegion(to, instance.getTeam1cornerX(), instance.getTeam1cornerY(), instance.getTeam1cornerZ(), instance.getSchemsizeX(), instance.getSchemsizeY(), instance.getSchemsizeZ())) {
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam == 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.getTeam1cornerY(), 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!");
}
}
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.getTeam1cornerY(), 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!");
}
} else 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!");
}
}

Datei anzeigen

@ -5,9 +5,9 @@ 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) {
public static boolean isInRegion(Location location, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int border) {
if(location.getBlockX() >= minX && location.getBlockX() <= maxX && location.getBlockY() >= minY && location.getBlockY() <= maxY && location.getBlockZ() >= minZ && location.getBlockZ() <= maxX) {
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;