Example #1
0
  public ZoneUserManager(Plugin plugin, ZoneConfig usersConfig) {
    this.usersConfigReference = usersConfig;
    this.usersConfigFilePath = usersConfig.getFile().getPath();
    this.plugin = plugin;
    if (plugin instanceof ZonePlugin) {
      this.isZonePlugin = true;
    } else {
      this.isZonePlugin = false;
    }

    loadUsers(usersConfig);

    if (preventOnlineUserGC) {
      for (Player player : Bukkit.getOnlinePlayers()) {
        holdUserFromGC(getUser(player));
      }
    }

    Bukkit.getPluginManager().registerEvents(this, plugin);

    Bukkit.getScheduler()
        .runTaskTimerAsynchronously(
            plugin,
            new Runnable() {
              @Override
              public void run() {
                getUsersConfig().schedualSave();
              }
            },
            saveInterval,
            saveInterval);
  }
Example #2
0
  public void loadUsers(ZoneConfig usersConfig) {
    if (isZonePlugin) {
      if (((ZonePlugin) plugin).inDebugMode()) {
        ((ZonePlugin) plugin).getLogger().log(Level.INFO, "Loading users...");
      }
    }
    Set<String> keys = usersConfig.getKeys(false);
    for (String userName : keys) {
      E user = loadUser(userName);
      this.addUserToUserList(user, false);
    }

    if (isZonePlugin) {
      if (((ZonePlugin) plugin).inDebugMode()) {
        ((ZonePlugin) plugin).getLogger().log(Level.INFO, "Loaded users");
      }
    }
  }