Skip to content

Commit 2e0ee18

Browse files
committed
more possible plugin compatibility?
1 parent 98a5f20 commit 2e0ee18

File tree

4 files changed

+13
-27
lines changed

4 files changed

+13
-27
lines changed

src/main/java/lol/hyper/toolstats/events/BlocksMined.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public BlocksMined(ToolStats toolStats) {
4444
this.toolStats = toolStats;
4545
}
4646

47-
@EventHandler(priority = EventPriority.HIGHEST)
47+
@EventHandler(priority = EventPriority.MONITOR)
4848
public void onBreak(BlockBreakEvent event) {
4949
if (event.isCancelled()) {
5050
return;

src/main/java/lol/hyper/toolstats/events/EntityDamage.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public EntityDamage(ToolStats toolStats) {
4747
this.toolStats = toolStats;
4848
}
4949

50-
@EventHandler(priority = EventPriority.HIGHEST)
50+
@EventHandler(priority = EventPriority.MONITOR)
5151
public void onDamage(EntityDamageByEntityEvent event) {
5252
if (event.isCancelled()) {
5353
return;
@@ -151,7 +151,7 @@ public void onDamage(EntityDamageByEntityEvent event) {
151151
}
152152
}
153153

154-
@EventHandler(priority = EventPriority.LOWEST)
154+
@EventHandler(priority = EventPriority.MONITOR)
155155
public void onDamage(EntityDamageEvent event) {
156156
if (!(event.getEntity() instanceof LivingEntity)) {
157157
return;
@@ -181,7 +181,7 @@ public void onDamage(EntityDamageEvent event) {
181181
}
182182
}
183183

184-
@EventHandler(priority = EventPriority.LOWEST)
184+
@EventHandler(priority = EventPriority.MONITOR)
185185
public void onDamage(EntityDamageByBlockEvent event) {
186186
if (!(event.getEntity() instanceof LivingEntity)) {
187187
return;

src/main/java/lol/hyper/toolstats/events/PlayerFish.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public PlayerFish(ToolStats toolStats) {
4747
this.toolStats = toolStats;
4848
}
4949

50-
@EventHandler(priority = EventPriority.HIGHEST)
50+
@EventHandler(priority = EventPriority.MONITOR)
5151
public void onFish(PlayerFishEvent event) {
5252
if (event.isCancelled()) {
5353
return;
@@ -86,8 +86,7 @@ public void onFish(PlayerFishEvent event) {
8686
}
8787

8888
// update the fishing rod!
89-
ItemStack finalFishingRod = fishingRod;
90-
Bukkit.getScheduler().runTaskLater(toolStats, () -> updateFishCount(finalFishingRod), 1);
89+
updateFishCount(fishingRod);
9190

9291
// check if the player caught an item
9392
if (event.getCaught() == null) {

src/main/java/lol/hyper/toolstats/events/SheepShear.java

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public SheepShear(ToolStats toolStats) {
4545
this.toolStats = toolStats;
4646
}
4747

48-
@EventHandler(priority = EventPriority.HIGHEST)
48+
@EventHandler(priority = EventPriority.MONITOR)
4949
public void onShear(PlayerInteractEntityEvent event) {
5050
if (event.isCancelled()) {
5151
return;
@@ -93,32 +93,20 @@ public void onShear(PlayerInteractEntityEvent event) {
9393
}
9494

9595
// update the stats
96-
ItemStack newShears = addLore(shears);
97-
if (newShears != null) {
98-
if (isMainHand && isOffHand) {
99-
Bukkit.getScheduler().runTaskLater(toolStats, () -> inventory.setItemInMainHand(newShears), 1);
100-
return;
101-
}
102-
if (isMainHand) {
103-
Bukkit.getScheduler().runTaskLater(toolStats, () -> inventory.setItemInMainHand(newShears), 1);
104-
}
105-
if (isOffHand) {
106-
Bukkit.getScheduler().runTaskLater(toolStats, () -> inventory.setItemInOffHand(newShears), 1);
107-
}
108-
}
96+
ItemStack finalShears = shears;
97+
addLore(finalShears);
10998
}
11099

111100
/**
112101
* Adds tags to shears.
113102
*
114-
* @param oldShears The shears.
103+
* @param newShears The shears.
115104
*/
116-
private ItemStack addLore(ItemStack oldShears) {
117-
ItemStack newShears = oldShears.clone();
105+
private void addLore(ItemStack newShears) {
118106
ItemMeta meta = newShears.getItemMeta();
119107
if (meta == null) {
120108
toolStats.logger.warning(newShears + " does NOT have any meta! Unable to update stats.");
121-
return null;
109+
return;
122110
}
123111
Integer sheepSheared = 0;
124112
PersistentDataContainer container = meta.getPersistentDataContainer();
@@ -139,7 +127,7 @@ private ItemStack addLore(ItemStack oldShears) {
139127

140128
if (sheepShearedLore == null || sheepShearedLoreRaw == null) {
141129
toolStats.logger.warning("There is no lore message for messages.sheep-sheared!");
142-
return null;
130+
return;
143131
}
144132

145133
List<String> lore;
@@ -169,6 +157,5 @@ private ItemStack addLore(ItemStack oldShears) {
169157
meta.setLore(lore);
170158
}
171159
newShears.setItemMeta(meta);
172-
return newShears;
173160
}
174161
}

0 commit comments

Comments
 (0)