Exemplo n.º 1
0
  int serverInitiateHandshake() {
    // Send mod salutation to the client
    // This will be ignored by vanilla clients
    this.state = ConnectionState.AWAITING_HANDSHAKE;
    // Need to start the handler here, so we can send custompayload packets
    serverHandler =
        new NetHandlerPlayServer(scm.getServerInstance(), manager, player) {
          /** Updates the JList with a new model. */
          @Override
          public void update() {
            if (NetworkDispatcher.this.state == ConnectionState.FINALIZING) {
              completeServerSideConnection(ConnectionType.MODDED);
            }
            super.update();
          }
        };
    this.netHandler = serverHandler;
    // NULL the play server here - we restore it further on. If not, there are packets sent before
    // the login
    player.playerNetServerHandler = null;
    // manually for the manager into the PLAY state, so we can send packets later
    this.manager.setConnectionState(EnumConnectionState.PLAY);

    // Return the dimension the player is in, so it can be pre-sent to the client in the ServerHello
    // v2 packet
    // Requires some hackery to the serverconfigmanager and stuff for this to work
    NBTTagCompound playerNBT = scm.getPlayerNBT(player);
    if (playerNBT != null) {
      return playerNBT.getInteger("Dimension");
    } else {
      return 0;
    }
  }
Exemplo n.º 2
0
	@Override
	public Set<OfflinePlayer> getOperators() {
		Set<OfflinePlayer> ops = new HashSet<OfflinePlayer>();
		Set<String> opers = configMan.getOps();
		for (String guy : opers) {
			ops.add(this.getOfflinePlayer(guy));
		}
		return ops;
	}
Exemplo n.º 3
0
	@Override
	public Set<OfflinePlayer> getBannedPlayers() {
		Set<OfflinePlayer> players = new HashSet<OfflinePlayer>();
		Set<String> banned = configMan.getBannedPlayers().getBannedList().entrySet();
		for (String guy : banned) {
			players.add(this.getOfflinePlayer(guy));
		}
		return players;
	}
  @Override
  public void playerLoggedOut(EntityPlayerMP par1EntityPlayerMP) {
    if (!MinecraftForge.EVENT_BUS.post(new PlayerLogoutEvent(par1EntityPlayerMP))) {
      GameRegistry.onPlayerLogout(par1EntityPlayerMP);
      super.writePlayerData(par1EntityPlayerMP);
      WorldServer worldserver = par1EntityPlayerMP.getServerForPlayer();

      if (par1EntityPlayerMP.ridingEntity != null) {
        worldserver.removeEntity(par1EntityPlayerMP.ridingEntity);
        System.out.println("removing player mount");
      }

      worldserver.removeEntity(par1EntityPlayerMP);
      worldserver.getPlayerManager().removePlayer(par1EntityPlayerMP);
      super.playerEntityList.remove(par1EntityPlayerMP);
      super.sendPacketToAllPlayers(
          new Packet201PlayerInfo(par1EntityPlayerMP.username, false, 9999));
    }
  }
Exemplo n.º 5
0
  @Override
  public Set<OfflinePlayer> getWhitelistedPlayers() {
    Set<OfflinePlayer> ret = new HashSet<OfflinePlayer>();
    // strings
    for (Object i : configMan.getWhiteListedPlayers()) {
      String name = (String) i;
      ret.add(new CraftOfflinePlayer(this, name));
    }

    // Set<OfflinePlayer> d = (Set<OfflinePlayer>) configMan.getWhiteListedPlayers();
    // Set<OfflinePlayer> j = (Set<OfflinePlayer>) new ArrayList<OfflinePlayer>();
    return ret;
  }
Exemplo n.º 6
0
 private synchronized void completeServerSideConnection(ConnectionType type) {
   this.connectionType = type;
   FMLLog.info(
       "[%s] Server side %s connection established",
       Thread.currentThread().getName(), this.connectionType.name().toLowerCase(Locale.ENGLISH));
   this.state = ConnectionState.CONNECTED;
   FMLCommonHandler.instance()
       .bus()
       .post(new FMLNetworkEvent.ServerConnectionFromClientEvent(manager));
   if (DEBUG_HANDSHAKE)
     manager.closeChannel(
         new ChatComponentText("Handshake Complete review log file for details."));
   scm.initializeConnectionToPlayer(manager, player, serverHandler);
 }
Exemplo n.º 7
0
	@Override
	public void reloadWhitelist() {
		configMan.loadWhiteList();

	}
Exemplo n.º 8
0
	@Override
	public void setWhitelist(boolean value) {
		configMan.setWhiteListEnabled(value);

	}
Exemplo n.º 9
0
	@Override
	public boolean hasWhitelist() {

		return configMan.isWhiteListEnabled();
	}
Exemplo n.º 10
0
	@Override
	public int getViewDistance() {

		return configMan.getViewDistance();
	}
Exemplo n.º 11
0
	@Override
	public int getMaxPlayers() {

		return configMan.getMaxPlayers();
	}
Exemplo n.º 12
0
	@Override
	public void unbanIP(String address) {
		configMan.getBannedIPs().remove(address);

	}
Exemplo n.º 13
0
	@Override
	public void banIP(String address) {
		BanEntry entry = new BanEntry(address);
		configMan.getBannedIPs().put(entry);

	}
Exemplo n.º 14
0
	@Override
	public void savePlayers() {
		configMan.saveAllPlayerData();

	}
  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;
  }