mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Update Updater, fix newline issue on event chain disabling
This commit is contained in:
1 parent
a7895f9414
commit
d4384ac550
2 files changed
+23
-3
No files matched your search
@@ -122,7 +122,7 @@ public class AnticheatManager {
|
||||
public String getEventChainReport() {
|
||||
String gen = "";
|
||||
if (!configuration.eventChains())
|
||||
return "Event Chains is disabled by the configuration.";
|
||||
return "Event Chains is disabled by the configuration.\n";
|
||||
|
||||
for (Entry<String, RegisteredListener[]> e : eventchains.entrySet()) {
|
||||
String toadd = "";
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
package net.h31ix.anticheat.update;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.IllegalThreadStateException;
|
||||
import java.lang.Runnable;
|
||||
import java.lang.Thread;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
@@ -50,12 +52,12 @@ public class Updater
|
||||
private boolean announce; // Whether to announce file downloads
|
||||
private URL url; // Connecting to RSS
|
||||
private File file; // The plugin's file
|
||||
private Thread thread; // Updater thread
|
||||
private static final String DBOUrl = "http://dev.bukkit.org/server-mods/"; // Slugs will be appended to this to get to the project's RSS feed
|
||||
private String [] noUpdateTag = {"-DEV","-PRE"}; // If the version number contains one of these, don't update.
|
||||
private static final int BYTE_SIZE = 1024; // Used for downloading files
|
||||
private String updateFolder = YamlConfiguration.loadConfiguration(new File("bukkit.yml")).getString("settings.update-folder"); // The folder that downloads will be placed in
|
||||
private Updater.UpdateResult result = Updater.UpdateResult.SUCCESS; // Used for determining the outcome of the update process
|
||||
|
||||
// Strings for reading RSS
|
||||
private static final String TITLE = "title";
|
||||
private static final String LINK = "link";
|
||||
@@ -147,7 +149,8 @@ public class Updater
|
||||
plugin.getLogger().warning("The project slug given ('" + slug + "') is invalid. Please nag the author about this.");
|
||||
result = Updater.UpdateResult.FAIL_BADSLUG; // Bad slug! Bad!
|
||||
}
|
||||
new Thread(new UpdateRunnable()).start();
|
||||
thread = new Thread(new UpdateRunnable());
|
||||
thread.start();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,6 +158,7 @@ public class Updater
|
||||
*/
|
||||
public Updater.UpdateResult getResult()
|
||||
{
|
||||
waitForThread();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -163,6 +167,7 @@ public class Updater
|
||||
*/
|
||||
public long getFileSize()
|
||||
{
|
||||
waitForThread();
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
@@ -171,9 +176,24 @@ public class Updater
|
||||
*/
|
||||
public String getLatestVersionString()
|
||||
{
|
||||
waitForThread();
|
||||
return versionTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* As the result of Updater output depends on the thread's completion, it is necessary to wait for the thread to finish
|
||||
* before alloowing anyone to check the result.
|
||||
*/
|
||||
public void waitForThread() {
|
||||
if(thread.isAlive()) {
|
||||
try {
|
||||
thread.join();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save an update from dev.bukkit.org into the server's update folder.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user