2019-02-14 18:37:38 +01:00
|
|
|
package me.yaruma.fightsystem;
|
|
|
|
|
|
|
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
|
|
|
import me.yaruma.fightsystem.commands.AkCommand;
|
|
|
|
import me.yaruma.fightsystem.fight.FightManager;
|
|
|
|
import me.yaruma.fightsystem.fight.FightState;
|
2019-02-16 00:43:08 +01:00
|
|
|
import me.yaruma.fightsystem.fight.FightTeam;
|
2019-02-14 18:37:38 +01:00
|
|
|
import me.yaruma.fightsystem.listener.*;
|
|
|
|
import me.yaruma.fightsystem.manager.FileManager;
|
|
|
|
import me.yaruma.fightsystem.utils.Coordinates;
|
|
|
|
import me.yaruma.fightsystem.utils.countdown.Countdown;
|
|
|
|
import me.yaruma.fightsystem.utils.countdown.FinishSetupOver;
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.plugin.PluginManager;
|
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
public class FightSystem extends JavaPlugin {
|
|
|
|
|
|
|
|
public static String PREFIX = "[FightSystem] ";
|
|
|
|
public static String NOPERM = PREFIX + "§4Du darfst das nicht!";
|
|
|
|
|
|
|
|
private static FightSystem plugin;
|
|
|
|
private FileManager fileManager;
|
|
|
|
private FightManager fightManager;
|
|
|
|
private Coordinates coordinates;
|
|
|
|
|
|
|
|
private FightState fightState;
|
|
|
|
|
|
|
|
|
|
|
|
public Location Team1SpawnLoc = null;
|
|
|
|
public Location Team2SpawnLoc = null;
|
2019-02-15 16:32:51 +01:00
|
|
|
public Location SpecSpawnLoc = null;
|
2019-02-14 18:37:38 +01:00
|
|
|
public Location Team1PasteLoc = null;
|
|
|
|
public Location Team2PasteLoc = null;
|
|
|
|
|
|
|
|
public int ArenaMinX;
|
|
|
|
public int ArenaMaxX;
|
|
|
|
public int ArenaMinZ;
|
|
|
|
public int ArenaMaxZ;
|
|
|
|
|
|
|
|
public int schemsizeX;
|
|
|
|
public int schemsizeY;
|
|
|
|
public int schemsizeZ;
|
|
|
|
|
|
|
|
public int team1cornerX;
|
|
|
|
public int team1cornerY;
|
|
|
|
public int team1cornerZ;
|
|
|
|
|
2019-02-15 23:23:07 +01:00
|
|
|
public int team2cornerX;
|
|
|
|
public int team2cornerY;
|
|
|
|
public int team2cornerZ;
|
|
|
|
|
2019-02-14 18:37:38 +01:00
|
|
|
public void onEnable() {
|
|
|
|
|
|
|
|
plugin = this;
|
|
|
|
this.fileManager = new FileManager(plugin);
|
|
|
|
this.fightManager = new FightManager();
|
|
|
|
this.coordinates = new Coordinates();
|
|
|
|
|
|
|
|
int schemsizeX = this.schemsizeX = fileManager.getIntegerFromConfig("Arena.Schemsize.x");
|
|
|
|
int schemsizeY = this.schemsizeZ = fileManager.getIntegerFromConfig("Arena.Schemsize.y");
|
|
|
|
int schemsizeZ = this.schemsizeY = fileManager.getIntegerFromConfig("Arena.Schemsize.z");
|
|
|
|
|
|
|
|
int team1cornerX = this.team1cornerX = fileManager.getIntegerFromConfig("Arena.Team1corner.x");
|
|
|
|
int team1cornerY = this.team1cornerY = fileManager.getIntegerFromConfig("Arena.Team1corner.y");
|
|
|
|
int team1cornerZ = this.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");
|
|
|
|
|
2019-02-15 23:23:07 +01:00
|
|
|
team2cornerX = team1toTeam2distanceX + team1cornerX;
|
|
|
|
team2cornerY = team1toTeam2distanceY + team1cornerY;
|
|
|
|
team2cornerZ = team1toTeam2distanceZ + schemsizeZ + 1 + team1cornerZ;
|
|
|
|
|
2019-02-14 18:37:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
coordinates.computePositions(schemsizeX, schemsizeY, schemsizeZ, team1cornerX, team1cornerY, team1cornerZ, team1toTeam2distanceX, team1toTeam2distanceY, team1toTeam2distanceZ, schem2BorderX, schem2BorderZ);
|
|
|
|
|
|
|
|
loadConfig();
|
|
|
|
|
|
|
|
init();
|
|
|
|
|
|
|
|
fightState = FightState.SETUP;
|
|
|
|
int setupDuration = fileManager.getIntegerFromConfig("Times.SetupDuration");
|
|
|
|
Countdown countdown = new Countdown(setupDuration, new FinishSetupOver());
|
|
|
|
countdown.startTimer(getPlugin());
|
|
|
|
|
|
|
|
System.out.println(PREFIX + "§aPlugin gestartet!");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onDisable() {
|
|
|
|
|
|
|
|
System.out.println(PREFIX + "§cPlugin deaktiviert!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void init() {
|
|
|
|
PluginManager pm = Bukkit.getPluginManager();
|
|
|
|
pm.registerEvents(new PlayerJoinListener(), plugin);
|
|
|
|
pm.registerEvents(new PlayerQuitListener(), plugin);
|
|
|
|
pm.registerEvents(new PlayerDeathListener(), plugin);
|
|
|
|
pm.registerEvents(new PlayerInteractListener(), plugin);
|
|
|
|
pm.registerEvents(new PlayerChatListener(), plugin);
|
|
|
|
pm.registerEvents(new BlockPlaceListener(), plugin);
|
|
|
|
pm.registerEvents(new BlockBreakListener(), plugin);
|
2019-02-15 23:23:07 +01:00
|
|
|
pm.registerEvents(new PlayerMoveListener(), plugin);
|
2019-02-14 18:37:38 +01:00
|
|
|
|
|
|
|
getCommand("ak").setExecutor(new AkCommand());
|
|
|
|
}
|
|
|
|
|
|
|
|
public void loadConfig() {
|
|
|
|
if(!new File("plugins/" + this.getName() + "/config.yml").exists()) {
|
|
|
|
saveDefaultConfig();
|
|
|
|
System.out.println(PREFIX + "config.yml erstellt und geladen!");
|
|
|
|
Bukkit.shutdown();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static FightSystem getPlugin() {
|
|
|
|
return plugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
public FightState getCurrentFightState() {
|
|
|
|
return fightState;
|
|
|
|
}
|
|
|
|
|
|
|
|
public FileManager getFileManager() {
|
|
|
|
return this.fileManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
public FightManager getFightManager() {
|
|
|
|
return this.fightManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
public FightState getFightState() {
|
|
|
|
return fightState;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSetupState() {
|
|
|
|
if(this.fightState == null) {
|
|
|
|
this.fightState = FightState.SETUP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPreRunningState() {
|
|
|
|
if(this.fightState == FightState.SETUP) {
|
|
|
|
this.fightState = FightState.PRE_RUNNING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setRunningState() {
|
|
|
|
if(this.fightState == FightState.PRE_RUNNING) {
|
|
|
|
this.fightState = FightState.RUNNING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-16 00:43:08 +01:00
|
|
|
public void setSpectateState(FightTeam winFightTeam) {
|
2019-02-14 18:37:38 +01:00
|
|
|
if(this.fightState == FightState.RUNNING) {
|
|
|
|
this.fightState = FightState.SPECTATE;
|
2019-02-16 00:43:08 +01:00
|
|
|
|
|
|
|
Bukkit.broadcastMessage(" ");
|
|
|
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDas Team von §6" + winFightTeam.getLeader().getPlayer().getName() + " §ahat gewonnen!");
|
|
|
|
plugin.getFightManager().teleportAllToFightSpawn();
|
2019-02-14 18:37:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static WorldEditPlugin getWorldEditPlugin() {
|
|
|
|
return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Location getTeam1SpawnLoc() {
|
|
|
|
return Team1SpawnLoc;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Location getTeam2SpawnLoc() {
|
|
|
|
return Team2SpawnLoc;
|
|
|
|
}
|
|
|
|
|
2019-02-15 16:32:51 +01:00
|
|
|
public Location getSpecSpawnLoc() {
|
|
|
|
return SpecSpawnLoc;
|
|
|
|
}
|
|
|
|
|
2019-02-14 18:37:38 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-02-15 23:23:07 +01:00
|
|
|
public int getTeam2cornerX() {
|
|
|
|
return team2cornerX;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getTeam2cornerY() {
|
|
|
|
return team2cornerY;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getTeam2cornerZ() {
|
|
|
|
return team2cornerZ;
|
|
|
|
}
|
|
|
|
|
2019-02-14 18:37:38 +01:00
|
|
|
public void setTeam1SpawnLoc(Location team1SpawnLoc) {
|
|
|
|
Team1SpawnLoc = team1SpawnLoc;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setTeam2SpawnLoc(Location team2SpawnLoc) {
|
|
|
|
Team2SpawnLoc = team2SpawnLoc;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setTeam1PasteLoc(Location team1PasteLoc) {
|
|
|
|
Team1PasteLoc = team1PasteLoc;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setTeam2PasteLoc(Location team2PasteLoc) {
|
|
|
|
Team2PasteLoc = team2PasteLoc;
|
|
|
|
}
|
|
|
|
|
2019-02-15 16:32:51 +01:00
|
|
|
public void setSpecSpawnLoc(Location specSpawnLoc) {
|
|
|
|
SpecSpawnLoc = specSpawnLoc;
|
|
|
|
}
|
|
|
|
|
2019-02-14 18:37:38 +01:00
|
|
|
public void setArenaMinX(int arenaMinX) {
|
|
|
|
ArenaMinX = arenaMinX;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setArenaMaxX(int arenaMaxX) {
|
|
|
|
ArenaMaxX = arenaMaxX;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setArenaMinZ(int arenaMinZ) {
|
|
|
|
ArenaMinZ = arenaMinZ;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setArenaMaxZ(int arenaMaxZ) {
|
|
|
|
ArenaMaxZ = arenaMaxZ;
|
|
|
|
}
|
|
|
|
}
|