Skip to content

Commit

Permalink
Merge pull request #47 from Sven65/feat/reload-location-fix
Browse files Browse the repository at this point in the history
Make slabbo reload command fix null locations
  • Loading branch information
Sven65 authored Jul 29, 2022
2 parents ecb6a2b + 86ad177 commit dd54414
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ public static void onCommand(CommandSender sender, CommandHelp help) {
@Description("Reloads Slabbo")
@CommandPermission("slabbo.reload")
public void onReload (Player player) {
boolean shouldSave = false;

player.sendMessage(LocaleManager.getString("general.general.reloading")+" Slabbo");

Slabbo.getInstance().reloadConfig();
Expand All @@ -129,9 +131,20 @@ public void onReload (Player player) {
for (Map.Entry<String, Shop> shopEntry : ShopManager.shops.entrySet()) {
Shop shop = shopEntry.getValue();

if (shop.location == null) {
Location shopLocation = ShopManager.fromString(shopEntry.getKey());

shop.location = shopLocation;

shouldSave = true;
}

ItemUtil.dropShopItem(shop.location, shop.item, shop.quantity);
}

if (shouldSave) {
DataUtil.saveShops();
}

player.sendMessage("Slabbo "+LocaleManager.getString("general.general.reloaded")+"!");
}
Expand Down

0 comments on commit dd54414

Please sign in to comment.