Fixed errors with server data thread
No longer crashes when finished sending server data.
This commit is contained in:
parent
60509d2d2f
commit
271335b1dd
3 changed files with 16 additions and 23 deletions
|
@ -18,6 +18,7 @@ import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||||
import cpw.mods.fml.server.FMLServerHandler;
|
import cpw.mods.fml.server.FMLServerHandler;
|
||||||
|
|
||||||
import net.minecraft.src.*;
|
import net.minecraft.src.*;
|
||||||
|
import net.uberkat.obsidian.client.ThreadServerData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Official Obsidian Ingots utilities. All miscellaneous methods are located here.
|
* Official Obsidian Ingots utilities. All miscellaneous methods are located here.
|
||||||
|
@ -62,14 +63,6 @@ public class ObsidianUtils
|
||||||
return "There is no news to show.";
|
return "There is no news to show.";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends Obsidian Ingots server information about this mod.
|
|
||||||
*/
|
|
||||||
public static void sendServerData()
|
|
||||||
{
|
|
||||||
new ThreadServerData();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns one line of HTML from the url.
|
* Returns one line of HTML from the url.
|
||||||
* @param urlToRead - URL to read from.
|
* @param urlToRead - URL to read from.
|
||||||
|
|
|
@ -117,7 +117,7 @@ public class ClientProxy extends CommonProxy
|
||||||
System.out.println("[ObsidianIngots] Beginning utility initiative...");
|
System.out.println("[ObsidianIngots] Beginning utility initiative...");
|
||||||
ObsidianIngots.latestVersionNumber = ObsidianUtils.getLatestVersion();
|
ObsidianIngots.latestVersionNumber = ObsidianUtils.getLatestVersion();
|
||||||
ObsidianIngots.recentNews = ObsidianUtils.getRecentNews();
|
ObsidianIngots.recentNews = ObsidianUtils.getRecentNews();
|
||||||
ObsidianUtils.sendServerData();
|
new ThreadServerData();
|
||||||
System.out.println("[ObsidianIngots] Utility initiative complete.");
|
System.out.println("[ObsidianIngots] Utility initiative complete.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package net.uberkat.obsidian.common;
|
package net.uberkat.obsidian.client;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
@ -8,6 +8,8 @@ import java.net.Socket;
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
|
|
||||||
import net.minecraft.src.ModLoader;
|
import net.minecraft.src.ModLoader;
|
||||||
|
import net.uberkat.obsidian.common.ObsidianIngots;
|
||||||
|
import net.uberkat.obsidian.common.ObsidianUtils;
|
||||||
|
|
||||||
public class ThreadServerData extends Thread
|
public class ThreadServerData extends Thread
|
||||||
{
|
{
|
||||||
|
@ -27,25 +29,23 @@ public class ThreadServerData extends Thread
|
||||||
InetAddress address = InetAddress.getByName(ObsidianIngots.hostIP);
|
InetAddress address = InetAddress.getByName(ObsidianIngots.hostIP);
|
||||||
Socket socket = new Socket(address, ObsidianIngots.hostPort);
|
Socket socket = new Socket(address, ObsidianIngots.hostPort);
|
||||||
PrintWriter writer = new PrintWriter(socket.getOutputStream());
|
PrintWriter writer = new PrintWriter(socket.getOutputStream());
|
||||||
if(ObsidianUtils.isMultiplayer())
|
writer.println("USER:" + FMLClientHandler.instance().getClient().session.username);
|
||||||
{
|
|
||||||
writer.println("USER:server");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(FMLClientHandler.instance().getClient().thePlayer != null)
|
|
||||||
{
|
|
||||||
writer.println("USER:" + FMLClientHandler.instance().getClient().thePlayer.username);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
writer.println("USER:client");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
writer.println("DONE");
|
writer.println("DONE");
|
||||||
writer.close();
|
writer.close();
|
||||||
socket.close();
|
socket.close();
|
||||||
|
try {
|
||||||
|
finalize();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
System.err.println("[ObsidianIngots] Could not end server thread, error was '" + e.getMessage() + ".'");
|
||||||
|
}
|
||||||
} catch (IOException e)
|
} catch (IOException e)
|
||||||
{
|
{
|
||||||
System.err.println("[ObsidianIngots] Could not connect to server, error was '" + e.getMessage() + ".'");
|
System.err.println("[ObsidianIngots] Could not connect to server, error was '" + e.getMessage() + ".'");
|
||||||
|
try {
|
||||||
|
finalize();
|
||||||
|
} catch (Throwable e1) {
|
||||||
|
System.err.println("[ObsidianIngots] Could not end server thread, error was '" + e.getMessage() + ".'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue