/* handle what happens when the player opens the compost bin */ public void openCompostBin(final int index) { // check if the time elapsed is enough to rot the compost int timerRequired; timerRequired = compostBins[index] == 200 ? 90 : 45; if (World.getWorld().getUptime() - compostBinsTimer[index] >= timerRequired) { compostBins[index] += 50; player.playAnimation(new Animation(834, 0)); World.getWorld() .schedule( new ScheduledTask(2, false) { @Override public void execute() { updateCompostBin(index); stop(); } @Override public void stop() { super.stop(); } }); } else { player.sendMessage("The compost bin is still rotting. I should wait until it is complete."); } }
@Override public void synchronize() { MobRepository<Player> players = World.getWorld().getPlayerRepository(); MobRepository<Npc> npcs = World.getWorld().getNpcRepository(); int playerCount = players.size(); int npcCount = npcs.size(); phaser.bulkRegister(playerCount); for (Player player : players) { SynchronizationTask task = new PrePlayerSynchronizationTask(player); executor.submit(new PhasedSynchronizationTask(phaser, task)); } phaser.arriveAndAwaitAdvance(); phaser.bulkRegister(npcCount); for (Npc npc : npcs) { SynchronizationTask task = new PreNpcSynchronizationTask(npc); executor.submit(new PhasedSynchronizationTask(phaser, task)); } phaser.arriveAndAwaitAdvance(); phaser.bulkRegister(playerCount); for (Player player : players) { SynchronizationTask task = new PlayerSynchronizationTask(player); executor.submit(new PhasedSynchronizationTask(phaser, task)); } phaser.arriveAndAwaitAdvance(); phaser.bulkRegister(playerCount); for (Player player : players) { SynchronizationTask task = new NpcSynchronizationTask(player); executor.submit(new PhasedSynchronizationTask(phaser, task)); } phaser.arriveAndAwaitAdvance(); phaser.bulkRegister(playerCount); for (Player player : players) { SynchronizationTask task = new PostPlayerSynchronizationTask(player); executor.submit(new PhasedSynchronizationTask(phaser, task)); } phaser.arriveAndAwaitAdvance(); phaser.bulkRegister(npcCount); for (Npc npc : npcs) { SynchronizationTask task = new PostNpcSynchronizationTask(npc); executor.submit(new PhasedSynchronizationTask(phaser, task)); } phaser.arriveAndAwaitAdvance(); }
@Override public GamePacket encode(TimeMethod method) { GamePacketBuilder builder = new GamePacketBuilder(4); builder.put(DataType.BYTE, World.getWorld().getId()); // 1 builder.put(DataType.INT, World.getWorld().getObjects().size()); // 1 builder.put(DataType.INT, World.getWorld().getNpcRepository().size()); builder.put(DataType.INT, World.getWorld().getItems().size()); builder.put(DataType.INT, World.getWorld().getRegionManager().size()); builder.put(DataType.INT, method.getTime()); // 4 ThreadMXBean bean = ManagementFactory.getThreadMXBean(); builder.put(DataType.INT, bean.getThreadCount()); builder.put(DataType.INT, SystemUtil.getCpuUsage()); builder.put(DataType.INT, SystemUtil.getRamUsage()); builder.put(DataType.BYTE, SystemUpdateTask.isUpdating() ? 1 : 0); // 34 return builder.toGamePacket(); }
/* handle what happens when the player close the compost bin */ public void closeCompostBin(final int index) { compostBins[index] = tempCompostState * 100; compostBinsTimer[index] = World.getWorld().getUptime(); player.playAnimation(new Animation(835, 0)); World.getWorld() .schedule( new ScheduledTask(2, false) { @Override public void execute() { player.sendMessage("You close the compost bin, and its content start to rot."); updateCompostBin(index); stop(); } public void stop() { super.stop(); } }); }
@Override public void execute(Player player, Command command) { PluginManager mgr = World.getWorld().getPluginManager(); final Set<String> authors = mgr.getAuthors(); List<String> text = new ArrayList<>(12 + authors.size()); text.add("@dre@Apollo"); text.add("@dre@Introduction"); text.add(""); text.add("This server is based on Apollo, a lightweight, fast, secure"); text.add("and open-source RuneScape emulator. For more"); text.add("information about Apollo, visit the website at:"); text.add("@dbl@https://github.com/apollo-rsps/apollo"); text.add(""); text.add("Apollo is released under the terms of the ISC license."); text.add(""); text.add("@dre@Credits"); text.add(""); text.addAll(authors); player.sendQuestInterface(text); }
/* handle compost bin filling */ @SuppressWarnings("unused") public void fillCompostBin(final Position binPosition, final int organicItemUsed) { final CompostBinLocations compostBinLocations = CompostBinLocations.forPosition(binPosition); final int index = compostBinLocations.getCompostIndex(); if (compostBinLocations == null) { return; } int incrementFactor = 0; // setting up the different increments. for (int normalCompost : COMPOST_ORGANIC) { if (organicItemUsed == normalCompost) { incrementFactor = 2; } } for (int superCompost : SUPER_COMPOST_ORGANIC) { if (organicItemUsed == superCompost) { incrementFactor = 17; } } if (organicItemUsed == TOMATO) { if (compostBins[index] % 77 == 0) { incrementFactor = 77; } else { incrementFactor = 2; } } // checking if the item used was an organic item. if (incrementFactor == 0) { player.sendMessage( "You need to put organic items into the compost bin in order to make compost."); return; } final int factor = incrementFactor; // launching the main event for filling the compost bin. World.getWorld() .schedule( new ScheduledTask(2, false) { @Override public void execute() { if (!player.getInventory().contains(organicItemUsed) || organicItemAdded[index] == 15) { stop(); return; } organicItemAdded[index]++; player.playAnimation(new Animation(832, 0)); player.getInventory().remove(new Item(organicItemUsed)); compostBins[index] += factor; updateCompostBin(index); } @Override public void stop() { player.stopAnimation(); super.stop(); } }); }