SteamWar/FightSystem
Archiviert
13
1

made it more modular; fixed some bugs and null pointers

Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Yaruma3341 2019-03-24 00:43:05 +01:00
Ursprung 2676e6e125
Commit ab9dc24bc2
17 geänderte Dateien mit 50 neuen und 38 gelöschten Zeilen

Datei anzeigen

@ -5,7 +5,6 @@ Times:
SpectatorDuration: 0 SpectatorDuration: 0
Arena: Arena:
WorldName: worldName
Schemsize: Schemsize:
x: 0 x: 0
y: 0 y: 0
@ -37,6 +36,7 @@ WinConditions:
AllDead: boolean AllDead: boolean
CaptainDead: boolean CaptainDead: boolean
PercentSystem: boolean PercentSystem: boolean
Entern: boolean
WinConditionParams: WinConditionParams:
TimeoutTime: 0 TimeoutTime: 0
@ -44,7 +44,6 @@ WinConditionParams:
PercentWin: 0 PercentWin: 0
Fight: Fight:
Entern: boolean
OnlyPublicSchematics: boolean OnlyPublicSchematics: boolean
Money: Money:

Datei anzeigen

@ -10,9 +10,7 @@ import me.yaruma.fightsystem.manager.FileManager;
import me.yaruma.fightsystem.utils.WorldEdit; import me.yaruma.fightsystem.utils.WorldEdit;
import me.yaruma.fightsystem.utils.countdown.*; import me.yaruma.fightsystem.utils.countdown.*;
import me.yaruma.fightsystem.utils.scoreboard.Scoreboard; import me.yaruma.fightsystem.utils.scoreboard.Scoreboard;
import me.yaruma.fightsystem.winconditions.WinconditionAllDead; import me.yaruma.fightsystem.winconditions.*;
import me.yaruma.fightsystem.winconditions.WinconditionCaptainDead;
import me.yaruma.fightsystem.winconditions.WinconditionPercentSystem;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
@ -110,7 +108,7 @@ public class FightSystem extends JavaPlugin {
int schem2BorderX = fileManager.getIntegerFromConfig("Arena.Schem2Border.x"); int schem2BorderX = fileManager.getIntegerFromConfig("Arena.Schem2Border.x");
int schem2BorderZ = fileManager.getIntegerFromConfig("Arena.Schem2Border.z"); int schem2BorderZ = fileManager.getIntegerFromConfig("Arena.Schem2Border.z");
World world = Bukkit.getWorld(fileManager.getStringFromConfig("Arena.WorldName")); World world = Bukkit.getWorlds().get(0);
underArenaBorder = fileManager.getIntegerFromConfig("Arena.underArenaBorder"); underArenaBorder = fileManager.getIntegerFromConfig("Arena.underArenaBorder");
@ -298,13 +296,8 @@ public class FightSystem extends JavaPlugin {
setAllPlayersGM(GameMode.SURVIVAL); setAllPlayersGM(GameMode.SURVIVAL);
if(fileManager.getBooleanFromConfig("WinConditions.Timeout")) { if(fileManager.getBooleanFromConfig("WinConditions.Timeout")) {
int timeTimeOver = fileManager.getIntegerFromConfig("WinConditionParams.TimeoutTime"); WinconditionTimeout.timeout();
Countdown countdownTimeOver = new Countdown(timeTimeOver, new FinishTimeOver()); WinconditionEntern.entern();
countdownTimeOver.startTimer(plugin);
int timeNoEntern = fileManager.getIntegerFromConfig("WinConditionParams.EnterPhaseBegin");
Countdown countdownTimeNoEntern = new Countdown(timeNoEntern, new FinishNoneEntern());
countdownTimeNoEntern.startTimer(plugin);
} }
Bukkit.broadcastMessage("§aArena freigegeben!"); Bukkit.broadcastMessage("§aArena freigegeben!");
} }

Datei anzeigen

@ -27,11 +27,11 @@ public class FightManager {
} }
public Location getBlueTeleportLocation() { public Location getBlueTeleportLocation() {
return FightSystem.getPlugin().getTeam1SpawnLoc(); return FightSystem.getPlugin().getTeam2SpawnLoc();
} }
public Location getRedTeleportLocation() { public Location getRedTeleportLocation() {
return FightSystem.getPlugin().getTeam2SpawnLoc(); return FightSystem.getPlugin().getTeam1SpawnLoc();
} }
public Location getBlueTeamPasteLocation() { public Location getBlueTeamPasteLocation() {

Datei anzeigen

@ -2,9 +2,6 @@ package me.yaruma.fightsystem.fight;
import me.yaruma.fightsystem.FightSystem; import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.utils.ItemBuilder; import me.yaruma.fightsystem.utils.ItemBuilder;
import me.yaruma.fightsystem.utils.WorldEdit;
import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.FinishPreRunning;
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;

Datei anzeigen

@ -6,7 +6,6 @@ import org.bukkit.inventory.ItemStack;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path;
import java.util.List; import java.util.List;
public class KitManager { public class KitManager {

Datei anzeigen

@ -6,14 +6,10 @@ 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.manager.FileManager;
import me.yaruma.fightsystem.utils.ItemBuilder;
import me.yaruma.fightsystem.utils.WorldEdit;
import me.yaruma.fightsystem.utils.countdown.Countdown; import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.FinishNoPlayersOnline; import me.yaruma.fightsystem.utils.countdown.FinishNoPlayersOnline;
import me.yaruma.fightsystem.utils.countdown.FinishPreRunning;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
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;

Datei anzeigen

@ -43,6 +43,7 @@ public class PlayerJoinListener implements Listener {
player.setGameMode(GameMode.SPECTATOR); player.setGameMode(GameMode.SPECTATOR);
player.teleport(instance.getSpecSpawnLoc()); player.teleport(instance.getSpecSpawnLoc());
} }
return;
} }
FightTeam fightTeam = Fight.getPlayerTeam(player); FightTeam fightTeam = Fight.getPlayerTeam(player);
@ -51,9 +52,9 @@ public class PlayerJoinListener implements Listener {
FightPlayer fightPlayer = fightTeam.getFightPlayer(player); FightPlayer fightPlayer = fightTeam.getFightPlayer(player);
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(instance.getFightManager().getRedTeleportLocation());
else } else
player.teleport(instance.getFightManager().getBlueTeleportLocation()); player.teleport(instance.getFightManager().getBlueTeleportLocation());
player.setGameMode(GameMode.ADVENTURE); player.setGameMode(GameMode.ADVENTURE);

Datei anzeigen

@ -63,15 +63,4 @@ public class FileManager
e.printStackTrace(); e.printStackTrace();
} }
} }
public Location getLocationFormConfig(String path) {
World world = Bukkit.getWorld(getStringFromConfig(path + ".world"));
int x = getIntegerFromConfig(path + ".x");
int y = getIntegerFromConfig(path + ".y");
int z = getIntegerFromConfig(path + ".z");
Location location = new Location(world, x, y, z);
return location;
}
} }

Datei anzeigen

@ -19,7 +19,7 @@ public class Countdown {
this.countdownCallback = countdownCallback; this.countdownCallback = countdownCallback;
countdowns.add(this); countdowns.add(this);
if(countdownCallback == new FinishTimeOver()) FightSystem.getPlugin().fightTime = time; if(countdownCallback instanceof FinishTimeOver) FightSystem.getPlugin().fightTime = time;
} }
@ -40,6 +40,7 @@ public class Countdown {
Bukkit.broadcastMessage("§6Noch §aeine §6Sekunde " + countdownCallback.countdownCounting()); Bukkit.broadcastMessage("§6Noch §aeine §6Sekunde " + countdownCallback.countdownCounting());
break; break;
case 0: case 0:
cancelTimer();
countdownCallback.countdownFinished(); countdownCallback.countdownFinished();
break; break;
} }

Datei anzeigen

@ -2,7 +2,6 @@ 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.FightPlayer;
import me.yaruma.fightsystem.fight.FightTeam; import me.yaruma.fightsystem.fight.FightTeam;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

Datei anzeigen

@ -0,0 +1,22 @@
package me.yaruma.fightsystem.winconditions;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.manager.FileManager;
import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.FinishTimeOver;
public class WinconditionEntern {
private static FightSystem instance = FightSystem.getPlugin();
private static FileManager fileManager = instance.getFileManager();
public static void entern() {
if(!Methods.isEnabled("WinConditions.Entern")) return;
int timeTimeOver = fileManager.getIntegerFromConfig("WinConditionParams.EnterPhaseBegin");
Countdown countdownTimeOver = new Countdown(timeTimeOver, new FinishTimeOver());
countdownTimeOver.startTimer(instance);
}
}

Datei anzeigen

@ -1,6 +1,22 @@
package me.yaruma.fightsystem.winconditions; package me.yaruma.fightsystem.winconditions;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.manager.FileManager;
import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.FinishTimeOver;
public class WinconditionTimeout { public class WinconditionTimeout {
private static FightSystem instance = FightSystem.getPlugin();
private static FileManager fileManager = instance.getFileManager();
public static void timeout() {
if(!Methods.isEnabled("WinConditions.Timeout")) return;
int timeTimeOver = fileManager.getIntegerFromConfig("WinConditionParams.TimeoutTime");
Countdown countdownTimeOver = new Countdown(timeTimeOver, new FinishTimeOver());
countdownTimeOver.startTimer(instance);
}
} }