Ejemplo n.º 1
0
 /** Generate the RPClass */
 public static void generateRPClass() {
   RPClass clazz = new RPClass("blocktarget");
   clazz.isA("area");
   clazz.addAttribute("x", Type.INT);
   clazz.addAttribute("y", Type.INT);
   clazz.addAttribute("shape", Type.STRING);
 }
Ejemplo n.º 2
0
 public static void generateRPClass() {
   try {
     final RPClass pet = new RPClass("pet");
     pet.isA("creature");
     pet.addAttribute("weight", Type.BYTE);
     pet.addAttribute("eat", Type.FLAG);
   } catch (final SyntaxException e) {
     LOGGER.error("cannot generate RPClass", e);
   }
 }
Ejemplo n.º 3
0
 public static void generateRPClasses() {
   ItemTestHelper.generateRPClasses();
   if (!RPClass.hasRPClass("corpse")) {
     Corpse.generateRPClass();
   }
 }
Ejemplo n.º 4
0
 /** Creates the rpclass. */
 public static void generateRPClass() {
   final RPClass rpclass = new RPClass(Events.PRIVATE_TEXT);
   rpclass.add(DefinitionClass.ATTRIBUTE, TEXT_TYPE, Type.STRING);
   rpclass.add(DefinitionClass.ATTRIBUTE, CHANNEL, Type.STRING);
   rpclass.add(DefinitionClass.ATTRIBUTE, TEXT, Type.LONG_STRING);
 }
Ejemplo n.º 5
0
  /** sends id, version and distribution */
  public static void send() {
    String clientid = readID();
    if (clientid == null) {
      clientid = generateRandomString();
      saveID(clientid);
    }

    final RPAction action = new RPAction();

    // compatibility with old servers
    if (RPClass.getRPClass("cstatus") != null) {
      action.put("type", "cstatus");
    } else {
      action.put("type", "cid");
    }

    // a client id to help with the investigation of hacked accounts
    // especially in the common "angry sibling" case.
    if (clientid != null) {
      action.put("cid", clientid);
    }

    // the client version, the server will deactivate certain features that
    // are incompatible with old clients. E. g. changing of light and dark
    // in the current zone is implemented by retransmitting the tileset
    // information. an old client would mistake that for a zone change and
    // hang.
    String version = Debug.VERSION;
    if (Debug.PRE_RELEASE_VERSION != null) {
      version = version + " - " + Debug.PRE_RELEASE_VERSION;
    }
    action.put("version", version);

    // extract the signer of the client, so that we can ask bug
    // reporters to try again with the official client, if they
    // are using an unofficial one.
    try {
      Class<?> clazz = Class.forName("games.stendhal.client.update.Starter");
      if (clazz != null) {
        Object[] objects = clazz.getSigners();
        if (objects instanceof Certificate[]) {
          Certificate[] certs = (Certificate[]) objects;
          if ((certs.length > 0)) {
            byte[] key = certs[0].getPublicKey().getEncoded();
            action.put("dist", Hash.toHexString(Hash.hash(key)));
          }
        }
      }

      // Throwable: both errors and exceptions
    } catch (Throwable e) {
      logger.error(e, e);
    }

    // Get build number. The class is not in CVS to prevent lots of unwanted
    // conflicts. This has, however, the side effect, that it is missing in
    // an IDE (e. g. Eclipes) environment.
    // The build number is especially helpful for pre releases
    try {
      Class<?> clazz = Class.forName("games.stendhal.client.StendhalBuild");
      Object buildNumber = clazz.getMethod("getBuildNumber").invoke(null);
      if (buildNumber != null) {
        action.put("build", buildNumber.toString());
      }
    } catch (Throwable e) {
      logger.debug(e, e);
    }

    ClientSingletonRepository.getClientFramework().send(action);
  }