FlatMMO+ Reminders

Adds reminders to the game

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         FlatMMO+ Reminders
// @namespace    com.dounford.flatmmo.reminder
// @version      0.0.3
// @description  Adds reminders to the game
// @author       Dounford
// @license      MIT
// @match        *://flatmmo.com/play.php*
// @grant        none
// @require      https://update.greatest.deepsurf.us/scripts/544062/FlatMMOPlus.js
// ==/UserScript==
 
(function() {
    'use strict';
	const ding = new Audio("https://github.com/Dounford-Felipe/DHM-Idle-Again/raw/refs/heads/main/ding.wav");
 
    class RemindersPlugin extends FlatMMOPlusPlugin {
        constructor() {
            super("reminders", {
                about: {
                    name: "Reminder",
                    version: "0.0.1",
                    author: "Dounford",
                    description: "Adds reminders to the game"
                },
                config: [
                    {
						id: "pingVolume",
						label: "Ping Volume",
						type: "range",
						min: 0,
						max: 100,
						step: 1,
						default: 100,
					},
                ]
            });
        }
 
        
        onLogin(){
            ding.volume = this.config.pingVolume / 100;

            window.FlatMMOPlus.registerCustomChatCommand("reminder", (command, data='') => {
				if (data === "") {
                    this.showText("You need to specify the duration")
					return;
				}
                let duration;
                let text = "Reminder";
                const space = data.indexOf(" ");
				if (space <= 0) {
					duration = parseInt(data) ;
				} else {
					duration = parseInt(data.substring(0, space));
					text += ": " + data.substring(space + 1);
				}

                this.showText(`Reminder created (${duration} minutes)`);

                setTimeout(()=>{
                    this.showText(text, "orange");
                    ding.play();
                }, duration * 60 * 1000);

			}, `Sets an reminder. Usage: /reminder <minutes> [text (optional)]`);
        }

        onConfigsChanged() {
            ding.volume = this.config.pingVolume / 100;
		}

        showText(text, color = "orange") {
            if("flatChat" in FlatMMOPlus.plugins) {
                FlatMMOPlus.plugins.flatChat.showWarning(text, color);
            } else {
                add_to_chat("", "", "", color, text);
            }
        }
    }
 
    const plugin = new RemindersPlugin();
    FlatMMOPlus.registerPlugin(plugin);
 
})();