IdlePixel+ Plugin Template

Blank plugin with all IP+ methods, and custom message handling

  1. // ==UserScript==
  2. // @name IdlePixel+ Plugin Template
  3. // @namespace luxferre.dev
  4. // @version 1.2.1
  5. // @description Blank plugin with all IP+ methods, and custom message handling
  6. // @author Lux-Ferre
  7. // @license MIT
  8. // @match *://idle-pixel.com/login/play*
  9. // @grant none
  10. // @require https://greatest.deepsurf.us/scripts/441206-idlepixel/code/IdlePixel+.js?anticache=20220905
  11. // @require https://greatest.deepsurf.us/scripts/484046/code/IdlePixel%2B%20Custom%20Handling.js?anticache=20240721
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. class TemplatePlugin extends IdlePixelPlusPlugin {
  18. constructor() {
  19. super("template", {
  20. about: {
  21. name: GM_info.script.name,
  22. version: GM_info.script.version,
  23. author: GM_info.script.author,
  24. description: GM_info.script.description
  25. },
  26. config: [
  27. {
  28. id: "template",
  29. label: "template",
  30. type: "string",
  31. max: 2000,
  32. default: ""
  33. }
  34. ]
  35. });
  36. this.previous = "";
  37. }
  38.  
  39. onConfigsChanged() { }
  40. onLogin() { }
  41. onMessageReceived(data) { }
  42. onVariableSet(key, valueBefore, valueAfter) { }
  43. onChat(data) { }
  44. onPanelChanged(panelBefore, panelAfter) { }
  45. onCombatStart() { }
  46. onCombatEnd() { }
  47. onCustomMessagePlayerOffline(player, content) { }
  48. onCustomMessageReceived(player, content, callbackId) {
  49. const customData = Customs.parseCustom(player, content, callbackId) // Parses custom data into an object, assumes the Anwinity Standard
  50. if (!(customData.plugin === "--template--" || customData.anwinFormatted)){ // Checks if custom is formatted in the correct way, and from the correct plugin
  51. return
  52. }
  53. if (customData.player === "--template--"){ // Checks if custom is received from the correct player
  54. if (customData.command === "--template--"){ // Runs relevant command code, replace with switch statment if using many commands
  55. console.log(customData.payload)
  56. }
  57. }
  58. }
  59. }
  60.  
  61. const plugin = new TemplatePlugin();
  62. IdlePixelPlus.registerPlugin(plugin);
  63. })();