@Test public void testOnGameTick() { List<NPC> ghosts = cerberusPlugin.getGhosts(); ghosts.addAll(Arrays.asList( mockNpc(new LocalPoint(0, 0)), mockNpc(new LocalPoint(1, 0)), mockNpc(new LocalPoint(0, 5)), mockNpc(new LocalPoint(2, 0)), mockNpc(new LocalPoint(2, 5)), mockNpc(new LocalPoint(1, 5)) )); cerberusPlugin.onGameTick(new GameTick()); assertEquals(ghosts.get(0).getLocalLocation(), new LocalPoint(0, 0)); assertEquals(ghosts.get(1).getLocalLocation(), new LocalPoint(1, 0)); assertEquals(ghosts.get(2).getLocalLocation(), new LocalPoint(2, 0)); assertEquals(ghosts.get(3).getLocalLocation(), new LocalPoint(0, 5)); assertEquals(ghosts.get(4).getLocalLocation(), new LocalPoint(1, 5)); assertEquals(ghosts.get(5).getLocalLocation(), new LocalPoint(2, 5)); }
@Subscribe public void onGameTick(GameTick gameTick) { if (ghosts.isEmpty()) { return; } Collections.sort(ghosts, (a, b) -> ComparisonChain.start() .compare(a.getLocalLocation().getY(), b.getLocalLocation().getY()) .compare(a.getLocalLocation().getX(), b.getLocalLocation().getX()) .result()); }
CerberusPlugin extends Plugin { @Subscribe public void onGameTick(GameTick gameTick) { if (ghosts.isEmpty()) { return; } Collections.sort(ghosts, (a, b) -> ComparisonChain.start() .compare(a.getLocalLocation().getY(), b.getLocalLocation().getY()) .compare(a.getLocalLocation().getX(), b.getLocalLocation().getX()) .result()); } }
CerberusPlugin extends Plugin { @Subscribe public void onGameTick(GameTick gameTick) { if (ghosts.isEmpty()) { return; } Collections.sort(ghosts, (a, b) -> ComparisonChain.start() .compare(a.getLocalLocation().getY(), b.getLocalLocation().getY()) .compare(a.getLocalLocation().getX(), b.getLocalLocation().getX()) .result()); }  }
CerberusPlugin extends Plugin { @Subscribe public void onGameTick(GameTick gameTick) { if (ghosts.isEmpty()) { return; } Collections.sort(ghosts, (a, b) -> ComparisonChain.start() .compare(a.getLocalLocation().getY(), b.getLocalLocation().getY()) .compare(a.getLocalLocation().getX(), b.getLocalLocation().getX()) .result()); }  @Override Overlay getOverlay(); @Subscribe void onNpcSpawned(final NpcSpawned event); @Subscribe void onNpcDespawned(final NpcDespawned event); @Subscribe void onGameTick(GameTick gameTick); }
CerberusPlugin extends Plugin { @Subscribe public void onGameTick(GameTick gameTick) { if (ghosts.isEmpty()) { return; } Collections.sort(ghosts, (a, b) -> ComparisonChain.start() .compare(a.getLocalLocation().getY(), b.getLocalLocation().getY()) .compare(a.getLocalLocation().getX(), b.getLocalLocation().getX()) .result()); }  @Override Overlay getOverlay(); @Subscribe void onNpcSpawned(final NpcSpawned event); @Subscribe void onNpcDespawned(final NpcDespawned event); @Subscribe void onGameTick(GameTick gameTick);  }