Basic Java and Bukkit coding questions

Discussion in 'Spigot Help' started by salamander555, May 28, 2017.

  1. Hello,

    I'm new to plugin making and java. I do have experience in C# but I have a few questions about java.

    1) how does a Foreach or For code work in Java? (i think its just a "For" in java bc I can't find a thing about foreach)

    2) in plugin making is there a way to make a script do something every frame?

    3) how can I find all specific entitities with a specific name?

    4) how to do something with all players
     
    #1 salamander555, May 28, 2017
    Last edited: May 28, 2017
  2. Strahan

    Benefactor

    1. You can't find a thing about foreach? Do you not know about this handy tool called "Google"? lol Google "java foreach" and there are tons of informative results. If you could not find anything about foreach in Java, that doesn't bode well for your IT aptitude heh.

    2. What do you mean, every frame? As in every rendered frame on the client? No.

    3. I suppose you could loop through the World object .getEntities collection and check .getName on each, but that sounds like it would be quite a performance hit. There is .getNearbyEntities to help with cutting down the amount to loop, but still doesn't sound very efficient.

    4. this.getServer().getOnlinePlayers()
     
  3. The reason I got confused on the foreach loop is because you don't use 'foreach' itself but just 'For' in a 'Foreach' form
     
  4. Strahan

    Benefactor

    Yea, but still.. if you Google it, it's all explained :)
     
  5. Just type your problem into the search bar and you will find a result :) trust me