Advertisement
Guest User

Untitled

a guest
May 19th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.92 KB | None | 0 0
  1. package org.jubaroo.mods.requiem;
  2.  
  3. import com.wurmonline.server.NoSuchPlayerException;
  4. import com.wurmonline.server.Players;
  5. import com.wurmonline.server.creatures.Creature;
  6. import com.wurmonline.server.items.Item;
  7. import com.wurmonline.server.players.PlayerInfoFactory;
  8. import org.jubaroo.mods.requiem.creatures.MethodsBestiary;
  9. import org.jubaroo.mods.requiem.items.RequiemItemIds;
  10. import org.jubaroo.mods.requiem.misc.MiscChanges;
  11.  
  12. import java.io.IOException;
  13. import java.util.concurrent.TimeUnit;
  14. import java.util.logging.Level;
  15.  
  16. public class RequiemLogging {
  17.  
  18. public static void logException(String msg, Throwable e) {
  19. if (Requiem.logger != null)
  20. Requiem.logger.log(Level.SEVERE, msg, e);
  21. }
  22.  
  23. public static void logWarning(String msg) {
  24. if (Requiem.logger != null)
  25. Requiem.logger.log(Level.WARNING, msg);
  26. }
  27.  
  28. public static void logInfo(String msg) {
  29. if (Requiem.logger != null)
  30. Requiem.logger.log(Level.INFO, msg);
  31. }
  32.  
  33. public static void debug(String msg) {
  34. if (Constants.debug) {
  35. Requiem.logger.info(msg);
  36. }
  37. }
  38.  
  39. public static void RequiemLoggingMessages() {
  40. // ========================= Logger Messages ==============================
  41. // ============================ Actions ================================
  42. if (Constants.addGmProtect) {
  43. logInfo("Add GM Protect Action: Enabled");
  44. } else {
  45. logInfo("Add GM Protect Action: Disabled");
  46. }
  47. if (Constants.addGmUnprotect) {
  48. logInfo("Add GM Unprotect Action: Enabled");
  49. } else {
  50. logInfo("Add GM Unprotect Action: Disabled");
  51. }
  52. if (Constants.addSpawnGuard) {
  53. logInfo("Add Spawn Guard Action: Enabled");
  54. } else {
  55. logInfo("Add Spawn Guard Action: Disabled");
  56. }
  57. if (Constants.searchDens) {
  58. logInfo("Searching Dens/Lairs Action: Enabled");
  59. } else {
  60. logInfo("Searching Dens/Lairs Action: Disabled");
  61. }
  62. if (Constants.addLabyrinth) {
  63. logInfo("Add Labyrinth Action: Enabled");
  64. } else {
  65. logInfo("Add Labyrinth Action: Disabled");
  66. }
  67. if (Constants.terrainSmoothing) {
  68. logInfo("Automatic Terrain Smoothing Action: Enabled");
  69. } else {
  70. logInfo("Automatic Terrain Smoothing Action: Disabled");
  71. }
  72. // ========================== GM Changes ===========================
  73. if (Constants.gmFullFavor) {
  74. logInfo("GM Full Favor: Enabled");
  75. } else {
  76. logInfo("GM Full Favor: Disabled");
  77. }
  78. if (Constants.gmFullStamina) {
  79. logInfo("GM Full Stamina: Enabled");
  80. } else {
  81. logInfo("GM Full Stamina: Disabled");
  82. }
  83. if (Constants.addCommands) {
  84. logInfo("Add Commands: Enabled");
  85. } else {
  86. logInfo("Add Commands: Disabled");
  87. }
  88. // ========================== Items ===========================
  89. if (Constants.itemHolyBook) {
  90. logInfo("Holy Book: Enabled");
  91. } else {
  92. logInfo("Holy Book: Disabled");
  93. }
  94. logInfo("Holy Book ID: " + RequiemItemIds.HOLY_BOOK_ID);
  95. if (Constants.itemNymphPortal) {
  96. logInfo("NymphPortal: Enabled");
  97. } else {
  98. logInfo("NymphPortal: Disabled");
  99. }
  100. logInfo("Nymph Portal ID: " + RequiemItemIds.PORTAL_NYMPH_ID);
  101. logInfo("Nymph Portal Home ID: " + RequiemItemIds.PORTAL_HOME_NYMPH_ID);
  102. if (Constants.itemDemonPortal) {
  103. logInfo("DemonPortal: Enabled");
  104. } else {
  105. logInfo("DemonPortal: Disabled");
  106. }
  107. logInfo("Demon Portal ID: " + RequiemItemIds.PORTAL_DEMON_ID);
  108. logInfo("Demon Portal Home ID: " + RequiemItemIds.PORTAL_HOME_DEMON_ID);
  109. if (Constants.enableDepots) {
  110. logInfo("Depots: Enabled");
  111. } else {
  112. logInfo("Depots: Disabled");
  113. }
  114. logInfo("Elemental Crystal Creation Damage: " + Constants.itemCrystalCreationDamage);
  115. // ========================== Creatures ===========================
  116. if (Constants.setUnicornIsHorse) {
  117. logInfo("set Unicorn Is Horse: Enabled");
  118. } else {
  119. logInfo("set Unicorn Is Horse: Disabled");
  120. }
  121. if (Constants.animals) {
  122. logInfo("Animals: Enabled");
  123. } else {
  124. logInfo("Animals: Disabled");
  125. }
  126. if (Constants.customMounts) {
  127. logInfo("Custom Mounts: Enabled");
  128. } else {
  129. logInfo("Custom Mounts: Disabled");
  130. }
  131. if (Constants.farmAnimals) {
  132. logInfo("Farm Animals: Enabled");
  133. } else {
  134. logInfo("Farm Animals: Disabled");
  135. }
  136. //if (Misc.isRequiemChristmasStart() | Misc.isRequiemChristmasEnd()()) {
  137. // Requiem.debug("Christmas Mobs And Loot: Enabled");
  138. //} else {
  139. // Requiem.debug("Christmas Mobs And Loot: Disabled");
  140. //}
  141. //if (Misc.isRequiemHalloween()) {
  142. // Requiem.debug("Halloween Mobs And Loot: Enabled");
  143. //} else {
  144. // Requiem.debug("Halloween Mobs And Loot: Disabled");
  145. //}
  146. if (Constants.milkWhales) {
  147. logInfo("Domesticate Whales For Milking: Enabled");
  148. } else {
  149. logInfo("Domesticate Whales For Milking: Disabled");
  150. }
  151. if (Constants.monsters) {
  152. logInfo("Monsters: Enabled");
  153. } else {
  154. logInfo("Monsters: Disabled");
  155. }
  156. if (Constants.npc) {
  157. logInfo("NPCs: Enabled");
  158. } else {
  159. logInfo("NPCs: Disabled");
  160. }
  161. if (Constants.titans) {
  162. logInfo("Titans: Enabled");
  163. } else {
  164. logInfo("Titans: Disabled");
  165. }
  166. if (Constants.uniques) {
  167. logInfo("Uniques: Enabled");
  168. } else {
  169. logInfo("Uniques: Disabled");
  170. }
  171. if (Constants.undead) {
  172. logInfo("Undead: Enabled");
  173. } else {
  174. logInfo("Undead: Disabled");
  175. }
  176. if (Constants.wyverns) {
  177. logInfo("Wyverns: Enabled");
  178. } else {
  179. logInfo("Wyverns: Disabled");
  180. }
  181. // ========================== Halloween ===========================
  182. //if (Constants.halloweenMobs) {
  183. // Requiem.debug("Halloween Mobs: Enabled");
  184. //} else {
  185. // Requiem.debug("Halloween Mobs: Disabled");
  186. //}
  187. // ========================== Christmas ===========================
  188. if (Constants.christmasMobs) {
  189. logInfo("Christmas Mobs: Enabled");
  190. } else {
  191. logInfo("Christmas Mobs: Disabled");
  192. }
  193. // ========================== Spells ===========================
  194. logInfo("No Cooldown On These Spells: " + Constants.noCooldownSpells);
  195. // ========================== Other ===========================
  196. if (Constants.stfuNpcs) {
  197. logInfo("Stfu Npcs: Enabled");
  198. } else {
  199. logInfo("Stfu Npcs: Disabled");
  200. }
  201. if (Constants.loadFullContainers) {
  202. logInfo("Load Full Containers: Enabled");
  203. } else {
  204. logInfo("Load Full Containers: Disabled");
  205. }
  206. if (Constants.noMineDrift) {
  207. logInfo("No Mine Drift: Enabled");
  208. } else {
  209. logInfo("No Mine Drift: Disabled");
  210. }
  211. if (Constants.lampsAutoLight) {
  212. logInfo("Lamps Auto Light: Enabled");
  213. } else {
  214. logInfo("Lamps Auto Light: Disabled");
  215. }
  216. if (Constants.allowTentsOnDeed) {
  217. logInfo("Allow Tents On Deed: Enabled");
  218. } else {
  219. logInfo("Allow Tents On Deed: Disabled");
  220. }
  221. if (Constants.allSurfaceMine) {
  222. logInfo("All Surface Mine: Enabled");
  223. } else {
  224. logInfo("All Surface Mine: Disabled");
  225. }
  226. if (Constants.hidePlayerGodInscriptions) {
  227. logInfo("Hide Player God Inscriptions: Enabled");
  228. } else {
  229. logInfo("Hide Player God Inscriptions: Disabled");
  230. }
  231. // ========================== Mission Items ===========================
  232. if (Constants.addMissionItems) {
  233. logInfo("Add Mission Items: Enabled");
  234. } else {
  235. logInfo("Add Mission Items: Disabled");
  236. }
  237. if (Constants.coins) {
  238. logInfo("Coins: Enabled");
  239. } else {
  240. logInfo("Coins: Disabled");
  241. }
  242. if (Constants.riftItems) {
  243. logInfo("Rift Items: Enabled");
  244. } else {
  245. logInfo("Rift Items: Disabled");
  246. }
  247. if (Constants.miscItems) {
  248. logInfo("Misc Items: Enabled");
  249. } else {
  250. logInfo("Misc Items: Disabled");
  251. }
  252. if (Constants.metalLumps) {
  253. logInfo("Metal Lumps: Enabled");
  254. } else {
  255. logInfo("Metal Lumps: Disabled");
  256. }
  257. if (Constants.metalOres) {
  258. logInfo("Metal Ores: Enabled");
  259. } else {
  260. logInfo("Metal Ores: Disabled");
  261. }
  262. if (Constants.gems) {
  263. logInfo("Gems: Enabled");
  264. } else {
  265. logInfo("Gems: Disabled");
  266. }
  267. if (Constants.potionsSalvesOils) {
  268. logInfo("Potions, Salves, And Oils: Enabled");
  269. } else {
  270. logInfo("Potions, Salves, And Oils: Disabled");
  271. }
  272. if (Constants.mineDoors) {
  273. logInfo("Mine Doors: Enabled");
  274. } else {
  275. logInfo("Mine Doors: Disabled");
  276. }
  277. if (Constants.mirrors) {
  278. logInfo("Mirrors: Enabled");
  279. } else {
  280. logInfo("Mirrors: Disabled");
  281. }
  282. if (Constants.masks) {
  283. logInfo("Masks: Enabled");
  284. } else {
  285. logInfo("Masks: Disabled");
  286. }
  287. if (Constants.magicItems) {
  288. logInfo("Magic Items: Enabled");
  289. } else {
  290. logInfo("Magic Items: Disabled");
  291. }
  292. if (Constants.wands) {
  293. logInfo("Wands: Enabled");
  294. } else {
  295. logInfo("Wands: Disabled");
  296. }
  297. // ====================== Athanor Mechanism =======================
  298. logInfo("delayFogGoblins: " + Constants.delayFogGoblins);
  299. logInfo("delayTradeTents: " + Constants.delayTradeTents);
  300. logInfo("delayResourcePoints: " + Constants.delayResourcePoints);
  301. logInfo("delayLootCarpets: " + Constants.delayLootCarpets);
  302. logInfo("delayMobSpawners: " + Constants.delayMobSpawners);
  303. logInfo("delayAthanorMechanism: " + Constants.delayAthanorMechanism);
  304. // ========================== debugging ===========================
  305. if (Constants.executionCostLogging) {
  306. logInfo("Execution Cost Logging: Enabled");
  307. } else {
  308. logInfo("Execution Cost Logging: Disabled");
  309. }
  310. if (Constants.debug) {
  311. logInfo("Debug: Enabled");
  312. } else {
  313. logInfo("Debug: Disabled");
  314. }
  315. if (Constants.creatureCreateLogging) {
  316. logInfo("New Creature Logging: Enabled");
  317. } else {
  318. logInfo("New Creature Logging: Disabled");
  319. }
  320. if (Constants.creatureDeathLogging) {
  321. logInfo("Creature Death Logging: Enabled");
  322. } else {
  323. logInfo("Creature Death Logging: Disabled");
  324. }
  325. if (Constants.itemCreateLogging) {
  326. logInfo("Item Creation Logging: Enabled");
  327. } else {
  328. logInfo("Item Creation Logging: Disabled");
  329. }
  330. // ========================== disable modules ===========================
  331. if (Constants.disableEntireMod) {
  332. logInfo("Requiem Module: Disabled");
  333. } else {
  334. logInfo("Requiem Module: Enabled");
  335. }
  336. if (Constants.disableCreatureLoot) {
  337. logInfo("Creature Loot Module: Disabled");
  338. } else {
  339. logInfo("Creature Loot Module: Enabled");
  340. }
  341. if (Constants.disableCreatureMods) {
  342. logInfo("Creature Module: Disabled");
  343. } else {
  344. logInfo("Creature Module: Enabled");
  345. }
  346. if (Constants.disableItemMods) {
  347. logInfo("Item Module: Disabled");
  348. } else {
  349. logInfo("Item Module: Enabled");
  350. }
  351. if (Constants.disableVehicleMods) {
  352. logInfo("Vehicle Module: Disabled");
  353. } else {
  354. logInfo("Vehicle Module: Enabled");
  355. }
  356. if (Constants.disableBytcodeMods) {
  357. logInfo("Bytecode Module: Disabled");
  358. } else {
  359. logInfo("Bytecode Module: Enabled");
  360. }
  361. if (Constants.disableMiscMods) {
  362. logInfo("Misc Module: Disabled");
  363. } else {
  364. logInfo("Misc Module: Enabled");
  365. }
  366.  
  367. logInfo(String.format("Newly created mailboxes will%s get %f power Courier enchants.", (!Constants.mailboxEnableEnchant ? " not" : ""), Constants.mailboxEnchantPower));
  368.  
  369. }
  370.  
  371. public static void CreatureSpawnLogging(Creature creature) {
  372. // make a small delay to logging so as to wait until the creature is fully initialized to get all data from it?
  373. int templateId = creature.getTemplate().getTemplateId();
  374. //Item[] allItems;
  375. //Item[] inventoryItems = allItems = creature.getInventory().getAllItems(true);
  376. //for (Item lInventoryItem : allItems) {
  377. // creature.getCommunicator().sendNormalServerMessage(lInventoryItem.getName());
  378. //}
  379. if (templateId != 0) {
  380. try {
  381. TimeUnit.SECONDS.sleep(1);
  382. } catch (InterruptedException e) {
  383. e.printStackTrace();
  384. }
  385. logInfo("----------> Creature Spawned <----------");
  386. logInfo("Name: " + creature.getNameWithoutPrefixes());
  387. logInfo("TemplateId: " + templateId);
  388. logInfo("WID: " + creature.getWurmId());
  389. logInfo("Sex: " + MiscChanges.getSexString(creature.getStatus().getSex()));
  390. logInfo("Condition: " + MethodsBestiary.getTypeString(creature));
  391. logInfo(String.format("Location: X= %s Y= %s", creature.getTileX(), creature.getTileY()));
  392. if (creature.getCurrentVillage() != null) {
  393. logInfo("Deed name: " + creature.getCurrentVillage().getName());
  394. }
  395. logInfo("Zone Id: " + creature.getStatus().getZoneId());
  396. logInfo("Surface?: " + creature.isOnSurface());
  397. logInfo("Age: " + creature.getStatus().age);
  398. logInfo("Age string: " + creature.getStatus().getAgeString());
  399. if (creature.numattackers != 0) {
  400. logInfo("Number of attackers: " + creature.numattackers);
  401. }
  402. logInfo("Is a player?: " + creature.isPlayer());
  403. logInfo("Hunger: " + creature.getStatus().getHunger());
  404. logInfo("Thirst: " + creature.getStatus().getThirst());
  405. logInfo("Fat: " + creature.getStatus().getFats());
  406. //logInfo(String.format("Inventory: ", (Object[]) inventoryItems));
  407. }
  408. logInfo("----------> Creature Spawned <----------");
  409. }
  410.  
  411. public static void CreatureDeathLogging(Creature creature) {
  412. try {
  413. //Item[] allItems;
  414. //Item[] inventoryItems = allItems = creature.getInventory().getAllItems(true);
  415. //for (Item lInventoryItem : allItems) {
  416. // creature.getCommunicator().sendNormalServerMessage(lInventoryItem.getName());
  417. //}
  418. int templateId = creature.getTemplate().getTemplateId();
  419. if (templateId != 0) {
  420. logInfo("----------> Creature Death <----------");
  421. logInfo("Name: " + creature.getNameWithoutPrefixes());
  422. logInfo("TemplateId: " + templateId);
  423. logInfo("WID: " + creature.getWurmId());
  424. logInfo("Sex: " + MiscChanges.getSexString(creature.getStatus().getSex()));
  425. logInfo("Condition: " + MethodsBestiary.getTypeString(creature));
  426. logInfo(String.format("Location: X= %s Y= %s", creature.getTileX(), creature.getTileY()));
  427. if (creature.getCurrentVillage() != null) {
  428. logInfo("Deed name: " + creature.getCurrentVillage().getName());
  429. }
  430. logInfo("Zone Id: " + creature.getStatus().getZoneId());
  431. logInfo("Surface?: " + creature.isOnSurface());
  432. //Requiem.debug("Creature was killed by: " + attackers);
  433. logInfo("Age: " + creature.getStatus().age);
  434. logInfo("Age string: " + creature.getStatus().getAgeString());
  435. logInfo("Number of attackers: " + creature.numattackers);
  436. logInfo("Is a player?: " + creature.isPlayer());
  437. logInfo("Hunger: " + creature.getStatus().getHunger());
  438. logInfo("Thirst: " + creature.getStatus().getThirst());
  439. if (creature.getNumberOfFollowers() != 0) {
  440. logInfo(String.format("Followers: %s", creature.getNumberOfFollowers()));
  441. }
  442. if (creature.getLeader() != null) {
  443. logInfo(String.format("Leader: %s", creature.getLeader().getNameWithoutPrefixes()));
  444. }
  445. if (creature.getDominator() != null) {
  446. logInfo("Dominated by: " + Players.getInstance().getNameFor(creature.dominator));
  447. }
  448. if (creature.getHitched() != null) {
  449. RequiemLogging.logInfo("Hitched Vehicle name: " + creature.getHitched().name);
  450. }
  451. //logInfo(String.format("Inventory: ", (Object[]) inventoryItems));
  452. logInfo("----------> Creature Death <----------");
  453. }
  454. } catch (NoSuchPlayerException | IOException e) {
  455. e.printStackTrace();
  456. }
  457.  
  458. }
  459.  
  460. public static void ItemCreationLogging(Item item) {
  461. // make a small delay to logging so as to wait until the item is fully initialized to get all data from it?
  462. int templateId = item.getTemplate().getTemplateId();
  463. if (templateId != 0) {
  464. logInfo("----------> Item Created <----------");
  465. logInfo(String.format("Name: %s", item.getName()));
  466. logInfo(String.format("TemplateId: %s", templateId));
  467. logInfo(String.format("WID: %s", item.getWurmId()));
  468. if (item.getParentOrNull() != null) {
  469. logInfo(String.format("Parent Name: %s", item.getParentOrNull().getName()));
  470. }
  471. if (item.getTopParentOrNull() != null) {
  472. logInfo(String.format("Top Parent Name: %s", item.getTopParentOrNull().getName()));
  473. }
  474. if (item.isHollow()) {
  475. logInfo(String.format("Container Size: X= %s, Y= %s, Z= %s", item.getContainerSizeX(), item.getContainerSizeY(), item.getContainerSizeZ()));
  476. } else if (item.isBulkContainer()) {
  477. logInfo(String.format("Container Volume: %s", item.getContainerVolume()));
  478. }
  479. logInfo(String.format("Created by: %s", PlayerInfoFactory.getPlayerName(item.lastOwner)));
  480. logInfo(String.format("Coordinates: X= %s Y= %s", item.getTileX(), item.getTileY()));
  481. logInfo(String.format("Raw Coordinates: X= %s Y= %s", item.getPosXRaw(), item.getPosYRaw()));
  482. logInfo(String.format("Quality: %s", item.getCurrentQualityLevel()));
  483. logInfo(String.format("Damage: %s", item.getDamage()));
  484. logInfo(String.format("Weight: %s grams", (int) item.getWeightGrams()));
  485. logInfo(String.format("Rarity: %s", MiscChanges.getRarityString(item.getRarity())));
  486. logInfo(String.format("Data1: %s", item.getData1()));
  487. logInfo(String.format("Data2: %s", item.getData2()));
  488. logInfo(String.format("AuxData: %s", item.getAuxData()));
  489. logInfo(String.format("Extra1: %s", item.getExtra1()));
  490. logInfo(String.format("Extra2: %s", item.getExtra2()));
  491. logInfo("----------> Item Created <----------");
  492. }
  493. }
  494.  
  495. public static void ItemRemovalLogging(Item item) {
  496. int templateId = item.getTemplate().getTemplateId();
  497. if (templateId != 0) {
  498. logInfo("----------> Item Destroyed <----------");
  499. logInfo(String.format("Name: %s", item.getName()));
  500. logInfo(String.format("TemplateId: %s", templateId));
  501. logInfo(String.format("WID: %s", item.getWurmId()));
  502. if (item.getParentOrNull() != null) {
  503. logInfo(String.format("Parent Name: %s", item.getParentOrNull().getName()));
  504. }
  505. if (item.getTopParentOrNull() != null) {
  506. logInfo(String.format("Top Parent Name: %s", item.getTopParentOrNull().getName()));
  507. }
  508. if (item.isHollow()) {
  509. logInfo(String.format("Container Size: X= %s, Y= %s, Z= %s", item.getContainerSizeX(), item.getContainerSizeY(), item.getContainerSizeZ()));
  510. } else if (item.isBulkContainer()) {
  511. logInfo(String.format("Container Volume: %s", item.getContainerVolume()));
  512. }
  513. logInfo(String.format("Created by: %s [%s]", PlayerInfoFactory.getPlayerName(item.lastOwner), item.getOwnerId()));
  514. logInfo(String.format("Coordinates: X= %s Y= %s", item.getTileX(), item.getTileY()));
  515. logInfo(String.format("Quality: %s", item.getCurrentQualityLevel()));
  516. logInfo(String.format("Damage: %s", item.getDamage()));
  517. logInfo(String.format("Weight: %s grams", (int) item.getWeightGrams()));
  518. logInfo(String.format("Rarity: %s", MiscChanges.getRarityString(item.getRarity())));
  519. logInfo(String.format("Data1: %s", item.getData1()));
  520. logInfo(String.format("Data2: %s", item.getData2()));
  521. logInfo(String.format("AuxData: %s", item.getAuxData()));
  522. logInfo(String.format("Extra1: %s", item.getExtra1()));
  523. logInfo(String.format("Extra2: %s", item.getExtra2()));
  524. logInfo("----------> Item Destroyed <----------");
  525. }
  526. }
  527.  
  528. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement