SteamWar/FightSystem
Archiviert
13
1

Added method getFightPlayer() to Fight class;

Code Cleanup PlayerDeathListener;
Added WinConditions;
Added Win/Lose/Undecided and give money to FightPlayers;
Added money variables to config.yml;

Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Yaruma3341 2019-02-17 20:29:32 +01:00
Ursprung 6b4b993590
Commit 2d03c39883
8 geänderte Dateien mit 139 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -32,12 +32,20 @@ Output:
GameName: AirWargear GameName: AirWargear
TeamChatDetection: + TeamChatDetection: +
ActiveWinConditions: WinConditions:
Timeout: boolean Timeout: boolean
AllDead: boolean AllDead: boolean
CaptainDead: boolean CaptainDead: boolean
Entern: boolean
WinConditionParams: WinConditionParams:
TimeoutTime: 0 TimeoutTime: 0
EnterPhaseBegin: 0 EnterPhaseBegin: 0
Fight:
Entern: boolean
OnlyPublicSchematics: boolean
Money:
Win: 0
Lose: 0
Undecided: 0

Datei anzeigen

@ -1,10 +1,9 @@
package me.yaruma.fightsystem; package me.yaruma.fightsystem;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import de.diamant.hunjy.CoinSystem.CoinSystem;
import me.yaruma.fightsystem.commands.AkCommand; import me.yaruma.fightsystem.commands.AkCommand;
import me.yaruma.fightsystem.fight.FightManager; import me.yaruma.fightsystem.fight.*;
import me.yaruma.fightsystem.fight.FightState;
import me.yaruma.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.listener.*; import me.yaruma.fightsystem.listener.*;
import me.yaruma.fightsystem.manager.FileManager; import me.yaruma.fightsystem.manager.FileManager;
import me.yaruma.fightsystem.utils.countdown.Countdown; import me.yaruma.fightsystem.utils.countdown.Countdown;
@ -25,7 +24,6 @@ public class FightSystem extends JavaPlugin {
private static FightSystem plugin; private static FightSystem plugin;
private FileManager fileManager; private FileManager fileManager;
private FightManager fightManager; private FightManager fightManager;
private Coordinates coordinates;
private FightState fightState; private FightState fightState;
@ -211,9 +209,34 @@ public class FightSystem extends JavaPlugin {
this.fightState = FightState.SPECTATE; this.fightState = FightState.SPECTATE;
Bukkit.broadcastMessage(" "); Bukkit.broadcastMessage(" ");
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDas Team von §6" + winFightTeam.getLeader().getPlayer().getName() + " §ahat gewonnen!");
if(winFightTeam != null) {
Bukkit.broadcastMessage(PREFIX + "§aDas Team von §6" + winFightTeam.getLeader().getPlayer().getName() + " §ahat gewonnen!");
plugin.getFightManager().teleportAllToFightSpawn(); 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"));
}
}
}
}
public int getMoneyToPay(String moneyPath) {
return fileManager.getIntegerFromConfig(moneyPath);
} }
public static WorldEditPlugin getWorldEditPlugin() { public static WorldEditPlugin getWorldEditPlugin() {

Datei anzeigen

@ -42,6 +42,18 @@ public class Fight {
redTeam.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;
}
return null;
}
public static FightTeam getRedTeam() { public static FightTeam getRedTeam() {
return redTeam; return redTeam;
} }

Datei anzeigen

@ -15,7 +15,7 @@ public class PlayerDeathListener implements Listener {
@EventHandler @EventHandler
public void handlePlayerDeath(PlayerDeathEvent event) { public void handlePlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity(); Player player = event.getEntity().getPlayer();
if(Fight.getPlayerTeam(player) == null) return; if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player); FightTeam fightTeam = Fight.getPlayerTeam(player);
FightTeam oppositeFightTeam = Fight.getOpposite(fightTeam); FightTeam oppositeFightTeam = Fight.getOpposite(fightTeam);

Datei anzeigen

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

Datei anzeigen

@ -0,0 +1,33 @@
package me.yaruma.fightsystem.winconditions;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightPlayer;
import me.yaruma.fightsystem.fight.FightTeam;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
public class WinconditionAllDead implements Listener {
FightSystem instance = FightSystem.getPlugin();
@EventHandler
public void handlePlayerDeath(PlayerDeathEvent event) {
if(!Methods.isEnabled("WinConditions.AllDead")) return;
Player player = event.getEntity().getPlayer();
if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player);
FightTeam oppositeFightTeam = Fight.getOpposite(fightTeam);
if(fightTeam.allPlayersOut()) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von " + fightTeam.getLeader().getPlayer().getName() + " §csind gestorben!");
instance.setSpectateState(oppositeFightTeam);
return;
}
}
}

Datei anzeigen

@ -0,0 +1,36 @@
package me.yaruma.fightsystem.winconditions;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.manager.FileManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
public class WinconditionCaptainDead implements Listener {
FightSystem instance = FightSystem.getPlugin();
FileManager fileManager = instance.getFileManager();
@EventHandler
public void handlePlayerDeath(PlayerDeathEvent event) {
if(!Methods.isEnabled("WinConditions.CaptainDead")) return;
Player player = event.getEntity().getPlayer();
if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player);
FightTeam oppositeFightTeam = Fight.getOpposite(fightTeam);
String team = Fight.getRedTeam().isPlayerLeader(player) ? "Red" : "Blue";
if(fightTeam.isPlayerLeader(player)) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von Team " + fileManager.getStringFromConfig("Output.Team" + team + "Color") + fileManager.getStringFromConfig("Output.Team" + team + "Name") + " §cist gestorben!");
instance.setSpectateState(oppositeFightTeam);
return;
}
}
}

Datei anzeigen

@ -0,0 +1,6 @@
package me.yaruma.fightsystem.winconditions;
public class WinconditionTimeout {
}