Skip to content

Commit 24d30f6

Browse files
committed
fix deepsource problems
1 parent bea7e52 commit 24d30f6

File tree

5 files changed

+8
-19
lines changed

5 files changed

+8
-19
lines changed

src/main/java/lol/hyper/toolstats/ToolStats.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public boolean checkConfig(ItemStack itemStack, String configName) {
186186
itemType = "trident";
187187
}
188188
} else {
189-
itemType = itemName.substring(itemName.indexOf("_") + 1);
189+
itemType = itemName.substring(itemName.indexOf('_') + 1);
190190
}
191191

192192
if (itemType == null) {

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,10 @@ private void updateBlocksMined(ItemStack playerTool) {
7474
}
7575
// read the current stats from the item
7676
// if they don't exist, then start from 0
77-
Integer blocksMined;
77+
Integer blocksMined = 0;
7878
PersistentDataContainer container = meta.getPersistentDataContainer();
7979
if (container.has(toolStats.genericMined, PersistentDataType.INTEGER)) {
8080
blocksMined = container.get(toolStats.genericMined, PersistentDataType.INTEGER);
81-
} else {
82-
blocksMined = 0;
8381
}
8482

8583
if (blocksMined == null) {

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,12 @@ private ItemStack updatePlayerKills(ItemStack itemStack) {
220220
toolStats.logger.warning(itemStack + " does NOT have any meta! Unable to update stats.");
221221
return null;
222222
}
223-
Integer playerKills;
223+
Integer playerKills = 0;
224224
PersistentDataContainer container = meta.getPersistentDataContainer();
225225
if (container.has(toolStats.swordPlayerKills, PersistentDataType.INTEGER)) {
226226
playerKills = container.get(toolStats.swordPlayerKills, PersistentDataType.INTEGER);
227-
} else {
228-
playerKills = 0;
229227
}
228+
230229
if (playerKills == null) {
231230
playerKills = 0;
232231
toolStats.logger.warning(itemStack + " does not have valid player-kills set! Resting to zero. This should NEVER happen.");
@@ -287,12 +286,10 @@ private ItemStack updateMobKills(ItemStack itemStack) {
287286
toolStats.logger.warning(itemStack + " does NOT have any meta! Unable to update stats.");
288287
return null;
289288
}
290-
Integer mobKills;
289+
Integer mobKills = 0;
291290
PersistentDataContainer container = meta.getPersistentDataContainer();
292291
if (container.has(toolStats.swordMobKills, PersistentDataType.INTEGER)) {
293292
mobKills = container.get(toolStats.swordMobKills, PersistentDataType.INTEGER);
294-
} else {
295-
mobKills = 0;
296293
}
297294

298295
if (mobKills == null) {
@@ -354,12 +351,10 @@ private void updateArmorDamage(ItemStack itemStack, double damage) {
354351
toolStats.logger.warning(itemStack + " does NOT have any meta! Unable to update stats.");
355352
return;
356353
}
357-
Double damageTaken;
354+
Double damageTaken = 0.0;
358355
PersistentDataContainer container = meta.getPersistentDataContainer();
359356
if (container.has(toolStats.armorDamage, PersistentDataType.DOUBLE)) {
360357
damageTaken = container.get(toolStats.armorDamage, PersistentDataType.DOUBLE);
361-
} else {
362-
damageTaken = 0.0;
363358
}
364359

365360
if (damageTaken == null) {

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,10 @@ private void updateFishCount(ItemStack fishingRod) {
9191
toolStats.logger.warning(fishingRod + " does NOT have any meta! Unable to update stats.");
9292
return;
9393
}
94-
Integer fishCaught;
94+
Integer fishCaught = 0;
9595
PersistentDataContainer container = meta.getPersistentDataContainer();
9696
if (container.has(toolStats.fishingRodCaught, PersistentDataType.INTEGER)) {
9797
fishCaught = container.get(toolStats.fishingRodCaught, PersistentDataType.INTEGER);
98-
} else {
99-
fishCaught = 0;
10098
}
10199

102100
if (fishCaught == null) {

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,10 @@ private ItemStack addLore(ItemStack oldShears) {
8686
toolStats.logger.warning(newShears + " does NOT have any meta! Unable to update stats.");
8787
return null;
8888
}
89-
Integer sheepSheared;
89+
Integer sheepSheared = 0;
9090
PersistentDataContainer container = meta.getPersistentDataContainer();
9191
if (container.has(toolStats.shearsSheared, PersistentDataType.INTEGER)) {
9292
sheepSheared = container.get(toolStats.shearsSheared, PersistentDataType.INTEGER);
93-
} else {
94-
sheepSheared = 0;
9593
}
9694

9795
if (sheepSheared == null) {

0 commit comments

Comments
 (0)