1.0.4-f6f3eup

This commit is contained in:
TntTastisch 2023-10-08 13:06:22 +02:00
parent 620430f2e8
commit 4843e25d64
12 changed files with 502 additions and 394 deletions

2
.gitattributes vendored
View File

@ -1,2 +0,0 @@
# Auto detect text files and perform LF normalization
* text=auto

109
.gitignore vendored
View File

@ -1,3 +1,11 @@
# User-specific stuff
.idea/
*.ipr
*.iws
# IntelliJ
out/
# Compiled class file
*.class
@ -7,9 +15,6 @@
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
@ -21,3 +26,101 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
.flattened-pom.xml
.classpath
.settings/
.project
bin/
/target/
# Common working directory
run/
.idea/discord.xml
.idea/inspectionProfiles/Project_Default.xml
.idea/misc.xml
.idea/vcs.xml
.idea/discord.xml
.idea/inspectionProfiles/Project_Default.xml
.idea/misc.xml
.idea/vcs.xml
.idea/encodings.xml
.idea/misc.xml

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../McPlugins4You/api/Waterfall/BungeeCord.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>

View File

@ -1,2 +0,0 @@
Manifest-Version: 1.0

80
pom.xml Normal file
View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.tnttastisch.SpigotMC</groupId>
<artifactId>BungeeMaintenanceSystem</artifactId>
<version>1.0.4</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.8-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.8-SNAPSHOT</version>
<type>javadoc</type>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<copy file="${project.build.directory}/${project.build.finalName}.jar" tofile="${project.build.directory}/${project.artifactId}.jar" />
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>

View File

@ -1,204 +0,0 @@
package de.TntTastisch.Spigot;
import de.TntTastisch.Spigot.commands.MaintenanceCMD;
import de.TntTastisch.Spigot.listener.ServerPingListener;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
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 net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.api.plugin.PluginManager;
import net.md_5.bungee.conf.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
public class Maintenance extends Plugin implements Listener {
public static boolean maintenance;
public static String prefix;
public static String permissions;
public static String noperms;
public static String reloaded;
public static String version;
public static String maintenancejoin;
public static String reason;
public static String noreason;
public static String MaintenanceKickMessage;
public static String MaintenanceMessage;
public static String Enabled;
public static String Disabled;
public static String alreadyEnabled;
public static String alreadyDisabled;
public static String FirstMOTD;
public static String SecondMOTD;
public static String MaintenanceFirstMOTD;
public static String MaintenanceSecondMOTD;
public static File file;
public static net.md_5.bungee.config.Configuration config;
@Override
public void onEnable() {
loadConfiguration();
PluginManager pluginManager = BungeeCord.getInstance().getPluginManager();
pluginManager.registerCommand(this, new MaintenanceCMD());
pluginManager.registerListener(this, new ServerPingListener());
BungeeCord.getInstance().getConsole().sendMessage(new TextComponent("[]===========[ Maintenance ]===========[]"));
BungeeCord.getInstance().getConsole().sendMessage(new TextComponent("[] §aThis Plugin was successfully activated."));
BungeeCord.getInstance().getConsole().sendMessage(new TextComponent("[] §aAuthor: TntTastisch."));
BungeeCord.getInstance().getConsole().sendMessage(new TextComponent("[] §aVersion: " + getDescription().getVersion() + "."));
BungeeCord.getInstance().getConsole().sendMessage(new TextComponent("[]===========[ Maintenance ]===========[]"));
}
@Override
public void onDisable() {
BungeeCord.getInstance().getConsole().sendMessage(new TextComponent("[]===========[ Maintenance ]===========[]"));
BungeeCord.getInstance().getConsole().sendMessage(new TextComponent("[] §cThis Plugin was successfully deactivated."));
BungeeCord.getInstance().getConsole().sendMessage(new TextComponent("[] §cAuthor: TntTastisch."));
BungeeCord.getInstance().getConsole().sendMessage(new TextComponent("[] §cVersion: " + getDescription().getVersion() + "."));
BungeeCord.getInstance().getConsole().sendMessage(new TextComponent("[]===========[ Maintenance ]===========[]"));
}
public void loadConfiguration() {
if(!getDataFolder().exists()){
getDataFolder().mkdir();
}
file = new File(getDataFolder().getPath(), "config.yml");
try {
if(!file.exists()) {
file.createNewFile();
}
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
} catch (IOException e) {
e.printStackTrace();
}
if(!config.contains("Maintenance.enable")) {
config.set("Maintenance.enable", false);
}
if(!config.contains("Maintenance.prefix")) {
config.set("Maintenance.prefix", "&8[&4Maintenance&8] &7");
}
if(!config.contains("Maintenance.permissions")) {
config.set("Maintenance.permissions", "maintenance.use");
}
if(!config.contains("Maintenance.noperms")) {
config.set("Maintenance.noperms", "&cYou have no rights to this command.");
}
if(!config.contains("Maintenance.reloaded")) {
config.set("Maintenance.reloaded", "&7The configuration was &asuccessfully &7reloaded.");
}
if(!config.contains("Maintenance.maintenancejoin")) {
config.set("Maintenance.maintenancejoin", "maintenance.bypass");
}
if(!config.contains("Maintenance.reason")) {
config.set("Maintenance.reason", "&7Cunstruction");
}
if(!config.contains("Maintenance.noreason")) {
config.set("Maintenance.noreason", "&cPlease specify a maintenance reason!");
}
if(!config.contains("Messages.Version")) {
config.set("Messages.Version", "&4Maintenance");
}
if(!config.contains("Messages.MaintenanceKickMessage")) {
config.set("Messages.MaintenanceKickMessage", "&8>> &4ServerNetwork.com &8<<\n&7This network is now under maintenance\n\n&7Reason&8: &e%reason%\n\n&7You want to contact us?\n&7TeamSpeak &8>> &ets.yourservernetwork.com\n&7Homepage &8>> &ewww.yourservernetwork.com");
}
if(!config.contains("Messages.MaintenanceMessage")) {
config.set("Messages.MaintenanceMessage", "&8>> &4ServerNetwork.com &8<<\n&7This network is currently under maintenance\n\n&7Reason&8: &e%reason%\n\n&7You want to contact us?\n&7TeamSpeak &8>> &ets.yourservernetwork.com\n&7Homepage &8>> &ewww.yourservernetwork.com");
}
if(!config.contains("Messages.Enabled")) {
config.set("Messages.Enabled", "&7The maintenancemode was successfully &aenabled&7 for %reason%");
}
if(!config.contains("Messages.Disabled")) {
config.set("Messages.Disabled", "&7The maintenancemode was successfully &cdisabled&7.");
}
if(!config.contains("Messages.alreadyEnable")) {
config.set("Messages.alreadyEnable", "&cThe maintenancemode is currently &aenabled&7.");
}
if(!config.contains("Messages.alreadyDisabled")) {
config.set("Messages.alreadyDisabled", "&cThe maintenancemode is currently &cdisabled&7.");
}
if(!config.contains("MOTD.FirstMOTD")) {
config.set("MOTD.FirstMOTD", "&4ServerNetwork.com &8- &fServer Network &8[&e1.8-1.12&8]");
}
if(!config.contains("MOTD.SecondMOTD")) {
config.set("MOTD.SecondMOTD", "&aWe are online again &8| &4Maintenance by TntTastisch");
}
if(!config.contains("MOTD.MaintenanceFirstMOTD")) {
config.set("MOTD.MaintenanceFirstMOTD", "&4ServerNetwork.com &8- &fServer Network &8[&e1.8-1.12&8]");
}
if(!config.contains("MOTD.MaintenanceSecondMOTD")) {
config.set("MOTD.MaintenanceSecondMOTD", "&8[&c!&8] &7This network is currently under &4maintenance&7!");
}
maintenance = config.getBoolean("Maintenance.enable");
prefix = config.getString("Maintenance.prefix").replaceAll("&", "§");
permissions = config.getString("Maintenance.permissions").replaceAll("&", "§");
noperms = config.getString("Maintenance.noperms").replaceAll("&", "§");
reloaded = config.getString("Maintenance.reloaded").replaceAll("&", "§");
version = config.getString("Messages.Version").replaceAll("&", "§");
maintenancejoin = config.getString("Maintenance.maintenancejoin").replaceAll("&", "§");
reason = config.getString("Maintenance.reason").replaceAll("&", "§");
noreason = config.getString("Maintenance.noreason").replaceAll("&", "§");
MaintenanceKickMessage = config.getString("Messages.MaintenanceKickMessage").replaceAll("&", "§").replace("%reason%", reason);
MaintenanceMessage = config.getString("Messages.MaintenanceMessage").replaceAll("&", "§").replace("%reason%", reason);
Enabled = config.getString("Messages.Enabled").replaceAll("&", "§").replace("%reason%", reason);
Disabled = config.getString("Messages.Disabled").replaceAll("&", "§");
alreadyEnabled = config.getString("Messages.alreadyEnable").replaceAll("&", "§");
alreadyDisabled = config.getString("Messages.alreadyDisabled").replaceAll("&", "§");
FirstMOTD = config.getString("MOTD.FirstMOTD").replaceAll("&", "§");
SecondMOTD = config.getString("MOTD.SecondMOTD").replaceAll("&", "§");
MaintenanceFirstMOTD = config.getString("MOTD.MaintenanceFirstMOTD").replaceAll("&", "§");
MaintenanceSecondMOTD = config.getString("MOTD.MaintenanceSecondMOTD").replaceAll("&", "§");
try {
ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -1,152 +0,0 @@
package de.TntTastisch.Spigot.commands;
import de.TntTastisch.Spigot.Maintenance;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
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 net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
import sun.applet.Main;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.nio.charset.MalformedInputException;
import java.util.concurrent.TimeUnit;
public class MaintenanceCMD extends Command {
public MaintenanceCMD() {
super("maintenance");
}
@Override
public void execute(CommandSender commandSender, String[] strings) {
if (commandSender.hasPermission(Maintenance.permissions)) {
if (strings.length == 0) {
commandSender.sendMessage(new TextComponent("§8§m============§r§8[ §4§lMaintenance §8]§8§m============"));
commandSender.sendMessage(new TextComponent("§8>> §e/maintenance reload"));
commandSender.sendMessage(new TextComponent("§8>> §e/maintenance <Reason>"));
commandSender.sendMessage(new TextComponent("§8>> §e/maintenance off"));
commandSender.sendMessage(new TextComponent("§8§m============§r§8[ §4§lMaintenance §8]§8§m============"));
} else if (strings.length == 1) {
if (strings[0].equalsIgnoreCase("reload")) {
try {
Maintenance.config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(Maintenance.file);
} catch (IOException e) {
e.printStackTrace();
}
Maintenance.maintenance = Maintenance.config.getBoolean("Maintenance.enable");
Maintenance.prefix = Maintenance.config.getString("Maintenance.prefix").replaceAll("&", "§");
Maintenance.permissions = Maintenance.config.getString("Maintenance.permissions").replaceAll("&", "§");
Maintenance.noperms = Maintenance.config.getString("Maintenance.noperms").replaceAll("&", "§");
Maintenance.reloaded = Maintenance.config.getString("Maintenance.reloaded").replaceAll("&", "§");
Maintenance.version = Maintenance.config.getString("Messages.Version").replaceAll("&", "§");
Maintenance.maintenancejoin = Maintenance.config.getString("Maintenance.maintenancejoin").replaceAll("&", "§");
Maintenance.reason = Maintenance.config.getString("Maintenance.reason").replaceAll("&", "§");
Maintenance.noreason = Maintenance.config.getString("Maintenance.noreason").replaceAll("&", "§");
Maintenance.MaintenanceKickMessage = Maintenance.config.getString("Messages.MaintenanceKickMessage").replaceAll("&", "§").replace("%reason%", Maintenance.reason);
Maintenance.MaintenanceMessage = Maintenance.config.getString("Messages.MaintenanceMessage").replaceAll("&", "§").replace("%reason%", Maintenance.reason);
Maintenance.Enabled = Maintenance.config.getString("Messages.Enabled").replaceAll("&", "§").replace("%reason%", Maintenance.reason);
Maintenance.Disabled = Maintenance.config.getString("Messages.Disabled").replaceAll("&", "§");
Maintenance.alreadyEnabled = Maintenance.config.getString("Messages.alreadyEnable").replaceAll("&", "§");
Maintenance.alreadyDisabled = Maintenance.config.getString("Messages.alreadyDisabled").replaceAll("&", "§");
Maintenance.FirstMOTD = Maintenance.config.getString("MOTD.FirstMOTD").replaceAll("&", "§");
Maintenance.SecondMOTD = Maintenance.config.getString("MOTD.SecondMOTD").replaceAll("&", "§");
Maintenance.MaintenanceFirstMOTD = Maintenance.config.getString("MOTD.MaintenanceFirstMOTD").replaceAll("&", "§");
Maintenance.MaintenanceSecondMOTD = Maintenance.config.getString("MOTD.MaintenanceSecondMOTD").replaceAll("&", "§");
commandSender.sendMessage(Maintenance.prefix + Maintenance.reloaded);
} else if (strings[0].equalsIgnoreCase("off")) {
if (!Maintenance.config.getBoolean("Maintenance.enable") == false) {
Maintenance.config.set("Maintenance.enable", false);
Maintenance.maintenance = false;
try {
ConfigurationProvider.getProvider(YamlConfiguration.class).save(Maintenance.config, Maintenance.file);
} catch (IOException e) {
e.printStackTrace();
}
ProxyServer.getInstance().broadcast(new TextComponent(Maintenance.prefix + Maintenance.Disabled));
} else {
commandSender.sendMessage(Maintenance.prefix + Maintenance.alreadyDisabled);
}
} else {
String reason = strings[0];
if (reason != null) {
if (!Maintenance.config.getBoolean("Maintenance.enable") == true) {
Maintenance.config.set("Maintenance.enable", true);
Maintenance.config.set("Maintenance.reason", reason);
Maintenance.maintenance = true;
try {
ConfigurationProvider.getProvider(YamlConfiguration.class).save(Maintenance.config, Maintenance.file);
} catch (IOException e) {
e.printStackTrace();
}
try {
Maintenance.config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(Maintenance.file);
} catch (IOException e) {
e.printStackTrace();
}
Maintenance.maintenance = Maintenance.config.getBoolean("Maintenance.enable");
Maintenance.prefix = Maintenance.config.getString("Maintenance.prefix").replaceAll("&", "§");
Maintenance.permissions = Maintenance.config.getString("Maintenance.permissions").replaceAll("&", "§");
Maintenance.noperms = Maintenance.config.getString("Maintenance.noperms").replaceAll("&", "§");
Maintenance.reloaded = Maintenance.config.getString("Maintenance.reloaded").replaceAll("&", "§");
Maintenance.version = Maintenance.config.getString("Messages.Version").replaceAll("&", "§");
Maintenance.maintenancejoin = Maintenance.config.getString("Maintenance.maintenancejoin").replaceAll("&", "§");
Maintenance.reason = Maintenance.config.getString("Maintenance.reason").replaceAll("&", "§");
Maintenance.noreason = Maintenance.config.getString("Maintenance.noreason").replaceAll("&", "§");
Maintenance.MaintenanceKickMessage = Maintenance.config.getString("Messages.MaintenanceKickMessage").replaceAll("&", "§").replace("%reason%", Maintenance.reason);
Maintenance.MaintenanceMessage = Maintenance.config.getString("Messages.MaintenanceMessage").replaceAll("&", "§").replace("%reason%", Maintenance.reason);
Maintenance.Enabled = Maintenance.config.getString("Messages.Enabled").replaceAll("&", "§").replace("%reason%", Maintenance.reason);
Maintenance.Disabled = Maintenance.config.getString("Messages.Disabled").replaceAll("&", "§");
Maintenance.alreadyEnabled = Maintenance.config.getString("Messages.alreadyEnable").replaceAll("&", "§");
Maintenance.alreadyDisabled = Maintenance.config.getString("Messages.alreadyDisabled").replaceAll("&", "§");
Maintenance.FirstMOTD = Maintenance.config.getString("MOTD.FirstMOTD").replaceAll("&", "§");
Maintenance.SecondMOTD = Maintenance.config.getString("MOTD.SecondMOTD").replaceAll("&", "§");
Maintenance.MaintenanceFirstMOTD = Maintenance.config.getString("MOTD.MaintenanceFirstMOTD").replaceAll("&", "§");
Maintenance.MaintenanceSecondMOTD = Maintenance.config.getString("MOTD.MaintenanceSecondMOTD").replaceAll("&", "§");
for (ProxiedPlayer all : ProxyServer.getInstance().getPlayers()) {
if (!all.hasPermission(Maintenance.maintenancejoin) || !all.hasPermission(Maintenance.permissions)) {
all.disconnect(new TextComponent(Maintenance.MaintenanceKickMessage));
}
}
ProxyServer.getInstance().broadcast(new TextComponent(Maintenance.prefix + Maintenance.Enabled));
} else {
commandSender.sendMessage(Maintenance.prefix + Maintenance.alreadyEnabled);
}
} else {
commandSender.sendMessage(Maintenance.prefix + Maintenance.noreason);
}
}
}
} else {
commandSender.sendMessage(Maintenance.prefix + Maintenance.noperms);
}
}
}

View File

@ -0,0 +1,151 @@
package de.TntTastisch.Spigot;
import de.TntTastisch.Spigot.commands.MaintenanceCMD;
import de.TntTastisch.Spigot.listener.ServerPingListener;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.api.plugin.PluginManager;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
import java.io.File;
import java.io.IOException;
public class Maintenance extends Plugin implements Listener {
private static Maintenance instance;
public static boolean maintenance;
public static String prefix;
public static String permissions;
public static String noperms;
public static String reloaded;
public static String version;
public static String maintenancejoin;
public static String reason;
public static String noreason;
public static String MaintenanceKickMessage;
public static String MaintenanceMessage;
public static String Enabled;
public static String Disabled;
public static String alreadyEnabled;
public static String alreadyDisabled;
public static String motdEnable;
public static String motdDisable;
public static boolean motdEnabled;
public static String FirstMOTD;
public static String SecondMOTD;
public static String MaintenanceFirstMOTD;
public static String MaintenanceSecondMOTD;
public static File file;
public static Configuration config;
@Override
public void onEnable() {
instance = this;
loadConfiguration();
PluginManager pluginManager = ProxyServer.getInstance().getPluginManager();
pluginManager.registerCommand(this, new MaintenanceCMD());
pluginManager.registerListener(this, new ServerPingListener());
ProxyServer.getInstance().getConsole().sendMessage(new TextComponent("[]===========[ Maintenance ]===========[]"));
ProxyServer.getInstance().getConsole().sendMessage(new TextComponent("[] §aThis Plugin was successfully activated."));
ProxyServer.getInstance().getConsole().sendMessage(new TextComponent("[] §aAuthor: TntTastisch."));
ProxyServer.getInstance().getConsole().sendMessage(new TextComponent("[] §aVersion: " + getDescription().getVersion() + "."));
ProxyServer.getInstance().getConsole().sendMessage(new TextComponent("[]===========[ Maintenance ]===========[]"));
}
@Override
public void onDisable() {
ProxyServer.getInstance().getConsole().sendMessage(new TextComponent("[]===========[ Maintenance ]===========[]"));
ProxyServer.getInstance().getConsole().sendMessage(new TextComponent("[] §cThis Plugin was successfully deactivated."));
ProxyServer.getInstance().getConsole().sendMessage(new TextComponent("[] §cAuthor: TntTastisch."));
ProxyServer.getInstance().getConsole().sendMessage(new TextComponent("[] §cVersion: " + getDescription().getVersion() + "."));
ProxyServer.getInstance().getConsole().sendMessage(new TextComponent("[]===========[ Maintenance ]===========[]"));
}
private void loadConfiguration() {
if (!getDataFolder().exists()) getDataFolder().mkdir();
file = new File(getDataFolder().getPath(), "config.yml");
try {
if (!file.exists()) {
file.createNewFile();
createConfigurationSection(file);
}
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
} catch (IOException e) {
e.printStackTrace();
}
loadVariables();
}
private void createConfigurationSection(File file) throws IOException {
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
config.set("Maintenance.enable", false);
config.set("Maintenance.prefix", "&8[&4Maintenance&8] &7");
config.set("Maintenance.permissions", "maintenance.use");
config.set("Maintenance.noperms", "&cYou have no rights to this command.");
config.set("Maintenance.reloaded", "&7The configuration was &asuccessfully &7reloaded.");
config.set("Maintenance.maintenancejoin", "maintenance.bypass");
config.set("Maintenance.reason", "&7Construction");
config.set("Maintenance.noreason", "&cPlease specify a maintenance reason!");
config.set("Messages.Version", "&4Maintenance");
config.set("Messages.MaintenanceKickMessage", "&8>> &4ServerNetwork.com &8<<\n&7This network is now under maintenance\n\n&7Reason&8: &e%reason%\n\n&7You want to contact us?\n&7TeamSpeak &8>> &ets.yourservernetwork.com\n&7Homepage &8>> &ewww.yourservernetwork.com");
config.set("Messages.MaintenanceMessage", "&8>> &4ServerNetwork.com &8<<\n&7This network is currently under maintenance\n\n&7Reason&8: &e%reason%\n\n&7You want to contact us?\n&7TeamSpeak &8>> &ets.yourservernetwork.com\n&7Homepage &8>> &ewww.yourservernetwork.com");
config.set("Messages.Enabled", "&7The maintenancemode was successfully &aenabled&7 for %reason%");
config.set("Messages.Disabled", "&7The maintenancemode was successfully &cdisabled&7.");
config.set("Messages.alreadyEnable", "&cThe maintenancemode is currently &aenabled&7.");
config.set("Messages.alreadyDisabled", "&cThe maintenancemode is currently &cdisabled&7.");
config.set("Messages.MOTD.Enabled", "&7MOTD was successfully &aenabled&7.");
config.set("Messages.MOTD.Disabled", "&7MOTD was successfully &cdisabled&7.");
config.set("MOTD.Enabled", true);
config.set("MOTD.FirstMOTD", "&4ServerNetwork.com &8- &fServer Network &8[&e1.8-1.12&8]");
config.set("MOTD.SecondMOTD", "&aWe are online again &8| &4Maintenance by TntTastisch");
config.set("MOTD.MaintenanceFirstMOTD", "&4ServerNetwork.com &8- &fServer Network &8[&e1.8-1.12&8]");
config.set("MOTD.MaintenanceSecondMOTD", "&8[&c!&8] &7This network is currently under &4maintenance&7!");
ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
}
public void loadVariables() {
maintenance = config.getBoolean("Maintenance.enable");
prefix = config.getString("Maintenance.prefix").replaceAll("&", "§");
permissions = config.getString("Maintenance.permissions").replaceAll("&", "§");
noperms = config.getString("Maintenance.noperms").replaceAll("&", "§");
reloaded = config.getString("Maintenance.reloaded").replaceAll("&", "§");
version = config.getString("Messages.Version").replaceAll("&", "§");
maintenancejoin = config.getString("Maintenance.maintenancejoin").replaceAll("&", "§");
reason = config.getString("Maintenance.reason").replaceAll("&", "§");
noreason = config.getString("Maintenance.noreason").replaceAll("&", "§");
MaintenanceKickMessage = config.getString("Messages.MaintenanceKickMessage").replaceAll("&", "§");
MaintenanceMessage = config.getString("Messages.MaintenanceMessage").replaceAll("&", "§");
Enabled = config.getString("Messages.Enabled").replaceAll("&", "§");
Disabled = config.getString("Messages.Disabled").replaceAll("&", "§");
alreadyEnabled = config.getString("Messages.alreadyEnable").replaceAll("&", "§");
alreadyDisabled = config.getString("Messages.alreadyDisabled").replaceAll("&", "§");
motdEnable = config.getString("Messages.MOTD.Enabled").replaceAll("&", "§");
motdDisable = config.getString("Messages.MOTD.Disabled").replaceAll("&", "§");
motdEnabled = config.getBoolean("MOTD.Enabled");
FirstMOTD = config.getString("MOTD.FirstMOTD").replaceAll("&", "§");
SecondMOTD = config.getString("MOTD.SecondMOTD").replaceAll("&", "§");
MaintenanceFirstMOTD = config.getString("MOTD.MaintenanceFirstMOTD").replaceAll("&", "§");
MaintenanceSecondMOTD = config.getString("MOTD.MaintenanceSecondMOTD").replaceAll("&", "§");
}
public static Maintenance getInstance() {
return instance;
}
}

View File

@ -0,0 +1,148 @@
package de.TntTastisch.Spigot.commands;
import de.TntTastisch.Spigot.Maintenance;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
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 net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
import java.io.IOException;
import static de.TntTastisch.Spigot.Maintenance.*;
public class MaintenanceCMD extends Command {
public MaintenanceCMD() {
super("maintenance");
}
@Override
public void execute(CommandSender commandSender, String[] strings) {
if (commandSender.hasPermission(permissions)) {
if (strings.length == 0) {
commandSender.sendMessage(new TextComponent("§8§m============§r§8[ §4§lMaintenance §8]§8§m============"));
commandSender.sendMessage(new TextComponent("§8>> §e/maintenance reload"));
commandSender.sendMessage(new TextComponent("§8>> §e/maintenance motd"));
commandSender.sendMessage(new TextComponent("§8>> §e/maintenance <Reason>"));
commandSender.sendMessage(new TextComponent("§8>> §e/maintenance off"));
commandSender.sendMessage(new TextComponent("§8§m============§r§8[ §4§lMaintenance §8]§8§m============"));
return;
}
switch (strings[0].toLowerCase()) {
case "reload": {
if (strings.length != 1) {
commandSender.sendMessage(new TextComponent("§8>> §e/maintenance reload"));
return;
}
try {
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
} catch (IOException e) {
e.printStackTrace();
}
Maintenance.getInstance().loadVariables();
commandSender.sendMessage(new TextComponent(prefix + reloaded));
break;
}
case "motd": {
if(strings.length != 1) {
commandSender.sendMessage(new TextComponent("§8>> §e/maintenance motd"));
return;
}
if (config.getBoolean("MOTD.Enabled")) {
config.set("MOTD.Enabled", false);
motdEnabled = false;
try {
ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
} catch (IOException e) {
e.printStackTrace();
}
commandSender.sendMessage(new TextComponent(prefix + motdDisable));
return;
}
config.set("MOTD.Enabled", true);
motdEnabled = true;
try {
ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
} catch (IOException e) {
e.printStackTrace();
}
commandSender.sendMessage(new TextComponent(prefix + motdEnable));
break;
}
case "off": {
if (strings.length != 1) {
commandSender.sendMessage(new TextComponent("§8>> §e/maintenance off"));
return;
}
if (!(config.getBoolean("Maintenance.enable"))) {
commandSender.sendMessage(prefix + alreadyDisabled);
return;
}
config.set("Maintenance.enable", false);
maintenance = false;
try {
ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
} catch (IOException e) {
e.printStackTrace();
}
ProxyServer.getInstance().broadcast(new TextComponent(prefix + Disabled));
break;
}
default: {
if (strings.length < 1) {
commandSender.sendMessage(new TextComponent("§8>> §e/maintenance <Reason>"));
return;
}
String reason = "";
for (int i = 0; i != strings.length; i++) {
reason += strings[i] + " ";
}
if (config.getBoolean("Maintenance.enable")) {
commandSender.sendMessage(prefix + alreadyEnabled);
return;
}
config.set("Maintenance.enable", true);
config.set("Maintenance.reason", reason);
maintenance = true;
try {
ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
} catch (IOException e) {
e.printStackTrace();
}
for (ProxiedPlayer all : ProxyServer.getInstance().getPlayers()) {
if (!all.hasPermission(maintenancejoin) || !all.hasPermission(permissions)) {
all.disconnect(new TextComponent(MaintenanceKickMessage.replace("%reason%", reason)));
}
}
ProxyServer.getInstance().broadcast(new TextComponent(prefix + Enabled.replace("%reason%", reason)));
break;
}
}
return;
}
commandSender.sendMessage(prefix + noperms);
}
}

View File

@ -8,6 +8,8 @@ import net.md_5.bungee.api.event.*;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import static de.TntTastisch.Spigot.Maintenance.*;
public class ServerPingListener implements Listener {
@SuppressWarnings("deprecation")
@ -16,14 +18,18 @@ public class ServerPingListener implements Listener {
ServerPing ping = e.getResponse();
ServerPing.Players players = ping.getPlayers();
ServerPing.Protocol protocol = ping.getVersion();
if (Maintenance.config.getBoolean("Maintenance.enable")) {
if (maintenance) {
protocol.setProtocol(2);
ping.setDescription(Maintenance.MaintenanceFirstMOTD + "\n" + Maintenance.MaintenanceSecondMOTD);
protocol.setName(Maintenance.version);
if(motdEnabled) {
ping.setDescription(MaintenanceFirstMOTD + "\n" + MaintenanceSecondMOTD);
}
protocol.setName(version);
ping.setVersion(protocol);
ping.setPlayers(players);
} else if (!Maintenance.maintenance) {
ping.setDescription(Maintenance.FirstMOTD + "\n" + Maintenance.SecondMOTD);
return;
}
if(motdEnabled) {
ping.setDescription(FirstMOTD + "\n" + SecondMOTD);
}
}
@ -31,9 +37,9 @@ public class ServerPingListener implements Listener {
public void onLogin(PostLoginEvent event) {
ProxiedPlayer player = event.getPlayer();
if (Maintenance.maintenance) {
if (!(player.hasPermission(Maintenance.permissions) || player.hasPermission(Maintenance.maintenancejoin))) {
player.disconnect(new TextComponent(Maintenance.MaintenanceMessage));
if (maintenance) {
if (!(player.hasPermission(permissions) || player.hasPermission(maintenancejoin))) {
player.disconnect(new TextComponent(MaintenanceMessage.replace("%reason%", reason)));
}
}
}

View File

@ -1,5 +1,5 @@
name: Maintenance
version: 1.0.3
version: ${project.version}
author: TntTastisch
main: de.TntTastisch.Spigot.Maintenance
commands:

View File

@ -1,4 +1,4 @@
# Use %reason% for the Mainteance-Reason.
# Use %reason% for the Maintenance-Reason.
Maintenance:
enable: false
prefix: '&8[&4Maintenance&8] &7'
@ -6,7 +6,7 @@ Maintenance:
noperms: '&cYou have no rights to this command.'
reloaded: '&7The configuration was &asuccessfully &7reloaded.'
maintenancejoin: 'maintenance.bypass'
reason: '&7Cunstruction'
reason: 'Construction'
noreason: '&cPlease specify a maintenance reason!'
Messages:
Version: '&4Maintenance'