Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b29462a5cb | ||
|
|
c9161ebe24 | ||
|
|
8441c6a8bf | ||
|
|
72c2ba77ee | ||
|
|
a097790b76 | ||
|
|
b7129e8aa8 | ||
|
|
ab9c2b8be1 | ||
|
|
a9a37b8fc8 | ||
|
|
d50cb67a26 | ||
|
|
5e42500308 | ||
|
|
50997a847f | ||
|
|
2305d85c01 | ||
|
|
33bbc35d88 | ||
|
|
28b3e100fb | ||
|
|
edae2d699b | ||
|
|
0cc477a769 | ||
|
|
53b84a999f | ||
|
|
49487c11ff | ||
|
|
0c4070b7a7 | ||
|
|
67909a4862 | ||
|
|
28ee563083 | ||
|
|
28b2b528c1 | ||
|
|
a53d9d0850 | ||
|
|
873a8812aa | ||
|
|
19ebc90963 | ||
|
|
dfbd1381de | ||
|
|
c9fe48a067 | ||
|
|
49b022b665 | ||
|
|
86be23ae5f | ||
|
|
420412978e | ||
|
|
25e2f4dae2 | ||
|
|
d767be96b5 | ||
|
|
6d73acca9b | ||
|
|
1f116374ad | ||
|
|
d0b7d96208 | ||
|
|
16285d7064 | ||
|
|
1f27084fe1 | ||
|
|
261aace0db | ||
|
|
344b910214 | ||
|
|
fbaa4896e1 | ||
|
|
2f93064f60 | ||
|
|
65b47c5e07 | ||
|
|
d70d01f2d3 | ||
|
|
769d7d3bcd | ||
|
|
a5f47688e0 | ||
|
|
7d2e6a25a4 | ||
|
|
69999b3b7a | ||
|
|
94d1bd4eb9 | ||
|
|
c18e8b7ab7 | ||
|
|
9f45187300 | ||
|
|
0c6ba8a9b7 | ||
|
|
1af69f2e8b | ||
|
|
a3b836b1c5 | ||
|
|
1eca6c81ad | ||
|
|
b9b4a78b5c | ||
|
|
fda23c5539 | ||
|
|
8297321971 | ||
|
|
cfeaf00f26 | ||
|
|
5ee1b32249 | ||
|
|
b69f0dc90e | ||
|
|
fe6cae4e47 | ||
|
|
b494b5c23c | ||
|
|
3bd3395128 | ||
|
|
3e3f63220d | ||
|
|
ccba0f042f | ||
|
|
abdd89259d | ||
|
|
256f203c48 | ||
|
|
205412b02c | ||
|
|
990289feb2 | ||
|
|
44b1ff1a1f | ||
|
|
f9e11bb9e5 | ||
|
|
eef1584b1c | ||
|
|
937dd84d1c | ||
|
|
80b9fe280b | ||
|
|
3892892792 | ||
|
|
519551e76c | ||
|
|
b30476ae3f | ||
|
|
9d417a12f1 | ||
|
|
fd5406b95d | ||
|
|
0ef59e557d | ||
|
|
15ed1db347 | ||
|
|
429d5b90d4 | ||
|
|
b3ab931aca | ||
|
|
21b42d0c72 | ||
|
|
7b1e1a27ba | ||
|
|
fb7b1e791f | ||
|
|
eecd59b387 | ||
|
|
ff7d8e0293 | ||
|
|
19c6d77a2c | ||
|
|
e002aa34e9 | ||
|
|
865e53a4a8 | ||
|
|
b8c652b7fb | ||
|
|
c4080f82dc | ||
|
|
1a33497e8f | ||
|
|
f8353b8eda | ||
|
|
4980ad54ec | ||
|
|
5363305411 | ||
|
|
6ff47619ad | ||
|
|
69315a3f74 | ||
|
|
8b1ddba672 | ||
|
|
bf63f0e209 | ||
|
|
450c923d24 | ||
|
|
9a922a6df5 | ||
|
|
08a5a9a021 | ||
|
|
61ad7d8533 | ||
|
|
52d2b3c096 | ||
|
|
b0a69cc048 | ||
|
|
74e445a62e | ||
|
|
91219202b2 | ||
|
|
a3545c83a0 | ||
|
|
31baf91e8f | ||
|
|
214cd53751 | ||
|
|
2be16882c7 | ||
|
|
75e2264b44 | ||
|
|
fd7a0eb6a5 | ||
|
|
177115f144 | ||
|
|
edbe31dc9c | ||
|
|
21a2f9ef2f |
No files matched your search
@@ -0,0 +1,13 @@
|
||||
## Issue
|
||||
Include here how the problem occured and how it's reproduceable.
|
||||
If present, also paste the entire error message from the console, preferably via a https://hastebin.com/ link.
|
||||
|
||||
## Necessary server information
|
||||
**Running on**: <BungeeCord/Bukkit>
|
||||
|
||||
**Maintenance version**: <>
|
||||
|
||||
## Other information
|
||||
**Other motd changing plugins**: <>
|
||||
|
||||
**ProtocolLib version**: <>
|
||||
@@ -1,4 +1,4 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
@@ -671,4 +671,4 @@ into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
Binary file not shown.
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<artifactId>maintenance-base</artifactId>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<version>2.2</version>
|
||||
<version>2.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>maintenance-api</artifactId>
|
||||
@@ -16,13 +16,13 @@
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package eu.kennytv.maintenance.api;
|
||||
|
||||
/**
|
||||
* @author KennyTV
|
||||
* @since 2.1
|
||||
*/
|
||||
public interface IMaintenance {
|
||||
|
||||
/**
|
||||
* Enabled/disabled maintenance mode.
|
||||
* Enables/disables maintenance mode.
|
||||
* If enabled, all non-permitted players will be kicked.
|
||||
* <p>
|
||||
* If using the BungeeCord version and MySQL is enabled,
|
||||
@@ -15,12 +19,12 @@ public interface IMaintenance {
|
||||
void setMaintenance(boolean maintenance);
|
||||
|
||||
/**
|
||||
* @return true if maintenance is enabled on the proxy
|
||||
* @return true if maintenance is currently enabled
|
||||
*/
|
||||
boolean isMaintenance();
|
||||
|
||||
/**
|
||||
* @return true if a timer task is currently running
|
||||
* @return true if a start- or endtimer task is currently running
|
||||
*/
|
||||
boolean isTaskRunning();
|
||||
|
||||
@@ -30,7 +34,7 @@ public interface IMaintenance {
|
||||
String getVersion();
|
||||
|
||||
/**
|
||||
* @return {@link ISettings} for more options
|
||||
* @return {@link ISettings} for options regarding configuration files
|
||||
*/
|
||||
ISettings getSettings();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package eu.kennytv.maintenance.api;
|
||||
|
||||
/**
|
||||
* @author KennyTV
|
||||
* @since 2.2.2
|
||||
*/
|
||||
public interface IMaintenanceBase {
|
||||
|
||||
/**
|
||||
* Returns API instance of IMaintenance.
|
||||
*
|
||||
* @return {@link IMaintenance} instance
|
||||
*/
|
||||
IMaintenance getApi();
|
||||
}
|
||||
@@ -3,15 +3,21 @@ package eu.kennytv.maintenance.api;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author KennyTV
|
||||
* @since 2.1
|
||||
*/
|
||||
public interface ISettings {
|
||||
|
||||
/**
|
||||
* @return true if maintenance is enabled on the proxy
|
||||
* Note that the value might need a few seconds to update, if you're on BungeeCord with MySQL enabled
|
||||
*
|
||||
* @return true if maintenance is currently enabled
|
||||
*/
|
||||
boolean isMaintenance();
|
||||
|
||||
/**
|
||||
* @return true if "join-notification" is set to true in the config
|
||||
* @return true if "send-join-notification" is set to true in the config
|
||||
*/
|
||||
boolean isJoinNotifications();
|
||||
|
||||
@@ -21,9 +27,7 @@ public interface ISettings {
|
||||
boolean hasCustomIcon();
|
||||
|
||||
/**
|
||||
* The keyset of the map contains the uuids as a string, the values the names of the players.
|
||||
*
|
||||
* @return map of uuids of whitelisted players with their last seen names
|
||||
* @return map of uuids of whitelisted players with their given names
|
||||
*/
|
||||
Map<UUID, String> getWhitelistedPlayers();
|
||||
|
||||
@@ -38,9 +42,12 @@ public interface ISettings {
|
||||
/**
|
||||
* Removes a player from the maintenance whitelist.
|
||||
*
|
||||
* @param name name of the player to remove in lowercase letters
|
||||
* @param name name of the player to remove with original lower-/uppercase letters
|
||||
* @return true if removing the player was successful
|
||||
* @deprecated if a player changes their name, the list will still contain the old one
|
||||
* @see #removeWhitelistedPlayer(UUID)
|
||||
*/
|
||||
@Deprecated
|
||||
boolean removeWhitelistedPlayer(String name);
|
||||
|
||||
/**
|
||||
@@ -51,4 +58,11 @@ public interface ISettings {
|
||||
* @return true if adding the player was successful
|
||||
*/
|
||||
boolean addWhitelistedPlayer(UUID uuid, String name);
|
||||
|
||||
/**
|
||||
* Reloads the maintenance-icon.png image from the server folder.
|
||||
*
|
||||
* @return true if loading the image was successful
|
||||
*/
|
||||
boolean reloadMaintenanceIcon();
|
||||
}
|
||||
@@ -6,11 +6,11 @@ import net.md_5.bungee.api.plugin.Plugin;
|
||||
/**
|
||||
* Utility class to get the {@link IMaintenance} instance for the BungeeCord version of the plugin.
|
||||
* <p>
|
||||
* This class is NOT available for the Spigot version!
|
||||
* Only access this class if you're running the plugin on a BungeeCord server!
|
||||
* </p>
|
||||
*
|
||||
* @author KennyTV
|
||||
* @since 1.0
|
||||
* @since 2.1
|
||||
*/
|
||||
public final class MaintenanceBungeeAPI {
|
||||
|
||||
@@ -24,6 +24,6 @@ public final class MaintenanceBungeeAPI {
|
||||
if (maintenance == null)
|
||||
ProxyServer.getInstance().getLogger().warning("Could not get instance of MaintenanceBungee!");
|
||||
|
||||
return (IMaintenance) maintenance;
|
||||
return ((IMaintenanceBase) maintenance).getApi();
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,16 @@
|
||||
package eu.kennytv.maintenance.api;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Utility class to get the {@link IMaintenance} instance for the Spigot/Bukkit version of the plugin.
|
||||
* Utility class to get the {@link IMaintenance} instance for the Spigot version of the plugin.
|
||||
* <p>
|
||||
* This class is NOT available for the BungeeCord version!
|
||||
* Only access this class if you're running the plugin on a Spigot server!
|
||||
* </p>
|
||||
*
|
||||
* @author KennyTV
|
||||
* @since 1.0
|
||||
* @since 2.1
|
||||
*/
|
||||
public final class MaintenanceSpigotAPI {
|
||||
|
||||
@@ -19,10 +20,10 @@ public final class MaintenanceSpigotAPI {
|
||||
* @return {@link IMaintenance} instance
|
||||
*/
|
||||
public static IMaintenance getAPI() {
|
||||
final org.bukkit.plugin.Plugin maintenance = Bukkit.getPluginManager().getPlugin("MaintenanceSpigot");
|
||||
final Plugin maintenance = Bukkit.getPluginManager().getPlugin("MaintenanceSpigot");
|
||||
if (maintenance == null)
|
||||
Bukkit.getLogger().warning("Could not get instance of MaintenanceSpigot!");
|
||||
|
||||
return (IMaintenance) maintenance;
|
||||
return ((IMaintenanceBase) maintenance).getApi();
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,13 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<artifactId>maintenance-base</artifactId>
|
||||
<version>2.2</version>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<version>2.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>maintenancebungee</artifactId>
|
||||
<artifactId>maintenance-bungee</artifactId>
|
||||
<name>MaintenanceBungee</name>
|
||||
|
||||
<repositories>
|
||||
@@ -24,13 +23,13 @@
|
||||
<dependency>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<artifactId>maintenance-core</artifactId>
|
||||
<version>2.2</version>
|
||||
<version>${parent.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -42,7 +41,7 @@
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<version>2.7.8</version>
|
||||
<version>3.2.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package eu.kennytv.maintenance.bungee;
|
||||
|
||||
import eu.kennytv.maintenance.api.IMaintenance;
|
||||
import eu.kennytv.maintenance.api.IMaintenanceBase;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public final class MaintenanceBungeeBase extends Plugin implements IMaintenanceBase {
|
||||
private IMaintenance maintenance;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
maintenance = new MaintenanceBungeePlugin(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMaintenance getApi() {
|
||||
return maintenance;
|
||||
}
|
||||
|
||||
File getPluginFile() {
|
||||
return getFile();
|
||||
}
|
||||
}
|
||||
+19
-24
@@ -4,8 +4,8 @@ import eu.kennytv.maintenance.api.IMaintenance;
|
||||
import eu.kennytv.maintenance.api.ISettings;
|
||||
import eu.kennytv.maintenance.api.MaintenanceBungeeAPI;
|
||||
import eu.kennytv.maintenance.bungee.command.MaintenanceBungeeCommand;
|
||||
import eu.kennytv.maintenance.bungee.command.MaintenanceBungeeCommandBase;
|
||||
import eu.kennytv.maintenance.bungee.listener.PostLoginListener;
|
||||
import eu.kennytv.maintenance.bungee.listener.ProxyPingListener;
|
||||
import eu.kennytv.maintenance.bungee.metrics.MetricsLite;
|
||||
import eu.kennytv.maintenance.core.MaintenanceModePlugin;
|
||||
import eu.kennytv.maintenance.core.hook.ServerListPlusHook;
|
||||
@@ -21,7 +21,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* @author KennyTV
|
||||
* @since 1.0
|
||||
*/
|
||||
public final class MaintenanceBungeePlugin extends MaintenanceModePlugin implements IMaintenance {
|
||||
public final class MaintenanceBungeePlugin extends MaintenanceModePlugin {
|
||||
private final MaintenanceBungeeBase plugin;
|
||||
private final SettingsBungee settings;
|
||||
|
||||
@@ -31,12 +31,12 @@ public final class MaintenanceBungeePlugin extends MaintenanceModePlugin impleme
|
||||
this.plugin = plugin;
|
||||
plugin.getLogger().info("Plugin by KennyTV");
|
||||
|
||||
settings = new SettingsBungee(plugin);
|
||||
settings = new SettingsBungee(this, plugin);
|
||||
|
||||
final PluginManager pm = getProxy().getPluginManager();
|
||||
pm.registerListener(plugin, new PostLoginListener(this, settings));
|
||||
pm.registerListener(plugin, new ProxyPingListener(plugin, settings));
|
||||
pm.registerCommand(plugin, new MaintenanceBungeeCommand(this, settings));
|
||||
final MaintenanceBungeeCommand maintenanceCommand = new MaintenanceBungeeCommand(this, settings);
|
||||
pm.registerCommand(plugin, new MaintenanceBungeeCommandBase(maintenanceCommand));
|
||||
|
||||
new MetricsLite(plugin);
|
||||
|
||||
@@ -44,50 +44,44 @@ public final class MaintenanceBungeePlugin extends MaintenanceModePlugin impleme
|
||||
final Plugin serverListPlus = pm.getPlugin("ServerListPlus");
|
||||
if (serverListPlus != null) {
|
||||
serverListPlusHook = new ServerListPlusHook(((ServerListPlusPlugin) serverListPlus).getCore());
|
||||
serverListPlusHook.setEnabled(!settings.isMaintenance());
|
||||
plugin.getLogger().info("Enabled ServerListPlus integration!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (settings.getMySQL() != null)
|
||||
settings.getMySQL().close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaintenance(final boolean maintenance) {
|
||||
if (settings.getMySQL() != null) {
|
||||
settings.setMaintenanceToSQL(maintenance);
|
||||
} else {
|
||||
settings.setMaintenance(maintenance);
|
||||
settings.setConfigBoolean("enable-maintenance-mode", maintenance);
|
||||
settings.setToConfig("enable-maintenance-mode", maintenance);
|
||||
settings.saveConfig();
|
||||
settings.reloadConfigs();
|
||||
}
|
||||
|
||||
if (serverListPlusHook != null)
|
||||
serverListPlusHook.setEnabled(!maintenance);
|
||||
serverActions(maintenance);
|
||||
|
||||
if (isTaskRunning())
|
||||
cancelTask();
|
||||
}
|
||||
|
||||
void serverActions(final boolean maintenance) {
|
||||
if (serverListPlusHook != null)
|
||||
serverListPlusHook.setEnabled(!maintenance);
|
||||
|
||||
if (maintenance) {
|
||||
getProxy().getPlayers().stream()
|
||||
.filter(p -> !p.hasPermission("maintenance.bypass") && !settings.getWhitelistedPlayers().containsKey(p.getUniqueId()))
|
||||
.forEach(p -> p.disconnect(settings.getKickMessage().replace("%NEWLINE%", "\n")));
|
||||
getProxy().broadcast(settings.getMaintenanceActivated());
|
||||
getProxy().broadcast(settings.getMessage("maintenanceActivated"));
|
||||
} else
|
||||
getProxy().broadcast(settings.getMaintenanceDeactivated());
|
||||
getProxy().broadcast(settings.getMessage("maintenanceDeactivated"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMaintenance() {
|
||||
return settings.isMaintenance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int schedule(final Runnable runnable) {
|
||||
return getProxy().getScheduler().schedule(plugin, runnable, 0, 1, TimeUnit.MINUTES).getId();
|
||||
public int startMaintenanceRunnable(final Runnable runnable) {
|
||||
return getProxy().getScheduler().schedule(plugin, runnable, 0, 1, TimeUnit.SECONDS).getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,7 +92,8 @@ public final class MaintenanceBungeePlugin extends MaintenanceModePlugin impleme
|
||||
@Override
|
||||
public void cancelTask() {
|
||||
getProxy().getScheduler().cancel(taskId);
|
||||
setTaskId(0);
|
||||
runnable = null;
|
||||
taskId = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,238 @@
|
||||
package eu.kennytv.maintenance.bungee;
|
||||
|
||||
import eu.kennytv.maintenance.bungee.listener.ProxyPingListener;
|
||||
import eu.kennytv.maintenance.bungee.mysql.MySQL;
|
||||
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.plugin.PluginManager;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.YamlConfiguration;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class SettingsBungee extends Settings {
|
||||
private final String updateQuery;
|
||||
private final String maintenanceQuery;
|
||||
private final MySQL mySQL;
|
||||
|
||||
private final MaintenanceBungeePlugin maintenancePlugin;
|
||||
private final MaintenanceBungeeBase plugin;
|
||||
private final IPingListener pingListener;
|
||||
private Configuration config;
|
||||
private Configuration language;
|
||||
private Configuration whitelist;
|
||||
|
||||
private long millisecondsToCheck;
|
||||
private long lastMySQLCheck;
|
||||
|
||||
SettingsBungee(final MaintenanceBungeePlugin maintenancePlugin, final MaintenanceBungeeBase plugin) {
|
||||
super(maintenancePlugin);
|
||||
this.maintenancePlugin = maintenancePlugin;
|
||||
this.plugin = plugin;
|
||||
|
||||
final PluginManager pm = plugin.getProxy().getPluginManager();
|
||||
final ProxyPingListener listener = new ProxyPingListener(plugin, this);
|
||||
pm.registerListener(plugin, listener);
|
||||
pingListener = listener;
|
||||
|
||||
if (!plugin.getDataFolder().exists())
|
||||
plugin.getDataFolder().mkdirs();
|
||||
createFile("bungee-config.yml");
|
||||
createFile("language.yml");
|
||||
createFile("WhitelistedPlayers.yml");
|
||||
|
||||
reloadConfigs();
|
||||
|
||||
final Configuration mySQLSection = config.getSection("mysql");
|
||||
if (mySQLSection.getBoolean("use-mysql", false)) {
|
||||
plugin.getLogger().info("Trying to open database connection...");
|
||||
mySQL = new MySQL(mySQLSection.getString("host"),
|
||||
mySQLSection.getInt("port"),
|
||||
mySQLSection.getString("username"),
|
||||
mySQLSection.getString("password"),
|
||||
mySQLSection.getString("database"));
|
||||
|
||||
// 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 = ?";
|
||||
plugin.getLogger().info("Done!");
|
||||
} else {
|
||||
mySQL = null;
|
||||
updateQuery = null;
|
||||
maintenanceQuery = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void createFile(final String name) {
|
||||
final File file = new File(plugin.getDataFolder(), name);
|
||||
if (!file.exists()) {
|
||||
try (final InputStream in = plugin.getResourceAsStream(name)) {
|
||||
Files.copy(in, file.toPath());
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException("Unable to create " + name + " file for MaintenanceBungee", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateExtraConfig() {
|
||||
// 2.3.1 mysql.update-interval
|
||||
if (!configContains("mysql.update-interval")) {
|
||||
setToConfig("mysql.update-interval", 15);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
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"));
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException("Unable to load Maintenance files!", e);
|
||||
}
|
||||
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveConfig() {
|
||||
final File file = new File(plugin.getDataFolder(), "bungee-config.yml");
|
||||
try {
|
||||
YamlConfiguration.getProvider(YamlConfiguration.class).save(config, new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8));
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException("Unable to save bungee-config.yml!", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveWhitelistedPlayers() {
|
||||
final File file = new File(plugin.getDataFolder(), "WhitelistedPlayers.yml");
|
||||
try {
|
||||
YamlConfiguration.getProvider(YamlConfiguration.class).save(whitelist, file);
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException("Unable to save WhitelistedPlayers.yml!", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadExtraSettings() {
|
||||
whitelistedPlayers.clear();
|
||||
whitelist.getKeys().forEach(key -> whitelistedPlayers.put(UUID.fromString(key), whitelist.getString(key)));
|
||||
if (mySQL != null) {
|
||||
final long configValue = config.getInt("mysql.update-interval");
|
||||
millisecondsToCheck = configValue > 0 ? configValue * 1000 : -1;
|
||||
lastMySQLCheck = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWhitelist(final String uuid, final String s) {
|
||||
whitelist.set(uuid, s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigString(final String path) {
|
||||
final String s = config.getString(path);
|
||||
if (s == null) {
|
||||
plugin.getLogger().warning("The config is missing the following string: " + path);
|
||||
return "null";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage(final String path) {
|
||||
final String s = language.getString(path);
|
||||
if (s == null) {
|
||||
plugin.getLogger().warning("The language file is missing the following string: " + path);
|
||||
return "null";
|
||||
}
|
||||
return ChatColor.translateAlternateColorCodes('&', s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getConfigBoolean(final String path) {
|
||||
return config.getBoolean(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getConfigIntList(final String path) {
|
||||
return config.getIntList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getConfigList(final String path) {
|
||||
return config.getStringList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setToConfig(final String path, final Object var) {
|
||||
config.set(path, var);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configContains(final String path) {
|
||||
return config.contains(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColoredString(final String message) {
|
||||
return ChatColor.translateAlternateColorCodes('&', message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMaintenance() {
|
||||
if (mySQL != null && (millisecondsToCheck == -1 || System.currentTimeMillis() - lastMySQLCheck > millisecondsToCheck)) {
|
||||
mySQL.executeQuery(maintenanceQuery, rs -> {
|
||||
try {
|
||||
if (rs.next()) {
|
||||
final boolean databaseValue = Boolean.parseBoolean(rs.getString("value"));
|
||||
if (databaseValue != maintenance)
|
||||
maintenancePlugin.serverActions(maintenance);
|
||||
|
||||
maintenance = databaseValue;
|
||||
}
|
||||
|
||||
} catch (final SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, "maintenance");
|
||||
if (millisecondsToCheck != -1)
|
||||
lastMySQLCheck = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
return maintenance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reloadMaintenanceIcon() {
|
||||
return pingListener.loadIcon();
|
||||
}
|
||||
|
||||
public void setMaintenanceToSQL(final boolean maintenance) {
|
||||
plugin.getProxy().getScheduler().runAsync(plugin, () -> {
|
||||
final String s = String.valueOf(maintenance);
|
||||
mySQL.executeUpdate(updateQuery, "maintenance", s, s);
|
||||
if (millisecondsToCheck != -1)
|
||||
lastMySQLCheck = System.currentTimeMillis();
|
||||
});
|
||||
this.maintenance = maintenance;
|
||||
}
|
||||
|
||||
public MySQL getMySQL() {
|
||||
return mySQL;
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package eu.kennytv.maintenance.bungee.command;
|
||||
|
||||
import eu.kennytv.maintenance.bungee.MaintenanceBungeePlugin;
|
||||
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.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;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
public final class MaintenanceBungeeCommand extends MaintenanceCommand {
|
||||
|
||||
public MaintenanceBungeeCommand(final MaintenanceBungeePlugin plugin, final SettingsBungee settings) {
|
||||
super(plugin, settings, "MaintenanceBungee");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addPlayerToWhitelist(final SenderInfo sender, final String name) {
|
||||
final ProxiedPlayer selected = ProxyServer.getInstance().getPlayer(name);
|
||||
if (selected == null) {
|
||||
sender.sendMessage(settings.getMessage("playerNotOnline"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (settings.addWhitelistedPlayer(selected.getUniqueId(), selected.getName()))
|
||||
sender.sendMessage(settings.getMessage("whitelistAdded").replace("%PLAYER%", selected.getName()));
|
||||
else
|
||||
sender.sendMessage(settings.getMessage("whitelistAlreadyAdded").replace("%PLAYER%", selected.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removePlayerFromWhitelist(final SenderInfo sender, final String name) {
|
||||
final ProxiedPlayer selected = ProxyServer.getInstance().getPlayer(name);
|
||||
if (selected == null) {
|
||||
if (settings.removeWhitelistedPlayer(name))
|
||||
sender.sendMessage(settings.getMessage("whitelistRemoved").replace("%PLAYER%", name));
|
||||
else
|
||||
sender.sendMessage(settings.getMessage("whitelistNotFound"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (settings.removeWhitelistedPlayer(selected.getUniqueId()))
|
||||
sender.sendMessage(settings.getMessage("whitelistRemoved").replace("%PLAYER%", selected.getName()));
|
||||
else
|
||||
sender.sendMessage(settings.getMessage("whitelistNotFound"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkForUpdate(final SenderInfo sender) {
|
||||
if (plugin.updateAvailable()) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cNewest version available: §aVersion " + plugin.getNewestVersion() + "§c, you're on §a" + plugin.getVersion());
|
||||
sender.sendMessage(plugin.getPrefix() + "§c§lWARNING: §cYou will have to restart the proxy to prevent further issues and to complete the update!" +
|
||||
" If you can't do that, don't update!");
|
||||
final TextComponent tc = new TextComponent("§6× §8[§aUpdate§8]");
|
||||
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/maintenance forceupdate"));
|
||||
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§aClick here to update the plugin")));
|
||||
tc.addExtra(" §8< §7Or use the command §c/maintenance forceupdate");
|
||||
|
||||
((ProxiedSenderInfo) sender).sendMessage(tc);
|
||||
} else
|
||||
sender.sendMessage(plugin.getPrefix() + "§aYou already have the latest version of the plugin!");
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package eu.kennytv.maintenance.bungee.command;
|
||||
|
||||
import eu.kennytv.maintenance.bungee.util.ProxiedSenderInfo;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
public final class MaintenanceBungeeCommandBase extends Command {
|
||||
private final MaintenanceBungeeCommand command;
|
||||
|
||||
public MaintenanceBungeeCommandBase(final MaintenanceBungeeCommand command) {
|
||||
super("maintenance", "", "maintenancebungee");
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final String[] args) {
|
||||
command.execute(new ProxiedSenderInfo(sender), args);
|
||||
}
|
||||
}
|
||||
+9
-3
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -12,9 +13,13 @@ import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.event.EventPriority;
|
||||
|
||||
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<UUID> notifiedPlayers = Sets.newHashSet();
|
||||
|
||||
public PostLoginListener(final MaintenanceBungeePlugin plugin, final SettingsBungee settings) {
|
||||
this.plugin = plugin;
|
||||
@@ -32,16 +37,17 @@ public final class PostLoginListener implements Listener {
|
||||
|
||||
if (settings.isJoinNotifications())
|
||||
plugin.getProxy().getPlayers().stream().filter(player -> player.hasPermission("maintenance.joinnotification"))
|
||||
.forEach(player -> player.sendMessage(settings.getJoinNotification().replace("%PLAYER%", p.getName())));
|
||||
.forEach(player -> player.sendMessage(settings.getMessage("joinNotification").replace("%PLAYER%", p.getName())));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!p.hasPermission("maintenance.admin")) return;
|
||||
if (!p.hasPermission("maintenance.admin") || notifiedPlayers.contains(p.getUniqueId())) return;
|
||||
|
||||
plugin.async(() -> {
|
||||
if (plugin.updateAvailable()) {
|
||||
p.sendMessage(plugin.getPrefix() + "§cThere is a newer version available: §aVersion " + plugin.getNewestVersion() + "§c, you're still on §a" + plugin.getVersion());
|
||||
p.sendMessage(plugin.getPrefix() + "§cThere is a newer version available: §aVersion " + plugin.getNewestVersion() + "§c, you're on §a" + plugin.getVersion());
|
||||
notifiedPlayers.add(p.getUniqueId());
|
||||
|
||||
final TextComponent tc1 = new TextComponent(TextComponent.fromLegacyText(plugin.getPrefix() + " "));
|
||||
final TextComponent tc2 = new TextComponent(TextComponent.fromLegacyText("§cDownload it at: §6https://www.spigotmc.org/resources/maintenancemode.40699/"));
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package eu.kennytv.maintenance.bungee.listener;
|
||||
|
||||
import eu.kennytv.maintenance.bungee.MaintenanceBungeeBase;
|
||||
import eu.kennytv.maintenance.bungee.SettingsBungee;
|
||||
import eu.kennytv.maintenance.core.listener.IPingListener;
|
||||
import net.md_5.bungee.api.Favicon;
|
||||
import net.md_5.bungee.api.ServerPing;
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.event.EventPriority;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public final class ProxyPingListener implements Listener, IPingListener {
|
||||
private final MaintenanceBungeeBase plugin;
|
||||
private final SettingsBungee settings;
|
||||
private Favicon favicon;
|
||||
|
||||
public ProxyPingListener(final MaintenanceBungeeBase plugin, final SettingsBungee settings) {
|
||||
this.plugin = plugin;
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void proxyPing(final ProxyPingEvent event) {
|
||||
if (!settings.isMaintenance()) return;
|
||||
|
||||
final ServerPing ping = event.getResponse();
|
||||
if (settings.hasCustomPlayerCountMessage()) {
|
||||
ping.getVersion().setProtocol(1);
|
||||
ping.getVersion().setName(settings.getPlayerCountMessage()
|
||||
.replace("%ONLINE%", Integer.toString(ping.getPlayers().getOnline()))
|
||||
.replace("%MAX%", Integer.toString(ping.getPlayers().getMax())));
|
||||
}
|
||||
|
||||
ping.setDescription(settings.getRandomPingMessage());
|
||||
ping.getPlayers().setOnline(0);
|
||||
ping.getPlayers().setMax(0);
|
||||
ping.getPlayers().setSample(new ServerPing.PlayerInfo[]{
|
||||
new ServerPing.PlayerInfo(settings.getPlayerCountHoverMessage().replace("%NEWLINE%", "\n"), "")
|
||||
});
|
||||
|
||||
if (settings.hasCustomIcon() && favicon != null)
|
||||
ping.setFavicon(favicon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadIcon() {
|
||||
try {
|
||||
favicon = Favicon.create(ImageIO.read(new File("maintenance-icon.png")));
|
||||
} catch (final IOException | IllegalArgumentException e) {
|
||||
plugin.getLogger().warning("§4Could not load 'maintenance-icon.png' - did you create one in your Bungee folder (not the plugins folder)?");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -12,6 +12,7 @@ import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -266,7 +267,7 @@ public final class MetricsLite {
|
||||
}
|
||||
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
final GZIPOutputStream gzip = new GZIPOutputStream(outputStream);
|
||||
gzip.write(str.getBytes("UTF-8"));
|
||||
gzip.write(str.getBytes(StandardCharsets.UTF_8));
|
||||
gzip.close();
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
+4
-3
@@ -12,6 +12,7 @@ import java.util.function.Consumer;
|
||||
public final class MySQL {
|
||||
private final HikariDataSource hikariDataSource;
|
||||
|
||||
// Excuse me and everything to do with the MySQL stuff, I have little to no idea of how to use databases
|
||||
public MySQL(final String hostname, final int port, final String username, final String password, final String database) {
|
||||
final HikariConfig hikariConfig = new HikariConfig();
|
||||
hikariConfig.setMaximumPoolSize(10);
|
||||
@@ -60,8 +61,8 @@ public final class MySQL {
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (hikariDataSource != null && !hikariDataSource.isClosed())
|
||||
hikariDataSource.close();
|
||||
public void executeUpdate(final String query, final Object... objects) {
|
||||
executeUpdate(query, res -> {
|
||||
}, objects);
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package eu.kennytv.maintenance.bungee.util;
|
||||
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ProxiedSenderInfo extends SenderInfo {
|
||||
private final CommandSender sender;
|
||||
|
||||
public ProxiedSenderInfo(final CommandSender sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
return sender instanceof ProxiedPlayer ? ((ProxiedPlayer) sender).getUniqueId() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return sender.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final String permission) {
|
||||
return sender.hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(final String message) {
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
|
||||
public void sendMessage(final TextComponent textComponent) {
|
||||
sender.sendMessage(textComponent);
|
||||
}
|
||||
}
|
||||
+17
-16
@@ -1,49 +1,50 @@
|
||||
# MaintenanceBungee Plugin by KennyTV
|
||||
# MaintenanceBungee Plugin by KennyTV
|
||||
# Version ${project.version}
|
||||
|
||||
# Enables maintenance-mode.
|
||||
enable-maintenance-mode: false
|
||||
|
||||
# The message shown in the multiplayer server list motd.
|
||||
pingmessage: "&cMaintenance mode!%NEWLINE%&6We will be back soon!"
|
||||
# If you put in multiple entries, one of them will be chosen randomly on every ping.
|
||||
pingmessages:
|
||||
- "&cMaintenance mode!%NEWLINE%&6We will be back soon!"
|
||||
#- "Another entry"
|
||||
|
||||
# Is shown at the top right corner of the server in the serverlist,
|
||||
# If set to true, the message below will be shown at the top right corner of the server in the serverlist,
|
||||
# where the playercount would normally be displayed.
|
||||
# If set to false, the normal playercount will be shown.
|
||||
# Alternatively you can use '%ONLINE%' and '%MAX% if you want to include the playercount in a custom message (e.g. '&cMaintenance &7%ONLINE%&8/&7%MAX%').
|
||||
enable-playercountmessage: true
|
||||
playercountmessage: "&4Maintenance"
|
||||
|
||||
# Is shown when you move your mouse above the text at the top right corner of the server in the serverlist,
|
||||
# where the playercount would normally be displayed.
|
||||
playercounthovermessage: "&cCurrently under%NEWLINE%&cmaintenance"
|
||||
|
||||
# Will be shown, when a player tries to join on the server without the permission.
|
||||
# Is shown when a player tries to join while maintenance is enabled and they don't have the permission to bypass it.
|
||||
kickmessage: "&cThe server is currently under maintenance!%NEWLINE%Try again later!"
|
||||
|
||||
# Some self explanatory messages
|
||||
no-permission: "&cYou do not have the permission to execute that command."
|
||||
maintenance-activated: "&6Maintenance mode is now activated."
|
||||
maintenance-deactivated: "&6Maintenance mode is now deactivated."
|
||||
|
||||
starttimer-broadcast-mesage: '&8[&eMaintenance&8] &7Maintenance mode will be enabled in &6%MINUTES% minutes&7.'
|
||||
endtimer-broadcast-mesage: '&8[&eMaintenance&8] &7Maintenance mode will be disabled in &6%MINUTES% minutes&7.'
|
||||
|
||||
# If using the timer command: In what intervalls before enabling/disabling maintenance there will be a broadcast.
|
||||
timer-broadcasts-for-minutes: [60, 30, 15, 10, 5, 4, 3, 2, 1]
|
||||
timer-broadcast-for-seconds: [1200, 900, 600, 300, 120, 60, 30, 20, 10, 5, 4, 3, 2, 1]
|
||||
|
||||
# If set to true, players with the maintenance.joinnotification permission will receive a message,
|
||||
# that a player tried to join the server while maintenance is enabled.
|
||||
send-join-notification: false
|
||||
join-notification: "&e%PLAYER% &ctried to join the server."
|
||||
|
||||
# If set to true, the server icon will be changed to maintenance-icon.png in the Bungee main/base-folder.
|
||||
custom-maintenance-icon: false
|
||||
|
||||
# Only enable MySQL if you really know what you are doing.
|
||||
# You need to have a table with the two following columns: 'setting' and 'value'.
|
||||
mysql:
|
||||
use-mysql: false
|
||||
host: host
|
||||
port: 3306
|
||||
database: database
|
||||
table: tablename
|
||||
username: username
|
||||
password: password
|
||||
# A new table with this name will be created on first startup when 'use-mysql' is set to true.
|
||||
table: maintenance_settings
|
||||
# Requests to the database will only be made at least x seconds after the last request,
|
||||
# so there won't be a request on every single ping on a server with many players.
|
||||
# Set this to 0 to make a database request on every single ping.
|
||||
update-interval: 15
|
||||
File renamed without changes.
@@ -6,19 +6,13 @@
|
||||
<parent>
|
||||
<artifactId>maintenance-base</artifactId>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<version>2.2</version>
|
||||
<version>2.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>maintenance-core</artifactId>
|
||||
<name>Maintenance-Core</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.minecrell</groupId>
|
||||
<artifactId>ServerListPlus</artifactId>
|
||||
@@ -28,7 +22,7 @@
|
||||
<dependency>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<artifactId>maintenance-api</artifactId>
|
||||
<version>2.2</version>
|
||||
<version>${parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
+29
-10
@@ -1,6 +1,8 @@
|
||||
package eu.kennytv.maintenance.core;
|
||||
|
||||
import eu.kennytv.maintenance.api.IMaintenance;
|
||||
import eu.kennytv.maintenance.core.hook.ServerListPlusHook;
|
||||
import eu.kennytv.maintenance.core.runnable.MaintenanceRunnable;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
@@ -8,10 +10,11 @@ import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
public abstract class MaintenanceModePlugin {
|
||||
public abstract class MaintenanceModePlugin implements IMaintenance {
|
||||
protected final String version;
|
||||
protected int taskId;
|
||||
protected ServerListPlusHook serverListPlusHook;
|
||||
protected MaintenanceRunnable runnable;
|
||||
protected int taskId;
|
||||
private final String prefix;
|
||||
private String newestVersion;
|
||||
|
||||
@@ -20,27 +23,31 @@ public abstract class MaintenanceModePlugin {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public abstract void onDisable();
|
||||
|
||||
public abstract void setMaintenance(boolean maintenance);
|
||||
@Override
|
||||
public boolean isMaintenance() {
|
||||
return getSettings().isMaintenance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTaskRunning() {
|
||||
return taskId != 0;
|
||||
return taskId != 0 && runnable != null;
|
||||
}
|
||||
|
||||
public void setTaskId(final int taskId) {
|
||||
this.taskId = taskId;
|
||||
public void startMaintenanceRunnable(final int minutes, final boolean enable) {
|
||||
runnable = new MaintenanceRunnable(this, (Settings) getSettings(), minutes, enable);
|
||||
taskId = startMaintenanceRunnable(runnable);
|
||||
}
|
||||
|
||||
public String getNewestVersion() {
|
||||
return newestVersion;
|
||||
}
|
||||
|
||||
public abstract int schedule(Runnable runnable);
|
||||
public abstract int startMaintenanceRunnable(Runnable runnable);
|
||||
|
||||
public abstract void async(Runnable runnable);
|
||||
|
||||
@@ -50,14 +57,26 @@ public abstract class MaintenanceModePlugin {
|
||||
|
||||
public abstract void broadcast(String message);
|
||||
|
||||
public MaintenanceRunnable getRunnable() {
|
||||
return runnable;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public String formatedTimer() {
|
||||
if (!isTaskRunning()) return "-";
|
||||
final int preHours = runnable.getSecondsLeft() / 60;
|
||||
final int minutes = preHours % 60;
|
||||
final int seconds = runnable.getSecondsLeft() % 60;
|
||||
return String.format("%02d:%02d:%02d", preHours / 60, minutes, seconds);
|
||||
}
|
||||
|
||||
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 newVersion = new BufferedReader(new InputStreamReader(c.getInputStream())).readLine().replaceAll("[a-zA-Z -]", "");
|
||||
|
||||
final boolean available = !newVersion.equals(version);
|
||||
if (available)
|
||||
|
||||
@@ -1,58 +1,89 @@
|
||||
package eu.kennytv.maintenance.core;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import eu.kennytv.maintenance.api.ISettings;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class Settings {
|
||||
protected final Map<UUID, String> whitelistedPlayers = Maps.newHashMap();
|
||||
public abstract class Settings implements ISettings {
|
||||
private static final Random RANDOM = new Random();
|
||||
protected final Map<UUID, String> whitelistedPlayers = new HashMap<>();
|
||||
private final MaintenanceModePlugin plugin;
|
||||
protected boolean maintenance;
|
||||
private Set<Integer> broadcastIntervalls;
|
||||
private String timerBroadcastMessage;
|
||||
private String endtimerBroadcastMessage;
|
||||
private String pingMessage;
|
||||
private String kickMessage;
|
||||
private String joinNotification;
|
||||
private String noPermMessage;
|
||||
private String maintenanceActivated;
|
||||
private String maintenanceDeactivated;
|
||||
private List<String> pingMessages;
|
||||
private String playerCountMessage;
|
||||
private String playerCountHoverMessage;
|
||||
private boolean joinNotifications;
|
||||
private String kickMessage;
|
||||
private boolean customPlayerCountMessage;
|
||||
private boolean customMaintenanceIcon;
|
||||
private boolean joinNotifications;
|
||||
|
||||
protected Settings(final MaintenanceModePlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
protected void loadSettings() {
|
||||
timerBroadcastMessage = getConfigString("starttimer-broadcast-mesage");
|
||||
endtimerBroadcastMessage = getConfigString("endtimer-broadcast-mesage");
|
||||
pingMessage = getConfigString("pingmessage");
|
||||
kickMessage = getConfigString("kickmessage");
|
||||
joinNotification = getConfigString("join-notification");
|
||||
noPermMessage = getConfigString("no-permission");
|
||||
maintenanceActivated = getConfigString("maintenance-activated");
|
||||
maintenanceDeactivated = getConfigString("maintenance-deactivated");
|
||||
updateConfig();
|
||||
|
||||
pingMessages = getConfigList("pingmessages");
|
||||
maintenance = getConfigBoolean("enable-maintenance-mode");
|
||||
joinNotifications = getConfigBoolean("send-join-notification");
|
||||
customPlayerCountMessage = getConfigBoolean("enable-playercountmessage");
|
||||
customMaintenanceIcon = getConfigBoolean("custom-maintenance-icon");
|
||||
broadcastIntervalls = Sets.newHashSet(getBroadcastIntervallList());
|
||||
playerCountMessage = getConfigString("playercountmessage");
|
||||
playerCountHoverMessage = getConfigString("playercounthovermessage");
|
||||
joinNotifications = getConfigBoolean("send-join-notification");
|
||||
broadcastIntervalls = new HashSet<>(getConfigIntList("timer-broadcast-for-seconds"));
|
||||
playerCountMessage = getColoredString(getConfigString("playercountmessage"));
|
||||
playerCountHoverMessage = getColoredString(getConfigString("playercounthovermessage"));
|
||||
kickMessage = getColoredString(getConfigString("kickmessage"));
|
||||
if (customMaintenanceIcon)
|
||||
reloadMaintenanceIcon();
|
||||
|
||||
loadExtraSettings();
|
||||
}
|
||||
|
||||
public abstract void saveWhitelistedPlayers();
|
||||
private void updateConfig() {
|
||||
boolean fileChanged = false;
|
||||
|
||||
public abstract boolean createFiles();
|
||||
// 2.3 pingmessage -> pingmessages
|
||||
if (configContains("pingmessage")) {
|
||||
final List<String> list = new ArrayList<>();
|
||||
list.add(getConfigString("pingmessage"));
|
||||
setToConfig("pingmessages", list);
|
||||
setToConfig("pingmessage", null);
|
||||
fileChanged = true;
|
||||
}
|
||||
// 2.4 enable-playercountmessage
|
||||
if (!configContains("enable-playercountmessage")) {
|
||||
setToConfig("enable-playercountmessage", true);
|
||||
fileChanged = true;
|
||||
}
|
||||
// 2.4. timer-broadcasts-for-minutes -> timer-broadcast-for-seconds
|
||||
if (configContains("timer-broadcasts-for-minutes") || !configContains("timer-broadcast-for-seconds")) {
|
||||
setToConfig("timer-broadcast-for-seconds", Arrays.asList(1200, 900, 600, 300, 120, 60, 30, 20, 10, 5, 4, 3, 2, 1));
|
||||
setToConfig("timer-broadcasts-for-minutes", null);
|
||||
fileChanged = true;
|
||||
}
|
||||
|
||||
if (updateExtraConfig() || fileChanged) {
|
||||
saveConfig();
|
||||
reloadConfigs();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean updateExtraConfig() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract void saveWhitelistedPlayers();
|
||||
|
||||
public abstract String getConfigString(String path);
|
||||
|
||||
public abstract String getMessage(String path);
|
||||
|
||||
public abstract boolean getConfigBoolean(String path);
|
||||
|
||||
public abstract List<Integer> getBroadcastIntervallList();
|
||||
public abstract List<Integer> getConfigIntList(String path);
|
||||
|
||||
public abstract List<String> getConfigList(String path);
|
||||
|
||||
public abstract void loadExtraSettings();
|
||||
|
||||
@@ -62,38 +93,18 @@ public abstract class Settings {
|
||||
|
||||
public abstract void reloadConfigs();
|
||||
|
||||
public abstract void setConfigBoolean(String path, boolean boo);
|
||||
public abstract void setToConfig(String path, Object var);
|
||||
|
||||
public String getTimerBroadcastMessage() {
|
||||
return timerBroadcastMessage;
|
||||
public abstract boolean configContains(String path);
|
||||
|
||||
public abstract String getColoredString(String s);
|
||||
|
||||
public List<String> getPingMessages() {
|
||||
return pingMessages;
|
||||
}
|
||||
|
||||
public String getEndtimerBroadcastMessage() {
|
||||
return endtimerBroadcastMessage;
|
||||
}
|
||||
|
||||
public String getPingMessage() {
|
||||
return pingMessage;
|
||||
}
|
||||
|
||||
public String getKickMessage() {
|
||||
return kickMessage;
|
||||
}
|
||||
|
||||
public String getJoinNotification() {
|
||||
return joinNotification;
|
||||
}
|
||||
|
||||
public String getNoPermMessage() {
|
||||
return noPermMessage;
|
||||
}
|
||||
|
||||
public String getMaintenanceActivated() {
|
||||
return maintenanceActivated;
|
||||
}
|
||||
|
||||
public String getMaintenanceDeactivated() {
|
||||
return maintenanceDeactivated;
|
||||
public Set<Integer> getBroadcastIntervalls() {
|
||||
return broadcastIntervalls;
|
||||
}
|
||||
|
||||
public String getPlayerCountMessage() {
|
||||
@@ -104,30 +115,45 @@ public abstract class Settings {
|
||||
return playerCountHoverMessage;
|
||||
}
|
||||
|
||||
public String getKickMessage() {
|
||||
return kickMessage;
|
||||
}
|
||||
|
||||
public void setMaintenance(final boolean maintenance) {
|
||||
this.maintenance = maintenance;
|
||||
}
|
||||
|
||||
public String getRandomPingMessage() {
|
||||
if (pingMessages.isEmpty()) return "";
|
||||
final String s = pingMessages.size() > 1 ? pingMessages.get(RANDOM.nextInt(pingMessages.size())) : pingMessages.get(0);
|
||||
return getColoredString(s.replace("%NEWLINE%", "\n").replace("%TIMER%", plugin.formatedTimer()));
|
||||
}
|
||||
|
||||
public boolean hasCustomPlayerCountMessage() {
|
||||
return customPlayerCountMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMaintenance() {
|
||||
return maintenance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJoinNotifications() {
|
||||
return joinNotifications;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomIcon() {
|
||||
return customMaintenanceIcon;
|
||||
}
|
||||
|
||||
public Set<Integer> getBroadcastIntervalls() {
|
||||
return broadcastIntervalls;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<UUID, String> getWhitelistedPlayers() {
|
||||
return whitelistedPlayers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeWhitelistedPlayer(final UUID uuid) {
|
||||
if (!whitelistedPlayers.containsKey(uuid)) return false;
|
||||
whitelistedPlayers.remove(uuid);
|
||||
@@ -137,15 +163,19 @@ public abstract class Settings {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean removeWhitelistedPlayer(final String name) {
|
||||
if (!whitelistedPlayers.containsValue(name)) return false;
|
||||
final UUID uuid = whitelistedPlayers.entrySet().stream().filter(entry -> entry.getValue().equals(name)).findFirst().get().getKey();
|
||||
final Map.Entry<UUID, String> entry = whitelistedPlayers.entrySet().stream().filter(e -> e.getValue().equalsIgnoreCase(name)).findAny().orElse(null);
|
||||
if (entry == null) return false;
|
||||
|
||||
final UUID uuid = entry.getKey();
|
||||
whitelistedPlayers.remove(uuid);
|
||||
setWhitelist(uuid.toString(), null);
|
||||
saveWhitelistedPlayers();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addWhitelistedPlayer(final UUID uuid, final String name) {
|
||||
final boolean contains = !whitelistedPlayers.containsKey(uuid);
|
||||
whitelistedPlayers.put(uuid, name);
|
||||
|
||||
+274
@@ -0,0 +1,274 @@
|
||||
package eu.kennytv.maintenance.core.command;
|
||||
|
||||
import eu.kennytv.maintenance.core.MaintenanceModePlugin;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class MaintenanceCommand {
|
||||
protected final MaintenanceModePlugin plugin;
|
||||
protected final Settings settings;
|
||||
private final String name;
|
||||
|
||||
protected MaintenanceCommand(final MaintenanceModePlugin plugin, final Settings settings, final String name) {
|
||||
this.plugin = plugin;
|
||||
this.settings = settings;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void execute(final SenderInfo sender, final String[] args) {
|
||||
if (checkPermission(sender, "command")) return;
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("off")) {
|
||||
if (checkPermission(sender, "toggle")) return;
|
||||
|
||||
final boolean maintenance = args[0].equalsIgnoreCase("on");
|
||||
if (maintenance == plugin.isMaintenance()) {
|
||||
sender.sendMessage(settings.getMessage(maintenance ? "alreadyEnabled" : "alreadyDisabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.setMaintenance(maintenance);
|
||||
} else if (args[0].equalsIgnoreCase("reload")) {
|
||||
if (checkPermission(sender, "reload")) return;
|
||||
settings.reloadConfigs();
|
||||
sender.sendMessage(settings.getMessage("reload"));
|
||||
} else if (args[0].equalsIgnoreCase("update")) {
|
||||
if (checkPermission(sender, "update")) return;
|
||||
checkForUpdate(sender);
|
||||
} 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
|
||||
sender.sendMessage(settings.getMessage("updateFailed"));
|
||||
} else if (args[0].equalsIgnoreCase("whitelist")) {
|
||||
if (checkPermission(sender, "whitelist.list")) return;
|
||||
final Map<UUID, String> players = settings.getWhitelistedPlayers();
|
||||
if (players.isEmpty()) {
|
||||
sender.sendMessage(settings.getMessage("whitelistEmtpy"));
|
||||
} else if (players.size() == 1 && players.containsKey(UUID.fromString("a8179ff3-c201-4a75-bdaa-9d14aca6f83f"))) {
|
||||
sender.sendMessage(settings.getMessage("whitelistEmptyDefault"));
|
||||
} else {
|
||||
sender.sendMessage(settings.getMessage("whitelistedPlayers"));
|
||||
final String format = settings.getMessage("whitelistedPlayersFormat");
|
||||
players.forEach((key, value) -> sender.sendMessage(format.replace("%NAME%", value).replace("%UUID%", key.toString())));
|
||||
sender.sendMessage("");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("motd")) {
|
||||
if (checkPermission(sender, "motd")) return;
|
||||
sender.sendMessage(settings.getMessage("motdList"));
|
||||
for (int i = 0; i < settings.getPingMessages().size(); i++) {
|
||||
sender.sendMessage("§b" + (i + 1) + "§8§m---------");
|
||||
for (final String motd : settings.getColoredString(settings.getPingMessages().get(i)).split("%NEWLINE%")) {
|
||||
sender.sendMessage(motd);
|
||||
}
|
||||
}
|
||||
sender.sendMessage("§8§m----------");
|
||||
} else
|
||||
sendUsage(sender);
|
||||
} else if (args.length == 2) {
|
||||
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 (!plugin.isMaintenance())
|
||||
plugin.setMaintenance(true);
|
||||
plugin.startMaintenanceRunnable(minutes, 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 (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;
|
||||
}
|
||||
|
||||
sender.sendMessage(settings.getMessage("starttimerStarted").replace("%TIME%", plugin.getRunnable().getTime()));
|
||||
plugin.startMaintenanceRunnable(minutes, true);
|
||||
} else if (args[0].equalsIgnoreCase("timer")) {
|
||||
if (args[1].equalsIgnoreCase("abort") || args[1].equalsIgnoreCase("stop") || args[1].equalsIgnoreCase("cancel")) {
|
||||
if (checkPermission(sender, "timer")) return;
|
||||
if (!plugin.isTaskRunning()) {
|
||||
sender.sendMessage(settings.getMessage("timerNotRunning"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.cancelTask();
|
||||
sender.sendMessage(settings.getMessage("timerCancelled"));
|
||||
} else
|
||||
sendUsage(sender);
|
||||
} else if (args[0].equalsIgnoreCase("add")) {
|
||||
if (checkPermission(sender, "whitelist.add")) return;
|
||||
addPlayerToWhitelist(sender, args[1]);
|
||||
} else if (args[0].equalsIgnoreCase("remove")) {
|
||||
if (checkPermission(sender, "whitelist.remove")) return;
|
||||
removePlayerFromWhitelist(sender, args[1]);
|
||||
} else if (args[0].equalsIgnoreCase("removemotd")) {
|
||||
if (checkPermission(sender, "setmotd")) return;
|
||||
if (!isNumeric(args[1])) {
|
||||
sender.sendMessage(settings.getMessage("removeMotdUsage"));
|
||||
return;
|
||||
}
|
||||
if (settings.getPingMessages().size() < 2) {
|
||||
sender.sendMessage(settings.getMessage("removeMotdError"));
|
||||
return;
|
||||
}
|
||||
|
||||
final int index = Integer.parseInt(args[1]);
|
||||
if (index > settings.getPingMessages().size()) {
|
||||
sender.sendMessage(settings.getMessage("setMotdIndexError").replace("%MOTDS%", Integer.toString(settings.getPingMessages().size()))
|
||||
.replace("%NEWAMOUNT%", Integer.toString(settings.getPingMessages().size())));
|
||||
return;
|
||||
}
|
||||
|
||||
settings.getPingMessages().remove(index - 1);
|
||||
settings.setToConfig("pingmessages", settings.getPingMessages());
|
||||
settings.saveConfig();
|
||||
settings.reloadConfigs();
|
||||
sender.sendMessage(settings.getMessage("removedMotd").replace("%INDEX%", args[1]));
|
||||
} else
|
||||
sendUsage(sender);
|
||||
} else if (args.length > 3 && args[0].equalsIgnoreCase("setmotd")) {
|
||||
if (checkPermission(sender, "setmotd")) return;
|
||||
if (!isNumeric(args[1])) {
|
||||
sender.sendMessage(settings.getMessage("setMotdUsage"));
|
||||
return;
|
||||
}
|
||||
|
||||
final int index = Integer.parseInt(args[1]);
|
||||
if (index < 1 || index > settings.getPingMessages().size() + 1) {
|
||||
sender.sendMessage(settings.getMessage("setMotdIndexError").replace("%MOTDS%", Integer.toString(settings.getPingMessages().size()))
|
||||
.replace("%NEWAMOUNT%", Integer.toString(settings.getPingMessages().size() + 1)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isNumeric(args[2])) {
|
||||
sender.sendMessage(settings.getMessage("setMotdLineError"));
|
||||
return;
|
||||
}
|
||||
|
||||
final int line = Integer.parseInt(args[2]);
|
||||
if (line != 1 && line != 2) {
|
||||
sender.sendMessage(settings.getMessage("setMotdLineError"));
|
||||
return;
|
||||
}
|
||||
|
||||
final String message = String.join(" ", Arrays.copyOfRange(args, 3, args.length));
|
||||
final String oldMessage = index > settings.getPingMessages().size() ? "" : settings.getPingMessages().get(index - 1);
|
||||
final String newMessage;
|
||||
if (line == 1)
|
||||
newMessage = oldMessage.contains("%NEWLINE%") ?
|
||||
message + "%NEWLINE%" + oldMessage.split("%NEWLINE%", 2)[1] : message;
|
||||
else
|
||||
newMessage = oldMessage.contains("%NEWLINE%") ?
|
||||
oldMessage.split("%NEWLINE%", 2)[0] + "%NEWLINE%" + message : oldMessage + "%NEWLINE%" + message;
|
||||
|
||||
if (index > settings.getPingMessages().size())
|
||||
settings.getPingMessages().add(newMessage);
|
||||
else
|
||||
settings.getPingMessages().set(index - 1, newMessage);
|
||||
settings.setToConfig("pingmessages", settings.getPingMessages());
|
||||
settings.saveConfig();
|
||||
settings.reloadConfigs();
|
||||
sender.sendMessage(settings.getMessage("setMotd").replace("%LINE%", args[2]).replace("%INDEX%", args[1])
|
||||
.replace("%MOTD%", "§f" + settings.getColoredString(message)));
|
||||
} else
|
||||
sendUsage(sender);
|
||||
}
|
||||
|
||||
private void sendUsage(final SenderInfo sender) {
|
||||
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")) {
|
||||
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 <minutes> §7(After the given time in minutes, maintenance mode will be enabled)");
|
||||
sender.sendMessage("§6/maintenance endtimer <minutes> §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 <player> §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 <player> §7(Removes the player from the maintenance whitelist)");
|
||||
if (sender.hasPermission("maintenance.setmotd")) {
|
||||
sender.sendMessage("§6/maintenance setmotd <index> <1/2> <message> §7(Sets a motd for maintenance mode)");
|
||||
sender.sendMessage("§6/maintenance removemotd <index> §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");
|
||||
sender.sendMessage("§8===========[ §e" + name + " §8| §eVersion: §e" + plugin.getVersion() + " §8]===========");
|
||||
sender.sendMessage("");
|
||||
}
|
||||
|
||||
private boolean checkPermission(final SenderInfo sender, final String permission) {
|
||||
if (!sender.hasPermission("maintenance." + permission)) {
|
||||
sender.sendMessage(settings.getMessage("noPermission"));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private 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);
|
||||
|
||||
protected abstract void checkForUpdate(SenderInfo sender);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package eu.kennytv.maintenance.core.listener;
|
||||
|
||||
public interface IPingListener {
|
||||
|
||||
boolean loadIcon();
|
||||
}
|
||||
+32
-9
@@ -7,28 +7,51 @@ public final class MaintenanceRunnable implements Runnable {
|
||||
private final MaintenanceModePlugin plugin;
|
||||
private final Settings settings;
|
||||
private final boolean enable;
|
||||
private int minutes;
|
||||
private int seconds;
|
||||
|
||||
public MaintenanceRunnable(final MaintenanceModePlugin plugin, final Settings settings, final int minutes, final boolean enable) {
|
||||
this.plugin = plugin;
|
||||
this.settings = settings;
|
||||
this.minutes = minutes;
|
||||
this.seconds = minutes * 60;
|
||||
this.enable = enable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (minutes <= 0) {
|
||||
if (seconds == 0) {
|
||||
plugin.setMaintenance(enable);
|
||||
|
||||
plugin.cancelTask();
|
||||
} else if (settings.getBroadcastIntervalls().contains(minutes)) {
|
||||
if (plugin.isTaskRunning())
|
||||
plugin.cancelTask();
|
||||
} else if (settings.getBroadcastIntervalls().contains(seconds)) {
|
||||
if (enable)
|
||||
plugin.broadcast(settings.getTimerBroadcastMessage().replaceAll("%MINUTES%", String.valueOf(minutes)));
|
||||
plugin.broadcast(settings.getMessage("starttimerBroadcast").replaceAll("%TIME%", getTime()));
|
||||
else
|
||||
plugin.broadcast(settings.getEndtimerBroadcastMessage().replaceAll("%MINUTES%", String.valueOf(minutes)));
|
||||
plugin.broadcast(settings.getMessage("endtimerBroadcast").replaceAll("%TIME%", getTime()));
|
||||
}
|
||||
|
||||
minutes--;
|
||||
seconds--;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
final int preHours = this.seconds / 60;
|
||||
final int minutes = preHours % 60;
|
||||
final int seconds = this.seconds % 60;
|
||||
|
||||
final StringBuilder buider = new StringBuilder();
|
||||
append(buider, "hour", preHours / 60);
|
||||
append(buider, "minute", minutes);
|
||||
append(buider, "second", seconds);
|
||||
return buider.toString();
|
||||
}
|
||||
|
||||
private void append(final StringBuilder builder, final String timeUnit, final int time) {
|
||||
if (time == 0) return;
|
||||
if (builder.length() != 0)
|
||||
builder.append(" ");
|
||||
builder.append(time).append(" ").append(settings.getMessage(time == 1 ? timeUnit : timeUnit + "s"));
|
||||
}
|
||||
|
||||
public int getSecondsLeft() {
|
||||
return seconds;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package eu.kennytv.maintenance.core.util;
|
||||
|
||||
public final class MessageUtil {
|
||||
|
||||
public static boolean isNumeric(final String string) {
|
||||
try {
|
||||
Integer.parseInt(string);
|
||||
} catch (final NumberFormatException nfe) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package eu.kennytv.maintenance.core.util;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class SenderInfo {
|
||||
|
||||
public abstract UUID getUuid();
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public abstract boolean hasPermission(String permission);
|
||||
|
||||
public abstract void sendMessage(String message);
|
||||
}
|
||||
@@ -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 <minutes>"
|
||||
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 <minutes>"
|
||||
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 <index> <1/2> <message>"
|
||||
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 <index>"
|
||||
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 <player>' to add someone!"
|
||||
whitelistEmptyDefault: "&8[&eMaintenance&8] &cUse '/maintenance add <player>' 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"
|
||||
@@ -6,29 +6,29 @@
|
||||
<parent>
|
||||
<artifactId>maintenance-base</artifactId>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<version>2.2</version>
|
||||
<version>2.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>maintenance</artifactId>
|
||||
<artifactId>maintenance-parent</artifactId>
|
||||
<name>Maintenance</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<artifactId>maintenance-core</artifactId>
|
||||
<version>2.2</version>
|
||||
<version>${parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<artifactId>maintenancebungee</artifactId>
|
||||
<version>2.2</version>
|
||||
<artifactId>maintenance-bungee</artifactId>
|
||||
<version>${parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<artifactId>maintenancespigot</artifactId>
|
||||
<version>2.2</version>
|
||||
<artifactId>maintenance-spigot</artifactId>
|
||||
<version>${parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -3,14 +3,13 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<artifactId>maintenance-base</artifactId>
|
||||
<version>2.2</version>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<version>2.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>maintenancespigot</artifactId>
|
||||
<artifactId>maintenance-spigot</artifactId>
|
||||
<name>MaintenanceSpigot</name>
|
||||
|
||||
<repositories>
|
||||
@@ -28,13 +27,13 @@
|
||||
<dependency>
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<artifactId>maintenance-core</artifactId>
|
||||
<version>2.2</version>
|
||||
<version>${parent.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.13.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -46,7 +45,7 @@
|
||||
<dependency>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib-API</artifactId>
|
||||
<version>4.3.0</version>
|
||||
<version>4.4.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package eu.kennytv.maintenance.spigot;
|
||||
|
||||
import eu.kennytv.maintenance.api.IMaintenance;
|
||||
import eu.kennytv.maintenance.api.IMaintenanceBase;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public final class MaintenanceSpigotBase extends JavaPlugin implements IMaintenanceBase {
|
||||
private IMaintenance maintenance;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
maintenance = new MaintenanceSpigotPlugin(this);
|
||||
}
|
||||
|
||||
File getPluginFile() {
|
||||
return getFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMaintenance getApi() {
|
||||
return maintenance;
|
||||
}
|
||||
}
|
||||
+11
-35
@@ -6,9 +6,7 @@ import eu.kennytv.maintenance.api.MaintenanceSpigotAPI;
|
||||
import eu.kennytv.maintenance.core.MaintenanceModePlugin;
|
||||
import eu.kennytv.maintenance.core.hook.ServerListPlusHook;
|
||||
import eu.kennytv.maintenance.spigot.command.MaintenanceSpigotCommand;
|
||||
import eu.kennytv.maintenance.spigot.listener.PacketListener;
|
||||
import eu.kennytv.maintenance.spigot.listener.PlayerLoginListener;
|
||||
import eu.kennytv.maintenance.spigot.listener.ServerListPingListener;
|
||||
import eu.kennytv.maintenance.spigot.metrics.MetricsLite;
|
||||
import net.minecrell.serverlistplus.core.plugin.ServerListPlusPlugin;
|
||||
import org.bukkit.Server;
|
||||
@@ -19,25 +17,17 @@ import java.io.File;
|
||||
|
||||
/**
|
||||
* @author KennyTV
|
||||
* @since 1.0
|
||||
* @since 2.0
|
||||
*/
|
||||
public final class MaintenanceSpigotPlugin extends MaintenanceModePlugin implements IMaintenance {
|
||||
public final class MaintenanceSpigotPlugin extends MaintenanceModePlugin {
|
||||
private final MaintenanceSpigotBase plugin;
|
||||
private final SettingsSpigot settings;
|
||||
|
||||
// Great update for the Spigot version of the plugin as well as performance improvements and bugfixes in both versions!
|
||||
// If you have ProtocolLib installed, you can set a custom server icon while maintenance is enabled, also the playercount-message and the playercount-hover-message are now available (as it has already been in the Bungee version)!
|
||||
// The Spigot version is now much more compatible with other motd-changing plugins, such as SexyMotd!
|
||||
// In the BungeeCord version of the plugin, the "/maintenance remove <player>" command now also works for offline players
|
||||
// Fixed some other issues with the ProtocolLib integration
|
||||
// Minor textfix for the updatemessage in the Spigot version
|
||||
// General performance improvements
|
||||
|
||||
MaintenanceSpigotPlugin(final MaintenanceSpigotBase plugin) {
|
||||
super("§8[§eMaintenanceSpigot§8] ", plugin.getDescription().getVersion());
|
||||
|
||||
this.plugin = plugin;
|
||||
settings = new SettingsSpigot(plugin);
|
||||
settings = new SettingsSpigot(this, plugin);
|
||||
|
||||
plugin.getLogger().info("Plugin by KennyTV");
|
||||
plugin.getCommand("maintenancespigot").setExecutor(new MaintenanceSpigotCommand(this, settings));
|
||||
@@ -47,29 +37,19 @@ public final class MaintenanceSpigotPlugin extends MaintenanceModePlugin impleme
|
||||
|
||||
new MetricsLite(plugin);
|
||||
|
||||
if (pm.getPlugin("ProtocolLib") != null)
|
||||
new PacketListener(this, plugin, settings);
|
||||
else
|
||||
pm.registerEvents(new ServerListPingListener(plugin, settings), plugin);
|
||||
|
||||
// ServerListPlus integration
|
||||
final Plugin serverListPlus = pm.getPlugin("ServerListPlus");
|
||||
if (serverListPlus != null) {
|
||||
serverListPlusHook = new ServerListPlusHook(((ServerListPlusPlugin) serverListPlus).getCore());
|
||||
serverListPlusHook.setEnabled(!settings.isMaintenance());
|
||||
plugin.getLogger().info("Enabled ServerListPlus integration!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (!getServer().getOnlinePlayers().isEmpty())
|
||||
plugin.getLogger().warning("This plugin does not fully support reloads, consider restarting the server as soon as possible.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaintenance(final boolean maintenance) {
|
||||
settings.setMaintenance(maintenance);
|
||||
settings.setConfigBoolean("enable-maintenance-mode", maintenance);
|
||||
settings.setToConfig("enable-maintenance-mode", maintenance);
|
||||
settings.saveConfig();
|
||||
settings.reloadConfigs();
|
||||
|
||||
@@ -83,19 +63,14 @@ public final class MaintenanceSpigotPlugin extends MaintenanceModePlugin impleme
|
||||
getServer().getOnlinePlayers().stream()
|
||||
.filter(p -> !p.hasPermission("maintenance.bypass") && !settings.getWhitelistedPlayers().containsKey(p.getUniqueId()))
|
||||
.forEach(p -> p.kickPlayer(settings.getKickMessage().replace("%NEWLINE%", "\n")));
|
||||
getServer().broadcastMessage(settings.getMaintenanceActivated());
|
||||
getServer().broadcastMessage(settings.getMessage("maintenanceActivated"));
|
||||
} else
|
||||
getServer().broadcastMessage(settings.getMaintenanceDeactivated());
|
||||
getServer().broadcastMessage(settings.getMessage("maintenanceDeactivated"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMaintenance() {
|
||||
return settings.isMaintenance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int schedule(final Runnable runnable) {
|
||||
return getServer().getScheduler().scheduleSyncRepeatingTask(plugin, runnable, 0, 1200);
|
||||
public int startMaintenanceRunnable(final Runnable runnable) {
|
||||
return getServer().getScheduler().scheduleSyncRepeatingTask(plugin, runnable, 0, 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,7 +81,8 @@ public final class MaintenanceSpigotPlugin extends MaintenanceModePlugin impleme
|
||||
@Override
|
||||
public void cancelTask() {
|
||||
getServer().getScheduler().cancelTask(taskId);
|
||||
setTaskId(0);
|
||||
runnable = null;
|
||||
taskId = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,156 @@
|
||||
package eu.kennytv.maintenance.spigot;
|
||||
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import eu.kennytv.maintenance.core.listener.IPingListener;
|
||||
import eu.kennytv.maintenance.spigot.listener.PacketListener;
|
||||
import eu.kennytv.maintenance.spigot.listener.ServerListPingListener;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class SettingsSpigot extends Settings {
|
||||
private final MaintenanceSpigotBase plugin;
|
||||
private final IPingListener pingListener;
|
||||
private FileConfiguration config;
|
||||
private FileConfiguration language;
|
||||
private FileConfiguration whitelist;
|
||||
|
||||
SettingsSpigot(final MaintenanceSpigotPlugin pl, final MaintenanceSpigotBase plugin) {
|
||||
super(pl);
|
||||
this.plugin = plugin;
|
||||
|
||||
final PluginManager pm = plugin.getServer().getPluginManager();
|
||||
if (pm.getPlugin("ProtocolLib") != null) {
|
||||
pingListener = new PacketListener(plugin, this);
|
||||
} else {
|
||||
final ServerListPingListener listener = new ServerListPingListener(plugin, this);
|
||||
pm.registerEvents(listener, plugin);
|
||||
pingListener = listener;
|
||||
}
|
||||
|
||||
if (!plugin.getDataFolder().exists())
|
||||
plugin.getDataFolder().mkdirs();
|
||||
createFile("spigot-config.yml");
|
||||
createFile("language.yml");
|
||||
createFile("WhitelistedPlayers.yml");
|
||||
|
||||
reloadConfigs();
|
||||
}
|
||||
|
||||
private void createFile(final String name) {
|
||||
final File file = new File(plugin.getDataFolder(), name);
|
||||
if (!file.exists()) {
|
||||
try (final InputStream in = plugin.getResource(name)) {
|
||||
Files.copy(in, file.toPath());
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException("Unable to create " + name + " file for Maintenance!", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveConfig() {
|
||||
try {
|
||||
config.save(new File(plugin.getDataFolder(), "spigot-config.yml"));
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveWhitelistedPlayers() {
|
||||
try {
|
||||
whitelist.save(new File(plugin.getDataFolder(), "WhitelistedPlayers.yml"));
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@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));
|
||||
whitelist = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "WhitelistedPlayers.yml"));
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException("Unable to load Maintenance files!", e);
|
||||
}
|
||||
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadExtraSettings() {
|
||||
whitelistedPlayers.clear();
|
||||
whitelist.getKeys(false).forEach(key -> whitelistedPlayers.put(UUID.fromString(key), whitelist.getString(key)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWhitelist(final String uuid, final String s) {
|
||||
whitelist.set(uuid, s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigString(final String path) {
|
||||
final String s = config.getString(path);
|
||||
if (s == null) {
|
||||
plugin.getLogger().warning("The config is missing the following string: " + path);
|
||||
return "null";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage(final String path) {
|
||||
final String s = language.getString(path);
|
||||
if (s == null) {
|
||||
plugin.getLogger().warning("The language file is missing the following string: " + path);
|
||||
return "null";
|
||||
}
|
||||
return ChatColor.translateAlternateColorCodes('&', s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getConfigBoolean(final String path) {
|
||||
return config.getBoolean(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getConfigIntList(final String path) {
|
||||
return config.getIntegerList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getConfigList(final String path) {
|
||||
return config.getStringList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setToConfig(final String path, final Object var) {
|
||||
config.set(path, var);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configContains(final String path) {
|
||||
return config.contains(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColoredString(final String message) {
|
||||
return ChatColor.translateAlternateColorCodes('&', message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reloadMaintenanceIcon() {
|
||||
return pingListener.loadIcon();
|
||||
}
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
package eu.kennytv.maintenance.spigot.command;
|
||||
|
||||
import eu.kennytv.maintenance.core.command.MaintenanceCommand;
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import eu.kennytv.maintenance.spigot.MaintenanceSpigotPlugin;
|
||||
import eu.kennytv.maintenance.spigot.SettingsSpigot;
|
||||
import eu.kennytv.maintenance.spigot.util.BukkitSenderInfo;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public final class MaintenanceSpigotCommand extends MaintenanceCommand implements CommandExecutor {
|
||||
|
||||
public MaintenanceSpigotCommand(final MaintenanceSpigotPlugin plugin, final SettingsSpigot settings) {
|
||||
super(plugin, settings, "MaintenanceSpigot");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String s, final String[] args) {
|
||||
execute(new BukkitSenderInfo(sender), args);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addPlayerToWhitelist(final SenderInfo sender, final String name) {
|
||||
final Player selected = Bukkit.getPlayer(name);
|
||||
if (selected != null) {
|
||||
if (settings.addWhitelistedPlayer(selected.getUniqueId(), selected.getName()))
|
||||
sender.sendMessage(settings.getMessage("whitelistAdded").replace("%PLAYER%", selected.getName()));
|
||||
else
|
||||
sender.sendMessage(settings.getMessage("whitelistAlreadyAdded").replace("%PLAYER%", selected.getName()));
|
||||
return;
|
||||
}
|
||||
|
||||
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(name);
|
||||
if (!offlinePlayer.hasPlayedBefore()) {
|
||||
sender.sendMessage(settings.getMessage("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (settings.addWhitelistedPlayer(offlinePlayer.getUniqueId(), offlinePlayer.getName()))
|
||||
sender.sendMessage(settings.getMessage("whitelistAdded").replace("%PLAYER%", offlinePlayer.getName()));
|
||||
else
|
||||
sender.sendMessage(settings.getMessage("whitelistAlreadyAdded").replace("%PLAYER%", offlinePlayer.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removePlayerFromWhitelist(final SenderInfo sender, final String name) {
|
||||
final Player selected = Bukkit.getPlayer(name);
|
||||
if (selected != null) {
|
||||
if (settings.removeWhitelistedPlayer(selected.getUniqueId()))
|
||||
sender.sendMessage(settings.getMessage("whitelistRemoved").replace("%PLAYER%", selected.getName()));
|
||||
else
|
||||
sender.sendMessage(settings.getMessage("whitelistNotFound"));
|
||||
return;
|
||||
}
|
||||
|
||||
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(name);
|
||||
if (!offlinePlayer.hasPlayedBefore()) {
|
||||
sender.sendMessage(settings.getMessage("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (settings.removeWhitelistedPlayer(offlinePlayer.getUniqueId()))
|
||||
sender.sendMessage(settings.getMessage("whitelistRemoved").replace("%PLAYER%", offlinePlayer.getName()));
|
||||
else
|
||||
sender.sendMessage(settings.getMessage("whitelistNotFound"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkForUpdate(final SenderInfo sender) {
|
||||
if (plugin.updateAvailable()) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cNewest version available: §aVersion " + plugin.getNewestVersion() + "§c, you're on §a" + plugin.getVersion());
|
||||
sender.sendMessage(plugin.getPrefix() + "§c§lWARNING: §cYou will have to restart the server to prevent further issues and to complete the update!" +
|
||||
" If you can't do that, don't update!");
|
||||
sender.sendMessage(plugin.getPrefix() + "§eUse §c§l/maintenance forceupdate §eto update!");
|
||||
} else
|
||||
sender.sendMessage(plugin.getPrefix() + "§aYou already have the latest version of the plugin!");
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package eu.kennytv.maintenance.spigot.listener;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
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.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class PacketListener implements IPingListener {
|
||||
private final MaintenanceSpigotBase pl;
|
||||
private WrappedServerPing.CompressedImage image;
|
||||
|
||||
public PacketListener(final MaintenanceSpigotBase base, final SettingsSpigot settings) {
|
||||
this.pl = base;
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(base, ListenerPriority.HIGHEST,
|
||||
PacketType.Status.Server.SERVER_INFO) {
|
||||
@Override
|
||||
public void onPacketSending(final PacketEvent event) {
|
||||
if (!settings.isMaintenance()) return;
|
||||
|
||||
final WrappedServerPing ping = event.getPacket().getServerPings().read(0);
|
||||
ping.setMotD(settings.getRandomPingMessage());
|
||||
|
||||
if (settings.hasCustomPlayerCountMessage()) {
|
||||
ping.setVersionProtocol(0);
|
||||
ping.setVersionName(settings.getPlayerCountMessage()
|
||||
.replace("%ONLINE%", Integer.toString(pl.getServer().getOnlinePlayers().size()))
|
||||
.replace("%MAX%", Integer.toString(pl.getServer().getMaxPlayers())));
|
||||
}
|
||||
|
||||
final List<WrappedGameProfile> players = Lists.newArrayList();
|
||||
for (final String string : settings.getPlayerCountHoverMessage().split("%NEWLINE%"))
|
||||
players.add(new WrappedGameProfile(UUID.randomUUID(), string));
|
||||
ping.setPlayers(players);
|
||||
|
||||
if (settings.hasCustomIcon() && image != null)
|
||||
ping.setFavicon(image);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadIcon() {
|
||||
try {
|
||||
image = WrappedServerPing.CompressedImage.fromPng(ImageIO.read(new File("maintenance-icon.png")));
|
||||
} catch (final Exception e) {
|
||||
pl.getLogger().warning("§4Could not load 'maintenance-icon.png' - did you create one in your Spigot folder (not the plugins folder)?");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+12
-13
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -13,14 +14,13 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
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<UUID> notifiedPlayers = Sets.newHashSet();
|
||||
|
||||
public PlayerLoginListener(final MaintenanceSpigotPlugin plugin, final SettingsSpigot settings) {
|
||||
this.plugin = plugin;
|
||||
@@ -39,21 +39,19 @@ public final class PlayerLoginListener implements Listener {
|
||||
|
||||
if (settings.isJoinNotifications())
|
||||
Bukkit.getOnlinePlayers().stream().filter(player -> player.hasPermission("maintenance.joinnotification"))
|
||||
.forEach(player -> player.sendMessage(settings.getJoinNotification().replace("%PLAYER%", p.getName())));
|
||||
.forEach(player -> player.sendMessage(settings.getMessage("joinNotification").replace("%PLAYER%", p.getName())));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!p.hasPermission("maintenance.admin")) return;
|
||||
if (!p.hasPermission("maintenance.admin") || notifiedPlayers.contains(p.getUniqueId())) return;
|
||||
|
||||
plugin.async(() -> {
|
||||
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();
|
||||
|
||||
if (!newVersion.equals(plugin.getVersion())) {
|
||||
p.sendMessage(plugin.getPrefix() + "§cThere is a newer version available: §aVersion " + newVersion + "§c, you're still on §a" + plugin.getVersion());
|
||||
if (plugin.updateAvailable()) {
|
||||
p.sendMessage(plugin.getPrefix() + "§cThere is a newer version available: §aVersion " + plugin.getNewestVersion() + "§c, you're on §a" + plugin.getVersion());
|
||||
notifiedPlayers.add(p.getUniqueId());
|
||||
|
||||
try {
|
||||
final TextComponent tc1 = new TextComponent(TextComponent.fromLegacyText(plugin.getPrefix()));
|
||||
final TextComponent tc2 = new TextComponent(TextComponent.fromLegacyText("§cDownload it at: §6https://www.spigotmc.org/resources/maintenancemode.40699/"));
|
||||
final TextComponent click = new TextComponent(TextComponent.fromLegacyText(" §7§l§o(CLICK ME)"));
|
||||
@@ -63,8 +61,9 @@ public final class PlayerLoginListener implements Listener {
|
||||
tc1.addExtra(click);
|
||||
|
||||
p.spigot().sendMessage(tc1);
|
||||
} catch (final Exception e) {
|
||||
p.sendMessage(plugin.getPrefix() + "§cDownload it at: §6https://www.spigotmc.org/resources/maintenancemode.40699/");
|
||||
}
|
||||
} catch (final Exception ignored) {
|
||||
}
|
||||
});
|
||||
}
|
||||
+15
-15
@@ -1,8 +1,8 @@
|
||||
package eu.kennytv.maintenance.spigot.listener;
|
||||
|
||||
import eu.kennytv.maintenance.core.listener.IPingListener;
|
||||
import eu.kennytv.maintenance.spigot.MaintenanceSpigotBase;
|
||||
import eu.kennytv.maintenance.spigot.SettingsSpigot;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -12,16 +12,14 @@ import org.bukkit.util.CachedServerIcon;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.File;
|
||||
|
||||
public final class ServerListPingListener implements Listener {
|
||||
public final class ServerListPingListener implements Listener, IPingListener {
|
||||
private final MaintenanceSpigotBase plugin;
|
||||
private final SettingsSpigot settings;
|
||||
private final File icon;
|
||||
private CachedServerIcon serverIcon;
|
||||
|
||||
public ServerListPingListener(final MaintenanceSpigotBase plugin, final SettingsSpigot settings) {
|
||||
this.plugin = plugin;
|
||||
this.settings = settings;
|
||||
icon = new File("maintenance-icon.png");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@@ -29,18 +27,20 @@ public final class ServerListPingListener implements Listener {
|
||||
if (!settings.isMaintenance()) return;
|
||||
|
||||
event.setMaxPlayers(0);
|
||||
event.setMotd(settings.getPingMessage().replace("%NEWLINE%", "\n"));
|
||||
event.setMotd(settings.getRandomPingMessage());
|
||||
|
||||
if (settings.hasCustomIcon()) {
|
||||
if (serverIcon != null)
|
||||
event.setServerIcon(serverIcon);
|
||||
else {
|
||||
try {
|
||||
serverIcon = Bukkit.loadServerIcon(ImageIO.read(icon));
|
||||
} catch (final Exception e) {
|
||||
plugin.getLogger().warning("§4Could not load 'maintenance-icon.png' - did you create one in your Spigot/Bukkit folder (not the plugins folder)?");
|
||||
}
|
||||
}
|
||||
if (settings.hasCustomIcon() && serverIcon != null)
|
||||
event.setServerIcon(serverIcon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadIcon() {
|
||||
try {
|
||||
serverIcon = plugin.getServer().loadServerIcon(ImageIO.read(new File("maintenance-icon.png")));
|
||||
} catch (final Exception e) {
|
||||
plugin.getLogger().warning("§4Could not load 'maintenance-icon.png' - did you create one in your Spigot folder (not the plugins folder)?");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -17,6 +17,7 @@ import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collection;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
@@ -227,7 +228,7 @@ public final class MetricsLite {
|
||||
}
|
||||
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
final GZIPOutputStream gzip = new GZIPOutputStream(outputStream);
|
||||
gzip.write(str.getBytes("UTF-8"));
|
||||
gzip.write(str.getBytes(StandardCharsets.UTF_8));
|
||||
gzip.close();
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package eu.kennytv.maintenance.spigot.util;
|
||||
|
||||
import eu.kennytv.maintenance.core.util.SenderInfo;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class BukkitSenderInfo extends SenderInfo {
|
||||
private final CommandSender sender;
|
||||
|
||||
public BukkitSenderInfo(final CommandSender sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
return sender instanceof Player ? ((Player) sender).getUniqueId() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return sender.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final String permission) {
|
||||
return sender.hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(final String message) {
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
}
|
||||
File renamed without changes.
+11
-13
@@ -1,38 +1,36 @@
|
||||
# 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.
|
||||
enable-maintenance-mode: false
|
||||
|
||||
# The message shown in the multiplayer server list motd.
|
||||
pingmessage: "&cMaintenance mode!%NEWLINE%&6We will be back soon!"
|
||||
# If you put in multiple entries, one of them will be chosen randomly on every ping.
|
||||
pingmessages:
|
||||
- "&cMaintenance mode!%NEWLINE%&6We will be back soon!"
|
||||
#- "Another entry"
|
||||
|
||||
# Is shown at the top right corner of the server in the serverlist,
|
||||
# If set to true, the message below will be shown at the top right corner of the server in the serverlist,
|
||||
# where the playercount would normally be displayed.
|
||||
# If set to false, the normal playercount will be shown.
|
||||
# Alternatively you can use '%ONLINE%' and '%MAX% if you want to include the playercount in a custom message (e.g. '&cMaintenance &7%ONLINE%&8/&7%MAX%').
|
||||
enable-playercountmessage: true
|
||||
playercountmessage: "&4Maintenance"
|
||||
|
||||
# Is shown when you move your mouse above the text at the top right corner of the server in the serverlist,
|
||||
# where the playercount would normally be displayed.
|
||||
playercounthovermessage: "&cCurrently under%NEWLINE%&cmaintenance"
|
||||
|
||||
# Will be shown, when a player tries to join on the server without the permission.
|
||||
# Is shown when a player tries to join while maintenance is enabled and they don't have the permission to bypass it.
|
||||
kickmessage: "&cThe server is currently under maintenance!%NEWLINE%Try again later!"
|
||||
|
||||
# Some self explanatory messages
|
||||
no-permission: "&cYou do not have the permission to execute that command."
|
||||
maintenance-activated: "&6Maintenance mode is now activated."
|
||||
maintenance-deactivated: "&6Maintenance mode is now deactivated."
|
||||
|
||||
starttimer-broadcast-mesage: '&8[&eMaintenance&8] &7Maintenance mode will be enabled in &6%MINUTES% minutes&7.'
|
||||
endtimer-broadcast-mesage: '&8[&eMaintenance&8] &7Maintenance mode will be disabled in &6%MINUTES% minutes&7.'
|
||||
|
||||
# If using the timer command: In what intervalls before enabling/disabling maintenance there will be a broadcast.
|
||||
timer-broadcasts-for-minutes: [60, 30, 15, 10, 5, 4, 3, 2, 1]
|
||||
timer-broadcast-for-seconds: [1200, 900, 600, 300, 120, 60, 30, 20, 10, 5, 4, 3, 2, 1]
|
||||
|
||||
# If set to true, players with the maintenance.joinnotification permission will receive a message,
|
||||
# that a player tried to join the server while maintenance is enabled.
|
||||
send-join-notification: false
|
||||
join-notification: "&e%PLAYER% &ctried to join the server."
|
||||
|
||||
# If set to true, the server icon will be changed to maintenance-icon.png in the Bungee main/base-folder.
|
||||
custom-maintenance-icon: false
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
package eu.kennytv.maintenance.bungee;
|
||||
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author KennyTV
|
||||
* @since 2.1
|
||||
*/
|
||||
public final class MaintenanceBungeeBase extends Plugin {
|
||||
private MaintenanceBungeePlugin plugin;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin = new MaintenanceBungeePlugin(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
plugin.onDisable();
|
||||
}
|
||||
|
||||
File getPluginFile() {
|
||||
return getFile();
|
||||
}
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
package eu.kennytv.maintenance.bungee;
|
||||
|
||||
import eu.kennytv.maintenance.api.ISettings;
|
||||
import eu.kennytv.maintenance.bungee.mysql.MySQL;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.YamlConfiguration;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class SettingsBungee extends Settings implements ISettings {
|
||||
private static final String UPDATE = "INSERT INTO %s (setting, value) VALUES (?, ?) ON DUPLICATE KEY UPDATE value = ?";
|
||||
private final MaintenanceBungeeBase plugin;
|
||||
|
||||
private final MySQL mySQL;
|
||||
private final String mySQLTable;
|
||||
|
||||
private Configuration config;
|
||||
private Configuration whitelist;
|
||||
|
||||
SettingsBungee(final MaintenanceBungeeBase plugin) {
|
||||
this.plugin = plugin;
|
||||
reloadConfigs(createFiles());
|
||||
|
||||
final Configuration mySQLSection = config.getSection("mysql");
|
||||
if (mySQLSection.getBoolean("use-mysql", false)) {
|
||||
// Needed: One column named "setting" (primary key), another named "value".
|
||||
plugin.getLogger().info("Trying to open database connection...");
|
||||
mySQL = new MySQL(mySQLSection.getString("host"),
|
||||
mySQLSection.getInt("port"),
|
||||
mySQLSection.getString("username"),
|
||||
mySQLSection.getString("password"),
|
||||
mySQLSection.getString("database"));
|
||||
mySQLTable = mySQLSection.getString("table");
|
||||
plugin.getLogger().info("Done!");
|
||||
} else {
|
||||
mySQL = null;
|
||||
mySQLTable = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfigs() {
|
||||
reloadConfigs(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveConfig() {
|
||||
final File file = new File(plugin.getDataFolder(), "bungee-config.yml");
|
||||
try {
|
||||
YamlConfiguration.getProvider(YamlConfiguration.class).save(config, new OutputStreamWriter(new FileOutputStream(file), "UTF8"));
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException("Unable to save bungee-config.yml!", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveWhitelistedPlayers() {
|
||||
final File file = new File(plugin.getDataFolder(), "WhitelistedPlayers.yml");
|
||||
try {
|
||||
YamlConfiguration.getProvider(YamlConfiguration.class).save(whitelist, file);
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException("Unable to save WhitelistedPlayers.yml!", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void reloadConfigs(final boolean createdNewWhitelist) {
|
||||
final File file = new File(plugin.getDataFolder(), "bungee-config.yml");
|
||||
try {
|
||||
config = YamlConfiguration.getProvider(YamlConfiguration.class).load(new InputStreamReader(new FileInputStream(file), "UTF8"));
|
||||
whitelist = YamlConfiguration.getProvider(YamlConfiguration.class).load(new File(plugin.getDataFolder(), "WhitelistedPlayers.yml"));
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException("Unable to load bungee-config.yml!", e);
|
||||
}
|
||||
|
||||
if (createdNewWhitelist) {
|
||||
whitelist.set("a8179ff3-c201-4a75-bdaa-9d14aca6f83f", "KennyTV");
|
||||
saveWhitelistedPlayers();
|
||||
}
|
||||
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadExtraSettings() {
|
||||
whitelistedPlayers.clear();
|
||||
whitelist.getKeys().forEach(key -> whitelistedPlayers.put(UUID.fromString(key), whitelist.getString(key)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWhitelist(final String uuid, final String s) {
|
||||
whitelist.set(uuid, s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createFiles() {
|
||||
if (!plugin.getDataFolder().exists())
|
||||
plugin.getDataFolder().mkdirs();
|
||||
|
||||
final File file = new File(plugin.getDataFolder(), "bungee-config.yml");
|
||||
if (!file.exists()) {
|
||||
try (final InputStream in = plugin.getResourceAsStream("bungee-config.yml")) {
|
||||
Files.copy(in, file.toPath());
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException("Unable to create bungee-config.yml file for MaintenanceBungee", e);
|
||||
}
|
||||
}
|
||||
|
||||
boolean createdNewWhitelist = false;
|
||||
final File whitelistFile = new File(plugin.getDataFolder(), "WhitelistedPlayers.yml");
|
||||
if (!whitelistFile.exists()) {
|
||||
createdNewWhitelist = true;
|
||||
try {
|
||||
whitelistFile.createNewFile();
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException("Unable to create WhitelistedPlayers.yml file for MaintenanceBungee", e);
|
||||
}
|
||||
}
|
||||
|
||||
return createdNewWhitelist;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigString(final String path) {
|
||||
return ChatColor.translateAlternateColorCodes('&', config.getString(path));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getConfigBoolean(final String path) {
|
||||
return config.getBoolean(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getBroadcastIntervallList() {
|
||||
return config.getIntList("timer-broadcasts-for-minutes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfigBoolean(final String path, final boolean var) {
|
||||
config.set(path, var);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMaintenance() {
|
||||
if (mySQL != null) {
|
||||
mySQL.executeQuery("SELECT * FROM " + mySQLTable + " WHERE setting LIKE ?", rs -> {
|
||||
try {
|
||||
maintenance = rs.next() && Boolean.parseBoolean(rs.getString("value"));
|
||||
} catch (final SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, "maintenance");
|
||||
}
|
||||
|
||||
return maintenance;
|
||||
}
|
||||
|
||||
public void setMaintenanceToSQL(final boolean maintenance) {
|
||||
plugin.getProxy().getScheduler().runAsync(plugin, () ->
|
||||
mySQL.executeUpdate(String.format(UPDATE, mySQLTable), res -> {
|
||||
}, "maintenance", String.valueOf(maintenance), String.valueOf(maintenance)));
|
||||
this.maintenance = maintenance;
|
||||
}
|
||||
|
||||
public MySQL getMySQL() {
|
||||
return mySQL;
|
||||
}
|
||||
}
|
||||
-198
@@ -1,198 +0,0 @@
|
||||
package eu.kennytv.maintenance.bungee.command;
|
||||
|
||||
import eu.kennytv.maintenance.bungee.MaintenanceBungeePlugin;
|
||||
import eu.kennytv.maintenance.bungee.SettingsBungee;
|
||||
import eu.kennytv.maintenance.core.runnable.MaintenanceRunnable;
|
||||
import eu.kennytv.maintenance.core.util.MessageUtil;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class MaintenanceBungeeCommand extends Command {
|
||||
private final MaintenanceBungeePlugin plugin;
|
||||
private final SettingsBungee settings;
|
||||
|
||||
public MaintenanceBungeeCommand(final MaintenanceBungeePlugin plugin, final SettingsBungee settings) {
|
||||
super("maintenance", "", "maintenancebungee");
|
||||
this.plugin = plugin;
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
public void execute(final CommandSender sender, final String[] args) {
|
||||
if (!sender.hasPermission("maintenance.admin")) {
|
||||
sender.sendMessage(settings.getNoPermMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("on")) {
|
||||
plugin.setMaintenance(true);
|
||||
} else if (args[0].equalsIgnoreCase("off")) {
|
||||
plugin.setMaintenance(false);
|
||||
} else if (args[0].equalsIgnoreCase("reload")) {
|
||||
if (!sender.hasPermission("maintenance.reload")) {
|
||||
sender.sendMessage(settings.getNoPermMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
settings.reloadConfigs();
|
||||
sender.sendMessage(plugin.getPrefix() + "§aReloaded config.yml");
|
||||
} else if (args[0].equalsIgnoreCase("update")) {
|
||||
if (!sender.hasPermission("maintenance.admin")) {
|
||||
sender.sendMessage(settings.getNoPermMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
checkForUpdate(sender);
|
||||
} else if (args[0].equals("forceupdate")) {
|
||||
if (!sender.hasPermission("maintenance.admin")) {
|
||||
sender.sendMessage(settings.getNoPermMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(plugin.getPrefix() + "§c§lDownloading update...");
|
||||
|
||||
if (plugin.installUpdate())
|
||||
sender.sendMessage(plugin.getPrefix() + "§a§lThe update was successful! To prevent issues with tasks and to complete the update, you have to restart the proxy!");
|
||||
else
|
||||
sender.sendMessage(plugin.getPrefix() + "§4Failed!");
|
||||
} else if (args[0].equalsIgnoreCase("whitelist")) {
|
||||
final Map<UUID, String> players = settings.getWhitelistedPlayers();
|
||||
if (players.isEmpty()) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThe maintenance whitelist is empty! Use \"/maintenance add <player>\" to add someone!");
|
||||
} else if (players.size() == 1 && players.containsKey(UUID.fromString("a8179ff3-c201-4a75-bdaa-9d14aca6f83f"))) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cUse \"/maintenance add <player>\" to add someone. Alternatively, you can add the uuid of a player to the WhitelistedPlayers.yml as seen in the example in the file!");
|
||||
} else {
|
||||
sender.sendMessage("§6Whitelisted players for maintenance:");
|
||||
players.forEach((key, value) -> sender.sendMessage("§8- §e" + value));
|
||||
sender.sendMessage("");
|
||||
}
|
||||
} else
|
||||
sendUsage(sender);
|
||||
} else if (args.length == 2) {
|
||||
if (args[0].equalsIgnoreCase("endtimer")) {
|
||||
if (!MessageUtil.isNumeric(args[1])) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§6/maintenance timer endtimer <minutes>");
|
||||
return;
|
||||
}
|
||||
if (plugin.isTaskRunning()) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThere's already a starttimer scheduled!");
|
||||
return;
|
||||
}
|
||||
|
||||
final int minutes = Integer.parseInt(args[1]);
|
||||
if (minutes > 40320) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThe number has to be less than 40320 (28 days)!");
|
||||
return;
|
||||
}
|
||||
if (minutes < 1) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThink about running a timer for a negative amount of minutes. Doesn't work §othat §r§cwell.");
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.setMaintenance(true);
|
||||
sender.sendMessage(plugin.getPrefix() + "§aStarted timer: §7Maintenance mode will be deactivated in §6" + minutes + " minutes§7.");
|
||||
plugin.setTaskId(plugin.schedule(new MaintenanceRunnable(plugin, settings, minutes, false)));
|
||||
} else if (args[0].equalsIgnoreCase("starttimer")) {
|
||||
if (!MessageUtil.isNumeric(args[1])) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§6/maintenance timer starttimer <minutes>");
|
||||
return;
|
||||
}
|
||||
if (plugin.isTaskRunning()) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThere's already running a timer!");
|
||||
return;
|
||||
}
|
||||
|
||||
final int minutes = Integer.parseInt(args[1]);
|
||||
if (minutes > 40320) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThe number has to be less than 40320 (28 days)!");
|
||||
return;
|
||||
}
|
||||
if (minutes < 1) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThink about running a timer for a negative amount of minutes. Doesn't work §othat §r§cwell.");
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(plugin.getPrefix() + "§aStarted timer: §7Maintenance mode will be activated in §6" + minutes + " minutes§7.");
|
||||
plugin.setTaskId(plugin.schedule(new MaintenanceRunnable(plugin, settings, minutes, true)));
|
||||
} else if (args[0].equalsIgnoreCase("timer")) {
|
||||
if (args[1].equalsIgnoreCase("abort") || args[1].equalsIgnoreCase("stop") || args[1].equalsIgnoreCase("cancel")) {
|
||||
if (!plugin.isTaskRunning()) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThere's currently no running timer.");
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.cancelTask();
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThe timer has been disabled.");
|
||||
} else
|
||||
sendUsage(sender);
|
||||
} else if (args[0].equalsIgnoreCase("add")) {
|
||||
final ProxiedPlayer player = plugin.getProxy().getPlayer(args[1]);
|
||||
if (player == null) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThere's no player online with that name.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (settings.addWhitelistedPlayer(player.getUniqueId(), player.getName()))
|
||||
sender.sendMessage(plugin.getPrefix() + "§aAdded §b" + player.getName() + " §ato the maintenance whitelist!");
|
||||
else
|
||||
sender.sendMessage(plugin.getPrefix() + "§b" + player.getName() + " §calready is in the maintenance whitelist!");
|
||||
} else if (args[0].equalsIgnoreCase("remove")) {
|
||||
final ProxiedPlayer player = plugin.getProxy().getPlayer(args[1]);
|
||||
if (player == null) {
|
||||
if (settings.removeWhitelistedPlayer(args[1].toLowerCase()))
|
||||
sender.sendMessage(plugin.getPrefix() + "§aRemoved §b" + args[1].toLowerCase() + " §afrom the maintenance whitelist!");
|
||||
else
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThere is no player with that name in the maintenance whitelist!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (settings.removeWhitelistedPlayer(player.getUniqueId()))
|
||||
sender.sendMessage(plugin.getPrefix() + "§aRemoved §b" + player.getName() + " §afrom the maintenance whitelist!");
|
||||
else
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThis player is not in the maintenance whitelist!");
|
||||
} else
|
||||
sendUsage(sender);
|
||||
} else
|
||||
sendUsage(sender);
|
||||
}
|
||||
|
||||
private void sendUsage(final CommandSender sender) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage("§8===========[ §eMaintenanceBungee §8| §eVersion: §e" + plugin.getVersion() + " §8]===========");
|
||||
sender.sendMessage("§6/maintenance reload §7(Reloads the config file)");
|
||||
sender.sendMessage("§6/maintenance on §7(Enables maintenance mode");
|
||||
sender.sendMessage("§6/maintenance off §7(Disables maintenance mode)");
|
||||
sender.sendMessage("§6/maintenance starttimer <minutes> §7(After the given time in minutes, maintenance mode will be enabled. Broadcast settings for the timer can be found in the config)");
|
||||
sender.sendMessage("§6/maintenance endtimer <minutes> §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)");
|
||||
sender.sendMessage("§6/maintenance add <player> §7(Adds the player to the maintenance whitelist, so they can join the server even though maintenance is enabled)");
|
||||
sender.sendMessage("§6/maintenance remove <player> §7(Removes the player from the maintenance whitelist)");
|
||||
sender.sendMessage("§6/maintenance whitelist §7(Shows all whitelisted players for the maintenance mode)");
|
||||
sender.sendMessage("§6/maintenance update §7(Remotely downloads the newest version of the plugin onto your server)");
|
||||
sender.sendMessage("§9Created by: KennyTV");
|
||||
sender.sendMessage("§8===========[ §eMaintenanceBungee §8| §eVersion: §e" + plugin.getVersion() + " §8]===========");
|
||||
sender.sendMessage("");
|
||||
}
|
||||
|
||||
private void checkForUpdate(final CommandSender sender) {
|
||||
if (plugin.updateAvailable()) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cNewest version available: §aVersion " + plugin.getNewestVersion() + "§c, you're still on §a" + plugin.getVersion());
|
||||
sender.sendMessage(plugin.getPrefix() + "§c§lWARNING: §cYou will have to restart the proxy to prevent further issues and to complete the update!" +
|
||||
" If you can't do that, don't update!");
|
||||
final TextComponent tc = new TextComponent("§6× §8[§aUpdate§8]");
|
||||
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/maintenance forceupdate"));
|
||||
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§aClick here to update the plugin")));
|
||||
tc.addExtra(" §8< §7Or use the command §c/maintenace forceupdate");
|
||||
|
||||
sender.sendMessage(tc);
|
||||
} else
|
||||
sender.sendMessage(plugin.getPrefix() + "§aYou already have the latest version of the plugin!");
|
||||
}
|
||||
}
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
package eu.kennytv.maintenance.bungee.listener;
|
||||
|
||||
import eu.kennytv.maintenance.bungee.MaintenanceBungeeBase;
|
||||
import eu.kennytv.maintenance.bungee.SettingsBungee;
|
||||
import net.md_5.bungee.api.Favicon;
|
||||
import net.md_5.bungee.api.ServerPing;
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.event.EventPriority;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public final class ProxyPingListener implements Listener {
|
||||
private final MaintenanceBungeeBase plugin;
|
||||
private final SettingsBungee settings;
|
||||
private final File icon;
|
||||
private Favicon favicon;
|
||||
|
||||
public ProxyPingListener(final MaintenanceBungeeBase plugin, final SettingsBungee settings) {
|
||||
this.plugin = plugin;
|
||||
this.settings = settings;
|
||||
icon = new File("maintenance-icon.png");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void proxyPing(final ProxyPingEvent event) {
|
||||
if (!settings.isMaintenance()) return;
|
||||
|
||||
final ServerPing ping = event.getResponse();
|
||||
ping.setVersion(new ServerPing.Protocol(settings.getPlayerCountMessage(), 1));
|
||||
ping.setDescription(settings.getPingMessage().replace("%NEWLINE%", "\n"));
|
||||
ping.setPlayers(new ServerPing.Players(0, 0, new ServerPing.PlayerInfo[]{
|
||||
new ServerPing.PlayerInfo(settings.getPlayerCountHoverMessage().replace("%NEWLINE%", "\n"), "")
|
||||
}));
|
||||
|
||||
if (settings.hasCustomIcon()) {
|
||||
if (favicon != null)
|
||||
ping.setFavicon(favicon);
|
||||
else {
|
||||
try {
|
||||
favicon = Favicon.create(ImageIO.read(icon));
|
||||
} catch (IOException | IllegalArgumentException e) {
|
||||
plugin.getLogger().warning("§4Could not load 'maintenance-icon.png' - did you create one in your Bungee folder (not the plugins folder)?");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
package eu.kennytv.maintenance.spigot;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author KennyTV
|
||||
* @since 2.1
|
||||
*/
|
||||
public final class MaintenanceSpigotBase extends JavaPlugin {
|
||||
private MaintenanceSpigotPlugin plugin;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin = new MaintenanceSpigotPlugin(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
plugin.onDisable();
|
||||
}
|
||||
|
||||
File getPluginFile() {
|
||||
return getFile();
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
package eu.kennytv.maintenance.spigot;
|
||||
|
||||
import eu.kennytv.maintenance.api.ISettings;
|
||||
import eu.kennytv.maintenance.core.Settings;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class SettingsSpigot extends Settings implements ISettings {
|
||||
private final MaintenanceSpigotBase plugin;
|
||||
private FileConfiguration config;
|
||||
private FileConfiguration whitelist;
|
||||
|
||||
SettingsSpigot(final MaintenanceSpigotBase plugin) {
|
||||
this.plugin = plugin;
|
||||
createFiles();
|
||||
reloadConfigs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveConfig() {
|
||||
try {
|
||||
config.save(new File(plugin.getDataFolder(), "spigot-config.yml"));
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveWhitelistedPlayers() {
|
||||
try {
|
||||
whitelist.save(new File(plugin.getDataFolder(), "WhitelistedPlayers.yml"));
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfigs() {
|
||||
final File file = new File(plugin.getDataFolder(), "spigot-config.yml");
|
||||
try {
|
||||
config = YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(file), "UTF8"));
|
||||
whitelist = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "WhitelistedPlayers.yml"));
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException("Unable to load spigot-config.yml!", e);
|
||||
}
|
||||
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadExtraSettings() {
|
||||
whitelistedPlayers.clear();
|
||||
whitelist.getKeys(false).forEach(key -> whitelistedPlayers.put(UUID.fromString(key), whitelist.getString(key)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWhitelist(final String uuid, final String s) {
|
||||
whitelist.set(uuid, s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createFiles() {
|
||||
if (!plugin.getDataFolder().exists())
|
||||
plugin.getDataFolder().mkdirs();
|
||||
|
||||
final File file = new File(plugin.getDataFolder(), "spigot-config.yml");
|
||||
if (!file.exists()) {
|
||||
try (final InputStream in = plugin.getResource("spigot-config.yml")) {
|
||||
Files.copy(in, file.toPath());
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException("Unable to create spigot-config.yml file for Maintenance!", e);
|
||||
}
|
||||
}
|
||||
|
||||
final File whitelistFile = new File(plugin.getDataFolder(), "WhitelistedPlayers.yml");
|
||||
if (!whitelistFile.exists()) {
|
||||
try (final InputStream in = plugin.getResource("WhitelistedPlayers.yml")) {
|
||||
Files.copy(in, whitelistFile.toPath());
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException("Unable to create WhitelistedPlayers.yml file for Maintenance!", e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigString(final String path) {
|
||||
return ChatColor.translateAlternateColorCodes('&', config.getString(path));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getConfigBoolean(final String path) {
|
||||
return config.getBoolean(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getBroadcastIntervallList() {
|
||||
return config.getIntegerList("timer-broadcasts-for-minutes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfigBoolean(final String path, final boolean var) {
|
||||
config.set(path, var);
|
||||
}
|
||||
}
|
||||
-206
@@ -1,206 +0,0 @@
|
||||
package eu.kennytv.maintenance.spigot.command;
|
||||
|
||||
import eu.kennytv.maintenance.core.runnable.MaintenanceRunnable;
|
||||
import eu.kennytv.maintenance.core.util.MessageUtil;
|
||||
import eu.kennytv.maintenance.spigot.MaintenanceSpigotPlugin;
|
||||
import eu.kennytv.maintenance.spigot.SettingsSpigot;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class MaintenanceSpigotCommand implements CommandExecutor {
|
||||
private final MaintenanceSpigotPlugin plugin;
|
||||
private final SettingsSpigot settings;
|
||||
|
||||
public MaintenanceSpigotCommand(final MaintenanceSpigotPlugin plugin, final SettingsSpigot settings) {
|
||||
this.plugin = plugin;
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String s, final String[] args) {
|
||||
if (!sender.hasPermission("maintenance.admin")) {
|
||||
sender.sendMessage(settings.getNoPermMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("on")) {
|
||||
plugin.setMaintenance(true);
|
||||
} else if (args[0].equalsIgnoreCase("off")) {
|
||||
plugin.setMaintenance(false);
|
||||
} else if (args[0].equalsIgnoreCase("reload")) {
|
||||
if (!sender.hasPermission("maintenance.reload")) {
|
||||
sender.sendMessage(settings.getNoPermMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
settings.reloadConfigs();
|
||||
sender.sendMessage(plugin.getPrefix() + "§aReloaded spigot-config.yml");
|
||||
} else if (args[0].equalsIgnoreCase("update")) {
|
||||
if (!sender.hasPermission("maintenance.admin")) {
|
||||
sender.sendMessage(settings.getNoPermMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
checkForUpdate(sender);
|
||||
} else if (args[0].equals("forceupdate")) {
|
||||
if (!sender.hasPermission("maintenance.admin")) {
|
||||
sender.sendMessage(settings.getNoPermMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(plugin.getPrefix() + "§c§lDownloading update...");
|
||||
|
||||
if (plugin.installUpdate())
|
||||
sender.sendMessage(plugin.getPrefix() + "§a§lThe update was successful! To prevent issues with tasks and to complete the update, you have to restart the server!");
|
||||
else
|
||||
sender.sendMessage(plugin.getPrefix() + "§4Failed!");
|
||||
} else if (args[0].equalsIgnoreCase("whitelist")) {
|
||||
final Map<UUID, String> players = settings.getWhitelistedPlayers();
|
||||
if (players.isEmpty()) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThe maintenance whitelist is empty! Use \"/maintenance add <player>\" to add someone!");
|
||||
} else if (players.size() == 1 && players.containsKey(UUID.fromString("a8179ff3-c201-4a75-bdaa-9d14aca6f83f"))) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cUse \"/maintenance add <player>\" to add someone. Alternatively, you can add the uuid of a player to the WhitelistedPlayers.yml as seen in the example in the file!");
|
||||
} else {
|
||||
sender.sendMessage("§6Whitelisted players for maintenance:");
|
||||
players.forEach((key, value) -> sender.sendMessage("§8- §e" + value));
|
||||
sender.sendMessage("");
|
||||
}
|
||||
} else
|
||||
sendUsage(sender);
|
||||
} else if (args.length == 2) {
|
||||
if (args[0].equalsIgnoreCase("endtimer")) {
|
||||
if (!MessageUtil.isNumeric(args[1])) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§6/maintenance timer endtimer <minutes>");
|
||||
return true;
|
||||
}
|
||||
if (plugin.isTaskRunning()) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThere's already a starttimer scheduled!");
|
||||
return true;
|
||||
}
|
||||
|
||||
final int minutes = Integer.parseInt(args[1]);
|
||||
if (minutes > 40320) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThe number has to be less than 40320 (28 days)!");
|
||||
return true;
|
||||
}
|
||||
if (minutes < 1) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThink about running a timer for a negative amount of minutes. Doesn't work §othat §r§cwell.");
|
||||
return true;
|
||||
}
|
||||
|
||||
plugin.setMaintenance(true);
|
||||
sender.sendMessage(plugin.getPrefix() + "§aStarted timer: §7Maintenance mode will be deactivated in §6" + minutes + " minutes§7.");
|
||||
plugin.setTaskId(plugin.schedule(new MaintenanceRunnable(plugin, settings, minutes, false)));
|
||||
} else if (args[0].equalsIgnoreCase("starttimer")) {
|
||||
if (!MessageUtil.isNumeric(args[1])) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§6/maintenance timer starttimer <minutes>");
|
||||
return true;
|
||||
}
|
||||
if (plugin.isTaskRunning()) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThere's already running a timer!");
|
||||
return true;
|
||||
}
|
||||
|
||||
final int minutes = Integer.parseInt(args[1]);
|
||||
if (minutes > 40320) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThe number has to be less than 40320 (28 days)!");
|
||||
return true;
|
||||
}
|
||||
if (minutes < 1) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThink about running a timer for a negative amount of minutes. Doesn't work §othat §r§cwell.");
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(plugin.getPrefix() + "§aStarted timer: §7Maintenance mode will be activated in §6" + minutes + " minutes§7.");
|
||||
plugin.setTaskId(plugin.schedule(new MaintenanceRunnable(plugin, settings, minutes, true)));
|
||||
} else if (args[0].equalsIgnoreCase("timer")) {
|
||||
if (args[1].equalsIgnoreCase("abort") || args[1].equalsIgnoreCase("stop") || args[1].equalsIgnoreCase("cancel")) {
|
||||
if (!plugin.isTaskRunning()) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThere's currently no running timer.");
|
||||
return true;
|
||||
}
|
||||
|
||||
plugin.cancelTask();
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThe timer has been disabled.");
|
||||
} else
|
||||
sendUsage(sender);
|
||||
} else if (args[0].equalsIgnoreCase("add")) {
|
||||
final Player player = Bukkit.getPlayer(args[1]);
|
||||
if (player != null) {
|
||||
settings.addWhitelistedPlayer(player.getUniqueId(), player.getName());
|
||||
sender.sendMessage(plugin.getPrefix() + "§aAdded §b" + player.getName() + " §ato the maintenance whitelist!");
|
||||
return true;
|
||||
}
|
||||
|
||||
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(args[1]);
|
||||
if (!offlinePlayer.hasPlayedBefore()) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cNo player with this name has played on this server before.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (settings.addWhitelistedPlayer(offlinePlayer.getUniqueId(), offlinePlayer.getName()))
|
||||
sender.sendMessage(plugin.getPrefix() + "§aAdded §b" + offlinePlayer.getName() + " §ato the maintenance whitelist!");
|
||||
else
|
||||
sender.sendMessage(plugin.getPrefix() + "§b" + player.getName() + " §calready is in the maintenance whitelist!");
|
||||
} else if (args[0].equalsIgnoreCase("remove")) {
|
||||
final Player player = Bukkit.getPlayer(args[1]);
|
||||
if (player != null) {
|
||||
settings.removeWhitelistedPlayer(player.getUniqueId());
|
||||
sender.sendMessage(plugin.getPrefix() + "§aRemoved §b" + player.getName() + " §afrom the maintenance whitelist!");
|
||||
return true;
|
||||
}
|
||||
|
||||
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(args[1]);
|
||||
if (!offlinePlayer.hasPlayedBefore()) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cNo player with this name has played on this server before.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (settings.removeWhitelistedPlayer(offlinePlayer.getUniqueId()))
|
||||
sender.sendMessage(plugin.getPrefix() + "§aRemoved §b" + offlinePlayer.getName() + " §afrom the maintenance whitelist!");
|
||||
else
|
||||
sender.sendMessage(plugin.getPrefix() + "§cThis player is not in the maintenance whitelist!");
|
||||
} else
|
||||
sendUsage(sender);
|
||||
} else
|
||||
sendUsage(sender);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendUsage(final CommandSender sender) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage("§8===========[ §eMaintenanceSpigot §8| §eVersion: §e" + plugin.getVersion() + " §8]===========");
|
||||
sender.sendMessage("§6/maintenance reload §7(Reloads the config file)");
|
||||
sender.sendMessage("§6/maintenance on §7(Enables maintenance mode");
|
||||
sender.sendMessage("§6/maintenance off §7(Disables maintenance mode)");
|
||||
sender.sendMessage("§6/maintenance starttimer <minutes> §7(After the given time in minutes, maintenance mode will be enabled. Broadcast settings for the timer can be found in the config)");
|
||||
sender.sendMessage("§6/maintenance endtimer <minutes> §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)");
|
||||
sender.sendMessage("§6/maintenance add <player> §7(Adds the player to the maintenance whitelist, so they can join the server even though maintenance is enabled)");
|
||||
sender.sendMessage("§6/maintenance remove <player> §7(Removes the player from the maintenance whitelist)");
|
||||
sender.sendMessage("§6/maintenance whitelist §7(Shows all whitelisted players for the maintenance mode)");
|
||||
sender.sendMessage("§6/maintenance update §7(Remotely downloads the newest version of the plugin onto your server)");
|
||||
sender.sendMessage("§9Created by: KennyTV");
|
||||
sender.sendMessage("§8===========[ §eMaintenanceSpigot §8| §eVersion: §e" + plugin.getVersion() + " §8]===========");
|
||||
sender.sendMessage("");
|
||||
}
|
||||
|
||||
private void checkForUpdate(final CommandSender sender) {
|
||||
if (plugin.updateAvailable()) {
|
||||
sender.sendMessage(plugin.getPrefix() + "§cNewest version available: §aVersion " + plugin.getNewestVersion() + "§c, you're still on §a" + plugin.getVersion());
|
||||
sender.sendMessage(plugin.getPrefix() + "§c§lWARNING: §cYou will have to restart the server to prevent further issues and to complete the update!" +
|
||||
" If you can't do that, don't update!");
|
||||
sender.sendMessage(plugin.getPrefix() + "§eUse §c§l/maintenance forceupdate §eto update!");
|
||||
} else
|
||||
sender.sendMessage(plugin.getPrefix() + "§aYou already have the latest version of the plugin!");
|
||||
}
|
||||
}
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
package eu.kennytv.maintenance.spigot.listener;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
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.spigot.MaintenanceSpigotBase;
|
||||
import eu.kennytv.maintenance.spigot.MaintenanceSpigotPlugin;
|
||||
import eu.kennytv.maintenance.spigot.SettingsSpigot;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class PacketListener {
|
||||
private final File icon;
|
||||
private WrappedServerPing.CompressedImage image;
|
||||
|
||||
public PacketListener(final MaintenanceSpigotPlugin pl, final MaintenanceSpigotBase base, final SettingsSpigot settings) {
|
||||
icon = new File("maintenance-icon.png");
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(base, ListenerPriority.HIGHEST,
|
||||
PacketType.Status.Server.OUT_SERVER_INFO) {
|
||||
@Override
|
||||
public void onPacketSending(final PacketEvent event) {
|
||||
if (!pl.isMaintenance()) return;
|
||||
|
||||
final WrappedServerPing ping = event.getPacket().getServerPings().read(0);
|
||||
ping.setVersionProtocol(0);
|
||||
ping.setMotD(settings.getPingMessage().replace("%NEWLINE%", "\n"));
|
||||
ping.setVersionName(settings.getPlayerCountMessage());
|
||||
|
||||
final List<WrappedGameProfile> players = Lists.newArrayList();
|
||||
for (final String string : settings.getPlayerCountHoverMessage().split("%NEWLINE%"))
|
||||
players.add(new WrappedGameProfile(UUID.randomUUID(), string));
|
||||
ping.setPlayers(players);
|
||||
|
||||
if (settings.hasCustomIcon()) {
|
||||
if (image != null)
|
||||
ping.setFavicon(image);
|
||||
else {
|
||||
try {
|
||||
image = WrappedServerPing.CompressedImage.fromPng(ImageIO.read(icon));
|
||||
} catch (final Exception e) {
|
||||
pl.getServer().getLogger().warning("§4Could not load 'maintenance-icon.png' - did you create one in your Spigot/Bukkit folder (not the plugins folder)?");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -12,5 +12,5 @@ Issues can be created here: https://github.com/KennyTV/Maintenance/issues
|
||||
|
||||
### MaintenanceMode API
|
||||
|
||||
There's no official repo, yet, but you can manually add the Maintenance-API.jar file to your library (can be downloaded in the code section, https://github.com/KennyTV/Maintenance/raw/master/Maintenance-API.jar).
|
||||
By using MaintenanceBungeeAPI#getAPI or MaintenanceSpigotAPI#getAPI (depending on what server you are using the plugin) you can get some base methods. Documentation and/or a repo might come, if a few people ask me to.
|
||||
There's no official maven repo, yet, but you can manually add the Maintenance-API.jar file to your library (can be downloaded in the code section, https://github.com/KennyTV/Maintenance/raw/master/Maintenance-API.jar).
|
||||
By using MaintenanceBungeeAPI#getAPI or MaintenanceSpigotAPI#getAPI (depending on what server you are using the plugin) you can get some base methods. A rough documentation can be found here https://github.com/KennyTV/Maintenance/tree/master/Maintenance-API/src/main/java/eu/kennytv/maintenance/api
|
||||
@@ -6,15 +6,15 @@
|
||||
|
||||
<groupId>eu.kennytv</groupId>
|
||||
<artifactId>maintenance-base</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>2.2</version>
|
||||
<version>2.4</version>
|
||||
<name>Maintenance</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>maintenance</module>
|
||||
<module>maintenance-parent</module>
|
||||
<module>maintenance-core</module>
|
||||
<module>maintenancespigot</module>
|
||||
<module>maintenancebungee</module>
|
||||
<module>maintenance-spigot</module>
|
||||
<module>maintenance-bungee</module>
|
||||
<module>maintenance-api</module>
|
||||
</modules>
|
||||
|
||||
@@ -31,13 +31,21 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.hikari</pattern>
|
||||
<shadedPattern>eu.kennytv.lib.hikari</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
Reference in new issue
Block a user