mirror of
https://github.com/hyperdefined/ToolStats.git
synced 2025-12-06 06:41:44 +00:00
hopefully fixed long standing bug
This commit is contained in:
@@ -70,17 +70,18 @@ public class BlocksMined implements Listener {
|
|||||||
}
|
}
|
||||||
// read the current stats from the item
|
// read the current stats from the item
|
||||||
// if they don't exist, then start from 0
|
// if they don't exist, then start from 0
|
||||||
Integer blocksMined = 0;
|
Integer blocksMined = null;
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
if (container.has(toolStats.genericMined, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.genericMined, PersistentDataType.INTEGER)) {
|
||||||
blocksMined = container.get(toolStats.genericMined, PersistentDataType.INTEGER);
|
blocksMined = container.get(toolStats.genericMined, PersistentDataType.INTEGER);
|
||||||
}
|
}
|
||||||
if (blocksMined == null) {
|
if (blocksMined == null) {
|
||||||
return;
|
blocksMined = 0;
|
||||||
} else {
|
|
||||||
blocksMined++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blocksMined++;
|
||||||
container.set(toolStats.genericMined, PersistentDataType.INTEGER, blocksMined);
|
container.set(toolStats.genericMined, PersistentDataType.INTEGER, blocksMined);
|
||||||
|
|
||||||
String configLore = toolStats.getLoreFromConfig("blocks-mined", false);
|
String configLore = toolStats.getLoreFromConfig("blocks-mined", false);
|
||||||
String configLoreRaw = toolStats.getLoreFromConfig("blocks-mined", true);
|
String configLoreRaw = toolStats.getLoreFromConfig("blocks-mined", true);
|
||||||
|
|
||||||
|
|||||||
@@ -201,16 +201,16 @@ public class EntityDamage implements Listener {
|
|||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Integer playerKills = 0;
|
Integer playerKills = null;
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
if (container.has(toolStats.swordPlayerKills, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.swordPlayerKills, PersistentDataType.INTEGER)) {
|
||||||
playerKills = container.get(toolStats.swordPlayerKills, PersistentDataType.INTEGER);
|
playerKills = container.get(toolStats.swordPlayerKills, PersistentDataType.INTEGER);
|
||||||
}
|
}
|
||||||
if (playerKills == null) {
|
if (playerKills == null) {
|
||||||
return null;
|
playerKills = 0;
|
||||||
} else {
|
|
||||||
playerKills++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
playerKills++;
|
||||||
container.set(toolStats.swordPlayerKills, PersistentDataType.INTEGER, playerKills);
|
container.set(toolStats.swordPlayerKills, PersistentDataType.INTEGER, playerKills);
|
||||||
|
|
||||||
String playerKillsLore = toolStats.getLoreFromConfig("kills.player", false);
|
String playerKillsLore = toolStats.getLoreFromConfig("kills.player", false);
|
||||||
@@ -264,16 +264,16 @@ public class EntityDamage implements Listener {
|
|||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Integer mobKills = 0;
|
Integer mobKills = null;
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
if (container.has(toolStats.swordMobKills, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.swordMobKills, PersistentDataType.INTEGER)) {
|
||||||
mobKills = container.get(toolStats.swordMobKills, PersistentDataType.INTEGER);
|
mobKills = container.get(toolStats.swordMobKills, PersistentDataType.INTEGER);
|
||||||
}
|
}
|
||||||
if (mobKills == null) {
|
if (mobKills == null) {
|
||||||
return null;
|
mobKills = 0;
|
||||||
} else {
|
|
||||||
mobKills++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mobKills++;
|
||||||
container.set(toolStats.swordMobKills, PersistentDataType.INTEGER, mobKills);
|
container.set(toolStats.swordMobKills, PersistentDataType.INTEGER, mobKills);
|
||||||
|
|
||||||
String mobKillsLore = toolStats.getLoreFromConfig("kills.mob", false);
|
String mobKillsLore = toolStats.getLoreFromConfig("kills.mob", false);
|
||||||
@@ -326,16 +326,16 @@ public class EntityDamage implements Listener {
|
|||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Double damageTaken = 0.0;
|
Double damageTaken = null;
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
if (container.has(toolStats.armorDamage, PersistentDataType.DOUBLE)) {
|
if (container.has(toolStats.armorDamage, PersistentDataType.DOUBLE)) {
|
||||||
damageTaken = container.get(toolStats.armorDamage, PersistentDataType.DOUBLE);
|
damageTaken = container.get(toolStats.armorDamage, PersistentDataType.DOUBLE);
|
||||||
}
|
}
|
||||||
if (damageTaken == null) {
|
if (damageTaken == null) {
|
||||||
return;
|
damageTaken = 0.0;
|
||||||
} else {
|
|
||||||
damageTaken = damageTaken + damage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
damageTaken = damageTaken + damage;
|
||||||
container.set(toolStats.armorDamage, PersistentDataType.DOUBLE, damageTaken);
|
container.set(toolStats.armorDamage, PersistentDataType.DOUBLE, damageTaken);
|
||||||
|
|
||||||
String damageTakenLore = toolStats.getLoreFromConfig("damage-taken", false);
|
String damageTakenLore = toolStats.getLoreFromConfig("damage-taken", false);
|
||||||
|
|||||||
@@ -82,16 +82,16 @@ public class PlayerFish implements Listener {
|
|||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Integer fishCaught = 0;
|
Integer fishCaught = null;
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
if (container.has(toolStats.fishingRodCaught, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.fishingRodCaught, PersistentDataType.INTEGER)) {
|
||||||
fishCaught = container.get(toolStats.fishingRodCaught, PersistentDataType.INTEGER);
|
fishCaught = container.get(toolStats.fishingRodCaught, PersistentDataType.INTEGER);
|
||||||
}
|
}
|
||||||
if (fishCaught == null) {
|
if (fishCaught == null) {
|
||||||
return;
|
fishCaught = 0;
|
||||||
} else {
|
|
||||||
fishCaught++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fishCaught++;
|
||||||
container.set(toolStats.fishingRodCaught, PersistentDataType.INTEGER, fishCaught);
|
container.set(toolStats.fishingRodCaught, PersistentDataType.INTEGER, fishCaught);
|
||||||
|
|
||||||
String fishCaughtLore = toolStats.getLoreFromConfig("fished.fish-caught", false);
|
String fishCaughtLore = toolStats.getLoreFromConfig("fished.fish-caught", false);
|
||||||
|
|||||||
@@ -84,10 +84,10 @@ public class SheepShear implements Listener {
|
|||||||
sheepSheared = container.get(toolStats.shearsSheared, PersistentDataType.INTEGER);
|
sheepSheared = container.get(toolStats.shearsSheared, PersistentDataType.INTEGER);
|
||||||
}
|
}
|
||||||
if (sheepSheared == null) {
|
if (sheepSheared == null) {
|
||||||
return;
|
sheepSheared = 0;
|
||||||
} else {
|
|
||||||
sheepSheared++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sheepSheared++;
|
||||||
container.set(toolStats.shearsSheared, PersistentDataType.INTEGER, sheepSheared);
|
container.set(toolStats.shearsSheared, PersistentDataType.INTEGER, sheepSheared);
|
||||||
|
|
||||||
String sheepShearedLore = toolStats.getLoreFromConfig("sheep-sheared", false);
|
String sheepShearedLore = toolStats.getLoreFromConfig("sheep-sheared", false);
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ public class VillagerTrade implements Listener {
|
|||||||
if (newItem != null) {
|
if (newItem != null) {
|
||||||
// this gets delayed since villager inventories suck for no reason
|
// this gets delayed since villager inventories suck for no reason
|
||||||
Bukkit.getScheduler().runTaskLater(toolStats, () -> event.setCurrentItem(newItem), 5);
|
Bukkit.getScheduler().runTaskLater(toolStats, () -> event.setCurrentItem(newItem), 5);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user