Solved I hit a wall.

Discussion in 'Plugin Development' started by robotballs, Aug 29, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    robotballs

    I have been attempting to solve this problem for the past 30 minutes. I just can't figure out one simple part of code. I need to set the player to spectator mode and teleport them to the game if they join late. My variable for the game spawn is spawnLocation. The problem is with the second part.
    Code:
        @EventHandler
        public void onPlayerJoin(PlayerJoinEvent event) {
            Game.setCanStart(Bukkit.getOnlinePlayers().size() >= 2);
            if(!Game.hasStarted())
            LocationUtilities.teleportToLobby(event.getPlayer());
           
        }
       
        @EventHandler
        public void onPlayerJoin1(PlayerJoinEvent event) {
            if(Game.hasStarted())
                event.---> The Part I Can't Figure Out <---
           
        }
     
  2. Offline

    sailorerik

    You don't have to make new Listener for it.
    Just return and sendMessage that arena is started.
     
  3. Offline

    maxecito

    Hey! :)
    Please use names which say something about the Handler, for example call "onPlayerJoin1" "onPlayerLatejoin" or something like that...
    Code:
    e.getPlayer().setGameMode(GameMode.SPECTATOR);
    e.getPlayer().teleport(spawnLocation);
    
    Naturally, you need to put them out of Spectator Mode when leaving / game ends.
     
  4. Offline

    robotballs

    Alright, thanks I got it.
     
Thread Status:
Not open for further replies.

Share This Page