Solved Best way to check players relation to players?

Discussion in 'Plugin Development' started by ilov3garfield, Nov 19, 2017.

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

    ilov3garfield

    Hello. I'm creating a plugin which needs to check every players relation to eachother. Let's say I need to check player1 money and if he has less than player2 then plugin sents particles to the player2 location. Currently I'm doing something like that:
    Code:
    for (Player player1 : Bukkit.getServer().getOnlinePlayers()){
        for (Player player2 : Bukkit.getServer().getOnlinePlayers()){
            if player1.hasMoreThan(player2.Balance()){
                spawn particles on player2 location
    repeat after 10ticks(scheduler)
    }}}
    and I wanted to ask is that the best way to do it? Isn't that going to use a lot of ram?
    Thanks.
     
  2. Online

    timtower Administrator Administrator Moderator

    ilov3garfield likes this.
  3. Offline

    MightyOne

    @ilov3garfield well iterating through some player will not take more than some milli seconds. But yeah the context would be more interesting. Why do you want ti do that?
     
    ilov3garfield likes this.
  4. Offline

    ilov3garfield

    If player is a member of a faction, then he will see a heart trail on his faction members and it's different for every player. I think it would use too much ram because in example if we have 100 players it will check 10,000 times every 10 ticks.
    How else should I do that?
     
  5. Online

    timtower Administrator Administrator Moderator

    @ilov3garfield The idea was not clear yet.
    You are confusing ram with CPU. This will take CPU, not ram, and see if it gives impact first, then you can improve it by spreading the load.
     
    ilov3garfield likes this.
  6. Offline

    ilov3garfield

    I'm sorry, I think I didn't understand you, I should check if the plugin impacts CPU? If so, I ran 4 minecraft clients, but that's only 4 players and it checks only 16 times every 10 ticks so it didn't impact it(pentium g2130). I hope you can understand my english and sorry if my questions are stupid or easy.
     
  7. Online

    timtower Administrator Administrator Moderator

    ilov3garfield likes this.
  8. Offline

    ilov3garfield

    Alright, thanks!:)
     
Thread Status:
Not open for further replies.

Share This Page