SteamWar/FightSystem
Archiviert
13
1
Dieses Repository wurde am 2024-08-05 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
FightSystem/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java

70 Zeilen
2.3 KiB
Java

package de.steamwar.fightsystem.fight;
import de.steamwar.fightsystem.Config;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
public class Fight {
private Fight(){}
public static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedPrefix, Config.TeamRedSpawn, Config.TeamRedCornerX, Config.TeamRedCornerY, Config.TeamRedCornerZ, Config.TeamRedRotate, false, Config.RedLeader);
public static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBluePrefix, Config.TeamBlueSpawn, Config.TeamBlueCornerX, Config.TeamBlueCornerY, Config.TeamBlueCornerZ, Config.TeamBlueRotate, true, Config.BlueLeader);
public static void init(){
IFight.init(redTeam, blueTeam);
}
public static FightTeam getPlayerTeam(Player player) {
if(redTeam.isPlayerInTeam(player))
return redTeam;
if(blueTeam.isPlayerInTeam(player))
return blueTeam;
return null;
}
public static FightTeam getOpposite(FightTeam fightTeam) {
if(fightTeam == null){
throw new IllegalArgumentException();
}
if(fightTeam == redTeam)
return blueTeam;
else
return redTeam;
}
public static FightTeam getInvitedTeam(Player player){
if(redTeam.getInvited().contains(player))
return redTeam;
else if(blueTeam.getInvited().contains(player))
return blueTeam;
return null;
}
public static FightPlayer getFightPlayer(Player player) {
if(redTeam.isPlayerInTeam(player))
return redTeam.getFightPlayer(player);
if(blueTeam.isPlayerInTeam(player))
return blueTeam.getFightPlayer(player);
return null;
}
public static FightTeam getRedTeam() {
return redTeam;
}
public static FightTeam getBlueTeam() {
return blueTeam;
}
public static void playSound(Sound sound, float volume, float pitch) {
//volume: max. 100, pitch: max. 2
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch));
}
public static void setLevel(int level) {
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.setLevel(level));
}
}