Skip to content

Commit

Permalink
- Fix issue with importing ushops shops selling air
Browse files Browse the repository at this point in the history
- Fix issue with shops from unknown users not opening
  • Loading branch information
Sven65 committed Aug 26, 2020
1 parent d7b2b69 commit 32a6128
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ public static ItemStack getUserInfoItem (Shop shop) {

HashMap<String, Object> replacementMap = new HashMap<String, Object>();

replacementMap.put("owner", owner.getName());
String ownerName = Misc.getValueOrDefault(owner.getName(), LocaleManager.getString("general.general.unknown-user"));

replacementMap.put("owner", ownerName);
replacementMap.put("item", shop.item.getType());
replacementMap.put("quantity", shop.quantity);
replacementMap.put("buyPrice", shop.buyPrice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public static void dropShopItem (Location location, ItemStack item, int quantity

String displayType = Slabbo.getInstance().getConfig().getString("itemdisplay", "quantity");

if (clonedItem.getType() == Material.AIR) {
return;
}

if (displayType.equalsIgnoreCase("quantity")) {
if (quantity < 1) quantity = 1;
if (quantity > 64) quantity = 64;
Expand All @@ -82,9 +86,11 @@ public static void dropShopItem (Location location, ItemStack item, int quantity
clonedItem.setAmount(64);
}

meta.setDisplayName("Slabbo Item "+ ShopManager.locationToString(location));
if (clonedItem.hasItemMeta() && meta != null) {
meta.setDisplayName("Slabbo Item " + ShopManager.locationToString(location));

clonedItem.setItemMeta(meta);
clonedItem.setItemMeta(meta);
}

Item itemEnt = location.getWorld().dropItem(dropLocation, clonedItem);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,8 @@ public static <T> List<T> getPage (List<T> sourceList, int page, int pageSize) {
// toIndex exclusive
return sourceList.subList(fromIndex, Math.min(fromIndex + pageSize, sourceList.size()));
}

public static <T> T getValueOrDefault(T value, T defaultValue) {
return value == null ? defaultValue : value;
}
}
2 changes: 2 additions & 0 deletions modules/Plugin/src/main/resources/lang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ general:
next-page: Next Page
previous-page: Previous Page

unknown-user: Unknown User


buy-price: Buy price
sell-price: Sell price
Expand Down

0 comments on commit 32a6128

Please sign in to comment.