public static void teleport(EntityPlayerMP player, WarpPoint point) {
    if (point.getWorld() == null) {
      DimensionManager.initDimension(point.getDimension());
      if (point.getWorld() == null) {
        ChatOutputHandler.chatError(
            player, Translator.translate("Unable to teleport! Target dimension does not exist"));
        return;
      }
    }

    // Check permissions
    UserIdent ident = UserIdent.get(player);
    if (!APIRegistry.perms.checkPermission(player, TELEPORT_FROM))
      throw new TranslatedCommandException("You are not allowed to teleport from here.");
    if (!APIRegistry.perms.checkUserPermission(ident, point.toWorldPoint(), TELEPORT_TO))
      throw new TranslatedCommandException("You are not allowed to teleport to that location.");
    if (player.dimension != point.getDimension()
        && !APIRegistry.perms.checkUserPermission(ident, point.toWorldPoint(), TELEPORT_CROSSDIM))
      throw new TranslatedCommandException("You are not allowed to teleport across dimensions.");

    // Get and check teleport cooldown
    int teleportCooldown =
        ServerUtil.parseIntDefault(
                APIRegistry.perms.getUserPermissionProperty(ident, TELEPORT_COOLDOWN), 0)
            * 1000;
    if (teleportCooldown > 0) {
      PlayerInfo pi = PlayerInfo.get(player);
      long cooldownDuration =
          (pi.getLastTeleportTime() + teleportCooldown) - System.currentTimeMillis();
      if (cooldownDuration >= 0) {
        ChatOutputHandler.chatNotification(
            player,
            Translator.format("Cooldown still active. %d seconds to go.", cooldownDuration / 1000));
        return;
      }
    }

    // Get and check teleport warmup
    int teleportWarmup =
        ServerUtil.parseIntDefault(
            APIRegistry.perms.getUserPermissionProperty(ident, TELEPORT_WARMUP), 0);
    if (teleportWarmup <= 0) {
      checkedTeleport(player, point);
      return;
    }

    if (!canTeleportTo(point)) {
      ChatOutputHandler.chatError(
          player, Translator.translate("Unable to teleport! Target location obstructed."));
      return;
    }

    // Setup timed teleport
    tpInfos.put(player.getPersistentID(), new TeleportInfo(player, point, teleportWarmup * 1000));
    ChatOutputHandler.chatNotification(
        player,
        Translator.format(
            "Teleporting. Please stand still for %s.",
            ChatOutputHandler.formatTimeDurationReadable(teleportWarmup, true)));
  }
Пример #2
0
 /** Gets the worldServer by the given dimension. */
 public WorldServer worldServerForDimension(int par1) {
   WorldServer ret = DimensionManager.getWorld(par1);
   if (ret == null) {
     DimensionManager.initDimension(par1);
     ret = DimensionManager.getWorld(par1);
   }
   return ret;
 }
Пример #3
0
  public WorldServer getWorld() {
    WorldServer world = DimensionManager.getWorld(dimension);

    if (world == null) {
      DimensionManager.initDimension(dimension);
      world = DimensionManager.getWorld(dimension);

      if (world == null) {
        return null; // How?
      }
    }

    return world;
  }
Пример #4
0
  public TileEntity getBlockTileEntity() {
    WorldServer world = getWorld();

    if (world == null) {
      DimensionManager.initDimension(dimension);
      world = DimensionManager.getWorld(dimension);

      if (world == null) {
        return null; // How?
      }
    }

    world.getChunkProvider().loadChunk(posX >> 4, posY >> 4);

    return world.getBlockTileEntity(posX, posY, posZ);
  }