Schematic Paste + Config refactor
Dieser Commit ist enthalten in:
Ursprung
07813dec0a
Commit
95975c5e96
@ -8,11 +8,11 @@ Arena:
|
|||||||
x: 0
|
x: 0
|
||||||
y: 0
|
y: 0
|
||||||
z: 0
|
z: 0
|
||||||
Team1corner:
|
TeamBlueCorner:
|
||||||
x: 0
|
x: 0
|
||||||
y: 0
|
y: 0
|
||||||
z: 0
|
z: 0
|
||||||
Team1toTeam2distance:
|
TeamBluetoReddistance:
|
||||||
x: 0
|
x: 0
|
||||||
y: 0
|
y: 0
|
||||||
z: 0
|
z: 0
|
||||||
@ -21,11 +21,15 @@ Arena:
|
|||||||
z: 0
|
z: 0
|
||||||
underArenaBorder: 0
|
underArenaBorder: 0
|
||||||
BorderFromSchematic: 0
|
BorderFromSchematic: 0
|
||||||
|
Schematic:
|
||||||
|
OnlyPublicSchematics: boolean
|
||||||
|
Directory: /home/netuser/schematics/
|
||||||
|
SchematicType: airship
|
||||||
Output:
|
Output:
|
||||||
TeamRedColor: &c
|
|
||||||
TeamBlueColor: &3
|
|
||||||
TeamRedName: Team1
|
TeamRedName: Team1
|
||||||
|
TeamRedPrefix: §c
|
||||||
TeamBlueName: Team2
|
TeamBlueName: Team2
|
||||||
|
TeamBluePrefix: §3
|
||||||
GameName: AirShip
|
GameName: AirShip
|
||||||
TeamChatDetection: +
|
TeamChatDetection: +
|
||||||
WinConditions:
|
WinConditions:
|
||||||
@ -37,10 +41,8 @@ WinConditions:
|
|||||||
WinConditionParams:
|
WinConditionParams:
|
||||||
TimeoutTime: 0
|
TimeoutTime: 0
|
||||||
EnterPhaseBegin: 0
|
EnterPhaseBegin: 0
|
||||||
PercentWin: 0
|
PercentWin: 0.0
|
||||||
Fight:
|
|
||||||
OnlyPublicSchematics: boolean
|
|
||||||
Money:
|
Money:
|
||||||
Win: 0
|
Win: 0
|
||||||
Lose: 0
|
Lose: 0
|
||||||
Undecided: 0
|
Draw: 0
|
||||||
|
@ -6,19 +6,21 @@ import me.yaruma.fightsystem.commands.AkCommand;
|
|||||||
import me.yaruma.fightsystem.fight.*;
|
import me.yaruma.fightsystem.fight.*;
|
||||||
import me.yaruma.fightsystem.kit.KitManager;
|
import me.yaruma.fightsystem.kit.KitManager;
|
||||||
import me.yaruma.fightsystem.listener.*;
|
import me.yaruma.fightsystem.listener.*;
|
||||||
import me.yaruma.fightsystem.manager.FileManager;
|
import me.yaruma.fightsystem.utils.Config;
|
||||||
import me.yaruma.fightsystem.utils.WorldEdit;
|
import me.yaruma.fightsystem.utils.WorldEdit;
|
||||||
import me.yaruma.fightsystem.utils.countdown.*;
|
import me.yaruma.fightsystem.utils.countdown.Countdown;
|
||||||
|
import me.yaruma.fightsystem.utils.countdown.FinishNoPlayersOnline;
|
||||||
|
import me.yaruma.fightsystem.utils.countdown.FinishPreRunning;
|
||||||
|
import me.yaruma.fightsystem.utils.countdown.FinishSpectateOver;
|
||||||
import me.yaruma.fightsystem.utils.scoreboard.Scoreboard;
|
import me.yaruma.fightsystem.utils.scoreboard.Scoreboard;
|
||||||
import me.yaruma.fightsystem.winconditions.*;
|
import me.yaruma.fightsystem.winconditions.*;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@ -28,41 +30,11 @@ public class FightSystem extends JavaPlugin {
|
|||||||
public static final String NOPERM = PREFIX + "§cDu darfst das nicht!";
|
public static final String NOPERM = PREFIX + "§cDu darfst das nicht!";
|
||||||
|
|
||||||
private static FightSystem plugin;
|
private static FightSystem plugin;
|
||||||
private FileManager fileManager;
|
|
||||||
private FightManager fightManager;
|
|
||||||
private Scoreboard scoreboard;
|
private Scoreboard scoreboard;
|
||||||
private KitManager kitManager;
|
private KitManager kitManager;
|
||||||
private WaterRemover waterRemover;
|
private WaterRemover waterRemover;
|
||||||
|
|
||||||
private FightState fightState;
|
private FightState fightState;
|
||||||
|
|
||||||
|
|
||||||
private Location Team1SpawnLoc = null;
|
|
||||||
private Location Team2SpawnLoc = null;
|
|
||||||
private Location SpecSpawnLoc = null;
|
|
||||||
private Location Team1PasteLoc = null;
|
|
||||||
private Location Team2PasteLoc = null;
|
|
||||||
|
|
||||||
public int ArenaMinX;
|
|
||||||
public int ArenaMaxX;
|
|
||||||
public int ArenaMinZ;
|
|
||||||
public int ArenaMaxZ;
|
|
||||||
|
|
||||||
private int schemsizeX;
|
|
||||||
private int schemsizeY;
|
|
||||||
private int schemsizeZ;
|
|
||||||
|
|
||||||
private int team1cornerX;
|
|
||||||
private int team1cornerY;
|
|
||||||
private int team1cornerZ;
|
|
||||||
|
|
||||||
private int team2cornerX;
|
|
||||||
private int team2cornerY;
|
|
||||||
private int team2cornerZ;
|
|
||||||
|
|
||||||
public int underArenaBorder;
|
|
||||||
|
|
||||||
|
|
||||||
public int fightTime = 0;
|
public int fightTime = 0;
|
||||||
|
|
||||||
|
|
||||||
@ -82,88 +54,12 @@ public class FightSystem extends JavaPlugin {
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
||||||
plugin = this;
|
plugin = this;
|
||||||
this.fileManager = new FileManager(plugin);
|
Config.load();
|
||||||
this.fightManager = new FightManager();
|
|
||||||
this.scoreboard = new Scoreboard(plugin);
|
this.scoreboard = new Scoreboard(plugin);
|
||||||
this.kitManager = new KitManager();
|
this.kitManager = new KitManager();
|
||||||
this.waterRemover = new WaterRemover();
|
this.waterRemover = new WaterRemover();
|
||||||
|
|
||||||
Fight.getRedTeam().setName(fileManager.getStringFromConfig("Output.TeamRedName"));
|
|
||||||
Fight.getRedTeam().setPrefix(fileManager.getStringFromConfig("Output.TeamRedColor"));
|
|
||||||
Fight.getBlueTeam().setName(fileManager.getStringFromConfig("Output.TeamBlueName"));
|
|
||||||
Fight.getBlueTeam().setPrefix(fileManager.getStringFromConfig("Output.TeamBlueColor"));
|
|
||||||
|
|
||||||
//Load config
|
|
||||||
schemsizeX = fileManager.getIntegerFromConfig("Arena.Schemsize.x");
|
|
||||||
schemsizeY = fileManager.getIntegerFromConfig("Arena.Schemsize.y");
|
|
||||||
schemsizeZ = fileManager.getIntegerFromConfig("Arena.Schemsize.z");
|
|
||||||
|
|
||||||
team1cornerX = fileManager.getIntegerFromConfig("Arena.Team1corner.x");
|
|
||||||
team1cornerY = fileManager.getIntegerFromConfig("Arena.Team1corner.y");
|
|
||||||
team1cornerZ = fileManager.getIntegerFromConfig("Arena.Team1corner.z");
|
|
||||||
|
|
||||||
int team1toTeam2distanceX = fileManager.getIntegerFromConfig("Arena.Team1toTeam2distance.x");
|
|
||||||
int team1toTeam2distanceY = fileManager.getIntegerFromConfig("Arena.Team1toTeam2distance.y");
|
|
||||||
int team1toTeam2distanceZ = fileManager.getIntegerFromConfig("Arena.Team1toTeam2distance.z");
|
|
||||||
|
|
||||||
int schem2BorderX = fileManager.getIntegerFromConfig("Arena.Schem2Border.x");
|
|
||||||
int schem2BorderZ = fileManager.getIntegerFromConfig("Arena.Schem2Border.z");
|
|
||||||
|
|
||||||
World world = Bukkit.getWorlds().get(0);
|
|
||||||
|
|
||||||
underArenaBorder = fileManager.getIntegerFromConfig("Arena.underArenaBorder");
|
|
||||||
|
|
||||||
//Rotate team1corner to edge (min. x, min. y, min. z)
|
|
||||||
if(schemsizeX < 0){
|
|
||||||
schemsizeX = -schemsizeX;
|
|
||||||
team1cornerX -= schemsizeX;
|
|
||||||
}
|
|
||||||
if(schemsizeY < 0){
|
|
||||||
schemsizeY = -schemsizeY;
|
|
||||||
team1cornerY -= schemsizeY;
|
|
||||||
}
|
|
||||||
if(schemsizeZ < 0){
|
|
||||||
schemsizeZ = -schemsizeZ;
|
|
||||||
team1cornerZ -= schemsizeZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Compute various positions
|
|
||||||
team2cornerX = team1toTeam2distanceX + team1cornerX;
|
|
||||||
team2cornerY = team1toTeam2distanceY + team1cornerY;
|
|
||||||
team2cornerZ = team1toTeam2distanceZ + team1cornerZ;
|
|
||||||
|
|
||||||
int Team1centerX = team1cornerX + schemsizeX/2;
|
|
||||||
int Team1centerY = team1cornerY;
|
|
||||||
int Team1centerZ = team1cornerZ + schemsizeZ/2;
|
|
||||||
|
|
||||||
int Team2centerX = Team1centerX + team1toTeam2distanceX;
|
|
||||||
int Team2centerY = Team1centerY + team1toTeam2distanceY;
|
|
||||||
int Team2centerZ = Team1centerZ + team1toTeam2distanceZ;
|
|
||||||
|
|
||||||
|
|
||||||
Team1SpawnLoc = new Location(world, Team1centerX, Team1centerY + schemsizeY, Team1centerZ);
|
|
||||||
Team2SpawnLoc = new Location(world, Team2centerX, Team2centerY + schemsizeY, Team2centerZ);
|
|
||||||
SpecSpawnLoc = new Location(world, Team1centerX + team1toTeam2distanceX/2,
|
|
||||||
Team1centerY + team1toTeam2distanceY/2 + schemsizeY/2,
|
|
||||||
Team1centerZ + team1toTeam2distanceZ/2);
|
|
||||||
Team1PasteLoc = new Location(world, Team1centerX, Team1centerY, Team1centerZ);
|
|
||||||
Team2PasteLoc = new Location(world, Team2centerX, Team2centerY, Team2centerZ);
|
|
||||||
|
|
||||||
if(team1toTeam2distanceX > 0){
|
|
||||||
ArenaMinX = team1cornerX - schem2BorderX;
|
|
||||||
ArenaMaxX = team1cornerX + team1toTeam2distanceX + schemsizeX + schem2BorderX;
|
|
||||||
}else{
|
|
||||||
ArenaMinX = team1cornerX + team1toTeam2distanceX - schem2BorderX;
|
|
||||||
ArenaMaxX = team1cornerX + schemsizeX + schem2BorderX;
|
|
||||||
}
|
|
||||||
if(team1toTeam2distanceZ > 0){
|
|
||||||
ArenaMinZ = team1cornerZ - schem2BorderZ;
|
|
||||||
ArenaMaxZ = team1cornerZ + team1toTeam2distanceZ + schemsizeZ + schem2BorderZ;
|
|
||||||
}else{
|
|
||||||
ArenaMinZ = team1cornerZ + team1toTeam2distanceZ - schem2BorderZ;
|
|
||||||
ArenaMaxZ = team1cornerZ + schemsizeZ + schem2BorderZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
loadConfig();
|
loadConfig();
|
||||||
|
|
||||||
getKitManager().loadAllKits();
|
getKitManager().loadAllKits();
|
||||||
@ -171,8 +67,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
init();
|
init();
|
||||||
|
|
||||||
fightState = FightState.SETUP;
|
fightState = FightState.SETUP;
|
||||||
int setupDuration = fileManager.getIntegerFromConfig("Times.NoPlayersOnlineDuration");
|
Countdown countdown = new Countdown(Config.SetupDuration, new FinishNoPlayersOnline());
|
||||||
Countdown countdown = new Countdown(setupDuration, new FinishNoPlayersOnline());
|
|
||||||
countdown.startTimer(getPlugin());
|
countdown.startTimer(getPlugin());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,20 +92,14 @@ public class FightSystem extends JavaPlugin {
|
|||||||
pm.registerEvents(new EntityExplodeListener(), plugin);
|
pm.registerEvents(new EntityExplodeListener(), plugin);
|
||||||
|
|
||||||
//WinConditions
|
//WinConditions
|
||||||
if(fileManager.getBooleanFromConfig("WinConditions.AllDead")) pm.registerEvents(new WinconditionAllDead(), plugin);
|
if(Config.AllDead) pm.registerEvents(new WinconditionAllDead(), plugin);
|
||||||
if(fileManager.getBooleanFromConfig("WinConditions.CaptainDead")) pm.registerEvents(new WinconditionCaptainDead(), plugin);
|
if(Config.CaptainDead) pm.registerEvents(new WinconditionCaptainDead(), plugin);
|
||||||
if(fileManager.getBooleanFromConfig("WinConditions.AllDead")) pm.registerEvents(new WinconditionAllDead(), plugin);
|
if(Config.PercentSystem) pm.registerEvents(new WinconditionPercentSystem(), plugin);
|
||||||
if(fileManager.getBooleanFromConfig("WinConditions.PercentSystem")) pm.registerEvents(new WinconditionPercentSystem(), plugin);
|
|
||||||
|
|
||||||
getCommand("ak").setExecutor(new AkCommand());
|
getCommand("ak").setExecutor(new AkCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadConfig() {
|
private void loadConfig() {
|
||||||
if(!new File("plugins/" + this.getName() + "/config.yml").exists()) {
|
|
||||||
saveDefaultConfig();
|
|
||||||
System.out.println(PREFIX + "config.yml erstellt und geladen!");
|
|
||||||
Bukkit.shutdown();
|
|
||||||
}
|
|
||||||
if(!new File("plugins/" + this.getName() + "/kits.data").exists()) {
|
if(!new File("plugins/" + this.getName() + "/kits.data").exists()) {
|
||||||
saveKitData();
|
saveKitData();
|
||||||
System.out.println(PREFIX + "kits.data erstellt und geladen!");
|
System.out.println(PREFIX + "kits.data erstellt und geladen!");
|
||||||
@ -226,14 +115,6 @@ public class FightSystem extends JavaPlugin {
|
|||||||
return fightState;
|
return fightState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileManager getFileManager() {
|
|
||||||
return this.fileManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FightManager getFightManager() {
|
|
||||||
return this.fightManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FightState getFightState() {
|
public FightState getFightState() {
|
||||||
return fightState;
|
return fightState;
|
||||||
}
|
}
|
||||||
@ -250,20 +131,13 @@ public class FightSystem extends JavaPlugin {
|
|||||||
return waterRemover;
|
return waterRemover;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSetupState() {
|
|
||||||
if(this.fightState == null) {
|
|
||||||
this.fightState = FightState.SETUP;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPreRunningState() {
|
public void setPreRunningState() {
|
||||||
if(this.fightState != FightState.SETUP)
|
if(this.fightState != FightState.SETUP)
|
||||||
return;
|
return;
|
||||||
this.fightState = FightState.PRE_RUNNING;
|
this.fightState = FightState.PRE_RUNNING;
|
||||||
Countdown.cancelAllTimers();
|
Countdown.cancelAllTimers();
|
||||||
|
|
||||||
int time = fileManager.getIntegerFromConfig("Times.PreFightDuration");
|
Countdown countdown = new Countdown(Config.PreFightDuration, new FinishPreRunning());
|
||||||
Countdown countdown = new Countdown(time, new FinishPreRunning());
|
|
||||||
countdown.startTimer(this);
|
countdown.startTimer(this);
|
||||||
for(FightPlayer allFightPlayers : Fight.getBlueTeam().getPlayers()) {
|
for(FightPlayer allFightPlayers : Fight.getBlueTeam().getPlayers()) {
|
||||||
allFightPlayers.getPlayer().getInventory().clear();
|
allFightPlayers.getPlayer().getInventory().clear();
|
||||||
@ -272,10 +146,18 @@ public class FightSystem extends JavaPlugin {
|
|||||||
allFightPlayers.getPlayer().getInventory().clear();
|
allFightPlayers.getPlayer().getInventory().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
getFightManager().teleportAllToFightSpawn();
|
teleportAllToFightSpawn();
|
||||||
WorldEdit.replace(Fight.getBlueTeam().getLeader().getPlayer(), team1cornerX, team1cornerY, team1cornerZ, team1cornerX + schemsizeX, team1cornerY + schemsizeY, team1cornerZ + schemsizeZ);
|
WorldEdit.replace(Fight.getBlueTeam().getLeader().getPlayer(),
|
||||||
|
Config.TeamBlueCornerX, Config.TeamBlueCornerY, Config.TeamBlueCornerZ,
|
||||||
|
Config.TeamBlueCornerX + Config.SchemsizeX,
|
||||||
|
Config.TeamBlueCornerY + Config.SchemsizeY,
|
||||||
|
Config.TeamBlueCornerZ + Config.SchemsizeZ);
|
||||||
|
|
||||||
WorldEdit.replace(Fight.getRedTeam().getLeader().getPlayer(), team2cornerX, team2cornerY, team2cornerZ, team2cornerX + schemsizeX, team2cornerY + schemsizeY, team2cornerZ + schemsizeZ);
|
WorldEdit.replace(Fight.getRedTeam().getLeader().getPlayer(),
|
||||||
|
Config.TeamRedCornerX, Config.TeamRedCornerY, Config.TeamRedCornerZ,
|
||||||
|
Config.TeamRedCornerX + Config.SchemsizeX,
|
||||||
|
Config.TeamRedCornerY + Config.SchemsizeY,
|
||||||
|
Config.TeamRedCornerZ + Config.SchemsizeZ);
|
||||||
Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!");
|
Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,116 +196,35 @@ public class FightSystem extends JavaPlugin {
|
|||||||
Bukkit.broadcastMessage(" ");
|
Bukkit.broadcastMessage(" ");
|
||||||
|
|
||||||
if(winFightTeam != null) {
|
if(winFightTeam != null) {
|
||||||
Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getPrefix() + winFightTeam.getName() + " §ahat gewonnen!");
|
Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getName() + " §ahat gewonnen!");
|
||||||
plugin.getFightManager().teleportAllToFightSpawn();
|
teleportAllToFightSpawn();
|
||||||
|
|
||||||
for(FightPlayer fightPlayer : winFightTeam.getPlayers()) {
|
for(FightPlayer fightPlayer : winFightTeam.getPlayers()) {
|
||||||
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Win"));
|
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(Config.MoneyWin);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(FightPlayer fightPlayer : Fight.getOpposite(winFightTeam).getPlayers()) {
|
for(FightPlayer fightPlayer : Fight.getOpposite(winFightTeam).getPlayers()) {
|
||||||
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Lose"));
|
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(Config.MoneyLose);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Bukkit.broadcastMessage(PREFIX + "§aKein Team hat gewonnen!");
|
Bukkit.broadcastMessage(PREFIX + "§aKein Team hat gewonnen!");
|
||||||
for(FightPlayer fightPlayer : Fight.getBlueTeam().getPlayers()) {
|
for(FightPlayer fightPlayer : Fight.getBlueTeam().getPlayers()) {
|
||||||
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Undecided"));
|
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(Config.MoneyDraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(FightPlayer fightPlayer : Fight.getRedTeam().getPlayers()) {
|
for(FightPlayer fightPlayer : Fight.getRedTeam().getPlayers()) {
|
||||||
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Undecided"));
|
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(Config.MoneyDraw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Countdown countdown = new Countdown(fileManager.getIntegerFromConfig("Times.SpectatorDuration"), new FinishSpectateOver());
|
Countdown countdown = new Countdown(Config.SpectatorDuration, new FinishSpectateOver());
|
||||||
countdown.startTimer(FightSystem.getPlugin());
|
countdown.startTimer(FightSystem.getPlugin());
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getMoneyToPay(String moneyPath) {
|
|
||||||
return fileManager.getIntegerFromConfig(moneyPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static WorldEditPlugin getWorldEditPlugin() {
|
public static WorldEditPlugin getWorldEditPlugin() {
|
||||||
return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
|
return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Location getTeam1SpawnLoc() {
|
|
||||||
return Team1SpawnLoc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Location getTeam2SpawnLoc() {
|
|
||||||
return Team2SpawnLoc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Location getSpecSpawnLoc() {
|
|
||||||
return SpecSpawnLoc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Location getTeam1PasteLoc() {
|
|
||||||
return Team1PasteLoc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Location getTeam2PasteLoc() {
|
|
||||||
return Team2PasteLoc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getArenaMinX() {
|
|
||||||
return ArenaMinX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getArenaMaxX() {
|
|
||||||
return ArenaMaxX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getArenaMinZ() {
|
|
||||||
return ArenaMinZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getArenaMaxZ() {
|
|
||||||
return ArenaMaxZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSchemsizeX() {
|
|
||||||
return schemsizeX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSchemsizeY() {
|
|
||||||
return schemsizeY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSchemsizeZ() {
|
|
||||||
return schemsizeZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTeam1cornerX() {
|
|
||||||
return team1cornerX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTeam1cornerY() {
|
|
||||||
return team1cornerY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTeam1cornerZ() {
|
|
||||||
return team1cornerZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTeam2cornerX() {
|
|
||||||
return team2cornerX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTeam2cornerY() {
|
|
||||||
return team2cornerY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTeam2cornerZ() {
|
|
||||||
return team2cornerZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getUnderArenaBorder() {
|
|
||||||
return underArenaBorder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFightTime() {
|
public int getFightTime() {
|
||||||
return fightTime;
|
return fightTime;
|
||||||
}
|
}
|
||||||
@ -441,4 +242,20 @@ public class FightSystem extends JavaPlugin {
|
|||||||
public boolean isEntern() {
|
public boolean isEntern() {
|
||||||
return entern;
|
return entern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void teleportAllToFightSpawn() {
|
||||||
|
|
||||||
|
for(FightPlayer fightPlayer : Fight.getBlueTeam().getPlayers()) {
|
||||||
|
fightPlayer.getPlayer().teleport(Config.TeamBlueSpawn);
|
||||||
|
}
|
||||||
|
for(FightPlayer fightPlayer : Fight.getRedTeam().getPlayers()) {
|
||||||
|
fightPlayer.getPlayer().teleport(Config.TeamRedSpawn);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||||
|
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||||
|
if(fightTeam == null) player.teleport(Config.SpecSpawn);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package me.yaruma.fightsystem.commands;
|
package me.yaruma.fightsystem.commands;
|
||||||
|
|
||||||
|
import de.warking.hunjy.MySQL.Schematic;
|
||||||
import me.yaruma.fightsystem.FightSystem;
|
import me.yaruma.fightsystem.FightSystem;
|
||||||
import me.yaruma.fightsystem.fight.Fight;
|
import me.yaruma.fightsystem.fight.Fight;
|
||||||
import me.yaruma.fightsystem.fight.FightPlayer;
|
import me.yaruma.fightsystem.fight.FightPlayer;
|
||||||
import me.yaruma.fightsystem.fight.FightState;
|
import me.yaruma.fightsystem.fight.FightState;
|
||||||
import me.yaruma.fightsystem.fight.FightTeam;
|
import me.yaruma.fightsystem.fight.FightTeam;
|
||||||
import me.yaruma.fightsystem.manager.FileManager;
|
import me.yaruma.fightsystem.kit.Kit;
|
||||||
|
import me.yaruma.fightsystem.kit.KitManager;
|
||||||
|
import me.yaruma.fightsystem.utils.Config;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -14,8 +17,6 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class AkCommand implements CommandExecutor {
|
public class AkCommand implements CommandExecutor {
|
||||||
|
|
||||||
FileManager fileManager = FightSystem.getPlugin().getFileManager();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
|
||||||
@ -32,13 +33,7 @@ public class AkCommand implements CommandExecutor {
|
|||||||
}else if(args[0].equalsIgnoreCase("ready") && FightSystem.getPlugin().getFightState() == FightState.SETUP){
|
}else if(args[0].equalsIgnoreCase("ready") && FightSystem.getPlugin().getFightState() == FightState.SETUP){
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||||
if(fightTeam != null) {
|
if(fightTeam != null) {
|
||||||
if(!fightTeam.isReady()) {
|
fightTeam.setReady(!fightTeam.isReady());
|
||||||
fightTeam.setReady(true);
|
|
||||||
fightTeam.broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit!");
|
|
||||||
} else {
|
|
||||||
fightTeam.setReady(false);
|
|
||||||
fightTeam.broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}else if(args[0].equalsIgnoreCase("accept") && FightSystem.getPlugin().getFightState() == FightState.SETUP){
|
}else if(args[0].equalsIgnoreCase("accept") && FightSystem.getPlugin().getFightState() == FightState.SETUP){
|
||||||
@ -64,12 +59,12 @@ public class AkCommand implements CommandExecutor {
|
|||||||
if(!Fight.getBlueTeam().hasTeamLeader()){
|
if(!Fight.getBlueTeam().hasTeamLeader()){
|
||||||
FightPlayer fightPlayer = new FightPlayer(player, false);
|
FightPlayer fightPlayer = new FightPlayer(player, false);
|
||||||
Fight.getBlueTeam().setLeader(fightPlayer);
|
Fight.getBlueTeam().setLeader(fightPlayer);
|
||||||
player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + Fight.getBlueTeam().getPrefix() + Fight.getBlueTeam().getName());
|
player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + Fight.getBlueTeam().getName());
|
||||||
|
|
||||||
} else if(!Fight.getRedTeam().hasTeamLeader()){
|
} else if(!Fight.getRedTeam().hasTeamLeader()){
|
||||||
FightPlayer fightPlayer = new FightPlayer(player, false);
|
FightPlayer fightPlayer = new FightPlayer(player, false);
|
||||||
Fight.getBlueTeam().setLeader(fightPlayer);
|
Fight.getBlueTeam().setLeader(fightPlayer);
|
||||||
player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + Fight.getRedTeam().getPrefix() + Fight.getRedTeam().getName());
|
player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + Fight.getRedTeam().getName());
|
||||||
|
|
||||||
} else
|
} else
|
||||||
player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits zwei Leader vorhanden!");
|
player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits zwei Leader vorhanden!");
|
||||||
@ -113,9 +108,56 @@ public class AkCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if(args[0].equalsIgnoreCase("kit")) {
|
}else if(args[0].equalsIgnoreCase("kit")) {
|
||||||
if(FightSystem.getPlugin().getFightState() == FightState.SETUP) {
|
if(FightSystem.getPlugin().getFightState() != FightState.SETUP) {
|
||||||
//Kit
|
player.sendMessage(FightSystem.PREFIX + "§cDu kannst dein Kit nicht mehr wechseln");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||||
|
if(fightTeam == null){
|
||||||
|
player.sendMessage(FightSystem.PREFIX + "§cDu bist in keinem Team");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Kit kit = KitManager.getKitByName(args[1]);
|
||||||
|
if(kit == null){
|
||||||
|
player.sendMessage(FightSystem.PREFIX + "§cDieses Kit existiert nicht");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
FightPlayer fightPlayer = fightTeam.getFightPlayer(player);
|
||||||
|
if(
|
||||||
|
(fightPlayer.isLeader() && !kit.isLeaderAllowed()) ||
|
||||||
|
(!fightPlayer.isLeader() && !kit.isMemberAllowed())
|
||||||
|
){
|
||||||
|
player.sendMessage(FightSystem.PREFIX + "§cDu darfst dieses Kit nicht verwenden");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Owns Kit
|
||||||
|
|
||||||
|
kit.loadToPlayer(player);
|
||||||
|
|
||||||
|
}else if(args[0].equalsIgnoreCase("schem")){
|
||||||
|
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||||
|
if(fightTeam == null){
|
||||||
|
player.sendMessage(FightSystem.PREFIX + "§cDu bist in keinem Team");
|
||||||
|
return false;
|
||||||
|
}else if(fightTeam.hasSchematic()){
|
||||||
|
player.sendMessage(FightSystem.PREFIX + "§cDie Schematic ist bereits gewählt");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Schematic schem = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
||||||
|
if(schem == null){
|
||||||
|
player.sendMessage(FightSystem.PREFIX + "§cDiese Schematic gibt es nicht");
|
||||||
|
return false;
|
||||||
|
}else if(schem.getSchemType() != Config.SchematicType){
|
||||||
|
player.sendMessage(FightSystem.PREFIX + "§cDiese Schematic ist kein " + Config.GameName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
fightTeam.setSchematic(schem);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
sendHelp(player);
|
sendHelp(player);
|
||||||
@ -123,7 +165,14 @@ public class AkCommand implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendHelp(Player player) {
|
private void sendHelp(Player p) {
|
||||||
player.sendMessage("-----[ Hilfe ]-----");
|
p.sendMessage(FightSystem.PREFIX + "§7Hilfe für den §6/ak§7-Befehl");
|
||||||
|
p.sendMessage("§8/§6ak help §8- §7Zeigt diese Hilfeseite");
|
||||||
|
p.sendMessage("§8/§6ak ready §8- §7Setzt das eigene Team auf bereit");
|
||||||
|
p.sendMessage("§8/§6ak leader §8- §7Tritt einem Team als Leader bei");
|
||||||
|
p.sendMessage("§8/§6ak invite [Spieler] §8- §7Lade den Spieler in dein Team bei");
|
||||||
|
p.sendMessage("§8/§6ak accept §8- §7Einladung annehmen");
|
||||||
|
p.sendMessage("§8/§6ak decline §8- §7Einladung ablehnen");
|
||||||
|
p.sendMessage("§8/§6ak kit <Kit> §8- §7Wähle ein Kit");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package me.yaruma.fightsystem.fight;
|
package me.yaruma.fightsystem.fight;
|
||||||
|
|
||||||
import me.yaruma.fightsystem.FightSystem;
|
import me.yaruma.fightsystem.utils.Config;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Fight {
|
public class Fight {
|
||||||
|
|
||||||
public static final FightTeam redTeam = new FightTeam(null, FightSystem.getPlugin());
|
public static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedPrefix);
|
||||||
public static final FightTeam blueTeam = new FightTeam(null, FightSystem.getPlugin());
|
public static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBluePrefix);
|
||||||
|
|
||||||
|
|
||||||
public static FightTeam getPlayerTeam(Player player) {
|
public static FightTeam getPlayerTeam(Player player) {
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
package me.yaruma.fightsystem.fight;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
class FightCreator {
|
|
||||||
|
|
||||||
@SuppressWarnings("EmptyMethod")
|
|
||||||
public static void invitePlayerToTeam(Player player) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
package me.yaruma.fightsystem.fight;
|
|
||||||
|
|
||||||
import me.yaruma.fightsystem.FightSystem;
|
|
||||||
import me.yaruma.fightsystem.manager.FileManager;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class FightManager {
|
|
||||||
|
|
||||||
public FileManager fileManager = FightSystem.getPlugin().getFileManager();
|
|
||||||
|
|
||||||
public void teleportAllToFightSpawn() {
|
|
||||||
|
|
||||||
for(FightPlayer fightPlayer : Fight.getBlueTeam().getPlayers()) {
|
|
||||||
fightPlayer.getPlayer().teleport(getBlueTeleportLocation());
|
|
||||||
}
|
|
||||||
for(FightPlayer fightPlayer : Fight.getRedTeam().getPlayers()) {
|
|
||||||
fightPlayer.getPlayer().teleport(getRedTeleportLocation());
|
|
||||||
}
|
|
||||||
|
|
||||||
for(Player player : Bukkit.getServer().getOnlinePlayers()) {
|
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
|
||||||
if(fightTeam == null) player.teleport(FightSystem.getPlugin().getSpecSpawnLoc());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Location getBlueTeleportLocation() {
|
|
||||||
return FightSystem.getPlugin().getTeam2SpawnLoc();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Location getRedTeleportLocation() {
|
|
||||||
return FightSystem.getPlugin().getTeam1SpawnLoc();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Location getBlueTeamPasteLocation() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Location getRedTeamPasteLocation() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,28 +1,38 @@
|
|||||||
package me.yaruma.fightsystem.fight;
|
package me.yaruma.fightsystem.fight;
|
||||||
|
|
||||||
|
import com.boydti.fawe.FaweAPI;
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
|
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import de.warking.hunjy.MySQL.Schematic;
|
||||||
|
import de.warking.hunjy.MySQL.WarkingUser;
|
||||||
import me.yaruma.fightsystem.FightSystem;
|
import me.yaruma.fightsystem.FightSystem;
|
||||||
|
import me.yaruma.fightsystem.utils.Config;
|
||||||
import me.yaruma.fightsystem.utils.ItemBuilder;
|
import me.yaruma.fightsystem.utils.ItemBuilder;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class FightTeam {
|
public class FightTeam {
|
||||||
|
|
||||||
private FightPlayer leader;
|
private FightPlayer leader;
|
||||||
private final ArrayList<FightPlayer> players;
|
private final ArrayList<FightPlayer> players;
|
||||||
private FightSystem plugin;
|
|
||||||
private boolean ready;
|
private boolean ready;
|
||||||
private final ArrayList<Player> invited;
|
private final ArrayList<Player> invited;
|
||||||
private String name;
|
private String name;
|
||||||
private String prefix;
|
private String prefix;
|
||||||
|
private Schematic schematic;
|
||||||
|
|
||||||
public FightTeam(Player leader, FightSystem plugin) {
|
public FightTeam(String Name, String Prefix) {
|
||||||
this.plugin = plugin;
|
|
||||||
this.leader = new FightPlayer(leader, false);
|
|
||||||
players = new ArrayList<>();
|
players = new ArrayList<>();
|
||||||
invited = new ArrayList<>();
|
invited = new ArrayList<>();
|
||||||
|
name = Name;
|
||||||
|
prefix = Prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FightPlayer getFightPlayer(Player player) {
|
public FightPlayer getFightPlayer(Player player) {
|
||||||
@ -57,10 +67,6 @@ public class FightTeam {
|
|||||||
return leader.getPlayer().equals(player);
|
return leader.getPlayer().equals(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlayerMember(Player player) {
|
|
||||||
return isPlayerInTeam(player) && !isPlayerLeader(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void broadcast(String message) {
|
public void broadcast(String message) {
|
||||||
for(FightPlayer fightPlayer : players) {
|
for(FightPlayer fightPlayer : players) {
|
||||||
fightPlayer.sendMessage(message);
|
fightPlayer.sendMessage(message);
|
||||||
@ -79,7 +85,7 @@ public class FightTeam {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasTeamLeader() {
|
public boolean hasTeamLeader() {
|
||||||
return leader.getPlayer() != null;
|
return leader != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FightPlayer getLeader() {
|
public FightPlayer getLeader() {
|
||||||
@ -96,35 +102,59 @@ public class FightTeam {
|
|||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FightSystem getPlugin() {
|
|
||||||
return plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlugin(FightSystem plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isReady() {
|
public boolean isReady() {
|
||||||
return ready;
|
return ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void pasteSchematic(){
|
||||||
|
File file = new File(Config.SchematicDirectory + WarkingUser.get(schematic.getSchemOwner()) + "/" + schematic.getSchemName() + ".schematic");
|
||||||
|
com.boydti.fawe.object.schematic.Schematic schem;
|
||||||
|
try {
|
||||||
|
schem = FaweAPI.load(file);
|
||||||
|
}catch(IOException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AffineTransform aT = new AffineTransform();
|
||||||
|
World w = (World) Bukkit.getWorlds().get(0);
|
||||||
|
Vector v = schem.getClipboard().getDimensions().divide(-2);
|
||||||
|
if(this == Fight.getBlueTeam())
|
||||||
|
v = v.add(Config.TeamBluePasteX, Config.TeamBluePasteY, Config.TeamBluePasteZ);
|
||||||
|
else
|
||||||
|
v = v.add(Config.TeamRedPasteX, Config.TeamRedPasteY, Config.TeamRedPasteZ);
|
||||||
|
schem.paste(w, v, false, true, aT).flushQueue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSchematic(Schematic schematic){
|
||||||
|
this.schematic = schematic;
|
||||||
|
if(Fight.getOpposite(this).hasSchematic()){
|
||||||
|
pasteSchematic();
|
||||||
|
Fight.getOpposite(this).pasteSchematic();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasSchematic(){
|
||||||
|
return schematic != null;
|
||||||
|
}
|
||||||
|
|
||||||
public void setReady(boolean ready) {
|
public void setReady(boolean ready) {
|
||||||
|
Player leader = getLeader().getPlayer();
|
||||||
|
|
||||||
|
if(schematic == null){
|
||||||
|
leader.sendMessage(FightSystem.PREFIX + "§cZuerst muss eine Schematic gewählt sein!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.ready = ready;
|
this.ready = ready;
|
||||||
|
if(ready) {
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(this.leader.getPlayer());
|
leader.getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short) 8).removeAllAtributs().addEnchantment(Enchantment.DURABILITY,1 ).setDisplayName("§aBereit").build());
|
||||||
|
|
||||||
FightSystem instance = FightSystem.getPlugin();
|
|
||||||
|
|
||||||
if(this.ready) {
|
|
||||||
|
|
||||||
fightTeam.getLeader().getPlayer().getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short) 8).removeAllAtributs().addEnchantment(Enchantment.DURABILITY,1 ).setDisplayName("§aBereit").build());
|
|
||||||
broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit!");
|
broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit!");
|
||||||
if(Fight.getOpposite(fightTeam).isReady()) {
|
if(Fight.getOpposite(this).isReady()) {
|
||||||
instance.setPreRunningState();
|
FightSystem.getPlugin().setPreRunningState();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fightTeam.getLeader().getPlayer().getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
|
leader.getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
|
||||||
fightTeam.broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit!");
|
broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,18 +163,10 @@ public class FightTeam {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return prefix + name;
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPrefix() {
|
public String getPrefix() {
|
||||||
return prefix;
|
return prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrefix(String prefix) {
|
|
||||||
this.prefix = prefix;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.yaruma.fightsystem.kit;
|
package me.yaruma.fightsystem.kit;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
|
||||||
@ -58,4 +59,9 @@ public class Kit {
|
|||||||
public void setPlayerInventory(Inventory inventory) {
|
public void setPlayerInventory(Inventory inventory) {
|
||||||
this.playerInventory = playerInventory;
|
this.playerInventory = playerInventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void loadToPlayer(Player player) {
|
||||||
|
player.getInventory().setContents(playerInventory.getContents());
|
||||||
|
player.getInventory().setArmorContents(playerInventory.getArmorContents());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,11 @@ import java.util.List;
|
|||||||
public class KitManager {
|
public class KitManager {
|
||||||
|
|
||||||
public static final FightSystem instance = FightSystem.getPlugin();
|
public static final FightSystem instance = FightSystem.getPlugin();
|
||||||
public static final String PREFIX = "[KIT] ";
|
|
||||||
private static final String kitsPath = "plugins/" + FightSystem.getPlugin().getName() + "/kits.data";
|
private static final String kitsPath = "plugins/" + FightSystem.getPlugin().getName() + "/kits.data";
|
||||||
|
|
||||||
private static ArrayList<Kit> loadedKits = new ArrayList<>();
|
private static final ArrayList<Kit> loadedKits = new ArrayList<>();
|
||||||
|
|
||||||
private void loadInventoryToPlayer(String kitName, Player player) {
|
private static void loadInventoryToPlayer(String kitName, Player player) {
|
||||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(new File(kitsPath));
|
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(new File(kitsPath));
|
||||||
ItemStack[] content = ((List<ItemStack>) yamlConfiguration.get("Kits." + kitName + ".Armor")).toArray(new ItemStack[0]);
|
ItemStack[] content = ((List<ItemStack>) yamlConfiguration.get("Kits." + kitName + ".Armor")).toArray(new ItemStack[0]);
|
||||||
player.getInventory().setArmorContents(content);
|
player.getInventory().setArmorContents(content);
|
||||||
@ -32,14 +31,14 @@ public class KitManager {
|
|||||||
player.getInventory().setContents(content);
|
player.getInventory().setContents(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveInventory(String kitName, Player player) throws IOException {
|
private static void saveInventory(String kitName, Player player) throws IOException {
|
||||||
YamlConfiguration yamlConfiguration = new YamlConfiguration();
|
YamlConfiguration yamlConfiguration = new YamlConfiguration();
|
||||||
yamlConfiguration.set("Kits." + kitName + ".Armor", player.getInventory().getArmorContents());
|
yamlConfiguration.set("Kits." + kitName + ".Armor", player.getInventory().getArmorContents());
|
||||||
yamlConfiguration.set("Kits." + kitName + ".Items", player.getInventory().getContents());
|
yamlConfiguration.set("Kits." + kitName + ".Items", player.getInventory().getContents());
|
||||||
yamlConfiguration.save(new File(kitsPath));
|
yamlConfiguration.save(new File(kitsPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canBuy(Player player, String kitName) {
|
public static boolean canBuy(Player player, String kitName) {
|
||||||
if(getKitByName(kitName).getPrice() <= CoinSystem.getCoinsManager(player).getCoins()) {
|
if(getKitByName(kitName).getPrice() <= CoinSystem.getCoinsManager(player).getCoins()) {
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
@ -50,11 +49,11 @@ public class KitManager {
|
|||||||
//wird spaeter gemacht
|
//wird spaeter gemacht
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean ownsKit(Player player) {
|
public static boolean ownsKit(Player player) {
|
||||||
return true; //wird spaeter gemacht
|
return true; //wird spaeter gemacht
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadKitToPlayer(Kit kit, Player player) {
|
public static void loadKitToPlayer(Kit kit, Player player) {
|
||||||
if(kit != null) {
|
if(kit != null) {
|
||||||
if(ownsKit(player)) {
|
if(ownsKit(player)) {
|
||||||
|
|
||||||
@ -62,24 +61,21 @@ public class KitManager {
|
|||||||
if(fightPlayer != null) {
|
if(fightPlayer != null) {
|
||||||
if(fightPlayer.isLeader() && kit.isLeaderAllowed() || !fightPlayer.isLeader() && kit.isMemberAllowed()) {
|
if(fightPlayer.isLeader() && kit.isLeaderAllowed() || !fightPlayer.isLeader() && kit.isMemberAllowed()) {
|
||||||
loadInventoryToPlayer(kit.getName(), player);
|
loadInventoryToPlayer(kit.getName(), player);
|
||||||
player.sendMessage(PREFIX + "§6" + kit.getName() + " §ageladen!");
|
player.sendMessage(FightSystem.PREFIX + "§6" + kit.getName() + " §ageladen!");
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(PREFIX + "§cDu darfst dieses Kit nicht verwenden!");
|
player.sendMessage(FightSystem.PREFIX + "§cDu darfst dieses Kit nicht verwenden!");
|
||||||
System.out.println(PREFIX + "§4Warning: EIN SPIELER WOLLTE EIN KIT AUSWAEHLEN WELCHES FUER IHN NICHT ZUGAENGLICH IST!");
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(PREFIX + "§cDu befindest dich in keinem Team!");
|
player.sendMessage(FightSystem.PREFIX + "§cDu befindest dich in keinem Team!");
|
||||||
System.out.println(PREFIX + "§4Warning: EIN SPIELER WOLLTE EIN KIT AUSWAEHLEN OBWOHL ER IN KEINEM TEAM IST!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(PREFIX + "§cDu besitzt dieses Kit nicht!");
|
player.sendMessage(FightSystem.PREFIX + "§cDu besitzt dieses Kit nicht!");
|
||||||
System.out.println("§4Warning: JEMAND HAT VERSUCHT EIN KIT ZU LADEN WELCHES ER NICHT BESITZT!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Kit loadKitFromConfig(String name) {
|
public static Kit loadKitFromConfig(String name) {
|
||||||
if(instance.getKitData().contains("Kit." + name)) {
|
if(instance.getKitData().contains("Kit." + name)) {
|
||||||
ItemStack[] armor = (ItemStack[]) instance.getKitData().get("Kit." + name + ".Armor");
|
ItemStack[] armor = (ItemStack[]) instance.getKitData().get("Kit." + name + ".Armor");
|
||||||
ItemStack[] items = (ItemStack[]) instance.getKitData().get("Kit." + name + ".Items");
|
ItemStack[] items = (ItemStack[]) instance.getKitData().get("Kit." + name + ".Items");
|
||||||
@ -99,13 +95,13 @@ public class KitManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadAllKits() {
|
public static void loadAllKits() {
|
||||||
for(String key : instance.getKitData().getConfigurationSection("Kits").getKeys(false)) {
|
//for(String key : instance.getKitData().getConfigurationSection("Kits").getKeys(false)) {
|
||||||
loadedKits.add(loadKitFromConfig(key));
|
// loadedKits.add(loadKitFromConfig(key));
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Kit getKitByName(String kitName) {
|
public static Kit getKitByName(String kitName) {
|
||||||
for(Kit kit : loadedKits) {
|
for(Kit kit : loadedKits) {
|
||||||
if(kit.getName().equalsIgnoreCase(kitName))
|
if(kit.getName().equalsIgnoreCase(kitName))
|
||||||
return kit;
|
return kit;
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package me.yaruma.fightsystem.listener;
|
package me.yaruma.fightsystem.listener;
|
||||||
|
|
||||||
import me.yaruma.fightsystem.FightSystem;
|
|
||||||
import me.yaruma.fightsystem.fight.Fight;
|
import me.yaruma.fightsystem.fight.Fight;
|
||||||
import me.yaruma.fightsystem.fight.FightTeam;
|
import me.yaruma.fightsystem.fight.FightTeam;
|
||||||
import me.yaruma.fightsystem.manager.FileManager;
|
import me.yaruma.fightsystem.utils.Config;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -12,24 +11,19 @@ import org.bukkit.event.player.PlayerChatEvent;
|
|||||||
|
|
||||||
public class PlayerChatListener implements Listener {
|
public class PlayerChatListener implements Listener {
|
||||||
|
|
||||||
private final FileManager fileManager = FightSystem.getPlugin().getFileManager();
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerChat(PlayerChatEvent event) {
|
public void handlePlayerChat(PlayerChatEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String message = event.getMessage();
|
String message = event.getMessage();
|
||||||
|
|
||||||
String teamChatDetection = fileManager.getStringFromConfig("Output.TeamChatDetection");
|
|
||||||
|
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||||
|
|
||||||
if(fightTeam != null) {
|
if(fightTeam != null) {
|
||||||
String prefixColorCode = fightTeam.getPrefix();
|
|
||||||
String teamName = fightTeam.getName();
|
String teamName = fightTeam.getName();
|
||||||
if(message.startsWith(teamChatDetection)) {
|
if(message.startsWith(Config.TeamChatDetection)) {
|
||||||
fightTeam.broadcast(prefixColorCode + player.getName() + "» " + prefixColorCode + message.substring(1));
|
fightTeam.broadcast(teamName + " " + player.getName() + "» " + message.substring(1));
|
||||||
} else {
|
} else {
|
||||||
Bukkit.broadcastMessage(prefixColorCode + teamName + " " + player.getName() + "§8» §7" + message);
|
Bukkit.broadcastMessage(teamName + " " + player.getName() + "§8» §7" + message);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
Bukkit.broadcastMessage("§7" + player.getName() + "§8» §7" + message);
|
Bukkit.broadcastMessage("§7" + player.getName() + "§8» §7" + message);
|
||||||
|
@ -5,7 +5,6 @@ import me.yaruma.fightsystem.fight.Fight;
|
|||||||
import me.yaruma.fightsystem.fight.FightPlayer;
|
import me.yaruma.fightsystem.fight.FightPlayer;
|
||||||
import me.yaruma.fightsystem.fight.FightState;
|
import me.yaruma.fightsystem.fight.FightState;
|
||||||
import me.yaruma.fightsystem.fight.FightTeam;
|
import me.yaruma.fightsystem.fight.FightTeam;
|
||||||
import me.yaruma.fightsystem.manager.FileManager;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -16,7 +15,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
|
|
||||||
public class PlayerInteractListener implements Listener {
|
public class PlayerInteractListener implements Listener {
|
||||||
|
|
||||||
FileManager fileManager = FightSystem.getPlugin().getFileManager();
|
|
||||||
private final FightSystem instance = FightSystem.getPlugin();
|
private final FightSystem instance = FightSystem.getPlugin();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -5,7 +5,7 @@ import me.yaruma.fightsystem.fight.Fight;
|
|||||||
import me.yaruma.fightsystem.fight.FightPlayer;
|
import me.yaruma.fightsystem.fight.FightPlayer;
|
||||||
import me.yaruma.fightsystem.fight.FightState;
|
import me.yaruma.fightsystem.fight.FightState;
|
||||||
import me.yaruma.fightsystem.fight.FightTeam;
|
import me.yaruma.fightsystem.fight.FightTeam;
|
||||||
import me.yaruma.fightsystem.manager.FileManager;
|
import me.yaruma.fightsystem.utils.Config;
|
||||||
import me.yaruma.fightsystem.utils.countdown.Countdown;
|
import me.yaruma.fightsystem.utils.countdown.Countdown;
|
||||||
import me.yaruma.fightsystem.utils.countdown.CountdownType;
|
import me.yaruma.fightsystem.utils.countdown.CountdownType;
|
||||||
import me.yaruma.fightsystem.utils.countdown.FinishSetupOver;
|
import me.yaruma.fightsystem.utils.countdown.FinishSetupOver;
|
||||||
@ -20,7 +20,6 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
public class PlayerJoinListener implements Listener {
|
public class PlayerJoinListener implements Listener {
|
||||||
|
|
||||||
private final FightSystem instance = FightSystem.getPlugin();
|
private final FightSystem instance = FightSystem.getPlugin();
|
||||||
private final FileManager fileManager = instance.getFileManager();
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerJoin(PlayerJoinEvent event) {
|
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||||
@ -41,7 +40,7 @@ public class PlayerJoinListener implements Listener {
|
|||||||
player.setGameMode(GameMode.ADVENTURE);
|
player.setGameMode(GameMode.ADVENTURE);
|
||||||
} else {
|
} else {
|
||||||
player.setGameMode(GameMode.SPECTATOR);
|
player.setGameMode(GameMode.SPECTATOR);
|
||||||
player.teleport(instance.getSpecSpawnLoc());
|
player.teleport(Config.SpecSpawn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,9 +51,9 @@ public class PlayerJoinListener implements Listener {
|
|||||||
|
|
||||||
if(instance.getFightState() == FightState.SETUP) {
|
if(instance.getFightState() == FightState.SETUP) {
|
||||||
if(fightTeam == Fight.redTeam) {
|
if(fightTeam == Fight.redTeam) {
|
||||||
player.teleport(instance.getFightManager().getRedTeleportLocation());
|
player.teleport(Config.TeamRedSpawn);
|
||||||
} else
|
} else
|
||||||
player.teleport(instance.getFightManager().getBlueTeleportLocation());
|
player.teleport(Config.TeamBlueSpawn);
|
||||||
|
|
||||||
player.setGameMode(GameMode.ADVENTURE);
|
player.setGameMode(GameMode.ADVENTURE);
|
||||||
if(fightPlayer.isLeader()) SetupItems.giveSetupItems(player);
|
if(fightPlayer.isLeader()) SetupItems.giveSetupItems(player);
|
||||||
@ -67,17 +66,16 @@ public class PlayerJoinListener implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
player.setGameMode(GameMode.SPECTATOR);
|
player.setGameMode(GameMode.SPECTATOR);
|
||||||
if(fightTeam == Fight.redTeam)
|
if(fightTeam == Fight.redTeam)
|
||||||
player.teleport(instance.getFightManager().getRedTeleportLocation());
|
player.teleport(Config.TeamRedSpawn);
|
||||||
else
|
else
|
||||||
player.teleport(instance.getFightManager().getBlueTeleportLocation());
|
player.teleport(Config.TeamBlueSpawn);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Fight.getRedTeam().hasTeamLeader() && Fight.getBlueTeam().hasTeamLeader()) {
|
if(Fight.getRedTeam().hasTeamLeader() && Fight.getBlueTeam().hasTeamLeader()) {
|
||||||
Countdown.cancelTimerType(CountdownType.NO_PLAYERS_ONLINE);
|
Countdown.cancelTimerType(CountdownType.NO_PLAYERS_ONLINE);
|
||||||
int setupDuration = fileManager.getIntegerFromConfig("Times.SetupDuration");
|
Countdown countdown = new Countdown(Config.SetupDuration, new FinishSetupOver());
|
||||||
Countdown countdown = new Countdown(setupDuration, new FinishSetupOver());
|
|
||||||
countdown.startTimer(instance);
|
countdown.startTimer(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import me.yaruma.fightsystem.FightSystem;
|
|||||||
import me.yaruma.fightsystem.fight.Fight;
|
import me.yaruma.fightsystem.fight.Fight;
|
||||||
import me.yaruma.fightsystem.fight.FightState;
|
import me.yaruma.fightsystem.fight.FightState;
|
||||||
import me.yaruma.fightsystem.fight.FightTeam;
|
import me.yaruma.fightsystem.fight.FightTeam;
|
||||||
import me.yaruma.fightsystem.manager.FileManager;
|
import me.yaruma.fightsystem.utils.Config;
|
||||||
import me.yaruma.fightsystem.utils.Region;
|
import me.yaruma.fightsystem.utils.Region;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -15,7 +15,6 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
|||||||
public class PlayerMoveListener implements Listener {
|
public class PlayerMoveListener implements Listener {
|
||||||
|
|
||||||
private final FightSystem instance = FightSystem.getPlugin();
|
private final FightSystem instance = FightSystem.getPlugin();
|
||||||
private final FileManager fileManager = FightSystem.getPlugin().getFileManager();
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerMove(PlayerMoveEvent event) {
|
public void handlePlayerMove(PlayerMoveEvent event) {
|
||||||
@ -25,29 +24,29 @@ public class PlayerMoveListener implements Listener {
|
|||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||||
|
|
||||||
//Check in Arena
|
//Check in Arena
|
||||||
if(!Region.isIn2DRegion(to, instance.ArenaMinX, instance.ArenaMinZ, instance.ArenaMaxX, instance.ArenaMaxZ)){
|
if(!Region.isIn2DRegion(to, Config.ArenaMinX, Config.ArenaMinZ, Config.ArenaMaxX, Config.ArenaMaxZ)){
|
||||||
player.teleport(from);
|
player.teleport(from);
|
||||||
player.sendMessage(FightSystem.PREFIX + "§cDu darfst die Arena nicht verlassen!");
|
player.sendMessage(FightSystem.PREFIX + "§cDu darfst die Arena nicht verlassen!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check under Arena
|
//Check under Arena
|
||||||
if(to.getBlockY() <= instance.underArenaBorder) {
|
if(to.getBlockY() <= Config.underArenaBorder) {
|
||||||
if(fightTeam == null){
|
if(fightTeam == null){
|
||||||
player.teleport(from);
|
player.teleport(from);
|
||||||
player.sendMessage(FightSystem.PREFIX + "§cDu darfst die Arena nicht verlassen!");
|
player.sendMessage(FightSystem.PREFIX + "§cDu darfst die Arena nicht verlassen!");
|
||||||
}else if(instance.getCurrentFightState() == FightState.RUNNING)
|
}else if(instance.getCurrentFightState() == FightState.RUNNING)
|
||||||
player.damage(2);
|
player.damage(2);
|
||||||
else if(fightTeam == Fight.redTeam)
|
else if(fightTeam == Fight.redTeam)
|
||||||
player.teleport(instance.getFightManager().getRedTeleportLocation());
|
player.teleport(Config.TeamRedSpawn);
|
||||||
else
|
else
|
||||||
player.teleport(instance.getFightManager().getBlueTeleportLocation());
|
player.teleport(Config.TeamBlueSpawn);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check TeamAreas
|
//Check TeamAreas
|
||||||
boolean inBlueArea = Region.isIn2DRange(to, instance.getTeam1cornerX(), instance.getTeam1cornerZ(), instance.getSchemsizeX(), instance.getSchemsizeZ(), fileManager.getIntegerFromConfig("Arena.BorderFromSchematic"));
|
boolean inBlueArea = Region.isIn2DRange(to, Config.TeamBlueCornerX, Config.TeamBlueCornerZ, Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic);
|
||||||
boolean inRedArea = Region.isIn2DRange(to, instance.getTeam2cornerX(), instance.getTeam2cornerZ(), instance.getSchemsizeX(), instance.getSchemsizeZ(), fileManager.getIntegerFromConfig("Arena.BorderFromSchematic"));
|
boolean inRedArea = Region.isIn2DRange(to, Config.TeamRedCornerX, Config.TeamRedCornerZ, Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic);
|
||||||
|
|
||||||
if(inBlueArea || inRedArea) {
|
if(inBlueArea || inRedArea) {
|
||||||
if(fightTeam == null){
|
if(fightTeam == null){
|
||||||
@ -56,7 +55,7 @@ public class PlayerMoveListener implements Listener {
|
|||||||
}
|
}
|
||||||
}else if(fightTeam != null && !instance.isEntern()){
|
}else if(fightTeam != null && !instance.isEntern()){
|
||||||
player.teleport(from);
|
player.teleport(from);
|
||||||
player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht zu " + Fight.getOpposite(fightTeam).getPrefix() + Fight.getOpposite(fightTeam).getName() + "§c!");
|
player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht zu " + Fight.getOpposite(fightTeam).getName() + "§c!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ public class PlayerQuitListener implements Listener {
|
|||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §chat den Kampf verlassen!");
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §chat den Kampf verlassen!");
|
||||||
|
|
||||||
if(fightTeam.allPlayersOut() && FightSystem.getPlugin().getFightState() == FightState.SETUP) {
|
if(fightTeam.allPlayersOut() && FightSystem.getPlugin().getFightState() == FightState.SETUP) {
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team " + fightTeam.getPrefix() + fightTeam.getName() + " §chaben den Kampf verlassen!");
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team " + fightTeam.getName() + " §chaben den Kampf verlassen!");
|
||||||
Countdown countdown = new Countdown(30, new FinishNoPlayersOnline());
|
Countdown countdown = new Countdown(30, new FinishNoPlayersOnline());
|
||||||
countdown.startTimer(FightSystem.getPlugin());
|
countdown.startTimer(FightSystem.getPlugin());
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package me.yaruma.fightsystem.listener;
|
|||||||
|
|
||||||
import me.yaruma.fightsystem.FightSystem;
|
import me.yaruma.fightsystem.FightSystem;
|
||||||
import me.yaruma.fightsystem.fight.Fight;
|
import me.yaruma.fightsystem.fight.Fight;
|
||||||
|
import me.yaruma.fightsystem.utils.Config;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -16,11 +17,11 @@ public class PlayerRespawnListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if(Fight.getPlayerTeam(player) != null) {
|
if(Fight.getPlayerTeam(player) != null) {
|
||||||
if(Fight.getPlayerTeam(player) == Fight.redTeam) {
|
if(Fight.getPlayerTeam(player) == Fight.redTeam) {
|
||||||
event.setRespawnLocation(instance.getTeam1SpawnLoc());
|
event.setRespawnLocation(Config.TeamRedSpawn);
|
||||||
} else
|
} else
|
||||||
event.setRespawnLocation(instance.getTeam2SpawnLoc());
|
event.setRespawnLocation(Config.TeamBlueSpawn);
|
||||||
} else
|
} else
|
||||||
event.setRespawnLocation(instance.getSpecSpawnLoc());
|
event.setRespawnLocation(Config.SpecSpawn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
package me.yaruma.fightsystem.manager;
|
|
||||||
|
|
||||||
import me.yaruma.fightsystem.FightSystem;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
|
|
||||||
public class FileManager
|
|
||||||
{
|
|
||||||
private final File file;
|
|
||||||
private final FileConfiguration config;
|
|
||||||
|
|
||||||
public FileManager(FightSystem instance) {
|
|
||||||
this.config = instance.getConfig();
|
|
||||||
this.config.options().copyDefaults(true);
|
|
||||||
this.file = new File(instance.getDataFolder(), "config.yml");
|
|
||||||
//instance.saveConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reloadFiles(FightSystem instance) {
|
|
||||||
instance.reloadConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addNewPath(String path, String data) {
|
|
||||||
if ((this.config.contains(path)) || (this.config.contains(data))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.config.set(path, data);
|
|
||||||
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStringFromConfig(String path) {
|
|
||||||
return this.config.getString(path).replaceAll("&", "§");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getIntegerFromConfig(String path) {
|
|
||||||
return this.config.getInt(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getBooleanFromConfig(String path) {
|
|
||||||
return this.config.getBoolean(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getFile() {
|
|
||||||
return this.file;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileConfiguration getConfig() {
|
|
||||||
return this.config;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void save() {
|
|
||||||
try {
|
|
||||||
this.config.save(this.file);
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
178
src/me/yaruma/fightsystem/utils/Config.java
Normale Datei
178
src/me/yaruma/fightsystem/utils/Config.java
Normale Datei
@ -0,0 +1,178 @@
|
|||||||
|
package me.yaruma.fightsystem.utils;
|
||||||
|
|
||||||
|
import de.warking.hunjy.MySQL.SchematicType;
|
||||||
|
import me.yaruma.fightsystem.FightSystem;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class Config {
|
||||||
|
|
||||||
|
public static int NoPlayerOnlineDuration;
|
||||||
|
public static int SetupDuration;
|
||||||
|
public static int PreFightDuration;
|
||||||
|
public static int SpectatorDuration;
|
||||||
|
|
||||||
|
public static int SchemsizeX;
|
||||||
|
public static int SchemsizeY;
|
||||||
|
public static int SchemsizeZ;
|
||||||
|
public static int TeamBlueCornerX;
|
||||||
|
public static int TeamBlueCornerY;
|
||||||
|
public static int TeamBlueCornerZ;
|
||||||
|
public static int TeamBluetoReddistanceX;
|
||||||
|
public static int TeamBluetoReddistanceY;
|
||||||
|
public static int TeamBluetoReddistanceZ;
|
||||||
|
public static int Schem2BorderX;
|
||||||
|
public static int Schem2BorderZ;
|
||||||
|
public static int underArenaBorder;
|
||||||
|
public static int BorderFromSchematic;
|
||||||
|
|
||||||
|
public static boolean OnlyPublicSchematics;
|
||||||
|
public static String SchematicDirectory;
|
||||||
|
public static SchematicType SchematicType;
|
||||||
|
|
||||||
|
public static String TeamRedName;
|
||||||
|
public static String TeamRedPrefix;
|
||||||
|
public static String TeamBlueName;
|
||||||
|
public static String TeamBluePrefix;
|
||||||
|
public static String GameName;
|
||||||
|
public static String TeamChatDetection;
|
||||||
|
|
||||||
|
public static boolean Timeout;
|
||||||
|
public static boolean AllDead;
|
||||||
|
public static boolean CaptainDead;
|
||||||
|
public static boolean PercentSystem;
|
||||||
|
public static boolean Entern;
|
||||||
|
|
||||||
|
public static int TimeoutTime;
|
||||||
|
public static int EnterPhaseBegin;
|
||||||
|
public static double PercentWin;
|
||||||
|
|
||||||
|
public static int MoneyWin;
|
||||||
|
public static int MoneyLose;
|
||||||
|
public static int MoneyDraw;
|
||||||
|
|
||||||
|
public static int TeamRedCornerX;
|
||||||
|
public static int TeamRedCornerY;
|
||||||
|
public static int TeamRedCornerZ;
|
||||||
|
|
||||||
|
public static Location TeamBlueSpawn;
|
||||||
|
public static Location TeamRedSpawn;
|
||||||
|
public static Location SpecSpawn;
|
||||||
|
|
||||||
|
public static int TeamBluePasteX;
|
||||||
|
public static int TeamBluePasteY;
|
||||||
|
public static int TeamBluePasteZ;
|
||||||
|
public static int TeamRedPasteX;
|
||||||
|
public static int TeamRedPasteY;
|
||||||
|
public static int TeamRedPasteZ;
|
||||||
|
|
||||||
|
public static int ArenaMinX;
|
||||||
|
public static int ArenaMinZ;
|
||||||
|
public static int ArenaMaxX;
|
||||||
|
public static int ArenaMaxZ;
|
||||||
|
|
||||||
|
public static void load(){
|
||||||
|
if(!new File("plugins/" + FightSystem.getPlugin().getName() + "/config.yml").exists()) {
|
||||||
|
FightSystem.getPlugin().saveDefaultConfig();
|
||||||
|
System.out.println(FightSystem.PREFIX + "config.yml erstellt und geladen!");
|
||||||
|
Bukkit.shutdown();
|
||||||
|
}
|
||||||
|
FileConfiguration config = FightSystem.getPlugin().getConfig();
|
||||||
|
|
||||||
|
NoPlayerOnlineDuration = config.getInt("Times.NoPlayersOnlineDuration");
|
||||||
|
SetupDuration = config.getInt("Times.SetupDuration");
|
||||||
|
PreFightDuration = config.getInt("Times.PreFightDuration");
|
||||||
|
SpectatorDuration = config.getInt("Times.SpectatorDuration");
|
||||||
|
|
||||||
|
SchemsizeX = config.getInt("Arena.Schemsize.x");
|
||||||
|
SchemsizeY = config.getInt("Arena.Schemsize.y");
|
||||||
|
SchemsizeZ = config.getInt("Arena.Schemsize.z");
|
||||||
|
TeamBlueCornerX = config.getInt("Arena.TeamBlueCorner.x");
|
||||||
|
TeamBlueCornerY = config.getInt("Arena.TeamBlueCorner.y");
|
||||||
|
TeamBlueCornerZ = config.getInt("Arena.TeamBlueCorner.z");
|
||||||
|
TeamBluetoReddistanceX = config.getInt("Arena.TeamBluetoReddistance.x");
|
||||||
|
TeamBluetoReddistanceY = config.getInt("Arena.TeamBluetoReddistance.y");
|
||||||
|
TeamBluetoReddistanceZ = config.getInt("Arena.TeamBluetoReddistance.z");
|
||||||
|
Schem2BorderX = config.getInt("Arena.Schem2Border.x");
|
||||||
|
Schem2BorderZ = config.getInt("Arena.Schem2Border.z");
|
||||||
|
underArenaBorder = config.getInt("Arena.underArenaBorder");
|
||||||
|
BorderFromSchematic = config.getInt("Arena.BorderFromSchematic");
|
||||||
|
|
||||||
|
OnlyPublicSchematics = config.getBoolean("Schematic.OnlyPublicSchematics");
|
||||||
|
SchematicDirectory = config.getString("Schematic.Directory");
|
||||||
|
SchematicType = de.warking.hunjy.MySQL.SchematicType.valueOf(config.getString("Schematic.SchematicType"));
|
||||||
|
|
||||||
|
TeamRedName = config.getString("Output.TeamRedName");
|
||||||
|
TeamRedPrefix = config.getString("Output.TeamRedPrefix");
|
||||||
|
TeamBlueName = config.getString("Output.TeamBlueName");
|
||||||
|
TeamBluePrefix = config.getString("Output.TeamBluePrefix");
|
||||||
|
GameName = config.getString("Output.GameName");
|
||||||
|
TeamChatDetection = config.getString("Output.TeamChatDetection");
|
||||||
|
|
||||||
|
Timeout = config.getBoolean("WinConditions.Timeout");
|
||||||
|
AllDead = config.getBoolean("WinConditions.AllDead");
|
||||||
|
CaptainDead = config.getBoolean("WinConditions.CaptainDead");
|
||||||
|
PercentSystem = config.getBoolean("WinConditions.PercentSystem");
|
||||||
|
Entern = config.getBoolean("WinConditions.Entern");
|
||||||
|
|
||||||
|
TimeoutTime = config.getInt("WinConditionParams.TimeoutTime");
|
||||||
|
EnterPhaseBegin = config.getInt("WinConditionParams.EnterPhaseBegin");
|
||||||
|
PercentWin = config.getDouble("WinConditionParams.PercentWin");
|
||||||
|
|
||||||
|
MoneyWin = config.getInt("Money.Win");
|
||||||
|
MoneyLose = config.getInt("Money.Lose");
|
||||||
|
MoneyDraw = config.getInt("Money.Draw");
|
||||||
|
|
||||||
|
if(SchemsizeX < 0){
|
||||||
|
SchemsizeX = -SchemsizeX;
|
||||||
|
TeamBlueCornerX -= SchemsizeX;
|
||||||
|
}
|
||||||
|
if(SchemsizeY < 0){
|
||||||
|
SchemsizeY = -SchemsizeY;
|
||||||
|
TeamBlueCornerY -= SchemsizeY;
|
||||||
|
}
|
||||||
|
if(SchemsizeZ < 0){
|
||||||
|
SchemsizeZ = -SchemsizeZ;
|
||||||
|
TeamBlueCornerZ -= SchemsizeZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
TeamRedCornerX = TeamBluetoReddistanceX + TeamBlueCornerX;
|
||||||
|
TeamRedCornerY = TeamBluetoReddistanceY + TeamBlueCornerY;
|
||||||
|
TeamRedCornerZ = TeamBluetoReddistanceZ + TeamBlueCornerZ;
|
||||||
|
|
||||||
|
TeamBluePasteX = TeamBlueCornerX + SchemsizeX/2;
|
||||||
|
TeamBluePasteY = TeamBlueCornerY;
|
||||||
|
TeamBluePasteZ = TeamBlueCornerZ + SchemsizeZ/2;
|
||||||
|
|
||||||
|
TeamRedPasteX = TeamBluePasteX + TeamBluetoReddistanceX;
|
||||||
|
TeamRedPasteY = TeamBluePasteY;
|
||||||
|
TeamRedPasteZ = TeamBluePasteZ + TeamBluetoReddistanceZ;
|
||||||
|
|
||||||
|
World world = Bukkit.getWorlds().get(0);
|
||||||
|
TeamBlueSpawn = new Location(world, TeamBluePasteX, TeamBluePasteY + SchemsizeY, TeamBluePasteZ);
|
||||||
|
TeamRedSpawn = new Location(world, TeamRedPasteX, TeamRedPasteY + SchemsizeY, TeamRedPasteZ);
|
||||||
|
SpecSpawn = new Location(world,
|
||||||
|
TeamBluePasteX + TeamBluetoReddistanceX/2,
|
||||||
|
TeamBluePasteY + TeamBluetoReddistanceY/2,
|
||||||
|
TeamBluePasteZ + TeamBluetoReddistanceZ/2);
|
||||||
|
|
||||||
|
if(TeamBluetoReddistanceX > 0){
|
||||||
|
ArenaMinX = TeamBlueCornerX - Schem2BorderX;
|
||||||
|
ArenaMaxX = TeamRedCornerX + SchemsizeX + Schem2BorderX;
|
||||||
|
}else{
|
||||||
|
ArenaMinX = TeamRedCornerX - Schem2BorderX;
|
||||||
|
ArenaMaxX = TeamBlueCornerX + SchemsizeX + Schem2BorderX;
|
||||||
|
}
|
||||||
|
if(TeamBluetoReddistanceZ > 0){
|
||||||
|
ArenaMinZ = TeamBlueCornerZ - Schem2BorderZ;
|
||||||
|
ArenaMaxZ = TeamRedCornerZ + SchemsizeZ + Schem2BorderZ;
|
||||||
|
}else{
|
||||||
|
ArenaMinZ = TeamRedCornerZ - Schem2BorderZ;
|
||||||
|
ArenaMaxZ = TeamBlueCornerZ + SchemsizeZ + Schem2BorderZ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,9 @@
|
|||||||
package me.yaruma.fightsystem.utils.countdown;
|
package me.yaruma.fightsystem.utils.countdown;
|
||||||
|
|
||||||
import me.yaruma.fightsystem.FightSystem;
|
import me.yaruma.fightsystem.FightSystem;
|
||||||
import me.yaruma.fightsystem.manager.FileManager;
|
|
||||||
|
|
||||||
public class FinishPreRunning implements CountdownCallback {
|
public class FinishPreRunning implements CountdownCallback {
|
||||||
|
|
||||||
FileManager fileManager = FightSystem.getPlugin().getFileManager();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String countdownCounting() {
|
public String countdownCounting() {
|
||||||
return "bis die Arena freigegeben ist!";
|
return "bis die Arena freigegeben ist!";
|
||||||
|
@ -4,7 +4,7 @@ import me.yaruma.fightsystem.FightSystem;
|
|||||||
import me.yaruma.fightsystem.fight.Fight;
|
import me.yaruma.fightsystem.fight.Fight;
|
||||||
import me.yaruma.fightsystem.fight.FightPlayer;
|
import me.yaruma.fightsystem.fight.FightPlayer;
|
||||||
import me.yaruma.fightsystem.fight.FightTeam;
|
import me.yaruma.fightsystem.fight.FightTeam;
|
||||||
import me.yaruma.fightsystem.winconditions.Methods;
|
import me.yaruma.fightsystem.utils.Config;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scoreboard.DisplaySlot;
|
import org.bukkit.scoreboard.DisplaySlot;
|
||||||
@ -35,7 +35,7 @@ public class Scoreboard {
|
|||||||
scoreboard.registerNewObjective("AAA", "BBB");
|
scoreboard.registerNewObjective("AAA", "BBB");
|
||||||
|
|
||||||
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
objective.setDisplayName(fightTeam.getPrefix() + fightTeam.getName());
|
objective.setDisplayName(fightTeam.getName());
|
||||||
|
|
||||||
for (FightPlayer fp : fightTeam.getPlayers()) {
|
for (FightPlayer fp : fightTeam.getPlayers()) {
|
||||||
objective.getScore(fightTeam.getPrefix() + fp.getPlayer().getName()).setScore((int) fp.getPlayer().getHealth());
|
objective.getScore(fightTeam.getPrefix() + fp.getPlayer().getName()).setScore((int) fp.getPlayer().getHealth());
|
||||||
@ -50,19 +50,19 @@ public class Scoreboard {
|
|||||||
|
|
||||||
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
objective.setDisplayName("§6Kampf");
|
objective.setDisplayName("§6Kampf");
|
||||||
if (Methods.isEnabled("WinConditions.Timeout")) {
|
if (Config.Timeout) {
|
||||||
int fightTime = FightSystem.getPlugin().getFightTime();
|
int fightTime = FightSystem.getPlugin().getFightTime();
|
||||||
if (fightTime >= 60)
|
if (fightTime >= 60)
|
||||||
objective.getScore("§7Zeit: §a" + fightTime / 60 + "m " + fightTime % 60 + "s").setScore(3);
|
objective.getScore("§7Zeit: §a" + fightTime / 60 + "m " + fightTime % 60 + "s").setScore(3);
|
||||||
else
|
else
|
||||||
objective.getScore("§7Zeit: §a" + fightTime + "s").setScore(3);
|
objective.getScore("§7Zeit: §a" + fightTime + "s").setScore(3);
|
||||||
}
|
}
|
||||||
if (Methods.isEnabled("WinConditions.Entern"))
|
if (Config.Entern)
|
||||||
objective.getScore("§7Entern: " + (FightSystem.getPlugin().isEntern() ? "§aja" : "§cnein")).setScore(2);
|
objective.getScore("§7Entern: " + (FightSystem.getPlugin().isEntern() ? "§aja" : "§cnein")).setScore(2);
|
||||||
if (Methods.isEnabled("WinConditions.PercentSystem"))
|
if (Config.PercentSystem){
|
||||||
objective.getScore("§eSchaden ROT: §c" + FightSystem.getPlugin().getDamageRed() + "%").setScore(1);
|
objective.getScore("§eSchaden ROT: §c" + FightSystem.getPlugin().getDamageRed() + "%").setScore(1);
|
||||||
if (Methods.isEnabled("WinConditions.PercentSystem"))
|
|
||||||
objective.getScore("§eSchaden BLAU: §c" + FightSystem.getPlugin().getGetDamageBlue() + "%").setScore(0);
|
objective.getScore("§eSchaden BLAU: §c" + FightSystem.getPlugin().getGetDamageBlue() + "%").setScore(0);
|
||||||
|
}
|
||||||
index = 0;
|
index = 0;
|
||||||
}
|
}
|
||||||
player.setScoreboard(scoreboard);
|
player.setScoreboard(scoreboard);
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -3,6 +3,7 @@ package me.yaruma.fightsystem.winconditions;
|
|||||||
import me.yaruma.fightsystem.FightSystem;
|
import me.yaruma.fightsystem.FightSystem;
|
||||||
import me.yaruma.fightsystem.fight.Fight;
|
import me.yaruma.fightsystem.fight.Fight;
|
||||||
import me.yaruma.fightsystem.fight.FightTeam;
|
import me.yaruma.fightsystem.fight.FightTeam;
|
||||||
|
import me.yaruma.fightsystem.utils.Config;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -16,7 +17,7 @@ public class WinconditionAllDead implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerDeath(PlayerDeathEvent event) {
|
public void handlePlayerDeath(PlayerDeathEvent event) {
|
||||||
if(!Methods.isEnabled("WinConditions.AllDead")) return;
|
if(!Config.AllDead) return;
|
||||||
Player player = event.getEntity().getPlayer();
|
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);
|
||||||
@ -29,7 +30,7 @@ public class WinconditionAllDead implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerQuit(PlayerQuitEvent event) {
|
public void handlePlayerQuit(PlayerQuitEvent event) {
|
||||||
if(!Methods.isEnabled("WinConditions.AllDead")) return;
|
if(!Config.AllDead) return;
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if(Fight.getPlayerTeam(player) == null) return;
|
if(Fight.getPlayerTeam(player) == null) return;
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||||
|
@ -3,7 +3,7 @@ package me.yaruma.fightsystem.winconditions;
|
|||||||
import me.yaruma.fightsystem.FightSystem;
|
import me.yaruma.fightsystem.FightSystem;
|
||||||
import me.yaruma.fightsystem.fight.Fight;
|
import me.yaruma.fightsystem.fight.Fight;
|
||||||
import me.yaruma.fightsystem.fight.FightTeam;
|
import me.yaruma.fightsystem.fight.FightTeam;
|
||||||
import me.yaruma.fightsystem.manager.FileManager;
|
import me.yaruma.fightsystem.utils.Config;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -14,11 +14,10 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
public class WinconditionCaptainDead implements Listener {
|
public class WinconditionCaptainDead implements Listener {
|
||||||
|
|
||||||
private final FightSystem instance = FightSystem.getPlugin();
|
private final FightSystem instance = FightSystem.getPlugin();
|
||||||
FileManager fileManager = instance.getFileManager();
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerDeath(PlayerDeathEvent event) {
|
public void handlePlayerDeath(PlayerDeathEvent event) {
|
||||||
if(!Methods.isEnabled("WinConditions.CaptainDead")) return;
|
if(!Config.CaptainDead) return;
|
||||||
Player player = event.getEntity().getPlayer();
|
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);
|
||||||
@ -32,7 +31,7 @@ public class WinconditionCaptainDead implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerQuit(PlayerQuitEvent event) {
|
public void handlePlayerQuit(PlayerQuitEvent event) {
|
||||||
if(!Methods.isEnabled("WinConditions.CaptainDead")) return;
|
if(!Config.CaptainDead) return;
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if(Fight.getPlayerTeam(player) == null) return;
|
if(Fight.getPlayerTeam(player) == null) return;
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
package me.yaruma.fightsystem.winconditions;
|
package me.yaruma.fightsystem.winconditions;
|
||||||
|
|
||||||
import me.yaruma.fightsystem.FightSystem;
|
import me.yaruma.fightsystem.FightSystem;
|
||||||
import me.yaruma.fightsystem.manager.FileManager;
|
import me.yaruma.fightsystem.utils.Config;
|
||||||
import me.yaruma.fightsystem.utils.countdown.Countdown;
|
import me.yaruma.fightsystem.utils.countdown.Countdown;
|
||||||
import me.yaruma.fightsystem.utils.countdown.FinishNoneEntern;
|
import me.yaruma.fightsystem.utils.countdown.FinishNoneEntern;
|
||||||
|
|
||||||
public class WinconditionEntern {
|
public class WinconditionEntern {
|
||||||
|
|
||||||
private static final FightSystem instance = FightSystem.getPlugin();
|
private static final FightSystem instance = FightSystem.getPlugin();
|
||||||
private static final FileManager fileManager = instance.getFileManager();
|
|
||||||
|
|
||||||
public static void entern() {
|
public static void entern() {
|
||||||
if(!Methods.isEnabled("WinConditions.Entern")) return;
|
if(!Config.Entern) return;
|
||||||
|
|
||||||
int timeTimeOver = fileManager.getIntegerFromConfig("WinConditionParams.EnterPhaseBegin");
|
Countdown countdownTimeOver = new Countdown(Config.EnterPhaseBegin, new FinishNoneEntern());
|
||||||
Countdown countdownTimeOver = new Countdown(timeTimeOver, new FinishNoneEntern());
|
|
||||||
countdownTimeOver.startTimer(instance);
|
countdownTimeOver.startTimer(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package me.yaruma.fightsystem.winconditions;
|
|||||||
|
|
||||||
import me.yaruma.fightsystem.FightSystem;
|
import me.yaruma.fightsystem.FightSystem;
|
||||||
import me.yaruma.fightsystem.fight.Fight;
|
import me.yaruma.fightsystem.fight.Fight;
|
||||||
import me.yaruma.fightsystem.manager.FileManager;
|
import me.yaruma.fightsystem.utils.Config;
|
||||||
import me.yaruma.fightsystem.utils.Region;
|
import me.yaruma.fightsystem.utils.Region;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -12,43 +12,38 @@ import org.bukkit.event.entity.EntityExplodeEvent;
|
|||||||
|
|
||||||
public class WinconditionPercentSystem implements Listener {
|
public class WinconditionPercentSystem implements Listener {
|
||||||
|
|
||||||
private static int team1DestroyedBlocks;
|
private static int blueDestroyedBlocks;
|
||||||
private static int team2DestroyedBlocks;
|
private static int redDestroyedBlocks;
|
||||||
|
|
||||||
private final FightSystem instance = FightSystem.getPlugin();
|
private static int schematicSize;
|
||||||
private final FileManager fileManager = instance.getFileManager();
|
|
||||||
|
|
||||||
private static final int schematicSize =
|
public WinconditionPercentSystem() {
|
||||||
Math.abs(
|
schematicSize = Math.abs(Config.SchemsizeX * Config.SchemsizeY * Config.SchemsizeZ);
|
||||||
FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.x") *
|
}
|
||||||
FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.y") *
|
|
||||||
FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.z"));
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handleEntityExplode(EntityExplodeEvent event) {
|
public void handleEntityExplode(EntityExplodeEvent event) {
|
||||||
Bukkit.broadcastMessage("boom");
|
if(!Config.PercentSystem) return;
|
||||||
if(!Methods.isEnabled("WinConditions.PercentSystem")) return;
|
|
||||||
Bukkit.broadcastMessage("enabled");
|
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
|
|
||||||
//Team 1 / Rot
|
//Team 1 / Rot
|
||||||
if(Region.isInRegion(entity.getLocation(), instance.getTeam1cornerX(), instance.getTeam1cornerY(), instance.getTeam1cornerZ(), instance.getTeam1cornerX() + instance.getSchemsizeX(), instance.getTeam1cornerY() + instance.getSchemsizeY(), instance.getTeam1cornerZ() + instance.getSchemsizeZ(), fileManager.getIntegerFromConfig("Arena.BorderFromSchematic"))) {
|
if(Region.isInRange(entity.getLocation(), Config.TeamBlueCornerX, Config.TeamBlueCornerY, Config.TeamBlueCornerZ, Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ, Config.BorderFromSchematic)){
|
||||||
team1DestroyedBlocks = team1DestroyedBlocks + event.blockList().size();
|
blueDestroyedBlocks = blueDestroyedBlocks + event.blockList().size();
|
||||||
Bukkit.broadcastMessage("red");
|
Bukkit.broadcastMessage("red");
|
||||||
double destroyPercent = team1DestroyedBlocks * 100 / schematicSize;
|
double destroyPercent = blueDestroyedBlocks * 100 / schematicSize;
|
||||||
Bukkit.broadcastMessage(" " + destroyPercent);
|
Bukkit.broadcastMessage(" " + destroyPercent);
|
||||||
if(destroyPercent >= fileManager.getIntegerFromConfig("WinConditionParams.PercentWin")) {
|
if(destroyPercent >= Config.PercentWin) {
|
||||||
instance.setSpectateState(Fight.blueTeam);
|
FightSystem.getPlugin().setSpectateState(Fight.blueTeam);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Team 2 / Blau
|
//Team 2 / Blau
|
||||||
if(Region.isInRegion(entity.getLocation(), instance.getTeam2cornerX(), instance.getTeam2cornerY(), instance.getTeam2cornerZ(), instance.getTeam2cornerX() + instance.getSchemsizeX(), instance.getTeam2cornerY() + instance.getSchemsizeY(), instance.getTeam2cornerZ() + instance.getSchemsizeZ(), fileManager.getIntegerFromConfig("Arena.BorderFromSchematic"))) {
|
if(Region.isInRange(entity.getLocation(), Config.TeamRedCornerX, Config.TeamRedCornerY, Config.TeamRedCornerZ, Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ, Config.BorderFromSchematic)) {
|
||||||
team2DestroyedBlocks = team2DestroyedBlocks + event.blockList().size();
|
redDestroyedBlocks = redDestroyedBlocks + event.blockList().size();
|
||||||
double destroyPercent = team2DestroyedBlocks * 100 / schematicSize;
|
double destroyPercent = redDestroyedBlocks * 100 / schematicSize;
|
||||||
if(destroyPercent >= fileManager.getIntegerFromConfig("WinConditionParams.PercentWin")) {
|
if(destroyPercent >= Config.PercentWin) {
|
||||||
instance.setSpectateState(Fight.redTeam);
|
FightSystem.getPlugin().setSpectateState(Fight.redTeam);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
package me.yaruma.fightsystem.winconditions;
|
package me.yaruma.fightsystem.winconditions;
|
||||||
|
|
||||||
import me.yaruma.fightsystem.FightSystem;
|
import me.yaruma.fightsystem.FightSystem;
|
||||||
import me.yaruma.fightsystem.manager.FileManager;
|
import me.yaruma.fightsystem.utils.Config;
|
||||||
import me.yaruma.fightsystem.utils.countdown.Countdown;
|
import me.yaruma.fightsystem.utils.countdown.Countdown;
|
||||||
import me.yaruma.fightsystem.utils.countdown.FinishTimeOver;
|
import me.yaruma.fightsystem.utils.countdown.FinishTimeOver;
|
||||||
|
|
||||||
public class WinconditionTimeout {
|
public class WinconditionTimeout {
|
||||||
|
|
||||||
private static final FightSystem instance = FightSystem.getPlugin();
|
private static final FightSystem instance = FightSystem.getPlugin();
|
||||||
private static final FileManager fileManager = instance.getFileManager();
|
|
||||||
|
|
||||||
public static void timeout() {
|
public static void timeout() {
|
||||||
if(!Methods.isEnabled("WinConditions.Timeout")) return;
|
if(!Config.Timeout) return;
|
||||||
|
|
||||||
int timeTimeOver = fileManager.getIntegerFromConfig("WinConditionParams.TimeoutTime");
|
Countdown countdownTimeOver = new Countdown(Config.TimeoutTime, new FinishTimeOver());
|
||||||
Countdown countdownTimeOver = new Countdown(timeTimeOver, new FinishTimeOver());
|
|
||||||
countdownTimeOver.startTimer(instance);
|
countdownTimeOver.startTimer(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren