001package net.tnemc.item.paper; 002 003/* 004 * The New Item Library 005 * Copyright (C) 2022 - 2025 Daniel "creatorfromhell" Vidmar 006 * 007 * This program is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 3 of the License, or (at your option) any later version. 011 * 012 * This program is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * You should have received a copy of the GNU Lesser General Public License 018 * along with this program; if not, write to the Free Software Foundation, 019 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 020 */ 021 022import net.kyori.adventure.text.Component; 023import net.tnemc.item.AbstractItemStack; 024import net.tnemc.item.component.SerialComponent; 025import net.tnemc.item.component.helper.AttributeModifier; 026import net.tnemc.item.component.helper.BlockPredicate; 027import net.tnemc.item.component.helper.EquipSlot; 028import net.tnemc.item.component.helper.ExplosionData; 029import net.tnemc.item.component.helper.ItemDamage; 030import net.tnemc.item.component.helper.PatternData; 031import net.tnemc.item.component.helper.ToolRule; 032import net.tnemc.item.component.helper.effect.ComponentEffect; 033import net.tnemc.item.component.helper.effect.EffectInstance; 034import net.tnemc.item.component.impl.AttributeModifiersComponent; 035import net.tnemc.item.component.impl.BannerPatternsComponent; 036import net.tnemc.item.component.impl.BaseColorComponent; 037import net.tnemc.item.component.impl.BlocksAttacksComponent; 038import net.tnemc.item.component.impl.BreakSoundComponent; 039import net.tnemc.item.component.impl.BucketEntityDataComponent; 040import net.tnemc.item.component.impl.BundleComponent; 041import net.tnemc.item.component.impl.CanBreakComponent; 042import net.tnemc.item.component.impl.CanPlaceOnComponent; 043import net.tnemc.item.component.impl.ConsumableComponent; 044import net.tnemc.item.component.impl.ContainerComponent; 045import net.tnemc.item.component.impl.CustomNameComponent; 046import net.tnemc.item.component.impl.DamageComponent; 047import net.tnemc.item.component.impl.DamageResistantComponent; 048import net.tnemc.item.component.impl.DeathProtectionComponent; 049import net.tnemc.item.component.impl.DyedColorComponent; 050import net.tnemc.item.component.impl.EnchantableComponent; 051import net.tnemc.item.component.impl.EnchantmentGlintOverrideComponent; 052import net.tnemc.item.component.impl.EnchantmentsComponent; 053import net.tnemc.item.component.impl.EntityVariantComponent; 054import net.tnemc.item.component.impl.EquipComponent; 055import net.tnemc.item.component.impl.FireworkExplosionComponent; 056import net.tnemc.item.component.impl.FireworksComponent; 057import net.tnemc.item.component.impl.FoodComponent; 058import net.tnemc.item.component.impl.GliderComponent; 059import net.tnemc.item.component.impl.HideAdditionalTooltipComponent; 060import net.tnemc.item.component.impl.HideTooltipComponent; 061import net.tnemc.item.component.impl.InstrumentComponent; 062import net.tnemc.item.component.impl.IntangibleProjectileComponent; 063import net.tnemc.item.component.impl.ItemModelComponent; 064import net.tnemc.item.component.impl.ItemNameComponent; 065import net.tnemc.item.component.impl.JukeBoxComponent; 066import net.tnemc.item.component.impl.LodestoneTrackerComponent; 067import net.tnemc.item.component.impl.LoreComponent; 068import net.tnemc.item.component.impl.MapColorComponent; 069import net.tnemc.item.component.impl.MapIDComponent; 070import net.tnemc.item.component.impl.MaxDamageComponent; 071import net.tnemc.item.component.impl.MaxStackSizeComponent; 072import net.tnemc.item.component.impl.ModelDataComponent; 073import net.tnemc.item.component.impl.ModelDataOldComponent; 074import net.tnemc.item.component.impl.NoteBlockSoundComponent; 075import net.tnemc.item.component.impl.OminousBottleAmplifierComponent; 076import net.tnemc.item.component.impl.PotDecorationsComponent; 077import net.tnemc.item.component.impl.PotionContentsComponent; 078import net.tnemc.item.component.impl.PotionDurationScaleComponent; 079import net.tnemc.item.component.impl.ProvidesBannerPatternsComponent; 080import net.tnemc.item.component.impl.ProvidesTrimMaterialComponent; 081import net.tnemc.item.component.impl.RarityComponent; 082import net.tnemc.item.component.impl.RecipesComponent; 083import net.tnemc.item.component.impl.RepairCostComponent; 084import net.tnemc.item.component.impl.RepairableComponent; 085import net.tnemc.item.component.impl.StoredEnchantmentsComponent; 086import net.tnemc.item.component.impl.SuspiciousStewEffectsComponent; 087import net.tnemc.item.component.impl.ToolComponent; 088import net.tnemc.item.component.impl.TooltipDisplayComponent; 089import net.tnemc.item.component.impl.TooltipStyleComponent; 090import net.tnemc.item.component.impl.TrimComponent; 091import net.tnemc.item.component.impl.UnbreakableComponent; 092import net.tnemc.item.component.impl.UseCooldownComponent; 093import net.tnemc.item.component.impl.WeaponComponent; 094import net.tnemc.item.component.impl.WritableBookContentComponent; 095import net.tnemc.item.component.impl.WrittenBookContentComponent; 096import net.tnemc.item.paper.platform.PaperItemPlatform; 097import net.tnemc.item.paper.platform.impl.modern.PaperBundleComponent; 098import net.tnemc.item.paper.platform.impl.modern.PaperContainerComponent; 099import net.tnemc.item.paper.platform.impl.modern.PaperCustomNameComponent; 100import net.tnemc.item.paper.platform.impl.modern.PaperDamageComponent; 101import net.tnemc.item.paper.platform.impl.modern.PaperDyedColorComponent; 102import net.tnemc.item.paper.platform.impl.modern.PaperEnchantmentsComponent; 103import net.tnemc.item.paper.platform.impl.modern.PaperItemModelComponent; 104import net.tnemc.item.paper.platform.impl.modern.PaperItemNameComponent; 105import net.tnemc.item.paper.platform.impl.modern.PaperLoreComponent; 106import net.tnemc.item.paper.platform.impl.modern.PaperModelDataComponent; 107import net.tnemc.item.paper.platform.impl.modern.PaperProfileComponent; 108import net.tnemc.item.paper.platform.impl.old.PaperOldModelDataLegacyComponent; 109import net.tnemc.item.persistent.PersistentDataHolder; 110import net.tnemc.item.providers.ItemProvider; 111import net.tnemc.item.providers.SkullProfile; 112import org.bukkit.inventory.ItemFlag; 113import org.bukkit.inventory.ItemStack; 114import org.bukkit.inventory.meta.ItemMeta; 115import org.json.simple.JSONObject; 116import org.json.simple.parser.ParseException; 117 118import java.util.ArrayList; 119import java.util.HashMap; 120import java.util.List; 121import java.util.Map; 122 123/** 124 * PaperItemStack 125 * 126 * @author creatorfromhell 127 * @since 0.1.7.5 128 */ 129public class PaperItemStack implements AbstractItemStack<ItemStack> { 130 131 private final Map<String, SerialComponent<AbstractItemStack<ItemStack>, ItemStack>> components = new HashMap<>(); 132 133 private final List<String> flags = new ArrayList<>(); 134 135 private final PersistentDataHolder holder = new PersistentDataHolder(); 136 137 private int slot = 0; 138 private String material; 139 private int amount = 1; 140 private boolean debug = false; 141 142 //item providers 143 private String itemProvider = PaperItemPlatform.instance().defaultProviderIdentifier(); 144 private String providerItemID = material; 145 146 //our locale stack 147 private boolean dirty = false; 148 private ItemStack localeStack; 149 150 /** 151 * Creates a new item stack with the specified material and amount. 152 * 153 * @param material The material of the item. 154 * @param amount The number of items in the stack. 155 * 156 * @return A new item stack instance. 157 */ 158 @Override 159 public PaperItemStack of(final String material, final int amount) { 160 161 this.material = material; 162 this.amount = amount; 163 this.dirty = true; 164 return this; 165 } 166 167 /** 168 * Creates a new item stack from a locale-specific object. 169 * 170 * @param locale The locale-specific representation. 171 * 172 * @return A new item stack instance. 173 */ 174 @Override 175 public PaperItemStack of(final ItemStack locale) { 176 177 this.localeStack = locale; 178 this.material = locale.getType().getKey().toString(); 179 180 this.amount = locale.getAmount(); 181 final ItemMeta meta = locale.getItemMeta(); 182 if(meta != null) { 183 for(final ItemFlag flag : meta.getItemFlags()) { 184 185 this.flags.add(flag.name()); 186 } 187 } 188 189 return PaperItemPlatform.instance().serializer(this.localeStack, this); 190 } 191 192 /** 193 * Creates a new item stack from a JSON representation. 194 * 195 * @param json The JSON object containing item stack data. 196 * 197 * @return A new item stack instance. 198 * 199 * @throws ParseException If the JSON structure is invalid. 200 */ 201 @Override 202 public PaperItemStack of(final JSONObject json) throws ParseException { 203 204 205 return this; 206 } 207 208 /** 209 * Sets the item flags. 210 * 211 * @param flags A list of flags to apply to the item. 212 * 213 * @return The updated item stack instance. 214 */ 215 @Override 216 public PaperItemStack flags(final List<String> flags) { 217 218 this.flags.addAll(flags); 219 this.dirty = true; 220 return this; 221 } 222 223 /** 224 * Sets the lore (descriptive text) of the item stack. 225 * 226 * @param lore A list of components representing the lore. 227 * 228 * @return The updated item stack instance. 229 */ 230 @Override 231 public PaperItemStack loreComponent(final List<Component> lore) { 232 233 applyComponent(new PaperLoreComponent(lore)); 234 return this; 235 } 236 237 /** 238 * Adds an enchantment to the item stack. 239 * 240 * @param enchantment The enchantment name. 241 * @param level The level of the enchantment. 242 * 243 * @return The updated item stack instance. 244 */ 245 @Override 246 public PaperItemStack enchant(final String enchantment, final int level) { 247 248 applyComponent(new PaperEnchantmentsComponent(new HashMap<>(){{ 249 put(enchantment, level); 250 }})); 251 return this; 252 } 253 254 /** 255 * Adds multiple enchantments to the item stack. 256 * 257 * @param enchantments A map of enchantment names and levels. 258 * 259 * @return The updated item stack instance. 260 */ 261 @Override 262 public PaperItemStack enchant(final Map<String, Integer> enchantments) { 263 264 applyComponent(new PaperEnchantmentsComponent(enchantments)); 265 return this; 266 } 267 268 /** 269 * Adds enchantments to the item stack by name. 270 * 271 * @param enchantments A list of enchantment names. 272 * 273 * @return The updated item stack instance. 274 */ 275 @Override 276 public PaperItemStack enchant(final List<String> enchantments) { 277 278 final Map<String, Integer> enchants = new HashMap<>(); 279 for(final String enchantment : enchantments) { 280 enchants.put(enchantment, 1); 281 } 282 applyComponent(new PaperEnchantmentsComponent(enchants)); 283 return this; 284 } 285 286 /** 287 * Returns the material of the item stack. 288 * 289 * @return The material of the item stack. 290 */ 291 @Override 292 public String material() { 293 294 return material; 295 } 296 297 /** 298 * Sets the material of the item stack. 299 * 300 * @param material The material name. 301 * 302 * @return The updated item stack instance. 303 */ 304 @Override 305 public PaperItemStack material(final String material) { 306 307 this.material = material; 308 this.dirty = true; 309 return this; 310 } 311 312 /** 313 * The quantity of the item stack. 314 * 315 * @return the quantity of the item stack. 316 */ 317 @Override 318 public int amount() { 319 320 return amount; 321 } 322 323 /** 324 * Sets the quantity of the item stack. 325 * 326 * @param amount The number of items in the stack. 327 * 328 * @return The updated item stack instance. 329 */ 330 @Override 331 public PaperItemStack amount(final int amount) { 332 333 this.amount = amount; 334 this.dirty = true; 335 return this; 336 } 337 338 /** 339 * Represents the inventory slot of the item stack. 340 * 341 * @return the inventory slot of the item stack. 342 */ 343 @Override 344 public int slot() { 345 346 return slot; 347 } 348 349 /** 350 * Sets the inventory slot of the item stack. 351 * 352 * @param slot The slot index. 353 * 354 * @return The updated item stack instance. 355 */ 356 @Override 357 public PaperItemStack slot(final int slot) { 358 359 this.slot = slot; 360 this.dirty = true; 361 return this; 362 } 363 364 /** 365 * Enables or disables debug mode for the item stack. 366 * 367 * @param debug True to enable, false to disable. 368 * 369 * @return The updated item stack instance. 370 */ 371 @Override 372 public PaperItemStack debug(final boolean debug) { 373 374 this.debug = debug; 375 return this; 376 } 377 378 public ItemStack cacheLocale() { 379 380 return this.localeStack; 381 } 382 383 public void updateCache(final ItemStack localeStack) { 384 385 this.localeStack = localeStack; 386 } 387 388 /** 389 * Replaces the persistent data holder for the item stack. 390 * 391 * @param newHolder The new persistent data holder. 392 * @param replaceOld True to replace existing data, false to merge. 393 * 394 * @return The updated item stack instance. 395 * 396 * @since 0.2.0.0 397 */ 398 @Override 399 public PaperItemStack applyPersistentHolder(final PersistentDataHolder newHolder, final boolean replaceOld) { 400 401 if(replaceOld) { 402 this.holder.getData().clear(); 403 } 404 405 this.holder.getData().putAll(newHolder.getData()); 406 this.dirty = true; 407 return this; 408 } 409 410 /** 411 * Retrieves the item flags. 412 * 413 * @return A list of flags applied to the item. 414 */ 415 @Override 416 public List<String> flags() { 417 418 return this.flags; 419 } 420 421 /** 422 * Retrieves the components applied to the item stack. 423 * 424 * @return A map of component types and their serialized representations. 425 * 426 * @since 0.2.0.0 427 */ 428 @Override 429 public Map<String, SerialComponent<AbstractItemStack<ItemStack>, ItemStack>> components() { 430 431 return components; 432 } 433 434 /** 435 * Retrieves the persistent data holder for the item stack. 436 * 437 * @return The persistent data holder. 438 * 439 * @since 0.2.0.0 440 */ 441 @Override 442 public PersistentDataHolder persistentHolder() { 443 444 return holder; 445 } 446 447 /** 448 * Resets the dirty flag, indicating that the object's state has been synchronized with the 449 * database. 450 */ 451 @Override 452 public void resetDirty() { 453 this.dirty = false; 454 } 455 456 /** 457 * Marks the item stack as dirty, indicating changes have been made. 458 */ 459 @Override 460 public void markDirty() { 461 462 this.dirty = true; 463 } 464 465 /** 466 * Checks whether the object is dirty or has unsaved changes. 467 * 468 * @return true if the object is dirty, false otherwise 469 */ 470 @Override 471 public boolean isDirty() { 472 473 return this.dirty; 474 } 475 476 /** 477 * This method returns a String representing the item provider. 478 * 479 * @return the item provider as a String 480 * 481 * @see ItemProvider 482 */ 483 @Override 484 public String itemProvider() { 485 486 return this.itemProvider; 487 } 488 489 /** 490 * Sets the item provider to be used for retrieving items. 491 * 492 * @param itemProvider the string representing the item provider to be set 493 */ 494 @Override 495 public PaperItemStack setItemProvider(final String itemProvider) { 496 this.itemProvider = itemProvider; 497 this.dirty = true; 498 return this; 499 } 500 501 /** 502 * Retrieves the provider item ID associated with the current object. 503 * 504 * @return The provider item ID of the object. 505 */ 506 @Override 507 public String providerItemID() { 508 509 return this.providerItemID; 510 } 511 512 /** 513 * Sets the provider's item ID for the current item. 514 * 515 * @param providerItemID the unique ID assigned by the provider for the item 516 */ 517 @Override 518 public PaperItemStack setProviderItemID(final String providerItemID) { 519 520 this.providerItemID = providerItemID; 521 this.dirty = true; 522 return this; 523 } 524 525 /** 526 * This method is used to return an ItemProvider object. 527 * 528 * @return ItemProvider object representing the item provider. 529 */ 530 @Override 531 public ItemProvider<ItemStack> provider() { 532 533 return PaperItemPlatform.instance().provider(itemProvider); 534 } 535 536 /** 537 * Converts the object to a JSONObject representation. 538 * 539 * @return A JSONObject representing the object data. 540 */ 541 @Override 542 public JSONObject toJSON() { 543 544 return null; 545 } 546 547 /** 548 * Updates the attribute modifiers of the item stack. 549 * 550 * @param modifiers a list of attribute modifiers 551 * @param showInTooltip whether to display the modifiers in the tooltip 552 * 553 * @return the updated PaperItemStack instance 554 * 555 * @see AttributeModifiersComponent 556 * @since 0.2.0.0 557 */ 558 @Override 559 public PaperItemStack attributeModifiers(final List<AttributeModifier> modifiers, final boolean showInTooltip) { 560 561 return this; 562 } 563 564 /** 565 * Updates the banner patterns of the item stack. 566 * 567 * @param patterns a list of pattern data 568 * 569 * @return the updated PaperItemStack instance 570 * 571 * @see BannerPatternsComponent 572 * @since 0.2.0.0 573 */ 574 @Override 575 public PaperItemStack bannerPatterns(final List<PatternData> patterns) { 576 577 return this; 578 } 579 580 /** 581 * Updates the base color of the item stack. 582 * 583 * @param color the new base color 584 * 585 * @return the updated PaperItemStack instance 586 * 587 * @see BaseColorComponent 588 * @since 0.2.0.0 589 */ 590 @Override 591 public PaperItemStack baseColor(final String color) { 592 593 return this; 594 } 595 596 /** 597 * Blocks attacks with the specified damage type using this item. 598 * 599 * @param damage the type of damage to block attacks from 600 * 601 * @return an AbstractItemStack object representing the item after blocking attacks 602 * 603 * @see BlocksAttacksComponent 604 * @since 0.2.0.0 605 */ 606 @Override 607 public AbstractItemStack<ItemStack> blocksAttacks(final ItemDamage damage) { 608 609 return this; 610 } 611 612 /** 613 * Set the break sound for this item stack. 614 * 615 * @param sound the sound to be played when the item is broken 616 * 617 * @return the updated item stack object 618 * 619 * @see BreakSoundComponent 620 * @since 0.2.0.0 621 */ 622 @Override 623 public AbstractItemStack<ItemStack> breakSound(final String sound) { 624 625 return this; 626 } 627 628 /** 629 * Updates the bucket entity data of the item stack. 630 * 631 * @param noAI whether the entity has AI disabled 632 * @param silent whether the entity is silent 633 * @param noGravity whether the entity is affected by gravity 634 * @param glowing whether the entity is glowing 635 * @param invulnerable whether the entity is invulnerable 636 * @param health the health of the entity 637 * @param age the age of the entity 638 * @param variant the variant of the entity 639 * @param huntingCooldown the hunting cooldown of the entity 640 * @param bucketVariantTag the variant tag of the bucket 641 * @param type the type of the entity 642 * 643 * @return the updated PaperItemStack instance 644 * 645 * @see BucketEntityDataComponent 646 * @since 0.2.0.0 647 */ 648 @Override 649 public PaperItemStack bucketEntityData(final boolean noAI, final boolean silent, final boolean noGravity, final boolean glowing, final boolean invulnerable, final float health, final int age, final int variant, final long huntingCooldown, final int bucketVariantTag, final String type) { 650 651 return this; 652 } 653 654 /** 655 * Bundles a collection of {@link AbstractItemStack} instances into a single collection. 656 * 657 * @param items A {@link Map} containing integer keys and {@link AbstractItemStack} values to be 658 * bundled. 659 * 660 * @return An {@link AbstractItemStack} instance that represents the bundled items. 661 * 662 * @see BundleComponent 663 * @since 0.2.0.0 664 */ 665 @Override 666 public PaperItemStack bundle(final Map<Integer, AbstractItemStack<ItemStack>> items) { 667 668 applyComponent(new PaperBundleComponent(items)); 669 return this; 670 } 671 672 /** 673 * Updates the blocks that the item stack can break. 674 * 675 * @param predicates a list of block predicates 676 * 677 * @return the updated PaperItemStack instance 678 * 679 * @see CanBreakComponent 680 * @since 0.2.0.0 681 */ 682 @Override 683 public PaperItemStack canBreak(final List<BlockPredicate> predicates) { 684 685 return this; 686 } 687 688 /** 689 * Updates the blocks that the item stack can be placed on. 690 * 691 * @param predicates a list of block predicates 692 * 693 * @return the updated PaperItemStack instance 694 * 695 * @see CanPlaceOnComponent 696 * @since 0.2.0.0 697 */ 698 @Override 699 public PaperItemStack canPlaceOn(final List<BlockPredicate> predicates) { 700 701 return this; 702 } 703 704 /** 705 * Updates the consumable properties of the item stack. 706 * 707 * @param consumeSeconds the time it takes to consume the item 708 * @param animation the animation to display when consuming 709 * @param sound the sound to play when consuming 710 * @param hasConsumeParticles whether to show consume particles 711 * @param effects a list of effects applied on consumption 712 * 713 * @return the updated PaperItemStack instance 714 * 715 * @see ConsumableComponent 716 * @since 0.2.0.0 717 */ 718 @Override 719 public PaperItemStack consumable(final float consumeSeconds, final String animation, final String sound, final boolean hasConsumeParticles, final List<ComponentEffect> effects) { 720 721 return this; 722 } 723 724 /** 725 * Constructs a container with the given map of items. 726 * 727 * @param items a map of items where the key is the position of the item in the container and the 728 * value is the item 729 * 730 * @return an AbstractItemStack container with the specified items 731 * 732 * @see ContainerComponent 733 * @since 0.2.0.0 734 */ 735 @Override 736 public PaperItemStack container(final Map<Integer, AbstractItemStack<ItemStack>> items) { 737 738 applyComponent(new PaperContainerComponent(items)); 739 this.dirty = true; 740 return this; 741 } 742 743 /** 744 * Updates the custom name of the item stack. 745 * 746 * @param customName the custom name to set 747 * 748 * @return the updated PaperItemStack instance 749 * 750 * @see CustomNameComponent 751 * @since 0.2.0.0 752 */ 753 @Override 754 public PaperItemStack customName(final Component customName) { 755 756 applyComponent(new PaperCustomNameComponent(customName)); 757 this.dirty = true; 758 return this; 759 } 760 761 /** 762 * Updates the damage of the item stack. 763 * 764 * @param damage the damage value to set 765 * 766 * @return the updated PaperItemStack instance 767 * 768 * @see DamageComponent 769 * @since 0.2.0.0 770 */ 771 @Override 772 public PaperItemStack damage(final int damage) { 773 774 applyComponent(new PaperDamageComponent(damage)); 775 this.dirty = true; 776 return this; 777 } 778 779 /** 780 * Updates the damage-resistant types of the item stack. 781 * 782 * @param types a list of damage-resistant types 783 * 784 * @return the updated PaperItemStack instance 785 * 786 * @see DamageResistantComponent 787 * @since 0.2.0.0 788 */ 789 @Override 790 public PaperItemStack damageResistant(final List<String> types) { 791 792 return this; 793 } 794 795 /** 796 * Updates the death protection effects of the item stack. 797 * 798 * @param deathEffects a list of death protection effects 799 * 800 * @return the updated PaperItemStack instance 801 * 802 * @see DeathProtectionComponent 803 * @since 0.2.0.0 804 */ 805 @Override 806 public PaperItemStack deathProtection(final List<ComponentEffect> deathEffects) { 807 808 return this; 809 } 810 811 /** 812 * Updates the dyed color of the item stack. 813 * 814 * @param rgb the RGB color value to set 815 * 816 * @return the updated PaperItemStack instance 817 * 818 * @see DyedColorComponent 819 * @since 0.2.0.0 820 */ 821 @Override 822 public PaperItemStack dyedColor(final int rgb) { 823 824 applyComponent(new PaperDyedColorComponent(rgb)); 825 this.dirty = true; 826 return this; 827 } 828 829 /** 830 * Updates the enchantability of the item stack. 831 * 832 * @param value the enchantability value to set 833 * 834 * @return the updated PaperItemStack instance 835 * 836 * @see EnchantableComponent 837 * @since 0.2.0.0 838 */ 839 @Override 840 public PaperItemStack enchantable(final int value) { 841 842 return this; 843 } 844 845 /** 846 * Updates the enchantment glint override of the item stack. 847 * 848 * @param glintOverride whether the enchantment glint should be overridden 849 * 850 * @return the updated PaperItemStack instance 851 * 852 * @see EnchantmentGlintOverrideComponent 853 * @since 0.2.0.0 854 */ 855 @Override 856 public PaperItemStack enchantmentGlintOverride(final boolean glintOverride) { 857 858 return this; 859 } 860 861 /** 862 * Updates the enchantments of the item stack. 863 * 864 * @param levels a map of enchantments and their levels 865 * 866 * @return the updated PaperItemStack instance 867 * 868 * @see EnchantmentsComponent 869 * @since 0.2.0.0 870 */ 871 @Override 872 public PaperItemStack enchantments(final Map<String, Integer> levels) { 873 874 applyComponent(new PaperEnchantmentsComponent(levels)); 875 this.dirty = true; 876 return this; 877 } 878 879 /** 880 * Generates an AbstractItemStack based on the given entity and variant. 881 * 882 * @param entity the entity name to create the stack for 883 * @param variant the variant of the entity 884 * 885 * @return an AbstractItemStack representing the entity with the specified variant 886 * 887 * @see EntityVariantComponent 888 * @since 0.2.0.0 889 */ 890 @Override 891 public AbstractItemStack<ItemStack> entityVariant(final String entity, final String variant) { 892 893 return this; 894 } 895 896 /** 897 * Equips an item with specified parameters. 898 * 899 * @param cameraKey the key identifying the camera 900 * @param equipSound the key identifying the equip sound 901 * @param modelKey the key identifying the model 902 * @param slot the slot in which the item should be equipped 903 * @param damageOnHurt flag indicating if damage should be taken on hurt 904 * @param dispensable flag indicating if the item is dispensable 905 * @param swappable flag indicating if the item is swappable 906 * @param equipOnInteract flag indicating if the item should be equipped on interact 907 * @param entities a list of entities to be equipped 908 * 909 * @return an PaperItemStack object representing the equipped item 910 * 911 * @see EquipComponent 912 * @since 0.2.0.0 913 */ 914 @Override 915 public PaperItemStack equip(final String cameraKey, final String equipSound, final String modelKey, final EquipSlot slot, final boolean damageOnHurt, final boolean dispensable, final boolean swappable, final boolean equipOnInteract, final List<String> entities) { 916 917 return this; 918 } 919 920 /** 921 * Updates the firework explosion properties of the item stack. 922 * 923 * @param explosion the explosion data to set 924 * 925 * @return the updated PaperItemStack instance 926 * 927 * @see FireworkExplosionComponent 928 * @since 0.2.0.0 929 */ 930 @Override 931 public PaperItemStack fireworkExplosion(final ExplosionData explosion) { 932 933 return this; 934 } 935 936 /** 937 * Updates the fireworks properties of the item stack. 938 * 939 * @param flightDuration the flight duration of the fireworks 940 * @param explosions a list of explosion data 941 * 942 * @return the updated PaperItemStack instance 943 * 944 * @see FireworksComponent 945 * @since 0.2.0.0 946 */ 947 @Override 948 public PaperItemStack fireworks(final byte flightDuration, final List<ExplosionData> explosions) { 949 950 return this; 951 } 952 953 /** 954 * Updates the food properties of the item stack. 955 * 956 * @param noHunger whether the item causes no hunger 957 * @param saturation the saturation value 958 * @param nutrition the nutrition value 959 * 960 * @return the updated PaperItemStack instance 961 * 962 * @see FoodComponent 963 * @since 0.2.0.0 964 */ 965 @Override 966 public PaperItemStack food(final boolean noHunger, final float saturation, final int nutrition) { 967 968 return this; 969 } 970 971 /** 972 * Updates the item stack to enable glider functionality. 973 * 974 * @return the updated PaperItemStack instance 975 * 976 * @see GliderComponent 977 * @since 0.2.0.0 978 */ 979 @Override 980 public PaperItemStack gliderTag() { 981 982 return this; 983 } 984 985 /** 986 * Updates the item stack to hide additional tooltip. 987 * 988 * @return the updated PaperItemStack instance 989 * 990 * @see HideAdditionalTooltipComponent 991 * @since 0.2.0.0 992 */ 993 @Override 994 public PaperItemStack hideAdditionalTooltipTag() { 995 996 return this; 997 } 998 999 /** 1000 * Updates the item stack to hide its tooltip. 1001 * 1002 * @return the updated PaperItemStack instance 1003 * 1004 * @see HideTooltipComponent 1005 * @since 0.2.0.0 1006 */ 1007 @Override 1008 public PaperItemStack hideTooltipTag() { 1009 1010 return this; 1011 } 1012 1013 /** 1014 * Updates the instrument properties of the item stack. 1015 * 1016 * @param soundEvent the sound event identifier 1017 * @param useDuration the duration of the sound in ticks 1018 * @param range the range of the sound 1019 * 1020 * @return the updated PaperItemStack instance 1021 * 1022 * @see InstrumentComponent 1023 * @since 0.2.0.0 1024 */ 1025 @Override 1026 public PaperItemStack instrument(final String soundEvent, final int useDuration, final int range) { 1027 1028 return this; 1029 } 1030 1031 /** 1032 * Updates the item stack as an intangible projectile. 1033 * 1034 * @return the updated PaperItemStack instance 1035 * 1036 * @see IntangibleProjectileComponent 1037 * @since 0.2.0.0 1038 */ 1039 @Override 1040 public PaperItemStack intangibleProjectileTag() { 1041 1042 return this; 1043 } 1044 1045 /** 1046 * Updates the model properties of the item stack. 1047 * 1048 * @param model the model identifier 1049 * 1050 * @return the updated PaperItemStack instance 1051 * 1052 * @see ItemModelComponent 1053 * @since 0.2.0.0 1054 */ 1055 @Override 1056 public PaperItemStack itemModel(final String model) { 1057 1058 applyComponent(new PaperItemModelComponent(model)); 1059 this.dirty = true; 1060 return this; 1061 } 1062 1063 /** 1064 * Updates the name of the item stack. 1065 * 1066 * @param itemName the name of the item 1067 * 1068 * @return the updated PaperItemStack instance 1069 * 1070 * @see ItemNameComponent 1071 * @since 0.2.0.0 1072 */ 1073 @Override 1074 public PaperItemStack itemName(final Component itemName) { 1075 1076 applyComponent(new PaperItemNameComponent(itemName)); 1077 this.dirty = true; 1078 return this; 1079 } 1080 1081 /** 1082 * Updates the jukebox properties of the item stack. 1083 * 1084 * @param song the song identifier 1085 * @param showInTooltip whether to display the song in the tooltip 1086 * 1087 * @return the updated PaperItemStack instance 1088 * 1089 * @see JukeBoxComponent 1090 * @since 0.2.0.0 1091 */ 1092 @Override 1093 public PaperItemStack jukebox(final String song, final boolean showInTooltip) { 1094 1095 return this; 1096 } 1097 1098 /** 1099 * Updates the lodestone tracker properties of the item stack. 1100 * 1101 * @param target the target identifier 1102 * @param pos the position array 1103 * @param dimension the dimension identifier 1104 * @param tracked whether the lodestone is tracked 1105 * 1106 * @return the updated PaperItemStack instance 1107 * 1108 * @see LodestoneTrackerComponent 1109 * @since 0.2.0.0 1110 */ 1111 @Override 1112 public PaperItemStack lodestoneTracker(final String target, final int[] pos, final String dimension, final boolean tracked) { 1113 1114 return this; 1115 } 1116 1117 /** 1118 * Updates the lore of the item stack. 1119 * 1120 * @param lore a list of lore strings 1121 * 1122 * @return the updated PaperItemStack instance 1123 * 1124 * @see LoreComponent 1125 * @since 0.2.0.0 1126 */ 1127 @Override 1128 public PaperItemStack lore(final List<Component> lore) { 1129 1130 applyComponent(new PaperLoreComponent(lore)); 1131 this.dirty = true; 1132 return this; 1133 } 1134 1135 /** 1136 * Updates the map color of the item stack. 1137 * 1138 * @param mapColor the map color value 1139 * 1140 * @return the updated PaperItemStack instance 1141 * 1142 * @see MapColorComponent 1143 * @since 0.2.0.0 1144 */ 1145 @Override 1146 public PaperItemStack mapColor(final int mapColor) { 1147 1148 return this; 1149 } 1150 1151 /** 1152 * Updates the map ID of the item stack. 1153 * 1154 * @param mapId the map ID value 1155 * 1156 * @return the updated PaperItemStack instance 1157 * 1158 * @see MapIDComponent 1159 * @since 0.2.0.0 1160 */ 1161 @Override 1162 public PaperItemStack mapId(final int mapId) { 1163 1164 return this; 1165 } 1166 1167 /** 1168 * Updates the maximum damage of the item stack. 1169 * 1170 * @param maxDamage the maximum damage value 1171 * 1172 * @return the updated PaperItemStack instance 1173 * 1174 * @see MaxDamageComponent 1175 * @since 0.2.0.0 1176 */ 1177 @Override 1178 public PaperItemStack maxDamage(final int maxDamage) { 1179 1180 return this; 1181 } 1182 1183 /** 1184 * Updates the maximum stack size of the item stack. 1185 * 1186 * @param maxStackSize the maximum stack size value 1187 * 1188 * @return the updated PaperItemStack instance 1189 * 1190 * @see MaxStackSizeComponent 1191 * @since 0.2.0.0 1192 */ 1193 @Override 1194 public PaperItemStack maxStackSize(final int maxStackSize) { 1195 1196 return this; 1197 } 1198 1199 /** 1200 * Updates the model data of the item stack. 1201 * 1202 * @param colours a list of color strings 1203 * @param floats a list of float values 1204 * @param flags a list of boolean flags 1205 * @param strings a list of string identifiers 1206 * 1207 * @return the updated PaperItemStack instance 1208 * 1209 * @see ModelDataComponent 1210 * @since 0.2.0.0 1211 */ 1212 @Override 1213 public PaperItemStack modelData(final List<String> colours, final List<Float> floats, final List<Boolean> flags, final List<String> strings) { 1214 1215 applyComponent(new PaperModelDataComponent(colours, floats, flags, strings)); 1216 this.dirty = true; 1217 return this; 1218 } 1219 1220 /** 1221 * Retrieves the model data for a custom item stack. 1222 * 1223 * @param customModelData the custom model data to retrieve 1224 * 1225 * @return an AbstractItemStack with the specified custom model data 1226 * 1227 * @see ModelDataOldComponent 1228 * @since 0.2.0.0 1229 * @deprecated Since MC 1.21.3 Use {@link ItemModelComponent} and {@link ModelDataComponent}. 1230 */ 1231 @Override 1232 public AbstractItemStack<ItemStack> modelDataOld(final int customModelData) { 1233 1234 applyComponent(new PaperOldModelDataLegacyComponent(customModelData)); 1235 this.dirty = true; 1236 return this; 1237 } 1238 1239 /** 1240 * Updates the note block sound of the item stack. 1241 * 1242 * @param soundId the identifier of the sound 1243 * 1244 * @return the updated PaperItemStack instance 1245 * 1246 * @see NoteBlockSoundComponent 1247 * @since 0.2.0.0 1248 */ 1249 @Override 1250 public PaperItemStack noteBlockSound(final String soundId) { 1251 1252 return this; 1253 } 1254 1255 /** 1256 * Updates the ominous bottle amplifier of the item stack. 1257 * 1258 * @param amplifier the amplifier value 1259 * 1260 * @return the updated PaperItemStack instance 1261 * 1262 * @see OminousBottleAmplifierComponent 1263 * @since 0.2.0.0 1264 */ 1265 @Override 1266 public PaperItemStack ominousBottleAmplifier(final int amplifier) { 1267 1268 return this; 1269 } 1270 1271 /** 1272 * Updates the pot decorations of the item stack. 1273 * 1274 * @param decorations a list of decorations 1275 * 1276 * @return the updated PaperItemStack instance 1277 * 1278 * @see PotDecorationsComponent 1279 * @since 0.2.0.0 1280 */ 1281 @Override 1282 public PaperItemStack potDecorations(final List<String> decorations) { 1283 1284 return this; 1285 } 1286 1287 /** 1288 * Updates the potion contents of the item stack. 1289 * 1290 * @param potionId the ID of the potion 1291 * @param customColor the custom color of the potion 1292 * @param customName the custom name of the potion 1293 * @param effects a list of effect instances 1294 * 1295 * @return the updated PaperItemStack instance 1296 * 1297 * @see PotionContentsComponent 1298 * @since 0.2.0.0 1299 */ 1300 @Override 1301 public PaperItemStack potionContents(final String potionId, final int customColor, final String customName, final List<EffectInstance> effects) { 1302 1303 return this; 1304 } 1305 1306 /** 1307 * Sets the duration of a potion effect for the item stack. Since MC Snapshot 25w02a. 1308 * 1309 * @param potionDuration the duration of the potion effect in seconds 1310 * 1311 * @return the modified PaperItemStack object with the updated potion duration 1312 * 1313 * @see PotionDurationScaleComponent 1314 * @since 0.2.0.0 1315 */ 1316 @Override 1317 public PaperItemStack potionDuration(final float potionDuration) { 1318 1319 return this; 1320 } 1321 1322 /** 1323 * Profiles the given SkullProfile to the PaperItemStack object. 1324 * 1325 * @param profile the SkullProfile to be assigned 1326 * 1327 * @return an PaperItemStack object with the provided profile 1328 */ 1329 @Override 1330 public PaperItemStack profile(final SkullProfile profile) { 1331 1332 applyComponent(new PaperProfileComponent(profile)); 1333 this.dirty = true; 1334 return this; 1335 } 1336 1337 /** 1338 * Retrieve an AbstractItemStack object that provides a specific pattern identified by the 1339 * patternTag. 1340 * 1341 * @param patternTag The unique identifier of the pattern to be provided. 1342 * 1343 * @return An AbstractItemStack object that provides the specified pattern. 1344 * 1345 * @see ProvidesBannerPatternsComponent 1346 * @since 0.2.0.0 1347 */ 1348 @Override 1349 public AbstractItemStack<ItemStack> providesPattern(final String patternTag) { 1350 1351 return this; 1352 } 1353 1354 /** 1355 * Applies the specified trim material 1356 * 1357 * @param material the trim material 1358 * 1359 * @return an AbstractItemStack object representing the trimmed material 1360 * 1361 * @see ProvidesTrimMaterialComponent 1362 * @since 0.2.0.0 1363 */ 1364 @Override 1365 public AbstractItemStack<ItemStack> providesTrim(final String material) { 1366 1367 return this; 1368 } 1369 1370 /** 1371 * Updates the rarity of the item stack. 1372 * 1373 * @param rarity the rarity value 1374 * 1375 * @return the updated PaperItemStack instance 1376 * 1377 * @see RarityComponent 1378 * @since 0.2.0.0 1379 */ 1380 @Override 1381 public PaperItemStack rarity(final String rarity) { 1382 1383 return this; 1384 } 1385 1386 /** 1387 * Updates the recipes of the item stack. 1388 * 1389 * @param recipes a list of recipe identifiers 1390 * 1391 * @return the updated PaperItemStack instance 1392 * 1393 * @see RecipesComponent 1394 * @since 0.2.0.0 1395 */ 1396 @Override 1397 public PaperItemStack recipes(final List<String> recipes) { 1398 1399 return this; 1400 } 1401 1402 /** 1403 * Updates the repairable items of the item stack. 1404 * 1405 * @param repairItems a list of repair item identifiers 1406 * 1407 * @return the updated PaperItemStack instance 1408 * 1409 * @see RepairableComponent 1410 * @since 0.2.0.0 1411 */ 1412 @Override 1413 public PaperItemStack repairable(final List<String> repairItems) { 1414 1415 return this; 1416 } 1417 1418 /** 1419 * Updates the repair cost of the item stack. 1420 * 1421 * @param repairCost the repair cost value 1422 * 1423 * @return the updated PaperItemStack instance 1424 * 1425 * @see RepairCostComponent 1426 * @since 0.2.0.0 1427 */ 1428 @Override 1429 public PaperItemStack repairCost(final int repairCost) { 1430 1431 return this; 1432 } 1433 1434 /** 1435 * Updates the stored enchantments of the item stack. 1436 * 1437 * @param enchantments a map of enchantment names to their levels 1438 * 1439 * @return the updated PaperItemStack instance 1440 * 1441 * @see StoredEnchantmentsComponent 1442 * @since 0.2.0.0 1443 */ 1444 @Override 1445 public PaperItemStack storedEnchantments(final Map<String, Integer> enchantments) { 1446 1447 return this; 1448 } 1449 1450 /** 1451 * Applies the given effects to the suspicious stew item. 1452 * 1453 * @param effects a list of EffectInstance objects representing the effects to be applied to the 1454 * suspicious stew 1455 * 1456 * @return an AbstractItemStack representing the suspicious stew with the applied effects 1457 * 1458 * @see SuspiciousStewEffectsComponent 1459 * @since 0.2.0.0 1460 */ 1461 @Override 1462 public AbstractItemStack<ItemStack> suspiciousStewEffects(final List<EffectInstance> effects) { 1463 1464 return this; 1465 } 1466 1467 /** 1468 * Applies the given effects to a suspicious stew item. 1469 * 1470 * @param effects an array of EffectInstance objects representing the effects to apply to the 1471 * suspicious stew 1472 * 1473 * @return an AbstractItemStack representing the suspicious stew item with the applied effects 1474 * 1475 * @see SuspiciousStewEffectsComponent 1476 * @since 0.2.0.0 1477 */ 1478 @Override 1479 public AbstractItemStack<ItemStack> suspiciousStewEffects(final EffectInstance... effects) { 1480 1481 return this; 1482 } 1483 1484 /** 1485 * Constructs a new tool item with the specified characteristics. 1486 * 1487 * @param defaultSpeed the default speed of the tool 1488 * @param blockDamage the damage inflicted by the tool to blocks 1489 * @param canDestroyBlocksCreative if the tool can destroy blocks in creative mode 1490 * @param rules a list of rules that define the behavior of the tool 1491 * 1492 * @return an PaperItemStack instance representing the created tool 1493 * 1494 * @see ToolComponent 1495 * @since 0.2.0.0 1496 */ 1497 @Override 1498 public PaperItemStack tool(final float defaultSpeed, final int blockDamage, final boolean canDestroyBlocksCreative, final List<ToolRule> rules) { 1499 1500 return this; 1501 } 1502 1503 /** 1504 * Displays tooltip for the item stack with an option to hide certain components. 1505 * 1506 * @param hideTooltip Flag to hide the tooltip 1507 * @param hiddenComponents Array of components to hide in the tooltip 1508 * 1509 * @return An AbstractItemStack object with the tooltip displayed 1510 * 1511 * @see TooltipDisplayComponent 1512 * @since 0.2.0.0 1513 */ 1514 @Override 1515 public AbstractItemStack<ItemStack> tooltipDisplay(final boolean hideTooltip, final String... hiddenComponents) { 1516 1517 return this; 1518 } 1519 1520 /** 1521 * Updates the tooltip style of the item stack. 1522 * 1523 * @param style the style to apply to the tooltip 1524 * 1525 * @return the updated PaperItemStack instance 1526 * 1527 * @see TooltipStyleComponent 1528 * @since 0.2.0.0 1529 */ 1530 @Override 1531 public PaperItemStack tooltipStyle(final String style) { 1532 1533 return this; 1534 } 1535 1536 /** 1537 * Updates the trim properties of the item stack. 1538 * 1539 * @param pattern the trim pattern 1540 * @param material the trim material 1541 * @param showInTooltip whether to display the trim in the tooltip 1542 * 1543 * @return the updated PaperItemStack instance 1544 * 1545 * @see TrimComponent 1546 * @since 0.2.0.0 1547 */ 1548 @Override 1549 public PaperItemStack trim(final String pattern, final String material, final boolean showInTooltip) { 1550 1551 return this; 1552 } 1553 1554 /** 1555 * Updates the unbreakable property of the item stack. 1556 * 1557 * @param showInTooltip whether to display the unbreakable property in the tooltip 1558 * 1559 * @return the updated PaperItemStack instance 1560 * 1561 * @see UnbreakableComponent 1562 * @since 0.2.0.0 1563 */ 1564 @Override 1565 public PaperItemStack unbreakable(final boolean showInTooltip) { 1566 1567 return this; 1568 } 1569 1570 /** 1571 * Updates the use cooldown properties of the item stack. 1572 * 1573 * @param cooldownGroup the cooldown group identifier 1574 * @param seconds the cooldown duration in seconds 1575 * 1576 * @return the updated PaperItemStack instance 1577 * 1578 * @see UseCooldownComponent 1579 * @since 0.2.0.0 1580 */ 1581 @Override 1582 public PaperItemStack useCooldown(final String cooldownGroup, final float seconds) { 1583 1584 return this; 1585 } 1586 1587 /** 1588 * Represents a weapon item that can be used for combat. Since MC Snapshot 25w02a. 1589 * 1590 * @param damagePerAttack The amount of damage this weapon inflicts per attack 1591 * @param canDisableBlocking Whether this weapon can disable blocking when used 1592 * 1593 * @see WeaponComponent 1594 * @since 0.2.0.0 1595 */ 1596 @Override 1597 public PaperItemStack weapon(final int damagePerAttack, final boolean canDisableBlocking) { 1598 1599 return this; 1600 } 1601 1602 /** 1603 * Updates the writable book content of the item stack. 1604 * 1605 * @param pages the pages to include in the writable book 1606 * 1607 * @return the updated PaperItemStack instance 1608 * 1609 * @see WritableBookContentComponent 1610 * @since 0.2.0.0 1611 */ 1612 @Override 1613 public PaperItemStack writableBookContent(final List<String> pages) { 1614 1615 return this; 1616 } 1617 1618 /** 1619 * Updates the written book content of the item stack. 1620 * 1621 * @param title the title of the book 1622 * @param author the author of the book 1623 * @param generation the generation of the book 1624 * @param resolved whether the book is resolved 1625 * @param pages the pages to include in the book 1626 * 1627 * @return the updated PaperItemStack instance 1628 * 1629 * @see WrittenBookContentComponent 1630 * @since 0.2.0.0 1631 */ 1632 @Override 1633 public PaperItemStack writtenBookContent(final String title, final String author, final int generation, final boolean resolved, final List<String> pages) { 1634 1635 return this; 1636 } 1637}