@Override public void edit(final MethodCall call) throws CannotCompileException { if (call.getMethodName().equals("isPopupTrigger")) { call.replace("$_ = $0.isPopupTrigger() && $0.getButton() != 0;"); } } };
@Override public void edit(MethodCall m) throws CannotCompileException { if (m.getMethodName().equals("get") && first) { m.replace("$_ = $proceed($$);" + "if ($_ == " + ModCommConstants.CMD_MODCOMM + ") {" + " org.gotti.wurmunlimited.modcomm.ModCommHandler.handlePacket(player, byteBuffer);" + " return;" + "}"); first = false; } } });
@Override public void edit(MethodCall m) throws CannotCompileException { if (m.getMethodName().equals("get") && first) { m.replace("$_ = $proceed($$);" + "if ($_ == " + ModIntraServerConstants.CMD_MODCOMM + ") { modcomm.handle(this, $0); return; }"); first = false; } } });
/** Replaces constructor call with standard non optimized invocation code. Up to subclasses to override this behaviour */ protected void replaceMethodCallInCon(ConstructorDetail cd)throws CannotCompileException, NotFoundException { String replaced = methodByConInfoFromWeakReference("info", cd.callerInfoField) + "if (info.getInterceptors() != (org.jboss.aop.advice.Interceptor[])null) { " + "$_ = ($r)aop$classAdvisor$aop.invokeConstructorCaller(info, this, $0, $args);" + //+ cd.callingIndex + ", $0, $args, " + cd.callerInfoField + "); " + "} else { " + "$_ = $proceed($$); " + "}"; cd.call.replace(replaced); }
@Override public void edit(final MethodCall call) throws CannotCompileException { if (call.getMethodName().equals("isPopupTrigger")) { call.replace("$_ = $0.isPopupTrigger() && $0.getButton() != 0;"); } } };
@Override public void edit(MethodCall m) throws CannotCompileException { // com.wurmonline.server.Players.getPlayers() if ("com.wurmonline.server.Players".equals(m.getClassName()) && "getPlayers".equals(m.getMethodName())) { StringBuffer code = new StringBuffer(); code.append("{\n"); code.append(String.format("%s#communicatorChannelHook(mess);\n", ProxyServerHook.class.getName())); code.append("$_ = $proceed($$);\n"); code.append("}\n"); m.replace(code.toString()); } } });
public void edit(MethodCall methodCall) throws CannotCompileException { if (methodCall.getClassName().equals("com.wurmonline.server.zones.TilePoller") && methodCall.getMethodName().equals("checkForFarmGrowth")) { StringBuffer code = new StringBuffer(); code.append("if ((($5 >> 4) & 0x7) != 6) {\n"); code.append(" $_ = $proceed($$);\n"); code.append("}\n"); methodCall.replace(code.toString()); } } });
public void edit(MethodCall methodCall) throws CannotCompileException { if (methodCall.getClassName().equals("com.wurmonline.server.zones.CropTilePoller") && methodCall.getMethodName().equals("checkForFarmGrowth")) { StringBuffer code = new StringBuffer(); code.append("if (((data >> 4) & 0x7) == 6) {\n"); code.append(" toRemove.add(cTile);\n"); code.append(" $_ = null;\n"); code.append("} else {\n"); code.append(" $_ = $proceed($$);\n"); code.append("}\n"); methodCall.replace(code.toString()); } } });
@Override public void edit(MethodCall m) throws CannotCompileException { if ("com.wurmonline.server.items.ItemTemplate".equals(m.getClassName())) { if ("getContainerSizeX".equals(m.getMethodName())) { m.replace("$_ = this.getContainerSizeX();"); } else if ("getContainerSizeY".equals(m.getMethodName())) { m.replace("$_ = this.getContainerSizeY();"); } else if ("getContainerSizeZ".equals(m.getMethodName())) { m.replace("$_ = this.getContainerSizeZ();"); } } } };
@Override public void edit(MethodCall m) throws CannotCompileException { // com.wurmonline.server.items.Item.setAuxData(byte) if (m.getClassName().equals("com.wurmonline.server.players.Player") && m.getMethodName().equals("isReimbursed")) { m.replace("$_ = christmasmod.hasPlayerReceivedPresent($0);"); } } });
public void edit(MethodCall m) throws CannotCompileException { if (m.getClassName().equals("com.wurmonline.server.creatures.Creature") && m.getMethodName().equals("isPriest")) { m.replace("$_ = false;"); } } }
@Override public void edit(MethodCall methodCall) throws CannotCompileException { if (methodCall.getClassName().equals("com.wurmonline.server.behaviours.Action") && methodCall.getMethodName().equals("isFatigue")) { methodCall.replace("$_ = this.action == com.wurmonline.server.behaviours.Actions.HARVEST && this.performer.getVehicle() != -10L ? false : $proceed($$);"); } } });
@Override public void edit(MethodCall m) throws CannotCompileException { // com.wurmonline.server.items.Item.setAuxData(byte) if (m.getClassName().equals("com.wurmonline.server.players.Player") && m.getMethodName().equals("isReimbursed")) { m.replace("$_ = christmasmod.hasPlayerReceivedPresent($0);"); } } });
@Override public void edit(MethodCall m) throws CannotCompileException { if ("com.wurmonline.server.items.Item".equals(m.getClassName()) && m.getMethodName().equals("insertItem")) { m.replace("{ dirt.putItemInfrontof(performer); $_ = true; }"); } else if ("com.wurmonline.server.items.Item".equals(m.getClassName()) && m.getMethodName().equals("isDredgingTool")) { m.replace("$_ = $proceed($$) && $0.getTemplateId() != 315 && $0.getTemplateId() != 176;"); } } });
@Override public void edit(MethodCall m) throws CannotCompileException { if (m.getClassName().equals("com.wurmonline.server.creatures.Traits") && m.getMethodName().equals("calcNewTraits") && m.getSignature().equals("(DZJJ)J")) { m.replace("$_ = org.gotti.wurmunlimited.modsupport.creatures.ModCreatures#calcNewTraits($1, $2, this, father);"); } } });
@Override public void edit(MethodCall m) throws CannotCompileException { switch (m.getClassName() + "." + m.getMethodName()) { case "com.wurmonline.server.items.Item.willLeaveServer": String code = ""; code += "int targetId = " + targetServerName + ";"; code += "$_ = (targetId == 0 || modPlayerTransfer.willItemLeaveServer(targetId, $0, $1)) && $proceed($$);"; m.replace("{" + code + "}"); break; } } }
@Override public void edit(MethodCall m) throws CannotCompileException { switch (m.getClassName() + "." + m.getMethodName()) { case "com.wurmonline.server.items.Item.getTemplateId": m.replace("$_ = modPlayerTransfer.getRemoteItemTemplateId($proceed($$));"); break; } } });
@Override public void edit(final MethodCall call) throws CannotCompileException { if (debug) { System.err.println("editing call " + call.getClassName() + "#" + call.getMethodName() + " (wanted " + calledClass + "#" + calledMethodName + ")"); } if (call.getMethodName().equals(calledMethodName) && call.getClassName().equals(calledClass)) { if (onlyNth > 0 && ++counter != onlyNth) return; call.replace(newCode); markEdited(); } }
@Override public void edit(final MethodCall call) throws CannotCompileException { if (debug) { System.err.println("editing call " + call.getClassName() + "#" + call.getMethodName() + " (wanted " + calledClass + "#" + calledMethodName + ")"); } if (call.getMethodName().equals(calledMethodName) && call.getClassName().equals(calledClass)) { if (onlyNth > 0 && ++counter != onlyNth) return; call.replace(newCode); markEdited(); } }
@Override public void edit(final MethodCall m) throws CannotCompileException { final String statement = getStatement(m.getClassName(), m.getMethodName()); if (statement != null) { try { m.replace(statement); } catch (final CannotCompileException e) { throw new CannotCompileException(String.format( "Compile statement '%1$s' FAILED with: %2$s", statement, e.getMessage()), e); } } } });