public void e(OEntityPlayerMP var1) {
   //        this.n.a(var1); //CanaryMod refactored
   this.playerFileDataSet.get(var1.getPlayer().getDimension().getName()).a(var1);
   // CanaryMod refactored
   ((CanaryDimension) var1.getDimension()).getHandle().e(var1);
   this.b.remove(var1);
   var1.getDimension().getPlayerManager().removePlayer(var1.getPlayer());
   //        this.a(var1.w).b(var1);
   this.sendPacketToAll((new OPacket201PlayerInfo(var1.v, false, 9999)));
 }
  public void a(OEntityPlayerMP var1) {
    //        this.d[0].b(var1);
    //        this.d[1].b(var1);
    //        this.d[2].b(var1);
    for (World w : Canary.getServer().getWorldManager().getAllWorlds()) {
      for (Dimension dim : w.getDimensions()) {
        dim.getPlayerManager().removePlayer(var1.getPlayer());
      }
    }
    //        this.a(var1.w).a(var1); //remove again? rly?

    //        OWorldServer var2 = this.c.a(var1.w);
    var1.getDimension().getPlayerManager().addPlayer(var1.getPlayer());
    OWorldServer var2 = (OWorldServer) ((CanaryDimension) var1.getDimension()).getHandle();
    var2.G.c((int) var1.bm >> 4, (int) var1.bo >> 4);
  }
  public void c(OEntityPlayerMP var1) {
    this.sendPacketToAll((new OPacket201PlayerInfo(var1.v, true, 1000)));
    this.b.add(var1);
    OWorldServer var2 =
        (OWorldServer)
            ((CanaryDimension) var1.getDimension().getWorld().getDimension(Type.fromId(var1.w)))
                .getHandle();
    var1.bi = var2; // re-set world
    var2.G.c((int) var1.bm >> 4, (int) var1.bo >> 4);

    while (var2.a(var1, var1.bw).size() != 0) {
      var1.c(var1.bm, var1.bn + 1.0D, var1.bo);
    }

    var2.b(var1);
    // CanaryMod
    var1.getDimension().getPlayerManager().addPlayer(var1.getPlayer());
    this.u();

    for (int var3 = 0; var3 < this.b.size(); ++var3) {
      OEntityPlayerMP var4 = (OEntityPlayerMP) this.b.get(var3);
      var1.a.b((new OPacket201PlayerInfo(var4.v, true, var4.i)));
    }
    Canary.hooks().callHook(new LoginHook(var1.getPlayer()));
    var1.getPlayer().refreshCreativeMode();
  }
 public void f(OEntityPlayerMP var1) {
   var1.a(var1.l);
   var1.D_();
 }
  /**
   * Send player to another dimension. Was a(OEntityPlayerMP var1, int var2) before
   *
   * @param var1 Player
   * @param var2 Dimension ID
   * @param createPortal true if a portal needs to be created
   */
  public void switchDimension(OEntityPlayerMP var1, int var2, boolean createPortal) {
    int var3 = var1.w; // current dimension
    OWorldServer var4 = (OWorldServer) ((CanaryDimension) var1.getDimension()).getHandle();

    var1.w = var2; // set new dimension
    OWorldServer var5 =
        (OWorldServer)
            ((CanaryDimension)
                    this.c
                        .getWorldManager()
                        .getDimension(var1.bi.getCanaryDimension().getName(), var1.w))
                .getHandle();
    var1.a.b(
        (new OPacket9Respawn(
            var1.w, (byte) var1.bi.q, var5.s().getWorldType(), var5.y(), var1.c.a())));
    //        var4.f(var1);

    var1.bE = false;
    double var6 = var1.bm;
    double var8 = var1.bo;
    double var10 = 8.0D;
    if (var1.w == -1) {
      var6 /= var10;
      var8 /= var10;
      var1.c(var6, var1.bn, var8, var1.bs, var1.bt);
      if (var1.aE()) {
        var4.a(var1, false);
      }
    } else if (var1.w == 0) {
      var6 *= var10;
      var8 *= var10;
      var1.c(var6, var1.bn, var8, var1.bs, var1.bt);
      if (var1.aE()) {
        var4.a(var1, false);
      }
    } else {
      OChunkCoordinates var12 = var5.d();
      var6 = var12.a;
      var1.bn = var12.b;
      var8 = var12.c;
      var1.c(var6, var1.bn, var8, 90.0F, 0.0F);
      if (var1.aE()) {
        var4.a(var1, false);
      }
    }

    if (var3 != 1 && var1.aE()) {
      var5.b(var1);
      var1.c(var6, var1.bn, var8, var1.bs, var1.bt);
      var5.a(var1, false);
      // CanaryMod - don't create portal if we are not using a portal to teleport.
      if (createPortal) {
        var5.G.a = true;
        (new OTeleporter()).a(var5, var1);
        var5.G.a = false;
      }
    }

    this.a(var1);
    var1.a.a(
        var1.bm,
        var1.bn,
        var1.bo,
        var1.bs,
        var1.bt,
        var1.w,
        var1.bi.getCanaryDimension().getName());
    var1.a(var5);
    var1.c.a(var5);
    this.a(var1, var5);
    this.f(var1);
  }
  // Respawn player
  public OEntityPlayerMP a(OEntityPlayerMP var1, int var2, boolean var3, Location spawnLocation) {
    var1.getDimension().getEntityTracker().untrackPlayerSymmetrics(var1.getPlayer());
    var1.getDimension().getEntityTracker().untrackEntity(var1.getCanaryEntity());
    var1.getDimension().getPlayerManager().removePlayer(var1.getPlayer());
    this.b.remove(var1);
    var1.getDimension()
        .removePlayerFromWorld(var1.getPlayer()); // This calls the despawn method in world!

    OChunkCoordinates var4 = var1.ab();
    var1.w = var2; // Set new dimension
    CanaryWorld cworld = (CanaryWorld) var1.getDimension().getWorld();
    CanaryDimension dim = (CanaryDimension) cworld.getDimension(Type.fromId(var2));
    OEntityPlayerMP var5 =
        new OEntityPlayerMP(
            this.c, dim.getHandle(), var1.v, new OItemInWorldManager(dim.getHandle()));
    var5.w = var2;
    if (var3) {
      // copy player
      var5.c((OEntityPlayer) var1);
    }

    var5.bd = var1.bd;
    // Set NetServerHandler
    var5.a = var1.a;
    var5.setServerHandler(var5.a.getCanaryNetServerHandler());
    var5.a.setUser(var5.getPlayer());

    OWorldServer var6 = (OWorldServer) dim.getHandle();
    var5.c.a(var1.c.a());
    var5.c.b(var6.s().getGameMode());
    if (var4 != null) {
      OChunkCoordinates var7 =
          OEntityPlayer.a(((CanaryDimension) var1.getDimension()).getHandle(), var4);
      if (var7 != null) {
        var5.c((var7.a + 0.5F), (var7.b + 0.1F), (var7.c + 0.5F), 0.0F, 0.0F);
        var5.a(var4);
      } else {
        var5.a.b((new OPacket70Bed(0, 0)));
      }
    }

    // CanaryMod set player location and angle if a spawn location is defined
    if (spawnLocation != null) {
      var5.c(
          spawnLocation.getX(),
          spawnLocation.getY(),
          spawnLocation.getZ(),
          spawnLocation.getRotation(),
          spawnLocation.getPitch());
    }

    var6.G.c((int) var5.bm >> 4, (int) var5.bo >> 4);

    while (var6.a(var5, var5.bw).size()
        != 0) { // This is the checks for canSpawnHere  should we do something with this so players
      // don't end up on roofs?
      var5.c(var5.bm, var5.bn + 1.0D, var5.bo);
    }

    // respawn packet
    var5.a.b(
        (new OPacket9Respawn(
            var5.w, (byte) var5.bi.q, var5.bi.s().getWorldType(), var5.bi.y(), var5.c.a())));
    // teleport to spawn location
    var5.a.a(
        var5.bm,
        var5.bn,
        var5.bo,
        var5.bs,
        var5.bt,
        var5.w,
        var5.bi.getCanaryDimension().getName());
    // something
    this.a(var5, var6);
    var5.getDimension().getPlayerManager().addPlayer((Player) var5.getPlayer());
    var5.getDimension()
        .addPlayerToWorld(var5.getPlayer()); // This also calls the spawn method in world!
    this.b.add(var5);
    var5.x();
    var5.E();
    return var5;
  }
 public void d(OEntityPlayerMP var1) {
   // Canary
   var1.getDimension().getPlayerManager().updateMountedMovingPlayer(var1.getPlayer());
 }
 public void b(OEntityPlayerMP var1) {
   //      this.n.b(var1); //CanaryMod refactored
   this.playerFileDataSet.get(var1.getPlayer().getDimension().getName()).b(var1);
 }