@@ -259,12 +259,22 @@ private void updateBowKills(PlayerInventory playerInventory, String type, Living
259259
260260 if (type .equalsIgnoreCase ("mob" )) {
261261 // player is shooting a mob
262- ItemMeta newBow ;
263- int count = 1 ;
264262 if (toolStats .roseStacker != null ) {
265- count = toolStats .roseStacker .countMobs (entity );
263+ toolStats .roseStacker .countMobs (entity , count -> {
264+ ItemMeta newBow = toolStats .itemLore .updateMobKills (heldBow , count );
265+ if (newBow != null ) {
266+ if (isMain && isOffHand ) {
267+ playerInventory .getItemInMainHand ().setItemMeta (newBow );
268+ } else if (isMain ) {
269+ playerInventory .getItemInMainHand ().setItemMeta (newBow );
270+ } else if (isOffHand ) {
271+ playerInventory .getItemInOffHand ().setItemMeta (newBow );
272+ }
273+ }
274+ });
275+ return ;
266276 }
267- newBow = toolStats .itemLore .updateMobKills (heldBow , count );
277+ ItemMeta newBow = toolStats .itemLore .updateMobKills (heldBow , 1 );
268278 if (newBow != null ) {
269279 if (isMain && isOffHand ) {
270280 playerInventory .getItemInMainHand ().setItemMeta (newBow );
@@ -292,19 +302,30 @@ private void updateBowKills(PlayerInventory playerInventory, String type, Living
292302
293303 private void updateTridentKills (Trident trident , String type , LivingEntity entity ) {
294304 ItemStack newTrident = trident .getItemStack ();
295- ItemMeta newTridentMeta ;
296305 if (type .equalsIgnoreCase ("player" )) {
297- newTridentMeta = toolStats .itemLore .updatePlayerKills (trident .getItemStack (), 1 );
298- } else {
299- int count = 1 ;
300- if (toolStats .roseStacker != null ) {
301- count = toolStats .roseStacker .countMobs (entity );
306+ ItemMeta newTridentMeta = toolStats .itemLore .updatePlayerKills (trident .getItemStack (), 1 );
307+ if (newTridentMeta != null ) {
308+ newTrident .setItemMeta (newTridentMeta );
309+ trident .setItemStack (newTrident );
302310 }
303- newTridentMeta = toolStats . itemLore . updateMobKills ( newTrident , count ) ;
311+ return ;
304312 }
305- if (newTridentMeta != null ) {
306- newTrident .setItemMeta (newTridentMeta );
307- trident .setItemStack (newTrident );
313+ if (type .equalsIgnoreCase ("mob" )) {
314+ if (toolStats .roseStacker != null ) {
315+ toolStats .roseStacker .countMobs (entity , count -> {
316+ ItemMeta newTridentMeta = toolStats .itemLore .updateMobKills (newTrident , count );
317+ if (newTridentMeta != null ) {
318+ newTrident .setItemMeta (newTridentMeta );
319+ trident .setItemStack (newTrident );
320+ }
321+ });
322+ return ;
323+ }
324+ ItemMeta newTridentMeta = toolStats .itemLore .updateMobKills (trident .getItemStack (), 1 );
325+ if (newTridentMeta != null ) {
326+ newTrident .setItemMeta (newTridentMeta );
327+ trident .setItemStack (newTrident );
328+ }
308329 }
309330 }
310331
@@ -327,27 +348,36 @@ private void updateWeaponDamage(PlayerInventory playerInventory, double damage)
327348
328349 private void updateWeaponKills (PlayerInventory playerInventory , String type , LivingEntity entity ) {
329350 ItemStack heldWeapon = playerInventory .getItemInMainHand ();
330- ItemMeta newHeldWeaponMeta = null ;
331351 if (type .equalsIgnoreCase ("player" )) {
332- newHeldWeaponMeta = toolStats .itemLore .updatePlayerKills (heldWeapon , 1 );
352+ ItemMeta newHeldWeaponMeta = toolStats .itemLore .updatePlayerKills (heldWeapon , 1 );
353+ if (newHeldWeaponMeta != null ) {
354+ playerInventory .getItemInMainHand ().setItemMeta (newHeldWeaponMeta );
355+ }
356+ return ;
333357 }
334358 if (type .equalsIgnoreCase ("mob" )) {
335- int count = 1 ;
336359 if (toolStats .roseStacker != null ) {
337- count = toolStats .roseStacker .countMobs (entity );
360+ toolStats .roseStacker .countMobs (entity , count -> {
361+ ItemStack currentHeldWeapon = playerInventory .getItemInMainHand ();
362+ ItemMeta newHeldWeaponMeta = toolStats .itemLore .updateMobKills (currentHeldWeapon , count );
363+ if (newHeldWeaponMeta != null ) {
364+ currentHeldWeapon .setItemMeta (newHeldWeaponMeta );
365+ }
366+ });
367+ } else {
368+ ItemMeta newHeldWeaponMeta = toolStats .itemLore .updateMobKills (heldWeapon , 1 );
369+ if (newHeldWeaponMeta != null ) {
370+ playerInventory .getItemInMainHand ().setItemMeta (newHeldWeaponMeta );
371+ }
338372 }
339- newHeldWeaponMeta = toolStats .itemLore .updateMobKills (heldWeapon , count );
340- }
341- if (newHeldWeaponMeta != null ) {
342- playerInventory .getItemInMainHand ().setItemMeta (newHeldWeaponMeta );
343373 }
344374 }
345375
346376 private void updateBossesKilled (PlayerInventory playerInventory , String boss , LivingEntity entity ) {
347377 ItemStack heldWeapon = playerInventory .getItemInMainHand ();
348378 int count = 1 ;
349379 if (toolStats .roseStacker != null ) {
350- count = toolStats .roseStacker .countMobs (entity );
380+ // count = toolStats.roseStacker.countMobs(entity);
351381 }
352382 ItemMeta newHeldWeaponMeta = toolStats .itemLore .updateBossesKilled (heldWeapon , count , boss );
353383 if (newHeldWeaponMeta != null ) {
@@ -364,12 +394,23 @@ private void updateBossesKilledByBow(PlayerInventory playerInventory, String bos
364394 boolean isMain = playerInventory .getItemInMainHand ().getType () == Material .BOW || playerInventory .getItemInMainHand ().getType () == Material .CROSSBOW ;
365395 boolean isOffHand = playerInventory .getItemInOffHand ().getType () == Material .BOW || playerInventory .getItemInOffHand ().getType () == Material .CROSSBOW ;
366396
367- int count = 1 ;
368397 if (toolStats .roseStacker != null ) {
369- count = toolStats .roseStacker .countMobs (entity );
398+ toolStats .roseStacker .countMobs (entity , count -> {
399+ ItemMeta newHeldWeaponMeta = toolStats .itemLore .updateBossesKilled (heldBow , count , boss );
400+ if (newHeldWeaponMeta != null ) {
401+ if (isMain && isOffHand ) {
402+ playerInventory .getItemInMainHand ().setItemMeta (newHeldWeaponMeta );
403+ } else if (isMain ) {
404+ playerInventory .getItemInMainHand ().setItemMeta (newHeldWeaponMeta );
405+ } else if (isOffHand ) {
406+ playerInventory .getItemInOffHand ().setItemMeta (newHeldWeaponMeta );
407+ }
408+ }
409+ });
410+ return ;
370411 }
371412
372- ItemMeta newHeldWeaponMeta = toolStats .itemLore .updateBossesKilled (heldBow , count , boss );
413+ ItemMeta newHeldWeaponMeta = toolStats .itemLore .updateBossesKilled (heldBow , 1 , boss );
373414 if (newHeldWeaponMeta != null ) {
374415 if (isMain && isOffHand ) {
375416 playerInventory .getItemInMainHand ().setItemMeta (newHeldWeaponMeta );
0 commit comments