SteamWar/FightSystem
Archiviert
13
1

Schematic Paste + Config refactor

Dieser Commit ist enthalten in:
lixfel 2019-04-05 19:32:59 +02:00
Ursprung 07813dec0a
Commit 95975c5e96
25 geänderte Dateien mit 446 neuen und 531 gelöschten Zeilen

Datei anzeigen

@ -8,11 +8,11 @@ Arena:
x: 0
y: 0
z: 0
Team1corner:
TeamBlueCorner:
x: 0
y: 0
z: 0
Team1toTeam2distance:
TeamBluetoReddistance:
x: 0
y: 0
z: 0
@ -21,11 +21,15 @@ Arena:
z: 0
underArenaBorder: 0
BorderFromSchematic: 0
Schematic:
OnlyPublicSchematics: boolean
Directory: /home/netuser/schematics/
SchematicType: airship
Output:
TeamRedColor: &c
TeamBlueColor: &3
TeamRedName: Team1
TeamRedPrefix: §c
TeamBlueName: Team2
TeamBluePrefix: §3
GameName: AirShip
TeamChatDetection: +
WinConditions:
@ -37,10 +41,8 @@ WinConditions:
WinConditionParams:
TimeoutTime: 0
EnterPhaseBegin: 0
PercentWin: 0
Fight:
OnlyPublicSchematics: boolean
PercentWin: 0.0
Money:
Win: 0
Lose: 0
Undecided: 0
Draw: 0

Datei anzeigen

@ -6,19 +6,21 @@ import me.yaruma.fightsystem.commands.AkCommand;
import me.yaruma.fightsystem.fight.*;
import me.yaruma.fightsystem.kit.KitManager;
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.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.winconditions.*;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.World;
import java.io.File;
@ -28,41 +30,11 @@ public class FightSystem extends JavaPlugin {
public static final String NOPERM = PREFIX + "§cDu darfst das nicht!";
private static FightSystem plugin;
private FileManager fileManager;
private FightManager fightManager;
private Scoreboard scoreboard;
private KitManager kitManager;
private WaterRemover waterRemover;
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;
@ -82,88 +54,12 @@ public class FightSystem extends JavaPlugin {
public void onEnable() {
plugin = this;
this.fileManager = new FileManager(plugin);
this.fightManager = new FightManager();
Config.load();
this.scoreboard = new Scoreboard(plugin);
this.kitManager = new KitManager();
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();
getKitManager().loadAllKits();
@ -171,8 +67,7 @@ public class FightSystem extends JavaPlugin {
init();
fightState = FightState.SETUP;
int setupDuration = fileManager.getIntegerFromConfig("Times.NoPlayersOnlineDuration");
Countdown countdown = new Countdown(setupDuration, new FinishNoPlayersOnline());
Countdown countdown = new Countdown(Config.SetupDuration, new FinishNoPlayersOnline());
countdown.startTimer(getPlugin());
}
@ -197,20 +92,14 @@ public class FightSystem extends JavaPlugin {
pm.registerEvents(new EntityExplodeListener(), plugin);
//WinConditions
if(fileManager.getBooleanFromConfig("WinConditions.AllDead")) pm.registerEvents(new WinconditionAllDead(), plugin);
if(fileManager.getBooleanFromConfig("WinConditions.CaptainDead")) pm.registerEvents(new WinconditionCaptainDead(), plugin);
if(fileManager.getBooleanFromConfig("WinConditions.AllDead")) pm.registerEvents(new WinconditionAllDead(), plugin);
if(fileManager.getBooleanFromConfig("WinConditions.PercentSystem")) pm.registerEvents(new WinconditionPercentSystem(), plugin);
if(Config.AllDead) pm.registerEvents(new WinconditionAllDead(), plugin);
if(Config.CaptainDead) pm.registerEvents(new WinconditionCaptainDead(), plugin);
if(Config.PercentSystem) pm.registerEvents(new WinconditionPercentSystem(), plugin);
getCommand("ak").setExecutor(new AkCommand());
}
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()) {
saveKitData();
System.out.println(PREFIX + "kits.data erstellt und geladen!");
@ -226,14 +115,6 @@ public class FightSystem extends JavaPlugin {
return fightState;
}
public FileManager getFileManager() {
return this.fileManager;
}
public FightManager getFightManager() {
return this.fightManager;
}
public FightState getFightState() {
return fightState;
}
@ -250,20 +131,13 @@ public class FightSystem extends JavaPlugin {
return waterRemover;
}
public void setSetupState() {
if(this.fightState == null) {
this.fightState = FightState.SETUP;
}
}
public void setPreRunningState() {
if(this.fightState != FightState.SETUP)
return;
this.fightState = FightState.PRE_RUNNING;
Countdown.cancelAllTimers();
int time = fileManager.getIntegerFromConfig("Times.PreFightDuration");
Countdown countdown = new Countdown(time, new FinishPreRunning());
Countdown countdown = new Countdown(Config.PreFightDuration, new FinishPreRunning());
countdown.startTimer(this);
for(FightPlayer allFightPlayers : Fight.getBlueTeam().getPlayers()) {
allFightPlayers.getPlayer().getInventory().clear();
@ -272,10 +146,18 @@ public class FightSystem extends JavaPlugin {
allFightPlayers.getPlayer().getInventory().clear();
}
getFightManager().teleportAllToFightSpawn();
WorldEdit.replace(Fight.getBlueTeam().getLeader().getPlayer(), team1cornerX, team1cornerY, team1cornerZ, team1cornerX + schemsizeX, team1cornerY + schemsizeY, team1cornerZ + schemsizeZ);
teleportAllToFightSpawn();
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!");
}
@ -314,116 +196,35 @@ public class FightSystem extends JavaPlugin {
Bukkit.broadcastMessage(" ");
if(winFightTeam != null) {
Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getPrefix() + winFightTeam.getName() + " §ahat gewonnen!");
plugin.getFightManager().teleportAllToFightSpawn();
Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getName() + " §ahat gewonnen!");
teleportAllToFightSpawn();
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()) {
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Lose"));
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(Config.MoneyLose);
}
} else {
Bukkit.broadcastMessage(PREFIX + "§aKein Team hat gewonnen!");
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()) {
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());
}
private int getMoneyToPay(String moneyPath) {
return fileManager.getIntegerFromConfig(moneyPath);
}
public static WorldEditPlugin getWorldEditPlugin() {
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() {
return fightTime;
}
@ -441,4 +242,20 @@ public class FightSystem extends JavaPlugin {
public boolean isEntern() {
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);
}
}
}

Datei anzeigen

@ -1,11 +1,14 @@
package me.yaruma.fightsystem.commands;
import de.warking.hunjy.MySQL.Schematic;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightPlayer;
import me.yaruma.fightsystem.fight.FightState;
import me.yaruma.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.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.command.Command;
import org.bukkit.command.CommandExecutor;
@ -14,8 +17,6 @@ import org.bukkit.entity.Player;
public class AkCommand implements CommandExecutor {
FileManager fileManager = FightSystem.getPlugin().getFileManager();
@Override
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){
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam != null) {
if(!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!");
}
fightTeam.setReady(!fightTeam.isReady());
}
}else if(args[0].equalsIgnoreCase("accept") && FightSystem.getPlugin().getFightState() == FightState.SETUP){
@ -64,12 +59,12 @@ public class AkCommand implements CommandExecutor {
if(!Fight.getBlueTeam().hasTeamLeader()){
FightPlayer fightPlayer = new FightPlayer(player, false);
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()){
FightPlayer fightPlayer = new FightPlayer(player, false);
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
player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits zwei Leader vorhanden!");
@ -112,10 +107,57 @@ public class AkCommand implements CommandExecutor {
}
}
}
} else if(args[0].equalsIgnoreCase("kit")) {
if(FightSystem.getPlugin().getFightState() == FightState.SETUP) {
//Kit
}else if(args[0].equalsIgnoreCase("kit")) {
if(FightSystem.getPlugin().getFightState() != FightState.SETUP) {
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{
sendHelp(player);
@ -123,7 +165,14 @@ public class AkCommand implements CommandExecutor {
return false;
}
private void sendHelp(Player player) {
player.sendMessage("-----[ Hilfe ]-----");
private void sendHelp(Player p) {
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");
}
}

Datei anzeigen

@ -1,12 +1,12 @@
package me.yaruma.fightsystem.fight;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.utils.Config;
import org.bukkit.entity.Player;
public class Fight {
public static final FightTeam redTeam = new FightTeam(null, FightSystem.getPlugin());
public static final FightTeam blueTeam = new FightTeam(null, FightSystem.getPlugin());
public static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedPrefix);
public static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBluePrefix);
public static FightTeam getPlayerTeam(Player player) {

Datei anzeigen

@ -1,13 +0,0 @@
package me.yaruma.fightsystem.fight;
import org.bukkit.entity.Player;
class FightCreator {
@SuppressWarnings("EmptyMethod")
public static void invitePlayerToTeam(Player player) {
}
}

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -1,28 +1,38 @@
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.utils.Config;
import me.yaruma.fightsystem.utils.ItemBuilder;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
public class FightTeam {
private FightPlayer leader;
private final ArrayList<FightPlayer> players;
private FightSystem plugin;
private boolean ready;
private final ArrayList<Player> invited;
private String name;
private String prefix;
private Schematic schematic;
public FightTeam(Player leader, FightSystem plugin) {
this.plugin = plugin;
this.leader = new FightPlayer(leader, false);
public FightTeam(String Name, String Prefix) {
players = new ArrayList<>();
invited = new ArrayList<>();
name = Name;
prefix = Prefix;
}
public FightPlayer getFightPlayer(Player player) {
@ -57,10 +67,6 @@ public class FightTeam {
return leader.getPlayer().equals(player);
}
public boolean isPlayerMember(Player player) {
return isPlayerInTeam(player) && !isPlayerLeader(player);
}
public void broadcast(String message) {
for(FightPlayer fightPlayer : players) {
fightPlayer.sendMessage(message);
@ -79,7 +85,7 @@ public class FightTeam {
}
public boolean hasTeamLeader() {
return leader.getPlayer() != null;
return leader != null;
}
public FightPlayer getLeader() {
@ -96,35 +102,59 @@ public class FightTeam {
return players;
}
public FightSystem getPlugin() {
return plugin;
}
public void setPlugin(FightSystem plugin) {
this.plugin = plugin;
}
public boolean isReady() {
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) {
Player leader = getLeader().getPlayer();
if(schematic == null){
leader.sendMessage(FightSystem.PREFIX + "§cZuerst muss eine Schematic gewählt sein!");
return;
}
this.ready = ready;
FightTeam fightTeam = Fight.getPlayerTeam(this.leader.getPlayer());
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());
if(ready) {
leader.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!");
if(Fight.getOpposite(fightTeam).isReady()) {
instance.setPreRunningState();
if(Fight.getOpposite(this).isReady()) {
FightSystem.getPlugin().setPreRunningState();
}
} else {
fightTeam.getLeader().getPlayer().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!");
leader.getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit!");
}
}
@ -133,18 +163,10 @@ public class FightTeam {
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
return prefix + name;
}
public String getPrefix() {
return prefix;
}
public void setPrefix(String prefix) {
this.prefix = prefix;
}
}

Datei anzeigen

@ -1,5 +1,6 @@
package me.yaruma.fightsystem.kit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.PlayerInventory;
@ -58,4 +59,9 @@ public class Kit {
public void setPlayerInventory(Inventory inventory) {
this.playerInventory = playerInventory;
}
public void loadToPlayer(Player player) {
player.getInventory().setContents(playerInventory.getContents());
player.getInventory().setArmorContents(playerInventory.getArmorContents());
}
}

Datei anzeigen

@ -19,12 +19,11 @@ import java.util.List;
public class KitManager {
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 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));
ItemStack[] content = ((List<ItemStack>) yamlConfiguration.get("Kits." + kitName + ".Armor")).toArray(new ItemStack[0]);
player.getInventory().setArmorContents(content);
@ -32,14 +31,14 @@ public class KitManager {
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.set("Kits." + kitName + ".Armor", player.getInventory().getArmorContents());
yamlConfiguration.set("Kits." + kitName + ".Items", player.getInventory().getContents());
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()) {
return true;
} else
@ -50,11 +49,11 @@ public class KitManager {
//wird spaeter gemacht
}
public boolean ownsKit(Player player) {
public static boolean ownsKit(Player player) {
return true; //wird spaeter gemacht
}
public void loadKitToPlayer(Kit kit, Player player) {
public static void loadKitToPlayer(Kit kit, Player player) {
if(kit != null) {
if(ownsKit(player)) {
@ -62,24 +61,21 @@ public class KitManager {
if(fightPlayer != null) {
if(fightPlayer.isLeader() && kit.isLeaderAllowed() || !fightPlayer.isLeader() && kit.isMemberAllowed()) {
loadInventoryToPlayer(kit.getName(), player);
player.sendMessage(PREFIX + "§6" + kit.getName() + " §ageladen!");
player.sendMessage(FightSystem.PREFIX + "§6" + kit.getName() + " §ageladen!");
} else {
player.sendMessage(PREFIX + "§cDu darfst dieses Kit nicht verwenden!");
System.out.println(PREFIX + "§4Warning: EIN SPIELER WOLLTE EIN KIT AUSWAEHLEN WELCHES FUER IHN NICHT ZUGAENGLICH IST!");
player.sendMessage(FightSystem.PREFIX + "§cDu darfst dieses Kit nicht verwenden!");
}
} else {
player.sendMessage(PREFIX + "§cDu befindest dich in keinem Team!");
System.out.println(PREFIX + "§4Warning: EIN SPIELER WOLLTE EIN KIT AUSWAEHLEN OBWOHL ER IN KEINEM TEAM IST!");
player.sendMessage(FightSystem.PREFIX + "§cDu befindest dich in keinem Team!");
}
} else {
player.sendMessage(PREFIX + "§cDu besitzt dieses Kit nicht!");
System.out.println("§4Warning: JEMAND HAT VERSUCHT EIN KIT ZU LADEN WELCHES ER NICHT BESITZT!");
player.sendMessage(FightSystem.PREFIX + "§cDu besitzt dieses Kit nicht!");
}
}
}
public Kit loadKitFromConfig(String name) {
public static Kit loadKitFromConfig(String name) {
if(instance.getKitData().contains("Kit." + name)) {
ItemStack[] armor = (ItemStack[]) instance.getKitData().get("Kit." + name + ".Armor");
ItemStack[] items = (ItemStack[]) instance.getKitData().get("Kit." + name + ".Items");
@ -99,13 +95,13 @@ public class KitManager {
return null;
}
public void loadAllKits() {
for(String key : instance.getKitData().getConfigurationSection("Kits").getKeys(false)) {
loadedKits.add(loadKitFromConfig(key));
}
public static void loadAllKits() {
//for(String key : instance.getKitData().getConfigurationSection("Kits").getKeys(false)) {
// loadedKits.add(loadKitFromConfig(key));
//}
}
public Kit getKitByName(String kitName) {
public static Kit getKitByName(String kitName) {
for(Kit kit : loadedKits) {
if(kit.getName().equalsIgnoreCase(kitName))
return kit;

Datei anzeigen

@ -1,9 +1,8 @@
package me.yaruma.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
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.entity.Player;
import org.bukkit.event.EventHandler;
@ -12,24 +11,19 @@ import org.bukkit.event.player.PlayerChatEvent;
public class PlayerChatListener implements Listener {
private final FileManager fileManager = FightSystem.getPlugin().getFileManager();
@EventHandler
public void handlePlayerChat(PlayerChatEvent event) {
Player player = event.getPlayer();
String message = event.getMessage();
String teamChatDetection = fileManager.getStringFromConfig("Output.TeamChatDetection");
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam != null) {
String prefixColorCode = fightTeam.getPrefix();
String teamName = fightTeam.getName();
if(message.startsWith(teamChatDetection)) {
fightTeam.broadcast(prefixColorCode + player.getName() + "» " + prefixColorCode + message.substring(1));
if(message.startsWith(Config.TeamChatDetection)) {
fightTeam.broadcast(teamName + " " + player.getName() + "» " + message.substring(1));
} else {
Bukkit.broadcastMessage(prefixColorCode + teamName + " " + player.getName() + "§8» §7" + message);
Bukkit.broadcastMessage(teamName + " " + player.getName() + "§8» §7" + message);
}
}else{
Bukkit.broadcastMessage("§7" + player.getName() + "§8» §7" + message);

Datei anzeigen

@ -5,7 +5,6 @@ import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightPlayer;
import me.yaruma.fightsystem.fight.FightState;
import me.yaruma.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.manager.FileManager;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -16,7 +15,6 @@ import org.bukkit.inventory.meta.ItemMeta;
public class PlayerInteractListener implements Listener {
FileManager fileManager = FightSystem.getPlugin().getFileManager();
private final FightSystem instance = FightSystem.getPlugin();
@EventHandler

Datei anzeigen

@ -5,7 +5,7 @@ import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightPlayer;
import me.yaruma.fightsystem.fight.FightState;
import me.yaruma.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.manager.FileManager;
import me.yaruma.fightsystem.utils.Config;
import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.CountdownType;
import me.yaruma.fightsystem.utils.countdown.FinishSetupOver;
@ -20,7 +20,6 @@ import org.bukkit.event.player.PlayerJoinEvent;
public class PlayerJoinListener implements Listener {
private final FightSystem instance = FightSystem.getPlugin();
private final FileManager fileManager = instance.getFileManager();
@EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) {
@ -41,7 +40,7 @@ public class PlayerJoinListener implements Listener {
player.setGameMode(GameMode.ADVENTURE);
} else {
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(fightTeam == Fight.redTeam) {
player.teleport(instance.getFightManager().getRedTeleportLocation());
player.teleport(Config.TeamRedSpawn);
} else
player.teleport(instance.getFightManager().getBlueTeleportLocation());
player.teleport(Config.TeamBlueSpawn);
player.setGameMode(GameMode.ADVENTURE);
if(fightPlayer.isLeader()) SetupItems.giveSetupItems(player);
@ -67,17 +66,16 @@ public class PlayerJoinListener implements Listener {
} else {
player.setGameMode(GameMode.SPECTATOR);
if(fightTeam == Fight.redTeam)
player.teleport(instance.getFightManager().getRedTeleportLocation());
player.teleport(Config.TeamRedSpawn);
else
player.teleport(instance.getFightManager().getBlueTeleportLocation());
player.teleport(Config.TeamBlueSpawn);
}
}
if(Fight.getRedTeam().hasTeamLeader() && Fight.getBlueTeam().hasTeamLeader()) {
Countdown.cancelTimerType(CountdownType.NO_PLAYERS_ONLINE);
int setupDuration = fileManager.getIntegerFromConfig("Times.SetupDuration");
Countdown countdown = new Countdown(setupDuration, new FinishSetupOver());
Countdown countdown = new Countdown(Config.SetupDuration, new FinishSetupOver());
countdown.startTimer(instance);
}

Datei anzeigen

@ -4,7 +4,7 @@ import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightState;
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 org.bukkit.Location;
import org.bukkit.entity.Player;
@ -15,7 +15,6 @@ import org.bukkit.event.player.PlayerMoveEvent;
public class PlayerMoveListener implements Listener {
private final FightSystem instance = FightSystem.getPlugin();
private final FileManager fileManager = FightSystem.getPlugin().getFileManager();
@EventHandler
public void handlePlayerMove(PlayerMoveEvent event) {
@ -25,29 +24,29 @@ public class PlayerMoveListener implements Listener {
FightTeam fightTeam = Fight.getPlayerTeam(player);
//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.sendMessage(FightSystem.PREFIX + "§cDu darfst die Arena nicht verlassen!");
return;
}
//Check under Arena
if(to.getBlockY() <= instance.underArenaBorder) {
if(to.getBlockY() <= Config.underArenaBorder) {
if(fightTeam == null){
player.teleport(from);
player.sendMessage(FightSystem.PREFIX + "§cDu darfst die Arena nicht verlassen!");
}else if(instance.getCurrentFightState() == FightState.RUNNING)
player.damage(2);
else if(fightTeam == Fight.redTeam)
player.teleport(instance.getFightManager().getRedTeleportLocation());
player.teleport(Config.TeamRedSpawn);
else
player.teleport(instance.getFightManager().getBlueTeleportLocation());
player.teleport(Config.TeamBlueSpawn);
return;
}
//Check TeamAreas
boolean inBlueArea = Region.isIn2DRange(to, instance.getTeam1cornerX(), instance.getTeam1cornerZ(), instance.getSchemsizeX(), instance.getSchemsizeZ(), fileManager.getIntegerFromConfig("Arena.BorderFromSchematic"));
boolean inRedArea = Region.isIn2DRange(to, instance.getTeam2cornerX(), instance.getTeam2cornerZ(), 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, Config.TeamRedCornerX, Config.TeamRedCornerZ, Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic);
if(inBlueArea || inRedArea) {
if(fightTeam == null){
@ -56,7 +55,7 @@ public class PlayerMoveListener implements Listener {
}
}else if(fightTeam != null && !instance.isEntern()){
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!");
}
}
}

Datei anzeigen

@ -25,7 +25,7 @@ public class PlayerQuitListener implements Listener {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §chat den Kampf verlassen!");
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.startTimer(FightSystem.getPlugin());
}

Datei anzeigen

@ -2,6 +2,7 @@ package me.yaruma.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.utils.Config;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -16,11 +17,11 @@ public class PlayerRespawnListener implements Listener {
Player player = event.getPlayer();
if(Fight.getPlayerTeam(player) != null) {
if(Fight.getPlayerTeam(player) == Fight.redTeam) {
event.setRespawnLocation(instance.getTeam1SpawnLoc());
event.setRespawnLocation(Config.TeamRedSpawn);
} else
event.setRespawnLocation(instance.getTeam2SpawnLoc());
event.setRespawnLocation(Config.TeamBlueSpawn);
} else
event.setRespawnLocation(instance.getSpecSpawnLoc());
event.setRespawnLocation(Config.SpecSpawn);
}

Datei anzeigen

@ -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();
}
}
}

Datei anzeigen

@ -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;
}
}
}

Datei anzeigen

@ -1,12 +1,9 @@
package me.yaruma.fightsystem.utils.countdown;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.manager.FileManager;
public class FinishPreRunning implements CountdownCallback {
FileManager fileManager = FightSystem.getPlugin().getFileManager();
@Override
public String countdownCounting() {
return "bis die Arena freigegeben ist!";

Datei anzeigen

@ -4,7 +4,7 @@ import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightPlayer;
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.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
@ -35,7 +35,7 @@ public class Scoreboard {
scoreboard.registerNewObjective("AAA", "BBB");
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.setDisplayName(fightTeam.getPrefix() + fightTeam.getName());
objective.setDisplayName(fightTeam.getName());
for (FightPlayer fp : fightTeam.getPlayers()) {
objective.getScore(fightTeam.getPrefix() + fp.getPlayer().getName()).setScore((int) fp.getPlayer().getHealth());
@ -50,19 +50,19 @@ public class Scoreboard {
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.setDisplayName("§6Kampf");
if (Methods.isEnabled("WinConditions.Timeout")) {
if (Config.Timeout) {
int fightTime = FightSystem.getPlugin().getFightTime();
if (fightTime >= 60)
objective.getScore("§7Zeit: §a" + fightTime / 60 + "m " + fightTime % 60 + "s").setScore(3);
else
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);
if (Methods.isEnabled("WinConditions.PercentSystem"))
if (Config.PercentSystem){
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);
}
index = 0;
}
player.setScoreboard(scoreboard);

Datei anzeigen

@ -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);
}
}

Datei anzeigen

@ -3,6 +3,7 @@ package me.yaruma.fightsystem.winconditions;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.utils.Config;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -16,7 +17,7 @@ public class WinconditionAllDead implements Listener {
@EventHandler
public void handlePlayerDeath(PlayerDeathEvent event) {
if(!Methods.isEnabled("WinConditions.AllDead")) return;
if(!Config.AllDead) return;
Player player = event.getEntity().getPlayer();
if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player);
@ -29,7 +30,7 @@ public class WinconditionAllDead implements Listener {
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
if(!Methods.isEnabled("WinConditions.AllDead")) return;
if(!Config.AllDead) return;
Player player = event.getPlayer();
if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player);

Datei anzeigen

@ -3,7 +3,7 @@ package me.yaruma.fightsystem.winconditions;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
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.entity.Player;
import org.bukkit.event.EventHandler;
@ -14,11 +14,10 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class WinconditionCaptainDead implements Listener {
private final FightSystem instance = FightSystem.getPlugin();
FileManager fileManager = instance.getFileManager();
@EventHandler
public void handlePlayerDeath(PlayerDeathEvent event) {
if(!Methods.isEnabled("WinConditions.CaptainDead")) return;
if(!Config.CaptainDead) return;
Player player = event.getEntity().getPlayer();
if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player);
@ -32,7 +31,7 @@ public class WinconditionCaptainDead implements Listener {
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
if(!Methods.isEnabled("WinConditions.CaptainDead")) return;
if(!Config.CaptainDead) return;
Player player = event.getPlayer();
if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player);

Datei anzeigen

@ -1,20 +1,18 @@
package me.yaruma.fightsystem.winconditions;
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.FinishNoneEntern;
public class WinconditionEntern {
private static final FightSystem instance = FightSystem.getPlugin();
private static final FileManager fileManager = instance.getFileManager();
public static void entern() {
if(!Methods.isEnabled("WinConditions.Entern")) return;
if(!Config.Entern) return;
int timeTimeOver = fileManager.getIntegerFromConfig("WinConditionParams.EnterPhaseBegin");
Countdown countdownTimeOver = new Countdown(timeTimeOver, new FinishNoneEntern());
Countdown countdownTimeOver = new Countdown(Config.EnterPhaseBegin, new FinishNoneEntern());
countdownTimeOver.startTimer(instance);
}

Datei anzeigen

@ -2,7 +2,7 @@ package me.yaruma.fightsystem.winconditions;
import me.yaruma.fightsystem.FightSystem;
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 org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
@ -12,43 +12,38 @@ import org.bukkit.event.entity.EntityExplodeEvent;
public class WinconditionPercentSystem implements Listener {
private static int team1DestroyedBlocks;
private static int team2DestroyedBlocks;
private static int blueDestroyedBlocks;
private static int redDestroyedBlocks;
private final FightSystem instance = FightSystem.getPlugin();
private final FileManager fileManager = instance.getFileManager();
private static int schematicSize;
private static final int schematicSize =
Math.abs(
FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.x") *
FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.y") *
FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.z"));
public WinconditionPercentSystem() {
schematicSize = Math.abs(Config.SchemsizeX * Config.SchemsizeY * Config.SchemsizeZ);
}
@EventHandler
public void handleEntityExplode(EntityExplodeEvent event) {
Bukkit.broadcastMessage("boom");
if(!Methods.isEnabled("WinConditions.PercentSystem")) return;
Bukkit.broadcastMessage("enabled");
if(!Config.PercentSystem) return;
Entity entity = event.getEntity();
//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"))) {
team1DestroyedBlocks = team1DestroyedBlocks + event.blockList().size();
if(Region.isInRange(entity.getLocation(), Config.TeamBlueCornerX, Config.TeamBlueCornerY, Config.TeamBlueCornerZ, Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ, Config.BorderFromSchematic)){
blueDestroyedBlocks = blueDestroyedBlocks + event.blockList().size();
Bukkit.broadcastMessage("red");
double destroyPercent = team1DestroyedBlocks * 100 / schematicSize;
double destroyPercent = blueDestroyedBlocks * 100 / schematicSize;
Bukkit.broadcastMessage(" " + destroyPercent);
if(destroyPercent >= fileManager.getIntegerFromConfig("WinConditionParams.PercentWin")) {
instance.setSpectateState(Fight.blueTeam);
if(destroyPercent >= Config.PercentWin) {
FightSystem.getPlugin().setSpectateState(Fight.blueTeam);
}
return;
}
//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"))) {
team2DestroyedBlocks = team2DestroyedBlocks + event.blockList().size();
double destroyPercent = team2DestroyedBlocks * 100 / schematicSize;
if(destroyPercent >= fileManager.getIntegerFromConfig("WinConditionParams.PercentWin")) {
instance.setSpectateState(Fight.redTeam);
if(Region.isInRange(entity.getLocation(), Config.TeamRedCornerX, Config.TeamRedCornerY, Config.TeamRedCornerZ, Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ, Config.BorderFromSchematic)) {
redDestroyedBlocks = redDestroyedBlocks + event.blockList().size();
double destroyPercent = redDestroyedBlocks * 100 / schematicSize;
if(destroyPercent >= Config.PercentWin) {
FightSystem.getPlugin().setSpectateState(Fight.redTeam);
}
return;
}

Datei anzeigen

@ -1,20 +1,18 @@
package me.yaruma.fightsystem.winconditions;
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.FinishTimeOver;
public class WinconditionTimeout {
private static final FightSystem instance = FightSystem.getPlugin();
private static final FileManager fileManager = instance.getFileManager();
public static void timeout() {
if(!Methods.isEnabled("WinConditions.Timeout")) return;
if(!Config.Timeout) return;
int timeTimeOver = fileManager.getIntegerFromConfig("WinConditionParams.TimeoutTime");
Countdown countdownTimeOver = new Countdown(timeTimeOver, new FinishTimeOver());
Countdown countdownTimeOver = new Countdown(Config.TimeoutTime, new FinishTimeOver());
countdownTimeOver.startTimer(instance);
}