示例#1
0
  public void equip(CreatureObject actor, SWGObject item) {
    String template =
        ((item.getAttachment("customServerTemplate") == null)
            ? item.getTemplate()
            : (item.getTemplate().split("shared_")[0]
                + "shared_"
                + ((String) item.getAttachment("customServerTemplate"))
                + ".iff"));
    String serverTemplate = template.replace(".iff", "");

    PyObject func =
        core.scriptService.getMethod(
            "scripts/" + serverTemplate.split("shared_", 2)[0].replace("shared_", ""),
            serverTemplate.split("shared_", 2)[1],
            "equip");
    if (func != null) func.__call__(Py.java2py(core), Py.java2py(actor), Py.java2py(item));

    // TODO: bio-link (assign it by objectID with setAttachment and then just display the customName
    // for that objectID).

    if (!actor.getEquipmentList().contains(item)) {
      actor.addObjectToEquipList(item);
      processItemAtrributes(actor, item, true);
    }
  }
示例#2
0
  /** Provide functionality for Oracle specific types, such as ROWID. */
  public PyObject getPyObject(ResultSet set, int col, int type) throws SQLException {

    PyObject obj = Py.None;

    switch (type) {
      case Types.BLOB:
        BLOB blob = ((OracleResultSet) set).getBLOB(col);

        if (blob == null) {
          return Py.None;
        }

        InputStream stream = new BufferedInputStream(blob.getBinaryStream());

        obj = Py.java2py(DataHandler.read(stream));
        break;

      case OracleTypes.ROWID:
        ROWID rowid = ((OracleResultSet) set).getROWID(col);

        if (rowid != null) {
          obj = Py.java2py(rowid.stringValue());
        }
        break;

      default:
        obj = super.getPyObject(set, col, type);
    }

    return (set.wasNull() ? Py.None : obj);
  }
示例#3
0
  /**
   * Gets the value of the attribute name.
   *
   * @param name
   * @return the attribute for the given name
   */
  public PyObject __findattr_ex__(String name) {

    if ("destinationDataHandler".equals(name)) {
      return Py.java2py(this.destDH);
    } else if ("sourceDataHandler".equals(name)) {
      return Py.java2py(this.sourceDH);
    } else if ("batchsize".equals(name)) {
      return Py.newInteger(this.batchsize);
    } else if ("queuesize".equals(name)) {
      return Py.newInteger(this.queuesize);
    }

    return super.__findattr_ex__(name);
  }
 public T createObject(Object args[], String keywords[]) {
   PyObject convertedArgs[] = new PyObject[args.length];
   for (int i = 0; i < args.length; i++) {
     convertedArgs[i] = Py.java2py(args[i]);
   }
   return (T) klass.__call__(convertedArgs, keywords).__tojava__(interfaceType);
 }
示例#5
0
  public void unequip(CreatureObject actor, SWGObject item) {
    String template =
        ((item.getAttachment("customServerTemplate") == null)
            ? item.getTemplate()
            : (item.getTemplate().split("shared_")[0]
                + "shared_"
                + ((String) item.getAttachment("customServerTemplate"))
                + ".iff"));
    String serverTemplate = template.replace(".iff", "");

    PyObject func =
        core.scriptService.getMethod(
            "scripts/" + serverTemplate.split("shared_", 2)[0].replace("shared_", ""),
            serverTemplate.split("shared_", 2)[1],
            "unequip");
    if (func != null) func.__call__(Py.java2py(core), Py.java2py(actor), Py.java2py(item));

    if (actor.getEquipmentList().contains(item)) {
      actor.removeObjectFromEquipList(item);
      processItemAtrributes(actor, item, false);
    }
  }
示例#6
0
 public Object __tojava__(Class c) {
   // If we are not being asked by the "default" conversion to java, then
   // we can provide this as the result, as long as it is a instance of the
   // specified class. Without this, derived.__tojava__(PyObject.class)
   // would broke. (And that's not pure speculation: PyReflectedFunction's
   // ReflectedArgs asks for things like that).
   if ((c != Object.class) && (c != Serializable.class) && (c.isInstance(this))) {
     return this;
   }
   // Otherwise, we call the derived __tojava__, if it exists:
   PyType self_type = getType();
   PyObject impl = self_type.lookup("__tojava__");
   if (impl != null)
     return impl.__get__(this, self_type).__call__(Py.java2py(c)).__tojava__(Object.class);
   return super.__tojava__(c);
 }
示例#7
0
 void doUnpack(ByteStream buf, int count, PyList list) {
   while (count-- > 0) list.append(Py.java2py(unpack(buf)));
 }
 /**
  * Set a variable in the local namespace
  *
  * @param name the name of the variable
  * @param value the value to set the variable to. Will be automatically converted to an
  *     appropriate Python object.
  */
 public void set(String name, Object value) {
   locals.__setitem__(name.intern(), Py.java2py(value));
 }
 public T createObject(Object arg1, Object arg2, Object arg3) {
   return (T)
       klass
           .__call__(Py.java2py(arg1), Py.java2py(arg2), Py.java2py(arg3))
           .__tojava__(interfaceType);
 }