forked from ChestShop-authors/ChestShop-3
-
Notifications
You must be signed in to change notification settings - Fork 2
/
PreShopCreationItemDisplayNameEvent.java
58 lines (44 loc) · 1.71 KB
/
PreShopCreationItemDisplayNameEvent.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
package com.Acrobot.ChestShop.Events;
import com.Acrobot.ChestShop.ItemNaming.ItemDisplayNameShortener;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
/**
* Represents an event that is fired before the display name of an item in a shop is created.
* The final value of displayName will be displayed on the sign of the newly created shop.
*/
public class PreShopCreationItemDisplayNameEvent extends Event {
private final ItemStack itemStack;
private String displayName;
private ItemDisplayNameShortener itemDisplayNameShortener = null;
public PreShopCreationItemDisplayNameEvent(ItemStack itemStack, String displayName) {
this.itemStack = itemStack;
this.displayName = displayName;
}
public ItemStack getItemStack() {
return itemStack;
}
public String getDisplayName() {
return displayName;
}
public ItemDisplayNameShortener getItemDisplayNameShortener() {
return itemDisplayNameShortener;
}
public void setDisplayName(String displayName) {
setDisplayName(displayName, null);
}
public void setDisplayName(String displayName, ItemDisplayNameShortener itemDisplayNameShortener) {
if (displayName == null || displayName.isBlank())
throw new IllegalArgumentException("The display name can't be blank or null.");
this.displayName = displayName;
this.itemDisplayNameShortener = itemDisplayNameShortener;
}
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}