168 Zeilen
5.7 KiB
Java
168 Zeilen
5.7 KiB
Java
|
package me.yaruma.fightsystem.commands;
|
||
|
|
||
|
import me.yaruma.fightsystem.FightSystem;
|
||
|
import me.yaruma.fightsystem.fight.Fight;
|
||
|
import me.yaruma.fightsystem.fight.FightPlayer;
|
||
|
import me.yaruma.fightsystem.fight.FightState;
|
||
|
import me.yaruma.fightsystem.fight.FightTeam;
|
||
|
import me.yaruma.fightsystem.utils.Config;
|
||
|
import org.bukkit.Bukkit;
|
||
|
import org.bukkit.GameMode;
|
||
|
import org.bukkit.entity.Player;
|
||
|
|
||
|
public class Commands {
|
||
|
|
||
|
private static void errNoTeam(Player p){
|
||
|
p.sendMessage(FightSystem.PREFIX + "§cDu bist in keinem Team!");
|
||
|
}
|
||
|
|
||
|
private static boolean checkSetupOver(Player p){
|
||
|
if(FightSystem.getFightState() != FightState.SETUP){
|
||
|
p.sendMessage(FightSystem.PREFIX + "§cDer Kampf hat bereits begonnen!");
|
||
|
return false;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
private static FightTeam checkGetInvitedTeam(Player p){
|
||
|
FightTeam fightTeam = Fight.getInvitedTeam(p);
|
||
|
if(fightTeam == null){
|
||
|
p.sendMessage(FightSystem.PREFIX + "§cDu wurdest von keinem Team eingeladen!");
|
||
|
}
|
||
|
return fightTeam;
|
||
|
}
|
||
|
|
||
|
private static FightPlayer checkGetPlayer(Player p){
|
||
|
FightPlayer fightPlayer = Fight.getFightPlayer(p);
|
||
|
if(fightPlayer == null){
|
||
|
errNoTeam(p);
|
||
|
}
|
||
|
return fightPlayer;
|
||
|
}
|
||
|
|
||
|
private static FightPlayer checkGetLeader(Player p){
|
||
|
FightPlayer fightPlayer = checkGetPlayer(p);
|
||
|
if(fightPlayer != null && !fightPlayer.isLeader()){
|
||
|
p.sendMessage(FightSystem.PREFIX + "§cDu bist kein Leader!");
|
||
|
fightPlayer = null;
|
||
|
}
|
||
|
return fightPlayer;
|
||
|
}
|
||
|
|
||
|
private static FightTeam checkGetTeam(Player p){
|
||
|
FightTeam fightTeam = Fight.getPlayerTeam(p);
|
||
|
if(fightTeam == null){
|
||
|
errNoTeam(p);
|
||
|
}
|
||
|
return fightTeam;
|
||
|
}
|
||
|
|
||
|
private static Player checkGetPlayer(Player p, String t){
|
||
|
Player target = Bukkit.getPlayer(t);
|
||
|
if(target == null) {
|
||
|
p.sendMessage(FightSystem.PREFIX + "§cDer Spieler ist nicht online!");
|
||
|
}
|
||
|
return target;
|
||
|
}
|
||
|
|
||
|
static void toggleReady(Player p){
|
||
|
if(!checkSetupOver(p))
|
||
|
return;
|
||
|
|
||
|
FightTeam fightTeam = checkGetTeam(p);
|
||
|
if(fightTeam == null || checkGetLeader(p) == null)
|
||
|
return;
|
||
|
|
||
|
fightTeam.setReady(!fightTeam.isReady());
|
||
|
}
|
||
|
|
||
|
static void acceptInvitation(Player p){
|
||
|
if(!checkSetupOver(p))
|
||
|
return;
|
||
|
|
||
|
FightTeam team = checkGetInvitedTeam(p);
|
||
|
if(team == null)
|
||
|
return;
|
||
|
|
||
|
FightPlayer leader = team.getLeader();
|
||
|
team.addMember(p);
|
||
|
p.setGameMode(GameMode.ADVENTURE);
|
||
|
p.teleport(team.getSpawn());
|
||
|
p.sendMessage(FightSystem.PREFIX + "§aDu bist Team " + team.getName() + " §abeigetreten!");
|
||
|
leader.sendMessage(FightSystem.PREFIX + "§aDer Spieler §6" + p.getName() + " §aist deinem Team beigetreten!");
|
||
|
}
|
||
|
|
||
|
static void declineInvitation(Player p){
|
||
|
if(!checkSetupOver(p))
|
||
|
return;
|
||
|
|
||
|
FightTeam team = checkGetInvitedTeam(p);
|
||
|
if(team == null)
|
||
|
return;
|
||
|
|
||
|
FightPlayer leader = team.getLeader();
|
||
|
team.getInvited().remove(p);
|
||
|
p.sendMessage(FightSystem.PREFIX + "§aDu hast die Einladung von " + team.getName() + " §aabgelehnt!");
|
||
|
leader.sendMessage(FightSystem.PREFIX + "§cDer Spieler §6" + p.getName() + " §chat deine Einladung abgelehnt!");
|
||
|
}
|
||
|
|
||
|
static void leaveTeam(Player p){
|
||
|
if(!checkSetupOver(p))
|
||
|
return;
|
||
|
|
||
|
FightTeam fightTeam = checkGetTeam(p);
|
||
|
if(fightTeam == null)
|
||
|
return;
|
||
|
|
||
|
fightTeam.removePlayer(p);
|
||
|
p.setGameMode(GameMode.SPECTATOR);
|
||
|
p.teleport(Config.SpecSpawn);
|
||
|
p.sendMessage(FightSystem.PREFIX + "§aDu hast das Team " + fightTeam.getName() + " §averlassen!");
|
||
|
}
|
||
|
|
||
|
static void invite(Player p, String invited){
|
||
|
if(!checkSetupOver(p))
|
||
|
return;
|
||
|
|
||
|
FightTeam fightTeam = checkGetTeam(p);
|
||
|
if(fightTeam == null)
|
||
|
return;
|
||
|
|
||
|
FightPlayer fightPlayer = checkGetLeader(p);
|
||
|
if(fightPlayer == null)
|
||
|
return;
|
||
|
|
||
|
Player target = checkGetPlayer(p, invited);
|
||
|
if(target == null)
|
||
|
return;
|
||
|
|
||
|
if(Fight.getPlayerTeam(target) != null) {
|
||
|
p.sendMessage(FightSystem.PREFIX + "§cDer Spieler §6" + target.getName() + " §cist bereits in einem Team!");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if(Fight.getOpposite(fightTeam).getInvited().contains(target) || fightTeam.getInvited().contains(target)) {
|
||
|
p.sendMessage(FightSystem.PREFIX + "§cDieser Spieler wurde bereits eingeladen!");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
fightTeam.getInvited().add(target);
|
||
|
target.sendMessage(FightSystem.PREFIX + "§aDu wurdest in das Team von §6" + p.getName() + " §aeingeladen!");
|
||
|
p.sendMessage(FightSystem.PREFIX + "§aDu hast den Spieler §6" + target.getName() + " §ain dein Team eingeladen!");
|
||
|
GUI.invitation(p, target);
|
||
|
}
|
||
|
|
||
|
static void sendHelp(Player p) {
|
||
|
p.sendMessage(FightSystem.PREFIX + "§7Hilfe für das Kampfsystem");
|
||
|
p.sendMessage("§8/§6ak help §8- §7Zeigt diese Hilfeseite");
|
||
|
p.sendMessage("§8/§6ak leader §8- §7Tritt einem Team als Leader bei");
|
||
|
p.sendMessage("§8/§6ak kit <Kit> §8- §7Wähle ein Kit");
|
||
|
p.sendMessage("§8/§6ak schem <Schematic> §8- §7Setze deine Schematic");
|
||
|
p.sendMessage("§8/§6ready §8- §7Setzt das eigene Team auf bereit");
|
||
|
p.sendMessage("§8/§6invite [Spieler] §8- §7Lade den Spieler in dein Team bei");
|
||
|
p.sendMessage("§8/§6accept §8- §7Einladung annehmen");
|
||
|
p.sendMessage("§8/§6decline §8- §7Einladung ablehnen");
|
||
|
p.sendMessage("§8/§6leave §8- §7Team verlassen");
|
||
|
|
||
|
}
|
||
|
}
|