Package org.spout.api

Examples of org.spout.api.Server


  private static String MC_VERSION = null;
  private static String MOTD = null;

  @Override
  public void handleServer(ServerSession session, ServerListPingMessage message) {
    Server server = (Server) VanillaPlugin.getInstance().getEngine();
    //Cache values for speed
    if (PROTOCOL == null) {
      PROTOCOL = VanillaPlugin.getInstance().getDescription().getData("protocol");
      MC_VERSION = VanillaPlugin.getInstance().getDescription().getVersion().trim().split(" ")[0];
      MOTD = VanillaConfiguration.MOTD.getString();
    }
    ServerListPingEvent event = VanillaPlugin.getInstance().getEngine().getEventManager().callEvent(new ServerListPingEvent(session.getAddress().getAddress(), MOTD, server.getOnlinePlayers().length, server.getMaxPlayers()));
    session.send(new PlayerKickMessage('\u00A7' + "1" + '\u0000' + PROTOCOL + '\u0000' + MC_VERSION + '\u0000' + event.getMessage()));
  }
View Full Code Here


import org.spout.vanilla.protocol.msg.player.pos.PlayerSpawnPositionMessage;

public class PlayerStatusHandler extends MessageHandler<PlayerStatusMessage> {
  @Override
  public void handleServer(ServerSession session, PlayerStatusMessage message) {
    final Server server = session.getEngine();

    if (message.getStatus() == PlayerStatusMessage.INITIAL_SPAWN) {
      server.getEventManager().callEvent(new PlayerConnectEvent(session, (String) session.getDataMap().get("username"), 10));
      if (server.debugMode()) {
        server.getLogger().info("Login took " + (System.currentTimeMillis() - session.getDataMap().get(VanillaProtocol.LOGIN_TIME)) + " ms");
      }
      final ManagedMap data = session.getPlayer().getWorld().getData();
      final Human human = session.getPlayer().add(Human.class);
      final Difficulty difficulty = data.get(VanillaData.DIFFICULTY);
      final Dimension dimension = data.get(VanillaData.DIMENSION);
      final WorldType worldType = data.get(VanillaData.WORLD_TYPE);

      GameMode gamemode;

      int entityId = session.getPlayer().getId();

      //  MC Packet Order: 0x01 Login, 0xFA Custom (ServerTypeName), 0x06 SpawnPos, 0xCA PlayerAbilities, 0x10 BlockSwitch
      gamemode = data.get(VanillaData.GAMEMODE);
      final PlayerLoginRequestMessage idMsg = new PlayerLoginRequestMessage(entityId, worldType.toString(), gamemode.getId(), (byte) dimension.getId(), difficulty.getId(), (byte) server.getMaxPlayers());
      session.send(Session.SendType.FORCE, idMsg);
      session.setState(Session.State.GAME);
      if (human.getAttachedCount() <= 1) {
        // If we haven't logged in before, we want to set all abilities to the default gamemode
        human.setGamemode(gamemode, false);
      }
    } else if (message.getStatus() == PlayerStatusMessage.RESPAWN) {
      Player player = session.getPlayer();
      Point point = player.getWorld().getSpawnPoint().getPosition();
      if (PlayerRespawnEvent.getHandlerList().getRegisteredListeners().length > 0) {
        PlayerRespawnEvent event = server.getEventManager().callEvent(new PlayerRespawnEvent(player, point));

        if (event.isCancelled()) {
          return;
        }
        point = event.getPoint();
View Full Code Here

TOP

Related Classes of org.spout.api.Server

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.