13
0
Dieser Commit ist enthalten in:
yoyosource 2022-04-23 22:31:16 +02:00
Ursprung 1925e5008c
Commit 95209dfd82
4 geänderte Dateien mit 25 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -7,6 +7,10 @@ plugin-enabled: true
# Set this to 'true' to force the joining coming from SteamWar.
force-only-steamwar-join: false
# Set this to a message to be displayed to the joinind player whilst not joining from SteamWar.
# This will only be sent if 'force-only-steamwar-join' is set to 'true'.
not-from-steamwar-message: "You are not allowed to join this server."
# Set this to 'true' to enable the TeamServer-Integration whitelist.
# This will not affect normal connections, only those coming from SteamWar.
whitelist-enabled: false

Datei anzeigen

@ -28,6 +28,7 @@ public class ConfigSystem {
configFile = new File(SteamWarBungeeTeamserver.plugin.getDataFolder(), "config.yml");
if (!configFile.exists()) {
try {
configFile.getParentFile().mkdirs();
configFile.createNewFile();
FileOutputStream fileOutputStream = new FileOutputStream(configFile);
InputStream inputStream = SteamWarBungeeTeamserver.plugin.getResourceAsStream("config.yml");
@ -40,9 +41,15 @@ public class ConfigSystem {
inputStream.close();
enabled = true;
} catch (Exception e) {
// ignored
}
} else {
enabled = true;
}
}
void init() {
}
}
}
private synchronized void load() {
@ -73,6 +80,14 @@ public class ConfigSystem {
return false;
}
public String getNotFromSteamWarMessage() {
load();
if (config != null) {
return config.getString("not-from-steamwar-message", "");
}
return "You are not allowed to join this server.";
}
public boolean isWhitelistEnabled() {
load();
if (config != null) {

Datei anzeigen

@ -10,6 +10,7 @@ public final class SteamWarBungeeTeamserver extends Plugin {
@Override
public void onEnable() {
plugin = this;
ConfigSystem.init();
getProxy().getPluginManager().registerListener(this, new SteamwarConnectionListener());
}

Datei anzeigen

@ -2,6 +2,7 @@ package de.steamwar.listener;
import de.steamwar.ConfigSystem;
import io.netty.buffer.ByteBuf;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.event.PreLoginEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.connection.InitialHandler;
@ -86,12 +87,9 @@ public class SteamwarConnectionListener implements Listener {
if (ConfigSystem.isWhitelistEnabled()) {
Set<String> whitelist = ConfigSystem.getWhitelist();
if (!whitelist.contains(uuidStringBuilder.toString())) {
preLoginEvent.setCancelled(true);
return;
}
if (!whitelist.contains(preLoginEvent.getConnection().getName())) {
if (!whitelist.contains(uuidStringBuilder.toString()) && !whitelist.contains(preLoginEvent.getConnection().getName())) {
preLoginEvent.setCancelled(true);
preLoginEvent.setCancelReason(new TextComponent());
return;
}
}
@ -110,6 +108,7 @@ public class SteamwarConnectionListener implements Listener {
initialHandler.setUniqueId(UUID.fromString(uuidStringBuilder.toString()));
} else if (ConfigSystem.isOnlySteamWarJoin()) {
preLoginEvent.setCancelled(true);
preLoginEvent.setCancelReason(ConfigSystem.getNotFromSteamWarMessage());
}
}
}