{"id":18136115,"url":"https://github.com/cupidonsauce173/pignotify","last_synced_at":"2025-04-19T14:38:19.205Z","repository":{"id":46892022,"uuid":"380669539","full_name":"CupidonSauce173/PigNotify","owner":"CupidonSauce173","description":"Multi-Threaded notification system working with MySQL for PocketMine-MP (PMMP)","archived":false,"fork":false,"pushed_at":"2022-01-06T18:22:35.000Z","size":188,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T08:43:37.660Z","etag":null,"topics":["multithreading","mysql","notifications","php","pmmp"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CupidonSauce173.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-27T06:38:44.000Z","updated_at":"2024-11-26T03:03:34.000Z","dependencies_parsed_at":"2022-09-05T02:51:00.004Z","dependency_job_id":null,"html_url":"https://github.com/CupidonSauce173/PigNotify","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CupidonSauce173%2FPigNotify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CupidonSauce173%2FPigNotify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CupidonSauce173%2FPigNotify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CupidonSauce173%2FPigNotify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CupidonSauce173","download_url":"https://codeload.github.com/CupidonSauce173/PigNotify/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249715820,"owners_count":21315058,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["multithreading","mysql","notifications","php","pmmp"],"created_at":"2024-11-01T14:10:54.830Z","updated_at":"2025-04-19T14:38:19.152Z","avatar_url":"https://github.com/CupidonSauce173.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg width=\"150\" height=\"150\" src=\"https://github.com/CupidonSauce173/PigraidNotifications/blob/main/PigNotifIcon.png\" /\u003e\n\u003c/p\u003e\n\u003ch1 align=\"center\"\u003e PigNotify \u003c/h1\u003e\n\u003cp align=\"center\"\u003eJoin my discord: https://discord.gg/2QAPHbqrny \u003c/p\u003e\n\u003cp align=\"center\"\u003eThis is a notification system designed for the now deleted Pigraid Network. \u003c/p\u003e\n\n#### Important Note\n\n- For the users using the version 3.2.0, know that we switched from player username to player uuid. This means that you\n  might have to reset your database. Using uuid is much more secure than player username. Thank you for your\n  understanding.\n\n| **Feature**                 | **State** | \n| --------------------------- |:----------:|\n| MultiThreaded System        | ✔️ |\n| Notification Object         | ✔️ |\n| Simple API                  | ✔️ |\n| Translation System          | ✔️ |\n| Command Customization       | ✔️ |\n| Automated MySQL Constructor | ✔️ |\n\n### Prerequisites\n\n- Working MySQL Server.\n- PocketMine-MP 4.+\n\n### Introduction\n\nThis is a notification system working with MySQL and is multi-threaded. The plugin will fetch notifications from the\nMySQL server, look if they have been displayed and display the notifications to the users. The plugin contains a simple\nAPI if you want to create third-party addons. This is a part of the Pigraid Network System.\n\n### Notification Object\n\nThe notifications have few properties that you can play with. Here's the list:\n\n| **Property** | **DataType** | **Description** |\n| ------------ | :---------- | :------------- |\n| $id          | Int          | Id of the notification. |\n| $displayed   | Boolean      | If the notification has been displayed as message to the player. |\n| $langKey     | String       | The message index from langKeys.ini |\n| $varKeys     | Array        | Array of variables to change in the langKey. |\n| $event       | String       | The event of the notification, like FRIEND_REQUEST |\n| $player      | Player       | Target player (PMMP). |\n\nYou can get and set the properties of the notification whenever you want.\n\n```php\n# Note:\n# NEVER use any -\u003eset{property} AFTER creating a notification. This could lead to weird behavior. Only -\u003esetDisplayed(true);.\n\n# Get / Set id.\n$notification-\u003esetId($id);\n$notification-\u003egetId(); # Returns Int.\n\n# Get / Set Player.\n$notification-\u003esetPlayer($player);\n$notification-\u003egetPlayer(); # Returns string/Uuid\n\n# Get / Set Displayed.\n$notification-\u003esetDisplayed(true|false);\n$notification-\u003ehasBeenDisplayed(); # Returns Boolean.\n\n# Get / Set langKey.\n$notification-\u003esetLangKey($messageIndex);\n$notification-\u003egetLangKey(); # Returns String.\n\n# Get / Set varKeys.\n$notification-\u003esetVarKeys(['target|CupidonSauce173','faction|Foo']);\n$notification-\u003egetVarKeys(); # Returns Array.\n\n# Get / Set Event.\n$notification-\u003esetEvent($event);\n$notification-\u003egetEvent($event); # Returns String.\n```\n\n### Config File\n\nThe configuration file allows you to modify pretty much any aspect of the plugin. You can set the command you want, and\nit's aliases, the permission and if the players needs the permission to use the command. You can also set the delays\nbetween checks from the database \u0026 if a notification has been displayed. Here's the list of settings you're allowed to\nchange from the config file.\n\n```yml\n\n# MySQL's information.\nMySQL:\n  database: notifications\n  host: mysql_host\n  username: mysql_username\n  password: user_password\n  port: 3306\n\n# At how every x times the plugin will check for new notifications for the players (in seconds).\ncheck-database-task: 2\n# At how every x times the plugin will check if the notification has been displayed (if not, displays it to the player) (in seconds).\ncheck-displayed-task: 2\n# Prefix for the messages.\nprefix: \"Notify \u003e \"\n\n# Set to false if you don't want to look if the user has the permission to use this command.\nuse-permission: false\n# Permission to use this command.\npermission: pig.notification.command\n# Message if the player doesn't have the permission.\nno-permission-message: You do not have the necessary permissions!\n# Main command, /notification for example.\ncommand-main: notification\n# Aliases to use this command, /notif or /n for example.\ncommand-aliases:\n  - notif\n  - n\n```\n\n### API\n\nThe plugin offers a small and simple API that you can use along the notifications methods. Here are all the methods from\nthe API.\n\nFirst, you need to register the API.\n\n```php\n\npublic PigNotify $api;\n\npublic function onEnable(){\n   $this-\u003eapi = $this-\u003egetServer()-\u003egetPluginManager()-\u003egetPlugin('PigraidNotifications');\n}\n```\n\nThen, you can use the API like you wish.\n\n```php\n\n# List of methods in the API.\n\n# Will create a new notification.\n$api-\u003ecreateNotification($uuid, $langKey, $event, $varKeys);\n$api-\u003ecreateNotification($uuid, $langKey, $event);\n# Will return a list of notification objects.\n$api-\u003egetPlayerNotifications($xuid);\n# Will delete one notification, must pass a notification object.\n$api-\u003edeleteNotification($notification);\n# Will delete a list of notifications, must pass an array of notification objects.\n$api-\u003edeleteNotifications($notifications);\n# Will return a string of readable text from a messageIndex with / without langKeys.\n$api-\u003egetText($messageIndex, $langKeys);\n$api-\u003egetText($messageIndex); #If the messageIndex doesn't require any changes (ex: %sender%)\n# Will translate a notification using the getText method to a readable message. \n$api-\u003etranslateNotification($notification);\n$api-\u003etranslateNotification($notification, false); #If you don't want the prefix.\n\n# Examples of how to use the API.\n\npublic function onDeath(PlayerDeathEvent $event){\n   $player = $event-\u003egetPlayer();\n   $notifCount = count($this-\u003eapi-\u003egetPlayerNotifications($player));\n   $player-\u003esendMessage(\"Don't forget, you have $notifCount notifications!\");\n}\n\npublic function onFriendRequestCreate(CustomEvent $event){\n   $sender = $event-\u003egetPlayer()-\u003egetName(); #Sender\n   $receiver = $event-\u003egetReceiver()-\u003egetName(); #Target\n   $receiverUuid = $event-\u003egetReceiver()-\u003egetUniqueId()-\u003etoString(); #Target Uuid\n   \n   $this-\u003eapi-\u003ecreateNotification(\n     $receiverUuid, #Target Uuid\n     'friend.request.send', #Index from the langKeys.ini\n     'friendRequestCreation',  #Notification event.\n     [\"target|$receiver\", \"sender|$player\"]); #Variables from the index (friend.request.send).\n}\n```\n\n### How it works?\n\nFirst, when the server first boosts, it will check if it can establish a MySQL connection, if it can't, it will close\nthe server. Otherwise, it will create (if the structure doesn't exist) the database and the table / columns. Then, a\nrepeatingTask will be started to check at every x amount of seconds all the notifications related to the OnlinePlayers.\nIt will exclude all already existing notifications in the server. Another repeatingTask is also ran to loop through all\nthe notifications in the server and see if they have been displayed. If not, it will get the notification to a readable\nmessage (Translation System) and send a message to the target player and finally set the notification as \"displayed\".\nWhen the player disconnects from the server, all the notifications that are related to that player will be destroyed\nwith the deleteNotification($notification) method.\n\n### How to create a notification\n\nTo create a new notification, you will need to call the $api-\u003ecreateNotification(); method. It won't directly show to\nthe player that they received a notification, it will just create a new one in the database and will be waiting to get\ncreated in the server.\n\nBasically:\n\n```\nserver -\u003e API (createNotification) -\u003e Database \u003c- Checknotifications Task -\u003e server -\u003e notificationCheckTask -\u003e API (translateNotification) -\u003e player.\n```\n\n#### langKeys\n\nIn order to create notifications, you need to add keys to the langKeys.ini file. There is already an example in the file\nbut here's another one.\n\nYou want to create notifications for your plugins, this is how you would do it :\n\n```ini\n\n; start plugin section (place your indexes here)\n\n; shop plugin\nshop.item.bought = %buyer% bought your item!\nshop.sale.ended = Your sale for the item : %item% has ended!\nshop.banned = You have been banned from the market during %time% for %reason%!\nshop.unbanned = You have been unbanned from the market!\nshop.new.bid = %player% placed a bid on your item!\nshop.auction.ended = Your auction for the \"%item%\" item ended!\n\n; party plugin\nparty.invitation.received = You received an invitation to join %owner%'s party!\nparty.disband = Your party has been removed!\n\n; friends plugin\nfriend.request.received = You received a friend request from %sender%.\nfriend.request.declined = %receiver% declined your friend request.\nfriend.request.accepted = %receiver% accepted your friend request!\nfriend.gift.received = You received a gift! %gift% from %friend%!\nfriend.purchase.made = You bought a %object%, you can send it to a friend!\n\n; end plugin section\n\n; plugin text (do not delete any index) \n\n; utils text\nform.close.button = §lClose\nmessage.no.notif = You have no notification!\nmessage.no.perm = You do not have the necessary permissions!\nmessage.command.description = Command to see all your notifications.\nform.warn.notif = §rThis notification will be removed when you leave this page.\n; title text\nform.title = Notifications\n; main form text\nform.content.main = Notification system. You can see or delete all your notifications here.\nform.notification.button = §lNotifications\nform.notifications.button = §lNotifications [%count%]\nform.clearAll.button = §lClear all\n; notification list ui\nform.content.list = Your notification list. Click on one for more information.\n```\n\n### Notes\n\n- You don't need to handle the PlayerQuitEvent to destruct the notifications.\n- You don't need to handle the join event to look if there are notifications for the player.\n- it is **NOT** recommended setting a check value smaller than 2 seconds. This could lead to performances issues.\n- Running your MySQL server in the same machine as your server is the best idea.\n- **NEVER** set values in the notifications after they have been created, this could lead to weird behavior.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcupidonsauce173%2Fpignotify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcupidonsauce173%2Fpignotify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcupidonsauce173%2Fpignotify/lists"}