From 7f933cb1d01edb61bab431083c872ec883e54d9c Mon Sep 17 00:00:00 2001 From: Acrobot Date: Sat, 27 Apr 2013 14:48:19 +0200 Subject: [PATCH] Document events --- .../Events/Economy/TransferCurrencyEvent.java | 25 +++++++ .../ChestShop/Events/ItemInfoEvent.java | 8 +++ .../Events/PreShopCreationEvent.java | 67 ++++++++++++++++++- .../ChestShop/Events/PreTransactionEvent.java | 62 +++++++++++++++++ .../ChestShop/Events/ShopCreatedEvent.java | 28 ++++++++ .../ChestShop/Events/ShopDestroyedEvent.java | 11 +++ .../ChestShop/Events/TransactionEvent.java | 29 ++++++++ 7 files changed, 229 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/Acrobot/ChestShop/Events/Economy/TransferCurrencyEvent.java diff --git a/src/main/java/com/Acrobot/ChestShop/Events/Economy/TransferCurrencyEvent.java b/src/main/java/com/Acrobot/ChestShop/Events/Economy/TransferCurrencyEvent.java new file mode 100644 index 0000000..47bbd41 --- /dev/null +++ b/src/main/java/com/Acrobot/ChestShop/Events/Economy/TransferCurrencyEvent.java @@ -0,0 +1,25 @@ +package com.Acrobot.ChestShop.Events.Economy; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import java.math.BigDecimal; + +/** + * @author Acrobot + */ +public class TransferCurrencyEvent extends Event { + private static final HandlerList handlers = new HandlerList(); + + private BigDecimal amount; + + public TransferCurrencyEvent(BigDecimal amount, String fromWho, String toWho) + + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/src/main/java/com/Acrobot/ChestShop/Events/ItemInfoEvent.java b/src/main/java/com/Acrobot/ChestShop/Events/ItemInfoEvent.java index ed865ad..4e926e8 100644 --- a/src/main/java/com/Acrobot/ChestShop/Events/ItemInfoEvent.java +++ b/src/main/java/com/Acrobot/ChestShop/Events/ItemInfoEvent.java @@ -6,6 +6,8 @@ import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; /** + * Represents an /iteminfo call + * * @author Acrobot */ public class ItemInfoEvent extends Event { @@ -19,10 +21,16 @@ public class ItemInfoEvent extends Event { this.item = item; } + /** + * @return CommandSender who initiated the call + */ public CommandSender getSender() { return sender; } + /** + * @return Item recognised by /iteminfo + */ public ItemStack getItem() { return item; } diff --git a/src/main/java/com/Acrobot/ChestShop/Events/PreShopCreationEvent.java b/src/main/java/com/Acrobot/ChestShop/Events/PreShopCreationEvent.java index 6787e66..9edd533 100644 --- a/src/main/java/com/Acrobot/ChestShop/Events/PreShopCreationEvent.java +++ b/src/main/java/com/Acrobot/ChestShop/Events/PreShopCreationEvent.java @@ -6,6 +6,8 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; /** + * Represents a state before shop is created + * * @author Acrobot */ public class PreShopCreationEvent extends Event { @@ -23,46 +25,103 @@ public class PreShopCreationEvent extends Event { this.signLines = signLines.clone(); } + /** + * Returns if event is cancelled + * + * @return Is event cancelled? + */ public boolean isCancelled() { return outcome != CreationOutcome.SHOP_CREATED_SUCCESSFULLY; } + /** + * Returns the outcome of the event + * + * @return Event's outcome + */ public CreationOutcome getOutcome() { return outcome; } + /** + * Sets the event's outcome + * + * @param outcome Outcome + */ public void setOutcome(CreationOutcome outcome) { this.outcome = outcome; } + /** + * Sets the shop's creator + * + * @param creator Shop's creator + */ public void setCreator(Player creator) { this.creator = creator; } + /** + * Sets the sign attached to the shop + * + * @param sign Shop sign + */ public void setSign(Sign sign) { this.sign = sign; } + /** + * Sets the text on the sign + * + * @param signLines Text to set + */ public void setSignLines(String[] signLines) { this.signLines = signLines; } + /** + * Sets one of the lines on the sign + * + * @param line Line number to set (0-3) + * @param text Text to set + */ public void setSignLine(byte line, String text) { this.signLines[line] = text; } + /** + * Returns the shop's creator + * + * @return Shop's creator + */ public Player getPlayer() { return creator; } + /** + * Returns the shop's sign + * + * @return Shop's sign + */ public Sign getSign() { return sign; } + /** + * Returns the text on the sign + * + * @param line Line number (0-3) + * @return Text on the sign + */ public String getSignLine(byte line) { return signLines[line]; } + /** + * Returns the text on the sign + * + * @return Text on the sign + */ public String[] getSignLines() { return signLines; } @@ -75,6 +134,9 @@ public class PreShopCreationEvent extends Event { return handlers; } + /** + * Possible outcomes + */ public static enum CreationOutcome { INVALID_ITEM, INVALID_PRICE, @@ -90,7 +152,10 @@ public class PreShopCreationEvent extends Event { NOT_ENOUGH_MONEY, - OTHER, //For plugin use! + /** + * For plugin use + */ + OTHER, SHOP_CREATED_SUCCESSFULLY } diff --git a/src/main/java/com/Acrobot/ChestShop/Events/PreTransactionEvent.java b/src/main/java/com/Acrobot/ChestShop/Events/PreTransactionEvent.java index da391c7..ca687ef 100644 --- a/src/main/java/com/Acrobot/ChestShop/Events/PreTransactionEvent.java +++ b/src/main/java/com/Acrobot/ChestShop/Events/PreTransactionEvent.java @@ -12,6 +12,8 @@ import static com.Acrobot.ChestShop.Events.PreTransactionEvent.TransactionOutcom import static com.Acrobot.ChestShop.Events.TransactionEvent.TransactionType; /** + * Represents a state before transaction occurs + * * @author Acrobot */ public class PreTransactionEvent extends Event { @@ -45,66 +47,126 @@ public class PreTransactionEvent extends Event { this.transactionType = type; } + /** + * @return Shop's sign + */ public Sign getSign() { return sign; } + /** + * @return Total price of the items + */ public double getPrice() { return price; } + /** + * Sets the price of the items + * + * @param price Price of the items + */ public void setPrice(double price) { this.price = price; } + /** + * Sets the stock + * + * @param stock Stock + */ public void setStock(ItemStack... stock) { items = stock; } + /** + * @return Stock available + */ public ItemStack[] getStock() { return items; } + /** + * @return Shop's client + */ public Player getClient() { return client; } + /** + * @return Shop's owner + */ public OfflinePlayer getOwner() { return owner; } + /** + * Sets the shop's owner + * + * @param owner Shop owner + */ public void setOwner(OfflinePlayer owner) { this.owner = owner; } + /** + * @return Owner's inventory + */ public Inventory getOwnerInventory() { return ownerInventory; } + /** + * Sets the owner's inventory + * + * @param ownerInventory Onwer's inventory + */ public void setOwnerInventory(Inventory ownerInventory) { this.ownerInventory = ownerInventory; } + /** + * Sets the client's inventory + * + * @param clientInventory Client's inventory + */ public void setClientInventory(Inventory clientInventory) { this.clientInventory = clientInventory; } + /** + * @return Client's inventory + */ public Inventory getClientInventory() { return clientInventory; } + /** + * @return Transaction's type + */ public TransactionType getTransactionType() { return transactionType; } + /** + * @return Is the transaction cancelled? + */ public boolean isCancelled() { return transactionOutcome != TRANSACTION_SUCCESFUL; } + /** + * @return Transaction's outcome + */ public TransactionOutcome getTransactionOutcome() { return transactionOutcome; } + /** + * Sets the outcome of the transaction + * + * @param reason Transction's outcome + */ public void setCancelled(TransactionOutcome reason) { transactionOutcome = reason; } diff --git a/src/main/java/com/Acrobot/ChestShop/Events/ShopCreatedEvent.java b/src/main/java/com/Acrobot/ChestShop/Events/ShopCreatedEvent.java index f3f5d08..a4db32f 100644 --- a/src/main/java/com/Acrobot/ChestShop/Events/ShopCreatedEvent.java +++ b/src/main/java/com/Acrobot/ChestShop/Events/ShopCreatedEvent.java @@ -9,6 +9,8 @@ import org.bukkit.event.HandlerList; import javax.annotation.Nullable; /** + * Represents a state after shop creation + * * @author Acrobot */ public class ShopCreatedEvent extends Event { @@ -27,22 +29,48 @@ public class ShopCreatedEvent extends Event { this.signLines = signLines.clone(); } + /** + * Returns the text on the sign + * + * @param line Line number (0-3) + * @return Text on the sign + */ public String getSignLine(short line) { return signLines[line]; } + /** + * Returns the text on the sign + * + * @return Text on the sign + */ public String[] getSignLines() { return signLines; } + /** + * Returns the shop's creator + * + * @return Shop's creator + */ public Player getPlayer() { return creator; } + /** + * Returns the shop's sign + * + * @return Shop's sign + */ public Sign getSign() { return sign; } + /** + * Returns the shop's chest (if applicable) + * + * @return Shop's chest + */ @Nullable public Chest getChest() { return chest; } diff --git a/src/main/java/com/Acrobot/ChestShop/Events/ShopDestroyedEvent.java b/src/main/java/com/Acrobot/ChestShop/Events/ShopDestroyedEvent.java index 0feb7ea..4f78c10 100644 --- a/src/main/java/com/Acrobot/ChestShop/Events/ShopDestroyedEvent.java +++ b/src/main/java/com/Acrobot/ChestShop/Events/ShopDestroyedEvent.java @@ -9,6 +9,8 @@ import org.bukkit.event.HandlerList; import javax.annotation.Nullable; /** + * Represents a state after shop destruction + * * @author Acrobot */ public class ShopDestroyedEvent extends Event { @@ -25,14 +27,23 @@ public class ShopDestroyedEvent extends Event { this.chest = chest; } + /** + * @return Shop's destroyer + */ @Nullable public Player getDestroyer() { return destroyer; } + /** + * @return Shop's chest + */ @Nullable public Chest getChest() { return chest; } + /** + * @return Shop's sign + */ public Sign getSign() { return sign; } diff --git a/src/main/java/com/Acrobot/ChestShop/Events/TransactionEvent.java b/src/main/java/com/Acrobot/ChestShop/Events/TransactionEvent.java index 582d546..18e29a7 100644 --- a/src/main/java/com/Acrobot/ChestShop/Events/TransactionEvent.java +++ b/src/main/java/com/Acrobot/ChestShop/Events/TransactionEvent.java @@ -9,6 +9,8 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; /** + * Represents a state after transaction has occured + * * @author Acrobot */ public class TransactionEvent extends Event { @@ -56,34 +58,58 @@ public class TransactionEvent extends Event { this.sign = sign; } + /** + * @return Type of the transaction + */ public TransactionType getTransactionType() { return type; } + /** + * @return Owner's inventory + */ public Inventory getOwnerInventory() { return ownerInventory; } + /** + * @return Client's inventory + */ public Inventory getClientInventory() { return clientInventory; } + /** + * @return Shop's client + */ public Player getClient() { return client; } + /** + * @return Shop's owner + */ public OfflinePlayer getOwner() { return owner; } + /** + * @return Stock available + */ public ItemStack[] getStock() { return stock; } + /** + * @return Total price of the items + */ public double getPrice() { return price; } + /** + * @return Shop's sign + */ public Sign getSign() { return sign; } @@ -96,6 +122,9 @@ public class TransactionEvent extends Event { return handlers; } + /** + * Possible transaction types + */ public enum TransactionType { BUY, SELL