SteamWar/FightSystem
Archiviert
13
1

Kick all nonparticipants if Event with SpectateSystem #198

Manuell gemergt
Lixfel hat 1 Commits von kickNonParticipants nach master 2020-10-30 21:42:41 +01:00 zusammengeführt
2 geänderte Dateien mit 19 neuen und 0 gelöschten Zeilen
Nur Änderungen aus Commit 55b27082cb werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -140,6 +140,7 @@ public class Config {
public static final int EventTeamRedID; public static final int EventTeamRedID;
public static final boolean BothTeamsPublic; public static final boolean BothTeamsPublic;
public static final int MaximumTeamMembers; public static final int MaximumTeamMembers;
public static final boolean SpectateSystem;
Review

Wenn groß, dann aber alles vom Variablen Namen.

Wenn groß, dann aber alles vom Variablen Namen.
Review

Ignorier die Java Conventions, welche oben auch nicht eingehalten werden weshalb es so besser zu lesen ist!

Ignorier die Java Conventions, welche oben auch nicht eingehalten werden weshalb es so besser zu lesen ist!
//check parameter //check parameter
public static final int CheckSchemID; public static final int CheckSchemID;
@ -370,6 +371,7 @@ public class Config {
OnlyPublicSchematics = event.publicSchemsOnly(); OnlyPublicSchematics = event.publicSchemsOnly();
MaximumTeamMembers = event.getMaximumTeamMembers(); MaximumTeamMembers = event.getMaximumTeamMembers();
} }
SpectateSystem = event.spectateSystem();
}else{ }else{
//No event //No event
TeamRedName = config.getString("Output.TeamRedName"); TeamRedName = config.getString("Output.TeamRedName");
@ -379,6 +381,7 @@ public class Config {
EventTeamRedID = 0; EventTeamRedID = 0;
BothTeamsPublic = true; BothTeamsPublic = true;
MaximumTeamMembers = Integer.MAX_VALUE; MaximumTeamMembers = Integer.MAX_VALUE;
SpectateSystem = false;
} }
String blueLeader = System.getProperty("blueLeader", null); 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.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import java.util.EnumSet; 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)); 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 @EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) { public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();