Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<dependency>
<groupId>org.maxgamer</groupId>
<artifactId>QuickShop</artifactId>
<version>5.1.0.0</version>
<version>5.1.2.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.maxgamer.quickshop.api.command.CommandContainer;
import org.maxgamer.quickshop.api.event.CalendarEvent;
import org.maxgamer.quickshop.api.event.ShopPurchaseEvent;
import org.maxgamer.quickshop.api.event.PlayerShopClickEvent;
import org.maxgamer.quickshop.api.event.ShopSuccessPurchaseEvent;
import org.maxgamer.quickshop.api.shop.Shop;
import org.maxgamer.quickshop.util.MsgUtil;
Expand Down Expand Up @@ -62,6 +63,21 @@ public void shopPurchased(ShopSuccessPurchaseEvent event) {
ChatColor.AQUA + MsgUtil.fillArgs(getConfig().getString("message.subtitle"), String.valueOf(limit - playerUsedLimit)));
}

@EventHandler
public void shopClick(PlayerShopClickEvent event) {

Shop shop = event.getShop();
ConfigurationSection storage = shop.getExtra(this);
if (storage.getInt("limit") < 1) {
return;
}
int limit = storage.getInt("limit");
int playerUsedLimit = storage.getInt("data." + event.getPlayer().getUniqueId(), 0);

//that the message is under the shop block
Bukkit.getScheduler().runTaskLaterAsynchronously(this, () -> event.getPlayer().sendMessage(ChatColor.YELLOW + MsgUtil.fillArgs(getConfig().getString("tell-the-limit"), String.valueOf(limit), String.valueOf(limit - playerUsedLimit))), 1);
}

@EventHandler(ignoreCancelled = true)
public void shopPrePurchase(ShopPurchaseEvent event) {
Shop shop = event.getShop();
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
command-description: "Limit the amount per player can purchase"
tell-the-limit: "This shop has an limit of {0} items! You can purchase {1}."
reach-the-limit: "You have reached the limit in this shop. You can purchase {0}, but you trying purchase {1}."
success-reset: "Reset successfully"
success-setup: "Set up!"
Expand Down