SteamWar/FightSystem
Archiviert
13
1

Merge pull request 'Kick all nonparticipants if Event with SpectateSystem' (#198) from kickNonParticipants into master

Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Lixfel 2020-10-30 21:42:40 +01:00
Commit fa03bc0609
2 geänderte Dateien mit 19 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -140,6 +140,7 @@ public class Config {
public static final int EventTeamRedID;
public static final boolean BothTeamsPublic;
public static final int MaximumTeamMembers;
public static final boolean SpectateSystem;
//check parameter
public static final int CheckSchemID;
@ -370,6 +371,7 @@ public class Config {
OnlyPublicSchematics = event.publicSchemsOnly();
MaximumTeamMembers = event.getMaximumTeamMembers();
}
SpectateSystem = event.spectateSystem();
}else{
//No event
TeamRedName = config.getString("Output.TeamRedName");
@ -379,6 +381,7 @@ public class Config {
EventTeamRedID = 0;
BothTeamsPublic = true;
MaximumTeamMembers = Integer.MAX_VALUE;
SpectateSystem = false;
}
String blueLeader = System.getProperty("blueLeader", null);

Datei anzeigen

@ -29,6 +29,7 @@ import de.steamwar.sql.SteamwarUser;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.EnumSet;
@ -39,6 +40,21 @@ public class EventJoinListener extends BasicListener {
super(Config.event() ? EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP) : EnumSet.noneOf(FightState.class));
}
@EventHandler
public void playerLogin(PlayerLoginEvent event) {
if(!Config.SpectateSystem)
return;
Player player = event.getPlayer();
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if(user.getTeam() == Config.EventTeamBlueID ||
user.getTeam() == Config.EventTeamRedID ||
user.getId() == FightSystem.getEventFight().getKampfleiter())
return;
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "§cDu bist kein Kampfteilnehmer");
}
@EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();