use the new GLIDER DataComponent

This commit is contained in:
hyperdefined
2025-07-23 12:19:40 -04:00
parent 86cbdd58ff
commit 525df4bcf6
3 changed files with 34 additions and 8 deletions

View File

@@ -169,7 +169,7 @@ public class AnvilEvent implements Listener {
}
return;
}
if (firstSlotMaterial == Material.ELYTRA) {
if (toolStats.itemChecker.canGlide(clone)) {
addToken(event, tokenType, "flight-time", clone);
return;
}

View File

@@ -53,15 +53,23 @@ public class PlayerMove implements Listener {
// player is not flying
if (playerStartFlight.containsKey(player)) {
PlayerInventory inventory = player.getInventory();
ItemStack chest = inventory.getChestplate();
// make sure the player is wearing an elytra
if (chest != null && chest.getType() == Material.ELYTRA) {
long duration = (System.currentTimeMillis() - playerStartFlight.get(player));
ItemMeta newItem = toolStats.itemLore.updateFlightTime(chest, duration);
if (newItem != null) {
inventory.getChestplate().setItemMeta(newItem);
// copy their current armor
ItemStack[] armor = inventory.getArmorContents().clone();
for (ItemStack armorPiece : armor) {
// skip missing slots
if (armorPiece == null) {
continue;
}
// if the armor piece can glide, track the flight time
if (toolStats.itemChecker.canGlide(armorPiece)) {
long duration = (System.currentTimeMillis() - playerStartFlight.get(player));
ItemMeta newMeta = toolStats.itemLore.updateFlightTime(armorPiece, duration);
if (newMeta != null) {
armorPiece.setItemMeta(newMeta);
}
}
}
inventory.setArmorContents(armor);
playerStartFlight.remove(player);
}
}