Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21a2f9ef2f |
No files matched your search
@@ -1 +0,0 @@
|
||||
.gitea/CODEOWNERS linguist-detectable=false
|
||||
@@ -1,3 +0,0 @@
|
||||
# Pull requests request review from the eligible staff team(s).
|
||||
# One approval from either an Admin or Developer satisfies branch protection.
|
||||
* @trueog/Admins @trueog/Developers
|
||||
@@ -1,330 +0,0 @@
|
||||
# Maintenance Changelog
|
||||
This file contains update logs for this project. The top may contain a `Unreleased` section, gathering update logs for a future update during development.
|
||||
|
||||
---
|
||||
## 4.3.0 - September 17th 2024
|
||||
### Changed
|
||||
* Added alternative player count and player list hover message for when endtimers are running, similar to the existing ping messages setting. They are disabled by default and can be found in their `player-count-message` and `player-list-hover-message` config sections
|
||||
* All timer commands now accept durations like `2h30m`, `1h30m5s`, or `90s`. The default behavior without units will still be in minutes
|
||||
* The language defaults will *not* automatically update the command help messages
|
||||
* Slightly reorganized the configuration file (it will be automatically migrated on startup, but new sections will be slapped at the bottom of the file)
|
||||
* The `fallback` field now also accepts null values next to an empty array for disabling the feature
|
||||
* Updated language files from [Crowdin](https://crowdin.com/translate/maintenance)
|
||||
|
||||
### Fixed
|
||||
* Fixed the `/maintenance dump` command
|
||||
* Fixed the original player sample not being cleared in Velocity
|
||||
* Velocity: Fixed the console getting broadcasts twice
|
||||
* Velocity: Don't log legacy color codes to the console
|
||||
* Paper: Fixed the player count messages on Paper 1.21
|
||||
---
|
||||
## 4.2.1 - May 17th 2024
|
||||
### Changed
|
||||
* The proxied maintenance status is now also shown for forced hosts (thanks to alec-jensen)
|
||||
* Offline player fetching improvements (thanks to EpicPlayerA10)
|
||||
* Added the setting `fallback-to-offline-uuid` to use offline player uuids in maintenance whitelist commands (defaults to false)
|
||||
* Maintenance now skips the plugin remapping process on 1.20.5+ Paper servers
|
||||
* Small optimizations
|
||||
* Updated language files from [Crowdin](https://crowdin.com/translate/maintenance)
|
||||
* Massive thank you to all the contributors! These include: vortix22, xdalul, CodeZhangBorui, jesusskye, Doc94,
|
||||
Texider_, marvin2k0, leonard.bausenwein, pro.timeo.kerjean, meviper, troev5, Murka124, jhqwqmc, Pryzinho,
|
||||
raysetratyboy, Kolja07, and rikunightcore
|
||||
---
|
||||
## 4.2.0 - September 17th 2023
|
||||
### Changed
|
||||
* Velocity/Bungee: Added `commands-on-single-maintenance-enable` and `commands-on-single-maintenance-disable` config options to define commands to be executed after maintenance has been toggled on a proxied server
|
||||
* Commands inside the `all` list will be executed for any proxied server, but you can also define commands for specific servers by adding arrays with the server names as keys
|
||||
* You can use the placeholder `%SERVER%` in commands to be replaced with the server name
|
||||
* Start-, end-, and schedule timers for proxied servers now also include the server in the feedback message
|
||||
* Updated language files from [Crowdin](https://crowdin.com/translate/maintenance) (including new language files for Danish, Japanese, Korean, and Hungarian)
|
||||
---
|
||||
## 4.1.0 - April 17th 2023
|
||||
### Changed
|
||||
* Added config option `enable-playercounthovermessage` to be able to toggle the player count hover message
|
||||
* Removed platform specific command aliases (e.g. `maintenancevelocity`)
|
||||
* Translations
|
||||
* Moved translation editing to [Crowdin](https://crowdin.com/translate/maintenance)
|
||||
* Added Turkish translation file (thanks to Proomp)
|
||||
* Added Swedish translation file (thanks to Sup33r)
|
||||
* Added Ukrainian translation file (thanks to Mrlucke)
|
||||
* Added Japanese translation file (thanks to yu-solt)
|
||||
* Added bStats metrics to Velocity and Sponge modules
|
||||
|
||||
### Fixed
|
||||
* Fixed disabling the `enable-pingmessages` setting not working on Paper servers
|
||||
* Fixed variable replacement in messages with gradients
|
||||
* Fixed the message for cancelling proxied server timers not replacing the server argument
|
||||
* Setting `enable-pingmessages` to `false` no longer disables custom player and player hover messages
|
||||
---
|
||||
## 4.0.1 - April 17th 2022
|
||||
### Fixed
|
||||
* Fixed the config header sometimes breaking the config on upgrading/saving
|
||||
---
|
||||
## 4.0.0 - March 17th 2022
|
||||
### Changed
|
||||
* Added support for hex colors in messages and replaced the component parsing with adventure-minimessage
|
||||
* This means that section symbols (`§`) are no longer the intended/supported format
|
||||
* You can use the following page to edit and preview formatted text: https://webui.adventure.kyori.net/
|
||||
* You can find full documentation on the format (including normal colors and formatting, rgb, click/hover events, and more) here: https://docs.adventure.kyori.net/minimessage/format
|
||||
* Your config and language file will be updated to the new format automatically, you won't have to change anything manually!
|
||||
* Note that the player count and player count hover messages do not support rgb colors
|
||||
* Updated Sponge module to SpongeAPI v8 (Minecraft 1.15+)
|
||||
* Changed `%NEWLINE%` replacement to `<br>`
|
||||
* Changed `enable-timerspecific-messages` to default to `true` in newly generated config files
|
||||
* Added `prefix` entry in language file to use the placeholder `<prefix>` instead of copy-pasting the actual prefix every time
|
||||
* Added `singleServerMaintenanceListEntry` language string
|
||||
* Added Polish translations (thanks to Slasherss1)
|
||||
* Updated French translations (thanks to Aurelien30000)
|
||||
* Updated Spanish translations (thanks to Jaximo)
|
||||
* If you were using the MaintenanceAddon, you need to update it to [version 1.2.0](https://github.com/kennytv/MaintenanceAddon/releases/tag/1.2.0)
|
||||
### Fixed
|
||||
* Fixed missing language key warning for the scheduletimer command
|
||||
* Fixed typo in `singleServerMaintenanceListEmpty` default language string
|
||||
* Fixed typo in language key `whitelistEmpty` in the German language file (by Ceddix)
|
||||
---
|
||||
## 3.0.7 - August 17th 2021
|
||||
### Changed
|
||||
* Bungee/Velocity: `/maintenance add <name>` now works for offline players as well
|
||||
* Added config options `commands-on-maintenance-enable` and `commands-on-maintenance-disable` to define commands to be executed after maintenance has been toggled
|
||||
* Added config option `enable-pingmessages` to can change whether a custom maintenance motd should be displayed during maintenance
|
||||
* Added language fields `scheduletimerBroadcast` and `singleScheduletimerBroadcast` with the variables `%SERVER%`, `%TIME%`, and `%DURATION%` instead of using the normal starttimer broadcasts
|
||||
### Fixed
|
||||
* Fixed SQL loading issues on some platforms
|
||||
* Fixed missing language key warning for the debug command
|
||||
* Velocity: Fixed the update message
|
||||
---
|
||||
## 3.0.6 - February 17th 2021
|
||||
### Changed
|
||||
* Updated the Velocity version to be compatible with Velocity 1.1.0 (use Maintenance 3.0.5 if you use an older version of Velocity)
|
||||
* Added `maintenance schedule <minutes> <duration> command`
|
||||
* This starts a timer for maintenance to be enabled, after which another timer will be started to disable it again (in contrast to `starttimer` and `endtimer`, which each only do one of)
|
||||
* On proxies, you can use `maintenance schedule [server] <minutes> <duration> command` to schedule maintenance on a proxied server
|
||||
* Added command alias `mt` for the Maintenance command
|
||||
* Added secret argument to the whitelist add command: You can use `maintenance add <uuid> <name>` to add offline entries per command
|
||||
* The maintenance's base command is now properly registered with a permission on each platform, so that it is excluded from tabcomplection to unauthorized players
|
||||
* Some improvements to the French language file (thanks to @Aurelien30000)
|
||||
* API addition: Added MaintenanceReloadedEvent
|
||||
* If you are using the MaintenancePlaceholderAddon, you need to [update it to 1.1.0](https://github.com/KennyTV/MaintenanceAddon/releases)
|
||||
### Fixed
|
||||
* Fixed not setting custom singleserver kickmessages throwing warnings
|
||||
* Bungee: Fixed linebreaks in the playercount hovermessage for 1.16+ clients
|
||||
---
|
||||
## 3.0.5 - June 17th 2020
|
||||
### Changed
|
||||
* The plugin identifiers are now `Maintenance` instead of the previous `MaintenanceSpigot` and `MaintenanceBungee`,
|
||||
and `maintenance` instead of `maintenancesponge` and `maintenancevelocity`
|
||||
* The plugin directory will automatically be renamed accordingly when starting the server
|
||||
* If you are using the MaintenancePlaceholderAddon, you need to [update it to 1.0.3](https://github.com/KennyTV/MaintenanceAddon/releases)
|
||||
* Bungee/Velocity: The `fallback` field can now also be set as a list to define multiple fallback servers
|
||||
* Bungee/Velocity: Added language fields to choose custom kickmessages for individual proxied servers
|
||||
* See [**HERE**](https://github.com/KennyTV/Maintenance/wiki/Configuration#language-file) for an example setting
|
||||
* Added Chinese language file (thanks to Spigot user yeban)
|
||||
* Added Italian language file
|
||||
* Updated Russian language file (thanks to Spigot user En_0t_S)
|
||||
* Removed automated config migration from 2.x->3.0
|
||||
* See [**HERE**](https://github.com/KennyTV/Maintenance/wiki/Updates#updating-from-2x) on how to do that manually - virtually noone should be using such old versions anymore
|
||||
### Fixed
|
||||
* Fixed the `use-ssl` option being inverted
|
||||
* Fixed disabling the playercount-message still hiding online/max players
|
||||
* Fixed config parsing with multi line strings
|
||||
* Bungee: Fixed compatibility with other motd changing plugins using the 'HIGHEST' ping listener priority
|
||||
---
|
||||
## 3.0.4 - March 17th 2020
|
||||
### Changed
|
||||
* Bungee/Velocity: Added config option `waiting-server` to send players to a waiting server when global maintenance is enabled (instead of kicking them)
|
||||
* Bungee/Velocity: Added config option `use-ssl` in the `mysql` section to disable SSL connections
|
||||
* Added Russian language file (thanks to Spigot user En_0t_S)
|
||||
* Updated missing translations in Portuguese language file (thanks to Spigot user JoaoPinto)
|
||||
* Updated bStats metrics
|
||||
### Fixed
|
||||
* Fixed singleserver timers using input as seconds instead of minutes (by mxs42)
|
||||
* Fixed singleserver timers broadcasting globally
|
||||
* Fixed language updating with an unknown/self-translated language file
|
||||
* Fixed Velocity server autocompletion in the maintenance command
|
||||
---
|
||||
## 3.0.3 - September 17th 2019
|
||||
### Changed
|
||||
* Bungee/Velocity: Added `maintenance.singleserver.bypass.<server>` permission to give individual bypasses for proxied servers (`maintenance.bypass` will still bypass everything as the super-perm)
|
||||
* Added the messages of the help command into the language files
|
||||
* Added config option `kick-online-players` to disable the kicks when maintenance is enabled (new connections will still be blocked)... not sure why you'd want that, but you can :p
|
||||
* The language file will now be automatically updated as well, so no need to delete and recreate it anymore, yay!
|
||||
* Updated missing and new translations in French language file (thanks to Spigot user Zendrique)
|
||||
* Updated missing and new translations in Spanish language file (thanks to Spigot user Vixo_Ulises)
|
||||
### Fixed
|
||||
* Bungee/Velocity: Fixed the join-notifications being sent twice if both global and server maintenance are enabled, as well as when just a server has maintenance in some cases
|
||||
* Bungee: Fixed players being kicked *after* the initial connection and thus triggering a join and leave message before being kicked
|
||||
* Bungee: Fixed the kickmessage not being displayed in some cases
|
||||
* Paper: Fixed the playercount message not being displayed on Paper servers with ViaVersion
|
||||
* Paper: Fixed the motd not being changed at all on Paper servers with ProtocolSupport (-> ProtocolLib listener used, since ProtocolSupport does not fire Paper's ping event)
|
||||
* Fixed the config autoupdater when the config contained strings broken over multiple lines
|
||||
---
|
||||
## 3.0.2 - May 17th 2019
|
||||
### Changed
|
||||
* Added config option `timerspecific-pingmessages` to have specific pingmessages shown when endtimers are run
|
||||
* You can also set them ingame by using `/maintenance setmotd timer <index> ...` instead of `/maintenance setmotd <index> ...`, along with `/maintenance removemotd timer <index>` and `/maintenance motd timer`
|
||||
* Made dumps a little prettier
|
||||
* Support Sponge 8.0.0-SNAPSHOT
|
||||
* Support latest text/Velocity (now only supports Velocity builds from May 7th upwards)
|
||||
---
|
||||
## 3.0.1 - April 17th 2019
|
||||
### Changed
|
||||
* Created an addon to have PlaceholderAPI placeholders on Spigot when running the Maintenance plugin on Bungee (see [**here**](https://github.com/KennyTV/Maintenance/wiki/MaintenanceAddon))
|
||||
* Spigot version: If running on Paper 1.12.2 or higher, ProtocolLib will not be needed anymore
|
||||
* The universal jar now only includes Bungee and Spigot (whereas before Sponge and Velocity as well) and has been further minimized in size
|
||||
* To use the plugin on the other platforms, use the `MaintenanceSponge.jar` or `MaintenanceVelocity.jar` respectively
|
||||
* Added config option `continue-endtimer-after-restart` to have endtimers continued, even if the server restarts during its runtime
|
||||
* Added custom eventsystem to the API
|
||||
* Removed bStats metrics from Sponge module
|
||||
### Fixed
|
||||
* Actually fixed compatibility to other plugins using the same MySQL library (such as LuckPerms) in the Bungee version
|
||||
* Fixed an issue with executing the maintenance change with MySQL enabled on connected proxies
|
||||
* Fixed an occasional error on pings of non clients in the Spigot version
|
||||
* Fixed 1.13 clients on sub 1.13 servers not showing the playercountmessage in the Spigot version
|
||||
* Minor fixes/changes to Spanish and Portuguese language files
|
||||
---
|
||||
## 3.0 - February 17th 2019
|
||||
### Changed
|
||||
* This plugin now also supports the platforms Sponge and Velocity!
|
||||
* Added tabcompletion for maintenance commands on all platforms
|
||||
* This plugin now uses a custom config system, which means comments won't vanish after saving them and the different configs have been unified
|
||||
* You can now also add and remove (offline) players to/from the maintenance whitelist by using their uuid (i.e. `/maintenance add <uuid>`)
|
||||
* The %TIMER% variable can now also be used in the playercount-, playercounthover- and kickmessages
|
||||
* To make life easier for people running on Bungee without an extra permission plugin: the `maintenance.admin` permission gives access to all subcommands
|
||||
* Made bug reports a little easier with the new `/maintenance dump` command
|
||||
* Added a config option to disable update checks (not recommended)
|
||||
* Moved `kickmessage` field from config to language file and added its default translations
|
||||
* Changed permissions nodes for the Bungee part (`from: to`):
|
||||
* `maintenance.toggleserver`: `maintenance.singleserver.toggle`
|
||||
* `maintenance.servertimer`: `maintenance.singleserver.timer`
|
||||
* `maintenance.status`: `maintenance.singleserver.status`
|
||||
* The command `/maintenance timer abort` has been renamed to `/maintenance aborttimer`
|
||||
* Added additional aliases: `/maintenance end` for `/maintenance endtimer`, `start` for `starttimer`, `abort` for `aborttimer`
|
||||
* On false command syntax usage, the reply will be the specific help message for that command, not the entire help window as it was before
|
||||
* Improved update checks and updater
|
||||
* Many many other runtime improvements and some major internal refactoring
|
||||
### Fixed
|
||||
* Fixed a startup issue with other plugins using the same MySQL library on Bungee (for example some versions of LuckPerms)
|
||||
* Fixed an error on Bungee when single servers are set to maintenance with no fallbackserver set
|
||||
* Fixed a rare problem with adding and removing players to/from the maintenance whitelist
|
||||
* Fixed an issue with starting server timers while also running a global maintenance timer
|
||||
* Fixed the `/maintenance status` not appearing in the help overview
|
||||
---
|
||||
## 2.5.2 - December 17th 2018
|
||||
### Changed
|
||||
* Added French `fr` (thanks to Zendrique) and Portuguese `pt` (thanks to JoaoPinto) translations!
|
||||
* Improvements to MySQL stuff on the Bungee part
|
||||
* If enabled, single servers (on the Bungee part) that are under maintenance are now saved into the given database as well!
|
||||
### Fixed
|
||||
* Fixed the maintenance value only loading on the first server ping, not on startup
|
||||
* Fixed an error while setting maintenance to single servers, when the executor is something other than a player
|
||||
* Fixed the maintenance-icon not loading on 1.13+ Spigot servers with ProtocolLib
|
||||
* Some other general improvements and a small message fix
|
||||
---
|
||||
## 2.5.1 - November 17th 2018
|
||||
### Fixed
|
||||
* Fixed an occasional file loading error on startup
|
||||
---
|
||||
## 2.5 - November 17th 2018
|
||||
### Changed
|
||||
* Added the possibility on BungeeCord to also enable maintenance on Spigot servers managed by the proxy
|
||||
* `/maintenance <on/off> <servername>` will now set maintenance to a proxied Spigot server
|
||||
* `/maintenance <starttimer/endtimer> <server> <minutes>` works analog to the normal timer commands
|
||||
* `/maintenance status` shows proxied servers that have maintenance enabled
|
||||
* new permissions are `maintenance.toggleserver`, `maintenance.servertimer` and `maintenance.status`
|
||||
* Added a multiple-language-support system! It's currently not that big tho, with the only language added being de/German
|
||||
* If you like this plugin, know French or Spanish (or any other language that isn't yet supported by the plugin) and want to contribute a bit to it, translations of the default language.yml are greatly appreciated!
|
||||
* Note: There will be a new 'language-en.yml' file created, so if you changed any messages before, you have to do it again in the new file
|
||||
* Made the help message a little fancier
|
||||
* Some API changes
|
||||
### Fixed
|
||||
* Fixed a bug with starttimers not being able to start properly
|
||||
---
|
||||
## 2.4 - September 17th 2018
|
||||
### Changed
|
||||
* Edit nearly every message to your hearts content with the now introduced language.yml file!
|
||||
* Added `/maintenance removemotd <index>` command to remove a motd via an ingame command (if you have multiple ones)
|
||||
* You can now include the `%TIMER%` variable into your maintenance motd - **If using the maintenance endtimer**, it will display the time left until maintenance will be disabled!
|
||||
* Simply shows `-` if maintenance is on without any timer
|
||||
* A nice integration could be `&cExpected to come back in: &6%TIMER%`
|
||||
* You can now choose to show the normal playercount during maintenance instead of a custom message by changing the `enable-playercountmessage` value in the config
|
||||
* You can also include the playercount in a custom playercountmessage by using the 2 variables `%ONLINE%` and `%MAX%`
|
||||
* If there's a new update available, the update notification will no longer be sent on every single login, but rather just on the first one after startup
|
||||
* Removing players from the maintenance whitelist now accepts uncapitalized names
|
||||
---
|
||||
## 2.3.1 - August 17th 2018
|
||||
### Changed
|
||||
* When a string in the config is missing, the plugin doesn't cancel the current process and throws an error anymore, but rather gives a soft warning in the console and returns a backup string
|
||||
* If MySQL is enabled, the plugin will only make a database request at least x seconds after the last request, whereas you can define the value in the config under `mysql.update-interval`
|
||||
* Example: If a first player pings the server after startup, the value will be updated -> No update in the next x seconds even if a player pings -> After elapsed, as soon as the next player pings the server again
|
||||
* Especially helpful as well as recommended for servers with many players
|
||||
* Another improvement for MySQL support: After enabling maintenance on one proxy, the other connected ones will then also kick all non permitted players and switch their ServerListPlus state!
|
||||
* The `/maintenance` helppage now only shows the commands the player actually has permission to execute
|
||||
---
|
||||
## 2.3 - July 17th 2018
|
||||
### Changed
|
||||
* Added the possibility to have multiple pingmessages, of which one will be randomly chosen on each ping when maintenance is enabled (you can also just keep it at one)!
|
||||
* Added permissions per subcommand
|
||||
* `maintenance.command` required to use any of the commands
|
||||
* `maintenance.toggle` to use /maintenance <on/off>
|
||||
* `maintenance.reload` to use /maintenance reload
|
||||
* `maintenance.update` to use /maintenance <update/forceupdate>
|
||||
* `maintenance.timer` to use /maintenance <starttimer/endtimer> <minutes>
|
||||
* `maintenance.whitelist.add` to use /maintenance add <player>
|
||||
* `maintenance.whitelist.remove` to use /maintenance remove <player>
|
||||
* `maintenance.whitelist.list` to use /maintenance whitelist
|
||||
* `maintenance.setmotd` to use /maintenance setmotd <index> <1/2> <message>
|
||||
* `maintenance.motd` to use /maintenance motd
|
||||
* Added `/maintenance motd` command to list all set maintenance pingmessages
|
||||
* `/maintenance whitelist` now also shows the UUID connected to each name
|
||||
### Fixed
|
||||
* Reworked/fixed the `/maintenance setmotd` command
|
||||
* Some typo and description fixes
|
||||
---
|
||||
## 2.2.2 - June 17th 2018
|
||||
### Changed
|
||||
* Changed the loading of the maintenance icon to be more predictable: It will load directly on startup and can now be reloaded by using the `/maintenance reload` command as well
|
||||
* Changed the reload message to read the proper reload changes
|
||||
* Removed an obsolete config comment
|
||||
* You can now hook into the plugin with the integrated API
|
||||
---
|
||||
## 2.2.1 - April 17th 2018
|
||||
### Changed
|
||||
* Added `/maintenance setmotd <1/2> <message>` command to edit the maintenance mode motd via a command
|
||||
* The Bungee version of the plugin will now automatically create a MySQL table if it is enabled, so you won't have to manually create one anymore
|
||||
### Fixed
|
||||
* Fixed the ServerListPlus motd only changing on using the command, but not on the server startup
|
||||
* Fixed an error with canceling the start-/endtimer in the Bungee version
|
||||
* Fixed an error with removing players from the whitelist in the Spigot version
|
||||
---
|
||||
## 2.2 - March 17th 2018
|
||||
### Changed
|
||||
* Great update for the Spigot version of the plugin as well as performance improvements and bugfixes in both versions
|
||||
* If you have ProtocolLib installed, you can set a custom server icon while maintenance is enabled, also the playercount-message and the playercount-hover-message are now available (as it has already been in the Bungee version)!
|
||||
* In the BungeeCord version of the plugin, the `/maintenance remove <player>` command now also works for offline players
|
||||
* Removed the plugin's prefix from some messages
|
||||
* General performance improvements
|
||||
### Fixed
|
||||
* The Spigot version should be much more compatible with other motd-changing plugins, such as SexyMotd
|
||||
* Fixed some other issues with the ProtocolLib integration
|
||||
* Minor textfix for the updatemessage in the Spigot version
|
||||
---
|
||||
## 2.1 - February 17th 2018
|
||||
### Changed
|
||||
* Massive code cleanup for both the Bungee and Spigot version of the plugin
|
||||
* Minor performance improvements
|
||||
### Fixed
|
||||
* Fixed start- and endtimers not being cancelled properly
|
||||
* Fixed an error for the update command in the Spigot version
|
||||
* Fixed an error regarding the ServerListPlus integration in the Spigot version
|
||||
---
|
||||
## 2.0 - February 15th 2018
|
||||
### Changed
|
||||
* You can now put the plugin not only inside your Bungee plugins folder, but also your Spigot/Bukkit one! Both will have the same feautures, but simply on their own platform. However, the Spigot version doesn't have MySQL support (as you would normally use BungeeCord for connecting multiple Spigot/Bukkit servers) and you can't use playercount-message, besides this, it has all its main features.
|
||||
* On BungeeCord you can make your own custom messages for the playercount
|
||||
* On Spigot you will see `N/0` (N being the actual count). If you also have ProtocolLib on your server, `0/0` will be displayed.
|
||||
* As many of you asked me: Maintenance now supports the plugin ServerListPlus
|
||||
* Performance improvements
|
||||
### Fixed
|
||||
* Fixed some permission and message bugs
|
||||
* Fixed problems with adding and removing players from the maintenance whitelist
|
||||
* Fixed update checks
|
||||
@@ -1,5 +0,0 @@
|
||||
# Contribution
|
||||
As I'm just a random guy making this plugin as a fun side-project, it will never be "perfect".
|
||||
Any improvement is welcome, as long as it fits with the general style of code, that should become apparent when looking at some of the other classes. :)
|
||||
|
||||
Generally, the used formatting is the default formatting of IntelliJ (Ctrl+Alt+L).
|
||||
@@ -1,14 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Report a bug to have it fixed
|
||||
|
||||
---
|
||||
|
||||
## Bug reproducibility
|
||||
**How does the problem occur/what are the steps to reproduce it?**
|
||||
|
||||
## Error
|
||||
**Is there an error? Save it via https://mclo.gs/ and link paste the link.**
|
||||
|
||||
## Server information
|
||||
**Type '/maintenance dump' and paste the given link here**
|
||||
@@ -1,26 +0,0 @@
|
||||
name: Build
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: gradle/actions/wrapper-validation@v3
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: 17
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Maintenance Files
|
||||
path: build/libs
|
||||
-98
@@ -1,98 +0,0 @@
|
||||
.metadata
|
||||
build/
|
||||
.gradle
|
||||
bin/
|
||||
run/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.settings/
|
||||
.loadpath
|
||||
.recommenders
|
||||
.project
|
||||
.externalToolBuilders/
|
||||
*.launch
|
||||
*.pydevproject
|
||||
.cproject
|
||||
.classpath
|
||||
.factorypath
|
||||
.buildpath
|
||||
.target
|
||||
.tern-project
|
||||
.texlipse
|
||||
.springBeans
|
||||
.recommenders/
|
||||
.cache-main
|
||||
.scala_dependencies
|
||||
.worksheet
|
||||
*.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
Icon
|
||||
._*
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
*.class
|
||||
*.log
|
||||
*.ctxt
|
||||
.mtj.tmp/
|
||||
*.war
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
hs_err_pid*
|
||||
*.iml
|
||||
.idea
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.xml
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/mongoSettings.xml
|
||||
*.iws
|
||||
/out/
|
||||
.idea_modules/
|
||||
atlassian-ide-plugin.xml
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
!/.mvn/wrapper/maven-wrapper.jar
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
Desktop.ini
|
||||
$RECYCLE.BIN/
|
||||
*.cab
|
||||
*.msi
|
||||
*.msm
|
||||
*.msp
|
||||
*.lnk
|
||||
!MaintenanceAPI.jar
|
||||
**/src/test/resources/
|
||||
!core/src/test/resources/dirty-config.yml
|
||||
@@ -1,7 +1,7 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
@@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found.
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
@@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
@@ -1,39 +0,0 @@
|
||||
# Maintenance
|
||||
[](https://github.com/kennytv/Maintenance/releases)
|
||||

|
||||
[](https://crowdin.com/project/maintenance)
|
||||
[](https://discord.gg/vGCUzHq)
|
||||
|
||||
Maintenance is the most customizable free maintenance plugin for your Minecraft server you can find. It runs on Paper (also Spigot, but with limited functionality), BungeeCord, Sponge, as well as Velocity.
|
||||
|
||||
Its features include:
|
||||
* A custom motd as well as server icon, that will be shown during maintenance
|
||||
* Start- and endtimers, which will enable/disable maintenance mode after the time is up
|
||||
* A '%TIMER%' variable usable in the pingmessage, to show the time until a running endtimer finishes (other variables and tricks are explained in the configuration file's comments)
|
||||
* A maintenance whitelist, to grant specific players the ability to join while you're working on your server
|
||||
* Nearly all messages are editable via the language file, given in a multitude of different languages
|
||||
* Features specifically for Bungee/Velocity
|
||||
* Only want to enable maintenance on a single server? You can also do so by using the `/maintenance <on/off> <servername>` command
|
||||
* Link multiple proxy instances through a MySQL database connection, so you don't have to change maintenance on each proxy by hand
|
||||
* Use PlaceholderAPI placeholders with the [**MaintenanceAddon**](https://hangar.papermc.io/kennytv/MaintenanceAddon) (for Velocity and Bungee)
|
||||
|
||||
A full list of commands, permissions and configuration options can be found in the wiki listed below.
|
||||
* [Hangar Downloads](https://hangar.papermc.io/kennytv/Maintenance)
|
||||
* [Wiki](https://github.com/kennytv/Maintenance/wiki) (configuration, permissions, API usage)
|
||||
* [Changelogs](https://github.com/kennytv/Maintenance/blob/master/.github/CHANGELOG.md)
|
||||
* [Issue tracker/bug reports](https://github.com/kennytv/Maintenance/issues)
|
||||
* [Discord](https://discord.gg/vGCUzHq)
|
||||
* [PlaceholderAPI addon](https://hangar.papermc.io/kennytv/MaintenanceAddon)
|
||||
|
||||
|
||||
## Localization
|
||||
The English base language file is localized using Crodwin. You can see and update translations here: https://crowdin.com/project/maintenance
|
||||
|
||||
Join [our Discord](https://discord.gg/vGCUzHq) if you want to get the proofreader or translator role on the project.
|
||||
Adding translations for languages not yet listed is always appreciated as well!
|
||||
|
||||
## Compiling
|
||||
To create a working jar yourself, simply clone the project and compile it with Gradle (`gradlew build`).
|
||||
|
||||
## License
|
||||
This project is licensed under the [GNU General Public License v3](LICENSE.txt).
|
||||
@@ -1,24 +0,0 @@
|
||||
plugins {
|
||||
id("com.gradleup.shadow")
|
||||
}
|
||||
|
||||
// Shade and relocate adventure in an extra module, so that common/the rest can directly depend on a
|
||||
// relocated adventure without breaking native platform's adventure usage with project wide relocation
|
||||
tasks {
|
||||
shadowJar {
|
||||
relocate("net.kyori", "eu.kennytv.maintenance.lib.kyori")
|
||||
}
|
||||
build {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(libs.bundles.adventure) {
|
||||
exclude("net.kyori", "adventure-api")
|
||||
exclude("net.kyori", "adventure-bom")
|
||||
exclude("com.google.code.gson", "gson")
|
||||
}
|
||||
}
|
||||
|
||||
publishShadowJar()
|
||||
@@ -1,20 +0,0 @@
|
||||
plugins {
|
||||
id("com.gradleup.shadow")
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
relocate("net.kyori", "eu.kennytv.maintenance.lib.kyori")
|
||||
}
|
||||
build {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(libs.adventurePlatformBukkit) {
|
||||
exclude("net.kyori", "adventure-api")
|
||||
}
|
||||
}
|
||||
|
||||
publishShadowJar()
|
||||
@@ -1,20 +0,0 @@
|
||||
plugins {
|
||||
id("com.gradleup.shadow")
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
relocate("net.kyori", "eu.kennytv.maintenance.lib.kyori")
|
||||
}
|
||||
build {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(libs.adventurePlatformBungee) {
|
||||
exclude("net.kyori", "adventure-api")
|
||||
}
|
||||
}
|
||||
|
||||
publishShadowJar()
|
||||
@@ -1,14 +0,0 @@
|
||||
plugins {
|
||||
id("maintenance.shadow-conventions")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(projects.maintenanceApi)
|
||||
compileOnly(projects.adventure.adventureApi) {
|
||||
targetConfiguration = "shadow"
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
withJavadocJar()
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.api.event.proxy;
|
||||
|
||||
import eu.kennytv.maintenance.api.event.manager.MaintenanceEvent;
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
|
||||
/**
|
||||
* Notification event fired when maintenance mode has been changed on a proxied server.
|
||||
*/
|
||||
public final class ServerMaintenanceChangedEvent implements MaintenanceEvent {
|
||||
private final Server server;
|
||||
private final boolean maintenance;
|
||||
|
||||
public ServerMaintenanceChangedEvent(final Server server, final boolean maintenance) {
|
||||
this.server = server;
|
||||
this.maintenance = maintenance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns wrapped server object for the server.
|
||||
* <br>
|
||||
* This does not necessarily have to be an existing server:
|
||||
* If maintenance is disabled on a *previously* registered server, see {@link Server#isRegisteredServer()}.
|
||||
*
|
||||
* @return wrapped server object for the server
|
||||
*/
|
||||
public Server getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if maintenance has been enabled on the server, false otherwise
|
||||
*/
|
||||
public boolean isMaintenance() {
|
||||
return maintenance;
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.api.proxy;
|
||||
|
||||
import eu.kennytv.maintenance.api.Maintenance;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface MaintenanceProxy extends Maintenance {
|
||||
|
||||
/**
|
||||
* Enables/disables maintenance mode on a proxied server.
|
||||
* If enabled, all non-permitted players will be kicked.
|
||||
* If MySQL is enabled, it will also be written into the database.
|
||||
*
|
||||
* @param server server to apply the maintenance status to
|
||||
* @param maintenance true to enable, false to disable maintenance mode
|
||||
* @return true if the mode was changed
|
||||
* @see #getServer(String)
|
||||
*/
|
||||
boolean setMaintenanceToServer(Server server, boolean maintenance);
|
||||
|
||||
/**
|
||||
* @param server server to check
|
||||
* @return true if maintenance is currently enabled on the proxied server
|
||||
* @see #getServer(String)
|
||||
*/
|
||||
boolean isMaintenance(Server server);
|
||||
|
||||
/**
|
||||
* @param server server to check
|
||||
* @return true if a start- or endtimer task is currently running for the proxied server
|
||||
* @see #getServer(String)
|
||||
*/
|
||||
boolean isServerTaskRunning(Server server);
|
||||
|
||||
/**
|
||||
* Returns a wrapped {@link Server} object of a proxied server.
|
||||
*
|
||||
* @param server name of the proxied server
|
||||
* @return wrapped server object if present, else null
|
||||
*/
|
||||
@Nullable
|
||||
Server getServer(String server);
|
||||
|
||||
/**
|
||||
* Returns the currently registered proxied servers.
|
||||
*
|
||||
* @return set of proxied servers
|
||||
*/
|
||||
Set<String> getServers();
|
||||
|
||||
/**
|
||||
* @return immutable set with names of all proxied server that are currently under maintenance
|
||||
*/
|
||||
Set<String> getMaintenanceServers();
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.api.proxy;
|
||||
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.Component;
|
||||
|
||||
/**
|
||||
* Wrapper for a proxied server.
|
||||
* Use {@link MaintenanceProxy#getServer(String)} to get a server instance.
|
||||
*/
|
||||
public interface Server {
|
||||
|
||||
/**
|
||||
* @return name of the server
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* @return true if there are players on the server
|
||||
*/
|
||||
boolean hasPlayers();
|
||||
|
||||
/**
|
||||
* Sends a message to all players on the server.
|
||||
*
|
||||
* @param component message to be broadcasted
|
||||
*/
|
||||
void broadcast(Component component);
|
||||
|
||||
/**
|
||||
* Returns whether the server is registered under the proxy.
|
||||
* This will only ever be false if maintenance is disabled on a *previously* registered server.
|
||||
*
|
||||
* @return whether the server is registered under the proxy
|
||||
*/
|
||||
boolean isRegisteredServer();
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
plugins {
|
||||
id("maintenance.shadow-conventions")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(libs.jetbrainsAnnotations)
|
||||
}
|
||||
|
||||
java {
|
||||
withJavadocJar()
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.api;
|
||||
|
||||
import eu.kennytv.maintenance.api.event.manager.EventManager;
|
||||
|
||||
public interface Maintenance {
|
||||
|
||||
/**
|
||||
* Enables/disables maintenance mode.
|
||||
* If enabled, all non-permitted players will be kicked.
|
||||
* <p>
|
||||
* If using the BungeeCord version and MySQL is enabled,
|
||||
* it will also be written into the database.
|
||||
* </p>
|
||||
*
|
||||
* @param maintenance true to enable, false to disable maintenance mode
|
||||
*/
|
||||
void setMaintenance(boolean maintenance);
|
||||
|
||||
/**
|
||||
* @return true if maintenance is currently enabled
|
||||
*/
|
||||
boolean isMaintenance();
|
||||
|
||||
/**
|
||||
* @return true if a start- or endtimer task is currently running
|
||||
*/
|
||||
boolean isTaskRunning();
|
||||
|
||||
/**
|
||||
* @return version of the plugin
|
||||
*/
|
||||
String getVersion();
|
||||
|
||||
/**
|
||||
* Returns the {@link Settings} instance, which gives further insight into settings set in the config files.
|
||||
*
|
||||
* @return {@link Settings} instance
|
||||
*/
|
||||
Settings getSettings();
|
||||
|
||||
/**
|
||||
* Returns the {@link EventManager} instance to register listeners to maintenance events.
|
||||
*
|
||||
* @return {@link EventManager} instance
|
||||
*/
|
||||
EventManager getEventManager();
|
||||
|
||||
/**
|
||||
* @return true if debug mode is enabled, currently only implemented on Bungee
|
||||
*/
|
||||
boolean isDebug();
|
||||
|
||||
/**
|
||||
* Sets the debug mode.
|
||||
*
|
||||
* @param debug debug state
|
||||
*/
|
||||
void setDebug(boolean debug);
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.api;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Provider to get the maintenance api instance.
|
||||
*/
|
||||
public final class MaintenanceProvider {
|
||||
private static Maintenance maintenance;
|
||||
|
||||
private MaintenanceProvider() {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static void setMaintenance(final Maintenance maintenance) {
|
||||
if (MaintenanceProvider.maintenance != null) {
|
||||
throw new IllegalArgumentException("MaintenanceProvider is already set!");
|
||||
}
|
||||
MaintenanceProvider.maintenance = maintenance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maintenance api instance, or null if not loaded yet.
|
||||
*
|
||||
* @return maintenance api instance
|
||||
*/
|
||||
public static @Nullable Maintenance get() {
|
||||
return maintenance;
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.api;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface Settings {
|
||||
|
||||
/**
|
||||
* Note that the value might need a few seconds to update, if you're on BungeeCord with MySQL enabled
|
||||
*
|
||||
* @return true if maintenance is currently enabled
|
||||
*/
|
||||
boolean isMaintenance();
|
||||
|
||||
/**
|
||||
* @return true if custom ping messages during maintenance should be used
|
||||
*/
|
||||
boolean isEnablePingMessages();
|
||||
|
||||
/**
|
||||
* @return value of the 'send-join-notification' config field
|
||||
*/
|
||||
boolean isJoinNotifications();
|
||||
|
||||
/**
|
||||
* @return value of the 'custom-maintenance-icon' config field
|
||||
*/
|
||||
boolean hasCustomIcon();
|
||||
|
||||
/**
|
||||
* Returns a map of the currently maintenance-whitelisted players as their uuid mapped to their saved name.
|
||||
* Note that the names might be incorrect/outdated.
|
||||
*
|
||||
* @return map of uuids of whitelisted players with their given names
|
||||
*/
|
||||
Map<UUID, String> getWhitelistedPlayers();
|
||||
|
||||
/**
|
||||
* Returns whether the uuid is whitelisted.
|
||||
*
|
||||
* @param uuid uuid of the player to check
|
||||
* @return true if the uuid is whitelisted
|
||||
*/
|
||||
boolean isWhitelisted(UUID uuid);
|
||||
|
||||
/**
|
||||
* Removes a player from the maintenance whitelist.
|
||||
*
|
||||
* @param uuid uuid of the player to remove
|
||||
* @return true if removing the player was successful
|
||||
*/
|
||||
boolean removeWhitelistedPlayer(UUID uuid);
|
||||
|
||||
/**
|
||||
* Removes a player from the maintenance whitelist.
|
||||
*
|
||||
* @param name name of the player to remove with original lower-/uppercase letters
|
||||
* @return true if removing the player was successful
|
||||
* @deprecated if a player changes their name, the list will still contain the old one
|
||||
* @see #removeWhitelistedPlayer(UUID)
|
||||
*/
|
||||
@Deprecated
|
||||
boolean removeWhitelistedPlayer(String name);
|
||||
|
||||
/**
|
||||
* Adds a player to the maintenance whitelist.
|
||||
*
|
||||
* @param uuid uuid of the player to add
|
||||
* @param name of the player to add
|
||||
* @return true if adding the player was successful, false if already on the whitelist
|
||||
*/
|
||||
boolean addWhitelistedPlayer(UUID uuid, String name);
|
||||
|
||||
/**
|
||||
* Reloads maintenance-icon, config, language file and WhitelistedPlayers.
|
||||
*/
|
||||
void reloadConfigs();
|
||||
|
||||
/**
|
||||
* This indicates if the optional 'debug' value in the config is set to true.
|
||||
*
|
||||
* @return true if debug is enabled
|
||||
*/
|
||||
boolean debugEnabled();
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.api.event;
|
||||
|
||||
import eu.kennytv.maintenance.api.event.manager.MaintenanceEvent;
|
||||
|
||||
/**
|
||||
* Notification event fired when maintenance mode has been changed.
|
||||
*/
|
||||
public final class MaintenanceChangedEvent implements MaintenanceEvent {
|
||||
private final boolean maintenance;
|
||||
|
||||
public MaintenanceChangedEvent(final boolean maintenance) {
|
||||
this.maintenance = maintenance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if maintenance has been enabled, false otherwise
|
||||
*/
|
||||
public boolean isMaintenance() {
|
||||
return maintenance;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.api.event;
|
||||
|
||||
import eu.kennytv.maintenance.api.Maintenance;
|
||||
import eu.kennytv.maintenance.api.event.manager.MaintenanceEvent;
|
||||
|
||||
/**
|
||||
* Notification event fired when Maintenance configuration is reloaded.
|
||||
*
|
||||
* @author kennytv
|
||||
* @see Maintenance#isMaintenance() for the new maintenance status
|
||||
* //@see MaintenanceProxy#getMaintenanceServers() for the new list of servers under maintenance
|
||||
*/
|
||||
public final class MaintenanceReloadedEvent implements MaintenanceEvent {
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.api.event.manager;
|
||||
|
||||
/**
|
||||
* Abstract class representing a maintenance eventlistener.
|
||||
*
|
||||
* @param <T> event to be listened to
|
||||
*/
|
||||
public abstract class EventListener<T extends MaintenanceEvent> {
|
||||
|
||||
/**
|
||||
* This method is to be overwritten and is called on the given event.
|
||||
*
|
||||
* @param event fired event
|
||||
*/
|
||||
public abstract void onEvent(final T event);
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.api.event.manager;
|
||||
|
||||
public interface EventManager {
|
||||
|
||||
/**
|
||||
* Registers an eventlistener for the given maintenance event.
|
||||
*
|
||||
* @param listener listener to register
|
||||
* @param eventClass class of the event that should be registered
|
||||
*/
|
||||
void registerListener(EventListener listener, Class<? extends MaintenanceEvent> eventClass);
|
||||
|
||||
/**
|
||||
* Fires a maintenance event.
|
||||
*
|
||||
* @param event event to fire
|
||||
*/
|
||||
void callEvent(MaintenanceEvent event);
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.api.event.manager;
|
||||
|
||||
/**
|
||||
* Dummy interface representing a maintenance event.
|
||||
*/
|
||||
public interface MaintenanceEvent {
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// version must be manually kept in sync with the one in root project settings.gradle.kts
|
||||
implementation("com.gradleup.shadow", "shadow-gradle-plugin", "8.3.9")
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.JavaPluginExtension
|
||||
import org.gradle.api.publish.PublishingExtension
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.gradle.jvm.toolchain.JavaLanguageVersion
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.get
|
||||
import org.gradle.kotlin.dsl.named
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
fun Project.publishShadowJar() {
|
||||
configurePublication {
|
||||
artifact(tasks["shadowJar"])
|
||||
artifact(tasks["sourcesJar"])
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.publishJavaComponents() {
|
||||
configurePublication {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
|
||||
private fun Project.configurePublication(configurer: MavenPublication.() -> Unit) {
|
||||
extensions.configure<PublishingExtension> {
|
||||
publications.named<MavenPublication>("mavenJava") {
|
||||
apply(configurer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.latestCommitHash(): String {
|
||||
return providers.exec {
|
||||
commandLine = listOf("git", "rev-parse", "--short", "HEAD")
|
||||
}.standardOutput.asBytes.get().toString(Charsets.UTF_8).trim()
|
||||
}
|
||||
|
||||
fun JavaPluginExtension.javaTarget(version: Int) {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
signing
|
||||
}
|
||||
|
||||
tasks {
|
||||
// Variable replacements
|
||||
processResources {
|
||||
val ver = project.version.toString()
|
||||
val desc = project.description
|
||||
filesMatching(listOf("plugin.yml", "bungee.yml", "META-INF/sponge_plugins.json")) {
|
||||
expand("version" to ver, "description" to desc)
|
||||
}
|
||||
}
|
||||
javadoc {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
(options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet")
|
||||
}
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.compilerArgs.addAll(listOf("-nowarn", "-Xlint:-unchecked", "-Xlint:-deprecation"))
|
||||
}
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
javaTarget(8)
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
signing {
|
||||
useGpgCmd()
|
||||
sign(publishing.publications)
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications.create<MavenPublication>("mavenJava") {
|
||||
groupId = rootProject.group as String
|
||||
artifactId = project.name
|
||||
version = rootProject.version as String
|
||||
pom {
|
||||
name.set("Maintenance")
|
||||
description.set("Paper plugin to enable maintenance mode on your Minecraft server.")
|
||||
url.set("https://github.com/kennytv/Maintenance")
|
||||
licenses {
|
||||
license {
|
||||
name.set("GNU GPLv3")
|
||||
url.set("https://www.gnu.org/licenses/gpl-3.0.html")
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id.set("kennytv")
|
||||
name.set("Nassim Jahnke")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!name.startsWith("adventure")) {
|
||||
repositories.maven {
|
||||
name = "OSSRH"
|
||||
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
|
||||
credentials {
|
||||
username = System.getenv("OSSRH_USERNAME")
|
||||
password = System.getenv("OSSRH_PASSWORD")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -1,12 +0,0 @@
|
||||
import java.util.*
|
||||
|
||||
plugins {
|
||||
id("maintenance.shadow-conventions")
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
archiveFileName.set("Maintenance-${project.name.substringAfter("maintenance-").replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}-${project.version}.jar")
|
||||
destinationDirectory.set(rootProject.layout.buildDirectory.dir("libs"))
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import org.gradle.kotlin.dsl.named
|
||||
|
||||
plugins {
|
||||
id("maintenance.base-conventions")
|
||||
id("com.gradleup.shadow")
|
||||
}
|
||||
|
||||
tasks {
|
||||
named<Jar>("jar") {
|
||||
archiveClassifier.set("unshaded")
|
||||
from(project.rootProject.file("LICENSE.txt"))
|
||||
}
|
||||
val shadowJar = named<ShadowJar>("shadowJar") {
|
||||
archiveClassifier.set("")
|
||||
configureRelocations()
|
||||
}
|
||||
named("build") {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
}
|
||||
|
||||
publishShadowJar()
|
||||
|
||||
fun ShadowJar.configureRelocations() {
|
||||
relocate("com.zaxxer.hikari", "eu.kennytv.maintenance.lib.hikari")
|
||||
relocate("org.bstats", "eu.kennytv.maintenance.lib.bstats")
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
plugins {
|
||||
id("maintenance.base-conventions")
|
||||
}
|
||||
|
||||
publishJavaComponents()
|
||||
@@ -1,41 +0,0 @@
|
||||
import org.gradle.api.plugins.JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME
|
||||
|
||||
plugins {
|
||||
base
|
||||
id("eclipse")
|
||||
id("maintenance.build-logic")
|
||||
}
|
||||
|
||||
allprojects {
|
||||
group = "eu.kennytv.maintenance"
|
||||
version = property("projectVersion") as String // from gradle.properties
|
||||
description = "Enable maintenance mode with a custom maintenance motd and icon."
|
||||
}
|
||||
|
||||
val platforms = setOf(
|
||||
projects.maintenancePaper,
|
||||
projects.maintenanceSponge,
|
||||
projects.maintenanceVelocity
|
||||
).map { it.path }
|
||||
|
||||
val special = setOf(
|
||||
projects.maintenance,
|
||||
projects.maintenanceApi,
|
||||
projects.maintenanceApiProxy,
|
||||
projects.adventure,
|
||||
projects.adventure.adventureApi,
|
||||
projects.adventure.adventurePlatformBukkit,
|
||||
).map { it.path }
|
||||
|
||||
subprojects {
|
||||
when (path) {
|
||||
in platforms -> plugins.apply("maintenance.platform-conventions")
|
||||
in special -> plugins.apply("maintenance.base-conventions")
|
||||
else -> plugins.apply("maintenance.standard-conventions")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
TEST_IMPLEMENTATION_CONFIGURATION_NAME(rootProject.libs.bundles.junit)
|
||||
TEST_IMPLEMENTATION_CONFIGURATION_NAME(rootProject.libs.snakeyaml)
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
dependencies {
|
||||
api(projects.maintenanceApiProxy)
|
||||
api(projects.maintenanceCore)
|
||||
implementation(libs.hikariCP)
|
||||
compileOnly(libs.luckperms)
|
||||
compileOnly(libs.guava)
|
||||
compileOnly(libs.gson)
|
||||
}
|
||||
|
||||
java {
|
||||
withJavadocJar()
|
||||
}
|
||||
-282
@@ -1,282 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.proxy;
|
||||
|
||||
import com.google.common.io.CharStreams;
|
||||
import com.google.gson.JsonObject;
|
||||
import eu.kennytv.maintenance.api.event.proxy.ServerMaintenanceChangedEvent;
|
||||
import eu.kennytv.maintenance.api.proxy.MaintenanceProxy;
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.proxy.command.MaintenanceProxyCommand;
|
||||
import eu.kennytv.maintenance.core.proxy.runnable.SingleMaintenanceRunnable;
|
||||
import eu.kennytv.maintenance.core.proxy.runnable.SingleMaintenanceScheduleRunnable;
|
||||
import eu.kennytv.maintenance.core.proxy.util.ProfileLookup;
|
||||
import eu.kennytv.maintenance.core.runnable.MaintenanceRunnableBase;
|
||||
import eu.kennytv.maintenance.core.util.RateLimitedException;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import eu.kennytv.maintenance.core.util.ServerType;
|
||||
import eu.kennytv.maintenance.core.util.Task;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.jetbrains.annotations.Blocking;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author kennytv
|
||||
* @since 3.0
|
||||
*/
|
||||
public abstract class MaintenanceProxyPlugin extends MaintenancePlugin implements MaintenanceProxy {
|
||||
private final Map<String, Task> serverTasks = new HashMap<>();
|
||||
protected SettingsProxy settingsProxy;
|
||||
|
||||
protected MaintenanceProxyPlugin(final String version, final ServerType serverType) {
|
||||
super(version, serverType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
super.disable();
|
||||
if (settingsProxy.getMySQL() != null) {
|
||||
settingsProxy.getMySQL().close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaintenance(final boolean maintenance) {
|
||||
if (settingsProxy.hasMySQL()) {
|
||||
settingsProxy.setMaintenanceToSQL(maintenance);
|
||||
}
|
||||
super.setMaintenance(maintenance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMaintenance(final Server server) {
|
||||
return settingsProxy.isMaintenance(server.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setMaintenanceToServer(final Server server, final boolean maintenance) {
|
||||
if (maintenance) {
|
||||
if (!settingsProxy.addMaintenanceServer(server.getName())) {
|
||||
return false;
|
||||
}
|
||||
} else if (!settingsProxy.removeMaintenanceServer(server.getName())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
serverActions(server, maintenance);
|
||||
|
||||
for (final String command : (maintenance ? settingsProxy.getCommandsOnMaintenanceEnable(server) : settingsProxy.getCommandsOnMaintenanceDisable(server))) {
|
||||
try {
|
||||
executeConsoleCommand(command.replace("%SERVER%", server.getName()));
|
||||
} catch (final Exception e) {
|
||||
getLogger().severe("Error while executing extra maintenance " + (maintenance ? "enable" : "disable") + " command: " + command);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void serverActions(final Server server, final boolean maintenance) {
|
||||
if (server == null) return;
|
||||
|
||||
// Skip to the even fire for dummy servers
|
||||
if (server.isRegisteredServer()) {
|
||||
if (maintenance) {
|
||||
final Server fallback = settingsProxy.getFallbackServer();
|
||||
if (fallback == null) {
|
||||
if (server.hasPlayers()) {
|
||||
getLogger().warning("The set fallback could not be found! Instead kicking players from that server off the network!");
|
||||
}
|
||||
}
|
||||
kickPlayers(server, fallback);
|
||||
} else {
|
||||
server.broadcast(settingsProxy.getMessage("singleMaintenanceDeactivated", "%SERVER%", server.getName()));
|
||||
}
|
||||
|
||||
cancelSingleTask(server);
|
||||
}
|
||||
|
||||
eventManager.callEvent(new ServerMaintenanceChangedEvent(server, maintenance));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isServerTaskRunning(final Server server) {
|
||||
return serverTasks.containsKey(server.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getMaintenanceServers() {
|
||||
return Collections.unmodifiableSet(settingsProxy.getMaintenanceServers());
|
||||
}
|
||||
|
||||
public void cancelSingleTask(final Server server) {
|
||||
final Task task = serverTasks.remove(server.getName());
|
||||
if (task != null) {
|
||||
task.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
public MaintenanceRunnableBase startSingleMaintenanceRunnable(final Server server, final Duration duration, final boolean enable) {
|
||||
final MaintenanceRunnableBase runnable = new SingleMaintenanceRunnable(this, settingsProxy, (int) duration.getSeconds(), enable, server);
|
||||
serverTasks.put(server.getName(), runnable.getTask());
|
||||
return runnable;
|
||||
}
|
||||
|
||||
public MaintenanceRunnableBase scheduleSingleMaintenanceRunnable(final Server server, final Duration enableIn, final Duration maintenanceDuration) {
|
||||
final MaintenanceRunnableBase runnable = new SingleMaintenanceScheduleRunnable(this, settingsProxy,
|
||||
(int) enableIn.getSeconds(), (int) maintenanceDuration.getSeconds(), server);
|
||||
serverTasks.put(server.getName(), runnable.getTask());
|
||||
return runnable;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public List<String> getMaintenanceServersDump() {
|
||||
final List<String> list = new ArrayList<>();
|
||||
if (isMaintenance()) {
|
||||
list.add("global");
|
||||
}
|
||||
list.addAll(settingsProxy.getMaintenanceServers());
|
||||
return list.isEmpty() ? null : list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaintenanceProxyCommand getCommandManager() {
|
||||
return (MaintenanceProxyCommand) commandManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void kickPlayers() {
|
||||
// Send players to waiting server is set
|
||||
if (settingsProxy.getWaitingServer() != null) {
|
||||
final Server waitingServer = getServer(settingsProxy.getWaitingServer());
|
||||
if (waitingServer != null) {
|
||||
kickPlayersTo(waitingServer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If not set, kick players from proxy
|
||||
kickPlayersFromProxy();
|
||||
}
|
||||
|
||||
@Blocking
|
||||
@Nullable
|
||||
protected ProfileLookup doUUIDLookup(final String name) throws IOException {
|
||||
ProfileLookup profileLookup;
|
||||
try {
|
||||
profileLookup = doUUIDLookupMojangAPI(name);
|
||||
} catch (RateLimitedException e) {
|
||||
// Use fallback API if rate limit is reached
|
||||
profileLookup = doUUIDLookupAshconAPI(name);
|
||||
}
|
||||
|
||||
if (settingsProxy.isFallbackToOfflineUUID() && profileLookup == null) {
|
||||
// Use offline uuid
|
||||
return new ProfileLookup(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(StandardCharsets.UTF_8)), name);
|
||||
}
|
||||
|
||||
return profileLookup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Official Mojang API
|
||||
*/
|
||||
@Nullable
|
||||
private ProfileLookup doUUIDLookupMojangAPI(final String name) throws IOException {
|
||||
final URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + name);
|
||||
final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
|
||||
int status = connection.getResponseCode();
|
||||
if (status == 429) {
|
||||
throw new RateLimitedException();
|
||||
}
|
||||
if (status == 404) {
|
||||
// Return null if profile not found
|
||||
return null;
|
||||
}
|
||||
|
||||
try (final InputStream in = connection.getInputStream()) {
|
||||
final String output = CharStreams.toString(new InputStreamReader(in));
|
||||
final JsonObject json = GSON.fromJson(output, JsonObject.class);
|
||||
|
||||
final UUID uuid = fromStringUUIDWithoutDashes(json.getAsJsonPrimitive("id").getAsString());
|
||||
final String username = json.getAsJsonPrimitive("name").getAsString();
|
||||
return new ProfileLookup(uuid, username);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fallback API (Ashcon API)
|
||||
*/
|
||||
@Nullable
|
||||
private ProfileLookup doUUIDLookupAshconAPI(final String name) throws IOException {
|
||||
final URL url = new URL("https://api.ashcon.app/mojang/v2/user/" + name);
|
||||
final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
if (connection.getResponseCode() == 403) {
|
||||
// Return null if profile not found
|
||||
return null;
|
||||
}
|
||||
|
||||
try (final InputStream in = connection.getInputStream()) {
|
||||
final String output = CharStreams.toString(new InputStreamReader(in));
|
||||
final JsonObject json = GSON.fromJson(output, JsonObject.class);
|
||||
|
||||
final UUID uuid = UUID.fromString(json.getAsJsonPrimitive("uuid").getAsString());
|
||||
final String username = json.getAsJsonPrimitive("username").getAsString();
|
||||
return new ProfileLookup(uuid, username);
|
||||
}
|
||||
}
|
||||
|
||||
private UUID fromStringUUIDWithoutDashes(String undashedUUID) {
|
||||
return UUID.fromString(
|
||||
undashedUUID.substring(0, 8) + "-" + undashedUUID.substring(8, 12) + "-" +
|
||||
undashedUUID.substring(12, 16) + "-" + undashedUUID.substring(16, 20) + "-" +
|
||||
undashedUUID.substring(20, 32)
|
||||
);
|
||||
}
|
||||
|
||||
public SettingsProxy getSettingsProxy() {
|
||||
return settingsProxy;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract String getServerNameOf(SenderInfo sender);
|
||||
|
||||
protected abstract void kickPlayers(Server server, Server fallback);
|
||||
|
||||
protected abstract void kickPlayersTo(Server server);
|
||||
|
||||
protected abstract void kickPlayersFromProxy();
|
||||
}
|
||||
@@ -1,310 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.proxy;
|
||||
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.core.config.ConfigSection;
|
||||
import eu.kennytv.maintenance.core.proxy.mysql.MySQL;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public final class SettingsProxy extends Settings {
|
||||
private final MaintenanceProxyPlugin proxyPlugin;
|
||||
private Set<String> maintenanceServers;
|
||||
private List<String> fallbackServers;
|
||||
private String waitingServer;
|
||||
private boolean fallbackToOfflineUUID;
|
||||
|
||||
private Map<String, List<String>> commandsOnMaintenanceEnable;
|
||||
private Map<String, List<String>> commandsOnMaintenanceDisable;
|
||||
private String mySQLTable;
|
||||
private String serverTable;
|
||||
private String maintenanceQuery;
|
||||
private String serverQuery;
|
||||
private MySQL mySQL;
|
||||
|
||||
private long millisecondsToCheck;
|
||||
private long lastMySQLCheck;
|
||||
private long lastServerCheck;
|
||||
|
||||
public SettingsProxy(final MaintenanceProxyPlugin plugin) {
|
||||
super(plugin);
|
||||
this.proxyPlugin = plugin;
|
||||
}
|
||||
|
||||
private void setupMySQL() {
|
||||
plugin.getLogger().info("Trying to open database connection... (also, you can simply ignore the SLF4J soft-warning if it shows up)");
|
||||
final ConfigSection section = config.getSection("mysql");
|
||||
if (section == null) {
|
||||
plugin.getLogger().warning("Section missing: mysql");
|
||||
return;
|
||||
}
|
||||
|
||||
mySQL = new MySQL(plugin.getLogger(),
|
||||
section.getString("host"),
|
||||
section.getInt("port"),
|
||||
section.getString("username"),
|
||||
section.getString("password"),
|
||||
section.getString("database"),
|
||||
section.getBoolean("use-ssl", true));
|
||||
|
||||
// Varchar as the value regarding the possibility of saving stuff like the motd as well in future updates
|
||||
mySQLTable = section.getString("table", "maintenance_settings");
|
||||
serverTable = section.getString("servertable", "maintenance_servers");
|
||||
mySQL.executeUpdate("CREATE TABLE IF NOT EXISTS " + mySQLTable + " (setting VARCHAR(16) PRIMARY KEY, value VARCHAR(255))");
|
||||
mySQL.executeUpdate("CREATE TABLE IF NOT EXISTS " + serverTable + " (server VARCHAR(64) PRIMARY KEY)");
|
||||
maintenanceQuery = "SELECT * FROM " + mySQLTable + " WHERE setting = ?";
|
||||
serverQuery = "SELECT * FROM " + serverTable;
|
||||
plugin.getLogger().info("Done!");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadExtraSettings() {
|
||||
// Open database connection if enabled and not already done
|
||||
if (!hasMySQL() && config.getBoolean("mysql.use-mysql")) {
|
||||
try {
|
||||
setupMySQL();
|
||||
} catch (final Exception e) {
|
||||
mySQL = null;
|
||||
plugin.getLogger().warning("Error while trying do open database connection!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
final Object fallback = config.getObject("fallback");
|
||||
fallbackServers = fallback instanceof String ? Collections.singletonList((String) fallback) : config.getStringList("fallback", Collections.emptyList());
|
||||
|
||||
waitingServer = config.getString("waiting-server", "");
|
||||
if (waitingServer.isEmpty() || waitingServer.equalsIgnoreCase("none")) {
|
||||
waitingServer = null;
|
||||
}
|
||||
fallbackToOfflineUUID = config.getBoolean("fallback-to-offline-uuid", false);
|
||||
|
||||
commandsOnMaintenanceEnable = new HashMap<>();
|
||||
final ConfigSection enableCommandsSection = config.getSection("commands-on-single-maintenance-enable");
|
||||
for (final String key : enableCommandsSection.getKeys()) {
|
||||
commandsOnMaintenanceEnable.put(key.toLowerCase(Locale.ROOT), enableCommandsSection.getStringList(key));
|
||||
}
|
||||
|
||||
commandsOnMaintenanceDisable = new HashMap<>();
|
||||
final ConfigSection disableCommandsSection = config.getSection("commands-on-single-maintenance-disable");
|
||||
for (final String key : disableCommandsSection.getKeys()) {
|
||||
commandsOnMaintenanceDisable.put(key.toLowerCase(Locale.ROOT), disableCommandsSection.getStringList(key));
|
||||
}
|
||||
|
||||
if (hasMySQL()) {
|
||||
maintenance = loadMaintenance();
|
||||
maintenanceServers = loadMaintenanceServersFromSQL();
|
||||
|
||||
final long configValue = config.getInt("mysql.update-interval");
|
||||
// Even if set to 0, only check every 500 millis
|
||||
millisecondsToCheck = configValue > 0 ? configValue * 1000 : 500;
|
||||
lastMySQLCheck = System.currentTimeMillis();
|
||||
lastServerCheck = System.currentTimeMillis();
|
||||
} else {
|
||||
final List<String> list = config.getStringList("proxied-maintenance-servers");
|
||||
maintenanceServers = list == null ? new HashSet<>() : new HashSet<>(list);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMaintenance() {
|
||||
if (hasMySQL() && System.currentTimeMillis() - lastMySQLCheck > millisecondsToCheck) {
|
||||
final boolean databaseValue = loadMaintenance();
|
||||
if (databaseValue != maintenance) {
|
||||
maintenance = databaseValue;
|
||||
plugin.serverActions(maintenance);
|
||||
}
|
||||
lastMySQLCheck = System.currentTimeMillis();
|
||||
}
|
||||
return maintenance;
|
||||
}
|
||||
|
||||
public boolean isMaintenance(final String serverName) {
|
||||
if (hasMySQL() && System.currentTimeMillis() - lastServerCheck > millisecondsToCheck) {
|
||||
final Set<String> databaseValue = loadMaintenanceServersFromSQL();
|
||||
if (!maintenanceServers.equals(databaseValue)) {
|
||||
// Enable maintenance on yet unlisted servers
|
||||
for (final String s : databaseValue) {
|
||||
if (!maintenanceServers.contains(s)) {
|
||||
proxyPlugin.serverActions(proxyPlugin.getServer(s), true);
|
||||
}
|
||||
}
|
||||
// Disable maintenance on now unlisted servers
|
||||
for (final String s : maintenanceServers) {
|
||||
if (!databaseValue.contains(s)) {
|
||||
proxyPlugin.serverActions(proxyPlugin.getServer(s), false);
|
||||
}
|
||||
}
|
||||
maintenanceServers = databaseValue;
|
||||
}
|
||||
lastServerCheck = System.currentTimeMillis();
|
||||
}
|
||||
return maintenanceServers.contains(serverName);
|
||||
}
|
||||
|
||||
public Component getServerKickMessage(final String server) {
|
||||
String message = getLanguageStringOrNull("singleMaintenanceKicks." + server, "%SERVER%", server);
|
||||
if (message == null) {
|
||||
message = getLanguageString("singleMaintenanceKick", "%SERVER%", server);
|
||||
}
|
||||
return parse(plugin.replacePingVariables(message));
|
||||
}
|
||||
|
||||
// Full = being kicked from the proxy, not just a proxied server
|
||||
public Component getFullServerKickMessage(final String server) {
|
||||
String message = getLanguageStringOrNull("singleMaintenanceKicksComplete." + server, "%SERVER%", server);
|
||||
if (message == null) {
|
||||
message = getLanguageString("singleMaintenanceKickComplete", "%SERVER%", server);
|
||||
}
|
||||
return parse(plugin.replacePingVariables(message));
|
||||
}
|
||||
|
||||
public boolean hasMySQL() {
|
||||
return mySQL != null;
|
||||
}
|
||||
|
||||
void setMaintenanceToSQL(final boolean maintenance) {
|
||||
plugin.async(() -> {
|
||||
final String s = String.valueOf(maintenance);
|
||||
mySQL.executeUpdate("INSERT INTO " + mySQLTable + " (setting, value) VALUES (?, ?) ON DUPLICATE KEY UPDATE value = ?", "maintenance", s, s);
|
||||
lastMySQLCheck = System.currentTimeMillis();
|
||||
});
|
||||
}
|
||||
|
||||
boolean addMaintenanceServer(final String server) {
|
||||
if (hasMySQL()) {
|
||||
maintenanceServers = loadMaintenanceServersFromSQL();
|
||||
if (!maintenanceServers.add(server)) return false;
|
||||
plugin.async(() -> mySQL.executeUpdate("INSERT INTO " + serverTable + " (server) VALUES (?)", server));
|
||||
lastServerCheck = System.currentTimeMillis();
|
||||
} else {
|
||||
if (!maintenanceServers.add(server)) return false;
|
||||
saveServersToConfig();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean removeMaintenanceServer(final String server) {
|
||||
if (hasMySQL()) {
|
||||
maintenanceServers = loadMaintenanceServersFromSQL();
|
||||
if (!maintenanceServers.remove(server)) return false;
|
||||
|
||||
plugin.async(() -> mySQL.executeUpdate("DELETE FROM " + serverTable + " WHERE server = ?", server));
|
||||
lastServerCheck = System.currentTimeMillis();
|
||||
} else {
|
||||
if (!maintenanceServers.remove(server)) return false;
|
||||
|
||||
saveServersToConfig();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Set<String> loadMaintenanceServersFromSQL() {
|
||||
final Set<String> maintenanceServers = new HashSet<>();
|
||||
mySQL.executeQuery(serverQuery, rs -> {
|
||||
try {
|
||||
while (rs.next()) {
|
||||
maintenanceServers.add(rs.getString("server"));
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
plugin.getLogger().warning("An error occured while trying to get the list of single servers with maintenance!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
return maintenanceServers;
|
||||
}
|
||||
|
||||
private boolean loadMaintenance() {
|
||||
final boolean[] databaseValue = {false};
|
||||
mySQL.executeQuery(maintenanceQuery, rs -> {
|
||||
try {
|
||||
if (rs.next()) {
|
||||
databaseValue[0] = Boolean.parseBoolean(rs.getString("value"));
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
plugin.getLogger().warning("An error occured while trying to get the maintenance value from the database!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, "maintenance");
|
||||
return databaseValue[0];
|
||||
}
|
||||
|
||||
private void saveServersToConfig() {
|
||||
config.set("proxied-maintenance-servers", new ArrayList<>(maintenanceServers));
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
public Set<String> getMaintenanceServers() {
|
||||
return maintenanceServers;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Server getFallbackServer() {
|
||||
for (final String fallbackServer : fallbackServers) {
|
||||
final Server server = proxyPlugin.getServer(fallbackServer);
|
||||
if (server != null && !isMaintenance(server.getName())) {
|
||||
return server;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getWaitingServer() {
|
||||
return waitingServer;
|
||||
}
|
||||
|
||||
public boolean isFallbackToOfflineUUID() {
|
||||
return fallbackToOfflineUUID;
|
||||
}
|
||||
|
||||
public List<String> getCommandsOnMaintenanceEnable(final Server server) {
|
||||
final List<String> enableCommands = commandsOnMaintenanceEnable.getOrDefault("all", new ArrayList<>());
|
||||
final List<String> serverEnableCommands = commandsOnMaintenanceEnable.get(server.getName().toLowerCase(Locale.ROOT));
|
||||
if (serverEnableCommands != null) {
|
||||
enableCommands.addAll(serverEnableCommands);
|
||||
}
|
||||
return enableCommands;
|
||||
}
|
||||
|
||||
public List<String> getCommandsOnMaintenanceDisable(final Server server) {
|
||||
final List<String> disableCommands = commandsOnMaintenanceDisable.getOrDefault("all", new ArrayList<>());
|
||||
final List<String> serverDisableCommands = commandsOnMaintenanceDisable.get(server.getName().toLowerCase(Locale.ROOT));
|
||||
if (serverDisableCommands != null) {
|
||||
disableCommands.addAll(serverDisableCommands);
|
||||
}
|
||||
return disableCommands;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
MySQL getMySQL() {
|
||||
return mySQL;
|
||||
}
|
||||
}
|
||||
-74
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.proxy.command;
|
||||
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import eu.kennytv.maintenance.core.command.MaintenanceCommand;
|
||||
import eu.kennytv.maintenance.core.proxy.MaintenanceProxyPlugin;
|
||||
import eu.kennytv.maintenance.core.proxy.SettingsProxy;
|
||||
import eu.kennytv.maintenance.core.proxy.command.subcommand.*;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class MaintenanceProxyCommand extends MaintenanceCommand {
|
||||
private final MaintenanceProxyPlugin plugin;
|
||||
private final SettingsProxy settingsBungee;
|
||||
|
||||
protected MaintenanceProxyCommand(final MaintenanceProxyPlugin plugin, final SettingsProxy settings) {
|
||||
super(plugin, settings);
|
||||
this.plugin = plugin;
|
||||
settingsBungee = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addToggleAndTimerCommands() {
|
||||
add(new SingleToggleCommand(plugin), "on", "off");
|
||||
add(new StatusCommand(plugin), "status");
|
||||
|
||||
add(new SingleStarttimerCommand(plugin), "starttimer", "start");
|
||||
add(new SingleEndtimerCommand(plugin), "endtimer", "end");
|
||||
add(new SingleScheduleTimerCommand(plugin), "scheduletimer", "schedule");
|
||||
add(new AbortSingleTimerCommand(plugin), "aborttimer", "abort");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMaintenanceServersCompletion(final String s) {
|
||||
final List<String> list = new ArrayList<>();
|
||||
for (final String server : settingsBungee.getMaintenanceServers()) {
|
||||
if (server.toLowerCase().startsWith(s)) {
|
||||
list.add(server);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Server checkSingleTimerServerArg(final SenderInfo sender, final String serverName) {
|
||||
final Server server = plugin.getServer(serverName);
|
||||
if (server == null) {
|
||||
sender.send(settings.getMessage("serverNotFound"));
|
||||
return null;
|
||||
}
|
||||
if (plugin.isServerTaskRunning(server)) {
|
||||
sender.send(settings.getMessage("singleTimerAlreadyRunning"));
|
||||
return null;
|
||||
}
|
||||
return server;
|
||||
}
|
||||
}
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.proxy.command;
|
||||
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.proxy.MaintenanceProxyPlugin;
|
||||
import eu.kennytv.maintenance.core.proxy.SettingsProxy;
|
||||
|
||||
public abstract class ProxyCommandInfo extends CommandInfo {
|
||||
protected final MaintenanceProxyPlugin plugin;
|
||||
|
||||
protected ProxyCommandInfo(final MaintenanceProxyPlugin plugin, final String permission) {
|
||||
super(plugin, permission);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SettingsProxy getSettings() {
|
||||
return plugin.getSettingsProxy();
|
||||
}
|
||||
}
|
||||
-72
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.proxy.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import eu.kennytv.maintenance.core.proxy.MaintenanceProxyPlugin;
|
||||
import eu.kennytv.maintenance.core.proxy.command.ProxyCommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class AbortSingleTimerCommand extends ProxyCommandInfo {
|
||||
|
||||
public AbortSingleTimerCommand(final MaintenanceProxyPlugin plugin) {
|
||||
super(plugin, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final SenderInfo sender) {
|
||||
return sender.hasMaintenancePermission("timer") || sender.hasPermission("maintenance.singleserver.timer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
if (checkPermission(sender, "timer")) return;
|
||||
if (!plugin.isTaskRunning()) {
|
||||
sender.send(getMessage("timerNotRunning"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.cancelTask();
|
||||
sender.send(getMessage("timerCancelled"));
|
||||
} else if (args.length == 2) {
|
||||
if (checkPermission(sender, "singleserver.timer")) return;
|
||||
final Server server = plugin.getServer(args[1]);
|
||||
if (server == null) {
|
||||
sender.send(getMessage("serverNotFound"));
|
||||
return;
|
||||
}
|
||||
if (!plugin.isServerTaskRunning(server)) {
|
||||
sender.send(getMessage("singleTimerNotRunning"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.cancelSingleTask(server);
|
||||
sender.send(getMessage("singleTimerCancelled", "%SERVER%", server.getName()));
|
||||
} else
|
||||
sender.send(getHelpMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletion(final SenderInfo sender, final String[] args) {
|
||||
return args.length == 2 && sender.hasMaintenancePermission("singleserver.timer") ? plugin.getCommandManager().getServersCompletion(args[1]) : Collections.emptyList();
|
||||
}
|
||||
}
|
||||
-88
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.proxy.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import eu.kennytv.maintenance.core.proxy.MaintenanceProxyPlugin;
|
||||
import eu.kennytv.maintenance.core.proxy.command.ProxyCommandInfo;
|
||||
import eu.kennytv.maintenance.core.runnable.MaintenanceRunnableBase;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class SingleEndtimerCommand extends ProxyCommandInfo {
|
||||
|
||||
public SingleEndtimerCommand(final MaintenanceProxyPlugin plugin) {
|
||||
super(plugin, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final SenderInfo sender) {
|
||||
return sender.hasMaintenancePermission("timer") || sender.hasPermission("maintenance.singleserver.timer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (args.length == 2) {
|
||||
if (checkPermission(sender, "timer")) return;
|
||||
|
||||
final Duration duration = plugin.getCommandManager().parseDurationAndCheckTask(sender, args[1]);
|
||||
if (duration == null) {
|
||||
sender.send(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
if (!plugin.isMaintenance()) {
|
||||
sender.send(getMessage("alreadyDisabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.startMaintenanceRunnable(duration, false);
|
||||
sender.send(getMessage("endtimerStarted", "%TIME%", plugin.getRunnable().getTime()));
|
||||
} else if (args.length == 3) {
|
||||
if (checkPermission(sender, "singleserver.timer")) return;
|
||||
|
||||
final Duration duration = plugin.getCommandManager().parseDurationAndCheckTask(sender, args[2], false);
|
||||
if (duration == null) {
|
||||
sender.send(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
final Server server = plugin.getCommandManager().checkSingleTimerServerArg(sender, args[1]);
|
||||
if (server == null) return;
|
||||
if (!plugin.isMaintenance(server)) {
|
||||
sender.send(getMessage("singleServerAlreadyDisabled", "%SERVER%", server.getName()));
|
||||
return;
|
||||
}
|
||||
|
||||
final MaintenanceRunnableBase runnable = plugin.startSingleMaintenanceRunnable(server, duration, false);
|
||||
sender.send(getMessage(
|
||||
"singleEndtimerStarted",
|
||||
"%TIME%", runnable.getTime(),
|
||||
"%SERVER%", server.getName()
|
||||
));
|
||||
} else {
|
||||
sender.send(getHelpMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletion(final SenderInfo sender, final String[] args) {
|
||||
return args.length == 2 && sender.hasMaintenancePermission("singleserver.timer") ? plugin.getCommandManager().getMaintenanceServersCompletion(args[1].toLowerCase()) : Collections.emptyList();
|
||||
}
|
||||
}
|
||||
-95
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.proxy.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import eu.kennytv.maintenance.core.proxy.MaintenanceProxyPlugin;
|
||||
import eu.kennytv.maintenance.core.proxy.command.ProxyCommandInfo;
|
||||
import eu.kennytv.maintenance.core.runnable.MaintenanceRunnableBase;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class SingleScheduleTimerCommand extends ProxyCommandInfo {
|
||||
|
||||
public SingleScheduleTimerCommand(final MaintenanceProxyPlugin plugin) {
|
||||
super(plugin, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final SenderInfo sender) {
|
||||
return sender.hasMaintenancePermission("timer") || sender.hasPermission("maintenance.singleserver.timer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (args.length == 3) {
|
||||
if (checkPermission(sender, "timer")) return;
|
||||
|
||||
final Duration enableIn = plugin.getCommandManager().parseDurationAndCheckTask(sender, args[1]);
|
||||
final Duration duration = plugin.getCommandManager().parseDurationAndCheckTask(sender, args[2], false);
|
||||
if (enableIn == null || duration == null) {
|
||||
sender.send(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
if (plugin.isMaintenance()) {
|
||||
sender.send(getMessage("alreadyEnabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.scheduleMaintenanceRunnable(duration, enableIn);
|
||||
sender.send(getMessage(
|
||||
"scheduletimerStarted",
|
||||
"%TIME%", plugin.getRunnable().getTime(),
|
||||
"%DURATION%", plugin.getFormattedTime((int) duration.getSeconds())
|
||||
));
|
||||
} else if (args.length == 4) {
|
||||
if (checkPermission(sender, "singleserver.timer")) return;
|
||||
|
||||
final Duration enableIn = plugin.getCommandManager().parseDurationAndCheckTask(sender, args[2], false);
|
||||
final Duration duration = plugin.getCommandManager().parseDurationAndCheckTask(sender, args[3], false);
|
||||
if (enableIn == null || duration == null) {
|
||||
sender.send(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
final Server server = plugin.getCommandManager().checkSingleTimerServerArg(sender, args[1]);
|
||||
if (server == null) return;
|
||||
if (plugin.isMaintenance(server)) {
|
||||
sender.send(getMessage("singleServerAlreadyEnabled", "%SERVER%", server.getName()));
|
||||
return;
|
||||
}
|
||||
|
||||
final MaintenanceRunnableBase runnable = plugin.scheduleSingleMaintenanceRunnable(server, enableIn, duration);
|
||||
sender.send(getMessage(
|
||||
"singleScheduletimerStarted",
|
||||
"%TIME%", runnable.getTime(),
|
||||
"%DURATION%", plugin.getFormattedTime((int) duration.getSeconds()),
|
||||
"%SERVER%", server.getName()
|
||||
));
|
||||
} else {
|
||||
sender.send(getHelpMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletion(final SenderInfo sender, final String[] args) {
|
||||
return args.length == 2 && sender.hasMaintenancePermission("singleserver.timer") ? plugin.getCommandManager().getServersCompletion(args[1].toLowerCase()) : Collections.emptyList();
|
||||
}
|
||||
}
|
||||
-88
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.proxy.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import eu.kennytv.maintenance.core.proxy.MaintenanceProxyPlugin;
|
||||
import eu.kennytv.maintenance.core.proxy.command.ProxyCommandInfo;
|
||||
import eu.kennytv.maintenance.core.runnable.MaintenanceRunnableBase;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class SingleStarttimerCommand extends ProxyCommandInfo {
|
||||
|
||||
public SingleStarttimerCommand(final MaintenanceProxyPlugin plugin) {
|
||||
super(plugin, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final SenderInfo sender) {
|
||||
return sender.hasMaintenancePermission("timer") || sender.hasPermission("maintenance.singleserver.timer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (args.length == 2) {
|
||||
if (checkPermission(sender, "timer")) return;
|
||||
|
||||
final Duration duration = plugin.getCommandManager().parseDurationAndCheckTask(sender, args[1]);
|
||||
if (duration == null) {
|
||||
sender.send(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
if (plugin.isMaintenance()) {
|
||||
sender.send(getMessage("alreadyEnabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.startMaintenanceRunnable(duration, true);
|
||||
sender.send(getMessage("starttimerStarted", "%TIME%", plugin.getRunnable().getTime()));
|
||||
} else if (args.length == 3) {
|
||||
if (checkPermission(sender, "singleserver.timer")) return;
|
||||
|
||||
final Duration duration = plugin.getCommandManager().parseDurationAndCheckTask(sender, args[2], false);
|
||||
if (duration == null) {
|
||||
sender.send(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
final Server server = plugin.getCommandManager().checkSingleTimerServerArg(sender, args[1]);
|
||||
if (server == null) return;
|
||||
if (plugin.isMaintenance(server)) {
|
||||
sender.send(getMessage("singleServerAlreadyEnabled", "%SERVER%", server.getName()));
|
||||
return;
|
||||
}
|
||||
|
||||
final MaintenanceRunnableBase runnable = plugin.startSingleMaintenanceRunnable(server, duration, true);
|
||||
sender.send(getMessage(
|
||||
"singleStarttimerStarted",
|
||||
"%TIME%", runnable.getTime(),
|
||||
"%SERVER%", server.getName()
|
||||
));
|
||||
} else {
|
||||
sender.send(getHelpMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletion(final SenderInfo sender, final String[] args) {
|
||||
return args.length == 2 && sender.hasMaintenancePermission("singleserver.timer") ? plugin.getCommandManager().getServersCompletion(args[1].toLowerCase()) : Collections.emptyList();
|
||||
}
|
||||
}
|
||||
-86
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.proxy.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import eu.kennytv.maintenance.core.proxy.MaintenanceProxyPlugin;
|
||||
import eu.kennytv.maintenance.core.proxy.command.ProxyCommandInfo;
|
||||
import eu.kennytv.maintenance.core.proxy.server.DummyServer;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class SingleToggleCommand extends ProxyCommandInfo {
|
||||
|
||||
public SingleToggleCommand(final MaintenanceProxyPlugin plugin) {
|
||||
super(plugin, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final SenderInfo sender) {
|
||||
return sender.hasMaintenancePermission("toggle") || sender.hasPermission("maintenance.singleserver.toggle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
if (checkPermission(sender, "toggle")) return;
|
||||
final boolean maintenance = args[0].equalsIgnoreCase("on");
|
||||
if (maintenance == plugin.isMaintenance()) {
|
||||
sender.send(getMessage(maintenance ? "alreadyEnabled" : "alreadyDisabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.setMaintenance(maintenance);
|
||||
} else if (args.length == 2) {
|
||||
if (checkPermission(sender, "singleserver.toggle")) return;
|
||||
final boolean maintenance = args[0].equalsIgnoreCase("on");
|
||||
Server server = plugin.getServer(args[1]);
|
||||
if (server == null) {
|
||||
if (maintenance) {
|
||||
sender.send(getMessage("serverNotFound"));
|
||||
return;
|
||||
}
|
||||
// Let servers be removed from the maintenance list, even if they don't exist on the proxy
|
||||
server = new DummyServer(args[1]);
|
||||
if (!plugin.isMaintenance(server)) {
|
||||
sender.send(getMessage("serverNotFound"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.setMaintenanceToServer(server, maintenance)) {
|
||||
if (!sender.isPlayer() || !server.getName().equals(plugin.getServerNameOf(sender))) {
|
||||
sender.send(getMessage(maintenance ? "singleMaintenanceActivated" : "singleMaintenanceDeactivated", "%SERVER%", server.getName()));
|
||||
}
|
||||
} else {
|
||||
sender.send(getMessage(maintenance ? "singleServerAlreadyEnabled" : "singleServerAlreadyDisabled", "%SERVER%", server.getName()));
|
||||
}
|
||||
} else {
|
||||
sender.send(getHelpMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletion(final SenderInfo sender, final String[] args) {
|
||||
if (args.length != 2 || !sender.hasMaintenancePermission("singleserver.toggle")) return Collections.emptyList();
|
||||
return args[0].equalsIgnoreCase("off") ? plugin.getCommandManager().getMaintenanceServersCompletion(args[1].toLowerCase())
|
||||
: plugin.getCommandManager().getServersCompletion(args[1].toLowerCase());
|
||||
}
|
||||
}
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.proxy.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.proxy.MaintenanceProxyPlugin;
|
||||
import eu.kennytv.maintenance.core.proxy.command.ProxyCommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
public final class StatusCommand extends ProxyCommandInfo {
|
||||
|
||||
public StatusCommand(final MaintenanceProxyPlugin plugin) {
|
||||
super(plugin, "singleserver.status");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (getSettings().getMaintenanceServers().isEmpty()) {
|
||||
sender.send(getMessage("singleServerMaintenanceListEmpty"));
|
||||
return;
|
||||
}
|
||||
|
||||
sender.send(getMessage("singleServerMaintenanceList"));
|
||||
for (final String server : getSettings().getMaintenanceServers()) {
|
||||
sender.send(getMessage("singleServerMaintenanceListEntry", "%SERVER%", server));
|
||||
}
|
||||
}
|
||||
}
|
||||
-78
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.proxy.hook;
|
||||
|
||||
import eu.kennytv.maintenance.core.hook.LuckPermsHook;
|
||||
import eu.kennytv.maintenance.core.proxy.MaintenanceProxyPlugin;
|
||||
import net.luckperms.api.LuckPermsProvider;
|
||||
import net.luckperms.api.context.ContextCalculator;
|
||||
import net.luckperms.api.context.ContextConsumer;
|
||||
import net.luckperms.api.context.ContextSet;
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public final class LuckPermsProxyHook {
|
||||
|
||||
public static <T> void register(final MaintenanceProxyPlugin plugin, final Function<T, String> function) {
|
||||
LuckPermsProvider.get().getContextManager().registerCalculator(new MaintenanceProxyCalculator<>(plugin, function));
|
||||
}
|
||||
|
||||
public static final class MaintenanceProxyCalculator<T> implements ContextCalculator<T> {
|
||||
|
||||
private static final String MAINTENANCE_ON_KEY = "is-maintenance-on-";
|
||||
private static final String ON_MAINTENANCE_SERVER_KEY = "on-maintenance-server";
|
||||
private final MaintenanceProxyPlugin maintenance;
|
||||
private final Function<T, String> playerServerFunction;
|
||||
|
||||
private MaintenanceProxyCalculator(final MaintenanceProxyPlugin plugin, final Function<T, String> playerServerFunction) {
|
||||
this.maintenance = plugin;
|
||||
this.playerServerFunction = playerServerFunction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate(@NotNull final T target, @NotNull final ContextConsumer consumer) {
|
||||
consumer.accept(LuckPermsHook.MaintenanceCalculator.MAINTENANCE_KEY, Boolean.toString(maintenance.isMaintenance()));
|
||||
/*for (final String serverName : maintenance.getServers()) {
|
||||
final Server server = maintenance.getServer(serverName);
|
||||
if (server != null) {
|
||||
consumer.accept(MAINTENANCE_ON_KEY + server, Boolean.toString(maintenance.isMaintenance(server)));
|
||||
}
|
||||
}*/
|
||||
final String server = playerServerFunction.apply(target);
|
||||
if (server != null) {
|
||||
final String value = Boolean.toString(maintenance.getSettingsProxy().isMaintenance(server));
|
||||
consumer.accept(MAINTENANCE_ON_KEY + server, value);
|
||||
consumer.accept(ON_MAINTENANCE_SERVER_KEY, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContextSet estimatePotentialContexts() {
|
||||
final ImmutableContextSet.Builder builder = ImmutableContextSet.builder();
|
||||
for (final String serverName : maintenance.getServers()) {
|
||||
final String key = MAINTENANCE_ON_KEY + serverName;
|
||||
builder.add(key, "true").add(key, "false");
|
||||
}
|
||||
return builder.add(ON_MAINTENANCE_SERVER_KEY, "true").add(ON_MAINTENANCE_SERVER_KEY, "false")
|
||||
.add(LuckPermsHook.MaintenanceCalculator.MAINTENANCE_KEY, "true")
|
||||
.add(LuckPermsHook.MaintenanceCalculator.MAINTENANCE_KEY, "false").build();
|
||||
}
|
||||
}
|
||||
}
|
||||
-121
@@ -1,121 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.proxy.listener;
|
||||
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import eu.kennytv.maintenance.core.listener.JoinListenerBase;
|
||||
import eu.kennytv.maintenance.core.proxy.MaintenanceProxyPlugin;
|
||||
import eu.kennytv.maintenance.core.proxy.SettingsProxy;
|
||||
import eu.kennytv.maintenance.core.proxy.util.ProxySenderInfo;
|
||||
import eu.kennytv.maintenance.core.proxy.util.ServerConnectResult;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class ProxyJoinListenerBase extends JoinListenerBase {
|
||||
private static final ServerConnectResult ALLOWED = new ServerConnectResult(false);
|
||||
private static final ServerConnectResult DENIED = new ServerConnectResult(true);
|
||||
protected final MaintenanceProxyPlugin plugin;
|
||||
protected final SettingsProxy settings;
|
||||
private boolean warned;
|
||||
|
||||
protected ProxyJoinListenerBase(final MaintenanceProxyPlugin plugin, final SettingsProxy settings) {
|
||||
super(plugin, settings);
|
||||
this.plugin = plugin;
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sender joined player
|
||||
* @param target target server
|
||||
* @param normalServerConnect true if normal server connect, false if initial proxy join or kick
|
||||
* @return connect result with data for further handling
|
||||
*/
|
||||
protected ServerConnectResult serverConnect(final ProxySenderInfo sender, final Server target, final boolean normalServerConnect) {
|
||||
// Check waiting server for global maintenance
|
||||
if (settings.isMaintenance()) {
|
||||
if (sender.hasMaintenancePermission("bypass") || settings.isWhitelisted(sender.getUuid())) return ALLOWED;
|
||||
|
||||
final Server waitingServer = shouldConnectToWaitingServer(sender);
|
||||
// Should never be null, but just in case
|
||||
if (waitingServer == null) return DENIED;
|
||||
|
||||
// Player is connecting to the waiting server
|
||||
if (target.getName().equals(waitingServer.getName())) return ALLOWED;
|
||||
|
||||
// Player already is on the waiting server
|
||||
final String currentServer = plugin.getServerNameOf(sender);
|
||||
if (waitingServer.getName().equals(currentServer)) {
|
||||
sender.send(settings.getMessage("forceWaitingServer"));
|
||||
return DENIED;
|
||||
}
|
||||
|
||||
sender.send(settings.getMessage("sentToWaitingServer"));
|
||||
return new ServerConnectResult(waitingServer);
|
||||
}
|
||||
|
||||
// Single server maintenance
|
||||
if (!settings.isMaintenance(target.getName())) return ALLOWED;
|
||||
if (sender.hasMaintenancePermission("bypass") || settings.isWhitelisted(sender.getUuid())
|
||||
|| sender.hasMaintenancePermission("singleserver.bypass." + target.getName().toLowerCase())) {
|
||||
return ALLOWED;
|
||||
}
|
||||
|
||||
if (settings.isJoinNotifications()) {
|
||||
broadcastJoinNotification(sender.getName(), target);
|
||||
}
|
||||
|
||||
if (normalServerConnect) {
|
||||
sender.send(settings.getServerKickMessage(target.getName()));
|
||||
return DENIED;
|
||||
}
|
||||
|
||||
// If it's the initial proxy join or a kick from another server, go back to fallback server
|
||||
final Server fallback = settings.getFallbackServer();
|
||||
if (fallback == null || !sender.canAccess(fallback)) {
|
||||
// Nothing to redirect to, player has to be kicked from the proxy
|
||||
sender.disconnect(settings.getFullServerKickMessage(target.getName()));
|
||||
if (!warned) {
|
||||
plugin.getLogger().warning("Could not send player to the set fallback server; instead kicking player off the network!");
|
||||
warned = true;
|
||||
}
|
||||
return DENIED;
|
||||
} else {
|
||||
return new ServerConnectResult(fallback);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To be called after {@link #shouldKick(SenderInfo, boolean)} to get the waiting server if present.
|
||||
* Does not do any permission checks, they should be done separately!
|
||||
*
|
||||
* @param sender sender
|
||||
* @return waiting server, null if player should be kicked
|
||||
*/
|
||||
@Nullable
|
||||
protected Server shouldConnectToWaitingServer(final ProxySenderInfo sender) {
|
||||
if (settings.getWaitingServer() == null) return null;
|
||||
|
||||
final Server waitingServer = plugin.getServer(settings.getWaitingServer());
|
||||
if (waitingServer == null) return null;
|
||||
if (!sender.canAccess(waitingServer) || settings.isMaintenance(waitingServer.getName())) return null;
|
||||
|
||||
return waitingServer;
|
||||
}
|
||||
|
||||
protected abstract void broadcastJoinNotification(String name, Server server);
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.proxy.mysql;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public final class MySQL {
|
||||
private final Logger logger;
|
||||
private final HikariDataSource hikariDataSource;
|
||||
|
||||
public MySQL(final Logger logger, final String hostname, final int port, final String username, final String password, final String database, final boolean useSSL) {
|
||||
this.logger = logger;
|
||||
|
||||
final HikariConfig hikariConfig = new HikariConfig();
|
||||
hikariConfig.setMaximumPoolSize(10);
|
||||
hikariConfig.addDataSourceProperty("serverName", hostname);
|
||||
hikariConfig.addDataSourceProperty("user", username);
|
||||
hikariConfig.addDataSourceProperty("password", password);
|
||||
|
||||
String urlProperty = "jdbc:mysql://" + hostname + ":" + port + "/" + database;
|
||||
if (!useSSL) {
|
||||
urlProperty += "?useSSL=false";
|
||||
}
|
||||
hikariConfig.addDataSourceProperty("url", urlProperty);
|
||||
|
||||
hikariConfig.setJdbcUrl(urlProperty);
|
||||
hikariConfig.setDataSourceClassName(findDriver("com.mysql.jdbc.jdbc2.optional.MysqlDataSource", "com.mysql.cj.jdbc.MysqlDataSource", "org.mariadb.jdbc.MariaDbDataSource"));
|
||||
hikariDataSource = new HikariDataSource(hikariConfig);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String findDriver(final String... classNames) {
|
||||
for (final String name : classNames) {
|
||||
try {
|
||||
Class.forName(name);
|
||||
return name;
|
||||
} catch (final ClassNotFoundException ignored) {
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("No sql driver class found");
|
||||
}
|
||||
|
||||
public void executeUpdate(final String query, final Consumer<Integer> callback, final Object... objects) {
|
||||
try (final Connection connection = hikariDataSource.getConnection()) {
|
||||
try (final PreparedStatement preparedStatement = connection.prepareStatement(query)) {
|
||||
int current = 1;
|
||||
for (final Object object : objects) {
|
||||
preparedStatement.setObject(current, object);
|
||||
current++;
|
||||
}
|
||||
|
||||
callback.accept(preparedStatement.executeUpdate());
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
logger.log(Level.SEVERE, "Error while executing update method: " + query);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void executeQuery(final String query, final Consumer<ResultSet> callback, final Object... objects) {
|
||||
try (final Connection connection = hikariDataSource.getConnection()) {
|
||||
try (final PreparedStatement preparedStatement = connection.prepareStatement(query)) {
|
||||
int current = 1;
|
||||
for (final Object object : objects) {
|
||||
preparedStatement.setObject(current, object);
|
||||
current++;
|
||||
}
|
||||
|
||||
try (final ResultSet resultSet = preparedStatement.executeQuery()) {
|
||||
callback.accept(resultSet);
|
||||
}
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
logger.log(Level.SEVERE, "Error while executing query method: " + query);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void executeUpdate(final String query, final Object... objects) {
|
||||
executeUpdate(query, res -> {
|
||||
}, objects);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
hikariDataSource.close();
|
||||
}
|
||||
}
|
||||
-58
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.proxy.runnable;
|
||||
|
||||
import eu.kennytv.maintenance.api.proxy.MaintenanceProxy;
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.core.runnable.MaintenanceRunnableBase;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.Component;
|
||||
|
||||
public class SingleMaintenanceRunnable extends MaintenanceRunnableBase {
|
||||
protected final Server server;
|
||||
|
||||
public SingleMaintenanceRunnable(final MaintenancePlugin plugin, final Settings settings, final int seconds, final boolean enable, final Server server) {
|
||||
super(plugin, settings, seconds, enable);
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void broadcast(final Component component) {
|
||||
server.broadcast(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finish() {
|
||||
((MaintenanceProxy) plugin).setMaintenanceToServer(server, enable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Component getStartMessage() {
|
||||
return settings.getMessage("singleStarttimerBroadcast",
|
||||
"%TIME%", getTime(),
|
||||
"%SERVER%", server.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Component getEndMessage() {
|
||||
return settings.getMessage("singleEndtimerBroadcast",
|
||||
"%TIME%", getTime(),
|
||||
"%SERVER%", server.getName());
|
||||
}
|
||||
}
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.proxy.runnable;
|
||||
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.core.proxy.MaintenanceProxyPlugin;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.Component;
|
||||
import java.time.Duration;
|
||||
|
||||
public final class SingleMaintenanceScheduleRunnable extends SingleMaintenanceRunnable {
|
||||
private final int maintenanceDurationSeconds;
|
||||
|
||||
public SingleMaintenanceScheduleRunnable(final MaintenancePlugin plugin, final Settings settings, final int seconds, final int maintenanceDuration, final Server server) {
|
||||
super(plugin, settings, seconds, true, server);
|
||||
this.maintenanceDurationSeconds = maintenanceDuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finish() {
|
||||
super.finish();
|
||||
((MaintenanceProxyPlugin) plugin).startSingleMaintenanceRunnable(server, Duration.ofSeconds(maintenanceDurationSeconds), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Component getStartMessage() {
|
||||
return settings.getMessage("singleScheduletimerBroadcast",
|
||||
"%SERVER%", server.getName(),
|
||||
"%TIME%", getTime(), "%DURATION%", plugin.getFormattedTime(maintenanceDurationSeconds));
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.proxy.server;
|
||||
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.Component;
|
||||
|
||||
public final class DummyServer implements Server {
|
||||
private final String name;
|
||||
|
||||
public DummyServer(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPlayers() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcast(final Component component) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegisteredServer() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.proxy.util;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ProfileLookup {
|
||||
private final UUID uuid;
|
||||
private final String name;
|
||||
|
||||
public ProfileLookup(final UUID uuid, final String name) {
|
||||
this.uuid = uuid;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.proxy.util;
|
||||
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ProxyOfflineSenderInfo implements ProxySenderInfo {
|
||||
private final UUID uuid;
|
||||
private final String name;
|
||||
|
||||
public ProxyOfflineSenderInfo(final UUID uuid, final String name) {
|
||||
this.uuid = uuid;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccess(final Server server) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(final Component component) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final String permission) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(final Component component) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.proxy.util;
|
||||
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.Component;
|
||||
|
||||
public interface ProxySenderInfo extends SenderInfo {
|
||||
|
||||
boolean canAccess(Server server);
|
||||
|
||||
void disconnect(Component component);
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.proxy.util;
|
||||
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public final class ServerConnectResult {
|
||||
private final boolean cancel;
|
||||
private final Server target;
|
||||
|
||||
public ServerConnectResult(final boolean cancel) {
|
||||
this.cancel = cancel;
|
||||
this.target = null;
|
||||
}
|
||||
|
||||
public ServerConnectResult(final Server target) {
|
||||
this.cancel = false;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancel;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Server getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServerConnectResult{" +
|
||||
"cancel=" + cancel +
|
||||
", target=" + target +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
plugins {
|
||||
id("net.kyori.blossom")
|
||||
id("org.jetbrains.gradle.plugin.idea-ext")
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
blossom {
|
||||
javaSources {
|
||||
property("version", project.version.toString())
|
||||
property("impl_version", "git-Maintenance-${project.version}:${rootProject.latestCommitHash()}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(projects.maintenanceApi)
|
||||
api(projects.adventure.adventureApi) {
|
||||
targetConfiguration = "shadow"
|
||||
}
|
||||
compileOnly(libs.luckperms)
|
||||
compileOnly(libs.serverlistplus)
|
||||
compileOnly(libs.guava)
|
||||
compileOnly(libs.gson)
|
||||
compileOnly(libs.snakeyaml)
|
||||
}
|
||||
|
||||
java {
|
||||
withJavadocJar()
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.util;
|
||||
|
||||
public final class MaintenanceVersion {
|
||||
|
||||
public static final String VERSION = "{{ version }}";
|
||||
private static final String IMPLEMENTATION_VERSION = "{{ impl_version }}";
|
||||
|
||||
public static String getVersion() {
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
public static String getImplementationVersion() {
|
||||
return IMPLEMENTATION_VERSION;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core;
|
||||
|
||||
import eu.kennytv.maintenance.api.Maintenance;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface MaintenanceBase {
|
||||
|
||||
/**
|
||||
* This method is used internally when getting the api instance.
|
||||
*
|
||||
* @return {@link Maintenance} instance
|
||||
*/
|
||||
Maintenance getApi();
|
||||
}
|
||||
@@ -1,479 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.io.CharStreams;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import eu.kennytv.maintenance.api.Maintenance;
|
||||
import eu.kennytv.maintenance.api.MaintenanceProvider;
|
||||
import eu.kennytv.maintenance.api.event.MaintenanceChangedEvent;
|
||||
import eu.kennytv.maintenance.api.event.manager.EventManager;
|
||||
import eu.kennytv.maintenance.core.command.MaintenanceCommand;
|
||||
import eu.kennytv.maintenance.core.dump.MaintenanceDump;
|
||||
import eu.kennytv.maintenance.core.dump.PluginDump;
|
||||
import eu.kennytv.maintenance.core.hook.ServerListPlusHook;
|
||||
import eu.kennytv.maintenance.core.runnable.MaintenanceRunnable;
|
||||
import eu.kennytv.maintenance.core.runnable.MaintenanceScheduleRunnable;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import eu.kennytv.maintenance.core.util.ServerType;
|
||||
import eu.kennytv.maintenance.core.util.Task;
|
||||
import eu.kennytv.maintenance.core.util.Version;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.Component;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.format.NamedTextColor;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class MaintenancePlugin implements Maintenance {
|
||||
public static final Gson GSON = new GsonBuilder().create();
|
||||
public static final String HANGAR_URL = "https://hangar.papermc.io/kennytv/Maintenance";
|
||||
private static final Pattern INT_PATTERN = Pattern.compile("[0-9]+");
|
||||
protected final EventManager eventManager;
|
||||
protected final Version version;
|
||||
protected Settings settings;
|
||||
protected ServerListPlusHook serverListPlusHook;
|
||||
protected MaintenanceRunnable runnable;
|
||||
protected MaintenanceCommand commandManager;
|
||||
private final Component prefix;
|
||||
private final ServerType serverType;
|
||||
private Version newestVersion;
|
||||
private boolean debug;
|
||||
|
||||
protected MaintenancePlugin(final String version, final ServerType serverType) {
|
||||
this.version = new Version(version);
|
||||
this.serverType = serverType;
|
||||
this.prefix = Component.text()
|
||||
.append(Component.text().content("[").color(NamedTextColor.DARK_GRAY))
|
||||
.append(Component.text().content("Maintenance").color(NamedTextColor.YELLOW))
|
||||
.append(Component.text().content("]").color(NamedTextColor.DARK_GRAY))
|
||||
.append(Component.text(" "))
|
||||
.build();
|
||||
this.eventManager = new eu.kennytv.maintenance.core.event.EventManager();
|
||||
MaintenanceProvider.setMaintenance(this);
|
||||
}
|
||||
|
||||
public void disable() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaintenance(final boolean maintenance) {
|
||||
settings.setMaintenance(maintenance);
|
||||
settings.getConfig().set("maintenance-enabled", maintenance);
|
||||
settings.saveConfig();
|
||||
serverActions(maintenance);
|
||||
|
||||
for (final String command : (maintenance ? settings.getCommandsOnMaintenanceEnable() : settings.getCommandsOnMaintenanceDisable())) {
|
||||
try {
|
||||
executeConsoleCommand(command);
|
||||
} catch (final Exception e) {
|
||||
getLogger().log(Level.SEVERE, "Error while executing extra maintenance " + (maintenance ? "enable" : "disable") + " command: " + command, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void serverActions(final boolean maintenance) {
|
||||
if (isTaskRunning()) {
|
||||
cancelTask();
|
||||
}
|
||||
if (serverListPlusHook != null && settings.isEnablePingMessages()) {
|
||||
serverListPlusHook.setEnabled(!maintenance);
|
||||
}
|
||||
|
||||
if (maintenance) {
|
||||
broadcast(settings.getMessage("maintenanceActivated"));
|
||||
if (settings.isKickOnlinePlayers()) {
|
||||
kickPlayers();
|
||||
}
|
||||
} else {
|
||||
broadcast(settings.getMessage("maintenanceDeactivated"));
|
||||
}
|
||||
|
||||
eventManager.callEvent(new MaintenanceChangedEvent(maintenance));
|
||||
}
|
||||
|
||||
public String replacePingVariables(String component) {
|
||||
if (component.contains("%TIMER%")) {
|
||||
component = component.replace("%TIMER%", getTimerMessage());
|
||||
}
|
||||
component = component.replace("%ONLINE%", String.valueOf(getOnlinePlayers()));
|
||||
component = component.replace("%MAX%", String.valueOf(getMaxPlayers()));
|
||||
return component;
|
||||
}
|
||||
|
||||
public String getTimerMessage() {
|
||||
if (!isTaskRunning()) {
|
||||
return settings.getLanguageString("motdTimerNotRunning");
|
||||
}
|
||||
|
||||
final int preHours = runnable.getSecondsLeft() / 60;
|
||||
final int minutes = preHours % 60;
|
||||
final int seconds = runnable.getSecondsLeft() % 60;
|
||||
return settings.getLanguageString("motdTimer",
|
||||
"%HOURS%", String.format("%02d", preHours / 60),
|
||||
"%MINUTES%", String.format("%02d", minutes),
|
||||
"%SECONDS%", String.format("%02d", seconds));
|
||||
}
|
||||
|
||||
public String getFormattedTime(final int timeSeconds) {
|
||||
final int preHours = timeSeconds / 60;
|
||||
final int minutes = preHours % 60;
|
||||
final int seconds = timeSeconds % 60;
|
||||
|
||||
final StringBuilder buider = new StringBuilder();
|
||||
append(buider, "hour", preHours / 60);
|
||||
append(buider, "minute", minutes);
|
||||
append(buider, "second", seconds);
|
||||
return buider.toString();
|
||||
}
|
||||
|
||||
private void append(final StringBuilder builder, final String timeUnit, final int time) {
|
||||
if (time == 0) return;
|
||||
if (builder.length() != 0) {
|
||||
builder.append(' ');
|
||||
}
|
||||
builder.append(time).append(' ').append(settings.language.getString(time == 1 ? timeUnit : timeUnit + "s"));
|
||||
}
|
||||
|
||||
public void startMaintenanceRunnable(final Duration duration, final boolean enable) {
|
||||
runnable = new MaintenanceRunnable(this, settings, (int) duration.getSeconds(), enable);
|
||||
// Save the endtimer to be able to continue it after a server stop
|
||||
if (settings.isSaveEndtimerOnStop() && !runnable.shouldEnable()) {
|
||||
settings.setSavedEndtimer(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(runnable.getSecondsLeft()));
|
||||
}
|
||||
}
|
||||
|
||||
public void scheduleMaintenanceRunnable(final Duration enableIn, final Duration maintenanceDuration) {
|
||||
runnable = new MaintenanceScheduleRunnable(this, settings, (int) enableIn.getSeconds(), (int) maintenanceDuration.getSeconds());
|
||||
}
|
||||
|
||||
public boolean updateAvailable() {
|
||||
try {
|
||||
checkNewestVersion();
|
||||
return version.compareTo(newestVersion) < 0;
|
||||
} catch (final Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void continueLastEndtimer() {
|
||||
if (!settings.isSaveEndtimerOnStop()) return;
|
||||
if (settings.getSavedEndtimer() == 0) return;
|
||||
|
||||
final long current = System.currentTimeMillis();
|
||||
getLogger().info("Found interrupted endtimer from last uptime...");
|
||||
if (!isMaintenance()) {
|
||||
getLogger().info("Maintenance has already been disabled, thus the timer has been cancelled.");
|
||||
settings.setSavedEndtimer(0);
|
||||
} else if (settings.getSavedEndtimer() < current) {
|
||||
getLogger().info("The endtimer has already expired, maintenance has been disabled.");
|
||||
setMaintenance(false);
|
||||
settings.setSavedEndtimer(0);
|
||||
} else {
|
||||
startMaintenanceRunnable(Duration.ofMillis(settings.getSavedEndtimer() - current), false);
|
||||
getLogger().info("The timer has been continued - maintenance will be disabled in: " + getTimerMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected void sendEnableMessage() {
|
||||
if (!settings.hasUpdateChecks()) return;
|
||||
async(() -> {
|
||||
try {
|
||||
checkNewestVersion();
|
||||
} catch (final Exception e) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int compare = version.compareTo(newestVersion);
|
||||
if (compare < 0) {
|
||||
getLogger().warning("Newest version available: Version " + newestVersion + ", you're on " + version);
|
||||
} else if (compare > 0) {
|
||||
if (version.getTag().equalsIgnoreCase("snapshot")) {
|
||||
getLogger().info("You're running a development version, please report bugs on the Discord server (https://discord.gg/vGCUzHq) or the GitHub issue tracker (https://github.com/kennytv/Maintenance/issues)");
|
||||
} else {
|
||||
getLogger().info("You're running a version, that doesn't exist!");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean installUpdate() throws Exception {
|
||||
// Sponge and Velocity need their own jar
|
||||
final String platformInfix = serverType == ServerType.VELOCITY ? "Velocity-" : serverType == ServerType.SPONGE ? "Sponge-" : "";
|
||||
final String fileName = "Maintenance-" + platformInfix + newestVersion + ".jar";
|
||||
final Path tempFilePath = Paths.get(getPluginFolder() + "Maintenance.tmp");
|
||||
final URLConnection connection = new URL("https://github.com/kennytv/Maintenance/releases/download/" + newestVersion + "/" + fileName).openConnection();
|
||||
try (final BufferedInputStream is = new BufferedInputStream(connection.getInputStream());
|
||||
final BufferedOutputStream os = new BufferedOutputStream(Files.newOutputStream(tempFilePath))) {
|
||||
writeFile(is, os);
|
||||
}
|
||||
|
||||
final File file = tempFilePath.toFile();
|
||||
final long newlength = file.length();
|
||||
if (newlength < 10_000) {
|
||||
// Sanity check the file length
|
||||
file.delete();
|
||||
return false;
|
||||
}
|
||||
|
||||
try (final InputStream is = Files.newInputStream(file.toPath());
|
||||
final BufferedOutputStream os = new BufferedOutputStream(Files.newOutputStream(getPluginFile().toPath()))) {
|
||||
writeFile(is, os);
|
||||
}
|
||||
|
||||
file.delete();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void writeFile(final InputStream is, final OutputStream os) throws IOException {
|
||||
final byte[] chunk = new byte[1024];
|
||||
int chunkSize;
|
||||
while ((chunkSize = is.read(chunk)) != -1) {
|
||||
os.write(chunk, 0, chunkSize);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkNewestVersion() throws Exception {
|
||||
final URLConnection connection = new URL("https://hangar.papermc.io/api/v1/projects/Maintenance/latestrelease").openConnection();
|
||||
connection.setRequestProperty("User-Agent", "Maintenance/" + getVersion());
|
||||
try (final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
|
||||
final String newVersionString = reader.readLine();
|
||||
final Version newVersion = new Version(newVersionString);
|
||||
if (!newVersion.equals(version)) {
|
||||
newestVersion = newVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String pasteDump() {
|
||||
final MaintenanceDump dump = new MaintenanceDump(this, settings);
|
||||
try {
|
||||
final HttpURLConnection connection = (HttpURLConnection) new URL("https://api.pastes.dev/post").openConnection();
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("User-Agent", "Maintenance/" + getVersion());
|
||||
connection.setRequestProperty("Content-Type", "text/plain");
|
||||
|
||||
try (final OutputStream out = connection.getOutputStream()) {
|
||||
out.write(new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create().toJson(dump).getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
if (connection.getResponseCode() == 503) {
|
||||
getLogger().warning("Could not paste dump, pastes.dev down?");
|
||||
return null;
|
||||
}
|
||||
|
||||
try (final InputStream in = connection.getInputStream()) {
|
||||
final String output = CharStreams.toString(new InputStreamReader(in));
|
||||
final JsonObject jsonOutput = GSON.fromJson(output, JsonObject.class);
|
||||
if (!jsonOutput.has("key")) {
|
||||
getLogger().log(Level.WARNING, "Could not paste dump, there was no key returned :(");
|
||||
return null;
|
||||
}
|
||||
|
||||
return jsonOutput.get("key").getAsString();
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
getLogger().log(Level.WARNING, "Could not paste dump :(", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void loadMaintenanceIcon() {
|
||||
final File file = new File(getDataFolder(), "maintenance-icon.png");
|
||||
if (!file.exists()) {
|
||||
getLogger().warning("Could not find a 'maintenance-icon.png' file - did you create one in the plugin's folder?");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
loadIcon(file);
|
||||
} catch (final Exception e) {
|
||||
getLogger().log(Level.WARNING, "Could not load the 'maintenance-icon.png' file!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void cancelTask() {
|
||||
if (settings.isSaveEndtimerOnStop() && !runnable.shouldEnable()) {
|
||||
settings.setSavedEndtimer(0);
|
||||
}
|
||||
|
||||
runnable.getTask().cancel();
|
||||
runnable = null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public UUID checkUUID(final SenderInfo sender, final String s) {
|
||||
final UUID uuid;
|
||||
try {
|
||||
uuid = UUID.fromString(s);
|
||||
} catch (final Exception e) {
|
||||
sender.send(settings.getMessage("invalidUuid"));
|
||||
return null;
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public String[] removeArrayIndex(final String[] args, final int index) {
|
||||
final List<String> argsList = Lists.newArrayList(args);
|
||||
argsList.remove(index);
|
||||
return argsList.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public boolean isNumeric(final String string) {
|
||||
return INT_PATTERN.matcher(string).matches();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMaintenance() {
|
||||
return settings.isMaintenance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTaskRunning() {
|
||||
return runnable != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Settings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventManager getEventManager() {
|
||||
return eventManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return version.toString();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> getMaintenanceServersDump() {
|
||||
return isMaintenance() ? Arrays.asList("global") : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebug() {
|
||||
return debug;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDebug(final boolean debug) {
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
public int getSaltLevel() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public Version getNewestVersion() {
|
||||
return newestVersion;
|
||||
}
|
||||
|
||||
public Component prefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #isTaskRunning()
|
||||
*/
|
||||
@Nullable
|
||||
public MaintenanceRunnable getRunnable() {
|
||||
return runnable;
|
||||
}
|
||||
|
||||
public MaintenanceCommand getCommandManager() {
|
||||
return commandManager;
|
||||
}
|
||||
|
||||
public ServerType getServerType() {
|
||||
return serverType;
|
||||
}
|
||||
|
||||
protected String getPluginFolder() {
|
||||
return "plugins/";
|
||||
}
|
||||
|
||||
public abstract void async(Runnable runnable);
|
||||
|
||||
protected abstract void executeConsoleCommand(String command);
|
||||
|
||||
public abstract void broadcast(Component component);
|
||||
|
||||
public abstract Task startMaintenanceRunnable(Runnable runnable);
|
||||
|
||||
/**
|
||||
* Gets the offline sender info of a player.
|
||||
* This method may do a web lookup.
|
||||
*
|
||||
* @param name name of the player
|
||||
*/
|
||||
public abstract CompletableFuture<@Nullable SenderInfo> getOfflinePlayer(String name);
|
||||
|
||||
public abstract CompletableFuture<@Nullable SenderInfo> getOfflinePlayer(UUID uuid);
|
||||
|
||||
public abstract File getDataFolder();
|
||||
|
||||
@Nullable
|
||||
public InputStream getResource(final String name) {
|
||||
return this.getClass().getClassLoader().getResourceAsStream(name);
|
||||
}
|
||||
|
||||
public abstract Logger getLogger();
|
||||
|
||||
public abstract String getServerVersion();
|
||||
|
||||
public abstract List<PluginDump> getPlugins();
|
||||
|
||||
protected abstract void loadIcon(File file) throws Exception;
|
||||
|
||||
protected abstract void kickPlayers();
|
||||
|
||||
protected abstract File getPluginFile();
|
||||
|
||||
protected abstract int getOnlinePlayers();
|
||||
|
||||
protected abstract int getMaxPlayers();
|
||||
}
|
||||
@@ -1,616 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core;
|
||||
|
||||
import eu.kennytv.maintenance.api.event.MaintenanceReloadedEvent;
|
||||
import eu.kennytv.maintenance.core.config.Config;
|
||||
import eu.kennytv.maintenance.core.config.ConfigSection;
|
||||
import eu.kennytv.maintenance.core.util.ServerType;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.Component;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.TextComponent;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class Settings implements eu.kennytv.maintenance.api.Settings {
|
||||
public static final String NEW_LINE_REPLACEMENT = "<br>";
|
||||
private static final int CONFIG_VERSION = 9;
|
||||
private static final int LANGUAGE_VERSION = 2;
|
||||
private static final Random RANDOM = new Random();
|
||||
protected final MaintenancePlugin plugin;
|
||||
private final Map<UUID, String> whitelistedPlayers = new HashMap<>();
|
||||
private final String[] unsupportedFields;
|
||||
protected boolean maintenance;
|
||||
private Set<Integer> broadcastIntervals;
|
||||
private List<String> pingMessages;
|
||||
private List<String> timerSpecificPingMessages;
|
||||
private List<String> commandsOnMaintenanceEnable;
|
||||
private List<String> commandsOnMaintenanceDisable;
|
||||
private String legacyParsedPlayerCountMessage;
|
||||
private String legacyParsedTimerPlayerCountMessage;
|
||||
private List<String> legacyParsedPlayerCountHoverLines;
|
||||
private List<String> legacyParsedTimerPlayerCountHoverLines;
|
||||
private String prefixString;
|
||||
private String languageName;
|
||||
private boolean enablePingMessages;
|
||||
private boolean customPlayerCountMessage;
|
||||
private boolean customPlayerCountHoverMessage;
|
||||
private boolean customMaintenanceIcon;
|
||||
private boolean joinNotifications;
|
||||
private boolean updateChecks;
|
||||
private boolean saveEndtimerOnStop;
|
||||
private boolean kickOnlinePlayers;
|
||||
private boolean debug;
|
||||
private long savedEndtimer;
|
||||
|
||||
protected Config config;
|
||||
protected Config language;
|
||||
protected Config whitelist;
|
||||
|
||||
public Settings(final MaintenancePlugin plugin, final String... unsupportedFields) {
|
||||
this.plugin = plugin;
|
||||
this.unsupportedFields = unsupportedFields;
|
||||
if (!plugin.getDataFolder().exists()) {
|
||||
updatePluginDirectory();
|
||||
plugin.getDataFolder().mkdirs();
|
||||
}
|
||||
|
||||
createFile("config.yml");
|
||||
createFile("WhitelistedPlayers.yml");
|
||||
|
||||
reloadConfigs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfigs() {
|
||||
try {
|
||||
config = new Config(new File(plugin.getDataFolder(), "config.yml"), unsupportedFields);
|
||||
config.load();
|
||||
config.resetAwesomeHeader();
|
||||
whitelist = new Config(new File(plugin.getDataFolder(), "WhitelistedPlayers.yml"));
|
||||
whitelist.load();
|
||||
} catch (final Exception e) {
|
||||
throw new RuntimeException("Unable to load Maintenance files - probably a malformed config file", e);
|
||||
}
|
||||
|
||||
loadSettings();
|
||||
createLanguageFile();
|
||||
|
||||
try {
|
||||
language = new Config(new File(plugin.getDataFolder(), "language-" + languageName + ".yml"));
|
||||
language.load();
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException("Unable to load Maintenance language file - probably a malformed file", e);
|
||||
}
|
||||
|
||||
try {
|
||||
updateLanguageFile();
|
||||
} catch (final IOException e) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Couldn't update language file", e);
|
||||
}
|
||||
|
||||
prefixString = language.getString("prefix");
|
||||
|
||||
plugin.getEventManager().callEvent(new MaintenanceReloadedEvent());
|
||||
}
|
||||
|
||||
public void saveConfig() {
|
||||
try {
|
||||
config.save();
|
||||
} catch (final IOException e) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Couldn't save the config file!", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Public, as it is used in the MaintenanceAddon
|
||||
public void createFile(final String name) {
|
||||
createFile(name, name);
|
||||
}
|
||||
|
||||
private void createFile(final String name, final String from) {
|
||||
final File file = new File(plugin.getDataFolder(), name);
|
||||
if (!file.exists()) {
|
||||
try (final InputStream in = plugin.getResource(from)) {
|
||||
Files.copy(in, file.toPath());
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException("Unable to create " + name + " file for Maintenance!", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveWhitelistedPlayers() {
|
||||
try {
|
||||
whitelist.save();
|
||||
} catch (final IOException e) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Couldn't save the whitelisted players file!", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void createLanguageFile() {
|
||||
final String fileName = "language-" + languageName + ".yml";
|
||||
final File file = new File(plugin.getDataFolder(), fileName);
|
||||
if (file.exists()) return;
|
||||
|
||||
try (final InputStream in = plugin.getResource(fileName)) {
|
||||
Files.copy(in, file.toPath());
|
||||
} catch (final IOException e) {
|
||||
plugin.getLogger().warning("Unable to provide language " + languageName);
|
||||
// Fall back to English language (if not already selected)
|
||||
if (!languageName.equals("en")) {
|
||||
plugin.getLogger().warning("Falling back to default language: en");
|
||||
languageName = "en";
|
||||
createLanguageFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadSettings() {
|
||||
updateConfig();
|
||||
|
||||
final ConfigSection pingMessageSection = config.getSection("ping-message");
|
||||
enablePingMessages = pingMessageSection.getBoolean("enabled", true);
|
||||
// Can't store this pre-parsed as components because gradients will break replacements
|
||||
pingMessages = loadPingMessages(pingMessageSection.getStringList("messages"));
|
||||
if (pingMessageSection.getBoolean("enable-timer-specific-messages")) {
|
||||
timerSpecificPingMessages = loadPingMessages(pingMessageSection.getStringList("timer-messages"));
|
||||
} else {
|
||||
timerSpecificPingMessages = null;
|
||||
}
|
||||
|
||||
maintenance = config.getBoolean("maintenance-enabled");
|
||||
commandsOnMaintenanceEnable = config.getStringList("commands-on-maintenance-enable");
|
||||
commandsOnMaintenanceDisable = config.getStringList("commands-on-maintenance-disable");
|
||||
customMaintenanceIcon = config.getBoolean("custom-maintenance-icon");
|
||||
joinNotifications = config.getBoolean("send-join-notification");
|
||||
broadcastIntervals = new HashSet<>(config.getIntList("timer-broadcast-for-seconds"));
|
||||
|
||||
// Player count and player list hover messages are only accepted and rendered as legacy chat
|
||||
if (plugin.getServerType() != ServerType.SPONGE) {
|
||||
final ConfigSection playerCountMessageSection = config.getSection("player-count-message");
|
||||
customPlayerCountMessage = playerCountMessageSection.getBoolean("enabled");
|
||||
legacyParsedPlayerCountMessage = toLegacy(parse(getConfigMessage(playerCountMessageSection, "message")));
|
||||
if (playerCountMessageSection.getBoolean("enable-timer-specific-message")) {
|
||||
legacyParsedTimerPlayerCountMessage = toLegacy(parse(getConfigMessage(playerCountMessageSection, "timer-message")));
|
||||
} else {
|
||||
legacyParsedTimerPlayerCountMessage = null;
|
||||
}
|
||||
}
|
||||
|
||||
final ConfigSection listHoverMessageSection = config.getSection("player-list-hover-message");
|
||||
customPlayerCountHoverMessage = listHoverMessageSection.getBoolean("enabled");
|
||||
legacyParsedPlayerCountHoverLines = new ArrayList<>();
|
||||
for (final String line : listHoverMessageSection.getString("message").split("<br>")) {
|
||||
legacyParsedPlayerCountHoverLines.add(toLegacy(parse(line)));
|
||||
}
|
||||
if (listHoverMessageSection.getBoolean("enable-timer-specific-message")) {
|
||||
legacyParsedTimerPlayerCountHoverLines = new ArrayList<>();
|
||||
for (final String line : listHoverMessageSection.getString("timer-message").split("<br>")) {
|
||||
legacyParsedTimerPlayerCountHoverLines.add(toLegacy(parse(line)));
|
||||
}
|
||||
} else {
|
||||
legacyParsedTimerPlayerCountHoverLines = null;
|
||||
}
|
||||
|
||||
languageName = config.getString("language").toLowerCase();
|
||||
kickOnlinePlayers = config.getBoolean("kick-online-players", true);
|
||||
updateChecks = config.getBoolean("update-checks", true);
|
||||
debug = config.getBoolean("debug");
|
||||
|
||||
final ConfigSection section = config.getSection("continue-endtimer-after-restart");
|
||||
saveEndtimerOnStop = section.getBoolean("enabled");
|
||||
savedEndtimer = section.getLong("end");
|
||||
|
||||
if (customMaintenanceIcon) {
|
||||
plugin.loadMaintenanceIcon();
|
||||
}
|
||||
|
||||
whitelistedPlayers.clear();
|
||||
for (final Map.Entry<String, Object> entry : whitelist.getValues().entrySet()) {
|
||||
try {
|
||||
whitelistedPlayers.put(UUID.fromString(entry.getKey()), String.valueOf(entry.getValue()));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
plugin.getLogger().warning("Invalid WhitelistedPlayers entry: " + entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
loadExtraSettings();
|
||||
}
|
||||
|
||||
private void updatePluginDirectory() {
|
||||
// All plugin identifiers were changed to 'Maintenance' ('maintenance' for Sponge and Velocity) in 3.0.5
|
||||
String oldDirName = "Maintenance" + plugin.getServerType();
|
||||
if (plugin.getServerType() == ServerType.SPONGE || plugin.getServerType() == ServerType.VELOCITY) {
|
||||
oldDirName = oldDirName.toLowerCase(Locale.ROOT);
|
||||
} else if (plugin.getServerType() == ServerType.SPIGOT) {
|
||||
oldDirName = "MaintenanceSpigot";
|
||||
}
|
||||
|
||||
final File oldDir = new File(plugin.getDataFolder().getParentFile(), oldDirName);
|
||||
if (!oldDir.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Files.move(oldDir.toPath(), plugin.getDataFolder().toPath());
|
||||
plugin.getLogger().info("Moved old " + oldDirName + " to new " + plugin.getDataFolder().getName() + " directory!");
|
||||
} catch (final IOException e) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Error while copying " + oldDirName + " to new " + plugin.getDataFolder().getName() + " directory!", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateConfig() {
|
||||
final int version = config.getInt("config-version");
|
||||
if (version != CONFIG_VERSION) {
|
||||
plugin.getLogger().info("Updating config to the latest version...");
|
||||
if (version < 6) {
|
||||
// Legacy text to MiniMessage
|
||||
config.getStringList("pingmessages").replaceAll(this::legacyToMinimessage);
|
||||
config.getStringList("timerspecific-pingmessages").replaceAll(this::legacyToMinimessage);
|
||||
config.set("playercounthovermessage", legacyToMinimessage(config.getString("playercounthovermessage")));
|
||||
config.set("playercountmessage", legacyToMinimessage(config.getString("playercountmessage")));
|
||||
}
|
||||
if (version < 9) {
|
||||
config.move("enable-pingmessages", "ping-message.enabled");
|
||||
config.move("pingmessages", "ping-message.messages");
|
||||
config.move("enable-timerspecific-messages", "ping-message.enable-timer-specific-messages");
|
||||
config.move("timerspecific-pingmessages", "ping-message.timer-messages");
|
||||
|
||||
config.move("enable-playercountmessage", "player-count-message.enabled");
|
||||
config.move("playercountmessage", "player-count-message.message");
|
||||
|
||||
config.move("enable-playercounthovermessage", "player-list-hover-message.enabled");
|
||||
config.move("playercounthovermessage", "player-list-hover-message.message");
|
||||
}
|
||||
|
||||
createFile("config-new.yml", "config.yml");
|
||||
final File file = new File(plugin.getDataFolder(), "config-new.yml");
|
||||
final Config tempConfig = new Config(file, unsupportedFields);
|
||||
try {
|
||||
tempConfig.load();
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
config.addMissingFields(tempConfig);
|
||||
config.replaceComments(tempConfig);
|
||||
config.set("config-version", CONFIG_VERSION);
|
||||
|
||||
file.delete();
|
||||
tempConfig.clear();
|
||||
|
||||
saveConfig();
|
||||
plugin.getLogger().info("Done! Updated config!");
|
||||
}
|
||||
}
|
||||
|
||||
private void updateLanguageFile() throws IOException {
|
||||
final int version = language.getInt("language-version");
|
||||
if (version == LANGUAGE_VERSION) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Updating language file to the latest version...");
|
||||
if (version < 1) {
|
||||
for (final Map.Entry<String, Object> entry : language.getValues().entrySet()) {
|
||||
if (!(entry.getValue() instanceof String)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String value = (String) entry.getValue();
|
||||
value = value.replace("&8[&eMaintenance&8] ", "<prefix>");
|
||||
value = legacyToMinimessage(value);
|
||||
value = value.replace("%NEWLINE%", NEW_LINE_REPLACEMENT);
|
||||
language.set(entry.getKey(), value);
|
||||
}
|
||||
}
|
||||
|
||||
final String filePrefix = "language-" + languageName;
|
||||
createFile(filePrefix + "-new.yml", filePrefix + ".yml");
|
||||
|
||||
final File file = new File(plugin.getDataFolder(), filePrefix + "-new.yml");
|
||||
final Config tempConfig = new Config(file);
|
||||
try {
|
||||
tempConfig.load();
|
||||
} finally {
|
||||
file.delete();
|
||||
}
|
||||
|
||||
language.addMissingFields(tempConfig);
|
||||
language.replaceComments(tempConfig);
|
||||
tempConfig.clear();
|
||||
|
||||
language.set("language-version", LANGUAGE_VERSION);
|
||||
|
||||
language.save();
|
||||
plugin.getLogger().info("Updated language file!");
|
||||
}
|
||||
|
||||
private String legacyToMinimessage(final String s) {
|
||||
final TextComponent component = LegacyComponentSerializer.legacyAmpersand().deserialize(s);
|
||||
final String serialized = MiniMessage.miniMessage().serialize(component);
|
||||
//TODO hack to remove explicit closing until fixed in MM
|
||||
return serialized.replaceAll("</[a-z_]+>", "");
|
||||
}
|
||||
|
||||
private String getConfigMessage(final ConfigSection section, final String path) {
|
||||
final String s = section.getString(path);
|
||||
if (s == null) {
|
||||
plugin.getLogger().warning("The config file is missing the following string: " + path);
|
||||
return path;
|
||||
}
|
||||
return replaceNewlineVar(s);
|
||||
}
|
||||
|
||||
public String getConfigMessage(final String path) {
|
||||
return getConfigMessage(config, path);
|
||||
}
|
||||
|
||||
public String getLanguageString(final String path, final String... replacements) {
|
||||
String s = language.getString(path);
|
||||
if (s == null) {
|
||||
plugin.getLogger().warning("The language file is missing the following string: " + path);
|
||||
return path;
|
||||
}
|
||||
if (replacements.length != 0) {
|
||||
if (replacements.length % 2 != 0) {
|
||||
throw new IllegalArgumentException("Invalid replacement count: " + replacements.length);
|
||||
}
|
||||
|
||||
for (int i = 0; i < replacements.length; i += 2) {
|
||||
final String key = replacements[i];
|
||||
s = s.replace(key, replacements[i + 1]);
|
||||
}
|
||||
}
|
||||
return replaceNewlineVar(s).replace("<prefix>", prefixString);
|
||||
}
|
||||
|
||||
public @Nullable String getLanguageStringOrNull(final String path, final String... replacements) {
|
||||
return language.contains(path) ? getLanguageString(path, replacements) : null;
|
||||
}
|
||||
|
||||
public Component getMessage(final String path, final String... replacements) {
|
||||
return parse(getLanguageString(path, replacements));
|
||||
}
|
||||
|
||||
// TODO Cache platform components if there are no replacements
|
||||
public Component getRandomPingMessage() {
|
||||
if (plugin.isTaskRunning() && !plugin.getRunnable().shouldEnable()
|
||||
&& hasTimerSpecificPingMessages() && !timerSpecificPingMessages.isEmpty()) {
|
||||
return getPingMessage(timerSpecificPingMessages);
|
||||
}
|
||||
return pingMessages.isEmpty() ? Component.empty() : getPingMessage(pingMessages);
|
||||
}
|
||||
|
||||
private Component getPingMessage(final List<String> list) {
|
||||
final String component = list.size() == 1 ? list.get(0) : list.get(RANDOM.nextInt(list.size()));
|
||||
return parse(plugin.replacePingVariables(component));
|
||||
}
|
||||
|
||||
private List<String> loadPingMessages(final List<String> list) {
|
||||
final List<String> components = new ArrayList<>(list.size());
|
||||
for (final String s : list) {
|
||||
components.add(replaceNewlineVar(s));
|
||||
}
|
||||
return components;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeWhitelistedPlayer(final UUID uuid) {
|
||||
if (whitelistedPlayers.remove(uuid) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
whitelist.remove(uuid.toString());
|
||||
saveWhitelistedPlayers();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeWhitelistedPlayer(final String name) {
|
||||
UUID uuid = null;
|
||||
for (final Map.Entry<UUID, String> e : whitelistedPlayers.entrySet()) {
|
||||
if (e.getValue().equalsIgnoreCase(name)) {
|
||||
uuid = e.getKey();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (uuid == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
whitelistedPlayers.remove(uuid);
|
||||
whitelist.remove(uuid.toString());
|
||||
saveWhitelistedPlayers();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addWhitelistedPlayer(final UUID uuid, final String name) {
|
||||
final boolean added = whitelistedPlayers.put(uuid, name) == null;
|
||||
whitelist.set(uuid.toString(), name);
|
||||
saveWhitelistedPlayers();
|
||||
return added;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<UUID, String> getWhitelistedPlayers() {
|
||||
return whitelistedPlayers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWhitelisted(final UUID uuid) {
|
||||
return whitelistedPlayers.containsKey(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMaintenance() {
|
||||
return maintenance;
|
||||
}
|
||||
|
||||
public void setMaintenance(final boolean maintenance) {
|
||||
this.maintenance = maintenance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnablePingMessages() {
|
||||
return enablePingMessages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJoinNotifications() {
|
||||
return joinNotifications;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomIcon() {
|
||||
return customMaintenanceIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean debugEnabled() {
|
||||
return debug;
|
||||
}
|
||||
|
||||
public boolean hasUpdateChecks() {
|
||||
return updateChecks;
|
||||
}
|
||||
|
||||
public boolean isSaveEndtimerOnStop() {
|
||||
return saveEndtimerOnStop;
|
||||
}
|
||||
|
||||
public boolean hasTimerSpecificPingMessages() {
|
||||
return timerSpecificPingMessages != null;
|
||||
}
|
||||
|
||||
public boolean isKickOnlinePlayers() {
|
||||
return kickOnlinePlayers;
|
||||
}
|
||||
|
||||
public long getSavedEndtimer() {
|
||||
return savedEndtimer;
|
||||
}
|
||||
|
||||
public void setSavedEndtimer(final long millis) {
|
||||
if (savedEndtimer == millis) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.savedEndtimer = millis;
|
||||
config.getSection("continue-endtimer-after-restart").set("end", millis);
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
public Config getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public List<String> getPingMessages() {
|
||||
return pingMessages;
|
||||
}
|
||||
|
||||
public List<String> getCommandsOnMaintenanceEnable() {
|
||||
return commandsOnMaintenanceEnable;
|
||||
}
|
||||
|
||||
public List<String> getCommandsOnMaintenanceDisable() {
|
||||
return commandsOnMaintenanceDisable;
|
||||
}
|
||||
|
||||
public @Nullable List<String> getTimerSpecificPingMessages() {
|
||||
return timerSpecificPingMessages;
|
||||
}
|
||||
|
||||
public Set<Integer> getBroadcastIntervals() {
|
||||
return broadcastIntervals;
|
||||
}
|
||||
|
||||
public String getLegacyParsedPlayerCountMessage() {
|
||||
final String message = timerDependent(legacyParsedPlayerCountMessage, legacyParsedTimerPlayerCountMessage);
|
||||
return plugin.replacePingVariables(message);
|
||||
}
|
||||
|
||||
public String[] getLegacyParsedPlayerCountHoverLines() {
|
||||
final List<String> lines = timerDependent(legacyParsedPlayerCountHoverLines, legacyParsedTimerPlayerCountHoverLines);
|
||||
final String[] parsedLines = new String[lines.size()];
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
parsedLines[i] = plugin.replacePingVariables(lines.get(i));
|
||||
}
|
||||
return parsedLines;
|
||||
}
|
||||
|
||||
private <T> T timerDependent(final T normal, final @Nullable T timerSpecific) {
|
||||
return timerSpecific != null && plugin.isTaskRunning() && !plugin.getRunnable().shouldEnable() ? timerSpecific : normal;
|
||||
}
|
||||
|
||||
public Component getKickMessage() {
|
||||
return parse(plugin.replacePingVariables(getLanguageString("kickmessage")));
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return languageName;
|
||||
}
|
||||
|
||||
public boolean hasCustomPlayerCountMessage() {
|
||||
return customPlayerCountMessage;
|
||||
}
|
||||
|
||||
public boolean hasCustomPlayerCountHoverMessage() {
|
||||
return customPlayerCountHoverMessage;
|
||||
}
|
||||
|
||||
protected Component parse(final String s) {
|
||||
return MiniMessage.miniMessage().deserialize(s);
|
||||
}
|
||||
|
||||
protected String toLegacy(final Component component) {
|
||||
return LegacyComponentSerializer.legacySection().serialize(component);
|
||||
}
|
||||
|
||||
/*
|
||||
* Note on why this even exists: Yaml will force save all strings containing line breaks '\n' in this rather chunky format:
|
||||
* key: |-
|
||||
* First line text
|
||||
* Second line text.
|
||||
* ...
|
||||
*
|
||||
* This also happens to string lists, making those practically unreadable (in particular the motd list), as well as confusing for most users in general.
|
||||
* Because of this, I replace <br> manually, to spare users from these ugly breaks (before I inevitably switch to a different configuration library).
|
||||
*/
|
||||
protected String replaceNewlineVar(final String s) {
|
||||
return s.replace(NEW_LINE_REPLACEMENT, "\n");
|
||||
}
|
||||
|
||||
protected void loadExtraSettings() {
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.command;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class CommandInfo {
|
||||
protected final MaintenancePlugin plugin;
|
||||
private final String helpMessageKey;
|
||||
private final String permission;
|
||||
private final boolean visible;
|
||||
|
||||
protected CommandInfo(final MaintenancePlugin plugin, @Nullable final String permission) {
|
||||
this(plugin, permission, true);
|
||||
}
|
||||
|
||||
protected CommandInfo(final MaintenancePlugin plugin, @Nullable final String permission, final boolean visible) {
|
||||
this.plugin = plugin;
|
||||
this.permission = permission;
|
||||
// Just take the class name as the language key
|
||||
this.helpMessageKey = "help" + getClass().getSimpleName().replace("Command", "");
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
public boolean hasPermission(final SenderInfo sender) {
|
||||
return sender.hasMaintenancePermission(permission);
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
public Component getHelpMessage() {
|
||||
return getMessage(helpMessageKey);
|
||||
}
|
||||
|
||||
public List<String> getTabCompletion(final SenderInfo sender, final String[] args) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public abstract void execute(SenderInfo sender, String[] args);
|
||||
|
||||
protected boolean checkPermission(final SenderInfo sender, final String permission) {
|
||||
if (!sender.hasMaintenancePermission(permission)) {
|
||||
sender.send(getMessage("noPermission"));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean checkArgs(final SenderInfo sender, final String[] args, final int length) {
|
||||
if (args.length != length) {
|
||||
sender.send(getHelpMessage());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected Component getMessage(final String path, final String... replacements) {
|
||||
return plugin.getSettings().getMessage(path, replacements);
|
||||
}
|
||||
|
||||
protected Settings getSettings() {
|
||||
return plugin.getSettings();
|
||||
}
|
||||
}
|
||||
@@ -1,193 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.command;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.core.command.subcommand.AbortTimerCommand;
|
||||
import eu.kennytv.maintenance.core.command.subcommand.DebugCommand;
|
||||
import eu.kennytv.maintenance.core.command.subcommand.DumpCommand;
|
||||
import eu.kennytv.maintenance.core.command.subcommand.EndtimerCommand;
|
||||
import eu.kennytv.maintenance.core.command.subcommand.HelpCommand;
|
||||
import eu.kennytv.maintenance.core.command.subcommand.MotdCommand;
|
||||
import eu.kennytv.maintenance.core.command.subcommand.ReloadCommand;
|
||||
import eu.kennytv.maintenance.core.command.subcommand.RemoveMotdCommand;
|
||||
import eu.kennytv.maintenance.core.command.subcommand.ScheduleTimerCommand;
|
||||
import eu.kennytv.maintenance.core.command.subcommand.SetMotdCommand;
|
||||
import eu.kennytv.maintenance.core.command.subcommand.StarttimerCommand;
|
||||
import eu.kennytv.maintenance.core.command.subcommand.ToggleCommand;
|
||||
import eu.kennytv.maintenance.core.command.subcommand.UpdateCommand;
|
||||
import eu.kennytv.maintenance.core.command.subcommand.WhitelistAddCommand;
|
||||
import eu.kennytv.maintenance.core.command.subcommand.WhitelistCommand;
|
||||
import eu.kennytv.maintenance.core.command.subcommand.WhitelistRemoveCommand;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import java.time.Duration;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class MaintenanceCommand {
|
||||
private static final long MAX_TASK_DURATION_SECONDS = TimeUnit.DAYS.toSeconds(28);
|
||||
protected final MaintenancePlugin plugin;
|
||||
protected final Settings settings;
|
||||
private final Map<String, CommandInfo> commandExecutors = new LinkedHashMap<>();
|
||||
private final List<CommandInfo> commands = new ArrayList<>();
|
||||
private final HelpCommand help;
|
||||
|
||||
protected MaintenanceCommand(final MaintenancePlugin plugin, final Settings settings) {
|
||||
this.plugin = plugin;
|
||||
this.settings = settings;
|
||||
help = new HelpCommand(plugin);
|
||||
}
|
||||
|
||||
protected void registerCommands() {
|
||||
add(help, "help");
|
||||
add(new ReloadCommand(plugin), "reload");
|
||||
|
||||
addToggleAndTimerCommands();
|
||||
|
||||
add(new WhitelistCommand(plugin), "whitelist");
|
||||
add(new WhitelistAddCommand(plugin), "add");
|
||||
add(new WhitelistRemoveCommand(plugin), "remove");
|
||||
|
||||
add(new SetMotdCommand(plugin), "setmotd");
|
||||
add(new RemoveMotdCommand(plugin), "removemotd");
|
||||
add(new MotdCommand(plugin), "motd");
|
||||
|
||||
add(new UpdateCommand(plugin), "update", "forceupdate");
|
||||
add(new DumpCommand(plugin), "dump");
|
||||
add(new DebugCommand(plugin), "debug");
|
||||
}
|
||||
|
||||
protected void add(final CommandInfo command, final String... aliases) {
|
||||
commands.add(command);
|
||||
for (final String alias : aliases) {
|
||||
commandExecutors.put(alias, command);
|
||||
}
|
||||
}
|
||||
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (!sender.hasMaintenancePermission("command")) {
|
||||
sender.send(settings.getMessage("noPermission"));
|
||||
return;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
help.sendUsage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
final CommandInfo command = commandExecutors.get(args[0].toLowerCase());
|
||||
if (command == null) {
|
||||
help.sendUsage(sender);
|
||||
return;
|
||||
}
|
||||
if (!command.hasPermission(sender)) {
|
||||
sender.send(settings.getMessage("noPermission"));
|
||||
return;
|
||||
}
|
||||
|
||||
command.execute(sender, args);
|
||||
}
|
||||
|
||||
public List<String> getSuggestions(final SenderInfo sender, final String[] args) {
|
||||
if (!sender.hasMaintenancePermission("command") || args.length == 0) return Collections.emptyList();
|
||||
final String s = args[0].toLowerCase();
|
||||
if (args.length == 1) {
|
||||
final List<String> list = new ArrayList<>();
|
||||
for (final Map.Entry<String, CommandInfo> entry : commandExecutors.entrySet()) {
|
||||
final String command = entry.getKey();
|
||||
final CommandInfo info = entry.getValue();
|
||||
if (info.isVisible() && command.startsWith(s) && info.hasPermission(sender)) {
|
||||
list.add(command);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
final CommandInfo info = commandExecutors.get(args[0]);
|
||||
return info != null && info.hasPermission(sender) ? info.getTabCompletion(sender, args) : Collections.emptyList();
|
||||
}
|
||||
|
||||
public @Nullable Duration parseDurationAndCheckTask(final SenderInfo sender, final String time, final boolean taskCheck) {
|
||||
final Duration duration;
|
||||
if (plugin.isNumeric(time)) {
|
||||
// Assume minutes by default as per old command behavior
|
||||
duration = Duration.ofMinutes(Integer.parseInt(time));
|
||||
} else {
|
||||
try {
|
||||
// Only accept hours, minutes, and seconds
|
||||
duration = Duration.parse("PT" + time.toUpperCase(Locale.ROOT));
|
||||
} catch (final DateTimeParseException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (taskCheck) {
|
||||
if (plugin.isTaskRunning()) {
|
||||
sender.send(settings.getMessage("timerAlreadyRunning"));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
final long seconds = duration.getSeconds();
|
||||
if (seconds > MAX_TASK_DURATION_SECONDS) {
|
||||
sender.send(settings.getMessage("timerTooLong"));
|
||||
return null;
|
||||
}
|
||||
if (seconds < 1) {
|
||||
sender.sendRich("<i><dark_gray>[kennytv whispers to you] <gray>Think about running a timer for a negative amount of minutes. Doesn't work <b>that</b> <gray>well.");
|
||||
return null;
|
||||
}
|
||||
return duration;
|
||||
}
|
||||
|
||||
public @Nullable Duration parseDurationAndCheckTask(final SenderInfo sender, final String time) {
|
||||
return parseDurationAndCheckTask(sender, time, true);
|
||||
}
|
||||
|
||||
protected void addToggleAndTimerCommands() {
|
||||
add(new ToggleCommand(plugin), "on", "off");
|
||||
|
||||
add(new StarttimerCommand(plugin), "starttimer", "start");
|
||||
add(new EndtimerCommand(plugin), "endtimer", "end");
|
||||
add(new ScheduleTimerCommand(plugin), "scheduletimer", "schedule");
|
||||
add(new AbortTimerCommand(plugin), "aborttimer", "abort");
|
||||
}
|
||||
|
||||
public List<String> getServersCompletion(final String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<String> getMaintenanceServersCompletion(final String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<String> getPlayersCompletion() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<CommandInfo> getCommands() {
|
||||
return commands;
|
||||
}
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
public final class AbortTimerCommand extends CommandInfo {
|
||||
|
||||
public AbortTimerCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "timer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (args.length != 1) {
|
||||
sender.send(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.isTaskRunning()) {
|
||||
sender.send(getMessage("timerNotRunning"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.cancelTask();
|
||||
sender.send(getMessage("timerCancelled"));
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
public final class DebugCommand extends CommandInfo {
|
||||
|
||||
public DebugCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "debug", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 1)) return;
|
||||
|
||||
plugin.setDebug(!plugin.isDebug());
|
||||
sender.sendPrefixedRich("<gray>Debug mode is now " + (plugin.isDebug() ? "<green>enabled" : "<red>disabled"));
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.Component;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.TextComponent;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.event.ClickEvent;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.event.HoverEvent;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.format.NamedTextColor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class DumpCommand extends CommandInfo {
|
||||
private long lastDump;
|
||||
|
||||
public DumpCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "dump");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 1)) return;
|
||||
if (System.currentTimeMillis() - lastDump < TimeUnit.MINUTES.toMillis(5)) {
|
||||
sender.sendPrefixedRich("<red>You can only create a dump every 5 minutes!");
|
||||
return;
|
||||
}
|
||||
|
||||
lastDump = System.currentTimeMillis();
|
||||
sender.sendPrefixedRich("<gray>The dump is being created, this might take a moment.");
|
||||
plugin.async(() -> {
|
||||
final String key = plugin.pasteDump();
|
||||
if (key == null) {
|
||||
if (sender.isPlayer()) {
|
||||
sender.sendPrefixedRich("<red>Could not paste dump (see the console for details)");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final String url = "https://pastes.dev/" + key;
|
||||
sender.sendPrefixedRich("<red><click:open_url:'" + url + "'>" + url + "</click>");
|
||||
if (sender.isPlayer()) {
|
||||
final TextComponent text = Component.text().content("Click here to copy the link").color(NamedTextColor.GRAY)
|
||||
.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, url))
|
||||
.hoverEvent(HoverEvent.showText(Component.text("Click here to copy the link to your clipboard").color(NamedTextColor.GREEN)))
|
||||
.build();
|
||||
sender.send(plugin.prefix().append(text));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public final class EndtimerCommand extends CommandInfo {
|
||||
|
||||
public EndtimerCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "timer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 2)) return;
|
||||
|
||||
final Duration duration = plugin.getCommandManager().parseDurationAndCheckTask(sender, args[1]);
|
||||
if (duration == null) {
|
||||
sender.send(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
if (!plugin.isMaintenance()) {
|
||||
sender.send(getMessage("alreadyDisabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.startMaintenanceRunnable(duration, false);
|
||||
sender.send(getMessage("endtimerStarted", "%TIME%", plugin.getRunnable().getTime()));
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.command.subcommand;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.Component;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class HelpCommand extends CommandInfo {
|
||||
private static final int COMMANDS_PER_PAGE = 8;
|
||||
|
||||
public HelpCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (args.length > 2) {
|
||||
sender.send(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length == 1) {
|
||||
sendUsage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.isNumeric(args[1])) {
|
||||
sender.send(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
final int page = Integer.parseInt(args[1]);
|
||||
sendUsage(sender, page == 0 ? 1 : page);
|
||||
}
|
||||
|
||||
public void sendUsage(final SenderInfo sender) {
|
||||
sendUsage(sender, 1);
|
||||
}
|
||||
|
||||
public void sendUsage(final SenderInfo sender, final int page) {
|
||||
Preconditions.checkArgument(page > 0);
|
||||
final List<Component> commands = new ArrayList<>();
|
||||
for (final CommandInfo cmd : plugin.getCommandManager().getCommands()) {
|
||||
if (cmd.isVisible() && cmd.hasPermission(sender)) {
|
||||
commands.add(cmd.getHelpMessage());
|
||||
}
|
||||
}
|
||||
if ((page - 1) * COMMANDS_PER_PAGE >= commands.size()) {
|
||||
sender.send(getMessage("helpPageNotFound"));
|
||||
return;
|
||||
}
|
||||
|
||||
final List<Component> filteredCommands = commands.subList((page - 1) * COMMANDS_PER_PAGE, Math.min(page * COMMANDS_PER_PAGE, commands.size()));
|
||||
|
||||
final Component header = getMessage("helpHeader",
|
||||
"%NAME%", "Maintenance" + plugin.getServerType(),
|
||||
"%PAGE%", Integer.toString(page),
|
||||
"%MAX%", Integer.toString((commands.size() + getDivide(commands.size())) / COMMANDS_PER_PAGE));
|
||||
sender.send(Component.empty());
|
||||
sender.send(header);
|
||||
for (final Component command : filteredCommands) {
|
||||
sender.send(command);
|
||||
}
|
||||
|
||||
if (page * COMMANDS_PER_PAGE < commands.size()) {
|
||||
sender.send(getMessage("helpNextPage", "%PAGE%", Integer.toString(page + 1)));
|
||||
} else {
|
||||
sender.sendRich("<dark_gray>× <yellow>Version: " + plugin.getVersion() + " <gray>by <aqua>kennytv");
|
||||
}
|
||||
|
||||
sender.send(header);
|
||||
sender.send(Component.empty());
|
||||
}
|
||||
|
||||
private int getDivide(final int size) {
|
||||
final int commandSize = size % COMMANDS_PER_PAGE;
|
||||
return commandSize > 0 ? COMMANDS_PER_PAGE - commandSize : 0;
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class MotdCommand extends CommandInfo {
|
||||
|
||||
public MotdCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "motd");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
sendList(sender, getSettings().getPingMessages());
|
||||
} else if (args.length == 2 && args[1].equalsIgnoreCase("timer")) {
|
||||
if (!getSettings().hasTimerSpecificPingMessages()) {
|
||||
sender.send(getMessage("timerMotdDisabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
sendList(sender, getSettings().getTimerSpecificPingMessages());
|
||||
} else {
|
||||
sender.send(getHelpMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void sendList(final SenderInfo sender, final List<String> list) {
|
||||
if (list == null || list.isEmpty()) {
|
||||
sender.send(getMessage("motdListEmpty"));
|
||||
return;
|
||||
}
|
||||
|
||||
sender.send(getMessage("motdList"));
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
sender.sendRich("<aqua>" + (i + 1) + "<dark_gray><st>---------");
|
||||
sender.sendRich(list.get(i));
|
||||
}
|
||||
sender.sendRich("<dark_gray><st>----------");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletion(final SenderInfo sender, final String[] args) {
|
||||
if (args.length != 2 || !getSettings().hasTimerSpecificPingMessages()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Collections.singletonList("timer");
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
public final class ReloadCommand extends CommandInfo {
|
||||
|
||||
public ReloadCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "reload");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 1)) return;
|
||||
getSettings().reloadConfigs();
|
||||
sender.send(getMessage("reload"));
|
||||
}
|
||||
}
|
||||
-90
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.config.ConfigSection;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class RemoveMotdCommand extends CommandInfo {
|
||||
|
||||
public RemoveMotdCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "setmotd");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, String[] args) {
|
||||
boolean timerPingMessages = false;
|
||||
if (args.length == 3 && args[1].equalsIgnoreCase("timer")) {
|
||||
if (!getSettings().hasTimerSpecificPingMessages()) {
|
||||
sender.send(getMessage("timerMotdDisabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
args = plugin.removeArrayIndex(args, 1);
|
||||
timerPingMessages = true;
|
||||
}
|
||||
if (checkArgs(sender, args, 2)) return;
|
||||
if (!plugin.isNumeric(args[1])) {
|
||||
sender.send(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
final Settings settings = getSettings();
|
||||
final ConfigSection section = settings.getConfig().getSection("ping-message");
|
||||
final List<String> pingMessages = section.getStringList(timerPingMessages ? "timer-messages" : "messages");
|
||||
if (pingMessages.size() < 2) {
|
||||
sender.send(getMessage("removeMotdError"));
|
||||
return;
|
||||
}
|
||||
|
||||
final int index = Integer.parseInt(args[1]);
|
||||
if (index == 0 || index > pingMessages.size()) {
|
||||
sender.send(getMessage("setMotdIndexError",
|
||||
"%MOTDS%", Integer.toString(pingMessages.size()),
|
||||
"%NEWAMOUNT%", Integer.toString(pingMessages.size())));
|
||||
return;
|
||||
}
|
||||
|
||||
final List<String> pingComponents = timerPingMessages ? settings.getTimerSpecificPingMessages() : settings.getPingMessages();
|
||||
pingComponents.remove(index - 1);
|
||||
pingMessages.remove(index - 1);
|
||||
section.set(timerPingMessages ? "timer-messages" : "messages", pingMessages);
|
||||
settings.saveConfig();
|
||||
sender.send(getMessage("removedMotd", "%INDEX%", args[1]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletion(final SenderInfo sender, final String[] args) {
|
||||
if (args.length == 2 || (args.length == 3 && args[1].equalsIgnoreCase("timer"))) {
|
||||
final int size = (args.length == 3 ? plugin.getSettings().getTimerSpecificPingMessages() : plugin.getSettings().getPingMessages()).size();
|
||||
final List<String> list = new ArrayList<>(size);
|
||||
for (int i = 1; i <= size; i++) {
|
||||
list.add(Integer.toString(i));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import java.time.Duration;
|
||||
|
||||
public final class ScheduleTimerCommand extends CommandInfo {
|
||||
|
||||
public ScheduleTimerCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "timer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 3)) return;
|
||||
|
||||
final Duration enableIn = plugin.getCommandManager().parseDurationAndCheckTask(sender, args[1]);
|
||||
final Duration maintenanceDuration = plugin.getCommandManager().parseDurationAndCheckTask(sender, args[2], false);
|
||||
if (enableIn == null || maintenanceDuration == null) {
|
||||
sender.send(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
if (plugin.isMaintenance()) {
|
||||
sender.send(getMessage("alreadyEnabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.scheduleMaintenanceRunnable(enableIn, maintenanceDuration);
|
||||
sender.send(getMessage(
|
||||
"scheduletimerStarted",
|
||||
"%TIME%", plugin.getRunnable().getTime(),
|
||||
"%DURATION%", plugin.getFormattedTime((int) maintenanceDuration.getSeconds())
|
||||
));
|
||||
}
|
||||
}
|
||||
-127
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.config.ConfigSection;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static eu.kennytv.maintenance.core.Settings.NEW_LINE_REPLACEMENT;
|
||||
|
||||
public final class SetMotdCommand extends CommandInfo {
|
||||
|
||||
public SetMotdCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "setmotd");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, String[] args) {
|
||||
boolean timerPingMessages = false;
|
||||
if (args.length > 1 && args[1].equalsIgnoreCase("timer")) {
|
||||
if (!getSettings().hasTimerSpecificPingMessages()) {
|
||||
sender.send(getMessage("timerMotdDisabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
// remove the "timer" off the args to keep the rest the code cleaner
|
||||
args = plugin.removeArrayIndex(args, 1);
|
||||
timerPingMessages = true;
|
||||
}
|
||||
if (args.length < 4 || !plugin.isNumeric(args[1])) {
|
||||
sender.send(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
final Settings settings = getSettings();
|
||||
final List<String> pingComponents = timerPingMessages ? settings.getTimerSpecificPingMessages() : settings.getPingMessages();
|
||||
final ConfigSection section = settings.getConfig().getSection("ping-message");
|
||||
final List<String> pingMessages = section.getStringList(timerPingMessages ? "timer-messages" : "messages");
|
||||
final int index = Integer.parseInt(args[1]);
|
||||
if (index == 0 || index > pingMessages.size() + 1) {
|
||||
sender.send(getMessage("setMotdIndexError",
|
||||
"%MOTDS%", Integer.toString(pingMessages.size()),
|
||||
"%NEWAMOUNT%", Integer.toString(pingMessages.size() + 1)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.isNumeric(args[2])) {
|
||||
sender.send(getMessage("setMotdLineError"));
|
||||
return;
|
||||
}
|
||||
|
||||
final int line = Integer.parseInt(args[2]);
|
||||
if (line != 1 && line != 2) {
|
||||
sender.send(getMessage("setMotdLineError"));
|
||||
return;
|
||||
}
|
||||
|
||||
final String message = String.join(" ", Arrays.copyOfRange(args, 3, args.length));
|
||||
final String oldMessage = index > pingMessages.size() ? "" : pingMessages.get(index - 1);
|
||||
final String newMessage;
|
||||
if (line == 1) {
|
||||
newMessage = oldMessage.contains(NEW_LINE_REPLACEMENT) ?
|
||||
message + NEW_LINE_REPLACEMENT + oldMessage.split(NEW_LINE_REPLACEMENT, 2)[1] : message;
|
||||
} else {
|
||||
newMessage = oldMessage.contains(NEW_LINE_REPLACEMENT) ?
|
||||
oldMessage.split(NEW_LINE_REPLACEMENT, 2)[0] + NEW_LINE_REPLACEMENT + message : oldMessage + NEW_LINE_REPLACEMENT + message;
|
||||
}
|
||||
|
||||
// Replace component in config and the cached list
|
||||
final String componentString = newMessage.replace(NEW_LINE_REPLACEMENT, "\n");
|
||||
if (index > pingMessages.size()) {
|
||||
pingMessages.add(newMessage);
|
||||
pingComponents.add(componentString);
|
||||
} else {
|
||||
pingMessages.set(index - 1, newMessage);
|
||||
pingComponents.set(index - 1, componentString);
|
||||
}
|
||||
|
||||
section.set(timerPingMessages ? "timer-messages" : "messages", pingMessages);
|
||||
settings.saveConfig();
|
||||
sender.send(settings.getMessage(
|
||||
"setMotd",
|
||||
"%LINE%", args[2],
|
||||
"%INDEX%", args[1],
|
||||
"%MOTD%", componentString
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletion(final SenderInfo sender, String[] args) {
|
||||
boolean timer = false;
|
||||
if (args.length > 1 && args[1].equalsIgnoreCase("timer")) {
|
||||
args = plugin.removeArrayIndex(args, 1);
|
||||
timer = true;
|
||||
}
|
||||
if (args.length == 3) return Arrays.asList("1", "2");
|
||||
if (args.length == 2) {
|
||||
final List<String> list = new ArrayList<>();
|
||||
for (int i = 1; i <= (timer ? getSettings().getTimerSpecificPingMessages() : getSettings().getPingMessages()).size() + 1; i++) {
|
||||
list.add(String.valueOf(i));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public final class StarttimerCommand extends CommandInfo {
|
||||
|
||||
public StarttimerCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "timer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 2)) return;
|
||||
|
||||
final Duration duration = plugin.getCommandManager().parseDurationAndCheckTask(sender, args[1]);
|
||||
if (duration == null) {
|
||||
sender.send(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
if (plugin.isMaintenance()) {
|
||||
sender.send(getMessage("alreadyEnabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.startMaintenanceRunnable(duration, true);
|
||||
sender.send(getMessage("starttimerStarted", "%TIME%", plugin.getRunnable().getTime()));
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
public final class ToggleCommand extends CommandInfo {
|
||||
|
||||
public ToggleCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "toggle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 1)) return;
|
||||
|
||||
final boolean maintenance = args[0].equalsIgnoreCase("on");
|
||||
if (maintenance == plugin.isMaintenance()) {
|
||||
sender.send(getMessage(maintenance ? "alreadyEnabled" : "alreadyDisabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.setMaintenance(maintenance);
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.Component;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.event.ClickEvent;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.event.HoverEvent;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.format.NamedTextColor;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.minimessage.MiniMessage;
|
||||
|
||||
public final class UpdateCommand extends CommandInfo {
|
||||
|
||||
public UpdateCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "update");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 1)) return;
|
||||
if (args[0].equalsIgnoreCase("update")) {
|
||||
plugin.async(() -> checkForUpdate(sender));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.updateAvailable()) {
|
||||
sender.sendPrefixedRich("<green>You already have the latest version of the plugin!");
|
||||
return;
|
||||
}
|
||||
|
||||
sender.send(getMessage("updateDownloading"));
|
||||
try {
|
||||
if (plugin.installUpdate()) {
|
||||
sender.send(getMessage("updateFinished"));
|
||||
} else {
|
||||
sender.send(getMessage("updateFailed"));
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
sender.send(getMessage("updateFailed"));
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkForUpdate(final SenderInfo sender) {
|
||||
if (!plugin.updateAvailable()) {
|
||||
sender.sendPrefixedRich("<green>You already have the latest version of the plugin!");
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendPrefixedRich("<red>Newest version available: <green>Version " + plugin.getNewestVersion() + "<red>, you're on <green>" + plugin.getVersion());
|
||||
sender.sendPrefixedRich("<b><red>WARNING: <red>You will have to restart the server to prevent further issues and to complete the update! If you can't do that, don't update!");
|
||||
|
||||
sender.send(Component.text().append(MiniMessage.miniMessage().deserialize("<gold>× <dark_gray>[<green>Update<dark_gray>]"))
|
||||
.clickEvent(ClickEvent.runCommand("/maintenance forceupdate"))
|
||||
.hoverEvent(HoverEvent.showText(Component.text().content("Click here to update the plugin").color(NamedTextColor.GREEN)))
|
||||
.append(Component.text().content(", or manually run ").color(NamedTextColor.GRAY))
|
||||
.append(Component.text().content("/maintenance forceupdate").color(NamedTextColor.RED)).build());
|
||||
}
|
||||
}
|
||||
-108
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.DummySenderInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public final class WhitelistAddCommand extends CommandInfo {
|
||||
|
||||
public WhitelistAddCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "whitelist.add");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (args.length == 2) {
|
||||
if (args[1].length() == 36) {
|
||||
final UUID uuid = plugin.checkUUID(sender, args[1]);
|
||||
if (uuid != null) {
|
||||
addPlayerToWhitelist(sender, uuid);
|
||||
}
|
||||
} else {
|
||||
addPlayerToWhitelist(sender, args[1]);
|
||||
}
|
||||
} else if (args.length == 3) {
|
||||
if (args[1].length() != 36) {
|
||||
sender.send(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
final UUID uuid = plugin.checkUUID(sender, args[1]);
|
||||
if (uuid != null) {
|
||||
addPlayerToWhitelist(sender, new DummySenderInfo(uuid, args[2]));
|
||||
}
|
||||
} else {
|
||||
sender.send(getHelpMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletion(final SenderInfo sender, final String[] args) {
|
||||
return args.length == 2 ? plugin.getCommandManager().getPlayersCompletion() : Collections.emptyList();
|
||||
}
|
||||
|
||||
private void addPlayerToWhitelist(final SenderInfo sender, final String name) {
|
||||
plugin.getOfflinePlayer(name).whenComplete((selected, ex) -> {
|
||||
if (ex != null) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Error while fetching offline player", ex);
|
||||
sender.send(getMessage("offlinePlayerFetchError"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (selected == null) {
|
||||
sender.send(getMessage("playerNotOnline"));
|
||||
return;
|
||||
}
|
||||
|
||||
addPlayerToWhitelist(sender, selected);
|
||||
});
|
||||
}
|
||||
|
||||
private void addPlayerToWhitelist(final SenderInfo sender, final UUID uuid) {
|
||||
plugin.getOfflinePlayer(uuid).whenComplete((selected, ex) -> {
|
||||
if (ex != null) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Error while fetching offline player", ex);
|
||||
sender.send(getMessage("offlinePlayerFetchError"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (selected == null) {
|
||||
sender.send(getMessage("playerNotFoundUuid"));
|
||||
return;
|
||||
}
|
||||
|
||||
addPlayerToWhitelist(sender, selected);
|
||||
});
|
||||
}
|
||||
|
||||
private void addPlayerToWhitelist(final SenderInfo sender, final SenderInfo selected) {
|
||||
if (getSettings().addWhitelistedPlayer(selected.getUuid(), selected.getName())) {
|
||||
sender.send(getMessage("whitelistAdded", "%PLAYER%", selected.getName()));
|
||||
} else {
|
||||
sender.send(getMessage("whitelistAlreadyAdded", "%PLAYER%", selected.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class WhitelistCommand extends CommandInfo {
|
||||
|
||||
public WhitelistCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "whitelist.list");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 1)) return;
|
||||
|
||||
final Map<UUID, String> players = getSettings().getWhitelistedPlayers();
|
||||
if (players.isEmpty()) {
|
||||
sender.send(getMessage("whitelistEmpty"));
|
||||
return;
|
||||
}
|
||||
|
||||
sender.send(getMessage("whitelistedPlayers"));
|
||||
final Component format = getMessage("whitelistedPlayersFormat");
|
||||
for (final Map.Entry<UUID, String> entry : players.entrySet()) {
|
||||
sender.send(format.replaceText(builder -> builder.matchLiteral("%NAME%").replacement(entry.getValue()))
|
||||
.replaceText(builder -> builder.matchLiteral("%UUID%").replacement(entry.getKey().toString())));
|
||||
}
|
||||
|
||||
sender.send(Component.empty());
|
||||
}
|
||||
}
|
||||
-94
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class WhitelistRemoveCommand extends CommandInfo {
|
||||
|
||||
public WhitelistRemoveCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "whitelist.remove");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 2)) return;
|
||||
if (args[1].length() == 36) {
|
||||
final UUID uuid = plugin.checkUUID(sender, args[1]);
|
||||
if (uuid != null) {
|
||||
removePlayerFromWhitelist(sender, uuid);
|
||||
}
|
||||
} else {
|
||||
removePlayerFromWhitelist(sender, args[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletion(final SenderInfo sender, final String[] args) {
|
||||
if (args.length != 2) return Collections.emptyList();
|
||||
|
||||
final List<String> list = new ArrayList<>();
|
||||
String matchNameLowerCase = args[1].toLowerCase();
|
||||
for (final String name : getSettings().getWhitelistedPlayers().values()) {
|
||||
if (name.toLowerCase().startsWith(matchNameLowerCase)) {
|
||||
list.add(name);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private void removePlayerFromWhitelist(final SenderInfo sender, final String name) {
|
||||
plugin.getOfflinePlayer(name).whenComplete((selected, ex) -> {
|
||||
if (selected == null) {
|
||||
if (getSettings().removeWhitelistedPlayer(name)) {
|
||||
sender.send(getMessage("whitelistRemoved", "%PLAYER%", name));
|
||||
} else {
|
||||
sender.send(getMessage("whitelistNotFound"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
removePlayerFromWhitelist(sender, selected.getUuid(), selected.getName());
|
||||
});
|
||||
}
|
||||
|
||||
private void removePlayerFromWhitelist(final SenderInfo sender, final UUID uuid) {
|
||||
plugin.getOfflinePlayer(uuid).whenComplete((selected, ex) -> {
|
||||
if (selected == null) {
|
||||
removePlayerFromWhitelist(sender, uuid, uuid.toString());
|
||||
} else {
|
||||
removePlayerFromWhitelist(sender, selected.getUuid(), selected.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void removePlayerFromWhitelist(final SenderInfo sender, final UUID uuid, final String toReplace) {
|
||||
if (getSettings().removeWhitelistedPlayer(uuid)) {
|
||||
sender.send(getMessage("whitelistRemoved", "%PLAYER%", toReplace));
|
||||
} else {
|
||||
sender.send(getMessage("whitelistNotFound"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,157 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.config;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
/**
|
||||
* Further modified version of the <a href="https://github.com/PSandro/SimpleConfig">SimpleConfig</a>SimpleConfig project of PSandro.
|
||||
*
|
||||
* @author PSandro on 26.01.19
|
||||
* @author kennytv
|
||||
*/
|
||||
public final class Config extends ConfigSection {
|
||||
|
||||
private static final String AWESOME_HEADER =
|
||||
"###################################################################################################################\n" +
|
||||
"# __ __ _ _ _ _ _ #\n" +
|
||||
"# | \\/ | __ _(_)_ __ | |_ ___ _ __ __ _ _ __ ___ ___ | |__ _ _ | | _____ _ __ _ __ _ _| |___ __ #\n" +
|
||||
"# | |\\/| |/ _` | | '_ \\| __/ _ \\ '_ \\ / _` | '_ \\ / __/ _ \\ | '_ \\| | | | | |/ / _ \\ '_ \\| '_ \\| | | | __\\ \\ / / #\n" +
|
||||
"# | | | | (_| | | | | | || __/ | | | (_| | | | | (_| __/ | |_) | |_| | | < __/ | | | | | | |_| | |_ \\ V / #\n" +
|
||||
"# |_| |_|\\__,_|_|_| |_|\\__\\___|_| |_|\\__,_|_| |_|\\___\\___| |_.__/ \\__, | |_|\\_\\___|_| |_|_| |_|\\__, |\\__| \\_/ #\n" +
|
||||
"# |___/ |___/ #\n" +
|
||||
"###################################################################################################################\n" +
|
||||
"# You can report bugs here: https://github.com/kennytv/Maintenance/issues\n" +
|
||||
"# If you need any other help/support, you can also join my Discord server: https://discord.gg/vGCUzHq\n" +
|
||||
"# The config and language files use MiniMessage, NOT legacy text for input. Use https://webui.adventure.kyori.net/ to edit and preview the formatted text.\n" +
|
||||
"# For a full list of formats and fancy examples of MiniMessage, see https://docs.adventure.kyori.net/minimessage/format.html\n";
|
||||
private final Yaml yaml = createYaml();
|
||||
private final File file;
|
||||
private final Set<String> unsupportedFields;
|
||||
private Map<String, String[]> comments = new HashMap<>();
|
||||
private String header;
|
||||
|
||||
public Config(final File file, final String... unsupportedFields) {
|
||||
super(null, "");
|
||||
this.file = file;
|
||||
this.unsupportedFields = unsupportedFields.length == 0 ? Collections.emptySet() : Sets.newHashSet(unsupportedFields);
|
||||
}
|
||||
|
||||
public void load() throws IOException {
|
||||
final String data = new String(Files.readAllBytes(this.file.toPath()), StandardCharsets.UTF_8);
|
||||
final Map<String, Object> map = yaml.load(data);
|
||||
this.values = map != null ? map : new LinkedHashMap<>();
|
||||
this.comments = ConfigSerializer.deserializeComments(data);
|
||||
|
||||
final String[] header = comments.remove(".header");
|
||||
if (header != null) {
|
||||
this.header = String.join("\n", header);
|
||||
}
|
||||
|
||||
final boolean removedFields = values.keySet().removeIf(key -> {
|
||||
final String[] split = key.split("\\.");
|
||||
String splitKey = "";
|
||||
for (final String s : split) {
|
||||
splitKey += s;
|
||||
if (!unsupportedFields.contains(splitKey)) {
|
||||
splitKey += ".";
|
||||
continue;
|
||||
}
|
||||
|
||||
// Unsupported field
|
||||
comments.remove(key);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (removedFields) {
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
public void save() throws IOException {
|
||||
saveTo(file);
|
||||
}
|
||||
|
||||
public void saveTo(final File file) throws IOException {
|
||||
final byte[] bytes = toString().getBytes(StandardCharsets.UTF_8);
|
||||
if (file.getParentFile() != null) {
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
file.createNewFile();
|
||||
Files.write(file.toPath(), bytes);
|
||||
}
|
||||
|
||||
public void replaceComments(final Config fromConfig) {
|
||||
this.comments = new HashMap<>(fromConfig.comments);
|
||||
}
|
||||
|
||||
private static Yaml createYaml() {
|
||||
final DumperOptions options = new DumperOptions();
|
||||
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
options.setPrettyFlow(false);
|
||||
options.setIndent(2);
|
||||
options.setWidth(10_000); // be sneaky because autobreak on saving looks disgusting
|
||||
return new Yaml(options);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.values.clear();
|
||||
this.comments.clear();
|
||||
this.header = null;
|
||||
}
|
||||
|
||||
public Map<String, String[]> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
public Set<String> getUnsupportedFields() {
|
||||
return unsupportedFields;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Config getRoot() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
public void resetAwesomeHeader() {
|
||||
this.header = AWESOME_HEADER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ConfigSerializer.serialize(this.header, this.values, this.comments, this.yaml);
|
||||
}
|
||||
}
|
||||
@@ -1,258 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.config;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Further modified version of the <a href="https://github.com/PSandro/SimpleConfig">SimpleConfig</a>SimpleConfig project of PSandro.
|
||||
*
|
||||
* @author kennytv
|
||||
*/
|
||||
public class ConfigSection {
|
||||
|
||||
protected final Config root;
|
||||
protected final String currentPath;
|
||||
protected Map<String, Object> values;
|
||||
|
||||
ConfigSection(final Config root, final String currentPath) {
|
||||
this(root, currentPath, new HashMap<>());
|
||||
}
|
||||
|
||||
ConfigSection(final Config root, final String currentPath, final Map<String, Object> values) {
|
||||
this.root = root;
|
||||
this.currentPath = currentPath;
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public <E> E get(final String key) {
|
||||
return (E) getObject(key);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public <E> E get(final String key, @Nullable final E def) {
|
||||
final Object o = getObject(key);
|
||||
return o != null ? (E) o : def;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object getObject(final String key) {
|
||||
return getObject(key, null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object getObject(final String key, final Object def) {
|
||||
int nextSeparatorIndex = -1;
|
||||
int sectionStartIndex;
|
||||
ConfigSection section = this;
|
||||
while ((nextSeparatorIndex = key.indexOf('.', sectionStartIndex = nextSeparatorIndex + 1)) != -1) {
|
||||
section = section.getSection(key.substring(sectionStartIndex, nextSeparatorIndex));
|
||||
if (section == null) return def;
|
||||
}
|
||||
|
||||
final String subKey = key.substring(sectionStartIndex);
|
||||
if (section == this) {
|
||||
final Object result = values.get(subKey);
|
||||
return result != null ? result : def;
|
||||
}
|
||||
return section.getObject(subKey, def);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public <E> E getOrSet(final String key, @Nullable final E def) {
|
||||
final Object o = getObject(key);
|
||||
if (o != null) {
|
||||
return (E) o;
|
||||
} else {
|
||||
this.set(key, def);
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ConfigSection getSection(final String key) {
|
||||
final Object o = getObject(key);
|
||||
if (!(o instanceof Map)) return null;
|
||||
return new ConfigSection(getRoot(), getFullKeyInPath(key), (Map<String, Object>) o);
|
||||
}
|
||||
|
||||
public ConfigSection getOrCreateSection(final String key) {
|
||||
final Object o = getObject(key);
|
||||
if (!(o instanceof Map)) {
|
||||
set(key, new LinkedHashMap<>());
|
||||
return getSection(key);
|
||||
}
|
||||
return new ConfigSection(getRoot(), getFullKeyInPath(key), (Map<String, Object>) o);
|
||||
}
|
||||
|
||||
public boolean contains(final String key) {
|
||||
return getObject(key) != null;
|
||||
}
|
||||
|
||||
public void set(final String key, @Nullable final Object value) {
|
||||
int nextSeparatorIndex = -1;
|
||||
int sectionStartIndex;
|
||||
ConfigSection section = this;
|
||||
while ((nextSeparatorIndex = key.indexOf('.', sectionStartIndex = nextSeparatorIndex + 1)) != -1) {
|
||||
section = section.getOrCreateSection(key.substring(sectionStartIndex, nextSeparatorIndex));
|
||||
}
|
||||
|
||||
final String sectionKey = key.substring(sectionStartIndex);
|
||||
if (value == null) {
|
||||
section.values.remove(sectionKey);
|
||||
getRoot().getComments().remove(getFullKeyInPath(key));
|
||||
} else {
|
||||
section.values.put(sectionKey, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void move(final String key, final String toKey) {
|
||||
final Object o = getObject(key);
|
||||
if (o != null) {
|
||||
remove(key);
|
||||
set(toKey, o);
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(final String key) {
|
||||
set(key, null);
|
||||
}
|
||||
|
||||
public Set<String> getKeys() {
|
||||
return this.values.keySet();
|
||||
}
|
||||
|
||||
public Map<String, Object> getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public boolean getBoolean(final String key) {
|
||||
return getBoolean(key, false);
|
||||
}
|
||||
|
||||
public boolean getBoolean(final String key, final boolean def) {
|
||||
final Object o = getObject(key);
|
||||
return o instanceof Boolean ? (boolean) o : def;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getString(final String key) {
|
||||
return get(key);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getString(final String key, @Nullable final String def) {
|
||||
final Object o = getObject(key);
|
||||
return o instanceof String ? (String) o : def;
|
||||
}
|
||||
|
||||
public int getInt(final String key) {
|
||||
return getInt(key, 0);
|
||||
}
|
||||
|
||||
public int getInt(final String key, final int def) {
|
||||
final Object o = getObject(key);
|
||||
return o instanceof Number ? ((Number) o).intValue() : def;
|
||||
}
|
||||
|
||||
public double getDouble(final String key) {
|
||||
return getDouble(key, 0D);
|
||||
}
|
||||
|
||||
public double getDouble(final String key, final double def) {
|
||||
final Object o = getObject(key);
|
||||
return o instanceof Number ? ((Number) o).doubleValue() : def;
|
||||
}
|
||||
|
||||
public long getLong(final String key) {
|
||||
return getLong(key, 0L);
|
||||
}
|
||||
|
||||
public long getLong(final String key, final long def) {
|
||||
final Object o = getObject(key);
|
||||
return o instanceof Number ? ((Number) o).longValue() : def;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> getStringList(final String key) {
|
||||
return get(key);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> getStringList(final String key, @Nullable final List<String> def) {
|
||||
final List<String> list = get(key);
|
||||
return list != null ? list : def;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<Integer> getIntList(final String key) {
|
||||
return get(key);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<Integer> getIntList(final String key, @Nullable final List<Integer> def) {
|
||||
final List<Integer> list = get(key);
|
||||
return list != null ? list : def;
|
||||
}
|
||||
|
||||
public boolean addMissingFields(final ConfigSection fromSection) {
|
||||
boolean changed = false;
|
||||
for (final Map.Entry<String, Object> entry : fromSection.values.entrySet()) {
|
||||
final String key = entry.getKey();
|
||||
final Object value = this.values.get(key);
|
||||
if (value != null) {
|
||||
// Go deeper for sections
|
||||
final Object newValue = entry.getValue();
|
||||
if (!(value instanceof Map) || !(newValue instanceof Map)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
changed |= this.getSection(key).addMissingFields(fromSection.getSection(key));
|
||||
} else {
|
||||
// Value is missing
|
||||
this.values.put(key, entry.getValue());
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return root config
|
||||
*/
|
||||
public Config getRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return current path, or empty string if root
|
||||
*/
|
||||
public String getCurrentPath() {
|
||||
return currentPath;
|
||||
}
|
||||
|
||||
protected String getFullKeyInPath(final String key) {
|
||||
return currentPath.isEmpty() ? key : currentPath + "." + key;
|
||||
}
|
||||
}
|
||||
@@ -1,193 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.config;
|
||||
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Further modified version of the <a href="https://github.com/PSandro/SimpleConfig">SimpleConfig</a>SimpleConfig project of PSandro.
|
||||
*
|
||||
* @author PSandro on 26.01.19
|
||||
* @author kennytv
|
||||
*/
|
||||
public final class ConfigSerializer {
|
||||
|
||||
private static final String[] EMPTY = new String[0];
|
||||
private static final String PATH_SEPARATOR_STRING = ".";
|
||||
private static final String PATH_SEPARATOR_QUOTED = Pattern.quote(PATH_SEPARATOR_STRING);
|
||||
private static final int INDENT_UNIT = 2;
|
||||
|
||||
public static String serialize(final String header, final Map<String, Object> data, final Map<String, String[]> comments, final Yaml yaml) {
|
||||
if (data.isEmpty()) {
|
||||
return yaml.dump(null);
|
||||
}
|
||||
|
||||
final String rawYaml = yaml.dump(data);
|
||||
final StringBuilder fileData = new StringBuilder();
|
||||
int currentKeyIndents = 0;
|
||||
String key = "";
|
||||
for (final String line : rawYaml.split("\n")) {
|
||||
if (line.isEmpty()) continue;
|
||||
|
||||
final int indent = getIndents(line);
|
||||
final int indents = indent / INDENT_UNIT;
|
||||
final boolean keyLine;
|
||||
final String substring = line.substring(indent);
|
||||
if (substring.trim().isEmpty() || substring.charAt(0) == '-') {
|
||||
keyLine = false;
|
||||
} else if (indents <= currentKeyIndents) {
|
||||
final String[] array = key.split(PATH_SEPARATOR_QUOTED);
|
||||
final int backspace = currentKeyIndents - indents + 1;
|
||||
key = join(array, array.length - backspace);
|
||||
keyLine = true;
|
||||
} else {
|
||||
keyLine = line.indexOf(':') != -1;
|
||||
}
|
||||
|
||||
if (!keyLine) {
|
||||
// Nothing to do, go to next line
|
||||
fileData.append(line).append('\n');
|
||||
continue;
|
||||
}
|
||||
|
||||
final String newKey = substring.split(Pattern.quote(":"))[0]; // Not sure about the quote thing, so I'll just keep it :aaa:
|
||||
if (!key.isEmpty()) {
|
||||
key += PATH_SEPARATOR_STRING;
|
||||
}
|
||||
key += newKey;
|
||||
|
||||
// Add comments if present
|
||||
if (comments != null) {
|
||||
final String[] strings = comments.get(key);
|
||||
if (strings != null) {
|
||||
final String indentText = indent > 0 ? line.substring(0, indent) : "";
|
||||
for (final String comment : strings) {
|
||||
if (comment.isEmpty()) {
|
||||
fileData.append('\n');
|
||||
} else {
|
||||
fileData.append(indentText).append(comment).append('\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currentKeyIndents = indents;
|
||||
fileData.append(line).append('\n');
|
||||
}
|
||||
return header != null && !header.isEmpty() ? header + fileData : fileData.toString();
|
||||
}
|
||||
|
||||
public static Map<String, String[]> deserializeComments(final String data) {
|
||||
//TODO go through known yaml keys and figure out comments from there instead of from line to line?
|
||||
// ... tho everything here would benefit from a cleanup
|
||||
final Map<String, String[]> comments = new HashMap<>();
|
||||
final List<String> currentComments = new ArrayList<>();
|
||||
boolean header = true;
|
||||
boolean multiLineValue = false;
|
||||
int currentIndents = 0;
|
||||
String key = "";
|
||||
for (final String line : data.split("\n")) {
|
||||
final String s = line.trim();
|
||||
// It's a comment!
|
||||
if (s.startsWith("#")) {
|
||||
currentComments.add(s);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Header is over - save it!
|
||||
if (header) {
|
||||
if (!currentComments.isEmpty()) {
|
||||
currentComments.add("");
|
||||
comments.put(".header", currentComments.toArray(EMPTY));
|
||||
currentComments.clear();
|
||||
}
|
||||
header = false;
|
||||
}
|
||||
|
||||
// Save empty lines as well
|
||||
if (s.isEmpty()) {
|
||||
currentComments.add(s);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Multi line values?
|
||||
if (s.startsWith("- |")) {
|
||||
multiLineValue = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
final int indent = getIndents(line);
|
||||
final int indents = indent / INDENT_UNIT;
|
||||
// Check if the multi line value is over
|
||||
if (multiLineValue) {
|
||||
if (indents > currentIndents) continue;
|
||||
|
||||
multiLineValue = false;
|
||||
}
|
||||
|
||||
// YAML list items are values, not keys - skip without touching key/indent state
|
||||
if (line.length() > indent && line.charAt(indent) == '-') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if this is a level lower
|
||||
if (indents <= currentIndents) {
|
||||
final String[] array = key.split(PATH_SEPARATOR_QUOTED);
|
||||
final int backspace = currentIndents - indents + 1;
|
||||
final int delta = array.length - backspace;
|
||||
key = delta >= 0 ? join(array, delta) : key;
|
||||
}
|
||||
|
||||
// Finish current key
|
||||
final String separator = key.isEmpty() ? "" : PATH_SEPARATOR_STRING;
|
||||
final String lineKey = line.indexOf(':') != -1 ? line.split(Pattern.quote(":"))[0] : line;
|
||||
key += separator + lineKey.substring(indent);
|
||||
currentIndents = indents;
|
||||
|
||||
if (!currentComments.isEmpty()) {
|
||||
comments.put(key, currentComments.toArray(EMPTY));
|
||||
currentComments.clear();
|
||||
}
|
||||
}
|
||||
return comments;
|
||||
}
|
||||
|
||||
private static int getIndents(final String line) {
|
||||
int count = 0;
|
||||
for (int i = 0; i < line.length(); i++) {
|
||||
if (line.charAt(i) != ' ') {
|
||||
break;
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private static String join(final String[] array, final int length) {
|
||||
final String[] copy = new String[length];
|
||||
System.arraycopy(array, 0, copy, 0, length);
|
||||
return String.join(PATH_SEPARATOR_STRING, copy);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.dump;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings({"FieldCanBeLocal", "unused"})
|
||||
public final class MaintenanceDump {
|
||||
private final ServerDump general;
|
||||
private final Map<String, Object> configuration;
|
||||
private final JsonObject plugins;
|
||||
|
||||
public MaintenanceDump(final MaintenancePlugin plugin, final Settings settings) {
|
||||
general = new ServerDump(plugin.getVersion(), plugin.getServerType().toString(), plugin.getServerVersion(), plugin.getMaintenanceServersDump());
|
||||
|
||||
configuration = new LinkedHashMap<>(settings.getConfig().getValues());
|
||||
final Object o = configuration.get("mysql");
|
||||
if (o instanceof Map) {
|
||||
final Map<String, Object> map = new LinkedHashMap<>(((Map<String, Object>) o));
|
||||
map.keySet().removeIf(key -> !key.equals("use-mysql") && !key.equals("update-interval"));
|
||||
configuration.put("mysql", map);
|
||||
}
|
||||
configuration.put("whitelisted-players", settings.getWhitelistedPlayers());
|
||||
configuration.put("icon-exists", new File(plugin.getDataFolder(), "maintenance-icon.png").exists());
|
||||
|
||||
final JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.add("plugins", MaintenancePlugin.GSON.toJsonTree(plugin.getPlugins()));
|
||||
plugins = jsonObject;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.dump;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings({"FieldCanBeLocal", "unused"})
|
||||
public final class PluginDump {
|
||||
private final String name;
|
||||
private final String version;
|
||||
private final List<String> authors;
|
||||
|
||||
public PluginDump(final String name, final String version, final List<String> authors) {
|
||||
this.name = name;
|
||||
this.version = version;
|
||||
this.authors = authors != null && authors.isEmpty() ? null : authors;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.dump;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings({"FieldCanBeLocal", "unused"})
|
||||
public final class ServerDump {
|
||||
private final String pluginVersion;
|
||||
private final String platform;
|
||||
private final String serverVersion;
|
||||
private final List<String> maintenance;
|
||||
|
||||
public ServerDump(final String pluginVersion, final String platform, final String serverVersion, final List<String> maintenance) {
|
||||
this.pluginVersion = pluginVersion;
|
||||
this.platform = platform;
|
||||
this.serverVersion = serverVersion;
|
||||
this.maintenance = maintenance;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.event;
|
||||
|
||||
import eu.kennytv.maintenance.api.event.manager.EventListener;
|
||||
import eu.kennytv.maintenance.api.event.manager.MaintenanceEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public final class EventManager implements eu.kennytv.maintenance.api.event.manager.EventManager {
|
||||
private final Map<String, List<EventListener>> listeners = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void registerListener(final EventListener listener, final Class<? extends MaintenanceEvent> eventClass) {
|
||||
listeners.computeIfAbsent(eventClass.getSimpleName(), s -> new ArrayList<>()).add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callEvent(final MaintenanceEvent event) {
|
||||
final List<EventListener> list = listeners.get(event.getClass().getSimpleName());
|
||||
if (list != null) {
|
||||
for (final EventListener listener : list) {
|
||||
listener.onEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.hook;
|
||||
|
||||
import eu.kennytv.maintenance.api.Maintenance;
|
||||
import net.luckperms.api.LuckPermsProvider;
|
||||
import net.luckperms.api.context.ContextCalculator;
|
||||
import net.luckperms.api.context.ContextConsumer;
|
||||
import net.luckperms.api.context.ContextSet;
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class LuckPermsHook {
|
||||
|
||||
public static <T> void register(final Maintenance maintenance) {
|
||||
LuckPermsProvider.get().getContextManager().registerCalculator(new MaintenanceCalculator<T>(maintenance));
|
||||
}
|
||||
|
||||
public static final class MaintenanceCalculator<T> implements ContextCalculator<T> {
|
||||
|
||||
public static final String MAINTENANCE_KEY = "is-maintenance";
|
||||
private final Maintenance maintenance;
|
||||
|
||||
private MaintenanceCalculator(final Maintenance maintenance) {
|
||||
this.maintenance = maintenance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate(@NotNull final T target, @NotNull final ContextConsumer consumer) {
|
||||
consumer.accept(MAINTENANCE_KEY, Boolean.toString(maintenance.isMaintenance()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContextSet estimatePotentialContexts() {
|
||||
return ImmutableContextSet.builder().add(MAINTENANCE_KEY, "true").add(MAINTENANCE_KEY, "false").build();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.hook;
|
||||
|
||||
import net.minecrell.serverlistplus.core.ServerListPlusCore;
|
||||
import net.minecrell.serverlistplus.core.plugin.ServerListPlusPlugin;
|
||||
|
||||
public final class ServerListPlusHook {
|
||||
private final ServerListPlusCore serverListPlusCore;
|
||||
|
||||
public ServerListPlusHook(final Object serverListPlus) {
|
||||
if (!(serverListPlus instanceof ServerListPlusPlugin)) {
|
||||
throw new IllegalArgumentException("Couldn't parse ServerListPlus instance!");
|
||||
}
|
||||
this.serverListPlusCore = ((ServerListPlusPlugin) serverListPlus).getCore();
|
||||
}
|
||||
|
||||
public void setEnabled(final boolean enable) {
|
||||
serverListPlusCore.getProfiles().setEnabled(enable);
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.listener;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.Component;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.TextComponent;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.event.ClickEvent;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.event.HoverEvent;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.format.NamedTextColor;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.format.TextDecoration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class JoinListenerBase {
|
||||
protected final MaintenancePlugin plugin;
|
||||
protected final Settings settings;
|
||||
private final Set<UUID> notifiedPlayers = new HashSet<>();
|
||||
|
||||
protected JoinListenerBase(final MaintenancePlugin plugin, final Settings settings) {
|
||||
this.plugin = plugin;
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deals with the login and returns true if the player should be kicked after this method.
|
||||
*
|
||||
* @param sender wrapper of the joining player
|
||||
* @return true if the sender should be kicked
|
||||
*/
|
||||
protected boolean shouldKick(final SenderInfo sender, final boolean updateCheck) {
|
||||
if (!settings.isMaintenance() || sender.hasMaintenancePermission("bypass") || settings.isWhitelisted(sender.getUuid())) {
|
||||
if (updateCheck) {
|
||||
updateCheck(sender);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean shouldKick(final SenderInfo sender) {
|
||||
return shouldKick(sender, true);
|
||||
}
|
||||
|
||||
protected void updateCheck(final SenderInfo sender) {
|
||||
if (!settings.hasUpdateChecks()) return;
|
||||
if (!sender.hasPermission("maintenance.admin") || notifiedPlayers.contains(sender.getUuid())) return;
|
||||
plugin.async(() -> {
|
||||
if (!plugin.updateAvailable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
notifiedPlayers.add(sender.getUuid());
|
||||
sender.sendPrefixedRich("<red>There is a newer version available: <green>Version " + plugin.getNewestVersion() + "<red>, you're on <green>" + plugin.getVersion());
|
||||
|
||||
final TextComponent text = Component.text().content("Download it at: ").color(NamedTextColor.RED)
|
||||
.append(Component.text().content(MaintenancePlugin.HANGAR_URL).color(NamedTextColor.GOLD))
|
||||
.append(Component.text().content(" (CLICK ME)").color(NamedTextColor.GRAY).decorate(TextDecoration.BOLD))
|
||||
.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.OPEN_URL, MaintenancePlugin.HANGAR_URL))
|
||||
.hoverEvent(HoverEvent.showText(Component.text("Download the latest version").color(NamedTextColor.GREEN)))
|
||||
.build();
|
||||
sender.send(plugin.prefix().append(text));
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract void broadcastJoinNotification(String name);
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.runnable;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.Component;
|
||||
|
||||
public class MaintenanceRunnable extends MaintenanceRunnableBase {
|
||||
|
||||
public MaintenanceRunnable(final MaintenancePlugin plugin, final Settings settings, final int seconds, final boolean enable) {
|
||||
super(plugin, settings, seconds, enable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finish() {
|
||||
plugin.setMaintenance(enable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Component getStartMessage() {
|
||||
return settings.getMessage("starttimerBroadcast", "%TIME%", getTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Component getEndMessage() {
|
||||
return settings.getMessage("endtimerBroadcast", "%TIME%", getTime());
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.runnable;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.core.util.Task;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.Component;
|
||||
|
||||
public abstract class MaintenanceRunnableBase implements Runnable {
|
||||
protected final MaintenancePlugin plugin;
|
||||
protected final Settings settings;
|
||||
protected final boolean enable;
|
||||
private final Task task;
|
||||
protected int seconds;
|
||||
|
||||
protected MaintenanceRunnableBase(final MaintenancePlugin plugin, final Settings settings, final int seconds, final boolean enable) {
|
||||
this.plugin = plugin;
|
||||
this.settings = settings;
|
||||
this.seconds = seconds;
|
||||
this.enable = enable;
|
||||
this.task = plugin.startMaintenanceRunnable(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (seconds == 0) {
|
||||
finish();
|
||||
} else if (settings.getBroadcastIntervals().contains(seconds)) {
|
||||
broadcast(enable ? getStartMessage() : getEndMessage());
|
||||
}
|
||||
|
||||
seconds--;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return plugin.getFormattedTime(seconds);
|
||||
}
|
||||
|
||||
public boolean shouldEnable() {
|
||||
return enable;
|
||||
}
|
||||
|
||||
public int getSecondsLeft() {
|
||||
return seconds;
|
||||
}
|
||||
|
||||
public Task getTask() {
|
||||
return task;
|
||||
}
|
||||
|
||||
protected void broadcast(final Component message) {
|
||||
plugin.broadcast(message);
|
||||
}
|
||||
|
||||
protected abstract void finish();
|
||||
|
||||
protected abstract Component getStartMessage();
|
||||
|
||||
protected abstract Component getEndMessage();
|
||||
}
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.runnable;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.Component;
|
||||
import java.time.Duration;
|
||||
|
||||
public final class MaintenanceScheduleRunnable extends MaintenanceRunnable {
|
||||
private final int maintenanceDuration;
|
||||
|
||||
public MaintenanceScheduleRunnable(final MaintenancePlugin plugin, final Settings settings, final int secondsToEnable, final int maintenanceDuration) {
|
||||
super(plugin, settings, secondsToEnable, true);
|
||||
this.maintenanceDuration = maintenanceDuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finish() {
|
||||
super.finish();
|
||||
|
||||
// Start the timer to disable maintenance again
|
||||
plugin.startMaintenanceRunnable(Duration.ofSeconds(maintenanceDuration), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Component getStartMessage() {
|
||||
return settings.getMessage("scheduletimerBroadcast",
|
||||
"%TIME%", getTime(),
|
||||
"%DURATION%", plugin.getFormattedTime(maintenanceDuration));
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.util;
|
||||
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class DummySenderInfo implements SenderInfo {
|
||||
private final UUID uuid;
|
||||
private final String name;
|
||||
|
||||
public DummySenderInfo(final UUID uuid, final String name) {
|
||||
this.uuid = uuid;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final String permission) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(final Component component) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package eu.kennytv.maintenance.core.util;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Exception thrown when an API rate limit is reached.
|
||||
*/
|
||||
public class RateLimitedException extends IOException {
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.util;
|
||||
|
||||
import eu.kennytv.maintenance.api.MaintenanceProvider;
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.Component;
|
||||
import eu.kennytv.maintenance.lib.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface SenderInfo {
|
||||
|
||||
UUID getUuid();
|
||||
|
||||
String getName();
|
||||
|
||||
boolean hasPermission(String permission);
|
||||
|
||||
default boolean hasMaintenancePermission(final String permission) {
|
||||
return permission == null || hasPermission("maintenance.admin") || hasPermission("maintenance." + permission);
|
||||
}
|
||||
|
||||
void send(Component component);
|
||||
|
||||
default void sendRich(final String message) {
|
||||
send(MiniMessage.miniMessage().deserialize(message));
|
||||
}
|
||||
|
||||
default void sendPrefixedRich(final String message) {
|
||||
final MaintenancePlugin maintenance = (MaintenancePlugin) MaintenanceProvider.get();
|
||||
send(maintenance.prefix().append(MiniMessage.miniMessage().deserialize(message)));
|
||||
}
|
||||
|
||||
boolean isPlayer();
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.util;
|
||||
|
||||
public enum ServerType {
|
||||
|
||||
BUNGEE("Bungee"),
|
||||
SPIGOT("Spigot"),
|
||||
SPONGE("Sponge"),
|
||||
VELOCITY("Velocity");
|
||||
|
||||
private final String name;
|
||||
|
||||
ServerType(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if type is BUNGEE or VELOCITY
|
||||
*/
|
||||
public boolean isProxy() {
|
||||
return this == BUNGEE || this == VELOCITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.util;
|
||||
|
||||
public interface Task {
|
||||
|
||||
void cancel();
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2024 kennytv (https://github.com/kennytv)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package eu.kennytv.maintenance.core.util;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public final class Version implements Comparable<Version> {
|
||||
private final int[] parts;
|
||||
private final String version;
|
||||
private final String tag;
|
||||
|
||||
/**
|
||||
* Creates a new version object to be compared.
|
||||
* The version format are numbers separated by '.', possibly followed by a '-' to include an extra tag after it.
|
||||
*
|
||||
* @param version string representation of the version
|
||||
* @throws IllegalArgumentException if the given version string is null or empty
|
||||
* @throws NumberFormatException if there are non-number characters in the version (before the tag)
|
||||
*/
|
||||
public Version(final String version) {
|
||||
Preconditions.checkArgument(version != null && !version.isEmpty());
|
||||
|
||||
final int index = version.indexOf('-');
|
||||
final String[] split = (index == -1 ? version : version.substring(0, index)).split("\\.");
|
||||
parts = new int[split.length];
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
// Let this throw an exception if parsing fails
|
||||
parts[i] = Integer.parseInt(split[i]);
|
||||
}
|
||||
|
||||
this.version = version;
|
||||
tag = index != -1 ? version.substring(index + 1) : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two versions.
|
||||
*
|
||||
* @param version version to compare to
|
||||
* @return 0 if they are the same, 1 if this instance is newer, -1 if older
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(@Nullable final Version version) {
|
||||
if (version == null) return 0;
|
||||
|
||||
final int max = Math.max(this.parts.length, version.parts.length);
|
||||
for (int i = 0; i < max; i++) {
|
||||
final int partA = i < this.parts.length ? this.parts[i] : 0;
|
||||
final int partB = i < version.parts.length ? version.parts[i] : 0;
|
||||
if (partA < partB) {
|
||||
return -1;
|
||||
} else if (partA > partB) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.tag.isEmpty() && !version.tag.isEmpty()) {
|
||||
return 1;
|
||||
} else if (!this.tag.isEmpty() && version.tag.isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof Version)) return false;
|
||||
final Version other = (Version) o;
|
||||
return version.equals(other.version);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
# You can add and remove players with the '/maintenance <add/remove> <name/uuid>' command.
|
||||
# Alternatively, you can just add their uuid and name here by hand in the following format:
|
||||
# a8179ff3-c201-4a75-bdaa-9d14aca6f83f: kennytv
|
||||
@@ -1,130 +0,0 @@
|
||||
###################################################################################################################
|
||||
# __ __ _ _ _ _ _ #
|
||||
# | \/ | __ _(_)_ __ | |_ ___ _ __ __ _ _ __ ___ ___ | |__ _ _ | | _____ _ __ _ __ _ _| |___ __ #
|
||||
# | |\/| |/ _` | | '_ \| __/ _ \ '_ \ / _` | '_ \ / __/ _ \ | '_ \| | | | | |/ / _ \ '_ \| '_ \| | | | __\ \ / / #
|
||||
# | | | | (_| | | | | | || __/ | | | (_| | | | | (_| __/ | |_) | |_| | | < __/ | | | | | | |_| | |_ \ V / #
|
||||
# |_| |_|\__,_|_|_| |_|\__\___|_| |_|\__,_|_| |_|\___\___| |_.__/ \__, | |_|\_\___|_| |_|_| |_|\__, |\__| \_/ #
|
||||
# |___/ |___/ #
|
||||
###################################################################################################################
|
||||
# You can report bugs here: https://github.com/kennytv/Maintenance/issues
|
||||
# If you need any other help/support, you can also join my Discord server: https://discord.gg/vGCUzHq
|
||||
# The config and language files use MiniMessage, NOT legacy text for input. Use https://webui.adventure.kyori.net/ to edit and preview the formatted text.
|
||||
# For a full list of formats and fancy examples of MiniMessage, see https://docs.adventure.kyori.net/minimessage/format.html
|
||||
|
||||
# Changes the language of command feedback/messages.
|
||||
# If you find missing translations or want to contribute, see https://crowdin.com/project/maintenance
|
||||
# Currently available are: en (English), de (German), fr (French), pt (Portuguese), es (Spanish), ru (Russian), zh (Chinese), it (Italian),
|
||||
# pl (Polish), tr (Turkish), sv (Swedish), uk (Ukrainian), ja (Japanese), da (Danish), ko (Korean), hu (Hungarian), vi (Vietnamese)
|
||||
language: en
|
||||
|
||||
# Enables maintenance mode.
|
||||
maintenance-enabled: true
|
||||
|
||||
# Enables maintenance on certain servers managed by your proxy instance(s).
|
||||
proxied-maintenance-servers:
|
||||
# - AServer
|
||||
|
||||
# If maintenance is enabled on a proxied server with players on it, they will be sent to the fallback server instead of being kicked off the network.
|
||||
# If the fallback server is not reachable/not set, they will just be kicked off the network.
|
||||
# This can also be set to an array to set multiple fallback servers, in case one server is not always reachable: 'fallback: [s1, s2, s3, ...]'
|
||||
fallback: unreachable
|
||||
|
||||
# If maintenance is enabled globally, you can define a "waiting" lobby for players to be sent to instead of being kicked.
|
||||
# Leave this empty to disable.
|
||||
waiting-server: ""
|
||||
|
||||
# The message (MOTD) shown in the multiplayer server list motd when maintenance is enabled.
|
||||
# If you put in multiple entries, one of them will be chosen randomly on every ping.
|
||||
# If running an endtimer, the time left can be displayed by including '%TIMER%' in a ping message.
|
||||
ping-message:
|
||||
enabled: true
|
||||
messages:
|
||||
- "<bold><green>True<red>OG</bold> <yellow>Network</yellow> <aqua>》<red> Updating... </red><aqua>《 <gold>[1.8.0-1.21.11]<br><yellow>⚠ <dark_red>Maintenance in progress! <yellow>We'll be back <dark_aqua>soon™"
|
||||
# If set to true and an endtimer is currently running, a message from this pool will be chosen
|
||||
# instead of the ones above, so you can have different messages for when an endtimer is running/not running.
|
||||
enable-timer-specific-messages: true
|
||||
timer-messages:
|
||||
- "<bold><green>True<red>OG</bold> <yellow>Network</yellow> <aqua>》<red>Maintenance Mode</red><aqua>《 <gold>[1.8.0-1.21.11]<br><dark_red>Maintenance ends in <yellow>%TIMER% <gray>| <green>Thanks for waiting!"
|
||||
|
||||
# If enabled, the message below will be shown in the top right corner of the server in the server list, where the player count would normally be displayed.
|
||||
# You can use '%ONLINE%' and '%MAX%' if you want to include the player count in a custom message (e.g. "Maintenance %ONLINE%/%MAX%").
|
||||
# DOES NOT SUPPORT RGB!
|
||||
player-count-message:
|
||||
enabled: true
|
||||
message: "<dark_red>Maintenance"
|
||||
# If set to true and an endtimer is currently running, the timer message will be used instead of the normal one.
|
||||
enable-timer-specific-message: true
|
||||
timer-message: "<dark_red>Come back in: <yellow>%TIMER%"
|
||||
|
||||
# Is shown when you move your mouse above the text in the top right corner of the server in the server list, where the player count would normally be displayed.
|
||||
# DOES NOT SUPPORT RGB!
|
||||
player-list-hover-message:
|
||||
enabled: true
|
||||
message: "<red>Currently under<br><red>maintenance"
|
||||
# If set to true and an endtimer is currently running, the timer message will be used instead of the normal one.
|
||||
enable-timer-specific-message: true
|
||||
timer-message: "<red>Come back in:<br><red><yellow>%TIMER%"
|
||||
|
||||
# Any extra commands inside the arrays will be executed when maintenance is enabled/disabled.
|
||||
# Example: commands-on-maintenance-enable: ["say hello!", "stop"]
|
||||
commands-on-maintenance-enable: []
|
||||
commands-on-maintenance-disable: []
|
||||
|
||||
# Any extra commands inside the "all" array will be executed when maintenance is enabled/disabled on a proxied server.
|
||||
# You can also add commands for specific servers by adding a new array with the server name as key.
|
||||
# In the commands, you can use the %SERVER% placeholder to get the server name.
|
||||
# Example: coolserver: ["say hello", "othercommand %SERVER%"]
|
||||
commands-on-single-maintenance-enable:
|
||||
all: []
|
||||
commands-on-single-maintenance-disable:
|
||||
all: []
|
||||
|
||||
# If set to true, the server icon will be changed to the 'maintenance-icon.png' file in the plugin's folder during maintenance.
|
||||
custom-maintenance-icon: false
|
||||
|
||||
# If set to true, players with the 'maintenance.joinnotification' permission will receive a message,
|
||||
# that a player tried to join the server while maintenance is enabled.
|
||||
send-join-notification: true
|
||||
|
||||
# Set this to false if you do not want players to be kicked when you enable maintenance (new connections will still be blocked).
|
||||
kick-online-players: true
|
||||
|
||||
# When fetched player does not exist then fallback to offline uuid. Only works on proxies like Velocity or BungeeCord
|
||||
fallback-to-offline-uuid: false
|
||||
|
||||
# If enabled and the server is restarted while running an endtimer, the timer will be continued after the restart.
|
||||
# If the timer ends while the server is offline, maintenance will be disabled as soon as the server starts again.
|
||||
continue-endtimer-after-restart:
|
||||
enabled: false
|
||||
# This value is set everytime an endtimer is started, cancelled or ended.
|
||||
# Do not manually change this value.
|
||||
end: 0
|
||||
|
||||
# If using the timer command: In what intervalls before enabling/disabling maintenance there will be a broadcast.
|
||||
timer-broadcast-for-seconds: [1200, 900, 600, 300, 120, 60, 30, 20, 10, 5, 4, 3, 2, 1]
|
||||
|
||||
# If you have 2 or more proxy instances, the database connection will make sure all proxies
|
||||
# have the same maintenance status, so you won't have to enable/disable it on every proxy by hand.
|
||||
mysql:
|
||||
use-mysql: false
|
||||
host: host
|
||||
port: 3306
|
||||
database: database
|
||||
username: username
|
||||
password: password
|
||||
# Requests to the database will only be made at least x seconds after the last request,
|
||||
# so there won't be a request on every single ping on a server with many players.
|
||||
#
|
||||
# Set this to 0 to make a database request on (almost) every single ping.
|
||||
# (0 is not recommended if having more than a hundred concurrent players, then I'd recommend keeping it from 10-60).
|
||||
update-interval: 15
|
||||
# If you for some reason cannot establish SSL connections to your database, you may disable it here (not recommended).
|
||||
use-ssl: true
|
||||
|
||||
# If disabled, you will no longer receive any messages if there is an update.
|
||||
# Not recommended to disable, as new versions generally tend to run better and with fewer bugs.
|
||||
# However, you can always check for updates manually using the '/maintenance update' command.
|
||||
update-checks: false
|
||||
|
||||
# Used for autoupdating the config, do not change this value.
|
||||
config-version: 9
|
||||
@@ -1,104 +0,0 @@
|
||||
#Maintenance Plugin by kennytv
|
||||
#You can use https://webui.adventure.kyori.net/ to edit and preview the formatted text
|
||||
#For a full list of formats and fancy examples, see https://docs.adventure.kyori.net/minimessage/format.html
|
||||
#Messages containing the placeholder "<prefix>" will have it replaced with the following string
|
||||
prefix: "<dark_gray>[<yellow>Maintenance<dark_gray>] "
|
||||
noPermission: "<red>Du har ikke tilladelse til at udføre denne kommando."
|
||||
kickmessage: "<red>Serveren er i øjeblikket under vedligeholdelse!<br>Prøv igen senere!"
|
||||
maintenanceActivated: "<prefix><gold>Vedligeholdelsestilstand er nu aktiveret."
|
||||
maintenanceDeactivated: "<prefix><gold>Vedligeholdelsestilstand er nu deaktiveret."
|
||||
alreadyEnabled: "<prefix><red>Vedligeholdelsestilstand er allerede aktiveret!"
|
||||
alreadyDisabled: "<prefix><red>Vedligeholdelsestilstand er allerede deaktiveret!"
|
||||
endtimerBroadcast: "<prefix><gray>Vedligeholdelsestilstand vil blive deaktiveret om <gold>%TIME%<gray>."
|
||||
endtimerStarted: "<prefix><green>Startet timer: <gray>Vedligeholdelsestilstand vil blive deaktiveret om <gold>%TIME%<gray>."
|
||||
starttimerBroadcast: "<prefix><gray>Vedligeholdelsestilstand vil blive aktiveret om <gold>%TIME%<gray>."
|
||||
starttimerStarted: "<prefix><green>Startet timer: <gray>Vedligeholdelsestilstand vil blive aktiveret om <gold>%TIME%<gray>."
|
||||
scheduletimerBroadcast: "<prefix><gray>Vedligeholdelsestilstand vil blive aktiveret om <gold>%TIME% <gray>og vil vare i <gold>%DURATION%<gray>."
|
||||
scheduletimerStarted: "<prefix><green>Startet timer: <gray>Vedligeholdelsestilstand vil blive aktiveret om <gold>%TIME% <gray>og vil vare i <gold>%DURATION%<gray>."
|
||||
timerAlreadyRunning: "<prefix><red>Der er allerede planlagt en timer!"
|
||||
timerNotRunning: "<prefix><red>Der er i øjeblikket ingen timer."
|
||||
timerCancelled: "<prefix><red>Den aktuelle timer er blevet deaktiveret."
|
||||
timerTooLong: "<prefix><red>Tallet skal være mindre end 40320 (28 days)!"
|
||||
timerMotdDisabled: "<prefix><red>Du skal angive 'enable-timerspecific-messages' i konfigurationsfilen til 'true', hvis du vil bruge/redigere tidsbestemte motds."
|
||||
motdTimer: "%HOURS%:%MINUTES%:%SECONDS%"
|
||||
motdTimerNotRunning: "-"
|
||||
joinNotification: "<prefix><yellow>%PLAYER% <red>prøvede at forbinde til serveren."
|
||||
motdList: "<prefix><gray>Liste over dine vedligeholdelses motds:"
|
||||
motdListEmpty: "<prefix><red>Du har ikke oprettet nogen vedligeholdelses motds!"
|
||||
reload: "<prefix><green>Genindlæs konfigurationsfilen, hvidlistede spillere, sprogfilen og vedligeholdelsesikonet."
|
||||
removedMotd: "<prefix><green>Slet motd nummer %INDEX%."
|
||||
removeMotdError: "<prefix><red>Du har kun én motd, så du kan ikke slette nogen!"
|
||||
setMotd: "<prefix><green>Angiv linje %LINE% af %INDEX%. vedligeholdelses motd til %MOTD%"
|
||||
setMotdIndexError: "<prefix><red>Du har %MOTDS% motds, så du skal angive et nummer mellem 1 og %NEWAMOUNT%."
|
||||
setMotdLineError: "<prefix><red>Det andet argument skal være linjenummer (1 or 2)!"
|
||||
updateDownloading: "<prefix><red><bold>Downloader opdatering..."
|
||||
updateFailed: "<prefix><dark_red><bold>Opdatering fejlede!"
|
||||
updateFinished: "<prefix><green><bold>Opdateringen lykkedes! For at forhindre problemer og for at fuldføre opdateringen skal du genstarte serveren!"
|
||||
whitelistedPlayers: "<prefix><gold>Hvidlistede spillere til vedligeholdelse:"
|
||||
whitelistedPlayersFormat: "<dark_gray>- <yellow>%NAME% <dark_gray>(<gray>%UUID%<dark_gray>)"
|
||||
whitelistAdded: "<prefix><green>Tilføj <aqua>%PLAYER% <green>til vedligeholdelseshvidlisten!"
|
||||
whitelistAlreadyAdded: "<prefix><aqua>%PLAYER% <red>findes allerede i vedligeholdelseshvidlisten!"
|
||||
whitelistRemoved: "<prefix><green>Fjern <aqua>%PLAYER% <green>fra vedligeholdelseshvidlisten!"
|
||||
whitelistNotFound: "<prefix><red>Denne spiller er ikke på vedligeholdelseshvidlisten!"
|
||||
whitelistEmpty: "<prefix><red>Vedligeholdelseshvidlisten er tom! Brug <yellow>/maintenance add <player/uuid> <red>til at tilføje spillere!"
|
||||
playerNotFound: "<prefix><red>Ingen spillere med dette navn har spillet på denne server før."
|
||||
playerNotFoundUuid: "<prefix><red>Ingen spiller med den uuid kunne findes."
|
||||
playerNotOnline: "<prefix><red>Der er ingen spiller online med det navn."
|
||||
offlinePlayerFetchError: "<prefix><red>There was an error while fetching offline player. Please try again later."
|
||||
invalidUuid: "<prefix><red>Ugyldigt uuid-format!"
|
||||
#Messages for the Bungee/Velocity part, you can ignore them if you use the plugin on Paper/Sponge
|
||||
sentToWaitingServer: "<prefix><red>Du er blevet sendt til en venteserver!"
|
||||
forceWaitingServer: "<prefix><red>Du kan ikke forlade venteserveren, mens vedligeholdelsetilstand er aktiveret!"
|
||||
serverNotFound: "<prefix><red>Ingen server med dette navn er registreret på proxyen!"
|
||||
singleTimerAlreadyRunning: "<prefix><red>Der er allerede planlagt en timer for den server!"
|
||||
singleTimerCancelled: "<prefix><red>Den aktuelle timer for serveren <yellow>%SERVER% <red>er deaktiveret."
|
||||
singleTimerNotRunning: "<prefix><red>Der er i øjeblikket ingen kørende timer for den server."
|
||||
singleEndtimerBroadcast: "<prefix><gray>Vedligeholdelsestilstand på server %SERVER% vil blive deaktiveret om <gold>%TIME%<gray>."
|
||||
singleEndtimerStarted: "<prefix><green>Startet timer: <gray>Vedligeholdelsestilstand på server %SERVER% vil blive deaktiveret om <gold>%TIME%<gray>."
|
||||
singleStarttimerBroadcast: "<prefix><gray>Vedligeholdelsestilstand på server %SERVER% vil blive aktiveret om <gold>%TIME%<gray>."
|
||||
singleStarttimerStarted: "<prefix><green>Startet timer: <gray>Vedligeholdelsestilstand på server %SERVER% vil blive aktiveret om <gold>%TIME%<gray>."
|
||||
singleScheduletimerBroadcast: "<prefix><gray>Vedligeholdelsestilstand på server %SERVER% vil blive aktiveret om <gold>%TIME% <gray>og vil vare i <gold>%DURATION%<gray>."
|
||||
singleScheduletimerStarted: "<prefix><green>Startet timer: <gray>Vedligeholdelsestilstand på server %SERVER% vil blive aktiveret om <gold>%TIME% <gray>og vil vare i <gold>%DURATION%<gray>."
|
||||
singleMaintenanceKick: "<prefix><red>Serveren %SERVER% er i øjeblikket under vedligeholdelse! Prøv igen senere!"
|
||||
singleMaintenanceKickComplete: "<red>Serveren %SERVER% er under vedligeholdelse!<br>Du kan prøve at forbinde igen for at gå ind på en anden server!"
|
||||
singleMaintenanceActivated: "<prefix><gold>Vedligeholdelsestilstand er nu aktiveret på serveren <yellow>%SERVER%<gold>."
|
||||
singleMaintenanceDeactivated: "<prefix><gold>Vedligeholdelsestilstand er nu deaktiveret på serveren <yellow>%SERVER%<gold>."
|
||||
singleServerAlreadyEnabled: "<prefix><red>Vedligeholdelsestilstand er allerede aktiveret på serveren <yellow>%SERVER%<red>!"
|
||||
singleServerAlreadyDisabled: "<prefix><red>Vedligeholdelsestilstand er allerede deaktiveret på serveren <yellow>%SERVER%<red>!"
|
||||
singleServerMaintenanceList: "<prefix><gray>Proxyservere, der har Vedligeholdelsestilstand aktiveret:"
|
||||
singleServerMaintenanceListEmpty: "<prefix><gray>Der er ingen proxy-servere, der er under vedligeholdelse."
|
||||
singleServerMaintenanceListEntry: "<dark_grey>- <aqua>%SERVER%"
|
||||
second: "sekund"
|
||||
seconds: "sekunder"
|
||||
minute: "minut"
|
||||
minutes: "minutter"
|
||||
hour: "time"
|
||||
hours: "timer"
|
||||
helpHeader: "<dark_gray>========[ <yellow>%NAME% <dark_gray>| <yellow>%PAGE%/%MAX% <dark_gray>]========"
|
||||
helpPageNotFound: "<prefix><red>Der er ingen side med det nummer!"
|
||||
helpNextPage: "<gray>Brug <aqua>/maintenance help %PAGE% <gray>for at komme til næste hjælpevindue."
|
||||
helpAbortTimer: "<gold>/maintenance aborttimer <gray>(Hvis timeren kører, vil den blive afbrudt)"
|
||||
helpEndtimer: "<gold>/maintenance endtimer <disable in> <gray>(After the given time, e.g. 1h5m, maintenance mode will be disabled)"
|
||||
helpStarttimer: "<gold>/maintenance starttimer <enable in> <gray>(After the given time, e.g. 1h5m, maintenance mode will be enabled)"
|
||||
helpScheduleTimer: "<gold>/maintenance scheduletimer <enable in> <maintenance duration> <gray>(After the given time, e.g. 1h5m, maintenance mode will be enabled)"
|
||||
helpDebug: "<gold>/maintenance debug <gray>(Aktiverer noget fejlretningslogning)"
|
||||
helpDump: "<gold>/maintenance dump <gray>(Dumper nogle serveroplysninger, brugt til fejlrapporter)"
|
||||
helpHelp: "<gold>/maintenance help [page] <gray>(Viser dette smukke hjælpevindue)"
|
||||
helpMotd: "<gold>/maintenance motd [timer] <gray>(Viser den aktuelle vedligeholdelses motds. Hvis 'timer' er angivet, bliver dennes motds vist)"
|
||||
helpRemoveMotd: "<gold>/maintenance removemotd [timer] <index> <gray>(Sletter en vedligeholdelses motd. Hvis 'timer' er angivet, vil en tidsspecifik pingbesked blive slettet)"
|
||||
helpSetMotd: "<gold>/maintenance setmotd [timer] <index> <1/2> <message> <gray>(Angiver en motd for vedligeholdelsestilstand. Hvis 'timer' er angivet, vil en tidsspecifik pingbesked blive angivet)"
|
||||
helpReload: "<gold>/maintenance reload <gray>(Genindlæser konfigurationsfilen, hvidlisten og serverikonet)"
|
||||
helpToggle: "<gold>/maintenance <on/off> <gray>(Aktiverer/deaktiverer vedligeholdelsestilstand)"
|
||||
helpUpdate: "<gold>/maintenance update <gray>(Downloader den nyeste version af plugin'et på din server)"
|
||||
helpWhitelist: "<gold>/maintenance whitelist <gray>(Viser alle hvidlistede spillere for vedligeholdelsestilstand)"
|
||||
helpWhitelistAdd: "<gold>/maintenance add <name/uuid> <gray>(Tilføjer spilleren til vedligeholdelseshvidlisten, så de kan forbinde til serveren, selvom vedligeholdelsestilstand er aktiveret)"
|
||||
helpWhitelistRemove: "<gold>/maintenance remove <name/uuid> <gray>(Sletter spilleren fra vedligeholdelseshvidlisten)"
|
||||
#Messages for the Bungee/Velocity part, you can ignore them if you use the plugin on Paper/Sponge
|
||||
helpAbortSingleTimer: "<gold>/maintenance aborttimer [server] <gray>(Hvis timeren kører, vil den blive afbrudt)"
|
||||
helpSingleEndtimer: "<gold>/maintenance endtimer [server] <disable in> <gray>(After the given time, e.g. 1h5m, maintenance mode will be disabled)"
|
||||
helpSingleStarttimer: "<gold>/maintenance starttimer [server] <enable in> <gray>(After the given time, e.g. 1h5m, maintenance mode will be enabled)"
|
||||
helpSingleScheduleTimer: "<gold>/maintenance scheduletimer [server] <enable in> <maintenance duration> <gray>(After the given time, e.g. 1h5m, maintenance mode will be enabled)"
|
||||
helpSingleToggle: "<gold>/maintenance <on/off> [server] <gray>(Aktiverer/deaktiverer vedligeholdelsestilstand)"
|
||||
helpStatus: "<gold>/maintenance status <gray>(Viser alle proxyservere, der har Vedligeholdelsestilstand aktiveret)"
|
||||
#Used for autoupdating the language file, do not change this value.
|
||||
language-version: 2
|
||||
@@ -1,104 +0,0 @@
|
||||
#Maintenance Plugin by kennytv
|
||||
#You can use https://webui.adventure.kyori.net/ to edit and preview the formatted text
|
||||
#For a full list of formats and fancy examples, see https://docs.adventure.kyori.net/minimessage/format.html
|
||||
#Messages containing the placeholder "<prefix>" will have it replaced with the following string
|
||||
prefix: "<dark_gray>[<yellow>Maintenance<dark_gray>] "
|
||||
noPermission: "<red>Du hast nicht die erforderliche Berechtigung, um diesen Befehl auszuführen."
|
||||
kickmessage: "<red>Der Server befindet sich momentan im Wartungsmodus!<br>Bitte versuche es später nochmal!"
|
||||
maintenanceActivated: "<prefix><gold>Der Wartungsmodus ist jetzt aktiviert."
|
||||
maintenanceDeactivated: "<prefix><gold>Der Wartungsmodus ist nun deaktiviert."
|
||||
alreadyEnabled: "<prefix><red>Der Wartungsmodus ist bereits aktiviert!"
|
||||
alreadyDisabled: "<prefix><red>Der Wartungsmodus ist bereits deaktiviert!"
|
||||
endtimerBroadcast: "<prefix><gray>Der Wartungsmodus wird deaktiviert in: <gold>%TIME%<gray>."
|
||||
endtimerStarted: "<prefix><green>Timer gestartet: <gray>Der Wartungsmodus wird deaktiviert in: <gold>%TIME%<gray>."
|
||||
starttimerBroadcast: "<prefix><gray>Der Wartungsmodus wird aktiviert in: <gold>%TIME%<gray>."
|
||||
starttimerStarted: "<prefix><green>Timer gestartet: <gray>Der Wartungsmodus wird aktiviert in: <gold>%TIME%<gray>."
|
||||
scheduletimerBroadcast: "<prefix><gray>Der Wartungsmodus wird in <gold>%TIME% <gray>aktiviert und <gold>%DURATION% <gray>dauern."
|
||||
scheduletimerStarted: "<prefix><green>Gestarteter Timer: <gray>Der Wartungsmodus ist in <gold>%TIME% <gray>aktiv und wird <gold>%DURATION% <gray>dauern."
|
||||
timerAlreadyRunning: "<prefix><red>Momentan läuft bereits ein Timer!"
|
||||
timerNotRunning: "<prefix><red>Momentan läuft kein Timer."
|
||||
timerCancelled: "<prefix><red>Der laufende Timer wurde beendet."
|
||||
timerTooLong: "<prefix><red>Die angegebene Zahl muss kleiner als 40320 sein, also 28 Tage!"
|
||||
timerMotdDisabled: "<prefix><red>Du musst den Wert 'enable-timerspecific-messages' in der Config auf 'true' stellen, wenn du timerspezifische Motds benutzen/bearbeiten möchtest."
|
||||
motdTimer: "%HOURS%:%MINUTES%:%SECONDS%"
|
||||
motdTimerNotRunning: "-"
|
||||
joinNotification: "<prefix><yellow>%PLAYER% <red>hat versucht dem Server beizutreten."
|
||||
motdList: "<prefix><gray>Liste deiner Motds, die während Maintenance angezeigt werden:"
|
||||
motdListEmpty: "<prefix><red>Du hast keine Maintenance MOTDs gesetzt!"
|
||||
reload: "<prefix><green>Die Config, die Liste der Spieler die während Maintenance beitreten können, die Sprachdateien und das Icon, das während der Maintenance angezeigt wird, wurden reloaded."
|
||||
removedMotd: "<prefix><green>Die %INDEX%. Wartungs-MOTD wurde entfernt."
|
||||
removeMotdError: "<prefix><red>Du hast nur eine Maintenance MOTD eingestellt, daher kannst du auch keine entfernen!"
|
||||
setMotd: "<prefix><green>Die %LINE%. Zeile der %INDEX%. Maintenance MOTD wurde geändert zu: %MOTD%"
|
||||
setMotdIndexError: "<prefix><red>Momentan gibt es %MOTDS% MOTDs, du musst also eine Zahl, die zwischen 1 und %NEWAMOUNT% liegt, wählen."
|
||||
setMotdLineError: "<prefix><red>Das zweite Argument des Befehls muss die Zeilennummer sein (1 oder 2)!"
|
||||
updateDownloading: "<prefix><red><bold>Das Update wird heruntergeladen..."
|
||||
updateFailed: "<prefix><dark_red><bold>Das Update ist fehlgeschlagen!"
|
||||
updateFinished: "<prefix><green><bold>Das Update war erfolgreich! Um keine Fehler mit Timern zu erhalten und das Update abzuschließen, wäre ein Serverneustart erforderlich!"
|
||||
whitelistedPlayers: "<prefix><gold>Spieler in der Maintenance Whitelist:"
|
||||
whitelistedPlayersFormat: "<dark_gray>- <yellow>%NAME% <dark_gray>(<gray>%UUID%<dark_gray>)"
|
||||
whitelistAdded: "<prefix><aqua>%PLAYER% <green>wurde zur Wartungs-Whitelist hinzugefügt!"
|
||||
whitelistAlreadyAdded: "<prefix><aqua>%PLAYER% <red>ist bereits in der Maintenance Whitelist!"
|
||||
whitelistRemoved: "<prefix><aqua>%PLAYER% <green>wurde von der Maintenance Whitelist entfernt!"
|
||||
whitelistNotFound: "<prefix><red>Dieser Spieler ist nicht in der Maintenance Whitelist!"
|
||||
whitelistEmpty: "<prefix><red>In der Maintenance Whitelist befinden sich keine Spieler! Nutze <yellow>/maintenance add <player/uuid><red>, um jemanden hinzuzufügen!"
|
||||
playerNotFound: "<prefix><red>Bisher hat kein Spieler mit diesem Namen auf diesem Server gespielt."
|
||||
playerNotFoundUuid: "<prefix><red>Es konnte kein Spieler mit dieser UUID gefunden werden."
|
||||
playerNotOnline: "<prefix><red>Es ist momentan kein Spieler mit diesem Namen online."
|
||||
offlinePlayerFetchError: "<prefix><red>Beim Abrufen des Offline-Spielers ist ein Fehler aufgetreten. Bitte versuche es später erneut."
|
||||
invalidUuid: "<prefix><red>Das UUID Format ist ungültig!"
|
||||
#Messages for the Bungee/Velocity part, you can ignore them if you use the plugin on Paper/Sponge
|
||||
sentToWaitingServer: "<prefix><red>Du wurdest auf einen Warteserver verbunden!"
|
||||
forceWaitingServer: "<prefix><red>Du kannst den Warteserver nicht verlassen, solange der Wartungsmodus aktiviert ist!"
|
||||
serverNotFound: "<prefix><red>Es wurde kein Server mit diesem Namen gefunden!"
|
||||
singleTimerAlreadyRunning: "<prefix><red>Momentan läuft bereits ein Timer auf diesem Server!"
|
||||
singleTimerCancelled: "<prefix><red>Der laufende Timer von <yellow>%SERVER% <red>wurde beendet."
|
||||
singleTimerNotRunning: "<prefix><red>Momentan läuft kein Timer auf diesem Server."
|
||||
singleEndtimerBroadcast: "<prefix><gray>Der Wartungsmodus auf Server %SERVER% wird deaktiviert in: <gold>%TIME%<gray>."
|
||||
singleEndtimerStarted: "<prefix><green>Gestarteter Timer: <gray>Der Wartungsmodus auf Server %SERVER% wird deaktiviert in: <gold>%TIME%<gray>."
|
||||
singleStarttimerBroadcast: "<prefix><gray>Der Wartungsmodus auf Server %SERVER% wird aktiviert in: <gold>%TIME%<gray>."
|
||||
singleStarttimerStarted: "<prefix><green>Gestarteter Timer: <gray>Der Wartungsmodus auf Server %SERVER% ist aktiv in: <gold>%TIME%<gray>."
|
||||
singleScheduletimerBroadcast: "<prefix><gray>Der Wartungsmodus auf Server %SERVER% wird aktiviert in <gold>%TIME% <gray>und wird <gold>%DURATION% <gray>dauern."
|
||||
singleScheduletimerStarted: "<prefix><green>Gestarteter Timer: <gray>Der Wartungsmodus auf Server %SERVER% ist in <gold>%TIME% <gray>aktiv und wird <gold>%DURATION% <gray>dauern."
|
||||
singleMaintenanceKick: "<prefix><red>Der Server %SERVER% befindet sich momentan im Wartungsmodus! Probier es später nochmal!"
|
||||
singleMaintenanceKickComplete: "<red>Der Server %SERVER% befindet sich in Wartung!<br>Du kannst versuchen zu rejoinen, um andere Server zu betreten!"
|
||||
singleMaintenanceActivated: "<prefix><gold>Der Wartungsmodus wurde auf <yellow>%SERVER% <gold>aktiviert."
|
||||
singleMaintenanceDeactivated: "<prefix><gold>Der Wartungsmodus wurde auf <yellow>%SERVER% <gold>deaktiviert."
|
||||
singleServerAlreadyEnabled: "<prefix><red>Der Wartungsmodus ist bereits an auf <yellow>%SERVER%<red>!"
|
||||
singleServerAlreadyDisabled: "<prefix><red>Der Wartungsmodus ist bereits aus auf <yellow>%SERVER%<red>!"
|
||||
singleServerMaintenanceList: "<prefix><gray>Unterserver, die im Wartungsmodus sind:"
|
||||
singleServerMaintenanceListEmpty: "<prefix><gray>Es befindet sich momentan kein Unterserver im Wartungsmodus."
|
||||
singleServerMaintenanceListEntry: "<dark_grey>- <aqua>%SERVER%"
|
||||
second: "Sekunde"
|
||||
seconds: "Sekunden"
|
||||
minute: "Minute"
|
||||
minutes: "Minuten"
|
||||
hour: "Stunde"
|
||||
hours: "Stunden"
|
||||
helpHeader: "<dark_gray>========[ <yellow>%NAME% <dark_gray>| <yellow>%PAGE%/%MAX% <dark_gray>]========"
|
||||
helpPageNotFound: "<prefix><red>Es gibt keine Seite mit dieser Nummer!"
|
||||
helpNextPage: "<gray>Nutze <aqua>/maintenance help %PAGE%<gray>, um zur nächsten Hilfeseite zu kommen."
|
||||
helpAbortTimer: "<gold>/maintenance aborttimer <gray>(Falls momentan ein Timer läuft, wird dieser abgebrochen)"
|
||||
helpEndtimer: "<gold>/maintenance endtimer <Deaktiviere in> <gray>(Sobald der Timer, bspw. 1h5m, abläuft wird der Wartungsmodus deaktiviert)"
|
||||
helpStarttimer: "<gold>/maintenance starttimer <Aktiviere in> <gray>(Sobald der Timer, bspw. 1h5m, abläuft wird der Wartungsmodus aktiviert)"
|
||||
helpScheduleTimer: "<gold>/maintenance scheduletimer <Aktiviere in> <Wartungsdauer> <gray>(Nach der gegebenen Zeit, bspw. 1h5m, wird der Wartungsmodus für die Länge in Minuten aktiviert)"
|
||||
helpDebug: "<gold>/maintenance debug <gray>(Aktiviert Debug Nachrichten in der Konsole)"
|
||||
helpDump: "<gold>/maintenance dump <gray>(Sammelt wichtige Informationen für Bugreports)"
|
||||
helpHelp: "<gold>/maintenance help [Seite] <gray>(Zeigt diese wunderschöne Hilfe)"
|
||||
helpMotd: "<gold>/maintenance motd [Timer] <gray>(Zeigt die momentan gesetzten Maintenance Motds an. Mit dem 'timer' Argument werden die timerspezifischen Motds angezeigt)"
|
||||
helpRemoveMotd: "<gold>/maintenance removemotd [Timer] <Index> <gray>(Entfernt eine Maintenance Motd. Mit dem 'timer' Argument wird eine timerspezifischen Motd entfernt)"
|
||||
helpSetMotd: "<gold>/maintenance setmotd [Timer] <Index> <1/2> <Nachricht> <gray>(Setzte eine Motd für den Wartungsmodus. Mit dem 'timer' Argument wird eine timerspezifische Motd gesetzt)"
|
||||
helpReload: "<gold>/maintenance reload <gray>(Lädt Config, Language und Whitelist Dateien sowie das Maintenance Icon neu)"
|
||||
helpToggle: "<gold>/maintenance <on/off> <gray>(Aktiviert/deaktiviert den Wartungsmodus)"
|
||||
helpUpdate: "<gold>/maintenance update <gray>(Sucht nach neuen Updates für das Plugin und lädt diese auf den Server)"
|
||||
helpWhitelist: "<gold>/maintenance whitelist <gray>(Zeigt alle gewhitelisteten Spieler für den Wartungsmodus an)"
|
||||
helpWhitelistAdd: "<gold>/maintenance add <Name/UUID> <gray>(Whitelistet einen Spieler für den Wartungsmodus, sodass dieser während Wartungen den Server betreten kann)"
|
||||
helpWhitelistRemove: "<gold>/maintenance remove <Name/UUID> <gray>(Entfernt einen Spieler aus der Wartungsmodus Whitelist)"
|
||||
#Messages for the Bungee/Velocity part, you can ignore them if you use the plugin on Paper/Sponge
|
||||
helpAbortSingleTimer: "<gold>/maintenance aborttimer [Server] <gray>(Falls momentan ein Timer läuft, wird dieser abgebrochen)"
|
||||
helpSingleEndtimer: "<gold>/maintenance endtimer [Server] <Deaktiviere in> <gray>(Sobald der Timer, bspw. 1h5m, abläuft wird der Wartungsmodus deaktiviert)"
|
||||
helpSingleStarttimer: "<gold>/maintenance starttimer [Server] <Aktiviere in> <gray>(Sobald der Timer, bspw. 1h5m, abläuft wird der Wartungsmodus aktiviert)"
|
||||
helpSingleScheduleTimer: "<gold>/maintenance scheduletimer [Server] <Starte in> <Wartungsdauer> <gray>(Sobald der Timer, bspw. 1h5m, abläuft wird der Wartungsmodus für die gegebene Länge aktiviert)"
|
||||
helpSingleToggle: "<gold>/maintenance <on/off> [Server] <gray>(Aktiviert/deaktiviert den Wartungsmodus)"
|
||||
helpStatus: "<gold>/maintenance status <gray>(Zeigt alle Server an, auf denen momentan der Wartungsmodus aktiviert ist)"
|
||||
#Used for autoupdating the language file, do not change this value.
|
||||
language-version: 2
|
||||
Loaded 100 of 163 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user