reformatted all src files (#141)
This commit is contained in:
@@ -19,6 +19,10 @@
|
||||
package appeng.server.subcommands;
|
||||
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.server.ISubCommand;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
@@ -26,76 +30,55 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.server.ISubCommand;
|
||||
|
||||
public class ChunkLogger implements ISubCommand {
|
||||
|
||||
public class ChunkLogger implements ISubCommand
|
||||
{
|
||||
private boolean enabled = false;
|
||||
|
||||
private boolean enabled = false;
|
||||
@SubscribeEvent
|
||||
public void onChunkLoadEvent(final ChunkEvent.Load event) {
|
||||
if (!event.getWorld().isRemote) {
|
||||
AELog.info("Chunk Loaded: " + event.getChunk().x + ", " + event.getChunk().z);
|
||||
this.displayStack();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onChunkLoadEvent( final ChunkEvent.Load event )
|
||||
{
|
||||
if( !event.getWorld().isRemote )
|
||||
{
|
||||
AELog.info( "Chunk Loaded: " + event.getChunk().x + ", " + event.getChunk().z );
|
||||
this.displayStack();
|
||||
}
|
||||
}
|
||||
private void displayStack() {
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.CHUNK_LOGGER_TRACE)) {
|
||||
boolean output = false;
|
||||
for (final StackTraceElement e : Thread.currentThread().getStackTrace()) {
|
||||
if (output) {
|
||||
AELog.info(" " + e.getClassName() + '.' + e.getMethodName() + " (" + e.getLineNumber() + ')');
|
||||
} else {
|
||||
output = e.getClassName().contains("EventBus") && e.getMethodName().contains("post");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void displayStack()
|
||||
{
|
||||
if( AEConfig.instance().isFeatureEnabled( AEFeature.CHUNK_LOGGER_TRACE ) )
|
||||
{
|
||||
boolean output = false;
|
||||
for( final StackTraceElement e : Thread.currentThread().getStackTrace() )
|
||||
{
|
||||
if( output )
|
||||
{
|
||||
AELog.info( " " + e.getClassName() + '.' + e.getMethodName() + " (" + e.getLineNumber() + ')' );
|
||||
}
|
||||
else
|
||||
{
|
||||
output = e.getClassName().contains( "EventBus" ) && e.getMethodName().contains( "post" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void onChunkUnloadEvent(final ChunkEvent.Unload unload) {
|
||||
if (!unload.getWorld().isRemote) {
|
||||
AELog.info("Chunk Unloaded: " + unload.getChunk().x + ", " + unload.getChunk().z);
|
||||
this.displayStack();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onChunkUnloadEvent( final ChunkEvent.Unload unload )
|
||||
{
|
||||
if( !unload.getWorld().isRemote )
|
||||
{
|
||||
AELog.info( "Chunk Unloaded: " + unload.getChunk().x + ", " + unload.getChunk().z );
|
||||
this.displayStack();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String getHelp(final MinecraftServer srv) {
|
||||
return "commands.ae2.ChunkLogger";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp( final MinecraftServer srv )
|
||||
{
|
||||
return "commands.ae2.ChunkLogger";
|
||||
}
|
||||
@Override
|
||||
public void call(final MinecraftServer srv, final String[] data, final ICommandSender sender) {
|
||||
this.enabled = !this.enabled;
|
||||
|
||||
@Override
|
||||
public void call( final MinecraftServer srv, final String[] data, final ICommandSender sender )
|
||||
{
|
||||
this.enabled = !this.enabled;
|
||||
|
||||
if( this.enabled )
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register( this );
|
||||
sender.sendMessage( new TextComponentTranslation( "commands.ae2.ChunkLoggerOn" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.unregister( this );
|
||||
sender.sendMessage( new TextComponentTranslation( "commands.ae2.ChunkLoggerOff" ) );
|
||||
}
|
||||
}
|
||||
if (this.enabled) {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
sender.sendMessage(new TextComponentTranslation("commands.ae2.ChunkLoggerOn"));
|
||||
} else {
|
||||
MinecraftForge.EVENT_BUS.unregister(this);
|
||||
sender.sendMessage(new TextComponentTranslation("commands.ae2.ChunkLoggerOff"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user