diff --git a/src/main/java/xyz/mackan/Slabbo/commands/SlabboCommand.java b/src/main/java/xyz/mackan/Slabbo/commands/SlabboCommand.java index 6e02092..e743f3a 100644 --- a/src/main/java/xyz/mackan/Slabbo/commands/SlabboCommand.java +++ b/src/main/java/xyz/mackan/Slabbo/commands/SlabboCommand.java @@ -8,6 +8,7 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Item; import org.bukkit.entity.Player; import xyz.mackan.Slabbo.GUI.ShopDeletionGUI; import xyz.mackan.Slabbo.Slabbo; @@ -19,8 +20,7 @@ import xyz.mackan.Slabbo.utils.ShopUtil; import java.io.File; -import java.util.Set; -import java.util.UUID; +import java.util.*; @CommandAlias("slabbo") @Description("Base command for Slabbo") @@ -43,6 +43,46 @@ public static void onCommand(CommandSender sender, CommandHelp help) { help.showHelp(); } + @Subcommand("reload") + @Description("Reloads Slabbo") + @CommandPermission("slabbo.reload") + public void onReload (Player player) { + player.sendMessage("Reloading Slabbo"); + for (String shopKey : Slabbo.shopUtil.shops.keySet()) { + Shop shop = Slabbo.shopUtil.shops.get(shopKey); + + Item droppedItem = ItemUtil.findItemEntity(shop.location); + + if (droppedItem != null) { + droppedItem.remove(); + } + } + + Slabbo.shopUtil.shops = new HashMap(); + Slabbo.shopUtil.shopsByOwnerId = new HashMap>(); + + Slabbo.shopUtil.loadShops(); + + for (Map.Entry shopEntry : Slabbo.shopUtil.shops.entrySet()) { + String key = shopEntry.getKey(); + Shop shop = shopEntry.getValue(); + + UUID itemUUID = UUID.randomUUID(); + + shop.droppedItemId = itemUUID; + + Location dropLocation = shop.location.clone(); + + dropLocation.add(0.5, 0.5, 0.5); + + ItemUtil.dropItem(dropLocation, shop.item, itemUUID); + + Slabbo.shopUtil.put(key, shop); + } + + player.sendMessage("Slabbo reloaded!"); + } + @Subcommand("info") @Description("Shows information about Slabbo") @CommandPermission("slabbo.info")