package me.nallar.tickthreading.minecraft.commands;

import java.util.List;

import me.nallar.tickthreading.minecraft.TickThreading;
import me.nallar.tickthreading.util.TableFormatter;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;

public class TicksCommand extends Command {
	public static String name = "ticks";

	@Override
	public String getCommandName() {
		return name;
	}

	@Override
	public boolean canCommandSenderUseCommand(ICommandSender commandSender) {
		return !TickThreading.instance.requireOpForTicksCommand || super.canCommandSenderUseCommand(commandSender);
	}

	@Override
	public void processCommand(ICommandSender commandSender, List<String> arguments) {
		World world = null;
		if (!arguments.isEmpty()) {
			try {
				world = DimensionManager.getWorld(Integer.valueOf(arguments.get(0)));
			} catch (Exception ignored) {
			}
		} else if (commandSender instanceof Entity) {
			world = ((Entity) commandSender).worldObj;
		}
		if (world == null) {
			sendChat(commandSender, "Usage: /ticks [dimensionid]");
			return;
		}
		sendChat(commandSender, String.valueOf(TickThreading.instance.getManager(world).writeDetailedStats(new TableFormatter(commandSender))));
	}
}

@@ -833,15 +833,49 @@
 d = 
-null;%0D%0A
+DimensionManager.getWorld(0);%0D%0A%09%09try %7B%0D%0A%09
 %09%09if
@@ -904,23 +904,25 @@
 ) %7B%0D%0A%09%09%09
+%09
 try %7B%0D%0A
+%09
 %09%09%09%09worl
@@ -991,16 +991,17 @@
 ));%0D%0A%09%09%09
+%09
 %7D catch 
@@ -1027,16 +1027,17 @@
  %7B%0D%0A
+%09
 %09%09%09%7D%0D%0A%09%09
 %7D el
@@ -1032,16 +1032,17 @@
 %09%09%09%7D%0D%0A%09%09
+%09
 %7D else i
@@ -1083,16 +1083,17 @@
 ) %7B%0D%0A%09%09%09
+%09
 world = 
@@ -1132,32 +1132,36 @@
 j;%0D%0A
+%09
 %09%09%7D%0D%0A%09%09
-if (world == null
+%7D catch (Exception e
 ) %7B%0D

Set default world for /ticks