mirror of
https://github.com/hyperdefined/ToolStats.git
synced 2025-12-08 05:34:58 +00:00
more possible plugin compatibility?
This commit is contained in:
@@ -44,7 +44,7 @@ public class BlocksMined implements Listener {
|
|||||||
this.toolStats = toolStats;
|
this.toolStats = toolStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onBreak(BlockBreakEvent event) {
|
public void onBreak(BlockBreakEvent event) {
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class EntityDamage implements Listener {
|
|||||||
this.toolStats = toolStats;
|
this.toolStats = toolStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onDamage(EntityDamageByEntityEvent event) {
|
public void onDamage(EntityDamageByEntityEvent event) {
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
@@ -151,7 +151,7 @@ public class EntityDamage implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onDamage(EntityDamageEvent event) {
|
public void onDamage(EntityDamageEvent event) {
|
||||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
if (!(event.getEntity() instanceof LivingEntity)) {
|
||||||
return;
|
return;
|
||||||
@@ -181,7 +181,7 @@ public class EntityDamage implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onDamage(EntityDamageByBlockEvent event) {
|
public void onDamage(EntityDamageByBlockEvent event) {
|
||||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
if (!(event.getEntity() instanceof LivingEntity)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class PlayerFish implements Listener {
|
|||||||
this.toolStats = toolStats;
|
this.toolStats = toolStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onFish(PlayerFishEvent event) {
|
public void onFish(PlayerFishEvent event) {
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
@@ -86,8 +86,7 @@ public class PlayerFish implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update the fishing rod!
|
// update the fishing rod!
|
||||||
ItemStack finalFishingRod = fishingRod;
|
updateFishCount(fishingRod);
|
||||||
Bukkit.getScheduler().runTaskLater(toolStats, () -> updateFishCount(finalFishingRod), 1);
|
|
||||||
|
|
||||||
// check if the player caught an item
|
// check if the player caught an item
|
||||||
if (event.getCaught() == null) {
|
if (event.getCaught() == null) {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class SheepShear implements Listener {
|
|||||||
this.toolStats = toolStats;
|
this.toolStats = toolStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onShear(PlayerInteractEntityEvent event) {
|
public void onShear(PlayerInteractEntityEvent event) {
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
@@ -93,32 +93,20 @@ public class SheepShear implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update the stats
|
// update the stats
|
||||||
ItemStack newShears = addLore(shears);
|
ItemStack finalShears = shears;
|
||||||
if (newShears != null) {
|
addLore(finalShears);
|
||||||
if (isMainHand && isOffHand) {
|
|
||||||
Bukkit.getScheduler().runTaskLater(toolStats, () -> inventory.setItemInMainHand(newShears), 1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isMainHand) {
|
|
||||||
Bukkit.getScheduler().runTaskLater(toolStats, () -> inventory.setItemInMainHand(newShears), 1);
|
|
||||||
}
|
|
||||||
if (isOffHand) {
|
|
||||||
Bukkit.getScheduler().runTaskLater(toolStats, () -> inventory.setItemInOffHand(newShears), 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds tags to shears.
|
* Adds tags to shears.
|
||||||
*
|
*
|
||||||
* @param oldShears The shears.
|
* @param newShears The shears.
|
||||||
*/
|
*/
|
||||||
private ItemStack addLore(ItemStack oldShears) {
|
private void addLore(ItemStack newShears) {
|
||||||
ItemStack newShears = oldShears.clone();
|
|
||||||
ItemMeta meta = newShears.getItemMeta();
|
ItemMeta meta = newShears.getItemMeta();
|
||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
toolStats.logger.warning(newShears + " does NOT have any meta! Unable to update stats.");
|
toolStats.logger.warning(newShears + " does NOT have any meta! Unable to update stats.");
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
Integer sheepSheared = 0;
|
Integer sheepSheared = 0;
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
@@ -139,7 +127,7 @@ public class SheepShear implements Listener {
|
|||||||
|
|
||||||
if (sheepShearedLore == null || sheepShearedLoreRaw == null) {
|
if (sheepShearedLore == null || sheepShearedLoreRaw == null) {
|
||||||
toolStats.logger.warning("There is no lore message for messages.sheep-sheared!");
|
toolStats.logger.warning("There is no lore message for messages.sheep-sheared!");
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> lore;
|
List<String> lore;
|
||||||
@@ -169,6 +157,5 @@ public class SheepShear implements Listener {
|
|||||||
meta.setLore(lore);
|
meta.setLore(lore);
|
||||||
}
|
}
|
||||||
newShears.setItemMeta(meta);
|
newShears.setItemMeta(meta);
|
||||||
return newShears;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user