mirror of
https://github.com/hyperdefined/ToolStats.git
synced 2025-12-06 06:41:44 +00:00
Compare commits
13 Commits
1.9
...
1.9.2-hotf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb5345bd14 | ||
|
|
eeb6038b66 | ||
|
|
5e3e9f0825 | ||
|
|
11ee83773e | ||
|
|
9f5da738dd | ||
|
|
434f0dfe30 | ||
|
|
06a3bb2498 | ||
|
|
5624c02ee2 | ||
|
|
3e1c2dcbc3 | ||
|
|
8a1759b6b1 | ||
|
|
b4be9eb741 | ||
|
|
7a18649474 | ||
|
|
32f1e78630 |
2
pom.xml
2
pom.xml
@@ -23,7 +23,7 @@
|
||||
|
||||
<groupId>lol.hyper</groupId>
|
||||
<artifactId>toolstats</artifactId>
|
||||
<version>1.9</version>
|
||||
<version>1.9.2-hotfix-2</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ToolStats</name>
|
||||
|
||||
@@ -112,7 +112,7 @@ public final class ToolStats extends JavaPlugin {
|
||||
*/
|
||||
public final NamespacedKey originType = new NamespacedKey(this, "origin");
|
||||
|
||||
public final int CONFIG_VERSION = 9;
|
||||
public final int CONFIG_VERSION = 10;
|
||||
public final Logger logger = this.getLogger();
|
||||
public final File configFile = new File(this.getDataFolder(), "config.yml");
|
||||
public boolean tokens = false;
|
||||
|
||||
@@ -184,39 +184,84 @@ public class AnvilEvent implements Listener {
|
||||
ItemStack newItem = toolStats.itemChecker.addToken(firstSlotItem, targetToken);
|
||||
switch (targetToken) {
|
||||
case "crops-mined": {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateCropsMined(newItem, 0));
|
||||
if (toolStats.config.getBoolean("enabled.crops-harvested")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateCropsMined(newItem, 0));
|
||||
} else {
|
||||
event.setResult(null);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "blocks-mined": {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateBlocksMined(newItem, 0));
|
||||
if (toolStats.configTools.checkConfig(newItem.getType(), "blocks-mined")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateBlocksMined(newItem, 0));
|
||||
} else {
|
||||
event.setResult(null);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "damage-taken": {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateDamage(newItem, 0.0, false));
|
||||
if (toolStats.config.getBoolean("enabled.armor-damage")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateDamage(newItem, 0.0, false));
|
||||
} else {
|
||||
event.setResult(null);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "mob-kills": {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateMobKills(newItem, 0));
|
||||
if (toolStats.configTools.checkConfig(newItem.getType(), "mob-kills")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateMobKills(newItem, 0));
|
||||
} else {
|
||||
event.setResult(null);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "player-kills": {
|
||||
newItem.setItemMeta(toolStats.itemLore.updatePlayerKills(newItem, 0));
|
||||
if (toolStats.configTools.checkConfig(newItem.getType(), "player-kills")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updatePlayerKills(newItem, 0));
|
||||
} else {
|
||||
event.setResult(null);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "arrows-shot": {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateArrowsShot(newItem, 0));
|
||||
if (toolStats.config.getBoolean("enabled.arrows-shot")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateArrowsShot(newItem, 0));
|
||||
} else {
|
||||
event.setResult(null);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "sheep-sheared": {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateSheepSheared(newItem, 0));
|
||||
if (toolStats.config.getBoolean("enabled.sheep-sheared")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateSheepSheared(newItem, 0));
|
||||
} else {
|
||||
event.setResult(null);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "flight-time": {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateFlightTime(newItem, 0));
|
||||
if (toolStats.config.getBoolean("enabled.flight-time")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateFlightTime(newItem, 0));
|
||||
} else {
|
||||
event.setResult(null);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "fish-caught": {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateFishCaught(newItem, 0));
|
||||
if (toolStats.config.getBoolean("enabled.fish-caught")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateFishCaught(newItem, 0));
|
||||
} else {
|
||||
event.setResult(null);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class CraftItem implements Listener {
|
||||
// if the slot was empty before we crafted, this means we just made it
|
||||
if (oldSlotItem == null) {
|
||||
// add the lore
|
||||
ItemStack newItem = addLore(newSlotItem, player);
|
||||
ItemStack newItem = addCraftOrigin(newSlotItem, player);
|
||||
if (newItem != null) {
|
||||
player.getInventory().setItem(i, newItem);
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class CraftItem implements Listener {
|
||||
}
|
||||
|
||||
// the player did not shift click
|
||||
ItemStack newItem = addLore(craftedItem, player);
|
||||
ItemStack newItem = addCraftOrigin(craftedItem, player);
|
||||
if (newItem != null) {
|
||||
// set the result
|
||||
event.setCurrentItem(newItem);
|
||||
@@ -111,7 +111,7 @@ public class CraftItem implements Listener {
|
||||
* @param owner The player crafting.
|
||||
* @return A copy of the item with the tags + lore.
|
||||
*/
|
||||
private ItemStack addLore(ItemStack itemStack, Player owner) {
|
||||
private ItemStack addCraftOrigin(ItemStack itemStack, Player owner) {
|
||||
// clone the item
|
||||
ItemStack newItem = itemStack.clone();
|
||||
ItemMeta meta = newItem.getItemMeta();
|
||||
@@ -130,25 +130,19 @@ public class CraftItem implements Listener {
|
||||
return null;
|
||||
}
|
||||
|
||||
// only make the hash if it's enabled
|
||||
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
||||
String hash = toolStats.hashMaker.makeHash(newItem.getType(), owner.getUniqueId(), timeCreated);
|
||||
container.set(toolStats.hash, PersistentDataType.STRING, hash);
|
||||
}
|
||||
|
||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 0);
|
||||
|
||||
List<Component> lore;
|
||||
// get the current lore the item
|
||||
List<Component> lore;
|
||||
if (meta.hasLore()) {
|
||||
lore = meta.lore();
|
||||
} else {
|
||||
lore = new ArrayList<>();
|
||||
}
|
||||
// do we add the lore based on the config?
|
||||
|
||||
// if creation date is enabled, add it
|
||||
if (toolStats.configTools.checkConfig(itemStack.getType(), "created-date")) {
|
||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 0);
|
||||
|
||||
String date = toolStats.numberFormat.formatDate(finalDate);
|
||||
Component newLine = toolStats.configTools.formatLore("created.created-on", "{date}", date);
|
||||
if (newLine == null) {
|
||||
@@ -157,7 +151,12 @@ public class CraftItem implements Listener {
|
||||
lore.add(newLine);
|
||||
meta.lore(lore);
|
||||
}
|
||||
|
||||
// if creation owner is enabled, add it
|
||||
if (toolStats.configTools.checkConfig(itemStack.getType(), "created-by")) {
|
||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 0);
|
||||
|
||||
Component newLine = toolStats.configTools.formatLore("created.created-by", "{player}", owner.getName());
|
||||
if (newLine == null) {
|
||||
return null;
|
||||
@@ -165,6 +164,12 @@ public class CraftItem implements Listener {
|
||||
lore.add(newLine);
|
||||
meta.lore(lore);
|
||||
}
|
||||
|
||||
// if hash is enabled, add it
|
||||
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
||||
String hash = toolStats.hashMaker.makeHash(newItem.getType(), owner.getUniqueId(), timeCreated);
|
||||
container.set(toolStats.hash, PersistentDataType.STRING, hash);
|
||||
}
|
||||
newItem.setItemMeta(meta);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
@@ -65,50 +65,53 @@ public class CreativeEvent implements Listener {
|
||||
}
|
||||
|
||||
// add the tags to the item
|
||||
ItemStack newItem = addLore(spawnedItem, player);
|
||||
ItemStack newItem = addCreativeOrigin(spawnedItem, player);
|
||||
if (newItem != null) {
|
||||
event.setCursor(newItem);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds tags to newly spawned items in creative.
|
||||
* Adds spawned in tags to item.
|
||||
*
|
||||
* @param spawnedItem The item.
|
||||
* @param itemStack The item add item to.
|
||||
* @param owner The player spawning in.
|
||||
* @return A copy of the item with the tags + lore.
|
||||
*/
|
||||
private ItemStack addLore(ItemStack spawnedItem, Player owner) {
|
||||
ItemStack newSpawnedItem = spawnedItem.clone();
|
||||
private ItemStack addCreativeOrigin(ItemStack itemStack, Player owner) {
|
||||
ItemStack newSpawnedItem = itemStack.clone();
|
||||
ItemMeta meta = newSpawnedItem.getItemMeta();
|
||||
if (meta == null) {
|
||||
toolStats.logger.warning(newSpawnedItem + " does NOT have any meta! Unable to update stats.");
|
||||
toolStats.logger.warning(itemStack + " does NOT have any meta! Unable to update stats.");
|
||||
return null;
|
||||
}
|
||||
|
||||
// get the current time
|
||||
long timeCreated = System.currentTimeMillis();
|
||||
Date finalDate = new Date(timeCreated);
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
|
||||
// if the item already has an origin set, don't add it again
|
||||
if (container.has(toolStats.originType, PersistentDataType.INTEGER)) {
|
||||
// if the item already has the tag
|
||||
// this is to prevent duplicate tags
|
||||
if (container.has(toolStats.timeCreated, PersistentDataType.LONG) || container.has(toolStats.itemOwner, PersistentDataType.LONG)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// only make the hash if it's enabled
|
||||
// if hash is enabled, add it
|
||||
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
||||
String hash = toolStats.hashMaker.makeHash(spawnedItem.getType(), owner.getUniqueId(), timeCreated);
|
||||
String hash = toolStats.hashMaker.makeHash(newSpawnedItem.getType(), owner.getUniqueId(), timeCreated);
|
||||
container.set(toolStats.hash, PersistentDataType.STRING, hash);
|
||||
}
|
||||
|
||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 6);
|
||||
|
||||
// if spawned in is enabled, add it
|
||||
if (toolStats.configTools.checkConfig(newSpawnedItem.getType(), "spawned-in")) {
|
||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 6);
|
||||
|
||||
String formattedDate = toolStats.numberFormat.formatDate(finalDate);
|
||||
List<Component> newLore = toolStats.itemLore.addNewOwner(meta, owner.getName(), formattedDate);
|
||||
meta.lore(newLore);
|
||||
}
|
||||
|
||||
newSpawnedItem.setItemMeta(meta);
|
||||
return newSpawnedItem;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package lol.hyper.toolstats.events;
|
||||
|
||||
import lol.hyper.toolstats.ToolStats;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -119,17 +120,32 @@ public class EntityDamage implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isMain = shootingPlayerInventory.getItemInMainHand().getType() == Material.BOW || shootingPlayerInventory.getItemInMainHand().getType() == Material.CROSSBOW;
|
||||
boolean isOffHand = shootingPlayerInventory.getItemInOffHand().getType() == Material.BOW || shootingPlayerInventory.getItemInOffHand().getType() == Material.CROSSBOW;
|
||||
|
||||
// player is shooting another player
|
||||
if (mobBeingAttacked instanceof Player) {
|
||||
ItemMeta newItem = toolStats.itemLore.updatePlayerKills(heldBow, 1);
|
||||
if (newItem != null) {
|
||||
shootingPlayerInventory.getItemInMainHand().setItemMeta(newItem);
|
||||
ItemMeta newBow = toolStats.itemLore.updatePlayerKills(heldBow, 1);
|
||||
if (newBow != null) {
|
||||
if (isMain && isOffHand) {
|
||||
shootingPlayerInventory.getItemInMainHand().setItemMeta(newBow);
|
||||
} else if (isMain) {
|
||||
shootingPlayerInventory.getItemInMainHand().setItemMeta(newBow);
|
||||
} else if (isOffHand) {
|
||||
shootingPlayerInventory.getItemInOffHand().setItemMeta(newBow);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// player is shooting a mob
|
||||
ItemMeta newItem = toolStats.itemLore.updateMobKills(heldBow, 1);
|
||||
if (newItem != null) {
|
||||
shootingPlayerInventory.getItemInMainHand().setItemMeta(newItem);
|
||||
ItemMeta newBow = toolStats.itemLore.updateMobKills(heldBow, 1);
|
||||
if (newBow != null) {
|
||||
if (isMain && isOffHand) {
|
||||
shootingPlayerInventory.getItemInMainHand().setItemMeta(newBow);
|
||||
} else if (isMain) {
|
||||
shootingPlayerInventory.getItemInMainHand().setItemMeta(newBow);
|
||||
} else if (isOffHand) {
|
||||
shootingPlayerInventory.getItemInOffHand().setItemMeta(newBow);
|
||||
}
|
||||
}
|
||||
trackedMobs.add(mobBeingAttacked.getUniqueId());
|
||||
}
|
||||
|
||||
@@ -84,18 +84,19 @@ public class EntityDeath implements Listener {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!toolStats.config.getBoolean("enabled.dropped-by")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 1);
|
||||
|
||||
if (toolStats.config.getBoolean("enabled.dropped-by")) {
|
||||
String mobName = toolStats.config.getString("messages.mob." + entity.getType());
|
||||
if (mobName == null) {
|
||||
mobName = entity.getName();
|
||||
}
|
||||
Component newLine = toolStats.configTools.formatLore("dropped-by", "{name}", mobName);
|
||||
List<Component> newLore = toolStats.itemLore.addItemLore(meta, newLine);
|
||||
meta.lore(newLore);
|
||||
String mobName = toolStats.config.getString("messages.mob." + entity.getType());
|
||||
if (mobName == null) {
|
||||
mobName = entity.getName();
|
||||
}
|
||||
Component newLine = toolStats.configTools.formatLore("dropped-by", "{name}", mobName);
|
||||
List<Component> newLore = toolStats.itemLore.addItemLore(meta, newLine);
|
||||
meta.lore(newLore);
|
||||
newItem.setItemMeta(meta);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class GenerateLoot implements Listener {
|
||||
* @param owner The player that found the item.
|
||||
* @return The item with the lore.
|
||||
*/
|
||||
private ItemStack addLore(ItemStack itemStack, Player owner) {
|
||||
private ItemStack addLootedOrigin(ItemStack itemStack, Player owner) {
|
||||
ItemStack newItem = itemStack.clone();
|
||||
ItemMeta meta = itemStack.getItemMeta();
|
||||
if (meta == null) {
|
||||
@@ -102,6 +102,10 @@ public class GenerateLoot implements Listener {
|
||||
Date finalDate = new Date(timeCreated);
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
|
||||
if (!toolStats.configTools.checkConfig(newItem.getType(), "looted-tag")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (container.has(toolStats.timeCreated, PersistentDataType.LONG) || container.has(toolStats.itemOwner, PersistentDataType.LONG)) {
|
||||
return null;
|
||||
}
|
||||
@@ -115,12 +119,9 @@ public class GenerateLoot implements Listener {
|
||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 2);
|
||||
|
||||
if (toolStats.configTools.checkConfig(newItem.getType(), "looted-tag")) {
|
||||
String formattedDate = toolStats.numberFormat.formatDate(finalDate);
|
||||
List<Component> newLore = toolStats.itemLore.addNewOwner(meta, owner.getName(), formattedDate);
|
||||
meta.lore(newLore);
|
||||
}
|
||||
String formattedDate = toolStats.numberFormat.formatDate(finalDate);
|
||||
List<Component> newLore = toolStats.itemLore.addNewOwner(meta, owner.getName(), formattedDate);
|
||||
meta.lore(newLore);
|
||||
newItem.setItemMeta(meta);
|
||||
return newItem;
|
||||
}
|
||||
@@ -139,7 +140,7 @@ public class GenerateLoot implements Listener {
|
||||
continue;
|
||||
}
|
||||
if (toolStats.itemChecker.isValidItem(itemStack.getType())) {
|
||||
ItemStack newItem = addLore(itemStack, player);
|
||||
ItemStack newItem = addLootedOrigin(itemStack, player);
|
||||
if (newItem != null) {
|
||||
loot.set(i, newItem);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ package lol.hyper.toolstats.events;
|
||||
|
||||
import lol.hyper.toolstats.ToolStats;
|
||||
import lol.hyper.toolstats.tools.UUIDDataType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
@@ -47,7 +46,7 @@ public class InventoryOpen implements Listener {
|
||||
}
|
||||
|
||||
Inventory inventory = event.getInventory();
|
||||
Location location = event.getInventory().getLocation();
|
||||
Player player = (Player) event.getPlayer();
|
||||
for (ItemStack itemStack : inventory) {
|
||||
if (itemStack == null) {
|
||||
continue;
|
||||
@@ -75,31 +74,35 @@ public class InventoryOpen implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
// generate a hash if the item doesn't have one (if it's enabled in the config)
|
||||
// generate a hash if the item doesn't have one (and enabled)
|
||||
// if hashes are disabled and the item has one, remove it.
|
||||
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
||||
if (!container.has(toolStats.hash, PersistentDataType.STRING)) {
|
||||
// make sure the item has an owner
|
||||
if (!container.has(toolStats.itemOwner, new UUIDDataType())) {
|
||||
continue;
|
||||
UUID owner = null;
|
||||
// get the current owner if there is one.
|
||||
if (container.has(toolStats.itemOwner, new UUIDDataType())) {
|
||||
owner = container.get(toolStats.itemOwner, new UUIDDataType());
|
||||
}
|
||||
UUID owner = container.get(toolStats.itemOwner, new UUIDDataType());
|
||||
// if there is no owner, use the player holding it
|
||||
if (owner == null) {
|
||||
continue;
|
||||
owner = player.getUniqueId();
|
||||
}
|
||||
Long timestamp = container.get(toolStats.timeCreated, PersistentDataType.LONG);
|
||||
if (timestamp == null) {
|
||||
continue;
|
||||
// if there is no time created, use now
|
||||
timestamp = System.currentTimeMillis();
|
||||
}
|
||||
String hash = toolStats.hashMaker.makeHash(itemStack.getType(), owner, timestamp);
|
||||
container.set(toolStats.hash, PersistentDataType.STRING, hash);
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
} else {
|
||||
// if hashes are disabled but the item has one, remove it.
|
||||
if (container.has(toolStats.hash, PersistentDataType.STRING)) {
|
||||
container.remove(toolStats.hash);
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
}
|
||||
ItemMeta clone = itemMeta.clone();
|
||||
if (location != null) {
|
||||
Bukkit.getRegionScheduler().runDelayed(toolStats, location, scheduledTask -> itemStack.setItemMeta(clone), 1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,10 @@ import lol.hyper.toolstats.tools.UUIDDataType;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -64,7 +67,7 @@ public class PickupItem implements Listener {
|
||||
if (itemStack.getType() == Material.ELYTRA) {
|
||||
// the elytra has the new key, set the lore to it
|
||||
if (container.has(toolStats.newElytra, PersistentDataType.INTEGER)) {
|
||||
ItemStack newElytra = addLore(itemStack, (Player) event.getEntity());
|
||||
ItemStack newElytra = addElytraOrigin(itemStack, (Player) event.getEntity());
|
||||
if (newElytra != null) {
|
||||
item.setItemStack(newElytra);
|
||||
}
|
||||
@@ -80,7 +83,7 @@ public class PickupItem implements Listener {
|
||||
* @param itemStack The elytra to add lore to.
|
||||
* @param owner The player who found it.
|
||||
*/
|
||||
private ItemStack addLore(ItemStack itemStack, Player owner) {
|
||||
private ItemStack addElytraOrigin(ItemStack itemStack, Player owner) {
|
||||
ItemStack finalItem = itemStack.clone();
|
||||
ItemMeta meta = finalItem.getItemMeta();
|
||||
if (meta == null) {
|
||||
@@ -90,6 +93,10 @@ public class PickupItem implements Listener {
|
||||
Date finalDate = new Date(timeCreated);
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
|
||||
if (!toolStats.config.getBoolean("enabled.elytra-tag")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// only make the hash if it's enabled
|
||||
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
||||
String hash = toolStats.hashMaker.makeHash(finalItem.getType(), owner.getUniqueId(), timeCreated);
|
||||
@@ -100,12 +107,9 @@ public class PickupItem implements Listener {
|
||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 4);
|
||||
container.remove(toolStats.newElytra);
|
||||
|
||||
if (toolStats.config.getBoolean("enabled.elytra-tag")) {
|
||||
String formattedDate = toolStats.numberFormat.formatDate(finalDate);
|
||||
List<Component> newLore = toolStats.itemLore.addNewOwner(meta, owner.getName(), formattedDate);
|
||||
meta.lore(newLore);
|
||||
}
|
||||
String formattedDate = toolStats.numberFormat.formatDate(finalDate);
|
||||
List<Component> newLore = toolStats.itemLore.addNewOwner(meta, owner.getName(), formattedDate);
|
||||
meta.lore(newLore);
|
||||
finalItem.setItemMeta(meta);
|
||||
return finalItem;
|
||||
}
|
||||
|
||||
@@ -72,10 +72,11 @@ public class PlayerFish implements Listener {
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
boolean isMain = inventory.getItemInMainHand().getType() == Material.FISHING_ROD;
|
||||
boolean isOffHand = inventory.getItemInOffHand().getType() == Material.FISHING_ROD;
|
||||
if (isMain) {
|
||||
if (isMain && isOffHand) {
|
||||
inventory.getItemInMainHand().setItemMeta(newFishingRod);
|
||||
}
|
||||
if (isOffHand) {
|
||||
} else if (isMain) {
|
||||
inventory.getItemInMainHand().setItemMeta(newFishingRod);
|
||||
} else if (isOffHand) {
|
||||
inventory.getItemInOffHand().setItemMeta(newFishingRod);
|
||||
}
|
||||
}
|
||||
@@ -111,22 +112,26 @@ public class PlayerFish implements Listener {
|
||||
Date finalDate = new Date(timeCreated);
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
|
||||
if (!toolStats.configTools.checkConfig(newItem.getType(), "fished-tag")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (container.has(toolStats.timeCreated, PersistentDataType.LONG) || container.has(toolStats.itemOwner, PersistentDataType.LONG)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String hash = toolStats.hashMaker.makeHash(newItem.getType(), owner.getUniqueId(), timeCreated);
|
||||
// only make the hash if it's enabled
|
||||
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
||||
String hash = toolStats.hashMaker.makeHash(newItem.getType(), owner.getUniqueId(), timeCreated);
|
||||
container.set(toolStats.hash, PersistentDataType.STRING, hash);
|
||||
}
|
||||
|
||||
container.set(toolStats.hash, PersistentDataType.STRING, hash);
|
||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 5);
|
||||
|
||||
if (toolStats.configTools.checkConfig(newItem.getType(), "fished-tag")) {
|
||||
String formattedDate = toolStats.numberFormat.formatDate(finalDate);
|
||||
List<Component> newLore = toolStats.itemLore.addNewOwner(meta, owner.getName(), formattedDate);
|
||||
meta.lore(newLore);
|
||||
}
|
||||
String formattedDate = toolStats.numberFormat.formatDate(finalDate);
|
||||
List<Component> newLore = toolStats.itemLore.addNewOwner(meta, owner.getName(), formattedDate);
|
||||
meta.lore(newLore);
|
||||
newItem.setItemMeta(meta);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
@@ -72,24 +72,33 @@ public class PlayerJoin implements Listener {
|
||||
}
|
||||
|
||||
// generate a hash if the item doesn't have one
|
||||
if (!container.has(toolStats.hash, PersistentDataType.STRING)) {
|
||||
// make sure the item has an owner
|
||||
if (!container.has(toolStats.itemOwner, new UUIDDataType())) {
|
||||
continue;
|
||||
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
||||
if (!container.has(toolStats.hash, PersistentDataType.STRING)) {
|
||||
UUID owner = null;
|
||||
// get the current owner if there is one.
|
||||
if (container.has(toolStats.itemOwner, new UUIDDataType())) {
|
||||
owner = container.get(toolStats.itemOwner, new UUIDDataType());
|
||||
}
|
||||
// if there is no owner, use the player holding it
|
||||
if (owner == null) {
|
||||
owner = player.getUniqueId();
|
||||
}
|
||||
Long timestamp = container.get(toolStats.timeCreated, PersistentDataType.LONG);
|
||||
if (timestamp == null) {
|
||||
// if there is no time created, use now
|
||||
timestamp = System.currentTimeMillis();
|
||||
}
|
||||
String hash = toolStats.hashMaker.makeHash(itemStack.getType(), owner, timestamp);
|
||||
container.set(toolStats.hash, PersistentDataType.STRING, hash);
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
UUID owner = container.get(toolStats.itemOwner, new UUIDDataType());
|
||||
if (owner == null) {
|
||||
continue;
|
||||
} else {
|
||||
// if hashes are disabled but the item has one, remove it.
|
||||
if (container.has(toolStats.hash, PersistentDataType.STRING)) {
|
||||
container.remove(toolStats.hash);
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
Long timestamp = container.get(toolStats.timeCreated, PersistentDataType.LONG);
|
||||
if (timestamp == null) {
|
||||
continue;
|
||||
}
|
||||
String hash = toolStats.hashMaker.makeHash(itemStack.getType(), owner, timestamp);
|
||||
container.set(toolStats.hash, PersistentDataType.STRING, hash);
|
||||
}
|
||||
ItemMeta clone = itemMeta.clone();
|
||||
player.getScheduler().runDelayed(toolStats, scheduledTask -> itemStack.setItemMeta(clone), null, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,16 +65,17 @@ public class SheepShear implements Listener {
|
||||
}
|
||||
|
||||
// update the stats
|
||||
ItemMeta newItem = toolStats.itemLore.updateSheepSheared(heldShears, 1);
|
||||
if (newItem != null) {
|
||||
ItemMeta newShears = toolStats.itemLore.updateSheepSheared(heldShears, 1);
|
||||
if (newShears != null) {
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
boolean isMain = inventory.getItemInMainHand().getType() == Material.SHEARS;
|
||||
boolean isOffHand = inventory.getItemInOffHand().getType() == Material.SHEARS;
|
||||
if (isMain) {
|
||||
inventory.getItemInMainHand().setItemMeta(newItem);
|
||||
}
|
||||
if (isOffHand) {
|
||||
inventory.getItemInOffHand().setItemMeta(newItem);
|
||||
if (isMain && isOffHand) {
|
||||
inventory.getItemInMainHand().setItemMeta(newShears);
|
||||
} else if (isMain) {
|
||||
inventory.getItemInMainHand().setItemMeta(newShears);
|
||||
} else if (isOffHand) {
|
||||
inventory.getItemInOffHand().setItemMeta(newShears);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,16 +56,17 @@ public class ShootBow implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemMeta newItem = toolStats.itemLore.updateArrowsShot(heldBow, 1);
|
||||
if (newItem != null) {
|
||||
ItemMeta newBow = toolStats.itemLore.updateArrowsShot(heldBow, 1);
|
||||
if (newBow != null) {
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
boolean isMain = inventory.getItemInMainHand().getType() == Material.BOW || inventory.getItemInMainHand().getType() == Material.CROSSBOW;
|
||||
boolean isOffHand = inventory.getItemInOffHand().getType() == Material.BOW || inventory.getItemInOffHand().getType() == Material.CROSSBOW;
|
||||
if (isMain) {
|
||||
inventory.getItemInMainHand().setItemMeta(newItem);
|
||||
}
|
||||
if (isOffHand) {
|
||||
inventory.getItemInOffHand().setItemMeta(newItem);
|
||||
if (isMain && isOffHand) {
|
||||
inventory.getItemInMainHand().setItemMeta(newBow);
|
||||
} else if (isMain) {
|
||||
inventory.getItemInMainHand().setItemMeta(newBow);
|
||||
} else if (isOffHand) {
|
||||
inventory.getItemInOffHand().setItemMeta(newBow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class VillagerTrade implements Listener {
|
||||
// if the slot was empty before we traded, this means we just traded it
|
||||
if (oldSlotItem == null) {
|
||||
// add the lore
|
||||
ItemStack newItem = addLore(newSlotItem, player);
|
||||
ItemStack newItem = addTradeOrigin(newSlotItem, player);
|
||||
if (newItem != null) {
|
||||
player.getInventory().setItem(i, newItem);
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public class VillagerTrade implements Listener {
|
||||
}, null, 1);
|
||||
return;
|
||||
}
|
||||
ItemStack newItem = addLore(tradedItem, player);
|
||||
ItemStack newItem = addTradeOrigin(tradedItem, player);
|
||||
if (newItem != null) {
|
||||
// set the new item
|
||||
inventory.setItem(event.getSlot(), newItem);
|
||||
@@ -118,7 +118,7 @@ public class VillagerTrade implements Listener {
|
||||
* @param owner The player who traded.
|
||||
* @return The item with lore.
|
||||
*/
|
||||
private ItemStack addLore(ItemStack oldItem, Player owner) {
|
||||
private ItemStack addTradeOrigin(ItemStack oldItem, Player owner) {
|
||||
ItemStack newItem = oldItem.clone();
|
||||
ItemMeta meta = newItem.getItemMeta();
|
||||
if (meta == null) {
|
||||
@@ -133,6 +133,10 @@ public class VillagerTrade implements Listener {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!toolStats.configTools.checkConfig(newItem.getType(), "traded-tag")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// only make the hash if it's enabled
|
||||
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
||||
String hash = toolStats.hashMaker.makeHash(newItem.getType(), owner.getUniqueId(), timeCreated);
|
||||
@@ -142,12 +146,9 @@ public class VillagerTrade implements Listener {
|
||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 3);
|
||||
|
||||
if (toolStats.configTools.checkConfig(newItem.getType(), "traded-tag")) {
|
||||
String formattedDate = toolStats.numberFormat.formatDate(finalDate);
|
||||
List<Component> newLore = toolStats.itemLore.addNewOwner(meta, owner.getName(), formattedDate);
|
||||
meta.lore(newLore);
|
||||
}
|
||||
String formattedDate = toolStats.numberFormat.formatDate(finalDate);
|
||||
List<Component> newLore = toolStats.itemLore.addNewOwner(meta, owner.getName(), formattedDate);
|
||||
meta.lore(newLore);
|
||||
newItem.setItemMeta(meta);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
@@ -220,6 +220,9 @@ public class ItemChecker {
|
||||
// if the player is holding a bow in their main hand, use that one
|
||||
// if the bow is in their offhand instead, use that one after checking main hand
|
||||
// Minecraft prioritizes main hand if the player holds in both hands
|
||||
if (isMain && isOffHand) {
|
||||
return main;
|
||||
}
|
||||
if (isMain) {
|
||||
return main;
|
||||
}
|
||||
@@ -246,6 +249,9 @@ public class ItemChecker {
|
||||
// if the player is holding shears in their main hand, use that one
|
||||
// if the shears are in their offhand instead, use that one after checking main hand
|
||||
// Minecraft prioritizes main hand if the player holds in both hands
|
||||
if (isMain && isOffHand) {
|
||||
return main;
|
||||
}
|
||||
if (isMain) {
|
||||
return main;
|
||||
}
|
||||
@@ -272,6 +278,9 @@ public class ItemChecker {
|
||||
// if the player is holding a fishing rod in their main hand, use that one
|
||||
// if the fishing rod is in their offhand instead, use that one after checking main hand
|
||||
// Minecraft prioritizes main hand if the player holds in both hands
|
||||
if (isMain && isOffHand) {
|
||||
return main;
|
||||
}
|
||||
if (isMain) {
|
||||
return main;
|
||||
}
|
||||
|
||||
@@ -88,6 +88,19 @@ public class ItemLore {
|
||||
return itemLore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a given lore from an item.
|
||||
*
|
||||
* @param inputLore The item's lore.
|
||||
* @param toRemove The line to remove.
|
||||
* @return The lore with the line removed.
|
||||
*/
|
||||
public List<Component> removeLore(List<Component> inputLore, Component toRemove) {
|
||||
List<Component> newLore = new ArrayList<>(inputLore);
|
||||
newLore.removeIf(line -> PlainTextComponentSerializer.plainText().serialize(line).equals(PlainTextComponentSerializer.plainText().serialize(toRemove)));
|
||||
return newLore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds new ownership to an item.
|
||||
*
|
||||
@@ -229,6 +242,26 @@ public class ItemLore {
|
||||
// if they don't exist, then start from 0
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
|
||||
// if it's disabled, don't update the stats
|
||||
// check to see if the item has the stats, remove them if it does
|
||||
if (!toolStats.config.getBoolean("enabled.crops-harvested")) {
|
||||
if (container.has(toolStats.cropsHarvested)) {
|
||||
Integer cropsMined = container.get(toolStats.cropsHarvested, PersistentDataType.INTEGER);
|
||||
if (cropsMined == null) {
|
||||
return null;
|
||||
}
|
||||
container.remove(toolStats.cropsHarvested);
|
||||
if (meta.hasLore()) {
|
||||
String oldCropsMinedFormatted = toolStats.numberFormat.formatInt(cropsMined);
|
||||
Component lineToRemove = toolStats.configTools.formatLore("crops-harvested", "{crops}", oldCropsMinedFormatted);
|
||||
List<Component> newLore = removeLore(meta.lore(), lineToRemove);
|
||||
meta.lore(newLore);
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// check for tokens
|
||||
boolean validToken = toolStats.itemChecker.checkTokens(container, "crops-mined");
|
||||
// check for tokens
|
||||
@@ -265,19 +298,15 @@ public class ItemLore {
|
||||
}
|
||||
|
||||
container.set(toolStats.cropsHarvested, PersistentDataType.INTEGER, cropsMined + add);
|
||||
|
||||
// do we add the lore based on the config?
|
||||
if (toolStats.configTools.checkConfig(clone.getType(), "blocks-mined")) {
|
||||
String oldCropsMinedFormatted = toolStats.numberFormat.formatInt(cropsMined);
|
||||
String newCropsMinedFormatted = toolStats.numberFormat.formatInt(cropsMined + add);
|
||||
Component oldLine = toolStats.configTools.formatLore("crops-harvested", "{crops}", oldCropsMinedFormatted);
|
||||
Component newLine = toolStats.configTools.formatLore("crops-harvested", "{crops}", newCropsMinedFormatted);
|
||||
if (oldLine == null || newLine == null) {
|
||||
return null;
|
||||
}
|
||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
||||
meta.lore(newLore);
|
||||
String oldCropsMinedFormatted = toolStats.numberFormat.formatInt(cropsMined);
|
||||
String newCropsMinedFormatted = toolStats.numberFormat.formatInt(cropsMined + add);
|
||||
Component oldLine = toolStats.configTools.formatLore("crops-harvested", "{crops}", oldCropsMinedFormatted);
|
||||
Component newLine = toolStats.configTools.formatLore("crops-harvested", "{crops}", newCropsMinedFormatted);
|
||||
if (oldLine == null || newLine == null) {
|
||||
return null;
|
||||
}
|
||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
||||
meta.lore(newLore);
|
||||
return meta;
|
||||
}
|
||||
|
||||
@@ -295,6 +324,27 @@ public class ItemLore {
|
||||
}
|
||||
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
|
||||
// if it's disabled, don't update the stats
|
||||
// check to see if the item has the stats, remove them if it does
|
||||
if (!toolStats.configTools.checkConfig(clone.getType(), "blocks-mined")) {
|
||||
if (container.has(toolStats.blocksMined)) {
|
||||
Integer blocksMined = container.get(toolStats.blocksMined, PersistentDataType.INTEGER);
|
||||
if (blocksMined == null) {
|
||||
return null;
|
||||
}
|
||||
container.remove(toolStats.blocksMined);
|
||||
if (meta.hasLore()) {
|
||||
String oldBlocksMinedFormatted = toolStats.numberFormat.formatInt(blocksMined);
|
||||
Component lineToRemove = toolStats.configTools.formatLore("blocks-mined", "{blocks}", oldBlocksMinedFormatted);
|
||||
List<Component> newLore = removeLore(meta.lore(), lineToRemove);
|
||||
meta.lore(newLore);
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean validToken = toolStats.itemChecker.checkTokens(container, "blocks-mined");
|
||||
// check for tokens
|
||||
if (toolStats.config.getBoolean("tokens.enabled")) {
|
||||
@@ -332,19 +382,15 @@ public class ItemLore {
|
||||
}
|
||||
|
||||
container.set(toolStats.blocksMined, PersistentDataType.INTEGER, blocksMined + add);
|
||||
|
||||
// do we add the lore based on the config?
|
||||
if (toolStats.configTools.checkConfig(clone.getType(), "blocks-mined")) {
|
||||
String oldBlocksMinedFormatted = toolStats.numberFormat.formatInt(blocksMined);
|
||||
String newBlocksMinedFormatted = toolStats.numberFormat.formatInt(blocksMined + add);
|
||||
Component oldLine = toolStats.configTools.formatLore("blocks-mined", "{blocks}", oldBlocksMinedFormatted);
|
||||
Component newLine = toolStats.configTools.formatLore("blocks-mined", "{blocks}", newBlocksMinedFormatted);
|
||||
if (oldLine == null || newLine == null) {
|
||||
return null;
|
||||
}
|
||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
||||
meta.lore(newLore);
|
||||
String oldBlocksMinedFormatted = toolStats.numberFormat.formatInt(blocksMined);
|
||||
String newBlocksMinedFormatted = toolStats.numberFormat.formatInt(blocksMined + add);
|
||||
Component oldLine = toolStats.configTools.formatLore("blocks-mined", "{blocks}", oldBlocksMinedFormatted);
|
||||
Component newLine = toolStats.configTools.formatLore("blocks-mined", "{blocks}", newBlocksMinedFormatted);
|
||||
if (oldLine == null || newLine == null) {
|
||||
return null;
|
||||
}
|
||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
||||
meta.lore(newLore);
|
||||
return meta;
|
||||
}
|
||||
|
||||
@@ -362,6 +408,27 @@ public class ItemLore {
|
||||
}
|
||||
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
|
||||
// if it's disabled, don't update the stats
|
||||
// check to see if the item has the stats, remove them if it does
|
||||
if (!toolStats.configTools.checkConfig(clone.getType(), "player-kills")) {
|
||||
if (container.has(toolStats.playerKills)) {
|
||||
Integer playerKills = container.get(toolStats.playerKills, PersistentDataType.INTEGER);
|
||||
if (playerKills == null) {
|
||||
return null;
|
||||
}
|
||||
container.remove(toolStats.playerKills);
|
||||
if (meta.hasLore()) {
|
||||
String oldPlayerKillsFormatted = toolStats.numberFormat.formatInt(playerKills);
|
||||
Component lineToRemove = toolStats.configTools.formatLore("player-kills", "{kills}", oldPlayerKillsFormatted);
|
||||
List<Component> newLore = removeLore(meta.lore(), lineToRemove);
|
||||
meta.lore(newLore);
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// check for tokens
|
||||
boolean validToken = toolStats.itemChecker.checkTokens(container, "player-kills");
|
||||
// check for tokens
|
||||
@@ -398,19 +465,15 @@ public class ItemLore {
|
||||
}
|
||||
|
||||
container.set(toolStats.playerKills, PersistentDataType.INTEGER, playerKills + add);
|
||||
|
||||
// do we add the lore based on the config?
|
||||
if (toolStats.configTools.checkConfig(clone.getType(), "player-kills")) {
|
||||
String oldPlayerKillsFormatted = toolStats.numberFormat.formatInt(playerKills);
|
||||
String newPlayerKillsFormatted = toolStats.numberFormat.formatInt(playerKills + add);
|
||||
Component oldLine = toolStats.configTools.formatLore("kills.player", "{kills}", oldPlayerKillsFormatted);
|
||||
Component newLine = toolStats.configTools.formatLore("kills.player", "{kills}", newPlayerKillsFormatted);
|
||||
if (oldLine == null || newLine == null) {
|
||||
return null;
|
||||
}
|
||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
||||
meta.lore(newLore);
|
||||
String oldPlayerKillsFormatted = toolStats.numberFormat.formatInt(playerKills);
|
||||
String newPlayerKillsFormatted = toolStats.numberFormat.formatInt(playerKills + add);
|
||||
Component oldLine = toolStats.configTools.formatLore("kills.player", "{kills}", oldPlayerKillsFormatted);
|
||||
Component newLine = toolStats.configTools.formatLore("kills.player", "{kills}", newPlayerKillsFormatted);
|
||||
if (oldLine == null || newLine == null) {
|
||||
return null;
|
||||
}
|
||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
||||
meta.lore(newLore);
|
||||
return meta;
|
||||
}
|
||||
|
||||
@@ -428,6 +491,27 @@ public class ItemLore {
|
||||
}
|
||||
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
|
||||
// if it's disabled, don't update the stats
|
||||
// check to see if the item has the stats, remove them if it does
|
||||
if (!toolStats.configTools.checkConfig(clone.getType(), "mob-kills")) {
|
||||
if (container.has(toolStats.mobKills)) {
|
||||
Integer mobKills = container.get(toolStats.mobKills, PersistentDataType.INTEGER);
|
||||
if (mobKills == null) {
|
||||
return null;
|
||||
}
|
||||
container.remove(toolStats.mobKills);
|
||||
if (meta.hasLore()) {
|
||||
String oldMobKillsFormatted = toolStats.numberFormat.formatInt(mobKills);
|
||||
Component lineToRemove = toolStats.configTools.formatLore("mob-kills", "{kills}", oldMobKillsFormatted);
|
||||
List<Component> newLore = removeLore(meta.lore(), lineToRemove);
|
||||
meta.lore(newLore);
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// check for tokens
|
||||
boolean validToken = toolStats.itemChecker.checkTokens(container, "mob-kills");
|
||||
// check for tokens
|
||||
@@ -464,19 +548,15 @@ public class ItemLore {
|
||||
}
|
||||
|
||||
container.set(toolStats.mobKills, PersistentDataType.INTEGER, mobKills + add);
|
||||
|
||||
// do we add the lore based on the config?
|
||||
if (toolStats.configTools.checkConfig(clone.getType(), "mob-kills")) {
|
||||
String oldMobKillsFormatted = toolStats.numberFormat.formatInt(mobKills);
|
||||
String newMobKillsFormatted = toolStats.numberFormat.formatInt(mobKills + add);
|
||||
Component oldLine = toolStats.configTools.formatLore("kills.mob", "{kills}", oldMobKillsFormatted);
|
||||
Component newLine = toolStats.configTools.formatLore("kills.mob", "{kills}", newMobKillsFormatted);
|
||||
if (oldLine == null || newLine == null) {
|
||||
return null;
|
||||
}
|
||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
||||
meta.lore(newLore);
|
||||
String oldMobKillsFormatted = toolStats.numberFormat.formatInt(mobKills);
|
||||
String newMobKillsFormatted = toolStats.numberFormat.formatInt(mobKills + add);
|
||||
Component oldLine = toolStats.configTools.formatLore("kills.mob", "{kills}", oldMobKillsFormatted);
|
||||
Component newLine = toolStats.configTools.formatLore("kills.mob", "{kills}", newMobKillsFormatted);
|
||||
if (oldLine == null || newLine == null) {
|
||||
return null;
|
||||
}
|
||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
||||
meta.lore(newLore);
|
||||
return meta;
|
||||
}
|
||||
|
||||
@@ -502,6 +582,27 @@ public class ItemLore {
|
||||
}
|
||||
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
|
||||
// if it's disabled, don't update the stats
|
||||
// check to see if the item has the stats, remove them if it does
|
||||
if (!toolStats.config.getBoolean("enabled.armor-damage")) {
|
||||
if (container.has(toolStats.armorDamage)) {
|
||||
Double armorDamage = container.get(toolStats.armorDamage, PersistentDataType.DOUBLE);
|
||||
if (armorDamage == null) {
|
||||
return null;
|
||||
}
|
||||
container.remove(toolStats.armorDamage);
|
||||
if (meta.hasLore()) {
|
||||
String oldDamageTakenFormatted = toolStats.numberFormat.formatDouble(armorDamage);
|
||||
Component lineToRemove = toolStats.configTools.formatLore("damage-taken", "{damage}", oldDamageTakenFormatted);
|
||||
List<Component> newLore = removeLore(meta.lore(), lineToRemove);
|
||||
meta.lore(newLore);
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// check for tokens
|
||||
boolean validToken = toolStats.itemChecker.checkTokens(container, "damage-taken");
|
||||
// check for tokens
|
||||
@@ -538,18 +639,15 @@ public class ItemLore {
|
||||
}
|
||||
|
||||
container.set(toolStats.armorDamage, PersistentDataType.DOUBLE, damageTaken + damage);
|
||||
|
||||
if (toolStats.config.getBoolean("enabled.armor-damage")) {
|
||||
String oldDamageFormatted = toolStats.numberFormat.formatDouble(damageTaken);
|
||||
String newDamageFormatted = toolStats.numberFormat.formatDouble(damageTaken + damage);
|
||||
Component oldLine = toolStats.configTools.formatLore("damage-taken", "{damage}", oldDamageFormatted);
|
||||
Component newLine = toolStats.configTools.formatLore("damage-taken", "{damage}", newDamageFormatted);
|
||||
if (oldLine == null || newLine == null) {
|
||||
return null;
|
||||
}
|
||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
||||
meta.lore(newLore);
|
||||
String oldDamageFormatted = toolStats.numberFormat.formatDouble(damageTaken);
|
||||
String newDamageFormatted = toolStats.numberFormat.formatDouble(damageTaken + damage);
|
||||
Component oldLine = toolStats.configTools.formatLore("damage-taken", "{damage}", oldDamageFormatted);
|
||||
Component newLine = toolStats.configTools.formatLore("damage-taken", "{damage}", newDamageFormatted);
|
||||
if (oldLine == null || newLine == null) {
|
||||
return null;
|
||||
}
|
||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
||||
meta.lore(newLore);
|
||||
return meta;
|
||||
}
|
||||
|
||||
@@ -567,6 +665,27 @@ public class ItemLore {
|
||||
}
|
||||
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
|
||||
// if it's disabled, don't update the stats
|
||||
// check to see if the item has the stats, remove them if it does
|
||||
if (!toolStats.config.getBoolean("enabled.flight-time")) {
|
||||
if (container.has(toolStats.flightTime)) {
|
||||
Long flightTime = container.get(toolStats.flightTime, PersistentDataType.LONG);
|
||||
if (flightTime == null) {
|
||||
return null;
|
||||
}
|
||||
container.remove(toolStats.flightTime);
|
||||
if (meta.hasLore()) {
|
||||
String oldFlightTimeFormatted = toolStats.numberFormat.formatDouble(flightTime);
|
||||
Component lineToRemove = toolStats.configTools.formatLore("flight-time", "{time}", oldFlightTimeFormatted);
|
||||
List<Component> newLore = removeLore(meta.lore(), lineToRemove);
|
||||
meta.lore(newLore);
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// check for tokens
|
||||
boolean validToken = toolStats.itemChecker.checkTokens(container, "flight-time");
|
||||
// check for tokens
|
||||
@@ -605,19 +724,15 @@ public class ItemLore {
|
||||
}
|
||||
|
||||
container.set(toolStats.flightTime, PersistentDataType.LONG, flightTime + duration);
|
||||
|
||||
// do we add the lore based on the config?
|
||||
if (toolStats.config.getBoolean("enabled.flight-time")) {
|
||||
String oldFlightFormatted = toolStats.numberFormat.formatDouble((double) flightTime / 1000);
|
||||
String newFlightFormatted = toolStats.numberFormat.formatDouble((double) (flightTime + duration) / 1000);
|
||||
Component oldLine = toolStats.configTools.formatLore("flight-time", "{time}", oldFlightFormatted);
|
||||
Component newLine = toolStats.configTools.formatLore("flight-time", "{time}", newFlightFormatted);
|
||||
if (oldLine == null || newLine == null) {
|
||||
return null;
|
||||
}
|
||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
||||
meta.lore(newLore);
|
||||
String oldFlightFormatted = toolStats.numberFormat.formatDouble((double) flightTime / 1000);
|
||||
String newFlightFormatted = toolStats.numberFormat.formatDouble((double) (flightTime + duration) / 1000);
|
||||
Component oldLine = toolStats.configTools.formatLore("flight-time", "{time}", oldFlightFormatted);
|
||||
Component newLine = toolStats.configTools.formatLore("flight-time", "{time}", newFlightFormatted);
|
||||
if (oldLine == null || newLine == null) {
|
||||
return null;
|
||||
}
|
||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
||||
meta.lore(newLore);
|
||||
return meta;
|
||||
}
|
||||
|
||||
@@ -635,6 +750,27 @@ public class ItemLore {
|
||||
}
|
||||
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
|
||||
// if it's disabled, don't update the stats
|
||||
// check to see if the item has the stats, remove them if it does
|
||||
if (!toolStats.config.getBoolean("enabled.sheep-sheared")) {
|
||||
if (container.has(toolStats.sheepSheared)) {
|
||||
Integer sheepSheared = container.get(toolStats.sheepSheared, PersistentDataType.INTEGER);
|
||||
if (sheepSheared == null) {
|
||||
return null;
|
||||
}
|
||||
container.remove(toolStats.sheepSheared);
|
||||
if (meta.hasLore()) {
|
||||
String oldSheepShearedFormatted = toolStats.numberFormat.formatDouble(sheepSheared);
|
||||
Component lineToRemove = toolStats.configTools.formatLore("sheep-sheared", "{sheep}", oldSheepShearedFormatted);
|
||||
List<Component> newLore = removeLore(meta.lore(), lineToRemove);
|
||||
meta.lore(newLore);
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// check for tokens
|
||||
boolean validToken = toolStats.itemChecker.checkTokens(container, "sheep-sheared");
|
||||
// check for tokens
|
||||
@@ -671,18 +807,15 @@ public class ItemLore {
|
||||
}
|
||||
|
||||
container.set(toolStats.sheepSheared, PersistentDataType.INTEGER, sheepSheared + add);
|
||||
|
||||
if (toolStats.config.getBoolean("enabled.sheep-sheared")) {
|
||||
String oldSheepFormatted = toolStats.numberFormat.formatInt(sheepSheared);
|
||||
String newSheepFormatted = toolStats.numberFormat.formatInt(sheepSheared + add);
|
||||
Component oldLine = toolStats.configTools.formatLore("sheep-sheared", "{sheep}", oldSheepFormatted);
|
||||
Component newLine = toolStats.configTools.formatLore("sheep-sheared", "{sheep}", newSheepFormatted);
|
||||
if (oldLine == null || newLine == null) {
|
||||
return null;
|
||||
}
|
||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
||||
meta.lore(newLore);
|
||||
String oldSheepFormatted = toolStats.numberFormat.formatInt(sheepSheared);
|
||||
String newSheepFormatted = toolStats.numberFormat.formatInt(sheepSheared + add);
|
||||
Component oldLine = toolStats.configTools.formatLore("sheep-sheared", "{sheep}", oldSheepFormatted);
|
||||
Component newLine = toolStats.configTools.formatLore("sheep-sheared", "{sheep}", newSheepFormatted);
|
||||
if (oldLine == null || newLine == null) {
|
||||
return null;
|
||||
}
|
||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
||||
meta.lore(newLore);
|
||||
return meta;
|
||||
}
|
||||
|
||||
@@ -700,6 +833,27 @@ public class ItemLore {
|
||||
}
|
||||
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
|
||||
// if it's disabled, don't update the stats
|
||||
// check to see if the item has the stats, remove them if it does
|
||||
if (!toolStats.config.getBoolean("enabled.arrows-shot")) {
|
||||
if (container.has(toolStats.arrowsShot)) {
|
||||
Integer arrowsShot = container.get(toolStats.arrowsShot, PersistentDataType.INTEGER);
|
||||
if (arrowsShot == null) {
|
||||
return null;
|
||||
}
|
||||
container.remove(toolStats.arrowsShot);
|
||||
if (meta.hasLore()) {
|
||||
String oldArrowsShotFormatted = toolStats.numberFormat.formatDouble(arrowsShot);
|
||||
Component lineToRemove = toolStats.configTools.formatLore("arrows-shot", "{arrows}", oldArrowsShotFormatted);
|
||||
List<Component> newLore = removeLore(meta.lore(), lineToRemove);
|
||||
meta.lore(newLore);
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// check for tokens
|
||||
boolean validToken = toolStats.itemChecker.checkTokens(container, "arrows-shot");
|
||||
// check for tokens
|
||||
@@ -738,19 +892,15 @@ public class ItemLore {
|
||||
}
|
||||
|
||||
container.set(toolStats.arrowsShot, PersistentDataType.INTEGER, arrowsShot + add);
|
||||
|
||||
// do we add the lore based on the config?
|
||||
if (toolStats.config.getBoolean("enabled.arrows-shot")) {
|
||||
String oldArrowsFormatted = toolStats.numberFormat.formatInt(arrowsShot);
|
||||
String newArrowsFormatted = toolStats.numberFormat.formatInt(arrowsShot + add);
|
||||
Component oldLine = toolStats.configTools.formatLore("arrows-shot", "{arrows}", oldArrowsFormatted);
|
||||
Component newLine = toolStats.configTools.formatLore("arrows-shot", "{arrows}", newArrowsFormatted);
|
||||
if (oldLine == null || newLine == null) {
|
||||
return null;
|
||||
}
|
||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
||||
meta.lore(newLore);
|
||||
String oldArrowsFormatted = toolStats.numberFormat.formatInt(arrowsShot);
|
||||
String newArrowsFormatted = toolStats.numberFormat.formatInt(arrowsShot + add);
|
||||
Component oldLine = toolStats.configTools.formatLore("arrows-shot", "{arrows}", oldArrowsFormatted);
|
||||
Component newLine = toolStats.configTools.formatLore("arrows-shot", "{arrows}", newArrowsFormatted);
|
||||
if (oldLine == null || newLine == null) {
|
||||
return null;
|
||||
}
|
||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
||||
meta.lore(newLore);
|
||||
return meta;
|
||||
}
|
||||
|
||||
@@ -768,6 +918,27 @@ public class ItemLore {
|
||||
}
|
||||
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
|
||||
// if it's disabled, don't update the stats
|
||||
// check to see if the item has the stats, remove them if it does
|
||||
if (!toolStats.config.getBoolean("enabled.fish-caught")) {
|
||||
if (container.has(toolStats.fishCaught)) {
|
||||
Integer fishCaught = container.get(toolStats.fishCaught, PersistentDataType.INTEGER);
|
||||
if (fishCaught == null) {
|
||||
return null;
|
||||
}
|
||||
container.remove(toolStats.fishCaught);
|
||||
if (meta.hasLore()) {
|
||||
String oldFishCaught = toolStats.numberFormat.formatDouble(fishCaught);
|
||||
Component lineToRemove = toolStats.configTools.formatLore("fished.fish-caught", "{fish}", oldFishCaught);
|
||||
List<Component> newLore = removeLore(meta.lore(), lineToRemove);
|
||||
meta.lore(newLore);
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// check for tokens
|
||||
boolean validToken = toolStats.itemChecker.checkTokens(container, "fish-caught");
|
||||
// check for tokens
|
||||
@@ -804,18 +975,15 @@ public class ItemLore {
|
||||
}
|
||||
|
||||
container.set(toolStats.fishCaught, PersistentDataType.INTEGER, fishCaught + add);
|
||||
|
||||
if (toolStats.config.getBoolean("enabled.fish-caught")) {
|
||||
String oldFishFormatted = toolStats.numberFormat.formatInt(fishCaught);
|
||||
String newFishFormatted = toolStats.numberFormat.formatInt(fishCaught + add);
|
||||
Component oldLine = toolStats.configTools.formatLore("fished.fish-caught", "{fish}", oldFishFormatted);
|
||||
Component newLine = toolStats.configTools.formatLore("fished.fish-caught", "{fish}", newFishFormatted);
|
||||
if (oldLine == null || newLine == null) {
|
||||
return null;
|
||||
}
|
||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
||||
meta.lore(newLore);
|
||||
String oldFishFormatted = toolStats.numberFormat.formatInt(fishCaught);
|
||||
String newFishFormatted = toolStats.numberFormat.formatInt(fishCaught + add);
|
||||
Component oldLine = toolStats.configTools.formatLore("fished.fish-caught", "{fish}", oldFishFormatted);
|
||||
Component newLine = toolStats.configTools.formatLore("fished.fish-caught", "{fish}", newFishFormatted);
|
||||
if (oldLine == null || newLine == null) {
|
||||
return null;
|
||||
}
|
||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
||||
meta.lore(newLore);
|
||||
return meta;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ConfigTools {
|
||||
*
|
||||
* @param material The item type to check.
|
||||
* @param configName The config we are checking under.
|
||||
* @return If we want to allow lore or not.
|
||||
* @return If we want to add data or not.
|
||||
*/
|
||||
public boolean checkConfig(Material material, String configName) {
|
||||
String itemName = material.toString().toLowerCase();
|
||||
|
||||
@@ -18,10 +18,7 @@
|
||||
package lol.hyper.toolstats.tools.config;
|
||||
|
||||
import lol.hyper.toolstats.ToolStats;
|
||||
import lol.hyper.toolstats.tools.config.versions.Version6;
|
||||
import lol.hyper.toolstats.tools.config.versions.Version7;
|
||||
import lol.hyper.toolstats.tools.config.versions.Version8;
|
||||
import lol.hyper.toolstats.tools.config.versions.Version9;
|
||||
import lol.hyper.toolstats.tools.config.versions.*;
|
||||
|
||||
public class ConfigUpdater {
|
||||
|
||||
@@ -34,31 +31,30 @@ public class ConfigUpdater {
|
||||
public void updateConfig() {
|
||||
int version = toolStats.config.getInt("config-version");
|
||||
|
||||
switch(version) {
|
||||
case 5: {
|
||||
// Version 5 to 6
|
||||
Version6 version6 = new Version6(toolStats);
|
||||
version6.update();
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
// Version 6 to 7
|
||||
Version7 version7 = new Version7(toolStats);
|
||||
version7.update();
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
// Version 7 to 8
|
||||
Version8 version8 = new Version8(toolStats);
|
||||
version8.update();
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
// Version 8 to 9
|
||||
Version9 version9 = new Version9(toolStats);
|
||||
version9.update();
|
||||
break;
|
||||
}
|
||||
// Version 5 to 6
|
||||
if (version == 5) {
|
||||
Version6 version6 = new Version6(toolStats);
|
||||
version6.update();
|
||||
}
|
||||
// Version 6 to 7
|
||||
if (version == 6) {
|
||||
Version7 version7 = new Version7(toolStats);
|
||||
version7.update();
|
||||
}
|
||||
// Version 7 to 8
|
||||
if (version == 7) {
|
||||
Version8 version8 = new Version8(toolStats);
|
||||
version8.update();
|
||||
}
|
||||
// Version 8 to 9
|
||||
if (version == 8) {
|
||||
Version9 version9 = new Version9(toolStats);
|
||||
version9.update();
|
||||
}
|
||||
// Version 9 to 10
|
||||
if (version == 9) {
|
||||
Version10 version10 = new Version10(toolStats);
|
||||
version10.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* This file is part of ToolStats.
|
||||
*
|
||||
* ToolStats is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ToolStats is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ToolStats. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package lol.hyper.toolstats.tools.config.versions;
|
||||
|
||||
import lol.hyper.toolstats.ToolStats;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Version10 {
|
||||
|
||||
private final ToolStats toolStats;
|
||||
|
||||
/**
|
||||
* Used for updating from version 9 to 10.
|
||||
*
|
||||
* @param toolStats ToolStats instance.
|
||||
*/
|
||||
public Version10(ToolStats toolStats) {
|
||||
this.toolStats = toolStats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the config update.
|
||||
*/
|
||||
public void update() {
|
||||
// save the old config first
|
||||
try {
|
||||
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config-9.yml");
|
||||
} catch (IOException exception) {
|
||||
toolStats.logger.severe("Unable to save config-9.yml!");
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
|
||||
// we make this super verbose so that admins can see what's being added
|
||||
toolStats.logger.info("Updating config.yml to version 10.");
|
||||
toolStats.config.set("config-version", 10);
|
||||
|
||||
// Add missing values I forgot...
|
||||
toolStats.logger.info("Adding entry for enabled.created-by.fishing-rod");
|
||||
toolStats.config.set("enabled.created-by.fishing-rod", true);
|
||||
toolStats.logger.info("Adding entry for enabled.created-date.fishing-rod");
|
||||
toolStats.config.set("enabled.created-date.fishing-rod", true);
|
||||
toolStats.logger.info("Adding entry for enabled.fished-tag.fishing-rod");
|
||||
toolStats.config.set("enabled.fished-tag.fishing-rod", true);
|
||||
toolStats.logger.info("Adding entry for enabled.looted-tag.fishing-rod");
|
||||
toolStats.config.set("enabled.looted-tag.fishing-rod", true);
|
||||
toolStats.logger.info("Adding entry for enabled.traded-tag.fishing-rod");
|
||||
toolStats.config.set("enabled.traded-tag.fishing-rod", true);
|
||||
toolStats.logger.info("Adding entry for enabled.spawned-in.fishing-rod");
|
||||
toolStats.config.set("enabled.spawned-in.fishing-rod", true);
|
||||
|
||||
toolStats.logger.info("Adding entry for enabled.crops-harvested");
|
||||
toolStats.config.set("enabled.crops-harvested", true);
|
||||
|
||||
// save the config and reload it
|
||||
try {
|
||||
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config.yml");
|
||||
} catch (IOException exception) {
|
||||
toolStats.logger.severe("Unable to save config.yml!");
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
toolStats.loadConfig();
|
||||
toolStats.logger.info("Config has been updated to version 10. A copy of version 9 has been saved as config-9.yml");
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,7 @@ enabled:
|
||||
bow: true
|
||||
armor: true
|
||||
mace: true
|
||||
fishing-rod: true
|
||||
# Will show time the item is created
|
||||
created-date:
|
||||
pickaxe: true
|
||||
@@ -78,6 +79,7 @@ enabled:
|
||||
bow: true
|
||||
armor: true
|
||||
mace: true
|
||||
fishing-rod: true
|
||||
# Will show "Fished by <player>"
|
||||
fished-tag:
|
||||
pickaxe: true
|
||||
@@ -88,6 +90,7 @@ enabled:
|
||||
shears: true
|
||||
bow: true
|
||||
armor: true
|
||||
fishing-rod: true
|
||||
# Will show "Found by <player>"
|
||||
looted-tag:
|
||||
pickaxe: true
|
||||
@@ -98,6 +101,7 @@ enabled:
|
||||
shears: true
|
||||
bow: true
|
||||
armor: true
|
||||
fishing-rod: true
|
||||
# Will show "Trade by <player>"
|
||||
traded-tag:
|
||||
pickaxe: true
|
||||
@@ -108,6 +112,7 @@ enabled:
|
||||
shears: true
|
||||
bow: true
|
||||
armor: true
|
||||
fishing-rod: true
|
||||
player-kills:
|
||||
sword: true
|
||||
axe: true
|
||||
@@ -137,6 +142,7 @@ enabled:
|
||||
bow: true
|
||||
armor: true
|
||||
mace: true
|
||||
fishing-rod: true
|
||||
fish-caught: true
|
||||
sheep-sheared: true
|
||||
armor-damage: true
|
||||
@@ -144,6 +150,7 @@ enabled:
|
||||
elytra-tag: true
|
||||
arrows-shot: true
|
||||
flight-time: true
|
||||
crops-harvested: true
|
||||
|
||||
messages:
|
||||
created:
|
||||
@@ -194,6 +201,6 @@ number-formats:
|
||||
# When any tool is created, it will generate a hash for the item.
|
||||
# This hash is not on the item lore, only stored in the NBT data.
|
||||
# This has no use currently, but can be used for future features for dupe detection.
|
||||
generate-hash-for-items: true
|
||||
generate-hash-for-items: false
|
||||
|
||||
config-version: 9
|
||||
config-version: 10
|
||||
Reference in New Issue
Block a user