diff --git a/Plugins/Mineplex.Core/src/mineplex/core/logger/Logger.java b/Plugins/Mineplex.Core/src/mineplex/core/logger/Logger.java index 26f34e986..48eaf324f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/logger/Logger.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/logger/Logger.java @@ -3,16 +3,19 @@ package mineplex.core.logger; import java.util.ArrayList; import java.util.List; +import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; public class Logger { public static Logger Instance; + private static JavaPlugin _plugin; private LoggerRepository _repository; public static void initialize(JavaPlugin plugin) { + _plugin = plugin; Instance = new Logger(plugin); } @@ -47,14 +50,20 @@ public class Logger } } - public void log(String message) + public void log(final String message) { - _repository.saveLog(message); + Bukkit.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable() + { + public void run() + { + _repository.saveLog(message); + } + }); } public void log(Throwable exception) { - List messages = new ArrayList(); + final List messages = new ArrayList(); messages.add("[Exception Start]" + exception.getMessage()); @@ -65,6 +74,12 @@ public class Logger messages.add("[Exception End]"); - _repository.saveLog(messages.toArray(new String[0])); + Bukkit.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable() + { + public void run() + { + _repository.saveLog(messages.toArray(new String[0])); + } + }); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/playerTracker/PlayerTracker.java b/Plugins/Mineplex.Core/src/mineplex/core/playerTracker/PlayerTracker.java index 28fcd7976..3540c4bf7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/playerTracker/PlayerTracker.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/playerTracker/PlayerTracker.java @@ -1,6 +1,20 @@ package mineplex.core.playerTracker; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Locale; +import java.util.TimeZone; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; + +import org.apache.commons.codec.binary.Hex; import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.libs.com.google.gson.Gson; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.plugin.java.JavaPlugin; @@ -8,18 +22,88 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.event.ClientUnloadEvent; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.conn.scheme.PlainSocketFactory; +import org.apache.http.conn.scheme.Scheme; +import org.apache.http.conn.scheme.SchemeRegistry; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.conn.PoolingClientConnectionManager; + public class PlayerTracker extends MiniPlugin { private PlayerTrackerRepository _repository = null; - + public PlayerTracker(JavaPlugin plugin, String serverName, boolean us) { super("Player Tracker", plugin); _repository = new PlayerTrackerRepository(); _repository.initialize(serverName, us); + + SchemeRegistry schemeRegistry = new SchemeRegistry(); + schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); + + PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager(schemeRegistry); + connectionManager.setMaxTotal(200); + connectionManager.setDefaultMaxPerRoute(20); + + HttpClient httpClient = new DefaultHttpClient(connectionManager); + InputStream in = null; + + try + { + + HttpGet request = new HttpGet("http://api.dnsmadeeasy.com/V2.0/dns/managed/962728/records/"); + + String timeStamp = getServerTime(); + SecretKeySpec keySpec = new SecretKeySpec("8c9af8cc-d306-4df3-8de8-944deafa8239".getBytes(), "HmacSHA1"); + Mac mac = Mac.getInstance("HmacSHA1"); + mac.init(keySpec); + byte[] hashBytes = mac.doFinal((timeStamp + "").getBytes()); + Hex.encodeHexString(hashBytes); + + request.addHeader("x-dnsme-apiKey", "610e21ee-4250-4b55-b637-a1fcc3847850"); + request.addHeader("x-dnsme-requestDate", timeStamp + ""); + request.addHeader("x-dnsme-hmac", Hex.encodeHexString(hashBytes)); + request.addHeader("Content-Type", "application/json"); + + HttpResponse response = httpClient.execute(request); + + if (response != null) + { + in = response.getEntity().getContent(); + System.out.println(convertStreamToString(in)); + } + } + catch (Exception ex) + { + System.out.println("JsonWebCall.Execute() Error:\n" + ex.getMessage()); + + for (StackTraceElement trace : ex.getStackTrace()) + { + System.out.println(trace); + } + } + finally + { + httpClient.getConnectionManager().shutdown(); + + if (in != null) + { + try + { + in.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + } } - + @EventHandler public void trackPlayer(final PlayerJoinEvent event) { @@ -31,7 +115,7 @@ public class PlayerTracker extends MiniPlugin } }); } - + @EventHandler public void untrackPlayer(final ClientUnloadEvent event) { @@ -43,4 +127,43 @@ public class PlayerTracker extends MiniPlugin } }); } + + String getServerTime() + { + Calendar calendar = Calendar.getInstance(); + SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US); + dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); + return dateFormat.format(calendar.getTime()); + } + + protected String convertStreamToString(InputStream is) + { + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + StringBuilder sb = new StringBuilder(); + + String line = null; + try + { + while ((line = reader.readLine()) != null) + { + sb.append(line + "\n"); + } + } + catch (IOException e) + { + e.printStackTrace(); + } + finally + { + try + { + is.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + return sb.toString(); + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 98ad8f6ec..0f462926e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -83,7 +83,7 @@ public class Hub extends JavaPlugin implements IRelation PreferencesManager preferenceManager = new PreferencesManager(this, clientManager, donationManager); preferenceManager.GiveItem = true; new MessageManager(this, clientManager, preferenceManager); - Creature creature = new Creature(this); + Creature creature = new Creature(this); NpcManager npcManager = new NpcManager(this, creature); PetManager petManager = new PetManager(this, clientManager, donationManager, creature, webServerAddress); new AntiStack(this); diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/DynamicServerSorter.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/DynamicServerSorter.java index d2fc1a589..fbf37f8f3 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/DynamicServerSorter.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/DynamicServerSorter.java @@ -22,9 +22,9 @@ public class DynamicServerSorter implements Comparator if (first.AvailableCPU > second.AvailableCPU) return -1; - if (second.AvailableCPU < first.AvailableCPU) + if (second.AvailableCPU > first.AvailableCPU) return 1; - return 1; + return 0; } } \ No newline at end of file diff --git a/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml b/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml index 62e1e74fb..bc5c764cc 100644 --- a/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml +++ b/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml @@ -1,7 +1,6 @@  - @@ -17,42 +16,39 @@ - + - - + - - + - + - + + - - @@ -61,7 +57,9 @@ - + + + @@ -72,23 +70,24 @@ - - + - + + + - + + - @@ -96,7 +95,7 @@ - + @@ -104,45 +103,40 @@ - + + + - - - - - - - - + + - - + @@ -153,73 +147,81 @@ - + - + + + + + + - - + + - + - + - + + + + - - + - + - - + + - + - + - + + @@ -227,50 +229,47 @@ - + - - + - - + + - - - + + - + - - + + - - + + - + - + - @@ -283,36 +282,41 @@ - + + + + + - + + - + + - - + @@ -322,7 +326,6 @@ - @@ -333,20 +336,20 @@ + - + + - - @@ -354,8 +357,6 @@ - - @@ -363,48 +364,50 @@ - - - + + + + - - + + + + - - + + + - - @@ -413,127 +416,124 @@ - - - - + - - + - + - - + - + + - + - - + + - - + - + - - + + - + - + - - + + + - + - + + - + - + - - + + - + - - + + - - + + - + - + - + @@ -546,38 +546,39 @@ - + + - + + + - + - - + - - + @@ -587,7 +588,6 @@ - @@ -598,72 +598,73 @@ + - + + - + - - - + - + - - + + + - - + + - + - + - + @@ -678,27 +679,24 @@ - - - - + - - + - - - + + + + @@ -708,95 +706,97 @@ - + + - + + - - + - + - - - + + + - + - + - + - + + - + - + + - + - - + - - + + - + - - + + - - + + - + - + - + @@ -809,38 +809,39 @@ - + + - + + + - + - - + - - + @@ -850,7 +851,6 @@ - @@ -861,28 +861,28 @@ + - + + - + - - @@ -891,42 +891,43 @@ - + - - + + + - - + + - + - + - + @@ -941,27 +942,24 @@ - - - - + - - + - + + @@ -971,85 +969,87 @@ - + + - + + - - + - + - - - + + + - + - + - + - + + - + - + + - + - - + - - + + - + - - + + - - + + - + \ No newline at end of file diff --git a/Website/LOCWebsite.suo b/Website/LOCWebsite.suo index 4ac012ac5..047b05239 100644 Binary files a/Website/LOCWebsite.suo and b/Website/LOCWebsite.suo differ