Cancel all interaction events before game started
This commit is contained in:
parent
bb4b47e84a
commit
2712ee60b3
1 changed files with 15 additions and 0 deletions
|
@ -1,10 +1,16 @@
|
|||
package gent.zeus.mc13dtl.gamestate;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import gent.zeus.mc13dtl.MC13DTL;
|
||||
|
||||
public class GameStateHandler implements Listener {
|
||||
@EventHandler
|
||||
|
@ -20,4 +26,13 @@ public class GameStateHandler implements Listener {
|
|||
}
|
||||
GameStateUtil.loadWorld(world);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
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")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue