From 86b56d5e55e70996d24f7881725c414210449a86 Mon Sep 17 00:00:00 2001 From: Chris Kearney <chris@kearneymail.com> Date: Mon, 8 Aug 2016 17:41:29 -0700 Subject: [PATCH] fix for loot vs normal inventory full messages --- .../com/comandante/creeper/command/LootCommand.java | 3 +-- .../com/comandante/creeper/managers/GameManager.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/comandante/creeper/command/LootCommand.java b/src/main/java/com/comandante/creeper/command/LootCommand.java index 8695e66f..f7d1e606 100644 --- a/src/main/java/com/comandante/creeper/command/LootCommand.java +++ b/src/main/java/com/comandante/creeper/command/LootCommand.java @@ -12,7 +12,6 @@ import java.util.Arrays; import java.util.List; import java.util.Locale; import java.util.Set; -import java.util.function.Consumer; public class LootCommand extends Command { @@ -39,7 +38,7 @@ public class LootCommand extends Command { } Set<Item> items = lootManager.lootItemsReturn(loot); for (Item i: items) { - gameManager.acquireItem(player, i.getItemId()); + gameManager.acquireItem(player, i.getItemId(), true); write("You looted " + i.getItemName() + " from a " + item.getItemName() + ".\r\n"); } if (gold < 0 && items.size() == 0) { diff --git a/src/main/java/com/comandante/creeper/managers/GameManager.java b/src/main/java/com/comandante/creeper/managers/GameManager.java index 2c3f26b0..258865bc 100755 --- a/src/main/java/com/comandante/creeper/managers/GameManager.java +++ b/src/main/java/com/comandante/creeper/managers/GameManager.java @@ -374,6 +374,10 @@ public class GameManager { } public boolean acquireItem(Player player, String itemId) { + return acquireItem(player, itemId, false); + } + + public boolean acquireItem(Player player, String itemId, boolean isFromLoot) { synchronized (interner.intern(itemId)) { Stats playerStatsWithEquipmentAndLevel = player.getPlayerStatsWithEquipmentAndLevel(); if (player.getInventory().size() < playerStatsWithEquipmentAndLevel.getInventorySize()) { @@ -385,8 +389,10 @@ public class GameManager { } else { Item itemEntity = entityManager.getItemEntity(itemId); channelUtils.write(player.getPlayerId(), "Your inventory is full, drop some items to free up room.\r\n"); - player.getCurrentRoom().addPresentItem(itemId); - roomSay(player.getCurrentRoom().getRoomId(), player.getPlayerName() + " dropped " + itemEntity.getItemName(), player.getPlayerId()); + if (isFromLoot) { + player.getCurrentRoom().addPresentItem(itemId); + roomSay(player.getCurrentRoom().getRoomId(), player.getPlayerName() + " dropped " + itemEntity.getItemName(), player.getPlayerId()); + } return false; } } -- GitLab