diff --git a/src/main/java/org/maxgamer/quickshop/Event/ShopCreateEvent.java b/src/main/java/org/maxgamer/quickshop/Event/ShopCreateEvent.java index 081c22366..38e716334 100644 --- a/src/main/java/org/maxgamer/quickshop/Event/ShopCreateEvent.java +++ b/src/main/java/org/maxgamer/quickshop/Event/ShopCreateEvent.java @@ -1,5 +1,6 @@ package org.maxgamer.quickshop.Event; +import lombok.*; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; @@ -7,33 +8,26 @@ import org.bukkit.event.HandlerList; import org.jetbrains.annotations.*; import org.maxgamer.quickshop.Shop.Shop; +@Builder public class ShopCreateEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); + @Getter + @NonNull private Shop shop; private boolean cancelled; - private Player p; + @Getter + @NonNull + private Player player; - public ShopCreateEvent(Shop shop, Player p) { + /** + * Call when have a new shop was createing. + * + * @param shop Target shop + * @param p The player creaing the shop + */ + public ShopCreateEvent(@NonNull Shop shop, @NonNull Player p) { this.shop = shop; - this.p = p; - } - - /** - * The shop to be created - * - * @return The shop to be created - */ - public Shop getShop() { - return this.shop; - } - - /** - * The player who is creating this shop - * - * @return The player who is creating this shop - */ - public Player getPlayer() { - return p; + this.player = p; } @NotNull @@ -42,17 +36,13 @@ public class ShopCreateEvent extends Event implements Cancellable { return handlers; } - public static HandlerList getHandlerList() { - return handlers; - } - @Override public boolean isCancelled() { - return this.cancelled; + return cancelled; } @Override - public void setCancelled(boolean cancel) { - this.cancelled = cancel; + public void setCancelled(boolean b) { + this.cancelled = b; } } \ No newline at end of file diff --git a/src/main/java/org/maxgamer/quickshop/Event/ShopDeleteEvent.java b/src/main/java/org/maxgamer/quickshop/Event/ShopDeleteEvent.java index fdbb5998e..b85370107 100644 --- a/src/main/java/org/maxgamer/quickshop/Event/ShopDeleteEvent.java +++ b/src/main/java/org/maxgamer/quickshop/Event/ShopDeleteEvent.java @@ -1,16 +1,20 @@ package org.maxgamer.quickshop.Event; +import lombok.*; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.*; import org.maxgamer.quickshop.Shop.Shop; +@Builder public class ShopDeleteEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); + @Getter + @NonNull private Shop shop; private boolean cancelled; - private boolean fromMemory; + @Getter private boolean fromMemory; /** * Call the event when shop is deleteing. @@ -19,39 +23,17 @@ public class ShopDeleteEvent extends Event implements Cancellable { * @param shop Target shop * @param fromMemory Only delete from the memory? false = delete both in memory and database */ - public ShopDeleteEvent(Shop shop, boolean fromMemory) { + public ShopDeleteEvent(@NonNull Shop shop, boolean fromMemory) { this.shop = shop; this.fromMemory = fromMemory; } - /** - * Get is only delete from the memory - * - * @return only from memory - */ - public boolean isFromMemory() { - return this.fromMemory; - } - - /** - * The shop to be deleted - * - * @return The shop to be deleted - */ - public Shop getShop() { - return this.shop; - } - @NotNull @Override public HandlerList getHandlers() { return handlers; } - public static HandlerList getHandlerList() { - return handlers; - } - @Override public boolean isCancelled() { return this.cancelled; diff --git a/src/main/java/org/maxgamer/quickshop/Event/ShopDisplayItemDespawnEvent.java b/src/main/java/org/maxgamer/quickshop/Event/ShopDisplayItemDespawnEvent.java index 3653ff093..fa9c10485 100644 --- a/src/main/java/org/maxgamer/quickshop/Event/ShopDisplayItemDespawnEvent.java +++ b/src/main/java/org/maxgamer/quickshop/Event/ShopDisplayItemDespawnEvent.java @@ -1,5 +1,6 @@ package org.maxgamer.quickshop.Event; +import lombok.*; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -12,11 +13,18 @@ import org.maxgamer.quickshop.Shop.Shop; /** * This event is called after DisplayItem removed */ +@Builder public class ShopDisplayItemDespawnEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; + @Getter + @NonNull private Shop shop; - private ItemStack iStack; + @Getter + @NonNull + private ItemStack itemStack; + @Getter + @NonNull private DisplayType displayType; /** @@ -25,9 +33,9 @@ public class ShopDisplayItemDespawnEvent extends Event implements Cancellable { * @param iStack Target itemstacck */ @Deprecated - public ShopDisplayItemDespawnEvent(Shop shop, ItemStack iStack) { + public ShopDisplayItemDespawnEvent(@NonNull Shop shop, @NonNull ItemStack iStack) { this.shop = shop; - this.iStack = iStack; + this.itemStack = iStack; this.displayType = DisplayItem.getNowUsing(); } @@ -37,34 +45,18 @@ public class ShopDisplayItemDespawnEvent extends Event implements Cancellable { * @param iStack Target itemstacck * @param displayType The displayType */ - public ShopDisplayItemDespawnEvent(Shop shop, ItemStack iStack, DisplayType displayType) { + public ShopDisplayItemDespawnEvent(@NonNull Shop shop, @NonNull ItemStack iStack, @NonNull DisplayType displayType) { this.shop = shop; - this.iStack = iStack; + this.itemStack = iStack; this.displayType = displayType; } - public Shop getShop() { - return shop; - } - - public DisplayType getDisplayType() { - return displayType; - } - - public ItemStack getItemStack() { - return iStack; - } - @NotNull @Override public HandlerList getHandlers() { return handlers; } - public static HandlerList getHandlerList() { - return handlers; - } - @Override public boolean isCancelled() { return this.cancelled; diff --git a/src/main/java/org/maxgamer/quickshop/Event/ShopDisplayItemSpawnEvent.java b/src/main/java/org/maxgamer/quickshop/Event/ShopDisplayItemSpawnEvent.java index 359cfc503..1fe7dbfa4 100644 --- a/src/main/java/org/maxgamer/quickshop/Event/ShopDisplayItemSpawnEvent.java +++ b/src/main/java/org/maxgamer/quickshop/Event/ShopDisplayItemSpawnEvent.java @@ -1,5 +1,6 @@ package org.maxgamer.quickshop.Event; +import lombok.*; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -11,11 +12,18 @@ import org.maxgamer.quickshop.Shop.Shop; /** * This event is called before the shop display item created */ +@Builder public class ShopDisplayItemSpawnEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; + @Getter + @NonNull private Shop shop; - private ItemStack iStack; + @Getter + @NonNull + private ItemStack itemStack; + @Getter + @NonNull private DisplayType displayType; /** @@ -24,9 +32,9 @@ public class ShopDisplayItemSpawnEvent extends Event implements Cancellable { * @param displayType The displayType * @param iStack Target ItemStack */ - public ShopDisplayItemSpawnEvent(Shop shop, ItemStack iStack, DisplayType displayType) { + public ShopDisplayItemSpawnEvent(@NonNull Shop shop, @NonNull ItemStack iStack, @NonNull DisplayType displayType) { this.shop = shop; - this.iStack = iStack; + this.itemStack = iStack; this.displayType = displayType; } @@ -38,31 +46,15 @@ public class ShopDisplayItemSpawnEvent extends Event implements Cancellable { @Deprecated public ShopDisplayItemSpawnEvent(Shop shop, ItemStack iStack) { this.shop = shop; - this.iStack = iStack; + this.itemStack = iStack; this.displayType = DisplayItem.getNowUsing(); } - public Shop getShop() { - return shop; - } - - public DisplayType getDisplayType() { - return displayType; - } - - public ItemStack getItemStack() { - return iStack; - } - @Override public HandlerList getHandlers() { return handlers; } - public static HandlerList getHandlerList() { - return handlers; - } - @Override public boolean isCancelled() { return this.cancelled; diff --git a/src/main/java/org/maxgamer/quickshop/Event/ShopInventoryPreviewEvent.java b/src/main/java/org/maxgamer/quickshop/Event/ShopInventoryPreviewEvent.java index a8e6ecba3..17c796235 100644 --- a/src/main/java/org/maxgamer/quickshop/Event/ShopInventoryPreviewEvent.java +++ b/src/main/java/org/maxgamer/quickshop/Event/ShopInventoryPreviewEvent.java @@ -1,5 +1,6 @@ package org.maxgamer.quickshop.Event; +import lombok.*; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; @@ -7,11 +8,16 @@ import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.*; +@Builder public class ShopInventoryPreviewEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; - private Player p; + @Getter + @NonNull + private Player player; + @Getter + @NonNull private ItemStack itemStack; /** @@ -20,38 +26,17 @@ public class ShopInventoryPreviewEvent extends Event implements Cancellable { * @param p Target plugin * @param itemStack The preview item, with preview flag. */ - public ShopInventoryPreviewEvent(Player p, ItemStack itemStack) { - this.p = p; + public ShopInventoryPreviewEvent(@NonNull Player p, @NonNull ItemStack itemStack) { + this.player = p; this.itemStack = itemStack; } - /** - * Get the preview ItemStack - * - * @return Itemstack for previewing - */ - public ItemStack getItemStack() { - return itemStack; - } - - /** - * The player who is preview item - * - * @return The player who is previewing - */ - public Player getPlayer() { - return p; - } - @NotNull @Override public HandlerList getHandlers() { return handlers; } - public static HandlerList getHandlerList() { - return handlers; - } @Override public boolean isCancelled() { diff --git a/src/main/java/org/maxgamer/quickshop/Event/ShopLoadEvent.java b/src/main/java/org/maxgamer/quickshop/Event/ShopLoadEvent.java index f3be15f8d..0c2f68d9b 100644 --- a/src/main/java/org/maxgamer/quickshop/Event/ShopLoadEvent.java +++ b/src/main/java/org/maxgamer/quickshop/Event/ShopLoadEvent.java @@ -1,5 +1,6 @@ package org.maxgamer.quickshop.Event; +import lombok.*; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -8,19 +9,23 @@ import org.maxgamer.quickshop.Shop.Shop; /** Call when loading shop **/ @SuppressWarnings("WeakerAccess") +@Builder public class ShopLoadEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; + @Getter + @NonNull private Shop shop; - - public ShopLoadEvent(Shop shop) { + /** + * Calling when shop loading + * + * @param shop Target shop + */ + public ShopLoadEvent(@NonNull Shop shop) { this.shop = shop; } - public Shop getShop() { - return shop; - } @NotNull @Override diff --git a/src/main/java/org/maxgamer/quickshop/Event/ShopModeratorChangedEvent.java b/src/main/java/org/maxgamer/quickshop/Event/ShopModeratorChangedEvent.java new file mode 100644 index 000000000..4c0c179f8 --- /dev/null +++ b/src/main/java/org/maxgamer/quickshop/Event/ShopModeratorChangedEvent.java @@ -0,0 +1,36 @@ +package org.maxgamer.quickshop.Event; + +import lombok.*; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.*; +import org.maxgamer.quickshop.Shop.Shop; +import org.maxgamer.quickshop.Shop.ShopModerator; + +/** Calling when moderator was changed, Can't cancel **/ +@Builder +public class ShopModeratorChangedEvent extends Event { + private static final HandlerList handlers = new HandlerList(); + @Getter + @NonNull + private Shop shop; + @Getter + @NonNull + private ShopModerator moderator; + + /** + * Will call when shop price was changed. + * + * @param shop Target shop + * @param shopModerator The shop moderator + */ + public ShopModeratorChangedEvent(@NonNull Shop shop, @NonNull ShopModerator shopModerator) { + this.shop = shop; + this.moderator = shopModerator; + } + + @Override + public @NotNull HandlerList getHandlers() { + return handlers; + } +} diff --git a/src/main/java/org/maxgamer/quickshop/Event/ShopPreCreateEvent.java b/src/main/java/org/maxgamer/quickshop/Event/ShopPreCreateEvent.java index 50902a175..5cbde8a80 100644 --- a/src/main/java/org/maxgamer/quickshop/Event/ShopPreCreateEvent.java +++ b/src/main/java/org/maxgamer/quickshop/Event/ShopPreCreateEvent.java @@ -1,5 +1,6 @@ package org.maxgamer.quickshop.Event; +import lombok.*; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; @@ -12,33 +13,26 @@ import org.jetbrains.annotations.*; * clicks a chest, this event is thrown, if successful, the player is asked how * much they wish to trade for. */ +@Builder public class ShopPreCreateEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; - private Player p; - private Location loc; - - public ShopPreCreateEvent(Player p, Location loc) { - this.loc = loc; - this.p = p; - } + @Getter + @NonNull + private Player player; + @Getter + @NonNull + private Location location; /** - * The location of the shop that will be created. - * - * @return The location of the shop that will be created. + * Calling when shop pre-creating. + * Shop won't one-percent will create after this event, if you want get the shop created event, please use ShopCreateEvent + * @param p Target player + * @param loc The location will create be shop */ - public Location getLocation() { - return loc; - } - - /** - * The player who is creating this shop - * - * @return The player who is creating this shop - */ - public Player getPlayer() { - return p; + public ShopPreCreateEvent(@NonNull Player p, @NonNull Location loc) { + this.location = loc; + this.player = p; } @NotNull @@ -47,9 +41,6 @@ public class ShopPreCreateEvent extends Event implements Cancellable { return handlers; } - public static HandlerList getHandlerList() { - return handlers; - } @Override public boolean isCancelled() { diff --git a/src/main/java/org/maxgamer/quickshop/Event/ShopPriceChangedEvent.java b/src/main/java/org/maxgamer/quickshop/Event/ShopPriceChangedEvent.java new file mode 100644 index 000000000..0db8d787c --- /dev/null +++ b/src/main/java/org/maxgamer/quickshop/Event/ShopPriceChangedEvent.java @@ -0,0 +1,36 @@ +package org.maxgamer.quickshop.Event; + +import lombok.*; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.*; +import org.maxgamer.quickshop.Shop.Shop; + +/** Calling when shop price was changed, Can't cancel **/ +@Builder +public class ShopPriceChangedEvent extends Event { + private static final HandlerList handlers = new HandlerList(); + @Getter + @NonNull + private Shop shop; + @Getter private double oldPrice; + @Getter private double newPrice; + + /** + * Will call when shop price was changed. + * + * @param shop Target shop + * @param oldPrice The old shop price + * @param newPrice The new shop price + */ + public ShopPriceChangedEvent(@NonNull Shop shop, double oldPrice, double newPrice) { + this.shop = shop; + this.oldPrice = oldPrice; + this.newPrice = newPrice; + } + + @Override + public @NotNull HandlerList getHandlers() { + return handlers; + } +} diff --git a/src/main/java/org/maxgamer/quickshop/Event/ShopPurchaseEvent.java b/src/main/java/org/maxgamer/quickshop/Event/ShopPurchaseEvent.java index 3a1d9f834..1a50a9a70 100644 --- a/src/main/java/org/maxgamer/quickshop/Event/ShopPurchaseEvent.java +++ b/src/main/java/org/maxgamer/quickshop/Event/ShopPurchaseEvent.java @@ -1,5 +1,6 @@ package org.maxgamer.quickshop.Event; +import lombok.*; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; @@ -7,11 +8,16 @@ import org.bukkit.event.HandlerList; import org.jetbrains.annotations.*; import org.maxgamer.quickshop.Shop.Shop; +@Builder public class ShopPurchaseEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); + @Getter + @NonNull private Shop shop; - private Player p; - private int amount; + @Getter + @NonNull + private Player player; + @Getter private int amount; private boolean cancelled; /** @@ -22,39 +28,12 @@ public class ShopPurchaseEvent extends Event implements Cancellable { * @param p The player buying * @param amount The amount they're buying */ - public ShopPurchaseEvent(Shop shop, Player p, int amount) { + public ShopPurchaseEvent(@NonNull Shop shop, @NonNull Player p, int amount) { this.shop = shop; - this.p = p; + this.player = p; this.amount = amount; } - /** - * The shop used in this event - * - * @return The shop used in this event - */ - public Shop getShop() { - return this.shop; - } - - /** - * The player trading with the shop - * - * @return The player trading with the shop - */ - public Player getPlayer() { - return this.p; - } - - /** - * The amount the purchase was for - * - * @return The amount the purchase was for - */ - public int getAmount() { - return this.amount; - } - @NotNull @Override public HandlerList getHandlers() { diff --git a/src/main/java/org/maxgamer/quickshop/Event/ShopSignUpdatedEvent.java b/src/main/java/org/maxgamer/quickshop/Event/ShopSignUpdatedEvent.java new file mode 100644 index 000000000..20d47fcca --- /dev/null +++ b/src/main/java/org/maxgamer/quickshop/Event/ShopSignUpdatedEvent.java @@ -0,0 +1,36 @@ +package org.maxgamer.quickshop.Event; + +import lombok.*; +import org.bukkit.block.Sign; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.*; +import org.maxgamer.quickshop.Shop.Shop; + +/** Calling when shop sign update, Can't cancel **/ +@Builder +public class ShopSignUpdatedEvent extends Event { + private static final HandlerList handlers = new HandlerList(); + @Getter + @NonNull + private Shop shop; + @Getter + @NonNull + private Sign sign; + + /** + * Will call when shop price was changed. + * + * @param shop Target shop + * @param sign updated sign + */ + public ShopSignUpdatedEvent(@NonNull Shop shop, @NonNull Sign sign) { + this.shop = shop; + this.sign = sign; + } + + @Override + public @NotNull HandlerList getHandlers() { + return handlers; + } +} diff --git a/src/main/java/org/maxgamer/quickshop/Event/ShopSuccessPurchaseEvent.java b/src/main/java/org/maxgamer/quickshop/Event/ShopSuccessPurchaseEvent.java index a88dc362b..db45ca3b9 100644 --- a/src/main/java/org/maxgamer/quickshop/Event/ShopSuccessPurchaseEvent.java +++ b/src/main/java/org/maxgamer/quickshop/Event/ShopSuccessPurchaseEvent.java @@ -1,5 +1,6 @@ package org.maxgamer.quickshop.Event; +import lombok.*; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; @@ -7,13 +8,18 @@ import org.bukkit.event.HandlerList; import org.jetbrains.annotations.*; import org.maxgamer.quickshop.Shop.Shop; +@Builder public class ShopSuccessPurchaseEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); + @Getter + @NonNull private Shop shop; - private Player p; - private int amount; + @Getter + @NonNull + private Player player; + @Getter private int amount; private double total; - private double tax; + @Getter private double tax; private boolean cancelled; /** @@ -26,40 +32,14 @@ public class ShopSuccessPurchaseEvent extends Event implements Cancellable { * @param tax The tax in this purchase * @param total The money in this purchase */ - public ShopSuccessPurchaseEvent(Shop shop, Player p, int amount, double total, double tax) { + public ShopSuccessPurchaseEvent(@NonNull Shop shop, @NonNull Player p, int amount, double total, double tax) { this.shop = shop; - this.p = p; + this.player = p; this.amount = amount; this.tax = tax; this.total = total; } - /** - * The shop used in this event - * - * @return The shop used in this event - */ - public Shop getShop() { - return this.shop; - } - - /** - * The player trading with the shop - * - * @return The player trading with the shop - */ - public Player getPlayer() { - return this.p; - } - - /** - * The amount the purchase was for - * - * @return The amount the purchase was for - */ - public int getAmount() { - return this.amount; - } /** * The total money changes in this purchase. @@ -77,15 +57,6 @@ public class ShopSuccessPurchaseEvent extends Event implements Cancellable { */ public double getBalanceWithoutTax() {return this.total;} - /** - * Get the tax in this purchase - * - * @return Tax - */ - public double getTax() { - return tax; - } - @NotNull @Override public HandlerList getHandlers() { diff --git a/src/main/java/org/maxgamer/quickshop/Event/ShopUnloadEvent.java b/src/main/java/org/maxgamer/quickshop/Event/ShopUnloadEvent.java index 9ba91c4e0..95ab01ae7 100644 --- a/src/main/java/org/maxgamer/quickshop/Event/ShopUnloadEvent.java +++ b/src/main/java/org/maxgamer/quickshop/Event/ShopUnloadEvent.java @@ -1,22 +1,24 @@ package org.maxgamer.quickshop.Event; +import lombok.*; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.*; import org.maxgamer.quickshop.Shop.Shop; /** Getting the unloading shop, Can't cancel. **/ +@Builder public class ShopUnloadEvent extends Event { + private static final HandlerList handlers = new HandlerList(); + @Getter + private @NonNull Shop shop; /* Getting the unloading shop, Can't cancel. **/ - public ShopUnloadEvent(Shop shop) { + public ShopUnloadEvent(@NonNull Shop shop) { this.shop = shop; } - private static final HandlerList handlers = new HandlerList(); - private Shop shop; - - public Shop getShop() { - return shop; + public static HandlerList getHandlerList() { + return handlers; } @NotNull @@ -24,8 +26,4 @@ public class ShopUnloadEvent extends Event { public HandlerList getHandlers() { return handlers; } - - public static HandlerList getHandlerList() { - return handlers; - } } diff --git a/src/main/java/org/maxgamer/quickshop/Event/ShopUpdateEvent.java b/src/main/java/org/maxgamer/quickshop/Event/ShopUpdateEvent.java index 32899d8f9..76c517814 100644 --- a/src/main/java/org/maxgamer/quickshop/Event/ShopUpdateEvent.java +++ b/src/main/java/org/maxgamer/quickshop/Event/ShopUpdateEvent.java @@ -1,14 +1,17 @@ package org.maxgamer.quickshop.Event; +import lombok.*; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.*; import org.maxgamer.quickshop.Shop.Shop; +@Builder public class ShopUpdateEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); - private Shop shop; + @Getter + private @NonNull Shop shop; private boolean cancelled; /** @@ -16,19 +19,9 @@ public class ShopUpdateEvent extends Event implements Cancellable { * * @param shop The shop bought from */ - public ShopUpdateEvent(Shop shop) { + public ShopUpdateEvent(@NonNull Shop shop) { this.shop = shop; } - - /** - * The shop used in this event - * - * @return The shop used in this event - */ - public Shop getShop() { - return this.shop; - } - @NotNull @Override public HandlerList getHandlers() { diff --git a/src/main/java/org/maxgamer/quickshop/InternalListener/InternalListener.java b/src/main/java/org/maxgamer/quickshop/InternalListener/InternalListener.java new file mode 100644 index 000000000..221505d0f --- /dev/null +++ b/src/main/java/org/maxgamer/quickshop/InternalListener/InternalListener.java @@ -0,0 +1,41 @@ +package org.maxgamer.quickshop.InternalListener; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.maxgamer.quickshop.Event.*; +import org.maxgamer.quickshop.QuickShop; + +public class InternalListener implements Listener { + private QuickShop plugin = QuickShop.instance; + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void shopCreate(ShopCreateEvent event) { + plugin.log("Player " + event.getPlayer().getName() + " created a shop at location " + event.getShop().getLocation()); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void shopDelete(ShopDeleteEvent event) { + plugin.log("Shop at " + event.getShop().getLocation() + " was removed."); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void shopPurchase(ShopSuccessPurchaseEvent event) { + plugin.log("Player " + event.getPlayer().getName() + " purchased " + event.getShop().ownerName() + " shop item x" + event + .getAmount() + " for " + plugin.getEconomy().format(event.getBalance()) + " (" + plugin.getEconomy() + .format(event.getTax()) + " tax)."); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void shopPriceChanges(ShopPriceChangedEvent event) { + plugin.log("Shop at location " + event.getShop().getLocation() + " price was changed from " + event + .getOldPrice() + " to " + event.getNewPrice()); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void shopModeratorChanges(ShopModeratorChangedEvent event) { + plugin.log("Shop at location " + event.getShop().getLocation() + " moderator was changed to " + event.getModerator() + .toString()); + } + +} diff --git a/src/main/java/org/maxgamer/quickshop/Listeners/ChatListener.java b/src/main/java/org/maxgamer/quickshop/Listeners/ChatListener.java index 9746d114b..a98f9582e 100644 --- a/src/main/java/org/maxgamer/quickshop/Listeners/ChatListener.java +++ b/src/main/java/org/maxgamer/quickshop/Listeners/ChatListener.java @@ -25,8 +25,6 @@ public class ChatListener implements Listener { } if (!plugin.getShopManager().getActions().containsKey(e.getPlayer().getUniqueId())) return; - plugin.log(e.getPlayer().getName() + "(" + e.getPlayer().getUniqueId().toString() + ") was " + plugin.getShopManager() - .getActions().get(e.getPlayer().getUniqueId()).getAction().name() + " the shop."); plugin.getShopManager().handleChat(e.getPlayer(), e.getMessage()); e.setCancelled(true); } diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java b/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java index 604c4e29d..b3876abb4 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java @@ -23,10 +23,7 @@ import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.Damageable; import org.jetbrains.annotations.*; -import org.maxgamer.quickshop.Event.ShopDeleteEvent; -import org.maxgamer.quickshop.Event.ShopLoadEvent; -import org.maxgamer.quickshop.Event.ShopUnloadEvent; -import org.maxgamer.quickshop.Event.ShopUpdateEvent; +import org.maxgamer.quickshop.Event.*; import org.maxgamer.quickshop.QuickShop; import org.maxgamer.quickshop.Util.MsgUtil; import org.maxgamer.quickshop.Util.Util; @@ -206,6 +203,8 @@ public class ContainerShop implements Shop { * @param price The new price of the shop. */ public void setPrice(double price) { + Bukkit.getPluginManager().callEvent(ShopPriceChangedEvent.builder().oldPrice(this.price).newPrice(price).shop(this) + .build()); this.price = price; setSignText(); update(); @@ -296,6 +295,9 @@ public class ContainerShop implements Shop { public boolean addStaff(@NotNull UUID player) { boolean result = this.moderator.addStaff(player); update(); + if (result == false) + return result; + Bukkit.getPluginManager().callEvent(ShopModeratorChangedEvent.builder().shop(this).moderator(this.moderator).build()); return result; } @@ -303,12 +305,16 @@ public class ContainerShop implements Shop { public boolean delStaff(@NotNull UUID player) { boolean result = this.moderator.delStaff(player); update(); + if (result == false) + return result; + Bukkit.getPluginManager().callEvent(ShopModeratorChangedEvent.builder().shop(this).moderator(this.moderator).build()); return result; } @Override public void clearStaffs() { this.moderator.clearStaffs(); + Bukkit.getPluginManager().callEvent(ShopModeratorChangedEvent.builder().shop(this).moderator(this.moderator).build()); update(); } @@ -485,6 +491,7 @@ public class ContainerShop implements Shop { */ public void setOwner(@NotNull UUID owner) { this.moderator.setOwner(owner); + Bukkit.getPluginManager().callEvent(ShopModeratorChangedEvent.builder().shop(this).moderator(this.moderator).build()); this.setSignText(); update(); } @@ -786,6 +793,7 @@ public class ContainerShop implements Shop { public void setModerator(ShopModerator shopModerator) { this.moderator = shopModerator.clone(); update(); + Bukkit.getPluginManager().callEvent(ShopModeratorChangedEvent.builder().shop(this).moderator(this.moderator).build()); } @Override diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java index e930ba68a..518e4ebdb 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java @@ -491,7 +491,6 @@ public class ShopManager { MsgUtil.sendSellSuccess(p, shop, amount); ShopSuccessPurchaseEvent se = new ShopSuccessPurchaseEvent(shop, p, amount, total, tax); Bukkit.getPluginManager().callEvent(se); - plugin.log(p.getName() + " sold " + amount + " for " + (shop.getPrice() * amount) + " to " + shop.toString()); shop.setSignText(); // Update the signs count } @@ -580,7 +579,6 @@ public class ShopManager { MsgUtil.sendPurchaseSuccess(p, shop, amount); ShopSuccessPurchaseEvent se = new ShopSuccessPurchaseEvent(shop, p, amount, total, tax); Bukkit.getPluginManager().callEvent(se); - plugin.log(p.getName() + " bought " + amount + " for " + (shop.getPrice() * amount) + " from " + shop.toString()); } @SuppressWarnings("deprecation") @@ -697,8 +695,6 @@ public class ShopManager { /* The shop has hereforth been successfully created */ createShop(shop, info); Location loc = shop.getLocation(); - plugin.log(p.getName() + " created a " + Util.getItemStackName(shop.getItem()) + " shop at (" - + loc.getWorld().getName() + " - " + loc.getX() + "," + loc.getY() + "," + loc.getZ() + ")"); if (!plugin.getConfig().getBoolean("shop.lock")) { // Warn them if they haven't been warned since // reboot diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ShopModerator.java b/src/main/java/org/maxgamer/quickshop/Shop/ShopModerator.java index 4f3b08f49..0be5b1c6f 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/ShopModerator.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/ShopModerator.java @@ -11,7 +11,6 @@ import org.jetbrains.annotations.*; * Contains shop's moderators infomations, owner, staffs etc. */ @EqualsAndHashCode -@ToString public class ShopModerator { private UUID owner; private ArrayList staffs; @@ -144,4 +143,9 @@ public class ShopModerator { Gson gson = new Gson(); return gson.fromJson(serilized, ShopModerator.class); } + + @Override + public String toString() { + return serialize(this); + } }