Fix dodgy gitignore

This commit is contained in:
md_5 2012-10-05 16:20:07 +10:00
parent 30330dd2bb
commit 01cf90a8ba
3 changed files with 123 additions and 1 deletions

2
.gitignore vendored
View File

@ -34,5 +34,5 @@
.idea/ .idea/
# other files # other files
*log* /*log*
*.yml *.yml

View File

@ -0,0 +1,83 @@
package net.md_5.bungee;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.logging.FileHandler;
import java.util.logging.Formatter;
import java.util.logging.Level;
import java.util.logging.LogRecord;
public class Logger extends java.util.logging.Logger {
private static final Formatter formatter = new ConsoleLogFormatter();
private static final Logger instance = new Logger();
public Logger() {
super("RubberBand", null);
try {
FileHandler handler = new FileHandler("proxy.log", BungeeCord.instance.config.logNumLines, 1, true);
handler.setFormatter(formatter);
addHandler(handler);
} catch (IOException | SecurityException ex) {
System.err.println("Could not register logger!");
ex.printStackTrace();
}
}
@Override
public void log(LogRecord record) {
super.log(record);
String message = formatter.format(record);
if (record.getLevel() == Level.SEVERE || record.getLevel() == Level.WARNING) {
System.err.print(message);
} else {
System.out.print(message);
}
}
public static Logger $() {
return instance;
}
public static class ConsoleLogFormatter extends Formatter {
private SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
@Override
public String format(LogRecord logrecord) {
StringBuilder formatted = new StringBuilder();
formatted.append(formatter.format(logrecord.getMillis()));
Level level = logrecord.getLevel();
if (level == Level.FINEST) {
formatted.append(" [FINEST] ");
} else if (level == Level.FINER) {
formatted.append(" [FINER] ");
} else if (level == Level.FINE) {
formatted.append(" [FINE] ");
} else if (level == Level.INFO) {
formatted.append(" [INFO] ");
} else if (level == Level.WARNING) {
formatted.append(" [WARNING] ");
} else if (level == Level.SEVERE) {
formatted.append(" [SEVERE] ");
}
formatted.append(logrecord.getMessage());
formatted.append('\n');
Throwable throwable = logrecord.getThrown();
if (throwable != null) {
StringWriter writer = new StringWriter();
throwable.printStackTrace(new PrintWriter(writer));
formatted.append(writer);
}
return formatted.toString();
}
}
}

View File

@ -0,0 +1,39 @@
package net.md_5.bungee.packet;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@ToString
@EqualsAndHashCode(callSuper = false)
public class Packet1Login extends DefinedPacket {
public int entityId;
public String levelType;
public byte gameMode;
public byte dimension;
public byte difficulty;
public byte unused;
public byte maxPlayers;
public Packet1Login(int entityId, String levelType, byte gameMode, byte dimension, byte difficulty, byte unused, byte maxPlayers) {
super(0x01);
writeInt(entityId);
writeUTF(levelType);
writeByte(gameMode);
writeByte(dimension);
writeByte(difficulty);
writeByte(unused);
writeByte(maxPlayers);
}
public Packet1Login(byte[] buf) {
super(0x01, buf);
this.entityId = readInt();
this.levelType = readUTF();
this.gameMode = readByte();
this.dimension = readByte();
this.difficulty = readByte();
this.unused = readByte();
this.maxPlayers = readByte();
}
}