Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
0c524b227a | ||
|
|
35deabf5a3 | ||
|
|
694cbb729f | ||
|
|
57047c519e | ||
|
|
fc8018c530 | ||
|
|
73707e2c3a | ||
|
|
ac92851e3d | ||
|
|
4e29a98a32 | ||
|
|
54d1c90795 | ||
|
|
6780914550 | ||
|
|
5ab5d11aed | ||
|
|
94378ca1fa | ||
|
|
4c0c425ba0 | ||
|
|
efea58e665 | ||
|
|
e15a7dd0ed | ||
|
|
2f327b9ce9 | ||
|
|
38d0f9de6d | ||
|
|
75f7330cc3 | ||
|
|
25bf7a3747 | ||
|
|
f8f0a23ede | ||
|
|
b4d7ed59de | ||
|
|
f64d07c1e8 | ||
|
|
4dc31a4635 | ||
|
|
cb243e1c04 | ||
|
|
bb5bdfe0c7 | ||
|
|
be144df5de | ||
|
|
a6f68810fc | ||
|
|
3ac01c9f1b | ||
|
|
c9d496e251 | ||
|
|
be31fdeb0a | ||
|
|
1ced445742 | ||
|
|
e52fffbe75 | ||
|
|
25b4cfe3f2 | ||
|
|
bc8453a96e | ||
|
|
0379b0c62c | ||
|
|
cdf34b76b8 | ||
|
|
d3cc9eb989 | ||
|
|
3048483b0c | ||
|
|
f16a5800e5 | ||
|
|
672f1f0ff3 | ||
|
|
a3ddfbefe3 | ||
|
|
e548a9a94b | ||
|
|
80d3069ffb | ||
|
|
fad9824e4d | ||
|
|
2bb7e3023d | ||
|
|
105f76d8f4 | ||
|
|
8e7874b691 | ||
|
|
710a69543a | ||
|
|
8b180342d0 | ||
|
|
1a62c596cb | ||
|
|
2b8e2c90c3 | ||
|
|
dcb9c97d0a | ||
|
|
74ed8783a8 | ||
|
|
0d07e6aed3 | ||
|
|
49fa7a6ff7 | ||
|
|
f40df14d03 | ||
|
|
6bc63e3fde | ||
|
|
c0b6e8ff40 | ||
|
|
0a4a1ce0cf | ||
|
|
35fd75aebb | ||
|
|
59e8dc057a | ||
|
|
91cd767dd7 | ||
|
|
57ca1ff88c | ||
|
|
15dd00fdcc | ||
|
|
10b14de218 | ||
|
|
66899564e8 | ||
|
|
6e8d8319f7 | ||
|
|
3ad8be9d3e | ||
|
|
b7c175060d | ||
|
|
ba6043e654 | ||
|
|
4bfd3339a2 | ||
|
|
c03d8d45e0 | ||
|
|
b150db8047 | ||
|
|
197ff4f813 | ||
|
|
fc6a5f8747 | ||
|
|
a4a37b39e5 | ||
|
|
b057b88e26 | ||
|
|
2dd383a640 | ||
|
|
d6526ae64e | ||
|
|
8be8b831ba | ||
|
|
ff1ded1fda | ||
|
|
bcc77cf3e0 | ||
|
|
4213d0824f | ||
|
|
729722259a | ||
|
|
6c408d823a | ||
|
|
9b7ec9d8bf | ||
|
|
3cce54a62d | ||
|
|
40119254a7 | ||
|
|
4b33e69d11 | ||
|
|
90d08d651e | ||
|
|
11b73a05c8 | ||
|
|
b68c8dd0d8 | ||
|
|
8933caa51f | ||
|
|
e82b1f760a | ||
|
|
dc97079967 | ||
|
|
2e44decaa9 | ||
|
|
244f7efe21 | ||
|
|
d299db678d | ||
|
|
0e558af1f1 | ||
|
|
a6cd5978e3 | ||
|
|
24c893bb1d | ||
|
|
8a80446c8c | ||
|
|
a88cc02f9a | ||
|
|
df442063ea | ||
|
|
40c49ba3ee | ||
|
|
9135f817d1 | ||
|
|
07fc9894b1 | ||
|
|
930612b5bb | ||
|
|
29a87c831a | ||
|
|
722340140a | ||
|
|
96d4834f83 | ||
|
|
308b42948a | ||
|
|
8e304bb09d | ||
|
|
7f2c23e69e | ||
|
|
1d68c4fee0 | ||
|
|
3d808ea718 | ||
|
|
79f1933b9a | ||
|
|
4089e75f2d | ||
|
|
a2d4e12ca6 | ||
|
|
72e5d596fc | ||
|
|
4f2dea5036 | ||
|
|
915dc25284 | ||
|
|
13e4468e93 | ||
|
|
ca23f0d546 | ||
|
|
53c450170a | ||
|
|
348521cc3e | ||
|
|
f4ce887d24 | ||
|
|
5e176dc10e | ||
|
|
00cd9a8bb1 | ||
|
|
0166aeadb2 | ||
|
|
864c22c3ed | ||
|
|
910b88d663 | ||
|
|
4a56c28a0d | ||
|
|
1c13465bf4 | ||
|
|
f4d46f03aa | ||
|
|
5b3e3ef179 | ||
|
|
392b12e592 | ||
|
|
e99f7772e6 | ||
|
|
54d20e9e50 | ||
|
|
fd0e361474 | ||
|
|
551e38f882 | ||
|
|
d18f04c010 | ||
|
|
3b7f3043f1 | ||
|
|
faf2a8d083 | ||
|
|
42071e3bad | ||
|
|
978d32e947 | ||
|
|
fe670cb3e2 | ||
|
|
d2f4a7d9a5 | ||
|
|
b162ce1825 | ||
|
|
fbdcce3c3b | ||
|
|
2d939f095c | ||
|
|
034e2f2b98 | ||
|
|
f429ab0a60 | ||
|
|
5578d0879b | ||
|
|
8b1e6244ea | ||
|
|
49c7b9c775 | ||
|
|
da1c724464 | ||
|
|
de15150a04 | ||
|
|
0d1fb2b260 | ||
|
|
55d0779a33 | ||
|
|
8f41d464e1 | ||
|
|
1db2b6c934 | ||
|
|
aa58f76057 | ||
|
|
1def0a1061 | ||
|
|
3b4a66b04e | ||
|
|
7384b2e55c | ||
|
|
f8eaed445a | ||
|
|
dfef9190ca | ||
|
|
7ce61834c2 | ||
|
|
240a7ab242 | ||
|
|
b3de59bfba | ||
|
|
5d5de39845 | ||
|
|
59af774d09 | ||
|
|
18828207c0 | ||
|
|
5c67922996 | ||
|
|
af50a45e65 | ||
|
|
7ccd265a30 | ||
|
|
e76f22f071 | ||
|
|
3c03b719d2 | ||
|
|
cd71531766 | ||
|
|
282c116d02 | ||
|
|
820171916b | ||
|
|
136fbb0ba8 | ||
|
|
4f0c05c357 | ||
|
|
0377838a26 | ||
|
|
b72ff1b772 | ||
|
|
287488f1b6 | ||
|
|
9ffb67db1f | ||
|
|
a563c0a8a8 | ||
|
|
234086444f | ||
|
|
a93b0834a2 | ||
|
|
b5550dfe82 | ||
|
|
d99300ecac | ||
|
|
1c0688a172 | ||
|
|
ff3b117189 | ||
|
|
aaed1b32cd | ||
|
|
38c8e1d2c3 | ||
|
|
1e1792d132 | ||
|
|
b29462a5cb | ||
|
|
c9161ebe24 | ||
|
|
8441c6a8bf | ||
|
|
72c2ba77ee | ||
|
|
a097790b76 | ||
|
|
b7129e8aa8 | ||
|
|
ab9c2b8be1 | ||
|
|
a9a37b8fc8 | ||
|
|
d50cb67a26 | ||
|
|
5e42500308 | ||
|
|
50997a847f | ||
|
|
2305d85c01 | ||
|
|
33bbc35d88 | ||
|
|
28b3e100fb | ||
|
|
edae2d699b | ||
|
|
0cc477a769 | ||
|
|
53b84a999f | ||
|
|
49487c11ff | ||
|
|
0c4070b7a7 | ||
|
|
67909a4862 | ||
|
|
28ee563083 | ||
|
|
28b2b528c1 | ||
|
|
a53d9d0850 | ||
|
|
873a8812aa | ||
|
|
19ebc90963 | ||
|
|
dfbd1381de | ||
|
|
c9fe48a067 | ||
|
|
49b022b665 | ||
|
|
86be23ae5f | ||
|
|
420412978e | ||
|
|
25e2f4dae2 | ||
|
|
d767be96b5 | ||
|
|
6d73acca9b | ||
|
|
1f116374ad | ||
|
|
d0b7d96208 | ||
|
|
16285d7064 | ||
|
|
1f27084fe1 | ||
|
|
261aace0db | ||
|
|
344b910214 | ||
|
|
fbaa4896e1 | ||
|
|
2f93064f60 | ||
|
|
65b47c5e07 | ||
|
|
d70d01f2d3 | ||
|
|
769d7d3bcd | ||
|
|
a5f47688e0 | ||
|
|
7d2e6a25a4 | ||
|
|
69999b3b7a | ||
|
|
94d1bd4eb9 | ||
|
|
c18e8b7ab7 | ||
|
|
9f45187300 | ||
|
|
0c6ba8a9b7 | ||
|
|
1af69f2e8b | ||
|
|
a3b836b1c5 | ||
|
|
1eca6c81ad | ||
|
|
b9b4a78b5c | ||
|
|
fda23c5539 | ||
|
|
8297321971 | ||
|
|
cfeaf00f26 | ||
|
|
5ee1b32249 | ||
|
|
b69f0dc90e | ||
|
|
fe6cae4e47 | ||
|
|
b494b5c23c | ||
|
|
3bd3395128 | ||
|
|
3e3f63220d | ||
|
|
ccba0f042f | ||
|
|
abdd89259d | ||
|
|
256f203c48 | ||
|
|
205412b02c | ||
|
|
990289feb2 | ||
|
|
44b1ff1a1f | ||
|
|
f9e11bb9e5 | ||
|
|
eef1584b1c | ||
|
|
937dd84d1c | ||
|
|
80b9fe280b | ||
|
|
3892892792 | ||
|
|
519551e76c | ||
|
|
b30476ae3f | ||
|
|
9d417a12f1 | ||
|
|
fd5406b95d | ||
|
|
0ef59e557d | ||
|
|
15ed1db347 | ||
|
|
429d5b90d4 | ||
|
|
b3ab931aca | ||
|
|
21b42d0c72 | ||
|
|
7b1e1a27ba | ||
|
|
fb7b1e791f | ||
|
|
eecd59b387 | ||
|
|
ff7d8e0293 | ||
|
|
19c6d77a2c | ||
|
|
e002aa34e9 | ||
|
|
865e53a4a8 | ||
|
|
b8c652b7fb | ||
|
|
c4080f82dc | ||
|
|
1a33497e8f | ||
|
|
f8353b8eda | ||
|
|
4980ad54ec | ||
|
|
5363305411 | ||
|
|
6ff47619ad | ||
|
|
69315a3f74 | ||
|
|
8b1ddba672 | ||
|
|
bf63f0e209 | ||
|
|
450c923d24 | ||
|
|
9a922a6df5 | ||
|
|
08a5a9a021 | ||
|
|
61ad7d8533 | ||
|
|
52d2b3c096 | ||
|
|
b0a69cc048 | ||
|
|
74e445a62e | ||
|
|
91219202b2 | ||
|
|
a3545c83a0 | ||
|
|
31baf91e8f | ||
|
|
9a5f9d490e | ||
|
|
214cd53751 | ||
|
|
2be16882c7 | ||
|
|
75e2264b44 | ||
|
|
fd7a0eb6a5 | ||
|
|
177115f144 | ||
|
|
edbe31dc9c |
No files matched your search
@@ -0,0 +1,201 @@
|
||||
# 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.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 language updating with an unknown/self-translated language file
|
||||
* Fixed Velocity server autocompletion in the maintenance command
|
||||
---
|
||||
## 3.0.3 - September 17th 2019
|
||||
### Changed
|
||||
* Bungee/Velocity: Added `maintenance.singleserver.bypass.<server>` permission to give individual bypasses for proxied servers (`maintenance.bypass` will still bypass everything as the super-perm)
|
||||
* Added the messages of the help command into the language files
|
||||
* Added config option `kick-online-players` to disable the kicks when maintenance is enabled (new connections will still be blocked)... not sure why you'd want that, but you can :p
|
||||
* The language file will now be automatically updated as well, so no need to delete and recreate it anymore, yay!
|
||||
* Updated missing and new translations in French language file (thanks to Spigot user Zendrique)
|
||||
* Updated missing and new translations in Spanish language file (thanks to Spigot user Vixo_Ulises)
|
||||
### Fixed
|
||||
* Bungee/Velocity: Fixed the join-notifications being sent twice if both global and server maintenance are enabled, as well as when just a server has maintenance in some cases
|
||||
* Bungee: Fixed players being kicked *after* the initial connection and thus triggering a join and leave message before being kicked
|
||||
* Bungee: Fixed the kickmessage not being displayed in some cases
|
||||
* Paper: Fixed the playercount message not being displayed on Paper servers with ViaVersion
|
||||
* Paper: Fixed the motd not being changed at all on Paper servers with ProtocolSupport (-> ProtocolLib listener used, since ProtocolSupport does not fire Paper's ping event)
|
||||
* Fixed the config autoupdater when the config contained strings broken over multiple lines
|
||||
---
|
||||
## 3.0.2 - May 17th 2019
|
||||
### Changed
|
||||
* Added config option `timerspecific-pingmessages` to have specific pingmessages shown when endtimers are run
|
||||
* You can also set them ingame by using `/maintenance setmotd timer <index> ...` instead of `/maintenance setmotd <index> ...`, along with `/maintenance removemotd timer <index>` and `/maintenance motd timer`
|
||||
* Made dumps a little prettier
|
||||
* Support Sponge 8.0.0-SNAPSHOT
|
||||
* Support latest text/Velocity (now only supports Velocity builds from May 7th upwards)
|
||||
---
|
||||
## 3.0.1 - April 17th 2019
|
||||
### Changed
|
||||
* Created an addon to have PlaceholderAPI placeholders on Spigot when running the Maintenance plugin on Bungee (see [**here**](https://github.com/KennyTV/Maintenance/wiki/MaintenanceAddon))
|
||||
* Spigot version: If running on Paper 1.12.2 or higher, ProtocolLib will not be needed anymore
|
||||
* The universal jar now only includes Bungee and Spigot (whereas before Sponge and Velocity as well) and has been further minimized in size
|
||||
* To use the plugin on the other platforms, use the `MaintenanceSponge.jar` or `MaintenanceVelocity.jar` respectively
|
||||
* Added config option `continue-endtimer-after-restart` to have endtimers continued, even if the server restarts during its runtime
|
||||
* Added custom eventsystem to the API
|
||||
* Removed bStats metrics from Sponge module
|
||||
### Fixed
|
||||
* Actually fixed compatibility to other plugins using the same MySQL library (such as LuckPerms) in the Bungee version
|
||||
* Fixed an issue with executing the maintenance change with MySQL enabled on connected proxies
|
||||
* Fixed an occasional error on pings of non clients in the Spigot version
|
||||
* Fixed 1.13 clients on sub 1.13 servers not showing the playercountmessage in the Spigot version
|
||||
* Minor fixes/changes to Spanish and Portuguese language files
|
||||
---
|
||||
## 3.0 - February 17th 2019
|
||||
### Changed
|
||||
* This plugin now also supports the platforms Sponge and Velocity!
|
||||
* Added tabcompletion for maintenance commands on all platforms
|
||||
* This plugin now uses a custom config system, which means comments won't vanish after saving them and the different configs have been unified
|
||||
* You can now also add and remove (offline) players to/from the maintenance whitelist by using their uuid (i.e. `/maintenance add <uuid>`)
|
||||
* The %TIMER% variable can now also be used in the playercount-, playercounthover- and kickmessages
|
||||
* To make life easier for people running on Bungee without an extra permission plugin: the `maintenance.admin` permission gives access to all subcommands
|
||||
* Made bug reports a little easier with the new `/maintenance dump` command
|
||||
* Added a config option to disable update checks (not recommended)
|
||||
* Moved `kickmessage` field from config to language file and added its default translations
|
||||
* Changed permissions nodes for the Bungee part (`from: to`):
|
||||
* `maintenance.toggleserver`: `maintenance.singleserver.toggle`
|
||||
* `maintenance.servertimer`: `maintenance.singleserver.timer`
|
||||
* `maintenance.status`: `maintenance.singleserver.status`
|
||||
* The command `/maintenance timer abort` has been renamed to `/maintenance aborttimer`
|
||||
* Added additional aliases: `/maintenance end` for `/maintenance endtimer`, `start` for `starttimer`, `abort` for `aborttimer`
|
||||
* On false command syntax usage, the reply will be the specific help message for that command, not the entire help window as it was before
|
||||
* Improved update checks and updater
|
||||
* Many many other runtime improvements and some major internal refactoring
|
||||
### Fixed
|
||||
* Fixed a startup issue with other plugins using the same MySQL library on Bungee (for example some versions of LuckPerms)
|
||||
* Fixed an error on Bungee when single servers are set to maintenance with no fallbackserver set
|
||||
* Fixed a rare problem with adding and removing players to/from the maintenance whitelist
|
||||
* Fixed an issue with starting server timers while also running a global maintenance timer
|
||||
* Fixed the `/maintenance status` not appearing in the help overview
|
||||
---
|
||||
## 2.5.2 - December 17th 2018
|
||||
### Changed
|
||||
* Added French `fr` (thanks to Zendrique) and Portuguese `pt` (thanks to JoaoPinto) translations!
|
||||
* Improvements to MySQL stuff on the Bungee part
|
||||
* If enabled, single servers (on the Bungee part) that are under maintenance are now saved into the given database as well!
|
||||
### Fixed
|
||||
* Fixed the maintenance value only loading on the first server ping, not on startup
|
||||
* Fixed an error while setting maintenance to single servers, when the executor is something other than a player
|
||||
* Fixed the maintenance-icon not loading on 1.13+ Spigot servers with ProtocolLib
|
||||
* Some other general improvements and a small message fix
|
||||
---
|
||||
## 2.5.1 - November 17th 2018
|
||||
### Fixed
|
||||
* Fixed an occasional file loading error on startup
|
||||
---
|
||||
## 2.5 - November 17th 2018
|
||||
### Changed
|
||||
* Added the possibility on BungeeCord to also enable maintenance on Spigot servers managed by the proxy
|
||||
* `/maintenance <on/off> <servername>` will now set maintenance to a proxied Spigot server
|
||||
* `/maintenance <starttimer/endtimer> <server> <minutes>` works analog to the normal timer commands
|
||||
* `/maintenance status` shows proxied servers that have maintenance enabled
|
||||
* new permissions are `maintenance.toggleserver`, `maintenance.servertimer` and `maintenance.status`
|
||||
* Added a multiple-language-support system! It's currently not that big tho, with the only language added being de/German
|
||||
* If you like this plugin, know French or Spanish (or any other language that isn't yet supported by the plugin) and want to contribute a bit to it, translations of the default language.yml are greatly appreciated!
|
||||
* Note: There will be a new 'language-en.yml' file created, so if you changed any messages before, you have to do it again in the new file
|
||||
* Made the help message a little fancier
|
||||
* Some API changes
|
||||
### Fixed
|
||||
* Fixed a bug with starttimers not being able to start properly
|
||||
---
|
||||
## 2.4 - September 17th 2018
|
||||
### Changed
|
||||
* Edit nearly every message to your hearts content with the now introduced language.yml file!
|
||||
* Added `/maintenance removemotd <index>` command to remove a motd via an ingame command (if you have multiple ones)
|
||||
* You can now include the `%TIMER%` variable into your maintenance motd - **If using the maintenance endtimer**, it will display the time left until maintenance will be disabled!
|
||||
* Simply shows `-` if maintenance is on without any timer
|
||||
* A nice integration could be `&cExpected to come back in: &6%TIMER%`
|
||||
* You can now choose to show the normal playercount during maintenance instead of a custom message by changing the `enable-playercountmessage` value in the config
|
||||
* You can also include the playercount in a custom playercountmessage by using the 2 variables `%ONLINE%` and `%MAX%`
|
||||
* If there's a new update available, the update notification will no longer be sent on every single login, but rather just on the first one after startup
|
||||
* Removing players from the maintenance whitelist now accepts uncapitalized names
|
||||
---
|
||||
## 2.3.1 - August 17th 2018
|
||||
### Changed
|
||||
* When a string in the config is missing, the plugin doesn't cancel the current process and throws an error anymore, but rather gives a soft warning in the console and returns a backup string
|
||||
* If MySQL is enabled, the plugin will only make a database request at least x seconds after the last request, whereas you can define the value in the config under `mysql.update-interval`
|
||||
* Example: If a first player pings the server after startup, the value will be updated -> No update in the next x seconds even if a player pings -> After elapsed, as soon as the next player pings the server again
|
||||
* Especially helpful as well as recommended for servers with many players
|
||||
* Another improvement for MySQL support: After enabling maintenance on one proxy, the other connected ones will then also kick all non permitted players and switch their ServerListPlus state!
|
||||
* The `/maintenance` helppage now only shows the commands the player actually has permission to execute
|
||||
---
|
||||
## 2.3 - July 17th 2018
|
||||
### Changed
|
||||
* Added the possibility to have multiple pingmessages, of which one will be randomly chosen on each ping when maintenance is enabled (you can also just keep it at one)!
|
||||
* Added permissions per subcommand
|
||||
* `maintenance.command` required to use any of the commands
|
||||
* `maintenance.toggle` to use /maintenance <on/off>
|
||||
* `maintenance.reload` to use /maintenance reload
|
||||
* `maintenance.update` to use /maintenance <update/forceupdate>
|
||||
* `maintenance.timer` to use /maintenance <starttimer/endtimer> <minutes>
|
||||
* `maintenance.whitelist.add` to use /maintenance add <player>
|
||||
* `maintenance.whitelist.remove` to use /maintenance remove <player>
|
||||
* `maintenance.whitelist.list` to use /maintenance whitelist
|
||||
* `maintenance.setmotd` to use /maintenance setmotd <index> <1/2> <message>
|
||||
* `maintenance.motd` to use /maintenance motd
|
||||
* Added `/maintenance motd` command to list all set maintenance pingmessages
|
||||
* `/maintenance whitelist` now also shows the UUID connected to each name
|
||||
### Fixed
|
||||
* Reworked/fixed the `/maintenance setmotd` command
|
||||
* Some typo and description fixes
|
||||
---
|
||||
## 2.2.2 - June 17th 2018
|
||||
### Changed
|
||||
* Changed the loading of the maintenance icon to be more predictable: It will load directly on startup and can now be reloaded by using the `/maintenance reload` command as well
|
||||
* Changed the reload message to read the proper reload changes
|
||||
* Removed an obsolete config comment
|
||||
* You can now hook into the plugin with the integrated API
|
||||
---
|
||||
## 2.2.1 - April 17th 2018
|
||||
### Changed
|
||||
* Added `/maintenance setmotd <1/2> <message>` command to edit the maintenance mode motd via a command
|
||||
* The Bungee version of the plugin will now automatically create a MySQL table if it is enabled, so you won't have to manually create one anymore
|
||||
### Fixed
|
||||
* Fixed the ServerListPlus motd only changing on using the command, but not on the server startup
|
||||
* Fixed an error with canceling the start-/endtimer in the Bungee version
|
||||
* Fixed an error with removing players from the whitelist in the Spigot version
|
||||
---
|
||||
## 2.2 - March 17th 2018
|
||||
### Changed
|
||||
* Great update for the Spigot version of the plugin as well as performance improvements and bugfixes in both versions
|
||||
* If you have ProtocolLib installed, you can set a custom server icon while maintenance is enabled, also the playercount-message and the playercount-hover-message are now available (as it has already been in the Bungee version)!
|
||||
* In the BungeeCord version of the plugin, the `/maintenance remove <player>` command now also works for offline players
|
||||
* Removed the plugin's prefix from some messages
|
||||
* General performance improvements
|
||||
### Fixed
|
||||
* The Spigot version should be much more compatible with other motd-changing plugins, such as SexyMotd
|
||||
* Fixed some other issues with the ProtocolLib integration
|
||||
* Minor textfix for the updatemessage in the Spigot version
|
||||
---
|
||||
## 2.1 - February 17th 2018
|
||||
### Changed
|
||||
* Massive code cleanup for both the Bungee and Spigot version of the plugin
|
||||
* Minor performance improvements
|
||||
### Fixed
|
||||
* Fixed start- and endtimers not being cancelled properly
|
||||
* Fixed an error for the update command in the Spigot version
|
||||
* Fixed an error regarding the ServerListPlus integration in the Spigot version
|
||||
---
|
||||
## 2.0 - February 15th 2018
|
||||
### Changed
|
||||
* You can now put the plugin not only inside your Bungee plugins folder, but also your Spigot/Bukkit one! Both will have the same feautures, but simply on their own platform. However, the Spigot version doesn't have MySQL support (as you would normally use BungeeCord for connecting multiple Spigot/Bukkit servers) and you can't use playercount-message, besides this, it has all its main features.
|
||||
* On BungeeCord you can make your own custom messages for the playercount
|
||||
* On Spigot you will see `N/0` (N being the actual count). If you also have ProtocolLib on your server, `0/0` will be displayed.
|
||||
* As many of you asked me: Maintenance now supports the plugin ServerListPlus
|
||||
* Performance improvements
|
||||
### Fixed
|
||||
* Fixed some permission and message bugs
|
||||
* Fixed problems with adding and removing players from the maintenance whitelist
|
||||
* Fixed update checks
|
||||
@@ -0,0 +1,5 @@
|
||||
# Contribution
|
||||
As I'm just a random guy making this plugin as a fun side-project, it will never be "perfect".
|
||||
Any improvement is welcome, as long as it fits with the general style of code, that should become apparent when looking at some of the other classes. :)
|
||||
|
||||
Generally, the used formatting is the default formatting of IntelliJ (Ctrl+Alt+L).
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Report a bug to have it fixed
|
||||
|
||||
---
|
||||
|
||||
## Bug reproducibility
|
||||
**How does the problem occur/what are the steps to reproduce it?**
|
||||
|
||||
## Error
|
||||
**Is there an error? Save it via https://pastebin.com/ and link paste the link.**
|
||||
|
||||
## Server information
|
||||
**Type '/maintenance dump' and paste the given link here**
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
.metadata
|
||||
dependencies/
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.settings/
|
||||
.loadpath
|
||||
.recommenders
|
||||
.project
|
||||
.externalToolBuilders/
|
||||
*.launch
|
||||
*.pydevproject
|
||||
*.jar
|
||||
.cproject
|
||||
.classpath
|
||||
.factorypath
|
||||
.buildpath
|
||||
.target
|
||||
.tern-project
|
||||
.texlipse
|
||||
.springBeans
|
||||
.recommenders/
|
||||
.cache-main
|
||||
.scala_dependencies
|
||||
.worksheet
|
||||
*.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
Icon
|
||||
._*
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
*.class
|
||||
*.log
|
||||
*.ctxt
|
||||
.mtj.tmp/
|
||||
*.war
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
hs_err_pid*
|
||||
*.iml
|
||||
.idea
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.xml
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/mongoSettings.xml
|
||||
*.iws
|
||||
/out/
|
||||
.idea_modules/
|
||||
atlassian-ide-plugin.xml
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
!/.mvn/wrapper/maven-wrapper.jar
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
Desktop.ini
|
||||
$RECYCLE.BIN/
|
||||
*.cab
|
||||
*.msi
|
||||
*.msm
|
||||
*.msp
|
||||
*.lnk
|
||||
!MaintenanceAPI.jar
|
||||
@@ -0,0 +1,7 @@
|
||||
language: java
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
dist: trusty
|
||||
cache:
|
||||
directories:
|
||||
- '$HOME/.m2/repository'
|
||||
+674
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
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/>.
|
||||
|
||||
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>.
|
||||
Binary file not shown.
@@ -0,0 +1,37 @@
|
||||
# Maintenance
|
||||
[](https://github.com/KennyTV/Maintenance/releases)
|
||||
[](https://travis-ci.org/KennyTV/Maintenance)
|
||||
[](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.
|
||||
|
||||
Its features include:
|
||||
* A custom motd as well as server icon, that will be shown during maintenance
|
||||
* Start- and endtimers, which will enable/disable maintenance mode after the time is up
|
||||
* A '%TIMER%' variable usable in the pingmessage, to show the time until a running endtimer finishes (other variables and tricks are explained in the configuration file's comments)
|
||||
* A maintenance whitelist, to grant specific players the ability to join while you're working on your server
|
||||
* Nearly all messages are editable via the language file, given in a multitude of different languages
|
||||
* Features specifically for Bungee/Velocity
|
||||
* Only want to enable maintenance on a single server? You can also do so by using the `/maintenance <on/off> <servername>` command
|
||||
* Link multiple proxy instances through a MySQL database connection, so you don't have to change maintenance on each proxy by hand
|
||||
* Use PlaceholderAPI placeholders with the [**MaintenanceAddon**](https://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/) (out of order at the moment)
|
||||
* [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)
|
||||
|
||||
Other forum threads
|
||||
* [Spigot forums](https://www.spigotmc.org/resources/maintenance.40699/)
|
||||
* [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
|
||||
When modifying the project's code, do that 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)).
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
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.maintenance</groupId>
|
||||
<artifactId>maintenance-parent</artifactId>
|
||||
<version>3.0.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>maintenance-api</artifactId>
|
||||
<name>MaintenanceAPI</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.15-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spongepowered</groupId>
|
||||
<artifactId>spongeapi</artifactId>
|
||||
<version>7.1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import eu.kennytv.maintenance.api.event.manager.IEventManager;
|
||||
|
||||
/**
|
||||
* @author KennyTV
|
||||
* @since 2.1
|
||||
*/
|
||||
public interface IMaintenance {
|
||||
|
||||
/**
|
||||
* Enables/disables maintenance mode.
|
||||
* If enabled, all non-permitted players will be kicked.
|
||||
* <p>
|
||||
* If using the BungeeCord version and MySQL is enabled,
|
||||
* it will also be written into the database.
|
||||
* </p>
|
||||
*
|
||||
* @param maintenance true to enable, false to disable maintenance mode
|
||||
*/
|
||||
void setMaintenance(boolean maintenance);
|
||||
|
||||
/**
|
||||
* @return true if maintenance is currently enabled
|
||||
*/
|
||||
boolean isMaintenance();
|
||||
|
||||
/**
|
||||
* @return true if a start- or endtimer task is currently running
|
||||
*/
|
||||
boolean isTaskRunning();
|
||||
|
||||
/**
|
||||
* @return version of the plugin
|
||||
*/
|
||||
String getVersion();
|
||||
|
||||
/**
|
||||
* Returns the {@link ISettings} instance, which gives further insight into settings set in the config files.
|
||||
*
|
||||
* @return {@link ISettings} instance
|
||||
*/
|
||||
ISettings getSettings();
|
||||
|
||||
/**
|
||||
* Returns the {@link IEventManager} instance to register listeners to maintenance events.
|
||||
*
|
||||
* @return {@link IEventManager} instance
|
||||
*/
|
||||
IEventManager getEventManager();
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
/**
|
||||
* @author KennyTV
|
||||
* @since 2.2.2
|
||||
*/
|
||||
public interface IMaintenanceBase {
|
||||
|
||||
/**
|
||||
* This method is used internally when getting the api instance.
|
||||
*
|
||||
* @return {@link IMaintenance} instance
|
||||
*/
|
||||
IMaintenance getApi();
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author KennyTV
|
||||
* @since 2.1
|
||||
*/
|
||||
public interface ISettings {
|
||||
|
||||
/**
|
||||
* Note that the value might need a few seconds to update, if you're on BungeeCord with MySQL enabled
|
||||
*
|
||||
* @return true if maintenance is currently enabled
|
||||
*/
|
||||
boolean isMaintenance();
|
||||
|
||||
/**
|
||||
* @return value of the 'send-join-notification' config field
|
||||
*/
|
||||
boolean isJoinNotifications();
|
||||
|
||||
/**
|
||||
* @return value of the 'custom-maintenance-icon' config field
|
||||
*/
|
||||
boolean hasCustomIcon();
|
||||
|
||||
/**
|
||||
* Returns a map of the currently maintenance-whitelisted players as their uuid mapped to their saved name.
|
||||
* Note that the names might be incorrect/outdated.
|
||||
*
|
||||
* @return map of uuids of whitelisted players with their given names
|
||||
*/
|
||||
Map<UUID, String> getWhitelistedPlayers();
|
||||
|
||||
/**
|
||||
* Returns whether the uuid is whitelisted.
|
||||
*
|
||||
* @param uuid uuid of the player to check
|
||||
* @return true if the uuid is whitelisted
|
||||
*/
|
||||
boolean isWhitelisted(UUID uuid);
|
||||
|
||||
/**
|
||||
* Removes a player from the maintenance whitelist.
|
||||
*
|
||||
* @param uuid uuid of the player to remove
|
||||
* @return true if removing the player was successful
|
||||
*/
|
||||
boolean removeWhitelistedPlayer(UUID uuid);
|
||||
|
||||
/**
|
||||
* Removes a player from the maintenance whitelist.
|
||||
*
|
||||
* @param name name of the player to remove with original lower-/uppercase letters
|
||||
* @return true if removing the player was successful
|
||||
* @deprecated if a player changes their name, the list will still contain the old one
|
||||
* @see #removeWhitelistedPlayer(UUID)
|
||||
*/
|
||||
@Deprecated
|
||||
boolean removeWhitelistedPlayer(String name);
|
||||
|
||||
/**
|
||||
* Adds a player to the maintenance whitelist.
|
||||
*
|
||||
* @param uuid uuid of the player to add
|
||||
* @param name of the player to add
|
||||
* @return true if adding the player was successful
|
||||
*/
|
||||
boolean addWhitelistedPlayer(UUID uuid, String name);
|
||||
|
||||
/**
|
||||
* Reloads maintenance-icon, config, language file and WhitelistedPlayers.
|
||||
*/
|
||||
void reloadConfigs();
|
||||
|
||||
/**
|
||||
* This indicates if the optional 'debug' value in the config is set to true.
|
||||
*
|
||||
* @return true if debug is enabled
|
||||
*/
|
||||
boolean debugEnabled();
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.api.bungee;
|
||||
|
||||
import eu.kennytv.maintenance.api.IMaintenanceBase;
|
||||
import eu.kennytv.maintenance.api.proxy.IMaintenanceProxy;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Utility class to get the {@link IMaintenanceProxy} instance for the BungeeCord version of the plugin.
|
||||
* <p>
|
||||
* Only access this class if you're running the plugin on a BungeeCord server!
|
||||
* </p>
|
||||
*
|
||||
* @author KennyTV
|
||||
* @since 2.5
|
||||
*/
|
||||
public final class MaintenanceBungeeAPI {
|
||||
|
||||
/**
|
||||
* Returns API instance of the Maintenance plugin.
|
||||
*
|
||||
* @return {@link IMaintenanceProxy} instance
|
||||
* @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?");
|
||||
return (IMaintenanceProxy) ((IMaintenanceBase) maintenance).getApi();
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.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;
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.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);
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.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);
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.api.event.manager;
|
||||
|
||||
/**
|
||||
* Dummy interface representing a maintenance event.
|
||||
*
|
||||
* @author KennyTV
|
||||
* @since 3.0.1
|
||||
*/
|
||||
public interface MaintenanceEvent {
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return wrapped server object for the proxied server
|
||||
*/
|
||||
public Server getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if maintenance has been enabled on the server, false otherwise
|
||||
*/
|
||||
public boolean isMaintenance() {
|
||||
return maintenance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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.api.proxy;
|
||||
|
||||
import eu.kennytv.maintenance.api.IMaintenance;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author KennyTV
|
||||
* @since 3.0
|
||||
*/
|
||||
public interface IMaintenanceProxy extends IMaintenance {
|
||||
|
||||
/**
|
||||
* Enables/disables maintenance mode on a proxied server.
|
||||
* If enabled, all non-permitted players will be kicked.
|
||||
* If MySQL is enabled, it will also be written into the database.
|
||||
*
|
||||
* @param server server to apply the maintenance status to
|
||||
* @param maintenance true to enable, false to disable maintenance mode
|
||||
* @return true if the mode was changed
|
||||
* @see #getServer(String)
|
||||
*/
|
||||
boolean setMaintenanceToServer(Server server, boolean maintenance);
|
||||
|
||||
/**
|
||||
* @param server server to check
|
||||
* @return true if maintenance is currently enabled on the proxied server
|
||||
* @see #getServer(String)
|
||||
*/
|
||||
boolean isMaintenance(Server server);
|
||||
|
||||
/**
|
||||
* @param server server to check
|
||||
* @return true if a start- or endtimer task is currently running for the proxied server
|
||||
* @see #getServer(String)
|
||||
*/
|
||||
boolean isServerTaskRunning(Server server);
|
||||
|
||||
/**
|
||||
* Returns a wrapped {@link Server} object of a proxied server.
|
||||
*
|
||||
* @param server name of the proxied server
|
||||
* @return wrapped server object if present, else null
|
||||
*/
|
||||
Server getServer(String server);
|
||||
|
||||
/**
|
||||
* @return immutable set with names of all proxied server that are currently under maintenance
|
||||
*/
|
||||
Set<String> getMaintenanceServers();
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.api.proxy;
|
||||
|
||||
/**
|
||||
* Wrapper for a proxied server.
|
||||
* Use {@link IMaintenanceProxy#getServer(String)} to get a server instance.
|
||||
*
|
||||
* @author KennyTV
|
||||
* @since 3.0
|
||||
*/
|
||||
public interface Server {
|
||||
|
||||
/**
|
||||
* @return name of the server
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* @return true if there are players on the server
|
||||
*/
|
||||
boolean hasPlayers();
|
||||
|
||||
/**
|
||||
* Sends a message to all players on the server.
|
||||
*
|
||||
* @param message message to be broadcasted
|
||||
*/
|
||||
void broadcast(String message);
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.api.spigot;
|
||||
|
||||
import eu.kennytv.maintenance.api.IMaintenance;
|
||||
import eu.kennytv.maintenance.api.IMaintenanceBase;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Utility class to get the {@link IMaintenance} instance for the Spigot version of the plugin.
|
||||
* <p>
|
||||
* Only access this class if you're running the plugin on a Spigot server!
|
||||
* </p>
|
||||
*
|
||||
* @author KennyTV
|
||||
* @since 2.5
|
||||
*/
|
||||
public final class MaintenanceSpigotAPI {
|
||||
|
||||
/**
|
||||
* Returns API instance of the Maintenance plugin.
|
||||
*
|
||||
* @return {@link IMaintenance} instance
|
||||
* @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?");
|
||||
return ((IMaintenanceBase) maintenance).getApi();
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.api.sponge;
|
||||
|
||||
import eu.kennytv.maintenance.api.IMaintenance;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.plugin.PluginContainer;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Utility class to get the {@link IMaintenance} instance for the Sponge version of the plugin.
|
||||
* <p>
|
||||
* Only access this class if you're running the plugin on a Sponge server!
|
||||
* </p>
|
||||
*
|
||||
* @author KennyTV
|
||||
* @since 3.0
|
||||
*/
|
||||
public final class MaintenanceSpongeAPI {
|
||||
|
||||
/**
|
||||
* Returns API instance of the Maintenance plugin.
|
||||
*
|
||||
* @return {@link IMaintenance} instance
|
||||
* @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?");
|
||||
return (IMaintenance) container.get().getInstance().get();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
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.maintenance</groupId>
|
||||
<artifactId>maintenance-parent</artifactId>
|
||||
<version>3.0.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>maintenance-build</artifactId>
|
||||
<name>Maintenance</name>
|
||||
|
||||
<dependencies>
|
||||
<!-- Also includes maintenance-core and maintenance-core-proxy modules -->
|
||||
<dependency>
|
||||
<groupId>eu.kennytv.maintenance</groupId>
|
||||
<artifactId>maintenance-bungee</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eu.kennytv.maintenance</groupId>
|
||||
<artifactId>maintenance-spigot</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>
|
||||
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
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.maintenance</groupId>
|
||||
<artifactId>maintenance-parent</artifactId>
|
||||
<version>3.0.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>maintenance-bungee</artifactId>
|
||||
<name>MaintenanceBungee</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<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.15-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>
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import eu.kennytv.maintenance.api.IMaintenance;
|
||||
import eu.kennytv.maintenance.api.IMaintenanceBase;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public final class MaintenanceBungeeBase extends Plugin implements IMaintenanceBase {
|
||||
private MaintenanceBungeePlugin maintenance;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
maintenance = new MaintenanceBungeePlugin(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
maintenance.disable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMaintenance getApi() {
|
||||
return maintenance;
|
||||
}
|
||||
|
||||
File getPluginFile() {
|
||||
return getFile();
|
||||
}
|
||||
}
|
||||
+247
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import eu.kennytv.maintenance.api.bungee.MaintenanceBungeeAPI;
|
||||
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.ProxyPingListener;
|
||||
import eu.kennytv.maintenance.bungee.listener.ServerConnectListener;
|
||||
import eu.kennytv.maintenance.bungee.metrics.MetricsLite;
|
||||
import eu.kennytv.maintenance.bungee.util.BungeeSenderInfo;
|
||||
import eu.kennytv.maintenance.bungee.util.BungeeServer;
|
||||
import eu.kennytv.maintenance.bungee.util.BungeeTask;
|
||||
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.util.SenderInfo;
|
||||
import eu.kennytv.maintenance.core.util.ServerType;
|
||||
import eu.kennytv.maintenance.core.util.Task;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.Favicon;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
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 net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.api.plugin.PluginManager;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author KennyTV
|
||||
* @since 1.0
|
||||
*/
|
||||
public final class MaintenanceBungeePlugin extends MaintenanceProxyPlugin {
|
||||
private final MaintenanceBungeeBase plugin;
|
||||
private Favicon favicon;
|
||||
|
||||
MaintenanceBungeePlugin(final MaintenanceBungeeBase plugin) {
|
||||
super(plugin.getDescription().getVersion(), ServerType.BUNGEE);
|
||||
this.plugin = plugin;
|
||||
|
||||
settingsProxy = new SettingsProxy(this);
|
||||
settings = settingsProxy;
|
||||
|
||||
sendEnableMessage();
|
||||
|
||||
final PluginManager pm = getProxy().getPluginManager();
|
||||
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());
|
||||
plugin.getLogger().info("Enabled ServerListPlus integration!");
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static IMaintenanceProxy getAPI() {
|
||||
return MaintenanceBungeeAPI.getAPI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendUpdateNotification(final SenderInfo sender) {
|
||||
final TextComponent tc1 = new TextComponent(TextComponent.fromLegacyText(getPrefix()));
|
||||
final TextComponent tc2 = new TextComponent(TextComponent.fromLegacyText("§cDownload it at: §6https://www.spigotmc.org/resources/maintenance.40699/"));
|
||||
final TextComponent click = new TextComponent(TextComponent.fromLegacyText(" §7§l§o(CLICK ME)"));
|
||||
click.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.spigotmc.org/resources/maintenance.40699/"));
|
||||
click.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§aDownload the latest version").create()));
|
||||
tc1.addExtra(tc2);
|
||||
tc1.addExtra(click);
|
||||
((BungeeSenderInfo) sender).sendMessage(tc1);
|
||||
}
|
||||
|
||||
public boolean isMaintenance(final ServerInfo serverInfo) {
|
||||
return settingsProxy.isMaintenance(serverInfo.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
final ServerInfo fallbackServer = fallback != null ? ((BungeeServer) fallback).getServer() : null;
|
||||
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.getMessage("singleMaintenanceKickComplete").replace("%NEWLINE%", "\n").replace("%SERVER%", server.getName()));
|
||||
} else {
|
||||
player.sendMessage(settingsProxy.getMessage("singleMaintenanceActivated").replace("%SERVER%", server.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void kickPlayersTo(final Server 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
|
||||
public Server getServer(final String server) {
|
||||
final ServerInfo serverInfo = getProxy().getServerInfo(server);
|
||||
return serverInfo != null ? new BungeeServer(serverInfo) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SenderInfo getOfflinePlayer(final String name) {
|
||||
final ProxiedPlayer player = getProxy().getPlayer(name);
|
||||
return player != null ? new BungeeSenderInfo(player) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
final ProxiedPlayer player = getProxy().getPlayer(sender.getUuid());
|
||||
if (player == null || player.getServer() == null) return null;
|
||||
return player.getServer().getInfo().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void async(final Runnable runnable) {
|
||||
getProxy().getScheduler().runAsync(plugin, runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcast(final String message) {
|
||||
getProxy().broadcast(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDataFolder() {
|
||||
return plugin.getDataFolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getPluginFile() {
|
||||
return plugin.getPluginFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getResource(final String name) {
|
||||
return plugin.getResourceAsStream(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return plugin.getLogger();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerVersion() {
|
||||
return getProxy().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PluginDump> getPlugins() {
|
||||
return getProxy().getPluginManager().getPlugins().stream().map(plugin ->
|
||||
new PluginDump(plugin.getDescription().getName(), plugin.getDescription().getVersion(), Arrays.asList(plugin.getDescription().getAuthor()))).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadIcon(final File file) throws IOException {
|
||||
favicon = Favicon.create(ImageIO.read(file));
|
||||
}
|
||||
|
||||
public boolean hasPermission(final CommandSender sender, final String permission) {
|
||||
return sender.hasPermission("maintenance." + permission) || sender.hasPermission("maintenance.admin");
|
||||
}
|
||||
|
||||
public ProxyServer getProxy() {
|
||||
return plugin.getProxy();
|
||||
}
|
||||
|
||||
public Favicon getFavicon() {
|
||||
return favicon;
|
||||
}
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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.command;
|
||||
|
||||
import eu.kennytv.maintenance.bungee.MaintenanceBungeePlugin;
|
||||
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.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.Map;
|
||||
|
||||
public final class MaintenanceBungeeCommand extends MaintenanceProxyCommand {
|
||||
private final MaintenanceBungeePlugin plugin;
|
||||
|
||||
public MaintenanceBungeeCommand(final MaintenanceBungeePlugin plugin, final SettingsProxy settings) {
|
||||
super(plugin, settings);
|
||||
this.plugin = plugin;
|
||||
registerCommands();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendUpdateMessage(final SenderInfo sender) {
|
||||
final TextComponent tc = new TextComponent("§6× §8[§aUpdate§8]");
|
||||
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/maintenance forceupdate"));
|
||||
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§aClick here to update the plugin")));
|
||||
tc.addExtra(" §8< §7Or use the command §c/maintenance forceupdate");
|
||||
((BungeeSenderInfo) sender).sendMessage(tc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getServersCompletion(final String s) {
|
||||
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
|
||||
public void sendDumpMessage(final SenderInfo sender, final String url) {
|
||||
final BungeeSenderInfo bungeeSender = ((BungeeSenderInfo) sender);
|
||||
final TextComponent clickText = new TextComponent(plugin.getPrefix() + "§7Click here to copy the link");
|
||||
clickText.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, url));
|
||||
clickText.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§aClick here to copy the link")));
|
||||
bungeeSender.sendMessage(clickText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPlayersCompletion() {
|
||||
final List<String> list = new ArrayList<>();
|
||||
for (final ProxiedPlayer p : plugin.getProxy().getPlayers()) {
|
||||
list.add(p.getName());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.command;
|
||||
|
||||
import eu.kennytv.maintenance.bungee.util.BungeeSenderInfo;
|
||||
import eu.kennytv.maintenance.core.command.MaintenanceCommand;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
import net.md_5.bungee.api.plugin.TabExecutor;
|
||||
|
||||
public final class MaintenanceBungeeCommandBase extends Command implements TabExecutor {
|
||||
private final MaintenanceCommand command;
|
||||
|
||||
public MaintenanceBungeeCommandBase(final MaintenanceCommand command) {
|
||||
super("maintenance", "", "maintenancebungee");
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final String[] args) {
|
||||
command.execute(new BungeeSenderInfo(sender), args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> onTabComplete(final CommandSender sender, final String[] args) {
|
||||
return command.getSuggestions(new BungeeSenderInfo(sender), args);
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.core.proxy.SettingsProxy;
|
||||
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;
|
||||
private final SettingsProxy settings;
|
||||
|
||||
public ProxyPingListener(final MaintenanceBungeePlugin plugin, final SettingsProxy settings) {
|
||||
this.plugin = plugin;
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void proxyPing(final ProxyPingEvent event) {
|
||||
if (!settings.isMaintenance()) return;
|
||||
|
||||
final ServerPing ping = event.getResponse();
|
||||
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.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)
|
||||
ping.setFavicon(plugin.getFavicon());
|
||||
}
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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.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.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 extends ProxyJoinListenerBase implements Listener {
|
||||
private final MaintenanceBungeePlugin plugin;
|
||||
|
||||
public ServerConnectListener(final MaintenanceBungeePlugin plugin, final SettingsProxy settings) {
|
||||
super(plugin, settings);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void initialServerConnect(final ServerConnectEvent event) {
|
||||
// Global maintenance check
|
||||
if (event.isCancelled() || event.getReason() != ServerConnectEvent.Reason.JOIN_PROXY) return;
|
||||
|
||||
final BungeeSenderInfo sender = new BungeeSenderInfo(event.getPlayer());
|
||||
if (shouldKick(sender)) {
|
||||
final Server waitingServer = shouldConnectToWaitingServer(sender);
|
||||
if (waitingServer != null) {
|
||||
event.setTarget(((BungeeServer) waitingServer).getServer());
|
||||
sender.sendMessage(settings.getMessage("sentToWaitingServer"));
|
||||
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 (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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+271
@@ -0,0 +1,271 @@
|
||||
package eu.kennytv.maintenance.bungee.metrics;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
import net.md_5.bungee.config.YamlConfiguration;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
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;
|
||||
private String serverUUID;
|
||||
private boolean logFailedRequests;
|
||||
private static boolean logSentData;
|
||||
private static boolean logResponseStatusText;
|
||||
private static final List<Object> knownMetricsInstances = new ArrayList<>();
|
||||
|
||||
public MetricsLite(final Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
try {
|
||||
loadConfig();
|
||||
} catch (final IOException e) {
|
||||
plugin.getLogger().log(Level.WARNING, "Failed to load bStats config!", e);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Class<?> usedMetricsClass = getFirstBStatsClass();
|
||||
if (usedMetricsClass == null) {
|
||||
return;
|
||||
}
|
||||
if (usedMetricsClass == getClass()) {
|
||||
linkMetrics(this);
|
||||
startSubmitting();
|
||||
} else {
|
||||
try {
|
||||
usedMetricsClass.getMethod("linkMetrics", Object.class).invoke(null, this);
|
||||
} catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||
if (logFailedRequests) {
|
||||
plugin.getLogger().log(Level.WARNING, "Failed to link to first metrics class " + usedMetricsClass.getName() + "!", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public static void linkMetrics(final Object metrics) {
|
||||
knownMetricsInstances.add(metrics);
|
||||
}
|
||||
|
||||
public JsonObject getPluginData() {
|
||||
final JsonObject data = new JsonObject();
|
||||
|
||||
final String pluginName = plugin.getDescription().getName();
|
||||
final String pluginVersion = plugin.getDescription().getVersion();
|
||||
|
||||
data.addProperty("pluginName", pluginName);
|
||||
data.addProperty("id", PLUGIN_ID);
|
||||
data.addProperty("pluginVersion", pluginVersion);
|
||||
|
||||
final JsonArray customCharts = new JsonArray();
|
||||
data.add("customCharts", customCharts);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private void startSubmitting() {
|
||||
plugin.getProxy().getScheduler().schedule(plugin, this::submitData, 2, 30, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
private JsonObject getServerData() {
|
||||
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();
|
||||
|
||||
final String javaVersion = System.getProperty("java.version");
|
||||
final String osName = System.getProperty("os.name");
|
||||
final String osArch = System.getProperty("os.arch");
|
||||
final String osVersion = System.getProperty("os.version");
|
||||
final int coreCount = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
final JsonObject data = new JsonObject();
|
||||
|
||||
data.addProperty("serverUUID", serverUUID);
|
||||
|
||||
data.addProperty("playerAmount", playerAmount);
|
||||
data.addProperty("managedServers", managedServers);
|
||||
data.addProperty("onlineMode", onlineMode);
|
||||
data.addProperty("bungeecordVersion", bungeecordVersion);
|
||||
|
||||
data.addProperty("javaVersion", javaVersion);
|
||||
data.addProperty("osName", osName);
|
||||
data.addProperty("osArch", osArch);
|
||||
data.addProperty("osVersion", osVersion);
|
||||
data.addProperty("coreCount", coreCount);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private void submitData() {
|
||||
final JsonObject data = getServerData();
|
||||
|
||||
final JsonArray pluginData = new JsonArray();
|
||||
for (final Object metrics : knownMetricsInstances) {
|
||||
try {
|
||||
final Object plugin = metrics.getClass().getMethod("getPluginData").invoke(metrics);
|
||||
if (plugin instanceof JsonObject) {
|
||||
pluginData.add((JsonObject) plugin);
|
||||
}
|
||||
} catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
data.add("plugins", pluginData);
|
||||
|
||||
try {
|
||||
sendData(plugin, data);
|
||||
} catch (final Exception e) {
|
||||
if (logFailedRequests) {
|
||||
plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats!", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadConfig() throws IOException {
|
||||
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.",
|
||||
"#To honor their work, you should not disable it.",
|
||||
"#This has nearly no effect on the server performance!",
|
||||
"#Check out https://bStats.org/ to learn more :)",
|
||||
"enabled: true",
|
||||
"serverUuid: \"" + UUID.randomUUID() + "\"",
|
||||
"logFailedRequests: false",
|
||||
"logSentData: false",
|
||||
"logResponseStatusText: false");
|
||||
}
|
||||
|
||||
final Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
|
||||
|
||||
enabled = configuration.getBoolean("enabled", true);
|
||||
serverUUID = configuration.getString("serverUuid");
|
||||
logFailedRequests = configuration.getBoolean("logFailedRequests", false);
|
||||
logSentData = configuration.getBoolean("logSentData", false);
|
||||
logResponseStatusText = configuration.getBoolean("logResponseStatusText", false);
|
||||
}
|
||||
|
||||
private Class<?> getFirstBStatsClass() {
|
||||
final Path configPath = plugin.getDataFolder().toPath().getParent().resolve("bStats");
|
||||
configPath.toFile().mkdirs();
|
||||
final File tempFile = new File(configPath.toFile(), "temp.txt");
|
||||
|
||||
try {
|
||||
final String className = readFile(tempFile);
|
||||
if (className != null) {
|
||||
try {
|
||||
return Class.forName(className);
|
||||
} catch (final ClassNotFoundException ignored) {
|
||||
}
|
||||
}
|
||||
writeFile(tempFile, getClass().getName());
|
||||
return getClass();
|
||||
} catch (final IOException e) {
|
||||
if (logFailedRequests) {
|
||||
plugin.getLogger().log(Level.WARNING, "Failed to get first bStats class!", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String readFile(final File file) throws IOException {
|
||||
if (!file.exists()) {
|
||||
return null;
|
||||
}
|
||||
try (final BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
|
||||
return bufferedReader.readLine();
|
||||
}
|
||||
}
|
||||
|
||||
private void writeFile(final File file, final String... lines) throws IOException {
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
try (final BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file))) {
|
||||
for (final String line : lines) {
|
||||
bufferedWriter.write(line);
|
||||
bufferedWriter.newLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void sendData(final Plugin plugin, final JsonObject data) throws Exception {
|
||||
if (data == null) {
|
||||
throw new IllegalArgumentException("Data cannot be null");
|
||||
}
|
||||
if (logSentData) {
|
||||
plugin.getLogger().info("Sending data to bStats: " + data);
|
||||
}
|
||||
|
||||
final HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection();
|
||||
|
||||
final byte[] compressedData = compress(data.toString());
|
||||
|
||||
connection.setRequestMethod("POST");
|
||||
connection.addRequestProperty("Accept", "application/json");
|
||||
connection.addRequestProperty("Connection", "close");
|
||||
connection.addRequestProperty("Content-Encoding", "gzip");
|
||||
connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length));
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
connection.setRequestProperty("User-Agent", "MC-Server/" + B_STATS_VERSION);
|
||||
|
||||
connection.setDoOutput(true);
|
||||
try (final DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) {
|
||||
outputStream.write(compressedData);
|
||||
}
|
||||
|
||||
if (logResponseStatusText) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
try (final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
builder.append(line);
|
||||
}
|
||||
}
|
||||
plugin.getLogger().info("Sent data to bStats and received response: " + builder);
|
||||
} else {
|
||||
connection.getInputStream().close();
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] compress(final String str) throws IOException {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
try (final GZIPOutputStream gzip = new GZIPOutputStream(outputStream)) {
|
||||
gzip.write(str.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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.util;
|
||||
|
||||
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 ProxySenderInfo {
|
||||
private final CommandSender sender;
|
||||
|
||||
public BungeeSenderInfo(final CommandSender sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
return sender instanceof ProxiedPlayer ? ((ProxiedPlayer) sender).getUniqueId() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return sender.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final String permission) {
|
||||
return sender.hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(final String message) {
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return sender instanceof ProxiedPlayer;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.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;
|
||||
|
||||
public BungeeServer(final ServerInfo server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return server.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPlayers() {
|
||||
return !server.getPlayers().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcast(final String message) {
|
||||
final BaseComponent[] s = TextComponent.fromLegacyText(message);
|
||||
for (final ProxiedPlayer p : server.getPlayers()) {
|
||||
p.sendMessage(s);
|
||||
}
|
||||
}
|
||||
|
||||
public ServerInfo getServer() {
|
||||
return server;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.util;
|
||||
|
||||
import eu.kennytv.maintenance.core.util.Task;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
||||
public final class BungeeTask implements Task {
|
||||
private final int id;
|
||||
|
||||
public BungeeTask(final int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
ProxyServer.getInstance().getScheduler().cancel(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
name: MaintenanceBungee
|
||||
version: ${project.version}
|
||||
main: eu.kennytv.maintenance.bungee.MaintenanceBungeeBase
|
||||
author: KennyTV
|
||||
description: Enable maintenance mode with a custom maintenance motd and icon.
|
||||
softDepends: [ServerListPlus]
|
||||
website: https://www.spigotmc.org/resources/maintenance.40699/
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
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.maintenance</groupId>
|
||||
<artifactId>maintenance-parent</artifactId>
|
||||
<version>3.0.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>maintenance-core-proxy</artifactId>
|
||||
<name>MaintenanceCoreProxy</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>eu.kennytv.maintenance</groupId>
|
||||
<artifactId>maintenance-core</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<version>3.4.2</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>
|
||||
</dependencies>
|
||||
</project>
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* 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.core.proxy;
|
||||
|
||||
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.runnable.MaintenanceRunnableBase;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import eu.kennytv.maintenance.core.util.ServerType;
|
||||
import eu.kennytv.maintenance.core.util.Task;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author KennyTV
|
||||
* @since 3.0
|
||||
*/
|
||||
public abstract class MaintenanceProxyPlugin extends MaintenancePlugin implements IMaintenanceProxy {
|
||||
private final Map<String, Task> serverTasks = new HashMap<>();
|
||||
protected SettingsProxy settingsProxy;
|
||||
|
||||
protected MaintenanceProxyPlugin(final String version, final ServerType serverType) {
|
||||
super(version, serverType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
super.disable();
|
||||
if (settingsProxy.getMySQL() != null) {
|
||||
settingsProxy.getMySQL().close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaintenance(final boolean maintenance) {
|
||||
if (settingsProxy.hasMySQL()) {
|
||||
settingsProxy.setMaintenanceToSQL(maintenance);
|
||||
}
|
||||
super.setMaintenance(maintenance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMaintenance(final Server server) {
|
||||
return settingsProxy.isMaintenance(server.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setMaintenanceToServer(final Server server, final boolean maintenance) {
|
||||
if (maintenance) {
|
||||
if (!settingsProxy.addMaintenanceServer(server.getName())) return false;
|
||||
} else {
|
||||
if (!settingsProxy.removeMaintenanceServer(server.getName())) return false;
|
||||
}
|
||||
serverActions(server, maintenance);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void serverActions(final Server server, final boolean maintenance) {
|
||||
if (server == null || 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);
|
||||
eventManager.callEvent(new ServerMaintenanceChangedEvent(server, maintenance));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isServerTaskRunning(final Server server) {
|
||||
return serverTasks.containsKey(server.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getMaintenanceServers() {
|
||||
return Collections.unmodifiableSet(settingsProxy.getMaintenanceServers());
|
||||
}
|
||||
|
||||
public void cancelSingleTask(final Server server) {
|
||||
final Task task = serverTasks.remove(server.getName());
|
||||
if (task != null)
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
public MaintenanceRunnableBase startSingleMaintenanceRunnable(final Server server, final int minutes, final boolean enable) {
|
||||
final MaintenanceRunnableBase runnable = new SingleMaintenanceRunnable(this, settingsProxy, minutes * 60, enable, server);
|
||||
serverTasks.put(server.getName(), runnable.getTask());
|
||||
return runnable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMaintenanceServersDump() {
|
||||
final List<String> list = new ArrayList<>();
|
||||
if (isMaintenance()) list.add("global");
|
||||
list.addAll(settingsProxy.getMaintenanceServers());
|
||||
return list.isEmpty() ? null : list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaintenanceProxyCommand getCommandManager() {
|
||||
return (MaintenanceProxyCommand) commandManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void kickPlayers() {
|
||||
// Send players to waiting server is set
|
||||
if (settingsProxy.getWaitingServer() != null) {
|
||||
final Server waitingServer = getServer(settingsProxy.getWaitingServer());
|
||||
if (waitingServer != null) {
|
||||
kickPlayersTo(waitingServer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If not set, kick players from proxy
|
||||
kickPlayersFromProxy();
|
||||
}
|
||||
|
||||
public SettingsProxy getSettingsProxy() {
|
||||
return settingsProxy;
|
||||
}
|
||||
|
||||
public abstract String getServer(SenderInfo sender);
|
||||
|
||||
protected abstract void kickPlayers(Server server, Server fallback);
|
||||
|
||||
protected abstract void kickPlayersTo(Server server);
|
||||
|
||||
protected abstract void kickPlayersFromProxy();
|
||||
}
|
||||
+233
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
* 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.core.proxy;
|
||||
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.core.config.ConfigSection;
|
||||
import eu.kennytv.maintenance.core.proxy.mysql.MySQL;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public final class SettingsProxy extends Settings {
|
||||
private Set<String> maintenanceServers;
|
||||
private String fallbackServer;
|
||||
private String waitingServer;
|
||||
|
||||
private String mySQLTable;
|
||||
private String serverTable;
|
||||
private String maintenanceQuery;
|
||||
private String serverQuery;
|
||||
private MySQL mySQL;
|
||||
|
||||
private long millisecondsToCheck;
|
||||
private long lastMySQLCheck;
|
||||
private long lastServerCheck;
|
||||
|
||||
public SettingsProxy(final MaintenanceProxyPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
private void setupMySQL() throws Exception {
|
||||
plugin.getLogger().info("Trying to open database connection... (also, you can simply ignore the SLF4J soft-warning if it shows up)");
|
||||
final ConfigSection section = config.getSection("mysql");
|
||||
if (section == null) {
|
||||
plugin.getLogger().warning("Section missing: mysql");
|
||||
return;
|
||||
}
|
||||
|
||||
mySQL = new MySQL(plugin.getLogger(),
|
||||
section.getString("host"),
|
||||
section.getInt("port"),
|
||||
section.getString("username"),
|
||||
section.getString("password"),
|
||||
section.getString("database"),
|
||||
section.getBoolean("use-ssl", true));
|
||||
|
||||
// Varchar as the value regarding the possibility of saving stuff like the motd as well in future updates
|
||||
mySQLTable = section.getString("table", "maintenance_settings");
|
||||
serverTable = section.getString("servertable", "maintenance_servers");
|
||||
mySQL.executeUpdate("CREATE TABLE IF NOT EXISTS " + mySQLTable + " (setting VARCHAR(16) PRIMARY KEY, value VARCHAR(255))");
|
||||
mySQL.executeUpdate("CREATE TABLE IF NOT EXISTS " + serverTable + " (server VARCHAR(64) PRIMARY KEY)");
|
||||
maintenanceQuery = "SELECT * FROM " + mySQLTable + " WHERE setting = ?";
|
||||
serverQuery = "SELECT * FROM " + serverTable;
|
||||
plugin.getLogger().info("Done!");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadExtraSettings() {
|
||||
// Open database connection if enabled and not already done
|
||||
if (!hasMySQL() && (boolean) config.getDeep("mysql.use-mysql")) {
|
||||
try {
|
||||
setupMySQL();
|
||||
} catch (final Exception e) {
|
||||
mySQL = null;
|
||||
plugin.getLogger().warning("Error while trying do open database connection!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
fallbackServer = config.getString("fallback", "lobby");
|
||||
waitingServer = config.getString("waiting-server", "");
|
||||
if (waitingServer.isEmpty() || waitingServer.equalsIgnoreCase("none")) {
|
||||
waitingServer = null;
|
||||
}
|
||||
|
||||
if (hasMySQL()) {
|
||||
maintenance = loadMaintenance();
|
||||
maintenanceServers = loadMaintenanceServersFromSQL();
|
||||
|
||||
final long configValue = config.getInt("mysql.update-interval");
|
||||
// Even if set to 0, only check every 500 millis
|
||||
millisecondsToCheck = configValue > 0 ? configValue * 1000 : 500;
|
||||
lastMySQLCheck = System.currentTimeMillis();
|
||||
lastServerCheck = System.currentTimeMillis();
|
||||
} else {
|
||||
final List<String> list = config.getStringList("proxied-maintenance-servers");
|
||||
maintenanceServers = list == null ? new HashSet<>() : new HashSet<>(list);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMaintenance() {
|
||||
if (hasMySQL() && System.currentTimeMillis() - lastMySQLCheck > millisecondsToCheck) {
|
||||
final boolean databaseValue = loadMaintenance();
|
||||
if (databaseValue != maintenance) {
|
||||
maintenance = databaseValue;
|
||||
plugin.serverActions(maintenance);
|
||||
}
|
||||
lastMySQLCheck = System.currentTimeMillis();
|
||||
}
|
||||
return maintenance;
|
||||
}
|
||||
|
||||
public boolean isMaintenance(final String serverName) {
|
||||
if (hasMySQL() && System.currentTimeMillis() - lastServerCheck > millisecondsToCheck) {
|
||||
final Set<String> databaseValue = loadMaintenanceServersFromSQL();
|
||||
if (!maintenanceServers.equals(databaseValue)) {
|
||||
final MaintenanceProxyPlugin plugin = (MaintenanceProxyPlugin) super.plugin;
|
||||
// Enable maintenance on yet unlisted servers
|
||||
for (final String s : databaseValue) {
|
||||
if (!maintenanceServers.contains(s))
|
||||
plugin.serverActions(plugin.getServer(s), true);
|
||||
}
|
||||
// Disable maintenance on now unlisted servers
|
||||
for (final String s : maintenanceServers) {
|
||||
if (!databaseValue.contains(s))
|
||||
plugin.serverActions(plugin.getServer(s), false);
|
||||
}
|
||||
maintenanceServers = databaseValue;
|
||||
}
|
||||
lastServerCheck = System.currentTimeMillis();
|
||||
}
|
||||
return maintenanceServers.contains(serverName);
|
||||
}
|
||||
|
||||
public boolean hasMySQL() {
|
||||
return mySQL != null;
|
||||
}
|
||||
|
||||
void setMaintenanceToSQL(final boolean maintenance) {
|
||||
plugin.async(() -> {
|
||||
final String s = String.valueOf(maintenance);
|
||||
mySQL.executeUpdate("INSERT INTO " + mySQLTable + " (setting, value) VALUES (?, ?) ON DUPLICATE KEY UPDATE value = ?", "maintenance", s, s);
|
||||
lastMySQLCheck = System.currentTimeMillis();
|
||||
});
|
||||
}
|
||||
|
||||
boolean addMaintenanceServer(final String server) {
|
||||
if (hasMySQL()) {
|
||||
maintenanceServers = loadMaintenanceServersFromSQL();
|
||||
if (!maintenanceServers.add(server)) return false;
|
||||
plugin.async(() -> mySQL.executeUpdate("INSERT INTO " + serverTable + " (server) VALUES (?)", server));
|
||||
lastServerCheck = System.currentTimeMillis();
|
||||
} else {
|
||||
if (!maintenanceServers.add(server)) return false;
|
||||
saveServersToConfig();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean removeMaintenanceServer(final String server) {
|
||||
if (hasMySQL()) {
|
||||
maintenanceServers = loadMaintenanceServersFromSQL();
|
||||
if (!maintenanceServers.remove(server)) return false;
|
||||
plugin.async(() -> mySQL.executeUpdate("DELETE FROM " + serverTable + " WHERE server = ?", server));
|
||||
lastServerCheck = System.currentTimeMillis();
|
||||
} else {
|
||||
if (!maintenanceServers.remove(server)) return false;
|
||||
saveServersToConfig();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Set<String> loadMaintenanceServersFromSQL() {
|
||||
final Set<String> maintenanceServers = new HashSet<>();
|
||||
mySQL.executeQuery(serverQuery, rs -> {
|
||||
try {
|
||||
while (rs.next()) {
|
||||
maintenanceServers.add(rs.getString("server"));
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
plugin.getLogger().warning("An error occured while trying to get the list of single servers with maintenance!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
return maintenanceServers;
|
||||
}
|
||||
|
||||
private boolean loadMaintenance() {
|
||||
final boolean[] databaseValue = {false};
|
||||
mySQL.executeQuery(maintenanceQuery, rs -> {
|
||||
try {
|
||||
if (rs.next()) {
|
||||
databaseValue[0] = Boolean.parseBoolean(rs.getString("value"));
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
plugin.getLogger().warning("An error occured while trying to get the maintenance value from the database!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, "maintenance");
|
||||
return databaseValue[0];
|
||||
}
|
||||
|
||||
private void saveServersToConfig() {
|
||||
config.set("proxied-maintenance-servers", new ArrayList<>(maintenanceServers));
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
public Set<String> getMaintenanceServers() {
|
||||
return maintenanceServers;
|
||||
}
|
||||
|
||||
public String getFallbackServer() {
|
||||
return fallbackServer;
|
||||
}
|
||||
|
||||
public String getWaitingServer() {
|
||||
return waitingServer;
|
||||
}
|
||||
|
||||
MySQL getMySQL() {
|
||||
return mySQL;
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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.core.proxy.command;
|
||||
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import eu.kennytv.maintenance.core.command.MaintenanceCommand;
|
||||
import eu.kennytv.maintenance.core.proxy.MaintenanceProxyPlugin;
|
||||
import eu.kennytv.maintenance.core.proxy.SettingsProxy;
|
||||
import eu.kennytv.maintenance.core.proxy.command.subcommand.*;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class MaintenanceProxyCommand extends MaintenanceCommand {
|
||||
private final MaintenanceProxyPlugin plugin;
|
||||
private final SettingsProxy settingsBungee;
|
||||
|
||||
protected MaintenanceProxyCommand(final MaintenanceProxyPlugin plugin, final SettingsProxy settings) {
|
||||
super(plugin, settings);
|
||||
this.plugin = plugin;
|
||||
settingsBungee = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addToggleAndTimerCommands() {
|
||||
add(new SingleToggleCommand(plugin), "on", "off");
|
||||
add(new StatusCommand(plugin), "status");
|
||||
|
||||
add(new SingleStarttimerCommand(plugin), "starttimer", "start");
|
||||
add(new SingleEndtimerCommand(plugin), "endtimer", "end");
|
||||
add(new AbortSingleTimerCommand(plugin), "aborttimer", "abort");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMaintenanceServersCompletion(final String s) {
|
||||
final List<String> list = new ArrayList<>();
|
||||
for (final String server : settingsBungee.getMaintenanceServers()) {
|
||||
if (server.toLowerCase().startsWith(s)) {
|
||||
list.add(server);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Server checkSingleTimerArgs(final SenderInfo sender, final String[] args) {
|
||||
final Server server = plugin.getServer(args[1]);
|
||||
if (server == null) {
|
||||
sender.sendMessage(settings.getMessage("serverNotFound"));
|
||||
return null;
|
||||
}
|
||||
if (plugin.isServerTaskRunning(server)) {
|
||||
sender.sendMessage(settings.getMessage("singleTimerAlreadyRunning"));
|
||||
return null;
|
||||
}
|
||||
return server;
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.core.proxy.command;
|
||||
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.proxy.MaintenanceProxyPlugin;
|
||||
import eu.kennytv.maintenance.core.proxy.SettingsProxy;
|
||||
|
||||
public abstract class ProxyCommandInfo extends CommandInfo {
|
||||
protected final MaintenanceProxyPlugin plugin;
|
||||
|
||||
protected ProxyCommandInfo(final MaintenanceProxyPlugin plugin, final String permission) {
|
||||
super(plugin, permission);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SettingsProxy getSettings() {
|
||||
return plugin.getSettingsProxy();
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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.core.proxy.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import eu.kennytv.maintenance.core.proxy.MaintenanceProxyPlugin;
|
||||
import eu.kennytv.maintenance.core.proxy.command.ProxyCommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class AbortSingleTimerCommand extends ProxyCommandInfo {
|
||||
|
||||
public AbortSingleTimerCommand(final MaintenanceProxyPlugin plugin) {
|
||||
super(plugin, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final SenderInfo sender) {
|
||||
return sender.hasMaintenancePermission("timer") || sender.hasPermission("maintenance.singleserver.timer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
if (checkPermission(sender, "timer")) return;
|
||||
if (!plugin.isTaskRunning()) {
|
||||
sender.sendMessage(getMessage("timerNotRunning"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.cancelTask();
|
||||
sender.sendMessage(getMessage("timerCancelled"));
|
||||
} else if (args.length == 2) {
|
||||
if (checkPermission(sender, "singleserver.timer")) return;
|
||||
final Server server = plugin.getServer(args[1]);
|
||||
if (server == null) {
|
||||
sender.sendMessage(getMessage("serverNotFound"));
|
||||
return;
|
||||
}
|
||||
if (!plugin.isServerTaskRunning(server)) {
|
||||
sender.sendMessage(getMessage("singleTimerNotRunning"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.cancelSingleTask(server);
|
||||
sender.sendMessage(getMessage("singleTimerCancelled"));
|
||||
} 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]) : Collections.emptyList();
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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.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;
|
||||
|
||||
public final class SingleEndtimerCommand extends ProxyCommandInfo {
|
||||
|
||||
public SingleEndtimerCommand(final MaintenanceProxyPlugin plugin) {
|
||||
super(plugin, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final SenderInfo sender) {
|
||||
return sender.hasMaintenancePermission("timer") || sender.hasPermission("maintenance.singleserver.timer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (args.length == 2) {
|
||||
if (checkPermission(sender, "timer")) return;
|
||||
if (plugin.getCommandManager().checkTimerArgs(sender, args[1])) {
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
if (!plugin.isMaintenance()) {
|
||||
sender.sendMessage(getMessage("alreadyDisabled"));
|
||||
return;
|
||||
}
|
||||
plugin.startMaintenanceRunnableForMinutes(Integer.parseInt(args[1]), 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(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
final Server server = plugin.getCommandManager().checkSingleTimerArgs(sender, args);
|
||||
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);
|
||||
sender.sendMessage(getMessage("endtimerStarted").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().getMaintenanceServersCompletion(args[1].toLowerCase()) : Collections.emptyList();
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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.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;
|
||||
|
||||
public final class SingleStarttimerCommand extends ProxyCommandInfo {
|
||||
|
||||
public SingleStarttimerCommand(final MaintenanceProxyPlugin plugin) {
|
||||
super(plugin, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final SenderInfo sender) {
|
||||
return sender.hasMaintenancePermission("timer") || sender.hasPermission("maintenance.singleserver.timer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (args.length == 2) {
|
||||
if (checkPermission(sender, "timer")) return;
|
||||
if (plugin.getCommandManager().checkTimerArgs(sender, args[1])) {
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
if (plugin.isMaintenance()) {
|
||||
sender.sendMessage(getMessage("alreadyEnabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.startMaintenanceRunnableForMinutes(Integer.parseInt(args[1]), 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(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
final Server server = plugin.getCommandManager().checkSingleTimerArgs(sender, args);
|
||||
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);
|
||||
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();
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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.core.proxy.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
import eu.kennytv.maintenance.core.proxy.MaintenanceProxyPlugin;
|
||||
import eu.kennytv.maintenance.core.proxy.command.ProxyCommandInfo;
|
||||
import eu.kennytv.maintenance.core.proxy.server.DummyServer;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class SingleToggleCommand extends ProxyCommandInfo {
|
||||
|
||||
public SingleToggleCommand(final MaintenanceProxyPlugin plugin) {
|
||||
super(plugin, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final SenderInfo sender) {
|
||||
return sender.hasMaintenancePermission("toggle") || sender.hasPermission("maintenance.singleserver.toggle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
if (checkPermission(sender, "toggle")) return;
|
||||
final boolean maintenance = args[0].equalsIgnoreCase("on");
|
||||
if (maintenance == plugin.isMaintenance()) {
|
||||
sender.sendMessage(getMessage(maintenance ? "alreadyEnabled" : "alreadyDisabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.setMaintenance(maintenance);
|
||||
} else if (args.length == 2) {
|
||||
if (checkPermission(sender, "singleserver.toggle")) return;
|
||||
final boolean maintenance = args[0].equalsIgnoreCase("on");
|
||||
Server server = plugin.getServer(args[1]);
|
||||
if (server == null) {
|
||||
if (maintenance) {
|
||||
sender.sendMessage(getMessage("serverNotFound"));
|
||||
return;
|
||||
}
|
||||
// Let servers be removed from the maintenance list, even if they don't exist on the proxy
|
||||
server = new DummyServer(args[1]);
|
||||
if (!plugin.isMaintenance(server)) {
|
||||
sender.sendMessage(getMessage("serverNotFound"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.setMaintenanceToServer(server, maintenance)) {
|
||||
if (!sender.isPlayer() || !server.getName().equals(plugin.getServer(sender))) {
|
||||
sender.sendMessage(getMessage(maintenance ? "singleMaintenanceActivated" : "singleMaintenanceDeactivated").replace("%SERVER%", server.getName()));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(getMessage(maintenance ? "singleServerAlreadyEnabled" : "singleServerAlreadyDisabled").replace("%SERVER%", server.getName()));
|
||||
}
|
||||
} else
|
||||
sender.sendMessage(getHelpMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletion(final SenderInfo sender, final String[] args) {
|
||||
if (args.length != 2 || !sender.hasMaintenancePermission("singleserver.toggle")) return Collections.emptyList();
|
||||
return args[0].equalsIgnoreCase("off") ? plugin.getCommandManager().getMaintenanceServersCompletion(args[1].toLowerCase())
|
||||
: plugin.getCommandManager().getServersCompletion(args[1].toLowerCase());
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.core.proxy.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.proxy.MaintenanceProxyPlugin;
|
||||
import eu.kennytv.maintenance.core.proxy.command.ProxyCommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
public final class StatusCommand extends ProxyCommandInfo {
|
||||
|
||||
public StatusCommand(final MaintenanceProxyPlugin plugin) {
|
||||
super(plugin, "singleserver.status");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (getSettings().getMaintenanceServers().isEmpty()) {
|
||||
sender.sendMessage(getMessage("singleServerMaintenanceListEmpty"));
|
||||
} else {
|
||||
sender.sendMessage(getMessage("singleServerMaintenanceList"));
|
||||
for (final String server : getSettings().getMaintenanceServers()) {
|
||||
sender.sendMessage("§8- §b" + server);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* 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.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;
|
||||
|
||||
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.getServer(sender);
|
||||
if (currentServer != null && currentServer.equals(waitingServer.getName())) {
|
||||
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.getMessage("singleMaintenanceKick").replace("%SERVER%", 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 = plugin.getServer(settings.getFallbackServer());
|
||||
if (fallback == null || !sender.canAccess(fallback) || plugin.isMaintenance(fallback)) {
|
||||
// Nothing to redirect to, player has to be kicked from the proxy
|
||||
sender.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;
|
||||
}
|
||||
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
|
||||
*/
|
||||
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);
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
package eu.kennytv.maintenance.core.proxy.mysql;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
|
||||
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 Logger logger, final String hostname, final int port, final String username, final String password, final String database, final boolean useSSL) {
|
||||
this.logger = logger;
|
||||
|
||||
final HikariConfig hikariConfig = new HikariConfig();
|
||||
hikariConfig.setMaximumPoolSize(10);
|
||||
hikariConfig.addDataSourceProperty("serverName", hostname);
|
||||
hikariConfig.addDataSourceProperty("user", username);
|
||||
hikariConfig.addDataSourceProperty("password", password);
|
||||
|
||||
String urlProperty = "jdbc:mysql://" + hostname + ":" + port + "/" + database;
|
||||
if (useSSL) {
|
||||
urlProperty += "?useSSL=false";
|
||||
}
|
||||
hikariConfig.addDataSourceProperty("url", urlProperty);
|
||||
|
||||
hikariConfig.setJdbcUrl(urlProperty);
|
||||
hikariConfig.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
|
||||
hikariDataSource = new HikariDataSource(hikariConfig);
|
||||
}
|
||||
|
||||
public void executeUpdate(final String query, final Consumer<Integer> callback, final Object... objects) {
|
||||
try (final Connection connection = hikariDataSource.getConnection()) {
|
||||
try (final PreparedStatement preparedStatement = connection.prepareStatement(query)) {
|
||||
int current = 1;
|
||||
for (final Object object : objects) {
|
||||
preparedStatement.setObject(current, object);
|
||||
current++;
|
||||
}
|
||||
|
||||
callback.accept(preparedStatement.executeUpdate());
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
logger.log(Level.SEVERE, "Error while executing update method: " + query);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void executeQuery(final String query, final Consumer<ResultSet> callback, final Object... objects) {
|
||||
try (final Connection connection = hikariDataSource.getConnection()) {
|
||||
try (final PreparedStatement preparedStatement = connection.prepareStatement(query)) {
|
||||
int current = 1;
|
||||
for (final Object object : objects) {
|
||||
preparedStatement.setObject(current, object);
|
||||
current++;
|
||||
}
|
||||
|
||||
final ResultSet resultSet = preparedStatement.executeQuery();
|
||||
callback.accept(resultSet);
|
||||
resultSet.close();
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
logger.log(Level.SEVERE, "Error while executing query method: " + query);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void executeUpdate(final String query, final Object... objects) {
|
||||
executeUpdate(query, res -> {
|
||||
}, objects);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
hikariDataSource.close();
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.core.proxy.runnable;
|
||||
|
||||
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.Settings;
|
||||
import eu.kennytv.maintenance.core.runnable.MaintenanceRunnableBase;
|
||||
|
||||
public final class SingleMaintenanceRunnable extends MaintenanceRunnableBase {
|
||||
private final Server server;
|
||||
|
||||
public SingleMaintenanceRunnable(final MaintenancePlugin plugin, final Settings settings, final int seconds, final boolean enable, final Server server) {
|
||||
super(plugin, settings, seconds, enable);
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void broadcast(final String message) {
|
||||
server.broadcast(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finish() {
|
||||
((IMaintenanceProxy) plugin).setMaintenanceToServer(server, enable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String startMessageKey() {
|
||||
return settings.getMessage("singleStarttimerBroadcast").replace("%TIME%", getTime()).replace("%SERVER%", server.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String endMessageKey() {
|
||||
return settings.getMessage("singleEndtimerBroadcast").replace("%TIME%", getTime()).replace("%SERVER%", server.getName());
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.core.proxy.server;
|
||||
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
|
||||
public final class DummyServer implements Server {
|
||||
private final String name;
|
||||
|
||||
public DummyServer(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPlayers() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcast(final String s) {
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.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);
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.core.proxy.util;
|
||||
|
||||
import eu.kennytv.maintenance.api.proxy.Server;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public Server getTarget() {
|
||||
return target;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
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.maintenance</groupId>
|
||||
<artifactId>maintenance-parent</artifactId>
|
||||
<version>3.0.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>maintenance-core</artifactId>
|
||||
<name>MaintenanceCore</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>eu.kennytv.maintenance</groupId>
|
||||
<artifactId>maintenance-api</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>1.23</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.minecrell</groupId>
|
||||
<artifactId>ServerListPlus</artifactId>
|
||||
<version>3.4.9-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>21.0</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>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package eu.kennytv.maintenance.core.util;
|
||||
|
||||
public final class MaintenanceVersion {
|
||||
|
||||
public static final String VERSION = "${project.version}";
|
||||
}
|
||||
@@ -0,0 +1,382 @@
|
||||
/*
|
||||
* 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.core;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.io.CharStreams;
|
||||
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.util.SenderInfo;
|
||||
import eu.kennytv.maintenance.core.util.ServerType;
|
||||
import eu.kennytv.maintenance.core.util.Task;
|
||||
import eu.kennytv.maintenance.core.util.Version;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
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 {
|
||||
protected final EventManager eventManager;
|
||||
protected final Version version;
|
||||
protected Settings settings;
|
||||
protected ServerListPlusHook serverListPlusHook;
|
||||
protected MaintenanceRunnable runnable;
|
||||
protected MaintenanceCommand commandManager;
|
||||
private final String prefix;
|
||||
private final ServerType serverType;
|
||||
private Version newestVersion;
|
||||
|
||||
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
|
||||
public void setMaintenance(final boolean maintenance) {
|
||||
settings.setMaintenance(maintenance);
|
||||
settings.getConfig().set("maintenance-enabled", maintenance);
|
||||
settings.saveConfig();
|
||||
serverActions(maintenance);
|
||||
}
|
||||
|
||||
public void serverActions(final boolean maintenance) {
|
||||
if (isTaskRunning()) {
|
||||
cancelTask();
|
||||
}
|
||||
if (serverListPlusHook != null) {
|
||||
serverListPlusHook.setEnabled(!maintenance);
|
||||
}
|
||||
|
||||
if (maintenance) {
|
||||
broadcast(settings.getMessage("maintenanceActivated"));
|
||||
if (settings.isKickOnlinePlayers()) {
|
||||
kickPlayers();
|
||||
}
|
||||
} else {
|
||||
broadcast(settings.getMessage("maintenanceDeactivated"));
|
||||
}
|
||||
|
||||
eventManager.callEvent(new MaintenanceChangedEvent(maintenance));
|
||||
}
|
||||
|
||||
public String formatedTimer(final String s) {
|
||||
return s.contains("%TIMER%") ? s.replace("%TIMER%", formatedTimer()) : s;
|
||||
}
|
||||
|
||||
public String formatedTimer() {
|
||||
if (!isTaskRunning()) return settings.getMessage("motdTimerNotRunning", "-");
|
||||
final int preHours = runnable.getSecondsLeft() / 60;
|
||||
final int minutes = preHours % 60;
|
||||
final int seconds = runnable.getSecondsLeft() % 60;
|
||||
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 startMaintenanceRunnableForMinutes(final int minutes, final boolean enable) {
|
||||
startMaintenanceRunnableForSeconds(minutes * 60, enable);
|
||||
}
|
||||
|
||||
public void startMaintenanceRunnableForSeconds(final int seconds, final boolean enable) {
|
||||
runnable = new MaintenanceRunnable(this, settings, seconds, 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 boolean updateAvailable() {
|
||||
checkNewestVersion();
|
||||
return version.compareTo(newestVersion) == -1;
|
||||
}
|
||||
|
||||
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 {
|
||||
final int seconds = (int) TimeUnit.MILLISECONDS.toSeconds(settings.getSavedEndtimer() - current);
|
||||
startMaintenanceRunnableForSeconds(seconds, false);
|
||||
getLogger().info("The timer has been continued - maintenance will be disabled in: " + formatedTimer());
|
||||
}
|
||||
}
|
||||
|
||||
protected void sendEnableMessage() {
|
||||
getLogger().info("Plugin by KennyTV");
|
||||
if (!settings.hasUpdateChecks()) return;
|
||||
async(() -> {
|
||||
checkNewestVersion();
|
||||
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://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!");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean installUpdate() {
|
||||
// Ore sad :(
|
||||
Preconditions.checkArgument(serverType != ServerType.SPONGE);
|
||||
try {
|
||||
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();
|
||||
if (newlength < 10000) {
|
||||
file.delete();
|
||||
return false;
|
||||
}
|
||||
|
||||
writeFile(new FileInputStream(file), new BufferedOutputStream(new FileOutputStream(getPluginFile())));
|
||||
file.delete();
|
||||
return true;
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void writeFile(final InputStream is, final OutputStream os) throws IOException {
|
||||
final byte[] chunk = new byte[1024];
|
||||
int chunkSize;
|
||||
while ((chunkSize = is.read(chunk)) != -1) {
|
||||
os.write(chunk, 0, chunkSize);
|
||||
}
|
||||
is.close();
|
||||
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()));
|
||||
final String newVersionString = reader.readLine();
|
||||
reader.close();
|
||||
final Version newVersion = new Version(newVersionString);
|
||||
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();
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("User-Agent", "Maintenance/" + getVersion());
|
||||
connection.setRequestProperty("Content-Type", "text/plain");
|
||||
|
||||
final GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
final OutputStream out = connection.getOutputStream();
|
||||
out.write(gsonBuilder.disableHtmlEscaping().setPrettyPrinting().create().toJson(dump).getBytes(StandardCharsets.UTF_8));
|
||||
out.close();
|
||||
|
||||
if (connection.getResponseCode() == 503) {
|
||||
getLogger().warning("Could not paste dump, hasteb.in down?");
|
||||
return null;
|
||||
}
|
||||
|
||||
final InputStream in = connection.getInputStream();
|
||||
final String output = CharStreams.toString(new InputStreamReader(in));
|
||||
in.close();
|
||||
|
||||
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();
|
||||
} catch (final IOException e) {
|
||||
getLogger().log(Level.WARNING, "Could not paste dump :(");
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void loadMaintenanceIcon() {
|
||||
final File file = new File(getDataFolder(), "maintenance-icon.png");
|
||||
if (!file.exists()) {
|
||||
getLogger().warning("Could not find a 'maintenance-icon.png' file - did you create one in the plugin's folder?");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
loadIcon(file);
|
||||
} catch (final Exception e) {
|
||||
getLogger().log(Level.WARNING, "Could not load the 'maintenance-icon.png' file!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void cancelTask() {
|
||||
if (settings.isSaveEndtimerOnStop() && !runnable.shouldEnable())
|
||||
settings.setSavedEndtimer(0);
|
||||
runnable.getTask().cancel();
|
||||
runnable = null;
|
||||
}
|
||||
|
||||
public UUID checkUUID(final SenderInfo sender, final String s) {
|
||||
final UUID uuid;
|
||||
try {
|
||||
uuid = UUID.fromString(s);
|
||||
} catch (final Exception e) {
|
||||
sender.sendMessage(settings.getMessage("invalidUuid"));
|
||||
return null;
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public String[] removeArrayIndex(final String[] args, final int index) {
|
||||
final List<String> argsList = Lists.newArrayList(args);
|
||||
argsList.remove(index);
|
||||
return argsList.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public boolean isNumeric(final String string) {
|
||||
return string.matches("[0-9]+");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMaintenance() {
|
||||
return settings.isMaintenance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTaskRunning() {
|
||||
return runnable != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Settings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEventManager getEventManager() {
|
||||
return eventManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return version.toString();
|
||||
}
|
||||
|
||||
public List<String> getMaintenanceServersDump() {
|
||||
return isMaintenance() ? Arrays.asList("global") : null;
|
||||
}
|
||||
|
||||
public int getSaltLevel() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public Version getNewestVersion() {
|
||||
return newestVersion;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public MaintenanceRunnable getRunnable() {
|
||||
return runnable;
|
||||
}
|
||||
|
||||
public MaintenanceCommand getCommandManager() {
|
||||
return commandManager;
|
||||
}
|
||||
|
||||
public ServerType getServerType() {
|
||||
return serverType;
|
||||
}
|
||||
|
||||
protected String getPluginFolder() {
|
||||
return "plugins/";
|
||||
}
|
||||
|
||||
public abstract void async(Runnable runnable);
|
||||
|
||||
public abstract void broadcast(String message);
|
||||
|
||||
public abstract void sendUpdateNotification(SenderInfo sender);
|
||||
|
||||
public abstract Task startMaintenanceRunnable(Runnable runnable);
|
||||
|
||||
public abstract SenderInfo getOfflinePlayer(String name);
|
||||
|
||||
public abstract SenderInfo getOfflinePlayer(UUID uuid);
|
||||
|
||||
public abstract File getDataFolder();
|
||||
|
||||
public abstract InputStream getResource(String name);
|
||||
|
||||
public abstract Logger getLogger();
|
||||
|
||||
public abstract String getServerVersion();
|
||||
|
||||
public abstract List<PluginDump> getPlugins();
|
||||
|
||||
protected abstract void loadIcon(File file) throws Exception;
|
||||
|
||||
protected abstract void kickPlayers();
|
||||
|
||||
protected abstract File getPluginFile();
|
||||
}
|
||||
@@ -0,0 +1,532 @@
|
||||
/*
|
||||
* 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.core;
|
||||
|
||||
import eu.kennytv.maintenance.api.ISettings;
|
||||
import eu.kennytv.maintenance.core.config.Config;
|
||||
import eu.kennytv.maintenance.core.config.ConfigSection;
|
||||
import eu.kennytv.maintenance.core.util.ServerType;
|
||||
|
||||
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;
|
||||
|
||||
public class Settings implements ISettings {
|
||||
private static final int CURRENT_CONFIG_VERSION = 4;
|
||||
private static final Random RANDOM = new Random();
|
||||
protected final MaintenancePlugin plugin;
|
||||
private final Map<UUID, String> whitelistedPlayers = new HashMap<>();
|
||||
private final String[] unsupportedFields;
|
||||
protected boolean maintenance;
|
||||
private Set<Integer> broadcastIntervals;
|
||||
private List<String> pingMessages;
|
||||
private List<String> timerSpecificPingMessages;
|
||||
private String playerCountMessage;
|
||||
private String playerCountHoverMessage;
|
||||
private String languageName;
|
||||
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;
|
||||
protected Config whitelist;
|
||||
|
||||
public Settings(final MaintenancePlugin plugin, final String... unsupportedFields) {
|
||||
this.plugin = plugin;
|
||||
this.unsupportedFields = unsupportedFields;
|
||||
if (!plugin.getDataFolder().exists())
|
||||
plugin.getDataFolder().mkdirs();
|
||||
|
||||
createFile("config.yml");
|
||||
createFile("WhitelistedPlayers.yml");
|
||||
|
||||
reloadConfigs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfigs() {
|
||||
try {
|
||||
config = new Config(new File(plugin.getDataFolder(), "config.yml"), unsupportedFields);
|
||||
config.load();
|
||||
config.resetAwesomeHeader();
|
||||
whitelist = new Config(new File(plugin.getDataFolder(), "WhitelistedPlayers.yml"));
|
||||
whitelist.load();
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException("Unable to load Maintenance files!", e);
|
||||
}
|
||||
|
||||
loadSettings();
|
||||
createLanguageFile();
|
||||
|
||||
try {
|
||||
language = new Config(new File(plugin.getDataFolder(), "language-" + languageName + ".yml"));
|
||||
language.load();
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException("Unable to load Maintenance language file!", e);
|
||||
}
|
||||
|
||||
updateLanguageFile();
|
||||
|
||||
// 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()));
|
||||
}
|
||||
}
|
||||
|
||||
public void saveConfig() {
|
||||
try {
|
||||
config.save();
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Public, as it is used in the MaintenanceAddon
|
||||
public void createFile(final String name) {
|
||||
createFile(name, name);
|
||||
}
|
||||
|
||||
private void createFile(final String name, final String from) {
|
||||
final File file = new File(plugin.getDataFolder(), name);
|
||||
if (!file.exists()) {
|
||||
try (final InputStream in = plugin.getResource(from)) {
|
||||
Files.copy(in, file.toPath());
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException("Unable to create " + name + " file for Maintenance!", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveWhitelistedPlayers() {
|
||||
try {
|
||||
whitelist.save();
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void createLanguageFile() {
|
||||
final String fileName = "language-" + languageName + ".yml";
|
||||
final File file = new File(plugin.getDataFolder(), fileName);
|
||||
if (file.exists()) return;
|
||||
|
||||
try (final InputStream in = plugin.getResource(fileName)) {
|
||||
Files.copy(in, file.toPath());
|
||||
} catch (final IOException e) {
|
||||
plugin.getLogger().warning("Unable to provide language " + languageName);
|
||||
// Fall back to English language (if not already selected)
|
||||
if (!languageName.equals("en")) {
|
||||
plugin.getLogger().warning("Falling back to default language: en");
|
||||
languageName = "en";
|
||||
createLanguageFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadSettings() {
|
||||
updateConfig();
|
||||
|
||||
pingMessages = config.getStringList("pingmessages");
|
||||
if (config.getBoolean("enable-timerspecific-messages")) {
|
||||
timerSpecificPingMessages = config.getStringList("timerspecific-pingmessages");
|
||||
}
|
||||
maintenance = config.getBoolean("maintenance-enabled");
|
||||
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) {
|
||||
playerCountMessage = getColoredString(getConfigString("playercountmessage"));
|
||||
}
|
||||
playerCountHoverMessage = 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();
|
||||
for (final Map.Entry<String, Object> entry : whitelist.getValues().entrySet()) {
|
||||
try {
|
||||
whitelistedPlayers.put(UUID.fromString(entry.getKey()), (String) entry.getValue());
|
||||
} catch (final Exception e) {
|
||||
plugin.getLogger().warning("invalid WhitelistedPlayers entry: " + entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
loadExtraSettings();
|
||||
}
|
||||
|
||||
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!");
|
||||
}
|
||||
}
|
||||
|
||||
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!");
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
saveConfig();
|
||||
plugin.getLogger().info("Done! Updated config!");
|
||||
}
|
||||
}
|
||||
|
||||
private void updateLanguageFile() {
|
||||
final String filePrefix = "language-" + languageName;
|
||||
try {
|
||||
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;
|
||||
}
|
||||
|
||||
final File file = new File(plugin.getDataFolder(), filePrefix + "-new.yml");
|
||||
final Config tempConfig = new Config(file);
|
||||
try {
|
||||
tempConfig.load();
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
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 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);
|
||||
try {
|
||||
oldConfig.load();
|
||||
} catch (final IOException e) {
|
||||
plugin.getLogger().log(Level.WARNING, "Error while trying to migrate old config file");
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
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"));
|
||||
for (final Map.Entry<String, Object> entry : config.getValues().entrySet()) {
|
||||
if (!oldConfig.contains(entry.getKey())) continue;
|
||||
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);
|
||||
try {
|
||||
oldFile.load();
|
||||
} catch (final IOException e) {
|
||||
plugin.getLogger().log(Level.WARNING, "Error while trying to migrate old SpigotServers file");
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private static final String ALL_CODES = "0123456789AaBbCcDdEeFfKkLlMmNnOoRr";
|
||||
|
||||
public String getColoredString(final String s) {
|
||||
// Method taken from Bungee
|
||||
final char[] b = s.toCharArray();
|
||||
for (int i = 0; i < b.length - 1; i++) {
|
||||
if (b[i] == '&' && ALL_CODES.indexOf(b[i + 1]) > -1) {
|
||||
b[i] = '§';
|
||||
b[i + 1] = Character.toLowerCase(b[i + 1]);
|
||||
}
|
||||
}
|
||||
return new String(b);
|
||||
}
|
||||
|
||||
public String getConfigString(final String path) {
|
||||
if (!config.contains(path)) {
|
||||
plugin.getLogger().warning("The config is missing the following string: " + path);
|
||||
return "null";
|
||||
}
|
||||
return config.getString(path);
|
||||
}
|
||||
|
||||
public String getMessage(final String path) {
|
||||
return getMessage(path, "null");
|
||||
}
|
||||
|
||||
public String getMessage(final String path, final String def) {
|
||||
if (!language.contains(path)) {
|
||||
plugin.getLogger().warning("The language file is missing the following string: " + path);
|
||||
return def;
|
||||
}
|
||||
return language.getString(path);
|
||||
}
|
||||
|
||||
public String getRandomPingMessage() {
|
||||
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(plugin.formatedTimer(s).replace("%NEWLINE%", "\n"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeWhitelistedPlayer(final UUID uuid) {
|
||||
if (!whitelistedPlayers.containsKey(uuid)) return false;
|
||||
whitelistedPlayers.remove(uuid);
|
||||
whitelist.remove(uuid.toString());
|
||||
saveWhitelistedPlayers();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean removeWhitelistedPlayer(final String name) {
|
||||
UUID uuid = null;
|
||||
for (final Map.Entry<UUID, String> e : whitelistedPlayers.entrySet()) {
|
||||
if (e.getValue().equalsIgnoreCase(name)) {
|
||||
uuid = e.getKey();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (uuid == null) return false;
|
||||
|
||||
whitelistedPlayers.remove(uuid);
|
||||
whitelist.remove(uuid.toString());
|
||||
saveWhitelistedPlayers();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addWhitelistedPlayer(final UUID uuid, final String name) {
|
||||
final boolean contains = !whitelistedPlayers.containsKey(uuid);
|
||||
whitelistedPlayers.put(uuid, name);
|
||||
whitelist.set(uuid.toString(), name);
|
||||
saveWhitelistedPlayers();
|
||||
return contains;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<UUID, String> getWhitelistedPlayers() {
|
||||
return whitelistedPlayers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWhitelisted(final UUID uuid) {
|
||||
return whitelistedPlayers.containsKey(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMaintenance() {
|
||||
return maintenance;
|
||||
}
|
||||
|
||||
public void setMaintenance(final boolean maintenance) {
|
||||
this.maintenance = maintenance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJoinNotifications() {
|
||||
return joinNotifications;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomIcon() {
|
||||
return customMaintenanceIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean debugEnabled() {
|
||||
return debug;
|
||||
}
|
||||
|
||||
public boolean hasUpdateChecks() {
|
||||
return updateChecks;
|
||||
}
|
||||
|
||||
public boolean isSaveEndtimerOnStop() {
|
||||
return saveEndtimerOnStop;
|
||||
}
|
||||
|
||||
public boolean hasTimerSpecificPingMessages() {
|
||||
return timerSpecificPingMessages != null;
|
||||
}
|
||||
|
||||
public boolean isKickOnlinePlayers() {
|
||||
return kickOnlinePlayers;
|
||||
}
|
||||
|
||||
public long getSavedEndtimer() {
|
||||
return savedEndtimer;
|
||||
}
|
||||
|
||||
public void setSavedEndtimer(final long millis) {
|
||||
if (savedEndtimer == millis) return;
|
||||
this.savedEndtimer = millis;
|
||||
config.getSection("continue-endtimer-after-restart").set("end", millis);
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
public Config getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public List<String> getPingMessages() {
|
||||
return pingMessages;
|
||||
}
|
||||
|
||||
/**
|
||||
* May be null
|
||||
*/
|
||||
public List<String> getTimerSpecificPingMessages() {
|
||||
return timerSpecificPingMessages;
|
||||
}
|
||||
|
||||
public Set<Integer> getBroadcastIntervals() {
|
||||
return broadcastIntervals;
|
||||
}
|
||||
|
||||
public String getPlayerCountMessage() {
|
||||
return plugin.formatedTimer(playerCountMessage);
|
||||
}
|
||||
|
||||
public String getPlayerCountHoverMessage() {
|
||||
return plugin.formatedTimer(playerCountHoverMessage);
|
||||
}
|
||||
|
||||
public String getKickMessage() {
|
||||
return plugin.formatedTimer(getMessage("kickmessage", "§cThe server is currently under maintenance!%NEWLINE%§cTry again later!").replace("%NEWLINE%", "\n"));
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return languageName;
|
||||
}
|
||||
|
||||
public boolean hasCustomPlayerCountMessage() {
|
||||
return customPlayerCountMessage;
|
||||
}
|
||||
|
||||
protected void loadExtraSettings() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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.core.command;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class CommandInfo {
|
||||
protected final MaintenancePlugin plugin;
|
||||
private final String helpMessageKey;
|
||||
private final String permission;
|
||||
|
||||
protected CommandInfo(final MaintenancePlugin plugin, final String permission) {
|
||||
this.plugin = plugin;
|
||||
this.permission = permission;
|
||||
// Just take the class name as the language key
|
||||
this.helpMessageKey = "help" + getClass().getSimpleName().replace("Command", "");
|
||||
}
|
||||
|
||||
public boolean hasPermission(final SenderInfo sender) {
|
||||
return sender.hasMaintenancePermission(permission);
|
||||
}
|
||||
|
||||
public String getHelpMessage() {
|
||||
return getMessage(helpMessageKey);
|
||||
}
|
||||
|
||||
public List<String> getTabCompletion(final SenderInfo sender, final String[] args) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public abstract void execute(SenderInfo sender, String[] args);
|
||||
|
||||
protected boolean checkPermission(final SenderInfo sender, final String permission) {
|
||||
if (!sender.hasMaintenancePermission(permission)) {
|
||||
sender.sendMessage(getMessage("noPermission"));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean checkArgs(final SenderInfo sender, final String[] args, final int length) {
|
||||
if (args.length != length) {
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected String getMessage(final String s) {
|
||||
return plugin.getSettings().getMessage(s);
|
||||
}
|
||||
|
||||
protected Settings getSettings() {
|
||||
return plugin.getSettings();
|
||||
}
|
||||
}
|
||||
+176
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* 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.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.util.SenderInfo;
|
||||
import eu.kennytv.maintenance.core.util.ServerType;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public abstract class MaintenanceCommand {
|
||||
protected final MaintenancePlugin plugin;
|
||||
protected final Settings settings;
|
||||
private final Map<String, CommandInfo> commandExecutors = new LinkedHashMap<>();
|
||||
private final List<CommandInfo> commands = new ArrayList<>();
|
||||
private final HelpCommand help;
|
||||
|
||||
protected MaintenanceCommand(final MaintenancePlugin plugin, final Settings settings) {
|
||||
this.plugin = plugin;
|
||||
this.settings = settings;
|
||||
help = new HelpCommand(plugin);
|
||||
}
|
||||
|
||||
protected void registerCommands() {
|
||||
add(help, "help");
|
||||
add(new ReloadCommand(plugin), "reload");
|
||||
|
||||
addToggleAndTimerCommands();
|
||||
|
||||
add(new WhitelistCommand(plugin), "whitelist");
|
||||
add(new WhitelistAddCommand(plugin), "add");
|
||||
add(new WhitelistRemoveCommand(plugin), "remove");
|
||||
|
||||
add(new SetMotdCommand(plugin), "setmotd");
|
||||
add(new RemoveMotdCommand(plugin), "removemotd");
|
||||
add(new MotdCommand(plugin), "motd");
|
||||
|
||||
add(new UpdateCommand(plugin), "update", "forceupdate");
|
||||
add(new DumpCommand(plugin), "dump");
|
||||
}
|
||||
|
||||
protected void add(final CommandInfo command, final String... aliases) {
|
||||
commands.add(command);
|
||||
for (final String alias : aliases) {
|
||||
commandExecutors.put(alias, command);
|
||||
}
|
||||
}
|
||||
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (!sender.hasMaintenancePermission("command")) {
|
||||
sender.sendMessage(settings.getMessage("noPermission"));
|
||||
return;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
help.sendUsage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
final CommandInfo command = commandExecutors.get(args[0].toLowerCase());
|
||||
if (command == null) {
|
||||
help.sendUsage(sender);
|
||||
return;
|
||||
}
|
||||
if (!command.hasPermission(sender)) {
|
||||
sender.sendMessage(settings.getMessage("noPermission"));
|
||||
return;
|
||||
}
|
||||
|
||||
command.execute(sender, args);
|
||||
}
|
||||
|
||||
public List<String> getSuggestions(final SenderInfo sender, final String[] args) {
|
||||
if (!sender.hasMaintenancePermission("command") || args.length == 0) return Collections.emptyList();
|
||||
final String s = args[0].toLowerCase();
|
||||
if (args.length == 1) {
|
||||
final List<String> list = new ArrayList<>();
|
||||
for (final Map.Entry<String, CommandInfo> entry : commandExecutors.entrySet()) {
|
||||
final String command = entry.getKey();
|
||||
if (command.startsWith(s) && entry.getValue().hasPermission(sender)) {
|
||||
list.add(command);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
final CommandInfo info = commandExecutors.get(args[0]);
|
||||
return info != null && info.hasPermission(sender) ? info.getTabCompletion(sender, args) : Collections.emptyList();
|
||||
}
|
||||
|
||||
public boolean checkTimerArgs(final SenderInfo sender, final String time, final boolean taskCheck) {
|
||||
if (!plugin.isNumeric(time)) return true;
|
||||
if (taskCheck) {
|
||||
if (plugin.isTaskRunning()) {
|
||||
sender.sendMessage(settings.getMessage("timerAlreadyRunning"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
final int minutes = Integer.parseInt(time);
|
||||
if (minutes > 40320) {
|
||||
sender.sendMessage(settings.getMessage("timerTooLong"));
|
||||
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.");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkTimerArgs(final SenderInfo sender, final String time) {
|
||||
return checkTimerArgs(sender, time, true);
|
||||
}
|
||||
|
||||
protected void addToggleAndTimerCommands() {
|
||||
add(new ToggleCommand(plugin), "on", "off");
|
||||
|
||||
add(new StarttimerCommand(plugin), "starttimer", "start");
|
||||
add(new EndtimerCommand(plugin), "endtimer", "end");
|
||||
add(new 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());
|
||||
// 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!");
|
||||
}
|
||||
|
||||
protected void sendUpdateMessage(final SenderInfo sender) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§eUse §c§l/maintenance forceupdate §eto update!");
|
||||
}
|
||||
|
||||
public List<String> getServersCompletion(final String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<String> getMaintenanceServersCompletion(final String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<String> getPlayersCompletion() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract void sendDumpMessage(final SenderInfo sender, final String url);
|
||||
|
||||
public List<CommandInfo> getCommands() {
|
||||
return commands;
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
public final class AbortTimerCommand extends CommandInfo {
|
||||
|
||||
public AbortTimerCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "timer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (args.length != 1) {
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.isTaskRunning()) {
|
||||
sender.sendMessage(getMessage("timerNotRunning"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.cancelTask();
|
||||
sender.sendMessage(getMessage("timerCancelled"));
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.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 DumpCommand extends CommandInfo {
|
||||
private long lastDump;
|
||||
|
||||
public DumpCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "dump");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 1)) return;
|
||||
if (System.currentTimeMillis() - lastDump < TimeUnit.MINUTES.toMillis(5)) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cYou can only create a dump every 5 minutes!");
|
||||
return;
|
||||
}
|
||||
|
||||
lastDump = System.currentTimeMillis();
|
||||
sender.sendMessage(plugin.getPrefix() + "§7The dump is being created, this might take a moment.");
|
||||
plugin.async(() -> {
|
||||
final String key = plugin.pasteDump();
|
||||
if (key == null) {
|
||||
if (sender.isPlayer())
|
||||
sender.sendMessage(plugin.getPrefix() + "§cCould not paste dump (see the console for details)");
|
||||
return;
|
||||
}
|
||||
|
||||
final String url = "https://hasteb.in/" + key;
|
||||
sender.sendMessage(plugin.getPrefix() + "§c" + url);
|
||||
if (sender.isPlayer())
|
||||
plugin.getCommandManager().sendDumpMessage(sender, url);
|
||||
});
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.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 EndtimerCommand extends CommandInfo {
|
||||
|
||||
public EndtimerCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "timer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 2)) return;
|
||||
if (plugin.getCommandManager().checkTimerArgs(sender, args[1])) {
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
if (!plugin.isMaintenance()) {
|
||||
sender.sendMessage(getMessage("alreadyDisabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.startMaintenanceRunnableForMinutes(Integer.parseInt(args[1]), false);
|
||||
sender.sendMessage(getMessage("endtimerStarted").replace("%TIME%", plugin.getRunnable().getTime()));
|
||||
}
|
||||
}
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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.core.command.subcommand;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class HelpCommand extends CommandInfo {
|
||||
private static final int COMMANDS_PER_PAGE = 8;
|
||||
|
||||
public HelpCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (args.length > 2) {
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length == 1) {
|
||||
sendUsage(sender);
|
||||
} else {
|
||||
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) {
|
||||
sendUsage(sender, 1);
|
||||
}
|
||||
|
||||
public void sendUsage(final SenderInfo sender, final int page) {
|
||||
Preconditions.checkArgument(page > 0);
|
||||
final List<String> commands = new ArrayList<>();
|
||||
for (final CommandInfo cmd : plugin.getCommandManager().getCommands()) {
|
||||
if (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 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);
|
||||
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("");
|
||||
}
|
||||
|
||||
private int getDivide(final int size) {
|
||||
final int commandSize = size % COMMANDS_PER_PAGE;
|
||||
return commandSize > 0 ? COMMANDS_PER_PAGE - commandSize : 0;
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class MotdCommand extends CommandInfo {
|
||||
|
||||
public MotdCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "motd");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
sendList(sender, getSettings().getPingMessages());
|
||||
} else if (args.length == 2 && args[1].equalsIgnoreCase("timer")) {
|
||||
if (!getSettings().hasTimerSpecificPingMessages()) {
|
||||
sender.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 < list.size(); i++) {
|
||||
sender.sendMessage("§b" + (i + 1) + "§8§m---------");
|
||||
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");
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
public final class ReloadCommand extends CommandInfo {
|
||||
|
||||
public ReloadCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "reload");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 1)) return;
|
||||
getSettings().reloadConfigs();
|
||||
sender.sendMessage(getMessage("reload"));
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class RemoveMotdCommand extends CommandInfo {
|
||||
|
||||
public RemoveMotdCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "setmotd");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, String[] args) {
|
||||
boolean timerPingMessages = false;
|
||||
if (args.length == 3 && args[1].equalsIgnoreCase("timer")) {
|
||||
if (!getSettings().hasTimerSpecificPingMessages()) {
|
||||
sender.sendMessage(getMessage("timerMotdDisabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
args = plugin.removeArrayIndex(args, 1);
|
||||
timerPingMessages = true;
|
||||
}
|
||||
if (checkArgs(sender, args, 2)) return;
|
||||
if (!plugin.isNumeric(args[1])) {
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
final Settings settings = getSettings();
|
||||
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 > pingMessages.size()) {
|
||||
sender.sendMessage(getMessage("setMotdIndexError").replace("%MOTDS%", Integer.toString(pingMessages.size()))
|
||||
.replace("%NEWAMOUNT%", Integer.toString(pingMessages.size())));
|
||||
return;
|
||||
}
|
||||
|
||||
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 || (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(String.valueOf(i));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* 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.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class SetMotdCommand extends CommandInfo {
|
||||
|
||||
public SetMotdCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "setmotd");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, String[] args) {
|
||||
boolean timerPingMessages = false;
|
||||
if (args.length > 1 && args[1].equalsIgnoreCase("timer")) {
|
||||
if (!getSettings().hasTimerSpecificPingMessages()) {
|
||||
sender.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(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 > pingMessages.size() + 1) {
|
||||
sender.sendMessage(getMessage("setMotdIndexError").replace("%MOTDS%", Integer.toString(pingMessages.size()))
|
||||
.replace("%NEWAMOUNT%", Integer.toString(pingMessages.size() + 1)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.isNumeric(args[2])) {
|
||||
sender.sendMessage(getMessage("setMotdLineError"));
|
||||
return;
|
||||
}
|
||||
|
||||
final int line = Integer.parseInt(args[2]);
|
||||
if (line != 1 && line != 2) {
|
||||
sender.sendMessage(getMessage("setMotdLineError"));
|
||||
return;
|
||||
}
|
||||
|
||||
final String message = String.join(" ", Arrays.copyOfRange(args, 3, args.length));
|
||||
final String oldMessage = index > pingMessages.size() ? "" : pingMessages.get(index - 1);
|
||||
final String newMessage;
|
||||
if (line == 1) {
|
||||
newMessage = oldMessage.contains("%NEWLINE%") ?
|
||||
message + "%NEWLINE%" + oldMessage.split("%NEWLINE%", 2)[1] : message;
|
||||
} else {
|
||||
newMessage = oldMessage.contains("%NEWLINE%") ?
|
||||
oldMessage.split("%NEWLINE%", 2)[0] + "%NEWLINE%" + message : oldMessage + "%NEWLINE%" + message;
|
||||
}
|
||||
|
||||
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, String[] args) {
|
||||
boolean timer = false;
|
||||
if (args.length > 1 && args[1].equalsIgnoreCase("timer")) {
|
||||
args = plugin.removeArrayIndex(args, 1);
|
||||
timer = true;
|
||||
}
|
||||
if (args.length == 3) return Arrays.asList("1", "2");
|
||||
if (args.length == 2) {
|
||||
final List<String> list = new ArrayList<>();
|
||||
for (int i = 1; i <= (timer ? getSettings().getTimerSpecificPingMessages() : getSettings().getPingMessages()).size() + 1; i++) {
|
||||
list.add(String.valueOf(i));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.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 StarttimerCommand extends CommandInfo {
|
||||
|
||||
public StarttimerCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "timer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 2)) return;
|
||||
if (plugin.getCommandManager().checkTimerArgs(sender, args[1])) {
|
||||
sender.sendMessage(getHelpMessage());
|
||||
return;
|
||||
}
|
||||
if (plugin.isMaintenance()) {
|
||||
sender.sendMessage(getMessage("alreadyEnabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.startMaintenanceRunnableForMinutes(Integer.parseInt(args[1]), true);
|
||||
sender.sendMessage(getMessage("starttimerStarted").replace("%TIME%", plugin.getRunnable().getTime()));
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
public final class ToggleCommand extends CommandInfo {
|
||||
|
||||
public ToggleCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "toggle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 1)) return;
|
||||
|
||||
final boolean maintenance = args[0].equalsIgnoreCase("on");
|
||||
if (maintenance == plugin.isMaintenance()) {
|
||||
sender.sendMessage(getMessage(maintenance ? "alreadyEnabled" : "alreadyDisabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.setMaintenance(maintenance);
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.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");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 1)) return;
|
||||
if (args[0].equalsIgnoreCase("update")) {
|
||||
plugin.async(() -> plugin.getCommandManager().checkForUpdate(sender));
|
||||
} else {
|
||||
if (!plugin.updateAvailable()) {
|
||||
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())
|
||||
sender.sendMessage(getMessage("updateFinished"));
|
||||
else
|
||||
sender.sendMessage(getMessage("updateFailed"));
|
||||
}
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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.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;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class WhitelistAddCommand extends CommandInfo {
|
||||
|
||||
public WhitelistAddCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "whitelist.add");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 2)) return;
|
||||
if (args[1].length() == 36) {
|
||||
final UUID uuid = plugin.checkUUID(sender, args[1]);
|
||||
if (uuid != null)
|
||||
addPlayerToWhitelist(sender, uuid);
|
||||
} else
|
||||
addPlayerToWhitelist(sender, args[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletion(final SenderInfo sender, final String[] args) {
|
||||
return args.length == 2 ? plugin.getCommandManager().getPlayersCompletion() : Collections.emptyList();
|
||||
}
|
||||
|
||||
private void addPlayerToWhitelist(final SenderInfo sender, final String name) {
|
||||
final SenderInfo selected = plugin.getOfflinePlayer(name);
|
||||
if (selected == null) {
|
||||
sender.sendMessage(getMessage("playerNotOnline"));
|
||||
return;
|
||||
}
|
||||
|
||||
whitelistAddMessage(sender, selected);
|
||||
}
|
||||
|
||||
private void addPlayerToWhitelist(final SenderInfo sender, final UUID uuid) {
|
||||
final SenderInfo selected = plugin.getOfflinePlayer(uuid);
|
||||
if (selected == null) {
|
||||
sender.sendMessage(getMessage("playerNotFoundUuid"));
|
||||
return;
|
||||
}
|
||||
|
||||
whitelistAddMessage(sender, selected);
|
||||
}
|
||||
|
||||
private void whitelistAddMessage(final SenderInfo sender, final SenderInfo selected) {
|
||||
if (getSettings().addWhitelistedPlayer(selected.getUuid(), selected.getName()))
|
||||
sender.sendMessage(getMessage("whitelistAdded").replace("%PLAYER%", selected.getName()));
|
||||
else
|
||||
sender.sendMessage(getMessage("whitelistAlreadyAdded").replace("%PLAYER%", selected.getName()));
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.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.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class WhitelistCommand extends CommandInfo {
|
||||
|
||||
public WhitelistCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "whitelist.list");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 1)) return;
|
||||
|
||||
final Map<UUID, String> players = getSettings().getWhitelistedPlayers();
|
||||
if (players.isEmpty()) {
|
||||
sender.sendMessage(getMessage("whitelistEmpty"));
|
||||
} else {
|
||||
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("");
|
||||
}
|
||||
}
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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.core.command.subcommand;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.command.CommandInfo;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class WhitelistRemoveCommand extends CommandInfo {
|
||||
|
||||
public WhitelistRemoveCommand(final MaintenancePlugin plugin) {
|
||||
super(plugin, "whitelist.remove");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkArgs(sender, args, 2)) return;
|
||||
if (args[1].length() == 36) {
|
||||
final UUID uuid = plugin.checkUUID(sender, args[1]);
|
||||
if (uuid != null)
|
||||
removePlayerFromWhitelist(sender, uuid);
|
||||
} else
|
||||
removePlayerFromWhitelist(sender, args[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletion(final SenderInfo sender, final String[] args) {
|
||||
if (args.length != 2) return Collections.emptyList();
|
||||
|
||||
final List<String> list = new ArrayList<>();
|
||||
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))
|
||||
sender.sendMessage(getMessage("whitelistRemoved").replace("%PLAYER%", name));
|
||||
else
|
||||
sender.sendMessage(getMessage("whitelistNotFound"));
|
||||
return;
|
||||
}
|
||||
|
||||
whitelistRemoveMessage(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());
|
||||
}
|
||||
|
||||
private void whitelistRemoveMessage(final SenderInfo sender, final UUID uuid, final String toReplace) {
|
||||
if (getSettings().removeWhitelistedPlayer(uuid))
|
||||
sender.sendMessage(getMessage("whitelistRemoved").replace("%PLAYER%", toReplace));
|
||||
else
|
||||
sender.sendMessage(getMessage("whitelistNotFound"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* 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.core.config;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Further modified version of the SimpleConfig project of PSandro (https://github.com/PSandro/SimpleConfig).
|
||||
*
|
||||
* @author PSandro on 26.01.19
|
||||
* @author KennyTV
|
||||
*/
|
||||
public final class Config extends ConfigSection {
|
||||
|
||||
private static final String AWESOME_HEADER =
|
||||
"#######################################################################################################################\n" +
|
||||
"# __ __ _ _ _ _ __ _______ __ #\n" +
|
||||
"# | \\/ | __ _(_)_ __ | |_ ___ _ __ __ _ _ __ ___ ___ | |__ _ _ | |/ /___ _ __ _ __ _ |_ _\\ \\ / / #\n" +
|
||||
"# | |\\/| |/ _` | | '_ \\| __/ _ \\ '_ \\ / _` | '_ \\ / __/ _ \\ | '_ \\| | | | | ' // _ \\ '_ \\| '_ \\| | | || | \\ \\ / / #\n" +
|
||||
"# | | | | (_| | | | | | || __/ | | | (_| | | | | (_| __/ | |_) | |_| | | . \\ __/ | | | | | | |_| || | \\ V / #\n" +
|
||||
"# |_| |_|\\__,_|_|_| |_|\\__\\___|_| |_|\\__,_|_| |_|\\___\\___| |_.__/ \\__, | |_|\\_\\___|_| |_|_| |_|\\__, ||_| \\_/ #\n" +
|
||||
"# |___/ |___/ #\n" +
|
||||
"#######################################################################################################################\n" +
|
||||
"# You can report bugs here: https://github.com/KennyTV/Maintenance/issues\n" +
|
||||
"# If you need any other help/support, you can also join my Discord server: https://discord.gg/vGCUzHq\n";
|
||||
private final Yaml yaml = createYaml();
|
||||
private final File file;
|
||||
private final Set<String> unsupportedFields;
|
||||
private Map<String, String[]> comments = new HashMap<>();
|
||||
private String header;
|
||||
|
||||
public Config(final File file, final String... unsupportedFields) {
|
||||
this.file = file;
|
||||
this.unsupportedFields = unsupportedFields.length == 0 ? Collections.emptySet() : Sets.newHashSet(unsupportedFields);
|
||||
}
|
||||
|
||||
public void load() throws IOException {
|
||||
final String data = new String(Files.readAllBytes(this.file.toPath()), StandardCharsets.UTF_8);
|
||||
final Map<String, Object> map = yaml.load(data);
|
||||
this.values = map != null ? map : new LinkedHashMap<>();
|
||||
this.comments = ConfigSerializer.deserializeComments(data);
|
||||
if (comments.containsKey(".header"))
|
||||
this.header = String.join("\n", comments.remove(".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)
|
||||
comments.remove(key);
|
||||
return remove;
|
||||
});
|
||||
if (removedFields) {
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
changed = true;
|
||||
}
|
||||
|
||||
this.comments = new HashMap<>(comments);
|
||||
return changed;
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(final String key) {
|
||||
this.values.remove(key);
|
||||
this.comments.remove(key);
|
||||
}
|
||||
|
||||
private static Yaml createYaml() {
|
||||
final DumperOptions options = new DumperOptions();
|
||||
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
options.setPrettyFlow(false);
|
||||
options.setIndent(2);
|
||||
options.setWidth(10_000); // be sneaky because autobreak on read/save 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();
|
||||
this.header = null;
|
||||
}
|
||||
|
||||
public Map<String, String[]> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
public Set<String> getUnsupportedFields() {
|
||||
return unsupportedFields;
|
||||
}
|
||||
|
||||
public String getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
public void resetAwesomeHeader() {
|
||||
this.header = AWESOME_HEADER;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* 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.core.config;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Further modified version of the SimpleConfig project of PSandro (https://github.com/PSandro/SimpleConfig).
|
||||
*
|
||||
* @author KennyTV
|
||||
*/
|
||||
public class ConfigSection {
|
||||
|
||||
protected Map<String, Object> values;
|
||||
|
||||
ConfigSection() {
|
||||
this(new HashMap<>());
|
||||
}
|
||||
|
||||
ConfigSection(final Map<String, Object> values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
public <E> E get(final String key) {
|
||||
return (E) this.values.get(key);
|
||||
}
|
||||
|
||||
public <E> E get(final String key, final E def) {
|
||||
final Object o = this.values.get(key);
|
||||
return o != null ? (E) o : def;
|
||||
}
|
||||
|
||||
public Object getObject(final String key) {
|
||||
return this.values.get(key);
|
||||
}
|
||||
|
||||
public <E> E getOrSet(final String key, final E def) {
|
||||
final Object o = this.values.get(key);
|
||||
if (o != null) {
|
||||
return (E) o;
|
||||
} else {
|
||||
this.set(key, def);
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Object o = getObject(split[0]);
|
||||
if (!(o instanceof Map)) return null;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public boolean contains(final String key) {
|
||||
return this.values.containsKey(key);
|
||||
}
|
||||
|
||||
public void set(final String key, final Object value) {
|
||||
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);
|
||||
} else {
|
||||
this.values.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(final String key) {
|
||||
this.values.remove(key);
|
||||
}
|
||||
|
||||
public Set<String> getKeys() {
|
||||
return this.values.keySet();
|
||||
}
|
||||
|
||||
public Map<String, Object> getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public boolean getBoolean(final String key) {
|
||||
return getBoolean(key, false);
|
||||
}
|
||||
|
||||
public boolean getBoolean(final String key, final boolean def) {
|
||||
final Object o = values.get(key);
|
||||
return o instanceof Boolean ? (boolean) o : def;
|
||||
}
|
||||
|
||||
public String getString(final String key) {
|
||||
return get(key);
|
||||
}
|
||||
|
||||
public String getString(final String key, final String def) {
|
||||
final Object o = get(key);
|
||||
return o instanceof String ? (String) o : def;
|
||||
}
|
||||
|
||||
public int getInt(final String key) {
|
||||
return getInt(key, 0);
|
||||
}
|
||||
|
||||
public int getInt(final String key, final int def) {
|
||||
final Object o = values.get(key);
|
||||
return o instanceof Number ? ((Number) o).intValue() : def;
|
||||
}
|
||||
|
||||
public double getDouble(final String key) {
|
||||
return getDouble(key, 0D);
|
||||
}
|
||||
|
||||
public double getDouble(final String key, final double def) {
|
||||
final Object o = values.get(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 = values.get(key);
|
||||
return o instanceof Number ? ((Number) o).longValue() : def;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* 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.core.config;
|
||||
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Further modified version of the SimpleConfig project of PSandro (https://github.com/PSandro/SimpleConfig).
|
||||
*
|
||||
* @author PSandro on 26.01.19
|
||||
* @author KennyTV
|
||||
*/
|
||||
public final class ConfigSerializer {
|
||||
|
||||
private static final String[] EMPTY = new String[0];
|
||||
private static final String PATH_SEPARATOR_STRING = ".";
|
||||
private static final String PATH_SEPARATOR_QUOTED = Pattern.quote(PATH_SEPARATOR_STRING);
|
||||
private static final int INDENT_UNIT = 2;
|
||||
|
||||
public static String serialize(final String header, final Map<String, Object> data, final Map<String, String[]> comments, final Yaml yaml) {
|
||||
if (data.isEmpty()) return yaml.dump(null);
|
||||
|
||||
final String rawYaml = yaml.dump(data);
|
||||
final StringBuilder fileData = new StringBuilder();
|
||||
int currentKeyIndents = 0;
|
||||
String key = "";
|
||||
for (final String line : rawYaml.split("\n")) {
|
||||
if (line.isEmpty()) continue;
|
||||
|
||||
final int indent = getIndents(line);
|
||||
final int indents = indent / INDENT_UNIT;
|
||||
final boolean keyLine;
|
||||
final String substring = line.substring(indent);
|
||||
if (substring.trim().isEmpty() || substring.charAt(0) == '-') {
|
||||
keyLine = false;
|
||||
} else if (indents <= currentKeyIndents) {
|
||||
final String[] array = key.split(PATH_SEPARATOR_QUOTED);
|
||||
final int backspace = currentKeyIndents - indents + 1;
|
||||
key = join(array, array.length - backspace);
|
||||
keyLine = true;
|
||||
} else {
|
||||
keyLine = line.contains(":");
|
||||
}
|
||||
|
||||
if (keyLine) {
|
||||
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) {
|
||||
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) {
|
||||
final Map<String, String[]> comments = new HashMap<>();
|
||||
final List<String> currentComments = new ArrayList<>();
|
||||
boolean header = true;
|
||||
int currentIndents = 0;
|
||||
String key = "";
|
||||
for (final String line : data.split("\n")) {
|
||||
final String s = line.trim();
|
||||
if (s.startsWith("#")) {
|
||||
currentComments.add(s);
|
||||
continue;
|
||||
}
|
||||
if (header) {
|
||||
if (!currentComments.isEmpty()) {
|
||||
currentComments.add("");
|
||||
comments.put(".header", currentComments.toArray(EMPTY));
|
||||
currentComments.clear();
|
||||
}
|
||||
header = false;
|
||||
}
|
||||
if (s.isEmpty()) {
|
||||
currentComments.add(s);
|
||||
continue;
|
||||
}
|
||||
|
||||
final int indent = getIndents(line);
|
||||
final int indents = indent / INDENT_UNIT;
|
||||
if (indents <= currentIndents) {
|
||||
final String[] array = key.split(PATH_SEPARATOR_QUOTED);
|
||||
final int backspace = currentIndents - indents + 1;
|
||||
key = join(array, array.length - backspace);
|
||||
}
|
||||
|
||||
final String separator = key.isEmpty() ? "" : PATH_SEPARATOR_STRING;
|
||||
final String lineKey = line.contains(":") ? line.split(Pattern.quote(":"))[0] : line;
|
||||
key += separator + lineKey.substring(indent);
|
||||
currentIndents = indents;
|
||||
|
||||
if (!currentComments.isEmpty()) {
|
||||
comments.put(key, currentComments.toArray(EMPTY));
|
||||
currentComments.clear();
|
||||
}
|
||||
}
|
||||
return comments;
|
||||
}
|
||||
|
||||
private static int getIndents(final String line) {
|
||||
int count = 0;
|
||||
for (int i = 0; i < line.length(); i++) {
|
||||
if (line.charAt(i) == ' ') count++;
|
||||
else break;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private static String join(final String[] array, final int length) {
|
||||
final String[] copy = new String[length];
|
||||
System.arraycopy(array, 0, copy, 0, length);
|
||||
return String.join(PATH_SEPARATOR_STRING, copy);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.core.dump;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class MaintenanceDump {
|
||||
private final ServerDump general;
|
||||
private final Map<String, Object> configuration;
|
||||
private final JsonObject plugins;
|
||||
|
||||
public MaintenanceDump(final MaintenancePlugin plugin, final Settings settings) {
|
||||
general = new ServerDump(plugin.getVersion(), plugin.getServerType().toString(), plugin.getServerVersion(), plugin.getMaintenanceServersDump());
|
||||
|
||||
configuration = new LinkedHashMap<>(settings.getConfig().getValues());
|
||||
final Object o = configuration.get("mysql");
|
||||
if (o instanceof Map) {
|
||||
final Map<String, Object> map = new LinkedHashMap<>(((Map<String, Object>) o));
|
||||
map.keySet().removeIf(key -> !key.equals("use-mysql") && !key.equals("update-interval"));
|
||||
configuration.put("mysql", map);
|
||||
}
|
||||
configuration.put("whitelisted-players", settings.getWhitelistedPlayers());
|
||||
configuration.put("icon-exists", new File(plugin.getDataFolder(), "maintenance-icon.png").exists());
|
||||
|
||||
final JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.add("plugins", new GsonBuilder().create().toJsonTree(plugin.getPlugins()));
|
||||
plugins = jsonObject;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.core.dump;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class PluginDump {
|
||||
private final String name;
|
||||
private final String version;
|
||||
private final List<String> authors;
|
||||
|
||||
public PluginDump(final String name, final String version, final List<String> authors) {
|
||||
this.name = name;
|
||||
this.version = version;
|
||||
this.authors = authors != null && authors.isEmpty() ? null : authors;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.core.dump;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class ServerDump {
|
||||
private final String pluginVersion;
|
||||
private final String platform;
|
||||
private final String serverVersion;
|
||||
private final List<String> maintenance;
|
||||
|
||||
public ServerDump(final String pluginVersion, final String platform, final String serverVersion, final List<String> maintenance) {
|
||||
this.pluginVersion = pluginVersion;
|
||||
this.platform = platform;
|
||||
this.serverVersion = serverVersion;
|
||||
this.maintenance = maintenance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.core.hook;
|
||||
|
||||
import net.minecrell.serverlistplus.core.ServerListPlusCore;
|
||||
import net.minecrell.serverlistplus.core.plugin.ServerListPlusPlugin;
|
||||
|
||||
public final class ServerListPlusHook {
|
||||
private final ServerListPlusCore serverListPlusCore;
|
||||
|
||||
public ServerListPlusHook(final Object serverListPlus) {
|
||||
if (!(serverListPlus instanceof ServerListPlusPlugin))
|
||||
throw new IllegalArgumentException("Couldn't parse ServerListPlus instance!");
|
||||
this.serverListPlusCore = ((ServerListPlusPlugin) serverListPlus).getCore();
|
||||
}
|
||||
|
||||
public void setEnabled(final boolean enable) {
|
||||
serverListPlusCore.getProfiles().setEnabled(enable);
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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.core.listener;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
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) {
|
||||
this.plugin = plugin;
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deals with the login and returns true if the player should be kicked after this method.
|
||||
*
|
||||
* @param sender wrapper of the joining player
|
||||
* @return true if the sender should be kicked
|
||||
*/
|
||||
protected boolean shouldKick(final SenderInfo sender, final boolean updateCheck) {
|
||||
if (!settings.isMaintenance() || sender.hasMaintenancePermission("bypass") || settings.isWhitelisted(sender.getUuid())) {
|
||||
if (updateCheck) {
|
||||
updateCheck(sender);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean shouldKick(final SenderInfo sender) {
|
||||
return shouldKick(sender, true);
|
||||
}
|
||||
|
||||
protected void updateCheck(final SenderInfo sender) {
|
||||
if (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);
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract void broadcastJoinNotification(String name);
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.core.runnable;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
|
||||
public final class MaintenanceRunnable extends MaintenanceRunnableBase {
|
||||
|
||||
public MaintenanceRunnable(final MaintenancePlugin plugin, final Settings settings, final int seconds, final boolean enable) {
|
||||
super(plugin, settings, seconds, enable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finish() {
|
||||
plugin.setMaintenance(enable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String startMessageKey() {
|
||||
return settings.getMessage("starttimerBroadcast").replace("%TIME%", getTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String endMessageKey() {
|
||||
return settings.getMessage("endtimerBroadcast").replace("%TIME%", getTime());
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 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.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 int seconds;
|
||||
|
||||
protected MaintenanceRunnableBase(final MaintenancePlugin plugin, final Settings settings, final int seconds, final boolean enable) {
|
||||
this.plugin = plugin;
|
||||
this.settings = settings;
|
||||
this.seconds = seconds;
|
||||
this.enable = enable;
|
||||
this.task = plugin.startMaintenanceRunnable(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (seconds == 0) {
|
||||
finish();
|
||||
} else if (settings.getBroadcastIntervals().contains(seconds)) {
|
||||
broadcast(enable ? startMessageKey() : endMessageKey());
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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 endMessageKey();
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.core.util;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface SenderInfo {
|
||||
|
||||
UUID getUuid();
|
||||
|
||||
String getName();
|
||||
|
||||
boolean hasPermission(String permission);
|
||||
|
||||
default boolean hasMaintenancePermission(final String permission) {
|
||||
return permission == null || hasPermission("maintenance.admin") || hasPermission("maintenance." + permission);
|
||||
}
|
||||
|
||||
void sendMessage(String message);
|
||||
|
||||
boolean isPlayer();
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.core.util;
|
||||
|
||||
public enum ServerType {
|
||||
|
||||
BUNGEE("Bungee"),
|
||||
SPIGOT("Spigot"),
|
||||
SPONGE("Sponge"),
|
||||
VELOCITY("Velocity");
|
||||
|
||||
private final String name;
|
||||
|
||||
ServerType(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if type is BUNGEE or VELOCITY
|
||||
*/
|
||||
public boolean isProxy() {
|
||||
return this == BUNGEE || this == VELOCITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.core.util;
|
||||
|
||||
public interface Task {
|
||||
|
||||
void cancel();
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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.core.util;
|
||||
|
||||
public final class Version implements Comparable<Version> {
|
||||
private final int[] parts;
|
||||
private final String version;
|
||||
private final String 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("\\.");
|
||||
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;
|
||||
}
|
||||
parts[i] = Integer.parseInt(split[i]);
|
||||
}
|
||||
|
||||
this.version = version;
|
||||
tag = version.contains("-") ? version.split("-", 2)[1] : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two versions.
|
||||
*
|
||||
* @param version version to compare to
|
||||
* @return 0 if they are the same, 1 if this instance is newer, -1 if older
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(final Version version) {
|
||||
if (version == null || version.toString() == 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 (this.tag.isEmpty() && !version.tag.isEmpty())
|
||||
return 1;
|
||||
if (!this.tag.isEmpty() && version.tag.isEmpty())
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == null) return false;
|
||||
return o instanceof Version && o == this || version.equals(o.toString());
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
@@ -0,0 +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
|
||||
@@ -0,0 +1,104 @@
|
||||
#######################################################################################################################
|
||||
# __ __ _ _ _ _ __ _______ __ #
|
||||
# | \/ | __ _(_)_ __ | |_ ___ _ __ __ _ _ __ ___ ___ | |__ _ _ | |/ /___ _ __ _ __ _ |_ _\ \ / / #
|
||||
# | |\/| |/ _` | | '_ \| __/ _ \ '_ \ / _` | '_ \ / __/ _ \ | '_ \| | | | | ' // _ \ '_ \| '_ \| | | || | \ \ / / #
|
||||
# | | | | (_| | | | | | || __/ | | | (_| | | | | (_| __/ | |_) | |_| | | . \ __/ | | | | | | |_| || | \ V / #
|
||||
# |_| |_|\__,_|_|_| |_|\__\___|_| |_|\__,_|_| |_|\___\___| |_.__/ \__, | |_|\_\___|_| |_|_| |_|\__, ||_| \_/ #
|
||||
# |___/ |___/ #
|
||||
#######################################################################################################################
|
||||
# You can report bugs here: https://github.com/KennyTV/Maintenance/issues
|
||||
# If you need any other help/support, you can also join my Discord server: https://discord.gg/vGCUzHq
|
||||
|
||||
# Enables maintenance mode.
|
||||
maintenance-enabled: false
|
||||
|
||||
# Enables maintenance on certain servers managed by your Bungee instance(s).
|
||||
proxied-maintenance-servers:
|
||||
- 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 the fallback server is not reachable/not set, they will just be kicked off the network.
|
||||
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"
|
||||
|
||||
# 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%").
|
||||
enable-playercountmessage: true
|
||||
playercountmessage: "&4Maintenance"
|
||||
|
||||
# Is shown when you move your mouse above the text at the top right corner of the server in the serverlist,
|
||||
# where the playercount would normally be displayed.
|
||||
playercounthovermessage: "&cCurrently under%NEWLINE%&cmaintenance"
|
||||
|
||||
# If set to true, the server icon will be changed to the 'maintenance-icon.png' file in the plugin's folder during maintenance.
|
||||
custom-maintenance-icon: false
|
||||
|
||||
# If set to true, players with the 'maintenance.joinnotification' permission will receive a message,
|
||||
# that a player tried to join the server while maintenance is enabled.
|
||||
send-join-notification: 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), es (Spanish), ru (Russian)
|
||||
language: en
|
||||
|
||||
# If you have 2 or more proxy instances, the database connection will make sure all proxies
|
||||
# have the same maintenance status, so you won't have to enable/disable it on every proxy by hand.
|
||||
mysql:
|
||||
use-mysql: false
|
||||
host: host
|
||||
port: 3306
|
||||
database: database
|
||||
username: username
|
||||
password: password
|
||||
# Requests to the database will only be made at least x seconds after the last request,
|
||||
# so there won't be a request on every single ping on a server with many players.
|
||||
#
|
||||
# Set this to 0 to make a database request on (almost) every single ping.
|
||||
# (0 is not recommended if having more than a hundred concurrent players, then I'd recommend keeping it from 10-60).
|
||||
update-interval: 15
|
||||
# If you for some reason cannot establish SSL connections to your database, you may disable it here (not recommended).
|
||||
use-ssl: true
|
||||
|
||||
# If enabled and the server is restarted while running an endtimer, the timer will be continued after the restart.
|
||||
# If the timer ends while the server is offline, maintenance will be disabled as soon as the server starts again.
|
||||
continue-endtimer-after-restart:
|
||||
enabled: false
|
||||
# This value is set everytime an endtimer is started, cancelled or ended.
|
||||
# Do not manually change this value.
|
||||
end: 0
|
||||
|
||||
# If using the timer command: In what intervalls before enabling/disabling maintenance there will be a broadcast.
|
||||
timer-broadcast-for-seconds: [1200, 900, 600, 300, 120, 60, 30, 20, 10, 5, 4, 3, 2, 1]
|
||||
|
||||
# If 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
|
||||
|
||||
# Used for autoupdating the config, do not change this value.
|
||||
config-version: 4
|
||||
@@ -0,0 +1,94 @@
|
||||
# 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."
|
||||
kickmessage: "&cDer Server befindet sich momentan im Wartungsmodus!%NEWLINE%&cVersuche es später nochmal!"
|
||||
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!"
|
||||
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"
|
||||
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!"
|
||||
setMotd: "&8[&eMaintenance&8] &aDie %LINE%. Zeile der %INDEX%. Maintenance MOTD wurde geändert zu: %MOTD%"
|
||||
setMotdIndexError: "&8[&eMaintenance&8] &cMomentan gibt es %MOTDS% MOTDs, du musst also eine Zahl zwischen 1 and %NEWAMOUNT% wählen."
|
||||
setMotdLineError: "&8[&eMaintenance&8] &cDas zweite Argument muss die Zeilennummer sein (1 oder 2)!"
|
||||
updateDownloading: "&8[&eMaintenance&8] &c&lUpdate wird heruntergeladen..."
|
||||
updateFailed: "&8[&eMaintenance&8] &4&lUpdate fehlgeschlagen!"
|
||||
updateFinished: "&8[&eMaintenance&8] &a&lDas Update war erfolgreich! Um Probleme mit Timern zu vermeiden und das Update zu vervollständigen, musst du den Server neustarten!"
|
||||
whitelistedPlayers: "&8[&eMaintenance&8] &6Spieler in der Maintenance Whitelist:"
|
||||
whitelistedPlayersFormat: "&8- &e%NAME% &8(&7%UUID%&8)"
|
||||
whitelistAdded: "&8[&eMaintenance&8] &b%PLAYER% &awurde zur Maintenance Whitelist hinzugefügt!"
|
||||
whitelistAlreadyAdded: "&8[&eMaintenance&8] &b%PLAYER% &cist bereits in der Maintenance Whitelist!"
|
||||
whitelistRemoved: "&8[&eMaintenance&8] &b%PLAYER% &awurde von der Maintenance Whitelist entfernt!"
|
||||
whitelistNotFound: "&8[&eMaintenance&8] &cDieser Spieler ist nicht in der Maintenance Whitelist!"
|
||||
whitelistEmtpy: "&8[&eMaintenance&8] &cDie Maintenance Whitelist ist leer! Nutze &e/maintenance add <Spieler/UUID>&c, um jemanden hinzuzufügen!"
|
||||
playerNotFound: "&8[&eMaintenance&8] &cBisher hat kein Spieler mit diesem Namen jemals auf diesem Server gespielt."
|
||||
playerNotFoundUuid: "&8[&eMaintenance&8] &cEs konnte kein Spieler mit dieser UUID gefunden werden."
|
||||
playerNotOnline: "&8[&eMaintenance&8] &cEs ist momentan kein Spieler mit diesem Namen online."
|
||||
invalidUuid: "&8[&eMaintenance&8] &cUngültiges UUID Format!"
|
||||
|
||||
# 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."
|
||||
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."
|
||||
singleMaintenanceDeactivated: "&8[&eMaintenance&8] &6Der Wartungsmodus wurde auf &e%SERVER% &6deaktiviert."
|
||||
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."
|
||||
|
||||
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)"
|
||||
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)"
|
||||
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)"
|
||||
@@ -0,0 +1,94 @@
|
||||
# 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."
|
||||
kickmessage: "&cThe server is currently under maintenance!%NEWLINE%&cTry again later!"
|
||||
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!"
|
||||
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."
|
||||
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!"
|
||||
setMotd: "&8[&eMaintenance&8] &aSet line %LINE% of the %INDEX%. maintenance motd to %MOTD%"
|
||||
setMotdIndexError: "&8[&eMaintenance&8] &cYou currently have %MOTDS% motds, so you have to pick a number between 1 and %NEWAMOUNT%."
|
||||
setMotdLineError: "&8[&eMaintenance&8] &cThe second argument has to be the line number (1 or 2)!"
|
||||
updateDownloading: "&8[&eMaintenance&8] &c&lDownloading update..."
|
||||
updateFailed: "&8[&eMaintenance&8] &4&lUpdate failed!"
|
||||
updateFinished: "&8[&eMaintenance&8] &a&lThe update was successful! To prevent issues with tasks and to complete the update, you have to restart the server!"
|
||||
whitelistedPlayers: "&8[&eMaintenance&8] &6Whitelisted players for maintenance:"
|
||||
whitelistedPlayersFormat: "&8- &e%NAME% &8(&7%UUID%&8)"
|
||||
whitelistAdded: "&8[&eMaintenance&8] &aAdded &b%PLAYER% &ato the maintenance whitelist!"
|
||||
whitelistAlreadyAdded: "&8[&eMaintenance&8] &b%PLAYER% &calready is in the maintenance whitelist!"
|
||||
whitelistRemoved: "&8[&eMaintenance&8] &aRemoved &b%PLAYER% &afrom the maintenance whitelist!"
|
||||
whitelistNotFound: "&8[&eMaintenance&8] &cThis player is not in the maintenance whitelist!"
|
||||
whitelistEmpty: "&8[&eMaintenance&8] &cThe maintenance whitelist is empty! Use &e/maintenance add <player/uuid> &cto add someone!"
|
||||
playerNotFound: "&8[&eMaintenance&8] &cNo player with this name has played on this server before."
|
||||
playerNotFoundUuid: "&8[&eMaintenance&8] &cNo player with that uuid could be found."
|
||||
playerNotOnline: "&8[&eMaintenance&8] &cThere is no player online with that name."
|
||||
invalidUuid: "&8[&eMaintenance&8] &cInvalid uuid format!"
|
||||
|
||||
# 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."
|
||||
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."
|
||||
singleMaintenanceDeactivated: "&8[&eMaintenance&8] &6Maintenance mode is now deactivated on server &e%SERVER%&6."
|
||||
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."
|
||||
|
||||
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)"
|
||||
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)"
|
||||
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,94 @@
|
||||
# Maintenance Plugin by KennyTV
|
||||
# Don't remove words inbetween the '%' if you don't exactly know why you're doing it
|
||||
|
||||
noPermission: "&4No tienes Permiso para ejecutar este comando."
|
||||
kickmessage: "&cEl servidor se encuentra en &6Mantenimiento!%NEWLINE%&cIntentalo de nuevo mas tarde!"
|
||||
maintenanceActivated: "&8[&eMaintenance&8] &6Mantenimiento &7Activado"
|
||||
maintenanceDeactivated: "&8[&eMaintenance&8] &7Modo &6Mantenimiento &7Desactivado"
|
||||
alreadyEnabled: "&8[&eMaintenance&8] &7Modo &6Mantenimiento &7se encuentra Habilitado!"
|
||||
alreadyDisabled: "&8[&eMaintenance&8] &7Modo &6Mantenimiento &7se encuentra Deshabilitado!"
|
||||
endtimerBroadcast: "&8[&eMaintenance&8] &7El Modo &6Mantenimiento &7se desactivara en &6%TIME%&7."
|
||||
endtimerStarted: "&8[&eMaintenance&8] &7Temporizador Iniciado: El Modo &6Mantenimiento &7se desactivará en &6%TIME%&7."
|
||||
starttimerBroadcast: "&8[&eMaintenance&8] &7El Modo &6Mantenimiento &7se habilitara en &6%TIME%&7."
|
||||
starttimerStarted: "&8[&eMaintenance&8] &7Temporizador Iniciado: El Modo &6Mantenimiento &7se activará en &6%TIME%&7."
|
||||
timerAlreadyRunning: "&8[&eMaintenance&8] &7Ya 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 &6(28 dias)"
|
||||
timerMotdDisabled: "&8[&eMaintenance&8] &cTienes que configurar 'enable-timerspecific-messages' en la configuración en 'true', 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 &6Mantenimiento&7:"
|
||||
motdListEmpty: "8[&eMaintenance&8] &c¡No tiene ningún juego de mantenimiento establecido!"
|
||||
reload: "&8[&eMaintenance&8] &aConfiguracion Recargada"
|
||||
removedMotd: "&8[&eMaintenance&8] &aNumero de Motd eliminado &6%INDEX%."
|
||||
removeMotdError: "&8[&eMaintenance&8] &Solo tienes un Motd, por lo que no puedes eliminar ninguno!"
|
||||
setMotd: "&8[&eMaintenance&8] &aEstablecer linea &6%LINE%&a del &6%INDEX%. &6Mantenimiento&a para %MOTD%"
|
||||
setMotdIndexError: "&8[&eMaintenance&8] &aActualmente tiene &6%MOTDS%&a Motds, 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)!"
|
||||
updateDownloading: "&8[&eMaintenance&8] &aDescargando Actualizacion..."
|
||||
updateFailed: "&8[&eMaintenance&8] &aActualizacion &cFallida!"
|
||||
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 &6Mantenimiento!"
|
||||
whitelistAlreadyAdded: "&8[&eMaintenance&8] &a%PLAYER% &7Se encuentra en la lista de &6Mantenimiento!"
|
||||
whitelistRemoved: "&8[&eMaintenance&8] &c%PLAYER% &7Eliminado de la lista de &6Mantenimiento!"
|
||||
whitelistNotFound: "&8[&eMaintenance&8] &7No se encuentra en la lista de &6Mantenimiento!"
|
||||
whitelistEmpty: "&8[&eMaintenance&8] &7La lista de &6Mantenimiento 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 ese 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] &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] &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% &c ha sido desactivado."
|
||||
singleEndtimerBroadcast: "&8[&eMaintenance&8] &7Modo &6Mantenimiento &7en el Servidor &6%SERVER% &cse desactivará en &6%TIME%"
|
||||
singleStarttimerBroadcast: "&8[&eMaintenance&8] &7Modo &6Mantenimiento &7en el Servidor &6%SERVER%&7se activará en &6%TIME%"
|
||||
singleMaintenanceKick: "&8[&eMaintenance&8] &7El servidor &6%SERVER% &7se encuentra en &6Mantenimiento&7! Intentalo mas tarde!"
|
||||
singleMaintenanceKickComplete: "&7El Servidor &6%SERVER% &7esta en &6Mantenimiento&7!%NEWLINE%&cVuelve Mas Tarde!"
|
||||
singleMaintenanceActivated: "&8[&eMaintenance&8] &7El Modo&6Mantenimiento &7Esta Activado en el Servidor &6%SERVER%&7."
|
||||
singleMaintenanceDeactivated: "&8[&eMaintenance&8] &7El Modo &6Mantenimiento &7Ahora esta deshabilitado en &6%SERVER%&7."
|
||||
singleServerAlreadyEnabled: "&8[&eMaintenance&8] &7El Modo &6Mantenimiento &7se encuentra Habilitado en &6%SERVER%&7!"
|
||||
singleServerAlreadyDisabled: "&8[&eMaintenance&8] 7El Modo &6Mantenimiento &7se encuentra Deshabilitado en &6%SERVER%&7!"
|
||||
singleServerMaintenanceList: "&8[&eMaintenance&8] &7Servidores Proxy, que tienen habilitado el &6Mantenimiento:"
|
||||
singleServerMaintenanceListEmpty: "&8[&eMaintenance&8] &7No hay servidores Proxy que están en &6Mantenimiento&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 &7(Si se ejecuta, se abortará el temporizador actual)"
|
||||
helpEndtimer: "&6/maintenance endtimer <minutes> &7(Después del tiempo en minutos, se desactivará el modo de mantenimiento)"
|
||||
helpStarttimer: "&6/maintenance starttimer <minutes> &7(Después del tiempo en minutos, se habilitará el modo de mantenimiento)"
|
||||
helpDump: "&6/maintenance dump &7(Vuelca información del servidor, usada para informes de errores)"
|
||||
helpHelp: "&6/maintenance help [page] &7(Muestra esta hermosa ventana de ayuda)"
|
||||
helpMotd: "&6/maintenance motd [timer] &7(Enumera los motivos de mantenimiento establecidos actualmente. Si se especifica el 'temporizador', se muestran los motivos del temporizador)"
|
||||
helpRemoveMotd: "&6/maintenance removemotd [timer] <index> &7(Elimina un mantenimiento motd. Si se usa 'timer' como argumento, se eliminará un pingmessage de temporizador específico)"
|
||||
helpSetMotd: "&6/maintenance setmotd [timer] <index> <1/2> <message> &7(Establece un motd para el modo de mantenimiento. Si usa 'timer' como argumento, se establecerá un mensaje de ping específico para el tiempo)"
|
||||
helpReload: "&6/maintenance reload &7(Vuelve a cargar el archivo de configuración, el archivo de la lista blanca y el ícono del servidor)"
|
||||
helpToggle: "&6/maintenance <on/off> &7(Habilita / deshabilita el modo de mantenimiento)"
|
||||
helpUpdate: "&6/maintenance update &7(Descarga de forma remota la versión más reciente del complemento en su servidor)"
|
||||
helpWhitelist: "&6/maintenance whitelist &7(Muestra todos los reproductores en lista blanca para el modo de mantenimiento)"
|
||||
helpWhitelistAdd: "&6/maintenance add <name/uuid> &7(Agrega el reproductor a la lista blanca de mantenimiento, para que puedan unirse al servidor aunque el mantenimiento esté habilitado)"
|
||||
helpWhitelistRemove: "&6/maintenance remove <name/uuid> &7(Quita el reproductor de la lista blanca de mantenimiento)"
|
||||
|
||||
# Messages for the Bungee/Velocity part, just can ignore them if you use the plugin on Spigot/Sponge
|
||||
helpAbortSingleTimer: "&6/maintenance aborttimer [servidor] &7(Si está funcionando, se abortará el temporizador actual)"
|
||||
helpSingleEndtimer: "&6/maintenance endtimer [server] <minutes> &7(Después del tiempo en minutos, se desactivará el modo de mantenimiento)"
|
||||
helpSingleStarttimer: "&6/maintenance starttimer [server] <minutes> &7(Después del tiempo en minutos, el modo de mantenimiento habilitado)"
|
||||
helpSingleToggle: "&6/maintenance <on/off> [server] &7(Habilita / deshabilita el modo de mantenimiento)"
|
||||
helpStatus: "&6/maintenance status &7(Enumera todos los servidores proxy, que están actualmente en mantenimiento)"
|
||||
@@ -0,0 +1,94 @@
|
||||
# Maintenance Plugin par KennyTV
|
||||
# Ne supprime pas des mots entre les '%' si tu ne sait pas pourqoi exactement
|
||||
|
||||
noPermission: "&cVous n'avez pas la permission d'exécuter cette commande."
|
||||
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!"
|
||||
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!"
|
||||
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)!"
|
||||
timerMotdDisabled: "&8[&eMaintenance&8] &cVous devez définir 'enable-timerspecific-messages' dans la configuration sur 'true', si vous voulez utiliser / éditer des timerspecific motd."
|
||||
motdTimer: "%HOURS%:%MINUTES%:%SECONDS%"
|
||||
motdTimerNotRunning: "-"
|
||||
joinNotification: "&8[&eMaintenance&8] &e%PLAYER% &ca essayé de rejoindre le serveur."
|
||||
motdList: "&8[&eMaintenance&8] &7Liste de vos motd pour la maintenance:"
|
||||
motdListEmpty: "8[&eMaintenance&8] &cVous n'avez pas de motds d'entretien fixés!"
|
||||
reload: "&8[&eMaintenance&8] &afichier config, liste blanche (whitelist) joueurs, fichier de langue et l'icône de maintenance, recharger."
|
||||
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)!"
|
||||
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:"
|
||||
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é."
|
||||
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!"
|
||||
|
||||
# Quelques messages pour la partie Bungee/Velocity, ignorez-les si vous utilisez le plugin sur 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] &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."
|
||||
|
||||
second: "second"
|
||||
seconds: "seconds"
|
||||
minute: "minute"
|
||||
minutes: "minutes"
|
||||
hour: "heur"
|
||||
hours: "heurs"
|
||||
|
||||
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é)"
|
||||
helpDump: "&6/maintenance dump &7(Dépose 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 sont 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, le fichier de liste blanche 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écharger 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 la 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 la 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é)"
|
||||
helpSingleToggle: "&6/maintenance <on/off> [server] &7(Active/désactive le mode maintenance)"
|
||||
helpStatus: "&6/maintenance status &7(Répertorie tout les serveurs mandatés, actuellement en maintenance)"
|
||||
@@ -0,0 +1,94 @@
|
||||
# Maintenance Plugin by KennyTV
|
||||
# Nao removas o '%' se nao souberes exatamente o que estas a fazer
|
||||
|
||||
noPermission: "&cNao tens permissao para executar este comando."
|
||||
kickmessage: "&cO servidor esta em manutencao!%NEWLINE%&cTente mais tarde!"
|
||||
maintenanceActivated: "&8[&cManutencao&8] &6Manutencao esta agora ativada!"
|
||||
maintenanceDeactivated: "&8[&cManutencao&8] &6Manutencao esta agora desativada!"
|
||||
alreadyEnabled: "&8[&cManutencao&8] &cManutencao ja esta ativada!"
|
||||
alreadyDisabled: "&8[&cManutencao&8] &cManutencao ja esta desativada!"
|
||||
endtimerBroadcast: "&8[&cManutencao&8] &7Manutencao vai ser desativada em &6%TIME%&7"
|
||||
endtimerStarted: "&8[&cManutencao&8] &aTemporizador: &7Manutencao vai ser desativada em &6%TIME%&7"
|
||||
starttimerBroadcast: "&8[&cManutencao&8] &7Manutencao vai ser ativada em &6%TIME%&7"
|
||||
starttimerStarted: "&8[&cManutencao&8] &7Manutencao vai ser ativada em &6%TIME%&7"
|
||||
timerAlreadyRunning: "&8[&cManutencao&8] &cO Timer ja esta a decorrer!"
|
||||
timerNotRunning: "&8[&cManutencao&8] &cO Timer nao esta a decorrer!"
|
||||
timerCancelled: "&8[&cManutencao&8] &cO Timer foi cancelado!"
|
||||
timerTooLong: "&8[&cManutencao&8] &cO numero tem de ser menor que 40320 (28 dias)!"
|
||||
timerMotdDisabled: "&8[&eMaintenance&8] &cDefine 'enable-timerspecific-messages' no config a 'true', se queres definir/editar motds de manutenção."
|
||||
motdTimer: "%HOURS%:%MINUTES%:%SECONDS%"
|
||||
motdTimerNotRunning: "-"
|
||||
joinNotification: "&8[&cManutencao&8] &e%PLAYER% &ctentou entrar no servidor."
|
||||
motdList: "&8[&cManutencao&8] &7Lista de motds de manutencao:"
|
||||
motdListEmpty: "8[&eMaintenance&8] &cNão tens motds de manutenção!"
|
||||
reload: "&8[&cManutencao&8] &aReloaded config, whitelistedplayers, linguagem e icon de manutencao."
|
||||
removedMotd: "&8[&cManutencao&8] &aRemovida motd numero %INDEX%."
|
||||
removeMotdError: "&8[&cManutencao&8] &cSo tens uma motd, entao nao podes remover esta!"
|
||||
setMotd: "&8[&eManutencao&8] &aLinha %LINE% do %INDEX%. Motd de manutencao %MOTD%"
|
||||
setMotdIndexError: "&8[&cManutencao&8] &cTens atualmente %MOTDS% motds, entao escolhe um numero entre 1 e %NEWAMOUNT%."
|
||||
setMotdLineError: "&8[&cManutencao&8] &cO segundo argumento tem de ser na linha (1 ou 2)!"
|
||||
updateDownloading: "&8[&cManutencao&8] &c&lA dar download do update..."
|
||||
updateFailed: "&8[&cManutencao&8] &4&lUpdate falhado!"
|
||||
updateFinished: "&8[&cManutencao&8] &a&lO update foi feito com sucesso! Reinicia o servidor paa evitar erros e acabar a atualizacao"
|
||||
whitelistedPlayers: "&8[&cManutencao&8] &6Whitelisted players para a manutencao:"
|
||||
whitelistedPlayersFormat: "&8- &e%NAME% &8(&7%UUID%&8)"
|
||||
whitelistAdded: "&8[&cManutencao&8] &aAdicionado &b%PLAYER% &ana whitelist!"
|
||||
whitelistAlreadyAdded: "&8[&cManutencao&8] &b%PLAYER% &cja esta na whitelist!"
|
||||
whitelistRemoved: "&8[&cManutencao&8] &b%PLAYER% &aremovido da whitelist!"
|
||||
whitelistNotFound: "&8[&cManutencao&8] &cEste jogador nao esta na whitelist!"
|
||||
whitelistEmpty: "&8[&cManutencao&8] &cA whitelist esta vazia! Usa &e/maintenance add <player/uuid> &cpara adicionar alguem!"
|
||||
playerNotFound: "&8[&cManutencao&8] &cNinguem com esse nome se registou no servidor."
|
||||
playerNotFoundUuid: "&8[&cManutencao&8] &cNenhum player com esse uuid foi encontrado."
|
||||
playerNotOnline: "&8[&cManutencao&8] &cNao esta ninguem online com esse nome"
|
||||
invalidUuid: "&8[&eMaintenance&8] &cFormato de uuid invalido!"
|
||||
|
||||
# Algumas mensagens para o Bungee/Velocity, ignora-as se estas a usar 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[&cManutencao&8] &cServidor nao encontrado!"
|
||||
|
||||
singleTimerAlreadyRunning: "&8[&cManutencao&8] &cO Timer ja esta a decorrer!"
|
||||
singleTimerNotRunning: "&8[&cManutencao&8] &cO Timer nao esta a decorrer!"
|
||||
singleTimerCancelled: "&8[&cManutencao&8] &cO Timer foi cancelado no!"
|
||||
singleEndtimerBroadcast: "&8[&cManutencao&8] &7Manutencao no %SERVER% vai ser desativada em &6%TIME%&7."
|
||||
singleStarttimerBroadcast: "&8[&cManutencao&8] &7Manutencao no %SERVER% vai ser ativada em &6%TIME%&7."
|
||||
singleMaintenanceKick: "&8[&cManutencao&8] &cO %SERVER% esta em manutencao! Tente mais tarde!"
|
||||
singleMaintenanceKickComplete: "&cO %SERVER% esta em manutencao!%NEWLINE%&cTente mais tarde!"
|
||||
singleMaintenanceActivated: "&8[&cManutencao&8] &6Manutencao esta agora ativada no &e%SERVER%&6."
|
||||
singleMaintenanceDeactivated: "&8[&cManutencao&8] &6Manutencao esta agora desativada no &e%SERVER%&6."
|
||||
singleServerAlreadyEnabled: "&8[&cManutencao&8] &cManutencao ja esta ativada no &e%SERVER%&c!"
|
||||
singleServerAlreadyDisabled: "&8[&cManutencao&8] &cManutencao ja esta desativada no &e%SERVER%&c!"
|
||||
singleServerMaintenanceList: "&8[&cManutencao&8] &7Servidores com manutencao ativa:"
|
||||
singleServerMaintenanceListEmpty: "&8[&cManutencao&8] &7Nao existem servidores com a manutencao ativa."
|
||||
|
||||
second: "segundo"
|
||||
seconds: "segundos"
|
||||
minute: "minuto"
|
||||
minutes: "minutos"
|
||||
hour: "hora"
|
||||
hours: "horas"
|
||||
|
||||
helpHeader: "&8========[ &e%NAME% &8| &e%PAGE%/%MAX% &8]========"
|
||||
helpPageNotFound: "&8[&eManutencao&8] &cNao existe nenhuma pagina com esse numero!"
|
||||
helpNextPage: "&7Use &b/maintenance help %PAGE% &7para ir para a próxima págin."
|
||||
helpAbortTimer: "&6/maintenance aborttimer &7(Se estiver a correr o temporizador vai ser abortado)"
|
||||
helpEndtimer: "&6/maintenance endtimer <minutes> &7(Depois do temporizador acabar a manutenção vai ser desativada)"
|
||||
helpStarttimer: "&6/maintenance starttimer <minutes> &7(Depois do temporizador acabar a manutenção vai ser ativa)"
|
||||
helpDump: "&6/maintenance dump &7(Discarta alguma informação do server, usado para bugs)"
|
||||
helpHelp: "&6/maintenance help [page] &7(Mostra o help da manutenção)"
|
||||
helpMotd: "&6/maintenance motd [timer] &7(Lista as motd currentes. Se usar 'timer', os temporizadores vão ser mostrados)"
|
||||
helpRemoveMotd: "&6/maintenance removemotd [timer] <index> &7(Remove a motd da manutenção. Se usar \"timer\" como argumento uma mensagem com tempo vai ser eliminada)"
|
||||
helpSetMotd: "&6/maintenance setmotd [timer] <index> <1/2> <message> &7(Define a motd da manutenção. Se usar \"timer\" como argumento uma mensagem com tempo vai aparecer)"
|
||||
helpReload: "&6/maintenance reload &7(Dá reload ao plugin de manutenção)"
|
||||
helpToggle: "&6/maintenance <on/off> &7(Ativa/Desativa a manutenção)"
|
||||
helpUpdate: "&6/maintenance update &7(Arualiza o plugin de manutenção)"
|
||||
helpWhitelist: "&6/maintenance whitelist &7(Mostra os payers que estão na whitelist)"
|
||||
helpWhitelistAdd: "&6/maintenance add <name/uuid> &7(Adiciona o player à whitelist para poder entrar durante a manutenção)"
|
||||
helpWhitelistRemove: "&6/maintenance remove <name/uuid> &7(Remove o player da whitelist)"
|
||||
|
||||
# Algumas mensagens para o Bungee/Velocity, ignora-as se estas a usar Spigot/Sponge
|
||||
helpAbortSingleTimer: "&6/maintenance aborttimer [server] &7(Se o timer estiver ativado este vai ser abortado)"
|
||||
helpSingleEndtimer: "&6/maintenance endtimer [server] <minutes> &7(Depois do tempo dado a manutenção vai ser desativada)"
|
||||
helpSingleStarttimer: "&6/maintenance starttimer [server] <minutes> &7(Depois do tempo dado a manutenção vai ser ativa)"
|
||||
helpSingleToggle: "&6/maintenance <on/off> [server] &7(Ativa/Desativa a manutenção)"
|
||||
helpStatus: "&6/maintenance status &7(Lista os servers em proxy que estão em manutenção)"
|
||||
@@ -0,0 +1,94 @@
|
||||
# Maintenance Plugin by KennyTV
|
||||
# Don't remove words inbetween the '%' if you don't exactly know why you're doing it
|
||||
|
||||
noPermission: "&cУ вас недостаточно прав!"
|
||||
kickmessage: "&cСервер закрыт на тех. работы!"
|
||||
maintenanceActivated: "&aРежим тех. работ включен!"
|
||||
maintenanceDeactivated: "&7Режим тех. работ выключен!"
|
||||
alreadyEnabled: "&cРежим тех. работ уже включен!"
|
||||
alreadyDisabled: "&cРежим тех. работ не был включен."
|
||||
endtimerBroadcast: "&aСервер будет открыт через &f%TIME% &aминут."
|
||||
endtimerStarted: "&aТаймер успешно запущен! &aСервер будет открыт через &f%TIME% &aминут."
|
||||
starttimerBroadcast: "&aСервер будет закрыт на тех. работы через &f%TIME% &aминут."
|
||||
starttimerStarted: "&aТаймер успешно запущен! &aСервер будет закрыт на тех. работы через &f%TIME% &aминут."
|
||||
timerAlreadyRunning: "&cТаймер уже запущен!"
|
||||
timerNotRunning: "&cТаймер не был запущен."
|
||||
timerCancelled: "&7Таймер был остановлен."
|
||||
timerTooLong: "&cЧисло должно быть не больше чем &f40320 &c(&f28 &cдней)."
|
||||
timerMotdDisabled: "&cСообщения по таймеру выключены в настройках плагина."
|
||||
motdTimer: "%HOURS%:%MINUTES%:%SECONDS%"
|
||||
motdTimerNotRunning: "-"
|
||||
joinNotification: "&cИгрок &f%PLAYER% &cпытался зайти на сервер."
|
||||
motdList: "&7Список титульных строк в режиме тех. работ:"
|
||||
motdListEmpty: "&cСписок пуст."
|
||||
reload: "&aПлагин успешно перезагружен!"
|
||||
removedMotd: "&aТитульная строка с индексом &f%INDEX% &aуспешно удалена!"
|
||||
removeMotdError: "&cВы не можете удалить последние 2 титульные строки."
|
||||
setMotd: "&aТитульная строка &f%LINE% &aс индексом &f%INDEX% &aуспешно изменена: &f%MOTD%"
|
||||
setMotdIndexError: "&cНеверный индекс, допустимые значения: 1 - %NEWAMOUNT%."
|
||||
setMotdLineError: "&cВторой аргумент должен быть номером строки (1 или 2)!"
|
||||
updateDownloading: "&aОбновление загружается..."
|
||||
updateFailed: "&cОбновление не удалось!"
|
||||
updateFinished: "&aОбновление успешно пройдено! Перезагрузите сервер, чтобы избежать возможных проблем."
|
||||
whitelistedPlayers: "&7Белый лист в режиме тех. работ:"
|
||||
whitelistedPlayersFormat: "&7- &f%NAME% &7(&f%UUID%&7)"
|
||||
whitelistAdded: "&aИгрок &f%PLAYER% &aуспешно добавлен в белый лист!"
|
||||
whitelistAlreadyAdded: "&cИгрок &f%PLAYER% &cуже в белом листе!"
|
||||
whitelistRemoved: "&aИгрок &f%PLAYER% &aуспешно удалён из белого листа!"
|
||||
whitelistNotFound: "&cДанный игрок не находится в белом листе!"
|
||||
whitelistEmpty: "&cБелый лист пуст! Используйте /maintenance add [игрок|uuid] чтобы добавить кого-нибудь."
|
||||
playerNotFound: "&cИгрок не найден!"
|
||||
playerNotFoundUuid: "&cИгрок с таким UUID не найден!"
|
||||
playerNotOnline: "&cИгрок должен быть онлайн!"
|
||||
invalidUuid: "&cНеверный формат UUID!"
|
||||
|
||||
# Messages for the Bungee/Velocity part, just can ignore them if you use the plugin on Spigot/Sponge
|
||||
sentToWaitingServer: "&cYou have been sent to a waiting server!"
|
||||
forceWaitingServer: "&cYou cannot leave the waiting server while maintenance is enabled!"
|
||||
serverNotFound: "&cСервер не найден!"
|
||||
|
||||
singleTimerAlreadyRunning: "&cТаймер сервера &f%SERVER% &cуже запущен!"
|
||||
singleTimerCancelled: "&7Таймер сервера &f%SERVER% &7был остановлен."
|
||||
singleTimerNotRunning: "&cТаймер сервера &f%SERVER% &cне был запущен."
|
||||
singleEndtimerBroadcast: "&aСервер &f%SERVER% &aбудет открыт через &f%TIME% &aминут."
|
||||
singleStarttimerBroadcast: "&cВнимание! Сервер &f%SERVER% &cбудет закрыт на тех. работы через &f%TIME%&c."
|
||||
singleMaintenanceKick: "&cДанный сервер закрыт на тех. работы! Попробуйте позже."
|
||||
singleMaintenanceKickComplete: "&cДанный сервер закрыт на тех. работы!%NEWLINE%&cПопробуйте позже."
|
||||
singleMaintenanceActivated: "&aРежим тех. работ на сервере &f%SERVER% &aвключен!"
|
||||
singleMaintenanceDeactivated: "&aРежим тех. работ на сервере &f%SERVER% &aвыключен!"
|
||||
singleServerAlreadyEnabled: "&cРежим тех. работ на сервере &f%SERVER% &cуже включен!"
|
||||
singleServerAlreadyDisabled: "&cРежим тех. работ на сервере &f%SERVER% &cне был включен."
|
||||
singleServerMaintenanceList: "&7Сервера на которых включен режим тех. работ:"
|
||||
singleServerMaintenanceListEmpty: "&7Сервера на которых включен режим тех. работ: &fпусто"
|
||||
|
||||
second: "секунда"
|
||||
seconds: "секунд"
|
||||
minute: "минута"
|
||||
minutes: "минут"
|
||||
hour: "час"
|
||||
hours: "часов"
|
||||
|
||||
helpHeader: "&7========[ &f%NAME% &7| &6%PAGE%&f/&6%MAX% &7]========"
|
||||
helpPageNotFound: "&cСтраница не найдена."
|
||||
helpNextPage: "&fИспользуйте &6/maintenance help %PAGE% &fчтобы перейти на следующую страницу."
|
||||
helpAbortTimer: "&6/maintenance aborttimer &7- &fОстановить таймер включения/выключения режима тех. работ."
|
||||
helpEndtimer: "&6/maintenance endtimer [время в минутах] &7- &fЗапустить таймер выключения режима тех. работ."
|
||||
helpStarttimer: "&6/maintenance starttimer [время в минутах] &7- &fЗапустить таймер включения режима тех. работ."
|
||||
helpDump: "&6/maintenance dump &7- &fСоздать дамп."
|
||||
helpHelp: "&6/maintenance help [страница] &7- &fОтобразить список доступных команд."
|
||||
helpMotd: "&6/maintenance motd <timer> &7- &fОтобразить список титульных сообщений."
|
||||
helpRemoveMotd: "&6/maintenance removemotd <timer> [индекс] &7- &fУдалить титульное сообщение."
|
||||
helpSetMotd: "&6/maintenance setmotd <timer> [индекс] [1|2] [сообщение] &7- &fДобавить новое титульное сообщение."
|
||||
helpReload: "&6/maintenance reload &7- &fПерезагрузить плагин."
|
||||
helpToggle: "&6/maintenance [on|off] &7- &fВключить/выключить режим тех. работ."
|
||||
helpUpdate: "&6/maintenance update &7- &fОбновить плагин."
|
||||
helpWhitelist: "&6/maintenance whitelist &7- &fОтобразить всех игроков из белого списка."
|
||||
helpWhitelistAdd: "&6/maintenance add [ник|uuid] &7- &fДобавить игрока в белый список."
|
||||
helpWhitelistRemove: "&6/maintenance remove [ник|uuid] &7- &fУдалить игрока из белого списка."
|
||||
|
||||
# Messages for the Bungee/Velocity part, just can ignore them if you use the plugin on Spigot/Sponge
|
||||
helpAbortSingleTimer: "&6/maintenance aborttimer [сервер] &7- &fОстановить таймер включения/выключения режима тех. работ."
|
||||
helpSingleEndtimer: "&6/maintenance endtimer [сервер] [время в минутах] &7- &fЗапустить таймер выключения режима тех. работ."
|
||||
helpSingleStarttimer: "&6/maintenance starttimer [сервер] [время в минутах] &7- &fЗапустить таймер включения режима тех. работ."
|
||||
helpSingleToggle: "&6/maintenance [on|off] [сервер] &7- &fВключить/выключить режим тех. работы."
|
||||
helpStatus: "&6/maintenance status &7- &fСписок всех серверов закрытых на тех. работы."
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
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.maintenance</groupId>
|
||||
<artifactId>maintenance-parent</artifactId>
|
||||
<version>3.0.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>maintenance-spigot</artifactId>
|
||||
<name>MaintenanceSpigot</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>eu.kennytv.maintenance</groupId>
|
||||
<artifactId>maintenance-core</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.destroystokyo.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Needed for backwards compatibility with Paper -->
|
||||
<dependency>
|
||||
<groupId>com.mojang</groupId>
|
||||
<artifactId>authlib</artifactId>
|
||||
<version>1.5.25</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib-API</artifactId>
|
||||
<version>4.4.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.spigot;
|
||||
|
||||
import eu.kennytv.maintenance.api.IMaintenance;
|
||||
import eu.kennytv.maintenance.api.IMaintenanceBase;
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public final class MaintenanceSpigotBase extends JavaPlugin implements IMaintenanceBase {
|
||||
private MaintenancePlugin maintenance;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
maintenance = new MaintenanceSpigotPlugin(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
maintenance.disable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMaintenance getApi() {
|
||||
return maintenance;
|
||||
}
|
||||
|
||||
File getPluginFile() {
|
||||
return getFile();
|
||||
}
|
||||
}
|
||||
+218
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
* 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.spigot;
|
||||
|
||||
import eu.kennytv.maintenance.api.IMaintenance;
|
||||
import eu.kennytv.maintenance.api.spigot.MaintenanceSpigotAPI;
|
||||
import eu.kennytv.maintenance.core.MaintenancePlugin;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.core.dump.PluginDump;
|
||||
import eu.kennytv.maintenance.core.hook.ServerListPlusHook;
|
||||
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.spigot.command.MaintenanceSpigotCommand;
|
||||
import eu.kennytv.maintenance.spigot.listener.PaperServerListPingListener;
|
||||
import eu.kennytv.maintenance.spigot.listener.PlayerLoginListener;
|
||||
import eu.kennytv.maintenance.spigot.listener.ServerInfoPacketListener;
|
||||
import eu.kennytv.maintenance.spigot.listener.ServerListPingListener;
|
||||
import eu.kennytv.maintenance.spigot.metrics.MetricsLite;
|
||||
import eu.kennytv.maintenance.spigot.util.BukkitOfflinePlayerInfo;
|
||||
import eu.kennytv.maintenance.spigot.util.BukkitSenderInfo;
|
||||
import eu.kennytv.maintenance.spigot.util.BukkitTask;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.util.CachedServerIcon;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author KennyTV
|
||||
* @since 2.0
|
||||
*/
|
||||
public final class MaintenanceSpigotPlugin extends MaintenancePlugin {
|
||||
private final MaintenanceSpigotBase plugin;
|
||||
private CachedServerIcon favicon;
|
||||
|
||||
MaintenanceSpigotPlugin(final MaintenanceSpigotBase plugin) {
|
||||
super(plugin.getDescription().getVersion(), ServerType.SPIGOT);
|
||||
this.plugin = plugin;
|
||||
|
||||
settings = new Settings(this, "mysql", "proxied-maintenance-servers", "fallback", "waiting-server");
|
||||
|
||||
sendEnableMessage();
|
||||
|
||||
final MaintenanceSpigotCommand command = new MaintenanceSpigotCommand(this, settings);
|
||||
commandManager = command;
|
||||
plugin.getCommand("maintenancespigot").setExecutor(command);
|
||||
|
||||
final PluginManager pm = getServer().getPluginManager();
|
||||
pm.registerEvents(new PlayerLoginListener(this, settings), plugin);
|
||||
|
||||
if (canUsePaperListener()) {
|
||||
pm.registerEvents(new PaperServerListPingListener(this, settings), plugin);
|
||||
} else if (pm.isPluginEnabled("ProtocolLib")) {
|
||||
pm.registerEvents(new ServerInfoPacketListener(this, plugin, settings), plugin);
|
||||
} else {
|
||||
pm.registerEvents(new ServerListPingListener(this, settings), plugin);
|
||||
getLogger().warning("To use this plugin on Spigot to its full extend, you need the plugin ProtocolLib!");
|
||||
}
|
||||
|
||||
continueLastEndtimer();
|
||||
new MetricsLite(plugin);
|
||||
|
||||
// ServerListPlus integration
|
||||
final Plugin serverListPlus = pm.getPlugin("ServerListPlus");
|
||||
if (pm.isPluginEnabled(serverListPlus)) {
|
||||
serverListPlusHook = new ServerListPlusHook(serverListPlus);
|
||||
serverListPlusHook.setEnabled(!settings.isMaintenance());
|
||||
plugin.getLogger().info("Enabled ServerListPlus integration!");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canUsePaperListener() {
|
||||
try {
|
||||
Class.forName("com.destroystokyo.paper.event.server.PaperServerListPingEvent");
|
||||
if (getServer().getPluginManager().isPluginEnabled("ProtocolSupport")) {
|
||||
getLogger().warning("Found ProtocolSupport - switching to ProtocolLib packet adapter, as PS does not fire Paper's ping event");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (final ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static IMaintenance getAPI() {
|
||||
return MaintenanceSpigotAPI.getAPI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task startMaintenanceRunnable(final Runnable runnable) {
|
||||
return new BukkitTask(getServer().getScheduler().scheduleSyncRepeatingTask(plugin, runnable, 0, 20));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void async(final Runnable runnable) {
|
||||
getServer().getScheduler().runTaskAsynchronously(plugin, runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcast(final String message) {
|
||||
getServer().broadcastMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendUpdateNotification(final SenderInfo sender) {
|
||||
final TextComponent tc1 = new TextComponent(TextComponent.fromLegacyText(getPrefix()));
|
||||
final TextComponent tc2 = new TextComponent(TextComponent.fromLegacyText("§cDownload it at: §6https://www.spigotmc.org/resources/maintenance.40699/"));
|
||||
final TextComponent click = new TextComponent(TextComponent.fromLegacyText(" §7§l§o(CLICK ME)"));
|
||||
click.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.spigotmc.org/resources/maintenance.40699/"));
|
||||
click.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§aDownload the latest version").create()));
|
||||
tc1.addExtra(tc2);
|
||||
tc1.addExtra(click);
|
||||
((BukkitSenderInfo) sender).sendMessage(tc1, getPrefix() + "§cDownload it at: §6https://www.spigotmc.org/resources/maintenance.40699/");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SenderInfo getOfflinePlayer(final String name) {
|
||||
final OfflinePlayer player = getServer().getOfflinePlayer(name);
|
||||
return player.getName() != null ? new BukkitOfflinePlayerInfo(player) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SenderInfo getOfflinePlayer(final UUID uuid) {
|
||||
final OfflinePlayer player = getServer().getOfflinePlayer(uuid);
|
||||
return player.getName() != null ? new BukkitOfflinePlayerInfo(player) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void kickPlayers() {
|
||||
for (final Player p : getServer().getOnlinePlayers()) {
|
||||
if (!hasPermission(p, "bypass") && !settings.isWhitelisted(p.getUniqueId())) {
|
||||
p.kickPlayer(settings.getKickMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDataFolder() {
|
||||
return plugin.getDataFolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getPluginFile() {
|
||||
return plugin.getPluginFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getResource(final String name) {
|
||||
return plugin.getResource(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return plugin.getLogger();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerVersion() {
|
||||
return getServer().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PluginDump> getPlugins() {
|
||||
return Arrays.stream(getServer().getPluginManager().getPlugins()).map(plugin ->
|
||||
new PluginDump(plugin.getDescription().getName(), plugin.getDescription().getVersion(), plugin.getDescription().getAuthors())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadIcon(final File file) throws Exception {
|
||||
favicon = plugin.getServer().loadServerIcon(ImageIO.read(file));
|
||||
}
|
||||
|
||||
public boolean hasPermission(final CommandSender sender, final String permission) {
|
||||
return sender.hasPermission("maintenance." + permission) || sender.hasPermission("maintenance.admin");
|
||||
}
|
||||
|
||||
public Server getServer() {
|
||||
return plugin.getServer();
|
||||
}
|
||||
|
||||
public CachedServerIcon getFavicon() {
|
||||
return favicon;
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.spigot.command;
|
||||
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.core.command.MaintenanceCommand;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import eu.kennytv.maintenance.spigot.MaintenanceSpigotPlugin;
|
||||
import eu.kennytv.maintenance.spigot.util.BukkitSenderInfo;
|
||||
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 org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class MaintenanceSpigotCommand extends MaintenanceCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
public MaintenanceSpigotCommand(final MaintenanceSpigotPlugin plugin, final Settings settings) {
|
||||
super(plugin, settings);
|
||||
registerCommands();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String s, final String[] args) {
|
||||
execute(new BukkitSenderInfo(sender), args);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(final CommandSender sender, final Command command, final String alias, final String[] args) {
|
||||
return getSuggestions(new BukkitSenderInfo(sender), args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendDumpMessage(final SenderInfo sender, final String url) {
|
||||
final TextComponent clickText = new TextComponent(plugin.getPrefix() + "§7Click here to copy the link)");
|
||||
clickText.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, url));
|
||||
clickText.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§aClick here to copy the link")));
|
||||
((BukkitSenderInfo) sender).sendMessage(clickText, null);
|
||||
}
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* 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.spigot.listener;
|
||||
|
||||
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import com.destroystokyo.paper.profile.ProfileProperty;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.spigot.MaintenanceSpigotPlugin;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
public final class PaperServerListPingListener implements Listener {
|
||||
private final MaintenanceSpigotPlugin plugin;
|
||||
private final Settings settings;
|
||||
|
||||
public PaperServerListPingListener(final MaintenanceSpigotPlugin plugin, final Settings settings) {
|
||||
this.plugin = plugin;
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void serverListPing(final PaperServerListPingEvent event) {
|
||||
if (!settings.isMaintenance()) return;
|
||||
|
||||
event.setMotd(settings.getRandomPingMessage());
|
||||
|
||||
if (settings.hasCustomPlayerCountMessage()) {
|
||||
event.setProtocolVersion(-1);
|
||||
event.setVersion(settings.getPlayerCountMessage()
|
||||
.replace("%ONLINE%", Integer.toString(plugin.getServer().getOnlinePlayers().size()))
|
||||
.replace("%MAX%", Integer.toString(plugin.getServer().getMaxPlayers())));
|
||||
}
|
||||
|
||||
final List<PlayerProfile> sample = event.getPlayerSample();
|
||||
sample.clear();
|
||||
for (final String string : settings.getPlayerCountHoverMessage().split("%NEWLINE%"))
|
||||
sample.add(new DummyProfile(string));
|
||||
|
||||
if (settings.hasCustomIcon() && plugin.getFavicon() != null)
|
||||
event.setServerIcon(plugin.getFavicon());
|
||||
}
|
||||
|
||||
// Less unnecessary object creation :>
|
||||
private static final class DummyProfile implements PlayerProfile {
|
||||
private final String name;
|
||||
|
||||
private DummyProfile(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String setName(@Nullable final String name) {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public UUID getId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID setId(@Nullable final UUID uuid) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<ProfileProperty> getProperties() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasProperty(final String property) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperty(final ProfileProperty property) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperties(final Collection<ProfileProperty> properties) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeProperty(final String property) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearProperties() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean completeFromCache() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean complete(final boolean textures) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Keep this here for backwards compatibility
|
||||
public GameProfile getGameProfile() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 127 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user