-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing checkstyle errors and moving event to aligning with other even…
…t location.
- Loading branch information
1 parent
d3daf32
commit e9c4be3
Showing
4 changed files
with
101 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 0 additions & 99 deletions
99
Essentials/src/main/java/com/earth2me/essentials/signs/event/SignTransactionEvent.java
This file was deleted.
Oops, something went wrong.
86 changes: 86 additions & 0 deletions
86
Essentials/src/main/java/net/ess3/api/events/SignTransactionEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package net.ess3.api.events; | ||
|
||
import com.earth2me.essentials.signs.EssentialsSign; | ||
import net.ess3.api.IUser; | ||
import org.bukkit.event.Cancellable; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.math.BigDecimal; | ||
|
||
/** | ||
* Fired when a player either buys or sells from an essentials sign | ||
*/ | ||
public final class SignTransactionEvent extends SignInteractEvent implements Cancellable { | ||
private final ItemStack itemStack; | ||
private final TransactionType transactionType; | ||
private final BigDecimal transactionValue; | ||
private boolean isCancelled = false; | ||
|
||
public SignTransactionEvent(EssentialsSign.ISign sign, | ||
EssentialsSign essSign, | ||
IUser user, | ||
@NotNull ItemStack itemStack, | ||
@NotNull TransactionType transactionType, | ||
BigDecimal transactionValue) { | ||
super(sign, essSign, user); | ||
this.itemStack = itemStack; | ||
this.transactionType = transactionType; | ||
this.transactionValue = transactionValue; | ||
} | ||
|
||
/** | ||
* | ||
* @return if the event should be cancelled. | ||
*/ | ||
|
||
@Override | ||
public boolean isCancelled() { | ||
return this.isCancelled; | ||
} | ||
|
||
/** | ||
* | ||
* @param cancelled sets the event to be cancelled, this will cancel the transaction. | ||
*/ | ||
|
||
@Override | ||
public void setCancelled(boolean cancelled) { | ||
this.isCancelled = cancelled; | ||
} | ||
|
||
/** | ||
* | ||
* @return a copy of the itemstack in the current transaction. | ||
*/ | ||
|
||
public @NotNull ItemStack getItemStack() { | ||
return itemStack.clone(); | ||
} | ||
|
||
/** | ||
* | ||
* @return the type of transaction executed. | ||
*/ | ||
public @NotNull TransactionType getTransactionType() { | ||
return transactionType; | ||
} | ||
|
||
/** | ||
* | ||
* @return how much was either sold or bought through the sign. | ||
*/ | ||
|
||
public BigDecimal getTransactionValue() { | ||
return transactionValue; | ||
} | ||
|
||
/** | ||
* Transaction type of the event | ||
*/ | ||
|
||
public enum TransactionType { | ||
BUY, | ||
SELL | ||
} | ||
} |