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 the `/maintenance dump` command
|
||||
* 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
|
||||
### Changed
|
||||
|
||||
@@ -37,6 +37,7 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class Settings implements eu.kennytv.maintenance.api.Settings {
|
||||
@@ -54,7 +55,9 @@ public class Settings implements eu.kennytv.maintenance.api.Settings {
|
||||
private List<String> commandsOnMaintenanceEnable;
|
||||
private List<String> commandsOnMaintenanceDisable;
|
||||
private String legacyParsedPlayerCountMessage;
|
||||
private String legacyParsedTimerPlayerCountMessage;
|
||||
private List<String> legacyParsedPlayerCountHoverLines;
|
||||
private List<String> legacyParsedTimerPlayerCountHoverLines;
|
||||
private String prefixString;
|
||||
private String languageName;
|
||||
private boolean enablePingMessages;
|
||||
@@ -111,8 +114,7 @@ public class Settings implements eu.kennytv.maintenance.api.Settings {
|
||||
try {
|
||||
updateLanguageFile();
|
||||
} catch (final IOException e) {
|
||||
plugin.getLogger().severe("Couldn't update language file");
|
||||
e.printStackTrace();
|
||||
plugin.getLogger().log(Level.SEVERE, "Couldn't update language file", e);
|
||||
}
|
||||
|
||||
prefixString = language.getString("prefix");
|
||||
@@ -124,7 +126,7 @@ public class Settings implements eu.kennytv.maintenance.api.Settings {
|
||||
try {
|
||||
config.save();
|
||||
} 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 {
|
||||
whitelist.save();
|
||||
} 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");
|
||||
if (config.getBoolean("enable-timerspecific-messages")) {
|
||||
timerSpecificPingMessages = loadPingMessages("timerspecific-pingmessages");
|
||||
} else {
|
||||
timerSpecificPingMessages = null;
|
||||
}
|
||||
maintenance = config.getBoolean("maintenance-enabled");
|
||||
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
|
||||
if (plugin.getServerType() != ServerType.SPONGE) {
|
||||
legacyParsedPlayerCountMessage = toLegacy(parse(getConfigMessage("playercountmessage")));
|
||||
if (config.getBoolean("enable-timerspecific-playercountmessage")) {
|
||||
legacyParsedTimerPlayerCountMessage = toLegacy(parse(getConfigMessage("timer-playercountmessage")));
|
||||
} else {
|
||||
legacyParsedTimerPlayerCountMessage = null;
|
||||
}
|
||||
}
|
||||
|
||||
legacyParsedPlayerCountHoverLines = new ArrayList<>();
|
||||
@@ -198,6 +207,15 @@ public class Settings implements eu.kennytv.maintenance.api.Settings {
|
||||
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();
|
||||
kickOnlinePlayers = config.getBoolean("kick-online-players", true);
|
||||
updateChecks = config.getBoolean("update-checks", true);
|
||||
@@ -214,9 +232,9 @@ public class Settings implements eu.kennytv.maintenance.api.Settings {
|
||||
whitelistedPlayers.clear();
|
||||
for (final Map.Entry<String, Object> entry : whitelist.getValues().entrySet()) {
|
||||
try {
|
||||
whitelistedPlayers.put(UUID.fromString(entry.getKey()), (String) entry.getValue());
|
||||
} catch (final Exception e) {
|
||||
plugin.getLogger().warning("invalid WhitelistedPlayers entry: " + entry.getKey());
|
||||
whitelistedPlayers.put(UUID.fromString(entry.getKey()), String.valueOf(entry.getValue()));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
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());
|
||||
plugin.getLogger().info("Moved old " + oldDirName + " to new " + plugin.getDataFolder().getName() + " directory!");
|
||||
} catch (final IOException e) {
|
||||
plugin.getLogger().severe("Error while copying " + oldDirName + " to new " + plugin.getDataFolder().getName() + " directory!");
|
||||
e.printStackTrace();
|
||||
plugin.getLogger().log(Level.SEVERE, "Error while copying " + oldDirName + " to new " + plugin.getDataFolder().getName() + " directory!", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -507,8 +524,7 @@ public class Settings implements eu.kennytv.maintenance.api.Settings {
|
||||
return commandsOnMaintenanceDisable;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> getTimerSpecificPingMessages() {
|
||||
public @Nullable List<String> getTimerSpecificPingMessages() {
|
||||
return timerSpecificPingMessages;
|
||||
}
|
||||
|
||||
@@ -517,15 +533,21 @@ public class Settings implements eu.kennytv.maintenance.api.Settings {
|
||||
}
|
||||
|
||||
public String getLegacyParsedPlayerCountMessage() {
|
||||
return plugin.replacePingVariables(legacyParsedPlayerCountMessage);
|
||||
final String message = timerDependent(legacyParsedPlayerCountMessage, legacyParsedTimerPlayerCountMessage);
|
||||
return plugin.replacePingVariables(message);
|
||||
}
|
||||
|
||||
public String[] getLegacyParsedPlayerCountHoverLines() {
|
||||
final String[] lines = new String[legacyParsedPlayerCountHoverLines.size()];
|
||||
for (int i = 0; i < legacyParsedPlayerCountHoverLines.size(); i++) {
|
||||
lines[i] = plugin.replacePingVariables(legacyParsedPlayerCountHoverLines.get(i));
|
||||
final List<String> lines = timerDependent(legacyParsedPlayerCountHoverLines, legacyParsedTimerPlayerCountHoverLines);
|
||||
final String[] parsedLines = new String[lines.size()];
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
parsedLines[i] = plugin.replacePingVariables(lines.get(i));
|
||||
}
|
||||
return 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() {
|
||||
|
||||
@@ -61,15 +61,21 @@ timerspecific-pingmessages:
|
||||
# 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%").
|
||||
# You may also set a different message for when a maintenance endtimer is running.
|
||||
# DOES NOT SUPPORT RGB!
|
||||
enable-playercountmessage: true
|
||||
enable-timerspecific-playercountmessage: false
|
||||
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,
|
||||
# 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!
|
||||
enable-playercounthovermessage: true
|
||||
enable-timerspecific-playercounthovermessage: false
|
||||
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.
|
||||
custom-maintenance-icon: false
|
||||
@@ -79,7 +85,6 @@ custom-maintenance-icon: 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).
|
||||
# ... I don't know why you would want that, but you can disable it. :p
|
||||
kick-online-players: true
|
||||
|
||||
# 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")
|
||||
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")
|
||||
private final Logger logger;
|
||||
private final PluginContainer container;
|
||||
@@ -92,8 +97,8 @@ public final class MaintenanceSpongePlugin extends MaintenancePlugin {
|
||||
|
||||
@Listener
|
||||
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();
|
||||
|
||||
|
||||
Reference in new issue
Block a user