private void unhook() { if (!isHookInstalled) return; isHookInstalled = false; final Collection<World> worlds = Arrays.<World>asList(DimensionManager.getWorlds()); synchronized (EntityModule.class) { for (World world : worlds) { uninstallHook(world); } } }
private void addDimensions(List<TeleportDestinationClientInfo> destinationList) { WorldServer[] worlds = DimensionManager.getWorlds(); for (WorldServer world : worlds) { int id = world.provider.dimensionId; TeleportDestination destination = new TeleportDestination(new Coordinate(0, 70, 0), id); destination.setName("Dimension: " + id); TeleportDestinationClientInfo teleportDestinationClientInfo = new TeleportDestinationClientInfo(destination); String dimName = world.provider.getDimensionName(); teleportDestinationClientInfo.setDimensionName(dimName); destinationList.add(teleportDestinationClientInfo); } }
private void hook() { if (isHookInstalled) return; isHookInstalled = true; HookRegistrar.Instance().hookEntityList(new TickEntities()); final Collection<World> worlds = Arrays.<World>asList(DimensionManager.getWorlds()); synchronized (EntityModule.class) { for (World world : worlds) { installHook(world); } } }
@Override public void processCommand(final ICommandSender commandSender, List<String> arguments) { World world = null; int time_ = 30; boolean location = false; Integer x = null; Integer z = null; try { if ("c".equals(arguments.get(0))) { location = true; if (arguments.size() > 2) { x = Integer.valueOf(arguments.remove(1)); z = Integer.valueOf(arguments.remove(1)); } } if (arguments.size() > 1) { time_ = Integer.valueOf(arguments.get(1)); } if (arguments.size() > 2) { world = DimensionManager.getWorld(Integer.valueOf(arguments.get(2))); } else if (location && commandSender instanceof Entity) { world = ((Entity) commandSender).worldObj; } if (location && x == null) { Entity entity = (Entity) commandSender; x = entity.chunkCoordX; z = entity.chunkCoordZ; } } catch (Exception e) { sendChat( commandSender, "Usage: /profile [e/(c [chunk x] [chunk z])] [time=30] [dimensionid=all]"); return; } final List<World> worlds = new ArrayList<World>(); if (world == null) { Collections.addAll(worlds, DimensionManager.getWorlds()); } else { worlds.add(world); } final int time = time_; final EntityTickProfiler entityTickProfiler = EntityTickProfiler.ENTITY_TICK_PROFILER; if (!entityTickProfiler.startProfiling( new Runnable() { @Override public void run() { sendChat( commandSender, entityTickProfiler.writeStringData(new TableFormatter(commandSender)).toString()); } }, location ? ProfilingState.CHUNK : ProfilingState.GLOBAL, time, worlds)) { sendChat(commandSender, "Someone else is currently profiling."); } if (location) { entityTickProfiler.setLocation(x, z); } sendChat( commandSender, "Profiling for " + time + " seconds in " + (world == null ? "all worlds " : Log.name(world)) + (location ? " at " + x + ',' + z : "")); }