getConfig() server reload required?

Discussion in 'Plugin Development' started by maxwell71, Jun 9, 2019 at 5:02 AM.

  1. Offline

    maxwell71

    So, I made a plugin which gets a location out of config with this code:

    PHP:
    Location lobby = (LocationgetConfig().get("lobby");
    Then, I have a command which sets the location like this:

    PHP:
    if (cmd.getName().equalsIgnoreCase("setlobby")) {
    getConfig().set("lobby"p.getLocation());
    saveConfig();
    p.sendMessage("set lobby");
    And I have a PlayerJoinEvent right here:

    PHP:
    @EventHandler
    public void onJoin(PlayerJoinEvent e) {
    Player p e.getPlayer();
    p.teleport(lobby); 
    The Problem is that the player doesn't get teleported until I reloaded the server a second time. Why?
     
  2. Offline

    timtower Ninja on the waves Moderator

    @maxwell71 It doesn't auto update.
    But you can set the lobby variable again.
     
  3. Offline

    maxwell71

    So I would have to declare it a second time in the onJoin method?
     
  4. Offline

    timtower Ninja on the waves Moderator

    Initialize it a second time.
    Best thing to do in my opinion is having a method that loads it from the config and call that again.
     

Share This Page