Solved help please !

Discussion in 'Plugin Development' started by GalaxyPrisonMc, Jul 9, 2014.

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

    GalaxyPrisonMc

    Code:java
    1.  
    2. @EventHandler
    3. public void onPlayerJoinEvent(PlayerJoinEvent event) {
    4. final Player player = event.getPlayer();
    5. if(!player.hasPlayedBefore());
    6. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
    7. public void run() {
    8. openGUI(player);
    9. }
    10. }, 20L);
    11. }

    the gui is still opening even when the player has joined before, any suggestions ?
     
  2. Offline

    ko47374737

    Try this :)
    Code:
    @EventHandler
        public void onJoin(PlayerJoinEvent e)
        {
            ArrayList<UUID> hasJoined = new ArrayList<UUID>();
            Player p = e.getPlayer();
            if(!hasJoined.contains(p.getUniqueId()))
            {
                hasJoined.add(p.getUniqueId());
                Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
     
                                  public void run() {
     
                          openGUI(p);
     
                                  }
        }, 20L);   
     
     
            }
        }
     
  3. Offline

    Gater12

    GalaxyPrisonMc
    That if statement is useless with a semicolon after it.

    ko47374737
    That is pretty much dead code because a new ArrayList is created everytime the event is fired, thus the player wouldn't be in the List anyways.
     
  4. Offline

    GalaxyPrisonMc

    nope :(
     
  5. Offline

    ko47374737

    Gater12 Well then he should create it out of the event!
     
  6. Offline

    GalaxyPrisonMc

    Gater12 i don't know how i didn't notice that lol but thank for reminding me :)
     
Thread Status:
Not open for further replies.

Share This Page