Fixed portal command stuff.

Removed temp code from PlayerTracker

Added temp project for future ddos prot switching.
This commit is contained in:
Jonathan Williams 2014-07-04 23:23:19 -07:00
parent e6666932aa
commit c882ab1b34
9 changed files with 341 additions and 294 deletions

View File

@ -2,6 +2,7 @@ package mineplex.core.account;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;
@ -16,6 +17,7 @@ import mineplex.core.account.repository.token.ClientToken;
import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.logger.Logger;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -250,6 +252,50 @@ public class CoreClientManager extends MiniPlugin
}, name, rank, perm);
}
public void checkPlayerName(final Player caller, final String playerName, final Callback<Boolean> callback)
{
_repository.MatchPlayerName(new Callback<List<String>>()
{
public void run(List<String> matches)
{
boolean matchedExact = false;
for (String match : matches)
{
if (match.equalsIgnoreCase(playerName))
{
matchedExact = true;
}
}
if (matchedExact)
{
for (Iterator<String> matchIterator = matches.iterator(); matchIterator.hasNext();)
{
if (!matchIterator.next().equalsIgnoreCase(playerName))
{
matchIterator.remove();
}
}
}
UtilPlayer.searchOffline(matches, new Callback<String>()
{
public void run(final String target)
{
if (target == null)
{
callback.run(false);
return;
}
callback.run(true);
}
}, caller, playerName, true);
}
}, playerName);
}
@EventHandler
public void cleanGlitchedClients(UpdateEvent event)
{

View File

@ -1,20 +1,6 @@
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;
@ -22,15 +8,6 @@ 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;
@ -41,67 +18,6 @@ public class PlayerTracker extends MiniPlugin
_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
@ -127,43 +43,4 @@ 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();
}
}

View File

@ -7,109 +7,59 @@ import org.bukkit.entity.Player;
import mineplex.core.command.*;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.portal.Portal;
public class SendCommand extends CommandBase<Portal>
{
private Portal _portal;
public SendCommand(Portal plugin)
{
super(plugin, Rank.ADMIN, "snd","send");
_portal = plugin;
}
private void SendPlayerToServerWithMessage(Player player, String serverName)
{
_portal.AddTransferRecord(player.getName(), serverName);
player.playSound(player.getLocation(), Sound.PORTAL, 0.5f, 2f);
UtilPlayer.message(player, F.main("SEND", C.cYellow + "You are being sent to server: " + C.cGold + serverName + C.cYellow + "!"));
super(plugin, Rank.ADMIN, "send");
}
@Override
public void Execute(final Player player, final String[] args)
{
Rank playerRank = CommandCenter.GetClientManager().Get(player).GetRank();
if(args == null || args.length == 0)
{
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your arguments are inappropriate for this command!"));
return;
}
else if(args.length == 1)
{
if((playerRank == Rank.OWNER) || (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN))
{
Player sendPlayer;
try
{
sendPlayer = CommandCenter.GetClientManager().Get(args[0]).GetPlayer();
}
catch(NullPointerException npe)
{
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your specified player, " + C.cGold + args[0] + C.cPurple + ", does not exist!"));
return;
}
String currentServer = sendPlayer.getServer().getPluginManager().getPlugin("Arcade").getConfig().getString("serverstatus.name");
UtilPlayer.message(player, F.main("SEND", C.cGold + args[0] + C.cPurple + " is currently on server: " + C.cGold + currentServer + C.cPurple + "!"));
return;
}
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your arguments are not allowed for this command!"));
UtilPlayer.message(player, F.main(Plugin.GetName(), C.cPurple + "Your arguments are inappropriate for this command!"));
return;
}
else if(args.length == 2)
{
if((playerRank == Rank.OWNER) || (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN))
CommandCenter.GetClientManager().checkPlayerName(player, args[0], new Callback<Boolean>()
{
_portal.DoesServerExist(args[1]);
Bukkit.getScheduler().runTaskLater(Plugin.GetPlugin(), new Runnable()
public void run(Boolean playerExists)
{
public void run()
if (!playerExists)
{
Player sendPlayer;
UtilPlayer.message(player, F.main(Plugin.GetName(), C.cPurple + "Player " + C.cGold + args[1] + C.cPurple + " does not exist!"));
return;
}
try
Plugin.DoesServerExist(args[1], new Callback<Boolean>()
{
sendPlayer = CommandCenter.GetClientManager().Get(args[0]).GetPlayer();
}
catch(NullPointerException npe)
public void run(Boolean serverExists)
{
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your specified player, " + C.cGold + args[0] + C.cPurple + ", does not exist!"));
if(!_portal.GetServerExists())
if (!serverExists)
{
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your specified server, " + C.cGold + args[1] + C.cPurple + ", does not exist!"));
}
UtilPlayer.message(player, F.main(Plugin.GetName(), C.cPurple + "Server " + C.cGold + args[1] + C.cPurple + " does not exist!"));
return;
}
if(!_portal.GetServerExists())
{
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your specified server, " + C.cGold + args[1] + C.cPurple + ", does not exist!"));
Plugin.getRepository().addServerTransfer(args[0], args[1]);
UtilPlayer.message(player, F.main(Plugin.GetName(), C.cYellow + "You have sent player: " + C.cGold + args[0] + C.cYellow + " to server: " + C.cGold + args[1] + C.cYellow + "!"));
return;
}
if(sendPlayer.getServer().getPluginManager().getPlugin("Arcade").getConfig().getString("serverstatus.name").equalsIgnoreCase(args[1]))
{
UtilPlayer.message(player, F.main("SEND", C.cGold + args[0] + C.cPurple + " is already on server: " + C.cGold + args[1] + C.cPurple + "!"));
return;
});
}
SendPlayerToServerWithMessage(sendPlayer, args[1]);
UtilPlayer.message(player, F.main("SEND", C.cYellow + "You have sent player: " + C.cGold + args[0] + C.cYellow + " to server: " + C.cGold + args[1] + C.cYellow + "!"));
return;
}
}, 20);
return;
}
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your arguments are not allowed for this command!"));
return;
});
}
else
{
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your arguments are inappropriate for this command!"));
UtilPlayer.message(player, F.main(Plugin.GetName(), C.cPurple + "Your arguments are inappropriate for this command!"));
return;
}
}

View File

@ -1,34 +1,20 @@
package mineplex.core.portal.Commands;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import mineplex.core.command.*;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.portal.Portal;
public class ServerCommand extends CommandBase<Portal>
{
private Portal _portal;
public ServerCommand(Portal plugin)
{
super(plugin, Rank.ALL, "srv","server");
_portal = plugin;
}
private void SendPlayerToServerWithMessage(Player player, String serverName)
{
_portal.SendPlayerToServer(player, serverName);
player.playSound(player.getLocation(), Sound.PORTAL, 0.5f, 2f);
UtilPlayer.message(player, F.main("SERVER", C.cYellow + "You have been sent to server: " + C.cGold + serverName + C.cYellow + "!"));
super(plugin, Rank.ALL, "server");
}
@Override
@ -37,72 +23,86 @@ public class ServerCommand extends CommandBase<Portal>
final Rank playerRank = CommandCenter.GetClientManager().Get(player).GetRank();
final String serverName = Plugin.GetPlugin().getConfig().getString("serverstatus.name");
if(args == null || args.length == 0)
if (args == null || args.length == 0)
{
UtilPlayer.message(player, F.main("SERVER", C.cYellow + "You are currently on server: " + C.cGold + serverName));
UtilPlayer.message(player,
F.main(Plugin.GetName(), C.cYellow + "You are currently on server: " + C.cGold + serverName));
return;
}
else if(args.length == 1)
else if (args.length == 1)
{
_portal.DoesServerExist(args[0]);
Bukkit.getServer().getScheduler().runTaskLater(Plugin.GetPlugin(), new Runnable()
if (serverName.equalsIgnoreCase(args[0]))
{
public void run()
{
if(serverName.equalsIgnoreCase(args[0]))
{
UtilPlayer.message(player, F.main("SERVER", C.cPurple + "You are already on server: " + C.cGold + serverName + C.cPurple + "!"));
return;
}
if(!_portal.GetServerExists())
{
UtilPlayer.message(player, F.main("SERVER", C.cPurple + "Your specified server, " + C.cGold + args[0] + C.cPurple + ", does not exist!"));
return;
}
String servUp = args[0].toUpperCase();
if(!(servUp.contains("HERO") || servUp.contains("ULTRA") || servUp.contains("BETA")
|| servUp.contains("STAFF") || servUp.contains("TEST")))
{
SendPlayerToServerWithMessage(player, args[0]);
return;
}
if(servUp.contains("HERO") && ((playerRank == Rank.OWNER)
|| (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR)
|| (playerRank == Rank.HELPER) || (playerRank == Rank.MAPDEV) || (playerRank == Rank.YOUTUBE)
|| (playerRank == Rank.ULTRA) || (playerRank == Rank.HERO)))
{
SendPlayerToServerWithMessage(player, args[0]);
return;
}
if((servUp.contains("ULTRA") || servUp.contains("BETA")) && ((playerRank == Rank.OWNER)
|| (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR)
|| (playerRank == Rank.HELPER) || (playerRank == Rank.MAPDEV) || (playerRank == Rank.YOUTUBE)
|| (playerRank == Rank.ULTRA)))
{
SendPlayerToServerWithMessage(player, args[0]);
return;
}
if(servUp.contains("STAFF") && ((playerRank == Rank.OWNER)
|| (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR)
|| (playerRank == Rank.HELPER)))
{
SendPlayerToServerWithMessage(player, args[0]);
return;
}
if(servUp.contains("TEST") && ((playerRank == Rank.OWNER)
|| (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR)))
{
SendPlayerToServerWithMessage(player, args[0]);
return;
}
UtilPlayer.message(player, F.main("SERVER", C.cPurple + "Your arguments are not allowed for this command!"));
return;
}
}, 20);
UtilPlayer.message(
player,
F.main(Plugin.GetName(), C.cPurple + "You are already on " + C.cGold + serverName + C.cPurple
+ "!"));
}
else
{
UtilPlayer.message(player, F.main("SERVER", C.cPurple + "Your arguments are inappropriate for this command!"));
Plugin.DoesServerExist(args[0], new Callback<Boolean>()
{
public void run(final Boolean serverExists)
{
if (!serverExists)
{
UtilPlayer.message(
player,
F.main(Plugin.GetName(), C.cPurple + "Server " + C.cGold + args[0]
+ C.cPurple + " does not exist!"));
return;
}
boolean deniedAccess = false;
String servUp = args[0].toUpperCase();
if (servUp.contains("HERO"))
{
if (playerRank.Has(Rank.HERO))
Plugin.SendPlayerToServerWithMessage(player, args[0]);
else
deniedAccess = true;
}
else if (servUp.contains("ULTRA"))
{
if (playerRank.Has(Rank.ULTRA))
Plugin.SendPlayerToServerWithMessage(player, args[0]);
else
deniedAccess = true;
}
else if (servUp.contains("STAFF"))
{
if (playerRank.Has(Rank.HELPER))
Plugin.SendPlayerToServerWithMessage(player, args[0]);
else
deniedAccess = true;
}
else if (servUp.contains("TEST"))
{
if (playerRank.Has(Rank.MODERATOR))
Plugin.SendPlayerToServerWithMessage(player, args[0]);
else
deniedAccess = true;
}
else
{
Plugin.SendPlayerToServerWithMessage(player, args[0]);
}
if (deniedAccess)
{
UtilPlayer.message(
player,
F.main(Plugin.GetName(), C.cPurple + "You don't have permission to join " + C.cGold + args[0]));
}
}
});
}
}
else
{
UtilPlayer.message(player,
F.main(Plugin.GetName(), C.cPurple + "Your arguments are inappropriate for this command!"));
return;
}
}

View File

@ -9,13 +9,18 @@ import java.util.List;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.portal.Commands.*;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -30,8 +35,6 @@ public class Portal extends MiniPlugin
private List<String> _transfers = new ArrayList<String>();
private boolean _retrieve = true;
private boolean _serverExists = false;
public Portal(JavaPlugin plugin)
{
super("Portal", plugin);
@ -49,6 +52,19 @@ public class Portal extends MiniPlugin
}
}
public void SendPlayerToServerWithMessage(Player player, String serverName)
{
SendPlayerToServer(player, serverName);
player.playSound(player.getLocation(), Sound.PORTAL, 0.5f, 2f);
UtilPlayer
.message(
player,
F.main("SERVER", C.cYellow + "You have been sent to server: " + C.cGold + serverName
+ C.cYellow + "!"));
}
public void SendPlayerToServer(final Player player, String serverName)
{
if (_connectingPlayers.contains(player.getName()))
@ -104,23 +120,26 @@ public class Portal extends MiniPlugin
}
}
public void DoesServerExist(final String serverName)
{
synchronized (_transferLock)
public void DoesServerExist(final String serverName, final Callback<Boolean> callback)
{
if (callback == null)
return;
Bukkit.getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
{
public void run()
{
_serverExists = _repository.doesServerExist(serverName);
final boolean serverExists = _repository.doesServerExist(serverName);
Bukkit.getScheduler().runTask(GetPlugin(), new Runnable()
{
public void run()
{
callback.run(serverExists);
}
});
}
}
public boolean GetServerExists()
{
return _serverExists;
});
}
public void AddCommands()
@ -188,4 +207,9 @@ public class Portal extends MiniPlugin
});
}
}
public PortalRepository getRepository()
{
return _repository;
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Mineplex.DDoSProtectionSwitcher</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7

View File

@ -0,0 +1,116 @@
package mineplex.ddos;
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;
public class DDoSProtectionSwitcher
{
public static void main (String args[])
{
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();
}
}
}
}
private static 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());
}
private static 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();
}
}