1 parent
97f6cb5d68
commit
1408dee12e
4 files changed
+53
-20
No files matched your search
@@ -10,7 +10,8 @@ This file contains update logs for this project. The top may contain a `Unreleas
|
|||||||
### Fixed
|
### Fixed
|
||||||
* Fixed the `/maintenance dump` command
|
* Fixed the `/maintenance dump` command
|
||||||
* Fixed the original player sample not being cleared in Velocity
|
* Fixed the original player sample not being cleared in Velocity
|
||||||
* Don't log legacy color codes to the console
|
* Velocity: Fixed the console getting broadcasts twice
|
||||||
|
* Velocity: Don't log legacy color codes to the console
|
||||||
---
|
---
|
||||||
## 4.2.1 - May 17th 2024
|
## 4.2.1 - May 17th 2024
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import java.util.Map;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Level;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class Settings implements eu.kennytv.maintenance.api.Settings {
|
public class Settings implements eu.kennytv.maintenance.api.Settings {
|
||||||
@@ -54,7 +55,9 @@ public class Settings implements eu.kennytv.maintenance.api.Settings {
|
|||||||
private List<String> commandsOnMaintenanceEnable;
|
private List<String> commandsOnMaintenanceEnable;
|
||||||
private List<String> commandsOnMaintenanceDisable;
|
private List<String> commandsOnMaintenanceDisable;
|
||||||
private String legacyParsedPlayerCountMessage;
|
private String legacyParsedPlayerCountMessage;
|
||||||
|
private String legacyParsedTimerPlayerCountMessage;
|
||||||
private List<String> legacyParsedPlayerCountHoverLines;
|
private List<String> legacyParsedPlayerCountHoverLines;
|
||||||
|
private List<String> legacyParsedTimerPlayerCountHoverLines;
|
||||||
private String prefixString;
|
private String prefixString;
|
||||||
private String languageName;
|
private String languageName;
|
||||||
private boolean enablePingMessages;
|
private boolean enablePingMessages;
|
||||||
@@ -111,8 +114,7 @@ public class Settings implements eu.kennytv.maintenance.api.Settings {
|
|||||||
try {
|
try {
|
||||||
updateLanguageFile();
|
updateLanguageFile();
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
plugin.getLogger().severe("Couldn't update language file");
|
plugin.getLogger().log(Level.SEVERE, "Couldn't update language file", e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
prefixString = language.getString("prefix");
|
prefixString = language.getString("prefix");
|
||||||
@@ -124,7 +126,7 @@ public class Settings implements eu.kennytv.maintenance.api.Settings {
|
|||||||
try {
|
try {
|
||||||
config.save();
|
config.save();
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
e.printStackTrace();
|
plugin.getLogger().log(Level.SEVERE, "Couldn't save the config file!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +150,7 @@ public class Settings implements eu.kennytv.maintenance.api.Settings {
|
|||||||
try {
|
try {
|
||||||
whitelist.save();
|
whitelist.save();
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
e.printStackTrace();
|
plugin.getLogger().log(Level.SEVERE, "Couldn't save the whitelisted players file!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,6 +180,8 @@ public class Settings implements eu.kennytv.maintenance.api.Settings {
|
|||||||
pingMessages = loadPingMessages("pingmessages");
|
pingMessages = loadPingMessages("pingmessages");
|
||||||
if (config.getBoolean("enable-timerspecific-messages")) {
|
if (config.getBoolean("enable-timerspecific-messages")) {
|
||||||
timerSpecificPingMessages = loadPingMessages("timerspecific-pingmessages");
|
timerSpecificPingMessages = loadPingMessages("timerspecific-pingmessages");
|
||||||
|
} else {
|
||||||
|
timerSpecificPingMessages = null;
|
||||||
}
|
}
|
||||||
maintenance = config.getBoolean("maintenance-enabled");
|
maintenance = config.getBoolean("maintenance-enabled");
|
||||||
commandsOnMaintenanceEnable = config.getStringList("commands-on-maintenance-enable");
|
commandsOnMaintenanceEnable = config.getStringList("commands-on-maintenance-enable");
|
||||||
@@ -191,6 +195,11 @@ public class Settings implements eu.kennytv.maintenance.api.Settings {
|
|||||||
// Player count and player count hover messages are only accepted and rendered as legacy chat
|
// Player count and player count hover messages are only accepted and rendered as legacy chat
|
||||||
if (plugin.getServerType() != ServerType.SPONGE) {
|
if (plugin.getServerType() != ServerType.SPONGE) {
|
||||||
legacyParsedPlayerCountMessage = toLegacy(parse(getConfigMessage("playercountmessage")));
|
legacyParsedPlayerCountMessage = toLegacy(parse(getConfigMessage("playercountmessage")));
|
||||||
|
if (config.getBoolean("enable-timerspecific-playercountmessage")) {
|
||||||
|
legacyParsedTimerPlayerCountMessage = toLegacy(parse(getConfigMessage("timer-playercountmessage")));
|
||||||
|
} else {
|
||||||
|
legacyParsedTimerPlayerCountMessage = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
legacyParsedPlayerCountHoverLines = new ArrayList<>();
|
legacyParsedPlayerCountHoverLines = new ArrayList<>();
|
||||||
@@ -198,6 +207,15 @@ public class Settings implements eu.kennytv.maintenance.api.Settings {
|
|||||||
legacyParsedPlayerCountHoverLines.add(toLegacy(parse(line)));
|
legacyParsedPlayerCountHoverLines.add(toLegacy(parse(line)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.getBoolean("enable-timerspecific-playercounthovermessage")) {
|
||||||
|
legacyParsedTimerPlayerCountHoverLines = new ArrayList<>();
|
||||||
|
for (final String line : config.getString("timer-playercounthovermessage").split("<br>")) {
|
||||||
|
legacyParsedTimerPlayerCountHoverLines.add(toLegacy(parse(line)));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
legacyParsedTimerPlayerCountHoverLines = null;
|
||||||
|
}
|
||||||
|
|
||||||
languageName = config.getString("language").toLowerCase();
|
languageName = config.getString("language").toLowerCase();
|
||||||
kickOnlinePlayers = config.getBoolean("kick-online-players", true);
|
kickOnlinePlayers = config.getBoolean("kick-online-players", true);
|
||||||
updateChecks = config.getBoolean("update-checks", true);
|
updateChecks = config.getBoolean("update-checks", true);
|
||||||
@@ -214,9 +232,9 @@ public class Settings implements eu.kennytv.maintenance.api.Settings {
|
|||||||
whitelistedPlayers.clear();
|
whitelistedPlayers.clear();
|
||||||
for (final Map.Entry<String, Object> entry : whitelist.getValues().entrySet()) {
|
for (final Map.Entry<String, Object> entry : whitelist.getValues().entrySet()) {
|
||||||
try {
|
try {
|
||||||
whitelistedPlayers.put(UUID.fromString(entry.getKey()), (String) entry.getValue());
|
whitelistedPlayers.put(UUID.fromString(entry.getKey()), String.valueOf(entry.getValue()));
|
||||||
} catch (final Exception e) {
|
} catch (final IllegalArgumentException e) {
|
||||||
plugin.getLogger().warning("invalid WhitelistedPlayers entry: " + entry.getKey());
|
plugin.getLogger().warning("Invalid WhitelistedPlayers entry: " + entry.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,8 +257,7 @@ public class Settings implements eu.kennytv.maintenance.api.Settings {
|
|||||||
Files.move(oldDir.toPath(), plugin.getDataFolder().toPath());
|
Files.move(oldDir.toPath(), plugin.getDataFolder().toPath());
|
||||||
plugin.getLogger().info("Moved old " + oldDirName + " to new " + plugin.getDataFolder().getName() + " directory!");
|
plugin.getLogger().info("Moved old " + oldDirName + " to new " + plugin.getDataFolder().getName() + " directory!");
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
plugin.getLogger().severe("Error while copying " + oldDirName + " to new " + plugin.getDataFolder().getName() + " directory!");
|
plugin.getLogger().log(Level.SEVERE, "Error while copying " + oldDirName + " to new " + plugin.getDataFolder().getName() + " directory!", e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,8 +524,7 @@ public class Settings implements eu.kennytv.maintenance.api.Settings {
|
|||||||
return commandsOnMaintenanceDisable;
|
return commandsOnMaintenanceDisable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public @Nullable List<String> getTimerSpecificPingMessages() {
|
||||||
public List<String> getTimerSpecificPingMessages() {
|
|
||||||
return timerSpecificPingMessages;
|
return timerSpecificPingMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -517,15 +533,21 @@ public class Settings implements eu.kennytv.maintenance.api.Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getLegacyParsedPlayerCountMessage() {
|
public String getLegacyParsedPlayerCountMessage() {
|
||||||
return plugin.replacePingVariables(legacyParsedPlayerCountMessage);
|
final String message = timerDependent(legacyParsedPlayerCountMessage, legacyParsedTimerPlayerCountMessage);
|
||||||
|
return plugin.replacePingVariables(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getLegacyParsedPlayerCountHoverLines() {
|
public String[] getLegacyParsedPlayerCountHoverLines() {
|
||||||
final String[] lines = new String[legacyParsedPlayerCountHoverLines.size()];
|
final List<String> lines = timerDependent(legacyParsedPlayerCountHoverLines, legacyParsedTimerPlayerCountHoverLines);
|
||||||
for (int i = 0; i < legacyParsedPlayerCountHoverLines.size(); i++) {
|
final String[] parsedLines = new String[lines.size()];
|
||||||
lines[i] = plugin.replacePingVariables(legacyParsedPlayerCountHoverLines.get(i));
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
|
parsedLines[i] = plugin.replacePingVariables(lines.get(i));
|
||||||
}
|
}
|
||||||
return lines;
|
return parsedLines;
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T> T timerDependent(final T normal, final @Nullable T timerSpecific) {
|
||||||
|
return timerSpecific != null && plugin.isTaskRunning() && !plugin.getRunnable().shouldEnable() ? timerSpecific : normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component getKickMessage() {
|
public Component getKickMessage() {
|
||||||
|
|||||||
@@ -61,15 +61,21 @@ timerspecific-pingmessages:
|
|||||||
# If set to false, the normal playercount will be shown.
|
# If set to false, the normal playercount will be shown.
|
||||||
#
|
#
|
||||||
# Alternatively you can use '%ONLINE%' and '%MAX%' if you want to include the playercount in a custom message (e.g. "Maintenance %ONLINE%/%MAX%").
|
# Alternatively you can use '%ONLINE%' and '%MAX%' if you want to include the playercount in a custom message (e.g. "Maintenance %ONLINE%/%MAX%").
|
||||||
|
# You may also set a different message for when a maintenance endtimer is running.
|
||||||
# DOES NOT SUPPORT RGB!
|
# DOES NOT SUPPORT RGB!
|
||||||
enable-playercountmessage: true
|
enable-playercountmessage: true
|
||||||
|
enable-timerspecific-playercountmessage: false
|
||||||
playercountmessage: "<dark_red>Maintenance"
|
playercountmessage: "<dark_red>Maintenance"
|
||||||
|
timer-playercountmessage: "<dark_red>Maintenance: <yellow>%TIMER%"
|
||||||
|
|
||||||
# Is shown when you move your mouse above the text in the top right corner of the server in the serverlist,
|
# Is shown when you move your mouse above the text in the top right corner of the server in the serverlist,
|
||||||
# where the playercount would normally be displayed.
|
# where the playercount would normally be displayed.
|
||||||
|
# You may also set a different message for when a maintenance endtimer is running.
|
||||||
# DOES NOT SUPPORT RGB!
|
# DOES NOT SUPPORT RGB!
|
||||||
enable-playercounthovermessage: true
|
enable-playercounthovermessage: true
|
||||||
|
enable-timerspecific-playercounthovermessage: false
|
||||||
playercounthovermessage: "<red>Currently under<br><red>maintenance"
|
playercounthovermessage: "<red>Currently under<br><red>maintenance"
|
||||||
|
timer-playercounthovermessage: "<red>Currently under<br><red>maintenance: <yellow>%TIMER%"
|
||||||
|
|
||||||
# If set to true, the server icon will be changed to the 'maintenance-icon.png' file in the plugin's folder during maintenance.
|
# If set to true, the server icon will be changed to the 'maintenance-icon.png' file in the plugin's folder during maintenance.
|
||||||
custom-maintenance-icon: false
|
custom-maintenance-icon: false
|
||||||
@@ -79,7 +85,6 @@ custom-maintenance-icon: false
|
|||||||
send-join-notification: false
|
send-join-notification: false
|
||||||
|
|
||||||
# Set this to false if you do not want players to be kicked when you enable maintenance (new connections will still be blocked).
|
# Set this to false if you do not want players to be kicked when you enable maintenance (new connections will still be blocked).
|
||||||
# ... I don't know why you would want that, but you can disable it. :p
|
|
||||||
kick-online-players: true
|
kick-online-players: true
|
||||||
|
|
||||||
# When fetched player does not exist then fallback to offline uuid. Only works on proxies like Velocity or BungeeCord
|
# When fetched player does not exist then fallback to offline uuid. Only works on proxies like Velocity or BungeeCord
|
||||||
|
|||||||
@@ -71,6 +71,11 @@ import org.spongepowered.plugin.metadata.model.PluginContributor;
|
|||||||
@Plugin("maintenance")
|
@Plugin("maintenance")
|
||||||
public final class MaintenanceSpongePlugin extends MaintenancePlugin {
|
public final class MaintenanceSpongePlugin extends MaintenancePlugin {
|
||||||
|
|
||||||
|
private static final String[] UNSUPPORTED_FIELDS = {
|
||||||
|
"mysql", "proxied-maintenance-servers", "fallback", "waiting-server",
|
||||||
|
"playercountmessage", "enable-timerspecific-playercountmessage", "timer-playercountmessage",
|
||||||
|
"commands-on-single-maintenance-enable", "commands-on-single-maintenance-disable",
|
||||||
|
};
|
||||||
@SuppressWarnings("SpongeLogging")
|
@SuppressWarnings("SpongeLogging")
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
private final PluginContainer container;
|
private final PluginContainer container;
|
||||||
@@ -92,8 +97,8 @@ public final class MaintenanceSpongePlugin extends MaintenancePlugin {
|
|||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void onEnable(final StartingEngineEvent<Server> event) {
|
public void onEnable(final StartingEngineEvent<Server> event) {
|
||||||
settings = new Settings(this, "mysql", "proxied-maintenance-servers", "fallback", "waiting-server",
|
|
||||||
"playercountmessage", "commands-on-single-maintenance-enable", "commands-on-single-maintenance-disable");
|
settings = new Settings(this, UNSUPPORTED_FIELDS);
|
||||||
|
|
||||||
sendEnableMessage();
|
sendEnableMessage();
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user