Package org.moparscape.msc.ls

Examples of org.moparscape.msc.ls.Server


      e.printStackTrace();
    }
  }

  private byte validatePlayer(long user, byte[] pass, String ip, String UID) {
    Server server = Server.getServer();
    byte returnVal = 0;

    if (UIDTracker.isActive(UID)) {
      return 8;
    }

    if (!Server.storage.playerExists(user)) {
      if (Config.AUTO_REGISTER) {
        PlayerSave p = Server.storage.registerPlayer(user, pass, DataConversions.hashToUsername(user));
        Server.storage.savePlayer(p);
      } else {
        return 10;
      }
    }

    if (!auth.validate(user, pass, new StringBuilder())) {
      return 2;
    }

    if (Server.storage.isBanned(user)) {
      System.out.println("Banned player: "
          + DataConversions.hashToUsername(user)
          + " trying to login.");
      return 6;
    }

    if (Server.storage.getGroupID(user) >= 5) {
      returnVal = 99;
    }

    long owner = Server.storage.getOwner(user);
    for (World w : server.getWorlds()) {
      for (Entry<Long, Long> player : w.getPlayers()) {
        if (player.getKey() == user) {
          return 3;
        }
        if (player.getValue() == owner) {
View Full Code Here


public class PrivacySettingHandler implements PacketHandler {

  public void handlePacket(Packet p, IoSession session) throws Exception {
    World world = (World) session.getAttachment();
    Server server = Server.getServer();

    long user = p.readLong();
    boolean on = p.readByte() == 1;
    int idx = (int) p.readByte();
    switch (idx) {
    case 0: // Chat block
      break;
    case 1: // Private block
      if (world.getSave(user).blockPrivate() && !on) {
        FriendsListService.turnOffPrivate(user);
      } else if (!world.getSave(user).blockPrivate() && on) {
        FriendsListService.turnOnPrivate(user);
      }
      break;
    case 2: // Trade block
      break;
    case 3: // Duel block
      break;
    }
    server.findSave(user, world).setPrivacySetting(idx, on);
  }
View Full Code Here

  public void handlePacket(Packet p, IoSession session) throws Exception {
    final long uID = ((LSPacket) p).getUID();
    builder.setUID(uID);
    builder.setSuccess(false);

    Server server = Server.getServer();
    if (((LSPacket) p).getID() == 1) {
      int id = p.readShort();
      if (server.getWorld(id) == null) {
        World world = server.getIdleWorld(id);
        if (world == null) {
          world = new World(id, session);
          if (!Server.devMode) {
            int passL = p.readInt();
            byte[] pass = p.readBytes(passL);
            if (!Arrays.equals(
                new Hash(Config.LS_CONNECT_PASS.getBytes())
                    .value(), pass)) {
              System.out
                  .println("World provided invalid password.");
              LSPacket temp = builder.getPacket();
              if (temp != null) {
                session.write(temp);
              }
              return;
            }
          } else {
            int length = p.readInt();
            if (length != 0) {
              System.out
                  .println("[WARNING] Loginserver is in dev mode, but gameserver is not! Connection refused.");
              LSPacket temp = builder.getPacket();
              if (temp != null) {
                session.write(temp);
              }
              return;
            }           
          }
          server.registerWorld(world);
          System.out.println("Registering world: " + id);
        } else {
          world.setSession(session);
          server.setIdle(world, false);
          System.out.println("Reattached to world " + id);
        }
        int playerCount = p.readShort();
        for (int i = 0; i < playerCount; i++) {
          world.registerPlayer(p.readLong(),
              DataConversions.IPToString(p.readLong()),
              p.readString(p.readInt()));
        }
        session.setAttachment(world);
        builder.setSuccess(true);
      }
    } else {
      World world = (World) session.getAttachment();

      server.unregisterWorld(world);
      System.out.println("UnRegistering world: " + world.getID());
      session.setAttachment(null);
      builder.setSuccess(true);
    }
View Full Code Here

public class FriendHandler implements PacketHandler {

  public void handlePacket(Packet p, IoSession session) throws Exception {
    World world = (World) session.getAttachment();
    Server server = Server.getServer();

    long user = p.readLong();
    long friend = p.readLong();

    World userWorld = server.findWorld(user);
    World friendWorld = server.findWorld(friend);

    PlayerSave save = server.findSave(user, world);
    switch (((LSPacket) p).getID()) {
    case 10: // Send PM
      boolean avoidBlock = p.readByte() == 1;
      byte[] message = p.getRemainingData();
      if (friendWorld != null) {
View Full Code Here

TOP

Related Classes of org.moparscape.msc.ls.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.