SteamWar/FightSystem
Archiviert
13
1

Implementing check capability into TestArenas

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2020-04-30 16:09:24 +02:00
Ursprung 1367305e26
Commit bf3baed537
3 geänderte Dateien mit 55 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -116,6 +116,9 @@ public class Config {
public static final boolean BothTeamsPublic;
public static final int MaximumTeamMembers;
//check parameter
public static final int CheckSchemID;
static{
File worldConfigFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml");
if(!worldConfigFile.exists()) {
@ -336,6 +339,8 @@ public class Config {
RedLeader = UUID.fromString(redLeader);
else
RedLeader = null;
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
}
public static boolean event(){
@ -344,4 +349,7 @@ public class Config {
public static boolean test(){
return EventKampfID == -1;
}
public static boolean check(){
return CheckSchemID != 0;
}
}

Datei anzeigen

@ -13,6 +13,7 @@ import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.utils.*;
import de.steamwar.fightsystem.winconditions.*;
import de.steamwar.sql.EventFight;
import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
@ -58,6 +59,7 @@ public class FightSystem extends JavaPlugin {
new InFightDamageListener();
new FreezeWorldStateListener();
new EventJoinListener();
new CheckListener();
new TestListener();
new NormalJoinListener();
if(Core.getVersion() > 8)
@ -95,7 +97,11 @@ public class FightSystem extends JavaPlugin {
setPreSchemState();
}else if(Config.test()){
Bukkit.getScheduler().runTaskLater(this, Fight.getBlueTeam()::pasteDummy, 0);
if(Config.check()){
Bukkit.getScheduler().runTaskLater(this, () -> Fight.getBlueTeam().setSchematic(Schematic.getSchemFromDB(Config.CheckSchemID)), 0);
}else{
Bukkit.getScheduler().runTaskLater(this, Fight.getBlueTeam()::pasteDummy, 0);
}
Bukkit.getScheduler().runTaskLater(this, Fight.getRedTeam()::pasteDummy, 0);
setPreSchemState();

Datei anzeigen

@ -0,0 +1,40 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerJoinEvent;
import java.util.EnumSet;
public class CheckListener extends BasicListener {
public CheckListener() {
super(Config.check() ? EnumSet.allOf(FightState.class) : EnumSet.noneOf(FightState.class));
}
public void onJoin(PlayerJoinEvent e){
Player player = e.getPlayer();
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if(allowedToCheck(user))
return;
Schematic schem = Schematic.getSchemFromDB(Config.CheckSchemID);
if(user.getId() == schem.getSchemOwner())
return;
player.sendMessage("§cAuf diesem Server wird momentan eine Schematic geprüft!");
player.kickPlayer("");
}
public static boolean allowedToCheck(SteamwarUser user) {
return user.getUserGroup() == UserGroup.Supporter ||
user.getUserGroup() == UserGroup.Developer ||
user.getUserGroup() == UserGroup.Moderator ||
user.getUserGroup() == UserGroup.Admin;
}
}