Merge branch 'implementing-check-capability'
Dieser Commit ist enthalten in:
Commit
ac6b441815
@ -116,6 +116,9 @@ public class Config {
|
|||||||
public static final boolean BothTeamsPublic;
|
public static final boolean BothTeamsPublic;
|
||||||
public static final int MaximumTeamMembers;
|
public static final int MaximumTeamMembers;
|
||||||
|
|
||||||
|
//check parameter
|
||||||
|
public static final int CheckSchemID;
|
||||||
|
|
||||||
static{
|
static{
|
||||||
File worldConfigFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml");
|
File worldConfigFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml");
|
||||||
if(!worldConfigFile.exists()) {
|
if(!worldConfigFile.exists()) {
|
||||||
@ -336,6 +339,8 @@ public class Config {
|
|||||||
RedLeader = UUID.fromString(redLeader);
|
RedLeader = UUID.fromString(redLeader);
|
||||||
else
|
else
|
||||||
RedLeader = null;
|
RedLeader = null;
|
||||||
|
|
||||||
|
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean event(){
|
public static boolean event(){
|
||||||
@ -344,4 +349,7 @@ public class Config {
|
|||||||
public static boolean test(){
|
public static boolean test(){
|
||||||
return EventKampfID == -1;
|
return EventKampfID == -1;
|
||||||
}
|
}
|
||||||
|
public static boolean check(){
|
||||||
|
return CheckSchemID != 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import de.steamwar.fightsystem.states.StateDependent;
|
|||||||
import de.steamwar.fightsystem.utils.*;
|
import de.steamwar.fightsystem.utils.*;
|
||||||
import de.steamwar.fightsystem.winconditions.*;
|
import de.steamwar.fightsystem.winconditions.*;
|
||||||
import de.steamwar.sql.EventFight;
|
import de.steamwar.sql.EventFight;
|
||||||
|
import de.steamwar.sql.Schematic;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -58,6 +59,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
new InFightDamageListener();
|
new InFightDamageListener();
|
||||||
new FreezeWorldStateListener();
|
new FreezeWorldStateListener();
|
||||||
new EventJoinListener();
|
new EventJoinListener();
|
||||||
|
new CheckListener();
|
||||||
new TestListener();
|
new TestListener();
|
||||||
new NormalJoinListener();
|
new NormalJoinListener();
|
||||||
if(Core.getVersion() > 8)
|
if(Core.getVersion() > 8)
|
||||||
@ -95,7 +97,11 @@ public class FightSystem extends JavaPlugin {
|
|||||||
|
|
||||||
setPreSchemState();
|
setPreSchemState();
|
||||||
}else if(Config.test()){
|
}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);
|
Bukkit.getScheduler().runTaskLater(this, Fight.getRedTeam()::pasteDummy, 0);
|
||||||
|
|
||||||
setPreSchemState();
|
setPreSchemState();
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren