Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1a03a6733 | ||
|
|
92ab4574e8 | ||
|
|
f81851ad9a | ||
|
|
6fb153eb9c | ||
|
|
a6e7bfa793 | ||
|
|
75656be4f5 | ||
|
|
f09f95549a | ||
|
|
78dc87e74a | ||
|
|
3503d02501 | ||
|
|
f8ea89b0b9 | ||
|
|
d0d672b76b | ||
|
|
616d4c7aba | ||
|
|
4415d036a2 | ||
|
|
1f70247c1d | ||
|
|
02ed575e3c | ||
|
|
4e005bca17 | ||
|
|
dcf61a4036 | ||
|
|
8e7b80bddf | ||
|
|
16775bda54 | ||
|
|
29d9fa2ec8 | ||
|
|
ef2ce99746 | ||
|
|
aa5437605f | ||
|
|
22e1d53f81 | ||
|
|
1359684c72 | ||
|
|
22c53bd4ff | ||
|
|
c0e2586684 | ||
|
|
2f095f32ca | ||
|
|
e1e4926f83 | ||
|
|
55b5bf2714 | ||
|
|
5f8f885530 | ||
|
|
fc40b0230d | ||
|
|
6fb79d7051 | ||
|
|
7bc522c1d3 | ||
|
|
8d0d97c220 | ||
|
|
e7c8430909 | ||
|
|
1646d4e417 | ||
|
|
f8384f4f99 | ||
|
|
4fd6ba33ff | ||
|
|
94c146d0e9 | ||
|
|
c624b18b8e | ||
|
|
18a00f9054 | ||
|
|
9778a900a7 | ||
|
|
21fa6a3b7f | ||
|
|
c7980cbc86 | ||
|
|
cdb6715744 | ||
|
|
d868f069cc | ||
|
|
c58b29a78f | ||
|
|
5fb4f06f4c | ||
|
|
8a3afdd1a8 | ||
|
|
36e561c413 | ||
|
|
4739176e9b | ||
|
|
9546cc7b74 | ||
|
|
740051dda5 | ||
|
|
e53f4f2518 | ||
|
|
03390d7be9 | ||
|
|
039c5a3d04 | ||
|
|
4360eb03e3 | ||
|
|
89691e8064 | ||
|
|
8f4860ad56 | ||
|
|
b8b231ce78 | ||
|
|
fd8b47a9f5 | ||
|
|
10c0b5bab3 | ||
|
|
cece2b5813 | ||
|
|
aa9a686b8a | ||
|
|
f29b38989c | ||
|
|
ad9c989213 | ||
|
|
f01e96a32a | ||
|
|
e247f4ef10 | ||
|
|
b8e0f84d54 | ||
|
|
424617c602 | ||
|
|
21ed266d3d | ||
|
|
a409ec5d66 | ||
|
|
66cba12fd3 | ||
|
|
f6d178d8d1 | ||
|
|
d04749c835 | ||
|
|
eebbc4d532 | ||
|
|
335fe303b5 | ||
|
|
1c4b5e62a4 | ||
|
|
d41fa5ab24 | ||
|
|
7fd486ef40 | ||
|
|
d0b10f2524 | ||
|
|
865df5e20a | ||
|
|
469e8eb57b | ||
|
|
368ac37099 | ||
|
|
0db4d77c10 | ||
|
|
ca4c711103 | ||
|
|
f4a5f288ca | ||
|
|
0a37bfdefe | ||
|
|
3a30dba011 | ||
|
|
111a229d48 | ||
|
|
7e948fbe52 | ||
|
|
355aa20244 | ||
|
|
6bc54d1812 | ||
|
|
0042ce3ccd | ||
|
|
beb0e52371 | ||
|
|
4774ec2f2a | ||
|
|
34115f443e | ||
|
|
c8f0c1699e | ||
|
|
f22be77023 | ||
|
|
730a8dbeea | ||
|
|
0548e0c447 | ||
|
|
da0a757c5e | ||
|
|
ac19bac11c | ||
|
|
1de926bb28 | ||
|
|
94308cde7c | ||
|
|
d863c709e1 | ||
|
|
741914283a | ||
|
|
64902d90ff | ||
|
|
d3b4c7c87b | ||
|
|
390b65a70e | ||
|
|
7cff908aae | ||
|
|
d1f049c3e5 | ||
|
|
8d552dbe33 | ||
|
|
d3a933d21d | ||
|
|
a4d87dabf5 | ||
|
|
c3b579e86c | ||
|
|
b75d2337df | ||
|
|
b3e83c5c2e | ||
|
|
b6f447aded | ||
|
|
9febdfc140 | ||
|
|
90bc30d701 | ||
|
|
843ba4ac86 | ||
|
|
032fd7d582 | ||
|
|
9a0f680177 | ||
|
|
415d5f3807 | ||
|
|
33c96de5fb | ||
|
|
d141b40190 | ||
|
|
77e1444dba | ||
|
|
915b43d897 | ||
|
|
adc06e3486 | ||
|
|
cc7f5c2d11 | ||
|
|
0bb54ffc5d | ||
|
|
15ee2e6074 | ||
|
|
89abab36f8 | ||
|
|
e0bb1336b0 | ||
|
|
888ffd301a | ||
|
|
3a55dd3280 | ||
|
|
61c47ba2fa | ||
|
|
b97e69a71f | ||
|
|
75c940d089 | ||
|
|
849fa2a720 | ||
|
|
7e249faa99 | ||
|
|
c8272b39d5 | ||
|
|
b3c561ae26 | ||
|
|
af24c5a331 | ||
|
|
4cc162f00d | ||
|
|
02610fd904 | ||
|
|
bccd1bb936 | ||
|
|
c08dd5d430 | ||
|
|
1104a50882 | ||
|
|
56898d7b40 | ||
|
|
4be31a6dd4 | ||
|
|
190a063d49 | ||
|
|
6e4591d45b | ||
|
|
86c556e841 | ||
|
|
404e14ee94 | ||
|
|
b8c0e3a799 | ||
|
|
10d798acd4 | ||
|
|
be057f4b3b | ||
|
|
eea7a595c9 | ||
|
|
bf4bf79b23 | ||
|
|
686535228e | ||
|
|
8b645b6f79 | ||
|
|
4d97293a8c | ||
|
|
c746a83f5f | ||
|
|
eb7e6e3f0b | ||
|
|
f5ce41853f | ||
|
|
e67cde591c | ||
|
|
39682635c6 | ||
|
|
efee532742 | ||
|
|
0aee3a8fd6 | ||
|
|
f79b6caccb | ||
|
|
73fd80b456 | ||
|
|
ad1a7eb420 | ||
|
|
bfa9b52497 | ||
|
|
ff4b5b0d2e | ||
|
|
b8e73062fa | ||
|
|
863a9b3beb | ||
|
|
fe64936ddf |
No files matched your search
@@ -1,6 +1,107 @@
|
||||
# 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.
|
||||
|
||||
---
|
||||
## 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 (thanks to @TheViperShow)
|
||||
* 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!
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
name: Build
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2.3.4
|
||||
|
||||
- uses: actions/cache@v2.1.6
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: ${{ runner.os }}-maven-
|
||||
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v2.1.0
|
||||
with:
|
||||
java-version: 11
|
||||
distribution: 'adopt'
|
||||
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v2.2.4
|
||||
with:
|
||||
name: MaintenanceFiles
|
||||
path: |
|
||||
**/Maintenance.jar
|
||||
**/MaintenanceSpigot.jar
|
||||
**/MaintenanceBungee.jar
|
||||
**/MaintenanceVelocity.jar
|
||||
**/MaintenanceSponge.jar
|
||||
+2
-2
@@ -1,5 +1,4 @@
|
||||
.metadata
|
||||
dependencies/
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
@@ -92,4 +91,5 @@ $RECYCLE.BIN/
|
||||
*.msm
|
||||
*.msp
|
||||
*.lnk
|
||||
!MaintenanceAPI.jar
|
||||
!MaintenanceAPI.jar
|
||||
**/src/test/resources/
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
language: java
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
|
||||
dist: trusty
|
||||
cache:
|
||||
directories:
|
||||
- '$HOME/.m2'
|
||||
- '$HOME/.m2/repository'
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://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 <http://www.gnu.org/licenses/>.
|
||||
along with this program. If not, see <https://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
|
||||
<http://www.gnu.org/licenses/>.
|
||||
<https://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
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
Binary file not shown.
@@ -1,9 +1,11 @@
|
||||
# Maintenance
|
||||
[](https://github.com/KennyTV/Maintenance/releases)
|
||||
[](https://travis-ci.org/KennyTV/Maintenance)
|
||||
[](https://discord.gg/vGCUzHq)
|
||||
[](https://github.com/kennytv/Maintenance/releases)
|
||||

|
||||
[](https://github.com/kennytv/Maintenance/releases)
|
||||
[](https://discord.gg/vGCUzHq)
|
||||
[](https://twitter.com/kennytvn)
|
||||
|
||||
Maintenance is probably the most customizable free maintenance plugin for your Minecraft server you can find. It runs on Bukkit/Spigot, BungeeCord, Sponge as well as Velocity.
|
||||
Maintenance is the most customizable free maintenance plugin for your Minecraft server you can find. It runs on Spigot, BungeeCord, Sponge, as well as Velocity.
|
||||
|
||||
Its features include:
|
||||
* A custom motd as well as server icon, that will be shown during maintenance
|
||||
@@ -14,22 +16,23 @@ Its features include:
|
||||
* 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://github.com/kennytv/Maintenance/wiki/MaintenanceAddon) (only for Bungee)
|
||||
|
||||
A full list of commands, permissions and configuration options can be found in the wiki listed below.
|
||||
* [Wiki](https://github.com/KennyTV/Maintenance/wiki)
|
||||
* [Downloads](https://github.com/KennyTV/Maintenance/releases) (GitHub)
|
||||
* [Development builds](https://kennytv.eu/maintenance/snapshot/) (might be unstable)
|
||||
* [Changelogs](https://github.com/KennyTV/Maintenance/blob/master/.github/CHANGELOG.md)
|
||||
* [Issue tracker/bug reports](https://github.com/KennyTV/Maintenance/issues)
|
||||
* [Wiki](https://github.com/kennytv/Maintenance/wiki) (configuration, permissions, API usage)
|
||||
* [Downloads](https://github.com/kennytv/Maintenance/releases) (GitHub)
|
||||
* [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://github.com/kennytv/Maintenance/wiki/MaintenanceAddon)
|
||||
|
||||
Other forums
|
||||
Other forum threads
|
||||
* [Spigot forums](https://www.spigotmc.org/resources/maintenance.40699/)
|
||||
* [Sponge forums](https://forums.spongepowered.org/t/maintenance/27421)
|
||||
* [Ore/Sponge Forums](https://ore.spongepowered.org/KennyTV/Maintenance)
|
||||
* [Velocity forums](https://forums.velocitypowered.com/t/maintenance/129)
|
||||
|
||||
## Compiling
|
||||
To create a working jar yourself, simply clone the project and compile it with maven (by using `mvn clean package` in your IDE console).
|
||||
|
||||
## Licence
|
||||
You may only copy the code on a public repository while also keeping it under the same license (see [GNU General Public License](http://www.gnu.org/licenses/gpl-3.0)).
|
||||
## License
|
||||
This project is licensed under the [GNU General Public License v3](LICENSE.txt).
|
||||
@@ -4,9 +4,9 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<groupId>eu.kennytv.maintenance</groupId>
|
||||
<artifactId>maintenance-parent</artifactId>
|
||||
<version>3.0</version>
|
||||
<version>3.0.7</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>maintenance-api</artifactId>
|
||||
@@ -16,13 +16,13 @@
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<version>1.17-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.5-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,11 +15,12 @@
|
||||
* 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.IEventManager;
|
||||
|
||||
/**
|
||||
* @author KennyTV
|
||||
* @author kennytv
|
||||
* @since 2.1
|
||||
*/
|
||||
public interface IMaintenance {
|
||||
@@ -57,4 +58,23 @@ public interface IMaintenance {
|
||||
* @return {@link ISettings} instance
|
||||
*/
|
||||
ISettings getSettings();
|
||||
|
||||
/**
|
||||
* Returns the {@link IEventManager} instance to register listeners to maintenance events.
|
||||
*
|
||||
* @return {@link IEventManager} instance
|
||||
*/
|
||||
IEventManager 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,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,11 +15,10 @@
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* @author KennyTV
|
||||
* @author kennytv
|
||||
* @since 2.2.2
|
||||
*/
|
||||
public interface IMaintenanceBase {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,14 +15,13 @@
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* @author KennyTV
|
||||
* @author kennytv
|
||||
* @since 2.1
|
||||
*/
|
||||
public interface ISettings {
|
||||
@@ -34,6 +33,11 @@ public interface ISettings {
|
||||
*/
|
||||
boolean isMaintenance();
|
||||
|
||||
/**
|
||||
* @return true if custom ping messages during maintenance should be used
|
||||
*/
|
||||
boolean isEnablePingMessages();
|
||||
|
||||
/**
|
||||
* @return value of the 'send-join-notification' config field
|
||||
*/
|
||||
@@ -52,6 +56,14 @@ public interface ISettings {
|
||||
*/
|
||||
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.
|
||||
*
|
||||
|
||||
+6
-7
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,9 +15,9 @@
|
||||
* 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.bungee;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import eu.kennytv.maintenance.api.IMaintenanceBase;
|
||||
import eu.kennytv.maintenance.api.proxy.IMaintenanceProxy;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
@@ -29,7 +29,7 @@ import net.md_5.bungee.api.plugin.Plugin;
|
||||
* Only access this class if you're running the plugin on a BungeeCord server!
|
||||
* </p>
|
||||
*
|
||||
* @author KennyTV
|
||||
* @author kennytv
|
||||
* @since 2.5
|
||||
*/
|
||||
public final class MaintenanceBungeeAPI {
|
||||
@@ -41,9 +41,8 @@ public final class MaintenanceBungeeAPI {
|
||||
* @throws IllegalArgumentException if using a custom (or broken?) version of the plugin, that can't be identified
|
||||
*/
|
||||
public static IMaintenanceProxy getAPI() {
|
||||
final Plugin maintenance = ProxyServer.getInstance().getPluginManager().getPlugin("MaintenanceBungee");
|
||||
if (maintenance == null)
|
||||
throw new IllegalArgumentException("Could not get instance of MaintenanceBungee! Broken/custom build of the plugin?");
|
||||
final Plugin maintenance = ProxyServer.getInstance().getPluginManager().getPlugin("Maintenance");
|
||||
Preconditions.checkNotNull(maintenance, "Could not get instance of Maintenance! Broken/custom build of the plugin?");
|
||||
return (IMaintenanceProxy) ((IMaintenanceBase) maintenance).getApi();
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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.
|
||||
*
|
||||
* @author kennytv
|
||||
* @since 3.0.1
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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.IMaintenance;
|
||||
import eu.kennytv.maintenance.api.event.manager.MaintenanceEvent;
|
||||
import eu.kennytv.maintenance.api.proxy.IMaintenanceProxy;
|
||||
|
||||
/**
|
||||
* Notification event fired when Maintenance configuration is reloaded.
|
||||
*
|
||||
* @author kennytv
|
||||
* @see IMaintenance#isMaintenance() for the new maintenance status
|
||||
* @see IMaintenanceProxy#getMaintenanceServers() for the new list of servers under maintenance
|
||||
* @since 3.0.6
|
||||
*/
|
||||
public final class MaintenanceReloadedEvent implements MaintenanceEvent {
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
* @author kennytv
|
||||
* @since 3.0.1
|
||||
*/
|
||||
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);
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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;
|
||||
|
||||
/**
|
||||
* @author kennytv
|
||||
* @since 3.0.1
|
||||
*/
|
||||
public interface IEventManager {
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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.
|
||||
*
|
||||
* @author kennytv
|
||||
* @since 3.0.1
|
||||
*/
|
||||
public interface MaintenanceEvent {
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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.
|
||||
*
|
||||
* @author kennytv
|
||||
* @since 3.0.1
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
+12
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,13 +15,15 @@
|
||||
* 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.IMaintenance;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author KennyTV
|
||||
* @author kennytv
|
||||
* @since 3.0
|
||||
*/
|
||||
public interface IMaintenanceProxy extends IMaintenance {
|
||||
@@ -58,5 +60,11 @@ public interface IMaintenanceProxy extends IMaintenance {
|
||||
* @param server name of the proxied server
|
||||
* @return wrapped server object if present, else null
|
||||
*/
|
||||
@Nullable
|
||||
Server getServer(String server);
|
||||
|
||||
/**
|
||||
* @return immutable set with names of all proxied server that are currently under maintenance
|
||||
*/
|
||||
Set<String> getMaintenanceServers();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,14 +15,13 @@
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Wrapper for a proxied server.
|
||||
* Use {@link IMaintenanceProxy#getServer(String)} to get a server instance.
|
||||
*
|
||||
* @author KennyTV
|
||||
* @author kennytv
|
||||
* @since 3.0
|
||||
*/
|
||||
public interface Server {
|
||||
@@ -43,4 +42,12 @@ public interface Server {
|
||||
* @param message message to be broadcasted
|
||||
*/
|
||||
void broadcast(String message);
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
+6
-7
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,9 +15,9 @@
|
||||
* 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.spigot;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import eu.kennytv.maintenance.api.IMaintenance;
|
||||
import eu.kennytv.maintenance.api.IMaintenanceBase;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -29,7 +29,7 @@ import org.bukkit.plugin.Plugin;
|
||||
* Only access this class if you're running the plugin on a Spigot server!
|
||||
* </p>
|
||||
*
|
||||
* @author KennyTV
|
||||
* @author kennytv
|
||||
* @since 2.5
|
||||
*/
|
||||
public final class MaintenanceSpigotAPI {
|
||||
@@ -41,9 +41,8 @@ public final class MaintenanceSpigotAPI {
|
||||
* @throws IllegalArgumentException if using a custom (or broken?) version of the plugin, that can't be identified
|
||||
*/
|
||||
public static IMaintenance getAPI() {
|
||||
final Plugin maintenance = Bukkit.getPluginManager().getPlugin("MaintenanceSpigot");
|
||||
if (maintenance == null)
|
||||
throw new IllegalArgumentException("Could not get instance of MaintenanceSpigot! Broken/custom build of the plugin?");
|
||||
final Plugin maintenance = Bukkit.getPluginManager().getPlugin("Maintenance");
|
||||
Preconditions.checkNotNull(maintenance, "Could not get instance of Maintenance! Broken/custom build of the plugin?");
|
||||
return ((IMaintenanceBase) maintenance).getApi();
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,9 +15,9 @@
|
||||
* 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.sponge;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import eu.kennytv.maintenance.api.IMaintenance;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.plugin.PluginContainer;
|
||||
@@ -30,7 +30,7 @@ import java.util.Optional;
|
||||
* Only access this class if you're running the plugin on a Sponge server!
|
||||
* </p>
|
||||
*
|
||||
* @author KennyTV
|
||||
* @author kennytv
|
||||
* @since 3.0
|
||||
*/
|
||||
public final class MaintenanceSpongeAPI {
|
||||
@@ -42,9 +42,9 @@ public final class MaintenanceSpongeAPI {
|
||||
* @throws IllegalArgumentException if using a custom (or broken?) version of the plugin, that can't be identified
|
||||
*/
|
||||
public static IMaintenance getAPI() {
|
||||
final Optional<PluginContainer> container = Sponge.getPluginManager().getPlugin("maintenancesponge");
|
||||
if (!container.isPresent() || !container.get().getInstance().isPresent())
|
||||
throw new IllegalArgumentException("Could not get instance of MaintenanceSponge! Broken/custom build of the plugin?");
|
||||
final Optional<PluginContainer> container = Sponge.getPluginManager().getPlugin("maintenance");
|
||||
Preconditions.checkArgument(container.isPresent() && container.get().getInstance().isPresent(),
|
||||
"Could not get instance of Maintenance! Broken/custom build of the plugin?");
|
||||
return (IMaintenance) container.get().getInstance().get();
|
||||
}
|
||||
}
|
||||
+36
-16
@@ -4,9 +4,9 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<groupId>eu.kennytv.maintenance</groupId>
|
||||
<artifactId>maintenance-parent</artifactId>
|
||||
<version>3.0</version>
|
||||
<version>3.0.7</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>maintenance-build</artifactId>
|
||||
@@ -15,28 +15,48 @@
|
||||
<dependencies>
|
||||
<!-- Also includes maintenance-core and maintenance-core-proxy modules -->
|
||||
<dependency>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<groupId>eu.kennytv.maintenance</groupId>
|
||||
<artifactId>maintenance-bungee</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<groupId>eu.kennytv.maintenance</groupId>
|
||||
<artifactId>maintenance-spigot</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<artifactId>maintenance-sponge</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<artifactId>maintenance-velocity</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- Don't include Sponge and Velocity in main jar anymore, counters relocation errors and minimizes shading -->
|
||||
</dependencies>
|
||||
|
||||
<!-- Needed to relocate stuff in Bungee module, but not in the core one -->
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.slf4j</pattern>
|
||||
<shadedPattern>eu.kennytv.lib.slf4j</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.hikari</pattern>
|
||||
<shadedPattern>eu.kennytv.lib.hikari</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -4,9 +4,9 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<groupId>eu.kennytv.maintenance</groupId>
|
||||
<artifactId>maintenance-parent</artifactId>
|
||||
<version>3.0</version>
|
||||
<version>3.0.7</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>maintenance-bungee</artifactId>
|
||||
@@ -14,16 +14,54 @@
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<groupId>eu.kennytv.maintenance</groupId>
|
||||
<artifactId>maintenance-core-proxy</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- Only compile slf4j on Bungee (not Velocity) to prevent relocation errors -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.30</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<version>1.17-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- Needed to relocate stuff in Bungee module, but not in the core one -->
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.slf4j</pattern>
|
||||
<shadedPattern>eu.kennytv.lib.slf4j</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.hikari</pattern>
|
||||
<shadedPattern>eu.kennytv.lib.hikari</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
+8
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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.bungee;
|
||||
|
||||
import eu.kennytv.maintenance.api.IMaintenance;
|
||||
@@ -25,13 +24,18 @@ import net.md_5.bungee.api.plugin.Plugin;
|
||||
import java.io.File;
|
||||
|
||||
public final class MaintenanceBungeeBase extends Plugin implements IMaintenanceBase {
|
||||
private IMaintenance maintenance;
|
||||
private MaintenanceBungeePlugin maintenance;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
maintenance = new MaintenanceBungeePlugin(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
maintenance.disable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMaintenance getApi() {
|
||||
return maintenance;
|
||||
|
||||
+82
-25
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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.bungee;
|
||||
|
||||
import eu.kennytv.maintenance.api.bungee.MaintenanceBungeeAPI;
|
||||
@@ -23,7 +22,6 @@ import eu.kennytv.maintenance.api.proxy.IMaintenanceProxy;
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import eu.kennytv.maintenance.bungee.command.MaintenanceBungeeCommand;
|
||||
import eu.kennytv.maintenance.bungee.command.MaintenanceBungeeCommandBase;
|
||||
import eu.kennytv.maintenance.bungee.listener.PostLoginListener;
|
||||
import eu.kennytv.maintenance.bungee.listener.ProxyPingListener;
|
||||
import eu.kennytv.maintenance.bungee.listener.ServerConnectListener;
|
||||
import eu.kennytv.maintenance.bungee.metrics.MetricsLite;
|
||||
@@ -34,6 +32,8 @@ import eu.kennytv.maintenance.core.dump.PluginDump;
|
||||
import eu.kennytv.maintenance.core.hook.ServerListPlusHook;
|
||||
import eu.kennytv.maintenance.core.proxy.MaintenanceProxyPlugin;
|
||||
import eu.kennytv.maintenance.core.proxy.SettingsProxy;
|
||||
import eu.kennytv.maintenance.core.proxy.util.ProfileLookup;
|
||||
import eu.kennytv.maintenance.core.proxy.util.ProxyOfflineSenderInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import eu.kennytv.maintenance.core.util.ServerType;
|
||||
import eu.kennytv.maintenance.core.util.Task;
|
||||
@@ -48,6 +48,7 @@ import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.api.plugin.PluginManager;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.File;
|
||||
@@ -61,7 +62,7 @@ import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author KennyTV
|
||||
* @author kennytv
|
||||
* @since 1.0
|
||||
*/
|
||||
public final class MaintenanceBungeePlugin extends MaintenanceProxyPlugin {
|
||||
@@ -78,19 +79,21 @@ public final class MaintenanceBungeePlugin extends MaintenanceProxyPlugin {
|
||||
sendEnableMessage();
|
||||
|
||||
final PluginManager pm = getProxy().getPluginManager();
|
||||
pm.registerListener(plugin, new PostLoginListener(this, settingsProxy));
|
||||
pm.registerListener(plugin, new ProxyPingListener(this, settingsProxy));
|
||||
pm.registerListener(plugin, new ServerConnectListener(this, settingsProxy));
|
||||
commandManager = new MaintenanceBungeeCommand(this, settingsProxy);
|
||||
pm.registerCommand(plugin, new MaintenanceBungeeCommandBase(commandManager));
|
||||
|
||||
continueLastEndtimer();
|
||||
new MetricsLite(plugin);
|
||||
|
||||
// ServerListPlus integration
|
||||
final Plugin serverListPlus = pm.getPlugin("ServerListPlus");
|
||||
if (serverListPlus != null) {
|
||||
serverListPlusHook = new ServerListPlusHook(serverListPlus);
|
||||
serverListPlusHook.setEnabled(!settingsProxy.isMaintenance());
|
||||
if (settings.isEnablePingMessages()) {
|
||||
serverListPlusHook.setEnabled(!settingsProxy.isMaintenance());
|
||||
}
|
||||
plugin.getLogger().info("Enabled ServerListPlus integration!");
|
||||
}
|
||||
}
|
||||
@@ -113,59 +116,98 @@ public final class MaintenanceBungeePlugin extends MaintenanceProxyPlugin {
|
||||
}
|
||||
|
||||
public boolean isMaintenance(final ServerInfo serverInfo) {
|
||||
return settingsProxy.isMaintenance(new BungeeServer(serverInfo));
|
||||
return settingsProxy.isMaintenance(serverInfo.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void kickPlayers() {
|
||||
getProxy().getPlayers().stream()
|
||||
.filter(p -> !hasPermission(p, "bypass") && !settingsProxy.getWhitelistedPlayers().containsKey(p.getUniqueId()))
|
||||
.forEach(p -> p.disconnect(settingsProxy.getKickMessage()));
|
||||
protected void kickPlayersFromProxy() {
|
||||
for (final ProxiedPlayer p : getProxy().getPlayers()) {
|
||||
if (!hasPermission(p, "bypass") && !settingsProxy.isWhitelisted(p.getUniqueId())) {
|
||||
p.disconnect(settingsProxy.getKickMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void kickPlayers(final Server server, final Server fallback) {
|
||||
// Kick players from a proxied server
|
||||
final ServerInfo fallbackServer = fallback != null ? ((BungeeServer) fallback).getServer() : null;
|
||||
((BungeeServer) server).getServer().getPlayers().forEach(p -> {
|
||||
if (!hasPermission(p, "bypass") && !settingsProxy.getWhitelistedPlayers().containsKey(p.getUniqueId())) {
|
||||
if (fallbackServer != null && fallbackServer.canAccess(p) && !isMaintenance(fallback)) {
|
||||
p.sendMessage(settingsProxy.getMessage("singleMaintenanceActivated").replace("%SERVER%", server.getName()));
|
||||
p.connect(fallbackServer);
|
||||
} else
|
||||
p.disconnect(settingsProxy.getMessage("singleMaintenanceKickComplete").replace("%NEWLINE%", "\n").replace("%SERVER%", server.getName()));
|
||||
final boolean checkForFallback = fallbackServer != null && !isMaintenance(fallback);
|
||||
for (final ProxiedPlayer player : ((BungeeServer) server).getServer().getPlayers()) {
|
||||
if (!hasPermission(player, "bypass") && !settingsProxy.isWhitelisted(player.getUniqueId())) {
|
||||
if (checkForFallback && fallbackServer.canAccess(player)) {
|
||||
player.sendMessage(settingsProxy.getMessage("singleMaintenanceActivated").replace("%SERVER%", server.getName()));
|
||||
player.connect(fallbackServer);
|
||||
} else {
|
||||
player.disconnect(settingsProxy.getFullServerKickMessage(server.getName()));
|
||||
}
|
||||
} else {
|
||||
p.sendMessage(settingsProxy.getMessage("singleMaintenanceActivated").replace("%SERVER%", server.getName()));
|
||||
player.sendMessage(settingsProxy.getMessage("singleMaintenanceActivated").replace("%SERVER%", server.getName()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Task startMaintenanceRunnable(final Runnable runnable) {
|
||||
protected void kickPlayersTo(final Server server) {
|
||||
// Kick all players to a single waiting server
|
||||
final ServerInfo serverInfo = ((BungeeServer) server).getServer();
|
||||
// Notifications done in global method
|
||||
for (final ProxiedPlayer player : getProxy().getPlayers()) {
|
||||
if (hasPermission(player, "bypass") || settingsProxy.isWhitelisted(player.getUniqueId())) continue;
|
||||
if (player.getServer() != null && player.getServer().getInfo().getName().equals(serverInfo.getName()))
|
||||
continue;
|
||||
if (serverInfo.canAccess(player) && !isMaintenance(serverInfo)) {
|
||||
player.sendMessage(settingsProxy.getMessage("sentToWaitingServer").replace("%SERVER%", server.getName()));
|
||||
player.connect(serverInfo);
|
||||
} else {
|
||||
player.disconnect(settingsProxy.getKickMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task startMaintenanceRunnable(final Runnable runnable) {
|
||||
return new BungeeTask(getProxy().getScheduler().schedule(plugin, runnable, 0, 1, TimeUnit.SECONDS).getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Server getServer(final String server) {
|
||||
final ServerInfo serverInfo = getProxy().getServerInfo(server);
|
||||
return serverInfo != null ? new BungeeServer(serverInfo) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public SenderInfo getOfflinePlayer(final String name) {
|
||||
final ProxiedPlayer player = getProxy().getPlayer(name);
|
||||
return player != null ? new BungeeSenderInfo(player) : null;
|
||||
if (player != null) {
|
||||
return new BungeeSenderInfo(player);
|
||||
}
|
||||
|
||||
final ProfileLookup profile;
|
||||
try {
|
||||
profile = doUUIDLookup(name);
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return new ProxyOfflineSenderInfo(profile.getUuid(), profile.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public SenderInfo getOfflinePlayer(final UUID uuid) {
|
||||
final ProxiedPlayer player = getProxy().getPlayer(uuid);
|
||||
return player != null ? new BungeeSenderInfo(player) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServer(final SenderInfo sender) {
|
||||
@Nullable
|
||||
public String getServerNameOf(final SenderInfo sender) {
|
||||
final ProxiedPlayer player = getProxy().getPlayer(sender.getUuid());
|
||||
return player != null ? player.getServer().getInfo().getName() : "";
|
||||
if (player == null || player.getServer() == null) return null;
|
||||
return player.getServer().getInfo().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -173,6 +215,11 @@ public final class MaintenanceBungeePlugin extends MaintenanceProxyPlugin {
|
||||
getProxy().getScheduler().runAsync(plugin, runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executeConsoleCommand(final String command) {
|
||||
getProxy().getPluginManager().dispatchCommand(getProxy().getConsole(), command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcast(final String message) {
|
||||
getProxy().broadcast(message);
|
||||
@@ -188,6 +235,16 @@ public final class MaintenanceBungeePlugin extends MaintenanceProxyPlugin {
|
||||
return plugin.getPluginFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getOnlinePlayers() {
|
||||
return getProxy().getOnlineCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMaxPlayers() {
|
||||
return getProxy().getConfig().getPlayerLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getResource(final String name) {
|
||||
return plugin.getResourceAsStream(name);
|
||||
|
||||
+19
-9
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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.bungee.command;
|
||||
|
||||
import eu.kennytv.maintenance.bungee.MaintenanceBungeePlugin;
|
||||
@@ -23,13 +22,15 @@ import eu.kennytv.maintenance.bungee.util.BungeeSenderInfo;
|
||||
import eu.kennytv.maintenance.core.proxy.SettingsProxy;
|
||||
import eu.kennytv.maintenance.core.proxy.command.MaintenanceProxyCommand;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.Map;
|
||||
|
||||
public final class MaintenanceBungeeCommand extends MaintenanceProxyCommand {
|
||||
private final MaintenanceBungeePlugin plugin;
|
||||
@@ -51,9 +52,14 @@ public final class MaintenanceBungeeCommand extends MaintenanceProxyCommand {
|
||||
|
||||
@Override
|
||||
public List<String> getServersCompletion(final String s) {
|
||||
return plugin.getProxy().getServers().entrySet().stream().filter(entry -> entry.getKey().toLowerCase().startsWith(s))
|
||||
.filter(entry -> !plugin.getSettingsProxy().getMaintenanceServers().contains(entry.getValue().getName()))
|
||||
.map(entry -> entry.getValue().getName()).collect(Collectors.toList());
|
||||
final List<String> list = new ArrayList<>();
|
||||
for (final Map.Entry<String, ServerInfo> entry : plugin.getProxy().getServers().entrySet()) {
|
||||
final String serverName = entry.getValue().getName();
|
||||
if (entry.getKey().toLowerCase().startsWith(s) && !plugin.getSettingsProxy().getMaintenanceServers().contains(serverName)) {
|
||||
list.add(serverName);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,6 +73,10 @@ public final class MaintenanceBungeeCommand extends MaintenanceProxyCommand {
|
||||
|
||||
@Override
|
||||
public List<String> getPlayersCompletion() {
|
||||
return plugin.getProxy().getPlayers().stream().map(CommandSender::getName).collect(Collectors.toList());
|
||||
final List<String> list = new ArrayList<>();
|
||||
for (final ProxiedPlayer p : plugin.getProxy().getPlayers()) {
|
||||
list.add(p.getName());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
+8
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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.bungee.command;
|
||||
|
||||
import eu.kennytv.maintenance.bungee.util.BungeeSenderInfo;
|
||||
@@ -28,10 +27,15 @@ public final class MaintenanceBungeeCommandBase extends Command implements TabEx
|
||||
private final MaintenanceCommand command;
|
||||
|
||||
public MaintenanceBungeeCommandBase(final MaintenanceCommand command) {
|
||||
super("maintenance", "", "maintenancebungee");
|
||||
super("maintenance", "maintenance.command", "maintenancebungee", "mt");
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final CommandSender sender) {
|
||||
return sender.hasPermission("maintenance.admin") || sender.hasPermission("maintenance.command");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final String[] args) {
|
||||
command.execute(new BungeeSenderInfo(sender), args);
|
||||
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 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.bungee.listener;
|
||||
|
||||
import eu.kennytv.maintenance.bungee.MaintenanceBungeePlugin;
|
||||
import eu.kennytv.maintenance.bungee.util.BungeeSenderInfo;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.core.listener.JoinListenerBase;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public final class PostLoginListener extends JoinListenerBase implements Listener {
|
||||
private final MaintenanceBungeePlugin plugin;
|
||||
|
||||
public PostLoginListener(final MaintenanceBungeePlugin plugin, final Settings settings) {
|
||||
super(plugin, settings);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void postLogin(final PostLoginEvent event) {
|
||||
if (kickPlayer(new BungeeSenderInfo(event.getPlayer())))
|
||||
event.getPlayer().disconnect(settings.getKickMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void broadcastJoinNotification(final String name) {
|
||||
final BaseComponent[] s = TextComponent.fromLegacyText(settings.getMessage("joinNotification").replace("%PLAYER%", name));
|
||||
ProxyServer.getInstance().getPlayers().stream().filter(p -> plugin.hasPermission(p, "joinnotification")).forEach(p -> p.sendMessage(s));
|
||||
}
|
||||
}
|
||||
+21
-16
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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.bungee.listener;
|
||||
|
||||
import eu.kennytv.maintenance.bungee.MaintenanceBungeePlugin;
|
||||
@@ -24,7 +23,6 @@ import net.md_5.bungee.api.ServerPing;
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.event.EventPriority;
|
||||
|
||||
public final class ProxyPingListener implements Listener {
|
||||
private final MaintenanceBungeePlugin plugin;
|
||||
@@ -35,26 +33,33 @@ public final class ProxyPingListener implements Listener {
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@EventHandler(priority = 80)
|
||||
public void proxyPing(final ProxyPingEvent event) {
|
||||
if (!settings.isMaintenance()) return;
|
||||
if (!settings.isMaintenance() || !settings.isEnablePingMessages()) return;
|
||||
|
||||
final ServerPing ping = event.getResponse();
|
||||
ServerPing.Players players = ping.getPlayers();
|
||||
if (players == null) {
|
||||
ping.setPlayers(players = new ServerPing.Players(0, 0, null));
|
||||
}
|
||||
|
||||
if (settings.hasCustomPlayerCountMessage()) {
|
||||
ping.getVersion().setProtocol(1);
|
||||
ping.getVersion().setName(settings.getPlayerCountMessage()
|
||||
.replace("%ONLINE%", Integer.toString(ping.getPlayers().getOnline()))
|
||||
.replace("%MAX%", Integer.toString(ping.getPlayers().getMax())));
|
||||
ping.setVersion(new ServerPing.Protocol(settings.getPlayerCountMessage()
|
||||
.replace("%ONLINE%", Integer.toString(players.getOnline()))
|
||||
.replace("%MAX%", Integer.toString(players.getMax())), 1));
|
||||
}
|
||||
|
||||
ping.setDescription(settings.getRandomPingMessage());
|
||||
ping.getPlayers().setOnline(0);
|
||||
ping.getPlayers().setMax(0);
|
||||
ping.getPlayers().setSample(new ServerPing.PlayerInfo[]{
|
||||
new ServerPing.PlayerInfo(settings.getPlayerCountHoverMessage().replace("%NEWLINE%", "\n"), "")
|
||||
});
|
||||
|
||||
if (settings.hasCustomIcon() && plugin.getFavicon() != null)
|
||||
final String[] split = settings.getPlayerCountHoverMessage().split("\n");
|
||||
final ServerPing.PlayerInfo[] samplePlayers = new ServerPing.PlayerInfo[split.length];
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
samplePlayers[i] = new ServerPing.PlayerInfo(split[i], "");
|
||||
}
|
||||
players.setSample(samplePlayers);
|
||||
|
||||
if (settings.hasCustomIcon() && plugin.getFavicon() != null) {
|
||||
ping.setFavicon(plugin.getFavicon());
|
||||
}
|
||||
}
|
||||
}
|
||||
+78
-32
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,58 +15,104 @@
|
||||
* 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.bungee.listener;
|
||||
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import eu.kennytv.maintenance.bungee.MaintenanceBungeePlugin;
|
||||
import eu.kennytv.maintenance.bungee.util.BungeeSenderInfo;
|
||||
import eu.kennytv.maintenance.bungee.util.BungeeServer;
|
||||
import eu.kennytv.maintenance.core.proxy.SettingsProxy;
|
||||
import eu.kennytv.maintenance.core.proxy.listener.ProxyJoinListenerBase;
|
||||
import eu.kennytv.maintenance.core.proxy.util.ServerConnectResult;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.ServerConnectEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.event.EventPriority;
|
||||
|
||||
public final class ServerConnectListener implements Listener {
|
||||
public final class ServerConnectListener extends ProxyJoinListenerBase implements Listener {
|
||||
private final MaintenanceBungeePlugin plugin;
|
||||
private final SettingsProxy settings;
|
||||
private boolean warned;
|
||||
|
||||
public ServerConnectListener(final MaintenanceBungeePlugin plugin, final SettingsProxy settings) {
|
||||
super(plugin, settings);
|
||||
this.plugin = plugin;
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void serverConnect(final ServerConnectEvent event) {
|
||||
final ProxiedPlayer player = event.getPlayer();
|
||||
final ServerInfo target = event.getTarget();
|
||||
if (!plugin.isMaintenance(target)) return;
|
||||
if (plugin.hasPermission(player, "bypass") || settings.getWhitelistedPlayers().containsKey(player.getUniqueId())) return;
|
||||
public void initialServerConnect(final ServerConnectEvent event) {
|
||||
// Global maintenance check
|
||||
if (event.isCancelled() || event.getReason() != ServerConnectEvent.Reason.JOIN_PROXY) return;
|
||||
|
||||
if (settings.isJoinNotifications()) {
|
||||
final BaseComponent[] s = TextComponent.fromLegacyText(settings.getMessage("joinNotification").replace("%PLAYER%", player.getName()));
|
||||
target.getPlayers().stream().filter(p -> plugin.hasPermission(p, "joinnotification")).forEach(p -> p.sendMessage(s));
|
||||
}
|
||||
// Normal serverconnect
|
||||
if (event.getReason() != ServerConnectEvent.Reason.JOIN_PROXY && event.getReason() != ServerConnectEvent.Reason.KICK_REDIRECT
|
||||
&& event.getReason() != ServerConnectEvent.Reason.LOBBY_FALLBACK && event.getReason() != ServerConnectEvent.Reason.SERVER_DOWN_REDIRECT) {
|
||||
player.sendMessage(settings.getMessage("singleMaintenanceKick").replace("%SERVER%", target.getName()));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
final BungeeSenderInfo sender = new BungeeSenderInfo(event.getPlayer());
|
||||
if (plugin.isDebug()) {
|
||||
plugin.getLogger().info("Join permission check for " + event.getPlayer().getName()
|
||||
+ " - Permission: " + sender.hasMaintenancePermission("bypass") + ", whitelist: " + settings.isWhitelisted(sender.getUuid()));
|
||||
}
|
||||
|
||||
// If it's the initial proxy join or a kick from another server, go back to fallback server
|
||||
final ServerInfo fallback = plugin.getProxy().getServerInfo(settings.getFallbackServer());
|
||||
if (fallback == null || !fallback.canAccess(player) || plugin.isMaintenance(fallback)) {
|
||||
player.disconnect(settings.getMessage("singleMaintenanceKickComplete").replace("%NEWLINE%", "\n").replace("%SERVER%", target.getName()));
|
||||
if (!warned) {
|
||||
plugin.getLogger().warning("Could not send player to the set fallback server! Instead kicking player off the network!");
|
||||
warned = true;
|
||||
if (shouldKick(sender)) {
|
||||
final Server waitingServer = shouldConnectToWaitingServer(sender);
|
||||
if (waitingServer != null) {
|
||||
event.setTarget(((BungeeServer) waitingServer).getServer());
|
||||
sender.sendMessage(settings.getMessage("sentToWaitingServer"));
|
||||
|
||||
if (plugin.isDebug()) {
|
||||
plugin.getLogger().info("Join to waiting server for " + event.getPlayer().getName());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().disconnect(settings.getKickMessage());
|
||||
if (settings.isJoinNotifications()) {
|
||||
broadcastJoinNotification(sender.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void serverConnect(final ServerConnectEvent event) {
|
||||
// Server specific maintenance check
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
final ProxiedPlayer player = event.getPlayer();
|
||||
final boolean normalServerConnect = event.getReason() != ServerConnectEvent.Reason.JOIN_PROXY && event.getReason() != ServerConnectEvent.Reason.KICK_REDIRECT
|
||||
&& event.getReason() != ServerConnectEvent.Reason.LOBBY_FALLBACK && event.getReason() != ServerConnectEvent.Reason.SERVER_DOWN_REDIRECT;
|
||||
final ServerConnectResult connectResult = serverConnect(new BungeeSenderInfo(player), new BungeeServer(event.getTarget()), normalServerConnect);
|
||||
if (plugin.isDebug()) {
|
||||
plugin.getLogger().info("Connectresult for " + player.getName() + " to " + event.getTarget().getName() + ": " + connectResult);
|
||||
}
|
||||
|
||||
if (connectResult.isCancelled()) {
|
||||
event.setCancelled(true);
|
||||
|
||||
// Player has no server to connect to
|
||||
if (player.getServer() == null) {
|
||||
player.disconnect(settings.getKickMessage());
|
||||
}
|
||||
} else if (connectResult.getTarget() != null) {
|
||||
event.setTarget(((BungeeServer) connectResult.getTarget()).getServer());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void broadcastJoinNotification(final String name) {
|
||||
sendJoinMessage(ProxyServer.getInstance().getPlayers(), name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void broadcastJoinNotification(final String name, final Server server) {
|
||||
sendJoinMessage(((BungeeServer) server).getServer().getPlayers(), name);
|
||||
}
|
||||
|
||||
private void sendJoinMessage(final Iterable<ProxiedPlayer> players, final String name) {
|
||||
final BaseComponent[] message = TextComponent.fromLegacyText(settings.getMessage("joinNotification").replace("%PLAYER%", name));
|
||||
for (final ProxiedPlayer player : players) {
|
||||
if (plugin.hasPermission(player, "joinnotification")) {
|
||||
player.sendMessage(message);
|
||||
}
|
||||
} else {
|
||||
event.setTarget(fallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
-31
@@ -23,6 +23,7 @@ import java.util.zip.GZIPOutputStream;
|
||||
public final class MetricsLite {
|
||||
|
||||
public static final int B_STATS_VERSION = 1;
|
||||
private static final int PLUGIN_ID = 742;
|
||||
private static final String URL = "https://bStats.org/submitData/bungeecord";
|
||||
private final Plugin plugin;
|
||||
private boolean enabled;
|
||||
@@ -75,10 +76,12 @@ public final class MetricsLite {
|
||||
public JsonObject getPluginData() {
|
||||
final JsonObject data = new JsonObject();
|
||||
|
||||
final String pluginName = plugin.getDescription().getName();
|
||||
//final String pluginName = plugin.getDescription().getName();
|
||||
final String pluginName = "MaintenanceBungee"; // I cut off the suffix, not sure how bStats would like the name change
|
||||
final String pluginVersion = plugin.getDescription().getVersion();
|
||||
|
||||
data.addProperty("pluginName", pluginName);
|
||||
data.addProperty("id", PLUGIN_ID);
|
||||
data.addProperty("pluginVersion", pluginVersion);
|
||||
|
||||
final JsonArray customCharts = new JsonArray();
|
||||
@@ -92,8 +95,7 @@ public final class MetricsLite {
|
||||
}
|
||||
|
||||
private JsonObject getServerData() {
|
||||
int playerAmount = plugin.getProxy().getOnlineCount();
|
||||
playerAmount = playerAmount > 500 ? 500 : playerAmount;
|
||||
final int playerAmount = Math.min(plugin.getProxy().getOnlineCount(), 500);
|
||||
final int onlineMode = plugin.getProxy().getConfig().isOnlineMode() ? 1 : 0;
|
||||
final String bungeecordVersion = plugin.getProxy().getVersion();
|
||||
final int managedServers = plugin.getProxy().getServers().size();
|
||||
@@ -148,9 +150,9 @@ public final class MetricsLite {
|
||||
}
|
||||
|
||||
private void loadConfig() throws IOException {
|
||||
final Path configPath = plugin.getDataFolder().toPath().getParent().resolve("bStats");
|
||||
configPath.toFile().mkdirs();
|
||||
final File configFile = new File(configPath.toFile(), "config.yml");
|
||||
final File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
|
||||
bStatsFolder.mkdirs();
|
||||
final File configFile = new File(bStatsFolder, "config.yml");
|
||||
if (!configFile.exists()) {
|
||||
writeFile(configFile,
|
||||
"#bStats collects some data for plugin authors like how many servers are using their plugins.",
|
||||
@@ -158,7 +160,7 @@ public final class MetricsLite {
|
||||
"#This has nearly no effect on the server performance!",
|
||||
"#Check out https://bStats.org/ to learn more :)",
|
||||
"enabled: true",
|
||||
"serverUuid: \"" + UUID.randomUUID().toString() + "\"",
|
||||
"serverUuid: \"" + UUID.randomUUID() + "\"",
|
||||
"logFailedRequests: false",
|
||||
"logSentData: false",
|
||||
"logResponseStatusText: false");
|
||||
@@ -200,10 +202,7 @@ public final class MetricsLite {
|
||||
if (!file.exists()) {
|
||||
return null;
|
||||
}
|
||||
try (
|
||||
final FileReader fileReader = new FileReader(file);
|
||||
final BufferedReader bufferedReader = new BufferedReader(fileReader);
|
||||
) {
|
||||
try (final BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
|
||||
return bufferedReader.readLine();
|
||||
}
|
||||
}
|
||||
@@ -212,10 +211,7 @@ public final class MetricsLite {
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
try (
|
||||
final FileWriter fileWriter = new FileWriter(file);
|
||||
final BufferedWriter bufferedWriter = new BufferedWriter(fileWriter)
|
||||
) {
|
||||
try (final BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file))) {
|
||||
for (final String line : lines) {
|
||||
bufferedWriter.write(line);
|
||||
bufferedWriter.newLine();
|
||||
@@ -228,7 +224,7 @@ public final class MetricsLite {
|
||||
throw new IllegalArgumentException("Data cannot be null");
|
||||
}
|
||||
if (logSentData) {
|
||||
plugin.getLogger().info("Sending data to bStats: " + data.toString());
|
||||
plugin.getLogger().info("Sending data to bStats: " + data);
|
||||
}
|
||||
|
||||
final HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection();
|
||||
@@ -244,22 +240,19 @@ public final class MetricsLite {
|
||||
connection.setRequestProperty("User-Agent", "MC-Server/" + B_STATS_VERSION);
|
||||
|
||||
connection.setDoOutput(true);
|
||||
final DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
|
||||
outputStream.write(compressedData);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
try (final DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) {
|
||||
outputStream.write(compressedData);
|
||||
}
|
||||
|
||||
if (logResponseStatusText) {
|
||||
final InputStream inputStream = connection.getInputStream();
|
||||
final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
builder.append(line);
|
||||
try (final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
builder.append(line);
|
||||
}
|
||||
}
|
||||
bufferedReader.close();
|
||||
plugin.getLogger().info("Sent data to bStats and received response: " + builder.toString());
|
||||
plugin.getLogger().info("Sent data to bStats and received response: " + builder);
|
||||
} else {
|
||||
connection.getInputStream().close();
|
||||
}
|
||||
@@ -270,9 +263,9 @@ public final class MetricsLite {
|
||||
return null;
|
||||
}
|
||||
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
final GZIPOutputStream gzip = new GZIPOutputStream(outputStream);
|
||||
gzip.write(str.getBytes(StandardCharsets.UTF_8));
|
||||
gzip.close();
|
||||
try (final GZIPOutputStream gzip = new GZIPOutputStream(outputStream)) {
|
||||
gzip.write(str.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
|
||||
|
||||
+18
-5
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,17 +15,18 @@
|
||||
* 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.bungee.util;
|
||||
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import eu.kennytv.maintenance.core.proxy.util.ProxySenderInfo;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.Connection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class BungeeSenderInfo implements SenderInfo {
|
||||
public final class BungeeSenderInfo implements ProxySenderInfo {
|
||||
private final CommandSender sender;
|
||||
|
||||
public BungeeSenderInfo(final CommandSender sender) {
|
||||
@@ -60,4 +61,16 @@ public final class BungeeSenderInfo implements SenderInfo {
|
||||
public void sendMessage(final TextComponent textComponent) {
|
||||
sender.sendMessage(textComponent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccess(final Server server) {
|
||||
return ((BungeeServer) server).getServer().canAccess(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(final String message) {
|
||||
if (sender instanceof Connection) {
|
||||
((Connection) sender).disconnect(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,13 +15,13 @@
|
||||
* 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.bungee.util;
|
||||
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
public final class BungeeServer implements Server {
|
||||
private final ServerInfo server;
|
||||
@@ -43,7 +43,14 @@ public final class BungeeServer implements Server {
|
||||
@Override
|
||||
public void broadcast(final String message) {
|
||||
final BaseComponent[] s = TextComponent.fromLegacyText(message);
|
||||
server.getPlayers().forEach(p -> p.sendMessage(s));
|
||||
for (final ProxiedPlayer p : server.getPlayers()) {
|
||||
p.sendMessage(s);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegisteredServer() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public ServerInfo getServer() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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.bungee.util;
|
||||
|
||||
import eu.kennytv.maintenance.core.util.Task;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
name: MaintenanceBungee
|
||||
name: Maintenance
|
||||
version: ${project.version}
|
||||
main: eu.kennytv.maintenance.bungee.MaintenanceBungeeBase
|
||||
author: KennyTV
|
||||
author: kennytv
|
||||
description: Enable maintenance mode with a custom maintenance motd and icon.
|
||||
softDepends: [ServerListPlus]
|
||||
website: https://www.spigotmc.org/resources/maintenance.40699/
|
||||
@@ -4,9 +4,9 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<groupId>eu.kennytv.maintenance</groupId>
|
||||
<artifactId>maintenance-parent</artifactId>
|
||||
<version>3.0</version>
|
||||
<version>3.0.7</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>maintenance-core-proxy</artifactId>
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<groupId>eu.kennytv.maintenance</groupId>
|
||||
<artifactId>maintenance-core</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
@@ -22,8 +22,27 @@
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<version>4.0.3</version>
|
||||
<scope>compile</scope>
|
||||
<!-- Shade slf4j specifically and only in the Bungee module to prevent issues -->
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>29.0-jre</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
+109
-33
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,27 +15,40 @@
|
||||
* 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.IMaintenanceProxy;
|
||||
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.server.DummyServer;
|
||||
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.SenderInfo;
|
||||
import eu.kennytv.maintenance.core.util.ServerType;
|
||||
import eu.kennytv.maintenance.core.util.Task;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
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 java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author KennyTV
|
||||
* @author kennytv
|
||||
* @since 3.0
|
||||
*/
|
||||
public abstract class MaintenanceProxyPlugin extends MaintenancePlugin implements IMaintenanceProxy {
|
||||
@@ -46,19 +59,25 @@ public abstract class MaintenanceProxyPlugin extends MaintenancePlugin implement
|
||||
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())
|
||||
if (settingsProxy.hasMySQL()) {
|
||||
settingsProxy.setMaintenanceToSQL(maintenance);
|
||||
settingsProxy.setMaintenance(maintenance);
|
||||
settingsProxy.getConfig().set("maintenance-enabled", maintenance);
|
||||
settingsProxy.saveConfig();
|
||||
serverActions(maintenance);
|
||||
}
|
||||
super.setMaintenance(maintenance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMaintenance(final Server server) {
|
||||
return settingsProxy.isMaintenance(server);
|
||||
return settingsProxy.isMaintenance(server.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,18 +92,26 @@ public abstract class MaintenanceProxyPlugin extends MaintenancePlugin implement
|
||||
}
|
||||
|
||||
public void serverActions(final Server server, final boolean maintenance) {
|
||||
if (server instanceof DummyServer) return;
|
||||
if (maintenance) {
|
||||
final Server fallback = getServer(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!");
|
||||
} else if (fallback.getName().equals(server.getName()))
|
||||
getLogger().warning("Maintenance has been enabled on the fallback server! If a player joins on a proxied server, they will be kicked completely instead of being sent to the fallback server!");
|
||||
kickPlayers(server, fallback);
|
||||
} else
|
||||
server.broadcast(settingsProxy.getMessage("singleMaintenanceDeactivated").replace("%SERVER%", server.getName()));
|
||||
cancelSingleTask(server);
|
||||
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").replace("%SERVER%", server.getName()));
|
||||
}
|
||||
|
||||
cancelSingleTask(server);
|
||||
}
|
||||
|
||||
eventManager.callEvent(new ServerMaintenanceChangedEvent(server, maintenance));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,22 +119,38 @@ public abstract class MaintenanceProxyPlugin extends MaintenancePlugin implement
|
||||
return serverTasks.containsKey(server.getName());
|
||||
}
|
||||
|
||||
public void cancelSingleTask(final Server server) {
|
||||
final Task task = serverTasks.remove(server.getName());
|
||||
if (task != null)
|
||||
task.cancel();
|
||||
@Override
|
||||
public Set<String> getMaintenanceServers() {
|
||||
return Collections.unmodifiableSet(settingsProxy.getMaintenanceServers());
|
||||
}
|
||||
|
||||
public MaintenanceRunnableBase startSingleMaintenanceRunnable(final Server server, final int minutes, final boolean enable) {
|
||||
final MaintenanceRunnableBase runnable = new SingleMaintenanceRunnable(this, settingsProxy, minutes, enable, server);
|
||||
serverTasks.put(server.getName(), startMaintenanceRunnable(runnable));
|
||||
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 long duration, final TimeUnit unit, final boolean enable) {
|
||||
final MaintenanceRunnableBase runnable = new SingleMaintenanceRunnable(this, settingsProxy, (int) unit.toSeconds(duration), enable, server);
|
||||
serverTasks.put(server.getName(), runnable.getTask());
|
||||
return runnable;
|
||||
}
|
||||
|
||||
public MaintenanceRunnableBase scheduleSingleMaintenanceRunnable(final Server server, final long duration, final long maintenanceDuration, final TimeUnit unit) {
|
||||
final MaintenanceRunnableBase runnable = new SingleMaintenanceScheduleRunnable(this, settingsProxy,
|
||||
(int) unit.toSeconds(duration), (int) unit.toSeconds(maintenanceDuration), server);
|
||||
serverTasks.put(server.getName(), runnable.getTask());
|
||||
return runnable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMaintenanceServers() {
|
||||
@Nullable
|
||||
public List<String> getMaintenanceServersDump() {
|
||||
final List<String> list = new ArrayList<>();
|
||||
if (isMaintenance()) list.add("global");
|
||||
if (isMaintenance()) {
|
||||
list.add("global");
|
||||
}
|
||||
list.addAll(settingsProxy.getMaintenanceServers());
|
||||
return list.isEmpty() ? null : list;
|
||||
}
|
||||
@@ -117,11 +160,44 @@ public abstract class MaintenanceProxyPlugin extends MaintenancePlugin implement
|
||||
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();
|
||||
}
|
||||
|
||||
protected ProfileLookup doUUIDLookup(final String name) throws IOException {
|
||||
final URL url = new URL("https://api.ashcon.app/mojang/v2/user/" + name);
|
||||
final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public SettingsProxy getSettingsProxy() {
|
||||
return settingsProxy;
|
||||
}
|
||||
|
||||
public abstract String getServer(SenderInfo sender);
|
||||
@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();
|
||||
}
|
||||
+80
-21
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,25 +15,26 @@
|
||||
* 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 org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public final class SettingsProxy extends Settings {
|
||||
private final MaintenanceProxyPlugin plugin;
|
||||
private final MaintenanceProxyPlugin proxyPlugin;
|
||||
private Set<String> maintenanceServers;
|
||||
private String fallbackServer;
|
||||
private List<String> fallbackServers;
|
||||
private String waitingServer;
|
||||
|
||||
private String mySQLTable;
|
||||
private String serverTable;
|
||||
@@ -47,22 +48,24 @@ public final class SettingsProxy extends Settings {
|
||||
|
||||
public SettingsProxy(final MaintenanceProxyPlugin plugin) {
|
||||
super(plugin);
|
||||
this.plugin = plugin;
|
||||
this.proxyPlugin = plugin;
|
||||
}
|
||||
|
||||
private void setupMySQL() throws Exception {
|
||||
super.plugin.getLogger().info("Trying to open database connection...");
|
||||
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(section.getString("host"),
|
||||
mySQL = new MySQL(plugin.getLogger(),
|
||||
section.getString("host"),
|
||||
section.getInt("port"),
|
||||
section.getString("username"),
|
||||
section.getString("password"),
|
||||
section.getString("database"));
|
||||
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");
|
||||
@@ -71,22 +74,30 @@ public final class SettingsProxy extends Settings {
|
||||
mySQL.executeUpdate("CREATE TABLE IF NOT EXISTS " + serverTable + " (server VARCHAR(64) PRIMARY KEY)");
|
||||
maintenanceQuery = "SELECT * FROM " + mySQLTable + " WHERE setting = ?";
|
||||
serverQuery = "SELECT * FROM " + serverTable;
|
||||
super.plugin.getLogger().info("Done!");
|
||||
plugin.getLogger().info("Done!");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadExtraSettings() {
|
||||
// Open database connection if enabled and not already done
|
||||
if (!hasMySQL() && (boolean) config.getDeep("mysql.use-mysql")) {
|
||||
if (!hasMySQL() && config.getBoolean("mysql.use-mysql")) {
|
||||
try {
|
||||
setupMySQL();
|
||||
} catch (final Exception e) {
|
||||
mySQL = null;
|
||||
super.plugin.getLogger().log(Level.WARNING, "Error while trying do open database connection!", e);
|
||||
plugin.getLogger().warning("Error while trying do open database connection!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
fallbackServer = config.getString("fallback", "lobby");
|
||||
final Object fallback = config.getObject("fallback");
|
||||
fallbackServers = fallback instanceof String ? Collections.singletonList((String) fallback) : config.getStringList("fallback");
|
||||
|
||||
waitingServer = config.getString("waiting-server", "");
|
||||
if (waitingServer.isEmpty() || waitingServer.equalsIgnoreCase("none")) {
|
||||
waitingServer = null;
|
||||
}
|
||||
|
||||
if (hasMySQL()) {
|
||||
maintenance = loadMaintenance();
|
||||
maintenanceServers = loadMaintenanceServersFromSQL();
|
||||
@@ -107,24 +118,52 @@ public final class SettingsProxy extends Settings {
|
||||
if (hasMySQL() && System.currentTimeMillis() - lastMySQLCheck > millisecondsToCheck) {
|
||||
final boolean databaseValue = loadMaintenance();
|
||||
if (databaseValue != maintenance) {
|
||||
plugin.serverActions(maintenance);
|
||||
maintenance = databaseValue;
|
||||
plugin.serverActions(maintenance);
|
||||
}
|
||||
lastMySQLCheck = System.currentTimeMillis();
|
||||
}
|
||||
return maintenance;
|
||||
}
|
||||
|
||||
public boolean isMaintenance(final Server server) {
|
||||
public boolean isMaintenance(final String serverName) {
|
||||
if (hasMySQL() && System.currentTimeMillis() - lastServerCheck > millisecondsToCheck) {
|
||||
final Set<String> databaseValue = loadMaintenanceServersFromSQL();
|
||||
if (!databaseValue.equals(maintenanceServers)) {
|
||||
plugin.serverActions(server, maintenance);
|
||||
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(server.getName());
|
||||
return maintenanceServers.contains(serverName);
|
||||
}
|
||||
|
||||
public String getServerKickMessage(final String server) {
|
||||
String message = language.getString("singleMaintenanceKicks." + server);
|
||||
if (message == null) {
|
||||
message = getMessage("singleMaintenanceKick");
|
||||
}
|
||||
return plugin.replacePingVariables(message).replace("%SERVER%", server);
|
||||
}
|
||||
|
||||
// Full = being kicked from the proxy, not just a proxied server
|
||||
public String getFullServerKickMessage(final String server) {
|
||||
String message = language.getString("singleMaintenanceKicksComplete." + server);
|
||||
if (message == null) {
|
||||
message = getMessage("singleMaintenanceKickComplete");
|
||||
}
|
||||
return plugin.replacePingVariables(message).replace("%SERVER%", server);
|
||||
}
|
||||
|
||||
public boolean hasMySQL() {
|
||||
@@ -156,10 +195,12 @@ public final class SettingsProxy extends Settings {
|
||||
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;
|
||||
@@ -188,6 +229,7 @@ public final class SettingsProxy extends Settings {
|
||||
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");
|
||||
@@ -203,7 +245,24 @@ public final class SettingsProxy extends Settings {
|
||||
return maintenanceServers;
|
||||
}
|
||||
|
||||
public String getFallbackServer() {
|
||||
return fallbackServer;
|
||||
@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;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
MySQL getMySQL() {
|
||||
return mySQL;
|
||||
}
|
||||
}
|
||||
+13
-7
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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;
|
||||
@@ -25,8 +24,8 @@ 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;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class MaintenanceProxyCommand extends MaintenanceCommand {
|
||||
private final MaintenanceProxyPlugin plugin;
|
||||
@@ -45,16 +44,23 @@ public abstract class MaintenanceProxyCommand extends MaintenanceCommand {
|
||||
|
||||
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) {
|
||||
return settingsBungee.getMaintenanceServers().stream().filter(server -> server.toLowerCase().startsWith(s)).collect(Collectors.toList());
|
||||
final List<String> list = new ArrayList<>();
|
||||
for (final String server : settingsBungee.getMaintenanceServers()) {
|
||||
if (server.toLowerCase().startsWith(s)) {
|
||||
list.add(server);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Server checkSingleTimerArgs(final SenderInfo sender, final String[] args) {
|
||||
final Server server = plugin.getServer(args[1]);
|
||||
public Server checkSingleTimerServerArg(final SenderInfo sender, final String serverName) {
|
||||
final Server server = plugin.getServer(serverName);
|
||||
if (server == null) {
|
||||
sender.sendMessage(settings.getMessage("serverNotFound"));
|
||||
return null;
|
||||
|
||||
+4
-5
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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;
|
||||
@@ -25,8 +24,8 @@ 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, final String helpMessage) {
|
||||
super(plugin, permission, helpMessage);
|
||||
protected ProxyCommandInfo(final MaintenanceProxyPlugin plugin, final String permission) {
|
||||
super(plugin, permission);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
+4
-5
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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;
|
||||
@@ -29,7 +28,7 @@ import java.util.List;
|
||||
public final class AbortSingleTimerCommand extends ProxyCommandInfo {
|
||||
|
||||
public AbortSingleTimerCommand(final MaintenanceProxyPlugin plugin) {
|
||||
super(plugin, null, "§6/maintenance aborttimer [server] §7(If running, the current timer will be aborted)");
|
||||
super(plugin, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,7 +62,7 @@ public final class AbortSingleTimerCommand extends ProxyCommandInfo {
|
||||
plugin.cancelSingleTask(server);
|
||||
sender.sendMessage(getMessage("singleTimerCancelled"));
|
||||
} else
|
||||
sender.sendMessage(helpMessage);
|
||||
sender.sendMessage(getHelpMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+14
-11
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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;
|
||||
@@ -26,11 +25,12 @@ import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class SingleEndtimerCommand extends ProxyCommandInfo {
|
||||
|
||||
public SingleEndtimerCommand(final MaintenanceProxyPlugin plugin) {
|
||||
super(plugin, null, "§6/maintenance endtimer [server] <minutes> §7(After the given time in minutes, maintenance mode will be disabled)");
|
||||
super(plugin, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,32 +43,35 @@ public final class SingleEndtimerCommand extends ProxyCommandInfo {
|
||||
if (args.length == 2) {
|
||||
if (checkPermission(sender, "timer")) return;
|
||||
if (plugin.getCommandManager().checkTimerArgs(sender, args[1])) {
|
||||
sender.sendMessage(helpMessage);
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
if (!plugin.isMaintenance()) {
|
||||
sender.sendMessage(getMessage("alreadyDisabled"));
|
||||
return;
|
||||
}
|
||||
plugin.startMaintenanceRunnable(Integer.parseInt(args[1]), false);
|
||||
|
||||
plugin.startMaintenanceRunnable(Integer.parseInt(args[1]), TimeUnit.MINUTES, false);
|
||||
sender.sendMessage(getMessage("endtimerStarted").replace("%TIME%", plugin.getRunnable().getTime()));
|
||||
} else if (args.length == 3) {
|
||||
if (checkPermission(sender, "singleserver.timer")) return;
|
||||
if (plugin.getCommandManager().checkTimerArgs(sender, args[2], false)) {
|
||||
sender.sendMessage(helpMessage);
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
final Server server = plugin.getCommandManager().checkSingleTimerArgs(sender, args);
|
||||
final Server server = plugin.getCommandManager().checkSingleTimerServerArg(sender, args[1]);
|
||||
if (server == null) return;
|
||||
if (!plugin.isMaintenance(server)) {
|
||||
sender.sendMessage(getMessage("singleServerAlreadyDisabled").replace("%SERVER%", server.getName()));
|
||||
return;
|
||||
}
|
||||
final MaintenanceRunnableBase runnable = plugin.startSingleMaintenanceRunnable(server, Integer.parseInt(args[2]), false);
|
||||
|
||||
final MaintenanceRunnableBase runnable = plugin.startSingleMaintenanceRunnable(server, Integer.parseInt(args[2]), TimeUnit.MINUTES, false);
|
||||
sender.sendMessage(getMessage("endtimerStarted").replace("%TIME%", runnable.getTime()));
|
||||
} else
|
||||
sender.sendMessage(helpMessage);
|
||||
} else {
|
||||
sender.sendMessage(getHelpMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
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;
|
||||
if (plugin.getCommandManager().checkTimerArgs(sender, args[1])
|
||||
|| plugin.getCommandManager().checkTimerArgs(sender, args[2], false)) {
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
if (plugin.isMaintenance()) {
|
||||
sender.sendMessage(getMessage("alreadyEnabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.scheduleMaintenanceRunnable(Integer.parseInt(args[1]), Integer.parseInt(args[2]), TimeUnit.MINUTES);
|
||||
sender.sendMessage(getMessage("starttimerStarted").replace("%TIME%", plugin.getRunnable().getTime()));
|
||||
} else if (args.length == 4) {
|
||||
if (checkPermission(sender, "singleserver.timer")) return;
|
||||
if (plugin.getCommandManager().checkTimerArgs(sender, args[2], false)
|
||||
|| plugin.getCommandManager().checkTimerArgs(sender, args[3], false)) {
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
final Server server = plugin.getCommandManager().checkSingleTimerServerArg(sender, args[1]);
|
||||
if (server == null) return;
|
||||
if (plugin.isMaintenance(server)) {
|
||||
sender.sendMessage(getMessage("singleServerAlreadyEnabled").replace("%SERVER%", server.getName()));
|
||||
return;
|
||||
}
|
||||
|
||||
final MaintenanceRunnableBase runnable = plugin.scheduleSingleMaintenanceRunnable(server, Integer.parseInt(args[2]), Integer.parseInt(args[3]), TimeUnit.MINUTES);
|
||||
sender.sendMessage(getMessage("starttimerStarted").replace("%TIME%", runnable.getTime()));
|
||||
} else {
|
||||
sender.sendMessage(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();
|
||||
}
|
||||
}
|
||||
+12
-11
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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;
|
||||
@@ -26,11 +25,12 @@ import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class SingleStarttimerCommand extends ProxyCommandInfo {
|
||||
|
||||
public SingleStarttimerCommand(final MaintenanceProxyPlugin plugin) {
|
||||
super(plugin, null, "§6/maintenance starttimer [server] <minutes> §7(After the given time in minutes, maintenance mode will be enabled)");
|
||||
super(plugin, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,7 +43,7 @@ public final class SingleStarttimerCommand extends ProxyCommandInfo {
|
||||
if (args.length == 2) {
|
||||
if (checkPermission(sender, "timer")) return;
|
||||
if (plugin.getCommandManager().checkTimerArgs(sender, args[1])) {
|
||||
sender.sendMessage(helpMessage);
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
if (plugin.isMaintenance()) {
|
||||
@@ -51,26 +51,27 @@ public final class SingleStarttimerCommand extends ProxyCommandInfo {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.startMaintenanceRunnable(Integer.parseInt(args[1]), true);
|
||||
plugin.startMaintenanceRunnable(Integer.parseInt(args[1]), TimeUnit.MINUTES, true);
|
||||
sender.sendMessage(getMessage("starttimerStarted").replace("%TIME%", plugin.getRunnable().getTime()));
|
||||
} else if (args.length == 3) {
|
||||
if (checkPermission(sender, "singleserver.timer")) return;
|
||||
if (plugin.getCommandManager().checkTimerArgs(sender, args[2], false)) {
|
||||
sender.sendMessage(helpMessage);
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
final Server server = plugin.getCommandManager().checkSingleTimerArgs(sender, args);
|
||||
final Server server = plugin.getCommandManager().checkSingleTimerServerArg(sender, args[1]);
|
||||
if (server == null) return;
|
||||
if (plugin.isMaintenance(server)) {
|
||||
sender.sendMessage(getMessage("singleServerAlreadyEnabled").replace("%SERVER%", server.getName()));
|
||||
return;
|
||||
}
|
||||
|
||||
final MaintenanceRunnableBase runnable = plugin.startSingleMaintenanceRunnable(server, Integer.parseInt(args[2]), true);
|
||||
final MaintenanceRunnableBase runnable = plugin.startSingleMaintenanceRunnable(server, Integer.parseInt(args[2]), TimeUnit.MINUTES, true);
|
||||
sender.sendMessage(getMessage("starttimerStarted").replace("%TIME%", runnable.getTime()));
|
||||
} else
|
||||
sender.sendMessage(helpMessage);
|
||||
} else {
|
||||
sender.sendMessage(getHelpMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+10
-8
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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;
|
||||
@@ -30,7 +29,7 @@ import java.util.List;
|
||||
public final class SingleToggleCommand extends ProxyCommandInfo {
|
||||
|
||||
public SingleToggleCommand(final MaintenanceProxyPlugin plugin) {
|
||||
super(plugin, null, "§6/maintenance <on/off> [server] §7(Enables/disables maintenance mode)");
|
||||
super(plugin, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,12 +66,15 @@ public final class SingleToggleCommand extends ProxyCommandInfo {
|
||||
}
|
||||
|
||||
if (plugin.setMaintenanceToServer(server, maintenance)) {
|
||||
if (!sender.isPlayer() || !plugin.getServer(sender).equals(server.getName()))
|
||||
if (!sender.isPlayer() || !server.getName().equals(plugin.getServerNameOf(sender))) {
|
||||
sender.sendMessage(getMessage(maintenance ? "singleMaintenanceActivated" : "singleMaintenanceDeactivated").replace("%SERVER%", server.getName()));
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(getMessage(maintenance ? "singleServerAlreadyEnabled" : "singleServerAlreadyDisabled").replace("%SERVER%", server.getName()));
|
||||
} else
|
||||
sender.sendMessage(helpMessage);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(getHelpMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+9
-7
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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;
|
||||
@@ -25,16 +24,19 @@ import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
public final class StatusCommand extends ProxyCommandInfo {
|
||||
|
||||
public StatusCommand(final MaintenanceProxyPlugin plugin) {
|
||||
super(plugin, "singleserver.status", "§6/maintenance status §7(Lists all proxied servers, that are currently under maintenance)");
|
||||
super(plugin, "singleserver.status");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (getSettings().getMaintenanceServers().isEmpty()) {
|
||||
sender.sendMessage(getMessage("singleServerMaintenanceListEmpty"));
|
||||
} else {
|
||||
sender.sendMessage(getMessage("singleServerMaintenanceList"));
|
||||
getSettings().getMaintenanceServers().forEach(server -> sender.sendMessage("§8- §b" + server));
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(getMessage("singleServerMaintenanceList"));
|
||||
for (final String server : getSettings().getMaintenanceServers()) {
|
||||
sender.sendMessage("§8- §b" + server);
|
||||
}
|
||||
}
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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.sendMessage(settings.getMessage("forceWaitingServer"));
|
||||
return DENIED;
|
||||
}
|
||||
|
||||
sender.sendMessage(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.sendMessage(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);
|
||||
}
|
||||
+54
-10
@@ -1,30 +1,70 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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;
|
||||
|
||||
// Excuse me and everything to do with the MySQL stuff, I have little to no idea of how to use databases
|
||||
public MySQL(final String hostname, final int port, final String username, final String password, final String database) {
|
||||
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);
|
||||
hikariConfig.addDataSourceProperty("url", "jdbc:mysql://" + hostname + ":" + port + "/" + database);
|
||||
hikariConfig.setJdbcUrl("jdbc:mysql://" + hostname + ":" + port + "/" + database);
|
||||
hikariConfig.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
|
||||
|
||||
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)) {
|
||||
@@ -37,7 +77,7 @@ public final class MySQL {
|
||||
callback.accept(preparedStatement.executeUpdate());
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
System.out.println("Error while executing update method: " + query);
|
||||
logger.log(Level.SEVERE, "Error while executing update method: " + query);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -51,12 +91,12 @@ public final class MySQL {
|
||||
current++;
|
||||
}
|
||||
|
||||
final ResultSet resultSet = preparedStatement.executeQuery();
|
||||
callback.accept(resultSet);
|
||||
resultSet.close();
|
||||
try (final ResultSet resultSet = preparedStatement.executeQuery()) {
|
||||
callback.accept(resultSet);
|
||||
}
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
System.out.println("Error while executing query method: " + query);
|
||||
logger.log(Level.SEVERE, "Error while executing query method: " + query);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -65,4 +105,8 @@ public final class MySQL {
|
||||
executeUpdate(query, res -> {
|
||||
}, objects);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
hikariDataSource.close();
|
||||
}
|
||||
}
|
||||
+13
-9
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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.IMaintenanceProxy;
|
||||
@@ -24,26 +23,31 @@ import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.core.runnable.MaintenanceRunnableBase;
|
||||
|
||||
public final class SingleMaintenanceRunnable extends MaintenanceRunnableBase {
|
||||
private final Server server;
|
||||
public class SingleMaintenanceRunnable extends MaintenanceRunnableBase {
|
||||
protected final Server server;
|
||||
|
||||
public SingleMaintenanceRunnable(final MaintenancePlugin plugin, final Settings settings, final int minutes, final boolean enable, final Server server) {
|
||||
super(plugin, settings, minutes, enable);
|
||||
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 String message) {
|
||||
server.broadcast(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finish() {
|
||||
((IMaintenanceProxy) plugin).setMaintenanceToServer(server, enable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String startMessageKey() {
|
||||
protected String getStartMessage() {
|
||||
return settings.getMessage("singleStarttimerBroadcast").replace("%TIME%", getTime()).replace("%SERVER%", server.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String endMessageKey() {
|
||||
protected String getEndMessage() {
|
||||
return settings.getMessage("singleEndtimerBroadcast").replace("%TIME%", getTime()).replace("%SERVER%", server.getName());
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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 java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class SingleMaintenanceScheduleRunnable extends SingleMaintenanceRunnable {
|
||||
private final int maintenanceDuration;
|
||||
|
||||
public SingleMaintenanceScheduleRunnable(final MaintenancePlugin plugin, final Settings settings, final int seconds, final int maintenanceDuration, final Server server) {
|
||||
super(plugin, settings, seconds, true, server);
|
||||
this.maintenanceDuration = maintenanceDuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finish() {
|
||||
super.finish();
|
||||
((MaintenanceProxyPlugin) plugin).startSingleMaintenanceRunnable(server, maintenanceDuration, TimeUnit.SECONDS, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getStartMessage() {
|
||||
return settings.getMessage("singleScheduletimerBroadcast").replace("%SERVER%", server.getName())
|
||||
.replace("%TIME%", getTime()).replace("%DURATION%", plugin.getFormattedTime(maintenanceDuration));
|
||||
}
|
||||
}
|
||||
+8
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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;
|
||||
@@ -38,6 +37,11 @@ public final class DummyServer implements Server {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcast(String s) {
|
||||
public void broadcast(final String s) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegisteredServer() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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;
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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 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 String message) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final String permission) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(final String message) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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;
|
||||
|
||||
public interface ProxySenderInfo extends SenderInfo {
|
||||
|
||||
boolean canAccess(Server server);
|
||||
|
||||
void disconnect(String message);
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,9 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<groupId>eu.kennytv.maintenance</groupId>
|
||||
<artifactId>maintenance-parent</artifactId>
|
||||
<version>3.0</version>
|
||||
<version>3.0.7</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>maintenance-core</artifactId>
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<groupId>eu.kennytv.maintenance</groupId>
|
||||
<artifactId>maintenance-api</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
@@ -23,7 +23,7 @@
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>1.23</version>
|
||||
<scope>compile</scope>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.minecrell</groupId>
|
||||
@@ -34,7 +34,7 @@
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>21.0</version>
|
||||
<version>29.0-jre</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
+210
-54
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,24 +15,40 @@
|
||||
* 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.base.Preconditions;
|
||||
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.IMaintenance;
|
||||
import eu.kennytv.maintenance.api.event.MaintenanceChangedEvent;
|
||||
import eu.kennytv.maintenance.api.event.manager.IEventManager;
|
||||
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.event.EventManager;
|
||||
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 org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
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;
|
||||
@@ -40,10 +56,13 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public abstract class MaintenancePlugin implements IMaintenance {
|
||||
public static final Gson GSON = new GsonBuilder().create();
|
||||
protected final EventManager eventManager;
|
||||
protected final Version version;
|
||||
protected Settings settings;
|
||||
protected ServerListPlusHook serverListPlusHook;
|
||||
@@ -52,12 +71,16 @@ public abstract class MaintenancePlugin implements IMaintenance {
|
||||
private final String prefix;
|
||||
private final ServerType serverType;
|
||||
private Version newestVersion;
|
||||
private Task task;
|
||||
private boolean debug;
|
||||
|
||||
protected MaintenancePlugin(final String version, final ServerType serverType) {
|
||||
this.version = new Version(version);
|
||||
this.serverType = serverType;
|
||||
this.prefix = "§8[§eMaintenance" + serverType + "§8] ";
|
||||
this.eventManager = new EventManager();
|
||||
}
|
||||
|
||||
public void disable() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,50 +89,137 @@ public abstract class MaintenancePlugin implements IMaintenance {
|
||||
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().severe("Error while executing extra maintenance " + (maintenance ? "enable" : "disable") + " command: " + command);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void serverActions(final boolean maintenance) {
|
||||
if (isTaskRunning())
|
||||
if (isTaskRunning()) {
|
||||
cancelTask();
|
||||
if (serverListPlusHook != null)
|
||||
}
|
||||
if (serverListPlusHook != null && settings.isEnablePingMessages()) {
|
||||
serverListPlusHook.setEnabled(!maintenance);
|
||||
}
|
||||
|
||||
if (maintenance) {
|
||||
kickPlayers();
|
||||
broadcast(settings.getMessage("maintenanceActivated"));
|
||||
} else
|
||||
if (settings.isKickOnlinePlayers()) {
|
||||
kickPlayers();
|
||||
}
|
||||
} else {
|
||||
broadcast(settings.getMessage("maintenanceDeactivated"));
|
||||
}
|
||||
|
||||
eventManager.callEvent(new MaintenanceChangedEvent(maintenance));
|
||||
}
|
||||
|
||||
public String formatedTimer() {
|
||||
if (!isTaskRunning()) return "-";
|
||||
public String replacePingVariables(String s) {
|
||||
if (s.contains("%TIMER%")) {
|
||||
s = s.replace("%TIMER%", getTimerMessage());
|
||||
}
|
||||
if (s.contains("%ONLINE%")) {
|
||||
s = s.replace("%ONLINE%", Integer.toString(getOnlinePlayers()));
|
||||
}
|
||||
if (s.contains("%MAX%")) {
|
||||
s = s.replace("%MAX%", Integer.toString(getMaxPlayers()));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public String getTimerMessage() {
|
||||
if (!isTaskRunning()) return settings.getMessage("motdTimerNotRunning", "-");
|
||||
final int preHours = runnable.getSecondsLeft() / 60;
|
||||
final int minutes = preHours % 60;
|
||||
final int seconds = runnable.getSecondsLeft() % 60;
|
||||
return String.format("%02d:%02d:%02d", preHours / 60, minutes, seconds);
|
||||
return settings.getMessage("motdTimer", "%HOURS%:%MINUTES%:%SECONDS%")
|
||||
.replace("%HOURS%", String.format("%02d", preHours / 60))
|
||||
.replace("%MINUTES%", String.format("%02d", minutes))
|
||||
.replace("%SECONDS%", String.format("%02d", seconds));
|
||||
}
|
||||
|
||||
public void startMaintenanceRunnable(final int minutes, final boolean enable) {
|
||||
runnable = new MaintenanceRunnable(this, settings, minutes, enable);
|
||||
task = startMaintenanceRunnable(runnable);
|
||||
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.getMessage(time == 1 ? timeUnit : timeUnit + "s"));
|
||||
}
|
||||
|
||||
public void startMaintenanceRunnable(final long duration, final TimeUnit unit, final boolean enable) {
|
||||
runnable = new MaintenanceRunnable(this, settings, (int) unit.toSeconds(duration), 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 long duration, final int maintenanceDuration, final TimeUnit unit) {
|
||||
runnable = new MaintenanceScheduleRunnable(this, settings, (int) unit.toSeconds(duration), (int) unit.toSeconds(maintenanceDuration));
|
||||
}
|
||||
|
||||
public boolean updateAvailable() {
|
||||
checkNewestVersion();
|
||||
return version.compareTo(newestVersion) == -1;
|
||||
try {
|
||||
checkNewestVersion();
|
||||
return version.compareTo(newestVersion) == -1;
|
||||
} 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(settings.getSavedEndtimer() - current, TimeUnit.MILLISECONDS, false);
|
||||
getLogger().info("The timer has been continued - maintenance will be disabled in: " + getTimerMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected void sendEnableMessage() {
|
||||
getLogger().info("Plugin by KennyTV");
|
||||
if (!settings.hasUpdateChecks()) return;
|
||||
async(() -> {
|
||||
checkNewestVersion();
|
||||
try {
|
||||
checkNewestVersion();
|
||||
} catch (final Exception e) {
|
||||
getLogger().warning("An error occured during update checking!");
|
||||
return;
|
||||
}
|
||||
|
||||
final int compare = version.compareTo(newestVersion);
|
||||
if (compare == -1) {
|
||||
getLogger().info("§cNewest version available: §aVersion " + newestVersion + "§c, you're on §a" + version);
|
||||
} else if (compare == 1) {
|
||||
if (version.getTag().equalsIgnoreCase("snapshot")) {
|
||||
getLogger().info("§cYou're running a development version, please report bugs on the Discord server (https://kennytv.eu/discord) or the GitHub issue tracker (https://kennytv.eu/maintenance/issues)");
|
||||
getLogger().info("§cYou'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("§cYou're running a version, that doesn't exist! §cN§ai§dc§ee§5!");
|
||||
}
|
||||
@@ -118,8 +228,11 @@ public abstract class MaintenancePlugin implements IMaintenance {
|
||||
}
|
||||
|
||||
public boolean installUpdate() {
|
||||
// Ore sad :(
|
||||
Preconditions.checkArgument(serverType != ServerType.SPONGE);
|
||||
try {
|
||||
final URLConnection conn = new URL("https://github.com/KennyTV/Maintenance/releases/download/" + newestVersion + "/Maintenance.jar").openConnection();
|
||||
final String fileSuffix = serverType == ServerType.VELOCITY ? "Velocity" : "";
|
||||
final URLConnection conn = new URL("https://github.com/kennytv/Maintenance/releases/download/" + newestVersion + "/Maintenance" + fileSuffix + ".jar").openConnection();
|
||||
writeFile(new BufferedInputStream(conn.getInputStream()), new BufferedOutputStream(new FileOutputStream(getPluginFolder() + "Maintenance.tmp")));
|
||||
final File file = new File(getPluginFolder() + "Maintenance.tmp");
|
||||
final long newlength = file.length();
|
||||
@@ -147,54 +260,48 @@ public abstract class MaintenancePlugin implements IMaintenance {
|
||||
os.close();
|
||||
}
|
||||
|
||||
private void checkNewestVersion() {
|
||||
try {
|
||||
final HttpURLConnection c = (HttpURLConnection) new URL("https://api.spigotmc.org/legacy/update.php?resource=40699").openConnection();
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(c.getInputStream()));
|
||||
private void checkNewestVersion() throws Exception {
|
||||
final HttpURLConnection c = (HttpURLConnection) new URL("https://api.spigotmc.org/legacy/update.php?resource=40699").openConnection();
|
||||
try (final BufferedReader reader = new BufferedReader(new InputStreamReader(c.getInputStream()))) {
|
||||
final String newVersionString = reader.readLine();
|
||||
reader.close();
|
||||
final Version newVersion = new Version(newVersionString);
|
||||
if (!newVersion.equals(version))
|
||||
if (!newVersion.equals(version)) {
|
||||
newestVersion = newVersion;
|
||||
} catch (final Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String pasteDump() {
|
||||
final MaintenanceDump dump = new MaintenanceDump(this, settings);
|
||||
try {
|
||||
final HttpURLConnection connection = (HttpURLConnection) new URL("https://hasteb.in/documents").openConnection();
|
||||
final HttpURLConnection connection = (HttpURLConnection) new URL("https://hastebin.com/documents").openConnection();
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("User-Agent", "Maintenance/" + getVersion());
|
||||
connection.setRequestProperty("Content-Type", "text/plain");
|
||||
|
||||
final GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
final byte[] bytes = gsonBuilder.setPrettyPrinting().create().toJson(dump).getBytes(StandardCharsets.UTF_8);
|
||||
connection.setRequestProperty("Content-Length", Integer.toString(bytes.length));
|
||||
|
||||
final OutputStream out = connection.getOutputStream();
|
||||
out.write(bytes);
|
||||
out.close();
|
||||
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, hasteb.in down?");
|
||||
getLogger().warning("Could not paste dump, hastebin.com down?");
|
||||
return null;
|
||||
}
|
||||
|
||||
final InputStream in = connection.getInputStream();
|
||||
final String output = CharStreams.toString(new InputStreamReader(in));
|
||||
in.close();
|
||||
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;
|
||||
}
|
||||
|
||||
final JsonObject jsonOutput = gsonBuilder.create().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();
|
||||
}
|
||||
|
||||
return jsonOutput.get("key").getAsString();
|
||||
} catch (final IOException e) {
|
||||
getLogger().log(Level.WARNING, "Could not paste dump :(", e);
|
||||
getLogger().log(Level.WARNING, "Could not paste dump :(");
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -209,17 +316,21 @@ public abstract class MaintenancePlugin implements IMaintenance {
|
||||
try {
|
||||
loadIcon(file);
|
||||
} catch (final Exception e) {
|
||||
getLogger().log(Level.WARNING, "Could not load the 'maintenance-icon.png' file!", e);
|
||||
getLogger().log(Level.WARNING, "Could not load the 'maintenance-icon.png' file!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void cancelTask() {
|
||||
task.cancel();
|
||||
if (settings.isSaveEndtimerOnStop() && !runnable.shouldEnable()) {
|
||||
settings.setSavedEndtimer(0);
|
||||
}
|
||||
|
||||
runnable.getTask().cancel();
|
||||
runnable = null;
|
||||
task = null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public UUID checkUUID(final SenderInfo sender, final String s) {
|
||||
final UUID uuid;
|
||||
try {
|
||||
@@ -231,6 +342,12 @@ public abstract class MaintenancePlugin implements IMaintenance {
|
||||
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 string.matches("[0-9]+");
|
||||
}
|
||||
@@ -242,7 +359,7 @@ public abstract class MaintenancePlugin implements IMaintenance {
|
||||
|
||||
@Override
|
||||
public boolean isTaskRunning() {
|
||||
return task != null && runnable != null;
|
||||
return runnable != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -250,15 +367,35 @@ public abstract class MaintenancePlugin implements IMaintenance {
|
||||
return settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEventManager getEventManager() {
|
||||
return eventManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return version.toString();
|
||||
}
|
||||
|
||||
public List<String> getMaintenanceServers() {
|
||||
@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;
|
||||
}
|
||||
@@ -267,6 +404,10 @@ public abstract class MaintenancePlugin implements IMaintenance {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #isTaskRunning()
|
||||
*/
|
||||
@Nullable
|
||||
public MaintenanceRunnable getRunnable() {
|
||||
return runnable;
|
||||
}
|
||||
@@ -285,12 +426,25 @@ public abstract class MaintenancePlugin implements IMaintenance {
|
||||
|
||||
public abstract void async(Runnable runnable);
|
||||
|
||||
protected abstract void executeConsoleCommand(String command);
|
||||
|
||||
public abstract void broadcast(String message);
|
||||
|
||||
public abstract void sendUpdateNotification(SenderInfo sender);
|
||||
|
||||
public abstract Task startMaintenanceRunnable(Runnable runnable);
|
||||
|
||||
/**
|
||||
* Returns offline sender info of a player.
|
||||
* This method may do a web lookup.
|
||||
*
|
||||
* @param name name of the player
|
||||
* @return sender info if found, else null
|
||||
*/
|
||||
@Nullable
|
||||
public abstract SenderInfo getOfflinePlayer(String name);
|
||||
|
||||
@Nullable
|
||||
public abstract SenderInfo getOfflinePlayer(UUID uuid);
|
||||
|
||||
public abstract File getDataFolder();
|
||||
@@ -307,7 +461,9 @@ public abstract class MaintenancePlugin implements IMaintenance {
|
||||
|
||||
protected abstract void kickPlayers();
|
||||
|
||||
protected abstract Task startMaintenanceRunnable(Runnable runnable);
|
||||
|
||||
protected abstract File getPluginFile();
|
||||
|
||||
protected abstract int getOnlinePlayers();
|
||||
|
||||
protected abstract int getMaxPlayers();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,21 +15,29 @@
|
||||
* 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.ISettings;
|
||||
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 org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Settings implements ISettings {
|
||||
private static final int CURRENT_CONFIG_VERSION = 5;
|
||||
private static final Random RANDOM = new Random();
|
||||
protected final MaintenancePlugin plugin;
|
||||
private final Map<UUID, String> whitelistedPlayers = new HashMap<>();
|
||||
@@ -37,14 +45,21 @@ public class Settings implements ISettings {
|
||||
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 playerCountMessage;
|
||||
private String playerCountHoverMessage;
|
||||
private String languageName;
|
||||
private boolean enablePingMessages;
|
||||
private boolean customPlayerCountMessage;
|
||||
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;
|
||||
@@ -53,8 +68,10 @@ public class Settings implements ISettings {
|
||||
public Settings(final MaintenancePlugin plugin, final String... unsupportedFields) {
|
||||
this.plugin = plugin;
|
||||
this.unsupportedFields = unsupportedFields;
|
||||
if (!plugin.getDataFolder().exists())
|
||||
if (!plugin.getDataFolder().exists()) {
|
||||
updatePluginDirectory();
|
||||
plugin.getDataFolder().mkdirs();
|
||||
}
|
||||
|
||||
createFile("config.yml");
|
||||
createFile("WhitelistedPlayers.yml");
|
||||
@@ -84,10 +101,21 @@ public class Settings implements ISettings {
|
||||
throw new RuntimeException("Unable to load Maintenance language file!", e);
|
||||
}
|
||||
|
||||
// Directly save colored messages
|
||||
for (final Map.Entry<String, Object> entry : language.getValues().entrySet()) {
|
||||
if (!(entry.getValue() instanceof String)) continue;
|
||||
entry.setValue(getColoredString((String) entry.getValue()));
|
||||
updateLanguageFile();
|
||||
|
||||
// Directly cache colored messages - this should not be saved!
|
||||
transformColoredMessages(language.getValues());
|
||||
|
||||
plugin.getEventManager().callEvent(new MaintenanceReloadedEvent());
|
||||
}
|
||||
|
||||
private void transformColoredMessages(final Map<String, Object> map) {
|
||||
for (final Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
if (entry.getValue() instanceof Map) {
|
||||
transformColoredMessages((Map<String, Object>) entry.getValue());
|
||||
} else if (entry.getValue() instanceof String) {
|
||||
entry.setValue(getColoredString(replaceNewlineVar((String) entry.getValue())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,10 +127,15 @@ public class Settings implements ISettings {
|
||||
}
|
||||
}
|
||||
|
||||
protected void createFile(final String name) {
|
||||
// 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(name)) {
|
||||
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);
|
||||
@@ -119,17 +152,19 @@ public class Settings implements ISettings {
|
||||
}
|
||||
|
||||
private void createLanguageFile() {
|
||||
final File file = new File(plugin.getDataFolder(), "language-" + languageName + ".yml");
|
||||
if (!file.exists()) {
|
||||
try (final InputStream in = plugin.getResource("language-" + languageName + ".yml")) {
|
||||
Files.copy(in, file.toPath());
|
||||
} catch (final IOException e) {
|
||||
plugin.getLogger().warning("Unable to provide language " + languageName);
|
||||
if (!languageName.equals("en")) {
|
||||
plugin.getLogger().warning("Falling back to default language: en");
|
||||
languageName = "en";
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,121 +172,130 @@ public class Settings implements ISettings {
|
||||
private void loadSettings() {
|
||||
updateConfig();
|
||||
|
||||
enablePingMessages = config.getBoolean("enable-pingmessages", true);
|
||||
pingMessages = config.getStringList("pingmessages");
|
||||
if (config.getBoolean("enable-timerspecific-messages")) {
|
||||
timerSpecificPingMessages = config.getStringList("timerspecific-pingmessages");
|
||||
}
|
||||
maintenance = config.getBoolean("maintenance-enabled");
|
||||
commandsOnMaintenanceEnable = config.getStringList("commands-on-maintenance-enable");
|
||||
commandsOnMaintenanceDisable = config.getStringList("commands-on-maintenance-disable");
|
||||
customPlayerCountMessage = config.getBoolean("enable-playercountmessage");
|
||||
customMaintenanceIcon = config.getBoolean("custom-maintenance-icon");
|
||||
joinNotifications = config.getBoolean("send-join-notification");
|
||||
broadcastIntervals = new HashSet<>(config.getIntList("timer-broadcast-for-seconds"));
|
||||
if (plugin.getServerType() != ServerType.SPONGE)
|
||||
if (plugin.getServerType() != ServerType.SPONGE) {
|
||||
playerCountMessage = getColoredString(getConfigString("playercountmessage"));
|
||||
playerCountHoverMessage = getColoredString(getConfigString("playercounthovermessage"));
|
||||
}
|
||||
playerCountHoverMessage = replaceNewlineVar(getColoredString(getConfigString("playercounthovermessage")));
|
||||
languageName = getConfigString("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();
|
||||
whitelist.getValues().forEach((key, value) -> {
|
||||
for (final Map.Entry<String, Object> entry : whitelist.getValues().entrySet()) {
|
||||
try {
|
||||
whitelistedPlayers.put(UUID.fromString(key), (String) value);
|
||||
whitelistedPlayers.put(UUID.fromString(entry.getKey()), (String) entry.getValue());
|
||||
} catch (final Exception e) {
|
||||
plugin.getLogger().warning("invalid WhitelistedPlayers entry: " + key);
|
||||
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
|
||||
// Don't worry, this is only checked if no plugin folder is found
|
||||
String oldDirName = "Maintenance" + plugin.getServerType();
|
||||
if (plugin.getServerType() == ServerType.SPONGE || plugin.getServerType() == ServerType.VELOCITY) {
|
||||
oldDirName = oldDirName.toLowerCase();
|
||||
}
|
||||
|
||||
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().severe("Error while copying " + oldDirName + " to new " + plugin.getDataFolder().getName() + " directory!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateConfig() {
|
||||
boolean changed = false;
|
||||
|
||||
// 3.0 - update config format from 2.5
|
||||
if (migrateConfig(new File(plugin.getDataFolder(), "bungee-config.yml"))
|
||||
|| migrateConfig(new File(plugin.getDataFolder(), "spigot-config.yml"))) {
|
||||
// Also rename old language file
|
||||
final File file = new File(plugin.getDataFolder(), "language-" + languageName + ".yml");
|
||||
if (file.exists()) {
|
||||
if (file.renameTo(new File(plugin.getDataFolder(), "language-" + languageName + ".old")))
|
||||
plugin.getLogger().info("Renamed old language file!");
|
||||
else
|
||||
plugin.getLogger().warning("Could not rename old language file! Please rename/delete it yourself as soon as possible!");
|
||||
// Update config to latest version (config version included since 3.0.1)
|
||||
if (config.getInt("config-version") != CURRENT_CONFIG_VERSION) {
|
||||
plugin.getLogger().info("Updating config to latest version...");
|
||||
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.getValues(), tempConfig.getComments());
|
||||
config.set("config-version", CURRENT_CONFIG_VERSION);
|
||||
|
||||
file.delete();
|
||||
tempConfig.clear();
|
||||
|
||||
changed = true;
|
||||
}
|
||||
// 3.0 - move SpigotServer.yml fields to config
|
||||
if (plugin.getServerType() == ServerType.BUNGEE && migrateSpigotServersFile()) {
|
||||
changed = true;
|
||||
}
|
||||
// 3.0 - move maintenace-icon from server to plugin directory
|
||||
final File icon = new File("maintenance-icon.png");
|
||||
if (icon.exists()) {
|
||||
if (icon.renameTo(new File(plugin.getDataFolder(), "maintenance-icon.png")))
|
||||
plugin.getLogger().info("Moved maintenance-icon from server directory to the plugin's directory!");
|
||||
else
|
||||
plugin.getLogger().warning("Could not move maintenance-icon from server directory to the plugin's directory! Please do so yourself!");
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
saveConfig();
|
||||
plugin.getLogger().info("Done! Updated all configs to the new format!");
|
||||
plugin.getLogger().info("Done! Updated config!");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean migrateConfig(final File file) {
|
||||
if (!file.exists()) return false;
|
||||
|
||||
plugin.getLogger().info("Migrating old config to new format...");
|
||||
final Config oldConfig = new Config(file);
|
||||
private void updateLanguageFile() {
|
||||
final String filePrefix = "language-" + languageName;
|
||||
try {
|
||||
oldConfig.load();
|
||||
} catch (final IOException e) {
|
||||
plugin.getLogger().log(Level.WARNING, "Error while trying to migrate old config file", e);
|
||||
return false;
|
||||
createFile(filePrefix + "-new.yml", filePrefix + ".yml");
|
||||
} catch (final NullPointerException e) {
|
||||
plugin.getLogger().info("Not checking for updated language strings, since there is no " + filePrefix + ".yml in the resource files (if your file is self translated and up to date, you can ignore this).");
|
||||
return;
|
||||
} catch (final Exception e) {
|
||||
plugin.getLogger().warning("Couldn't update language file, as the " + filePrefix + ".yml could not be loaded from the resource files!");
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
if (oldConfig.contains("pingmessage"))
|
||||
config.set("pingmessages", Arrays.asList(oldConfig.getString("pingmessage")));
|
||||
if (oldConfig.contains("enable-maintenance-mode"))
|
||||
config.set("maintenance-enabled", oldConfig.getBoolean("enable-maintenance-mode"));
|
||||
config.getValues().entrySet().forEach(entry -> {
|
||||
if (!oldConfig.contains(entry.getKey())) return;
|
||||
entry.setValue(oldConfig.get(entry.getKey()));
|
||||
});
|
||||
|
||||
oldConfig.clear();
|
||||
if (!file.delete())
|
||||
plugin.getLogger().warning("Could not delete old config file! Please delete it as soon as possible.");
|
||||
else
|
||||
plugin.getLogger().info("Updated to new config file!");
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean migrateSpigotServersFile() {
|
||||
final File file = new File(plugin.getDataFolder(), "SpigotServers.yml");
|
||||
if (!file.exists()) return false;
|
||||
|
||||
final Config oldFile = new Config(file);
|
||||
final File file = new File(plugin.getDataFolder(), filePrefix + "-new.yml");
|
||||
final Config tempConfig = new Config(file);
|
||||
try {
|
||||
oldFile.load();
|
||||
tempConfig.load();
|
||||
} catch (final IOException e) {
|
||||
plugin.getLogger().log(Level.WARNING, "Error while trying to migrate old SpigotServers file", e);
|
||||
return false;
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
if (oldFile.contains("maintenance-on"))
|
||||
config.set("proxied-maintenance-servers", oldFile.getStringList("maintenance-on"));
|
||||
if (oldFile.contains("fallback"))
|
||||
config.set("fallback", oldFile.getString("fallback"));
|
||||
|
||||
oldFile.clear();
|
||||
if (!file.delete())
|
||||
plugin.getLogger().warning("Could not delete old SpigotServers.yml file! Please delete it as soon as possible.");
|
||||
else
|
||||
plugin.getLogger().info("Deleted old SpigotServers.yml file!");
|
||||
return true;
|
||||
final boolean updated = language.addMissingFields(tempConfig.getValues(), tempConfig.getComments());
|
||||
tempConfig.clear();
|
||||
file.delete();
|
||||
if (updated) {
|
||||
try {
|
||||
language.save();
|
||||
plugin.getLogger().info("Updated language file!");
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final String ALL_CODES = "0123456789AaBbCcDdEeFfKkLlMmNnOoRr";
|
||||
@@ -269,11 +313,12 @@ public class Settings implements ISettings {
|
||||
}
|
||||
|
||||
public String getConfigString(final String path) {
|
||||
if (!config.contains(path)) {
|
||||
final String s = config.getString(path);
|
||||
if (s == null) {
|
||||
plugin.getLogger().warning("The config is missing the following string: " + path);
|
||||
return "null";
|
||||
}
|
||||
return config.getString(path);
|
||||
return s;
|
||||
}
|
||||
|
||||
public String getMessage(final String path) {
|
||||
@@ -281,17 +326,25 @@ public class Settings implements ISettings {
|
||||
}
|
||||
|
||||
public String getMessage(final String path, final String def) {
|
||||
if (!language.contains(path)) {
|
||||
final String s = language.getString(path);
|
||||
if (s == null) {
|
||||
plugin.getLogger().warning("The language file is missing the following string: " + path);
|
||||
return def;
|
||||
}
|
||||
return language.getString(path);
|
||||
return s;
|
||||
}
|
||||
|
||||
public String getRandomPingMessage() {
|
||||
if (pingMessages.isEmpty()) return "";
|
||||
final String s = pingMessages.size() > 1 ? pingMessages.get(RANDOM.nextInt(pingMessages.size())) : pingMessages.get(0);
|
||||
return getColoredString(s.replace("%NEWLINE%", "\n").replace("%TIMER%", plugin.formatedTimer()));
|
||||
if (plugin.isTaskRunning() && !plugin.getRunnable().shouldEnable()
|
||||
&& hasTimerSpecificPingMessages() && !timerSpecificPingMessages.isEmpty()) {
|
||||
return getPingMessage(timerSpecificPingMessages);
|
||||
}
|
||||
return pingMessages.isEmpty() ? "" : getPingMessage(pingMessages);
|
||||
}
|
||||
|
||||
private String getPingMessage(final List<String> list) {
|
||||
final String s = list.size() == 1 ? list.get(0) : list.get(RANDOM.nextInt(list.size()));
|
||||
return getColoredString(replaceNewlineVar(plugin.replacePingVariables(s)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -306,10 +359,16 @@ public class Settings implements ISettings {
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean removeWhitelistedPlayer(final String name) {
|
||||
final Map.Entry<UUID, String> entry = whitelistedPlayers.entrySet().stream().filter(e -> e.getValue().equalsIgnoreCase(name)).findAny().orElse(null);
|
||||
if (entry == null) return false;
|
||||
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;
|
||||
|
||||
final UUID uuid = entry.getKey();
|
||||
whitelistedPlayers.remove(uuid);
|
||||
whitelist.remove(uuid.toString());
|
||||
saveWhitelistedPlayers();
|
||||
@@ -330,6 +389,11 @@ public class Settings implements ISettings {
|
||||
return whitelistedPlayers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWhitelisted(final UUID uuid) {
|
||||
return whitelistedPlayers.containsKey(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMaintenance() {
|
||||
return maintenance;
|
||||
@@ -339,6 +403,11 @@ public class Settings implements ISettings {
|
||||
this.maintenance = maintenance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnablePingMessages() {
|
||||
return enablePingMessages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJoinNotifications() {
|
||||
return joinNotifications;
|
||||
@@ -358,29 +427,65 @@ public class Settings implements ISettings {
|
||||
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;
|
||||
}
|
||||
|
||||
// The ping messages still contain the %NEWLINE% (if they have 2 lines)
|
||||
public List<String> getPingMessages() {
|
||||
return pingMessages;
|
||||
}
|
||||
|
||||
public List<String> getCommandsOnMaintenanceEnable() {
|
||||
return commandsOnMaintenanceEnable;
|
||||
}
|
||||
|
||||
public List<String> getCommandsOnMaintenanceDisable() {
|
||||
return commandsOnMaintenanceDisable;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> getTimerSpecificPingMessages() {
|
||||
return timerSpecificPingMessages;
|
||||
}
|
||||
|
||||
public Set<Integer> getBroadcastIntervals() {
|
||||
return broadcastIntervals;
|
||||
}
|
||||
|
||||
public String getPlayerCountMessage() {
|
||||
return playerCountMessage.replace("%TIMER%", plugin.formatedTimer());
|
||||
return plugin.replacePingVariables(playerCountMessage);
|
||||
}
|
||||
|
||||
public String getPlayerCountHoverMessage() {
|
||||
return playerCountHoverMessage.replace("%TIMER%", plugin.formatedTimer());
|
||||
return plugin.replacePingVariables(playerCountHoverMessage);
|
||||
}
|
||||
|
||||
public String getKickMessage() {
|
||||
return getMessage("kickmessage", "§cThe server is currently under maintenance!%NEWLINE%§cTry again later!")
|
||||
.replace("%NEWLINE%", "\n").replace("%TIMER%", plugin.formatedTimer());
|
||||
return plugin.replacePingVariables(getMessage("kickmessage"));
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
@@ -391,6 +496,20 @@ public class Settings implements ISettings {
|
||||
return customPlayerCountMessage;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 partciular the motd list), as well as confusing for most users in general.
|
||||
* Because of this, I replace %NEWLINE% manually, to spare users from these ugly breaks.
|
||||
*/
|
||||
protected String replaceNewlineVar(final String s) {
|
||||
return s.replace("%NEWLINE%", "\n");
|
||||
}
|
||||
|
||||
protected void loadExtraSettings() {
|
||||
}
|
||||
}
|
||||
+19
-8
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,33 +15,44 @@
|
||||
* 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 org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class CommandInfo {
|
||||
protected final MaintenancePlugin plugin;
|
||||
protected final String helpMessage;
|
||||
private final String helpMessageKey;
|
||||
private final String permission;
|
||||
private final boolean visible;
|
||||
|
||||
protected CommandInfo(final MaintenancePlugin plugin, final String permission, final String helpMessage) {
|
||||
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;
|
||||
this.helpMessage = helpMessage;
|
||||
// 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 String getHelpMessage() {
|
||||
return helpMessage;
|
||||
return getMessage(helpMessageKey);
|
||||
}
|
||||
|
||||
public List<String> getTabCompletion(final SenderInfo sender, final String[] args) {
|
||||
@@ -60,7 +71,7 @@ public abstract class CommandInfo {
|
||||
|
||||
protected boolean checkArgs(final SenderInfo sender, final String[] args, final int length) {
|
||||
if (args.length != length) {
|
||||
sender.sendMessage(helpMessage);
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
+46
-11
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,16 +15,34 @@
|
||||
* 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.*;
|
||||
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 eu.kennytv.maintenance.core.util.ServerType;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class MaintenanceCommand {
|
||||
protected final MaintenancePlugin plugin;
|
||||
@@ -55,6 +73,7 @@ public abstract class MaintenanceCommand {
|
||||
|
||||
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) {
|
||||
@@ -90,8 +109,18 @@ public abstract class MaintenanceCommand {
|
||||
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)
|
||||
return commandExecutors.entrySet().stream().filter(entry -> entry.getKey().startsWith(s) && entry.getValue().hasPermission(sender)).map(Map.Entry::getKey).collect(Collectors.toList());
|
||||
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();
|
||||
}
|
||||
@@ -111,7 +140,7 @@ public abstract class MaintenanceCommand {
|
||||
return true;
|
||||
}
|
||||
if (minutes < 1) {
|
||||
sender.sendMessage("§8§o[KennyTV whispers to you] §7§oThink about running a timer for a negative amount of minutes. Doesn't work §lthat §7§owell.");
|
||||
sender.sendMessage("§8§o[kennytv whispers to you] §7§oThink about running a timer for a negative amount of minutes. Doesn't work §lthat §7§owell.");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -126,14 +155,20 @@ public abstract class MaintenanceCommand {
|
||||
|
||||
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 void checkForUpdate(final SenderInfo sender) {
|
||||
if (plugin.updateAvailable()) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cNewest version available: §aVersion " + plugin.getNewestVersion() + "§c, you're on §a" + plugin.getVersion());
|
||||
sender.sendMessage(plugin.getPrefix() + "§c§lWARNING: §cYou will have to restart the server to prevent further issues and to complete the update! If you can't do that, don't update!");
|
||||
sendUpdateMessage(sender);
|
||||
// Ore sad :(
|
||||
if (plugin.getServerType() != ServerType.SPONGE) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§c§lWARNING: §cYou will have to restart the server to prevent further issues and to complete the update! If you can't do that, don't update!");
|
||||
sendUpdateMessage(sender);
|
||||
} else {
|
||||
sender.sendMessage(plugin.getPrefix() + "§aDownload the latest version on the Ore plugin page: §bhttps://ore.spongepowered.org/KennyTV/Maintenance");
|
||||
}
|
||||
} else
|
||||
sender.sendMessage(plugin.getPrefix() + "§aYou already have the latest version of the plugin!");
|
||||
}
|
||||
|
||||
+4
-5
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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;
|
||||
@@ -25,13 +24,13 @@ import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
public final class AbortTimerCommand extends CommandInfo {
|
||||
|
||||
public AbortTimerCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "timer", "§6/maintenance aborttimer §7(If running, the current timer will be aborted)");
|
||||
super(plugin, "timer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (args.length != 1) {
|
||||
sender.sendMessage(helpMessage);
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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.sendMessage("Debug mode is now " + (plugin.isDebug() ? "enabled" : "disabled"));
|
||||
}
|
||||
}
|
||||
+8
-7
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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;
|
||||
@@ -28,7 +27,7 @@ public final class DumpCommand extends CommandInfo {
|
||||
private long lastDump;
|
||||
|
||||
public DumpCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "dump", "§6/maintenance dump §7(Dumps some server information, used for bug reports)");
|
||||
super(plugin, "dump");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,15 +43,17 @@ public final class DumpCommand extends CommandInfo {
|
||||
plugin.async(() -> {
|
||||
final String key = plugin.pasteDump();
|
||||
if (key == null) {
|
||||
if (sender.isPlayer())
|
||||
if (sender.isPlayer()) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cCould not paste dump (see the console for details)");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final String url = "https://hasteb.in/" + key;
|
||||
final String url = "https://hastebin.com/" + key;
|
||||
sender.sendMessage(plugin.getPrefix() + "§c" + url);
|
||||
if (sender.isPlayer())
|
||||
if (sender.isPlayer()) {
|
||||
plugin.getCommandManager().sendDumpMessage(sender, url);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+7
-6
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,24 +15,25 @@
|
||||
* 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.concurrent.TimeUnit;
|
||||
|
||||
public final class EndtimerCommand extends CommandInfo {
|
||||
|
||||
public EndtimerCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "timer", "§6/maintenance endtimer <minutes> §7(After the given time in minutes, maintenance mode will be disabled)");
|
||||
super(plugin, "timer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 2)) return;
|
||||
if (plugin.getCommandManager().checkTimerArgs(sender, args[1])) {
|
||||
sender.sendMessage(helpMessage);
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
if (!plugin.isMaintenance()) {
|
||||
@@ -40,7 +41,7 @@ public final class EndtimerCommand extends CommandInfo {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.startMaintenanceRunnable(Integer.parseInt(args[1]), false);
|
||||
plugin.startMaintenanceRunnable(Integer.parseInt(args[1]), TimeUnit.MINUTES, false);
|
||||
sender.sendMessage(getMessage("endtimerStarted").replace("%TIME%", plugin.getRunnable().getTime()));
|
||||
}
|
||||
}
|
||||
+33
-26
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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;
|
||||
@@ -23,34 +22,35 @@ 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.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class HelpCommand extends CommandInfo {
|
||||
private static final int COMMANDS_PER_PAGE = 8;
|
||||
|
||||
public HelpCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, null, "§6/maintenance help [page] §7(Shows this beautiful help window)");
|
||||
super(plugin, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (args.length > 2) {
|
||||
sender.sendMessage(helpMessage);
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length == 1) {
|
||||
sendUsage(sender);
|
||||
} else {
|
||||
if (!plugin.isNumeric(args[1])) {
|
||||
sender.sendMessage(helpMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
final int page = Integer.parseInt(args[1]);
|
||||
sendUsage(sender, page == 0 ? 1 : page);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.isNumeric(args[1])) {
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
final int page = Integer.parseInt(args[1]);
|
||||
sendUsage(sender, page == 0 ? 1 : page);
|
||||
}
|
||||
|
||||
public void sendUsage(final SenderInfo sender) {
|
||||
@@ -59,26 +59,33 @@ public final class HelpCommand extends CommandInfo {
|
||||
|
||||
public void sendUsage(final SenderInfo sender, final int page) {
|
||||
Preconditions.checkArgument(page > 0);
|
||||
final List<String> commands = plugin.getCommandManager().getCommands().stream().filter(cmd -> cmd.hasPermission(sender)).map(CommandInfo::getHelpMessage).collect(Collectors.toList());
|
||||
final List<String> 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.sendMessage(getMessage("helpPageNotFound"));
|
||||
return;
|
||||
}
|
||||
|
||||
final List<String> filteredCommands;
|
||||
if (page * COMMANDS_PER_PAGE >= commands.size())
|
||||
filteredCommands = commands.subList((page - 1) * COMMANDS_PER_PAGE, commands.size());
|
||||
else
|
||||
filteredCommands = commands.subList((page - 1) * COMMANDS_PER_PAGE, page * COMMANDS_PER_PAGE);
|
||||
final List<String> filteredCommands = commands.subList((page - 1) * COMMANDS_PER_PAGE, Math.min(page * COMMANDS_PER_PAGE, commands.size()));
|
||||
|
||||
final String header = "§8========[ §eMaintenance" + plugin.getServerType() + " §8| §e" + page + "/" + ((commands.size() + getDivide(commands.size())) / COMMANDS_PER_PAGE) + " §8]========";
|
||||
final String header = getMessage("helpHeader").replace("%NAME%", "Maintenance" + plugin.getServerType())
|
||||
.replace("%PAGE%", Integer.toString(page)).replace("%MAX%", Integer.toString((commands.size() + getDivide(commands.size())) / COMMANDS_PER_PAGE));
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(header);
|
||||
filteredCommands.forEach(sender::sendMessage);
|
||||
if (page * COMMANDS_PER_PAGE < commands.size())
|
||||
sender.sendMessage("§7Use §b/maintenance help " + (page + 1) + " §7to get to the next help window.");
|
||||
else
|
||||
sender.sendMessage("§8× §eVersion " + plugin.getVersion() + " §7by §bKennyTV");
|
||||
for (final String command : filteredCommands) {
|
||||
sender.sendMessage(command);
|
||||
}
|
||||
|
||||
if (page * COMMANDS_PER_PAGE < commands.size()) {
|
||||
sender.sendMessage(getMessage("helpNextPage").replace("%PAGE%", Integer.toString(page + 1)));
|
||||
} else {
|
||||
sender.sendMessage("§8× §eVersion " + plugin.getVersion() + " §7by §bkennytv");
|
||||
}
|
||||
|
||||
sender.sendMessage(header);
|
||||
sender.sendMessage("");
|
||||
}
|
||||
|
||||
+34
-7
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,29 +15,56 @@
|
||||
* 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", "§6/maintenance motd §7(Lists the currently set maintenance motds)");
|
||||
super(plugin, "motd");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 1)) return;
|
||||
if (args.length == 1) {
|
||||
sendList(sender, getSettings().getPingMessages());
|
||||
} else if (args.length == 2 && args[1].equalsIgnoreCase("timer")) {
|
||||
if (!getSettings().hasTimerSpecificPingMessages()) {
|
||||
sender.sendMessage(getMessage("timerMotdDisabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
sendList(sender, getSettings().getTimerSpecificPingMessages());
|
||||
} else {
|
||||
sender.sendMessage(getHelpMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void sendList(final SenderInfo sender, final List<String> list) {
|
||||
if (list == null || list.isEmpty()) {
|
||||
sender.sendMessage(getMessage("motdListEmpty"));
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(getMessage("motdList"));
|
||||
for (int i = 0; i < getSettings().getPingMessages().size(); i++) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
sender.sendMessage("§b" + (i + 1) + "§8§m---------");
|
||||
for (final String motd : getSettings().getColoredString(getSettings().getPingMessages().get(i)).split("%NEWLINE%")) {
|
||||
for (final String motd : getSettings().getColoredString(list.get(i)).split("%NEWLINE%")) {
|
||||
sender.sendMessage(motd);
|
||||
}
|
||||
}
|
||||
sender.sendMessage("§8§m----------");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletion(final SenderInfo sender, final String[] args) {
|
||||
if (args.length != 2 || !getSettings().hasTimerSpecificPingMessages()) return Collections.emptyList();
|
||||
return Collections.singletonList("timer");
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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;
|
||||
@@ -25,7 +24,7 @@ import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
public final class ReloadCommand extends CommandInfo {
|
||||
|
||||
public ReloadCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "reload", "§6/maintenance reload §7(Reloads the config file, whitelist file and the server-icon)");
|
||||
super(plugin, "reload");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+30
-18
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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;
|
||||
@@ -30,44 +29,57 @@ import java.util.List;
|
||||
public final class RemoveMotdCommand extends CommandInfo {
|
||||
|
||||
public RemoveMotdCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "setmotd", "§6/maintenance removemotd <index> §7(Removes a maintenance motd)");
|
||||
super(plugin, "setmotd");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
public void execute(final SenderInfo sender, String[] args) {
|
||||
boolean timerPingMessages = false;
|
||||
if (args.length == 3 && args[1].equalsIgnoreCase("timer")) {
|
||||
if (!getSettings().hasTimerSpecificPingMessages()) {
|
||||
sender.sendMessage(getMessage("timerMotdDisabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
args = plugin.removeArrayIndex(args, 1);
|
||||
timerPingMessages = true;
|
||||
}
|
||||
if (checkArgs(sender, args, 2)) return;
|
||||
if (!plugin.isNumeric(args[1])) {
|
||||
sender.sendMessage(helpMessage);
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
final Settings settings = getSettings();
|
||||
if (settings.getPingMessages().size() < 2) {
|
||||
final List<String> pingMessages = timerPingMessages ? settings.getTimerSpecificPingMessages() : settings.getPingMessages();
|
||||
if (pingMessages.size() < 2) {
|
||||
sender.sendMessage(getMessage("removeMotdError"));
|
||||
return;
|
||||
}
|
||||
|
||||
final int index = Integer.parseInt(args[1]);
|
||||
if (index == 0 || index > settings.getPingMessages().size()) {
|
||||
sender.sendMessage(getMessage("setMotdIndexError").replace("%MOTDS%", Integer.toString(settings.getPingMessages().size()))
|
||||
.replace("%NEWAMOUNT%", Integer.toString(settings.getPingMessages().size())));
|
||||
if (index == 0 || index > pingMessages.size()) {
|
||||
sender.sendMessage(getMessage("setMotdIndexError").replace("%MOTDS%", Integer.toString(pingMessages.size()))
|
||||
.replace("%NEWAMOUNT%", Integer.toString(pingMessages.size())));
|
||||
return;
|
||||
}
|
||||
|
||||
settings.getPingMessages().remove(index - 1);
|
||||
settings.getConfig().set("pingmessages", settings.getPingMessages());
|
||||
pingMessages.remove(index - 1);
|
||||
settings.getConfig().set(timerPingMessages ? "timerspecific-pingmessages" : "pingmessages", pingMessages);
|
||||
settings.saveConfig();
|
||||
sender.sendMessage(getMessage("removedMotd").replace("%INDEX%", args[1]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletion(final SenderInfo sender, final String[] args) {
|
||||
if (args.length != 2) return Collections.emptyList();
|
||||
final int size = plugin.getSettings().getPingMessages().size();
|
||||
final List<String> list = new ArrayList<>(size);
|
||||
for (int i = 1; i <= size; i++) {
|
||||
list.add(String.valueOf(i));
|
||||
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 list;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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.concurrent.TimeUnit;
|
||||
|
||||
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;
|
||||
if (plugin.getCommandManager().checkTimerArgs(sender, args[1])
|
||||
|| plugin.getCommandManager().checkTimerArgs(sender, args[2], false)) {
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
if (plugin.isMaintenance()) {
|
||||
sender.sendMessage(getMessage("alreadyEnabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.scheduleMaintenanceRunnable(Integer.parseInt(args[1]), Integer.parseInt(args[2]), TimeUnit.MINUTES);
|
||||
sender.sendMessage(getMessage("starttimerStarted").replace("%TIME%", plugin.getRunnable().getTime()));
|
||||
}
|
||||
}
|
||||
+38
-19
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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;
|
||||
@@ -31,21 +30,33 @@ import java.util.List;
|
||||
public final class SetMotdCommand extends CommandInfo {
|
||||
|
||||
public SetMotdCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "setmotd", "§6/maintenance setmotd <index> <1/2> <message> §7(Sets a motd for maintenance mode)");
|
||||
super(plugin, "setmotd");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
public void execute(final SenderInfo sender, String[] args) {
|
||||
boolean timerPingMessages = false;
|
||||
if (args.length > 1 && args[1].equalsIgnoreCase("timer")) {
|
||||
if (!getSettings().hasTimerSpecificPingMessages()) {
|
||||
sender.sendMessage(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.sendMessage(helpMessage);
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
final Settings settings = getSettings();
|
||||
final List<String> pingMessages = timerPingMessages ? settings.getTimerSpecificPingMessages() : settings.getPingMessages();
|
||||
final int index = Integer.parseInt(args[1]);
|
||||
if (index == 0 || index > settings.getPingMessages().size() + 1) {
|
||||
sender.sendMessage(getMessage("setMotdIndexError").replace("%MOTDS%", Integer.toString(settings.getPingMessages().size()))
|
||||
.replace("%NEWAMOUNT%", Integer.toString(settings.getPingMessages().size() + 1)));
|
||||
if (index == 0 || index > pingMessages.size() + 1) {
|
||||
sender.sendMessage(getMessage("setMotdIndexError").replace("%MOTDS%", Integer.toString(pingMessages.size()))
|
||||
.replace("%NEWAMOUNT%", Integer.toString(pingMessages.size() + 1)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -61,31 +72,39 @@ public final class SetMotdCommand extends CommandInfo {
|
||||
}
|
||||
|
||||
final String message = String.join(" ", Arrays.copyOfRange(args, 3, args.length));
|
||||
final String oldMessage = index > settings.getPingMessages().size() ? "" : settings.getPingMessages().get(index - 1);
|
||||
final String oldMessage = index > pingMessages.size() ? "" : pingMessages.get(index - 1);
|
||||
final String newMessage;
|
||||
if (line == 1)
|
||||
if (line == 1) {
|
||||
newMessage = oldMessage.contains("%NEWLINE%") ?
|
||||
message + "%NEWLINE%" + oldMessage.split("%NEWLINE%", 2)[1] : message;
|
||||
else
|
||||
} else {
|
||||
newMessage = oldMessage.contains("%NEWLINE%") ?
|
||||
oldMessage.split("%NEWLINE%", 2)[0] + "%NEWLINE%" + message : oldMessage + "%NEWLINE%" + message;
|
||||
}
|
||||
|
||||
if (index > settings.getPingMessages().size())
|
||||
settings.getPingMessages().add(newMessage);
|
||||
else
|
||||
settings.getPingMessages().set(index - 1, newMessage);
|
||||
settings.getConfig().set("pingmessages", settings.getPingMessages());
|
||||
if (index > pingMessages.size()) {
|
||||
pingMessages.add(newMessage);
|
||||
} else {
|
||||
pingMessages.set(index - 1, newMessage);
|
||||
}
|
||||
|
||||
settings.getConfig().set(timerPingMessages ? "timerspecific-pingmessages" : "pingmessages", pingMessages);
|
||||
settings.saveConfig();
|
||||
sender.sendMessage(settings.getMessage("setMotd").replace("%LINE%", args[2]).replace("%INDEX%", args[1])
|
||||
.replace("%MOTD%", "§f" + settings.getColoredString(message)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletion(final SenderInfo sender, final String[] args) {
|
||||
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 <= getSettings().getPingMessages().size() + 1; i++) {
|
||||
for (int i = 1; i <= (timer ? getSettings().getTimerSpecificPingMessages() : getSettings().getPingMessages()).size() + 1; i++) {
|
||||
list.add(String.valueOf(i));
|
||||
}
|
||||
return list;
|
||||
|
||||
+7
-6
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,24 +15,25 @@
|
||||
* 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.concurrent.TimeUnit;
|
||||
|
||||
public final class StarttimerCommand extends CommandInfo {
|
||||
|
||||
public StarttimerCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "timer", "§6/maintenance starttimer <minutes> §7(After the given time in minutes, maintenance mode will be enabled)");
|
||||
super(plugin, "timer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 2)) return;
|
||||
if (plugin.getCommandManager().checkTimerArgs(sender, args[1])) {
|
||||
sender.sendMessage(helpMessage);
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
if (plugin.isMaintenance()) {
|
||||
@@ -40,7 +41,7 @@ public final class StarttimerCommand extends CommandInfo {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.startMaintenanceRunnable(Integer.parseInt(args[1]), true);
|
||||
plugin.startMaintenanceRunnable(Integer.parseInt(args[1]), TimeUnit.MINUTES, true);
|
||||
sender.sendMessage(getMessage("starttimerStarted").replace("%TIME%", plugin.getRunnable().getTime()));
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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;
|
||||
@@ -25,7 +24,7 @@ import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
public final class ToggleCommand extends CommandInfo {
|
||||
|
||||
public ToggleCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "toggle", "§6/maintenance <on/off> §7(Enables/disables maintenance mode)");
|
||||
super(plugin, "toggle");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+12
-6
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,17 +15,17 @@
|
||||
* 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.core.util.ServerType;
|
||||
|
||||
public final class UpdateCommand extends CommandInfo {
|
||||
|
||||
public UpdateCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "update", "§6/maintenance update §7(Remotely downloads the newest version of the plugin onto your server)");
|
||||
super(plugin, "update");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,12 +38,18 @@ public final class UpdateCommand extends CommandInfo {
|
||||
sender.sendMessage(plugin.getPrefix() + "§aYou already have the latest version of the plugin!");
|
||||
return;
|
||||
}
|
||||
// Ore very sad :(
|
||||
if (plugin.getServerType() == ServerType.SPONGE) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cSorry, automated downloading of the plugin is not supported on Sponge! Please download the latest version manually! :(");
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(getMessage("updateDownloading"));
|
||||
if (plugin.installUpdate())
|
||||
if (plugin.installUpdate()) {
|
||||
sender.sendMessage(getMessage("updateFinished"));
|
||||
else
|
||||
} else {
|
||||
sender.sendMessage(getMessage("updateFailed"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+31
-15
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,11 +15,11 @@
|
||||
* 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;
|
||||
@@ -29,18 +29,33 @@ import java.util.UUID;
|
||||
public final class WhitelistAddCommand extends CommandInfo {
|
||||
|
||||
public WhitelistAddCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "whitelist.add", "§6/maintenance add <name/uuid> §7(Adds the player to the maintenance whitelist, so they can join the server even though maintenance is enabled)");
|
||||
super(plugin, "whitelist.add");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 2)) return;
|
||||
if (args[1].length() == 36) {
|
||||
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.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
final UUID uuid = plugin.checkUUID(sender, args[1]);
|
||||
if (uuid != null)
|
||||
addPlayerToWhitelist(sender, uuid);
|
||||
} else
|
||||
addPlayerToWhitelist(sender, args[1]);
|
||||
if (uuid != null) {
|
||||
addPlayerToWhitelist(sender, new DummySenderInfo(uuid, args[2]));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(getHelpMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,7 +70,7 @@ public final class WhitelistAddCommand extends CommandInfo {
|
||||
return;
|
||||
}
|
||||
|
||||
whitelistAddMessage(sender, selected);
|
||||
addPlayerToWhitelist(sender, selected);
|
||||
}
|
||||
|
||||
private void addPlayerToWhitelist(final SenderInfo sender, final UUID uuid) {
|
||||
@@ -65,13 +80,14 @@ public final class WhitelistAddCommand extends CommandInfo {
|
||||
return;
|
||||
}
|
||||
|
||||
whitelistAddMessage(sender, selected);
|
||||
addPlayerToWhitelist(sender, selected);
|
||||
}
|
||||
|
||||
private void whitelistAddMessage(final SenderInfo sender, final SenderInfo selected) {
|
||||
if (getSettings().addWhitelistedPlayer(selected.getUuid(), selected.getName()))
|
||||
private void addPlayerToWhitelist(final SenderInfo sender, final SenderInfo selected) {
|
||||
if (getSettings().addWhitelistedPlayer(selected.getUuid(), selected.getName())) {
|
||||
sender.sendMessage(getMessage("whitelistAdded").replace("%PLAYER%", selected.getName()));
|
||||
else
|
||||
} else {
|
||||
sender.sendMessage(getMessage("whitelistAlreadyAdded").replace("%PLAYER%", selected.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
-9
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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;
|
||||
@@ -28,7 +27,7 @@ import java.util.UUID;
|
||||
public final class WhitelistCommand extends CommandInfo {
|
||||
|
||||
public WhitelistCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "whitelist.list", "§6/maintenance whitelist §7(Shows all whitelisted players for the maintenance mode)");
|
||||
super(plugin, "whitelist.list");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,11 +37,15 @@ public final class WhitelistCommand extends CommandInfo {
|
||||
final Map<UUID, String> players = getSettings().getWhitelistedPlayers();
|
||||
if (players.isEmpty()) {
|
||||
sender.sendMessage(getMessage("whitelistEmpty"));
|
||||
} else {
|
||||
sender.sendMessage(getMessage("whitelistedPlayers"));
|
||||
final String format = getMessage("whitelistedPlayersFormat");
|
||||
players.forEach((key, value) -> sender.sendMessage(format.replace("%NAME%", value).replace("%UUID%", key.toString())));
|
||||
sender.sendMessage("");
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(getMessage("whitelistedPlayers"));
|
||||
final String format = getMessage("whitelistedPlayersFormat");
|
||||
for (final Map.Entry<UUID, String> entry : players.entrySet()) {
|
||||
sender.sendMessage(format.replace("%NAME%", entry.getValue()).replace("%UUID%", entry.getKey().toString()));
|
||||
}
|
||||
|
||||
sender.sendMessage("");
|
||||
}
|
||||
}
|
||||
+30
-19
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,22 +15,21 @@
|
||||
* 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;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class WhitelistRemoveCommand extends CommandInfo {
|
||||
|
||||
public WhitelistRemoveCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "whitelist.remove", "§6/maintenance remove <name/uuid> §7(Removes the player from the maintenance whitelist)");
|
||||
super(plugin, "whitelist.remove");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,43 +37,55 @@ public final class WhitelistRemoveCommand extends CommandInfo {
|
||||
if (checkArgs(sender, args, 2)) return;
|
||||
if (args[1].length() == 36) {
|
||||
final UUID uuid = plugin.checkUUID(sender, args[1]);
|
||||
if (uuid != null)
|
||||
if (uuid != null) {
|
||||
removePlayerFromWhitelist(sender, uuid);
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
removePlayerFromWhitelist(sender, args[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletion(final SenderInfo sender, final String[] args) {
|
||||
return args.length == 2 ? getSettings().getWhitelistedPlayers().values().stream()
|
||||
.filter(name -> name.toLowerCase().startsWith(args[1])).collect(Collectors.toList()) : Collections.emptyList();
|
||||
if (args.length != 2) return Collections.emptyList();
|
||||
|
||||
final List<String> list = new ArrayList<>();
|
||||
for (final String name : getSettings().getWhitelistedPlayers().values()) {
|
||||
if (name.toLowerCase().startsWith(args[1])) {
|
||||
list.add(name);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private void removePlayerFromWhitelist(final SenderInfo sender, final String name) {
|
||||
final SenderInfo selected = plugin.getOfflinePlayer(name);
|
||||
if (selected == null) {
|
||||
if (getSettings().removeWhitelistedPlayer(name))
|
||||
if (getSettings().removeWhitelistedPlayer(name)) {
|
||||
sender.sendMessage(getMessage("whitelistRemoved").replace("%PLAYER%", name));
|
||||
else
|
||||
} else {
|
||||
sender.sendMessage(getMessage("whitelistNotFound"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
whitelistRemoveMessage(sender, selected.getUuid(), selected.getName());
|
||||
removePlayerFromWhitelist(sender, selected.getUuid(), selected.getName());
|
||||
}
|
||||
|
||||
private void removePlayerFromWhitelist(final SenderInfo sender, final UUID uuid) {
|
||||
final SenderInfo selected = plugin.getOfflinePlayer(uuid);
|
||||
if (selected == null)
|
||||
whitelistRemoveMessage(sender, uuid, uuid.toString());
|
||||
else
|
||||
whitelistRemoveMessage(sender, selected.getUuid(), selected.getName());
|
||||
if (selected == null) {
|
||||
removePlayerFromWhitelist(sender, uuid, uuid.toString());
|
||||
} else {
|
||||
removePlayerFromWhitelist(sender, selected.getUuid(), selected.getName());
|
||||
}
|
||||
}
|
||||
|
||||
private void whitelistRemoveMessage(final SenderInfo sender, final UUID uuid, final String toReplace) {
|
||||
if (getSettings().removeWhitelistedPlayer(uuid))
|
||||
private void removePlayerFromWhitelist(final SenderInfo sender, final UUID uuid, final String toReplace) {
|
||||
if (getSettings().removeWhitelistedPlayer(uuid)) {
|
||||
sender.sendMessage(getMessage("whitelistRemoved").replace("%PLAYER%", toReplace));
|
||||
else
|
||||
} else {
|
||||
sender.sendMessage(getMessage("whitelistNotFound"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,9 +15,10 @@
|
||||
* 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 org.jetbrains.annotations.Nullable;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
@@ -25,13 +26,17 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Further modified version of the SimpleConfig project of PSandro (https://github.com/PSandro/SimpleConfig).
|
||||
*
|
||||
* @author PSandro on 26.01.19
|
||||
* @author KennyTV
|
||||
* @author kennytv
|
||||
*/
|
||||
public final class Config extends ConfigSection {
|
||||
|
||||
@@ -44,7 +49,7 @@ public final class Config extends ConfigSection {
|
||||
"# |_| |_|\\__,_|_|_| |_|\\__\\___|_| |_|\\__,_|_| |_|\\___\\___| |_.__/ \\__, | |_|\\_\\___|_| |_|_| |_|\\__, ||_| \\_/ #\n" +
|
||||
"# |___/ |___/ #\n" +
|
||||
"#######################################################################################################################\n" +
|
||||
"# You can report bugs here: https://github.com/KennyTV/Maintenance/issues\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";
|
||||
private final Yaml yaml = createYaml();
|
||||
private final File file;
|
||||
@@ -53,8 +58,9 @@ public final class Config extends ConfigSection {
|
||||
private String header;
|
||||
|
||||
public Config(final File file, final String... unsupportedFields) {
|
||||
super(null, "");
|
||||
this.file = file;
|
||||
this.unsupportedFields = new HashSet<>(Arrays.asList(unsupportedFields));
|
||||
this.unsupportedFields = unsupportedFields.length == 0 ? Collections.emptySet() : Sets.newHashSet(unsupportedFields);
|
||||
}
|
||||
|
||||
public void load() throws IOException {
|
||||
@@ -62,26 +68,27 @@ public final class Config extends ConfigSection {
|
||||
final Map<String, Object> map = yaml.load(data);
|
||||
this.values = map != null ? map : new LinkedHashMap<>();
|
||||
this.comments = ConfigSerializer.deserializeComments(data);
|
||||
if (comments.containsKey(".header"))
|
||||
this.header = String.join("\n", comments.remove(".header"));
|
||||
|
||||
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 = "";
|
||||
boolean remove = false;
|
||||
for (final String s : split) {
|
||||
splitKey += s;
|
||||
if (!unsupportedFields.contains(splitKey)) {
|
||||
splitKey += ".";
|
||||
continue;
|
||||
}
|
||||
remove = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (remove)
|
||||
// Unsupported field
|
||||
comments.remove(key);
|
||||
return remove;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (removedFields) {
|
||||
save();
|
||||
@@ -89,49 +96,42 @@ public final class Config extends ConfigSection {
|
||||
}
|
||||
|
||||
public void save() throws IOException {
|
||||
final byte[] bytes = this.saveConfigToString().getBytes(StandardCharsets.UTF_8);
|
||||
this.file.getParentFile().mkdirs();
|
||||
this.file.createNewFile();
|
||||
Files.write(this.file.toPath(), bytes);
|
||||
saveTo(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(final String key, final Object value, final String... comments) {
|
||||
if (value == null) {
|
||||
remove(key);
|
||||
} else {
|
||||
this.values.put(key, value);
|
||||
this.comments.put(key, comments);
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(final String key) {
|
||||
this.values.remove(key);
|
||||
this.comments.remove(key);
|
||||
}
|
||||
public boolean addMissingFields(final Map<String, Object> fields, final Map<String, String[]> comments) {
|
||||
// Note: Only scans for the first two levels
|
||||
boolean changed = false;
|
||||
for (final Map.Entry<String, Object> entry : fields.entrySet()) {
|
||||
final Object o = values.get(entry.getKey());
|
||||
if (o != null) {
|
||||
final Object o2 = entry.getValue();
|
||||
if (!(o instanceof Map) || !(o2 instanceof Map)) continue;
|
||||
|
||||
/**
|
||||
* Convenience method, not further established as currently not necessary.
|
||||
*
|
||||
* @see #getSection(String)
|
||||
* @deprecated this config is only made for a quite simple use, only goes one level deeper
|
||||
*/
|
||||
@Deprecated
|
||||
public Object getDeep(final String key) {
|
||||
final String[] split = key.split("\\.", 2);
|
||||
if (split.length != 2) return get(key);
|
||||
final Map<String, Object> deepMap = (Map<String, Object>) o2;
|
||||
for (final Map.Entry<String, Object> deepEntry : ((Map<String, Object>) o2).entrySet()) {
|
||||
if (deepMap.containsKey(deepEntry.getKey())) continue;
|
||||
deepMap.put(deepEntry.getKey(), deepEntry.getValue());
|
||||
changed = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
final Object o = getObject(split[0]);
|
||||
if (!(o instanceof Map)) return null;
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
changed = true;
|
||||
}
|
||||
|
||||
final Map<String, Object> map = (Map<String, Object>) o;
|
||||
return map.get(split[1]);
|
||||
}
|
||||
|
||||
public ConfigSection getSection(final String key) {
|
||||
final Object o = getObject(key);
|
||||
return o instanceof Map ? new ConfigSection((Map<String, Object>) o) : null;
|
||||
this.comments = new HashMap<>(comments);
|
||||
return changed;
|
||||
}
|
||||
|
||||
private static Yaml createYaml() {
|
||||
@@ -139,13 +139,10 @@ public final class Config extends ConfigSection {
|
||||
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 String saveConfigToString() {
|
||||
return ConfigSerializer.serialize(this.header, this.values, this.comments, this.yaml);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.values.clear();
|
||||
this.comments.clear();
|
||||
@@ -160,6 +157,12 @@ public final class Config extends ConfigSection {
|
||||
return unsupportedFields;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Config getRoot() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getHeader() {
|
||||
return header;
|
||||
}
|
||||
@@ -168,5 +171,8 @@ public final class Config extends ConfigSection {
|
||||
this.header = AWESOME_HEADER;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ConfigSerializer.serialize(this.header, this.values, this.comments, this.yaml);
|
||||
}
|
||||
}
|
||||
+110
-39
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,9 +15,10 @@
|
||||
* 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.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -26,58 +27,92 @@ import java.util.Set;
|
||||
/**
|
||||
* Further modified version of the SimpleConfig project of PSandro (https://github.com/PSandro/SimpleConfig).
|
||||
*
|
||||
* @author KennyTV
|
||||
* @author kennytv
|
||||
*/
|
||||
public class ConfigSection {
|
||||
|
||||
protected final Config root;
|
||||
protected final String currentPath;
|
||||
protected Map<String, Object> values;
|
||||
|
||||
ConfigSection() {
|
||||
this(new HashMap<>());
|
||||
ConfigSection(final Config root, final String currentPath) {
|
||||
this(root, currentPath, new HashMap<>());
|
||||
}
|
||||
|
||||
ConfigSection(final Map<String, Object> values) {
|
||||
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) this.values.get(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 this.values.get(key);
|
||||
return getObject(key, null);
|
||||
}
|
||||
|
||||
public <E> E getOrSet(final String key, final E def) {
|
||||
if (this.values.containsKey(key)) {
|
||||
return (E) this.values.get(key);
|
||||
@Nullable
|
||||
public Object getObject(final String key, final Object def) {
|
||||
int i1 = -1;
|
||||
int i2;
|
||||
ConfigSection section = this;
|
||||
while ((i1 = key.indexOf('.', i2 = i1 + 1)) != -1) {
|
||||
section = section.getSection(key.substring(i2, i1));
|
||||
if (section == null) return def;
|
||||
}
|
||||
|
||||
final String subKey = key.substring(i2);
|
||||
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 boolean contains(final String key) {
|
||||
return this.values.containsKey(key);
|
||||
return getObject(key) != null;
|
||||
}
|
||||
|
||||
public void set(final String key, final Object value) {
|
||||
public void set(final String key, @Nullable final Object value) {
|
||||
//TODO go deep if necessary
|
||||
if (value == null) {
|
||||
remove(key);
|
||||
} else
|
||||
this.values.put(key, value);
|
||||
}
|
||||
|
||||
public void set(final String key, final Object value, final String... comments) {
|
||||
if (value == null) {
|
||||
remove(key);
|
||||
values.remove(key);
|
||||
getRoot().getComments().remove(getFullKeyInPath(key));
|
||||
} else {
|
||||
this.values.put(key, value);
|
||||
values.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(final String key) {
|
||||
this.values.remove(key);
|
||||
set(key, null);
|
||||
}
|
||||
|
||||
public Set<String> getKeys() {
|
||||
@@ -89,53 +124,89 @@ public class ConfigSection {
|
||||
}
|
||||
|
||||
public boolean getBoolean(final String key) {
|
||||
final Object o = values.get(key);
|
||||
return o instanceof Boolean && (boolean) o;
|
||||
return getBoolean(key, false);
|
||||
}
|
||||
|
||||
public boolean getBoolean(final String key, final boolean def) {
|
||||
return values.containsKey(key) ? get(key) : def;
|
||||
final Object o = getObject(key);
|
||||
return o instanceof Boolean ? (boolean) o : def;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getString(final String key) {
|
||||
return get(key);
|
||||
}
|
||||
|
||||
public String getString(final String key, final String def) {
|
||||
return values.containsKey(key) ? get(key) : def;
|
||||
@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) {
|
||||
final Object o = values.get(key);
|
||||
return o instanceof Number ? ((Number) o).intValue() : 0;
|
||||
return getInt(key, 0);
|
||||
}
|
||||
|
||||
public int getInt(final String key, final int def) {
|
||||
return values.containsKey(key) ? get(key) : def;
|
||||
final Object o = getObject(key);
|
||||
return o instanceof Number ? ((Number) o).intValue() : def;
|
||||
}
|
||||
|
||||
public double getDouble(final String key) {
|
||||
final Object o = values.get(key);
|
||||
return o instanceof Number ? ((Number) o).doubleValue() : 0;
|
||||
return getDouble(key, 0D);
|
||||
}
|
||||
|
||||
public double getDouble(final String key, final double def) {
|
||||
return values.containsKey(key) ? get(key) : 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);
|
||||
}
|
||||
|
||||
public List<String> getStringList(final String key, final List<String> def) {
|
||||
return values.containsKey(key) ? get(key) : def;
|
||||
@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);
|
||||
}
|
||||
|
||||
public List<Integer> getIntList(final String key, final List<Integer> def) {
|
||||
return values.containsKey(key) ? get(key) : def;
|
||||
@Nullable
|
||||
public List<Integer> getIntList(final String key, @Nullable final List<Integer> def) {
|
||||
final List<Integer> list = get(key);
|
||||
return list != null ? list : def;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
+71
-26
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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;
|
||||
@@ -30,68 +29,93 @@ import java.util.regex.Pattern;
|
||||
* Further modified version of the SimpleConfig project of PSandro (https://github.com/PSandro/SimpleConfig).
|
||||
*
|
||||
* @author PSandro on 26.01.19
|
||||
* @author KennyTV
|
||||
* @author kennytv
|
||||
*/
|
||||
public final class ConfigSerializer {
|
||||
|
||||
private static final String[] EMPTY = new String[0];
|
||||
private static final int INDENT_UNIT = 2;
|
||||
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);
|
||||
if (data.isEmpty()) {
|
||||
return yaml.dump(null);
|
||||
}
|
||||
|
||||
final String rawYaml = yaml.dump(data);
|
||||
final StringBuilder fileData = new StringBuilder();
|
||||
int currentIndents = 0;
|
||||
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 String indentText = indent > 0 ? line.substring(0, indent) : "";
|
||||
if (indents <= currentIndents) {
|
||||
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 = currentIndents - indents + 1;
|
||||
final int backspace = currentKeyIndents - indents + 1;
|
||||
key = join(array, array.length - backspace);
|
||||
keyLine = true;
|
||||
} else {
|
||||
keyLine = line.indexOf(':') != -1;
|
||||
}
|
||||
|
||||
final String separator = key.isEmpty() ? "" : PATH_SEPARATOR_STRING;
|
||||
final String lineKey = line.contains(":") ? line.split(Pattern.quote(":"))[0] : line;
|
||||
key += separator + lineKey.substring(indent);
|
||||
if (!keyLine) {
|
||||
// Nothing to do, go to next line
|
||||
fileData.append(line).append('\n');
|
||||
continue;
|
||||
}
|
||||
|
||||
currentIndents = indents;
|
||||
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;
|
||||
|
||||
final String[] strings = comments.get(key);
|
||||
if (strings != null) {
|
||||
for (final String comment : strings) {
|
||||
if (comment.isEmpty())
|
||||
fileData.append('\n');
|
||||
else
|
||||
fileData.append(indentText).append(comment).append('\n');
|
||||
// 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("");
|
||||
@@ -100,21 +124,39 @@ public final class ConfigSerializer {
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
// Check if this is a level lower
|
||||
if (indents <= currentIndents) {
|
||||
final String[] array = key.split(PATH_SEPARATOR_QUOTED);
|
||||
final int backspace = currentIndents - indents + 1;
|
||||
key = join(array, array.length - backspace);
|
||||
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.contains(":") ? line.split(Pattern.quote(":"))[0] : line;
|
||||
final String lineKey = line.indexOf(':') != -1 ? line.split(Pattern.quote(":"))[0] : line;
|
||||
key += separator + lineKey.substring(indent);
|
||||
currentIndents = indents;
|
||||
|
||||
@@ -129,8 +171,11 @@ public final class ConfigSerializer {
|
||||
private static int getIndents(final String line) {
|
||||
int count = 0;
|
||||
for (int i = 0; i < line.length(); i++) {
|
||||
if (line.charAt(i) == ' ') count++;
|
||||
else break;
|
||||
if (line.charAt(i) != ' ') {
|
||||
break;
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
+4
-6
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,10 +15,8 @@
|
||||
* 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.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
@@ -33,7 +31,7 @@ public final class MaintenanceDump {
|
||||
private final JsonObject plugins;
|
||||
|
||||
public MaintenanceDump(final MaintenancePlugin plugin, final Settings settings) {
|
||||
general = new ServerDump(plugin.getVersion(), plugin.getServerType().toString(), plugin.getServerVersion(), plugin.getMaintenanceServers());
|
||||
general = new ServerDump(plugin.getVersion(), plugin.getServerType().toString(), plugin.getServerVersion(), plugin.getMaintenanceServersDump());
|
||||
|
||||
configuration = new LinkedHashMap<>(settings.getConfig().getValues());
|
||||
final Object o = configuration.get("mysql");
|
||||
@@ -46,7 +44,7 @@ public final class MaintenanceDump {
|
||||
configuration.put("icon-exists", new File(plugin.getDataFolder(), "maintenance-icon.png").exists());
|
||||
|
||||
final JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.add("plugins", new GsonBuilder().create().toJsonTree(plugin.getPlugins()));
|
||||
jsonObject.add("plugins", MaintenancePlugin.GSON.toJsonTree(plugin.getPlugins()));
|
||||
plugins = jsonObject;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,20 +15,19 @@
|
||||
* 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;
|
||||
|
||||
public final class ServerDump {
|
||||
private final String pluginVersion;
|
||||
private final String serverType;
|
||||
private final String platform;
|
||||
private final String serverVersion;
|
||||
private final List<String> maintenance;
|
||||
|
||||
public ServerDump(final String pluginVersion, final String serverType, final String serverVersion, final List<String> maintenance) {
|
||||
public ServerDump(final String pluginVersion, final String platform, final String serverVersion, final List<String> maintenance) {
|
||||
this.pluginVersion = pluginVersion;
|
||||
this.serverType = serverType;
|
||||
this.platform = platform;
|
||||
this.serverVersion = serverVersion;
|
||||
this.maintenance = maintenance;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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.IEventManager;
|
||||
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 IEventManager {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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;
|
||||
@@ -25,8 +24,9 @@ public final class ServerListPlusHook {
|
||||
private final ServerListPlusCore serverListPlusCore;
|
||||
|
||||
public ServerListPlusHook(final Object serverListPlus) {
|
||||
if (!(serverListPlus instanceof ServerListPlusPlugin))
|
||||
if (!(serverListPlus instanceof ServerListPlusPlugin)) {
|
||||
throw new IllegalArgumentException("Couldn't parse ServerListPlus instance!");
|
||||
}
|
||||
this.serverListPlusCore = ((ServerListPlusPlugin) serverListPlus).getCore();
|
||||
}
|
||||
|
||||
|
||||
+12
-19
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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;
|
||||
@@ -29,7 +28,6 @@ import java.util.UUID;
|
||||
public abstract class JoinListenerBase {
|
||||
protected final MaintenancePlugin plugin;
|
||||
protected final Settings settings;
|
||||
protected final UUID notifyUuid = new UUID(-6334418481592579467L, -4779835342378829761L);
|
||||
private final Set<UUID> notifiedPlayers = new HashSet<>();
|
||||
|
||||
protected JoinListenerBase(final MaintenancePlugin plugin, final Settings settings) {
|
||||
@@ -43,32 +41,27 @@ public abstract class JoinListenerBase {
|
||||
* @param sender wrapper of the joining player
|
||||
* @return true if the sender should be kicked
|
||||
*/
|
||||
protected boolean kickPlayer(final SenderInfo sender, final boolean updateCheck) {
|
||||
if (settings.isMaintenance() && !sender.getUuid().equals(notifyUuid)) {
|
||||
if (!sender.hasMaintenancePermission("bypass") && !settings.getWhitelistedPlayers().containsKey(sender.getUuid())) {
|
||||
if (settings.isJoinNotifications())
|
||||
broadcastJoinNotification(sender.getName());
|
||||
return true;
|
||||
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;
|
||||
}
|
||||
if (updateCheck)
|
||||
updateCheck(sender);
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean kickPlayer(final SenderInfo sender) {
|
||||
return kickPlayer(sender, true);
|
||||
protected boolean shouldKick(final SenderInfo sender) {
|
||||
return shouldKick(sender, true);
|
||||
}
|
||||
|
||||
protected void updateCheck(final SenderInfo sender) {
|
||||
if (sender.getUuid().equals(notifyUuid)) {
|
||||
sender.sendMessage("§6Maintenance §aVersion " + plugin.getVersion());
|
||||
return;
|
||||
}
|
||||
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.sendMessage(plugin.getPrefix() + "§cThere is a newer version available: §aVersion " + plugin.getNewestVersion() + "§c, you're on §a" + plugin.getVersion());
|
||||
plugin.sendUpdateNotification(sender);
|
||||
|
||||
+7
-8
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,16 +15,15 @@
|
||||
* 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;
|
||||
|
||||
public final class MaintenanceRunnable extends MaintenanceRunnableBase {
|
||||
public class MaintenanceRunnable extends MaintenanceRunnableBase {
|
||||
|
||||
public MaintenanceRunnable(final MaintenancePlugin plugin, final Settings settings, final int minutes, final boolean enable) {
|
||||
super(plugin, settings, minutes, enable);
|
||||
public MaintenanceRunnable(final MaintenancePlugin plugin, final Settings settings, final int seconds, final boolean enable) {
|
||||
super(plugin, settings, seconds, enable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -33,12 +32,12 @@ public final class MaintenanceRunnable extends MaintenanceRunnableBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String startMessageKey() {
|
||||
protected String getStartMessage() {
|
||||
return settings.getMessage("starttimerBroadcast").replace("%TIME%", getTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String endMessageKey() {
|
||||
protected String getEndMessage() {
|
||||
return settings.getMessage("endtimerBroadcast").replace("%TIME%", getTime());
|
||||
}
|
||||
}
|
||||
+22
-26
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,23 +15,25 @@
|
||||
* 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;
|
||||
|
||||
public abstract class MaintenanceRunnableBase implements Runnable {
|
||||
protected final MaintenancePlugin plugin;
|
||||
protected final Settings settings;
|
||||
protected final boolean enable;
|
||||
private final Task task;
|
||||
protected boolean enable;
|
||||
protected int seconds;
|
||||
|
||||
protected MaintenanceRunnableBase(final MaintenancePlugin plugin, final Settings settings, final int minutes, final boolean enable) {
|
||||
protected MaintenanceRunnableBase(final MaintenancePlugin plugin, final Settings settings, final int seconds, final boolean enable) {
|
||||
this.plugin = plugin;
|
||||
this.settings = settings;
|
||||
this.seconds = minutes * 60;
|
||||
this.seconds = seconds;
|
||||
this.enable = enable;
|
||||
this.task = plugin.startMaintenanceRunnable(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,41 +41,35 @@ public abstract class MaintenanceRunnableBase implements Runnable {
|
||||
if (seconds == 0) {
|
||||
finish();
|
||||
} else if (settings.getBroadcastIntervals().contains(seconds)) {
|
||||
if (enable)
|
||||
plugin.broadcast(startMessageKey());
|
||||
else
|
||||
plugin.broadcast(endMessageKey());
|
||||
broadcast(enable ? getStartMessage() : getEndMessage());
|
||||
}
|
||||
|
||||
seconds--;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
final int preHours = this.seconds / 60;
|
||||
final int minutes = preHours % 60;
|
||||
final int seconds = this.seconds % 60;
|
||||
|
||||
final StringBuilder buider = new StringBuilder();
|
||||
append(buider, "hour", preHours / 60);
|
||||
append(buider, "minute", minutes);
|
||||
append(buider, "second", seconds);
|
||||
return buider.toString();
|
||||
return plugin.getFormattedTime(seconds);
|
||||
}
|
||||
|
||||
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.getMessage(time == 1 ? timeUnit : timeUnit + "s"));
|
||||
public boolean shouldEnable() {
|
||||
return enable;
|
||||
}
|
||||
|
||||
public int getSecondsLeft() {
|
||||
return seconds;
|
||||
}
|
||||
|
||||
public Task getTask() {
|
||||
return task;
|
||||
}
|
||||
|
||||
protected void broadcast(final String message) {
|
||||
plugin.broadcast(message);
|
||||
}
|
||||
|
||||
protected abstract void finish();
|
||||
|
||||
protected abstract String startMessageKey();
|
||||
protected abstract String getStartMessage();
|
||||
|
||||
protected abstract String endMessageKey();
|
||||
protected abstract String getEndMessage();
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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 java.util.concurrent.TimeUnit;
|
||||
|
||||
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(maintenanceDuration, TimeUnit.SECONDS, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getStartMessage() {
|
||||
return settings.getMessage("scheduletimerBroadcast")
|
||||
.replace("%TIME%", getTime()).replace("%DURATION%", plugin.getFormattedTime(maintenanceDuration));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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 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 sendMessage(final String message) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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 java.util.UUID;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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 {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,7 +15,6 @@
|
||||
* 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 {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Maintenance - https://git.io/maintenancemode
|
||||
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
|
||||
* This file is part of Maintenance - https://github.com/kennytv/Maintenance
|
||||
* Copyright (C) 2018-2021 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
|
||||
@@ -15,36 +15,37 @@
|
||||
* 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) {
|
||||
if (version == null || version.isEmpty()) {
|
||||
this.version = "";
|
||||
tag = "";
|
||||
parts = new int[0];
|
||||
System.out.println("Unknown Maintenance version detected!");
|
||||
return;
|
||||
}
|
||||
final String[] split = version.split("-", 2)[0].split("\\.");
|
||||
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++) {
|
||||
if (!split[i].matches("[0-9]+")) {
|
||||
this.version = "";
|
||||
tag = "";
|
||||
System.out.println("Unknown Maintenance version detected!");
|
||||
return;
|
||||
}
|
||||
// Let this throw an exception if parsing fails
|
||||
parts[i] = Integer.parseInt(split[i]);
|
||||
}
|
||||
|
||||
this.version = version;
|
||||
tag = version.contains("-") ? version.split("-", 2)[1] : "";
|
||||
tag = index != -1 ? version.substring(index + 1) : "";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,20 +55,25 @@ public final class Version implements Comparable<Version> {
|
||||
* @return 0 if they are the same, 1 if this instance is newer, -1 if older
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(final Version version) {
|
||||
if (version == null || version.toString() == null) return 0;
|
||||
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;
|
||||
if (partA > partB) return 1;
|
||||
if (partA < partB) {
|
||||
return -1;
|
||||
} else if (partA > partB) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.tag.isEmpty() && !version.tag.isEmpty())
|
||||
if (this.tag.isEmpty() && !version.tag.isEmpty()) {
|
||||
return 1;
|
||||
if (!this.tag.isEmpty() && version.tag.isEmpty())
|
||||
} else if (!this.tag.isEmpty() && version.tag.isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -82,7 +88,9 @@ public final class Version implements Comparable<Version> {
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == null) return false;
|
||||
return o instanceof Version && o == this || version.equals(o.toString());
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof Version)) return false;
|
||||
final Version other = (Version) o;
|
||||
return version.equals(other.version);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
# 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
|
||||
# a8179ff3-c201-4a75-bdaa-9d14aca6f83f: kennytv
|
||||
@@ -6,7 +6,7 @@
|
||||
# |_| |_|\__,_|_|_| |_|\__\___|_| |_|\__,_|_| |_|\___\___| |_.__/ \__, | |_|\_\___|_| |_|_| |_|\__, ||_| \_/ #
|
||||
# |___/ |___/ #
|
||||
#######################################################################################################################
|
||||
# You can report bugs here: https://github.com/KennyTV/Maintenance/issues
|
||||
# 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
|
||||
|
||||
# Enables maintenance mode.
|
||||
@@ -14,25 +14,42 @@ maintenance-enabled: false
|
||||
|
||||
# Enables maintenance on certain servers managed by your Bungee instance(s).
|
||||
proxied-maintenance-servers:
|
||||
#- SpigotServer1
|
||||
#- AnotherServer
|
||||
- SpigotServer1
|
||||
# - AnotherServer
|
||||
|
||||
# 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 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: lobby
|
||||
|
||||
# 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 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 pingmessage (also works in playercount(-hover) message).
|
||||
pingmessages:
|
||||
- "&cMaintenance mode!%NEWLINE%&6We will be back soon!"
|
||||
# - "Other entry"
|
||||
enable-pingmessages: true
|
||||
|
||||
# Any extra commands inside of 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: []
|
||||
|
||||
# If set to true and an endtimer is currently running, a pingmessage 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-timerspecific-messages: false
|
||||
timerspecific-pingmessages:
|
||||
- "&cMaintenance mode!%NEWLINE%&6We will be back in %TIMER%!"
|
||||
# - "Other entry"
|
||||
|
||||
# If set to true, the message below will be shown at the top right corner of the server in the serverlist, where the playercount would normally be displayed.
|
||||
# If set to false, the normal playercount will be shown.
|
||||
#
|
||||
# Alternatively you can use '%ONLINE%' and '%MAX% if you want to include the playercount in a custom message (e.g. "&cMaintenance &7%ONLINE%&8/&7%MAX%").
|
||||
# Alternatively you can use '%ONLINE%' and '%MAX%' if you want to include the playercount in a custom message (e.g. "&cMaintenance &7%ONLINE%&8/&7%MAX%").
|
||||
enable-playercountmessage: true
|
||||
playercountmessage: "&4Maintenance"
|
||||
|
||||
@@ -47,8 +64,13 @@ custom-maintenance-icon: false
|
||||
# that a player tried to join the server while maintenance is enabled.
|
||||
send-join-notification: false
|
||||
|
||||
# Set this to false if you do not want players to be kicked when you enable maintenance (new connections will still be blocked).
|
||||
# ... I don't know why you would want that, but you can disable it. :p
|
||||
kick-online-players: true
|
||||
|
||||
# Changes the language of command feedback/messages.
|
||||
# Currently available are: en (English), de (German), fr (French), pt (Portuguese)
|
||||
# If you find missing translations or want to contribute a new language file, you are very welcome to message me on Spigot or my Discord server! :)
|
||||
# Currently available are: en (English), de (German), fr (French), pt (Portuguese), es (Spanish), ru (Russian), zh (Chinese), it (Italian)
|
||||
language: en
|
||||
|
||||
# If you have 2 or more proxy instances, the database connection will make sure all proxies
|
||||
@@ -66,6 +88,16 @@ mysql:
|
||||
# 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 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]
|
||||
@@ -73,4 +105,7 @@ timer-broadcast-for-seconds: [1200, 900, 600, 300, 120, 60, 30, 20, 10, 5, 4, 3,
|
||||
# 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 less bugs.
|
||||
# However, you can always check for updates manually using the '/maintenance update' command.
|
||||
update-checks: true
|
||||
update-checks: true
|
||||
|
||||
# Used for autoupdating the config, do not change this value.
|
||||
config-version: 5
|
||||
@@ -1,4 +1,4 @@
|
||||
# Maintenance Plugin by KennyTV
|
||||
# Maintenance Plugin by kennytv
|
||||
# Wörter zwischen dem '%'-Zeichen nur entfernen, wenn Du wirklich weißt, warum Du sie entfernen willst
|
||||
|
||||
noPermission: "&cDu hast nicht die erforderliche Berechtigung für diesen Befehl."
|
||||
@@ -7,17 +7,21 @@ maintenanceActivated: "&8[&eMaintenance&8] &6Der Wartungsmodus ist nun aktiviert
|
||||
maintenanceDeactivated: "&8[&eMaintenance&8] &6Der Wartungsmodus ist nun deaktiviert."
|
||||
alreadyEnabled: "&8[&eMaintenance&8] &cDer Wartungsmodus ist bereits aktiviert!"
|
||||
alreadyDisabled: "&8[&eMaintenance&8] &cDer Wartungsmodus ist bereits deaktiviert!"
|
||||
helpPageNotFound: "&8[&eMaintenance&8] &cEs gibt keine Seite mit dieser Nummer!"
|
||||
endtimerBroadcast: "&8[&eMaintenance&8] &7Der Wartungsmodus wird deaktiviert in: &6%TIME%&7."
|
||||
endtimerStarted: "&8[&eMaintenance&8] &aGestarteter Timer: &7Der Wartungsmodus wird deaktiviert in: &6%TIME%&7."
|
||||
starttimerBroadcast: "&8[&eMaintenance&8] &7Der Wartungsmodus wird aktiviert in: &6%TIME%&7."
|
||||
starttimerStarted: "&8[&eMaintenance&8] &aGestarteter Timer: &7Der Wartungsmodus wird aktiviert in: &6%TIME%&7"
|
||||
scheduletimerBroadcast: "&8[&eMaintenance&8] &7Der Wartungsmodus wird in &6%TIME% &7aktiviert und &6%DURATION% &7dauern."
|
||||
timerAlreadyRunning: "&8[&eMaintenance&8] &cMomentan läuft bereits ein Timer!"
|
||||
timerNotRunning: "&8[&eMaintenance&8] &cMomentan läuft kein Timer."
|
||||
timerCancelled: "&8[&eMaintenance&8] &cDer laufende Timer wurde beendet."
|
||||
timerTooLong: "&8[&eMaintenance&8] &cDie angegebene Nummer muss kleiner als 40320 sein (= 28 Tage)!"
|
||||
timerMotdDisabled: "&8[&eMaintenance&8] &cDu musst 'enable-timerspecific-messages' in der Config auf 'true' stellen, wenn du timerspezifische Motds benutzen/editieren möchtest."
|
||||
motdTimer: "%HOURS%:%MINUTES%:%SECONDS%"
|
||||
motdTimerNotRunning: "-"
|
||||
joinNotification: "&8[&eMaintenance&8] &e%PLAYER% &chat versucht den Server beizutreten."
|
||||
motdList: "&8[&eMaintenance&8] &7Liste der Maintenance MOTDs:"
|
||||
motdListEmpty: "8[&eMaintenance&8] &cDu hast keine Maintenance MOTDs gesetzt!"
|
||||
reload: "&8[&eMaintenance&8] &aConfig, WhitelistedPlayers, Language Datei und Maintenance Icon wurden neugeladen."
|
||||
removedMotd: "&8[&eMaintenance&8] &aDie %INDEX%. Maintenance MOTD wurde entfernt."
|
||||
removeMotdError: "&8[&eMaintenance&8] &cDu hast nur eine Maintenance MOTD, daher kannst du auch keine entfernen!"
|
||||
@@ -39,20 +43,17 @@ playerNotFoundUuid: "&8[&eMaintenance&8] &cEs konnte kein Spieler mit dieser UUI
|
||||
playerNotOnline: "&8[&eMaintenance&8] &cEs ist momentan kein Spieler mit diesem Namen online."
|
||||
invalidUuid: "&8[&eMaintenance&8] &cUngültiges UUID Format!"
|
||||
|
||||
second: "Sekunde"
|
||||
seconds: "Sekunden"
|
||||
minute: "Minute"
|
||||
minutes: "Minuten"
|
||||
hour: "Stunde"
|
||||
hours: "Stunden"
|
||||
|
||||
# Nachrichten für den Bungee Teil des Plugins, einfach ignorieren, falls das Plugin auf Spigot verwendet wird
|
||||
# Nachrichten für den Bungee/Velocity Teil des Plugins, einfach ignorieren, falls das Plugin auf Spigot/Sponge verwendet wird
|
||||
sentToWaitingServer: "&8[&eMaintenance&8] &cDu wurdest auf den Warteserver verbunden!"
|
||||
forceWaitingServer: "&8[&eMaintenance&8] &cDu kannst den Warteserver nicht verlassen solange der Wartungsmodus aktiviert ist!"
|
||||
serverNotFound: "&8[&eMaintenance&8] &cEs wurde kein Server mit diesem Namen gefunden!"
|
||||
|
||||
singleTimerAlreadyRunning: "&8[&eMaintenance&8] &cMomentan läuft bereits ein Timer auf diesem Server!"
|
||||
singleTimerNotRunning: "&8[&eMaintenance&8] &cMomentan läuft kein Timer auf diesem Server."
|
||||
singleTimerCancelled: "&8[&eMaintenance&8] &cDer laufende Timer dieses Servers wurde beendet."
|
||||
singleEndtimerBroadcast: "&8[&eMaintenance&8] &7Der Wartungsmodus auf Server %SERVER% wird deaktiviert in: &6%TIME%&7."
|
||||
singleStarttimerBroadcast: "&8[&eMaintenance&8] &7Der Wartungsmodus auf Server %SERVER% wird aktiviert in: &6%TIME%&7."
|
||||
singleScheduletimerBroadcast: "&8[&eMaintenance&8] &7Der Wartungsmodus auf Server %SERVER% wird aktiviert in &6%TIME% &7und wird &6%DURATION% &7dauern."
|
||||
singleMaintenanceKick: "&8[&eMaintenance&8] &cDer Server %SERVER% befindet sich momentan im Wartungsmodus! Probier es später nochmal!"
|
||||
singleMaintenanceKickComplete: "&cDer Server %SERVER% befindet sich in Wartung!%NEWLINE%&cDu kannst versuchen zu rejoinen, um andere Server zu betreten!"
|
||||
singleMaintenanceActivated: "&8[&eMaintenance&8] &6Der Wartungsmodus wurde auf &e%SERVER% &6aktiviert."
|
||||
@@ -60,4 +61,38 @@ singleMaintenanceDeactivated: "&8[&eMaintenance&8] &6Der Wartungsmodus wurde auf
|
||||
singleServerAlreadyEnabled: "&8[&eMaintenance&8] &cDer Wartungsmodus ist bereits an auf &e%SERVER%&c!"
|
||||
singleServerAlreadyDisabled: "&8[&eMaintenance&8] &cDer Wartungsmodus ist bereits aus auf &e%SERVER%&c!"
|
||||
singleServerMaintenanceList: "&8[&eMaintenance&8] &7Unterserver, die im Wartungsmodus sind:"
|
||||
singleServerMaintenanceListEmpty: "&8[&eMaintenance&8] &7Es befindet sich momentan kein Unterserver im Wartungsmodus."
|
||||
singleServerMaintenanceListEmpty: "&8[&eMaintenance&8] &7Es befindet sich momentan kein Unterserver im Wartungsmodus."
|
||||
|
||||
second: "Sekunde"
|
||||
seconds: "Sekunden"
|
||||
minute: "Minute"
|
||||
minutes: "Minuten"
|
||||
hour: "Stunde"
|
||||
hours: "Stunden"
|
||||
|
||||
helpHeader: "&8========[ &e%NAME% &8| &e%PAGE%/%MAX% &8]========"
|
||||
helpPageNotFound: "&8[&eMaintenance&8] &cEs gibt keine Seite mit dieser Nummer!"
|
||||
helpNextPage: "&7Nutze &b/maintenance help %SEITE%&7, um zur nächsten Hilfeseite zu kommen."
|
||||
helpAbortTimer: "&6/maintenance aborttimer &7(Falls momentan ein Timer läuft, wird dieser abgebrochen)"
|
||||
helpEndtimer: "&6/maintenance endtimer <Minuten> &7(Sobald der Timer abläuft wird der Wartungsmodus deaktiviert)"
|
||||
helpStarttimer: "&6/maintenance starttimer <minutes> &7(Sobald der Timer abläuft wird der Wartungsmodus aktiviert)"
|
||||
helpDebug: "&6/maintenance debug &7(Aktiviert Debug Nachrichten in der Konsole)"
|
||||
helpDump: "&6/maintenance dump &7(Sammelt wichtige Informationen für Bugreports)"
|
||||
helpHelp: "&6/maintenance help [Seite] &7(Zeigt diese wunderschöne Hilfe)"
|
||||
helpMotd: "&6/maintenance motd [timer] &7(Zeigt die momentan gesetzten Maintenance Motds an. Mit dem 'timer' Argument werden die timerspezifischen Motds angezeigt)"
|
||||
helpRemoveMotd: "&6/maintenance removemotd [timer] <Index> &7(Entfernt eine Maintenance Motd. Mit dem 'timer' Argument wird eine timerspezifischen Motd entfernt)"
|
||||
helpSetMotd: "&6/maintenance setmotd [timer] <Index> <1/2> <Nachricht> &7(Setzte eine Motd für den Wartungsmodus. Mit dem 'timer' Argument as an argument wird eine timerspezifische Motd gesetzt)"
|
||||
helpReload: "&6/maintenance reload &7(Lädt Config, Language und Whitelist Dateien sowie das Maintenance Icon neu)"
|
||||
helpToggle: "&6/maintenance <on/off> &7(Aktiviert/deaktiviert den Wartungsmodus)"
|
||||
helpUpdate: "&6/maintenance update &7(Sucht nach neuen Updates für das Plugin und lädt diese auf den Server)"
|
||||
helpWhitelist: "&6/maintenance whitelist &7(Zeigt alle gewhitelisteten Spieler für den Wartungsmodus an)"
|
||||
helpWhitelistAdd: "&6/maintenance add <Name/UUID> &7(Whitelistet einen Spieler für den Wartungsmodus, sodass dieser während Wartungen den Server betreten kann)"
|
||||
helpWhitelistRemove: "&6/maintenance remove <Name/UUID> &7(Entfernt einen Spieler aus der Wartungsmodus Whitelist)"
|
||||
|
||||
# Nachrichten für den Bungee/Velocity Teil des Plugins, einfach ignorieren, falls das Plugin auf Spigot/Sponge verwendet wird
|
||||
helpAbortSingleTimer: "&6/maintenance aborttimer [Server] &7(Falls momentan ein Timer läuft, wird dieser abgebrochen)"
|
||||
helpSingleEndtimer: "&6/maintenance endtimer [Server] <Minuten> &7(Sobald der Timer abläuft wird der Wartungsmodus deaktiviert)"
|
||||
helpSingleStarttimer: "&6/maintenance starttimer [Server] <Minuten> &7(Sobald der Timer abläuft wird der Wartungsmodus aktiviert)"
|
||||
helpSingleScheduleTimer: "&6/maintenance scheduletimer [Server] <Minuten> <Wartung in Minuten> &7(Sobald der Timer abläuft wird der Wartungsmodus für die gegebene Länge aktiviert)"
|
||||
helpSingleToggle: "&6/maintenance <on/off> [Server] &7(Aktiviert/deaktiviert den Wartungsmodus)"
|
||||
helpStatus: "&6/maintenance status &7(Zeigt alle Server an, auf denen momentan der Wartungsmodus aktiviert ist)"
|
||||
@@ -1,4 +1,4 @@
|
||||
# Maintenance Plugin by KennyTV
|
||||
# Maintenance Plugin by kennytv
|
||||
# Don't remove words inbetween the '%' if you don't exactly know why you're doing it
|
||||
|
||||
noPermission: "&cYou do not have the permission to execute that command."
|
||||
@@ -7,17 +7,21 @@ maintenanceActivated: "&8[&eMaintenance&8] &6Maintenance mode is now activated."
|
||||
maintenanceDeactivated: "&8[&eMaintenance&8] &6Maintenance mode is now deactivated."
|
||||
alreadyEnabled: "&8[&eMaintenance&8] &cMaintenance is already enabled!"
|
||||
alreadyDisabled: "&8[&eMaintenance&8] &cMaintenance is already disabled!"
|
||||
helpPageNotFound: "&8[&eMaintenance&8] &cThere is no page with that number!"
|
||||
endtimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode will be disabled in &6%TIME%&7."
|
||||
endtimerStarted: "&8[&eMaintenance&8] &aStarted timer: &7Maintenance mode will be deactivated in &6%TIME%&7."
|
||||
starttimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode will be enabled in &6%TIME%&7."
|
||||
starttimerStarted: "&8[&eMaintenance&8] &aStarted timer: &7Maintenance mode will be activated in &6%TIME%&7."
|
||||
scheduletimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode will be enabled in &6%TIME% &7and will last for &6%DURATION%&7."
|
||||
timerAlreadyRunning: "&8[&eMaintenance&8] &cThere is already a timer scheduled!"
|
||||
timerNotRunning: "&8[&eMaintenance&8] &cThere is currently no running timer."
|
||||
timerCancelled: "&8[&eMaintenance&8] &cThe current timer has been disabled."
|
||||
timerTooLong: "&8[&eMaintenance&8] &cThe number has to be less than 40320 (28 days)!"
|
||||
timerMotdDisabled: "&8[&eMaintenance&8] &cYou have to set 'enable-timerspecific-messages' in the config to 'true', if you want to use/edit timerspecific motds."
|
||||
motdTimer: "%HOURS%:%MINUTES%:%SECONDS%"
|
||||
motdTimerNotRunning: "-"
|
||||
joinNotification: "&8[&eMaintenance&8] &e%PLAYER% &ctried to join the server."
|
||||
motdList: "&8[&eMaintenance&8] &7List of your maintenance motds:"
|
||||
motdListEmpty: "8[&eMaintenance&8] &cYou don't have any maintenance motds set!"
|
||||
reload: "&8[&eMaintenance&8] &aReloaded config, whitelistedplayers, language file and the maintenance icon."
|
||||
removedMotd: "&8[&eMaintenance&8] &aRemoved motd number %INDEX%."
|
||||
removeMotdError: "&8[&eMaintenance&8] &cYou only have one motd, so you cannot remove any!"
|
||||
@@ -39,20 +43,17 @@ playerNotFoundUuid: "&8[&eMaintenance&8] &cNo player with that uuid could be fou
|
||||
playerNotOnline: "&8[&eMaintenance&8] &cThere is no player online with that name."
|
||||
invalidUuid: "&8[&eMaintenance&8] &cInvalid uuid format!"
|
||||
|
||||
second: "second"
|
||||
seconds: "seconds"
|
||||
minute: "minute"
|
||||
minutes: "minutes"
|
||||
hour: "hour"
|
||||
hours: "hours"
|
||||
|
||||
# Some messages for the Bungee part, just ignore them if you use the plugin on Spigot
|
||||
# Messages for the Bungee/Velocity part, just can ignore them if you use the plugin on Spigot/Sponge
|
||||
sentToWaitingServer: "&8[&eMaintenance&8] &cYou have been sent to a waiting server!"
|
||||
forceWaitingServer: "&8[&eMaintenance&8] &cYou cannot leave the waiting server while maintenance is enabled!"
|
||||
serverNotFound: "&8[&eMaintenance&8] &cNo server with this name is registered on the proxy!"
|
||||
|
||||
singleTimerAlreadyRunning: "&8[&eMaintenance&8] &cThere is already a timer scheduled for that server!"
|
||||
singleTimerCancelled: "&8[&eMaintenance&8] &cThe current timer for server &e%SERVER% &chas been disabled."
|
||||
singleTimerNotRunning: "&8[&eMaintenance&8] &cThere is currently no running timer for that server."
|
||||
singleEndtimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode on server %SERVER% will be disabled in &6%TIME%&7."
|
||||
singleStarttimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode on server %SERVER% will be enabled in &6%TIME%&7."
|
||||
singleScheduletimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode on server %SERVER% will be enabled in &6%TIME% &7and will last for &6%DURATION%&7."
|
||||
singleMaintenanceKick: "&8[&eMaintenance&8] &cThe server %SERVER% is currently under maintenance! Try again later!"
|
||||
singleMaintenanceKickComplete: "&cThe server %SERVER% is under maintenance!%NEWLINE%&cYou may try to rejoin to go onto another server!"
|
||||
singleMaintenanceActivated: "&8[&eMaintenance&8] &6Maintenance mode is now activated on server &e%SERVER%&6."
|
||||
@@ -60,4 +61,39 @@ singleMaintenanceDeactivated: "&8[&eMaintenance&8] &6Maintenance mode is now dea
|
||||
singleServerAlreadyEnabled: "&8[&eMaintenance&8] &cMaintenance is already enabled on server &e%SERVER%&c!"
|
||||
singleServerAlreadyDisabled: "&8[&eMaintenance&8] &cMaintenance is already disabled on server &e%SERVER%&c!"
|
||||
singleServerMaintenanceList: "&8[&eMaintenance&8] &7Proxied servers, that have maintenance enabled:"
|
||||
singleServerMaintenanceListEmpty: "&8[&eMaintenance&8] &7There are no proxied servers that are under maintenance."
|
||||
singleServerMaintenanceListEmpty: "&8[&eMaintenance&8] &7There are no proxied servers that are under maintenance."
|
||||
|
||||
second: "second"
|
||||
seconds: "seconds"
|
||||
minute: "minute"
|
||||
minutes: "minutes"
|
||||
hour: "hour"
|
||||
hours: "hours"
|
||||
|
||||
helpHeader: "&8========[ &e%NAME% &8| &e%PAGE%/%MAX% &8]========"
|
||||
helpPageNotFound: "&8[&eMaintenance&8] &cThere is no page with that number!"
|
||||
helpNextPage: "&7Use &b/maintenance help %PAGE% &7to get to the next help window."
|
||||
helpAbortTimer: "&6/maintenance aborttimer &7(If running, the current timer will be aborted)"
|
||||
helpEndtimer: "&6/maintenance endtimer <minutes> &7(After the given time in minutes, maintenance mode will be disabled)"
|
||||
helpStarttimer: "&6/maintenance starttimer <minutes> &7(After the given time in minutes, maintenance mode will be enabled)"
|
||||
helpScheduleTimer: "&6/maintenance scheduletimer <timer minutes> <maintenance duration> &7(After the given time in minutes, maintenance mode will be enabled for the given duration in minutes)"
|
||||
helpDebug: "&6/maintenance debug &7(Enables some debug logging)"
|
||||
helpDump: "&6/maintenance dump &7(Dumps some server information, used for bug reports)"
|
||||
helpHelp: "&6/maintenance help [page] &7(Shows this beautiful help window)"
|
||||
helpMotd: "&6/maintenance motd [timer] &7(Lists the currently set maintenance motds. If specifying 'timer', the timer motds are shown)"
|
||||
helpRemoveMotd: "&6/maintenance removemotd [timer] <index> &7(Removes a maintenance motd. If using 'timer' as an argument, a timerspecific pingmessage will be removed)"
|
||||
helpSetMotd: "&6/maintenance setmotd [timer] <index> <1/2> <message> &7(Sets a motd for maintenance mode. If using 'timer' as an argument, a timerspecific pingmessage will be set)"
|
||||
helpReload: "&6/maintenance reload &7(Reloads the config file, whitelist file and the server-icon)"
|
||||
helpToggle: "&6/maintenance <on/off> &7(Enables/disables maintenance mode)"
|
||||
helpUpdate: "&6/maintenance update &7(Remotely downloads the newest version of the plugin onto your server)"
|
||||
helpWhitelist: "&6/maintenance whitelist &7(Shows all whitelisted players for the maintenance mode)"
|
||||
helpWhitelistAdd: "&6/maintenance add <name/uuid> &7(Adds the player to the maintenance whitelist, so they can join the server even though maintenance is enabled)"
|
||||
helpWhitelistRemove: "&6/maintenance remove <name/uuid> &7(Removes the player from the maintenance whitelist)"
|
||||
|
||||
# Messages for the Bungee/Velocity part, just can ignore them if you use the plugin on Spigot/Sponge
|
||||
helpAbortSingleTimer: "&6/maintenance aborttimer [server] &7(If running, the current timer will be aborted)"
|
||||
helpSingleEndtimer: "&6/maintenance endtimer [server] <minutes> &7(After the given time in minutes, maintenance mode will be disabled)"
|
||||
helpSingleStarttimer: "&6/maintenance starttimer [server] <minutes> &7(After the given time in minutes, maintenance mode will be enabled)"
|
||||
helpSingleScheduleTimer: "&6/maintenance scheduletimer [server] <timer minutes> <maintenance duration> &7(After the given time in minutes, maintenance mode will be enabled for the given duration in minutes)"
|
||||
helpSingleToggle: "&6/maintenance <on/off> [server] &7(Enables/disables maintenance mode)"
|
||||
helpStatus: "&6/maintenance status &7(Lists all proxied servers, that are currently under maintenance)"
|
||||
@@ -0,0 +1,99 @@
|
||||
# Maintenance Plugin by kennytv
|
||||
# Translators: Vixo_Ulises
|
||||
# Don't remove words inbetween the '%' if you don't exactly know why you're doing it
|
||||
|
||||
noPermission: "&8[&eMaintenance&8] &4No tienes permiso para ejecutar este comando."
|
||||
kickmessage: "&cEl servidor se encuentra en mantenimiento!%NEWLINE%&cIntentalo de nuevo mas tarde!"
|
||||
maintenanceActivated: "&8[&eMaintenance&8] Mantenimiento &7activado"
|
||||
maintenanceDeactivated: "&8[&eMaintenance&8] &7Modo mantenimiento &7desactivado"
|
||||
alreadyEnabled: "&8[&eMaintenance&8] &7Modo mantenimiento se encuentra habilitado!"
|
||||
alreadyDisabled: "&8[&eMaintenance&8] &7Modo mantenimiento se encuentra deshabilitado!"
|
||||
endtimerBroadcast: "&8[&eMaintenance&8] &7El modo mantenimiento se desactivara en &6%TIME%&7."
|
||||
endtimerStarted: "&8[&eMaintenance&8] &7Temporizador iniciado: El modo mantenimiento se desactivará en &6%TIME%&7."
|
||||
starttimerBroadcast: "&8[&eMaintenance&8] &7El modo mantenimiento se habilitara en &6%TIME%&7."
|
||||
starttimerStarted: "&8[&eMaintenance&8] &7Temporizador iniciado: El modo mantenimiento se activará en &6%TIME%&7."
|
||||
scheduletimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode will be enabled in &6%TIME% &7and will last for &6%DURATION%&7."
|
||||
timerAlreadyRunning: "&8[&eMaintenance&8] &cYa hay un temporizador programado!"
|
||||
timerNotRunning: "&8[&eMaintenance&8] &7Actualmente no hay temporizador."
|
||||
timerCancelled: "&8[&eMaintenance&8] &cEl Temporizador actual ha sido deshabilitado."
|
||||
timerTooLong: "&8[&eMaintenance&8] &7El numero debe ser menor a 40320 &8(&628 días&8)"
|
||||
timerMotdDisabled: "&8[&eMaintenance&8] &cTienes que configurar &a'enable-timerspecific-messages'&c en la configuración en &a'true'&c, si quieres usar / editar motdspecers específicos."
|
||||
motdTimer: "%HOURS%:%MINUTES%:%SECONDS%"
|
||||
motdTimerNotRunning: "-"
|
||||
joinNotification: "&8[&eMaintenance&8] &c%PLAYER% &7Intenta unirse al servidor."
|
||||
motdList: "&8[&eMaintenance&8] &7Lista de motds de mantenimiento&7:"
|
||||
motdListEmpty: "8[&eMaintenance&8] &c¡No tiene ningún motd(s&8) de mantenimiento establecido!"
|
||||
reload: "&8[&eMaintenance&8] &aConfiguracion recargada"
|
||||
removedMotd: "&8[&eMaintenance&8] &aNumero de motd eliminado &6%INDEX%&a."
|
||||
removeMotdError: "&8[&eMaintenance&8] &Solo tienes un motd, por lo que no puedes eliminar ninguno!"
|
||||
setMotd: "&8[&eMaintenance&8] &aEstablecer linea &6%LINE%&a sobre &6%INDEX%&a. Para mantenimiento para %MOTD%"
|
||||
setMotdIndexError: "&8[&eMaintenance&8] &aActualmente tiene &6%MOTDS%&a Motd(s&8), por lo que debe elegir un número entre 1 y %NEWAMOUNT%."
|
||||
setMotdLineError: "&8[&eMaintenance&8] &7El segundo argumento tiene que ser el numero de línea.(1 ó 2&8)!"
|
||||
updateDownloading: "&8[&eMaintenance&8] &aDescargando actualización..."
|
||||
updateFailed: "&8[&eMaintenance&8] &cActualizacion fallida!"
|
||||
updateFinished: "&8[&eMaintenance&8] &aLa actualización fue exitosa!, debes reiniciar el servidor!"
|
||||
whitelistedPlayers: "&8[&eMaintenance&8] &6Jugadores en lista blanca:"
|
||||
whitelistedPlayersFormat: "&7- &a%NAME% &8(&7%UUID%&8)"
|
||||
whitelistAdded: "&8[&eMaintenance&8] &a%PLAYER% &7Añadido a la lista de mantenimiento!"
|
||||
whitelistAlreadyAdded: "&8[&eMaintenance&8] &a%PLAYER% &7Se encuentra en la lista de mantenimiento!"
|
||||
whitelistRemoved: "&8[&eMaintenance&8] &c%PLAYER% &7Eliminado de la lista de mantenimiento!"
|
||||
whitelistNotFound: "&8[&eMaintenance&8] &7No se encuentra en la lista de mantenimiento!"
|
||||
whitelistEmpty: "&8[&eMaintenance&8] &7La lista de mantenimiento está vacía! Usa '&6/Maintenance add <Player>' &7para agregar a alguien!"
|
||||
playerNotFound: "&8[&eMaintenance&8] &7Ningun jugador con este nombre ha jugado en este servidor antes!"
|
||||
playerNotFoundUuid: "&8[&eMaintenance&8] &cNo se pudo encontrar el jugador con ese UUID."
|
||||
playerNotOnline: "&8[&eMaintenance&8] &7No hay jugador en línea con este nombre."
|
||||
invalidUuid: "&8[&eMaintenance&8] &cFormato inválido!"
|
||||
|
||||
# Messages for the Bungee/Velocity part, just can ignore them if you use the plugin on Spigot/Sponge
|
||||
sentToWaitingServer: "&8[&eMaintenance&8] &aHas sido enviado a un servidor de espera!"
|
||||
forceWaitingServer: "&8[&eMaintenance&8] &cNo puedes dejar el servidor de espera mientras el mantenimiento está activado!"
|
||||
serverNotFound: "&8[&eMaintenance&8] &cNingún servidor con este nombre está registrado en el proxy!"
|
||||
|
||||
singleTimerAlreadyRunning: "&8[&eMaintenance&8] &cYa hay un temporizador programado!"
|
||||
singleTimerNotRunning: "&8[&eMaintenance&8] &cActualmente no hay ningún temporizador en ejecución para ese servidor."
|
||||
singleTimerCancelled: "&8[&eMaintenance&8] &cEl temporizador actual para el servidor &6%SERVER% &cha sido desactivado."
|
||||
singleEndtimerBroadcast: "&8[&eMaintenance&8] &7El modo mantenimiento en el Servidor &6%SERVER% &7se desactivará en &a%TIME%&7."
|
||||
singleStarttimerBroadcast: "&8[&eMaintenance&8] &7El modo mantenimiento en el servidor &6%SERVER%&7 se activará en &a%TIME%&7"
|
||||
singleScheduletimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode on server %SERVER% will be enabled in &6%TIME% &7and will last for &6%DURATION%&7."
|
||||
singleMaintenanceKick: "&8[&eMaintenance&8] &7El servidor &6%SERVER% &7se encuentra en mantenimiento&7! Intentalo mas tarde!"
|
||||
singleMaintenanceKickComplete: "&7El Servidor &6%SERVER% &7esta en mantenimiento&7!%NEWLINE%&cVuelve Mas Tarde!"
|
||||
singleMaintenanceActivated: "&8[&eMaintenance&8] &7El modo mantenimiento esta activado en el servidor &6%SERVER%&7."
|
||||
singleMaintenanceDeactivated: "&8[&eMaintenance&8] &7El modo mantenimiento ahora esta deshabilitado en &6%SERVER%&7."
|
||||
singleServerAlreadyEnabled: "&8[&eMaintenance&8] &7El modo mantenimiento se encuentra habilitado en &6%SERVER%&7!"
|
||||
singleServerAlreadyDisabled: "&8[&eMaintenance&8] &7El modo mantenimiento se encuentra deshabilitado en &6%SERVER%&7!"
|
||||
singleServerMaintenanceList: "&8[&eMaintenance&8] &7Servidores proxy, que tienen habilitado el mantenimiento:"
|
||||
singleServerMaintenanceListEmpty: "&8[&eMaintenance&8] &7No hay servidores proxy que están en mantenimiento&7."
|
||||
|
||||
second: "Segundo"
|
||||
seconds: "Segundos"
|
||||
minute: "Minuto"
|
||||
minutes: "Minutos"
|
||||
hour: "Hora"
|
||||
hours: "Horas"
|
||||
|
||||
helpHeader: "&8========[ &e%NAME% &8| &e%PAGE%/%MAX% &8]========"
|
||||
helpPageNotFound: "&8[&eMaintenance&8] &7No hay pagina con ese número."
|
||||
helpNextPage: "&7Utilice &b/maintenance help %PAGE% &7Para pasar a la siguiente ventana de ayuda."
|
||||
helpAbortTimer: "&6/maintenance aborttimer &8(&7Si se ejecuta, se abortará el temporizador actual&8)"
|
||||
helpEndtimer: "&6/maintenance endtimer <minutes> &8(&7Después del tiempo en minutos, se desactivará el modo de mantenimiento&8)"
|
||||
helpStarttimer: "&6/maintenance starttimer <minutes> &8(&7Después del tiempo en minutos, se habilitará el modo de mantenimiento&8)"
|
||||
helpDebug: "&6/maintenance debug &7(Enables some debug logging)"
|
||||
helpDump: "&6/maintenance dump &8(&7Descarga información del servidor, usada para informes de errores&8)"
|
||||
helpHelp: "&6/maintenance help [page] &8(&7Muestra la pagina de ayuda&8)"
|
||||
helpMotd: "&6/maintenance motd [timer] &8(&7Enumera los motivos de mantenimiento establecidos actualmente. Si se especifica el 'temporizador', se muestran los motivos del temporizador&8)"
|
||||
helpRemoveMotd: "&6/maintenance removemotd [timer] <index> &8(&7Elimina un mantenimiento motd. Si se usa 'timer' como argumento, se eliminará un pingmessage de temporizador específico&8)"
|
||||
helpSetMotd: "&6/maintenance setmotd [timer] <index> <1/2> <message> &8(&7Establece un motd para el modo de mantenimiento. Si usa 'timer' como argumento, se establecerá un mensaje de ping específico para el tiempo&8)"
|
||||
helpReload: "&6/maintenance reload &8(&7Vuelve a cargar el archivo de configuración, el archivo de la lista blanca y el ícono del servidor&8)"
|
||||
helpToggle: "&6/maintenance <on/off> &8(&7Habilita / deshabilita el modo de mantenimiento&8)"
|
||||
helpUpdate: "&6/maintenance update &8(&7Descarga de forma remota la versión más reciente del complemento en su servidor&8)"
|
||||
helpWhitelist: "&6/maintenance whitelist &8(&7Muestra todos los jugadores en lista blanca para el modo de mantenimiento&8)"
|
||||
helpWhitelistAdd: "&6/maintenance add <name/uuid> &8(&7Agrega al jugador a la lista blanca de mantenimiento, para que puedan unirse al servidor aunque el mantenimiento esté habilitado&8)"
|
||||
helpWhitelistRemove: "&6/maintenance remove <name/uuid> &8(&7Quita al jugador de la lista blanca de mantenimiento&8)"
|
||||
|
||||
# Messages for the Bungee/Velocity part, just can ignore them if you use the plugin on Spigot/Sponge
|
||||
helpAbortSingleTimer: "&6/maintenance aborttimer [servidor] &8(&7Si está funcionando, se abortará el temporizador actual&8)"
|
||||
helpSingleEndtimer: "&6/maintenance endtimer [server] <minutes> &8(&7Después del tiempo en minutos, se desactivará el modo de mantenimiento&8)"
|
||||
helpSingleStarttimer: "&6/maintenance starttimer [server] <minutes> &8(&7Después del tiempo en minutos, se activara el modo de mantenimiento&8)"
|
||||
helpSingleScheduleTimer: "&6/maintenance scheduletimer [server] <timer minutes> <maintenance duration> &7(After the given time in minutes, maintenance mode will be enabled for the given duration in minutes)"
|
||||
helpSingleToggle: "&6/maintenance <on/off> [server] &8(&7Habilita / deshabilita el modo de mantenimiento&8)"
|
||||
helpStatus: "&6/maintenance status &8(&7Enumera todos los servidores proxy, que están actualmente en mantenimiento&8)"
|
||||
@@ -1,63 +1,98 @@
|
||||
# Maintenance Plugin par KennyTV
|
||||
# Ne supprime pas des mots entre les '%' si tu ne sait pas pourqoi exactement
|
||||
# Plugin Maintenance par kennytv, traduit en Français par Zendrique & Aurelien30000.
|
||||
# Ne supprimez pas de mots entre les '%' si vous ne savez pas exactement pourquoi, ils correspondent à des référencements de valeurs changeantes.
|
||||
|
||||
noPermission: "&cVous n'avez pas la permission d'exécuter cette commande."
|
||||
kickmessage: "&cLe serveur est actuellement en maintenance!%NEWLINE%&cRéessayez plus tard!"
|
||||
kickmessage: "&cLe serveur est actuellement en maintenance !%NEWLINE%&cRéessayez plus tard !"
|
||||
maintenanceActivated: "&8[&eMaintenance&8] &6Le mode maintenance est maintenant activé."
|
||||
maintenanceDeactivated: "&8[&eMaintenance&8] &6Le mode maintenance est maintenant désactivé."
|
||||
alreadyEnabled: "&8[&eMaintenance&8] &cLa maintenance est déjà activée!"
|
||||
alreadyDisabled: "&8[&eMaintenance&8] &cLa maintenance est déjà désactivée!"
|
||||
helpPageNotFound: "&8[&eMaintenance&8] &cIl n'y a pas cette page!"
|
||||
alreadyEnabled: "&8[&eMaintenance&8] &cLa maintenance est déjà activée !"
|
||||
alreadyDisabled: "&8[&eMaintenance&8] &cLa maintenance est déjà désactivée !"
|
||||
endtimerBroadcast: "&8[&eMaintenance&8] &7Le mode maintenance sera désactivé dans &6%TIME%&7."
|
||||
endtimerStarted: "&8[&eMaintenance&8] &aminuterie: &7Le mode maintenance sera désactivé dans &6%TIME%&7."
|
||||
starttimerBroadcast: "&8[&eMaintenance&8] &7MLe mode de maintenance sera activé dans &6%TIME%&7."
|
||||
starttimerStarted: "&8[&eMaintenance&8] &aminuterie: &7Le mode maintenance sera activé dans &6%TIME%&7."
|
||||
timerAlreadyRunning: "&8[&eMaintenance&8] &cIl y a déjà un horaire prévu!"
|
||||
endtimerStarted: "&8[&eMaintenance&8] &aMinuterie : &7Le mode maintenance sera désactivé dans &6%TIME%&7."
|
||||
starttimerBroadcast: "&8[&eMaintenance&8] &7Le mode de maintenance sera activé dans &6%TIME%&7."
|
||||
starttimerStarted: "&8[&eMaintenance&8] &aMinuterie : &7Le mode maintenance sera activé dans &6%TIME%&7."
|
||||
scheduletimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode will be enabled in &6%TIME% &7and will last for &6%DURATION%&7."
|
||||
timerAlreadyRunning: "&8[&eMaintenance&8] &cIl y a déjà un horaire prévu !"
|
||||
timerNotRunning: "&8[&eMaintenance&8] &cIl n'y a actuellement aucune maintenance prévue."
|
||||
timerCancelled: "&8[&eMaintenance&8] &cLa minuterie actuelle a été désactivée."
|
||||
timerTooLong: "&8[&eMaintenance&8] &cLe nombre doit être inférieur à 40320 (28 jours)!"
|
||||
joinNotification: "&8[&eMaintenance&8] &e%PLAYER% &ca essayé de rejoindre le serveur."
|
||||
motdList: "&8[&eMaintenance&8] &7Liste de vos motd pour la maintenance:"
|
||||
reload: "&8[&eMaintenance&8] &afichier config, liste blanche (whitelist) joueurs, fichier de langue et l'icône de maintenance, recharger."
|
||||
timerTooLong: "&8[&eMaintenance&8] &cLe nombre doit être inférieur à 40320 (28 jours) !"
|
||||
timerMotdDisabled: "&8[&eMaintenance&8] &cVous devez définir 'enable-timerspecific-messages' sur 'true' au sein de la configuration si vous souhaitez utiliser / éditer des motds spécifiques au timer."
|
||||
motdTimer: "%HOURS%:%MINUTES%:%SECONDS%"
|
||||
motdTimerNotRunning: "-"
|
||||
joinNotification: "&8[&eMaintenance&8] &e%PLAYER% &ca essayé de rejoindre le serveur !"
|
||||
motdList: "&8[&eMaintenance&8] &7Liste de vos motds pour la maintenance :"
|
||||
motdListEmpty: "8[&eMaintenance&8] &cVous n'avez pas de motds d'entretien fixés !"
|
||||
reload: "&8[&eMaintenance&8] &aFichier de configuration, liste blanche (whitelist) des joueurs autorisés, fichier de langue et icône de maintenance rechargés avec succès."
|
||||
removedMotd: "&8[&eMaintenance&8] &aNuméro de motd supprimé %INDEX%."
|
||||
removeMotdError: "&8[&eMaintenance&8] &cVous n’avez qu’un motd, vous ne pouvez donc en supprimer!"
|
||||
setMotd: "&8[&eMaintenance&8] &aLigne fixe %LINE% du %INDEX%. maintenance motd à %MOTD%"
|
||||
setMotdIndexError: "&8[&eMaintenance&8] &cVous avez actuellement %MOTDS% vous devez donc choisir un nombre compris entre 1 et %NEWAMOUNT%."
|
||||
setMotdLineError: "&8[&eMaintenance&8] &cLe deuxième argument doit être le numéro de ligne (1 ou 2)!"
|
||||
removeMotdError: "&8[&eMaintenance&8] &cVous n’avez qu’un motd, vous ne pouvez donc pas en supprimer !"
|
||||
setMotd: "&8[&eMaintenance&8] &aLigne %LINE% du motd %INDEX%. fixée à %MOTD%"
|
||||
setMotdIndexError: "&8[&eMaintenance&8] &cVous avez actuellement %MOTDS% motd(s), vous devez donc choisir un nombre compris entre 1 et %NEWAMOUNT%."
|
||||
setMotdLineError: "&8[&eMaintenance&8] &cLe deuxième argument doit être le numéro de ligne (1 ou 2) !"
|
||||
updateDownloading: "&8[&eMaintenance&8] &c&lTéléchargement de la mise à jour..."
|
||||
updateFailed: "&8[&eMaintenance&8] &4&lLa mise à jour a échoué!"
|
||||
updateFinished: "&8[&eMaintenance&8] &a&lLa mise à jour a été réussie! Pour éviter les problèmes liés aux tâches et terminer la mise à jour, vous devez redémarrer le serveur!"
|
||||
whitelistedPlayers: "&8[&eMaintenance&8] &6Liste blanche des joueurs pour la maintenance:"
|
||||
updateFailed: "&8[&eMaintenance&8] &4&lLa mise à jour a échoué !"
|
||||
updateFinished: "&8[&eMaintenance&8] &a&lLa mise à jour a été réussie ! Pour éviter les problèmes liés aux tâches et terminer la mise à jour, vous devez redémarrer le serveur !"
|
||||
whitelistedPlayers: "&8[&eMaintenance&8] &6Liste blanche des joueurs pour la maintenance :"
|
||||
whitelistedPlayersFormat: "&8- &e%NAME% &8(&7%UUID%&8)"
|
||||
whitelistAdded: "&8[&eMaintenance&8] &aAdded &b%PLAYER% &aà la liste blanche de maintenance!"
|
||||
whitelistAlreadyAdded: "&8[&eMaintenance&8] &b%PLAYER% &cest déjà dans la liste blanche de maintenance!"
|
||||
whitelistRemoved: "&8[&eMaintenance&8] &aEnlevé &b%PLAYER% &ade la liste blanche de maintenance!"
|
||||
whitelistNotFound: "&8[&eMaintenance&8] &cCe joueur n'est pas dans la liste blanche de la maintenance!"
|
||||
whitelistEmpty: "&8[&eMaintenance&8] &cLa liste blanche de maintenance est vide! Utilisation &e/maintenance add <joueur/uuid> &cajouter quelqu'un!"
|
||||
playerNotFound: "&8[&eMaintenance&8] &cAucun joueur avec ce nom n'a joué sur ce serveur auparavant."
|
||||
playerNotFoundUuid: "&8[&eMaintenance&8] &cAucun joueur avec cet uuid n'a pu être trouvé."
|
||||
whitelistAdded: "&8[&eMaintenance&8] &b%PLAYER% &aa été ajouté la liste blanche de maintenance !"
|
||||
whitelistAlreadyAdded: "&8[&eMaintenance&8] &b%PLAYER% &cest déjà dans la liste blanche de maintenance !"
|
||||
whitelistRemoved: "&8[&eMaintenance&8] &b%PLAYER% &aa été retiré de la liste blanche de maintenance !"
|
||||
whitelistNotFound: "&8[&eMaintenance&8] &cCe joueur n'est pas dans la liste blanche de maintenance !"
|
||||
whitelistEmpty: "&8[&eMaintenance&8] &cLa liste blanche de maintenance est vide : Utilisation &e/maintenance add <joueur/uuid> &c afin d'ajouter quelqu'un !"
|
||||
playerNotFound: "&8[&eMaintenance&8] &cAucun joueur avec ce nom n'a auparavant joué sur ce serveur."
|
||||
playerNotFoundUuid: "&8[&eMaintenance&8] &cAucun joueur avec cet UUID n'a pu être trouvé."
|
||||
playerNotOnline: "&8[&eMaintenance&8] &cIl n'y a pas de joueur en ligne avec ce nom."
|
||||
invalidUuid: "&8[&eMaintenance&8] &cLe format de l'uuid est invalide!"
|
||||
invalidUuid: "&8[&eMaintenance&8] &cLe format de l'UUID est invalide !"
|
||||
|
||||
second: "second"
|
||||
seconds: "seconds"
|
||||
# Quelques messages pour la partie Bungee/Velocity, ignorez-les si vous utilisez le plugin sur Spigot/Sponge
|
||||
sentToWaitingServer: "&8[&eMaintenance&8] &cVous avez été redirigé(e) vers un serveur d'attente !"
|
||||
forceWaitingServer: "&8[&eMaintenance&8] &cVous ne pouvez pas quitter le serveur d'attente tant que la maintenance est activée !"
|
||||
serverNotFound: "&8[&eMaintenance&8] &cAucun serveur avec ce nom n'est enregistré sur le proxy !"
|
||||
|
||||
singleTimerAlreadyRunning: "&8[&eMaintenance&8] &cIl y a déjà un horaire prévu sur ce serveur !"
|
||||
singleTimerNotRunning: "&8[&eMaintenance&8] &cIl n'y a actuellement aucune maintenance prévue sur ce serveur."
|
||||
singleTimerCancelled: "&8[&eMaintenance&8] &cLa minuterie actuelle a été désactivée sur ce serveur."
|
||||
singleEndtimerBroadcast: "&8[&eMaintenance&8] &7La maintenance sur le serveur %SERVER% sera désactivée dans &6%TIME%&7."
|
||||
singleStarttimerBroadcast: "&8[&eMaintenance&8] &7La maintenance sur le serveur %SERVER% sera activée dans &6%TIME%&7."
|
||||
singleScheduletimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode on server %SERVER% will be enabled in &6%TIME% &7and will last for &6%DURATION%&7."
|
||||
singleMaintenanceKick: "&8[&eMaintenance&8] &cLe serveur %SERVER% est actuellement en maintenance ! Réessayez plus tard !"
|
||||
singleMaintenanceKickComplete: "&cLe serveur %SERVER% est en maintenance !%NEWLINE%&cVous pouvez essayer un autre serveur !"
|
||||
singleMaintenanceActivated: "&8[&eMaintenance&8] &6La maintenance est maintenant activée sur le serveur &e%SERVER%&6."
|
||||
singleMaintenanceDeactivated: "&8[&eMaintenance&8] &6La maintenance est maintenant désactivée sur le serveur &e%SERVER%&6."
|
||||
singleServerAlreadyEnabled: "&8[&eMaintenance&8] &cLa maintenance est déjà activée sur le serveur &e%SERVER%&c !"
|
||||
singleServerAlreadyDisabled: "&8[&eMaintenance&8] &cLa maintenance est déjà désactivée sur le serveur &e%SERVER%&c !"
|
||||
singleServerMaintenanceList: "&8[&eMaintenance&8] &7Serveurs proxy ayant la maintenance activée :"
|
||||
singleServerMaintenanceListEmpty: "&8[&eMaintenance&8] &7Il n'y a pas de serveurs proxy en maintenance."
|
||||
|
||||
second: "seconde"
|
||||
seconds: "secondes"
|
||||
minute: "minute"
|
||||
minutes: "minutes"
|
||||
hour: "heur"
|
||||
hours: "heurs"
|
||||
hour: "heure"
|
||||
hours: "heures"
|
||||
|
||||
# Quelques messages pour la partie Bungee, ignorez-les si vous utilisez le plugin sur Spigot
|
||||
serverNotFound: "&8[&eMaintenance&8] &cAucun serveur avec ce nom n'est enregistré sur le proxy!"
|
||||
singleTimerAlreadyRunning: "&8[&eMaintenance&8] &cIl y a déjà un horaire prévu sur ce server!"
|
||||
singleTimerNotRunning: "&8[&eMaintenance&8] &cIl n'y a actuellement aucune maintenance prévue sur ce server."
|
||||
singleTimerCancelled: "&8[&eMaintenance&8] &cLa minuterie actuelle a été désactivée sur ce server."
|
||||
singleEndtimerBroadcast: "&8[&eMaintenance&8] &7maintenance sur serveur %SERVER% sera désactivé dans &6%TIME%&7."
|
||||
singleStarttimerBroadcast: "&8[&eMaintenance&8] &7Maintenance sur le serveur %SERVER% sera activé dans &6%TIME%&7."
|
||||
singleMaintenanceKick: "&8[&eMaintenance&8] &cLe serveur %SERVER% est actuellement en maintenance! Réessayez plus tard!"
|
||||
singleMaintenanceKickComplete: "&cLe serveur %SERVER% est en maintenance!%NEWLINE%&cVous pouvez essayer un autre serveur!"
|
||||
singleMaintenanceActivated: "&8[&eMaintenance&8] &6La maintenance est maintenant activé sur le serveur &e%SERVER%&6."
|
||||
singleMaintenanceDeactivated: "&8[&eMaintenance&8] &6La maintenance est maintenant désactivé sur le serveur &e%SERVER%&6."
|
||||
singleServerAlreadyEnabled: "&8[&eMaintenance&8] &cLa maintenance est déjà activée sur le serveur &e%SERVER%&c!"
|
||||
singleServerAlreadyDisabled: "&8[&eMaintenance&8] &cLa maintenance est déjà désactivée sur le serveur &e%SERVER%&c!"
|
||||
singleServerMaintenanceList: "&8[&eMaintenance&8] &7Serveurs proxy avec maintenance activée:"
|
||||
singleServerMaintenanceListEmpty: "&8[&eMaintenance&8] &7Il n'y a pas de serveurs proxy en maintenance."
|
||||
helpHeader: "&8========[ &e%NAME% &8| &e%PAGE%/%MAX% &8]========"
|
||||
helpPageNotFound: "&8[&eMaintenance&8] &cIl n'y a pas cette page !"
|
||||
helpNextPage: "&7Utilisez &b/maintenance help %PAGE% &7pour accéder à la fenêtre d’aide suivante."
|
||||
helpAbortTimer: "&6/maintenance aborttimer &7(Si en cours d'exécution, le minuteur actuel sera abandonné)"
|
||||
helpEndtimer: "&6/maintenance endtimer <minutes> &7(Après le temps imparti en minutes, le mode maintenance sera désactivé)"
|
||||
helpStarttimer: "&6/maintenance starttimer <minutes> &7(Après le temps imparti en minutes, le mode maintenance sera activé)"
|
||||
helpDebug: "&6/maintenance debug &7(Enables some debug logging)"
|
||||
helpDump: "&6/maintenance dump &7(Enregistre certaines informations sur le serveur, utilisées pour les rapports de bug)"
|
||||
helpHelp: "&6/maintenance help [page] &7(Montre cette belle fenêtre d'aide)"
|
||||
helpMotd: "&6/maintenance motd [timer] &7(Répertorie les paramètres de maintenance actuellement définis. Si vous spécifiez 'timer', les mots de la minuterie seront affichés)"
|
||||
helpRemoveMotd: "&6/maintenance removemotd [timer] <index> &7(Supprime un motd de maintenance. Si vous utilisez 'timer' comme argument, un message ping spécifique au temporisateur sera supprimé)"
|
||||
helpSetMotd: "&6/maintenance setmotd [timer] <index> <1/2> <message> &7(Définit un motd pour le mode maintenance. Si vous utilisez 'timer' comme argument, un message ping spécifique à un temporisateur sera défini)"
|
||||
helpReload: "&6/maintenance reload &7(Recharge le fichier de configuration, la liste blanche, le fichier de langue et l'icône du serveur)"
|
||||
helpToggle: "&6/maintenance <on/off> &7(Active/désactive le mode maintenance)"
|
||||
helpUpdate: "&6/maintenance update &7(Télécharge la dernière version du plugin sur votre serveur)"
|
||||
helpWhitelist: "&6/maintenance whitelist &7(Affiche les joueurs de la liste blanche pour le mode maintenance)"
|
||||
helpWhitelistAdd: "&6/maintenance add <name/uuid> &7(Ajoute un joueur à la liste blanche de maintenance afin qu'il puisse rejoindre le serveur même si la maintenance est activée)"
|
||||
helpWhitelistRemove: "&6/maintenance remove <name/uuid> &7(Supprime un joueur de la liste blanche de maintenance)"
|
||||
|
||||
# Quelques messages pour la partie Bungee/Velocity, ignorez-les si vous utilisez le plugin sur Spigot/Sponge
|
||||
helpAbortSingleTimer: "&6/maintenance aborttimer [server] &7(Si en cours d'exécution, le minuteur actuel sera abandonné)"
|
||||
helpSingleEndtimer: "&6/maintenance endtimer [server] <minutes> &7(Après le temps imparti en minutes, le mode maintenance sera désactivé)"
|
||||
helpSingleStarttimer: "&6/maintenance starttimer [server] <minutes> &7(Après le temps imparti en minutes, le mode maintenance sera activé)"
|
||||
helpSingleScheduleTimer: "&6/maintenance scheduletimer [server] <timer minutes> <maintenance duration> &7(Après le temps imparti en minutes, le mode maintenance sera activé pour la durée spécifiée en minutes)"
|
||||
helpSingleToggle: "&6/maintenance <on/off> [server] &7(Active/désactive le mode maintenance)"
|
||||
helpStatus: "&6/maintenance status &7(Répertorie tous les serveurs mandatés actuellement en maintenance)"
|
||||
Loaded 100 of 139 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user