Ejemplo n.º 1
0
  @Override
  public boolean updateQuitLoc(final PlayerAuth auth) {
    if (!cache.containsKey(auth.getNickname())) {
      return false;
    }
    final PlayerAuth cachedAuth = cache.get(auth.getNickname());
    final double oldX = cachedAuth.getQuitLocX();
    final double oldY = cachedAuth.getQuitLocY();
    final double oldZ = cachedAuth.getQuitLocZ();
    final String oldWorld = cachedAuth.getWorld();

    cachedAuth.setQuitLocX(auth.getQuitLocX());
    cachedAuth.setQuitLocY(auth.getQuitLocY());
    cachedAuth.setQuitLocZ(auth.getQuitLocZ());
    cachedAuth.setWorld(auth.getWorld());
    exec.execute(
        new Runnable() {
          @Override
          public void run() {
            if (!source.updateQuitLoc(auth)) {
              if (cache.containsKey(auth.getNickname())) {
                PlayerAuth cachedAuth = cache.get(auth.getNickname());
                cachedAuth.setQuitLocX(oldX);
                cachedAuth.setQuitLocY(oldY);
                cachedAuth.setQuitLocZ(oldZ);
                cachedAuth.setWorld(oldWorld);
              }
            }
          }
        });
    return true;
  }
Ejemplo n.º 2
0
  public void process() {
    preLogout();
    if (!canLogout) return;
    final Player p = player;
    BukkitScheduler sched = p.getServer().getScheduler();
    PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
    database.updateSession(auth);
    auth.setQuitLocX(p.getLocation().getX());
    auth.setQuitLocY(p.getLocation().getY());
    auth.setQuitLocZ(p.getLocation().getZ());
    auth.setWorld(p.getWorld().getName());
    database.updateQuitLoc(auth);

    PlayerCache.getInstance().removePlayer(name);
    database.setUnlogged(name);
    sched.scheduleSyncDelayedTask(
        plugin,
        new Runnable() {
          @Override
          public void run() {
            Utils.teleportToSpawn(p);
          }
        });
    if (LimboCache.getInstance().hasLimboPlayer(name))
      LimboCache.getInstance().deleteLimboPlayer(name);
    LimboCache.getInstance().addLimboPlayer(player);
    Utils.setGroup(player, GroupType.NOTLOGGEDIN);

    sched.scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerLogout(p, plugin));
  }
  public void process() {
    preLogout();
    if (!canLogout) return;
    final Player p = player;
    BukkitScheduler sched = p.getServer().getScheduler();
    PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
    database.updateSession(auth);
    auth.setQuitLocX(p.getLocation().getX());
    auth.setQuitLocY(p.getLocation().getY());
    auth.setQuitLocZ(p.getLocation().getZ());
    auth.setWorld(p.getWorld().getName());
    database.updateQuitLoc(auth);

    PlayerCache.getInstance().removePlayer(name);
    database.setUnlogged(name);
    if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
      Location spawnLoc = plugin.getSpawnLocation(p);
      final AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(p, spawnLoc);
      sched.scheduleSyncDelayedTask(
          plugin,
          new Runnable() {

            @Override
            public void run() {
              plugin.getServer().getPluginManager().callEvent(tpEvent);
              if (!tpEvent.isCancelled()) {
                if (tpEvent.getTo() != null) p.teleport(tpEvent.getTo());
              }
            }
          });
    }

    if (LimboCache.getInstance().hasLimboPlayer(name))
      LimboCache.getInstance().deleteLimboPlayer(name);
    LimboCache.getInstance().addLimboPlayer(player);
    utils.setGroup(player, GroupType.NOTLOGGEDIN);
    if (Settings.protectInventoryBeforeLogInEnabled) {
      player.getInventory().clear();
      // create cache file for handling lost of inventories on unlogged in
      // status
      DataFileCache playerData =
          new DataFileCache(
              LimboCache.getInstance().getLimboPlayer(name).getInventory(),
              LimboCache.getInstance().getLimboPlayer(name).getArmour());
      playerBackup.createCache(player, playerData);
    }
    sched.scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerLogout(p, plugin));
  }