Fail on death/disconnect
This commit is contained in:
parent
09f59f4975
commit
defb527073
2 changed files with 20 additions and 3 deletions
|
@ -5,8 +5,11 @@ import java.util.List;
|
|||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import gent.zeus.mc13dtl.MC13DTL;
|
||||
|
@ -41,6 +44,20 @@ public abstract class Event implements Listener {
|
|||
eventFinished();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||
if (getPlayers().contains(event.getPlayer())) {
|
||||
eventFailed();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDeath(PlayerQuitEvent event) {
|
||||
if (getPlayers().contains(event.getPlayer())) {
|
||||
eventFailed();
|
||||
}
|
||||
}
|
||||
|
||||
protected List<Player> getPlayers() {
|
||||
List<Player> players = new ArrayList<>();
|
||||
for (String entry : team.getEntries()) {
|
||||
|
|
|
@ -14,12 +14,12 @@ import gent.zeus.mc13dtl.MC13DTL;
|
|||
|
||||
public class GameStateHandler implements Listener {
|
||||
@EventHandler
|
||||
void onPlayerJoin(PlayerJoinEvent event) {
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
GameStateUtil.loadPlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onWorldLoad(WorldLoadEvent event) {
|
||||
public void onWorldLoad(WorldLoadEvent event) {
|
||||
World world = event.getWorld();
|
||||
if (!world.getName().equals("world")) {
|
||||
return;
|
||||
|
@ -28,7 +28,7 @@ public class GameStateHandler implements Listener {
|
|||
}
|
||||
|
||||
@EventHandler
|
||||
void onPlayerInteract(PlayerInteractEvent event) {
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
NamespacedKey key = new NamespacedKey(MC13DTL.instance, "game-state");
|
||||
String gameState = Bukkit.getWorld("world").getPersistentDataContainer().get(key, PersistentDataType.STRING);
|
||||
if (gameState.equals("lobby")) {
|
||||
|
|
Loading…
Reference in a new issue