Use logger instead of System.out

This commit is contained in:
Myles 2016-11-13 13:25:56 +00:00
parent 10a2df5a7d
commit 1c584040ca
13 changed files with 23 additions and 24 deletions

View File

@ -122,7 +122,7 @@ public class BukkitViaInjector implements ViaInjector {
ReflectionUtil.set(bootstrapAcceptor, "childHandler", ((BukkitChannelInitializer) oldInit).getOriginal());
}
} catch (Exception e) {
System.out.println("Failed to remove injection handler, reload won't work with connections, please reboot!");
Via.getPlatform().getLogger().severe("Failed to remove injection handler, reload won't work with connections, please reboot!");
}
}
injectedFutures.clear();
@ -134,7 +134,7 @@ public class BukkitViaInjector implements ViaInjector {
pair.getKey().set(pair.getValue(), ((ListWrapper) o).getOriginalList());
}
} catch (IllegalAccessException e) {
System.out.println("Failed to remove injection, reload won't work with connections, please reboot!");
Via.getPlatform().getLogger().severe("Failed to remove injection, reload won't work with connections, please reboot!");
}
}

View File

@ -78,7 +78,7 @@ public class BukkitViaLoader implements ViaPlatformLoader {
}
}).get(10, TimeUnit.SECONDS);
} catch (Exception e) {
System.out.println("Error fetching hand item: " + e.getClass().getName());
Via.getPlatform().getLogger().severe("Error fetching hand item: " + e.getClass().getName());
if (Via.getManager().isDebug())
e.printStackTrace();
return null;

View File

@ -1,5 +1,6 @@
package us.myles.ViaVersion.bungee.commands;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.bungee.commands.subs.ProbeSubCmd;
import us.myles.ViaVersion.commands.ViaCommandHandler;
@ -8,7 +9,7 @@ public class BungeeCommandHandler extends ViaCommandHandler {
try {
registerSubCommand(new ProbeSubCmd());
} catch (Exception e) {
System.out.println("Failed to register Bungee subcommands");
Via.getPlatform().getLogger().severe("Failed to register Bungee subcommands");
e.printStackTrace();
}
}

View File

@ -2,6 +2,7 @@ package us.myles.ViaVersion.bungee.providers;
import com.google.common.collect.Lists;
import net.md_5.bungee.api.ProxyServer;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.protocols.base.VersionProvider;
@ -16,7 +17,7 @@ public class BungeeVersionProvider extends VersionProvider {
try {
ref = Class.forName("net.md_5.bungee.protocol.ProtocolConstants");
} catch (Exception e) {
System.out.println("Could not detect the ProtocolConstants class");
Via.getPlatform().getLogger().severe("Could not detect the ProtocolConstants class");
e.printStackTrace();
}
}
@ -45,7 +46,7 @@ public class BungeeVersionProvider extends VersionProvider {
return protocol;
}
System.out.println("Panic, no protocol id found for " + info.getProtocolVersion());
Via.getPlatform().getLogger().severe("Panic, no protocol id found for " + info.getProtocolVersion());
return info.getProtocolVersion();
}

View File

@ -4,6 +4,7 @@ import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.handler.codec.MessageToMessageDecoder;
import us.myles.ViaVersion.api.Via;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@ -20,14 +21,12 @@ public class BungeePipelineUtil {
DECODE_METHOD.setAccessible(true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
System.out.println("Netty issue?");
}
try {
ENCODE_METHOD = MessageToByteEncoder.class.getDeclaredMethod("encode", ChannelHandlerContext.class, Object.class, ByteBuf.class);
ENCODE_METHOD.setAccessible(true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
System.out.println("Netty issue?");
}
}

View File

@ -176,7 +176,7 @@ public class PacketWrapper {
if (type instanceof TypeConverter) {
value = (T) ((TypeConverter) type).from(value);
} else {
System.out.println("Possible type mismatch: " + value.getClass().getName() + " -> " + type.getOutputClass());
Via.getPlatform().getLogger().warning("Possible type mismatch: " + value.getClass().getName() + " -> " + type.getOutputClass());
}
}
}
@ -237,7 +237,7 @@ public class PacketWrapper {
if (packetValue.getKey() instanceof TypeConverter) {
value = ((TypeConverter) packetValue.getKey()).from(value);
} else {
System.out.println("Possible type mismatch: " + value.getClass().getName() + " -> " + packetValue.getKey().getOutputClass());
Via.getPlatform().getLogger().warning("Possible type mismatch: " + value.getClass().getName() + " -> " + packetValue.getKey().getOutputClass());
}
}
}

View File

@ -87,8 +87,8 @@ public class MetadataRewriter {
}
} catch (Exception e) {
if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) {
System.out.println("An error occurred with entity type rewriter");
System.out.println("Metadata: " + metadata);
Via.getPlatform().getLogger().warning("An error occurred with entity type rewriter");
Via.getPlatform().getLogger().warning("Metadata: " + metadata);
e.printStackTrace();
}
}
@ -195,8 +195,8 @@ public class MetadataRewriter {
} catch (Exception e) {
metadatas.remove(metadata);
if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) {
System.out.println("An error occurred with entity metadata handler");
System.out.println("Metadata: " + metadata);
Via.getPlatform().getLogger().warning("An error occurred with entity metadata handler");
Via.getPlatform().getLogger().warning("Metadata: " + metadata);
e.printStackTrace();
}
}

View File

@ -52,7 +52,7 @@ public class BlockEntity {
updateBlockEntity(pos, (short) newId, tag, connection);
} catch (Exception e) {
if (Via.getManager().isDebug()) {
System.out.println("Block Entity: " + e.getMessage() + ": " + tag);
Via.getPlatform().getLogger().warning("Block Entity: " + e.getMessage() + ": " + tag);
}
}
}

View File

@ -43,7 +43,7 @@ public class Protocol1_9TO1_8 extends Protocol {
if (Via.getConfig().isForceJsonTransform()) {
return constructJson(line);
} else {
System.out.println("Invalid JSON String: \"" + line + "\" Please report this issue to the ViaVersion Github: " + e.getMessage());
Via.getPlatform().getLogger().warning("Invalid JSON String: \"" + line + "\" Please report this issue to the ViaVersion Github: " + e.getMessage());
return "{\"text\":\"\"}";
}
}

View File

@ -121,7 +121,7 @@ public class MetadataRewriter {
entry.setValue(value);
break;
default:
System.out.println("[Out] Unhandled MetaDataType: " + metaIndex.getNewType());
Via.getPlatform().getLogger().warning("[Out] Unhandled MetaDataType: " + metaIndex.getNewType());
list.remove(entry);
break;
}

View File

@ -1,6 +1,7 @@
package us.myles.ViaVersion.protocols.protocol1_9to1_8.packets;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.entities.Entity1_10Types;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
@ -216,7 +217,7 @@ public class SpawnPackets {
if (tracker.getClientEntityTypes().containsKey(entityID)) {
MetadataRewriter.transform(tracker.getClientEntityTypes().get(entityID), metadataList);
} else {
System.out.println("Unable to find entity for metadata, entity ID: " + entityID);
Via.getPlatform().getLogger().warning("Unable to find entity for metadata, entity ID: " + entityID);
metadataList.clear();
}
}
@ -296,7 +297,6 @@ public class SpawnPackets {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
short item = wrapper.read(Type.SHORT);
// System.out.println(item);
if (item != 0) {
PacketWrapper packet = new PacketWrapper(0x3C, null, wrapper.user());
packet.write(Type.VAR_INT, wrapper.get(Type.VAR_INT, 0));
@ -322,7 +322,7 @@ public class SpawnPackets {
if (tracker.getClientEntityTypes().containsKey(entityID)) {
MetadataRewriter.transform(tracker.getClientEntityTypes().get(entityID), metadataList);
} else {
System.out.println("Unable to find entity for metadata, entity ID: " + entityID);
Via.getPlatform().getLogger().warning("Unable to find entity for metadata, entity ID: " + entityID);
metadataList.clear();
}
}

View File

@ -21,14 +21,12 @@ public class PipelineUtil {
DECODE_METHOD.setAccessible(true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
System.out.println("Netty issue?");
}
try {
ENCODE_METHOD = MessageToByteEncoder.class.getDeclaredMethod("encode", ChannelHandlerContext.class, Object.class, ByteBuf.class);
ENCODE_METHOD.setAccessible(true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
System.out.println("Netty issue?");
}
}

View File

@ -114,7 +114,7 @@ public class SpongeViaInjector implements ViaInjector {
ReflectionUtil.set(bootstrapAcceptor, "childHandler", ((SpongeChannelInitializer) oldInit).getOriginal());
}
} catch (Exception e) {
System.out.println("Failed to remove injection handler, reload won't work with connections, please reboot!");
Via.getPlatform().getLogger().severe("Failed to remove injection handler, reload won't work with connections, please reboot!");
}
}
injectedFutures.clear();
@ -126,7 +126,7 @@ public class SpongeViaInjector implements ViaInjector {
pair.getKey().set(pair.getValue(), ((ListWrapper) o).getOriginalList());
}
} catch (IllegalAccessException e) {
System.out.println("Failed to remove injection, reload won't work with connections, please reboot!");
Via.getPlatform().getLogger().severe("Failed to remove injection, reload won't work with connections, please reboot!");
}
}