Fix stuff
Dieser Commit ist enthalten in:
Ursprung
1925e5008c
Commit
95209dfd82
@ -7,6 +7,10 @@ plugin-enabled: true
|
|||||||
# Set this to 'true' to force the joining coming from SteamWar.
|
# Set this to 'true' to force the joining coming from SteamWar.
|
||||||
force-only-steamwar-join: false
|
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.
|
# Set this to 'true' to enable the TeamServer-Integration whitelist.
|
||||||
# This will not affect normal connections, only those coming from SteamWar.
|
# This will not affect normal connections, only those coming from SteamWar.
|
||||||
whitelist-enabled: false
|
whitelist-enabled: false
|
||||||
|
@ -28,6 +28,7 @@ public class ConfigSystem {
|
|||||||
configFile = new File(SteamWarBungeeTeamserver.plugin.getDataFolder(), "config.yml");
|
configFile = new File(SteamWarBungeeTeamserver.plugin.getDataFolder(), "config.yml");
|
||||||
if (!configFile.exists()) {
|
if (!configFile.exists()) {
|
||||||
try {
|
try {
|
||||||
|
configFile.getParentFile().mkdirs();
|
||||||
configFile.createNewFile();
|
configFile.createNewFile();
|
||||||
FileOutputStream fileOutputStream = new FileOutputStream(configFile);
|
FileOutputStream fileOutputStream = new FileOutputStream(configFile);
|
||||||
InputStream inputStream = SteamWarBungeeTeamserver.plugin.getResourceAsStream("config.yml");
|
InputStream inputStream = SteamWarBungeeTeamserver.plugin.getResourceAsStream("config.yml");
|
||||||
@ -40,11 +41,17 @@ public class ConfigSystem {
|
|||||||
inputStream.close();
|
inputStream.close();
|
||||||
enabled = true;
|
enabled = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
// ignored
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private synchronized void load() {
|
private synchronized void load() {
|
||||||
if (!enabled) return;
|
if (!enabled) return;
|
||||||
if (lastModified >= configFile.lastModified()) return;
|
if (lastModified >= configFile.lastModified()) return;
|
||||||
@ -73,6 +80,14 @@ public class ConfigSystem {
|
|||||||
return false;
|
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() {
|
public boolean isWhitelistEnabled() {
|
||||||
load();
|
load();
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
|
@ -10,6 +10,7 @@ public final class SteamWarBungeeTeamserver extends Plugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
plugin = this;
|
plugin = this;
|
||||||
|
ConfigSystem.init();
|
||||||
getProxy().getPluginManager().registerListener(this, new SteamwarConnectionListener());
|
getProxy().getPluginManager().registerListener(this, new SteamwarConnectionListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package de.steamwar.listener;
|
|||||||
|
|
||||||
import de.steamwar.ConfigSystem;
|
import de.steamwar.ConfigSystem;
|
||||||
import io.netty.buffer.ByteBuf;
|
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.event.PreLoginEvent;
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.connection.InitialHandler;
|
import net.md_5.bungee.connection.InitialHandler;
|
||||||
@ -86,12 +87,9 @@ public class SteamwarConnectionListener implements Listener {
|
|||||||
|
|
||||||
if (ConfigSystem.isWhitelistEnabled()) {
|
if (ConfigSystem.isWhitelistEnabled()) {
|
||||||
Set<String> whitelist = ConfigSystem.getWhitelist();
|
Set<String> whitelist = ConfigSystem.getWhitelist();
|
||||||
if (!whitelist.contains(uuidStringBuilder.toString())) {
|
if (!whitelist.contains(uuidStringBuilder.toString()) && !whitelist.contains(preLoginEvent.getConnection().getName())) {
|
||||||
preLoginEvent.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!whitelist.contains(preLoginEvent.getConnection().getName())) {
|
|
||||||
preLoginEvent.setCancelled(true);
|
preLoginEvent.setCancelled(true);
|
||||||
|
preLoginEvent.setCancelReason(new TextComponent());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,6 +108,7 @@ public class SteamwarConnectionListener implements Listener {
|
|||||||
initialHandler.setUniqueId(UUID.fromString(uuidStringBuilder.toString()));
|
initialHandler.setUniqueId(UUID.fromString(uuidStringBuilder.toString()));
|
||||||
} else if (ConfigSystem.isOnlySteamWarJoin()) {
|
} else if (ConfigSystem.isOnlySteamWarJoin()) {
|
||||||
preLoginEvent.setCancelled(true);
|
preLoginEvent.setCancelled(true);
|
||||||
|
preLoginEvent.setCancelReason(ConfigSystem.getNotFromSteamWarMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren