Document events

This commit is contained in:
Acrobot 2013-04-27 14:48:19 +02:00
parent 12a1dd87f3
commit 7f933cb1d0
7 changed files with 229 additions and 1 deletions

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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