forked from ChestShop-authors/ChestShop-3
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ShopCreatedEvent.java
100 lines (86 loc) · 2.2 KB
/
ShopCreatedEvent.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package com.Acrobot.ChestShop.Events;
import com.Acrobot.ChestShop.Signs.ChestShopMetaData;
import javax.annotation.Nullable;
import org.bukkit.block.Container;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
/**
* Represents a state after shop creation
*
* @author Acrobot
*/
public class ShopCreatedEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private final Player creator;
private final Sign sign;
private final String[] signLines;
private final ChestShopMetaData chestShopMetaData;
@Nullable
private final Container chest;
public ShopCreatedEvent(Player creator, Sign sign, @Nullable Container chest, String[] signLines, ChestShopMetaData chestShopMetaData) {
this.creator = creator;
this.sign = sign;
this.chest = chest;
this.signLines = signLines.clone();
this.chestShopMetaData = chestShopMetaData;
}
public ItemStack getItemStack() {
return chestShopMetaData.getItemStack();
}
public int getQuantity() {
return chestShopMetaData.getQuantity();
}
/**
* 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 Container getChest() {
return chest;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}