SteamWar/FightSystem
Archiviert
13
1

Merge branch 'implementing-check-capability'

Dieser Commit ist enthalten in:
Lixfel 2020-05-10 19:18:30 +02:00
Commit ac6b441815
3 geänderte Dateien mit 71 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()){
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,56 @@
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.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import java.util.EnumSet;
import java.util.logging.Level;
public class CheckListener extends BasicListener {
public CheckListener() {
super(Config.check() ? EnumSet.allOf(FightState.class) : EnumSet.noneOf(FightState.class));
}
@EventHandler
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("");
}
@EventHandler
public void handlePlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
if(!event.getMessage().contains("copy") && !event.getMessage().contains("cut"))
return;
event.setCancelled(true);
player.sendMessage("§cDieser Befehl ist beim Prüfen gesperrt! Admin wird benachrichtigt.");
Bukkit.getLogger().log(Level.SEVERE, player.getName() + " tried to use a copy command!");
}
private static boolean allowedToCheck(SteamwarUser user) {
return user.getUserGroup() == UserGroup.Supporter ||
user.getUserGroup() == UserGroup.Developer ||
user.getUserGroup() == UserGroup.Moderator ||
user.getUserGroup() == UserGroup.Admin;
}
}