From 1e1792d132e4ab0f63032a8a3ab0f461d1051b2f Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Sat, 22 Sep 2018 19:20:55 +0200
Subject: [PATCH 01/33] Version increase to 2.4.1-SNAPSHOT Update ProtocolLib
dependency to newest release
---
Maintenance-API/pom.xml | 2 +-
Maintenance-Bungee/pom.xml | 2 +-
Maintenance-Core/pom.xml | 2 +-
Maintenance-Parent/pom.xml | 2 +-
Maintenance-Spigot/pom.xml | 4 ++--
pom.xml | 2 +-
6 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/Maintenance-API/pom.xml b/Maintenance-API/pom.xml
index 34728b3a..71978dc5 100644
--- a/Maintenance-API/pom.xml
+++ b/Maintenance-API/pom.xml
@@ -6,7 +6,7 @@
maintenance-base
eu.kennytv
- 2.4
+ 2.4.1-SNAPSHOT
maintenance-api
diff --git a/Maintenance-Bungee/pom.xml b/Maintenance-Bungee/pom.xml
index 90c2e9a3..b08b00db 100644
--- a/Maintenance-Bungee/pom.xml
+++ b/Maintenance-Bungee/pom.xml
@@ -6,7 +6,7 @@
maintenance-base
eu.kennytv
- 2.4
+ 2.4.1-SNAPSHOT
maintenance-bungee
diff --git a/Maintenance-Core/pom.xml b/Maintenance-Core/pom.xml
index aa0286c7..0ae04a04 100644
--- a/Maintenance-Core/pom.xml
+++ b/Maintenance-Core/pom.xml
@@ -6,7 +6,7 @@
maintenance-base
eu.kennytv
- 2.4
+ 2.4.1-SNAPSHOT
maintenance-core
diff --git a/Maintenance-Parent/pom.xml b/Maintenance-Parent/pom.xml
index 5c8110f1..a21c6a13 100644
--- a/Maintenance-Parent/pom.xml
+++ b/Maintenance-Parent/pom.xml
@@ -6,7 +6,7 @@
maintenance-base
eu.kennytv
- 2.4
+ 2.4.1-SNAPSHOT
maintenance-parent
diff --git a/Maintenance-Spigot/pom.xml b/Maintenance-Spigot/pom.xml
index cdd2c3ce..6e04a5bf 100644
--- a/Maintenance-Spigot/pom.xml
+++ b/Maintenance-Spigot/pom.xml
@@ -6,7 +6,7 @@
maintenance-base
eu.kennytv
- 2.4
+ 2.4.1-SNAPSHOT
maintenance-spigot
@@ -45,7 +45,7 @@
com.comphenix.protocol
ProtocolLib-API
- 4.4.0-SNAPSHOT
+ 4.4.0
provided
diff --git a/pom.xml b/pom.xml
index a719132b..b5798f17 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
eu.kennytv
maintenance-base
- 2.4
+ 2.4.1-SNAPSHOT
Maintenance
pom
From 38c8e1d2c3787f4970685cab4db128d7fd294a73 Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Wed, 26 Sep 2018 11:11:56 +0200
Subject: [PATCH 02/33] Shade slf4j to fix compatibility with plugins using
older Hikari dependencies
---
pom.xml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/pom.xml b/pom.xml
index b5798f17..21385303 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,6 +44,10 @@
com.zaxxer.hikari
eu.kennytv.lib.hikari
+
+ org.slf4j
+ eu.kennytv.lib.slf4j
+
From aaed1b32cdffaef1fd97ef4168c6afcf3ae64680 Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Thu, 27 Sep 2018 09:57:56 +0200
Subject: [PATCH 03/33] Fix starttimer command not working Remove slf4j shade
for now
---
.../kennytv/maintenance/core/command/MaintenanceCommand.java | 2 +-
pom.xml | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
index 16b947d0..14eb9d27 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
@@ -123,8 +123,8 @@ public void execute(final SenderInfo sender, final String[] args) {
return;
}
- sender.sendMessage(settings.getMessage("starttimerStarted").replace("%TIME%", plugin.getRunnable().getTime()));
plugin.startMaintenanceRunnable(minutes, true);
+ sender.sendMessage(settings.getMessage("starttimerStarted").replace("%TIME%", plugin.getRunnable().getTime()));
} else if (args[0].equalsIgnoreCase("timer")) {
if (args[1].equalsIgnoreCase("abort") || args[1].equalsIgnoreCase("stop") || args[1].equalsIgnoreCase("cancel")) {
if (checkPermission(sender, "timer")) return;
diff --git a/pom.xml b/pom.xml
index 21385303..6a54b45f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,10 +44,10 @@
com.zaxxer.hikari
eu.kennytv.lib.hikari
-
+
From ff3b117189bd64faf4131a1ae0461734eadc1007 Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Thu, 27 Sep 2018 10:14:29 +0200
Subject: [PATCH 04/33] Make SenderInfo an interface instead of an abstract
class
---
.../maintenance/bungee/util/ProxiedSenderInfo.java | 2 +-
.../eu/kennytv/maintenance/core/util/SenderInfo.java | 10 +++++-----
.../maintenance/spigot/util/BukkitSenderInfo.java | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/util/ProxiedSenderInfo.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/util/ProxiedSenderInfo.java
index d7c68ce0..06f8922d 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/util/ProxiedSenderInfo.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/util/ProxiedSenderInfo.java
@@ -7,7 +7,7 @@
import java.util.UUID;
-public final class ProxiedSenderInfo extends SenderInfo {
+public final class ProxiedSenderInfo implements SenderInfo {
private final CommandSender sender;
public ProxiedSenderInfo(final CommandSender sender) {
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/util/SenderInfo.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/util/SenderInfo.java
index 75c68d61..0c7cf67e 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/util/SenderInfo.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/util/SenderInfo.java
@@ -2,13 +2,13 @@
import java.util.UUID;
-public abstract class SenderInfo {
+public interface SenderInfo {
- public abstract UUID getUuid();
+ UUID getUuid();
- public abstract String getName();
+ String getName();
- public abstract boolean hasPermission(String permission);
+ boolean hasPermission(String permission);
- public abstract void sendMessage(String message);
+ void sendMessage(String message);
}
\ No newline at end of file
diff --git a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/util/BukkitSenderInfo.java b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/util/BukkitSenderInfo.java
index f7deef43..ce3a204c 100644
--- a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/util/BukkitSenderInfo.java
+++ b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/util/BukkitSenderInfo.java
@@ -6,7 +6,7 @@
import java.util.UUID;
-public final class BukkitSenderInfo extends SenderInfo {
+public final class BukkitSenderInfo implements SenderInfo {
private final CommandSender sender;
public BukkitSenderInfo(final CommandSender sender) {
From 1c0688a172375bc54f256d1ca34e9e82a667dcd1 Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Fri, 28 Sep 2018 12:00:40 +0200
Subject: [PATCH 05/33] Add language-de
---
.../core/MaintenanceModePlugin.java | 3 ++
.../src/main/resources/language-de.yml | 48 +++++++++++++++++++
2 files changed, 51 insertions(+)
create mode 100644 Maintenance-Core/src/main/resources/language-de.yml
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java
index 77c1e1cd..df0b3f12 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java
@@ -18,6 +18,9 @@ public abstract class MaintenanceModePlugin implements IMaintenance {
private final String prefix;
private String newestVersion;
+ //TODO language file system
+ //TODO merge bungee and spigot config (?)
+ //TODO enable maintenance on single servers on bungee
protected MaintenanceModePlugin(final String prefix, final String version) {
this.prefix = prefix;
this.version = version;
diff --git a/Maintenance-Core/src/main/resources/language-de.yml b/Maintenance-Core/src/main/resources/language-de.yml
new file mode 100644
index 00000000..83384b7f
--- /dev/null
+++ b/Maintenance-Core/src/main/resources/language-de.yml
@@ -0,0 +1,48 @@
+# 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."
+reload: "&8[&eMaintenance&8] &aConfig, WhitelistedPlayers, Language Datei und Maintenance Icon wurden neugeladen."
+alreadyEnabled: "&8[&eMaintenance&8] &cDer Wartungsmodus ist bereits aktiviert!"
+alreadyDisabled: "&8[&eMaintenance&8] &cDer Wartungsmodus ist bereits deaktiviert!"
+maintenanceActivated: "&8[&eMaintenance&8] &6Der Wartungsmodus ist nun aktiviert."
+maintenanceDeactivated: "&8[&eMaintenance&8] &6Der Wartungsmodus ist nun deaktiviert."
+starttimerUsage: "&8[&eMaintenance&8] &c/maintenance starttimer "
+starttimerStarted: "&8[&eMaintenance&8] &aGestarteter Timer: &7Der Wartungsmodus wird aktiviert in: &6%TIME%&7"
+starttimerBroadcast: "&8[&eMaintenance&8] &7Der Wartungsmodus wird aktiviert in: &6%TIME%&7."
+endtimerUsage: "&8[&eMaintenance&8] &c/maintenance endtimer "
+endtimerStarted: "&8[&eMaintenance&8] &aGestarteter Timer: &7Der Wartungsmodus wird aktiviert in: &6%TIME%&7."
+endtimerBroadcast: "&8[&eMaintenance&8] &7Der Wartungsmodus wird aktiviert in: &6%TIME%&7."
+timerTooLong: "&8[&eMaintenance&8] &cDie angegebene Nummer muss kleiner als 40320 sein (= 28 Tage)!"
+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."
+joinNotification: "&8[&eMaintenance&8] &e%PLAYER% &chat versucht den Server beizutreten."
+updateDownloading: "&8[&eMaintenance&8] &c&lUpdate wird heruntergeladen..."
+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!"
+updateFailed: "&8[&eMaintenance&8] &4&lUpdate fehlgeschlagen!"
+setMotdUsage: "&8[&eMaintenance&8] &c/maintenance setmotd <1/2> "
+setMotdLineError: "&8[&eMaintenance&8] &cDas zweite Argument muss die Zeilennummer sein (1 oder 2)!"
+setMotdIndexError: "&8[&eMaintenance&8] §cMomentan gibt es %MOTDS% MOTDs, du musst also eine Zahl zwischen 1 and %NEWAMOUNT% wählen."
+setMotd: "&8[&eMaintenance&8] &aDie %LINE%. Zeile der %INDEX%. Maintenance MOTD wurde geändert zu: %MOTD%"
+removeMotdUsage: "&8[&eMaintenance&8] &c/maintenance removemotd "
+removeMotdError: "&8[&eMaintenance&8] &cDu hast nur eine Maintenance MOTD, daher kannst du auch keine entfernen!"
+removedMotd: "&8[&eMaintenance&8] &aDie %INDEX%. Maintenance MOTD wurde entfernt."
+motdList: "&8[&eMaintenance&8] &7Liste der Maintenance MOTDs:"
+whitelistEmtpy: "&8[&eMaintenance&8] &cDie Maintenance Whitelist ist leer! Nutze '/maintenance add ', um jemanden hinzuzufügen!"
+whitelistEmptyDefault: "&8[&eMaintenance&8] &cNutze '/maintenance add ', um jemanden hinzuzufügen. Ansonsten kannst auch die UUID des Spielers in die WhitelistedPlayers.yml einsetzen, wie es im dortigen Beispiel schon drinsteht!"
+whitelistedPlayers: "&8[&eMaintenance&8] &6Spieler in der Maintenance Whitelist:"
+whitelistedPlayersFormat: "&8- &e%NAME% &8(&7%UUID%&8)"
+whitelistNotFound: "&8[&eMaintenance&8] &cDieser Spieler ist nicht in der Maintenance Whitelist!"
+whitelistAlreadyAdded: "&8[&eMaintenance&8] &b%PLAYER% &cist bereits in der Maintenance Whitelist!"
+whitelistAdded: "&8[&eMaintenance&8] &b%PLAYER% &awurde zur Maintenance Whitelist hinzugefügt!"
+whitelistRemoved: "&8[&eMaintenance&8] &b%PLAYER% &awurde von der Maintenance Whitelist entfernt!"
+playerNotOnline: "&8[&eMaintenance&8] &cEs ist momentan kein Spieler mit diesem Namen online."
+playerNotFound: "&8[&eMaintenance&8] &cBisher hat kein Spieler mit diesem Namen jemals auf diesem Server gespielt."
+
+second: "Sekunde"
+seconds: "Sekunden"
+minute: "Minute"
+minutes: "Minuten"
+hour: "Stunde"
+hours: "Stunden"
\ No newline at end of file
From d99300ecac77bc08e3a8f92041750a101d57287f Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Fri, 28 Sep 2018 12:42:06 +0200
Subject: [PATCH 06/33] Version increase to 2.5-SNAPSHOT Increase from
2.4.1-SNAPSHOT as bigger feature updates are planned
---
Maintenance-API/pom.xml | 2 +-
Maintenance-Bungee/pom.xml | 2 +-
Maintenance-Core/pom.xml | 2 +-
Maintenance-Parent/pom.xml | 2 +-
Maintenance-Spigot/pom.xml | 2 +-
pom.xml | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/Maintenance-API/pom.xml b/Maintenance-API/pom.xml
index 71978dc5..810c5032 100644
--- a/Maintenance-API/pom.xml
+++ b/Maintenance-API/pom.xml
@@ -6,7 +6,7 @@
maintenance-base
eu.kennytv
- 2.4.1-SNAPSHOT
+ 2.5-SNAPSHOT
maintenance-api
diff --git a/Maintenance-Bungee/pom.xml b/Maintenance-Bungee/pom.xml
index b08b00db..cce073f7 100644
--- a/Maintenance-Bungee/pom.xml
+++ b/Maintenance-Bungee/pom.xml
@@ -6,7 +6,7 @@
maintenance-base
eu.kennytv
- 2.4.1-SNAPSHOT
+ 2.5-SNAPSHOT
maintenance-bungee
diff --git a/Maintenance-Core/pom.xml b/Maintenance-Core/pom.xml
index 0ae04a04..07c68214 100644
--- a/Maintenance-Core/pom.xml
+++ b/Maintenance-Core/pom.xml
@@ -6,7 +6,7 @@
maintenance-base
eu.kennytv
- 2.4.1-SNAPSHOT
+ 2.5-SNAPSHOT
maintenance-core
diff --git a/Maintenance-Parent/pom.xml b/Maintenance-Parent/pom.xml
index a21c6a13..39e65c9f 100644
--- a/Maintenance-Parent/pom.xml
+++ b/Maintenance-Parent/pom.xml
@@ -6,7 +6,7 @@
maintenance-base
eu.kennytv
- 2.4.1-SNAPSHOT
+ 2.5-SNAPSHOT
maintenance-parent
diff --git a/Maintenance-Spigot/pom.xml b/Maintenance-Spigot/pom.xml
index 6e04a5bf..391fffd6 100644
--- a/Maintenance-Spigot/pom.xml
+++ b/Maintenance-Spigot/pom.xml
@@ -6,7 +6,7 @@
maintenance-base
eu.kennytv
- 2.4.1-SNAPSHOT
+ 2.5-SNAPSHOT
maintenance-spigot
diff --git a/pom.xml b/pom.xml
index 6a54b45f..ed35a1aa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
eu.kennytv
maintenance-base
- 2.4.1-SNAPSHOT
+ 2.5-SNAPSHOT
Maintenance
pom
From b5550dfe82a38b152f58ccae5758a086e8d67b4c Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Fri, 28 Sep 2018 13:22:55 +0200
Subject: [PATCH 07/33] Add multiple language support
---
.../maintenance/bungee/SettingsBungee.java | 15 +++++-
.../src/main/resources/bungee-config.yml | 4 ++
.../eu/kennytv/maintenance/core/Settings.java | 10 ++++
.../src/main/resources/language-en.yml | 48 +++++++++++++++++++
.../maintenance/spigot/SettingsSpigot.java | 31 ++++++++++--
.../src/main/resources/spigot-config.yml | 6 ++-
6 files changed, 107 insertions(+), 7 deletions(-)
create mode 100644 Maintenance-Core/src/main/resources/language-en.yml
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
index 7f14169e..3f623c27 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
@@ -44,7 +44,7 @@ public final class SettingsBungee extends Settings {
if (!plugin.getDataFolder().exists())
plugin.getDataFolder().mkdirs();
createFile("bungee-config.yml");
- createFile("language.yml");
+ createLanguageFile();
createFile("WhitelistedPlayers.yml");
reloadConfigs();
@@ -82,6 +82,19 @@ private void createFile(final String name) {
}
}
+ private void createLanguageFile() {
+ final File file = new File(plugin.getDataFolder(), "language.yml");
+ if (!file.exists()) {
+ try (final InputStream in = plugin.getResourceAsStream("language-" + getLanguage() + ".yml")) {
+ Files.copy(in, file.toPath());
+ } catch (final IOException e) {
+ plugin.getLogger().warning("Unable to provide language " + getLanguage());
+ plugin.getLogger().warning("Falling back to default language: en");
+ createFile("language.yml");
+ }
+ }
+ }
+
@Override
public boolean updateExtraConfig() {
// 2.3.1 mysql.update-interval
diff --git a/Maintenance-Bungee/src/main/resources/bungee-config.yml b/Maintenance-Bungee/src/main/resources/bungee-config.yml
index a3c14d62..9fca1355 100644
--- a/Maintenance-Bungee/src/main/resources/bungee-config.yml
+++ b/Maintenance-Bungee/src/main/resources/bungee-config.yml
@@ -34,6 +34,10 @@ send-join-notification: false
# If set to true, the server icon will be changed to maintenance-icon.png in the Bungee main/base-folder.
custom-maintenance-icon: false
+# Changes the language of command feedback/messages.
+# Currently available are: en (English), de (German)
+language: en
+
# Only enable MySQL if you really know what you are doing.
mysql:
use-mysql: false
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/Settings.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/Settings.java
index 16ad38f6..88311057 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/Settings.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/Settings.java
@@ -14,6 +14,7 @@ public abstract class Settings implements ISettings {
private String playerCountMessage;
private String playerCountHoverMessage;
private String kickMessage;
+ private String languageName;
private boolean customPlayerCountMessage;
private boolean customMaintenanceIcon;
private boolean joinNotifications;
@@ -34,6 +35,7 @@ protected void loadSettings() {
playerCountMessage = getColoredString(getConfigString("playercountmessage"));
playerCountHoverMessage = getColoredString(getConfigString("playercounthovermessage"));
kickMessage = getColoredString(getConfigString("kickmessage"));
+ languageName = getConfigString("language");
if (customMaintenanceIcon)
reloadMaintenanceIcon();
@@ -62,6 +64,10 @@ private void updateConfig() {
setToConfig("timer-broadcasts-for-minutes", null);
fileChanged = true;
}
+ // 2.5 language
+ if (!configContains("language")) {
+ setToConfig("language", "en");
+ }
if (updateExtraConfig() || fileChanged) {
saveConfig();
@@ -119,6 +125,10 @@ public String getKickMessage() {
return kickMessage;
}
+ public String getLanguage() {
+ return languageName;
+ }
+
public void setMaintenance(final boolean maintenance) {
this.maintenance = maintenance;
}
diff --git a/Maintenance-Core/src/main/resources/language-en.yml b/Maintenance-Core/src/main/resources/language-en.yml
new file mode 100644
index 00000000..a1f9500e
--- /dev/null
+++ b/Maintenance-Core/src/main/resources/language-en.yml
@@ -0,0 +1,48 @@
+# 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."
+reload: "&8[&eMaintenance&8] &aReloaded config, whitelistedplayers, language file and the maintenance icon."
+alreadyEnabled: "&8[&eMaintenance&8] &cMaintenance already is enabled!"
+alreadyDisabled: "&8[&eMaintenance&8] &cMaintenance already is disabled!"
+maintenanceActivated: "&8[&eMaintenance&8] &6Maintenance mode is now activated."
+maintenanceDeactivated: "&8[&eMaintenance&8] &6Maintenance mode is now deactivated."
+starttimerUsage: "&8[&eMaintenance&8] &c/maintenance starttimer "
+starttimerStarted: "&8[&eMaintenance&8] &aStarted timer: &7Maintenance mode will be activated in &6%TIME%&7."
+starttimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode will be enabled in &6%TIME%&7."
+endtimerUsage: "&8[&eMaintenance&8] &c/maintenance endtimer "
+endtimerStarted: "&8[&eMaintenance&8] &aStarted timer: &7Maintenance mode will be deactivated in &6%TIME%&7."
+endtimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode will be disabled in &6%TIME%&7."
+timerTooLong: "&8[&eMaintenance&8] &cThe number has to be less than 40320 (28 days)!"
+timerAlreadyRunning: "&8[&eMaintenance&8] &cThere's already a starttimer scheduled!"
+timerNotRunning: "&8[&eMaintenance&8] &cThere's currently no running timer."
+timerCancelled: "&8[&eMaintenance&8] &cThe current timer has been disabled."
+joinNotification: "&8[&eMaintenance&8] &e%PLAYER% &ctried to join the server."
+updateDownloading: "&8[&eMaintenance&8] &c&lDownloading update..."
+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!"
+updateFailed: "&8[&eMaintenance&8] &4&lUpdate failed!"
+setMotdUsage: "&8[&eMaintenance&8] &c/maintenance setmotd <1/2> "
+setMotdLineError: "&8[&eMaintenance&8] &cThe second argument has to be the line number (1 or 2)!"
+setMotdIndexError: "&8[&eMaintenance&8] §cYou currently have %MOTDS% motds, so you have to pick a number between 1 and %NEWAMOUNT%."
+setMotd: "&8[&eMaintenance&8] &aSet line %LINE% of the %INDEX%. maintenance motd to %MOTD%"
+removeMotdUsage: "&8[&eMaintenance&8] &c/maintenance removemotd "
+removeMotdError: "&8[&eMaintenance&8] &cYou only have one motd, so you can't remove any!"
+removedMotd: "&8[&eMaintenance&8] &aRemoved motd number %INDEX%."
+motdList: "&8[&eMaintenance&8] &7List of your maintenance motds:"
+whitelistEmtpy: "&8[&eMaintenance&8] &cThe maintenance whitelist is empty! Use '/maintenance add ' to add someone!"
+whitelistEmptyDefault: "&8[&eMaintenance&8] &cUse '/maintenance add ' to add someone. Alternatively, you can add the uuid of a player to the WhitelistedPlayers.yml as seen in the example in the file!"
+whitelistedPlayers: "&8[&eMaintenance&8] &6Whitelisted players for maintenance:"
+whitelistedPlayersFormat: "&8- &e%NAME% &8(&7%UUID%&8)"
+whitelistNotFound: "&8[&eMaintenance&8] &cThis player is not in the maintenance whitelist!"
+whitelistAlreadyAdded: "&8[&eMaintenance&8] &b%PLAYER% &calready is in the maintenance whitelist!"
+whitelistAdded: "&8[&eMaintenance&8] &aAdded &b%PLAYER% &ato the maintenance whitelist!"
+whitelistRemoved: "&8[&eMaintenance&8] &aRemoved &b%PLAYER% &afrom the maintenance whitelist!"
+playerNotOnline: "&8[&eMaintenance&8] &cThere's no player online with that name."
+playerNotFound: "&8[&eMaintenance&8] &cNo player with this name has played on this server before."
+
+second: "second"
+seconds: "seconds"
+minute: "minute"
+minutes: "minutes"
+hour: "hour"
+hours: "hours"
\ No newline at end of file
diff --git a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/SettingsSpigot.java b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/SettingsSpigot.java
index 151f4cd7..cfbb76d8 100644
--- a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/SettingsSpigot.java
+++ b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/SettingsSpigot.java
@@ -38,7 +38,7 @@ public final class SettingsSpigot extends Settings {
if (!plugin.getDataFolder().exists())
plugin.getDataFolder().mkdirs();
createFile("spigot-config.yml");
- createFile("language.yml");
+ createLanguageFile();
createFile("WhitelistedPlayers.yml");
reloadConfigs();
@@ -55,6 +55,29 @@ private void createFile(final String name) {
}
}
+ private void createLanguageFile() {
+ final File file = new File(plugin.getDataFolder(), "language.yml");
+ if (!file.exists()) {
+ try (final InputStream in = plugin.getResource("language-" + getLanguage() + ".yml")) {
+ Files.copy(in, file.toPath());
+ } catch (final IOException e) {
+ plugin.getLogger().warning("Unable to provide language " + getLanguage());
+ plugin.getLogger().warning("Falling back to default language: en");
+ createFile("language.yml");
+ }
+ }
+ }
+
+ @Override
+ public boolean updateExtraConfig() {
+ // Remove MySQL part from default config
+ if (configContains("mysql")) {
+ setToConfig("mysql", null);
+ return true;
+ }
+ return false;
+ }
+
@Override
public void saveConfig() {
try {
@@ -76,10 +99,8 @@ public void saveWhitelistedPlayers() {
@Override
public void reloadConfigs() {
try {
- final File file = new File(plugin.getDataFolder(), "spigot-config.yml");
- config = YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8));
- final File languageFile = new File(plugin.getDataFolder(), "language.yml");
- language = YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(languageFile), StandardCharsets.UTF_8));
+ config = YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(new File(plugin.getDataFolder(), "spigot-config.yml")), StandardCharsets.UTF_8));
+ language = YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(new File(plugin.getDataFolder(), "language.yml")), StandardCharsets.UTF_8));
whitelist = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "WhitelistedPlayers.yml"));
} catch (final IOException e) {
throw new RuntimeException("Unable to load Maintenance files!", e);
diff --git a/Maintenance-Spigot/src/main/resources/spigot-config.yml b/Maintenance-Spigot/src/main/resources/spigot-config.yml
index 7531f7b8..b4e0c19a 100644
--- a/Maintenance-Spigot/src/main/resources/spigot-config.yml
+++ b/Maintenance-Spigot/src/main/resources/spigot-config.yml
@@ -33,4 +33,8 @@ timer-broadcast-for-seconds: [1200, 900, 600, 300, 120, 60, 30, 20, 10, 5, 4, 3,
send-join-notification: false
# If set to true, the server icon will be changed to maintenance-icon.png in the Bungee main/base-folder.
-custom-maintenance-icon: false
\ No newline at end of file
+custom-maintenance-icon: false
+
+# Changes the language of command feedback/messages.
+# Currently available are: en (English), de (German)
+language: en
\ No newline at end of file
From a93b0834a2dd69f600d428881cc896307ec21c1d Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Sun, 30 Sep 2018 11:29:48 +0200
Subject: [PATCH 08/33] Remove more or less deprecated Guava usages
---
.../maintenance/bungee/listener/PostLoginListener.java | 4 ++--
.../eu/kennytv/maintenance/core/MaintenanceModePlugin.java | 3 +--
.../kennytv/maintenance/spigot/listener/PacketListener.java | 4 ++--
.../maintenance/spigot/listener/PlayerLoginListener.java | 4 ++--
4 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/PostLoginListener.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/PostLoginListener.java
index 2afe3c39..85ce44be 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/PostLoginListener.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/PostLoginListener.java
@@ -1,6 +1,5 @@
package eu.kennytv.maintenance.bungee.listener;
-import com.google.common.collect.Sets;
import eu.kennytv.maintenance.bungee.MaintenanceBungeePlugin;
import eu.kennytv.maintenance.bungee.SettingsBungee;
import net.md_5.bungee.api.chat.ClickEvent;
@@ -13,13 +12,14 @@
import net.md_5.bungee.event.EventHandler;
import net.md_5.bungee.event.EventPriority;
+import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
public final class PostLoginListener implements Listener {
private final MaintenanceBungeePlugin plugin;
private final SettingsBungee settings;
- private final Set notifiedPlayers = Sets.newHashSet();
+ private final Set notifiedPlayers = new HashSet<>();
public PostLoginListener(final MaintenanceBungeePlugin plugin, final SettingsBungee settings) {
this.plugin = plugin;
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java
index df0b3f12..44971f43 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java
@@ -18,8 +18,7 @@ public abstract class MaintenanceModePlugin implements IMaintenance {
private final String prefix;
private String newestVersion;
- //TODO language file system
- //TODO merge bungee and spigot config (?)
+ //TODO merge bungee and spigot config
//TODO enable maintenance on single servers on bungee
protected MaintenanceModePlugin(final String prefix, final String version) {
this.prefix = prefix;
diff --git a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/listener/PacketListener.java b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/listener/PacketListener.java
index fc9d0e1e..45349a89 100644
--- a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/listener/PacketListener.java
+++ b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/listener/PacketListener.java
@@ -7,13 +7,13 @@
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import com.comphenix.protocol.wrappers.WrappedServerPing;
-import com.google.common.collect.Lists;
import eu.kennytv.maintenance.core.listener.IPingListener;
import eu.kennytv.maintenance.spigot.MaintenanceSpigotBase;
import eu.kennytv.maintenance.spigot.SettingsSpigot;
import javax.imageio.ImageIO;
import java.io.File;
+import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@@ -39,7 +39,7 @@ public void onPacketSending(final PacketEvent event) {
.replace("%MAX%", Integer.toString(pl.getServer().getMaxPlayers())));
}
- final List players = Lists.newArrayList();
+ final List players = new ArrayList<>();
for (final String string : settings.getPlayerCountHoverMessage().split("%NEWLINE%"))
players.add(new WrappedGameProfile(UUID.randomUUID(), string));
ping.setPlayers(players);
diff --git a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/listener/PlayerLoginListener.java b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/listener/PlayerLoginListener.java
index e5d42988..674f8c92 100644
--- a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/listener/PlayerLoginListener.java
+++ b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/listener/PlayerLoginListener.java
@@ -1,6 +1,5 @@
package eu.kennytv.maintenance.spigot.listener;
-import com.google.common.collect.Sets;
import eu.kennytv.maintenance.spigot.MaintenanceSpigotPlugin;
import eu.kennytv.maintenance.spigot.SettingsSpigot;
import net.md_5.bungee.api.chat.ClickEvent;
@@ -14,13 +13,14 @@
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerLoginEvent;
+import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
public final class PlayerLoginListener implements Listener {
private final MaintenanceSpigotPlugin plugin;
private final SettingsSpigot settings;
- private final Set notifiedPlayers = Sets.newHashSet();
+ private final Set notifiedPlayers = new HashSet<>();
public PlayerLoginListener(final MaintenanceSpigotPlugin plugin, final SettingsSpigot settings) {
this.plugin = plugin;
From 234086444faf51d9b40087fa9e2a042992794b88 Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Tue, 2 Oct 2018 11:56:30 +0200
Subject: [PATCH 09/33] WIP: Add possibility to set single servers to
maintenance
---
.../bungee/MaintenanceBungeePlugin.java | 3 ++-
.../maintenance/bungee/SettingsBungee.java | 11 ++++++++++
.../command/MaintenanceBungeeCommand.java | 20 +++++++++++++++++++
.../core/MaintenanceModePlugin.java | 11 +++++++---
.../core/command/MaintenanceCommand.java | 17 +++++++++++++---
.../maintenance/core/util/ServerType.java | 7 +++++++
.../src/main/resources/language-de.yml | 1 +
.../src/main/resources/language-en.yml | 1 +
.../src/main/resources/language.yml | 1 +
.../spigot/MaintenanceSpigotPlugin.java | 3 ++-
.../command/MaintenanceSpigotCommand.java | 5 +++++
11 files changed, 72 insertions(+), 8 deletions(-)
create mode 100644 Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/util/ServerType.java
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
index fbd6f328..a93b190f 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
@@ -9,6 +9,7 @@
import eu.kennytv.maintenance.bungee.metrics.MetricsLite;
import eu.kennytv.maintenance.core.MaintenanceModePlugin;
import eu.kennytv.maintenance.core.hook.ServerListPlusHook;
+import eu.kennytv.maintenance.core.util.ServerType;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.api.plugin.PluginManager;
@@ -26,7 +27,7 @@ public final class MaintenanceBungeePlugin extends MaintenanceModePlugin {
private final SettingsBungee settings;
MaintenanceBungeePlugin(final MaintenanceBungeeBase plugin) {
- super("§8[§eMaintenanceBungee§8] ", plugin.getDescription().getVersion());
+ super("§8[§eMaintenanceBungee§8] ", plugin.getDescription().getVersion(), ServerType.BUNGEE);
this.plugin = plugin;
plugin.getLogger().info("Plugin by KennyTV");
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
index 3f623c27..f7c5c4ec 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
@@ -13,7 +13,9 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.sql.SQLException;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import java.util.UUID;
public final class SettingsBungee extends Settings {
@@ -24,6 +26,7 @@ public final class SettingsBungee extends Settings {
private final MaintenanceBungeePlugin maintenancePlugin;
private final MaintenanceBungeeBase plugin;
private final IPingListener pingListener;
+ private final Set maintenanceServers = new HashSet<>();
private Configuration config;
private Configuration language;
private Configuration whitelist;
@@ -248,4 +251,12 @@ public void setMaintenanceToSQL(final boolean maintenance) {
public MySQL getMySQL() {
return mySQL;
}
+
+ public Set getMaintenanceServers() {
+ return maintenanceServers;
+ }
+
+ public void setMaintenanceToServer(final String server, final boolean maintenance) {
+ //TODO
+ }
}
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
index 14fbdd3e..279dd06f 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
@@ -9,12 +9,15 @@
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;
public final class MaintenanceBungeeCommand extends MaintenanceCommand {
+ private final SettingsBungee settingsBungee;
public MaintenanceBungeeCommand(final MaintenanceBungeePlugin plugin, final SettingsBungee settings) {
super(plugin, settings, "MaintenanceBungee");
+ settingsBungee = settings;
}
@Override
@@ -63,4 +66,21 @@ protected void checkForUpdate(final SenderInfo sender) {
} else
sender.sendMessage(plugin.getPrefix() + "§aYou already have the latest version of the plugin!");
}
+
+ @Override
+ protected void handleToggleServerCommand(final SenderInfo sender, final String args[]) {
+ final ServerInfo server = ProxyServer.getInstance().getServerInfo(args[1]);
+ if (server == null) {
+ sender.sendMessage(settings.getMessage("serverNotFound"));
+ return;
+ }
+
+ final boolean maintenance = args[0].equalsIgnoreCase("on");
+ if (maintenance == settingsBungee.getMaintenanceServers().contains(server.getName())) {
+ sender.sendMessage(settings.getMessage(maintenance ? "alreadyEnabled" : "alreadyDisabled"));
+ return;
+ }
+
+ settingsBungee.setMaintenanceToServer(server.getName(), maintenance);
+ }
}
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java
index 44971f43..f57a6e6e 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java
@@ -3,6 +3,7 @@
import eu.kennytv.maintenance.api.IMaintenance;
import eu.kennytv.maintenance.core.hook.ServerListPlusHook;
import eu.kennytv.maintenance.core.runnable.MaintenanceRunnable;
+import eu.kennytv.maintenance.core.util.ServerType;
import java.io.*;
import java.net.HttpURLConnection;
@@ -16,13 +17,13 @@ public abstract class MaintenanceModePlugin implements IMaintenance {
protected MaintenanceRunnable runnable;
protected int taskId;
private final String prefix;
+ private final ServerType serverType;
private String newestVersion;
- //TODO merge bungee and spigot config
- //TODO enable maintenance on single servers on bungee
- protected MaintenanceModePlugin(final String prefix, final String version) {
+ protected MaintenanceModePlugin(final String prefix, final String version, final ServerType serverType) {
this.prefix = prefix;
this.version = version;
+ this.serverType = serverType;
}
@Override
@@ -67,6 +68,10 @@ public String getPrefix() {
return prefix;
}
+ public ServerType getServerType() {
+ return serverType;
+ }
+
public String formatedTimer() {
if (!isTaskRunning()) return "-";
final int preHours = runnable.getSecondsLeft() / 60;
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
index 14eb9d27..59cfdfe9 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
@@ -3,6 +3,7 @@
import eu.kennytv.maintenance.core.MaintenanceModePlugin;
import eu.kennytv.maintenance.core.Settings;
import eu.kennytv.maintenance.core.util.SenderInfo;
+import eu.kennytv.maintenance.core.util.ServerType;
import java.util.Arrays;
import java.util.Map;
@@ -73,7 +74,10 @@ public void execute(final SenderInfo sender, final String[] args) {
} else
sendUsage(sender);
} else if (args.length == 2) {
- if (args[0].equalsIgnoreCase("endtimer")) {
+ if ((args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("off")) && plugin.getServerType() == ServerType.BUNGEE) {
+ if (checkPermission(sender, "toggle")) return;
+ handleToggleServerCommand(sender, args);
+ } else if (args[0].equalsIgnoreCase("endtimer")) {
if (checkPermission(sender, "timer")) return;
if (!isNumeric(args[1])) {
sender.sendMessage(settings.getMessage("endtimerUsage"));
@@ -222,8 +226,13 @@ private void sendUsage(final SenderInfo sender) {
if (sender.hasPermission("maintenance.reload"))
sender.sendMessage("§6/maintenance reload §7(Reloads the config file, whitelist file and the server-icon)");
if (sender.hasPermission("maintenance.toggle")) {
- sender.sendMessage("§6/maintenance on §7(Enables maintenance mode");
- sender.sendMessage("§6/maintenance off §7(Disables maintenance mode)");
+ if (plugin.getServerType() == ServerType.BUNGEE) {
+ sender.sendMessage("§6/maintenance on [server] §7(Enables maintenance mode");
+ sender.sendMessage("§6/maintenance off [server] §7(Disables maintenance mode)");
+ } else {
+ sender.sendMessage("§6/maintenance on §7(Enables maintenance mode");
+ sender.sendMessage("§6/maintenance off §7(Disables maintenance mode)");
+ }
}
if (sender.hasPermission("maintenance.timer")) {
sender.sendMessage("§6/maintenance starttimer §7(After the given time in minutes, maintenance mode will be enabled)");
@@ -271,4 +280,6 @@ private boolean isNumeric(final String string) {
protected abstract void removePlayerFromWhitelist(SenderInfo sender, String name);
protected abstract void checkForUpdate(SenderInfo sender);
+
+ protected abstract void handleToggleServerCommand(SenderInfo sender, String args[]);
}
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/util/ServerType.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/util/ServerType.java
new file mode 100644
index 00000000..4b9adecc
--- /dev/null
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/util/ServerType.java
@@ -0,0 +1,7 @@
+package eu.kennytv.maintenance.core.util;
+
+public enum ServerType {
+
+ BUNGEE,
+ SPIGOT
+}
diff --git a/Maintenance-Core/src/main/resources/language-de.yml b/Maintenance-Core/src/main/resources/language-de.yml
index 83384b7f..db2aa838 100644
--- a/Maintenance-Core/src/main/resources/language-de.yml
+++ b/Maintenance-Core/src/main/resources/language-de.yml
@@ -39,6 +39,7 @@ whitelistAdded: "&8[&eMaintenance&8] &b%PLAYER% &awurde zur Maintenance Whitelis
whitelistRemoved: "&8[&eMaintenance&8] &b%PLAYER% &awurde von der Maintenance Whitelist entfernt!"
playerNotOnline: "&8[&eMaintenance&8] &cEs ist momentan kein Spieler mit diesem Namen online."
playerNotFound: "&8[&eMaintenance&8] &cBisher hat kein Spieler mit diesem Namen jemals auf diesem Server gespielt."
+serverNotFound: "&8[&eMaintenance&8] &cEs wurde kein Server mit diesem Namen gefunden!"
second: "Sekunde"
seconds: "Sekunden"
diff --git a/Maintenance-Core/src/main/resources/language-en.yml b/Maintenance-Core/src/main/resources/language-en.yml
index a1f9500e..75ef7280 100644
--- a/Maintenance-Core/src/main/resources/language-en.yml
+++ b/Maintenance-Core/src/main/resources/language-en.yml
@@ -39,6 +39,7 @@ whitelistAdded: "&8[&eMaintenance&8] &aAdded &b%PLAYER% &ato the maintenance whi
whitelistRemoved: "&8[&eMaintenance&8] &aRemoved &b%PLAYER% &afrom the maintenance whitelist!"
playerNotOnline: "&8[&eMaintenance&8] &cThere's no player online with that name."
playerNotFound: "&8[&eMaintenance&8] &cNo player with this name has played on this server before."
+serverNotFound: "&8[&eMaintenance&8] &cNo server with this name is registered on the proxy!"
second: "second"
seconds: "seconds"
diff --git a/Maintenance-Core/src/main/resources/language.yml b/Maintenance-Core/src/main/resources/language.yml
index a1f9500e..75ef7280 100644
--- a/Maintenance-Core/src/main/resources/language.yml
+++ b/Maintenance-Core/src/main/resources/language.yml
@@ -39,6 +39,7 @@ whitelistAdded: "&8[&eMaintenance&8] &aAdded &b%PLAYER% &ato the maintenance whi
whitelistRemoved: "&8[&eMaintenance&8] &aRemoved &b%PLAYER% &afrom the maintenance whitelist!"
playerNotOnline: "&8[&eMaintenance&8] &cThere's no player online with that name."
playerNotFound: "&8[&eMaintenance&8] &cNo player with this name has played on this server before."
+serverNotFound: "&8[&eMaintenance&8] &cNo server with this name is registered on the proxy!"
second: "second"
seconds: "seconds"
diff --git a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/MaintenanceSpigotPlugin.java b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/MaintenanceSpigotPlugin.java
index 186c141e..4575adde 100644
--- a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/MaintenanceSpigotPlugin.java
+++ b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/MaintenanceSpigotPlugin.java
@@ -5,6 +5,7 @@
import eu.kennytv.maintenance.api.MaintenanceSpigotAPI;
import eu.kennytv.maintenance.core.MaintenanceModePlugin;
import eu.kennytv.maintenance.core.hook.ServerListPlusHook;
+import eu.kennytv.maintenance.core.util.ServerType;
import eu.kennytv.maintenance.spigot.command.MaintenanceSpigotCommand;
import eu.kennytv.maintenance.spigot.listener.PlayerLoginListener;
import eu.kennytv.maintenance.spigot.metrics.MetricsLite;
@@ -24,7 +25,7 @@ public final class MaintenanceSpigotPlugin extends MaintenanceModePlugin {
private final SettingsSpigot settings;
MaintenanceSpigotPlugin(final MaintenanceSpigotBase plugin) {
- super("§8[§eMaintenanceSpigot§8] ", plugin.getDescription().getVersion());
+ super("§8[§eMaintenanceSpigot§8] ", plugin.getDescription().getVersion(), ServerType.SPIGOT);
this.plugin = plugin;
settings = new SettingsSpigot(this, plugin);
diff --git a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/command/MaintenanceSpigotCommand.java b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/command/MaintenanceSpigotCommand.java
index cef13bb4..720c0ad9 100644
--- a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/command/MaintenanceSpigotCommand.java
+++ b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/command/MaintenanceSpigotCommand.java
@@ -80,4 +80,9 @@ protected void checkForUpdate(final SenderInfo sender) {
} else
sender.sendMessage(plugin.getPrefix() + "§aYou already have the latest version of the plugin!");
}
+
+ @Override
+ @Deprecated
+ protected void handleToggleServerCommand(final SenderInfo senderInfo, final String[] args) {
+ }
}
From a563c0a8a887a30718c99c269609eb955f1367ea Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Tue, 2 Oct 2018 12:15:08 +0200
Subject: [PATCH 10/33] Restructured language files
---
.../src/main/resources/language-de.yml | 48 +++++++++----------
.../src/main/resources/language-en.yml | 48 +++++++++----------
.../src/main/resources/language.yml | 48 +++++++++----------
3 files changed, 72 insertions(+), 72 deletions(-)
diff --git a/Maintenance-Core/src/main/resources/language-de.yml b/Maintenance-Core/src/main/resources/language-de.yml
index db2aa838..cb34bb15 100644
--- a/Maintenance-Core/src/main/resources/language-de.yml
+++ b/Maintenance-Core/src/main/resources/language-de.yml
@@ -2,44 +2,44 @@
# 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."
-reload: "&8[&eMaintenance&8] &aConfig, WhitelistedPlayers, Language Datei und Maintenance Icon wurden neugeladen."
-alreadyEnabled: "&8[&eMaintenance&8] &cDer Wartungsmodus ist bereits aktiviert!"
-alreadyDisabled: "&8[&eMaintenance&8] &cDer Wartungsmodus ist bereits deaktiviert!"
maintenanceActivated: "&8[&eMaintenance&8] &6Der Wartungsmodus ist nun aktiviert."
maintenanceDeactivated: "&8[&eMaintenance&8] &6Der Wartungsmodus ist nun deaktiviert."
-starttimerUsage: "&8[&eMaintenance&8] &c/maintenance starttimer "
-starttimerStarted: "&8[&eMaintenance&8] &aGestarteter Timer: &7Der Wartungsmodus wird aktiviert in: &6%TIME%&7"
-starttimerBroadcast: "&8[&eMaintenance&8] &7Der Wartungsmodus wird aktiviert in: &6%TIME%&7."
-endtimerUsage: "&8[&eMaintenance&8] &c/maintenance endtimer "
-endtimerStarted: "&8[&eMaintenance&8] &aGestarteter Timer: &7Der Wartungsmodus wird aktiviert in: &6%TIME%&7."
+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 aktiviert in: &6%TIME%&7."
-timerTooLong: "&8[&eMaintenance&8] &cDie angegebene Nummer muss kleiner als 40320 sein (= 28 Tage)!"
+endtimerStarted: "&8[&eMaintenance&8] &aGestarteter Timer: &7Der Wartungsmodus wird aktiviert in: &6%TIME%&7."
+endtimerUsage: "&8[&eMaintenance&8] &c/maintenance endtimer "
+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"
+starttimerUsage: "&8[&eMaintenance&8] &c/maintenance starttimer "
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)!"
joinNotification: "&8[&eMaintenance&8] &e%PLAYER% &chat versucht den Server beizutreten."
-updateDownloading: "&8[&eMaintenance&8] &c&lUpdate wird heruntergeladen..."
-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!"
-updateFailed: "&8[&eMaintenance&8] &4&lUpdate fehlgeschlagen!"
+motdList: "&8[&eMaintenance&8] &7Liste der Maintenance MOTDs:"
+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!"
+removeMotdUsage: "&8[&eMaintenance&8] &c/maintenance removemotd "
+serverNotFound: "&8[&eMaintenance&8] &cEs wurde kein Server mit diesem Namen gefunden!"
+setMotd: "&8[&eMaintenance&8] &aDie %LINE%. Zeile der %INDEX%. Maintenance MOTD wurde geändert zu: %MOTD%"
setMotdUsage: "&8[&eMaintenance&8] &c/maintenance setmotd <1/2> "
-setMotdLineError: "&8[&eMaintenance&8] &cDas zweite Argument muss die Zeilennummer sein (1 oder 2)!"
setMotdIndexError: "&8[&eMaintenance&8] §cMomentan gibt es %MOTDS% MOTDs, du musst also eine Zahl zwischen 1 and %NEWAMOUNT% wählen."
-setMotd: "&8[&eMaintenance&8] &aDie %LINE%. Zeile der %INDEX%. Maintenance MOTD wurde geändert zu: %MOTD%"
-removeMotdUsage: "&8[&eMaintenance&8] &c/maintenance removemotd "
-removeMotdError: "&8[&eMaintenance&8] &cDu hast nur eine Maintenance MOTD, daher kannst du auch keine entfernen!"
-removedMotd: "&8[&eMaintenance&8] &aDie %INDEX%. Maintenance MOTD wurde entfernt."
-motdList: "&8[&eMaintenance&8] &7Liste der Maintenance MOTDs:"
-whitelistEmtpy: "&8[&eMaintenance&8] &cDie Maintenance Whitelist ist leer! Nutze '/maintenance add ', um jemanden hinzuzufügen!"
-whitelistEmptyDefault: "&8[&eMaintenance&8] &cNutze '/maintenance add ', um jemanden hinzuzufügen. Ansonsten kannst auch die UUID des Spielers in die WhitelistedPlayers.yml einsetzen, wie es im dortigen Beispiel schon drinsteht!"
+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)"
-whitelistNotFound: "&8[&eMaintenance&8] &cDieser Spieler ist nicht in der Maintenance Whitelist!"
-whitelistAlreadyAdded: "&8[&eMaintenance&8] &b%PLAYER% &cist bereits in der Maintenance Whitelist!"
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!"
-playerNotOnline: "&8[&eMaintenance&8] &cEs ist momentan kein Spieler mit diesem Namen online."
+whitelistNotFound: "&8[&eMaintenance&8] &cDieser Spieler ist nicht in der Maintenance Whitelist!"
+whitelistEmtpy: "&8[&eMaintenance&8] &cDie Maintenance Whitelist ist leer! Nutze '/maintenance add ', um jemanden hinzuzufügen!"
+whitelistEmptyDefault: "&8[&eMaintenance&8] &cNutze '/maintenance add ', um jemanden hinzuzufügen. Ansonsten kannst auch die UUID des Spielers in die WhitelistedPlayers.yml einsetzen, wie es im dortigen Beispiel schon drinsteht!"
playerNotFound: "&8[&eMaintenance&8] &cBisher hat kein Spieler mit diesem Namen jemals auf diesem Server gespielt."
-serverNotFound: "&8[&eMaintenance&8] &cEs wurde kein Server mit diesem Namen gefunden!"
+playerNotOnline: "&8[&eMaintenance&8] &cEs ist momentan kein Spieler mit diesem Namen online."
second: "Sekunde"
seconds: "Sekunden"
diff --git a/Maintenance-Core/src/main/resources/language-en.yml b/Maintenance-Core/src/main/resources/language-en.yml
index 75ef7280..9a742198 100644
--- a/Maintenance-Core/src/main/resources/language-en.yml
+++ b/Maintenance-Core/src/main/resources/language-en.yml
@@ -2,44 +2,44 @@
# 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."
-reload: "&8[&eMaintenance&8] &aReloaded config, whitelistedplayers, language file and the maintenance icon."
-alreadyEnabled: "&8[&eMaintenance&8] &cMaintenance already is enabled!"
-alreadyDisabled: "&8[&eMaintenance&8] &cMaintenance already is disabled!"
maintenanceActivated: "&8[&eMaintenance&8] &6Maintenance mode is now activated."
maintenanceDeactivated: "&8[&eMaintenance&8] &6Maintenance mode is now deactivated."
-starttimerUsage: "&8[&eMaintenance&8] &c/maintenance starttimer "
-starttimerStarted: "&8[&eMaintenance&8] &aStarted timer: &7Maintenance mode will be activated in &6%TIME%&7."
-starttimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode will be enabled in &6%TIME%&7."
-endtimerUsage: "&8[&eMaintenance&8] &c/maintenance endtimer "
-endtimerStarted: "&8[&eMaintenance&8] &aStarted timer: &7Maintenance mode will be deactivated in &6%TIME%&7."
+alreadyEnabled: "&8[&eMaintenance&8] &cMaintenance already is enabled!"
+alreadyDisabled: "&8[&eMaintenance&8] &cMaintenance already is disabled!"
endtimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode will be disabled in &6%TIME%&7."
-timerTooLong: "&8[&eMaintenance&8] &cThe number has to be less than 40320 (28 days)!"
+endtimerStarted: "&8[&eMaintenance&8] &aStarted timer: &7Maintenance mode will be deactivated in &6%TIME%&7."
+endtimerUsage: "&8[&eMaintenance&8] &c/maintenance endtimer "
+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."
+starttimerUsage: "&8[&eMaintenance&8] &c/maintenance starttimer "
timerAlreadyRunning: "&8[&eMaintenance&8] &cThere's already a starttimer scheduled!"
timerNotRunning: "&8[&eMaintenance&8] &cThere's 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)!"
joinNotification: "&8[&eMaintenance&8] &e%PLAYER% &ctried to join the server."
-updateDownloading: "&8[&eMaintenance&8] &c&lDownloading update..."
-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!"
-updateFailed: "&8[&eMaintenance&8] &4&lUpdate failed!"
+motdList: "&8[&eMaintenance&8] &7List of your maintenance motds:"
+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 can't remove any!"
+removeMotdUsage: "&8[&eMaintenance&8] &c/maintenance removemotd "
+serverNotFound: "&8[&eMaintenance&8] &cNo server with this name is registered on the proxy!"
+setMotd: "&8[&eMaintenance&8] &aSet line %LINE% of the %INDEX%. maintenance motd to %MOTD%"
setMotdUsage: "&8[&eMaintenance&8] &c/maintenance setmotd <1/2> "
-setMotdLineError: "&8[&eMaintenance&8] &cThe second argument has to be the line number (1 or 2)!"
setMotdIndexError: "&8[&eMaintenance&8] §cYou currently have %MOTDS% motds, so you have to pick a number between 1 and %NEWAMOUNT%."
-setMotd: "&8[&eMaintenance&8] &aSet line %LINE% of the %INDEX%. maintenance motd to %MOTD%"
-removeMotdUsage: "&8[&eMaintenance&8] &c/maintenance removemotd "
-removeMotdError: "&8[&eMaintenance&8] &cYou only have one motd, so you can't remove any!"
-removedMotd: "&8[&eMaintenance&8] &aRemoved motd number %INDEX%."
-motdList: "&8[&eMaintenance&8] &7List of your maintenance motds:"
-whitelistEmtpy: "&8[&eMaintenance&8] &cThe maintenance whitelist is empty! Use '/maintenance add ' to add someone!"
-whitelistEmptyDefault: "&8[&eMaintenance&8] &cUse '/maintenance add ' to add someone. Alternatively, you can add the uuid of a player to the WhitelistedPlayers.yml as seen in the example in the file!"
+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)"
-whitelistNotFound: "&8[&eMaintenance&8] &cThis player is not in the maintenance whitelist!"
-whitelistAlreadyAdded: "&8[&eMaintenance&8] &b%PLAYER% &calready is in the maintenance whitelist!"
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!"
-playerNotOnline: "&8[&eMaintenance&8] &cThere's no player online with that name."
+whitelistNotFound: "&8[&eMaintenance&8] &cThis player is not in the maintenance whitelist!"
+whitelistEmtpy: "&8[&eMaintenance&8] &cThe maintenance whitelist is empty! Use '/maintenance add ' to add someone!"
+whitelistEmptyDefault: "&8[&eMaintenance&8] &cUse '/maintenance add ' to add someone. Alternatively, you can add the uuid of a player to the WhitelistedPlayers.yml as seen in the example in the file!"
playerNotFound: "&8[&eMaintenance&8] &cNo player with this name has played on this server before."
-serverNotFound: "&8[&eMaintenance&8] &cNo server with this name is registered on the proxy!"
+playerNotOnline: "&8[&eMaintenance&8] &cThere's no player online with that name."
second: "second"
seconds: "seconds"
diff --git a/Maintenance-Core/src/main/resources/language.yml b/Maintenance-Core/src/main/resources/language.yml
index 75ef7280..9a742198 100644
--- a/Maintenance-Core/src/main/resources/language.yml
+++ b/Maintenance-Core/src/main/resources/language.yml
@@ -2,44 +2,44 @@
# 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."
-reload: "&8[&eMaintenance&8] &aReloaded config, whitelistedplayers, language file and the maintenance icon."
-alreadyEnabled: "&8[&eMaintenance&8] &cMaintenance already is enabled!"
-alreadyDisabled: "&8[&eMaintenance&8] &cMaintenance already is disabled!"
maintenanceActivated: "&8[&eMaintenance&8] &6Maintenance mode is now activated."
maintenanceDeactivated: "&8[&eMaintenance&8] &6Maintenance mode is now deactivated."
-starttimerUsage: "&8[&eMaintenance&8] &c/maintenance starttimer "
-starttimerStarted: "&8[&eMaintenance&8] &aStarted timer: &7Maintenance mode will be activated in &6%TIME%&7."
-starttimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode will be enabled in &6%TIME%&7."
-endtimerUsage: "&8[&eMaintenance&8] &c/maintenance endtimer "
-endtimerStarted: "&8[&eMaintenance&8] &aStarted timer: &7Maintenance mode will be deactivated in &6%TIME%&7."
+alreadyEnabled: "&8[&eMaintenance&8] &cMaintenance already is enabled!"
+alreadyDisabled: "&8[&eMaintenance&8] &cMaintenance already is disabled!"
endtimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode will be disabled in &6%TIME%&7."
-timerTooLong: "&8[&eMaintenance&8] &cThe number has to be less than 40320 (28 days)!"
+endtimerStarted: "&8[&eMaintenance&8] &aStarted timer: &7Maintenance mode will be deactivated in &6%TIME%&7."
+endtimerUsage: "&8[&eMaintenance&8] &c/maintenance endtimer "
+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."
+starttimerUsage: "&8[&eMaintenance&8] &c/maintenance starttimer "
timerAlreadyRunning: "&8[&eMaintenance&8] &cThere's already a starttimer scheduled!"
timerNotRunning: "&8[&eMaintenance&8] &cThere's 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)!"
joinNotification: "&8[&eMaintenance&8] &e%PLAYER% &ctried to join the server."
-updateDownloading: "&8[&eMaintenance&8] &c&lDownloading update..."
-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!"
-updateFailed: "&8[&eMaintenance&8] &4&lUpdate failed!"
+motdList: "&8[&eMaintenance&8] &7List of your maintenance motds:"
+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 can't remove any!"
+removeMotdUsage: "&8[&eMaintenance&8] &c/maintenance removemotd "
+serverNotFound: "&8[&eMaintenance&8] &cNo server with this name is registered on the proxy!"
+setMotd: "&8[&eMaintenance&8] &aSet line %LINE% of the %INDEX%. maintenance motd to %MOTD%"
setMotdUsage: "&8[&eMaintenance&8] &c/maintenance setmotd <1/2> "
-setMotdLineError: "&8[&eMaintenance&8] &cThe second argument has to be the line number (1 or 2)!"
setMotdIndexError: "&8[&eMaintenance&8] §cYou currently have %MOTDS% motds, so you have to pick a number between 1 and %NEWAMOUNT%."
-setMotd: "&8[&eMaintenance&8] &aSet line %LINE% of the %INDEX%. maintenance motd to %MOTD%"
-removeMotdUsage: "&8[&eMaintenance&8] &c/maintenance removemotd "
-removeMotdError: "&8[&eMaintenance&8] &cYou only have one motd, so you can't remove any!"
-removedMotd: "&8[&eMaintenance&8] &aRemoved motd number %INDEX%."
-motdList: "&8[&eMaintenance&8] &7List of your maintenance motds:"
-whitelistEmtpy: "&8[&eMaintenance&8] &cThe maintenance whitelist is empty! Use '/maintenance add ' to add someone!"
-whitelistEmptyDefault: "&8[&eMaintenance&8] &cUse '/maintenance add ' to add someone. Alternatively, you can add the uuid of a player to the WhitelistedPlayers.yml as seen in the example in the file!"
+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)"
-whitelistNotFound: "&8[&eMaintenance&8] &cThis player is not in the maintenance whitelist!"
-whitelistAlreadyAdded: "&8[&eMaintenance&8] &b%PLAYER% &calready is in the maintenance whitelist!"
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!"
-playerNotOnline: "&8[&eMaintenance&8] &cThere's no player online with that name."
+whitelistNotFound: "&8[&eMaintenance&8] &cThis player is not in the maintenance whitelist!"
+whitelistEmtpy: "&8[&eMaintenance&8] &cThe maintenance whitelist is empty! Use '/maintenance add ' to add someone!"
+whitelistEmptyDefault: "&8[&eMaintenance&8] &cUse '/maintenance add ' to add someone. Alternatively, you can add the uuid of a player to the WhitelistedPlayers.yml as seen in the example in the file!"
playerNotFound: "&8[&eMaintenance&8] &cNo player with this name has played on this server before."
-serverNotFound: "&8[&eMaintenance&8] &cNo server with this name is registered on the proxy!"
+playerNotOnline: "&8[&eMaintenance&8] &cThere's no player online with that name."
second: "second"
seconds: "seconds"
From 9ffb67db1fd9bebdefd136ecb512ce0732eb4e8c Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Fri, 12 Oct 2018 23:17:46 +0200
Subject: [PATCH 11/33] WIP: Add possibility to set single servers to
maintenance
---
.../maintenance/bungee/SettingsBungee.java | 20 +++++++++++++++++--
.../command/MaintenanceBungeeCommand.java | 4 +++-
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
index f7c5c4ec..4beeb50c 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
@@ -5,6 +5,7 @@
import eu.kennytv.maintenance.core.Settings;
import eu.kennytv.maintenance.core.listener.IPingListener;
import net.md_5.bungee.api.ChatColor;
+import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.plugin.PluginManager;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.YamlConfiguration;
@@ -256,7 +257,22 @@ public Set getMaintenanceServers() {
return maintenanceServers;
}
- public void setMaintenanceToServer(final String server, final boolean maintenance) {
- //TODO
+ public void setMaintenanceToServer(final ServerInfo server, final boolean maintenance) {
+ if (maintenance) {
+ maintenanceServers.add(server.getName());
+ server.getPlayers().forEach(p -> {
+ if (!p.hasPermission("maintenance.bypass") && !getWhitelistedPlayers().containsKey(p.getUniqueId())) {
+ //TODO runterwerfen
+ p.disconnect(getKickMessage().replace("%NEWLINE%", "\n"));
+ } else {
+ //TODO
+ p.sendMessage(getMessage("maintenanceActivated"));
+ }
+ });
+ } else {
+ maintenanceServers.remove(server.getName());
+ //TODO
+ server.getPlayers().forEach(p -> p.sendMessage(getMessage("maintenanceDeactivated")));
+ }
}
}
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
index 279dd06f..c59dfe0f 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
@@ -81,6 +81,8 @@ protected void handleToggleServerCommand(final SenderInfo sender, final String a
return;
}
- settingsBungee.setMaintenanceToServer(server.getName(), maintenance);
+ settingsBungee.setMaintenanceToServer(server, maintenance);
+ //TODO
+ sender.sendMessage(settings.getMessage(""));
}
}
From 287488f1b6f692b6eeb2c0320856ab4b881582c0 Mon Sep 17 00:00:00 2001
From: KennyTV
Date: Fri, 19 Oct 2018 12:08:37 +0200
Subject: [PATCH 12/33] =?UTF-8?q?Some=20single=20server=20maintenance=20st?=
=?UTF-8?q?uff=20I=20did=20during=20a=20course=20at=20university=20=C2=AF\?=
=?UTF-8?q?=5F(=E3=83=84)=5F/=C2=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../maintenance/bungee/SettingsBungee.java | 52 ++++++++++++++-----
.../command/MaintenanceBungeeCommand.java | 7 +--
.../src/main/resources/SpigotServers.yml | 4 ++
.../src/main/resources/language.yml | 6 +++
4 files changed, 52 insertions(+), 17 deletions(-)
create mode 100644 Maintenance-Core/src/main/resources/SpigotServers.yml
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
index 4beeb50c..05d0531a 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
@@ -14,23 +14,22 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.sql.SQLException;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.UUID;
+import java.util.*;
public final class SettingsBungee extends Settings {
private final String updateQuery;
private final String maintenanceQuery;
+ private final String serversQuery;
private final MySQL mySQL;
private final MaintenanceBungeePlugin maintenancePlugin;
private final MaintenanceBungeeBase plugin;
private final IPingListener pingListener;
- private final Set maintenanceServers = new HashSet<>();
+ private Set maintenanceServers;
private Configuration config;
private Configuration language;
private Configuration whitelist;
+ private Configuration spigotServers;
private long millisecondsToCheck;
private long lastMySQLCheck;
@@ -50,6 +49,7 @@ public final class SettingsBungee extends Settings {
createFile("bungee-config.yml");
createLanguageFile();
createFile("WhitelistedPlayers.yml");
+ createFile("SpigotServers.yml");
reloadConfigs();
@@ -62,16 +62,19 @@ public final class SettingsBungee extends Settings {
mySQLSection.getString("password"),
mySQLSection.getString("database"));
+ //TODO boolean there + extra table?
// Varchar as the value regarding the possibility of saving stuff like the motd as well in future updates
final String mySQLTable = mySQLSection.getString("table");
mySQL.executeUpdate("CREATE TABLE IF NOT EXISTS " + mySQLTable + " (setting VARCHAR(16) PRIMARY KEY, value VARCHAR(255))");
updateQuery = "INSERT INTO " + mySQLTable + " (setting, value) VALUES (?, ?) ON DUPLICATE KEY UPDATE value = ?";
maintenanceQuery = "SELECT * FROM " + mySQLTable + " WHERE setting = ?";
+ serversQuery = "INSERT INTO " + mySQLTable + " (setting, value) VALUES (?, ?) ON DUPLICATE KEY UPDATE value = ?";
plugin.getLogger().info("Done!");
} else {
mySQL = null;
updateQuery = null;
maintenanceQuery = null;
+ serversQuery = null;
}
}
@@ -117,6 +120,7 @@ public void reloadConfigs() {
language = YamlConfiguration.getProvider(YamlConfiguration.class)
.load(new InputStreamReader(new FileInputStream(new File(plugin.getDataFolder(), "language.yml")), StandardCharsets.UTF_8));
whitelist = YamlConfiguration.getProvider(YamlConfiguration.class).load(new File(plugin.getDataFolder(), "WhitelistedPlayers.yml"));
+ spigotServers = YamlConfiguration.getProvider(YamlConfiguration.class).load(new File(plugin.getDataFolder(), "spigot-servers.yml"));
} catch (final IOException e) {
throw new RuntimeException("Unable to load Maintenance files!", e);
}
@@ -136,11 +140,19 @@ public void saveConfig() {
@Override
public void saveWhitelistedPlayers() {
- final File file = new File(plugin.getDataFolder(), "WhitelistedPlayers.yml");
+ saveFile(whitelist, "WhitelistedPlayers.yml");
+ }
+
+ public void saveSpigotServers() {
+ saveFile(spigotServers, "SpigotServers.yml");
+ }
+
+ private void saveFile(final Configuration config, final String name) {
+ final File file = new File(plugin.getDataFolder(), name);
try {
- YamlConfiguration.getProvider(YamlConfiguration.class).save(whitelist, file);
+ YamlConfiguration.getProvider(YamlConfiguration.class).save(config, file);
} catch (final IOException e) {
- throw new RuntimeException("Unable to save WhitelistedPlayers.yml!", e);
+ throw new RuntimeException("Unable to save " + name + "!", e);
}
}
@@ -152,6 +164,10 @@ public void loadExtraSettings() {
final long configValue = config.getInt("mysql.update-interval");
millisecondsToCheck = configValue > 0 ? configValue * 1000 : -1;
lastMySQLCheck = 0;
+ //TODO maintenance servers from database
+ } else {
+ final List list = spigotServers.getStringList("maintenance-on");
+ maintenanceServers = list == null || list.isEmpty() ? Collections.emptySet() : new HashSet<>(list);
}
}
@@ -257,22 +273,30 @@ public Set getMaintenanceServers() {
return maintenanceServers;
}
- public void setMaintenanceToServer(final ServerInfo server, final boolean maintenance) {
+ public boolean setMaintenanceToServer(final ServerInfo server, final boolean maintenance) {
if (maintenance) {
- maintenanceServers.add(server.getName());
+ if (!maintenanceServers.add(server.getName())) return false;
server.getPlayers().forEach(p -> {
if (!p.hasPermission("maintenance.bypass") && !getWhitelistedPlayers().containsKey(p.getUniqueId())) {
- //TODO runterwerfen
+ //TODO message
p.disconnect(getKickMessage().replace("%NEWLINE%", "\n"));
} else {
- //TODO
+ //TODO message
p.sendMessage(getMessage("maintenanceActivated"));
}
});
} else {
- maintenanceServers.remove(server.getName());
- //TODO
+ if (!maintenanceServers.remove(server.getName())) return false;
server.getPlayers().forEach(p -> p.sendMessage(getMessage("maintenanceDeactivated")));
}
+
+ if (mySQL != null) {
+ //TODO test query with single entry
+ mySQL.executeUpdate(serversQuery, "spigot-servers-with-maintenance", maintenanceServers, maintenanceServers);
+ } else {
+ spigotServers.set("maintenance-on", maintenanceServers);
+ saveSpigotServers();
+ }
+ return true;
}
}
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
index c59dfe0f..ce280d1d 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
@@ -81,8 +81,9 @@ protected void handleToggleServerCommand(final SenderInfo sender, final String a
return;
}
- settingsBungee.setMaintenanceToServer(server, maintenance);
- //TODO
- sender.sendMessage(settings.getMessage(""));
+ if (settingsBungee.setMaintenanceToServer(server, maintenance)) {
+ sender.sendMessage(settings.getMessage(maintenance ? "singleMaintenanceActivated" : "singleMaintenanceDectivated"));
+ } else
+ sender.sendMessage(settings.getMessage(maintenance ? "singleServeralreadyEnabled" : "singleServeralreadyDisabled"));
}
}
diff --git a/Maintenance-Core/src/main/resources/SpigotServers.yml b/Maintenance-Core/src/main/resources/SpigotServers.yml
new file mode 100644
index 00000000..75523a73
--- /dev/null
+++ b/Maintenance-Core/src/main/resources/SpigotServers.yml
@@ -0,0 +1,4 @@
+# Enables maintenance on certain Spigot servers managed by your Bungee instance(s)
+maintenance-on:
+ #- SpigotServer1
+ #- AnotherServer
\ No newline at end of file
diff --git a/Maintenance-Core/src/main/resources/language.yml b/Maintenance-Core/src/main/resources/language.yml
index 9a742198..71e142cc 100644
--- a/Maintenance-Core/src/main/resources/language.yml
+++ b/Maintenance-Core/src/main/resources/language.yml
@@ -41,6 +41,12 @@ whitelistEmptyDefault: "&8[&eMaintenance&8] &cUse '/maintenance add ' to
playerNotFound: "&8[&eMaintenance&8] &cNo player with this name has played on this server before."
playerNotOnline: "&8[&eMaintenance&8] &cThere's no player online with that name."
+# Some messages for the Bungee part
+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 already is enabled on server &e%SERVER%&c!"
+singleServeralreadyDisabled: "&8[&eMaintenance&8] &cMaintenance already is disabled on server &e%SERVER%&c!"
+
second: "second"
seconds: "seconds"
minute: "minute"
From b72ff1b772f5840e12b9687166960b5511f34afc Mon Sep 17 00:00:00 2001
From: KennyTV
Date: Fri, 19 Oct 2018 14:21:21 +0200
Subject: [PATCH 13/33] Some message changes
---
.../bungee/command/MaintenanceBungeeCommand.java | 2 +-
Maintenance-Core/src/main/resources/language-de.yml | 6 ++++++
Maintenance-Core/src/main/resources/language-en.yml | 10 ++++++++--
Maintenance-Core/src/main/resources/language.yml | 8 ++++----
4 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
index ce280d1d..d6ab2903 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
@@ -84,6 +84,6 @@ protected void handleToggleServerCommand(final SenderInfo sender, final String a
if (settingsBungee.setMaintenanceToServer(server, maintenance)) {
sender.sendMessage(settings.getMessage(maintenance ? "singleMaintenanceActivated" : "singleMaintenanceDectivated"));
} else
- sender.sendMessage(settings.getMessage(maintenance ? "singleServeralreadyEnabled" : "singleServeralreadyDisabled"));
+ sender.sendMessage(settings.getMessage(maintenance ? "singleServerAlreadyEnabled" : "singleServerAlreadyDisabled"));
}
}
diff --git a/Maintenance-Core/src/main/resources/language-de.yml b/Maintenance-Core/src/main/resources/language-de.yml
index cb34bb15..f2ad9f38 100644
--- a/Maintenance-Core/src/main/resources/language-de.yml
+++ b/Maintenance-Core/src/main/resources/language-de.yml
@@ -41,6 +41,12 @@ whitelistEmptyDefault: "&8[&eMaintenance&8] &cNutze '/maintenance add ',
playerNotFound: "&8[&eMaintenance&8] &cBisher hat kein Spieler mit diesem Namen jemals auf diesem Server gespielt."
playerNotOnline: "&8[&eMaintenance&8] &cEs ist momentan kein Spieler mit diesem Namen online."
+# Nachrichten für den Bungee Teil des Plugins
+singleMaintenanceActivated: "&8[&eMaintenance&8] &6Der Wartungsmodus wurde auf Server &e%SERVER% &6aktiviert."
+singleMaintenanceDeactivated: "&8[&eMaintenance&8] &6Der Wartungsmodus wurde auf Server &e%SERVER% &6deaktiviert."
+singleServerAlreadyEnabled: "&8[&eMaintenance&8] &cDer Wartungsmodus ist bereits an auf Server &e%SERVER%&c!"
+singleServerAlreadyDisabled: "&8[&eMaintenance&8] &cDer Wartungsmodus ist bereits aus auf Server &e%SERVER%&c!"
+
second: "Sekunde"
seconds: "Sekunden"
minute: "Minute"
diff --git a/Maintenance-Core/src/main/resources/language-en.yml b/Maintenance-Core/src/main/resources/language-en.yml
index 9a742198..be578491 100644
--- a/Maintenance-Core/src/main/resources/language-en.yml
+++ b/Maintenance-Core/src/main/resources/language-en.yml
@@ -4,8 +4,8 @@
noPermission: "&cYou do not have the permission to execute that command."
maintenanceActivated: "&8[&eMaintenance&8] &6Maintenance mode is now activated."
maintenanceDeactivated: "&8[&eMaintenance&8] &6Maintenance mode is now deactivated."
-alreadyEnabled: "&8[&eMaintenance&8] &cMaintenance already is enabled!"
-alreadyDisabled: "&8[&eMaintenance&8] &cMaintenance already is disabled!"
+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."
endtimerUsage: "&8[&eMaintenance&8] &c/maintenance endtimer "
@@ -41,6 +41,12 @@ whitelistEmptyDefault: "&8[&eMaintenance&8] &cUse '/maintenance add ' to
playerNotFound: "&8[&eMaintenance&8] &cNo player with this name has played on this server before."
playerNotOnline: "&8[&eMaintenance&8] &cThere's no player online with that name."
+# Some messages for the Bungee part
+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!"
+
second: "second"
seconds: "seconds"
minute: "minute"
diff --git a/Maintenance-Core/src/main/resources/language.yml b/Maintenance-Core/src/main/resources/language.yml
index 71e142cc..be578491 100644
--- a/Maintenance-Core/src/main/resources/language.yml
+++ b/Maintenance-Core/src/main/resources/language.yml
@@ -4,8 +4,8 @@
noPermission: "&cYou do not have the permission to execute that command."
maintenanceActivated: "&8[&eMaintenance&8] &6Maintenance mode is now activated."
maintenanceDeactivated: "&8[&eMaintenance&8] &6Maintenance mode is now deactivated."
-alreadyEnabled: "&8[&eMaintenance&8] &cMaintenance already is enabled!"
-alreadyDisabled: "&8[&eMaintenance&8] &cMaintenance already is disabled!"
+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."
endtimerUsage: "&8[&eMaintenance&8] &c/maintenance endtimer "
@@ -44,8 +44,8 @@ playerNotOnline: "&8[&eMaintenance&8] &cThere's no player online with that name.
# Some messages for the Bungee part
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 already is enabled on server &e%SERVER%&c!"
-singleServeralreadyDisabled: "&8[&eMaintenance&8] &cMaintenance already is disabled on server &e%SERVER%&c!"
+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!"
second: "second"
seconds: "seconds"
From 0377838a264f962bb803dad2a1234df0d2602053 Mon Sep 17 00:00:00 2001
From: KennyTV
Date: Sun, 4 Nov 2018 14:43:47 +0100
Subject: [PATCH 14/33] Dont save and get Spigot maintenance servers from sql
for now
---
.../maintenance/bungee/SettingsBungee.java | 29 +++++++++++--------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
index 05d0531a..aac26741 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
@@ -14,12 +14,15 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.sql.SQLException;
-import java.util.*;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
public final class SettingsBungee extends Settings {
private final String updateQuery;
private final String maintenanceQuery;
- private final String serversQuery;
+ //private final String serversQuery;
private final MySQL mySQL;
private final MaintenanceBungeePlugin maintenancePlugin;
@@ -62,19 +65,18 @@ public final class SettingsBungee extends Settings {
mySQLSection.getString("password"),
mySQLSection.getString("database"));
- //TODO boolean there + extra table?
// Varchar as the value regarding the possibility of saving stuff like the motd as well in future updates
final String mySQLTable = mySQLSection.getString("table");
mySQL.executeUpdate("CREATE TABLE IF NOT EXISTS " + mySQLTable + " (setting VARCHAR(16) PRIMARY KEY, value VARCHAR(255))");
updateQuery = "INSERT INTO " + mySQLTable + " (setting, value) VALUES (?, ?) ON DUPLICATE KEY UPDATE value = ?";
maintenanceQuery = "SELECT * FROM " + mySQLTable + " WHERE setting = ?";
- serversQuery = "INSERT INTO " + mySQLTable + " (setting, value) VALUES (?, ?) ON DUPLICATE KEY UPDATE value = ?";
+ //serversQuery = "INSERT INTO " + serversTable + " (setting, value) VALUES (?, ?) ON DUPLICATE KEY UPDATE value = ?";
plugin.getLogger().info("Done!");
} else {
mySQL = null;
updateQuery = null;
maintenanceQuery = null;
- serversQuery = null;
+ //serversQuery = null;
}
}
@@ -164,11 +166,13 @@ public void loadExtraSettings() {
final long configValue = config.getInt("mysql.update-interval");
millisecondsToCheck = configValue > 0 ? configValue * 1000 : -1;
lastMySQLCheck = 0;
- //TODO maintenance servers from database
- } else {
+ }/* else {
final List list = spigotServers.getStringList("maintenance-on");
- maintenanceServers = list == null || list.isEmpty() ? Collections.emptySet() : new HashSet<>(list);
- }
+ maintenanceServers = list == null ? new HashSet<>() : new HashSet<>(list);
+ }*/
+
+ final List list = spigotServers.getStringList("maintenance-on");
+ maintenanceServers = list == null ? new HashSet<>() : new HashSet<>(list);
}
@Override
@@ -290,13 +294,14 @@ public boolean setMaintenanceToServer(final ServerInfo server, final boolean mai
server.getPlayers().forEach(p -> p.sendMessage(getMessage("maintenanceDeactivated")));
}
- if (mySQL != null) {
- //TODO test query with single entry
+ /*if (mySQL != null) {
mySQL.executeUpdate(serversQuery, "spigot-servers-with-maintenance", maintenanceServers, maintenanceServers);
} else {
spigotServers.set("maintenance-on", maintenanceServers);
saveSpigotServers();
- }
+ }*/
+ spigotServers.set("maintenance-on", maintenanceServers);
+ saveSpigotServers();
return true;
}
}
From 4f0c05c35798bcace5fcbe7b7ca7afacbc1de00c Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Mon, 5 Nov 2018 21:24:56 +0100
Subject: [PATCH 15/33] Further single server maintenance stuff
---
.../bungee/MaintenanceBungeePlugin.java | 2 ++
.../maintenance/bungee/SettingsBungee.java | 16 +++++++--
.../listener/ServerConnectListener.java | 33 +++++++++++++++++++
.../src/main/resources/SpigotServers.yml | 4 ++-
4 files changed, 51 insertions(+), 4 deletions(-)
create mode 100644 Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
index a93b190f..23868a63 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
@@ -6,6 +6,7 @@
import eu.kennytv.maintenance.bungee.command.MaintenanceBungeeCommand;
import eu.kennytv.maintenance.bungee.command.MaintenanceBungeeCommandBase;
import eu.kennytv.maintenance.bungee.listener.PostLoginListener;
+import eu.kennytv.maintenance.bungee.listener.ServerConnectListener;
import eu.kennytv.maintenance.bungee.metrics.MetricsLite;
import eu.kennytv.maintenance.core.MaintenanceModePlugin;
import eu.kennytv.maintenance.core.hook.ServerListPlusHook;
@@ -36,6 +37,7 @@ public final class MaintenanceBungeePlugin extends MaintenanceModePlugin {
final PluginManager pm = getProxy().getPluginManager();
pm.registerListener(plugin, new PostLoginListener(this, settings));
+ pm.registerListener(plugin, new ServerConnectListener(settings));
final MaintenanceBungeeCommand maintenanceCommand = new MaintenanceBungeeCommand(this, settings);
pm.registerCommand(plugin, new MaintenanceBungeeCommandBase(maintenanceCommand));
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
index aac26741..0e010bad 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
@@ -5,6 +5,7 @@
import eu.kennytv.maintenance.core.Settings;
import eu.kennytv.maintenance.core.listener.IPingListener;
import net.md_5.bungee.api.ChatColor;
+import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.plugin.PluginManager;
import net.md_5.bungee.config.Configuration;
@@ -33,6 +34,7 @@ public final class SettingsBungee extends Settings {
private Configuration language;
private Configuration whitelist;
private Configuration spigotServers;
+ private String fallbackServer;
private long millisecondsToCheck;
private long lastMySQLCheck;
@@ -162,6 +164,7 @@ private void saveFile(final Configuration config, final String name) {
public void loadExtraSettings() {
whitelistedPlayers.clear();
whitelist.getKeys().forEach(key -> whitelistedPlayers.put(UUID.fromString(key), whitelist.getString(key)));
+ fallbackServer = spigotServers.getString("fallback", "hub");
if (mySQL != null) {
final long configValue = config.getInt("mysql.update-interval");
millisecondsToCheck = configValue > 0 ? configValue * 1000 : -1;
@@ -250,7 +253,6 @@ public boolean isMaintenance() {
if (millisecondsToCheck != -1)
lastMySQLCheck = System.currentTimeMillis();
}
-
return maintenance;
}
@@ -280,10 +282,18 @@ public Set getMaintenanceServers() {
public boolean setMaintenanceToServer(final ServerInfo server, final boolean maintenance) {
if (maintenance) {
if (!maintenanceServers.add(server.getName())) return false;
+
+ final ServerInfo fallback = ProxyServer.getInstance().getServerInfo(fallbackServer);
+ if (fallback == null)
+ plugin.getLogger().warning("Fallback server set in the SpigotServers.yml could not be found! Instead kicking players from the network!");
server.getPlayers().forEach(p -> {
if (!p.hasPermission("maintenance.bypass") && !getWhitelistedPlayers().containsKey(p.getUniqueId())) {
- //TODO message
- p.disconnect(getKickMessage().replace("%NEWLINE%", "\n"));
+ //TODO message (+ kickmessage)
+ if (fallback != null && fallback.canAccess(p)) {
+ p.sendMessage(getMessage("maintenanceActivated"));
+ p.connect(fallback);
+ } else
+ p.disconnect(getKickMessage().replace("%NEWLINE%", "\n"));
} else {
//TODO message
p.sendMessage(getMessage("maintenanceActivated"));
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java
new file mode 100644
index 00000000..0ed3e584
--- /dev/null
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java
@@ -0,0 +1,33 @@
+package eu.kennytv.maintenance.bungee.listener;
+
+import eu.kennytv.maintenance.bungee.SettingsBungee;
+import net.md_5.bungee.api.config.ServerInfo;
+import net.md_5.bungee.api.connection.ProxiedPlayer;
+import net.md_5.bungee.api.event.ServerConnectEvent;
+import net.md_5.bungee.api.plugin.Listener;
+import net.md_5.bungee.event.EventHandler;
+import net.md_5.bungee.event.EventPriority;
+
+public final class ServerConnectListener implements Listener {
+ private final SettingsBungee settings;
+
+ public ServerConnectListener(final SettingsBungee settings) {
+ this.settings = settings;
+ }
+
+ @EventHandler(priority = EventPriority.HIGHEST)
+ public void serverConnect(final ServerConnectEvent event) {
+ final ProxiedPlayer p = event.getPlayer();
+ final ServerInfo target = event.getTarget();
+ if (settings.getMaintenanceServers().contains(target.getName())) {
+ if (!p.hasPermission("maintenance.bypass") && !settings.getWhitelistedPlayers().containsKey(p.getUniqueId())) {
+ event.setCancelled(true);
+ //TODO message
+ p.sendMessage("");
+ if (settings.isJoinNotifications())
+ target.getPlayers().stream().filter(player -> player.hasPermission("maintenance.joinnotification"))
+ .forEach(player -> player.sendMessage(settings.getMessage("joinNotification").replace("%PLAYER%", p.getName())));
+ }
+ }
+ }
+}
diff --git a/Maintenance-Core/src/main/resources/SpigotServers.yml b/Maintenance-Core/src/main/resources/SpigotServers.yml
index 75523a73..b45f439c 100644
--- a/Maintenance-Core/src/main/resources/SpigotServers.yml
+++ b/Maintenance-Core/src/main/resources/SpigotServers.yml
@@ -1,4 +1,6 @@
# Enables maintenance on certain Spigot servers managed by your Bungee instance(s)
+# If it's enabled on a server while players are on it, they will be forwarded to the fallback server (kicked completely if not set correctly)
maintenance-on:
#- SpigotServer1
- #- AnotherServer
\ No newline at end of file
+ #- AnotherServer
+fallback: lobby
\ No newline at end of file
From 136fbb0ba8d7f861a5b2e71a77477c3784d7a183 Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Mon, 5 Nov 2018 22:58:12 +0100
Subject: [PATCH 16/33] Improve version check handling
---
.../bungee/MaintenanceBungeePlugin.java | 1 +
.../core/MaintenanceModePlugin.java | 30 ++++++--
.../maintenance/core/util/Version.java | 69 +++++++++++++++++++
.../spigot/MaintenanceSpigotPlugin.java | 1 +
4 files changed, 94 insertions(+), 7 deletions(-)
create mode 100644 Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/util/Version.java
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
index 23868a63..1c838dd6 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
@@ -32,6 +32,7 @@ public final class MaintenanceBungeePlugin extends MaintenanceModePlugin {
this.plugin = plugin;
plugin.getLogger().info("Plugin by KennyTV");
+ plugin.getLogger().info(getUpdateMessage());
settings = new SettingsBungee(this, plugin);
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java
index f57a6e6e..e05df32f 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java
@@ -4,6 +4,7 @@
import eu.kennytv.maintenance.core.hook.ServerListPlusHook;
import eu.kennytv.maintenance.core.runnable.MaintenanceRunnable;
import eu.kennytv.maintenance.core.util.ServerType;
+import eu.kennytv.maintenance.core.util.Version;
import java.io.*;
import java.net.HttpURLConnection;
@@ -12,18 +13,19 @@
import java.net.URLConnection;
public abstract class MaintenanceModePlugin implements IMaintenance {
- protected final String version;
+ protected final Version version;
protected ServerListPlusHook serverListPlusHook;
protected MaintenanceRunnable runnable;
protected int taskId;
private final String prefix;
private final ServerType serverType;
- private String newestVersion;
+ private Version newestVersion;
protected MaintenanceModePlugin(final String prefix, final String version, final ServerType serverType) {
this.prefix = prefix;
- this.version = version;
+ this.version = new Version(version);
this.serverType = serverType;
+ updateAvailable();
}
@Override
@@ -33,7 +35,7 @@ public boolean isMaintenance() {
@Override
public String getVersion() {
- return version;
+ return version.toString();
}
@Override
@@ -46,7 +48,7 @@ public void startMaintenanceRunnable(final int minutes, final boolean enable) {
taskId = startMaintenanceRunnable(runnable);
}
- public String getNewestVersion() {
+ public Version getNewestVersion() {
return newestVersion;
}
@@ -83,18 +85,32 @@ public String formatedTimer() {
public boolean updateAvailable() {
try {
final HttpURLConnection c = (HttpURLConnection) new URL("https://api.spigotmc.org/legacy/update.php?resource=40699").openConnection();
- final String newVersion = new BufferedReader(new InputStreamReader(c.getInputStream())).readLine().replaceAll("[a-zA-Z -]", "");
+ final String newVersionString = new BufferedReader(new InputStreamReader(c.getInputStream())).readLine();
+ if (newVersionString == null) return false;
+ final Version newVersion = new Version(newVersionString);
final boolean available = !newVersion.equals(version);
if (available)
newestVersion = newVersion;
-
return available;
} catch (final Exception ignored) {
return false;
}
}
+ public String getUpdateMessage() {
+ if (version.compareTo(newestVersion) == -1) {
+ return "§cNewest version available: §aVersion " + newestVersion + "§c, you're on §a" + version;
+ } else if (version.compareTo(newestVersion) != 0) {
+ if (version.getTag().equalsIgnoreCase("snapshot")) {
+ return "§cYou're running a development version, please report bugs on the Discord server (https://kennytv.eu/discord) or the GitHub tracker (https://kennytv.eu/maintenance/issues)";
+ } else {
+ return "§cYou're running a version, that doesn't exist! §cN§ai§dc§ee§5!";
+ }
+ }
+ return "You have the latest version of the plugin installed.";
+ }
+
public boolean installUpdate() {
try {
URL url = null;
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/util/Version.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/util/Version.java
new file mode 100644
index 00000000..8f084eb3
--- /dev/null
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/util/Version.java
@@ -0,0 +1,69 @@
+package eu.kennytv.maintenance.core.util;
+
+public final class Version implements Comparable {
+ private final int[] parts = new int[3];
+ private final String version;
+ private final String tag;
+
+ public Version(final String version) {
+ final String[] split = version.split("-", 2)[0].split("\\.");
+ for (int i = 0; i < split.length; i++) {
+ if (!isNumeric(split[i])) {
+ this.version = null;
+ tag = null;
+ 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 version (not the one to compare to) is newer, -1 if older
+ */
+ @Override
+ public int compareTo(final Version version) {
+ final int max = Math.max(this.parts.length, version.parts.length);
+ for (int i = 0; i < max; i += 1) {
+ 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) {
+ return o instanceof Version && o == this || version.equals(o.toString());
+ }
+
+ private boolean isNumeric(final String string) {
+ try {
+ Integer.parseInt(string);
+ } catch (final NumberFormatException nfe) {
+ return false;
+ }
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/MaintenanceSpigotPlugin.java b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/MaintenanceSpigotPlugin.java
index 4575adde..2403451c 100644
--- a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/MaintenanceSpigotPlugin.java
+++ b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/MaintenanceSpigotPlugin.java
@@ -31,6 +31,7 @@ public final class MaintenanceSpigotPlugin extends MaintenanceModePlugin {
settings = new SettingsSpigot(this, plugin);
plugin.getLogger().info("Plugin by KennyTV");
+ plugin.getLogger().info(getUpdateMessage());
plugin.getCommand("maintenancespigot").setExecutor(new MaintenanceSpigotCommand(this, settings));
final PluginManager pm = getServer().getPluginManager();
From 820171916b482c912bab737a630811e11a5b50f4 Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Mon, 5 Nov 2018 23:02:46 +0100
Subject: [PATCH 17/33] Improve version check handling
---
.../maintenance/core/MaintenanceModePlugin.java | 13 ++++++++-----
.../eu/kennytv/maintenance/core/util/Version.java | 1 +
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java
index e05df32f..480c4cfc 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java
@@ -25,7 +25,7 @@ protected MaintenanceModePlugin(final String prefix, final String version, final
this.prefix = prefix;
this.version = new Version(version);
this.serverType = serverType;
- updateAvailable();
+ checkNewestVersion();
}
@Override
@@ -82,22 +82,25 @@ public String formatedTimer() {
return String.format("%02d:%02d:%02d", preHours / 60, minutes, seconds);
}
- public boolean updateAvailable() {
+ public void checkNewestVersion() {
try {
final HttpURLConnection c = (HttpURLConnection) new URL("https://api.spigotmc.org/legacy/update.php?resource=40699").openConnection();
final String newVersionString = new BufferedReader(new InputStreamReader(c.getInputStream())).readLine();
- if (newVersionString == null) return false;
+ if (newVersionString == null) return;
final Version newVersion = new Version(newVersionString);
final boolean available = !newVersion.equals(version);
if (available)
newestVersion = newVersion;
- return available;
} catch (final Exception ignored) {
- return false;
}
}
+ public boolean updateAvailable() {
+ checkNewestVersion();
+ return version.compareTo(newestVersion) == -1;
+ }
+
public String getUpdateMessage() {
if (version.compareTo(newestVersion) == -1) {
return "§cNewest version available: §aVersion " + newestVersion + "§c, you're on §a" + version;
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/util/Version.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/util/Version.java
index 8f084eb3..44cf21ea 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/util/Version.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/util/Version.java
@@ -29,6 +29,7 @@ public Version(final String version) {
*/
@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 += 1) {
final int partA = i < this.parts.length ? this.parts[i] : 0;
From 282c116d02688f9747041a7071019f2c0c516161 Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Tue, 6 Nov 2018 11:01:04 +0100
Subject: [PATCH 18/33] Some improvements to messages and message handling
---
.../maintenance/bungee/SettingsBungee.java | 18 +++---
.../command/MaintenanceBungeeCommand.java | 4 ++
.../listener/ServerConnectListener.java | 3 +-
.../src/main/resources/SpigotServers.yml | 6 ++
.../src/main/resources/bungee-config.yml | 1 -
.../core/MaintenanceModePlugin.java | 1 -
.../eu/kennytv/maintenance/core/Settings.java | 2 +-
.../core/command/MaintenanceCommand.java | 4 +-
.../maintenance/core/util/Version.java | 10 +++-
.../src/main/resources/SpigotServers.yml | 6 --
.../src/main/resources/language-de.yml | 18 +++---
.../src/main/resources/language-en.yml | 16 +++---
.../src/main/resources/language.yml | 55 -------------------
.../maintenance/spigot/SettingsSpigot.java | 12 ++--
.../src/main/resources/spigot-config.yml | 1 -
15 files changed, 59 insertions(+), 98 deletions(-)
create mode 100644 Maintenance-Bungee/src/main/resources/SpigotServers.yml
delete mode 100644 Maintenance-Core/src/main/resources/SpigotServers.yml
delete mode 100644 Maintenance-Core/src/main/resources/language.yml
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
index 0e010bad..2cfd0446 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
@@ -100,8 +100,11 @@ private void createLanguageFile() {
Files.copy(in, file.toPath());
} catch (final IOException e) {
plugin.getLogger().warning("Unable to provide language " + getLanguage());
- plugin.getLogger().warning("Falling back to default language: en");
- createFile("language.yml");
+ if (!languageName.equals("en")) {
+ plugin.getLogger().warning("Falling back to default language: en");
+ languageName = "en";
+ createLanguageFile();
+ }
}
}
}
@@ -285,23 +288,22 @@ public boolean setMaintenanceToServer(final ServerInfo server, final boolean mai
final ServerInfo fallback = ProxyServer.getInstance().getServerInfo(fallbackServer);
if (fallback == null)
- plugin.getLogger().warning("Fallback server set in the SpigotServers.yml could not be found! Instead kicking players from the network!");
+ plugin.getLogger().warning("The fallback server set in the SpigotServers.yml could not be found! Instead kicking players from the network!");
server.getPlayers().forEach(p -> {
if (!p.hasPermission("maintenance.bypass") && !getWhitelistedPlayers().containsKey(p.getUniqueId())) {
- //TODO message (+ kickmessage)
+ //TODO messages, yikes
if (fallback != null && fallback.canAccess(p)) {
- p.sendMessage(getMessage("maintenanceActivated"));
+ p.sendMessage(getMessage("singleMaintenanceActivated").replace("%SERVER%", server.getName()));
p.connect(fallback);
} else
p.disconnect(getKickMessage().replace("%NEWLINE%", "\n"));
} else {
- //TODO message
- p.sendMessage(getMessage("maintenanceActivated"));
+ p.sendMessage(getMessage("singleMaintenanceActivated").replace("%SERVER%", server.getName()));
}
});
} else {
if (!maintenanceServers.remove(server.getName())) return false;
- server.getPlayers().forEach(p -> p.sendMessage(getMessage("maintenanceDeactivated")));
+ server.getPlayers().forEach(p -> p.sendMessage(getMessage("singleMaintenanceDeactivated").replace("%SERVER%", server.getName())));
}
/*if (mySQL != null) {
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
index d6ab2903..fde76525 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
@@ -74,6 +74,10 @@ protected void handleToggleServerCommand(final SenderInfo sender, final String a
sender.sendMessage(settings.getMessage("serverNotFound"));
return;
}
+ if (!sender.hasPermission("maintenance.toggleserver." + server.getName().toLowerCase())) {
+ sender.sendMessage(settings.getMessage("noServerPermission").replace("%SERVER%", server.getName()));
+ return;
+ }
final boolean maintenance = args[0].equalsIgnoreCase("on");
if (maintenance == settingsBungee.getMaintenanceServers().contains(server.getName())) {
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java
index 0ed3e584..76544a89 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java
@@ -22,8 +22,7 @@ public void serverConnect(final ServerConnectEvent event) {
if (settings.getMaintenanceServers().contains(target.getName())) {
if (!p.hasPermission("maintenance.bypass") && !settings.getWhitelistedPlayers().containsKey(p.getUniqueId())) {
event.setCancelled(true);
- //TODO message
- p.sendMessage("");
+ p.sendMessage(settings.getMessage("singleMaintenanceKick"));
if (settings.isJoinNotifications())
target.getPlayers().stream().filter(player -> player.hasPermission("maintenance.joinnotification"))
.forEach(player -> player.sendMessage(settings.getMessage("joinNotification").replace("%PLAYER%", p.getName())));
diff --git a/Maintenance-Bungee/src/main/resources/SpigotServers.yml b/Maintenance-Bungee/src/main/resources/SpigotServers.yml
new file mode 100644
index 00000000..48ca7187
--- /dev/null
+++ b/Maintenance-Bungee/src/main/resources/SpigotServers.yml
@@ -0,0 +1,6 @@
+# Enables maintenance on certain Spigot servers managed by your Bungee instance(s)
+# If it's enabled on a server with players on it, they will be forwarded to the fallback server (or kicked completely if not set correctly)
+maintenance-on:
+ #- SpigotServer1
+ #- AnotherServer
+fallback: hub
\ No newline at end of file
diff --git a/Maintenance-Bungee/src/main/resources/bungee-config.yml b/Maintenance-Bungee/src/main/resources/bungee-config.yml
index 9fca1355..8f427409 100644
--- a/Maintenance-Bungee/src/main/resources/bungee-config.yml
+++ b/Maintenance-Bungee/src/main/resources/bungee-config.yml
@@ -1,5 +1,4 @@
# MaintenanceBungee Plugin by KennyTV
-# Version ${project.version}
# Enables maintenance-mode.
enable-maintenance-mode: false
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java
index 480c4cfc..69806b75 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java
@@ -86,7 +86,6 @@ public void checkNewestVersion() {
try {
final HttpURLConnection c = (HttpURLConnection) new URL("https://api.spigotmc.org/legacy/update.php?resource=40699").openConnection();
final String newVersionString = new BufferedReader(new InputStreamReader(c.getInputStream())).readLine();
- if (newVersionString == null) return;
final Version newVersion = new Version(newVersionString);
final boolean available = !newVersion.equals(version);
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/Settings.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/Settings.java
index 88311057..fe5beccf 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/Settings.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/Settings.java
@@ -14,7 +14,7 @@ public abstract class Settings implements ISettings {
private String playerCountMessage;
private String playerCountHoverMessage;
private String kickMessage;
- private String languageName;
+ protected String languageName;
private boolean customPlayerCountMessage;
private boolean customMaintenanceIcon;
private boolean joinNotifications;
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
index 59cfdfe9..5da7ff1f 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
@@ -75,7 +75,7 @@ public void execute(final SenderInfo sender, final String[] args) {
sendUsage(sender);
} else if (args.length == 2) {
if ((args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("off")) && plugin.getServerType() == ServerType.BUNGEE) {
- if (checkPermission(sender, "toggle")) return;
+ if (checkPermission(sender, "toggleserver")) return;
handleToggleServerCommand(sender, args);
} else if (args[0].equalsIgnoreCase("endtimer")) {
if (checkPermission(sender, "timer")) return;
@@ -226,7 +226,7 @@ private void sendUsage(final SenderInfo sender) {
if (sender.hasPermission("maintenance.reload"))
sender.sendMessage("§6/maintenance reload §7(Reloads the config file, whitelist file and the server-icon)");
if (sender.hasPermission("maintenance.toggle")) {
- if (plugin.getServerType() == ServerType.BUNGEE) {
+ if (plugin.getServerType() == ServerType.BUNGEE && sender.hasPermission("maintenance.toggleserver")) {
sender.sendMessage("§6/maintenance on [server] §7(Enables maintenance mode");
sender.sendMessage("§6/maintenance off [server] §7(Disables maintenance mode)");
} else {
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/util/Version.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/util/Version.java
index 44cf21ea..3adc3605 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/util/Version.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/util/Version.java
@@ -6,11 +6,17 @@ public final class Version implements Comparable {
private final String tag;
public Version(final String version) {
+ if (version == null || version.isEmpty()) {
+ this.version = "";
+ tag = "";
+ System.out.println("Unknown Maintenance version detected!");
+ return;
+ }
final String[] split = version.split("-", 2)[0].split("\\.");
for (int i = 0; i < split.length; i++) {
if (!isNumeric(split[i])) {
- this.version = null;
- tag = null;
+ this.version = "";
+ tag = "";
System.out.println("Unknown Maintenance version detected!");
return;
}
diff --git a/Maintenance-Core/src/main/resources/SpigotServers.yml b/Maintenance-Core/src/main/resources/SpigotServers.yml
deleted file mode 100644
index b45f439c..00000000
--- a/Maintenance-Core/src/main/resources/SpigotServers.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-# Enables maintenance on certain Spigot servers managed by your Bungee instance(s)
-# If it's enabled on a server while players are on it, they will be forwarded to the fallback server (kicked completely if not set correctly)
-maintenance-on:
- #- SpigotServer1
- #- AnotherServer
-fallback: lobby
\ No newline at end of file
diff --git a/Maintenance-Core/src/main/resources/language-de.yml b/Maintenance-Core/src/main/resources/language-de.yml
index f2ad9f38..72aab0a7 100644
--- a/Maintenance-Core/src/main/resources/language-de.yml
+++ b/Maintenance-Core/src/main/resources/language-de.yml
@@ -1,5 +1,5 @@
# Maintenance Plugin by KennyTV
-# Wörter zwischen dem '%'-Zeichen nur entfernen, wenn Du wirklich weißt, warum Du sie entfernen willst.
+# 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."
maintenanceActivated: "&8[&eMaintenance&8] &6Der Wartungsmodus ist nun aktiviert."
@@ -41,15 +41,17 @@ whitelistEmptyDefault: "&8[&eMaintenance&8] &cNutze '/maintenance add ',
playerNotFound: "&8[&eMaintenance&8] &cBisher hat kein Spieler mit diesem Namen jemals auf diesem Server gespielt."
playerNotOnline: "&8[&eMaintenance&8] &cEs ist momentan kein Spieler mit diesem Namen online."
-# Nachrichten für den Bungee Teil des Plugins
-singleMaintenanceActivated: "&8[&eMaintenance&8] &6Der Wartungsmodus wurde auf Server &e%SERVER% &6aktiviert."
-singleMaintenanceDeactivated: "&8[&eMaintenance&8] &6Der Wartungsmodus wurde auf Server &e%SERVER% &6deaktiviert."
-singleServerAlreadyEnabled: "&8[&eMaintenance&8] &cDer Wartungsmodus ist bereits an auf Server &e%SERVER%&c!"
-singleServerAlreadyDisabled: "&8[&eMaintenance&8] &cDer Wartungsmodus ist bereits aus auf Server &e%SERVER%&c!"
-
second: "Sekunde"
seconds: "Sekunden"
minute: "Minute"
minutes: "Minuten"
hour: "Stunde"
-hours: "Stunden"
\ No newline at end of file
+hours: "Stunden"
+
+# Nachrichten für den Bungee Teil des Plugins, einfach ignorieren, falls das Plugin auf Spigot verwendet wird
+noServerPermission: "&8[&eMaintenance&8] &cDu nicht die erforderliche Berechtigung, den Wartungsmodus auf dem Server %SERVER% zu ändern!"
+singleMaintenanceKick: "&8[&eMaintenance&8] &cDieser Server befindet sich momentan im Wartungsmodus! Probier es später nochmal!"
+singleMaintenanceActivated: "&8[&eMaintenance&8] &6Der Wartungsmodus wurde auf Server &e%SERVER% &6aktiviert."
+singleMaintenanceDeactivated: "&8[&eMaintenance&8] &6Der Wartungsmodus wurde auf Server &e%SERVER% &6deaktiviert."
+singleServerAlreadyEnabled: "&8[&eMaintenance&8] &cDer Wartungsmodus ist bereits an auf Server &e%SERVER%&c!"
+singleServerAlreadyDisabled: "&8[&eMaintenance&8] &cDer Wartungsmodus ist bereits aus auf Server &e%SERVER%&c!"
\ No newline at end of file
diff --git a/Maintenance-Core/src/main/resources/language-en.yml b/Maintenance-Core/src/main/resources/language-en.yml
index be578491..b30b753b 100644
--- a/Maintenance-Core/src/main/resources/language-en.yml
+++ b/Maintenance-Core/src/main/resources/language-en.yml
@@ -41,15 +41,17 @@ whitelistEmptyDefault: "&8[&eMaintenance&8] &cUse '/maintenance add ' to
playerNotFound: "&8[&eMaintenance&8] &cNo player with this name has played on this server before."
playerNotOnline: "&8[&eMaintenance&8] &cThere's no player online with that name."
-# Some messages for the Bungee part
-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!"
-
second: "second"
seconds: "seconds"
minute: "minute"
minutes: "minutes"
hour: "hour"
-hours: "hours"
\ No newline at end of file
+hours: "hours"
+
+# Some messages for the Bungee part, just ignore them if you use the plugin on Spigot
+noServerPermission: "&8[&eMaintenance&8] &cYou don't have the permission to set maintenance on server %SERVER%!"
+singleMaintenanceKick: "&8[&eMaintenance&8] &cThis server is currently under maintenance! Try again later!"
+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!"
diff --git a/Maintenance-Core/src/main/resources/language.yml b/Maintenance-Core/src/main/resources/language.yml
deleted file mode 100644
index be578491..00000000
--- a/Maintenance-Core/src/main/resources/language.yml
+++ /dev/null
@@ -1,55 +0,0 @@
-# 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."
-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."
-endtimerUsage: "&8[&eMaintenance&8] &c/maintenance endtimer "
-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."
-starttimerUsage: "&8[&eMaintenance&8] &c/maintenance starttimer "
-timerAlreadyRunning: "&8[&eMaintenance&8] &cThere's already a starttimer scheduled!"
-timerNotRunning: "&8[&eMaintenance&8] &cThere's 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)!"
-joinNotification: "&8[&eMaintenance&8] &e%PLAYER% &ctried to join the server."
-motdList: "&8[&eMaintenance&8] &7List of your maintenance motds:"
-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 can't remove any!"
-removeMotdUsage: "&8[&eMaintenance&8] &c/maintenance removemotd "
-serverNotFound: "&8[&eMaintenance&8] &cNo server with this name is registered on the proxy!"
-setMotd: "&8[&eMaintenance&8] &aSet line %LINE% of the %INDEX%. maintenance motd to %MOTD%"
-setMotdUsage: "&8[&eMaintenance&8] &c/maintenance setmotd <1/2> "
-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!"
-whitelistEmtpy: "&8[&eMaintenance&8] &cThe maintenance whitelist is empty! Use '/maintenance add ' to add someone!"
-whitelistEmptyDefault: "&8[&eMaintenance&8] &cUse '/maintenance add ' to add someone. Alternatively, you can add the uuid of a player to the WhitelistedPlayers.yml as seen in the example in the file!"
-playerNotFound: "&8[&eMaintenance&8] &cNo player with this name has played on this server before."
-playerNotOnline: "&8[&eMaintenance&8] &cThere's no player online with that name."
-
-# Some messages for the Bungee part
-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!"
-
-second: "second"
-seconds: "seconds"
-minute: "minute"
-minutes: "minutes"
-hour: "hour"
-hours: "hours"
\ No newline at end of file
diff --git a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/SettingsSpigot.java b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/SettingsSpigot.java
index cfbb76d8..f4f24318 100644
--- a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/SettingsSpigot.java
+++ b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/SettingsSpigot.java
@@ -62,8 +62,11 @@ private void createLanguageFile() {
Files.copy(in, file.toPath());
} catch (final IOException e) {
plugin.getLogger().warning("Unable to provide language " + getLanguage());
- plugin.getLogger().warning("Falling back to default language: en");
- createFile("language.yml");
+ if (!languageName.equals("en")) {
+ plugin.getLogger().warning("Falling back to default language: en");
+ languageName = "en";
+ createLanguageFile();
+ }
}
}
}
@@ -71,10 +74,11 @@ private void createLanguageFile() {
@Override
public boolean updateExtraConfig() {
// Remove MySQL part from default config
- if (configContains("mysql")) {
+ //TODO with single config
+ /*if (configContains("mysql")) {
setToConfig("mysql", null);
return true;
- }
+ }*/
return false;
}
diff --git a/Maintenance-Spigot/src/main/resources/spigot-config.yml b/Maintenance-Spigot/src/main/resources/spigot-config.yml
index b4e0c19a..5f2ad628 100644
--- a/Maintenance-Spigot/src/main/resources/spigot-config.yml
+++ b/Maintenance-Spigot/src/main/resources/spigot-config.yml
@@ -1,5 +1,4 @@
# MaintenanceSpigot Plugin by KennyTV
-# Version ${project.version}
# Important note: To use this plugin to its full extend, it requires the plugin 'ProtocolLib'
# Enables maintenance-mode.
From cd71531766d0816257d1522fa72b7a0af7e9d2f4 Mon Sep 17 00:00:00 2001
From: KennyTV
Date: Wed, 7 Nov 2018 20:02:59 +0100
Subject: [PATCH 19/33] Timers for single server maintenance Todo:
Implementation in command
---
.../bungee/MaintenanceBungeePlugin.java | 52 ++++++++++++++++
.../maintenance/bungee/SettingsBungee.java | 38 ++----------
.../command/MaintenanceBungeeCommand.java | 4 +-
.../runnable/SingleMaintenanceRunnable.java | 34 +++++++++++
.../core/runnable/MaintenanceRunnable.java | 53 ++++------------
.../runnable/MaintenanceRunnableBase.java | 61 +++++++++++++++++++
.../src/main/resources/language-de.yml | 6 +-
.../src/main/resources/language-en.yml | 2 +
8 files changed, 173 insertions(+), 77 deletions(-)
create mode 100644 Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/runnable/SingleMaintenanceRunnable.java
create mode 100644 Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/runnable/MaintenanceRunnableBase.java
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
index 1c838dd6..eade0761 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
@@ -8,15 +8,20 @@
import eu.kennytv.maintenance.bungee.listener.PostLoginListener;
import eu.kennytv.maintenance.bungee.listener.ServerConnectListener;
import eu.kennytv.maintenance.bungee.metrics.MetricsLite;
+import eu.kennytv.maintenance.bungee.runnable.SingleMaintenanceRunnable;
import eu.kennytv.maintenance.core.MaintenanceModePlugin;
+import eu.kennytv.maintenance.core.Settings;
import eu.kennytv.maintenance.core.hook.ServerListPlusHook;
import eu.kennytv.maintenance.core.util.ServerType;
import net.md_5.bungee.api.ProxyServer;
+import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.api.plugin.PluginManager;
import net.minecrell.serverlistplus.core.plugin.ServerListPlusPlugin;
import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
@@ -26,6 +31,7 @@
public final class MaintenanceBungeePlugin extends MaintenanceModePlugin {
private final MaintenanceBungeeBase plugin;
private final SettingsBungee settings;
+ private final Map serverTaskIds = new HashMap<>();
MaintenanceBungeePlugin(final MaintenanceBungeeBase plugin) {
super("§8[§eMaintenanceBungee§8] ", plugin.getDescription().getVersion(), ServerType.BUNGEE);
@@ -83,11 +89,51 @@ void serverActions(final boolean maintenance) {
getProxy().broadcast(settings.getMessage("maintenanceDeactivated"));
}
+ public boolean setMaintenanceToServer(final ServerInfo server, final boolean maintenance) {
+ if (maintenance) {
+ if (!settings.getMaintenanceServers().add(server.getName())) return false;
+
+ final ServerInfo fallback = ProxyServer.getInstance().getServerInfo(settings.getFallbackServer());
+ if (fallback == null)
+ plugin.getLogger().warning("The fallback server set in the SpigotServers.yml could not be found! Instead kicking players from the network!");
+ server.getPlayers().forEach(p -> {
+ if (!p.hasPermission("maintenance.bypass") && !settings.getWhitelistedPlayers().containsKey(p.getUniqueId())) {
+ //TODO messages, yikes
+ if (fallback != null && fallback.canAccess(p)) {
+ p.sendMessage(settings.getMessage("singleMaintenanceActivated").replace("%SERVER%", server.getName()));
+ p.connect(fallback);
+ } else
+ p.disconnect(settings.getKickMessage().replace("%NEWLINE%", "\n"));
+ } else {
+ p.sendMessage(settings.getMessage("singleMaintenanceActivated").replace("%SERVER%", server.getName()));
+ }
+ });
+ } else {
+ if (!settings.getMaintenanceServers().remove(server.getName())) return false;
+ server.getPlayers().forEach(p -> p.sendMessage(settings.getMessage("singleMaintenanceDeactivated").replace("%SERVER%", server.getName())));
+ }
+
+ /*if (mySQL != null) {
+ mySQL.executeUpdate(serversQuery, "spigot-servers-with-maintenance", maintenanceServers, maintenanceServers);
+ } else {
+ spigotServers.set("maintenance-on", maintenanceServers);
+ saveSpigotServers();
+ }*/
+ cancelSingleTask(server);
+ settings.saveServersToConfig();
+ return true;
+ }
+
@Override
public int startMaintenanceRunnable(final Runnable runnable) {
return getProxy().getScheduler().schedule(plugin, runnable, 0, 1, TimeUnit.SECONDS).getId();
}
+ public void startSingleMaintenanceRunnable(final ServerInfo server, final int minutes, final boolean enable) {
+ getProxy().getScheduler().schedule(plugin,
+ new SingleMaintenanceRunnable(this, (Settings) getSettings(), minutes, enable, server), 0, 1, TimeUnit.SECONDS).getId();
+ }
+
@Override
public void async(final Runnable runnable) {
getProxy().getScheduler().runAsync(plugin, runnable);
@@ -100,6 +146,12 @@ public void cancelTask() {
taskId = 0;
}
+ public void cancelSingleTask(final ServerInfo server) {
+ final Integer task = serverTaskIds.get(server.getName());
+ if (task != null)
+ getProxy().getScheduler().cancel(task);
+ }
+
@Override
public ISettings getSettings() {
return settings;
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
index 2cfd0446..0d53643a 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
@@ -5,8 +5,6 @@
import eu.kennytv.maintenance.core.Settings;
import eu.kennytv.maintenance.core.listener.IPingListener;
import net.md_5.bungee.api.ChatColor;
-import net.md_5.bungee.api.ProxyServer;
-import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.plugin.PluginManager;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.YamlConfiguration;
@@ -282,38 +280,12 @@ public Set getMaintenanceServers() {
return maintenanceServers;
}
- public boolean setMaintenanceToServer(final ServerInfo server, final boolean maintenance) {
- if (maintenance) {
- if (!maintenanceServers.add(server.getName())) return false;
-
- final ServerInfo fallback = ProxyServer.getInstance().getServerInfo(fallbackServer);
- if (fallback == null)
- plugin.getLogger().warning("The fallback server set in the SpigotServers.yml could not be found! Instead kicking players from the network!");
- server.getPlayers().forEach(p -> {
- if (!p.hasPermission("maintenance.bypass") && !getWhitelistedPlayers().containsKey(p.getUniqueId())) {
- //TODO messages, yikes
- if (fallback != null && fallback.canAccess(p)) {
- p.sendMessage(getMessage("singleMaintenanceActivated").replace("%SERVER%", server.getName()));
- p.connect(fallback);
- } else
- p.disconnect(getKickMessage().replace("%NEWLINE%", "\n"));
- } else {
- p.sendMessage(getMessage("singleMaintenanceActivated").replace("%SERVER%", server.getName()));
- }
- });
- } else {
- if (!maintenanceServers.remove(server.getName())) return false;
- server.getPlayers().forEach(p -> p.sendMessage(getMessage("singleMaintenanceDeactivated").replace("%SERVER%", server.getName())));
- }
-
- /*if (mySQL != null) {
- mySQL.executeUpdate(serversQuery, "spigot-servers-with-maintenance", maintenanceServers, maintenanceServers);
- } else {
- spigotServers.set("maintenance-on", maintenanceServers);
- saveSpigotServers();
- }*/
+ public void saveServersToConfig() {
spigotServers.set("maintenance-on", maintenanceServers);
saveSpigotServers();
- return true;
+ }
+
+ public String getFallbackServer() {
+ return fallbackServer;
}
}
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
index fde76525..3d522862 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
@@ -13,10 +13,12 @@
import net.md_5.bungee.api.connection.ProxiedPlayer;
public final class MaintenanceBungeeCommand extends MaintenanceCommand {
+ private final MaintenanceBungeePlugin plugin;
private final SettingsBungee settingsBungee;
public MaintenanceBungeeCommand(final MaintenanceBungeePlugin plugin, final SettingsBungee settings) {
super(plugin, settings, "MaintenanceBungee");
+ this.plugin = plugin;
settingsBungee = settings;
}
@@ -85,7 +87,7 @@ protected void handleToggleServerCommand(final SenderInfo sender, final String a
return;
}
- if (settingsBungee.setMaintenanceToServer(server, maintenance)) {
+ if (plugin.setMaintenanceToServer(server, maintenance)) {
sender.sendMessage(settings.getMessage(maintenance ? "singleMaintenanceActivated" : "singleMaintenanceDectivated"));
} else
sender.sendMessage(settings.getMessage(maintenance ? "singleServerAlreadyEnabled" : "singleServerAlreadyDisabled"));
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/runnable/SingleMaintenanceRunnable.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/runnable/SingleMaintenanceRunnable.java
new file mode 100644
index 00000000..4e795df0
--- /dev/null
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/runnable/SingleMaintenanceRunnable.java
@@ -0,0 +1,34 @@
+package eu.kennytv.maintenance.bungee.runnable;
+
+import eu.kennytv.maintenance.bungee.MaintenanceBungeePlugin;
+import eu.kennytv.maintenance.core.MaintenanceModePlugin;
+import eu.kennytv.maintenance.core.Settings;
+import eu.kennytv.maintenance.core.runnable.MaintenanceRunnableBase;
+import net.md_5.bungee.api.config.ServerInfo;
+
+public final class SingleMaintenanceRunnable extends MaintenanceRunnableBase {
+ private final ServerInfo server;
+
+ public SingleMaintenanceRunnable(final MaintenanceModePlugin plugin, final Settings settings, final int minutes,
+ final boolean enable, final ServerInfo server) {
+ super(plugin, settings, minutes, enable);
+ this.server = server;
+ }
+
+ @Override
+ protected void finish() {
+ final MaintenanceBungeePlugin plugin = (MaintenanceBungeePlugin) this.plugin;
+ plugin.setMaintenanceToServer(server, enable);
+ plugin.cancelSingleTask(server);
+ }
+
+ @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());
+ }
+}
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/runnable/MaintenanceRunnable.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/runnable/MaintenanceRunnable.java
index cf312558..02ed41d4 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/runnable/MaintenanceRunnable.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/runnable/MaintenanceRunnable.java
@@ -3,55 +3,26 @@
import eu.kennytv.maintenance.core.MaintenanceModePlugin;
import eu.kennytv.maintenance.core.Settings;
-public final class MaintenanceRunnable implements Runnable {
- private final MaintenanceModePlugin plugin;
- private final Settings settings;
- private final boolean enable;
- private int seconds;
+public final class MaintenanceRunnable extends MaintenanceRunnableBase {
public MaintenanceRunnable(final MaintenanceModePlugin plugin, final Settings settings, final int minutes, final boolean enable) {
- this.plugin = plugin;
- this.settings = settings;
- this.seconds = minutes * 60;
- this.enable = enable;
+ super(plugin, settings, minutes, enable);
}
@Override
- public void run() {
- if (seconds == 0) {
- plugin.setMaintenance(enable);
- if (plugin.isTaskRunning())
- plugin.cancelTask();
- } else if (settings.getBroadcastIntervalls().contains(seconds)) {
- if (enable)
- plugin.broadcast(settings.getMessage("starttimerBroadcast").replaceAll("%TIME%", getTime()));
- else
- plugin.broadcast(settings.getMessage("endtimerBroadcast").replaceAll("%TIME%", getTime()));
- }
-
- 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();
+ protected void finish() {
+ plugin.setMaintenance(enable);
+ if (plugin.isTaskRunning())
+ plugin.cancelTask();
}
- 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"));
+ @Override
+ protected String startMessageKey() {
+ return settings.getMessage("starttimerBroadcast").replace("%TIME%", getTime());
}
- public int getSecondsLeft() {
- return seconds;
+ @Override
+ protected String endMessageKey() {
+ return settings.getMessage("endtimerBroadcast").replace("%TIME%", getTime());
}
}
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/runnable/MaintenanceRunnableBase.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/runnable/MaintenanceRunnableBase.java
new file mode 100644
index 00000000..1ebe2c5c
--- /dev/null
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/runnable/MaintenanceRunnableBase.java
@@ -0,0 +1,61 @@
+package eu.kennytv.maintenance.core.runnable;
+
+import eu.kennytv.maintenance.core.MaintenanceModePlugin;
+import eu.kennytv.maintenance.core.Settings;
+
+public abstract class MaintenanceRunnableBase implements Runnable {
+ protected final MaintenanceModePlugin plugin;
+ protected final Settings settings;
+ protected final boolean enable;
+ protected int seconds;
+
+ protected MaintenanceRunnableBase(final MaintenanceModePlugin plugin, final Settings settings, final int minutes, final boolean enable) {
+ this.plugin = plugin;
+ this.settings = settings;
+ this.seconds = minutes * 60;
+ this.enable = enable;
+ }
+
+ @Override
+ public void run() {
+ if (seconds == 0) {
+ finish();
+ } else if (settings.getBroadcastIntervalls().contains(seconds)) {
+ if (enable)
+ plugin.broadcast(startMessageKey());
+ else
+ plugin.broadcast(endMessageKey());
+ }
+
+ seconds--;
+ }
+
+ protected abstract void finish();
+
+ protected abstract String startMessageKey();
+
+ protected abstract String endMessageKey();
+
+ 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 int getSecondsLeft() {
+ return seconds;
+ }
+}
diff --git a/Maintenance-Core/src/main/resources/language-de.yml b/Maintenance-Core/src/main/resources/language-de.yml
index 72aab0a7..8b2574e0 100644
--- a/Maintenance-Core/src/main/resources/language-de.yml
+++ b/Maintenance-Core/src/main/resources/language-de.yml
@@ -6,8 +6,8 @@ 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 aktiviert in: &6%TIME%&7."
-endtimerStarted: "&8[&eMaintenance&8] &aGestarteter Timer: &7Der Wartungsmodus wird aktiviert in: &6%TIME%&7."
+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."
endtimerUsage: "&8[&eMaintenance&8] &c/maintenance endtimer "
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"
@@ -50,6 +50,8 @@ hours: "Stunden"
# Nachrichten für den Bungee Teil des Plugins, einfach ignorieren, falls das Plugin auf Spigot verwendet wird
noServerPermission: "&8[&eMaintenance&8] &cDu nicht die erforderliche Berechtigung, den Wartungsmodus auf dem Server %SERVER% zu ändern!"
+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] &cDieser Server befindet sich momentan im Wartungsmodus! Probier es später nochmal!"
singleMaintenanceActivated: "&8[&eMaintenance&8] &6Der Wartungsmodus wurde auf Server &e%SERVER% &6aktiviert."
singleMaintenanceDeactivated: "&8[&eMaintenance&8] &6Der Wartungsmodus wurde auf Server &e%SERVER% &6deaktiviert."
diff --git a/Maintenance-Core/src/main/resources/language-en.yml b/Maintenance-Core/src/main/resources/language-en.yml
index b30b753b..5fb2ca3f 100644
--- a/Maintenance-Core/src/main/resources/language-en.yml
+++ b/Maintenance-Core/src/main/resources/language-en.yml
@@ -50,6 +50,8 @@ hours: "hours"
# Some messages for the Bungee part, just ignore them if you use the plugin on Spigot
noServerPermission: "&8[&eMaintenance&8] &cYou don't have the permission to set maintenance on server %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] &cThis server is currently under maintenance! Try again later!"
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."
From 3c03b719d2a4ffe25ba1a17dd6581691d73193b3 Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Wed, 7 Nov 2018 21:31:49 +0100
Subject: [PATCH 20/33] API changes
---
.../api/bungee/IMaintenanceBungee.java | 30 +++++++++++++++++++
.../{ => bungee}/MaintenanceBungeeAPI.java | 7 +++--
.../{ => spigot}/MaintenanceSpigotAPI.java | 7 +++--
3 files changed, 38 insertions(+), 6 deletions(-)
create mode 100644 Maintenance-API/src/main/java/eu/kennytv/maintenance/api/bungee/IMaintenanceBungee.java
rename Maintenance-API/src/main/java/eu/kennytv/maintenance/api/{ => bungee}/MaintenanceBungeeAPI.java (83%)
rename Maintenance-API/src/main/java/eu/kennytv/maintenance/api/{ => spigot}/MaintenanceSpigotAPI.java (82%)
diff --git a/Maintenance-API/src/main/java/eu/kennytv/maintenance/api/bungee/IMaintenanceBungee.java b/Maintenance-API/src/main/java/eu/kennytv/maintenance/api/bungee/IMaintenanceBungee.java
new file mode 100644
index 00000000..6d5f80c7
--- /dev/null
+++ b/Maintenance-API/src/main/java/eu/kennytv/maintenance/api/bungee/IMaintenanceBungee.java
@@ -0,0 +1,30 @@
+package eu.kennytv.maintenance.api.bungee;
+
+import eu.kennytv.maintenance.api.IMaintenance;
+import net.md_5.bungee.api.config.ServerInfo;
+
+/**
+ * @author KennyTV
+ * @since 2.5
+ */
+public interface IMaintenanceBungee 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 maintenance true to enable, false to disable maintenance mode
+ */
+ boolean setMaintenanceToServer(ServerInfo server, boolean maintenance);
+
+ /**
+ * @return true if maintenance is currently enabled on the proxied server
+ */
+ boolean isMaintenance(ServerInfo server);
+
+ /**
+ * @return true if a start- or endtimer task is currently running regarding the proxied server
+ */
+ boolean isServerTaskRunning(ServerInfo server);
+}
diff --git a/Maintenance-API/src/main/java/eu/kennytv/maintenance/api/MaintenanceBungeeAPI.java b/Maintenance-API/src/main/java/eu/kennytv/maintenance/api/bungee/MaintenanceBungeeAPI.java
similarity index 83%
rename from Maintenance-API/src/main/java/eu/kennytv/maintenance/api/MaintenanceBungeeAPI.java
rename to Maintenance-API/src/main/java/eu/kennytv/maintenance/api/bungee/MaintenanceBungeeAPI.java
index a98948ff..2270d7a1 100644
--- a/Maintenance-API/src/main/java/eu/kennytv/maintenance/api/MaintenanceBungeeAPI.java
+++ b/Maintenance-API/src/main/java/eu/kennytv/maintenance/api/bungee/MaintenanceBungeeAPI.java
@@ -1,5 +1,7 @@
-package eu.kennytv.maintenance.api;
+package eu.kennytv.maintenance.api.bungee;
+import eu.kennytv.maintenance.api.IMaintenance;
+import eu.kennytv.maintenance.api.IMaintenanceBase;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin;
@@ -10,7 +12,7 @@
*
*
* @author KennyTV
- * @since 2.1
+ * @since 2.5
*/
public final class MaintenanceBungeeAPI {
@@ -23,7 +25,6 @@ public static IMaintenance getAPI() {
final Plugin maintenance = ProxyServer.getInstance().getPluginManager().getPlugin("MaintenanceBungee");
if (maintenance == null)
ProxyServer.getInstance().getLogger().warning("Could not get instance of MaintenanceBungee!");
-
return ((IMaintenanceBase) maintenance).getApi();
}
}
diff --git a/Maintenance-API/src/main/java/eu/kennytv/maintenance/api/MaintenanceSpigotAPI.java b/Maintenance-API/src/main/java/eu/kennytv/maintenance/api/spigot/MaintenanceSpigotAPI.java
similarity index 82%
rename from Maintenance-API/src/main/java/eu/kennytv/maintenance/api/MaintenanceSpigotAPI.java
rename to Maintenance-API/src/main/java/eu/kennytv/maintenance/api/spigot/MaintenanceSpigotAPI.java
index 6586861b..83800719 100644
--- a/Maintenance-API/src/main/java/eu/kennytv/maintenance/api/MaintenanceSpigotAPI.java
+++ b/Maintenance-API/src/main/java/eu/kennytv/maintenance/api/spigot/MaintenanceSpigotAPI.java
@@ -1,5 +1,7 @@
-package eu.kennytv.maintenance.api;
+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;
@@ -10,7 +12,7 @@
*
*
* @author KennyTV
- * @since 2.1
+ * @since 2.5
*/
public final class MaintenanceSpigotAPI {
@@ -23,7 +25,6 @@ public static IMaintenance getAPI() {
final Plugin maintenance = Bukkit.getPluginManager().getPlugin("MaintenanceSpigot");
if (maintenance == null)
Bukkit.getLogger().warning("Could not get instance of MaintenanceSpigot!");
-
return ((IMaintenanceBase) maintenance).getApi();
}
}
From e76f22f0716449da4413cb555d91213db540902d Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Wed, 7 Nov 2018 21:32:08 +0100
Subject: [PATCH 21/33] Timer commands for single server maintenance
---
.../bungee/MaintenanceBungeePlugin.java | 29 +++++--
.../command/MaintenanceBungeeCommand.java | 51 ++++++++++++
.../runnable/SingleMaintenanceRunnable.java | 1 -
.../core/MaintenanceModePlugin.java | 2 +-
.../core/command/MaintenanceCommand.java | 81 +++++++++----------
.../core/runnable/MaintenanceRunnable.java | 2 -
.../src/main/resources/language-en.yml | 2 +
.../spigot/MaintenanceSpigotPlugin.java | 2 +-
.../command/MaintenanceSpigotCommand.java | 5 --
9 files changed, 113 insertions(+), 62 deletions(-)
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
index eade0761..165fb1b6 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
@@ -2,7 +2,8 @@
import eu.kennytv.maintenance.api.IMaintenance;
import eu.kennytv.maintenance.api.ISettings;
-import eu.kennytv.maintenance.api.MaintenanceBungeeAPI;
+import eu.kennytv.maintenance.api.bungee.IMaintenanceBungee;
+import eu.kennytv.maintenance.api.bungee.MaintenanceBungeeAPI;
import eu.kennytv.maintenance.bungee.command.MaintenanceBungeeCommand;
import eu.kennytv.maintenance.bungee.command.MaintenanceBungeeCommandBase;
import eu.kennytv.maintenance.bungee.listener.PostLoginListener;
@@ -12,6 +13,7 @@
import eu.kennytv.maintenance.core.MaintenanceModePlugin;
import eu.kennytv.maintenance.core.Settings;
import eu.kennytv.maintenance.core.hook.ServerListPlusHook;
+import eu.kennytv.maintenance.core.runnable.MaintenanceRunnableBase;
import eu.kennytv.maintenance.core.util.ServerType;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
@@ -28,7 +30,7 @@
* @author KennyTV
* @since 1.0
*/
-public final class MaintenanceBungeePlugin extends MaintenanceModePlugin {
+public final class MaintenanceBungeePlugin extends MaintenanceModePlugin implements IMaintenanceBungee {
private final MaintenanceBungeeBase plugin;
private final SettingsBungee settings;
private final Map serverTaskIds = new HashMap<>();
@@ -71,7 +73,6 @@ public void setMaintenance(final boolean maintenance) {
}
serverActions(maintenance);
-
if (isTaskRunning())
cancelTask();
}
@@ -89,6 +90,12 @@ void serverActions(final boolean maintenance) {
getProxy().broadcast(settings.getMessage("maintenanceDeactivated"));
}
+ @Override
+ public boolean isMaintenance(final ServerInfo server) {
+ return settings.getMaintenanceServers().contains(server.getName());
+ }
+
+ @Override
public boolean setMaintenanceToServer(final ServerInfo server, final boolean maintenance) {
if (maintenance) {
if (!settings.getMaintenanceServers().add(server.getName())) return false;
@@ -125,13 +132,19 @@ public boolean setMaintenanceToServer(final ServerInfo server, final boolean mai
}
@Override
- public int startMaintenanceRunnable(final Runnable runnable) {
+ public boolean isServerTaskRunning(final ServerInfo server) {
+ return serverTaskIds.containsKey(server.getName());
+ }
+
+ @Override
+ protected int startMaintenanceRunnable(final Runnable runnable) {
return getProxy().getScheduler().schedule(plugin, runnable, 0, 1, TimeUnit.SECONDS).getId();
}
- public void startSingleMaintenanceRunnable(final ServerInfo server, final int minutes, final boolean enable) {
- getProxy().getScheduler().schedule(plugin,
- new SingleMaintenanceRunnable(this, (Settings) getSettings(), minutes, enable, server), 0, 1, TimeUnit.SECONDS).getId();
+ public MaintenanceRunnableBase startSingleMaintenanceRunnable(final ServerInfo server, final int minutes, final boolean enable) {
+ final MaintenanceRunnableBase runnable = new SingleMaintenanceRunnable(this, (Settings) getSettings(), minutes, enable, server);
+ serverTaskIds.put(server.getName(), getProxy().getScheduler().schedule(plugin, runnable, 0, 1, TimeUnit.SECONDS).getId());
+ return runnable;
}
@Override
@@ -147,7 +160,7 @@ public void cancelTask() {
}
public void cancelSingleTask(final ServerInfo server) {
- final Integer task = serverTaskIds.get(server.getName());
+ final Integer task = serverTaskIds.remove(server.getName());
if (task != null)
getProxy().getScheduler().cancel(task);
}
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
index 3d522862..11066621 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
@@ -4,6 +4,7 @@
import eu.kennytv.maintenance.bungee.SettingsBungee;
import eu.kennytv.maintenance.bungee.util.ProxiedSenderInfo;
import eu.kennytv.maintenance.core.command.MaintenanceCommand;
+import eu.kennytv.maintenance.core.runnable.MaintenanceRunnableBase;
import eu.kennytv.maintenance.core.util.SenderInfo;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.ClickEvent;
@@ -92,4 +93,54 @@ protected void handleToggleServerCommand(final SenderInfo sender, final String a
} else
sender.sendMessage(settings.getMessage(maintenance ? "singleServerAlreadyEnabled" : "singleServerAlreadyDisabled"));
}
+
+ @Override
+ protected void handleTimerServerCommands(final SenderInfo sender, final String args[]) {
+ if (args[0].equalsIgnoreCase("endtimer")) {
+ if (checkPermission(sender, "servertimer")) return;
+ if (checkTimerArgs(sender, args[2], "singleEndtimerUsage")) return;
+
+ final ServerInfo server = ProxyServer.getInstance().getServerInfo(args[1]);
+ if (server == null) {
+ sender.sendMessage(settings.getMessage("serverNotFound"));
+ return;
+ }
+ if (!plugin.isMaintenance(server))
+ plugin.setMaintenanceToServer(server, true);
+ final MaintenanceRunnableBase runnable = plugin.startSingleMaintenanceRunnable(server, Integer.parseInt(args[2]), false);
+ sender.sendMessage(settings.getMessage("endtimerStarted").replace("%TIME%", runnable.getTime()));
+ } else if (args[0].equalsIgnoreCase("starttimer")) {
+ if (checkPermission(sender, "servertimer")) return;
+ if (checkTimerArgs(sender, args[2], "singleStarttimerUsage")) return;
+ final ServerInfo server = ProxyServer.getInstance().getServerInfo(args[1]);
+ if (server == null) {
+ sender.sendMessage(settings.getMessage("serverNotFound"));
+ return;
+ }
+ if (plugin.isMaintenance(server)) {
+ sender.sendMessage(settings.getMessage("alreadyEnabled"));
+ return;
+ }
+
+ final MaintenanceRunnableBase runnable = plugin.startSingleMaintenanceRunnable(server, Integer.parseInt(args[2]), true);
+ sender.sendMessage(settings.getMessage("starttimerStarted").replace("%TIME%", runnable.getTime()));
+ } else if (args[0].equalsIgnoreCase("timer")) {
+ if (args[1].equalsIgnoreCase("abort") || args[1].equalsIgnoreCase("stop") || args[1].equalsIgnoreCase("cancel")) {
+ if (checkPermission(sender, "servertimer")) return;
+ final ServerInfo server = ProxyServer.getInstance().getServerInfo(args[1]);
+ if (server == null) {
+ sender.sendMessage(settings.getMessage("serverNotFound"));
+ return;
+ }
+ if (!plugin.isServerTaskRunning(server)) {
+ sender.sendMessage(settings.getMessage("timerNotRunning"));
+ return;
+ }
+
+ plugin.cancelSingleTask(server);
+ sender.sendMessage(settings.getMessage("timerCancelled"));
+ } else
+ sendUsage(sender);
+ }
+ }
}
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/runnable/SingleMaintenanceRunnable.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/runnable/SingleMaintenanceRunnable.java
index 4e795df0..1a57c7f6 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/runnable/SingleMaintenanceRunnable.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/runnable/SingleMaintenanceRunnable.java
@@ -19,7 +19,6 @@ public SingleMaintenanceRunnable(final MaintenanceModePlugin plugin, final Setti
protected void finish() {
final MaintenanceBungeePlugin plugin = (MaintenanceBungeePlugin) this.plugin;
plugin.setMaintenanceToServer(server, enable);
- plugin.cancelSingleTask(server);
}
@Override
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java
index 69806b75..2cf74fca 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/MaintenanceModePlugin.java
@@ -52,7 +52,7 @@ public Version getNewestVersion() {
return newestVersion;
}
- public abstract int startMaintenanceRunnable(Runnable runnable);
+ protected abstract int startMaintenanceRunnable(Runnable runnable);
public abstract void async(Runnable runnable);
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
index 5da7ff1f..980fba87 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
@@ -43,7 +43,6 @@ public void execute(final SenderInfo sender, final String[] args) {
} else if (args[0].equals("forceupdate")) {
if (checkPermission(sender, "update")) return;
sender.sendMessage(settings.getMessage("updateDownloading"));
-
if (plugin.installUpdate())
sender.sendMessage(settings.getMessage("updateFinished"));
else
@@ -79,55 +78,20 @@ public void execute(final SenderInfo sender, final String[] args) {
handleToggleServerCommand(sender, args);
} else if (args[0].equalsIgnoreCase("endtimer")) {
if (checkPermission(sender, "timer")) return;
- if (!isNumeric(args[1])) {
- sender.sendMessage(settings.getMessage("endtimerUsage"));
- return;
- }
- if (plugin.isTaskRunning()) {
- sender.sendMessage(settings.getMessage("timerAlreadyRunning"));
- return;
- }
-
- final int minutes = Integer.parseInt(args[1]);
- if (minutes > 40320) {
- sender.sendMessage(settings.getMessage("timerTooLong"));
- return;
- }
- if (minutes < 1) {
- sender.sendMessage("§8§o[KennyTV whispers to you] §c§oThink about running a timer for a negative amount of minutes. Doesn't work §lthat §c§owell.");
- return;
- }
-
+ if (checkTimerArgs(sender, args[1], "endtimerUsage")) return;
if (!plugin.isMaintenance())
plugin.setMaintenance(true);
- plugin.startMaintenanceRunnable(minutes, false);
+ plugin.startMaintenanceRunnable(Integer.parseInt(args[1]), false);
sender.sendMessage(settings.getMessage("endtimerStarted").replace("%TIME%", plugin.getRunnable().getTime()));
} else if (args[0].equalsIgnoreCase("starttimer")) {
if (checkPermission(sender, "timer")) return;
- if (!isNumeric(args[1])) {
- sender.sendMessage(settings.getMessage("starttimerUsage"));
- return;
- }
+ if (checkTimerArgs(sender, args[1], "starttimerUsage")) return;
if (plugin.isMaintenance()) {
sender.sendMessage(settings.getMessage("alreadyEnabled"));
return;
}
- if (plugin.isTaskRunning()) {
- sender.sendMessage(settings.getMessage("timerAlreadyRunning"));
- return;
- }
-
- final int minutes = Integer.parseInt(args[1]);
- if (minutes > 40320) {
- sender.sendMessage(settings.getMessage("timerTooLong"));
- return;
- }
- if (minutes < 1) {
- sender.sendMessage("§8§o[KennyTV whispers to you] §c§oThink about running a timer for a negative amount of minutes. Doesn't work §lthat §c§owell.");
- return;
- }
- plugin.startMaintenanceRunnable(minutes, true);
+ plugin.startMaintenanceRunnable(Integer.parseInt(args[1]), true);
sender.sendMessage(settings.getMessage("starttimerStarted").replace("%TIME%", plugin.getRunnable().getTime()));
} else if (args[0].equalsIgnoreCase("timer")) {
if (args[1].equalsIgnoreCase("abort") || args[1].equalsIgnoreCase("stop") || args[1].equalsIgnoreCase("cancel")) {
@@ -172,6 +136,8 @@ public void execute(final SenderInfo sender, final String[] args) {
sender.sendMessage(settings.getMessage("removedMotd").replace("%INDEX%", args[1]));
} else
sendUsage(sender);
+ } else if (args.length == 3) {
+
} else if (args.length > 3 && args[0].equalsIgnoreCase("setmotd")) {
if (checkPermission(sender, "setmotd")) return;
if (!isNumeric(args[1])) {
@@ -220,7 +186,8 @@ public void execute(final SenderInfo sender, final String[] args) {
sendUsage(sender);
}
- private void sendUsage(final SenderInfo sender) {
+ protected void sendUsage(final SenderInfo sender) {
+ //TODO split, switch toggle permission check, timer usage
sender.sendMessage("");
sender.sendMessage("§8===========[ §e" + name + " §8| §eVersion: §e" + plugin.getVersion() + " §8]===========");
if (sender.hasPermission("maintenance.reload"))
@@ -258,7 +225,7 @@ private void sendUsage(final SenderInfo sender) {
sender.sendMessage("");
}
- private boolean checkPermission(final SenderInfo sender, final String permission) {
+ protected boolean checkPermission(final SenderInfo sender, final String permission) {
if (!sender.hasPermission("maintenance." + permission)) {
sender.sendMessage(settings.getMessage("noPermission"));
return true;
@@ -266,7 +233,7 @@ private boolean checkPermission(final SenderInfo sender, final String permission
return false;
}
- private boolean isNumeric(final String string) {
+ protected boolean isNumeric(final String string) {
try {
Integer.parseInt(string);
} catch (final NumberFormatException nfe) {
@@ -275,11 +242,37 @@ private boolean isNumeric(final String string) {
return true;
}
+ protected boolean checkTimerArgs(final SenderInfo sender, final String time, final String usageKey) {
+ if (!isNumeric(time)) {
+ sender.sendMessage(settings.getMessage(usageKey));
+ return true;
+ }
+ 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] §c§oThink about running a timer for a negative amount of minutes. Doesn't work §lthat §c§owell.");
+ return true;
+ }
+ return false;
+ }
+
protected abstract void addPlayerToWhitelist(SenderInfo sender, String name);
protected abstract void removePlayerFromWhitelist(SenderInfo sender, String name);
protected abstract void checkForUpdate(SenderInfo sender);
- protected abstract void handleToggleServerCommand(SenderInfo sender, String args[]);
+ protected void handleToggleServerCommand(SenderInfo sender, String args[]) {
+ }
+
+ protected void handleTimerServerCommands(SenderInfo sender, String args[]) {
+ }
}
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/runnable/MaintenanceRunnable.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/runnable/MaintenanceRunnable.java
index 02ed41d4..7be43e20 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/runnable/MaintenanceRunnable.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/runnable/MaintenanceRunnable.java
@@ -12,8 +12,6 @@ public MaintenanceRunnable(final MaintenanceModePlugin plugin, final Settings se
@Override
protected void finish() {
plugin.setMaintenance(enable);
- if (plugin.isTaskRunning())
- plugin.cancelTask();
}
@Override
diff --git a/Maintenance-Core/src/main/resources/language-en.yml b/Maintenance-Core/src/main/resources/language-en.yml
index 5fb2ca3f..daf956ca 100644
--- a/Maintenance-Core/src/main/resources/language-en.yml
+++ b/Maintenance-Core/src/main/resources/language-en.yml
@@ -51,7 +51,9 @@ hours: "hours"
# Some messages for the Bungee part, just ignore them if you use the plugin on Spigot
noServerPermission: "&8[&eMaintenance&8] &cYou don't have the permission to set maintenance on server %SERVER%!"
singleEndtimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode on server %SERVER% will be disabled in &6%TIME%&7."
+singleEndtimerUsage: "&8[&eMaintenance&8] &c/maintenance endtimer "
singleStarttimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode on server %SERVER% will be enabled in &6%TIME%&7."
+singleStarttimerUsage: "&8[&eMaintenance&8] &c/maintenance starttimer "
singleMaintenanceKick: "&8[&eMaintenance&8] &cThis server is currently under maintenance! Try again later!"
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."
diff --git a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/MaintenanceSpigotPlugin.java b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/MaintenanceSpigotPlugin.java
index 2403451c..ce2863de 100644
--- a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/MaintenanceSpigotPlugin.java
+++ b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/MaintenanceSpigotPlugin.java
@@ -2,7 +2,7 @@
import eu.kennytv.maintenance.api.IMaintenance;
import eu.kennytv.maintenance.api.ISettings;
-import eu.kennytv.maintenance.api.MaintenanceSpigotAPI;
+import eu.kennytv.maintenance.api.spigot.MaintenanceSpigotAPI;
import eu.kennytv.maintenance.core.MaintenanceModePlugin;
import eu.kennytv.maintenance.core.hook.ServerListPlusHook;
import eu.kennytv.maintenance.core.util.ServerType;
diff --git a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/command/MaintenanceSpigotCommand.java b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/command/MaintenanceSpigotCommand.java
index 720c0ad9..cef13bb4 100644
--- a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/command/MaintenanceSpigotCommand.java
+++ b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/command/MaintenanceSpigotCommand.java
@@ -80,9 +80,4 @@ protected void checkForUpdate(final SenderInfo sender) {
} else
sender.sendMessage(plugin.getPrefix() + "§aYou already have the latest version of the plugin!");
}
-
- @Override
- @Deprecated
- protected void handleToggleServerCommand(final SenderInfo senderInfo, final String[] args) {
- }
}
From 7ccd265a30cfcf93cc620a4079649481a08a68d2 Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Wed, 7 Nov 2018 21:36:29 +0100
Subject: [PATCH 22/33] pom changes
---
Maintenance-API/pom.xml | 2 +-
pom.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Maintenance-API/pom.xml b/Maintenance-API/pom.xml
index 810c5032..85e4ef71 100644
--- a/Maintenance-API/pom.xml
+++ b/Maintenance-API/pom.xml
@@ -22,7 +22,7 @@
org.spigotmc
spigot-api
- 1.12.2-R0.1-SNAPSHOT
+ 1.13.2-R0.1-SNAPSHOT
provided
diff --git a/pom.xml b/pom.xml
index ed35a1aa..8ab2ea1d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -31,7 +31,7 @@
org.apache.maven.plugins
maven-shade-plugin
- 3.1.1
+ 3.2.0
package
From af50a45e65fca40f27cb1c6b577d983647830664 Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Fri, 9 Nov 2018 21:14:32 +0100
Subject: [PATCH 23/33] Command
---
.../kennytv/maintenance/core/command/MaintenanceCommand.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
index 980fba87..224013c0 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
@@ -136,8 +136,8 @@ public void execute(final SenderInfo sender, final String[] args) {
sender.sendMessage(settings.getMessage("removedMotd").replace("%INDEX%", args[1]));
} else
sendUsage(sender);
- } else if (args.length == 3) {
-
+ } else if (args.length == 3 && plugin.getServerType() == ServerType.BUNGEE) {
+ handleTimerServerCommands(sender, args);
} else if (args.length > 3 && args[0].equalsIgnoreCase("setmotd")) {
if (checkPermission(sender, "setmotd")) return;
if (!isNumeric(args[1])) {
From 5c67922996f0c362d8c0dd187be10f4fa2be84ac Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Fri, 9 Nov 2018 23:20:34 +0100
Subject: [PATCH 24/33] Some fixes and changes
---
.../bungee/MaintenanceBungeePlugin.java | 2 +-
.../maintenance/bungee/SettingsBungee.java | 46 ++++++++++---------
.../command/MaintenanceBungeeCommand.java | 12 ++---
.../eu/kennytv/maintenance/core/Settings.java | 2 +-
.../core/command/MaintenanceCommand.java | 4 +-
.../src/main/resources/language-de.yml | 1 -
.../src/main/resources/language-en.yml | 1 -
.../maintenance/spigot/SettingsSpigot.java | 16 ++++---
8 files changed, 43 insertions(+), 41 deletions(-)
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
index 165fb1b6..d25c76c8 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
@@ -121,7 +121,7 @@ public boolean setMaintenanceToServer(final ServerInfo server, final boolean mai
}
/*if (mySQL != null) {
- mySQL.executeUpdate(serversQuery, "spigot-servers-with-maintenance", maintenanceServers, maintenanceServers);
+ mySQL.executeUpdate(serversQuery, "spigotServers-with-maintenance", maintenanceServers, maintenanceServers);
} else {
spigotServers.set("maintenance-on", maintenanceServers);
saveSpigotServers();
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
index 0d53643a..bbbce44f 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
@@ -50,10 +50,8 @@ public final class SettingsBungee extends Settings {
if (!plugin.getDataFolder().exists())
plugin.getDataFolder().mkdirs();
createFile("bungee-config.yml");
- createLanguageFile();
createFile("WhitelistedPlayers.yml");
createFile("SpigotServers.yml");
-
reloadConfigs();
final Configuration mySQLSection = config.getSection("mysql");
@@ -91,22 +89,6 @@ private void createFile(final String name) {
}
}
- private void createLanguageFile() {
- final File file = new File(plugin.getDataFolder(), "language.yml");
- if (!file.exists()) {
- try (final InputStream in = plugin.getResourceAsStream("language-" + getLanguage() + ".yml")) {
- Files.copy(in, file.toPath());
- } catch (final IOException e) {
- plugin.getLogger().warning("Unable to provide language " + getLanguage());
- if (!languageName.equals("en")) {
- plugin.getLogger().warning("Falling back to default language: en");
- languageName = "en";
- createLanguageFile();
- }
- }
- }
- }
-
@Override
public boolean updateExtraConfig() {
// 2.3.1 mysql.update-interval
@@ -122,15 +104,37 @@ public void reloadConfigs() {
try {
config = YamlConfiguration.getProvider(YamlConfiguration.class)
.load(new InputStreamReader(new FileInputStream(new File(plugin.getDataFolder(), "bungee-config.yml")), StandardCharsets.UTF_8));
- language = YamlConfiguration.getProvider(YamlConfiguration.class)
- .load(new InputStreamReader(new FileInputStream(new File(plugin.getDataFolder(), "language.yml")), StandardCharsets.UTF_8));
whitelist = YamlConfiguration.getProvider(YamlConfiguration.class).load(new File(plugin.getDataFolder(), "WhitelistedPlayers.yml"));
- spigotServers = YamlConfiguration.getProvider(YamlConfiguration.class).load(new File(plugin.getDataFolder(), "spigot-servers.yml"));
+ spigotServers = YamlConfiguration.getProvider(YamlConfiguration.class).load(new File(plugin.getDataFolder(), "spigotServers.yml"));
} catch (final IOException e) {
throw new RuntimeException("Unable to load Maintenance files!", e);
}
loadSettings();
+ createAndLoadLanguageFile();
+ }
+
+ private void createAndLoadLanguageFile() {
+ final File file = new File(plugin.getDataFolder(), "language-" + getLanguage() + ".yml");
+ if (!file.exists()) {
+ try (final InputStream in = plugin.getResourceAsStream("language-" + getLanguage() + ".yml")) {
+ Files.copy(in, file.toPath());
+ } catch (final IOException | NullPointerException e) {
+ plugin.getLogger().warning("Unable to provide language " + getLanguage());
+ if (!languageName.equals("en")) {
+ plugin.getLogger().warning("Falling back to default language: en");
+ languageName = "en";
+ createAndLoadLanguageFile();
+ return;
+ }
+ }
+ }
+ try {
+ language = YamlConfiguration.getProvider(YamlConfiguration.class)
+ .load(new InputStreamReader(new FileInputStream(new File(plugin.getDataFolder(), "language-" + getLanguage() + ".yml")), StandardCharsets.UTF_8));
+ } catch (final IOException e) {
+ throw new RuntimeException("Unable to load Maintenance language file!", e);
+ }
}
@Override
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
index 11066621..c93d02f8 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
@@ -77,10 +77,6 @@ protected void handleToggleServerCommand(final SenderInfo sender, final String a
sender.sendMessage(settings.getMessage("serverNotFound"));
return;
}
- if (!sender.hasPermission("maintenance.toggleserver." + server.getName().toLowerCase())) {
- sender.sendMessage(settings.getMessage("noServerPermission").replace("%SERVER%", server.getName()));
- return;
- }
final boolean maintenance = args[0].equalsIgnoreCase("on");
if (maintenance == settingsBungee.getMaintenanceServers().contains(server.getName())) {
@@ -88,10 +84,10 @@ protected void handleToggleServerCommand(final SenderInfo sender, final String a
return;
}
- if (plugin.setMaintenanceToServer(server, maintenance)) {
- sender.sendMessage(settings.getMessage(maintenance ? "singleMaintenanceActivated" : "singleMaintenanceDectivated"));
- } else
+ if (!plugin.setMaintenanceToServer(server, maintenance))
sender.sendMessage(settings.getMessage(maintenance ? "singleServerAlreadyEnabled" : "singleServerAlreadyDisabled"));
+ else if (!ProxyServer.getInstance().getPlayer(sender.getUuid()).getServer().getInfo().equals(server))
+ sender.sendMessage(settings.getMessage(maintenance ? "singleMaintenanceActivated" : "singleMaintenanceDectivated"));
}
@Override
@@ -127,7 +123,7 @@ protected void handleTimerServerCommands(final SenderInfo sender, final String a
} else if (args[0].equalsIgnoreCase("timer")) {
if (args[1].equalsIgnoreCase("abort") || args[1].equalsIgnoreCase("stop") || args[1].equalsIgnoreCase("cancel")) {
if (checkPermission(sender, "servertimer")) return;
- final ServerInfo server = ProxyServer.getInstance().getServerInfo(args[1]);
+ final ServerInfo server = ProxyServer.getInstance().getServerInfo(args[2]);
if (server == null) {
sender.sendMessage(settings.getMessage("serverNotFound"));
return;
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/Settings.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/Settings.java
index fe5beccf..b925022c 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/Settings.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/Settings.java
@@ -35,7 +35,7 @@ protected void loadSettings() {
playerCountMessage = getColoredString(getConfigString("playercountmessage"));
playerCountHoverMessage = getColoredString(getConfigString("playercounthovermessage"));
kickMessage = getColoredString(getConfigString("kickmessage"));
- languageName = getConfigString("language");
+ languageName = getConfigString("language").toLowerCase();
if (customMaintenanceIcon)
reloadMaintenanceIcon();
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
index 224013c0..8a9d354c 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
@@ -189,7 +189,7 @@ public void execute(final SenderInfo sender, final String[] args) {
protected void sendUsage(final SenderInfo sender) {
//TODO split, switch toggle permission check, timer usage
sender.sendMessage("");
- sender.sendMessage("§8===========[ §e" + name + " §8| §eVersion: §e" + plugin.getVersion() + " §8]===========");
+ sender.sendMessage("§8========[ §e" + name + " §8| §eVersion: §e" + plugin.getVersion() + " §8]========");
if (sender.hasPermission("maintenance.reload"))
sender.sendMessage("§6/maintenance reload §7(Reloads the config file, whitelist file and the server-icon)");
if (sender.hasPermission("maintenance.toggle")) {
@@ -221,7 +221,7 @@ protected void sendUsage(final SenderInfo sender) {
if (sender.hasPermission("maintenance.update"))
sender.sendMessage("§6/maintenance update §7(Remotely downloads the newest version of the plugin onto your server)");
sender.sendMessage("§8× §7Created by §bKennyTV");
- sender.sendMessage("§8===========[ §e" + name + " §8| §eVersion: §e" + plugin.getVersion() + " §8]===========");
+ sender.sendMessage("§8========[ §e" + name + " §8| §eVersion: §e" + plugin.getVersion() + " §8]========");
sender.sendMessage("");
}
diff --git a/Maintenance-Core/src/main/resources/language-de.yml b/Maintenance-Core/src/main/resources/language-de.yml
index 8b2574e0..e61aded2 100644
--- a/Maintenance-Core/src/main/resources/language-de.yml
+++ b/Maintenance-Core/src/main/resources/language-de.yml
@@ -49,7 +49,6 @@ hour: "Stunde"
hours: "Stunden"
# Nachrichten für den Bungee Teil des Plugins, einfach ignorieren, falls das Plugin auf Spigot verwendet wird
-noServerPermission: "&8[&eMaintenance&8] &cDu nicht die erforderliche Berechtigung, den Wartungsmodus auf dem Server %SERVER% zu ändern!"
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] &cDieser Server befindet sich momentan im Wartungsmodus! Probier es später nochmal!"
diff --git a/Maintenance-Core/src/main/resources/language-en.yml b/Maintenance-Core/src/main/resources/language-en.yml
index daf956ca..76488143 100644
--- a/Maintenance-Core/src/main/resources/language-en.yml
+++ b/Maintenance-Core/src/main/resources/language-en.yml
@@ -49,7 +49,6 @@ hour: "hour"
hours: "hours"
# Some messages for the Bungee part, just ignore them if you use the plugin on Spigot
-noServerPermission: "&8[&eMaintenance&8] &cYou don't have the permission to set maintenance on server %SERVER%!"
singleEndtimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode on server %SERVER% will be disabled in &6%TIME%&7."
singleEndtimerUsage: "&8[&eMaintenance&8] &c/maintenance endtimer "
singleStarttimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode on server %SERVER% will be enabled in &6%TIME%&7."
diff --git a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/SettingsSpigot.java b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/SettingsSpigot.java
index f4f24318..d03b6d3d 100644
--- a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/SettingsSpigot.java
+++ b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/SettingsSpigot.java
@@ -38,9 +38,7 @@ public final class SettingsSpigot extends Settings {
if (!plugin.getDataFolder().exists())
plugin.getDataFolder().mkdirs();
createFile("spigot-config.yml");
- createLanguageFile();
createFile("WhitelistedPlayers.yml");
-
reloadConfigs();
}
@@ -55,8 +53,8 @@ private void createFile(final String name) {
}
}
- private void createLanguageFile() {
- final File file = new File(plugin.getDataFolder(), "language.yml");
+ private void createAndLoadLanguageFile() {
+ final File file = new File(plugin.getDataFolder(), "language-" + getLanguage() + ".yml");
if (!file.exists()) {
try (final InputStream in = plugin.getResource("language-" + getLanguage() + ".yml")) {
Files.copy(in, file.toPath());
@@ -65,10 +63,16 @@ private void createLanguageFile() {
if (!languageName.equals("en")) {
plugin.getLogger().warning("Falling back to default language: en");
languageName = "en";
- createLanguageFile();
+ createAndLoadLanguageFile();
+ return;
}
}
}
+ try {
+ language = YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(new File(plugin.getDataFolder(), "language-" + getLanguage() + ".yml")), StandardCharsets.UTF_8));
+ } catch (final IOException e) {
+ throw new RuntimeException("Unable to load Maintenance language file!", e);
+ }
}
@Override
@@ -104,13 +108,13 @@ public void saveWhitelistedPlayers() {
public void reloadConfigs() {
try {
config = YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(new File(plugin.getDataFolder(), "spigot-config.yml")), StandardCharsets.UTF_8));
- language = YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(new File(plugin.getDataFolder(), "language.yml")), StandardCharsets.UTF_8));
whitelist = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "WhitelistedPlayers.yml"));
} catch (final IOException e) {
throw new RuntimeException("Unable to load Maintenance files!", e);
}
loadSettings();
+ createAndLoadLanguageFile();
}
@Override
From 18828207c0d8db7182a05fb7ceaa8f395e249ee2 Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Sat, 10 Nov 2018 15:08:32 +0100
Subject: [PATCH 25/33] Maintenance status command + some more minor changes
---
.../command/MaintenanceBungeeCommand.java | 38 ++++++++++++++-----
.../core/command/MaintenanceCommand.java | 6 +++
.../src/main/resources/language-de.yml | 10 +++--
.../src/main/resources/language-en.yml | 4 +-
4 files changed, 43 insertions(+), 15 deletions(-)
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
index c93d02f8..1c8b142e 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
@@ -96,11 +96,8 @@ protected void handleTimerServerCommands(final SenderInfo sender, final String a
if (checkPermission(sender, "servertimer")) return;
if (checkTimerArgs(sender, args[2], "singleEndtimerUsage")) return;
- final ServerInfo server = ProxyServer.getInstance().getServerInfo(args[1]);
- if (server == null) {
- sender.sendMessage(settings.getMessage("serverNotFound"));
- return;
- }
+ final ServerInfo server = checkSingleTimerArgs(sender, args);
+ if (server == null) return;
if (!plugin.isMaintenance(server))
plugin.setMaintenanceToServer(server, true);
final MaintenanceRunnableBase runnable = plugin.startSingleMaintenanceRunnable(server, Integer.parseInt(args[2]), false);
@@ -108,11 +105,9 @@ protected void handleTimerServerCommands(final SenderInfo sender, final String a
} else if (args[0].equalsIgnoreCase("starttimer")) {
if (checkPermission(sender, "servertimer")) return;
if (checkTimerArgs(sender, args[2], "singleStarttimerUsage")) return;
- final ServerInfo server = ProxyServer.getInstance().getServerInfo(args[1]);
- if (server == null) {
- sender.sendMessage(settings.getMessage("serverNotFound"));
- return;
- }
+
+ final ServerInfo server = checkSingleTimerArgs(sender, args);
+ if (server == null) return;
if (plugin.isMaintenance(server)) {
sender.sendMessage(settings.getMessage("alreadyEnabled"));
return;
@@ -139,4 +134,27 @@ protected void handleTimerServerCommands(final SenderInfo sender, final String a
sendUsage(sender);
}
}
+
+ @Override
+ protected void showMaintenanceStatus(final SenderInfo sender) {
+ if (settingsBungee.getMaintenanceServers().isEmpty()) {
+ sender.sendMessage(settings.getMessage("singleServerMaintenanceListEmpty"));
+ } else {
+ sender.sendMessage(settings.getMessage("singleServerMaintenanceList"));
+ settingsBungee.getMaintenanceServers().forEach(server -> sender.sendMessage("§8- §b" + server));
+ }
+ }
+
+ private ServerInfo checkSingleTimerArgs(final SenderInfo sender, final String[] args) {
+ final ServerInfo server = ProxyServer.getInstance().getServerInfo(args[1]);
+ if (server == null) {
+ sender.sendMessage(settings.getMessage("serverNotFound"));
+ return null;
+ }
+ if (plugin.isServerTaskRunning(server)) {
+ sender.sendMessage(settings.getMessage("timerAlreadyRunning"));
+ return null;
+ }
+ return server;
+ }
}
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
index 8a9d354c..f7c6c2cc 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
@@ -70,6 +70,9 @@ public void execute(final SenderInfo sender, final String[] args) {
}
}
sender.sendMessage("§8§m----------");
+ } else if (args[0].equalsIgnoreCase("status") && plugin.getServerType() == ServerType.BUNGEE) {
+ if (checkPermission(sender, "status")) return;
+ showMaintenanceStatus(sender);
} else
sendUsage(sender);
} else if (args.length == 2) {
@@ -270,6 +273,9 @@ protected boolean checkTimerArgs(final SenderInfo sender, final String time, fin
protected abstract void checkForUpdate(SenderInfo sender);
+ protected void showMaintenanceStatus(SenderInfo sender) {
+ }
+
protected void handleToggleServerCommand(SenderInfo sender, String args[]) {
}
diff --git a/Maintenance-Core/src/main/resources/language-de.yml b/Maintenance-Core/src/main/resources/language-de.yml
index e61aded2..7557d0b4 100644
--- a/Maintenance-Core/src/main/resources/language-de.yml
+++ b/Maintenance-Core/src/main/resources/language-de.yml
@@ -52,7 +52,9 @@ hours: "Stunden"
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] &cDieser Server befindet sich momentan im Wartungsmodus! Probier es später nochmal!"
-singleMaintenanceActivated: "&8[&eMaintenance&8] &6Der Wartungsmodus wurde auf Server &e%SERVER% &6aktiviert."
-singleMaintenanceDeactivated: "&8[&eMaintenance&8] &6Der Wartungsmodus wurde auf Server &e%SERVER% &6deaktiviert."
-singleServerAlreadyEnabled: "&8[&eMaintenance&8] &cDer Wartungsmodus ist bereits an auf Server &e%SERVER%&c!"
-singleServerAlreadyDisabled: "&8[&eMaintenance&8] &cDer Wartungsmodus ist bereits aus auf Server &e%SERVER%&c!"
\ No newline at end of file
+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] &7Unterserverserver, die im Wartungsmodus sind:"
+singleServerMaintenanceListEmpty: "&8[&eMaintenance&8] &7Es befindet sich momentan kein Unterserver im Wartungsmodus."
\ No newline at end of file
diff --git a/Maintenance-Core/src/main/resources/language-en.yml b/Maintenance-Core/src/main/resources/language-en.yml
index 76488143..60f5cb07 100644
--- a/Maintenance-Core/src/main/resources/language-en.yml
+++ b/Maintenance-Core/src/main/resources/language-en.yml
@@ -12,7 +12,7 @@ endtimerUsage: "&8[&eMaintenance&8] &c/maintenance endtimer "
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."
starttimerUsage: "&8[&eMaintenance&8] &c/maintenance starttimer "
-timerAlreadyRunning: "&8[&eMaintenance&8] &cThere's already a starttimer scheduled!"
+timerAlreadyRunning: "&8[&eMaintenance&8] &cThere's already a timer scheduled!"
timerNotRunning: "&8[&eMaintenance&8] &cThere's 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)!"
@@ -58,3 +58,5 @@ singleMaintenanceActivated: "&8[&eMaintenance&8] &6Maintenance mode is now activ
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."
From 59af774d092c4126a547ac1c81aa001b1f8881bd Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Sat, 10 Nov 2018 16:50:10 +0100
Subject: [PATCH 26/33] Some more fixes
---
.../bungee/MaintenanceBungeePlugin.java | 13 +++++--
.../maintenance/bungee/SettingsBungee.java | 7 ++--
.../command/MaintenanceBungeeCommand.java | 13 ++++---
.../listener/ServerConnectListener.java | 36 ++++++++++++++-----
.../maintenance/spigot/SettingsSpigot.java | 1 -
5 files changed, 45 insertions(+), 25 deletions(-)
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
index d25c76c8..714b26f5 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
@@ -25,6 +25,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
+import java.util.logging.Logger;
/**
* @author KennyTV
@@ -46,7 +47,7 @@ public final class MaintenanceBungeePlugin extends MaintenanceModePlugin impleme
final PluginManager pm = getProxy().getPluginManager();
pm.registerListener(plugin, new PostLoginListener(this, settings));
- pm.registerListener(plugin, new ServerConnectListener(settings));
+ pm.registerListener(plugin, new ServerConnectListener(this, settings));
final MaintenanceBungeeCommand maintenanceCommand = new MaintenanceBungeeCommand(this, settings);
pm.registerCommand(plugin, new MaintenanceBungeeCommandBase(maintenanceCommand));
@@ -100,9 +101,11 @@ public boolean setMaintenanceToServer(final ServerInfo server, final boolean mai
if (maintenance) {
if (!settings.getMaintenanceServers().add(server.getName())) return false;
- final ServerInfo fallback = ProxyServer.getInstance().getServerInfo(settings.getFallbackServer());
+ final ServerInfo fallback = getProxy().getServerInfo(settings.getFallbackServer());
if (fallback == null)
- plugin.getLogger().warning("The fallback server set in the SpigotServers.yml could not be found! Instead kicking players from the network!");
+ plugin.getLogger().warning("The fallback server set in the SpigotServers.yml could not be found! Instead kicking players from that server off the network!");
+ else if (fallback.equals(server))
+ plugin.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!");
server.getPlayers().forEach(p -> {
if (!p.hasPermission("maintenance.bypass") && !settings.getWhitelistedPlayers().containsKey(p.getUniqueId())) {
//TODO messages, yikes
@@ -188,4 +191,8 @@ public static IMaintenance getAPI() {
public ProxyServer getProxy() {
return plugin.getProxy();
}
+
+ public Logger getLogger() {
+ return plugin.getLogger();
+ }
}
\ No newline at end of file
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
index bbbce44f..55edd438 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/SettingsBungee.java
@@ -13,10 +13,7 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.sql.SQLException;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.UUID;
+import java.util.*;
public final class SettingsBungee extends Settings {
private final String updateQuery;
@@ -285,7 +282,7 @@ public Set getMaintenanceServers() {
}
public void saveServersToConfig() {
- spigotServers.set("maintenance-on", maintenanceServers);
+ spigotServers.set("maintenance-on", new ArrayList<>(maintenanceServers));
saveSpigotServers();
}
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
index 1c8b142e..0a3e1af7 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
@@ -6,7 +6,6 @@
import eu.kennytv.maintenance.core.command.MaintenanceCommand;
import eu.kennytv.maintenance.core.runnable.MaintenanceRunnableBase;
import eu.kennytv.maintenance.core.util.SenderInfo;
-import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
@@ -25,7 +24,7 @@ public MaintenanceBungeeCommand(final MaintenanceBungeePlugin plugin, final Sett
@Override
protected void addPlayerToWhitelist(final SenderInfo sender, final String name) {
- final ProxiedPlayer selected = ProxyServer.getInstance().getPlayer(name);
+ final ProxiedPlayer selected = plugin.getProxy().getPlayer(name);
if (selected == null) {
sender.sendMessage(settings.getMessage("playerNotOnline"));
return;
@@ -39,7 +38,7 @@ protected void addPlayerToWhitelist(final SenderInfo sender, final String name)
@Override
protected void removePlayerFromWhitelist(final SenderInfo sender, final String name) {
- final ProxiedPlayer selected = ProxyServer.getInstance().getPlayer(name);
+ final ProxiedPlayer selected = plugin.getProxy().getPlayer(name);
if (selected == null) {
if (settings.removeWhitelistedPlayer(name))
sender.sendMessage(settings.getMessage("whitelistRemoved").replace("%PLAYER%", name));
@@ -72,7 +71,7 @@ protected void checkForUpdate(final SenderInfo sender) {
@Override
protected void handleToggleServerCommand(final SenderInfo sender, final String args[]) {
- final ServerInfo server = ProxyServer.getInstance().getServerInfo(args[1]);
+ final ServerInfo server = plugin.getProxy().getServerInfo(args[1]);
if (server == null) {
sender.sendMessage(settings.getMessage("serverNotFound"));
return;
@@ -86,7 +85,7 @@ protected void handleToggleServerCommand(final SenderInfo sender, final String a
if (!plugin.setMaintenanceToServer(server, maintenance))
sender.sendMessage(settings.getMessage(maintenance ? "singleServerAlreadyEnabled" : "singleServerAlreadyDisabled"));
- else if (!ProxyServer.getInstance().getPlayer(sender.getUuid()).getServer().getInfo().equals(server))
+ else if (!plugin.getProxy().getPlayer(sender.getUuid()).getServer().getInfo().equals(server))
sender.sendMessage(settings.getMessage(maintenance ? "singleMaintenanceActivated" : "singleMaintenanceDectivated"));
}
@@ -118,7 +117,7 @@ protected void handleTimerServerCommands(final SenderInfo sender, final String a
} else if (args[0].equalsIgnoreCase("timer")) {
if (args[1].equalsIgnoreCase("abort") || args[1].equalsIgnoreCase("stop") || args[1].equalsIgnoreCase("cancel")) {
if (checkPermission(sender, "servertimer")) return;
- final ServerInfo server = ProxyServer.getInstance().getServerInfo(args[2]);
+ final ServerInfo server = plugin.getProxy().getServerInfo(args[2]);
if (server == null) {
sender.sendMessage(settings.getMessage("serverNotFound"));
return;
@@ -146,7 +145,7 @@ protected void showMaintenanceStatus(final SenderInfo sender) {
}
private ServerInfo checkSingleTimerArgs(final SenderInfo sender, final String[] args) {
- final ServerInfo server = ProxyServer.getInstance().getServerInfo(args[1]);
+ final ServerInfo server = plugin.getProxy().getServerInfo(args[1]);
if (server == null) {
sender.sendMessage(settings.getMessage("serverNotFound"));
return null;
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java
index 76544a89..50f8c5c0 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java
@@ -1,5 +1,6 @@
package eu.kennytv.maintenance.bungee.listener;
+import eu.kennytv.maintenance.bungee.MaintenanceBungeePlugin;
import eu.kennytv.maintenance.bungee.SettingsBungee;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
@@ -9,9 +10,11 @@
import net.md_5.bungee.event.EventPriority;
public final class ServerConnectListener implements Listener {
+ private final MaintenanceBungeePlugin plugin;
private final SettingsBungee settings;
- public ServerConnectListener(final SettingsBungee settings) {
+ public ServerConnectListener(final MaintenanceBungeePlugin plugin, final SettingsBungee settings) {
+ this.plugin = plugin;
this.settings = settings;
}
@@ -19,14 +22,29 @@ public ServerConnectListener(final SettingsBungee settings) {
public void serverConnect(final ServerConnectEvent event) {
final ProxiedPlayer p = event.getPlayer();
final ServerInfo target = event.getTarget();
- if (settings.getMaintenanceServers().contains(target.getName())) {
- if (!p.hasPermission("maintenance.bypass") && !settings.getWhitelistedPlayers().containsKey(p.getUniqueId())) {
- event.setCancelled(true);
- p.sendMessage(settings.getMessage("singleMaintenanceKick"));
- if (settings.isJoinNotifications())
- target.getPlayers().stream().filter(player -> player.hasPermission("maintenance.joinnotification"))
- .forEach(player -> player.sendMessage(settings.getMessage("joinNotification").replace("%PLAYER%", p.getName())));
- }
+ if (!settings.getMaintenanceServers().contains(target.getName())) return;
+ if (p.hasPermission("maintenance.bypass") || settings.getWhitelistedPlayers().containsKey(p.getUniqueId()))
+ return;
+
+ event.setCancelled(true);
+ if (settings.isJoinNotifications()) {
+ target.getPlayers().stream().filter(player -> player.hasPermission("maintenance.joinnotification"))
+ .forEach(player -> player.sendMessage(settings.getMessage("joinNotification").replace("%PLAYER%", p.getName())));
+ }
+ // Normal serverconnect
+ if (event.getReason() != ServerConnectEvent.Reason.JOIN_PROXY && event.getReason() != ServerConnectEvent.Reason.KICK_REDIRECT) {
+ p.sendMessage(settings.getMessage("singleMaintenanceKick"));
+ return;
}
+
+ // If it's the initial proxy join or a kick from another server, go back to fallback server
+ final ServerInfo fallback = plugin.getProxy().getServerInfo(settings.getFallbackServer());
+ //TODO message
+ if (fallback == null || !fallback.canAccess(p) || plugin.isMaintenance(fallback)) {
+ p.disconnect(settings.getKickMessage().replace("%NEWLINE%", "\n"));
+ plugin.getLogger().warning("Could not send player to the fallback server set in the SpigotServers.yml! Instead kicking player off the network!");
+ } else
+ p.connect(fallback);
+
}
}
diff --git a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/SettingsSpigot.java b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/SettingsSpigot.java
index d03b6d3d..70a85c0c 100644
--- a/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/SettingsSpigot.java
+++ b/Maintenance-Spigot/src/main/java/eu/kennytv/maintenance/spigot/SettingsSpigot.java
@@ -78,7 +78,6 @@ private void createAndLoadLanguageFile() {
@Override
public boolean updateExtraConfig() {
// Remove MySQL part from default config
- //TODO with single config
/*if (configContains("mysql")) {
setToConfig("mysql", null);
return true;
From 5d5de3984576ce2e7cad916ad93f773c59a37020 Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Sat, 10 Nov 2018 17:38:41 +0100
Subject: [PATCH 27/33] Make the help message a little fancier
---
.../maintenance/core/command/CommandInfo.java | 21 ++++
.../core/command/MaintenanceCommand.java | 103 ++++++++++++------
.../src/main/resources/language-de.yml | 1 +
.../src/main/resources/language-en.yml | 1 +
4 files changed, 90 insertions(+), 36 deletions(-)
create mode 100644 Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/CommandInfo.java
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/CommandInfo.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/CommandInfo.java
new file mode 100644
index 00000000..25d42364
--- /dev/null
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/CommandInfo.java
@@ -0,0 +1,21 @@
+package eu.kennytv.maintenance.core.command;
+
+import eu.kennytv.maintenance.core.util.SenderInfo;
+
+final class CommandInfo {
+ private final String[] messages;
+ private final String permission;
+
+ CommandInfo(final String permission, final String... messages) {
+ this.messages = messages;
+ this.permission = permission;
+ }
+
+ public boolean hasPermission(final SenderInfo sender) {
+ return sender.hasPermission("maintenance." + permission);
+ }
+
+ public String[] getMessages() {
+ return messages;
+ }
+}
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
index f7c6c2cc..1e478056 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
@@ -5,19 +5,43 @@
import eu.kennytv.maintenance.core.util.SenderInfo;
import eu.kennytv.maintenance.core.util.ServerType;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.UUID;
+import java.util.*;
public abstract class MaintenanceCommand {
protected final MaintenanceModePlugin plugin;
protected final Settings settings;
+ private final List commandInfos;
private final String name;
protected MaintenanceCommand(final MaintenanceModePlugin plugin, final Settings settings, final String name) {
this.plugin = plugin;
this.settings = settings;
this.name = name;
+ this.commandInfos = new ArrayList<>();
+ addCommandInfo("reload", "§6/maintenance reload §7(Reloads the config file, whitelist file and the server-icon)");
+ addCommandInfo("toggle", "§6/maintenance on §7(Enables maintenance mode)", "§6/maintenance off §7(Disables maintenance mode)");
+ if (plugin.getServerType() == ServerType.BUNGEE) {
+ addCommandInfo("toggleserver", "§6/maintenance on §7(Enables maintenance mode on a specific proxied server)",
+ "§6/maintenance off §7(Disables maintenance mode on a specific proxied server)");
+ }
+ addCommandInfo("timer", "§6/maintenance starttimer §7(After the given time in minutes, maintenance mode will be enabled)",
+ "§6/maintenance endtimer §7(After the given time in minutes, maintenance mode will be disabled)",
+ "§6/maintenance timer abort §7(If running, the current timer will be aborted)");
+ if (plugin.getServerType() == ServerType.BUNGEE) {
+ addCommandInfo("servertimer", "§6/maintenance starttimer §7(After the given time in minutes, maintenance mode will be enabled on the given server)",
+ "§6/maintenance endtimer §7(After the given time in minutes, maintenance mode will be disabled on the given server)",
+ "§6/maintenance timer abort §7(If running, the timer running for that server will be aborted)");
+ }
+ addCommandInfo("whitelist.list", "§6/maintenance whitelist §7(Shows all whitelisted players for the maintenance mode)");
+ addCommandInfo("whitelist.add", "§6/maintenance add §7(Adds the player to the maintenance whitelist, so they can join the server even though maintenance is enabled)");
+ addCommandInfo("whitelist.remove", "§6/maintenance remove §7(Removes the player from the maintenance whitelist)");
+ addCommandInfo("setmotd", "§6/maintenance setmotd <1/2> §7(Sets a motd for maintenance mode)", "§6/maintenance removemotd §7(Removes a maintenance motd)");
+ addCommandInfo("motd", "§6/maintenance motd §7(Lists the currently set maintenance motds)");
+ addCommandInfo("update", "§6/maintenance update §7(Remotely downloads the newest version of the plugin onto your server)");
+ }
+
+ private void addCommandInfo(final String permission, final String... messages) {
+ commandInfos.add(new CommandInfo(permission, messages));
}
public void execute(final SenderInfo sender, final String[] args) {
@@ -76,7 +100,13 @@ public void execute(final SenderInfo sender, final String[] args) {
} else
sendUsage(sender);
} else if (args.length == 2) {
- if ((args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("off")) && plugin.getServerType() == ServerType.BUNGEE) {
+ if (args[0].equalsIgnoreCase("help")) {
+ if (!isNumeric(args[1])) {
+ sender.sendMessage(settings.getMessage("helpUsage"));
+ return;
+ }
+ sendUsage(sender, Integer.parseInt(args[1]));
+ } else if ((args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("off")) && plugin.getServerType() == ServerType.BUNGEE) {
if (checkPermission(sender, "toggleserver")) return;
handleToggleServerCommand(sender, args);
} else if (args[0].equalsIgnoreCase("endtimer")) {
@@ -190,44 +220,45 @@ public void execute(final SenderInfo sender, final String[] args) {
}
protected void sendUsage(final SenderInfo sender) {
- //TODO split, switch toggle permission check, timer usage
- sender.sendMessage("");
- sender.sendMessage("§8========[ §e" + name + " §8| §eVersion: §e" + plugin.getVersion() + " §8]========");
- if (sender.hasPermission("maintenance.reload"))
- sender.sendMessage("§6/maintenance reload §7(Reloads the config file, whitelist file and the server-icon)");
- if (sender.hasPermission("maintenance.toggle")) {
- if (plugin.getServerType() == ServerType.BUNGEE && sender.hasPermission("maintenance.toggleserver")) {
- sender.sendMessage("§6/maintenance on [server] §7(Enables maintenance mode");
- sender.sendMessage("§6/maintenance off [server] §7(Disables maintenance mode)");
- } else {
- sender.sendMessage("§6/maintenance on §7(Enables maintenance mode");
- sender.sendMessage("§6/maintenance off §7(Disables maintenance mode)");
+ sendUsage(sender, 1);
+ }
+
+ private static final int COMMANDS_PER_PAGE = 8;
+
+ protected void sendUsage(final SenderInfo sender, final int page) {
+ final List commands = new ArrayList<>();
+ commandInfos.stream().filter(cmd -> cmd.hasPermission(sender)).forEach(cmd -> {
+ for (String message : cmd.getMessages()) {
+ commands.add(message);
}
+ });
+ if ((page - 1) * COMMANDS_PER_PAGE > commands.size()) {
+ sender.sendMessage(plugin.getPrefix() + "§cThere is no page with that number!");
+ return;
}
- if (sender.hasPermission("maintenance.timer")) {
- sender.sendMessage("§6/maintenance starttimer §7(After the given time in minutes, maintenance mode will be enabled)");
- sender.sendMessage("§6/maintenance endtimer §7(Enables maintenance mode. After the given time in minutes, maintenance mode will be disabled)");
- sender.sendMessage("§6/maintenance timer abort §7(If running, the current timer will be aborted)");
- }
- if (sender.hasPermission("maintenance.whitelist.list"))
- sender.sendMessage("§6/maintenance whitelist §7(Shows all whitelisted players for the maintenance mode)");
- if (sender.hasPermission("maintenance.whitelist.add"))
- sender.sendMessage("§6/maintenance add §7(Adds the player to the maintenance whitelist, so they can join the server even though maintenance is enabled)");
- if (sender.hasPermission("maintenance.whitelist.remove"))
- sender.sendMessage("§6/maintenance remove §7(Removes the player from the maintenance whitelist)");
- if (sender.hasPermission("maintenance.setmotd")) {
- sender.sendMessage("§6/maintenance setmotd <1/2> §7(Sets a motd for maintenance mode)");
- sender.sendMessage("§6/maintenance removemotd §7(Removes a maintenance motd)");
- }
- if (sender.hasPermission("maintenance.motd"))
- sender.sendMessage("§6/maintenance motd §7(Lists the currently set maintenance motds)");
- if (sender.hasPermission("maintenance.update"))
- sender.sendMessage("§6/maintenance update §7(Remotely downloads the newest version of the plugin onto your server)");
- sender.sendMessage("§8× §7Created by §bKennyTV");
+
+ final List 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);
+
+ sender.sendMessage("");
sender.sendMessage("§8========[ §e" + name + " §8| §eVersion: §e" + plugin.getVersion() + " §8]========");
+ filteredCommands.forEach(sender::sendMessage);
+ if (page * 10 < commands.size())
+ sender.sendMessage("§7Use §b/maintenance help " + (page + 1) + " §7to get to the next help window.");
+ else
+ sender.sendMessage("§8× §7Created by §bKennyTV");
+ sender.sendMessage("§8========[ §e" + name + " §8| §e" + page + "/" + ((commands.size() + getDivide(commands.size())) / COMMANDS_PER_PAGE) + " §8]========");
sender.sendMessage("");
}
+ private int getDivide(final int size) {
+ final int commandSize = size % COMMANDS_PER_PAGE;
+ return commandSize > 0 ? COMMANDS_PER_PAGE - commandSize : 0;
+ }
+
protected boolean checkPermission(final SenderInfo sender, final String permission) {
if (!sender.hasPermission("maintenance." + permission)) {
sender.sendMessage(settings.getMessage("noPermission"));
diff --git a/Maintenance-Core/src/main/resources/language-de.yml b/Maintenance-Core/src/main/resources/language-de.yml
index 7557d0b4..12684f14 100644
--- a/Maintenance-Core/src/main/resources/language-de.yml
+++ b/Maintenance-Core/src/main/resources/language-de.yml
@@ -6,6 +6,7 @@ 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!"
+helpUsage: "&8[&eMaintenance&8] &c/maintenance help "
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."
endtimerUsage: "&8[&eMaintenance&8] &c/maintenance endtimer "
diff --git a/Maintenance-Core/src/main/resources/language-en.yml b/Maintenance-Core/src/main/resources/language-en.yml
index 60f5cb07..f46b319b 100644
--- a/Maintenance-Core/src/main/resources/language-en.yml
+++ b/Maintenance-Core/src/main/resources/language-en.yml
@@ -6,6 +6,7 @@ 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!"
+helpUsage: "&8[&eMaintenance&8] &c/maintenance help "
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."
endtimerUsage: "&8[&eMaintenance&8] &c/maintenance endtimer "
From b3de59bfba68b0bcdd8190910bcde1008eee8330 Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Sat, 10 Nov 2018 22:08:29 +0100
Subject: [PATCH 28/33] API change
---
.../maintenance/api/bungee/MaintenanceBungeeAPI.java | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/Maintenance-API/src/main/java/eu/kennytv/maintenance/api/bungee/MaintenanceBungeeAPI.java b/Maintenance-API/src/main/java/eu/kennytv/maintenance/api/bungee/MaintenanceBungeeAPI.java
index 2270d7a1..0c692b7e 100644
--- a/Maintenance-API/src/main/java/eu/kennytv/maintenance/api/bungee/MaintenanceBungeeAPI.java
+++ b/Maintenance-API/src/main/java/eu/kennytv/maintenance/api/bungee/MaintenanceBungeeAPI.java
@@ -1,12 +1,11 @@
package eu.kennytv.maintenance.api.bungee;
-import eu.kennytv.maintenance.api.IMaintenance;
import eu.kennytv.maintenance.api.IMaintenanceBase;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin;
/**
- * Utility class to get the {@link IMaintenance} instance for the BungeeCord version of the plugin.
+ * Utility class to get the {@link IMaintenanceBungee} instance for the BungeeCord version of the plugin.
*
* Only access this class if you're running the plugin on a BungeeCord server!
*
@@ -19,12 +18,12 @@ public final class MaintenanceBungeeAPI {
/**
* Returns API instance of IMaintenance.
*
- * @return {@link IMaintenance} instance
+ * @return {@link IMaintenanceBungee} instance
*/
- public static IMaintenance getAPI() {
+ public static IMaintenanceBungee getAPI() {
final Plugin maintenance = ProxyServer.getInstance().getPluginManager().getPlugin("MaintenanceBungee");
if (maintenance == null)
ProxyServer.getInstance().getLogger().warning("Could not get instance of MaintenanceBungee!");
- return ((IMaintenanceBase) maintenance).getApi();
+ return (IMaintenanceBungee) ((IMaintenanceBase) maintenance).getApi();
}
}
From 240a7ab242d284e80e725d04dec4afbf83fbda86 Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Fri, 16 Nov 2018 22:08:35 +0100
Subject: [PATCH 29/33] Message changes
---
.../kennytv/maintenance/bungee/MaintenanceBungeePlugin.java | 3 +--
.../maintenance/bungee/listener/ServerConnectListener.java | 5 ++---
Maintenance-Core/src/main/resources/language-de.yml | 3 +++
Maintenance-Core/src/main/resources/language-en.yml | 3 ++-
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
index 714b26f5..33d20c39 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/MaintenanceBungeePlugin.java
@@ -108,12 +108,11 @@ else if (fallback.equals(server))
plugin.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!");
server.getPlayers().forEach(p -> {
if (!p.hasPermission("maintenance.bypass") && !settings.getWhitelistedPlayers().containsKey(p.getUniqueId())) {
- //TODO messages, yikes
if (fallback != null && fallback.canAccess(p)) {
p.sendMessage(settings.getMessage("singleMaintenanceActivated").replace("%SERVER%", server.getName()));
p.connect(fallback);
} else
- p.disconnect(settings.getKickMessage().replace("%NEWLINE%", "\n"));
+ p.disconnect(settings.getMessage("singleMaintenanceKickComplete").replace("%NEWLINE%", "\n").replace("%SERVER%", server.getName()));
} else {
p.sendMessage(settings.getMessage("singleMaintenanceActivated").replace("%SERVER%", server.getName()));
}
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java
index 50f8c5c0..3e5a9993 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java
@@ -32,6 +32,7 @@ public void serverConnect(final ServerConnectEvent event) {
.forEach(player -> player.sendMessage(settings.getMessage("joinNotification").replace("%PLAYER%", p.getName())));
}
// Normal serverconnect
+ //TODO check other reasons
if (event.getReason() != ServerConnectEvent.Reason.JOIN_PROXY && event.getReason() != ServerConnectEvent.Reason.KICK_REDIRECT) {
p.sendMessage(settings.getMessage("singleMaintenanceKick"));
return;
@@ -39,12 +40,10 @@ public void serverConnect(final ServerConnectEvent event) {
// If it's the initial proxy join or a kick from another server, go back to fallback server
final ServerInfo fallback = plugin.getProxy().getServerInfo(settings.getFallbackServer());
- //TODO message
if (fallback == null || !fallback.canAccess(p) || plugin.isMaintenance(fallback)) {
- p.disconnect(settings.getKickMessage().replace("%NEWLINE%", "\n"));
+ p.disconnect(settings.getMessage("singleMaintenanceKickComplete").replace("%NEWLINE%", "\n").replace("%SERVER%", target.getName()));
plugin.getLogger().warning("Could not send player to the fallback server set in the SpigotServers.yml! Instead kicking player off the network!");
} else
p.connect(fallback);
-
}
}
diff --git a/Maintenance-Core/src/main/resources/language-de.yml b/Maintenance-Core/src/main/resources/language-de.yml
index 12684f14..e0d81fa2 100644
--- a/Maintenance-Core/src/main/resources/language-de.yml
+++ b/Maintenance-Core/src/main/resources/language-de.yml
@@ -51,8 +51,11 @@ hours: "Stunden"
# Nachrichten für den Bungee Teil des Plugins, einfach ignorieren, falls das Plugin auf Spigot verwendet wird
singleEndtimerBroadcast: "&8[&eMaintenance&8] &7Der Wartungsmodus auf Server %SERVER% wird deaktiviert in: &6%TIME%&7."
+singleEndtimerUsage: "&8[&eMaintenance&8] &c/maintenance endtimer "
singleStarttimerBroadcast: "&8[&eMaintenance&8] &7Der Wartungsmodus auf Server %SERVER% wird aktiviert in: &6%TIME%&7."
+singleStarttimerUsage: "&8[&eMaintenance&8] &c/maintenance starttimer "
singleMaintenanceKick: "&8[&eMaintenance&8] &cDieser 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!"
diff --git a/Maintenance-Core/src/main/resources/language-en.yml b/Maintenance-Core/src/main/resources/language-en.yml
index f46b319b..e14747f4 100644
--- a/Maintenance-Core/src/main/resources/language-en.yml
+++ b/Maintenance-Core/src/main/resources/language-en.yml
@@ -55,9 +55,10 @@ singleEndtimerUsage: "&8[&eMaintenance&8] &c/maintenance endtimer "
singleMaintenanceKick: "&8[&eMaintenance&8] &cThis 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."
+singleServerMaintenanceListEmpty: "&8[&eMaintenance&8] &7There are no proxied servers that are under maintenance."
\ No newline at end of file
From 7ce61834c2445fe692f725966802ca2a08ee4b0e Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Fri, 16 Nov 2018 22:23:58 +0100
Subject: [PATCH 30/33] Check for other kick reasons
---
.../maintenance/bungee/listener/ServerConnectListener.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java
index 3e5a9993..8702dc50 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java
@@ -32,8 +32,8 @@ public void serverConnect(final ServerConnectEvent event) {
.forEach(player -> player.sendMessage(settings.getMessage("joinNotification").replace("%PLAYER%", p.getName())));
}
// Normal serverconnect
- //TODO check other reasons
- if (event.getReason() != ServerConnectEvent.Reason.JOIN_PROXY && event.getReason() != ServerConnectEvent.Reason.KICK_REDIRECT) {
+ if (event.getReason() != ServerConnectEvent.Reason.JOIN_PROXY && event.getReason() != ServerConnectEvent.Reason.KICK_REDIRECT
+ && event.getReason() != ServerConnectEvent.Reason.LOBBY_FALLBACK && event.getReason() != ServerConnectEvent.Reason.SERVER_DOWN_REDIRECT) {
p.sendMessage(settings.getMessage("singleMaintenanceKick"));
return;
}
From dfef9190cada7514ba082dce14feee66e7b53d9d Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Sat, 17 Nov 2018 11:41:51 +0100
Subject: [PATCH 31/33] Some final fixes and changes
---
.../command/MaintenanceBungeeCommand.java | 10 +++--
.../listener/ServerConnectListener.java | 8 +++-
.../core/command/MaintenanceCommand.java | 40 ++++++++++---------
.../src/main/resources/language-de.yml | 2 +-
.../src/main/resources/language-en.yml | 2 +-
5 files changed, 35 insertions(+), 27 deletions(-)
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
index 0a3e1af7..7c2b8908 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/command/MaintenanceBungeeCommand.java
@@ -86,7 +86,7 @@ protected void handleToggleServerCommand(final SenderInfo sender, final String a
if (!plugin.setMaintenanceToServer(server, maintenance))
sender.sendMessage(settings.getMessage(maintenance ? "singleServerAlreadyEnabled" : "singleServerAlreadyDisabled"));
else if (!plugin.getProxy().getPlayer(sender.getUuid()).getServer().getInfo().equals(server))
- sender.sendMessage(settings.getMessage(maintenance ? "singleMaintenanceActivated" : "singleMaintenanceDectivated"));
+ sender.sendMessage(settings.getMessage(maintenance ? "singleMaintenanceActivated" : "singleMaintenanceDeactivated").replace("%SERVER%", server.getName()));
}
@Override
@@ -97,8 +97,10 @@ protected void handleTimerServerCommands(final SenderInfo sender, final String a
final ServerInfo server = checkSingleTimerArgs(sender, args);
if (server == null) return;
- if (!plugin.isMaintenance(server))
- plugin.setMaintenanceToServer(server, true);
+ if (!plugin.isMaintenance(server)) {
+ sender.sendMessage(settings.getMessage("singleServerAlreadyDisabled").replace("%SERVER%", server.getName()));
+ return;
+ }
final MaintenanceRunnableBase runnable = plugin.startSingleMaintenanceRunnable(server, Integer.parseInt(args[2]), false);
sender.sendMessage(settings.getMessage("endtimerStarted").replace("%TIME%", runnable.getTime()));
} else if (args[0].equalsIgnoreCase("starttimer")) {
@@ -108,7 +110,7 @@ protected void handleTimerServerCommands(final SenderInfo sender, final String a
final ServerInfo server = checkSingleTimerArgs(sender, args);
if (server == null) return;
if (plugin.isMaintenance(server)) {
- sender.sendMessage(settings.getMessage("alreadyEnabled"));
+ sender.sendMessage(settings.getMessage("singleServerAlreadyEnabled").replace("%SERVER%", server.getName()));
return;
}
diff --git a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java
index 8702dc50..e88d46cc 100644
--- a/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java
+++ b/Maintenance-Bungee/src/main/java/eu/kennytv/maintenance/bungee/listener/ServerConnectListener.java
@@ -12,6 +12,7 @@
public final class ServerConnectListener implements Listener {
private final MaintenanceBungeePlugin plugin;
private final SettingsBungee settings;
+ private boolean warned;
public ServerConnectListener(final MaintenanceBungeePlugin plugin, final SettingsBungee settings) {
this.plugin = plugin;
@@ -34,7 +35,7 @@ public void serverConnect(final ServerConnectEvent event) {
// Normal serverconnect
if (event.getReason() != ServerConnectEvent.Reason.JOIN_PROXY && event.getReason() != ServerConnectEvent.Reason.KICK_REDIRECT
&& event.getReason() != ServerConnectEvent.Reason.LOBBY_FALLBACK && event.getReason() != ServerConnectEvent.Reason.SERVER_DOWN_REDIRECT) {
- p.sendMessage(settings.getMessage("singleMaintenanceKick"));
+ p.sendMessage(settings.getMessage("singleMaintenanceKick").replace("%SERVER%", target.getName()));
return;
}
@@ -42,7 +43,10 @@ public void serverConnect(final ServerConnectEvent event) {
final ServerInfo fallback = plugin.getProxy().getServerInfo(settings.getFallbackServer());
if (fallback == null || !fallback.canAccess(p) || plugin.isMaintenance(fallback)) {
p.disconnect(settings.getMessage("singleMaintenanceKickComplete").replace("%NEWLINE%", "\n").replace("%SERVER%", target.getName()));
- plugin.getLogger().warning("Could not send player to the fallback server set in the SpigotServers.yml! Instead kicking player off the network!");
+ if (!warned) {
+ plugin.getLogger().warning("Could not send player to the fallback server set in the SpigotServers.yml! Instead kicking player off the network!");
+ warned = true;
+ }
} else
p.connect(fallback);
}
diff --git a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
index 1e478056..f9a17e37 100644
--- a/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
+++ b/Maintenance-Core/src/main/java/eu/kennytv/maintenance/core/command/MaintenanceCommand.java
@@ -112,8 +112,10 @@ public void execute(final SenderInfo sender, final String[] args) {
} else if (args[0].equalsIgnoreCase("endtimer")) {
if (checkPermission(sender, "timer")) return;
if (checkTimerArgs(sender, args[1], "endtimerUsage")) return;
- if (!plugin.isMaintenance())
- plugin.setMaintenance(true);
+ if (!plugin.isMaintenance()) {
+ sender.sendMessage(settings.getMessage("alreadyDisabled"));
+ return;
+ }
plugin.startMaintenanceRunnable(Integer.parseInt(args[1]), false);
sender.sendMessage(settings.getMessage("endtimerStarted").replace("%TIME%", plugin.getRunnable().getTime()));
} else if (args[0].equalsIgnoreCase("starttimer")) {
@@ -259,23 +261,6 @@ private int getDivide(final int size) {
return commandSize > 0 ? COMMANDS_PER_PAGE - commandSize : 0;
}
- protected boolean checkPermission(final SenderInfo sender, final String permission) {
- if (!sender.hasPermission("maintenance." + permission)) {
- sender.sendMessage(settings.getMessage("noPermission"));
- return true;
- }
- return false;
- }
-
- protected boolean isNumeric(final String string) {
- try {
- Integer.parseInt(string);
- } catch (final NumberFormatException nfe) {
- return false;
- }
- return true;
- }
-
protected boolean checkTimerArgs(final SenderInfo sender, final String time, final String usageKey) {
if (!isNumeric(time)) {
sender.sendMessage(settings.getMessage(usageKey));
@@ -298,6 +283,23 @@ protected boolean checkTimerArgs(final SenderInfo sender, final String time, fin
return false;
}
+ protected boolean checkPermission(final SenderInfo sender, final String permission) {
+ if (!sender.hasPermission("maintenance." + permission)) {
+ sender.sendMessage(settings.getMessage("noPermission"));
+ return true;
+ }
+ return false;
+ }
+
+ protected boolean isNumeric(final String string) {
+ try {
+ Integer.parseInt(string);
+ } catch (final NumberFormatException nfe) {
+ return false;
+ }
+ return true;
+ }
+
protected abstract void addPlayerToWhitelist(SenderInfo sender, String name);
protected abstract void removePlayerFromWhitelist(SenderInfo sender, String name);
diff --git a/Maintenance-Core/src/main/resources/language-de.yml b/Maintenance-Core/src/main/resources/language-de.yml
index e0d81fa2..2552fbee 100644
--- a/Maintenance-Core/src/main/resources/language-de.yml
+++ b/Maintenance-Core/src/main/resources/language-de.yml
@@ -54,7 +54,7 @@ singleEndtimerBroadcast: "&8[&eMaintenance&8] &7Der Wartungsmodus auf Server %SE
singleEndtimerUsage: "&8[&eMaintenance&8] &c/maintenance endtimer "
singleStarttimerBroadcast: "&8[&eMaintenance&8] &7Der Wartungsmodus auf Server %SERVER% wird aktiviert in: &6%TIME%&7."
singleStarttimerUsage: "&8[&eMaintenance&8] &c/maintenance starttimer "
-singleMaintenanceKick: "&8[&eMaintenance&8] &cDieser Server befindet sich momentan im Wartungsmodus! Probier es später nochmal!"
+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."
diff --git a/Maintenance-Core/src/main/resources/language-en.yml b/Maintenance-Core/src/main/resources/language-en.yml
index e14747f4..5465d58e 100644
--- a/Maintenance-Core/src/main/resources/language-en.yml
+++ b/Maintenance-Core/src/main/resources/language-en.yml
@@ -54,7 +54,7 @@ singleEndtimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode on server %SERV
singleEndtimerUsage: "&8[&eMaintenance&8] &c/maintenance endtimer "
singleStarttimerBroadcast: "&8[&eMaintenance&8] &7Maintenance mode on server %SERVER% will be enabled in &6%TIME%&7."
singleStarttimerUsage: "&8[&eMaintenance&8] &c/maintenance starttimer "
-singleMaintenanceKick: "&8[&eMaintenance&8] &cThis server is currently under maintenance! Try again later!"
+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."
From f8eaed445aac0b124c1eede2f178ec00c4631f33 Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Sat, 17 Nov 2018 11:43:43 +0100
Subject: [PATCH 32/33] Version increase to 2.5
---
Maintenance-API/pom.xml | 2 +-
Maintenance-Bungee/pom.xml | 2 +-
Maintenance-Core/pom.xml | 2 +-
Maintenance-Parent/pom.xml | 2 +-
Maintenance-Spigot/pom.xml | 2 +-
pom.xml | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/Maintenance-API/pom.xml b/Maintenance-API/pom.xml
index 85e4ef71..03c9c714 100644
--- a/Maintenance-API/pom.xml
+++ b/Maintenance-API/pom.xml
@@ -6,7 +6,7 @@
maintenance-base
eu.kennytv
- 2.5-SNAPSHOT
+ 2.5
maintenance-api
diff --git a/Maintenance-Bungee/pom.xml b/Maintenance-Bungee/pom.xml
index cce073f7..2608821d 100644
--- a/Maintenance-Bungee/pom.xml
+++ b/Maintenance-Bungee/pom.xml
@@ -6,7 +6,7 @@
maintenance-base
eu.kennytv
- 2.5-SNAPSHOT
+ 2.5
maintenance-bungee
diff --git a/Maintenance-Core/pom.xml b/Maintenance-Core/pom.xml
index 07c68214..2c16a278 100644
--- a/Maintenance-Core/pom.xml
+++ b/Maintenance-Core/pom.xml
@@ -6,7 +6,7 @@
maintenance-base
eu.kennytv
- 2.5-SNAPSHOT
+ 2.5
maintenance-core
diff --git a/Maintenance-Parent/pom.xml b/Maintenance-Parent/pom.xml
index 39e65c9f..90c20405 100644
--- a/Maintenance-Parent/pom.xml
+++ b/Maintenance-Parent/pom.xml
@@ -6,7 +6,7 @@
maintenance-base
eu.kennytv
- 2.5-SNAPSHOT
+ 2.5
maintenance-parent
diff --git a/Maintenance-Spigot/pom.xml b/Maintenance-Spigot/pom.xml
index 391fffd6..26b92e01 100644
--- a/Maintenance-Spigot/pom.xml
+++ b/Maintenance-Spigot/pom.xml
@@ -6,7 +6,7 @@
maintenance-base
eu.kennytv
- 2.5-SNAPSHOT
+ 2.5
maintenance-spigot
diff --git a/pom.xml b/pom.xml
index 8ab2ea1d..c43c4b68 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
eu.kennytv
maintenance-base
- 2.5-SNAPSHOT
+ 2.5
Maintenance
pom
From 7384b2e55cf73d1efd9883f9ac8738818d10e121 Mon Sep 17 00:00:00 2001
From: KennyTV <28825609+KennyTV@users.noreply.github.com>
Date: Sat, 17 Nov 2018 11:44:28 +0100
Subject: [PATCH 33/33] 2.5 API
---
Maintenance-API.jar | Bin 4972 -> 5780 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
diff --git a/Maintenance-API.jar b/Maintenance-API.jar
index aa766f22d88d7420db806cb37e3a6a6bd9a063d3..b92bfd0564608b6994267a598a60d7e4573d07a2 100644
GIT binary patch
delta 3336
zcmai02RNH+8x|o}A|a|ZYuAVxvA5VGwon~-{-l%=e<8m<;z3ttbj~B46LlI3~`cbVO^01Bzb@a9Zvv^>3ADp&P{!eX4rL!F_4;}Ld?Fn&;SgH2oU~_phYL(
z=>&{|1==StG!hf)6Y7US(Z*m7`vv=8u~|7UEZdI3QhL7e&O;0hXpefVJ*#xm
zysQ94pkgwtz`|miDPDEIULsUdO5WE%I&`K*6RVd>*^K?cFyUvtR6bEx*;Jng_j`Sg
zKa0>k@a4u!S3>eL?;mFZV(=oZ9i929>ZX2Y+-^#o5`Ihg3T%{mZgeSpWq*RBBOA%X
zL%g5@*
zacb^P0~i?gq<>FFb?6BL?Iet}$Si;_a&)(a8}e*(lI5+=I+&cj!L#hZu6*PD4HLMe
zQXt}OS*iE5+A{?>;>EJh}>fEmH+2>2Gx2?Sx?YlTM#?lfoD;nWG}8lb)egla^EIc=bA*
zGZaw^Pql69F}6bu=Ba6&Ha*dUu950xeqqYOO(0GrkBK2JDh%4>mJ97$5(t`>a<`Ky
z%JIokDrLM|zY@BjFDvF0zxc|=nKIl-erfh$5+!+mpRsi-lS@OQv$a?XKw!)K>lLMj
zcd0}*xju6<3gIJCf?vs6(CGdE-WhD_HpmJ*blm({dQOmYS1arFjccN;eey|pYa$6-l<**@*3;KM=w2J@GCr5
z)~zmhR`7i+z_v@HxFw|Z<fp_g4c<2hy>@zPMmVc^*`LMz52_<9SkE@Qy?2TLpz(BZfs@Pa~6saINo
z>igyks+W)-@3~xB`12c%N1gQOwZVY;5&u%YVP}PJpXSP=_8sqSzoZrW)}U8t7MCmj
zSbKTw%8!f%h2`02jZsfKc#4;<;zw9oOreXTf~#sBp$O1)(`4u2nu@e&r4`v990?IR
zxlQ-aS8WPEiPjPO?6ZLM8@8WT1*|7$rffviMUK3M$w9H*Tr0sd*G~CQ#UR3sT{AX5
zZL-h=`9jKb%AS#dL5}%<3GzM*qY!}J01g4)(-F#~jSsOy+qN3OikPRZ3}GCxgJm9{
zO>7Uq#g!f>@(ZXeKdANN3y!vEkes|7v&6DinmL?-N<^!XV!qCFcWtb1uQ4TJHGIR9
z?tUktx?Xp&Yp|sxaj?kiNmd7xI!H8DGGrQtv<8fPsb9L8*2^U1oQO!C)BlL5LRQ+T
zxXvj)$6uXy0YNerB+kWEeaI55G0!l^KGS)4PFym%SezNyX7pWIDn-wPeblU^N2$N@
z;m|_GD?gJa)rnV}$>(vOPe}@K#*NzG>+jq`J@TEkT&+War@`v&AB4JbDgM~Dk$#J%
z8TOH3-I79P6y+p71IKk&fJ4zhXnsshmb%qMI5%pv%pYm^h?8l{MLg(*zmxBut-ui
zKm`jGGxLY8c0#*=C#osPU;`S~eU$MQ?NI^H^>;aEy{Xz&r;z^XJza6F|{o(;pXz
zfObW^2$3n8@PP7S;p}G$=p8ua{90B{XU^%HwO>jUpUAy_1m;%kyKI=}(~d7q1!uec
z2&k~=djK9kFn3|D#3@P&KUamAja6F&Z8d$N9N__b+!!zq8DtACA4YMw$AW{(v<-!g
z8#dJ)kjXLAeV2`j^LzNv@7UYsyj8#mfD=w`0ps;kahAi~A8nquDzi&nv=i*8
z_0YcOEw+(sGa;9zO~`{CoOiHib1@npJTO2WZ5blhesXsTmC^l%Z{tO**5PVOPjU0M
zeNpiQ4)SG^TVD~B5FY((S&tzj)_xGOd7zs+NH+5RkJGo@eWfA&?MNj%zMJAfH;CHc
z8DmkSi1p~QD=a7RAZcVJ54SjKv4>?6C7l+}07cV(o&VC&HZ2zM(?%?*Ahf^Rg
zTRlhO6OgaU%p@F$=cp(ifOKk@m_|HUVXK1nuIReKxh}UQxFN+E`xIsVknSO#$4G$k
zvm-Q{!;>x?C?0HjtkZt7X_Jc_$kdp2gvR!-GayZ~>(JkMaSk&&hH$t5eW>Q(
z8HX{x*QQmGCqaGk;KfI`NA2K7mTU^9aC@QdZhH@~D=JceH4vrH%$v#8xV*?lYoQ|*2Wf8+$tO>RB#>f~%kcNbaORqO)JI^x5J
zTY_&M#+Pbh>t1<7jMEMT$?+>z#XK+ZdplyvE`Myf-#U2!lcfD7HNcgvvo|c8aKWZY
zaiNA;{<0Hize|Sy-w2o>575GEu6!AW=+&0~J}H|-b~PB*;hZnUCRNu!NBD;rSb`PB
z@vDD{Wb89I1PIf4B=wi+Fp&`~JsFKkf`rtqnI%S@k_oSbbx@j|8jjCeT>yrAW&pkL
znc_x6fyxa+wgE2D(1zr|p^HJleuXeeX4a$vEDX5V9bv51Z26r3N|4KvAGg{_bD7cB
zw4TXOGXZ>U#&b(n6|b?yL@OCD=nL;O%}Kz2)@-L_@zm0kK+yOk0~o{0jh4-}#Mv^{
za+pqvaa!XvG*j!TSa+w^;k8u?Q6Vnf(w}rLwaBZ`nCqUp08TWwArFg-sjALf2(f)S
zGz!am@|qyyDc3*#k}5{}B}Sq^5y+qJ
zkrsJZVDxT7rS)^b4(Kz|Y^l}%ah<=$+kGDD?1`5Oq{Z81%BZ{Evlh}Pr~soOh{hr%
z!obQqw)Phix{6Oq{~R^&3+k=3XM#|cpF_n&Xerp;`DOPIkFe5-<1hg_k@nxex!OYn
zv(t#kou04o>q>UN@q4%GMIZOiX+k|KsNQwYR_Si_pE;p>=9~kQCb)!X#mwUtV3dK7
zY9N9nO>XdSOWnICERBfRGY_@Jps5o7SK)iJ)lD0qNSfz{ickfQ-mN~3Jqs#>Qi)o;
Tc2>+F+H*MdL;Ds3qy731wIL0D
delta 2680
zcmZXW2{@E%8^^~!7-Loj$;cX`W+V}kZL*DqBV>$yX{s?K%)v1vDzd&DYcZ!ykq8kY
z>#=V+*^>AaWh)(Pi*HO_=d1HQ*Y#e%>wVt)xu55H@Bee(ce=)cvKZNlj~@jBgTWw0
zJ3^}1VZI$$-sfTqzXL#nM~BN(Jf>Ve;4$A}xs9M24|gJ5=rxyKU_DkWnQFyrgnDx0
zjpJ$O$f5A)`ilLl-u$WjM28Be{_*N?%7ew;_NC%iZu4xp{^WRH6)OvN^pvJwufh6@
zj~_PIpdgjfzE?1>d30=6Q8qdNAtE3Nb&jxfm?YjZXWBwBG4C$+Rlg3JIvILH_^_G~
zO)$f4FmR=>z@?@}?C__Uh1c6|
z_TMpQhcAEBjmvR76YAgnw^J%ZY@?#90PTtOt0oSYkEzd0l}^qpL#0KBaPCE9iZ(My
zU};LrbP-B5DCnhz#%vAbZ23+QFW1j3SxQXmNt|8bcML2n*JXXF9Uk2tn;mlwq@_1D
zn&40Z8|LuDh&q_@z5J+zM^{aR9<=|7i$Qr~bvGd~xEav-p8cmiY!gbw4jcDa8c`dp
z$l6R{HECMb*W2|cd&UTcCknG`a#c@N_=Hu}gUD7w;Asn&S5zJl$cGoidH*4NBoIgx
z^v^g5u=#egNFFr*^FIC_{$4)D!Tx?eK1O7VeO_lhf`T&a>Bo^qu*kS7^;_h^Jwty~
z>=~2rHZ!xodL<%Jk^
zXWwM!KF)7wh~x_pPX-&udQzmy8S5=cLv3mbq+f(bS%ZIsc|VA2JMoT2pWuNLt7fjF
zu4|PrM@Q^P^97kH1{#s_B1#bb=frW9i!VKC3b8yo7Jthd&6P7&_j#19wDEsV=3nnIbvF_(nl
zzb9ne=yR-!)?Tudd>m-^OLdwl)NwolJ(-w6DtnlPuNXt_4$ro&I4+fbOy2HXqE+de
zOD}z2ZfN(tuUkq#wA|2<-|uAp>afQO&Q<6TxR<3Tg;|5Q9S2(I4yJprqZ7$lULwzIJCni_y5&M2CnQxu;TQF)5Tg37spb;?3M$d3QHRZ|UtvyW;M+nu*F&
z2Z&F=q0(w|%(!_6?W&@Of0Y5jhLD_h*=s0?f#w)AN13O3nN&}!_cnFwnT8(ky&@v=
zS;O|@R}|xzZg0Y|Yc~n)e$BF_NgYw6eboU`SFG1S&-%Iy@rdyQ*`s{j84V^8jj~Nb
z&;pvXsk7C%1-LT+66)x$y(Yd*L~|q
zf8e!;*Oa>a6SpnhDpngee5VZ_!FZPqADFXgw%qj~J}wvh_f
zKIZxk&YQ(!sjDi2zQ%xbFW?QB@yG_s^
z{;c>R#D30q`-5{;i@9_mDa^A_bHwzysca~wdoQ-Rb0O%aFY86f`d*dEkWWpc$m{#qM+ZNQ;5yVtA-=Uh;W#J4JB|(c|z|36$n;NXCF2N>Fg)F#T;s}z2MVec_{M>A&Fn<&cNpo&0Mz$g9YeqA4-WBxuNbB3Jdn{y@p{j
zk`x9vPZ&RMx30~T14^g9%2VS9=Z+9N8ZIsz?Wx^5ar$e(mN2&{*+@#}{K~0H$e&`S
z#OWW(#7V3eJOtDqj@^d6*Qc2UAoUXoA@6S*rqHxI@fuXz#`?Hk{kwf?*(8Us-CF11
zW`%8qS{8dIQ$wFDhlR4|={a`;zg{IPvP_29cPSS`lfuJ_V-{AA*^8@#^EB$1Wh}<7
zA=8tRx`85K!=2OAxt3=!IH~6x=OJ71@QR{9|1>$kW!SfVrWt0))sO&u-#1OcwYg-#
zjk&CV6S