Runnable Help.

Discussion in 'Plugin Help/Development/Requests' started by Divinity Realms, Feb 19, 2015.

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

    Divinity Realms

    Im trying to make a timer method but im getting a random error when i try to get all the online players.. Heres my code:
    Code:
        public void timer() {
            Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
                @Override
                public void run() {
                    for (Player p : getServer().getOnlinePlayers()){
    
                    }
                }
            }, 2*20L);
        }
    And heres the error: http://imgur.com/qW0FsJ2
     
  2. Offline

    glory_fades

    try doing

    Code:
    public void timer() {
            Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
                @Override
                public void run() {
                    for (Player p : Bukkit.getOnlinePlayers()){
                    }
                }
            }, 2*20L);
        }
     
  3. Offline

    mine-care

    Prefer bukkit API in your build path, not craftbukkit... Unless you use nms
     
  4. Offline

    Divinity Realms

    Still nope... @glor_fades do you think its something to do with IntelliJ?
     
  5. Offline

    Justinian6

    @Divinity Realms ... If you took the time to google what ambiguous means ('cause I'm sure you don't know what it means). You would understand the issue. The problem is that there are multiple interpretation of the code you're using. You get the same error when you try getting player health. Now, assuming you ARE using the latest build, there is a large chance that @mine-care is right. Make sure you but the Bukkit API (The one not labeled CraftBukkit) At the top of the build list.
     
    mine-care likes this.
  6. Offline

    teej107

    But you should still include the Bukkit API in your build path though.
     
  7. Offline

    Justinian6

    @teej107 What??? I never said not too... I just said to prefer it over everything else in the Build Path.
     
  8. Offline

    teej107

    I wasn't quoting your post.
     
  9. Offline

    Divinity Realms

    @Justinian6 @teej107 Well.. I googled it. Thanks now I know the deffinition but how can I fix it lol
     
  10. Offline

    Justinian6

  11. Offline

    Divinity Realms

    @Justinian6 Its building to my desktop ive imported spigot_server and Spigot API im still new to intelliJ though but yeah
     
  12. Offline

    Justinian6

    @Divinity Realms That's not the build path... the build path is the API's you're building against...

    - Right Click the project then click Build Path
    - Make sure on that list the Spigot API is above the Spigot.jar
    - Save it

    That should fix it
     
  13. Offline

    Divinity Realms

    @Justinian6 lol as i said im in IntelliJ there isnt a build path its libraries and its above by default because it sorts it alphabetacaly
     
  14. Offline

    teej107

    If you aren't using NMS, remove CB/Spigot from the referenced libraries. Regardless of using NMS or not, always import the API
     
    Justinian6 likes this.
  15. Offline

    Divinity Realms

    @teej107 I have the apis you guys are just telling me to do stuff that I already know how to
     
  16. Offline

    teej107

    So what's the problem then? Are you using NMS?
     
  17. Offline

    Divinity Realms

    @teej107 no, look at the error. It seems like nothings wrong but IntelliJ begs to differ...
     
  18. Offline

    teej107

    @Divinity Realms
    Also what are in your referenced libraries?
     
  19. Offline

    Divinity Realms

    @teej107 Ive tried that but i dont know how to add potion effects...

    Code:
            if(cmd.getName().equalsIgnoreCase("spwnarcher")){
                Player p = (Player) sender;
                World w = Bukkit.getServer().getWorld("world");
                Location arch = new Location(w,-1.500,72,5.500,180,0);
                Entity archz = w.spawnCreature(arch, EntityType.ZOMBIE);
                archz.
            } A bit there -- I cant do archz.addPotionEffect
     
    Last edited by a moderator: Feb 20, 2015
  20. Offline

    teej107

  21. Moved to Bukkit Alternates
     
Thread Status:
Not open for further replies.

Share This Page