@Override public boolean invoke( MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { MOB target = CMLib.players().getLoadPlayer(CMParms.combine(commands, 0)); if (target == null) target = getTargetAnywhere(mob, commands, givenTarget, false, true, false); if (target == null) return false; final Archon_Record A = (Archon_Record) target.fetchEffect(ID()); if (A != null) { target.delEffect(A); if (target.playerStats() != null) target.playerStats().setLastUpdated(0); mob.tell(L("@x1 will no longer be recorded.", target.Name())); return true; } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; final boolean success = proficiencyCheck(mob, 0, auto); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, CMMsg.MASK_MOVE | CMMsg.TYP_JUSTICE | (auto ? CMMsg.MASK_ALWAYS : 0), L("^F<S-NAME> begin(s) recording <T-NAMESELF>.^?")); CMLib.color().fixSourceFightColor(msg); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); final String filename = "/" + target.Name() + System.currentTimeMillis() + ".log"; final CMFile file = new CMFile(filename, null, CMFile.FLAG_LOGERRORS); if (!file.canWrite()) { if (!CMSecurity.isASysOp(mob) || (CMSecurity.isASysOp(target))) Log.sysOut("Record", mob.Name() + " failed to start recording " + target.name() + "."); } else { if (!CMSecurity.isASysOp(mob) || (CMSecurity.isASysOp(target))) Log.sysOut( "Record", mob.Name() + " started recording " + target.name() + " to /" + filename + "."); final Archon_Record A2 = (Archon_Record) copyOf(); final Session F = (Session) CMClass.getCommon("FakeSession"); F.initializeSession(null, Thread.currentThread().getThreadGroup().getName(), filename); if (target.session() == null) target.setSession(F); A2.sess = F; target.addNonUninvokableEffect(A2); mob.tell(L("Enter RECORD @x1 again to stop recording.", target.Name())); } } } else return beneficialVisualFizzle( mob, target, L("<S-NAME> attempt(s) to hush <T-NAMESELF>, but fail(s).")); return success; }
@Override public boolean execute(MOB mob, List<String> commands, int metaFlags) throws java.io.IOException { final StringBuffer head = new StringBuffer(""); final boolean isArchonLooker = CMSecurity.isASysOp(mob); head.append("^x["); head.append(CMStrings.padRight(L("Class"), 16) + " "); head.append(CMStrings.padRight(L("Race"), 8) + " "); head.append(CMStrings.padRight(L("Lvl"), 4) + " "); if (isArchonLooker) head.append(CMStrings.padRight(L("Last"), 18) + " "); head.append("] Character Name^.^?\n\r"); mob.tell( "^x[" + CMStrings.centerPreserve( L("The Administrators of @x1", CMProps.getVar(CMProps.Str.MUDNAME)), head.length() - 10) + "]^.^?"); final java.util.List<PlayerLibrary.ThinPlayer> allUsers = CMLib.database().getExtendedUserList(); String mask = CMProps.getVar(CMProps.Str.WIZLISTMASK); if (mask.length() == 0) mask = "-ANYCLASS +Archon"; final MaskingLibrary.CompiledZMask compiledMask = CMLib.masking().maskCompile(mask); for (final PlayerLibrary.ThinPlayer U : allUsers) { CharClass C; final MOB player = CMLib.players().getPlayer(U.name()); if (player != null) C = player.charStats().getCurrentClass(); else C = CMClass.getCharClass(U.charClass()); if (C == null) C = CMClass.findCharClass(U.charClass()); if (((player != null) && (CMLib.masking().maskCheck(compiledMask, player, true))) || (CMLib.masking().maskCheck(compiledMask, U))) { head.append("["); if (C != null) head.append(CMStrings.padRight(C.name(), 16) + " "); else head.append(CMStrings.padRight(L("Unknown"), 16) + " "); head.append(CMStrings.padRight(U.race(), 8) + " "); if ((C == null) || (!C.leveless())) head.append(CMStrings.padRight("" + U.level(), 4) + " "); else head.append(CMStrings.padRight(" ", 4) + " "); if (isArchonLooker) head.append(CMStrings.padRight(CMLib.time().date2String(U.last()), 18) + " "); head.append("] " + U.name()); head.append("\n\r"); } } mob.tell(head.toString()); return false; }
public String runMacro(ExternalHTTPRequests httpReq, String parm) { Hashtable parms = parseParms(parm); String journalName = httpReq.getRequestParameter("JOURNAL"); if (journalName == null) return " @break@"; if (CMLib.journals().isArchonJournalName(journalName)) { MOB M = Authenticate.getAuthenticatedMob(httpReq); if ((M == null) || (!CMSecurity.isASysOp(M))) return " @break@"; } String srch = httpReq.getRequestParameter("JOURNALMESSAGESEARCH"); if (srch != null) srch = srch.toLowerCase(); String last = httpReq.getRequestParameter("JOURNALMESSAGE"); int cardinal = CMath.s_int(httpReq.getRequestParameter("JOURNALCARDINAL")); if (parms.containsKey("RESET")) { if (last != null) { httpReq.removeRequestParameter("JOURNALMESSAGE"); httpReq.removeRequestParameter("JOURNALCARDINAL"); } return ""; } MOB M = Authenticate.getAuthenticatedMob(httpReq); cardinal++; JournalsLibrary.JournalEntry entry = null; List<JournalsLibrary.JournalEntry> msgs = JournalInfo.getMessages(httpReq, journalName); while ((entry == null) || (!CMLib.journals().canReadMessage(entry, srch, M, parms.contains("NOPRIV")))) { entry = JournalInfo.getNextEntry(msgs, last); if (entry == null) { httpReq.addRequestParameters("JOURNALMESSAGE", ""); if (parms.containsKey("EMPTYOK")) return "<!--EMPTY-->"; return " @break@"; } last = entry.key; } entry.cardinal = cardinal; httpReq.addRequestParameters("JOURNALCARDINAL", "" + cardinal); httpReq.addRequestParameters("JOURNALMESSAGE", last); return ""; }
@Override public String runMacro(HTTPRequest httpReq, String parm) { final java.util.Map<String, String> parms = parseParms(parm); final String last = httpReq.getUrlParameter("JOURNAL"); if (last == null) return " @break@"; boolean securityOverride = false; if ((Thread.currentThread() instanceof CWThread) && CMath.s_bool(((CWThread) Thread.currentThread()).getConfig().getMiscProp("ADMIN")) && parms.containsKey("ALLFORUMJOURNALS")) securityOverride = true; final MOB M = Authenticate.getAuthenticatedMob(httpReq); if ((!securityOverride) && (CMLib.journals().isArchonJournalName(last)) && ((M == null) || (!CMSecurity.isASysOp(M)))) return " @break@"; final Clan setClan = CMLib.clans().getClan(httpReq.getUrlParameter("CLAN")); final JournalsLibrary.ForumJournal journal = CMLib.journals().getForumJournal(last, setClan); if (journal == null) return " @break@"; final StringBuffer str = new StringBuffer(""); if (parms.containsKey("ISSMTPFORWARD")) { @SuppressWarnings("unchecked") final TreeMap<String, JournalsLibrary.SMTPJournal> set = (TreeMap<String, JournalsLibrary.SMTPJournal>) Resources.getResource("SYSTEM_SMTP_JOURNALS"); final JournalsLibrary.SMTPJournal entry = (set != null) ? set.get(last.toUpperCase().trim()) : null; final String email = ((M != null) && (M.playerStats() != null) && (M.playerStats().getEmail() != null)) ? M.playerStats().getEmail() : ""; str.append( ((entry != null) && (email.length() > 0)) ? Boolean.toString(entry.forward) : "false") .append(", "); } if (parms.containsKey("ISSMTPSUBSCRIBER")) { final Map<String, List<String>> lists = Resources.getCachedMultiLists("mailinglists.txt", true); final List<String> mylist = lists.get(last); str.append( ((mylist != null) && (M != null)) ? Boolean.toString(mylist.contains(M.Name())) : "false") .append(", "); } if (parms.containsKey("SMTPADDRESS")) { @SuppressWarnings("unchecked") final TreeMap<String, JournalsLibrary.SMTPJournal> set = (TreeMap<String, JournalsLibrary.SMTPJournal>) Resources.getResource("SYSTEM_SMTP_JOURNALS"); final JournalsLibrary.SMTPJournal entry = (set != null) ? set.get(last.toUpperCase().trim()) : null; if ((entry != null) && (entry.forward)) { str.append(entry.name.replace(' ', '_') + "@" + CMProps.getVar(CMProps.Str.MUDDOMAIN)) .append(", "); } } if (parms.containsKey("CANADMIN") || parms.containsKey("ISADMIN")) str.append("" + journal.authorizationCheck(M, ForumJournalFlags.ADMIN)).append(", "); if (parms.containsKey("CANPOST")) str.append("" + journal.authorizationCheck(M, ForumJournalFlags.POST)).append(", "); if (parms.containsKey("CANREAD")) str.append("" + journal.authorizationCheck(M, ForumJournalFlags.READ)).append(", "); if (parms.containsKey("CANREPLY")) str.append("" + journal.authorizationCheck(M, ForumJournalFlags.REPLY)).append(", "); if (parms.containsKey("ADMINMASK")) str.append("" + journal.adminMask()).append(", "); if (parms.containsKey("READMASK")) str.append("" + journal.readMask()).append(", "); if (parms.containsKey("POSTMASK")) str.append("" + journal.postMask()).append(", "); if (parms.containsKey("REPLYMASK")) str.append("" + journal.replyMask()).append(", "); if (parms.containsKey("ID")) str.append("" + journal.NAME()).append(", "); if (parms.containsKey("NAME")) str.append("" + journal.NAME()).append(", "); if (parms.containsKey("EXPIRE")) str.append("").append(", "); final JournalsLibrary.JournalSummaryStats stats = CMLib.journals().getJournalStats(journal); if (stats == null) return " @break@"; if (parms.containsKey("POSTS")) str.append("" + stats.posts).append(", "); if (parms.containsKey("THREADS")) str.append("" + stats.threads).append(", "); if (parms.containsKey("SHORTDESC")) str.append("" + stats.shortIntro).append(", "); if (parms.containsKey("LONGDESC")) str.append("" + stats.longIntro).append(", "); if (parms.containsKey("IMAGEPATH")) { if ((stats.imagePath == null) || (stats.imagePath.trim().length() == 0)) str.append(L("images/lilcm.jpg")).append(", "); else str.append("" + stats.threads).append(", "); } String strstr = str.toString(); if (strstr.endsWith(", ")) strstr = strstr.substring(0, strstr.length() - 2); return clearWebMacros(strstr); }
@Override public boolean invoke( MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { final MOB target = super.getTarget(mob, commands, givenTarget); if (target == null) return false; final Race R = target.charStats().getMyRace(); if (R.bodyMask()[Race.BODY_HEAD] <= 0) { mob.tell(L("@x1 has no head!", target.name(mob))); return false; } LegalBehavior B = null; if (mob.location() != null) B = CMLib.law().getLegalBehavior(mob.location()); List<LegalWarrant> warrants = new Vector<LegalWarrant>(); if (B != null) warrants = B.getWarrantsOf(CMLib.law().getLegalObject(mob.location()), target); if ((warrants.size() == 0) && (!CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.ABOVELAW))) { mob.tell(L("You are not allowed to behead @x1 at this time.", target.Name())); return false; } final Item w = mob.fetchWieldedItem(); Weapon ww = null; if ((w == null) || (!(w instanceof Weapon))) { mob.tell(L("You cannot behead without a weapon!")); return false; } ww = (Weapon) w; if ((!auto) && (!CMSecurity.isASysOp(mob))) { if (ww.weaponDamageType() != Weapon.TYPE_SLASHING) { mob.tell(L("You cannot behead with a @x1!", ww.name())); return false; } if (mob.isInCombat() && (mob.rangeToTarget() > 0)) { mob.tell(L("You are too far away to try that!")); return false; } if (!CMLib.flags().isBoundOrHeld(target)) { mob.tell(L("@x1 is not bound and would resist.", target.charStats().HeShe())); return false; } } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; int levelDiff = target.phyStats().level() - (mob.phyStats().level() + (2 * getXLEVELLevel(mob))); if (levelDiff > 0) levelDiff = levelDiff * 3; else levelDiff = 0; final boolean hit = (auto) || CMLib.combat().rollToHit(mob, target); boolean success = proficiencyCheck(mob, 0, auto) && (hit); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, CMMsg.MASK_MALICIOUS | CMMsg.MASK_MOVE | CMMsg.MASK_SOUND | CMMsg.TYP_JUSTICE | (auto ? CMMsg.MASK_ALWAYS : 0), null); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); target.curState().setHitPoints(1); final Ability A2 = target.fetchEffect("Injury"); if (A2 != null) A2.setMiscText(mob.Name() + "/head"); CMLib.combat() .postDamage( mob, target, ww, Integer.MAX_VALUE / 2, CMMsg.MSG_WEAPONATTACK, ww.weaponClassification(), auto ? "" : L( "^F^<FIGHT^><S-NAME> rear(s) back and behead(s) <T-NAME>!^</FIGHT^>^?@x1", CMLib.protocol().msp("decap.wav", 30))); mob.location().recoverRoomStats(); final Item limb = CMClass.getItem("GenLimb"); limb.setName(L("@x1`s head", target.Name())); limb.basePhyStats().setAbility(1); limb.setDisplayText(L("the bloody head of @x1 is sitting here.", target.Name())); limb.setSecretIdentity(target.name() + "`s bloody head."); int material = RawMaterial.RESOURCE_MEAT; for (int r = 0; r < R.myResources().size(); r++) { final Item I = R.myResources().get(r); final int mat = I.material() & RawMaterial.MATERIAL_MASK; if (((mat == RawMaterial.MATERIAL_FLESH)) || (r == R.myResources().size() - 1)) { material = I.material(); break; } } limb.setMaterial(material); limb.basePhyStats().setLevel(1); limb.basePhyStats().setWeight(5); limb.recoverPhyStats(); mob.location().addItem(limb, ItemPossessor.Expire.Player_Drop); for (int i = 0; i < warrants.size(); i++) { final LegalWarrant W = warrants.get(i); W.setCrime("pardoned"); W.setOffenses(0); } } else success = false; if (mob.getVictim() == target) mob.makePeace(true); if (target.getVictim() == mob) target.makePeace(true); } else maliciousFizzle(mob, target, L("<S-NAME> attempt(s) a beheading and fail(s)!")); return success; }