blob: ae9e1c90743d674731aafec68030a2fe1e937329 (
plain)
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
|
package org.bukkit.event.player;
import org.bukkit.entity.ExperienceOrb;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
/**
* Represents when a player has an item repaired via the Mending enchantment.
* <br>
* This event is fired directly before the {@link PlayerExpChangeEvent}, and the
* results of this event directly affect the {@link PlayerExpChangeEvent}.
*/
public class PlayerItemMendEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
//
private final ItemStack item;
private final ExperienceOrb experienceOrb;
private int repairAmount;
private boolean cancelled;
public PlayerItemMendEvent(Player who, ItemStack item, ExperienceOrb experienceOrb, int repairAmount) {
super(who);
this.item = item;
this.experienceOrb = experienceOrb;
this.repairAmount = repairAmount;
}
/**
* Get the {@link ItemStack} to be repaired.
*
* This is not necessarily the item the player is holding.
*
* @return the item to be repaired
*/
public ItemStack getItem() {
return item;
}
/**
* Get the experience orb triggering the event.
*
* @return the experience orb
*/
public ExperienceOrb getExperienceOrb() {
return experienceOrb;
}
/**
* Get the amount the item is to be repaired.
*
* The default value is twice the value of the consumed experience orb
* or the remaining damage left on the item, whichever is smaller.
*
* @return how much damage will be repaired by the experience orb
*/
public int getRepairAmount() {
return repairAmount;
}
/**
* Set the amount the item will be repaired.
*
* Half of this value will be subtracted from the experience orb which initiated this event.
*
* @param amount how much damage will be repaired on the item
*/
public void setRepairAmount(int amount) {
this.repairAmount = amount;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}
|