diff --git a/src/main/java/com/comandante/creeper/command/DelCommand.java b/src/main/java/com/comandante/creeper/command/DelCommand.java index d25cc8ba65e3dec50fffe536473867900efbe16f..ce1c80f23955c982a9bbb9a0efb270862afc69fa 100644 --- a/src/main/java/com/comandante/creeper/command/DelCommand.java +++ b/src/main/java/com/comandante/creeper/command/DelCommand.java @@ -22,14 +22,8 @@ public class DelCommand extends Command { @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { - execCommand(ctx, e, new CommandRunnable() { - @Override - public void run() { - - } - }); - try { - if (originalMessageParts.size() <= 1) { + execCommand(ctx, e, () -> { + if (originalMessageParts.size() <= 1) { write(returnAllSettings()); return; } @@ -37,9 +31,7 @@ public class DelCommand extends Command { String desiredSettingName = originalMessageParts.get(0); player.removePlayerSetting(desiredSettingName); write("Setting removed.\r\n"); - } finally { - super.messageReceived(ctx, e); - } + }); } private String returnAllSettings() { diff --git a/src/main/java/com/comandante/creeper/command/LootCommand.java b/src/main/java/com/comandante/creeper/command/LootCommand.java index 68ede92d144e441bb4ef843f80c38a89df22b852..8695e66f15e1736badeab01b3efa76f31ab43079 100644 --- a/src/main/java/com/comandante/creeper/command/LootCommand.java +++ b/src/main/java/com/comandante/creeper/command/LootCommand.java @@ -28,7 +28,7 @@ public class LootCommand extends Command { public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { execCommand(ctx, e, () -> { if (originalMessageParts.size() > 1) { - player.getInventory().forEach(item -> { + for (Item item : player.getInventory()) { if (item.getItemTypeId() == Item.CORPSE_ID_RESERVED) { Loot loot = item.getLoot(); if (loot != null) { @@ -38,18 +38,19 @@ public class LootCommand extends Command { player.incrementGold(gold); } Set<Item> items = lootManager.lootItemsReturn(loot); - items.forEach(i -> { + for (Item i: items) { gameManager.acquireItem(player, i.getItemId()); - write("You looted " + i.getItemName() + " from a " + item.getItemName() + ".\r\n"); - }); + write("You looted " + i.getItemName() + " from a " + item.getItemName() + ".\r\n"); + } if (gold < 0 && items.size() == 0) { write("You looted nothing from " + item.getItemName() + "\r\n"); } } player.removeInventoryId(item.getItemId()); entityManager.removeItem(item); + return; } - }); + } } }); } diff --git a/src/test/com/comandante/creeper/player/NpcTestHarness.java b/src/test/com/comandante/creeper/player/NpcTestHarness.java index f682686a2a812e45f6c11ed4766e5b830e1f9efb..0e251edec9c70688fb55a80827e562a00a1c02e3 100644 --- a/src/test/com/comandante/creeper/player/NpcTestHarness.java +++ b/src/test/com/comandante/creeper/player/NpcTestHarness.java @@ -71,7 +71,7 @@ public class NpcTestHarness { int npcWins = 0; totalFightRounds = 0; - int totalIterations = 100000; + int totalIterations = 1000; for (int i = 0; i < totalIterations; i++) { String username = UUID.randomUUID().toString(); Player player = createRandomPlayer(username);