diff --git a/pom.xml b/pom.xml
index 7194aaa..02d1b13 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
BungeePackFix
BungeePackFix
- 1.1.0-r2
+ 1.1.0-r3
jar
BungeePackFix
diff --git a/src/main/java/dev/lone/bungeepackfix/bungee/Main.java b/src/main/java/dev/lone/bungeepackfix/bungee/Main.java
index d43fc1d..7e89c82 100644
--- a/src/main/java/dev/lone/bungeepackfix/bungee/Main.java
+++ b/src/main/java/dev/lone/bungeepackfix/bungee/Main.java
@@ -33,7 +33,7 @@ public void onEnable()
adventure = BungeeAudiences.create(this);
try
{
- settings = new Settings(this.getDataFolder().toPath());
+ settings = new Settings(this.getDataFolder().toPath(), getResourceAsStream("config.yml"));
}
catch (Throwable ex)
{
@@ -144,7 +144,7 @@ else if(packet.status == ServerboundResourcePackPacket.Status.FAILED_DOWNLOAD.or
private boolean isIgnoredServer(UserConnection conn)
{
- return (settings.ignored_servers.contains(conn.getServer().getInfo().getName()));
+ return settings.isIgnoredServer(conn.getServer().getInfo().getName());
}
/**
diff --git a/src/main/java/dev/lone/bungeepackfix/bungee/Settings.java b/src/main/java/dev/lone/bungeepackfix/bungee/Settings.java
index 6f0d3e3..3ca0710 100644
--- a/src/main/java/dev/lone/bungeepackfix/bungee/Settings.java
+++ b/src/main/java/dev/lone/bungeepackfix/bungee/Settings.java
@@ -5,13 +5,14 @@
import net.md_5.bungee.api.chat.BaseComponent;
import java.io.IOException;
+import java.io.InputStream;
import java.nio.file.Path;
public class Settings extends AbstractSettings
{
- public Settings(Path dataDirectory) throws IOException
+ public Settings(Path dataDirectory, InputStream defaultConfigStream) throws IOException
{
- super(dataDirectory);
+ super(dataDirectory, defaultConfigStream);
}
@Override
diff --git a/src/main/java/dev/lone/bungeepackfix/generic/AbstractSettings.java b/src/main/java/dev/lone/bungeepackfix/generic/AbstractSettings.java
index 18c22ff..1278b08 100644
--- a/src/main/java/dev/lone/bungeepackfix/generic/AbstractSettings.java
+++ b/src/main/java/dev/lone/bungeepackfix/generic/AbstractSettings.java
@@ -7,6 +7,7 @@
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
import java.nio.file.Path;
import java.util.List;
@@ -20,6 +21,9 @@ public abstract class AbstractSettings
public boolean ignore_hash_in_url;
public String main_server_name;
+
+ public boolean ignored_servers_enabled;
+ public boolean ignored_servers_invert_check;
public List ignored_servers;
public boolean log_debug;
@@ -33,10 +37,10 @@ public abstract class AbstractSettings
protected YamlConfig config;
- public AbstractSettings(Path dataDirectory) throws IOException
+ public AbstractSettings(Path dataDirectory, InputStream defaultConfigStream) throws IOException
{
config = new YamlConfig(new File(dataDirectory.toFile(), "config.yml").toPath());
- config.load();
+ config.loadConfig(defaultConfigStream);
equal_pack_attributes_hash = config.getBoolean("equal_pack_attributes.hash", true);
equal_pack_attributes_forced = config.getBoolean("equal_pack_attributes.forced", true);
@@ -44,7 +48,10 @@ public AbstractSettings(Path dataDirectory) throws IOException
ignore_hash_in_url = config.getBoolean("ignore_hash_in_url", true);
main_server_name = config.getString("main_server_name", "server_1");
- ignored_servers = config.getStringList("ignored_servers");
+
+ ignored_servers_enabled = config.getBoolean("ignored_servers.enabled");
+ ignored_servers_invert_check = config.getBoolean("ignored_servers.invert_check");
+ ignored_servers = config.getStringList("ignored_servers.list");
log_debug = config.getBoolean("log.debug", false);
log_ignored_respack = config.getBoolean("log.ignored_respack", false);
@@ -62,4 +69,13 @@ public AbstractSettings(Path dataDirectory) throws IOException
}
protected abstract void runPlatformDependentCode();
+
+ public boolean isIgnoredServer(String name)
+ {
+ if(!ignored_servers_enabled)
+ return false;
+ if(ignored_servers_invert_check)
+ return !(ignored_servers.contains(name));
+ return (ignored_servers.contains(name));
+ }
}
\ No newline at end of file
diff --git a/src/main/java/dev/lone/bungeepackfix/velocity/BungeePackFixVelocity.java b/src/main/java/dev/lone/bungeepackfix/velocity/BungeePackFixVelocity.java
index db36b04..8e4c683 100644
--- a/src/main/java/dev/lone/bungeepackfix/velocity/BungeePackFixVelocity.java
+++ b/src/main/java/dev/lone/bungeepackfix/velocity/BungeePackFixVelocity.java
@@ -17,7 +17,7 @@
@Plugin(
id = "bungeepackfix",
name = "BungeePackFix (Velocity)",
- version = "1.1.0-r2",
+ version = "1.1.0-r3",
description = "Avoid sending resourcepacks again if it's the same resourcepack. Useful when you switch servers.", authors = {"LoneDev", "YoSoyVillaa"}
)
public class BungeePackFixVelocity
@@ -57,15 +57,17 @@ public void onProxyInitialization(ProxyInitializeEvent e)
{
try
{
- //TODO add metrics
- this.settings = new Settings(dataDirectory);
+ this.settings = new Settings(dataDirectory, getClass().getClassLoader().getResourceAsStream("config.yml"));
proxy.getEventManager().register(this, new ServerResourcePackSendListener(this));
}
catch (Throwable ex)
{
ex.printStackTrace();
logger.error("Disabling plugin.");
+ return;
}
+
+ //TODO add metrics
}
@Subscribe(order = PostOrder.NORMAL)
diff --git a/src/main/java/dev/lone/bungeepackfix/velocity/Settings.java b/src/main/java/dev/lone/bungeepackfix/velocity/Settings.java
index 8ecc232..486c5e7 100644
--- a/src/main/java/dev/lone/bungeepackfix/velocity/Settings.java
+++ b/src/main/java/dev/lone/bungeepackfix/velocity/Settings.java
@@ -4,13 +4,14 @@
import net.kyori.adventure.text.Component;
import java.io.IOException;
+import java.io.InputStream;
import java.nio.file.Path;
public class Settings extends AbstractSettings
{
- public Settings(Path dataDirectory) throws IOException
+ public Settings(Path dataDirectory, InputStream defaultConfigStream) throws IOException
{
- super(dataDirectory);
+ super(dataDirectory, defaultConfigStream);
}
@Override
diff --git a/src/main/java/dev/lone/bungeepackfix/velocity/listeners/ServerResourcePackSendListener.java b/src/main/java/dev/lone/bungeepackfix/velocity/listeners/ServerResourcePackSendListener.java
index 38745b6..6629ac0 100644
--- a/src/main/java/dev/lone/bungeepackfix/velocity/listeners/ServerResourcePackSendListener.java
+++ b/src/main/java/dev/lone/bungeepackfix/velocity/listeners/ServerResourcePackSendListener.java
@@ -34,7 +34,7 @@ public void onServerResourcePackSend(ServerResourcePackSendEvent e)
if (settings.log_debug)
plugin.getLogger().warn("ServerResourcePackSendEvent: " + player.getUsername() + " " + readablePacket(serverPack));
- if (settings.ignored_servers.contains(e.getServerConnection().getServerInfo().getName()))
+ if (settings.isIgnoredServer(e.getServerConnection().getServerInfo().getName()))
{
plugin.getLogger().warn("Skipping ignored server: " + player.getUsername() + " " + readablePacket(serverPack));
return;
diff --git a/src/main/resources/bungee.yml b/src/main/resources/bungee.yml
index 1aa2b59..74b93d4 100644
--- a/src/main/resources/bungee.yml
+++ b/src/main/resources/bungee.yml
@@ -1,5 +1,5 @@
name: BungeePackFix
-version: '1.1.0-r2'
+version: '1.1.0-r3'
main: dev.lone.bungeepackfix.bungee.Main
author: LoneDev
description: Avoid sending resourcepacks again if it's the same resourcepack. Useful when you switch servers.
\ No newline at end of file
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 77ba80c..06231a6 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -10,8 +10,11 @@ equal_pack_attributes:
ignore_hash_in_url: true
main_spigot_server_name: server_1
ignored_servers:
- - ignored_1
- - ignored_2
+ enabled: true
+ invert_check: false
+ list:
+ - ignored_1
+ - ignored_2
log:
ignored_respack: false
sent_respack: false