2019-09-05 18:26:13 +02:00
|
|
|
package de.steamwar.fightsystem.fight;
|
2019-02-14 18:37:38 +01:00
|
|
|
|
2019-11-16 08:37:33 +01:00
|
|
|
import de.steamwar.fightsystem.Config;
|
2019-07-04 22:07:12 +02:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.Sound;
|
2019-02-14 18:37:38 +01:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
public class Fight {
|
2019-09-05 18:26:13 +02:00
|
|
|
private Fight(){}
|
2019-02-14 18:37:38 +01:00
|
|
|
|
2019-11-23 18:15:45 +01:00
|
|
|
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);
|
2019-02-14 18:37:38 +01:00
|
|
|
|
2019-11-16 08:37:33 +01:00
|
|
|
public static void init(){
|
|
|
|
IFight.init(redTeam, blueTeam);
|
|
|
|
}
|
|
|
|
|
2019-02-14 18:37:38 +01:00
|
|
|
public static FightTeam getPlayerTeam(Player player) {
|
2019-02-23 16:07:31 +01:00
|
|
|
if(redTeam.isPlayerInTeam(player))
|
2019-02-14 18:37:38 +01:00
|
|
|
return redTeam;
|
2019-02-23 16:07:31 +01:00
|
|
|
if(blueTeam.isPlayerInTeam(player))
|
2019-02-14 18:37:38 +01:00
|
|
|
return blueTeam;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static FightTeam getOpposite(FightTeam fightTeam) {
|
2019-09-05 18:26:13 +02:00
|
|
|
if(fightTeam == null){
|
|
|
|
throw new IllegalArgumentException();
|
|
|
|
}
|
|
|
|
|
2019-02-23 16:07:31 +01:00
|
|
|
if(fightTeam == redTeam)
|
2019-02-14 18:37:38 +01:00
|
|
|
return blueTeam;
|
2019-09-05 18:26:13 +02:00
|
|
|
else
|
2019-02-14 18:37:38 +01:00
|
|
|
return redTeam;
|
|
|
|
}
|
|
|
|
|
2019-02-15 16:04:50 +01:00
|
|
|
public static FightTeam getInvitedTeam(Player player){
|
2019-02-23 16:07:31 +01:00
|
|
|
if(redTeam.getInvited().contains(player))
|
2019-02-15 16:04:50 +01:00
|
|
|
return redTeam;
|
2019-02-23 16:07:31 +01:00
|
|
|
else if(blueTeam.getInvited().contains(player))
|
2019-02-15 16:04:50 +01:00
|
|
|
return blueTeam;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2019-02-17 20:29:32 +01:00
|
|
|
public static FightPlayer getFightPlayer(Player player) {
|
2019-02-23 16:07:31 +01:00
|
|
|
if(redTeam.isPlayerInTeam(player))
|
|
|
|
return redTeam.getFightPlayer(player);
|
|
|
|
if(blueTeam.isPlayerInTeam(player))
|
|
|
|
return blueTeam.getFightPlayer(player);
|
2019-02-17 20:29:32 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2019-02-14 18:37:38 +01:00
|
|
|
public static FightTeam getRedTeam() {
|
|
|
|
return redTeam;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static FightTeam getBlueTeam() {
|
|
|
|
return blueTeam;
|
|
|
|
}
|
2019-07-04 22:07:12 +02:00
|
|
|
|
|
|
|
public static void playSound(Sound sound, float volume, float pitch) {
|
2019-09-05 18:26:13 +02:00
|
|
|
//volume: max. 100, pitch: max. 2
|
|
|
|
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch));
|
2019-07-04 22:07:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void setLevel(int level) {
|
2019-09-05 18:26:13 +02:00
|
|
|
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.setLevel(level));
|
2019-07-04 22:07:12 +02:00
|
|
|
}
|
2019-02-14 18:37:38 +01:00
|
|
|
}
|