Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.IOException;
- import java.io.PrintStream;
- import java.net.InetSocketAddress;
- import java.util.logging.Logger;
- import java.util.logging.Level;
- import java.util.Date;
- import java.util.SimpleDateFormat;
- import net.minecraft.client.Minecraft;
- public class mod_chatlogfix extends BaseMod
- {
- public File outdir;
- public File curLogFile;
- public PrintStream outstream;
- private static Logger loggy = ModLoader.getLogger();
- public static final SimpleDateFormat format = new SimpleDateFormat("-yyyy-MM-dd");
- public mod_chatlogfix()
- {
- String s = "Herpaderp, we don't use constructors here in CorrectLand!";
- }
- public String getVersion()
- {
- return "1.0 by Riking";
- }
- public void load()
- {
- try {
- outdir = new File(ModLoader.getMinecraftInstance().b(), "/logs");
- outdir.mkdirs();
- } catch (IOException e) {
- ModLoader.throwException("ChatLog: Failed to create directories");
- }
- curLogFile = null;
- outstream = null;
- }
- public void receiveChatPacket(String text)
- {
- loggy.finest("ChatLog: recieved chat packet");
- if (curLogFile == null || outstream == null)
- {
- loggy.warning("ChatLog: recieved message while output was not set up. Aborting write.");
- return;
- }
- outstream.println(text);
- }
- /**
- * Create the output File, and open the output stream.
- */
- // serverConnect(NetClientHandler handler)
- public void serverConnect(adl handler)
- {
- try {
- // final NetworkManager networkmanager = ModLoader.getPrivateValue(NetClientHandler.class, handler, "netManager");
- final lg networkmanager = ModLoader.getPrivateValue(adl.class, handler, "g");
- // bla bla bla bla (NetworkManager.class, networkmanager, "remoteSocketAddress");
- final InetSocketAddress addr = (InetSocketAddress) ModLoader.getPrivateValue(lg.class, networkmanager, "i");
- final String serveraddress = addr.getHostName();
- StringBuilder sb = new StringBuilder(serveraddress);
- sb.append(format.format(new Date()));
- sb.append(".log");
- curLogFile = new File(outdir, sb.toString());
- outstream = new PrintStream(curLogFile);
- } catch (Throwable error) {
- ModLoader.throwException("ChatLog: failed to initialize log",error);
- }
- }
- /**
- * Close the output stream and anull the File object.
- */
- public void serverDisconnect()
- {
- try {
- outstream.close();
- } catch (Throwable error) {
- //}catch (Exception error) {
- ModLoader.throwException("ChatLog: failed to write output",error);
- }
- finally {
- curLogFile = null;
- outstream = null;
- }
- }
- }
- /* Location: C:\Users\Kane\Downloads\chatlog beta 2.zip
- * Qualified Name: mod_chatlog
- * JD-Core Version: 0.6.0
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement