mirror of
https://github.com/hyperdefined/ToolStats.git
synced 2026-01-28 00:15:59 +00:00
support for swapping modes
this makes sure the PDC matches when token mode is off so you can swap without issue
This commit is contained in:
@@ -229,14 +229,29 @@ public class ItemLore {
|
||||
// if they don't exist, then start from 0
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
|
||||
// check for tokens
|
||||
boolean validToken = toolStats.itemChecker.checkTokens(container, "crops-mined");
|
||||
// check for tokens
|
||||
if (toolStats.config.getBoolean("tokens.enabled")) {
|
||||
// if the item has this token, then continue
|
||||
// if the item does not, ignore
|
||||
boolean validTokens = toolStats.itemChecker.checkTokens(container, "crops-mined");
|
||||
if (!validTokens) {
|
||||
// if the item has stats but no token, add the token
|
||||
if (container.has(toolStats.cropsHarvested) && !validToken) {
|
||||
String newTokens = toolStats.itemChecker.addTokensToExisting(clone);
|
||||
if (newTokens != null) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, newTokens);
|
||||
}
|
||||
}
|
||||
|
||||
// the item does not have a valid token
|
||||
if (!validToken) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (!validToken) {
|
||||
String newTokens = toolStats.itemChecker.addTokensToExisting(clone);
|
||||
if (newTokens != null) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, newTokens);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Integer cropsMined = 0;
|
||||
@@ -244,6 +259,8 @@ public class ItemLore {
|
||||
cropsMined = container.get(toolStats.cropsHarvested, PersistentDataType.INTEGER);
|
||||
}
|
||||
|
||||
toolStats.logger.info("woooo!!!!!!!!!!");
|
||||
|
||||
if (cropsMined == null) {
|
||||
cropsMined = 0;
|
||||
toolStats.logger.warning(clone + " does not have valid crops-mined set! Resting to zero. This should NEVER happen.");
|
||||
@@ -280,14 +297,28 @@ public class ItemLore {
|
||||
}
|
||||
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
boolean validToken = toolStats.itemChecker.checkTokens(container, "blocks-mined");
|
||||
// check for tokens
|
||||
if (toolStats.config.getBoolean("tokens.enabled")) {
|
||||
// if the item has this token, then continue
|
||||
// if the item does not, ignore
|
||||
boolean validTokens = toolStats.itemChecker.checkTokens(container, "blocks-mined");
|
||||
if (!validTokens) {
|
||||
// if the item has stats but no token, add the token
|
||||
if (container.has(toolStats.blocksMined) && !validToken) {
|
||||
String newTokens = toolStats.itemChecker.addTokensToExisting(clone);
|
||||
if (newTokens != null) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, newTokens);
|
||||
}
|
||||
}
|
||||
|
||||
// the item does not have a valid token
|
||||
if (!validToken) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (!validToken) {
|
||||
String newTokens = toolStats.itemChecker.addTokensToExisting(clone);
|
||||
if (newTokens != null) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, newTokens);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// read the current stats from the item
|
||||
@@ -334,13 +365,28 @@ public class ItemLore {
|
||||
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
// check for tokens
|
||||
boolean validToken = toolStats.itemChecker.checkTokens(container, "player-kills");
|
||||
// check for tokens
|
||||
if (toolStats.config.getBoolean("tokens.enabled")) {
|
||||
// if the item has this token, then continue
|
||||
// if the item does not, ignore
|
||||
boolean validTokens = toolStats.itemChecker.checkTokens(container, "player-kills");
|
||||
if (!validTokens) {
|
||||
// if the item has stats but no token, add the token
|
||||
if (container.has(toolStats.playerKills) && !validToken) {
|
||||
String newTokens = toolStats.itemChecker.addTokensToExisting(clone);
|
||||
if (newTokens != null) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, newTokens);
|
||||
}
|
||||
}
|
||||
|
||||
// the item does not have a valid token
|
||||
if (!validToken) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (!validToken) {
|
||||
String newTokens = toolStats.itemChecker.addTokensToExisting(clone);
|
||||
if (newTokens != null) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, newTokens);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Integer playerKills = 0;
|
||||
@@ -385,13 +431,28 @@ public class ItemLore {
|
||||
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
// check for tokens
|
||||
boolean validToken = toolStats.itemChecker.checkTokens(container, "mob-kills");
|
||||
// check for tokens
|
||||
if (toolStats.config.getBoolean("tokens.enabled")) {
|
||||
// if the item has this token, then continue
|
||||
// if the item does not, ignore
|
||||
boolean validTokens = toolStats.itemChecker.checkTokens(container, "mob-kills");
|
||||
if (!validTokens) {
|
||||
// if the item has stats but no token, add the token
|
||||
if (container.has(toolStats.mobKills) && !validToken) {
|
||||
String newTokens = toolStats.itemChecker.addTokensToExisting(clone);
|
||||
if (newTokens != null) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, newTokens);
|
||||
}
|
||||
}
|
||||
|
||||
// the item does not have a valid token
|
||||
if (!validToken) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (!validToken) {
|
||||
String newTokens = toolStats.itemChecker.addTokensToExisting(clone);
|
||||
if (newTokens != null) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, newTokens);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Integer mobKills = 0;
|
||||
@@ -444,13 +505,28 @@ public class ItemLore {
|
||||
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
// check for tokens
|
||||
boolean validToken = toolStats.itemChecker.checkTokens(container, "damage-taken");
|
||||
// check for tokens
|
||||
if (toolStats.config.getBoolean("tokens.enabled")) {
|
||||
// if the item has this token, then continue
|
||||
// if the item does not, ignore
|
||||
boolean validTokens = toolStats.itemChecker.checkTokens(container, "damage-taken");
|
||||
if (!validTokens) {
|
||||
// if the item has stats but no token, add the token
|
||||
if (container.has(toolStats.armorDamage) && !validToken) {
|
||||
String newTokens = toolStats.itemChecker.addTokensToExisting(clone);
|
||||
if (newTokens != null) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, newTokens);
|
||||
}
|
||||
}
|
||||
|
||||
// the item does not have a valid token
|
||||
if (!validToken) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (!validToken) {
|
||||
String newTokens = toolStats.itemChecker.addTokensToExisting(clone);
|
||||
if (newTokens != null) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, newTokens);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Double damageTaken = 0.0;
|
||||
@@ -494,13 +570,28 @@ public class ItemLore {
|
||||
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
// check for tokens
|
||||
boolean validToken = toolStats.itemChecker.checkTokens(container, "flight-time");
|
||||
// check for tokens
|
||||
if (toolStats.config.getBoolean("tokens.enabled")) {
|
||||
// if the item has this token, then continue
|
||||
// if the item does not, ignore
|
||||
boolean validTokens = toolStats.itemChecker.checkTokens(container, "flight-time");
|
||||
if (!validTokens) {
|
||||
// if the item has stats but no token, add the token
|
||||
if (container.has(toolStats.flightTime) && !validToken) {
|
||||
String newTokens = toolStats.itemChecker.addTokensToExisting(clone);
|
||||
if (newTokens != null) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, newTokens);
|
||||
}
|
||||
}
|
||||
|
||||
// the item does not have a valid token
|
||||
if (!validToken) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (!validToken) {
|
||||
String newTokens = toolStats.itemChecker.addTokensToExisting(clone);
|
||||
if (newTokens != null) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, newTokens);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// read the current stats from the item
|
||||
@@ -547,13 +638,28 @@ public class ItemLore {
|
||||
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
// check for tokens
|
||||
boolean validToken = toolStats.itemChecker.checkTokens(container, "sheep-sheared");
|
||||
// check for tokens
|
||||
if (toolStats.config.getBoolean("tokens.enabled")) {
|
||||
// if the item has this token, then continue
|
||||
// if the item does not, ignore
|
||||
boolean validTokens = toolStats.itemChecker.checkTokens(container, "sheep-sheared");
|
||||
if (!validTokens) {
|
||||
// if the item has stats but no token, add the token
|
||||
if (container.has(toolStats.sheepSheared) && !validToken) {
|
||||
String newTokens = toolStats.itemChecker.addTokensToExisting(clone);
|
||||
if (newTokens != null) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, newTokens);
|
||||
}
|
||||
}
|
||||
|
||||
// the item does not have a valid token
|
||||
if (!validToken) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (!validToken) {
|
||||
String newTokens = toolStats.itemChecker.addTokensToExisting(clone);
|
||||
if (newTokens != null) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, newTokens);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Integer sheepSheared = 0;
|
||||
@@ -597,13 +703,28 @@ public class ItemLore {
|
||||
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
// check for tokens
|
||||
boolean validToken = toolStats.itemChecker.checkTokens(container, "arrows-shot");
|
||||
// check for tokens
|
||||
if (toolStats.config.getBoolean("tokens.enabled")) {
|
||||
// if the item has this token, then continue
|
||||
// if the item does not, ignore
|
||||
boolean validTokens = toolStats.itemChecker.checkTokens(container, "arrows-shot");
|
||||
if (!validTokens) {
|
||||
// if the item has stats but no token, add the token
|
||||
if (container.has(toolStats.arrowsShot) && !validToken) {
|
||||
String newTokens = toolStats.itemChecker.addTokensToExisting(clone);
|
||||
if (newTokens != null) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, newTokens);
|
||||
}
|
||||
}
|
||||
|
||||
// the item does not have a valid token
|
||||
if (!validToken) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (!validToken) {
|
||||
String newTokens = toolStats.itemChecker.addTokensToExisting(clone);
|
||||
if (newTokens != null) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, newTokens);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// read the current stats from the item
|
||||
@@ -650,13 +771,28 @@ public class ItemLore {
|
||||
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
// check for tokens
|
||||
boolean validToken = toolStats.itemChecker.checkTokens(container, "fish-caught");
|
||||
// check for tokens
|
||||
if (toolStats.config.getBoolean("tokens.enabled")) {
|
||||
// if the item has this token, then continue
|
||||
// if the item does not, ignore
|
||||
boolean validTokens = toolStats.itemChecker.checkTokens(container, "fish-caught");
|
||||
if (!validTokens) {
|
||||
// if the item has stats but no token, add the token
|
||||
if (container.has(toolStats.fishCaught) && !validToken) {
|
||||
String newTokens = toolStats.itemChecker.addTokensToExisting(clone);
|
||||
if (newTokens != null) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, newTokens);
|
||||
}
|
||||
}
|
||||
|
||||
// the item does not have a valid token
|
||||
if (!validToken) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (!validToken) {
|
||||
String newTokens = toolStats.itemChecker.addTokensToExisting(clone);
|
||||
if (newTokens != null) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, newTokens);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Integer fishCaught = 0;
|
||||
|
||||
Reference in New Issue
Block a user