File tree Expand file tree Collapse file tree 3 files changed +33
-3
lines changed
src/main/java/org/maxgamer/quickshop Expand file tree Collapse file tree 3 files changed +33
-3
lines changed Original file line number Diff line number Diff line change 2121
2222import lombok .Getter ;
2323import org .bukkit .entity .Player ;
24+ import org .bukkit .event .Cancellable ;
2425import org .jetbrains .annotations .NotNull ;
2526import org .maxgamer .quickshop .api .shop .Shop ;
2627
2930 * <p>
3031 * Since 5.1.2.0
3132 */
32- public class PlayerShopClickEvent extends ShopClickEvent {
33+ public class PlayerShopClickEvent extends AbstractQSEvent implements Cancellable {
3334
3435
3536 @ Getter
3637 private final Player player ;
3738
39+ @ NotNull
40+ private final Shop shop ;
41+
42+ private boolean cancelled ;
43+
3844 /**
3945 * Call when shop was clicked.
4046 *
4147 * @param shop The shop bought from
4248 * @param player the player clicking shop
4349 */
4450 public PlayerShopClickEvent (@ NotNull Shop shop , Player player ) {
45- super ( shop ) ;
51+ this . shop = shop ;
4652 this .player = player ;
4753 }
54+
55+ @ Override
56+ public boolean isCancelled () {
57+ return this .cancelled ;
58+ }
59+
60+ @ Override
61+ public void setCancelled (boolean cancelled ) {
62+ this .cancelled = cancelled ;
63+ }
64+
65+ /**
66+ * Getting the shops that clicked
67+ *
68+ * @return Clicked shop
69+ */
70+ public @ NotNull Shop getShop () {
71+ return this .shop ;
72+ }
4873}
Original file line number Diff line number Diff line change 1919
2020package org .maxgamer .quickshop .api .event ;
2121
22+ import org .bukkit .Warning ;
2223import org .bukkit .event .Cancellable ;
2324import org .jetbrains .annotations .NotNull ;
2425import org .maxgamer .quickshop .api .shop .Shop ;
2930 * Deprecated, use PlayerShopClickEvent instead
3031 */
3132@ Deprecated
33+ @ Warning (reason = "Deprecated for improper api event design" )
3234public class ShopClickEvent extends AbstractQSEvent implements Cancellable {
3335
3436 @ NotNull
Original file line number Diff line number Diff line change 4949import org .maxgamer .quickshop .QuickShop ;
5050import org .maxgamer .quickshop .api .economy .AbstractEconomy ;
5151import org .maxgamer .quickshop .api .event .PlayerShopClickEvent ;
52+ import org .maxgamer .quickshop .api .event .ShopClickEvent ;
5253import org .maxgamer .quickshop .api .shop .Info ;
5354import org .maxgamer .quickshop .api .shop .Shop ;
5455import org .maxgamer .quickshop .api .shop .ShopAction ;
@@ -215,7 +216,9 @@ private void postTrade(PlayerInteractEvent e) {
215216 //Prevent use item by ancient
216217 e .setUseItemInHand (Event .Result .DENY );
217218 PlayerShopClickEvent event = new PlayerShopClickEvent (shop , p );
218- if (Util .fireCancellableEvent (event )) {
219+ @ SuppressWarnings ("deprecation" )
220+ ShopClickEvent eventOld = new ShopClickEvent (shop );
221+ if (Util .fireCancellableEvent (event ) || Util .fireCancellableEvent (eventOld )) {
219222 Util .debugLog ("Ignore shop click, because some plugin cancel it." );
220223 return ;
221224 }
You can’t perform that action at this time.
0 commit comments