Will this cause lagg?

Discussion in 'Plugin Development' started by Gamesareme, Aug 26, 2014.

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

    Gamesareme

    So I have made a bit of code, but I think it may cause lagg. It works fine on my test server but I have no idea what would happen if it went onto my big one.
    So this is the code. Could someone tell me if this is the most efficient way of doing this?
    Code:
    @EventHandler
        public void onPlayerMoveEvent(PlayerMoveEvent event){
            Player player = event.getPlayer();
            FileConfiguration arena = plugin.getConfig("Arenas", "");
            for(String s: arena.getStringList("Arenas")){
                if(plugin.s.playerandarena.get(s) !=null && plugin.s.playerandarena.get(s).contains(player.getName())){
                            }
                    }
          }
    if there are a hundred+ players, it is in my opinion that this will cause bukkit loads of lagg.

    Really? No one knows?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
  2. Offline

    chasechocolate

    Yes, eventually. Cache the list.
     
  3. Offline

    Gamesareme

  4. Offline

    mine-care

    It will cause, if you've seen how many times move event fires, you will realize that opening a file and writing/reading to and from it for all those players is a pain in the backside. Change that somehow :/
     
  5. Most likely, yes, PlayerMoveEvent even fires when the player moves it's camera around.
     
  6. Offline

    fireblast709

    Gamesareme
    • does getConfig(String, String) load it fresh from file each time?
    • What type is the playerarena value?
     
Thread Status:
Not open for further replies.

Share This Page