diff --git a/.gitignore b/.gitignore
index a6f89c2..c2417b1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
-/target/
\ No newline at end of file
+/target
+
+.idea/workspace.xml
\ No newline at end of file
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..008c945
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+Capatchafy
\ No newline at end of file
diff --git a/.idea/artifacts/Capatchafy.xml b/.idea/artifacts/Capatchafy.xml
new file mode 100644
index 0000000..ef60c76
--- /dev/null
+++ b/.idea/artifacts/Capatchafy.xml
@@ -0,0 +1,38 @@
+
+
+ $PROJECT_DIR$/target/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..677eb3b
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..b26911b
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..4b661a5
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 67ae21d..275f306 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,6 +16,10 @@
spigot-repo
https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+
+ maven-central
+ http://central.maven.org/maven2/
+
@@ -49,6 +53,11 @@
4.9
test
+
+ javax.activation
+ activation
+ 1.1.1
+
commons-io
commons-io
diff --git a/src/main/java/me/hockey/capatchafy/Capatchafy.java b/src/main/java/me/hockey/capatchafy/Capatchafy.java
index 9a940c6..88acf97 100644
--- a/src/main/java/me/hockey/capatchafy/Capatchafy.java
+++ b/src/main/java/me/hockey/capatchafy/Capatchafy.java
@@ -69,7 +69,7 @@ public class Capatchafy extends JavaPlugin
Bukkit.getLogger().severe("[Capatchafy] The 'security-level' config field was not between 1 and 3. Setting security level to 2.");
}
enabled = configs.config.getBoolean("always-on");
- server = HttpdServer.startServer();
+ server = HttpdServer.getServer();
listeners.setURLMessage();
Bukkit.getLogger().info("[Capatchafy] Running in security level " + securityLevel + ".");
}
@@ -81,7 +81,6 @@ public class Capatchafy extends JavaPlugin
{
return; //Prevents errors on the first startup.
}
-
try
{
configs.saveNames(true);
@@ -91,7 +90,7 @@ public class Capatchafy extends JavaPlugin
{
e.printStackTrace();
}
- server.stop();
+ server.shutdownNow();
configs.ipList.clear(); //TODO See if removing this line affects functionality.
}
}
diff --git a/src/main/java/me/hockey/capatchafy/Configuration.java b/src/main/java/me/hockey/capatchafy/Configuration.java
index bf1f70f..9e024d9 100644
--- a/src/main/java/me/hockey/capatchafy/Configuration.java
+++ b/src/main/java/me/hockey/capatchafy/Configuration.java
@@ -139,6 +139,11 @@ public class Configuration
return config.getString("hostname");
}
+ public String getBindingIP()
+ {
+ return config.getString("binding-ip");
+ }
+
public String getPort()
{
return config.getString("port");
diff --git a/src/main/java/me/hockey/capatchafy/Listeners.java b/src/main/java/me/hockey/capatchafy/Listeners.java
index 1f1afdd..90c19ac 100644
--- a/src/main/java/me/hockey/capatchafy/Listeners.java
+++ b/src/main/java/me/hockey/capatchafy/Listeners.java
@@ -58,6 +58,10 @@ public class Listeners implements Listener
String ip = event.getAddress().toString().replaceAll("/", "");
if (!Capatchafy.configs.isAuthorized(ip))
{
+ if (url == null)
+ {
+ setURLMessage();
+ }
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ChatColor.RED + "" + ChatColor.BOLD + "Yikes, we're under attack! Please solve the capatcha.\n" +
ChatColor.WHITE + "Please go to " + ChatColor.GOLD + url + ChatColor.WHITE + " in your web browser and solve the capatcha.\n" +
"Once solved successfully, you will be able to join.");
diff --git a/src/main/java/me/hockey/capatchafy/httpd/HttpdServer.java b/src/main/java/me/hockey/capatchafy/httpd/HttpdServer.java
index 3c3b333..fad72c8 100644
--- a/src/main/java/me/hockey/capatchafy/httpd/HttpdServer.java
+++ b/src/main/java/me/hockey/capatchafy/httpd/HttpdServer.java
@@ -27,8 +27,8 @@ import org.glassfish.jersey.server.ResourceConfig;
public class HttpdServer
{
- public static final String BASE_URI = "http://" + Capatchafy.configs.getHostname() + ":" + Capatchafy.configs.getPort() + "/";
- public static HttpServer startServer()
+ public static final String BASE_URI = "http://" + (Capatchafy.configs.getBindingIP().isEmpty() ? Capatchafy.configs.getHostname() : Capatchafy.configs.getBindingIP()) + ":" + Capatchafy.configs.getPort() + "/";
+ public static HttpServer getServer()
{
final ResourceConfig rc = new ResourceConfig().packages("me.hockey.capatchafy.httpd");
final Set> classes = new HashSet>();
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 1ce6c8e..7e9f218 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -11,6 +11,9 @@ always-on: false
#3 - Strict. You must verify each time you join.
security-level: 2
+# IP to bind the httpd to, leave blank to use hostname
+binding-ip: ''
+
#Hostname - The ip that you want Capatchafy to listen on goes here.
#You don't HAVE to change this, but leaving it will cause problems when a player tries to find the link to the capatcha.
hostname: 127.0.0.1
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 403ed86..751a8e0 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,5 +1,5 @@
name: Capatchafy
-version: 1.1.0
+version: 1.1.0-TF
main: me.hockey.capatchafy.Capatchafy
commands: