2020import lol .hyper .toolstats .ToolStats ;
2121import lol .hyper .toolstats .tools .ItemChecker ;
2222import lol .hyper .toolstats .tools .UUIDDataType ;
23+ import org .bukkit .Bukkit ;
2324import org .bukkit .GameMode ;
2425import org .bukkit .Material ;
2526import org .bukkit .entity .Item ;
3637import java .util .ArrayList ;
3738import java .util .Date ;
3839import java .util .List ;
40+ import java .util .ListIterator ;
3941
4042public class PlayerFish implements Listener {
4143
@@ -45,7 +47,7 @@ public PlayerFish(ToolStats toolStats) {
4547 this .toolStats = toolStats ;
4648 }
4749
48- @ EventHandler (priority = EventPriority .HIGHEST )
50+ @ EventHandler (priority = EventPriority .HIGH )
4951 public void onFish (PlayerFishEvent event ) {
5052 if (event .isCancelled ()) {
5153 return ;
@@ -66,10 +68,7 @@ public void onFish(PlayerFishEvent event) {
6668 return ;
6769 }
6870 // update the fishing rod to the new one
69- ItemStack newRod = updateFishCount (heldItem );
70- if (newRod != null ) {
71- player .getInventory ().setItem (heldItemSlot , newRod );
72- }
71+ updateFishCount (heldItem );
7372 // check if the player caught an item
7473 if (event .getCaught () == null ) {
7574 return ;
@@ -86,15 +85,14 @@ public void onFish(PlayerFishEvent event) {
8685
8786 /**
8887 * Update a fishing rod's fish count.
89- * @param originalRod The fishing rod to update.
88+ * @param fishingRod The fishing rod to update.
9089 * @return A new fishing rod with update counts.
9190 */
92- private ItemStack updateFishCount (ItemStack originalRod ) {
93- ItemStack newRod = originalRod .clone ();
94- ItemMeta meta = newRod .getItemMeta ();
91+ private void updateFishCount (ItemStack fishingRod ) {
92+ ItemMeta meta = fishingRod .getItemMeta ();
9593 if (meta == null ) {
96- toolStats .logger .warning (originalRod + " does NOT have any meta! Unable to update stats." );
97- return null ;
94+ toolStats .logger .warning (fishingRod + " does NOT have any meta! Unable to update stats." );
95+ return ;
9896 }
9997 Integer fishCaught ;
10098 PersistentDataContainer container = meta .getPersistentDataContainer ();
@@ -106,7 +104,7 @@ private ItemStack updateFishCount(ItemStack originalRod) {
106104
107105 if (fishCaught == null ) {
108106 fishCaught = 0 ;
109- toolStats .logger .warning (originalRod + " does not have valid fish-caught set! Resting to zero. This should NEVER happen." );
107+ toolStats .logger .warning (fishingRod + " does not have valid fish-caught set! Resting to zero. This should NEVER happen." );
110108 }
111109
112110 fishCaught ++;
@@ -117,7 +115,7 @@ private ItemStack updateFishCount(ItemStack originalRod) {
117115
118116 if (fishCaughtLore == null || fishCaughtLoreRaw == null ) {
119117 toolStats .logger .warning ("There is no lore message for messages.fish-caught!" );
120- return null ;
118+ return ;
121119 }
122120
123121 List <String > lore ;
@@ -142,11 +140,23 @@ private ItemStack updateFishCount(ItemStack originalRod) {
142140 lore = new ArrayList <>();
143141 lore .add (fishCaughtLoreRaw .replace ("{fish}" , toolStats .commaFormat .format (fishCaught )));
144142 }
143+
144+ /*
145+ if (Bukkit.getPluginManager().isPluginEnabled("EvenMoreFish")) {
146+ ListIterator<String> iterator = lore.listIterator();
147+ while (iterator.hasNext()) {
148+ String line = iterator.next();
149+ toolStats.logger.info(line);
150+ if (line.equalsIgnoreCase("§f")) {
151+ iterator.remove();
152+ }
153+ }
154+ }*/
155+
145156 if (toolStats .config .getBoolean ("enabled.fish-caught" )) {
146157 meta .setLore (lore );
147158 }
148- newRod .setItemMeta (meta );
149- return newRod ;
159+ fishingRod .setItemMeta (meta );
150160 }
151161
152162 /**
0 commit comments