public void handleClientCommand(Packet205ClientCommand par1Packet205ClientCommand) {
    if (par1Packet205ClientCommand.forceRespawn == 1) {
      if (playerEntity.playerHasConqueredTheEnd) {
        playerEntity = mcServer.getConfigurationManager().respawnPlayer(playerEntity, 0, true);
      } else if (playerEntity.getServerForPlayer().getWorldInfo().isHardcoreModeEnabled()) {
        if (mcServer.isSinglePlayer() && playerEntity.username.equals(mcServer.getServerOwner())) {
          playerEntity.serverForThisPlayer.kickPlayerFromServer(
              "You have died. Game over, man, it's game over!");
          mcServer.deleteWorldAndStopServer();
        } else {
          BanEntry banentry = new BanEntry(playerEntity.username);
          banentry.setBanReason("Death in Hardcore");
          mcServer.getConfigurationManager().getBannedPlayers().put(banentry);
          playerEntity.serverForThisPlayer.kickPlayerFromServer(
              "You have died. Game over, man, it's game over!");
        }
      } else {
        if (playerEntity.getHealth() > 0) {
          return;
        }

        playerEntity = mcServer.getConfigurationManager().respawnPlayer(playerEntity, 0, false);
      }
    }
  }
  public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) {
    MinecraftServer var3 = MinecraftServer.getServer();
    par1ICommandSender.sendChatToPlayer(
        par1ICommandSender.translateString("commands.save.start", new Object[0]));

    if (var3.getConfigurationManager() != null) {
      var3.getConfigurationManager().saveAllPlayerData();
    }

    try {
      for (int var4 = 0; var4 < var3.worldServers.length; ++var4) {
        if (var3.worldServers[var4] != null) {
          WorldServer var5 = var3.worldServers[var4];
          boolean var6 = var5.levelSaving;
          var5.levelSaving = false;
          var5.saveAllChunks(true, (IProgressUpdate) null);
          var5.levelSaving = var6;
        }
      }
    } catch (MinecraftException var7) {
      notifyAdmins(par1ICommandSender, "commands.save.failed", new Object[] {var7.getMessage()});
      return;
    }

    notifyAdmins(par1ICommandSender, "commands.save.success", new Object[0]);
  }
  public void handleChat(Packet3Chat par1Packet3Chat) {
    ModLoader.serverChat(this, par1Packet3Chat.message);

    if (playerEntity.getChatVisibility() == 2) {
      sendPacketToPlayer(new Packet3Chat("Cannot send chat message."));
      return;
    }

    String s = par1Packet3Chat.message;

    if (s.length() > 100) {
      kickPlayerFromServer("Chat message too long");
      return;
    }

    s = s.trim();

    for (int i = 0; i < s.length(); i++) {
      if (!ChatAllowedCharacters.isAllowedCharacter(s.charAt(i))) {
        kickPlayerFromServer("Illegal characters in chat");
        return;
      }
    }

    if (s.startsWith("/")) {
      func_72566_d(s);
    } else {
      if (playerEntity.getChatVisibility() == 1) {
        sendPacketToPlayer(new Packet3Chat("Cannot send chat message."));
        return;
      }

      s =
          (new StringBuilder())
              .append("<")
              .append(playerEntity.username)
              .append("> ")
              .append(s)
              .toString();
      logger.info(s);
      mcServer.getConfigurationManager().sendPacketToAllPlayers(new Packet3Chat(s, false));
    }

    chatSpamThresholdCount += 20;

    if (chatSpamThresholdCount > 200
        && !mcServer.getConfigurationManager().areCommandsAllowed(playerEntity.username)) {
      kickPlayerFromServer("disconnect.spam");
    }
  }
예제 #4
0
  public static EntityPlayerMP getPlayerBaseServerFromPlayerUsername(
      String username, boolean ignoreCase) {
    MinecraftServer server = MinecraftServer.getServer();

    if (server != null) {
      if (ignoreCase) {
        return getPlayerForUsernameVanilla(server, username);
      } else {
        Iterator iterator = server.getConfigurationManager().playerEntityList.iterator();
        EntityPlayerMP entityplayermp;

        do {
          if (!iterator.hasNext()) {
            return null;
          }

          entityplayermp = (EntityPlayerMP) iterator.next();
        } while (!entityplayermp.getName().equalsIgnoreCase(username));

        return entityplayermp;
      }
    }

    GCLog.severe("Warning: Could not find player base server instance for player " + username);

    return null;
  }
예제 #5
0
  public EntityPlayerMP(
      MinecraftServer par1MinecraftServer,
      World par2World,
      String par3Str,
      ItemInWorldManager par4ItemInWorldManager) {
    super(par2World, par3Str);
    par4ItemInWorldManager.thisPlayerMP = this;
    this.theItemInWorldManager = par4ItemInWorldManager;
    this.renderDistance = par1MinecraftServer.getConfigurationManager().getViewDistance();
    ChunkCoordinates var5 = par2World.getSpawnPoint();
    int var6 = var5.posX;
    int var7 = var5.posZ;
    int var8 = var5.posY;

    if (!par2World.provider.hasNoSky
        && par2World.getWorldInfo().getGameType() != EnumGameType.ADVENTURE) {
      int var9 = Math.max(5, par1MinecraftServer.getSpawnProtectionSize() - 6);
      var6 += this.rand.nextInt(var9 * 2) - var9;
      var7 += this.rand.nextInt(var9 * 2) - var9;
      var8 = par2World.getTopSolidOrLiquidBlock(var6, var7);
    }

    this.mcServer = par1MinecraftServer;
    this.stepHeight = 0.0F;
    this.yOffset = 0.0F;
    this.setLocationAndAngles(
        (double) var6 + 0.5D, (double) var8, (double) var7 + 0.5D, 0.0F, 0.0F);

    while (!par2World.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty()) {
      this.setPosition(this.posX, this.posY + 1.0D, this.posZ);
    }
  }
예제 #6
0
	@Override
	public Player[] getOnlinePlayers() {
		List<Player> players= new ArrayList<Player>();
		for (Object i : theServer.getConfigurationManager().playerEntityList) {
			players.add(BukkitPlayerCache.getBukkitPlayer((EntityPlayerMP) i));
		}
		return players.toArray(new Player[0]);
	}
예제 #7
0
  @SuppressWarnings("unchecked")
  public void sendUpdates(MinecraftServer server) {
    if (mapsToUpdate.isEmpty()) return;

    MapUpdatesEvent evt = new MapUpdatesEvent();
    evt.mapIds.addAll(mapsToUpdate);
    mapsToUpdate.clear();

    evt.sendToPlayers(server.getConfigurationManager().playerEntityList);
  }
 private void func_72566_d(String par1Str) {
   if (mcServer.getConfigurationManager().areCommandsAllowed(playerEntity.username)
       || "/seed".equals(par1Str)) {
     logger.info(
         (new StringBuilder())
             .append(playerEntity.username)
             .append(" issued server command: ")
             .append(par1Str)
             .toString());
     mcServer.getCommandManager().executeCommand(playerEntity, par1Str);
   }
 }
 public PacketPlayerRaces applyPlayers() {
   MinecraftServer server = MinecraftServer.getServer();
   playerNames = server.getAllUsernames();
   races = new int[playerNames.length];
   for (int i = 0; i < races.length; i++) {
     races[i] =
         Util.getIntegerStat(
             server.getConfigurationManager().getPlayerForUsername(playerNames[i]),
             Reference.RACE);
   }
   return this;
 }
예제 #10
0
 public void kickPlayerFromServer(String par1Str) {
   if (serverShuttingDown) {
     return;
   } else {
     playerEntity.mountEntityAndWakeUp();
     sendPacketToPlayer(new Packet255KickDisconnect(par1Str));
     theNetworkManager.serverShutdown();
     mcServer
         .getConfigurationManager()
         .sendPacketToAllPlayers(
             new Packet3Chat(
                 (new StringBuilder())
                     .append("\247e")
                     .append(playerEntity.username)
                     .append(" left the game.")
                     .toString()));
     mcServer.getConfigurationManager().func_72367_e(playerEntity);
     serverShuttingDown = true;
     return;
   }
 }
예제 #11
0
  /** Teleports the entity to another dimension. Params: Dimension number to teleport to */
  public static void travelEntityToDimension(Entity entity, int dimensionId, int x, int y, int z) {
    if (!entity.worldObj.isRemote && !entity.isDead) {
      entity.worldObj.theProfiler.startSection("changeDimension");
      MinecraftServer minecraftserver = MinecraftServer.getServer();
      int j = entity.dimension;
      WorldServer worldserver = minecraftserver.worldServerForDimension(j);
      WorldServer worldserver1 = minecraftserver.worldServerForDimension(dimensionId);
      entity.dimension = dimensionId;

      if (j == 1 && dimensionId == 1) {
        worldserver1 = minecraftserver.worldServerForDimension(0);
        entity.dimension = 0;
      }

      entity.worldObj.removeEntity(entity);
      entity.isDead = false;
      entity.worldObj.theProfiler.startSection("reposition");
      minecraftserver
          .getConfigurationManager()
          .transferEntityToWorld(entity, j, worldserver, worldserver1);
      entity.worldObj.theProfiler.endStartSection("reloading");
      Entity newEntity =
          EntityList.createEntityByName(EntityList.getEntityString(entity), worldserver1);

      if (newEntity != null) {
        newEntity.copyDataFrom(entity, true);

        if (j == 1 && dimensionId == 1) {
          ChunkCoordinates chunkcoordinates = worldserver1.getSpawnPoint();
          chunkcoordinates.posY =
              entity.worldObj.getTopSolidOrLiquidBlock(
                  chunkcoordinates.posX, chunkcoordinates.posZ);
          newEntity.setLocationAndAngles(
              (double) chunkcoordinates.posX,
              (double) chunkcoordinates.posY,
              (double) chunkcoordinates.posZ,
              newEntity.rotationYaw,
              newEntity.rotationPitch);
        }

        worldserver1.spawnEntityInWorld(newEntity);
        newEntity.setPosition(x + 0.5D, y, z + 0.5D);
      }

      entity.isDead = true;
      entity.worldObj.theProfiler.endSection();
      worldserver.resetUpdateEntityTick();
      worldserver1.resetUpdateEntityTick();
      entity.worldObj.theProfiler.endSection();
    }
  }
  /**
   * OP detection
   *
   * @param player
   * @return
   */
  public static boolean isPlayerOp(String player) {
    if (FMLCommonHandler.instance().getEffectiveSide().isClient()) return true;

    MinecraftServer server = FMLCommonHandler.instance().getSidedDelegate().getServer();

    // SP and LAN
    if (server.isSinglePlayer()) {
      if (server instanceof IntegratedServer && server.getServerOwner().equalsIgnoreCase(player))
        return true;
    }

    // SMP
    return server.getConfigurationManager().getOps().contains(player);
  }
예제 #13
0
  public void handleErrorMessage(String par1Str, Object par2ArrayOfObj[]) {
    logger.info(
        (new StringBuilder())
            .append(playerEntity.username)
            .append(" lost connection: ")
            .append(par1Str)
            .toString());
    mcServer
        .getConfigurationManager()
        .sendPacketToAllPlayers(
            new Packet3Chat(
                (new StringBuilder())
                    .append("\247e")
                    .append(playerEntity.username)
                    .append(" left the game.")
                    .toString()));
    mcServer.getConfigurationManager().func_72367_e(playerEntity);
    serverShuttingDown = true;

    if (mcServer.isSinglePlayer() && playerEntity.username.equals(mcServer.getServerOwner())) {
      logger.info("Stopping singleplayer server as player logged out");
      mcServer.setServerStopping();
    }
  }
예제 #14
0
 public static void travelToDimension(Entity entity, int dimensionId, int x, int y, int z) {
   if (!entity.worldObj.isRemote && !entity.isDead) {
     MinecraftServer minecraftserver = MinecraftServer.getServer();
     WorldServer newWorldServer = minecraftserver.worldServerForDimension(dimensionId);
     if (entity instanceof EntityPlayerMP) {
       minecraftserver
           .getConfigurationManager()
           .transferPlayerToDimension(
               (EntityPlayerMP) entity, dimensionId, new CustomTeleporter(newWorldServer));
       ((EntityPlayerMP) entity).setPositionAndUpdate(x + 0.5, y, z + 0.5);
     } else {
       travelEntityToDimension(entity, dimensionId, x, y, z);
     }
   }
 }
예제 #15
0
  public WorldServer(
      MinecraftServer par1MinecraftServer,
      ISaveHandler par2ISaveHandler,
      String par3Str,
      int par4,
      WorldSettings par5WorldSettings,
      Profiler par6Profiler,
      ILogAgent par7ILogAgent) {
    super(
        par2ISaveHandler,
        par3Str,
        par5WorldSettings,
        WorldProvider.getProviderForDimension(par4),
        par6Profiler,
        par7ILogAgent);
    this.mcServer = par1MinecraftServer;
    this.theEntityTracker = new EntityTracker(this);
    this.thePlayerManager =
        new PlayerManager(this, par1MinecraftServer.getConfigurationManager().getViewDistance());

    if (this.entityIdMap == null) {
      this.entityIdMap = new IntHashMap();
    }

    if (this.pendingTickListEntriesHashSet == null) {
      this.pendingTickListEntriesHashSet = new HashSet();
    }

    if (this.pendingTickListEntriesTreeSet == null) {
      this.pendingTickListEntriesTreeSet = new TreeSet();
    }

    this.field_85177_Q = new Teleporter(this);
    this.worldScoreboard = new ServerScoreboard(par1MinecraftServer);
    ScoreboardSaveData var8 =
        (ScoreboardSaveData) this.mapStorage.loadData(ScoreboardSaveData.class, "scoreboard");

    if (var8 == null) {
      var8 = new ScoreboardSaveData();
      this.mapStorage.setData("scoreboard", var8);
    }

    var8.func_96499_a(this.worldScoreboard);
    ((ServerScoreboard) this.worldScoreboard).func_96547_a(var8);
  }
예제 #16
0
  @Override
  public void processCommand(ICommandSender sender, String[] par2ArrayOfStr) {
    MinecraftServer server = ModLoader.getMinecraftServerInstance();
    EntityPlayer player = getCommandSenderAsPlayer(sender);
    EntityPlayerMP playerMP = (EntityPlayerMP) sender;
    String ho = "";

    if (par2ArrayOfStr.length == 0) {
      ho = "[Default]";
    } else {
      ho = par2ArrayOfStr[0];
    }

    setBackLocation(player);

    NBTTagCompound playerdata =
        NecessitiesMain.instance.necessities_data.getCompoundTag(player.username);
    NecessitiesMain.instance.necessities_data.setCompoundTag(player.username, playerdata);
    NBTTagCompound homes = playerdata.getCompoundTag("Homes");
    playerdata.setCompoundTag("Homes", homes);

    // Go to the specified home
    if (!homes.hasKey(ho)) {
      sender.sendChatToPlayer("Unknown home.");
      return;
    }

    NBTTagCompound h = homes.getCompoundTag(ho);
    double posX = h.getDouble("PosX");
    double posY = h.getDouble("PosY");
    double posZ = h.getDouble("PosZ");
    float yaw = h.getFloat("Yaw");
    float pitch = h.getFloat("Pitch");
    int dim = h.getInteger("Dim");

    if (player.dimension != dim)
      server.getConfigurationManager().transferPlayerToDimension(((EntityPlayerMP) player), dim);

    playerMP.playerNetServerHandler.setPlayerLocation(posX, posY, posZ, yaw, pitch);
  } // public voice processCommand(...)
  void initTicket() {
    if (Platform.isClient()) {
      return;
    }

    this.ct = ForgeChunkManager.requestTicket(AppEng.instance(), this.worldObj, Type.NORMAL);

    if (this.ct == null) {
      MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
      if (server != null) {
        List<EntityPlayerMP> pl = server.getConfigurationManager().playerEntityList;
        for (EntityPlayerMP p : pl) {
          p.addChatMessage(new ChatComponentText("Can't chunk load.."));
        }
      }
      return;
    }

    AELog.info("New Ticket " + this.ct.toString());
    ForgeChunkManager.forceChunk(
        this.ct, new ChunkCoordIntPair(this.xCoord >> 4, this.zCoord >> 4));
  }
  public EntityPlayerMP(
      MinecraftServer p_i45285_1_,
      WorldServer p_i45285_2_,
      GameProfile p_i45285_3_,
      ItemInWorldManager p_i45285_4_) {
    super(p_i45285_2_, p_i45285_3_);
    p_i45285_4_.thisPlayerMP = this;
    this.theItemInWorldManager = p_i45285_4_;
    ChunkCoordinates chunkcoordinates = p_i45285_2_.provider.getRandomizedSpawnPoint();
    int i = chunkcoordinates.posX;
    int j = chunkcoordinates.posZ;
    int k = chunkcoordinates.posY;

    this.mcServer = p_i45285_1_;
    this.field_147103_bO = p_i45285_1_.getConfigurationManager().getPlayerStatsFile(this);
    this.stepHeight = 0.0F;
    this.yOffset = 0.0F;
    this.setLocationAndAngles((double) i + 0.5D, (double) k, (double) j + 0.5D, 0.0F, 0.0F);

    while (!p_i45285_2_.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty()) {
      this.setPosition(this.posX, this.posY + 1.0D, this.posZ);
    }
  }
예제 #19
0
 @Override
 public void onPlayerRespawn(EntityPlayer player) {
   MinecraftServer server = ModLoader.getMinecraftServerInstance();
   ChunkCoordinates var4 = ((EntityPlayerMP) player).getSpawnChunk();
   if (var4 == null) {
     if (Permissions.rankData.getCompoundTag(Permissions.getRank(player)).hasKey("Spawn")) {
       NBTTagCompound data =
           Permissions.rankData
               .getCompoundTag(Permissions.getRank(player))
               .getCompoundTag("Spawn");
       Double X = data.getDouble("X");
       Double Y = data.getDouble("Y");
       Double Z = data.getDouble("Z");
       Float yaw = data.getFloat("yaw");
       Float pitch = data.getFloat("pitch");
       Integer dim = data.getInteger("Dim");
       if (player.dimension != dim)
         server
             .getConfigurationManager()
             .transferPlayerToDimension(((EntityPlayerMP) player), dim);
       ((EntityPlayerMP) player).playerNetServerHandler.setPlayerLocation(X, Y, Z, yaw, pitch);
       player.sendChatToPlayer("Welcome to " + data.getString("name"));
     } else if (SimpleModsConfiguration.spawnOverride) {
       ChunkCoordinates coords = player.worldObj.getSpawnPoint();
       player.setPosition(coords.posX, coords.posY, coords.posZ);
       while (!server
           .worldServerForDimension(player.dimension)
           .getCollidingBoundingBoxes(player, player.boundingBox)
           .isEmpty()) {
         player.setPosition(player.posX, player.posY + 0.5D, player.posZ);
       }
       ((EntityPlayerMP) player)
           .playerNetServerHandler.setPlayerLocation(coords.posX, coords.posY, coords.posZ, 0, 0);
     }
   }
 }
예제 #20
0
  @SideOnly(Side.CLIENT)
  @Override
  public void handleClientSide(EntityPlayer player) {
    GCEntityClientPlayerMP playerBaseClient = null;

    if (player instanceof GCEntityClientPlayerMP) {
      playerBaseClient = (GCEntityClientPlayerMP) player;
    } else {
      return;
    }

    switch (this.type) {
      case C_AIR_REMAINING:
        if (String.valueOf(this.data.get(2))
            .equals(
                String.valueOf(
                    FMLClientHandler.instance()
                        .getClient()
                        .thePlayer
                        .getGameProfile()
                        .getName()))) {
          TickHandlerClient.airRemaining = (Integer) this.data.get(0);
          TickHandlerClient.airRemaining2 = (Integer) this.data.get(1);
        }
        break;
      case C_UPDATE_DIMENSION_LIST:
        if (String.valueOf(this.data.get(0))
            .equals(FMLClientHandler.instance().getClient().thePlayer.getGameProfile().getName())) {
          final String[] destinations = ((String) this.data.get(1)).split("\\.");

          if (FMLClientHandler.instance().getClient().theWorld != null
              && !(FMLClientHandler.instance().getClient().currentScreen
                      instanceof GuiCelestialSelection
                  || FMLClientHandler.instance().getClient().currentScreen
                      instanceof GuiGalaxyMap)) {
            FMLClientHandler.instance().getClient().displayGuiScreen(new GuiCelestialSelection());
          }
        }
        break;
      case C_SPAWN_SPARK_PARTICLES:
        int x, y, z;
        x = (Integer) this.data.get(0);
        y = (Integer) this.data.get(1);
        z = (Integer) this.data.get(2);
        Minecraft mc = Minecraft.getMinecraft();

        for (int i = 0; i < 4; i++) {
          if (mc != null
              && mc.renderViewEntity != null
              && mc.effectRenderer != null
              && mc.theWorld != null) {
            final EntityFX fx =
                new EntityFXSparks(
                    mc.theWorld,
                    x - 0.15 + 0.5,
                    y + 1.2,
                    z + 0.15 + 0.5,
                    mc.theWorld.rand.nextDouble() / 20 - mc.theWorld.rand.nextDouble() / 20,
                    mc.theWorld.rand.nextDouble() / 20 - mc.theWorld.rand.nextDouble() / 20);

            if (fx != null) {
              mc.effectRenderer.addEffect(fx);
            }
          }
        }
        break;
      case C_UPDATE_GEAR_SLOT:
        int subtype = (Integer) this.data.get(2);
        EntityPlayer gearDataPlayer = null;
        MinecraftServer server = MinecraftServer.getServer();

        if (server != null) {
          gearDataPlayer =
              server.getConfigurationManager().getPlayerForUsername((String) this.data.get(0));
        } else {
          gearDataPlayer = player.worldObj.getPlayerEntityByName((String) this.data.get(0));
        }

        if (gearDataPlayer != null) {
          PlayerGearData gearData =
              ClientProxyCore.playerItemData.get(gearDataPlayer.getPersistentID());

          if (gearData == null) {
            gearData = new PlayerGearData(player);
          }

          EnumModelPacket type = EnumModelPacket.values()[(Integer) this.data.get(1)];

          switch (type) {
            case ADDMASK:
              gearData.setMask(0);
              break;
            case REMOVEMASK:
              gearData.setMask(-1);
              break;
            case ADDGEAR:
              gearData.setGear(0);
              break;
            case REMOVEGEAR:
              gearData.setGear(-1);
              break;
            case ADDLEFTGREENTANK:
              gearData.setLeftTank(0);
              break;
            case ADDLEFTORANGETANK:
              gearData.setLeftTank(1);
              break;
            case ADDLEFTREDTANK:
              gearData.setLeftTank(2);
              break;
            case ADDRIGHTGREENTANK:
              gearData.setRightTank(0);
              break;
            case ADDRIGHTORANGETANK:
              gearData.setRightTank(1);
              break;
            case ADDRIGHTREDTANK:
              gearData.setRightTank(2);
              break;
            case REMOVE_LEFT_TANK:
              gearData.setLeftTank(-1);
              break;
            case REMOVE_RIGHT_TANK:
              gearData.setRightTank(-1);
              break;
            case ADD_PARACHUTE:
              String name = "";

              if (subtype != -1) {
                name = ItemParaChute.names[subtype];
                gearData.setParachute(
                    new ResourceLocation(
                        GalacticraftCore.ASSET_DOMAIN,
                        "textures/model/parachute/" + name + ".png"));
              }
              break;
            case REMOVE_PARACHUTE:
              gearData.setParachute(null);
              break;
            case ADD_FREQUENCY_MODULE:
              gearData.setFrequencyModule(0);
              break;
            case REMOVE_FREQUENCY_MODULE:
              gearData.setFrequencyModule(-1);
              break;
            case ADD_THERMAL_HELMET:
              gearData.setThermalPadding(0, 0);
              break;
            case ADD_THERMAL_CHESTPLATE:
              gearData.setThermalPadding(1, 0);
              break;
            case ADD_THERMAL_LEGGINGS:
              gearData.setThermalPadding(2, 0);
              break;
            case ADD_THERMAL_BOOTS:
              gearData.setThermalPadding(3, 0);
              break;
            case REMOVE_THERMAL_HELMET:
              gearData.setThermalPadding(0, -1);
              break;
            case REMOVE_THERMAL_CHESTPLATE:
              gearData.setThermalPadding(1, -1);
              break;
            case REMOVE_THERMAL_LEGGINGS:
              gearData.setThermalPadding(2, -1);
              break;
            case REMOVE_THERMAL_BOOTS:
              gearData.setThermalPadding(3, -1);
              break;
            default:
              break;
          }

          ClientProxyCore.playerItemData.put(playerBaseClient.getPersistentID(), gearData);
        }

        break;
      case C_CLOSE_GUI:
        FMLClientHandler.instance().getClient().displayGuiScreen(null);
        break;
      case C_RESET_THIRD_PERSON:
        FMLClientHandler.instance().getClient().gameSettings.thirdPersonView =
            playerBaseClient.getThirdPersonView();
        break;
      case C_UPDATE_SPACESTATION_LIST:
        try {
          if (WorldUtil.registeredSpaceStations != null) {
            for (Integer registeredID : WorldUtil.registeredSpaceStations) {
              DimensionManager.unregisterDimension(registeredID);
            }
          }
          WorldUtil.registeredSpaceStations = new ArrayList<Integer>();

          if (this.data.size() > 0) {
            if (this.data.get(0) instanceof Integer) {
              for (Object o : this.data) {
                Integer dimID = (Integer) o;

                if (!WorldUtil.registeredSpaceStations.contains(dimID)) {
                  WorldUtil.registeredSpaceStations.add(dimID);
                  if (!DimensionManager.isDimensionRegistered(dimID)) {
                    DimensionManager.registerDimension(
                        dimID, ConfigManagerCore.idDimensionOverworldOrbit);
                  } else {
                    GCLog.severe(
                        "Dimension already registered on client: unable to register space station dimension "
                            + dimID);
                  }
                }
              }
            } else if (this.data.get(0) instanceof Integer[]) {
              for (Object o : (Integer[]) this.data.get(0)) {
                Integer dimID = (Integer) o;

                if (!WorldUtil.registeredSpaceStations.contains(dimID)) {
                  WorldUtil.registeredSpaceStations.add(dimID);
                  if (!DimensionManager.isDimensionRegistered(dimID)) {
                    DimensionManager.registerDimension(
                        dimID, ConfigManagerCore.idDimensionOverworldOrbit);
                  } else {
                    GCLog.severe(
                        "Dimension already registered on client: unable to register space station dimension "
                            + dimID);
                  }
                }
              }
            }
          }
          break;
        } catch (final Exception e) {
          e.printStackTrace();
        }
      case C_UPDATE_SPACESTATION_DATA:
        SpaceStationWorldData var4 =
            SpaceStationWorldData.getMPSpaceStationData(
                player.worldObj, (Integer) this.data.get(0), player);
        var4.readFromNBT((NBTTagCompound) this.data.get(1));
        break;
      case C_UPDATE_SPACESTATION_CLIENT_ID:
        ClientProxyCore.clientSpaceStationID = (Integer) this.data.get(0);
        break;
      case C_UPDATE_PLANETS_LIST:
        try {
          if (WorldUtil.registeredPlanets != null) {
            for (Integer registeredID : WorldUtil.registeredPlanets) {
              DimensionManager.unregisterDimension(registeredID);
            }
          }
          WorldUtil.registeredPlanets = new ArrayList<Integer>();

          if (this.data.size() > 0) {
            if (this.data.get(0) instanceof Integer) {
              for (Object o : this.data) {
                Integer dimID = (Integer) o;

                if (!WorldUtil.registeredPlanets.contains(dimID)) {
                  WorldUtil.registeredPlanets.add(dimID);
                  DimensionManager.registerDimension(dimID, dimID);
                }
              }
            } else if (this.data.get(0) instanceof Integer[]) {
              for (Object o : (Integer[]) this.data.get(0)) {
                Integer dimID = (Integer) o;

                if (!WorldUtil.registeredPlanets.contains(dimID)) {
                  WorldUtil.registeredPlanets.add(dimID);
                  DimensionManager.registerDimension(dimID, dimID);
                }
              }
            }
          }
          break;
        } catch (final Exception e) {
          e.printStackTrace();
        }
      case C_ADD_NEW_SCHEMATIC:
        final ISchematicPage page =
            SchematicRegistry.getMatchingRecipeForID((Integer) this.data.get(0));
        if (!playerBaseClient.unlockedSchematics.contains(page)) {
          playerBaseClient.unlockedSchematics.add(page);
        }
        break;
      case C_UPDATE_SCHEMATIC_LIST:
        for (Object o : this.data) {
          Integer schematicID = (Integer) o;

          if (schematicID != -2) {
            Collections.sort(playerBaseClient.unlockedSchematics);

            if (!playerBaseClient.unlockedSchematics.contains(
                SchematicRegistry.getMatchingRecipeForID(Integer.valueOf(schematicID)))) {
              playerBaseClient.unlockedSchematics.add(
                  SchematicRegistry.getMatchingRecipeForID(Integer.valueOf(schematicID)));
            }
          }
        }
        break;
      case C_PLAY_SOUND_BOSS_DEATH:
        player.playSound(GalacticraftCore.ASSET_PREFIX + "entity.bossdeath", 10.0F, 0.8F);
        break;
      case C_PLAY_SOUND_EXPLODE:
        player.playSound("random.explode", 10.0F, 0.7F);
        break;
      case C_PLAY_SOUND_BOSS_LAUGH:
        player.playSound(GalacticraftCore.ASSET_PREFIX + "entity.bosslaugh", 10.0F, 0.2F);
        break;
      case C_PLAY_SOUND_BOW:
        player.playSound("random.bow", 10.0F, 0.2F);
        break;
      case C_UPDATE_OXYGEN_VALIDITY:
        playerBaseClient.oxygenSetupValid = (Boolean) this.data.get(0);
        break;
      case C_OPEN_PARACHEST_GUI:
        switch ((Integer) this.data.get(1)) {
          case 0:
            if (player.ridingEntity instanceof EntityBuggy) {
              FMLClientHandler.instance()
                  .getClient()
                  .displayGuiScreen(
                      new GuiBuggy(
                          player.inventory,
                          (EntityBuggy) player.ridingEntity,
                          ((EntityBuggy) player.ridingEntity).getType()));
              player.openContainer.windowId = (Integer) this.data.get(0);
            }
            break;
          case 1:
            int entityID = (Integer) this.data.get(2);
            Entity entity = player.worldObj.getEntityByID(entityID);

            if (entity != null && entity instanceof IInventorySettable) {
              FMLClientHandler.instance()
                  .getClient()
                  .displayGuiScreen(
                      new GuiParaChest(player.inventory, (IInventorySettable) entity));
            }

            player.openContainer.windowId = (Integer) this.data.get(0);
            break;
        }
        break;
      case C_UPDATE_WIRE_BOUNDS:
        TileEntity tile =
            player.worldObj.getTileEntity(
                (Integer) this.data.get(0), (Integer) this.data.get(1), (Integer) this.data.get(2));

        if (tile instanceof TileEntityConductor) {
          ((TileEntityConductor) tile).adjacentConnections = null;
          player
              .worldObj
              .getBlock(tile.xCoord, tile.yCoord, tile.zCoord)
              .setBlockBoundsBasedOnState(player.worldObj, tile.xCoord, tile.yCoord, tile.zCoord);
        }
        break;
      case C_OPEN_SPACE_RACE_GUI:
        if (Minecraft.getMinecraft().currentScreen == null) {
          TickHandlerClient.spaceRaceGuiScheduled = false;
          player.openGui(
              GalacticraftCore.instance,
              GuiIdsCore.SPACE_RACE_START,
              player.worldObj,
              (int) player.posX,
              (int) player.posY,
              (int) player.posZ);
        } else {
          TickHandlerClient.spaceRaceGuiScheduled = true;
        }
        break;
      case C_UPDATE_SPACE_RACE_DATA:
        Integer teamID = (Integer) this.data.get(0);
        String teamName = (String) this.data.get(1);
        FlagData flagData = (FlagData) this.data.get(2);
        Vector3 teamColor = (Vector3) this.data.get(3);
        List<String> playerList = new ArrayList<String>();

        for (int i = 4; i < this.data.size(); i++) {
          String playerName = (String) this.data.get(i);
          ClientProxyCore.flagRequestsSent.remove(playerName);
          playerList.add(playerName);
        }

        SpaceRace race = new SpaceRace(playerList, teamName, flagData, teamColor);
        race.setSpaceRaceID(teamID);
        SpaceRaceManager.addSpaceRace(race);
        break;
      case C_OPEN_JOIN_RACE_GUI:
        playerBaseClient.spaceRaceInviteTeamID = (Integer) this.data.get(0);
        player.openGui(
            GalacticraftCore.instance,
            GuiIdsCore.SPACE_RACE_JOIN,
            player.worldObj,
            (int) player.posX,
            (int) player.posY,
            (int) player.posZ);
        break;
      case C_UPDATE_FOOTPRINT_LIST:
        ClientProxyCore.footprintRenderer.footprints.clear();
        for (int i = 0; i < this.data.size(); i++) {
          Footprint print = (Footprint) this.data.get(i);
          ClientProxyCore.footprintRenderer.addFootprint(print);
        }
        break;
      case C_UPDATE_STATION_SPIN:
        if (playerBaseClient.worldObj.provider instanceof WorldProviderOrbit) {
          ((WorldProviderOrbit) playerBaseClient.worldObj.provider)
              .setSpinRate((Float) this.data.get(0), (Boolean) this.data.get(1));
        }
        break;
      case C_UPDATE_STATION_DATA:
        if (playerBaseClient.worldObj.provider instanceof WorldProviderOrbit) {
          ((WorldProviderOrbit) playerBaseClient.worldObj.provider)
              .setSpinCentre((Double) this.data.get(0), (Double) this.data.get(1));
        }
        break;
      case C_UPDATE_STATION_BOX:
        if (playerBaseClient.worldObj.provider instanceof WorldProviderOrbit) {
          ((WorldProviderOrbit) playerBaseClient.worldObj.provider)
              .setSpinBox(
                  (Integer) this.data.get(0),
                  (Integer) this.data.get(1),
                  (Integer) this.data.get(2),
                  (Integer) this.data.get(3),
                  (Integer) this.data.get(4),
                  (Integer) this.data.get(5));
        }
        break;
      case C_UPDATE_THERMAL_LEVEL:
        playerBaseClient.thermalLevel = (Integer) this.data.get(0);
        break;
      case C_DISPLAY_ROCKET_CONTROLS:
        player.addChatMessage(
            new ChatComponentText(
                Keyboard.getKeyName(KeyHandlerClient.spaceKey.getKeyCode())
                    + "  - "
                    + GCCoreUtil.translate("gui.rocket.launch.name")));
        player.addChatMessage(
            new ChatComponentText(
                Keyboard.getKeyName(KeyHandlerClient.leftKey.getKeyCode())
                    + " / "
                    + Keyboard.getKeyName(KeyHandlerClient.rightKey.getKeyCode())
                    + "  - "
                    + GCCoreUtil.translate("gui.rocket.turn.name")));
        player.addChatMessage(
            new ChatComponentText(
                Keyboard.getKeyName(KeyHandlerClient.accelerateKey.getKeyCode())
                    + " / "
                    + Keyboard.getKeyName(KeyHandlerClient.decelerateKey.getKeyCode())
                    + "  - "
                    + GCCoreUtil.translate("gui.rocket.updown.name")));
        player.addChatMessage(
            new ChatComponentText(
                Keyboard.getKeyName(KeyHandlerClient.openFuelGui.getKeyCode())
                    + "       - "
                    + GCCoreUtil.translate("gui.rocket.inv.name")));
        break;
      default:
        break;
    }
  }
  private static Entity sendEntityToWorld(
      Entity entity, int newDimension, Vector3 newPos, Facing3 newLook) {
    MinecraftServer server = MinecraftServer.getServer();
    Entity currentEntity = entity;
    if (entity.dimension != newDimension) {
      if (entity instanceof EntityPlayerMP) {
        EntityPlayerMP player = (EntityPlayerMP) entity;
        ServerConfigurationManager scm = server.getConfigurationManager();
        int oldDimension = player.dimension;
        player.dimension = newDimension;
        WorldServer oldWorld = server.worldServerForDimension(oldDimension);
        WorldServer newWorld = server.worldServerForDimension(newDimension);

        DimensionRegisterMessage packet =
            new DimensionRegisterMessage(
                newDimension, DimensionManager.getProviderType(newDimension));
        LCRuntime.runtime.network().getPreferredPipe().sendForgeMessageTo(packet, player);

        player.closeScreen();
        player.playerNetServerHandler.sendPacket(
            new S07PacketRespawn(
                player.dimension,
                player.worldObj.difficultySetting,
                newWorld.getWorldInfo().getTerrainType(),
                player.theItemInWorldManager.getGameType()));
        oldWorld.removePlayerEntityDangerously(player);
        player.isDead = false;
        player.setLocationAndAngles(
            newPos.x, newPos.y, newPos.z, (float) newLook.yaw, (float) newLook.pitch);
        newWorld.spawnEntityInWorld(player);
        player.setWorld(newWorld);
        scm.func_72375_a(player, oldWorld);
        player.playerNetServerHandler.setPlayerLocation(
            newPos.x, newPos.y, newPos.z, (float) newLook.yaw, (float) newLook.pitch);
        player.theItemInWorldManager.setWorld(newWorld);
        scm.updateTimeAndWeatherForPlayer(player, newWorld);
        scm.syncPlayerInventory(player);
        Iterator<?> var6 = player.getActivePotionEffects().iterator();
        while (var6.hasNext())
          player.playerNetServerHandler.sendPacket(
              new S1DPacketEntityEffect(player.getEntityId(), (PotionEffect) var6.next()));
        player.playerNetServerHandler.sendPacket(
            new S1FPacketSetExperience(
                player.experience, player.experienceTotal, player.experienceLevel));
      } else {
        int oldDimension = entity.dimension;
        WorldServer oldWorld = server.worldServerForDimension(oldDimension);
        WorldServer newWorld = server.worldServerForDimension(newDimension);
        entity.dimension = newDimension;

        entity.worldObj.removeEntity(entity);
        entity.isDead = false;
        server
            .getConfigurationManager()
            .transferEntityToWorld(entity, oldDimension, oldWorld, newWorld);
        currentEntity = EntityList.createEntityByName(EntityList.getEntityString(entity), newWorld);

        if (currentEntity != null) {
          currentEntity.copyDataFrom(entity, true);
          currentEntity.setLocationAndAngles(
              newPos.x, newPos.y, newPos.z, (float) newLook.yaw, (float) newLook.pitch);
          newWorld.spawnEntityInWorld(currentEntity);
        }

        entity.isDead = true;
        oldWorld.resetUpdateEntityTick();
        newWorld.resetUpdateEntityTick();
      }
    } else {
      currentEntity.setLocationAndAngles(
          newPos.x, newPos.y, newPos.z, (float) newLook.yaw, (float) newLook.pitch);
      if (currentEntity instanceof EntityPlayerMP) {
        EntityPlayerMP mpEnt = (EntityPlayerMP) currentEntity;
        mpEnt.rotationYaw = (float) newLook.yaw;
        mpEnt.setPositionAndUpdate(newPos.x, newPos.y, newPos.z);
        mpEnt.worldObj.updateEntityWithOptionalForce(entity, false);
      }
    }
    return currentEntity;
  }
예제 #22
0
	public BukkitServer(MinecraftServer server) {
		instance = this;
		cbBuild = BukkitContainer.CRAFT_VERSION;
		configMan = server.getConfigurationManager();
		theServer = server;
		List<Integer> ids = Arrays.asList(DimensionManager.getIDs());
		Iterator<Integer> _ = ids.iterator();

		System.out.println("IS THE INSTANCE NULL? " + (instance == null ? "YES" : "NO"));
		this.pluginManager = new SimplePluginManager(this, commandMap);
		
		//pluginManager = new SimplePluginManager(this, commandMap);
		bukkitConfig = new YamlConfiguration();
		YamlConfiguration yml = new YamlConfiguration();
		try {
			yml.load(getClass().getClassLoader().getResourceAsStream("configurations/bukkit.yml"));
			if (!new File("bukkit.yml").exists()) {
				new File("bukkit.yml").createNewFile();
				yml.save("bukkit.yml");
			}
			bukkitConfig.load("bukkit.yml");
			bukkitConfig.addDefaults(yml);
			bukkitConfig.save("bukkit.yml");

		}
		catch (Exception e) {
			e.printStackTrace();
		}

		String vanillaName = theServer.worldServerForDimension(0).getWorldInfo().getWorldName();
		
		while(_.hasNext()) {
			int i = _.next();
			WorldServer x = theServer.worldServerForDimension(i);
			BukkitWorld world = new BukkitWorld(x, this.getGenerator(x.getWorldInfo().getDimension()), this.wtToEnv(x));
			worlds.put(i, world);
			//if (!x.getWorldInfo().getWorldName().equals(vanillaName))
				pluginWorldMapping.put(x.getWorldInfo().getWorldName(), world);
		}
		this.theLogger = BukkitContainer.bukkitLogger;
		theLogger.info("Bukkit API for Vanilla, version " + apiVer + " starting up...");
		thePluginLoader = new BukkitClassLoader(getClass().getClassLoader());
		
		// I MAINTAIN THAT THIS WILL WORK EVENTUALLY
		/*try {
			System.out.println("This is a test of the SPM Loader!");
			// this *should* load simplepluginamanger via BukkitClassLoader
			Class<?> pluginMan = thePluginLoader.loadClass("org.bukkit.plugin.SimplePluginManager");
			System.out.println("Loaded class: " + pluginMan.getCanonicalName() + " via " + pluginMan.getClassLoader().getClass().getCanonicalName());
			Method insn = pluginMan.getMethod("newInstance", new Class[] { BukkitServer.class, SimpleCommandMap.class });
			insn.setAccessible(true);
			this.pluginManager = (PluginManager) insn.invoke(null, this, this.commandMap);


		} catch (Exception e1) {
			throw new RuntimeException("BukkitForge encountered an error (most likely it  was installed incorrectly!)", e1);
		}*/
		Bukkit.setServer(this);
		this.theHelpMap = new SimpleHelpMap(this);
		this.theMessenger = new StandardMessenger();
		//theLogger.info("Testing the bukkit Logger!");
		this.entityMetadata = new EntityMetadataStore();
		this.playerMetadata = new PlayerMetadataStore();
		this.worldMetadata = new WorldMetadataStore();
		this.warningState = Warning.WarningState.DEFAULT;
		this.console = (BukkitConsoleCommandSender) BukkitConsoleCommandSender.getInstance();
		// wait until server start

		/*try {
			Thread.currentThread().wait();
		} catch (InterruptedException e) {
			theLogger.log(Level.FINE, "The server was interrupted, it might explode!", e);
		}*/
		theLogger.info("Completing load...");
		// fix for the 'mod recipes disappear' bug
		BukkitModRecipeHelper.saveCraftingManagerRecipes();
		//configMan = theServer.getConfigurationManager();
		//theServer = (DedicatedServer) server;
		HelpTopic myHelp = new CommandHelpTopic("bexec", "Run a command forcibly bukkit aliases", "", "");
		Bukkit.getServer().getHelpMap().addTopic(myHelp);
		
		loadPlugins();
		enablePlugins(PluginLoadOrder.STARTUP);

		theLogger.info("Loading PostWorld plugins...");
		enablePlugins(PluginLoadOrder.POSTWORLD);
		theLogger.info("Loaded plugins: ");
		for (Plugin i : pluginManager.getPlugins()) {
			theLogger.info(i.getName() + "- Enabled: " +  i.isEnabled());
		}
		ForgeEventHandler.ready = true;
		commandMap.doneLoadingPlugins((ServerCommandManager) theServer.getCommandManager());
		if (!theServer.isDedicatedServer()) {
			EntityPlayer par0 = theServer.getConfigurationManager().getPlayerForUsername(theServer.getServerOwner());
			if (par0 != null) {
				par0.sendChatToPlayer(ChatColor.GREEN + "BukkitForge has finished loading! You may now enjoy a (relatively) lag-free game!");
				theServer.getCommandManager().executeCommand(par0, "/plugins");
				(new PlayerTracker()).onPlayerLogin(par0);
			}

		}

	}
예제 #23
0
	@Override
	public Set<String> getIPBans() {

		return theServer.getConfigurationManager().getBannedIPs().getBannedList().entrySet();
	}
예제 #24
0
  public CraftServer(MinecraftServer server) {
    instance = this;
    configMan = server.getConfigurationManager();
    theServer = server;
    List<Integer> ids = Arrays.asList(DimensionManager.getIDs());
    Iterator<Integer> worldIter = ids.iterator();

    System.out.println("IS THE INSTANCE NULL? " + (instance == null ? "YES" : "NO"));
    this.pluginManager = new SimplePluginManager(this, commandMap);

    // pluginManager = new SimplePluginManager(this, commandMap);
    configuration = new YamlConfiguration();
    YamlConfiguration yml = new YamlConfiguration();
    try {
      yml.load(getClass().getClassLoader().getResourceAsStream("configurations/bukkit.yml"));
      if (!new File("bukkit.yml").exists()) {
        new File("bukkit.yml").createNewFile();
        yml.save("bukkit.yml");
      }
      configuration.load("bukkit.yml");
      configuration.addDefaults(yml);
      configuration.save("bukkit.yml");

    } catch (Exception e) {
      e.printStackTrace();
    }

    for (int id : ids) {
      worlds.get(id);
    }

    this.theLogger = BukkitContainer.bukkitLogger;
    // theLogger.info("Bukkit API for Vanilla, version " + apiVer + " starting up...");
    theLogger.info(
        "Starting BukkitForge "
            + BukkitContainer.BF_FULL_VERSION
            + "(CB-Version: "
            + BukkitContainer.CRAFT_VERSION
            + ").");

    Bukkit.setServer(this);
    this.theHelpMap = new SimpleHelpMap(this);
    this.theMessenger = new StandardMessenger();
    this.entityMetadata = new EntityMetadataStore();
    this.playerMetadata = new PlayerMetadataStore();
    this.worldMetadata = new WorldMetadataStore();
    this.warningState = Warning.WarningState.DEFAULT;
    this.console = (CraftConsoleCommandSender) CraftConsoleCommandSender.getInstance();

    CraftModRecipeHelper.saveCraftingManagerRecipes();

    HelpTopic myHelp =
        new CommandHelpTopic("bexec", "Run a command forcibly bukkit aliases", "", "");
    Bukkit.getServer().getHelpMap().addTopic(myHelp);

    loadPlugins();
    enablePlugins(PluginLoadOrder.STARTUP);

    // load plugin worlds - TODO

    theLogger.info("Loading PostWorld plugins...");
    enablePlugins(PluginLoadOrder.POSTWORLD);
    theLogger.info("Loaded plugins: ");
    for (Plugin i : pluginManager.getPlugins()) {
      theLogger.info(i.getName() + "- Enabled: " + i.isEnabled());
    }
    ForgeEventHandler.ready = true;
    commandMap.doneLoadingPlugins((ServerCommandManager) theServer.getCommandManager());
    if (!theServer.isDedicatedServer()) {
      EntityPlayer player =
          theServer.getConfigurationManager().getPlayerForUsername(theServer.getServerOwner());
      if (player != null) {
        player.sendChatToPlayer(
            ChatColor.GREEN
                + "CraftForge has finished loading! You may now enjoy a (relatively) lag-free game!");
        theServer.getCommandManager().executeCommand(player, "/plugins");
        (new PlayerTracker()).onPlayerLogin(player);
      }
    }
  }
예제 #25
0
 public static EntityPlayerMP getPlayerForUsernameVanilla(
     MinecraftServer server, String username) {
   return server.getConfigurationManager().getPlayerByUsername(username);
   //        return VersionUtil.getPlayerForUsername(server, username);
 }
예제 #26
0
  public void handleFlying(Packet10Flying par1Packet10Flying) {
    WorldServer worldserver = mcServer.worldServerForDimension(playerEntity.dimension);
    field_72584_h = true;

    if (playerEntity.playerHasConqueredTheEnd) {
      return;
    }

    if (!field_72587_r) {
      double d = par1Packet10Flying.yPosition - lastPosY;

      if (par1Packet10Flying.xPosition == lastPosX
          && d * d < 0.01D
          && par1Packet10Flying.zPosition == lastPosZ) {
        field_72587_r = true;
      }
    }

    if (field_72587_r) {
      if (playerEntity.ridingEntity != null) {
        float f = playerEntity.rotationYaw;
        float f1 = playerEntity.rotationPitch;
        playerEntity.ridingEntity.updateRiderPosition();
        double d2 = playerEntity.posX;
        double d4 = playerEntity.posY;
        double d6 = playerEntity.posZ;
        double d8 = 0.0D;
        double d9 = 0.0D;

        if (par1Packet10Flying.rotating) {
          f = par1Packet10Flying.yaw;
          f1 = par1Packet10Flying.pitch;
        }

        if (par1Packet10Flying.moving
            && par1Packet10Flying.yPosition == -999D
            && par1Packet10Flying.stance == -999D) {
          if (par1Packet10Flying.xPosition > 1.0D || par1Packet10Flying.zPosition > 1.0D) {
            System.err.println(
                (new StringBuilder())
                    .append(playerEntity.username)
                    .append(" was caught trying to crash the server with an invalid position.")
                    .toString());
            kickPlayerFromServer("Nope!");
            return;
          }

          d8 = par1Packet10Flying.xPosition;
          d9 = par1Packet10Flying.zPosition;
        }

        playerEntity.onGround = par1Packet10Flying.onGround;
        playerEntity.onUpdateEntity();
        playerEntity.moveEntity(d8, 0.0D, d9);
        playerEntity.setPositionAndRotation(d2, d4, d6, f, f1);
        playerEntity.motionX = d8;
        playerEntity.motionZ = d9;

        if (playerEntity.ridingEntity != null) {
          worldserver.uncheckedUpdateEntity(playerEntity.ridingEntity, true);
        }

        if (playerEntity.ridingEntity != null) {
          playerEntity.ridingEntity.updateRiderPosition();
        }

        mcServer.getConfigurationManager().func_72358_d(playerEntity);
        lastPosX = playerEntity.posX;
        lastPosY = playerEntity.posY;
        lastPosZ = playerEntity.posZ;
        worldserver.updateEntity(playerEntity);
        return;
      }

      if (playerEntity.isPlayerSleeping()) {
        playerEntity.onUpdateEntity();
        playerEntity.setPositionAndRotation(
            lastPosX, lastPosY, lastPosZ, playerEntity.rotationYaw, playerEntity.rotationPitch);
        worldserver.updateEntity(playerEntity);
        return;
      }

      double d1 = playerEntity.posY;
      lastPosX = playerEntity.posX;
      lastPosY = playerEntity.posY;
      lastPosZ = playerEntity.posZ;
      double d3 = playerEntity.posX;
      double d5 = playerEntity.posY;
      double d7 = playerEntity.posZ;
      float f2 = playerEntity.rotationYaw;
      float f3 = playerEntity.rotationPitch;

      if (par1Packet10Flying.moving
          && par1Packet10Flying.yPosition == -999D
          && par1Packet10Flying.stance == -999D) {
        par1Packet10Flying.moving = false;
      }

      if (par1Packet10Flying.moving) {
        d3 = par1Packet10Flying.xPosition;
        d5 = par1Packet10Flying.yPosition;
        d7 = par1Packet10Flying.zPosition;
        double d10 = par1Packet10Flying.stance - par1Packet10Flying.yPosition;

        if (!playerEntity.isPlayerSleeping()
            && (d10 > 1.6499999999999999D || d10 < 0.10000000000000001D)) {
          kickPlayerFromServer("Illegal stance");
          logger.warning(
              (new StringBuilder())
                  .append(playerEntity.username)
                  .append(" had an illegal stance: ")
                  .append(d10)
                  .toString());
          return;
        }

        if (Math.abs(par1Packet10Flying.xPosition) > 32000000D
            || Math.abs(par1Packet10Flying.zPosition) > 32000000D) {
          kickPlayerFromServer("Illegal position");
          return;
        }
      }

      if (par1Packet10Flying.rotating) {
        f2 = par1Packet10Flying.yaw;
        f3 = par1Packet10Flying.pitch;
      }

      playerEntity.onUpdateEntity();
      playerEntity.ySize = 0.0F;
      playerEntity.setPositionAndRotation(lastPosX, lastPosY, lastPosZ, f2, f3);

      if (!field_72587_r) {
        return;
      }

      double d11 = d3 - playerEntity.posX;
      double d12 = d5 - playerEntity.posY;
      double d13 = d7 - playerEntity.posZ;
      double d14 = Math.min(Math.abs(d11), Math.abs(playerEntity.motionX));
      double d15 = Math.min(Math.abs(d12), Math.abs(playerEntity.motionY));
      double d16 = Math.min(Math.abs(d13), Math.abs(playerEntity.motionZ));
      double d17 = d14 * d14 + d15 * d15 + d16 * d16;

      if (d17 > 100D
          && (!mcServer.isSinglePlayer()
              || !mcServer.getServerOwner().equals(playerEntity.username))) {
        logger.warning(
            (new StringBuilder())
                .append(playerEntity.username)
                .append(" moved too quickly! ")
                .append(d11)
                .append(",")
                .append(d12)
                .append(",")
                .append(d13)
                .append(" (")
                .append(d14)
                .append(", ")
                .append(d15)
                .append(", ")
                .append(d16)
                .append(")")
                .toString());
        setPlayerLocation(
            lastPosX, lastPosY, lastPosZ, playerEntity.rotationYaw, playerEntity.rotationPitch);
        return;
      }

      float f4 = 0.0625F;
      boolean flag =
          worldserver
              .getCollidingBoundingBoxes(
                  playerEntity, playerEntity.boundingBox.copy().contract(f4, f4, f4))
              .isEmpty();

      if (playerEntity.onGround && !par1Packet10Flying.onGround && d12 > 0.0D) {
        playerEntity.addExhaustion(0.2F);
      }

      playerEntity.moveEntity(d11, d12, d13);
      playerEntity.onGround = par1Packet10Flying.onGround;
      playerEntity.addMovementStat(d11, d12, d13);
      double d18 = d12;
      d11 = d3 - playerEntity.posX;
      d12 = d5 - playerEntity.posY;

      if (d12 > -0.5D || d12 < 0.5D) {
        d12 = 0.0D;
      }

      d13 = d7 - playerEntity.posZ;
      d17 = d11 * d11 + d12 * d12 + d13 * d13;
      boolean flag1 = false;

      if (d17 > 0.0625D
          && !playerEntity.isPlayerSleeping()
          && !playerEntity.theItemInWorldManager.isCreative()) {
        flag1 = true;
        logger.warning(
            (new StringBuilder())
                .append(playerEntity.username)
                .append(" moved wrongly!")
                .toString());
      }

      playerEntity.setPositionAndRotation(d3, d5, d7, f2, f3);
      boolean flag2 =
          worldserver
              .getCollidingBoundingBoxes(
                  playerEntity, playerEntity.boundingBox.copy().contract(f4, f4, f4))
              .isEmpty();

      if (flag && (flag1 || !flag2) && !playerEntity.isPlayerSleeping()) {
        setPlayerLocation(lastPosX, lastPosY, lastPosZ, f2, f3);
        return;
      }

      AxisAlignedBB axisalignedbb =
          playerEntity
              .boundingBox
              .copy()
              .expand(f4, f4, f4)
              .addCoord(0.0D, -0.55000000000000004D, 0.0D);

      if (!mcServer.isFlightAllowed()
          && !playerEntity.theItemInWorldManager.isCreative()
          && !worldserver.isAABBNonEmpty(axisalignedbb)) {
        if (d18 >= -0.03125D) {
          ticksForFloatKick++;

          if (ticksForFloatKick > 80) {
            logger.warning(
                (new StringBuilder())
                    .append(playerEntity.username)
                    .append(" was kicked for floating too long!")
                    .toString());
            kickPlayerFromServer("Flying is not enabled on this server");
            return;
          }
        }
      } else {
        ticksForFloatKick = 0;
      }

      playerEntity.onGround = par1Packet10Flying.onGround;
      mcServer.getConfigurationManager().func_72358_d(playerEntity);
      playerEntity.updateFlyingState(playerEntity.posY - d1, par1Packet10Flying.onGround);
    }
  }
예제 #27
0
  public void handleBlockDig(Packet14BlockDig par1Packet14BlockDig) {
    WorldServer worldserver = mcServer.worldServerForDimension(playerEntity.dimension);

    if (par1Packet14BlockDig.status == 4) {
      playerEntity.dropOneItem();
      return;
    }

    if (par1Packet14BlockDig.status == 5) {
      playerEntity.stopUsingItem();
      return;
    }

    boolean flag =
        worldserver.actionsAllowed =
            worldserver.provider.worldType != 0
                || mcServer.getConfigurationManager().areCommandsAllowed(playerEntity.username)
                || mcServer.isSinglePlayer();
    boolean flag1 = false;

    if (par1Packet14BlockDig.status == 0) {
      flag1 = true;
    }

    if (par1Packet14BlockDig.status == 2) {
      flag1 = true;
    }

    int i = par1Packet14BlockDig.xPosition;
    int j = par1Packet14BlockDig.yPosition;
    int k = par1Packet14BlockDig.zPosition;

    if (flag1) {
      double d = playerEntity.posX - ((double) i + 0.5D);
      double d1 = (playerEntity.posY - ((double) j + 0.5D)) + 1.5D;
      double d3 = playerEntity.posZ - ((double) k + 0.5D);
      double d5 = d * d + d1 * d1 + d3 * d3;

      if (d5 > 36D) {
        return;
      }

      if (j >= mcServer.getBuildLimit()) {
        return;
      }
    }

    ChunkCoordinates chunkcoordinates = worldserver.getSpawnPoint();
    int l = MathHelper.abs_int(i - chunkcoordinates.posX);
    int i1 = MathHelper.abs_int(k - chunkcoordinates.posZ);

    if (l > i1) {
      i1 = l;
    }

    if (par1Packet14BlockDig.status == 0) {
      if (i1 > 16 || flag) {
        playerEntity.theItemInWorldManager.onBlockClicked(i, j, k, par1Packet14BlockDig.face);
      } else {
        playerEntity.serverForThisPlayer.sendPacketToPlayer(
            new Packet53BlockChange(i, j, k, worldserver));
      }
    } else if (par1Packet14BlockDig.status == 2) {
      playerEntity.theItemInWorldManager.uncheckedTryHarvestBlock(i, j, k);

      if (worldserver.getBlockId(i, j, k) != 0) {
        playerEntity.serverForThisPlayer.sendPacketToPlayer(
            new Packet53BlockChange(i, j, k, worldserver));
      }
    } else if (par1Packet14BlockDig.status == 1) {
      playerEntity.theItemInWorldManager.destroyBlockInWorldPartially(i, j, k);

      if (worldserver.getBlockId(i, j, k) != 0) {
        playerEntity.serverForThisPlayer.sendPacketToPlayer(
            new Packet53BlockChange(i, j, k, worldserver));
      }
    } else if (par1Packet14BlockDig.status == 3) {
      double d2 = playerEntity.posX - ((double) i + 0.5D);
      double d4 = playerEntity.posY - ((double) j + 0.5D);
      double d6 = playerEntity.posZ - ((double) k + 0.5D);
      double d7 = d2 * d2 + d4 * d4 + d6 * d6;

      if (d7 < 256D) {
        playerEntity.serverForThisPlayer.sendPacketToPlayer(
            new Packet53BlockChange(i, j, k, worldserver));
      }
    }

    worldserver.actionsAllowed = false;
  }
예제 #28
0
  public void handlePlace(Packet15Place par1Packet15Place) {
    WorldServer worldserver = mcServer.worldServerForDimension(playerEntity.dimension);
    ItemStack itemstack = playerEntity.inventory.getCurrentItem();
    boolean flag = false;
    int i = par1Packet15Place.getXPosition();
    int j = par1Packet15Place.getYPosition();
    int k = par1Packet15Place.getZPosition();
    int l = par1Packet15Place.getDirection();
    boolean flag1 =
        worldserver.actionsAllowed =
            worldserver.provider.worldType != 0
                || mcServer.getConfigurationManager().areCommandsAllowed(playerEntity.username)
                || mcServer.isSinglePlayer();

    if (par1Packet15Place.getDirection() == 255) {
      if (itemstack == null) {
        return;
      }

      playerEntity.theItemInWorldManager.tryUseItem(playerEntity, worldserver, itemstack);
    } else if (par1Packet15Place.getYPosition() < mcServer.getBuildLimit() - 1
        || par1Packet15Place.getDirection() != 1
            && par1Packet15Place.getYPosition() < mcServer.getBuildLimit()) {
      ChunkCoordinates chunkcoordinates = worldserver.getSpawnPoint();
      int i1 = MathHelper.abs_int(i - chunkcoordinates.posX);
      int j1 = MathHelper.abs_int(k - chunkcoordinates.posZ);

      if (i1 > j1) {
        j1 = i1;
      }

      if (field_72587_r
          && playerEntity.getDistanceSq((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D)
              < 64D
          && (j1 > 16 || flag1)) {
        playerEntity.theItemInWorldManager.activateBlockOrUseItem(
            playerEntity,
            worldserver,
            itemstack,
            i,
            j,
            k,
            l,
            par1Packet15Place.getXOffset(),
            par1Packet15Place.getYOffset(),
            par1Packet15Place.getZOffset());
      }

      flag = true;
    } else {
      playerEntity.serverForThisPlayer.sendPacketToPlayer(
          new Packet3Chat(
              (new StringBuilder())
                  .append("\2477Height limit for building is ")
                  .append(mcServer.getBuildLimit())
                  .toString()));
      flag = true;
    }

    if (flag) {
      playerEntity.serverForThisPlayer.sendPacketToPlayer(
          new Packet53BlockChange(i, j, k, worldserver));

      if (l == 0) {
        j--;
      }

      if (l == 1) {
        j++;
      }

      if (l == 2) {
        k--;
      }

      if (l == 3) {
        k++;
      }

      if (l == 4) {
        i--;
      }

      if (l == 5) {
        i++;
      }

      playerEntity.serverForThisPlayer.sendPacketToPlayer(
          new Packet53BlockChange(i, j, k, worldserver));
    }

    itemstack = playerEntity.inventory.getCurrentItem();

    if (itemstack != null && itemstack.stackSize == 0) {
      playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] = null;
      itemstack = null;
    }

    if (itemstack == null || itemstack.getMaxItemUseDuration() == 0) {
      playerEntity.playerInventoryBeingManipulated = true;
      playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] =
          ItemStack.copyItemStack(
              playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem]);
      Slot slot =
          playerEntity.craftingInventory.getSlotFromInventory(
              playerEntity.inventory, playerEntity.inventory.currentItem);
      playerEntity.craftingInventory.updateCraftingResults();
      playerEntity.playerInventoryBeingManipulated = false;

      if (!ItemStack.areItemStacksEqual(
          playerEntity.inventory.getCurrentItem(), par1Packet15Place.getItemStack())) {
        sendPacketToPlayer(
            new Packet103SetSlot(
                playerEntity.craftingInventory.windowId,
                slot.slotNumber,
                playerEntity.inventory.getCurrentItem()));
      }
    }

    worldserver.actionsAllowed = false;
  }