Skip to content

Commit

Permalink
progress for melody alert
Browse files Browse the repository at this point in the history
  • Loading branch information
soshimee committed Jun 22, 2024
1 parent 6d33fe4 commit 183d85c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
26 changes: 22 additions & 4 deletions features/melodyAlert/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
import Settings from "../../config";
import packetOpenWindow from "../../events/packetOpenWindow";
import packetSetSlot from "../../events/packetSetSlot";
import closeWindow from "../../events/closeWindow";

function listener(title) {
function openWindowListener(title) {
if (title !== "Click the button on time!") return;
ChatLib.command("party chat " + Settings.melodyAlertMessage);
closeWindow.addListener(closeWindowListener);
packetSetSlot.addListener(setSlotListener);
}

function setSlotListener(itemStack, slot) {
if (itemStack === null) return;
const slots = [16, 25, 34, 43];
const index = slots.indexOf(slot);
if (index === -1) return;
const item = new Item(itemStack);
if (item.getID() !== 159 || item.getMetadata() !== 5) return;
ChatLib.command("party chat " + Settings.melodyAlertMessage + " " + index + "/4");
}

function closeWindowListener() {
closeWindow.removeListener(closeWindowListener);
packetSetSlot.removeListener(setSlotListener);
}

export function enable() {
packetOpenWindow.addListener(listener);
packetOpenWindow.addListener(openWindowListener);
}

export function disable() {
packetOpenWindow.removeListener(listener);
packetOpenWindow.removeListener(openWindowListener);
}

export default { enable, disable };
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "soshimeeaddons",
"description": "F7 on top",
"creator": "soshimee",
"version": "2.5.3",
"version": "2.5.4",
"entry": "index.js",
"requires": ["PromiseV2", "BloomCore", "fparser", "requestV2", "Vigilance", "PogData", "RenderLib"]
}

0 comments on commit 183d85c

Please sign in to comment.