├── .gitattributes
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── docs
├── allclasses-frame.html
├── allclasses-noframe.html
├── com
│ ├── chrismin13
│ │ └── additionsapi
│ │ │ ├── AdditionsAPI.html
│ │ │ ├── class-use
│ │ │ └── AdditionsAPI.html
│ │ │ ├── commands
│ │ │ ├── AdditionsCmd.html
│ │ │ ├── AdditionsTab.html
│ │ │ ├── class-use
│ │ │ │ ├── AdditionsCmd.html
│ │ │ │ └── AdditionsTab.html
│ │ │ ├── package-frame.html
│ │ │ ├── package-summary.html
│ │ │ ├── package-tree.html
│ │ │ └── package-use.html
│ │ │ ├── durability
│ │ │ ├── ArmorDurability.html
│ │ │ ├── AxeDurability.html
│ │ │ ├── BowDurability.html
│ │ │ ├── CarrotStickDurability.html
│ │ │ ├── ElytraDurability.html
│ │ │ ├── FishingRodDurability.html
│ │ │ ├── FlintAndSteelDurability.html
│ │ │ ├── HoeDurability.html
│ │ │ ├── ItemDurability.html
│ │ │ ├── PickaxeDurability.html
│ │ │ ├── ShearDurability.html
│ │ │ ├── ShieldDurability.html
│ │ │ ├── SpadeDurability.html
│ │ │ ├── SwordDurability.html
│ │ │ ├── class-use
│ │ │ │ ├── ArmorDurability.html
│ │ │ │ ├── AxeDurability.html
│ │ │ │ ├── BowDurability.html
│ │ │ │ ├── CarrotStickDurability.html
│ │ │ │ ├── ElytraDurability.html
│ │ │ │ ├── FishingRodDurability.html
│ │ │ │ ├── FlintAndSteelDurability.html
│ │ │ │ ├── HoeDurability.html
│ │ │ │ ├── ItemDurability.html
│ │ │ │ ├── PickaxeDurability.html
│ │ │ │ ├── ShearDurability.html
│ │ │ │ ├── ShieldDurability.html
│ │ │ │ ├── SpadeDurability.html
│ │ │ │ └── SwordDurability.html
│ │ │ ├── package-frame.html
│ │ │ ├── package-summary.html
│ │ │ ├── package-tree.html
│ │ │ └── package-use.html
│ │ │ ├── enums
│ │ │ ├── ArmorType.html
│ │ │ ├── ItemType.html
│ │ │ ├── ToolType.html
│ │ │ ├── class-use
│ │ │ │ ├── ArmorType.html
│ │ │ │ ├── ItemType.html
│ │ │ │ └── ToolType.html
│ │ │ ├── package-frame.html
│ │ │ ├── package-summary.html
│ │ │ ├── package-tree.html
│ │ │ └── package-use.html
│ │ │ ├── events
│ │ │ ├── AdditionsAPIInitializationEvent.html
│ │ │ ├── AdditionsAPIPostInitializationEvent.html
│ │ │ ├── armor
│ │ │ │ ├── PlayerCustomArmorDamageEvent.html
│ │ │ │ ├── class-use
│ │ │ │ │ └── PlayerCustomArmorDamageEvent.html
│ │ │ │ ├── package-frame.html
│ │ │ │ ├── package-summary.html
│ │ │ │ ├── package-tree.html
│ │ │ │ └── package-use.html
│ │ │ ├── bow
│ │ │ │ ├── ArrowFromCustomBowHitEvent.html
│ │ │ │ ├── CustomBowEvent.html
│ │ │ │ ├── CustomBowStackEvent.html
│ │ │ │ ├── EntityShootCustomBowEvent.html
│ │ │ │ ├── class-use
│ │ │ │ │ ├── ArrowFromCustomBowHitEvent.html
│ │ │ │ │ ├── CustomBowEvent.html
│ │ │ │ │ ├── CustomBowStackEvent.html
│ │ │ │ │ └── EntityShootCustomBowEvent.html
│ │ │ │ ├── package-frame.html
│ │ │ │ ├── package-summary.html
│ │ │ │ ├── package-tree.html
│ │ │ │ └── package-use.html
│ │ │ ├── class-use
│ │ │ │ ├── AdditionsAPIInitializationEvent.html
│ │ │ │ └── AdditionsAPIPostInitializationEvent.html
│ │ │ ├── elytra
│ │ │ │ ├── CustomElytraPlayerToggleGlideEvent.html
│ │ │ │ ├── class-use
│ │ │ │ │ └── CustomElytraPlayerToggleGlideEvent.html
│ │ │ │ ├── package-frame.html
│ │ │ │ ├── package-summary.html
│ │ │ │ ├── package-tree.html
│ │ │ │ └── package-use.html
│ │ │ ├── item
│ │ │ │ ├── CustomItemBlockBreakEvent.html
│ │ │ │ ├── CustomItemBlockIgniteEvent.html
│ │ │ │ ├── CustomItemEvent.html
│ │ │ │ ├── CustomItemFishEvent.html
│ │ │ │ ├── CustomItemFurnaceBurnEvent.html
│ │ │ │ ├── CustomItemPlayerInteractEvent.html
│ │ │ │ ├── CustomItemShearEntityEvent.html
│ │ │ │ ├── CustomItemStackEvent.html
│ │ │ │ ├── EntityDamageByPlayerUsingCustomItemEvent.html
│ │ │ │ ├── PlayerCustomItemBreakEvent.html
│ │ │ │ ├── PlayerCustomItemDamageEvent.html
│ │ │ │ ├── PlayerDropCustomItemEvent.html
│ │ │ │ ├── PlayerPickupCustomItemEvent.html
│ │ │ │ ├── class-use
│ │ │ │ │ ├── CustomItemBlockBreakEvent.html
│ │ │ │ │ ├── CustomItemBlockIgniteEvent.html
│ │ │ │ │ ├── CustomItemEvent.html
│ │ │ │ │ ├── CustomItemFishEvent.html
│ │ │ │ │ ├── CustomItemFurnaceBurnEvent.html
│ │ │ │ │ ├── CustomItemPlayerInteractEvent.html
│ │ │ │ │ ├── CustomItemShearEntityEvent.html
│ │ │ │ │ ├── CustomItemStackEvent.html
│ │ │ │ │ ├── EntityDamageByPlayerUsingCustomItemEvent.html
│ │ │ │ │ ├── PlayerCustomItemBreakEvent.html
│ │ │ │ │ ├── PlayerCustomItemDamageEvent.html
│ │ │ │ │ ├── PlayerDropCustomItemEvent.html
│ │ │ │ │ └── PlayerPickupCustomItemEvent.html
│ │ │ │ ├── package-frame.html
│ │ │ │ ├── package-summary.html
│ │ │ │ ├── package-tree.html
│ │ │ │ └── package-use.html
│ │ │ ├── package-frame.html
│ │ │ ├── package-summary.html
│ │ │ ├── package-tree.html
│ │ │ ├── package-use.html
│ │ │ └── shield
│ │ │ │ ├── CustomShieldPlayerDamageByEntityEvent.html
│ │ │ │ ├── class-use
│ │ │ │ └── CustomShieldPlayerDamageByEntityEvent.html
│ │ │ │ ├── package-frame.html
│ │ │ │ ├── package-summary.html
│ │ │ │ ├── package-tree.html
│ │ │ │ └── package-use.html
│ │ │ ├── files
│ │ │ ├── BossBarConfig.html
│ │ │ ├── ConfigFile.DebugType.html
│ │ │ ├── ConfigFile.html
│ │ │ ├── CustomItemConfig.html
│ │ │ ├── DataFile.html
│ │ │ ├── LangFile.html
│ │ │ ├── PermissionConfig.html
│ │ │ ├── class-use
│ │ │ │ ├── BossBarConfig.html
│ │ │ │ ├── ConfigFile.DebugType.html
│ │ │ │ ├── ConfigFile.html
│ │ │ │ ├── CustomItemConfig.html
│ │ │ │ ├── DataFile.html
│ │ │ │ ├── LangFile.html
│ │ │ │ └── PermissionConfig.html
│ │ │ ├── package-frame.html
│ │ │ ├── package-summary.html
│ │ │ ├── package-tree.html
│ │ │ └── package-use.html
│ │ │ ├── items
│ │ │ ├── CustomArmor.html
│ │ │ ├── CustomBow.html
│ │ │ ├── CustomItem.html
│ │ │ ├── CustomItemStack.html
│ │ │ ├── CustomLeatherArmor.html
│ │ │ ├── CustomPlayerSkull.html
│ │ │ ├── CustomTool.html
│ │ │ ├── StorageCustomItem.html
│ │ │ ├── class-use
│ │ │ │ ├── CustomArmor.html
│ │ │ │ ├── CustomBow.html
│ │ │ │ ├── CustomItem.html
│ │ │ │ ├── CustomItemStack.html
│ │ │ │ ├── CustomLeatherArmor.html
│ │ │ │ ├── CustomPlayerSkull.html
│ │ │ │ ├── CustomTool.html
│ │ │ │ └── StorageCustomItem.html
│ │ │ ├── package-frame.html
│ │ │ ├── package-summary.html
│ │ │ ├── package-tree.html
│ │ │ ├── package-use.html
│ │ │ └── textured
│ │ │ │ ├── CustomTexturedArmor.html
│ │ │ │ ├── CustomTexturedBow.html
│ │ │ │ ├── CustomTexturedItem.html
│ │ │ │ ├── CustomTexturedLeatherArmor.html
│ │ │ │ ├── CustomTexturedTool.html
│ │ │ │ ├── class-use
│ │ │ │ ├── CustomTexturedArmor.html
│ │ │ │ ├── CustomTexturedBow.html
│ │ │ │ ├── CustomTexturedItem.html
│ │ │ │ ├── CustomTexturedLeatherArmor.html
│ │ │ │ └── CustomTexturedTool.html
│ │ │ │ ├── package-frame.html
│ │ │ │ ├── package-summary.html
│ │ │ │ ├── package-tree.html
│ │ │ │ └── package-use.html
│ │ │ ├── listeners
│ │ │ ├── DurabilityBar.html
│ │ │ ├── class-use
│ │ │ │ └── DurabilityBar.html
│ │ │ ├── custom
│ │ │ │ ├── ArmorEquip.html
│ │ │ │ ├── ArrowFromCustomBowHit.html
│ │ │ │ ├── CustomElytraPlayerToggleGlide.html
│ │ │ │ ├── CustomItemBlockBreak.html
│ │ │ │ ├── CustomItemBlockIgnite.html
│ │ │ │ ├── CustomItemFish.html
│ │ │ │ ├── CustomItemFurnaceBurn.html
│ │ │ │ ├── CustomItemPlayerInteract.html
│ │ │ │ ├── CustomItemShearEntity.html
│ │ │ │ ├── CustomShieldEntityDamageByEntity.html
│ │ │ │ ├── EntityDamageByPlayerUsingCustomItem.html
│ │ │ │ ├── EntityShootCustomBow.html
│ │ │ │ ├── PlayerCustomItemDamage.html
│ │ │ │ ├── PlayerDropCustomItem.html
│ │ │ │ ├── PlayerPickupCustomItem.html
│ │ │ │ ├── class-use
│ │ │ │ │ ├── ArmorEquip.html
│ │ │ │ │ ├── ArrowFromCustomBowHit.html
│ │ │ │ │ ├── CustomElytraPlayerToggleGlide.html
│ │ │ │ │ ├── CustomItemBlockBreak.html
│ │ │ │ │ ├── CustomItemBlockIgnite.html
│ │ │ │ │ ├── CustomItemFish.html
│ │ │ │ │ ├── CustomItemFurnaceBurn.html
│ │ │ │ │ ├── CustomItemPlayerInteract.html
│ │ │ │ │ ├── CustomItemShearEntity.html
│ │ │ │ │ ├── CustomShieldEntityDamageByEntity.html
│ │ │ │ │ ├── EntityDamageByPlayerUsingCustomItem.html
│ │ │ │ │ ├── EntityShootCustomBow.html
│ │ │ │ │ ├── PlayerCustomItemDamage.html
│ │ │ │ │ ├── PlayerDropCustomItem.html
│ │ │ │ │ └── PlayerPickupCustomItem.html
│ │ │ │ ├── package-frame.html
│ │ │ │ ├── package-summary.html
│ │ │ │ ├── package-tree.html
│ │ │ │ └── package-use.html
│ │ │ ├── package-frame.html
│ │ │ ├── package-summary.html
│ │ │ ├── package-tree.html
│ │ │ ├── package-use.html
│ │ │ └── vanilla
│ │ │ │ ├── Anvil.html
│ │ │ │ ├── BlockBreak.html
│ │ │ │ ├── BlockIgnite.html
│ │ │ │ ├── CraftingTable.html
│ │ │ │ ├── EnchantItem.html
│ │ │ │ ├── EntityDamage.html
│ │ │ │ ├── EntityShootBow.html
│ │ │ │ ├── EntityToggleGlide.html
│ │ │ │ ├── Experience.html
│ │ │ │ ├── FurnaceBurn.html
│ │ │ │ ├── PlayerDeath.html
│ │ │ │ ├── PlayerDropItem.html
│ │ │ │ ├── PlayerFish.html
│ │ │ │ ├── PlayerInteract.html
│ │ │ │ ├── PlayerPickupItem.html
│ │ │ │ ├── PlayerShearEntity.html
│ │ │ │ ├── class-use
│ │ │ │ ├── Anvil.html
│ │ │ │ ├── BlockBreak.html
│ │ │ │ ├── BlockIgnite.html
│ │ │ │ ├── CraftingTable.html
│ │ │ │ ├── EnchantItem.html
│ │ │ │ ├── EntityDamage.html
│ │ │ │ ├── EntityShootBow.html
│ │ │ │ ├── EntityToggleGlide.html
│ │ │ │ ├── Experience.html
│ │ │ │ ├── FurnaceBurn.html
│ │ │ │ ├── PlayerDeath.html
│ │ │ │ ├── PlayerDropItem.html
│ │ │ │ ├── PlayerFish.html
│ │ │ │ ├── PlayerInteract.html
│ │ │ │ ├── PlayerPickupItem.html
│ │ │ │ └── PlayerShearEntity.html
│ │ │ │ ├── package-frame.html
│ │ │ │ ├── package-summary.html
│ │ │ │ ├── package-tree.html
│ │ │ │ └── package-use.html
│ │ │ ├── package-frame.html
│ │ │ ├── package-summary.html
│ │ │ ├── package-tree.html
│ │ │ ├── package-use.html
│ │ │ ├── permissions
│ │ │ ├── ArmorPermissions.html
│ │ │ ├── BowPermissions.html
│ │ │ ├── CarrotStickPermissions.html
│ │ │ ├── ElytraPermissions.html
│ │ │ ├── FishingRodPermissions.html
│ │ │ ├── FlintAndSteelPermissions.html
│ │ │ ├── HoePermissions.html
│ │ │ ├── ItemPermissions.html
│ │ │ ├── PermissionType.html
│ │ │ ├── ShearPermissions.html
│ │ │ ├── ShieldPermissions.html
│ │ │ ├── SpadePermissions.html
│ │ │ ├── class-use
│ │ │ │ ├── ArmorPermissions.html
│ │ │ │ ├── BowPermissions.html
│ │ │ │ ├── CarrotStickPermissions.html
│ │ │ │ ├── ElytraPermissions.html
│ │ │ │ ├── FishingRodPermissions.html
│ │ │ │ ├── FlintAndSteelPermissions.html
│ │ │ │ ├── HoePermissions.html
│ │ │ │ ├── ItemPermissions.html
│ │ │ │ ├── PermissionType.html
│ │ │ │ ├── ShearPermissions.html
│ │ │ │ ├── ShieldPermissions.html
│ │ │ │ └── SpadePermissions.html
│ │ │ ├── package-frame.html
│ │ │ ├── package-summary.html
│ │ │ ├── package-tree.html
│ │ │ └── package-use.html
│ │ │ ├── recipes
│ │ │ ├── CustomFurnaceRecipe.html
│ │ │ ├── CustomRecipe.html
│ │ │ ├── CustomShapedRecipe.html
│ │ │ ├── CustomShapelessRecipe.html
│ │ │ ├── RecipeIngredient.html
│ │ │ ├── class-use
│ │ │ │ ├── CustomFurnaceRecipe.html
│ │ │ │ ├── CustomRecipe.html
│ │ │ │ ├── CustomShapedRecipe.html
│ │ │ │ ├── CustomShapelessRecipe.html
│ │ │ │ └── RecipeIngredient.html
│ │ │ ├── package-frame.html
│ │ │ ├── package-summary.html
│ │ │ ├── package-tree.html
│ │ │ └── package-use.html
│ │ │ └── utils
│ │ │ ├── BowStackContainer.html
│ │ │ ├── Debug.html
│ │ │ ├── ElytraDurabilityTask.html
│ │ │ ├── EquipmentSlotUtils.html
│ │ │ ├── LangFileUtils.html
│ │ │ ├── MaterialUtils.html
│ │ │ ├── NumberUtils.html
│ │ │ ├── PermissionUtils.html
│ │ │ ├── RecipeUtils.html
│ │ │ ├── StringUtils.html
│ │ │ ├── class-use
│ │ │ ├── BowStackContainer.html
│ │ │ ├── Debug.html
│ │ │ ├── ElytraDurabilityTask.html
│ │ │ ├── EquipmentSlotUtils.html
│ │ │ ├── LangFileUtils.html
│ │ │ ├── MaterialUtils.html
│ │ │ ├── NumberUtils.html
│ │ │ ├── PermissionUtils.html
│ │ │ ├── RecipeUtils.html
│ │ │ └── StringUtils.html
│ │ │ ├── package-frame.html
│ │ │ ├── package-summary.html
│ │ │ ├── package-tree.html
│ │ │ └── package-use.html
│ ├── codingforcookies
│ │ └── armorequip
│ │ │ ├── ArmorEquipEvent.EquipMethod.html
│ │ │ ├── ArmorEquipEvent.html
│ │ │ ├── ArmorListener.html
│ │ │ ├── class-use
│ │ │ ├── ArmorEquipEvent.EquipMethod.html
│ │ │ ├── ArmorEquipEvent.html
│ │ │ └── ArmorListener.html
│ │ │ ├── package-frame.html
│ │ │ ├── package-summary.html
│ │ │ ├── package-tree.html
│ │ │ └── package-use.html
│ └── comphenix
│ │ └── attribute
│ │ ├── Attributes.Attribute.Builder.html
│ │ ├── Attributes.Attribute.html
│ │ ├── Attributes.AttributeType.html
│ │ ├── Attributes.Operation.html
│ │ ├── Attributes.html
│ │ ├── NbtFactory.NbtCompound.html
│ │ ├── NbtFactory.NbtList.html
│ │ ├── NbtFactory.StreamOptions.html
│ │ ├── NbtFactory.Wrapper.html
│ │ ├── NbtFactory.html
│ │ ├── class-use
│ │ ├── Attributes.Attribute.Builder.html
│ │ ├── Attributes.Attribute.html
│ │ ├── Attributes.AttributeType.html
│ │ ├── Attributes.Operation.html
│ │ ├── Attributes.html
│ │ ├── NbtFactory.NbtCompound.html
│ │ ├── NbtFactory.NbtList.html
│ │ ├── NbtFactory.StreamOptions.html
│ │ ├── NbtFactory.Wrapper.html
│ │ └── NbtFactory.html
│ │ ├── package-frame.html
│ │ ├── package-summary.html
│ │ ├── package-tree.html
│ │ └── package-use.html
├── constant-values.html
├── deprecated-list.html
├── help-doc.html
├── index-files
│ ├── index-1.html
│ ├── index-10.html
│ ├── index-11.html
│ ├── index-12.html
│ ├── index-13.html
│ ├── index-14.html
│ ├── index-15.html
│ ├── index-16.html
│ ├── index-17.html
│ ├── index-18.html
│ ├── index-19.html
│ ├── index-2.html
│ ├── index-20.html
│ ├── index-21.html
│ ├── index-22.html
│ ├── index-3.html
│ ├── index-4.html
│ ├── index-5.html
│ ├── index-6.html
│ ├── index-7.html
│ ├── index-8.html
│ └── index-9.html
├── index.html
├── me
│ └── benfah
│ │ └── cu
│ │ └── init
│ │ └── impl
│ │ ├── MinePackInitializationMethod.html
│ │ ├── class-use
│ │ └── MinePackInitializationMethod.html
│ │ ├── package-frame.html
│ │ ├── package-summary.html
│ │ ├── package-tree.html
│ │ └── package-use.html
├── overview-frame.html
├── overview-summary.html
├── overview-tree.html
├── package-list
├── script.js
├── serialized-form.html
├── stylesheet.css
└── us
│ └── fihgu
│ └── toolbox
│ ├── file
│ ├── FileUtils.html
│ ├── class-use
│ │ └── FileUtils.html
│ ├── package-frame.html
│ ├── package-summary.html
│ ├── package-tree.html
│ └── package-use.html
│ ├── http
│ ├── AccessPoint.html
│ ├── BadRequestException.html
│ ├── ByteBufferContext.html
│ ├── FileContext.html
│ ├── HTTPAcceptHandler.html
│ ├── HTTPContext.html
│ ├── HTTPReadHandler.html
│ ├── HTTPRequest.html
│ ├── HTTPRequestMethod.html
│ ├── HTTPResponse.html
│ ├── HTTPServer.html
│ ├── HTTPWriteHandler.html
│ ├── IContextGenerator.html
│ ├── IReleasable.html
│ ├── ResponseCode.html
│ ├── StaticContextGenerator.html
│ ├── class-use
│ │ ├── AccessPoint.html
│ │ ├── BadRequestException.html
│ │ ├── ByteBufferContext.html
│ │ ├── FileContext.html
│ │ ├── HTTPAcceptHandler.html
│ │ ├── HTTPContext.html
│ │ ├── HTTPReadHandler.html
│ │ ├── HTTPRequest.html
│ │ ├── HTTPRequestMethod.html
│ │ ├── HTTPResponse.html
│ │ ├── HTTPServer.html
│ │ ├── HTTPWriteHandler.html
│ │ ├── IContextGenerator.html
│ │ ├── IReleasable.html
│ │ ├── ResponseCode.html
│ │ └── StaticContextGenerator.html
│ ├── package-frame.html
│ ├── package-summary.html
│ ├── package-tree.html
│ └── package-use.html
│ ├── item
│ ├── BowModelInjection.html
│ ├── DamageableItem.html
│ ├── ItemUtils.html
│ ├── ModelInjection.html
│ ├── ModelInjector.html
│ ├── class-use
│ │ ├── BowModelInjection.html
│ │ ├── DamageableItem.html
│ │ ├── ItemUtils.html
│ │ ├── ModelInjection.html
│ │ └── ModelInjector.html
│ ├── package-frame.html
│ ├── package-summary.html
│ ├── package-tree.html
│ └── package-use.html
│ ├── json
│ ├── JsonUtils.html
│ ├── class-use
│ │ └── JsonUtils.html
│ ├── package-frame.html
│ ├── package-summary.html
│ ├── package-tree.html
│ └── package-use.html
│ ├── network
│ ├── NetworkUtils.html
│ ├── class-use
│ │ └── NetworkUtils.html
│ ├── package-frame.html
│ ├── package-summary.html
│ ├── package-tree.html
│ └── package-use.html
│ ├── reflection
│ ├── ReflectionUtils.html
│ ├── class-use
│ │ └── ReflectionUtils.html
│ ├── package-frame.html
│ ├── package-summary.html
│ ├── package-tree.html
│ └── package-use.html
│ ├── resourcepack
│ ├── ResourcePackListener.html
│ ├── ResourcePackManager.html
│ ├── ResourcePackServer.html
│ ├── class-use
│ │ ├── ResourcePackListener.html
│ │ ├── ResourcePackManager.html
│ │ └── ResourcePackServer.html
│ ├── model
│ │ ├── BlockModel.html
│ │ ├── DisplayEntry.html
│ │ ├── DisplayOptions.html
│ │ ├── ElementFaceEntry.html
│ │ ├── ElementFaceOptions.html
│ │ ├── ElementRotation.html
│ │ ├── ItemModel.html
│ │ ├── Model.html
│ │ ├── ModelAxis.html
│ │ ├── ModelElement.html
│ │ ├── ModelFace.html
│ │ ├── OverrideEntry.html
│ │ ├── Predicate.html
│ │ ├── class-use
│ │ │ ├── BlockModel.html
│ │ │ ├── DisplayEntry.html
│ │ │ ├── DisplayOptions.html
│ │ │ ├── ElementFaceEntry.html
│ │ │ ├── ElementFaceOptions.html
│ │ │ ├── ElementRotation.html
│ │ │ ├── ItemModel.html
│ │ │ ├── Model.html
│ │ │ ├── ModelAxis.html
│ │ │ ├── ModelElement.html
│ │ │ ├── ModelFace.html
│ │ │ ├── OverrideEntry.html
│ │ │ └── Predicate.html
│ │ ├── package-frame.html
│ │ ├── package-summary.html
│ │ ├── package-tree.html
│ │ └── package-use.html
│ ├── package-frame.html
│ ├── package-summary.html
│ ├── package-tree.html
│ └── package-use.html
│ └── web
│ ├── SelectionHandler.html
│ ├── SelectorThread.html
│ ├── SelectorThreadPool.html
│ ├── TimerThread.html
│ ├── WebServer.html
│ ├── class-use
│ ├── SelectionHandler.html
│ ├── SelectorThread.html
│ ├── SelectorThreadPool.html
│ ├── TimerThread.html
│ └── WebServer.html
│ ├── package-frame.html
│ ├── package-summary.html
│ ├── package-tree.html
│ └── package-use.html
├── pom.xml
├── scripts
└── dev.bat
└── src
└── main
├── java
├── com
│ ├── chrismin13
│ │ └── additionsapi
│ │ │ ├── AdditionsAPI.java
│ │ │ ├── commands
│ │ │ ├── AdditionsCmd.java
│ │ │ └── AdditionsTab.java
│ │ │ ├── durability
│ │ │ ├── ArmorDurability.java
│ │ │ ├── AxeDurability.java
│ │ │ ├── BowDurability.java
│ │ │ ├── CarrotStickDurability.java
│ │ │ ├── ElytraDurability.java
│ │ │ ├── FishingRodDurability.java
│ │ │ ├── FlintAndSteelDurability.java
│ │ │ ├── HoeDurability.java
│ │ │ ├── ItemDurability.java
│ │ │ ├── PickaxeDurability.java
│ │ │ ├── ShearDurability.java
│ │ │ ├── ShieldDurability.java
│ │ │ ├── SpadeDurability.java
│ │ │ └── SwordDurability.java
│ │ │ ├── enums
│ │ │ ├── ArmorType.java
│ │ │ ├── ItemType.java
│ │ │ └── ToolType.java
│ │ │ ├── events
│ │ │ ├── AdditionsAPIInitializationEvent.java
│ │ │ ├── AdditionsAPIPostInitializationEvent.java
│ │ │ ├── armor
│ │ │ │ └── PlayerCustomArmorDamageEvent.java
│ │ │ ├── bow
│ │ │ │ ├── ArrowFromCustomBowHitEvent.java
│ │ │ │ ├── CustomBowEvent.java
│ │ │ │ ├── CustomBowStackEvent.java
│ │ │ │ └── EntityShootCustomBowEvent.java
│ │ │ ├── elytra
│ │ │ │ └── CustomElytraPlayerToggleGlideEvent.java
│ │ │ ├── item
│ │ │ │ ├── CustomItemBlockBreakEvent.java
│ │ │ │ ├── CustomItemBlockIgniteEvent.java
│ │ │ │ ├── CustomItemEvent.java
│ │ │ │ ├── CustomItemFishEvent.java
│ │ │ │ ├── CustomItemFurnaceBurnEvent.java
│ │ │ │ ├── CustomItemPlayerInteractEvent.java
│ │ │ │ ├── CustomItemShearEntityEvent.java
│ │ │ │ ├── CustomItemStackEvent.java
│ │ │ │ ├── EntityDamageByPlayerUsingCustomItemEvent.java
│ │ │ │ ├── PlayerCustomItemBreakEvent.java
│ │ │ │ ├── PlayerCustomItemDamageEvent.java
│ │ │ │ ├── PlayerDropCustomItemEvent.java
│ │ │ │ └── PlayerPickupCustomItemEvent.java
│ │ │ └── shield
│ │ │ │ └── CustomShieldPlayerDamageByEntityEvent.java
│ │ │ ├── files
│ │ │ ├── BossBarConfig.java
│ │ │ ├── ConfigFile.java
│ │ │ ├── CustomItemConfig.java
│ │ │ ├── DataFile.java
│ │ │ ├── LangFile.java
│ │ │ └── PermissionConfig.java
│ │ │ ├── items
│ │ │ ├── CustomArmor.java
│ │ │ ├── CustomBow.java
│ │ │ ├── CustomItem.java
│ │ │ ├── CustomItemStack.java
│ │ │ ├── CustomLeatherArmor.java
│ │ │ ├── CustomPlayerSkull.java
│ │ │ ├── CustomTool.java
│ │ │ ├── StorageCustomItem.java
│ │ │ └── textured
│ │ │ │ ├── CustomTexturedArmor.java
│ │ │ │ ├── CustomTexturedBow.java
│ │ │ │ ├── CustomTexturedItem.java
│ │ │ │ ├── CustomTexturedLeatherArmor.java
│ │ │ │ └── CustomTexturedTool.java
│ │ │ ├── listeners
│ │ │ ├── DurabilityBar.java
│ │ │ ├── custom
│ │ │ │ ├── ArmorEquip.java
│ │ │ │ ├── ArrowFromCustomBowHit.java
│ │ │ │ ├── CustomElytraPlayerToggleGlide.java
│ │ │ │ ├── CustomItemBlockBreak.java
│ │ │ │ ├── CustomItemBlockIgnite.java
│ │ │ │ ├── CustomItemFish.java
│ │ │ │ ├── CustomItemFurnaceBurn.java
│ │ │ │ ├── CustomItemPlayerInteract.java
│ │ │ │ ├── CustomItemShearEntity.java
│ │ │ │ ├── CustomShieldEntityDamageByEntity.java
│ │ │ │ ├── EntityDamageByPlayerUsingCustomItem.java
│ │ │ │ ├── EntityShootCustomBow.java
│ │ │ │ ├── PlayerCustomItemDamage.java
│ │ │ │ ├── PlayerDropCustomItem.java
│ │ │ │ └── PlayerPickupCustomItem.java
│ │ │ └── vanilla
│ │ │ │ ├── Anvil.java
│ │ │ │ ├── BlockBreak.java
│ │ │ │ ├── BlockIgnite.java
│ │ │ │ ├── CraftingTable.java
│ │ │ │ ├── EnchantItem.java
│ │ │ │ ├── EntityDamage.java
│ │ │ │ ├── EntityShootBow.java
│ │ │ │ ├── EntityToggleGlide.java
│ │ │ │ ├── Experience.java
│ │ │ │ ├── FurnaceBurn.java
│ │ │ │ ├── PlayerDeath.java
│ │ │ │ ├── PlayerDropItem.java
│ │ │ │ ├── PlayerFish.java
│ │ │ │ ├── PlayerInteract.java
│ │ │ │ ├── PlayerPickupItem.java
│ │ │ │ └── PlayerShearEntity.java
│ │ │ ├── permissions
│ │ │ ├── ArmorPermissions.java
│ │ │ ├── BowPermissions.java
│ │ │ ├── CarrotStickPermissions.java
│ │ │ ├── ElytraPermissions.java
│ │ │ ├── FishingRodPermissions.java
│ │ │ ├── FlintAndSteelPermissions.java
│ │ │ ├── HoePermissions.java
│ │ │ ├── ItemPermissions.java
│ │ │ ├── PermissionType.java
│ │ │ ├── ShearPermissions.java
│ │ │ ├── ShieldPermissions.java
│ │ │ └── SpadePermissions.java
│ │ │ ├── recipes
│ │ │ ├── CustomFurnaceRecipe.java
│ │ │ ├── CustomRecipe.java
│ │ │ ├── CustomShapedRecipe.java
│ │ │ ├── CustomShapelessRecipe.java
│ │ │ └── RecipeIngredient.java
│ │ │ └── utils
│ │ │ ├── BowStackContainer.java
│ │ │ ├── Debug.java
│ │ │ ├── ElytraDurabilityTask.java
│ │ │ ├── EquipmentSlotUtils.java
│ │ │ ├── LangFileUtils.java
│ │ │ ├── MaterialUtils.java
│ │ │ ├── NumberUtils.java
│ │ │ ├── PermissionUtils.java
│ │ │ ├── RecipeUtils.java
│ │ │ └── StringUtils.java
│ ├── codingforcookies
│ │ └── armorequip
│ │ │ ├── ArmorEquipEvent.java
│ │ │ ├── ArmorListener.java
│ │ │ ├── ArmorType.java
│ │ │ └── DispenserArmorListener.java
│ └── comphenix
│ │ └── attribute
│ │ ├── Attributes.java
│ │ └── NbtFactory.java
├── me
│ └── benfah
│ │ └── cu
│ │ └── init
│ │ └── impl
│ │ └── MinePackInitializationMethod.java
└── us
│ └── fihgu
│ └── toolbox
│ ├── file
│ └── FileUtils.java
│ ├── http
│ ├── AccessPoint.java
│ ├── BadRequestException.java
│ ├── ByteBufferContext.java
│ ├── FileContext.java
│ ├── HTTPAcceptHandler.java
│ ├── HTTPContext.java
│ ├── HTTPReadHandler.java
│ ├── HTTPRequest.java
│ ├── HTTPRequestMethod.java
│ ├── HTTPResponse.java
│ ├── HTTPServer.java
│ ├── HTTPWriteHandler.java
│ ├── IContextGenerator.java
│ ├── IReleasable.java
│ ├── ResponseCode.java
│ └── StaticContextGenerator.java
│ ├── item
│ ├── BowModelInjection.java
│ ├── DamageableItem.java
│ ├── ItemUtils.java
│ ├── ModelInjection.java
│ └── ModelInjector.java
│ ├── json
│ └── JsonUtils.java
│ ├── network
│ └── NetworkUtils.java
│ ├── reflection
│ └── ReflectionUtils.java
│ ├── resourcepack
│ ├── ResourcePackListener.java
│ ├── ResourcePackManager.java
│ ├── ResourcePackServer.java
│ └── model
│ │ ├── BlockModel.java
│ │ ├── DisplayEntry.java
│ │ ├── DisplayOptions.java
│ │ ├── ElementFaceEntry.java
│ │ ├── ElementFaceOptions.java
│ │ ├── ElementRotation.java
│ │ ├── ItemModel.java
│ │ ├── Model.java
│ │ ├── ModelAxis.java
│ │ ├── ModelElement.java
│ │ ├── ModelFace.java
│ │ ├── OverrideEntry.java
│ │ └── Predicate.java
│ └── web
│ ├── SelectionHandler.java
│ ├── SelectorThread.java
│ ├── SelectorThreadPool.java
│ ├── TimerThread.java
│ └── WebServer.java
└── resources
├── config.yml
├── plugin.yml
└── resource
├── no_hoe_sound.zip
├── pack.mcmeta
├── pack.png
└── smooth_armor.zip
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.class
2 |
3 | # Mobile Tools for Java (J2ME)
4 | .mtj.tmp/
5 |
6 | # Package Files #
7 | *.jar
8 | *.war
9 | *.ear
10 |
11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
12 | hs_err_pid*
13 |
14 | # =========================
15 | # Operating System Files
16 | # =========================
17 |
18 | # OSX
19 | # =========================
20 |
21 | .DS_Store
22 | .AppleDouble
23 | .LSOverride
24 |
25 | # Thumbnails
26 | ._*
27 |
28 | # Files that might appear in the root of a volume
29 | .DocumentRevisions-V100
30 | .fseventsd
31 | .Spotlight-V100
32 | .TemporaryItems
33 | .Trashes
34 | .VolumeIcon.icns
35 |
36 | # Directories potentially created on remote AFP share
37 | .AppleDB
38 | .AppleDesktop
39 | Network Trash Folder
40 | Temporary Items
41 | .apdisk
42 |
43 | # Windows
44 | # =========================
45 |
46 | # Windows image file caches
47 | Thumbs.db
48 | ehthumbs.db
49 |
50 | # Folder config file
51 | Desktop.ini
52 |
53 | # Recycle Bin used on file shares
54 | $RECYCLE.BIN/
55 |
56 | # Windows Installer files
57 | *.cab
58 | *.msi
59 | *.msm
60 | *.msp
61 |
62 | # Windows shortcuts
63 | *.lnk
64 | /bin/
65 | .classpath
66 | *.class
67 | *.prefs
68 | .project
69 | */target/**
70 |
71 | dependency-reduced-pom.xml
72 | /target/
73 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Christos Miniotis
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | The Additions API allows you to create Custom Items with Custom Textures without using hardcoded durability values. It creates the resource pack itself, provides its own durability system for unbreakable items, allows you to switch through textures on the fly, and much much more!
2 |
3 | Documentation is still Work in Progress, but you can view the JavaDoc at https://chrismin13.github.io/AdditionsAPI/index.html
4 |
5 | chrismin13 is no longer maintaining the project, so it will likely only receive version updates.
6 |
--------------------------------------------------------------------------------
/docs/com/chrismin13/additionsapi/commands/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.chrismin13.additionsapi.commands
7 |
8 |
9 |
10 |
11 |
12 |
13 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/docs/com/chrismin13/additionsapi/durability/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.chrismin13.additionsapi.durability
7 |
8 |
9 |
10 |
11 |
12 |
13 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/docs/com/chrismin13/additionsapi/enums/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.chrismin13.additionsapi.enums
7 |
8 |
9 |
10 |
11 |
12 |
13 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/docs/com/chrismin13/additionsapi/events/armor/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.chrismin13.additionsapi.events.armor
7 |
8 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/com/chrismin13/additionsapi/events/bow/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.chrismin13.additionsapi.events.bow
7 |
8 |
9 |
10 |
11 |
12 |
13 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/docs/com/chrismin13/additionsapi/events/elytra/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.chrismin13.additionsapi.events.elytra
7 |
8 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/com/chrismin13/additionsapi/events/item/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.chrismin13.additionsapi.events.item
7 |
8 |
9 |
10 |
11 |
12 |
13 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/docs/com/chrismin13/additionsapi/events/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.chrismin13.additionsapi.events
7 |
8 |
9 |
10 |
11 |
12 |
13 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/docs/com/chrismin13/additionsapi/events/shield/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.chrismin13.additionsapi.events.shield
7 |
8 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/com/chrismin13/additionsapi/files/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.chrismin13.additionsapi.files
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
Classes
15 |
23 |
Enums
24 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/docs/com/chrismin13/additionsapi/items/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.chrismin13.additionsapi.items
7 |
8 |
9 |
10 |
11 |
12 |
13 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/docs/com/chrismin13/additionsapi/items/textured/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.chrismin13.additionsapi.items.textured
7 |
8 |
9 |
10 |
11 |
12 |
13 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/docs/com/chrismin13/additionsapi/listeners/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.chrismin13.additionsapi.listeners
7 |
8 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/com/chrismin13/additionsapi/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.chrismin13.additionsapi
7 |
8 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/com/chrismin13/additionsapi/permissions/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.chrismin13.additionsapi.permissions
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
Classes
15 |
28 |
Enums
29 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/docs/com/chrismin13/additionsapi/recipes/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.chrismin13.additionsapi.recipes
7 |
8 |
9 |
10 |
11 |
12 |
13 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/docs/com/chrismin13/additionsapi/utils/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.chrismin13.additionsapi.utils
7 |
8 |
9 |
10 |
11 |
12 |
13 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/docs/com/codingforcookies/armorequip/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.codingforcookies.armorequip
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
Classes
15 |
19 |
Enums
20 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/docs/com/comphenix/attribute/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.comphenix.attribute
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
Interfaces
15 |
18 |
Classes
19 |
26 |
Enums
27 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/docs/me/benfah/cu/init/impl/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | me.benfah.cu.init.impl
7 |
8 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/package-list:
--------------------------------------------------------------------------------
1 | com.chrismin13.additionsapi
2 | com.chrismin13.additionsapi.commands
3 | com.chrismin13.additionsapi.durability
4 | com.chrismin13.additionsapi.enums
5 | com.chrismin13.additionsapi.events
6 | com.chrismin13.additionsapi.events.armor
7 | com.chrismin13.additionsapi.events.bow
8 | com.chrismin13.additionsapi.events.elytra
9 | com.chrismin13.additionsapi.events.item
10 | com.chrismin13.additionsapi.events.shield
11 | com.chrismin13.additionsapi.files
12 | com.chrismin13.additionsapi.items
13 | com.chrismin13.additionsapi.items.textured
14 | com.chrismin13.additionsapi.listeners
15 | com.chrismin13.additionsapi.listeners.custom
16 | com.chrismin13.additionsapi.listeners.vanilla
17 | com.chrismin13.additionsapi.permissions
18 | com.chrismin13.additionsapi.recipes
19 | com.chrismin13.additionsapi.utils
20 | com.codingforcookies.armorequip
21 | com.comphenix.attribute
22 | me.benfah.cu.init.impl
23 | us.fihgu.toolbox.file
24 | us.fihgu.toolbox.http
25 | us.fihgu.toolbox.item
26 | us.fihgu.toolbox.json
27 | us.fihgu.toolbox.network
28 | us.fihgu.toolbox.reflection
29 | us.fihgu.toolbox.resourcepack
30 | us.fihgu.toolbox.resourcepack.model
31 | us.fihgu.toolbox.web
32 |
--------------------------------------------------------------------------------
/docs/script.js:
--------------------------------------------------------------------------------
1 | function show(type)
2 | {
3 | count = 0;
4 | for (var key in methods) {
5 | var row = document.getElementById(key);
6 | if ((methods[key] & type) != 0) {
7 | row.style.display = '';
8 | row.className = (count++ % 2) ? rowColor : altColor;
9 | }
10 | else
11 | row.style.display = 'none';
12 | }
13 | updateTabs(type);
14 | }
15 |
16 | function updateTabs(type)
17 | {
18 | for (var value in tabs) {
19 | var sNode = document.getElementById(tabs[value][0]);
20 | var spanNode = sNode.firstChild;
21 | if (value == type) {
22 | sNode.className = activeTableTab;
23 | spanNode.innerHTML = tabs[value][1];
24 | }
25 | else {
26 | sNode.className = tableTab;
27 | spanNode.innerHTML = "" + tabs[value][1] + "";
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/docs/us/fihgu/toolbox/file/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | us.fihgu.toolbox.file
7 |
8 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/us/fihgu/toolbox/http/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | us.fihgu.toolbox.http
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
Interfaces
15 |
19 |
Classes
20 |
33 |
Enums
34 |
38 |
Exceptions
39 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/docs/us/fihgu/toolbox/item/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | us.fihgu.toolbox.item
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
Interfaces
15 |
18 |
Classes
19 |
24 |
Enums
25 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/docs/us/fihgu/toolbox/json/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | us.fihgu.toolbox.json
7 |
8 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/us/fihgu/toolbox/network/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | us.fihgu.toolbox.network
7 |
8 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/us/fihgu/toolbox/reflection/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | us.fihgu.toolbox.reflection
7 |
8 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/us/fihgu/toolbox/resourcepack/model/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | us.fihgu.toolbox.resourcepack.model
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
Classes
15 |
28 |
Enums
29 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/docs/us/fihgu/toolbox/resourcepack/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | us.fihgu.toolbox.resourcepack
7 |
8 |
9 |
10 |
11 |
12 |
13 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/docs/us/fihgu/toolbox/web/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | us.fihgu.toolbox.web
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
Interfaces
15 |
18 |
Classes
19 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/scripts/dev.bat:
--------------------------------------------------------------------------------
1 | @Echo off
2 | rem THIS BATCH SCRIPT SIMPLY MAKES TESTING EASIER
3 | rem IT IS NOT REQUIRED FOR COMPILATION
4 | rem IF YOU WANT TO USE IT, CHANGE THE DIRECTORIES TO YOUR TEST SERVER'S PLUGIN FOLDER
5 | rem THE SCRIPT WILL COPY THE MAVEN BUILD INTO THE FOLDER AUTOMAGICALLY
6 | rem DON'T FORGET TO USE THE 'development' PROFILE!
7 | echo Apply Script: COPY
8 | echo %1
9 | echo F|xcopy /y /s /f /q "%1" "C:\Users\chris\Test Servers\Spigot 1.13.1\plugins\AdditionsAPI.jar"
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/commands/AdditionsTab.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.commands;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Arrays;
5 | import java.util.List;
6 |
7 | import org.bukkit.Bukkit;
8 | import org.bukkit.command.Command;
9 | import org.bukkit.command.CommandSender;
10 | import org.bukkit.command.TabCompleter;
11 |
12 | import com.chrismin13.additionsapi.AdditionsAPI;
13 | import com.chrismin13.additionsapi.utils.StringUtils;
14 |
15 | public class AdditionsTab implements TabCompleter {
16 |
17 | public static final List SUBCOMMANDS = Arrays.asList("give");
18 |
19 | @Override
20 | public List onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
21 | if (args.length == 1) {
22 | String start = args[0];
23 | return StringUtils.startsWith(SUBCOMMANDS, start);
24 | }
25 |
26 | if (args.length == 2) {
27 | String firstArg = args[0];
28 |
29 | if (firstArg.equals("give")) {
30 | return null;
31 | }
32 | }
33 |
34 | if (args.length == 3) {
35 | String firstArg = args[0];
36 | String secondArg = args[1];
37 | String start = args[2];
38 |
39 | if (firstArg.equals("give") && Bukkit.getPlayer(secondArg) != null)
40 | return StringUtils.startsWith(AdditionsAPI.getAllCustomItemIdNames(), start);
41 | }
42 |
43 | if (args.length == 4) {
44 | String firstArg = args[0];
45 | String secondArg = args[1];
46 | String thirdArg = args[2];
47 | String start = args[3];
48 |
49 | if (firstArg.equals("give") && Bukkit.getPlayer(secondArg) != null && AdditionsAPI.isCustomItem(thirdArg))
50 | return StringUtils.startsWith(Arrays.asList("1"), start);
51 | }
52 |
53 | if (args.length == 5) {
54 | String firstArg = args[0];
55 | String secondArg = args[1];
56 | String thirdArg = args[2];
57 | String fourthArg = args[3];
58 | String start = args[4];
59 |
60 | if (firstArg.equals("give") && Bukkit.getPlayer(secondArg) != null && AdditionsAPI.isCustomItem(thirdArg) && fourthArg.equals("1"))
61 | return StringUtils.startsWith(Arrays.asList("0"), start);
62 | }
63 |
64 | return new ArrayList();
65 | }
66 |
67 | }
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/durability/AxeDurability.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.durability;
2 |
3 | /**
4 | * This specifies how an axe will have its durability reduced when performing
5 | * certain actions. Default values are set up exactly like in vanilla
6 | * Minecraft.
7 | * BlockBreak defaults to 1
8 | * EntityHit defautls to 2
9 | *
10 | * @author chrismin13
11 | */
12 | public class AxeDurability extends ItemDurability {
13 |
14 | public AxeDurability() {
15 | super.setBlockBreak(1);
16 | super.setEntityHit(2);
17 | }
18 |
19 | }
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/durability/BowDurability.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.durability;
2 |
3 | /**
4 | * This specifies how a bow will have its durability reduced when performing
5 | * certain actions. Default values are set up exactly like in vanilla
6 | * Minecraft.
7 | * BlockBreak defaults to 0
8 | * EntityHit defautls to 0
9 | * Fire arrow defaults to 1
10 | *
11 | * @author chrismin13
12 | */
13 | public class BowDurability extends ItemDurability {
14 |
15 | private int fireArrow = 1;
16 |
17 | /**
18 | * @return The durability reduced when using the bow to fire an arrow.
19 | */
20 | public int getFireArrow() {
21 | return fireArrow;
22 | }
23 |
24 | /**
25 | * Set the durability reduced when using the bow to fire an arrow.
26 | *
27 | * @param fireArrow
28 | */
29 | public BowDurability setFireArrow(int fireArrow) {
30 | this.fireArrow = fireArrow;
31 | return this;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/durability/CarrotStickDurability.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.durability;
2 |
3 | /**
4 | * TODO: STILL NOT DONE. All values are placeholders for when it finally gets
5 | * implemented. Testing it in Vanilla had wierd results, seems to be bugged atm.
6 | * Upon boosting, nothing happened. Who even uses Carrots on a Stick anyway?
7 | * (unless we're talking 2b2t)
8 | * This specifies how a Carrot on a Stick will have its durability reduced when
9 | * performing certain actions. Default values are set up exactly like in vanilla
10 | * Minecraft.
11 | * BlockBreak defaults to 0
12 | * EntityHit defautls to 0
13 | * Boost defaults to 1
14 | *
15 | * @author chrismin13
16 | */
17 | public class CarrotStickDurability extends ItemDurability {
18 |
19 | private int boost = 7;
20 |
21 | /**
22 | * @return The durability reduced when the player right clicks to boost.
23 | */
24 | public int getBoost() {
25 | return boost;
26 | }
27 |
28 | /**
29 | * Set the durability reduced when the player right clicks to boost.
30 | *
31 | * @param boost
32 | */
33 | public CarrotStickDurability setBoost(int boost) {
34 | this.boost = boost;
35 | return this;
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/durability/ElytraDurability.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.durability;
2 |
3 | /**
4 | * This specifies how an elytra will have its durability reduced when performing
5 | * certain actions. Default values are set up exactly like in vanilla
6 | * Minecraft.
7 | * BlockBreak defaults to 0
8 | * EntityHit defautls to 0
9 | * Flight for 1 second defaults to 1
10 | *
11 | * @author chrismin13
12 | */
13 | public class ElytraDurability extends ItemDurability {
14 |
15 | private int flightOneSecond = 1;
16 |
17 | /**
18 | * @return The durability reduced when flying for 1 second.
19 | */
20 | public int getFlightOneSecond() {
21 | return flightOneSecond;
22 | }
23 |
24 | /**
25 | * Set the durability reduced when flying for 1 second.
26 | *
27 | * @param flightOneSecond
28 | */
29 | public ElytraDurability setFlightOneSecond(int flightOneSecond) {
30 | this.flightOneSecond = flightOneSecond;
31 | return this;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/durability/FishingRodDurability.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.durability;
2 |
3 | /**
4 | * This specifies how a Fishing Rod will have its durability reduced when
5 | * performing certain actions. Default values are set up exactly like in vanilla
6 | * Minecraft.
7 | * BlockBreak defaults to 0
8 | * EntityHit defautls to 0
9 | * Fish Catch defaults to 1
10 | * Block Reel defaults to 2
11 | * Item Reel defaults to 3
12 | * Entity Reel defaults to 5
13 | *
14 | * @author chrismin13
15 | */
16 |
17 | public class FishingRodDurability extends ItemDurability {
18 |
19 | private int fishCatch = 1;
20 | private int blockReel = 2;
21 | private int itemReel = 3;
22 | private int entityReel = 5;
23 |
24 | /**
25 | * @return The durability reduced when a fish is caught.
26 | */
27 | public int getFishCatch() {
28 | return fishCatch;
29 | }
30 |
31 | /**
32 | * Set the durability reduced when a fish is caught.
33 | *
34 | * @param fishCatch
35 | */
36 | public FishingRodDurability setFishCatch(int fishCatch) {
37 | this.fishCatch = fishCatch;
38 | return this;
39 | }
40 |
41 | /**
42 | * @return The durability reduced when the hook is on a block and the
43 | * fishing rod is reeled.
44 | */
45 | public int getBlockReel() {
46 | return blockReel;
47 | }
48 |
49 | /**
50 | * Set the durability reduced when the hook is on a block and the fishing
51 | * rod is reeled.
52 | *
53 | * @param blockReel
54 | */
55 | public FishingRodDurability setBlockReel(int blockReel) {
56 | this.blockReel = blockReel;
57 | return this;
58 | }
59 |
60 | /**
61 | * @return The durability reduced when the hook is on an item on the ground
62 | * and the fishing rod is reeled.
63 | */
64 | public int getItemReel() {
65 | return itemReel;
66 | }
67 |
68 | /**
69 | * Set the durability reduced when the hook is on an item on the ground and
70 | * the fishing rod is reeled.
71 | *
72 | * @param itemReel
73 | */
74 | public FishingRodDurability setItemReel(int itemReel) {
75 | this.itemReel = itemReel;
76 | return this;
77 | }
78 |
79 | /**
80 | * @return The durability reduced when the hook is on an entity that is
81 | * neither a fish nor an item and the fishing rod is reeled.
82 | */
83 | public int getEntityReel() {
84 | return entityReel;
85 | }
86 |
87 | /**
88 | * Set the durability reduced when the hook is on an entity that is neither
89 | * a fish nor an item and the fishing rod is reeled.
90 | *
91 | * @param entityReel
92 | */
93 | public FishingRodDurability setEntityReel(int entityReel) {
94 | this.entityReel = entityReel;
95 | return this;
96 | }
97 |
98 | }
99 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/durability/FlintAndSteelDurability.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.durability;
2 |
3 | /**
4 | * This specifies how a Flint and Steel will have its durability reduced when
5 | * performing certain actions. Default values are set up exactly like in vanilla
6 | * Minecraft.
7 | * BlockBreak defaults to 0
8 | * EntityHit defautls to 0
9 | * Setting a block on fire defaults to 1
10 | *
11 | * @author chrismin13
12 | */
13 | public class FlintAndSteelDurability extends ItemDurability {
14 |
15 | private int fire = 1;
16 |
17 | /**
18 | * @return The durability reduced when setting a block on fire
19 | */
20 | public int getFire() {
21 | return fire;
22 | }
23 |
24 | /**
25 | * Set the durability reduced when setting a block on fire
26 | *
27 | * @param fire
28 | */
29 | public FlintAndSteelDurability setFire(int fire) {
30 | this.fire = fire;
31 | return this;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/durability/HoeDurability.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.durability;
2 |
3 | /**
4 | * This specifies how a hoe will have its durability reduced when performing
5 | * certain actions. Default values are set up exactly like in vanilla
6 | * Minecraft.
7 | * BlockBreak defaults to 0
8 | * EntityHit defautls to 1
9 | * Hoe defaults to 1
10 | *
11 | * @author chrismin13
12 | */
13 | public class HoeDurability extends ItemDurability {
14 |
15 | private int hoe = 1;
16 |
17 | public HoeDurability() {
18 | super.setEntityHit(1);
19 | }
20 |
21 | /**
22 | * @return The damage that will be reduced when you hoe the ground.
23 | */
24 | public int getHoe() {
25 | return hoe;
26 | }
27 |
28 | /**
29 | * Set the damage that will be reduced when you hoe the ground.
30 | *
31 | * @param hoe
32 | */
33 | public HoeDurability setHoe(int hoe) {
34 | this.hoe = hoe;
35 | return this;
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/durability/PickaxeDurability.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.durability;
2 |
3 | /**
4 | * This specifies how a pickaxe will have its durability reduced when performing
5 | * certain actions. Default values are set up exactly like in vanilla
6 | * Minecraft.
7 | * BlockBreak defaults to 1
8 | * EntityHit defautls to 2
9 | *
10 | * @author chrismin13
11 | */
12 | public class PickaxeDurability extends ItemDurability {
13 |
14 | public PickaxeDurability() {
15 | super.setBlockBreak(1);
16 | super.setEntityHit(2);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/durability/ShearDurability.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.durability;
2 |
3 | import org.bukkit.Material;
4 |
5 | /**
6 | * This specifies how shears will have their durability reduced when performing
7 | * certain actions. Default values are set up exactly like in vanilla
8 | * Minecraft.
9 | * BlockBreak defaults to 0
10 | * EntityHit defautls to 0
11 | * Instant block break defaults to 1
12 | * Special blocks include: Web, Leaves, Leaves_2, Wool and Vine. They all
13 | * default to 1
14 | * Shearing sheep defaults to 1
15 | *
16 | * @author chrismin13
17 | */
18 | public class ShearDurability extends ItemDurability {
19 |
20 | private int shearSheep = 1;
21 |
22 | public ShearDurability() {
23 | super.setInstantBlockBreak(1);
24 | super.addSpecialBlock(Material.COBWEB, 1);
25 | super.addSpecialBlock(Material.ACACIA_LEAVES, 1);
26 | super.addSpecialBlock(Material.BIRCH_LEAVES, 1);
27 | super.addSpecialBlock(Material.JUNGLE_LEAVES, 1);
28 | super.addSpecialBlock(Material.OAK_LEAVES, 1);
29 | super.addSpecialBlock(Material.SPRUCE_LEAVES, 1);
30 | super.addSpecialBlock(Material.BLACK_WOOL, 1);
31 | super.addSpecialBlock(Material.BLUE_WOOL, 1);
32 | super.addSpecialBlock(Material.BROWN_WOOL, 1);
33 | super.addSpecialBlock(Material.CYAN_WOOL, 1);
34 | super.addSpecialBlock(Material.GRAY_WOOL, 1);
35 | super.addSpecialBlock(Material.GREEN_WOOL, 1);
36 | super.addSpecialBlock(Material.LIME_WOOL, 1);
37 | super.addSpecialBlock(Material.MAGENTA_WOOL, 1);
38 | super.addSpecialBlock(Material.ORANGE_WOOL, 1);
39 | super.addSpecialBlock(Material.PINK_WOOL, 1);
40 | super.addSpecialBlock(Material.PURPLE_WOOL, 1);
41 | super.addSpecialBlock(Material.RED_WOOL, 1);
42 | super.addSpecialBlock(Material.WHITE_WOOL, 1);
43 | super.addSpecialBlock(Material.YELLOW_WOOL, 1);
44 | super.addSpecialBlock(Material.LIGHT_BLUE_WOOL, 1);
45 | super.addSpecialBlock(Material.LIGHT_GRAY_WOOL, 1);
46 | super.addSpecialBlock(Material.VINE, 1);
47 | }
48 |
49 | /**
50 | * @return The durability reduced when shearing sheep.
51 | */
52 | public int getShearSheep() {
53 | return shearSheep;
54 | }
55 |
56 | /**
57 | * Set the durability reduced when shearing sheep.
58 | *
59 | * @param shearSheep
60 | */
61 | public ShearDurability setShearSheep(int shearSheep) {
62 | this.shearSheep = shearSheep;
63 | return this;
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/durability/ShieldDurability.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.durability;
2 |
3 | /**
4 | * This specifies how a shield will have its durability reduced when performing
5 | * certain actions. Default values are set up exactly like in vanilla
6 | * Minecraft.
7 | * BlockBreak defaults to 0
8 | * EntityHit defautls to 0
9 | * The sheild will be damaged as much as the damage that the player blocking
10 | * received
11 | * There are extra durability points taken when blocking a hit, default is 1
12 | * There is a damage multiplier, it defaults to 1F
13 | *
14 | * @author chrismin13
15 | */
16 | public class ShieldDurability extends ItemDurability {
17 |
18 | private int extraDurabilityTaken = 1;
19 | private float damageMultiplier = 1F;
20 |
21 | /**
22 | * @return The Extra Durability taken upon blocking a hit.
23 | */
24 | public int getExtraDurabilityTaken() {
25 | return extraDurabilityTaken;
26 | }
27 |
28 | /**
29 | * Set the Extra Durability taken upon blocking a hit.
30 | *
31 | * @param extraDurabilityTaken
32 | */
33 | public ShieldDurability setExtraDurabilityTaken(int extraDurabilityTaken) {
34 | this.extraDurabilityTaken = extraDurabilityTaken;
35 | return this;
36 | }
37 |
38 | /**
39 | * If the shield is blocking when the player takes damage by another entity,
40 | * the amount of durability reduced by the shield will be however much the
41 | * damage taken was. This multiplier determines how much the durability will
42 | * be decreased or increased.
43 | */
44 | public float getDamageMultiplier() {
45 | return damageMultiplier;
46 | }
47 |
48 | /**
49 | * If the shield is blocking when the player takes damage by another entity,
50 | * the amount of durability reduced by the shield will be however much the
51 | * damage taken was. This multiplier determines how much the durability will
52 | * be decreased or increased.
53 | *
54 | * @param damageMultiplier
55 | */
56 | public ShieldDurability setDamageMultiplier(float damageMultiplier) {
57 | this.damageMultiplier = damageMultiplier;
58 | return this;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/durability/SpadeDurability.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.durability;
2 |
3 | /**
4 | * This specifies how a spade will have its durability reduced when performing
5 | * certain actions. Default values are set up exactly like in vanilla
6 | * Minecraft.
7 | * BlockBreak defaults to 1
8 | * EntityHit defautls to 2
9 | * PathTile defaults to 1
10 | *
11 | * @author chrismin13
12 | */
13 | public class SpadeDurability extends ItemDurability {
14 |
15 | private int pathTile = 1;
16 |
17 | public SpadeDurability() {
18 | super.setBlockBreak(1);
19 | super.setEntityHit(2);
20 | }
21 |
22 | /**
23 | * @return The damage that will be reduced if a path block is created using the Spade.
24 | */
25 | public int getPathTile() {
26 | return pathTile;
27 | }
28 |
29 | /**
30 | * Set the damage that will be reduced if a path block is created using the Spade.
31 | * @param pathTile
32 | */
33 | public SpadeDurability setPathTile(int pathTile) {
34 | this.pathTile = pathTile;
35 | return this;
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/durability/SwordDurability.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.durability;
2 |
3 | /**
4 | * This specifies how a sword will have its durability reduced when performing
5 | * certain actions. Default values are set up exactly like in vanilla
6 | * Minecraft.
7 | * BlockBreak defaults to 2
8 | * EntityHit defautls to 1
9 | *
10 | * @author chrismin13
11 | */
12 | public class SwordDurability extends ItemDurability {
13 |
14 | public SwordDurability() {
15 | super.setBlockBreak(2);
16 | super.setEntityHit(1);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/AdditionsAPIInitializationEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events;
2 |
3 | import java.io.File;
4 | import java.io.FileInputStream;
5 | import java.io.FileNotFoundException;
6 | import java.io.IOException;
7 | import java.io.InputStream;
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | import org.bukkit.event.Event;
12 | import org.bukkit.event.HandlerList;
13 | import org.bukkit.plugin.java.JavaPlugin;
14 |
15 | import com.chrismin13.additionsapi.items.CustomItem;
16 | import com.chrismin13.additionsapi.utils.Debug;
17 |
18 | import us.fihgu.toolbox.resourcepack.ResourcePackManager;
19 |
20 | public class AdditionsAPIInitializationEvent extends Event {
21 |
22 | private List cItems = new ArrayList();
23 | private static final HandlerList handlers = new HandlerList();
24 |
25 | public AdditionsAPIInitializationEvent addCustomItem(CustomItem cItem) {
26 | Debug.sayTrue("Added Custom Item to Processing List: " + cItem.getIdName());
27 | Debug.saySuper("Properties: Material: " + cItem.getMaterial() + ", DisplayName: " + cItem.getDisplayName()
28 | + ", ItemType: " + cItem.getItemType() + ".");
29 | cItems.add(cItem);
30 | return this;
31 | }
32 |
33 | public CustomItem[] getCustomItems() {
34 | CustomItem[] cItems = new CustomItem[this.cItems.size()];
35 | int index = 0;
36 | for (CustomItem cItem : this.cItems) {
37 | cItems[index] = cItem;
38 | index++;
39 | }
40 | return cItems;
41 | }
42 |
43 | public AdditionsAPIInitializationEvent addResourcePack(JavaPlugin plugin, InputStream inputstream) {
44 | try {
45 | ResourcePackManager.registerResource(plugin, inputstream);
46 | } catch (IOException e) {
47 | e.printStackTrace();
48 | }
49 | return this;
50 | }
51 |
52 | public AdditionsAPIInitializationEvent addResourcePack(JavaPlugin plugin, File file) {
53 | try {
54 | addResourcePack(plugin, new FileInputStream(file));
55 | } catch (FileNotFoundException e) {
56 | Debug.sayError("Could not add Resource Pack! The file specified was not found in the following path: "
57 | + file.getPath());
58 | e.printStackTrace();
59 | }
60 | return this;
61 | }
62 |
63 | public AdditionsAPIInitializationEvent addResourcePackFromPlugin(JavaPlugin plugin, String filename) {
64 | addResourcePack(plugin, plugin.getResource(filename));
65 | return this;
66 | }
67 |
68 | @Override
69 | public HandlerList getHandlers() {
70 | return handlers;
71 | }
72 |
73 | public static HandlerList getHandlerList() {
74 | return handlers;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/AdditionsAPIPostInitializationEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events;
2 |
3 | import org.bukkit.event.Event;
4 | import org.bukkit.event.HandlerList;
5 |
6 | import com.chrismin13.additionsapi.AdditionsAPI;
7 | import com.chrismin13.additionsapi.items.CustomItem;
8 | import com.google.common.collect.ImmutableList;
9 |
10 | public class AdditionsAPIPostInitializationEvent extends Event {
11 |
12 | private static final HandlerList handlers = new HandlerList();
13 |
14 | public ImmutableList getCustomItems() {
15 | return AdditionsAPI.getAllCustomItems();
16 | }
17 |
18 | @Override
19 | public HandlerList getHandlers() {
20 | return handlers;
21 | }
22 |
23 | public static HandlerList getHandlerList() {
24 | return handlers;
25 | }
26 |
27 | }
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/armor/PlayerCustomArmorDamageEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events.armor;
2 |
3 | import org.bukkit.entity.Player;
4 | import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
5 | import org.bukkit.event.player.PlayerItemDamageEvent;
6 | import org.bukkit.inventory.ItemStack;
7 |
8 | import com.chrismin13.additionsapi.events.item.PlayerCustomItemDamageEvent;
9 | import com.chrismin13.additionsapi.items.CustomArmor;
10 |
11 | public class PlayerCustomArmorDamageEvent extends PlayerCustomItemDamageEvent {
12 |
13 | private DamageCause damageCause;
14 |
15 | public PlayerCustomArmorDamageEvent(PlayerItemDamageEvent event, CustomArmor cArmor, DamageCause damageCause, short durability) {
16 | super(event, cArmor);
17 | event.setDamage(durability);
18 | setDamageCause(damageCause);
19 | }
20 |
21 | public PlayerCustomArmorDamageEvent(Player player, ItemStack item, CustomArmor cArmor, DamageCause damageCause, short durability) {
22 | super(player, item, durability, cArmor);
23 | setDamageCause(damageCause);
24 | }
25 |
26 | public PlayerCustomArmorDamageEvent(Player player, ItemStack item, CustomArmor cArmor, DamageCause damageCause, float damage, boolean hadThorns) {
27 | this(player, item, cArmor, damageCause, (short) cArmor.getDurabilityMechanics().getArmorDamage(damageCause, damage, hadThorns));
28 | }
29 |
30 | public PlayerCustomArmorDamageEvent(Player player, ItemStack item, CustomArmor cArmor, boolean usedThorns) {
31 | this(player, item, cArmor, DamageCause.THORNS, (short) cArmor.getDurabilityMechanics().getThornsExtraDamageOnHit());
32 | }
33 |
34 | /**
35 | * @return the damageCause
36 | */
37 | public DamageCause getDamageCause() {
38 | return damageCause;
39 | }
40 |
41 | /**
42 | * @param damageCause
43 | * the damageCause to set
44 | */
45 | public PlayerCustomArmorDamageEvent setDamageCause(DamageCause damageCause) {
46 | this.damageCause = damageCause;
47 | return this;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/bow/ArrowFromCustomBowHitEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events.bow;
2 |
3 | import org.bukkit.entity.LivingEntity;
4 | import org.bukkit.event.entity.ProjectileHitEvent;
5 |
6 | import com.chrismin13.additionsapi.items.CustomItemStack;
7 |
8 | public class ArrowFromCustomBowHitEvent extends CustomBowStackEvent {
9 |
10 | private ProjectileHitEvent projectileHitEvent;
11 | private LivingEntity shooter;
12 |
13 | public ArrowFromCustomBowHitEvent(ProjectileHitEvent event, LivingEntity shooter, CustomItemStack cBowStack) {
14 | super(cBowStack);
15 | this.projectileHitEvent = event;
16 | this.shooter = shooter;
17 | }
18 |
19 | /**
20 | * @return the projectileHitEvent
21 | */
22 | public ProjectileHitEvent getProjectileHitEvent() {
23 | return projectileHitEvent;
24 | }
25 |
26 | /**
27 | * @param projectileHitEvent the projectileHitEvent to set
28 | */
29 | public ArrowFromCustomBowHitEvent setProjectileHitEvent(ProjectileHitEvent projectileHitEvent) {
30 | this.projectileHitEvent = projectileHitEvent;
31 | return this;
32 | }
33 |
34 | /**
35 | * @return the shooter
36 | */
37 | public LivingEntity getShooter() {
38 | return shooter;
39 | }
40 |
41 | /**
42 | * @param shooter the shooter to set
43 | */
44 | public ArrowFromCustomBowHitEvent setShooter(LivingEntity shooter) {
45 | this.shooter = shooter;
46 | return this;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/bow/CustomBowEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events.bow;
2 |
3 | import org.bukkit.event.Event;
4 | import org.bukkit.event.HandlerList;
5 |
6 | import com.chrismin13.additionsapi.items.CustomBow;
7 |
8 | public class CustomBowEvent extends Event {
9 |
10 | private CustomBow cBow;
11 | private static final HandlerList handlers = new HandlerList();
12 |
13 | public CustomBowEvent(CustomBow cBow) {
14 | this.cBow = cBow;
15 | }
16 |
17 | public CustomBow getCustomBow() {
18 | return cBow;
19 | }
20 |
21 | @Override
22 | public HandlerList getHandlers() {
23 | return handlers;
24 | }
25 |
26 | public static HandlerList getHandlerList() {
27 | return handlers;
28 | }
29 |
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/bow/CustomBowStackEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events.bow;
2 |
3 | import com.chrismin13.additionsapi.items.CustomBow;
4 | import com.chrismin13.additionsapi.items.CustomItemStack;
5 | import com.chrismin13.additionsapi.utils.Debug;
6 |
7 | public class CustomBowStackEvent extends CustomBowEvent {
8 |
9 | private CustomItemStack cStack;
10 |
11 | public CustomBowStackEvent(CustomItemStack cBowStack) {
12 | super(checkStackForBow(cBowStack));
13 | this.cStack = cBowStack;
14 | }
15 |
16 | public CustomItemStack getCustomBowItemStack() {
17 | return cStack;
18 | }
19 |
20 | public static CustomBow checkStackForBow(CustomItemStack cStack) {
21 | if (cStack.getCustomItem() instanceof CustomBow)
22 | return (CustomBow) cStack.getCustomItem();
23 | else
24 | Debug.sayError(
25 | "The CustomItemStack specified for the event does not contain a Custom Bow as the Custom Item");
26 | return null;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/bow/EntityShootCustomBowEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events.bow;
2 |
3 | import org.bukkit.event.Cancellable;
4 | import org.bukkit.event.entity.EntityShootBowEvent;
5 |
6 | import com.chrismin13.additionsapi.items.CustomItemStack;
7 |
8 | public class EntityShootCustomBowEvent extends CustomBowStackEvent implements Cancellable {
9 |
10 | private EntityShootBowEvent playerFishEvent;
11 |
12 | public EntityShootCustomBowEvent(EntityShootBowEvent event, CustomItemStack cBowStack) {
13 | super(cBowStack);
14 | this.playerFishEvent = event;
15 | }
16 |
17 | public EntityShootBowEvent getEntityShootBowEvent() {
18 | return playerFishEvent;
19 | }
20 |
21 | @Override
22 | public boolean isCancelled() {
23 | return playerFishEvent.isCancelled();
24 | }
25 |
26 | @Override
27 | public void setCancelled(boolean cancel) {
28 | playerFishEvent.setCancelled(true);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/elytra/CustomElytraPlayerToggleGlideEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events.elytra;
2 |
3 | import org.bukkit.entity.Player;
4 | import org.bukkit.event.Cancellable;
5 | import org.bukkit.event.entity.EntityToggleGlideEvent;
6 |
7 | import com.chrismin13.additionsapi.events.item.CustomItemStackEvent;
8 | import com.chrismin13.additionsapi.items.CustomItemStack;
9 |
10 | public class CustomElytraPlayerToggleGlideEvent extends CustomItemStackEvent implements Cancellable {
11 |
12 | private EntityToggleGlideEvent entityToggleGlideEvent;
13 |
14 | public CustomElytraPlayerToggleGlideEvent(EntityToggleGlideEvent event, CustomItemStack cStack) {
15 | super(cStack);
16 | this.entityToggleGlideEvent = event;
17 | }
18 |
19 | public EntityToggleGlideEvent getEntityToggleGlideEvent() {
20 | return entityToggleGlideEvent;
21 | }
22 |
23 | public Player getPlayer() {
24 | return (Player) entityToggleGlideEvent.getEntity();
25 | }
26 |
27 | @Override
28 | public boolean isCancelled() {
29 | return entityToggleGlideEvent.isCancelled();
30 | }
31 |
32 | @Override
33 | public void setCancelled(boolean cancel) {
34 | entityToggleGlideEvent.setCancelled(true);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/item/CustomItemBlockBreakEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events.item;
2 |
3 | import org.bukkit.event.Cancellable;
4 | import org.bukkit.event.block.BlockBreakEvent;
5 |
6 | import com.chrismin13.additionsapi.items.CustomItemStack;
7 |
8 | public final class CustomItemBlockBreakEvent extends CustomItemStackEvent implements Cancellable {
9 |
10 | private BlockBreakEvent blockBreakEvent;
11 |
12 | public CustomItemBlockBreakEvent(BlockBreakEvent event, CustomItemStack cStack) {
13 | super(cStack);
14 | this.blockBreakEvent = event;
15 | }
16 |
17 | public BlockBreakEvent getBlockBreakEvent() {
18 | return blockBreakEvent;
19 | }
20 |
21 | @Override
22 | public void setCancelled(boolean cancel) {
23 | blockBreakEvent.setCancelled(cancel);
24 | }
25 |
26 | @Override
27 | public boolean isCancelled() {
28 | return blockBreakEvent.isCancelled();
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/item/CustomItemBlockIgniteEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events.item;
2 |
3 | import org.bukkit.event.Cancellable;
4 | import org.bukkit.event.block.BlockIgniteEvent;
5 |
6 | import com.chrismin13.additionsapi.items.CustomItemStack;
7 |
8 | public class CustomItemBlockIgniteEvent extends CustomItemStackEvent implements Cancellable {
9 |
10 | private BlockIgniteEvent blockIgniteEvent;
11 |
12 | public CustomItemBlockIgniteEvent(BlockIgniteEvent event, CustomItemStack cStack) {
13 | super(cStack);
14 | this.blockIgniteEvent = event;
15 | }
16 |
17 | public BlockIgniteEvent getBlockIgniteEvent() {
18 | return blockIgniteEvent;
19 | }
20 |
21 | @Override
22 | public boolean isCancelled() {
23 | return blockIgniteEvent.isCancelled();
24 | }
25 |
26 | @Override
27 | public void setCancelled(boolean cancel) {
28 | blockIgniteEvent.setCancelled(true);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/item/CustomItemEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events.item;
2 |
3 | import org.bukkit.event.Event;
4 | import org.bukkit.event.HandlerList;
5 |
6 | import com.chrismin13.additionsapi.items.CustomItem;
7 |
8 | public class CustomItemEvent extends Event {
9 |
10 | private CustomItem cItem;
11 | private static final HandlerList handlers = new HandlerList();
12 |
13 | public CustomItemEvent(CustomItem cItem) {
14 | this.cItem = cItem;
15 | }
16 |
17 | public CustomItem getCustomItem() {
18 | return cItem;
19 | }
20 |
21 | @Override
22 | public HandlerList getHandlers() {
23 | return handlers;
24 | }
25 |
26 | public static HandlerList getHandlerList() {
27 | return handlers;
28 | }
29 |
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/item/CustomItemFishEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events.item;
2 |
3 | import org.bukkit.event.Cancellable;
4 | import org.bukkit.event.player.PlayerFishEvent;
5 |
6 | import com.chrismin13.additionsapi.items.CustomItemStack;
7 |
8 | public class CustomItemFishEvent extends CustomItemStackEvent implements Cancellable {
9 |
10 | private PlayerFishEvent playerFishEvent;
11 |
12 | public CustomItemFishEvent(PlayerFishEvent event, CustomItemStack cStack) {
13 | super(cStack);
14 | this.playerFishEvent = event;
15 | }
16 |
17 | public PlayerFishEvent getPlayerFishEvent() {
18 | return playerFishEvent;
19 | }
20 |
21 | @Override
22 | public boolean isCancelled() {
23 | return playerFishEvent.isCancelled();
24 | }
25 |
26 | @Override
27 | public void setCancelled(boolean cancel) {
28 | playerFishEvent.setCancelled(true);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/item/CustomItemFurnaceBurnEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events.item;
2 |
3 | import org.bukkit.event.Cancellable;
4 | import org.bukkit.event.inventory.FurnaceBurnEvent;
5 |
6 | import com.chrismin13.additionsapi.items.CustomItemStack;
7 |
8 | public class CustomItemFurnaceBurnEvent extends CustomItemStackEvent implements Cancellable {
9 |
10 | private FurnaceBurnEvent event;
11 |
12 | public CustomItemFurnaceBurnEvent(FurnaceBurnEvent event, CustomItemStack cStack) {
13 | super(cStack);
14 | this.setFurnaceBurnEvent(event);
15 | }
16 |
17 | /**
18 | * @return the event
19 | */
20 | public FurnaceBurnEvent getFurnaceBurnEvent() {
21 | return event;
22 | }
23 |
24 | /**
25 | * @param event
26 | * the event to set
27 | */
28 | public void setFurnaceBurnEvent(FurnaceBurnEvent event) {
29 | this.event = event;
30 | }
31 |
32 | @Override
33 | public boolean isCancelled() {
34 | return event.isCancelled();
35 | }
36 |
37 | @Override
38 | public void setCancelled(boolean cancel) {
39 | event.setCancelled(cancel);
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/item/CustomItemPlayerInteractEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events.item;
2 |
3 | import org.bukkit.event.Cancellable;
4 | import org.bukkit.event.player.PlayerInteractEvent;
5 |
6 | import com.chrismin13.additionsapi.items.CustomItemStack;
7 |
8 | public class CustomItemPlayerInteractEvent extends CustomItemStackEvent implements Cancellable {
9 |
10 | private PlayerInteractEvent playerInteractEvent;
11 |
12 | public CustomItemPlayerInteractEvent(PlayerInteractEvent event, CustomItemStack cStack) {
13 | super(cStack);
14 | this.playerInteractEvent = event;
15 | }
16 |
17 | public PlayerInteractEvent getPlayerInteractEvent() {
18 | return playerInteractEvent;
19 | }
20 |
21 | @Override
22 | public boolean isCancelled() {
23 | return playerInteractEvent.isCancelled();
24 | }
25 |
26 | @Override
27 | public void setCancelled(boolean cancel) {
28 | playerInteractEvent.setCancelled(cancel);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/item/CustomItemShearEntityEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events.item;
2 |
3 | import org.bukkit.event.Cancellable;
4 | import org.bukkit.event.player.PlayerShearEntityEvent;
5 |
6 | import com.chrismin13.additionsapi.items.CustomItemStack;
7 |
8 | public class CustomItemShearEntityEvent extends CustomItemStackEvent implements Cancellable {
9 |
10 | private PlayerShearEntityEvent playerShearEntityEvent;
11 |
12 | public CustomItemShearEntityEvent(PlayerShearEntityEvent event, CustomItemStack cStack) {
13 | super(cStack);
14 | this.playerShearEntityEvent = event;
15 | }
16 |
17 | public PlayerShearEntityEvent getPlayerShearEntityEvent() {
18 | return playerShearEntityEvent;
19 | }
20 |
21 | @Override
22 | public boolean isCancelled() {
23 | return playerShearEntityEvent.isCancelled();
24 | }
25 |
26 | @Override
27 | public void setCancelled(boolean cancel) {
28 | playerShearEntityEvent.setCancelled(true);
29 | }
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/item/CustomItemStackEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events.item;
2 |
3 | import com.chrismin13.additionsapi.items.CustomItemStack;
4 |
5 | public class CustomItemStackEvent extends CustomItemEvent {
6 |
7 | private CustomItemStack cStack;
8 |
9 | public CustomItemStackEvent(CustomItemStack cStack) {
10 | super(cStack.getCustomItem());
11 | this.cStack = cStack;
12 | }
13 |
14 | public CustomItemStack getCustomItemStack() {
15 | return cStack;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/item/EntityDamageByPlayerUsingCustomItemEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events.item;
2 |
3 | import org.bukkit.entity.Player;
4 | import org.bukkit.event.Cancellable;
5 | import org.bukkit.event.entity.EntityDamageByEntityEvent;
6 |
7 | import com.chrismin13.additionsapi.items.CustomItemStack;
8 |
9 | public class EntityDamageByPlayerUsingCustomItemEvent extends CustomItemStackEvent implements Cancellable {
10 |
11 | private EntityDamageByEntityEvent entityDamageByEntityEvent;
12 |
13 | public EntityDamageByPlayerUsingCustomItemEvent(EntityDamageByEntityEvent event, CustomItemStack cStack) {
14 | super(cStack);
15 | this.entityDamageByEntityEvent = event;
16 | }
17 |
18 | public EntityDamageByEntityEvent getEntityDamageByEntityEvent() {
19 | return entityDamageByEntityEvent;
20 | }
21 |
22 | public Player getPlayer() {
23 | return (Player) entityDamageByEntityEvent.getDamager();
24 | }
25 |
26 | @Override
27 | public boolean isCancelled() {
28 | return entityDamageByEntityEvent.isCancelled();
29 | }
30 |
31 | @Override
32 | public void setCancelled(boolean cancel) {
33 | entityDamageByEntityEvent.setCancelled(true);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/item/PlayerCustomItemBreakEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events.item;
2 |
3 | import org.bukkit.entity.Player;
4 | import org.bukkit.event.player.PlayerItemBreakEvent;
5 | import org.bukkit.inventory.ItemStack;
6 |
7 | import com.chrismin13.additionsapi.items.CustomItem;
8 |
9 | public class PlayerCustomItemBreakEvent extends PlayerItemBreakEvent {
10 |
11 | private CustomItem cItem;
12 |
13 | public PlayerCustomItemBreakEvent(Player player, ItemStack brokenItem, CustomItem cItem) {
14 | super(player, brokenItem);
15 | this.cItem = cItem;
16 | }
17 |
18 | public CustomItem getCustomItem() {
19 | return cItem;
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/item/PlayerCustomItemDamageEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events.item;
2 |
3 | import org.bukkit.entity.Player;
4 | import org.bukkit.event.player.PlayerItemDamageEvent;
5 | import org.bukkit.inventory.ItemStack;
6 |
7 | import com.chrismin13.additionsapi.items.CustomItem;
8 |
9 | public class PlayerCustomItemDamageEvent extends PlayerItemDamageEvent {
10 |
11 | private CustomItem cItem;
12 |
13 | public PlayerCustomItemDamageEvent(PlayerItemDamageEvent event, CustomItem cItem) {
14 | super(event.getPlayer(), event.getItem(), event.getDamage());
15 | if (cItem.isUnbreakable()) {
16 | this.setDamage(0);
17 | }
18 | this.setCancelled(event.isCancelled());
19 | this.cItem = cItem;
20 | }
21 |
22 | public PlayerCustomItemDamageEvent(Player player, ItemStack what, int damage, CustomItem cItem) {
23 | super(player, what, damage);
24 | this.cItem = cItem;
25 | }
26 |
27 | public CustomItem getCustomItem() {
28 | return cItem;
29 | }
30 |
31 | public PlayerCustomItemDamageEvent setCustomItem(CustomItem cItem) {
32 | this.cItem = cItem;
33 | return this;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/item/PlayerDropCustomItemEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events.item;
2 |
3 | import org.bukkit.entity.Player;
4 | import org.bukkit.event.Cancellable;
5 | import org.bukkit.event.player.PlayerDropItemEvent;
6 |
7 | import com.chrismin13.additionsapi.items.CustomItemStack;
8 |
9 | public class PlayerDropCustomItemEvent extends CustomItemStackEvent implements Cancellable {
10 |
11 | private PlayerDropItemEvent playerDropItemEvent;
12 |
13 | public PlayerDropCustomItemEvent(PlayerDropItemEvent event, CustomItemStack cStack) {
14 | super(cStack);
15 | this.playerDropItemEvent = event;
16 | }
17 |
18 | public PlayerDropItemEvent getPlayerDropItemEvent() {
19 | return playerDropItemEvent;
20 | }
21 |
22 | public Player getPlayer() {
23 | return playerDropItemEvent.getPlayer();
24 | }
25 |
26 | @Override
27 | public boolean isCancelled() {
28 | return playerDropItemEvent.isCancelled();
29 | }
30 |
31 | @Override
32 | public void setCancelled(boolean cancel) {
33 | playerDropItemEvent.setCancelled(true);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/item/PlayerPickupCustomItemEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events.item;
2 |
3 | import org.bukkit.entity.Player;
4 | import org.bukkit.event.Cancellable;
5 | import org.bukkit.event.player.PlayerPickupItemEvent;
6 |
7 | import com.chrismin13.additionsapi.items.CustomItemStack;
8 |
9 | public class PlayerPickupCustomItemEvent extends CustomItemStackEvent implements Cancellable {
10 |
11 | private PlayerPickupItemEvent playerPickupItemEvent;
12 |
13 | public PlayerPickupCustomItemEvent(PlayerPickupItemEvent event, CustomItemStack cStack) {
14 | super(cStack);
15 | this.playerPickupItemEvent = event;
16 | }
17 |
18 | public PlayerPickupItemEvent getPlayerPickupItemEvent() {
19 | return playerPickupItemEvent;
20 | }
21 |
22 | public Player getPlayer() {
23 | return playerPickupItemEvent.getPlayer();
24 | }
25 |
26 | @Override
27 | public boolean isCancelled() {
28 | return playerPickupItemEvent.isCancelled();
29 | }
30 |
31 | @Override
32 | public void setCancelled(boolean cancel) {
33 | playerPickupItemEvent.setCancelled(true);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/events/shield/CustomShieldPlayerDamageByEntityEvent.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.events.shield;
2 |
3 | import org.bukkit.event.Cancellable;
4 | import org.bukkit.event.entity.EntityDamageByEntityEvent;
5 |
6 | import com.chrismin13.additionsapi.events.item.CustomItemStackEvent;
7 | import com.chrismin13.additionsapi.items.CustomItemStack;
8 |
9 | public class CustomShieldPlayerDamageByEntityEvent extends CustomItemStackEvent implements Cancellable {
10 |
11 | private EntityDamageByEntityEvent entityDamageByEntityEvent;
12 |
13 | public CustomShieldPlayerDamageByEntityEvent(EntityDamageByEntityEvent event, CustomItemStack cStack) {
14 | super(cStack);
15 | this.entityDamageByEntityEvent = event;
16 | }
17 |
18 | public EntityDamageByEntityEvent getEntityDamageByEntityEvent() {
19 | return entityDamageByEntityEvent;
20 | }
21 |
22 | @Override
23 | public boolean isCancelled() {
24 | return entityDamageByEntityEvent.isCancelled();
25 | }
26 |
27 | @Override
28 | public void setCancelled(boolean cancel) {
29 | entityDamageByEntityEvent.setCancelled(true);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/files/BossBarConfig.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.files;
2 |
3 | import com.chrismin13.additionsapi.items.CustomItem;
4 |
5 | /**
6 | * Holds the values of the config.yml's sub-section specifying the BossBar(s)'s
7 | * behavior in regards to if and how it will display durability values.
8 | *
9 | * @author chris
10 | *
11 | */
12 | public class BossBarConfig {
13 |
14 | /**
15 | * Create an instance of this Class.
16 | *
17 | * @param show
18 | * Whether the BossBar(s) will be displayed or not.
19 | * @param vanillaItems
20 | * Whether durability for the Damageable Items already in the
21 | * game will be displayed in the BossBar(s).
22 | * @param customItems
23 | * Whether durability for the {@link CustomItem}s will be
24 | * displayed in the BossBar(s).
25 | */
26 | public BossBarConfig(boolean show, boolean vanillaItems, boolean customItems) {
27 | this.show = show;
28 | this.vanillaItems = vanillaItems;
29 | this.customItems = customItems;
30 | }
31 |
32 | private boolean show;
33 | private boolean vanillaItems;
34 | private boolean customItems;
35 |
36 | /**
37 | * @return Whether the BossBar(s) will be displayed or not.
38 | */
39 | public boolean show() {
40 | return show;
41 | }
42 |
43 | /**
44 | * @return Whether durability for the Damageable Items already in the game
45 | * will be displayed in the BossBar(s).
46 | */
47 | public boolean showVanillaItems() {
48 | return vanillaItems;
49 | }
50 |
51 | /**
52 | * @return Whether durability for the {@link CustomItem}s will be displayed
53 | * in the BossBar(s).
54 | */
55 | public boolean showCustomItems() {
56 | return customItems;
57 | }
58 | }
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/files/PermissionConfig.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.files;
2 |
3 | import com.chrismin13.additionsapi.permissions.PermissionType;
4 |
5 | /**
6 | * Holds the values of the config.yml's sub-section specifying the Permission
7 | * System's different aspects.
8 | *
9 | * @author chris
10 | *
11 | */
12 | public class PermissionConfig {
13 |
14 | /**
15 | * Create an instance of this Class.
16 | *
17 | * @param defaultType
18 | * The default Permission Type that will be used. Refer to the
19 | * plugin page for more info on how Permissions work.
20 | */
21 | public PermissionConfig(PermissionType defaultType) {
22 | this.defaultType = defaultType;
23 | }
24 |
25 | private PermissionType defaultType;
26 |
27 | /**
28 | * @return Which permission type is the default.
29 | */
30 | public PermissionType getDefaultType() {
31 | return defaultType;
32 | }
33 | }
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/items/CustomBow.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.items;
2 |
3 | import org.bukkit.Material;
4 |
5 | import com.chrismin13.additionsapi.durability.BowDurability;
6 | import com.chrismin13.additionsapi.durability.ItemDurability;
7 | import com.chrismin13.additionsapi.items.textured.CustomTexturedBow;
8 |
9 | /**
10 | * A Custom Bow. No special stuff at the moment. Mostly used for
11 | * {@link CustomTexturedBow}
12 | *
13 | * @author chrismin13
14 | *
15 | */
16 | public class CustomBow extends CustomItem {
17 |
18 | /**
19 | * Creates a Custom Bow.
20 | *
21 | * @param amount
22 | * The amount that the Custom Bow will have. Recommended value is
23 | * one as bows do not have a stackable size higher than 1 by
24 | * default.
25 | * @param durability
26 | * The durability of the Custom Bow.
27 | * @param idName
28 | * the Custom Bow's ID Name. This MUST BE SIMILAR to
29 | * "vanilla_additions:emerald_sword" and is saved in the
30 | * ItemStack so you can easily detect which Custom Bow it is.
31 | * @param itemDurability
32 | * The Bow's Item Durability. Recommended class is
33 | * {@link BowDurability}
34 | */
35 | public CustomBow(int amount, short durability, String idName, ItemDurability itemDurability) {
36 | super(Material.BOW, amount, durability, idName, itemDurability);
37 | }
38 |
39 | /**
40 | * Creates a Custom Bow.
41 | *
42 | * @param amount
43 | * The amount that the Custom Bow will have. Recommended value is
44 | * one as bows do not have a stackable size higher than 1 by
45 | * default.
46 | * @param durability
47 | * The durability of the Custom Bow.
48 | * @param idName
49 | * the Custom Bow's ID Name. This MUST BE SIMILAR to
50 | * "vanilla_additions:emerald_sword" and is saved in the
51 | * ItemStack so you can easily detect which Custom Bow it is.
52 | */
53 | public CustomBow(int amount, short durability, String idName) {
54 | super(Material.BOW, amount, durability, idName);
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/items/CustomLeatherArmor.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.items;
2 |
3 | import org.bukkit.Color;
4 |
5 | import com.chrismin13.additionsapi.enums.ArmorType;
6 |
7 | /**
8 | * A Custom Armor that is made of a leather armor material. Includes
9 | * modifications for the Color of the Leather Armor.
10 | *
11 | * @author chrismin13
12 | *
13 | */
14 | public class CustomLeatherArmor extends CustomArmor {
15 |
16 | // === VARIABLES === //
17 |
18 | private Color color;
19 |
20 | // ================= //
21 |
22 | // === CREATING THE ARMOR === //
23 |
24 | /**
25 | * Creates a Custom Leather Armor piece.
26 | *
27 | * @param armorType
28 | * The type of the Leather Armor. This will automatically set the
29 | * Material using {@link ArmorType#getLeatherMaterial()}.
30 | * @param amount
31 | * The amount of the Leather Armor. Recommended value is one, as
32 | * Armor Pieces do not have a stackable size higher than 1 by
33 | * default.
34 | * @param durability
35 | * The durability of the Leather Armor.
36 | * @param idName
37 | * the Custom Armor's ID Name. This MUST BE SIMILAR to
38 | * "vanilla_additions:emerald_sword" and is saved in the
39 | * ItemStack so you can easily detect which Custom Armor it is.
40 | * @param color
41 | * The color that the leather armor will have.
42 | */
43 | public CustomLeatherArmor(ArmorType armorType, int amount, short durability, String idName, Color color) {
44 | super(armorType.getLeatherMaterial(), amount, durability, idName);
45 | this.color = color;
46 | }
47 |
48 | // === COLOR === //
49 |
50 | /**
51 | * @return The Color that the leather armor will have.
52 | */
53 | public Color getColor() {
54 | return color;
55 | }
56 |
57 | /**
58 | * Set the CustomLeatherArmor's Color.
59 | *
60 | * @param color
61 | * the color to set. Use {@link Color#fromRGB(int, int, int)} to
62 | * find it easily using RGB values.
63 | */
64 | public CustomLeatherArmor setColor(Color color) {
65 | this.color = color;
66 | return this;
67 | }
68 | }
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/items/CustomPlayerSkull.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.items;
2 |
3 | public class CustomPlayerSkull {
4 |
5 | }
6 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/custom/ArmorEquip.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.custom;
2 |
3 | import org.bukkit.event.EventHandler;
4 | import org.bukkit.event.EventPriority;
5 | import org.bukkit.event.Listener;
6 | import org.bukkit.inventory.ItemStack;
7 |
8 | import com.chrismin13.additionsapi.AdditionsAPI;
9 | import com.chrismin13.additionsapi.items.CustomItem;
10 | import com.chrismin13.additionsapi.items.CustomItemStack;
11 | import com.chrismin13.additionsapi.permissions.ArmorPermissions;
12 | import com.chrismin13.additionsapi.utils.PermissionUtils;
13 | import com.codingforcookies.armorequip.ArmorEquipEvent;
14 |
15 | public class ArmorEquip implements Listener {
16 |
17 | @EventHandler(priority = EventPriority.LOWEST)
18 | public void onArmorEquip(ArmorEquipEvent event) {
19 | if (event.isCancelled())
20 | return;
21 |
22 | if (event.getNewArmorPiece() == null)
23 | return;
24 | ItemStack item = event.getNewArmorPiece();
25 |
26 | if (!AdditionsAPI.isCustomItem(item))
27 | return;
28 | CustomItemStack cStack = new CustomItemStack(item);
29 | CustomItem cItem = cStack.getCustomItem();
30 |
31 | if (!(cItem.getPermissions() instanceof ArmorPermissions))
32 | return;
33 | ArmorPermissions perm = (ArmorPermissions) cItem.getPermissions();
34 |
35 | if (!PermissionUtils.allowedAction(event.getPlayer(), perm.getType(), perm.getWear()))
36 | event.setCancelled(true);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/custom/ArrowFromCustomBowHit.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.custom;
2 |
3 | import java.util.HashMap;
4 |
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.entity.Entity;
7 | import org.bukkit.entity.LivingEntity;
8 | import org.bukkit.event.EventHandler;
9 | import org.bukkit.event.EventPriority;
10 | import org.bukkit.event.Listener;
11 |
12 | import com.chrismin13.additionsapi.AdditionsAPI;
13 | import com.chrismin13.additionsapi.events.bow.ArrowFromCustomBowHitEvent;
14 | import com.chrismin13.additionsapi.items.CustomItemStack;
15 | import com.chrismin13.additionsapi.utils.BowStackContainer;
16 |
17 | public class ArrowFromCustomBowHit implements Listener {
18 |
19 | private static HashMap arrowsShotFromCustomBow = new HashMap();
20 |
21 | public static void addArrow(Entity entity, CustomItemStack cBowStack, LivingEntity owner) {
22 | arrowsShotFromCustomBow.put(entity, new BowStackContainer(cBowStack, owner));
23 | }
24 |
25 | public static boolean containsArrow(Entity arrow) {
26 | return arrowsShotFromCustomBow.containsKey(arrow);
27 | }
28 |
29 | public static BowStackContainer getBowStackContainer(Entity arrow) {
30 | return arrowsShotFromCustomBow.get(arrow);
31 | }
32 |
33 | public static void removeArrow(Entity arrow) {
34 | arrowsShotFromCustomBow.remove(arrow);
35 | }
36 |
37 | @EventHandler(priority = EventPriority.MONITOR)
38 | public void onArrowFromCustomBowHit(ArrowFromCustomBowHitEvent event) {
39 | Bukkit.getScheduler().runTask(AdditionsAPI.getInstance(), () -> removeArrow(event.getProjectileHitEvent().getEntity()));
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/custom/CustomElytraPlayerToggleGlide.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.custom;
2 |
3 | import java.util.HashMap;
4 | import java.util.UUID;
5 |
6 | import org.bukkit.Bukkit;
7 | import org.bukkit.entity.EntityType;
8 | import org.bukkit.entity.Player;
9 | import org.bukkit.event.EventHandler;
10 | import org.bukkit.event.EventPriority;
11 | import org.bukkit.event.Listener;
12 | import org.bukkit.event.entity.EntityToggleGlideEvent;
13 |
14 | import com.chrismin13.additionsapi.AdditionsAPI;
15 | import com.chrismin13.additionsapi.durability.ElytraDurability;
16 | import com.chrismin13.additionsapi.events.elytra.CustomElytraPlayerToggleGlideEvent;
17 | import com.chrismin13.additionsapi.items.CustomItem;
18 | import com.chrismin13.additionsapi.permissions.ElytraPermissions;
19 | import com.chrismin13.additionsapi.utils.ElytraDurabilityTask;
20 | import com.chrismin13.additionsapi.utils.PermissionUtils;
21 |
22 | public class CustomElytraPlayerToggleGlide implements Listener {
23 |
24 | private static HashMap playersGliding = new HashMap();
25 |
26 | @EventHandler(priority = EventPriority.MONITOR)
27 | public void onCustomElytraPlayerGlide(CustomElytraPlayerToggleGlideEvent customEvent) {
28 | if (customEvent.isCancelled())
29 | return;
30 | CustomItem cItem = customEvent.getCustomItem();
31 | Player player = customEvent.getPlayer();
32 | UUID playerUUID = player.getUniqueId();
33 | if (cItem.getDurabilityMechanics() instanceof ElytraDurability) {
34 | cancelPlayerGlideDamage(playerUUID);
35 | ElytraDurabilityTask task = new ElytraDurabilityTask(player,
36 | customEvent.getCustomItemStack().getItemStack(), cItem);
37 | task.runTaskTimer(AdditionsAPI.getInstance(), 0L, 20L);
38 | playersGliding.put(playerUUID, task.getTaskId());
39 | }
40 | }
41 |
42 | @EventHandler(priority = EventPriority.LOWEST)
43 | public void onCustomElytraPlayerGlideLowest(CustomElytraPlayerToggleGlideEvent customEvent) {
44 | if (customEvent.isCancelled())
45 | return;
46 |
47 | CustomItem cItem = customEvent.getCustomItem();
48 |
49 | if (!(cItem.getPermissions() instanceof ElytraPermissions))
50 | return;
51 | ElytraPermissions perm = (ElytraPermissions) cItem.getPermissions();
52 |
53 | EntityToggleGlideEvent event = customEvent.getEntityToggleGlideEvent();
54 |
55 | if (event.getEntity().getType().equals(EntityType.PLAYER)
56 | && !PermissionUtils.allowedAction((Player) event.getEntity(), perm.getType(), perm.getFlight()))
57 | event.setCancelled(true);
58 | }
59 |
60 | public static void cancelPlayerGlideDamage(UUID playerUUID) {
61 | if (playersGliding.containsKey(playerUUID)) {
62 | Bukkit.getScheduler().cancelTask(playersGliding.get(playerUUID));
63 | playersGliding.remove(playerUUID);
64 | }
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/custom/CustomItemBlockBreak.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.custom;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.Material;
5 | import org.bukkit.block.Block;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.event.EventHandler;
8 | import org.bukkit.event.EventPriority;
9 | import org.bukkit.event.Listener;
10 | import org.bukkit.event.block.BlockBreakEvent;
11 | import org.bukkit.inventory.ItemStack;
12 |
13 | import com.chrismin13.additionsapi.durability.ItemDurability;
14 | import com.chrismin13.additionsapi.events.item.CustomItemBlockBreakEvent;
15 | import com.chrismin13.additionsapi.events.item.PlayerCustomItemDamageEvent;
16 | import com.chrismin13.additionsapi.items.CustomItem;
17 | import com.chrismin13.additionsapi.permissions.ItemPermissions;
18 | import com.chrismin13.additionsapi.utils.MaterialUtils;
19 | import com.chrismin13.additionsapi.utils.PermissionUtils;
20 |
21 | public class CustomItemBlockBreak implements Listener {
22 |
23 | @EventHandler(priority = EventPriority.MONITOR)
24 | public void onCustomItemBlockBreak(CustomItemBlockBreakEvent event) {
25 | if (event.isCancelled())
26 | return;
27 | BlockBreakEvent breakEvent = event.getBlockBreakEvent();
28 | Player player = breakEvent.getPlayer();
29 | Block block = breakEvent.getBlock();
30 | Material material = block.getType();
31 | CustomItem cItem = event.getCustomItem();
32 | ItemStack item = event.getCustomItemStack().getItemStack();
33 | boolean instantlyBreakable = MaterialUtils.isInstantlyBreakable(material);
34 | PlayerCustomItemDamageEvent damageEvent = new PlayerCustomItemDamageEvent(player, item, 0, cItem);
35 | ItemDurability mechanics = cItem.getDurabilityMechanics();
36 |
37 | if (instantlyBreakable) {
38 | damageEvent.setDamage(mechanics.getInstantBlockBreak());
39 | } else {
40 | damageEvent.setDamage(mechanics.getBlockBreak());
41 | }
42 |
43 | if (mechanics.getSpecialBlockDurability(material) != null) {
44 | damageEvent.setDamage(mechanics.getSpecialBlockDurability(material));
45 | }
46 |
47 | if (damageEvent.getDamage() != 0)
48 | Bukkit.getServer().getPluginManager().callEvent(damageEvent);
49 | }
50 |
51 | @EventHandler(priority = EventPriority.LOWEST)
52 | public void onCustomItemBlockBreakLowest(CustomItemBlockBreakEvent customEvent) {
53 | if (customEvent.isCancelled())
54 | return;
55 |
56 | CustomItem cItem = customEvent.getCustomItem();
57 | ItemPermissions perm = cItem.getPermissions();
58 |
59 | BlockBreakEvent event = customEvent.getBlockBreakEvent();
60 | if (!PermissionUtils.allowedAction(event.getPlayer(), perm.getType(), perm.getBreak()))
61 | event.setCancelled(true);
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/custom/CustomItemBlockIgnite.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.custom;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.entity.Player;
5 | import org.bukkit.event.EventHandler;
6 | import org.bukkit.event.EventPriority;
7 | import org.bukkit.event.Listener;
8 | import org.bukkit.event.block.BlockIgniteEvent;
9 | import org.bukkit.inventory.ItemStack;
10 |
11 | import com.chrismin13.additionsapi.durability.FlintAndSteelDurability;
12 | import com.chrismin13.additionsapi.durability.ItemDurability;
13 | import com.chrismin13.additionsapi.events.item.CustomItemBlockIgniteEvent;
14 | import com.chrismin13.additionsapi.events.item.PlayerCustomItemDamageEvent;
15 | import com.chrismin13.additionsapi.items.CustomItem;
16 | import com.chrismin13.additionsapi.permissions.FlintAndSteelPermissions;
17 | import com.chrismin13.additionsapi.utils.PermissionUtils;
18 |
19 | public class CustomItemBlockIgnite implements Listener {
20 |
21 | @EventHandler(priority = EventPriority.MONITOR)
22 | public void onCustomItemBlockIgnite(CustomItemBlockIgniteEvent customEvent) {
23 | if (customEvent.isCancelled())
24 | return;
25 | CustomItem cItem = customEvent.getCustomItem();
26 | BlockIgniteEvent event = customEvent.getBlockIgniteEvent();
27 | Player player = event.getPlayer();
28 | ItemDurability mechanics = cItem.getDurabilityMechanics();
29 | if (mechanics instanceof FlintAndSteelDurability) {
30 | ItemStack item = customEvent.getCustomItemStack().getItemStack();
31 | FlintAndSteelDurability fsMechanics = (FlintAndSteelDurability) cItem.getDurabilityMechanics();
32 | Bukkit.getServer().getPluginManager().callEvent(new PlayerCustomItemDamageEvent(player, item, fsMechanics.getFire(), cItem));
33 | }
34 | }
35 |
36 | @EventHandler(priority = EventPriority.LOWEST)
37 | public void onCustomItemBlockIgniteLowest(CustomItemBlockIgniteEvent customEvent) {
38 | if (customEvent.isCancelled())
39 | return;
40 |
41 | CustomItem cItem = customEvent.getCustomItem();
42 |
43 | if (!(cItem.getPermissions() instanceof FlintAndSteelPermissions))
44 | return;
45 | FlintAndSteelPermissions perm = (FlintAndSteelPermissions) cItem.getPermissions();
46 |
47 | BlockIgniteEvent event = customEvent.getBlockIgniteEvent();
48 |
49 | if (!PermissionUtils.allowedAction(event.getPlayer(), perm.getType(), perm.getFire()))
50 | event.setCancelled(true);
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/custom/CustomItemFish.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.custom;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.entity.EntityType;
5 | import org.bukkit.entity.Player;
6 | import org.bukkit.event.EventHandler;
7 | import org.bukkit.event.EventPriority;
8 | import org.bukkit.event.Listener;
9 | import org.bukkit.event.player.PlayerFishEvent;
10 | import org.bukkit.event.player.PlayerFishEvent.State;
11 | import org.bukkit.inventory.ItemStack;
12 |
13 | import com.chrismin13.additionsapi.durability.FishingRodDurability;
14 | import com.chrismin13.additionsapi.events.item.CustomItemFishEvent;
15 | import com.chrismin13.additionsapi.events.item.PlayerCustomItemDamageEvent;
16 | import com.chrismin13.additionsapi.items.CustomItem;
17 | import com.chrismin13.additionsapi.permissions.FishingRodPermissions;
18 | import com.chrismin13.additionsapi.utils.PermissionUtils;
19 |
20 | public class CustomItemFish implements Listener {
21 |
22 | @EventHandler(priority = EventPriority.MONITOR)
23 | public void onCustomItemFish(CustomItemFishEvent customEvent) {
24 | if (customEvent.isCancelled())
25 | return;
26 | CustomItem cItem = customEvent.getCustomItem();
27 | PlayerFishEvent event = customEvent.getPlayerFishEvent();
28 | Player player = event.getPlayer();
29 | if (cItem.getDurabilityMechanics() instanceof FishingRodDurability) {
30 | ItemStack item = customEvent.getCustomItemStack().getItemStack();
31 | State state = event.getState();
32 | FishingRodDurability mechanics = (FishingRodDurability) cItem.getDurabilityMechanics();
33 | PlayerCustomItemDamageEvent damageEvent = new PlayerCustomItemDamageEvent(player, item, 0, cItem);
34 |
35 | switch (state) {
36 | case CAUGHT_ENTITY:
37 | if (event.getCaught().getType() == EntityType.DROPPED_ITEM) {
38 | damageEvent.setDamage(mechanics.getItemReel());
39 | } else {
40 | damageEvent.setDamage(mechanics.getEntityReel());
41 | }
42 | break;
43 | case CAUGHT_FISH:
44 | damageEvent.setDamage(mechanics.getFishCatch());
45 | break;
46 | case IN_GROUND:
47 | damageEvent.setDamage(mechanics.getBlockReel());
48 | break;
49 | default:
50 | break;
51 | }
52 |
53 | if (damageEvent.getDamage() != 0)
54 | Bukkit.getServer().getPluginManager().callEvent(damageEvent);
55 | }
56 | }
57 |
58 | @EventHandler(priority = EventPriority.LOWEST)
59 | public void onCustomItemFishLowest(CustomItemFishEvent customEvent) {
60 | if (customEvent.isCancelled())
61 | return;
62 |
63 | CustomItem cItem = customEvent.getCustomItem();
64 |
65 | if (!(cItem.getPermissions() instanceof FishingRodPermissions))
66 | return;
67 | FishingRodPermissions perm = (FishingRodPermissions) cItem.getPermissions();
68 |
69 | PlayerFishEvent event = customEvent.getPlayerFishEvent();
70 |
71 | if (!PermissionUtils.allowedAction(event.getPlayer(), perm.getType(), perm.getReel()))
72 | event.setCancelled(true);
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/custom/CustomItemFurnaceBurn.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.custom;
2 |
3 | import org.bukkit.event.EventHandler;
4 | import org.bukkit.event.EventPriority;
5 | import org.bukkit.event.Listener;
6 |
7 | import com.chrismin13.additionsapi.events.item.CustomItemFurnaceBurnEvent;
8 | import com.chrismin13.additionsapi.items.CustomItem;
9 |
10 | public class CustomItemFurnaceBurn implements Listener {
11 |
12 | @EventHandler(priority = EventPriority.LOWEST)
13 | public void onCustomItemFurnaceBurn(CustomItemFurnaceBurnEvent event) {
14 | if (event.isCancelled())
15 | return;
16 | CustomItem cItem = event.getCustomItem();
17 | if (cItem.getBurnTime() != 0)
18 | event.getFurnaceBurnEvent().setBurnTime(cItem.getBurnTime());
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/custom/CustomItemShearEntity.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.custom;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.entity.Player;
5 | import org.bukkit.event.EventHandler;
6 | import org.bukkit.event.EventPriority;
7 | import org.bukkit.event.Listener;
8 | import org.bukkit.event.player.PlayerShearEntityEvent;
9 | import org.bukkit.inventory.ItemStack;
10 |
11 | import com.chrismin13.additionsapi.durability.ShearDurability;
12 | import com.chrismin13.additionsapi.events.item.CustomItemShearEntityEvent;
13 | import com.chrismin13.additionsapi.events.item.PlayerCustomItemDamageEvent;
14 | import com.chrismin13.additionsapi.items.CustomItem;
15 | import com.chrismin13.additionsapi.permissions.ShearPermissions;
16 | import com.chrismin13.additionsapi.utils.PermissionUtils;
17 |
18 | public class CustomItemShearEntity implements Listener {
19 |
20 | @EventHandler(priority = EventPriority.MONITOR)
21 | public void onCustomItemShearEntity(CustomItemShearEntityEvent customEvent) {
22 | if (customEvent.isCancelled())
23 | return;
24 | CustomItem cItem = customEvent.getCustomItem();
25 | PlayerShearEntityEvent event = customEvent.getPlayerShearEntityEvent();
26 | Player player = event.getPlayer();
27 | if (cItem.getDurabilityMechanics() instanceof ShearDurability) {
28 | ItemStack item = customEvent.getCustomItemStack().getItemStack();
29 | ShearDurability mechanics = (ShearDurability) cItem.getDurabilityMechanics();
30 | Bukkit.getServer().getPluginManager()
31 | .callEvent(new PlayerCustomItemDamageEvent(player, item, mechanics.getShearSheep(), cItem));
32 | }
33 | }
34 |
35 | @EventHandler(priority = EventPriority.LOWEST)
36 | public void onCustomItemShearEntityLowest(CustomItemShearEntityEvent customEvent) {
37 | if (customEvent.isCancelled())
38 | return;
39 |
40 | CustomItem cItem = customEvent.getCustomItem();
41 |
42 | if (!(cItem.getPermissions() instanceof ShearPermissions))
43 | return;
44 | ShearPermissions perm = (ShearPermissions) cItem.getPermissions();
45 |
46 | if (!PermissionUtils.allowedAction(customEvent.getPlayerShearEntityEvent().getPlayer(), perm.getType(),
47 | perm.getShear()))
48 | customEvent.setCancelled(true);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/custom/CustomShieldEntityDamageByEntity.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.custom;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.entity.Player;
5 | import org.bukkit.event.EventHandler;
6 | import org.bukkit.event.EventPriority;
7 | import org.bukkit.event.Listener;
8 | import org.bukkit.event.entity.EntityDamageByEntityEvent;
9 | import org.bukkit.inventory.ItemStack;
10 |
11 | import com.chrismin13.additionsapi.durability.ShieldDurability;
12 | import com.chrismin13.additionsapi.events.item.PlayerCustomItemDamageEvent;
13 | import com.chrismin13.additionsapi.events.shield.CustomShieldPlayerDamageByEntityEvent;
14 | import com.chrismin13.additionsapi.items.CustomItem;
15 | import com.chrismin13.additionsapi.utils.NumberUtils;
16 |
17 | public class CustomShieldEntityDamageByEntity implements Listener {
18 |
19 | @EventHandler(priority = EventPriority.MONITOR)
20 | public void onCustomShieldEntityDamageByEntity(CustomShieldPlayerDamageByEntityEvent customEvent) {
21 | if (customEvent.isCancelled())
22 | return;
23 | CustomItem cItem = customEvent.getCustomItem();
24 | EntityDamageByEntityEvent event = customEvent.getEntityDamageByEntityEvent();
25 | Player player = (Player) event.getEntity();
26 | if (cItem.getDurabilityMechanics() instanceof ShieldDurability) {
27 | ItemStack item = customEvent.getCustomItemStack().getItemStack();
28 | if (!player.isBlocking())
29 | return;
30 | ShieldDurability mechanics = (ShieldDurability) cItem.getDurabilityMechanics();
31 | Bukkit.getServer().getPluginManager()
32 | .callEvent(new PlayerCustomItemDamageEvent(player, item,
33 | NumberUtils.safeLongToInt(Math.round(event.getDamage() * mechanics.getDamageMultiplier()))
34 | + mechanics.getExtraDurabilityTaken(),
35 | cItem));
36 | }
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/custom/EntityDamageByPlayerUsingCustomItem.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.custom;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.entity.Player;
5 | import org.bukkit.event.EventHandler;
6 | import org.bukkit.event.EventPriority;
7 | import org.bukkit.event.Listener;
8 | import org.bukkit.inventory.ItemStack;
9 |
10 | import com.chrismin13.additionsapi.events.item.EntityDamageByPlayerUsingCustomItemEvent;
11 | import com.chrismin13.additionsapi.events.item.PlayerCustomItemDamageEvent;
12 | import com.chrismin13.additionsapi.items.CustomItem;
13 | import com.chrismin13.additionsapi.permissions.ItemPermissions;
14 | import com.chrismin13.additionsapi.utils.PermissionUtils;
15 |
16 | public class EntityDamageByPlayerUsingCustomItem implements Listener {
17 |
18 | @EventHandler(priority = EventPriority.MONITOR)
19 | public void onEntityDamageByCustomItem(EntityDamageByPlayerUsingCustomItemEvent event) {
20 | if (event.isCancelled())
21 | return;
22 | Player player = event.getPlayer();
23 | CustomItem cItem = event.getCustomItem();
24 | ItemStack item = event.getCustomItemStack().getItemStack();
25 | PlayerCustomItemDamageEvent damageEvent = new PlayerCustomItemDamageEvent(player, item,
26 | cItem.getDurabilityMechanics().getEntityHit(), cItem);
27 | if (damageEvent.getDamage() != 0)
28 | Bukkit.getServer().getPluginManager().callEvent(damageEvent);
29 | }
30 |
31 | @EventHandler(priority = EventPriority.LOWEST)
32 | public void onEntityDamageByCustomItemLowest(EntityDamageByPlayerUsingCustomItemEvent customEvent) {
33 | if (customEvent.isCancelled())
34 | return;
35 |
36 | CustomItem cItem = customEvent.getCustomItem();
37 | ItemPermissions perm = cItem.getPermissions();
38 |
39 | if (!PermissionUtils.allowedAction(customEvent.getPlayer(), perm.getType(), perm.getHit()))
40 | customEvent.setCancelled(true);
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/custom/EntityShootCustomBow.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.custom;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.entity.EntityType;
5 | import org.bukkit.entity.Player;
6 | import org.bukkit.event.EventHandler;
7 | import org.bukkit.event.EventPriority;
8 | import org.bukkit.event.Listener;
9 | import org.bukkit.event.entity.EntityShootBowEvent;
10 | import org.bukkit.inventory.ItemStack;
11 |
12 | import com.chrismin13.additionsapi.durability.BowDurability;
13 | import com.chrismin13.additionsapi.durability.ItemDurability;
14 | import com.chrismin13.additionsapi.events.bow.EntityShootCustomBowEvent;
15 | import com.chrismin13.additionsapi.events.item.PlayerCustomItemDamageEvent;
16 | import com.chrismin13.additionsapi.items.CustomBow;
17 | import com.chrismin13.additionsapi.items.CustomItemStack;
18 | import com.chrismin13.additionsapi.permissions.BowPermissions;
19 | import com.chrismin13.additionsapi.utils.PermissionUtils;
20 |
21 | public class EntityShootCustomBow implements Listener {
22 |
23 | @EventHandler(priority = EventPriority.MONITOR)
24 | public void onEntityShootCustomBow(EntityShootCustomBowEvent customEvent) {
25 | if (customEvent.isCancelled())
26 | return;
27 | CustomBow cBow = customEvent.getCustomBow();
28 | EntityShootBowEvent event = customEvent.getEntityShootBowEvent();
29 | ItemStack item = event.getBow();
30 | ItemDurability mechanics = cBow.getDurabilityMechanics();
31 | if (event.getEntityType() == EntityType.PLAYER && mechanics instanceof BowDurability) {
32 | Player player = (Player) event.getEntity();
33 | BowDurability bowMechanics = (BowDurability) mechanics;
34 | Bukkit.getServer().getPluginManager()
35 | .callEvent(new PlayerCustomItemDamageEvent(player, item, bowMechanics.getFireArrow(), cBow));
36 | }
37 | ArrowFromCustomBowHit.addArrow(event.getProjectile(), new CustomItemStack(item), event.getEntity());
38 | }
39 |
40 | @EventHandler(priority = EventPriority.LOWEST)
41 | public void onEntityShootCustomBowLowest(EntityShootCustomBowEvent customEvent) {
42 | if (customEvent.isCancelled())
43 | return;
44 |
45 | CustomBow cBow = customEvent.getCustomBow();
46 |
47 | if (!(cBow.getPermissions() instanceof BowPermissions))
48 | return;
49 | BowPermissions perm = (BowPermissions) cBow.getPermissions();
50 |
51 | EntityShootBowEvent event = customEvent.getEntityShootBowEvent();
52 |
53 | if (event.getEntity().getType().equals(EntityType.PLAYER)
54 | && !PermissionUtils.allowedAction((Player) event.getEntity(), perm.getType(), perm.getShoot()))
55 | event.setCancelled(true);
56 | }
57 | }
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/custom/PlayerDropCustomItem.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.custom;
2 |
3 | import org.bukkit.event.EventHandler;
4 | import org.bukkit.event.EventPriority;
5 | import org.bukkit.event.Listener;
6 | import org.bukkit.event.player.PlayerDropItemEvent;
7 |
8 | import com.chrismin13.additionsapi.events.item.PlayerDropCustomItemEvent;
9 | import com.chrismin13.additionsapi.items.CustomItem;
10 | import com.chrismin13.additionsapi.permissions.ItemPermissions;
11 | import com.chrismin13.additionsapi.utils.PermissionUtils;
12 |
13 | public class PlayerDropCustomItem implements Listener {
14 |
15 | @EventHandler(priority = EventPriority.LOWEST)
16 | public void onPlayerDropCustomItemLowest(PlayerDropCustomItemEvent customEvent) {
17 | if (customEvent.isCancelled())
18 | return;
19 |
20 | CustomItem cItem = customEvent.getCustomItem();
21 | ItemPermissions perm = cItem.getPermissions();
22 |
23 | PlayerDropItemEvent event = customEvent.getPlayerDropItemEvent();
24 | if (!PermissionUtils.allowedAction(event.getPlayer(), perm.getType(), perm.getDrop()))
25 | event.setCancelled(true);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/custom/PlayerPickupCustomItem.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.custom;
2 |
3 | import org.bukkit.event.EventHandler;
4 | import org.bukkit.event.EventPriority;
5 | import org.bukkit.event.Listener;
6 | import org.bukkit.event.player.PlayerPickupItemEvent;
7 |
8 | import com.chrismin13.additionsapi.events.item.PlayerPickupCustomItemEvent;
9 | import com.chrismin13.additionsapi.items.CustomItem;
10 | import com.chrismin13.additionsapi.permissions.ItemPermissions;
11 | import com.chrismin13.additionsapi.utils.PermissionUtils;
12 |
13 | public class PlayerPickupCustomItem implements Listener {
14 |
15 | @EventHandler(priority = EventPriority.LOWEST)
16 | public void onPlayerPickupCustomItemLowest(PlayerPickupCustomItemEvent customEvent) {
17 | if (customEvent.isCancelled())
18 | return;
19 |
20 | CustomItem cItem = customEvent.getCustomItem();
21 | ItemPermissions perm = cItem.getPermissions();
22 |
23 | PlayerPickupItemEvent event = customEvent.getPlayerPickupItemEvent();
24 | if (!PermissionUtils.allowedAction(event.getPlayer(), perm.getType(), perm.getPickup()))
25 | event.setCancelled(true);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/vanilla/Anvil.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.vanilla;
2 |
3 | import org.bukkit.Material;
4 | import org.bukkit.enchantments.Enchantment;
5 | import org.bukkit.event.EventHandler;
6 | import org.bukkit.event.EventPriority;
7 | import org.bukkit.event.Listener;
8 | import org.bukkit.event.inventory.PrepareAnvilEvent;
9 | import org.bukkit.inventory.AnvilInventory;
10 | import org.bukkit.inventory.ItemStack;
11 | import org.bukkit.inventory.meta.ItemMeta;
12 |
13 | import com.chrismin13.additionsapi.AdditionsAPI;
14 | import com.chrismin13.additionsapi.items.CustomItem;
15 | import com.chrismin13.additionsapi.items.CustomItemStack;
16 |
17 | import net.md_5.bungee.api.ChatColor;
18 |
19 | public class Anvil implements Listener {
20 | @EventHandler(priority = EventPriority.HIGHEST)
21 | public void onItemRename(PrepareAnvilEvent event) {
22 | if (event.getResult() == null)
23 | return;
24 | ItemStack resultItem = event.getResult();
25 | if (!AdditionsAPI.isCustomItem(resultItem))
26 | return;
27 | AnvilInventory inv = event.getInventory();
28 | ItemMeta resultMeta = resultItem.getItemMeta();
29 | CustomItemStack cStack = new CustomItemStack(resultItem);
30 | CustomItem cItem = cStack.getCustomItem();
31 |
32 | ItemStack leftItem = inv.getItem(0);
33 | ItemMeta leftMeta = leftItem.getItemMeta();
34 | /*
35 | * A fix for the bug that occurred due to the Display Name of the Custom
36 | * Item having a ChatColor.RESET in front.
37 | */
38 | if (cItem.getDisplayName() != null && resultMeta.getDisplayName() != null) {
39 | String renamedDisplayName = resultMeta.getDisplayName();
40 | if (cItem.getDisplayName() != renamedDisplayName
41 | && leftMeta.getDisplayName().startsWith(ChatColor.RESET + "")) {
42 | if (renamedDisplayName.startsWith("r"))
43 | renamedDisplayName = renamedDisplayName.replaceFirst("r", "");
44 | resultMeta.setDisplayName(renamedDisplayName);
45 |
46 | }
47 | }
48 | /*
49 | * A fix for being able to put books of any enchantment, even if it's
50 | * forbidden
51 | */
52 | if (!cItem.getForbidenEnchantments().isEmpty())
53 | for (Enchantment ench : cItem.getForbidenEnchantments())
54 | if (resultItem.containsEnchantment(ench))
55 | event.setResult(new ItemStack(Material.AIR));
56 |
57 | if (cItem.getDisplayName() != null) {
58 | String customName = cItem.getDisplayName();
59 | /*
60 | * Fixes a bug that allowed you to rename the resultItem to it
61 | * original material name
62 | */
63 | if (resultMeta.getDisplayName() == null) {
64 | resultMeta.setDisplayName(customName);
65 |
66 | } else {
67 | /*
68 | * TODO: A fix for the italic text even if you didn't change the
69 | * name
70 | */
71 | }
72 | }
73 | resultItem.setItemMeta(resultMeta);
74 | /*
75 | * A fix for the fake lore not updating when adding Sharpness.
76 | */
77 | cStack.updateLore();
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/vanilla/BlockBreak.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.vanilla;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.entity.Player;
5 | import org.bukkit.event.EventHandler;
6 | import org.bukkit.event.EventPriority;
7 | import org.bukkit.event.Listener;
8 | import org.bukkit.event.block.BlockBreakEvent;
9 | import org.bukkit.inventory.ItemStack;
10 |
11 | import com.chrismin13.additionsapi.AdditionsAPI;
12 | import com.chrismin13.additionsapi.events.item.CustomItemBlockBreakEvent;
13 | import com.chrismin13.additionsapi.items.CustomItemStack;
14 |
15 | public class BlockBreak implements Listener {
16 |
17 | @EventHandler(priority = EventPriority.MONITOR)
18 | public void onBlockBreak(BlockBreakEvent event) {
19 | Player player = event.getPlayer();
20 | ItemStack item = player.getInventory().getItemInMainHand();
21 | if (AdditionsAPI.isCustomItem(item)) {
22 | CustomItemBlockBreakEvent customEvent = new CustomItemBlockBreakEvent(event, new CustomItemStack(item));
23 | Bukkit.getServer().getPluginManager().callEvent(customEvent);
24 | }
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/vanilla/BlockIgnite.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.vanilla;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.event.EventHandler;
5 | import org.bukkit.event.EventPriority;
6 | import org.bukkit.event.Listener;
7 | import org.bukkit.event.block.BlockIgniteEvent;
8 | import org.bukkit.inventory.ItemStack;
9 | import org.bukkit.inventory.PlayerInventory;
10 |
11 | import com.chrismin13.additionsapi.AdditionsAPI;
12 | import com.chrismin13.additionsapi.enums.ItemType;
13 | import com.chrismin13.additionsapi.events.item.CustomItemBlockIgniteEvent;
14 | import com.chrismin13.additionsapi.items.CustomItemStack;
15 |
16 | public class BlockIgnite implements Listener {
17 |
18 | @EventHandler(priority = EventPriority.MONITOR)
19 | public void onBlockIgnite(BlockIgniteEvent event) {
20 | if (event.getPlayer() == null)
21 | return;
22 | PlayerInventory inv = event.getPlayer().getInventory();
23 | ItemStack item = inv.getItemInMainHand();
24 | if (ItemType.getItemType(item) != ItemType.FLINT_AND_STEEL) {
25 | item = inv.getItemInOffHand();
26 | if (ItemType.getItemType(item) != ItemType.FLINT_AND_STEEL)
27 | return;
28 | }
29 | if (AdditionsAPI.isCustomItem(item)) {
30 | CustomItemBlockIgniteEvent customEvent = new CustomItemBlockIgniteEvent(event, new CustomItemStack(item));
31 | Bukkit.getServer().getPluginManager().callEvent(customEvent);
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/vanilla/EnchantItem.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.vanilla;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.Map;
6 | import java.util.Set;
7 |
8 | import org.bukkit.enchantments.Enchantment;
9 | import org.bukkit.event.EventHandler;
10 | import org.bukkit.event.EventPriority;
11 | import org.bukkit.event.Listener;
12 | import org.bukkit.event.enchantment.EnchantItemEvent;
13 | import org.bukkit.inventory.ItemStack;
14 |
15 | import com.chrismin13.additionsapi.AdditionsAPI;
16 | import com.chrismin13.additionsapi.items.CustomItem;
17 | import com.chrismin13.additionsapi.items.CustomItemStack;
18 |
19 | public class EnchantItem implements Listener {
20 |
21 | @EventHandler(priority = EventPriority.HIGHEST)
22 | public void onItemEnchant(EnchantItemEvent event) {
23 | if (event.isCancelled() || !AdditionsAPI.isCustomItem(event.getItem()))
24 | return;
25 | ItemStack item = event.getItem();
26 | CustomItemStack cStack = new CustomItemStack(item);
27 | Map eToAdd = event.getEnchantsToAdd();
28 | Set eSet = eToAdd.keySet();
29 | List e = new ArrayList(eSet);
30 | CustomItem cItem = cStack.getCustomItem();
31 | /*
32 | * Non Enchantable Items
33 | */
34 | if (!cItem.isEnchantable()) {
35 | event.setCancelled(true);
36 | } else {
37 | /*
38 | * Forbidden Enchantments
39 | */
40 | List eInvalid = cItem.getForbidenEnchantments();
41 | for (Enchantment eToCheck : e) {
42 | if (eInvalid.contains(eToCheck)) {
43 | if (eToAdd.containsKey(eToCheck)) {
44 | eToAdd.remove(eToCheck);
45 | }
46 | if (eToAdd.isEmpty()) {
47 | event.setCancelled(true);
48 | return;
49 | }
50 | }
51 | }
52 | }
53 | cStack.updateLore(eToAdd);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/vanilla/EntityShootBow.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.vanilla;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.entity.EntityType;
5 | import org.bukkit.event.EventHandler;
6 | import org.bukkit.event.EventPriority;
7 | import org.bukkit.event.Listener;
8 | import org.bukkit.event.entity.EntityShootBowEvent;
9 | import org.bukkit.event.entity.ProjectileHitEvent;
10 | import org.bukkit.inventory.ItemStack;
11 |
12 | import com.chrismin13.additionsapi.AdditionsAPI;
13 | import com.chrismin13.additionsapi.enums.ItemType;
14 | import com.chrismin13.additionsapi.events.bow.ArrowFromCustomBowHitEvent;
15 | import com.chrismin13.additionsapi.events.bow.EntityShootCustomBowEvent;
16 | import com.chrismin13.additionsapi.items.CustomItem;
17 | import com.chrismin13.additionsapi.items.CustomItemStack;
18 | import com.chrismin13.additionsapi.listeners.custom.ArrowFromCustomBowHit;
19 | import com.chrismin13.additionsapi.utils.BowStackContainer;
20 |
21 | public class EntityShootBow implements Listener {
22 |
23 | @EventHandler(priority = EventPriority.HIGHEST)
24 | public void onEntityShootBow(EntityShootBowEvent event) {
25 | ItemStack item = event.getBow();
26 | if (AdditionsAPI.isCustomItem(item)) {
27 | CustomItemStack cStack = new CustomItemStack(item);
28 | CustomItem cItem = cStack.getCustomItem();
29 | if (cItem.getItemType() == ItemType.BOW) {
30 | Bukkit.getServer().getPluginManager().callEvent(new EntityShootCustomBowEvent(event, cStack));
31 | }
32 | }
33 | }
34 |
35 | @EventHandler(priority = EventPriority.HIGHEST)
36 | public void onArrowHit(ProjectileHitEvent event) {
37 | if (event.getEntityType() != EntityType.ARROW && event.getEntityType() != EntityType.SPECTRAL_ARROW)
38 | return;
39 | if (ArrowFromCustomBowHit.containsArrow(event.getEntity())) {
40 | BowStackContainer container = ArrowFromCustomBowHit.getBowStackContainer(event.getEntity());
41 | Bukkit.getServer().getPluginManager()
42 | .callEvent(new ArrowFromCustomBowHitEvent(event, container.getOwner(), container.getBowStack()));
43 | }
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/vanilla/EntityToggleGlide.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.vanilla;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.entity.EntityType;
5 | import org.bukkit.entity.Player;
6 | import org.bukkit.event.EventHandler;
7 | import org.bukkit.event.EventPriority;
8 | import org.bukkit.event.Listener;
9 | import org.bukkit.event.entity.EntityToggleGlideEvent;
10 | import org.bukkit.inventory.ItemStack;
11 | import org.bukkit.inventory.PlayerInventory;
12 |
13 | import com.chrismin13.additionsapi.AdditionsAPI;
14 | import com.chrismin13.additionsapi.enums.ItemType;
15 | import com.chrismin13.additionsapi.events.elytra.CustomElytraPlayerToggleGlideEvent;
16 | import com.chrismin13.additionsapi.items.CustomItemStack;
17 |
18 | public class EntityToggleGlide implements Listener {
19 |
20 | @EventHandler(priority = EventPriority.MONITOR)
21 | public void onEntityToggleGlide(EntityToggleGlideEvent event) {
22 | if (event.getEntityType() != EntityType.PLAYER)
23 | return;
24 | PlayerInventory inv = ((Player) event.getEntity()).getInventory();
25 | if (inv.getChestplate() == null)
26 | return;
27 | ItemStack elytra = inv.getChestplate();
28 | if (!AdditionsAPI.isCustomItem(elytra)
29 | || new CustomItemStack(elytra).getCustomItem().getItemType() != ItemType.ELYTRA)
30 | return;
31 | Bukkit.getServer().getPluginManager()
32 | .callEvent(new CustomElytraPlayerToggleGlideEvent(event, new CustomItemStack(elytra)));
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/vanilla/FurnaceBurn.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.vanilla;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.event.EventHandler;
5 | import org.bukkit.event.EventPriority;
6 | import org.bukkit.event.Listener;
7 | import org.bukkit.event.inventory.FurnaceBurnEvent;
8 | import org.bukkit.inventory.ItemStack;
9 |
10 | import com.chrismin13.additionsapi.AdditionsAPI;
11 | import com.chrismin13.additionsapi.events.item.CustomItemFurnaceBurnEvent;
12 | import com.chrismin13.additionsapi.items.CustomItemStack;
13 |
14 | public class FurnaceBurn implements Listener {
15 |
16 | @EventHandler(priority = EventPriority.LOWEST)
17 | public void onFurnaceBurn(FurnaceBurnEvent event) {
18 | if (event.isCancelled())
19 | return;
20 | ItemStack fuel = event.getFuel();
21 | if (!AdditionsAPI.isCustomItem(fuel))
22 | return;
23 | CustomItemStack cStack = new CustomItemStack(fuel);
24 | Bukkit.getPluginManager().callEvent(new CustomItemFurnaceBurnEvent(event, cStack));
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/vanilla/PlayerDeath.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.vanilla;
2 |
3 | import org.bukkit.event.EventHandler;
4 | import org.bukkit.event.EventPriority;
5 | import org.bukkit.event.Listener;
6 | import org.bukkit.event.entity.PlayerDeathEvent;
7 |
8 | import com.chrismin13.additionsapi.AdditionsAPI;
9 | import com.chrismin13.additionsapi.items.CustomItem;
10 | import com.chrismin13.additionsapi.utils.Debug;
11 | import com.chrismin13.additionsapi.utils.LangFileUtils;
12 |
13 | public class PlayerDeath implements Listener {
14 |
15 | // TODO: Check if it works when you get some internet
16 | @EventHandler(priority = EventPriority.LOWEST)
17 | public void onPlayerDeath(PlayerDeathEvent event) {
18 | String msg = event.getDeathMessage();
19 | if(msg!=null) {
20 | Debug.saySuper("Original Death Message: " + msg);
21 | for (CustomItem cItem : AdditionsAPI.getAllCustomItems()) {
22 | if (msg.contains(cItem.getDisplayName())) {
23 | msg.replaceFirst(LangFileUtils.get("death_message").replaceFirst("CustomItem", cItem.getDisplayName()),
24 | "");
25 | Debug.saySuper("Replaced " + cItem.getDisplayName());
26 | break;
27 | }
28 | }
29 | Debug.saySuper("Final Death Message: " + msg);
30 | event.setDeathMessage(msg);
31 | }
32 | }
33 |
34 | // TODO: Make the same for every entity that dies e.g. Wolf
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/vanilla/PlayerDropItem.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.vanilla;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.event.EventHandler;
5 | import org.bukkit.event.EventPriority;
6 | import org.bukkit.event.Listener;
7 | import org.bukkit.event.player.PlayerDropItemEvent;
8 | import org.bukkit.inventory.ItemStack;
9 |
10 | import com.chrismin13.additionsapi.AdditionsAPI;
11 | import com.chrismin13.additionsapi.events.item.PlayerDropCustomItemEvent;
12 | import com.chrismin13.additionsapi.items.CustomItemStack;
13 |
14 | public class PlayerDropItem implements Listener {
15 |
16 | @EventHandler(priority = EventPriority.LOWEST)
17 | public void onPlayerDropItem(PlayerDropItemEvent event) {
18 | if (event.isCancelled())
19 | return;
20 |
21 | ItemStack item = event.getItemDrop().getItemStack();
22 |
23 | if (!AdditionsAPI.isCustomItem(item))
24 | return;
25 | CustomItemStack cStack = new CustomItemStack(item);
26 |
27 | Bukkit.getPluginManager().callEvent(new PlayerDropCustomItemEvent(event, cStack));
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/vanilla/PlayerFish.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.vanilla;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.event.EventHandler;
5 | import org.bukkit.event.EventPriority;
6 | import org.bukkit.event.Listener;
7 | import org.bukkit.event.player.PlayerFishEvent;
8 | import org.bukkit.inventory.ItemStack;
9 | import org.bukkit.inventory.PlayerInventory;
10 |
11 | import com.chrismin13.additionsapi.AdditionsAPI;
12 | import com.chrismin13.additionsapi.enums.ItemType;
13 | import com.chrismin13.additionsapi.events.item.CustomItemFishEvent;
14 | import com.chrismin13.additionsapi.items.CustomItemStack;
15 |
16 | public class PlayerFish implements Listener {
17 |
18 | @EventHandler(priority = EventPriority.MONITOR)
19 | public void onPlayerFishEvent(PlayerFishEvent event) {
20 | PlayerInventory inv = event.getPlayer().getInventory();
21 | ItemStack item = inv.getItemInMainHand();
22 | if (ItemType.getItemType(item) != ItemType.FISHING_ROD) {
23 | item = inv.getItemInOffHand();
24 | if (ItemType.getItemType(item) != ItemType.FISHING_ROD)
25 | return;
26 | }
27 | if (AdditionsAPI.isCustomItem(item))
28 | Bukkit.getServer().getPluginManager().callEvent(new CustomItemFishEvent(event, new CustomItemStack(item)));
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/vanilla/PlayerPickupItem.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.vanilla;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.event.EventHandler;
5 | import org.bukkit.event.EventPriority;
6 | import org.bukkit.event.Listener;
7 | import org.bukkit.event.player.PlayerPickupItemEvent;
8 | import org.bukkit.inventory.ItemStack;
9 |
10 | import com.chrismin13.additionsapi.AdditionsAPI;
11 | import com.chrismin13.additionsapi.events.item.PlayerPickupCustomItemEvent;
12 | import com.chrismin13.additionsapi.items.CustomItemStack;
13 |
14 | public class PlayerPickupItem implements Listener {
15 |
16 | @EventHandler(priority = EventPriority.LOWEST)
17 | public void onPlayerPickupItem(PlayerPickupItemEvent event) {
18 | if (event.isCancelled())
19 | return;
20 |
21 | ItemStack item = event.getItem().getItemStack();
22 | if (!AdditionsAPI.isCustomItem(item))
23 | return;
24 | CustomItemStack cStack = new CustomItemStack(item);
25 |
26 | Bukkit.getPluginManager().callEvent(new PlayerPickupCustomItemEvent(event, cStack));
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/listeners/vanilla/PlayerShearEntity.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.listeners.vanilla;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.event.EventHandler;
5 | import org.bukkit.event.EventPriority;
6 | import org.bukkit.event.Listener;
7 | import org.bukkit.event.player.PlayerShearEntityEvent;
8 | import org.bukkit.inventory.ItemStack;
9 | import org.bukkit.inventory.PlayerInventory;
10 |
11 | import com.chrismin13.additionsapi.AdditionsAPI;
12 | import com.chrismin13.additionsapi.enums.ItemType;
13 | import com.chrismin13.additionsapi.events.item.CustomItemShearEntityEvent;
14 | import com.chrismin13.additionsapi.items.CustomItemStack;
15 |
16 | public class PlayerShearEntity implements Listener {
17 |
18 | @EventHandler(priority = EventPriority.MONITOR)
19 | public void onPlayerShearEntity(PlayerShearEntityEvent event) {
20 | PlayerInventory inv = event.getPlayer().getInventory();
21 | ItemStack item = inv.getItemInMainHand();
22 | if (ItemType.getItemType(item) != ItemType.SHEARS) {
23 | item = inv.getItemInOffHand();
24 | if (ItemType.getItemType(item) != ItemType.SHEARS)
25 | return;
26 | }
27 | if (AdditionsAPI.isCustomItem(item)) {
28 | CustomItemShearEntityEvent customEvent = new CustomItemShearEntityEvent(event, new CustomItemStack(item));
29 | Bukkit.getServer().getPluginManager().callEvent(customEvent);
30 | }
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/permissions/ArmorPermissions.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.permissions;
2 |
3 | /**
4 | * This specifies the permissions that will be checked when using the Custom
5 | * Armor.
6 | *
7 | * @author chrismin13
8 | */
9 | public class ArmorPermissions extends ItemPermissions {
10 |
11 | private String wear;
12 |
13 | public ArmorPermissions(String permissionPrefix, PermissionType type) {
14 | super(permissionPrefix, type);
15 | wear = this.getPermissionPrefix() + "."+ this.getType().getPermission() + ".wear";
16 | }
17 |
18 | /**
19 | * @return The permission node for wearing the Custom Armor. This is also
20 | * the same for Elytras.
21 | */
22 | public String getWear() {
23 | return wear;
24 | }
25 |
26 | /**
27 | * @param Set
28 | * the permission node for wearing the Custom Armor. This is also
29 | * the same for Elytras.
30 | */
31 | public ArmorPermissions setWear(String wear) {
32 | this.wear = wear;
33 | return this;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/permissions/BowPermissions.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.permissions;
2 |
3 | /**
4 | * This specifies the permissions that will be checked when using a Custom Bow.
5 | *
6 | * @author chrismin13
7 | */
8 | public class BowPermissions extends ItemPermissions {
9 |
10 | private String shoot;
11 |
12 | public BowPermissions(String permissionPrefix, PermissionType type) {
13 | super(permissionPrefix, type);
14 | shoot = this.getPermissionPrefix() + "."+ this.getType().getPermission() + ".shoot";
15 | }
16 |
17 | /**
18 | * @return The permission node for shooting with the bow.
19 | */
20 | public String getShoot() {
21 | return shoot;
22 | }
23 |
24 | /**
25 | * Set the permission node for shooting with the bow.
26 | *
27 | * @param shoot
28 | */
29 | public BowPermissions setShoot(String shoot) {
30 | this.shoot = shoot;
31 | return this;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/permissions/CarrotStickPermissions.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.permissions;
2 |
3 | /**
4 | * TODO: STILL NOT DONE. All values are placeholders for when it finally gets
5 | * implemented. This specifies the permissions that will be checked when using
6 | * the Custom Item that is of Material CARROT_STICK.
7 | *
8 | * @author chrismin13
9 | */
10 | public class CarrotStickPermissions extends ItemPermissions {
11 |
12 | private String boost;
13 |
14 | public CarrotStickPermissions(String permissionPrefix, PermissionType type) {
15 | super(permissionPrefix, type);
16 | boost = this.getPermissionPrefix() + "."+ this.getType().getPermission() + ".boost";
17 | }
18 |
19 | /**
20 | * @return The permission node for boosting by right-clicking when on a pig.
21 | */
22 | public String getBoost() {
23 | return boost;
24 | }
25 |
26 | /**
27 | * Set the permission node for boosting by right-clicking when on a pig.
28 | *
29 | * @param boost
30 | */
31 | public CarrotStickPermissions setBoost(String boost) {
32 | this.boost = boost;
33 | return this;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/permissions/ElytraPermissions.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.permissions;
2 |
3 | /**
4 | * This specifies the permissions that will be checked when using the Custom
5 | * Item that is of Material ELYTRA
6 | *
7 | * @author chrismin13
8 | */
9 | public class ElytraPermissions extends ItemPermissions {
10 |
11 | private String flight;
12 |
13 | public ElytraPermissions(String permissionPrefix, PermissionType type) {
14 | super(permissionPrefix, type);
15 | flight = this.getPermissionPrefix() + "."+ this.getType().getPermission() + ".flight";
16 | }
17 |
18 | /**
19 | * @return The permission node for toggling flight with the Elytra
20 | */
21 | public String getFlight() {
22 | return flight;
23 | }
24 |
25 | /**
26 | * Set the permission node for toggling flight with the Elytra
27 | *
28 | * @param flight
29 | */
30 | public ElytraPermissions setFlight(String flight) {
31 | this.flight = flight;
32 | return this;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/permissions/FishingRodPermissions.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.permissions;
2 |
3 | /**
4 | * This specifies the permissions that will be checked when using the Custom
5 | * Item that is of Material FISHING_ROD
6 | *
7 | * @author chrismin13
8 | */
9 |
10 | public class FishingRodPermissions extends ItemPermissions {
11 |
12 | private String reel;
13 |
14 | public FishingRodPermissions(String permissionPrefix, PermissionType type) {
15 | super(permissionPrefix, type);
16 | reel = this.getPermissionPrefix() + "."+ this.getType().getPermission() + ".reel";
17 | }
18 |
19 | /**
20 | * @return The permission node for reeling on a Fishing Rod
21 | */
22 | public String getReel() {
23 | return reel;
24 | }
25 |
26 | /**
27 | * @param Set the permission node for reeling on a Fishing Rod
28 | */
29 | public void setReel(String reel) {
30 | this.reel = reel;
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/permissions/FlintAndSteelPermissions.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.permissions;
2 |
3 | /**
4 | * This specifies the permissions that will be checked when using the Custom
5 | * Item that is of Material FLINT_AND_STEEL.
6 | *
7 | * @author chrismin13
8 | */
9 | public class FlintAndSteelPermissions extends ItemPermissions {
10 |
11 | private String fire;
12 |
13 | public FlintAndSteelPermissions(String permissionPrefix, PermissionType type) {
14 | super(permissionPrefix, type);
15 | fire = this.getPermissionPrefix() + "."+ this.getType().getPermission() + ".fire";
16 | }
17 |
18 | /**
19 | * @return The permission node for setting a block on fire.
20 | */
21 | public String getFire() {
22 | return fire;
23 | }
24 |
25 | /**
26 | * Set the permission node for setting a block on fire.
27 | *
28 | * @param fire
29 | */
30 | public FlintAndSteelPermissions setFire(String fire) {
31 | this.fire = fire;
32 | return this;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/permissions/HoePermissions.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.permissions;
2 |
3 | /**
4 | * This specifies the permissions that will be checked when using the Custom
5 | * Tool that is of ToolType HOE.
6 | *
7 | * @author chrismin13
8 | */
9 | public class HoePermissions extends ItemPermissions {
10 |
11 | private String hoe;
12 |
13 | public HoePermissions(String permissionPrefix, PermissionType type) {
14 | super(permissionPrefix, type);
15 | hoe = this.getPermissionPrefix() + "." + this.getType().getPermission() + ".hoe";
16 | }
17 |
18 | /**
19 | * @return The permission node for tiling the ground with a hoe.
20 | */
21 | public String getHoe() {
22 | return hoe;
23 | }
24 |
25 | /**
26 | * Set the permission node for tiling the ground with a hoe.
27 | *
28 | * @param hoe
29 | */
30 | public HoePermissions setHoe(String hoe) {
31 | this.hoe = hoe;
32 | return this;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/permissions/PermissionType.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.permissions;
2 |
3 | public enum PermissionType {
4 |
5 | ALLOW, DENY;
6 |
7 | public String getPermission() {
8 | return toString().toLowerCase();
9 | }
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/permissions/ShearPermissions.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.permissions;
2 |
3 | /**
4 | * This specifies the permissions that will be checked when using the Custom
5 | * Item that is of Material SHEARS.
6 | *
7 | * @author chrismin13
8 | */
9 | public class ShearPermissions extends ItemPermissions {
10 |
11 | private String shear;
12 |
13 | public ShearPermissions(String permissionPrefix, PermissionType type) {
14 | super(permissionPrefix, type);
15 | shear = this.getPermissionPrefix() + "."+ this.getType().getPermission() + ".shear";
16 | }
17 |
18 | /**
19 | * @return The permission node for shearing sheep
20 | */
21 | public String getShear() {
22 | return shear;
23 | }
24 |
25 | /**
26 | * Set the permission node for shearing sheep
27 | *
28 | * @param shear
29 | */
30 | public ShearPermissions setShear(String shear) {
31 | this.shear = shear;
32 | return this;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/permissions/ShieldPermissions.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.permissions;
2 |
3 | /**
4 | * This specifies the permissions that will be checked when using the Custom
5 | * Item that is of Material SHIELD.
6 | *
7 | * @author chrismin13
8 | */
9 | public class ShieldPermissions extends ItemPermissions {
10 |
11 | private String block;
12 |
13 | public ShieldPermissions(String permissionPrefix, PermissionType type) {
14 | super(permissionPrefix, type);
15 | block = this.getPermissionPrefix() + "."+ this.getType().getPermission() + ".block";
16 | }
17 |
18 | /**
19 | * @return The permission node for blocking with the shield.
20 | */
21 | public String getBlock() {
22 | return block;
23 | }
24 |
25 | /**
26 | * @param Set the permission node for blocking with the shield.
27 | */
28 | public void setBlock(String block) {
29 | this.block = block;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/permissions/SpadePermissions.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.permissions;
2 |
3 | /**
4 | * This specifies the permissions that will be checked when using the Custom
5 | * Tool that is of ToolType SPADE.
6 | *
7 | * @author chrismin13
8 | */
9 | public class SpadePermissions extends ItemPermissions {
10 |
11 | private String tile;
12 |
13 | public SpadePermissions(String permissionPrefix, PermissionType type) {
14 | super(permissionPrefix, type);
15 | tile = this.getPermissionPrefix() + "."+ this.getType().getPermission() + ".tile";
16 | }
17 |
18 | /**
19 | * @return The permission node for creating a path block.
20 | */
21 | public String getTile() {
22 | return tile;
23 | }
24 |
25 | /**
26 | * Set the permission node for creating a path block.
27 | *
28 | * @param tile
29 | */
30 | public SpadePermissions setTile(String tile) {
31 | this.tile = tile;
32 | return this;
33 | }
34 |
35 | }
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/recipes/CustomRecipe.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.recipes;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.NamespacedKey;
5 | import org.bukkit.inventory.ItemStack;
6 | import org.bukkit.inventory.Recipe;
7 |
8 | public abstract class CustomRecipe {
9 |
10 | @Deprecated
11 | public abstract Recipe toBukkitRecipe(ItemStack result);
12 |
13 | public abstract Recipe toBukkitRecipe(NamespacedKey key, ItemStack result);
14 |
15 | @Deprecated
16 | public CustomRecipe registerBukkitRecipe(ItemStack result) {
17 | Recipe recipe = toBukkitRecipe(result);
18 | Bukkit.addRecipe(recipe);
19 | return this;
20 | }
21 |
22 | public CustomRecipe registerBukkitRecipe(NamespacedKey key, ItemStack result) {
23 | Recipe recipe = toBukkitRecipe(key, result);
24 | Bukkit.addRecipe(recipe);
25 | return this;
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/recipes/CustomShapelessRecipe.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.recipes;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import org.bukkit.Material;
7 | import org.bukkit.NamespacedKey;
8 | import org.bukkit.inventory.ItemStack;
9 | import org.bukkit.inventory.ShapelessRecipe;
10 |
11 | public class CustomShapelessRecipe extends CustomRecipe {
12 |
13 | private List ingredients = new ArrayList();
14 |
15 | public CustomShapelessRecipe() {
16 | }
17 |
18 | public CustomShapelessRecipe(CustomShapelessRecipe recipe) {
19 | for (RecipeIngredient ingredient : recipe.getIngredients())
20 | this.addIngredient(ingredient.clone());
21 | }
22 |
23 | public CustomShapelessRecipe addIngredient(Material material) {
24 | return addIngredient(new RecipeIngredient(material));
25 | }
26 |
27 | public CustomShapelessRecipe addIngredient(RecipeIngredient ingredient) {
28 | ingredients.add(ingredient);
29 | return this;
30 | }
31 |
32 | public RecipeIngredient[] getIngredients() {
33 | RecipeIngredient[] ingredients = new RecipeIngredient[9];
34 | int index = 0;
35 | for (RecipeIngredient ingredient : this.ingredients) {
36 | ingredients[index] = ingredient;
37 | index++;
38 | }
39 | return ingredients;
40 | }
41 |
42 | @Override
43 | public ShapelessRecipe toBukkitRecipe(ItemStack result) {
44 | return toBukkitRecipe(null, result);
45 | }
46 |
47 | @SuppressWarnings("deprecation")
48 | @Override
49 | public ShapelessRecipe toBukkitRecipe(NamespacedKey key, ItemStack result) {
50 | ShapelessRecipe recipe;
51 | if (key != null)
52 | recipe = new ShapelessRecipe(key, result);
53 | else
54 | recipe = new ShapelessRecipe(result);
55 |
56 | for (RecipeIngredient ingredient : getIngredients()) {
57 | if (ingredient != null) {
58 | recipe.addIngredient(ingredient.getMaterial(), ingredient.getBlockData());
59 | }
60 | }
61 |
62 | return recipe;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/utils/BowStackContainer.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.utils;
2 |
3 | import org.bukkit.entity.LivingEntity;
4 |
5 | import com.chrismin13.additionsapi.items.CustomItemStack;
6 |
7 | public class BowStackContainer {
8 |
9 | private CustomItemStack cBowStack;
10 | private LivingEntity owner;
11 |
12 | public BowStackContainer(CustomItemStack cBowStack, LivingEntity owner) {
13 | this.cBowStack = cBowStack;
14 | this.owner = owner;
15 | }
16 |
17 | /**
18 | * @return the cBowStack
19 | */
20 | public CustomItemStack getBowStack() {
21 | return cBowStack;
22 | }
23 |
24 | /**
25 | * @param cBowStack the cBowStack to set
26 | */
27 | public BowStackContainer setBowStack(CustomItemStack cBowStack) {
28 | this.cBowStack = cBowStack;
29 | return this;
30 | }
31 |
32 | /**
33 | * @return the owner
34 | */
35 | public LivingEntity getOwner() {
36 | return owner;
37 | }
38 |
39 | /**
40 | * @param owner the owner to set
41 | */
42 | public BowStackContainer setOwner(LivingEntity owner) {
43 | this.owner = owner;
44 | return this;
45 | }
46 | }
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/utils/Debug.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.utils;
2 |
3 | import java.util.logging.Logger;
4 |
5 | import org.bukkit.Bukkit;
6 |
7 | import com.chrismin13.additionsapi.files.ConfigFile;
8 | import com.chrismin13.additionsapi.files.ConfigFile.DebugType;
9 |
10 | public class Debug {
11 |
12 | private static Logger log = Bukkit.getLogger();
13 | private static DebugType type = ConfigFile.getInstance().getDebug();
14 |
15 | public static void say(String s) {
16 | log.info(s);
17 | }
18 |
19 | public static void sayTrue(String s) {
20 | if (type != DebugType.FALSE)
21 | log.info(s);
22 | }
23 |
24 | public static void saySuper(String s) {
25 | if (type == DebugType.SUPER)
26 | log.info(s);
27 | }
28 |
29 | public static void sayError(String s) {
30 | log.severe(s);
31 | }
32 |
33 | public static void sayTrueError(String s) {
34 | if (type != DebugType.FALSE)
35 | log.severe(s);
36 | }
37 |
38 | public static void saySuperError(String s) {
39 | if (type == DebugType.SUPER)
40 | log.severe(s);
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/utils/ElytraDurabilityTask.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.utils;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.entity.Player;
5 | import org.bukkit.inventory.ItemStack;
6 | import org.bukkit.scheduler.BukkitRunnable;
7 |
8 | import com.chrismin13.additionsapi.durability.ElytraDurability;
9 | import com.chrismin13.additionsapi.events.item.PlayerCustomItemDamageEvent;
10 | import com.chrismin13.additionsapi.items.CustomItem;
11 | import com.chrismin13.additionsapi.listeners.custom.CustomElytraPlayerToggleGlide;
12 |
13 | public class ElytraDurabilityTask extends BukkitRunnable {
14 |
15 | private Player player;
16 | private ItemStack elytra;
17 | private CustomItem cItem;
18 | private boolean justStarted = true;
19 |
20 | public ElytraDurabilityTask(Player player, ItemStack elytra, CustomItem cItem) {
21 | this.player = player;
22 | this.cItem = cItem;
23 | this.elytra = elytra;
24 | }
25 |
26 | @Override
27 | public void run() {
28 | if (justStarted) {
29 | justStarted = false;
30 | return;
31 | }
32 | if (player.isGliding() && cItem.getDurabilityMechanics() instanceof ElytraDurability) {
33 | Bukkit.getPluginManager().callEvent(new PlayerCustomItemDamageEvent(player, elytra,
34 | ((ElytraDurability) cItem.getDurabilityMechanics()).getFlightOneSecond(), cItem));
35 | } else {
36 | CustomElytraPlayerToggleGlide.cancelPlayerGlideDamage(player.getUniqueId());
37 | }
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/utils/EquipmentSlotUtils.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.utils;
2 |
3 | import org.bukkit.inventory.EquipmentSlot;
4 |
5 | public class EquipmentSlotUtils {
6 |
7 | public static String toAttributeString(EquipmentSlot slot) {
8 | if (slot == EquipmentSlot.HAND)
9 | return "mainhand";
10 | if (slot == EquipmentSlot.OFF_HAND)
11 | return "offhand";
12 | return slot.toString().toLowerCase();
13 | }
14 |
15 | public static EquipmentSlot valueFromAttribute(String string) {
16 | switch(string) {
17 | case "mainhand":
18 | return EquipmentSlot.HAND;
19 | case "offhand":
20 | return EquipmentSlot.OFF_HAND;
21 | case "head":
22 | return EquipmentSlot.HEAD;
23 | case "chest":
24 | return EquipmentSlot.CHEST;
25 | case "feet":
26 | return EquipmentSlot.FEET;
27 | case "legs":
28 | return EquipmentSlot.LEGS;
29 | default:
30 | return EquipmentSlot.HAND;
31 | }
32 | }
33 |
34 | public static String valueFromLangFile(EquipmentSlot slot) {
35 | switch(slot) {
36 | case CHEST:
37 | return LangFileUtils.get("when_in_body");
38 | case FEET:
39 | return LangFileUtils.get("when_in_feet");
40 | case HAND:
41 | return LangFileUtils.get("when_in_main_hand");
42 | case HEAD:
43 | return LangFileUtils.get("when_in_head");
44 | case LEGS:
45 | return LangFileUtils.get("when_in_legs");
46 | case OFF_HAND:
47 | return LangFileUtils.get("when_in_off_hand");
48 | default:
49 | return null;
50 | }
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/utils/LangFileUtils.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.utils;
2 |
3 | import com.chrismin13.additionsapi.files.LangFile;
4 | import com.comphenix.attribute.Attributes.AttributeType;
5 |
6 | public class LangFileUtils {
7 |
8 | public static String get(String entryName) {
9 | return LangFile.getInstance().getEntry("more_minecraft", entryName);
10 | }
11 |
12 | public static String get(AttributeType type) {
13 | if (type.equals(AttributeType.ARMOR)) {
14 | return LangFileUtils.get("attribute_armor");
15 | } else if (type.equals(AttributeType.ARMOR_TOUGHNESS)) {
16 | return LangFileUtils.get("attribute_armor_toughness");
17 | } else if (type.equals(AttributeType.GENERIC_ATTACK_DAMAGE)) {
18 | return LangFileUtils.get("attribute_generic_attack_damage");
19 | } else if (type.equals(AttributeType.GENERIC_ATTACK_SPEED)) {
20 | return LangFileUtils.get("attribute_generic_attack_speed");
21 | } else if (type.equals(AttributeType.GENERIC_FOLLOW_RANGE)) {
22 | return LangFileUtils.get("attribute_generic_follow_range");
23 | } else if (type.equals(AttributeType.GENERIC_KNOCKBACK_RESISTANCE)) {
24 | return LangFileUtils.get("attribute_generic_knockback_resistance");
25 | } else if (type.equals(AttributeType.GENERIC_LUCK)) {
26 | return LangFileUtils.get("attribute_generic_luck");
27 | } else if (type.equals(AttributeType.GENERIC_MAX_HEALTH)) {
28 | return LangFileUtils.get("attribute_generic_max_health");
29 | } else if (type.equals(AttributeType.GENERIC_MOVEMENT_SPEED)) {
30 | return LangFileUtils.get("attribute_generic_movement_speed");
31 | } else if (type.equals(AttributeType.HORSE_JUMP_STRENGTH)) {
32 | return LangFileUtils.get("attribute_horse_jump_strength");
33 | } else if (type.equals(AttributeType.ZOMBIE_SPAWN_REINFORCEMENTS)) {
34 | return LangFileUtils.get("attribute_zombie_spawn_reinforcements");
35 | } else {
36 | return "Unknown Attribute";
37 | }
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/utils/NumberUtils.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.utils;
2 |
3 | import java.math.BigDecimal;
4 | import java.math.RoundingMode;
5 | import java.util.concurrent.ThreadLocalRandom;
6 |
7 | public class NumberUtils {
8 |
9 | public static boolean calculateChance(double percentage) {
10 | double d = Math.random();
11 | if (d <= percentage)
12 | return true;
13 | return false;
14 | }
15 |
16 | public static int safeLongToInt(long l) {
17 | if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) {
18 | throw new IllegalArgumentException(l + " cannot be cast to int without changing its value.");
19 | }
20 | return (int) l;
21 | }
22 |
23 | public static boolean isValidShort(int integer) {
24 | return (integer < Short.MAX_VALUE && integer > Short.MIN_VALUE);
25 | }
26 |
27 | /**
28 | * A rounding method for doubles that also specifies up to how many decimal
29 | * places there will be.
30 | * Credit goes to Jonik from Stack Overflow.
31 | * http://stackoverflow.com/questions/2808535/round-a-double-to-2-decimal-places
32 | *
33 | * @param value
34 | * The double you want to round.
35 | * @param places
36 | * How many decimals there will be.
37 | * @return The rounded double.
38 | */
39 | public static double round(double value, int places) {
40 | if (places < 0)
41 | throw new IllegalArgumentException();
42 |
43 | BigDecimal bd = new BigDecimal(value);
44 | bd = bd.setScale(places, RoundingMode.HALF_UP);
45 | return bd.doubleValue();
46 | }
47 |
48 | public static int randomInt(int min, int max) {
49 | return ThreadLocalRandom.current().nextInt(min, max + 1);
50 | }
51 |
52 | public static boolean isInteger(String string) {
53 | try {
54 | Integer.parseInt(string);
55 | return true;
56 | } catch (Exception e) {
57 | return false;
58 | }
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/utils/PermissionUtils.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.utils;
2 |
3 | import org.bukkit.entity.Player;
4 |
5 | import com.chrismin13.additionsapi.permissions.PermissionType;
6 |
7 | public class PermissionUtils {
8 |
9 | public static boolean allowedAction(Player player, PermissionType type, String permission) {
10 | switch(type) {
11 | case ALLOW:
12 | if (player.hasPermission(permission))
13 | return true;
14 | break;
15 | case DENY:
16 | if (!player.hasPermission(permission) || player.isOp() || player.hasPermission("*"))
17 | return true;
18 | break;
19 | }
20 | return false;
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/utils/RecipeUtils.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.utils;
2 |
3 | import org.bukkit.inventory.Recipe;
4 |
5 | import com.google.gson.JsonObject;
6 |
7 | public class RecipeUtils {
8 |
9 | public static JsonObject getRecipeJson(Recipe recipe) {
10 | JsonObject json = new JsonObject();
11 |
12 | JsonObject object=new JsonObject();
13 | object.addProperty("number", 1);
14 | object.addProperty("latitude", 2);
15 | object.addProperty("longitude", 3);
16 | object.addProperty("text", 4);
17 |
18 | return json;
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/com/chrismin13/additionsapi/utils/StringUtils.java:
--------------------------------------------------------------------------------
1 | package com.chrismin13.additionsapi.utils;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | public class StringUtils {
7 |
8 | public static List startsWith(List subcommands, String start) {
9 | if (start == null || start.equals("") || subcommands == null || subcommands.isEmpty())
10 | return subcommands;
11 |
12 | ArrayList startingStrings = new ArrayList();
13 |
14 | for (String string : subcommands)
15 | if (string.startsWith(start))
16 | startingStrings.add(string);
17 |
18 | return startingStrings;
19 |
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/com/codingforcookies/armorequip/ArmorType.java:
--------------------------------------------------------------------------------
1 | package com.codingforcookies.armorequip;
2 |
3 | import org.bukkit.Material;
4 | import org.bukkit.inventory.ItemStack;
5 |
6 | /**
7 | * @author Arnah
8 | * @since Jul 30, 2015
9 | */
10 | public enum ArmorType{
11 | HELMET(5), CHESTPLATE(6), LEGGINGS(7), BOOTS(8);
12 |
13 | private final int slot;
14 |
15 | ArmorType(int slot){
16 | this.slot = slot;
17 | }
18 |
19 | /**
20 | * Attempts to match the ArmorType for the specified ItemStack.
21 | *
22 | * @param itemStack The ItemStack to parse the type of.
23 | * @return The parsed ArmorType. (null if none were found.)
24 | */
25 | public final static ArmorType matchType(final ItemStack itemStack){
26 | if(itemStack == null || itemStack.getType().equals(Material.AIR)) return null;
27 | String type = itemStack.getType().name();
28 | if(type.endsWith("_HELMET") || type.endsWith("_SKULL")) return HELMET;
29 | else if(type.endsWith("_CHESTPLATE")) return CHESTPLATE;
30 | else if(type.endsWith("_LEGGINGS")) return LEGGINGS;
31 | else if(type.endsWith("_BOOTS")) return BOOTS;
32 | else return null;
33 | }
34 |
35 | public int getSlot(){
36 | return slot;
37 | }
38 | }
--------------------------------------------------------------------------------
/src/main/java/com/codingforcookies/armorequip/DispenserArmorListener.java:
--------------------------------------------------------------------------------
1 | package com.codingforcookies.armorequip;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.entity.Player;
5 | import org.bukkit.event.EventHandler;
6 | import org.bukkit.event.Listener;
7 | import org.bukkit.event.block.BlockDispenseArmorEvent;
8 |
9 | /**
10 | * @author Arnah
11 | * @since Feb 08, 2019
12 | */
13 | public class DispenserArmorListener implements Listener{
14 |
15 |
16 | @EventHandler
17 | public void dispenseArmorEvent(BlockDispenseArmorEvent event){
18 | ArmorType type = ArmorType.matchType(event.getItem());
19 | if(type != null){
20 | if(event.getTargetEntity() instanceof Player){
21 | Player p = (Player) event.getTargetEntity();
22 | ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(p, ArmorEquipEvent.EquipMethod.DISPENSER, type, null, event.getItem());
23 | Bukkit.getServer().getPluginManager().callEvent(armorEquipEvent);
24 | if(armorEquipEvent.isCancelled()){
25 | event.setCancelled(true);
26 | }
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/me/benfah/cu/init/impl/MinePackInitializationMethod.java:
--------------------------------------------------------------------------------
1 | package me.benfah.cu.init.impl;
2 |
3 | import java.io.File;
4 | import java.util.List;
5 |
6 | import org.openqa.selenium.By;
7 | import org.openqa.selenium.WebDriver;
8 | import org.openqa.selenium.WebElement;
9 | import org.openqa.selenium.htmlunit.HtmlUnitDriver;
10 |
11 | import com.chrismin13.additionsapi.AdditionsAPI;
12 | import com.chrismin13.additionsapi.utils.Debug;
13 |
14 | import us.fihgu.toolbox.resourcepack.ResourcePackManager;
15 |
16 | public class MinePackInitializationMethod {
17 |
18 | public static String resourcePack;
19 | public static String resourcePackHash;
20 |
21 | public static void uploadResourcePack(File f) {
22 | if (ResourcePackManager.neededRebuild) {
23 | Debug.saySuper(org.apache.http.conn.ssl.SSLConnectionSocketFactory.class.getProtectionDomain()
24 | .getCodeSource().getLocation().getPath());
25 | WebDriver driver = new HtmlUnitDriver();
26 |
27 | driver.get("https://minepack.net");
28 |
29 | WebElement element = driver.findElement(By.name("resourcepack"));
30 | element.sendKeys(f.getAbsolutePath());
31 |
32 | WebElement element2 = driver.findElement(By.name("submit"));
33 | element2.submit();
34 |
35 | List wel = driver.findElements(By.className("select"));
36 |
37 | try {
38 | resourcePack = wel.get(0).getAttribute("value").replace("https", "http");
39 | resourcePackHash = wel.get(1).getAttribute("value");
40 | } catch (IndexOutOfBoundsException e) {
41 | if (wel.isEmpty()) {
42 | Debug.saySuper("Resource Pack already exists on Minepack!");
43 | resourcePack = "http://download.nodecdn.net/containers/nodecraft/minepack/"
44 | + ResourcePackManager.resourcePackMd5 + ".zip";
45 | resourcePackHash = ResourcePackManager.resourcePackSha1;
46 | }
47 | AdditionsAPI.getInstance().getConfig().set("resource-pack.sha1",
48 | MinePackInitializationMethod.resourcePackHash);
49 | AdditionsAPI.getInstance().getConfig().set("resource-pack.link",
50 | MinePackInitializationMethod.resourcePack);
51 | }
52 | } else {
53 | resourcePack = AdditionsAPI.getInstance().getConfig().getString("resource-pack.link");
54 | resourcePackHash = AdditionsAPI.getInstance().getConfig().getString("resource-pack.sha1");
55 | }
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/http/AccessPoint.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.http;
2 |
3 | public class AccessPoint
4 | {
5 | private IReleasable resource;
6 |
7 | protected AccessPoint(IReleasable resource)
8 | {
9 | this.resource = resource;
10 | }
11 |
12 | public void release()
13 | {
14 | if(this.resource != null)
15 | {
16 | this.resource.removeAccessPoint(this);
17 | this.resource = null;
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/http/BadRequestException.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.http;
2 |
3 | /**
4 | * thrown when a HTTPRequest is like
5 | */
6 | public class BadRequestException extends Exception
7 | {
8 | private static final long serialVersionUID = 1L;
9 |
10 | public BadRequestException()
11 | {
12 | super();
13 | }
14 |
15 | public BadRequestException(String note)
16 | {
17 | super(note);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/http/ByteBufferContext.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.http;
2 |
3 | import java.io.IOException;
4 | import java.nio.ByteBuffer;
5 | import java.nio.channels.SocketChannel;
6 |
7 | public class ByteBufferContext extends HTTPContext
8 | {
9 |
10 | protected ByteBuffer buffer;
11 |
12 | public ByteBufferContext(ByteBuffer buffer)
13 | {
14 | this.buffer = buffer;
15 | }
16 |
17 | @Override
18 | public long getSize()
19 | {
20 | return buffer.limit();
21 | }
22 |
23 | @Override
24 | public synchronized long read(SocketChannel channel, long position) throws IOException
25 | {
26 | if(position >= this.getSize())
27 | {
28 | throw new IOException();
29 | }
30 |
31 | buffer.position((int)position);
32 | return channel.read(buffer);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/http/FileContext.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.http;
2 |
3 | import java.io.IOException;
4 | import java.nio.channels.FileChannel;
5 | import java.nio.channels.SeekableByteChannel;
6 | import java.nio.channels.SocketChannel;
7 | import java.nio.file.Files;
8 | import java.nio.file.Path;
9 | import java.nio.file.StandardOpenOption;
10 | import java.util.EnumSet;
11 | import java.util.LinkedList;
12 |
13 | public class FileContext extends HTTPContext implements IReleasable
14 | {
15 | protected Path path;
16 | protected SeekableByteChannel fileChannel;
17 | protected LinkedList accessPoints = new LinkedList();
18 |
19 | public FileContext(Path path)
20 | {
21 | this.path = path;
22 | }
23 |
24 | protected void construct()
25 | {
26 | try
27 | {
28 | this.fileChannel = Files.newByteChannel(path, EnumSet.of(StandardOpenOption.READ));
29 | }
30 | catch (IOException e)
31 | {
32 | e.printStackTrace();
33 | }
34 | }
35 |
36 | protected void release()
37 | {
38 | if(this.fileChannel != null)
39 | {
40 | try
41 | {
42 | this.fileChannel.close();
43 | this.fileChannel = null;
44 | }
45 | catch (IOException e)
46 | {
47 | e.printStackTrace();
48 | }
49 | }
50 | }
51 |
52 | @Override
53 | public long getSize()
54 | {
55 | try
56 | {
57 | if(this.fileChannel != null)
58 | {
59 | return fileChannel.size();
60 | }
61 | else
62 | {
63 | return 0;
64 | }
65 | }
66 | catch (IOException e)
67 | {
68 | return 0;
69 | }
70 | }
71 |
72 | @Override
73 | public synchronized long read(SocketChannel channel, long position) throws IOException
74 | {
75 | if(this.fileChannel != null)
76 | {
77 | return ((FileChannel) fileChannel).transferTo(position, this.getSize(), channel);
78 | }
79 | else
80 | {
81 | return -1;
82 | }
83 | }
84 |
85 | @Override
86 | public AccessPoint aquireAccess()
87 | {
88 | AccessPoint accessPoint = new AccessPoint(this);
89 | this.accessPoints.add(accessPoint);
90 |
91 | if(this.fileChannel == null)
92 | {
93 | this.construct();
94 | }
95 |
96 | return accessPoint;
97 | }
98 |
99 | @Override
100 | public void removeAccessPoint(AccessPoint accessPoint)
101 | {
102 | this.accessPoints.remove(accessPoint);
103 |
104 | if(this.accessPoints.size() <= 0)
105 | {
106 | this.release();
107 | }
108 | }
109 |
110 | }
111 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/http/HTTPAcceptHandler.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.http;
2 |
3 | import java.io.IOException;
4 | import java.nio.channels.SelectionKey;
5 | import java.nio.channels.ServerSocketChannel;
6 | import java.nio.channels.SocketChannel;
7 | import java.util.Calendar;
8 |
9 | import com.chrismin13.additionsapi.utils.Debug;
10 |
11 | import us.fihgu.toolbox.web.SelectionHandler;
12 |
13 | public class HTTPAcceptHandler implements SelectionHandler
14 | {
15 | private HTTPServer server;
16 |
17 | public HTTPAcceptHandler(HTTPServer server)
18 | {
19 | this.server = server;
20 | }
21 |
22 | @Override
23 | public void handleSelection(SelectionKey selectionKey)
24 | {
25 | try
26 | {
27 | if(selectionKey.isAcceptable())
28 | {
29 | SocketChannel client = ((ServerSocketChannel)selectionKey.channel()).accept();
30 | client.configureBlocking(false);
31 |
32 | HTTPRequest request = new HTTPRequest(server);
33 | SelectionKey key = server.readPool.getLightest().register(client, request);
34 |
35 | server.timer.putTimer(key, Calendar.getInstance().getTimeInMillis() + server.timeOut);
36 |
37 | if(server.info)
38 | {
39 | Debug.sayTrue("HTTP connect: " + client.getRemoteAddress().toString());
40 | }
41 | }
42 | }
43 | catch (IOException e)
44 | {
45 | e.printStackTrace();
46 | }
47 | }
48 |
49 | @Override
50 | public int getDefaultInterestSet()
51 | {
52 | return SelectionKey.OP_ACCEPT;
53 | }
54 |
55 | @Override
56 | public void onRegister(SelectionKey key)
57 | {
58 |
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/http/HTTPContext.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.http;
2 |
3 | import java.io.IOException;
4 | import java.nio.channels.SocketChannel;
5 |
6 | /**
7 | * a HTTPContext is a resource that's related to a web path
8 | * HTTPContext has a few important properties:
9 | * It is thread safe.
10 | * Any Thread can read from a random position of the resource at any time.
11 | * @author fihgu
12 | *
13 | */
14 | public abstract class HTTPContext
15 | {
16 | protected String path;
17 |
18 | public abstract long getSize();
19 |
20 | /**
21 | * read as much bytes as possible, from the resource to the given channel.
22 | * @param channel the channel to write to
23 | * @param contextPosition the beginning position to read, inclusive.
24 | * @return the number of bytes actually read
25 | * @throws IOException
26 | */
27 | public abstract long read(SocketChannel channel, long contextPosition) throws IOException;
28 |
29 | public String getPath()
30 | {
31 | return this.path;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/http/HTTPRequest.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.http;
2 |
3 | import java.nio.ByteBuffer;
4 | import java.util.HashMap;
5 |
6 | public class HTTPRequest
7 | {
8 | protected ByteBuffer readBuffer;
9 | protected StringBuilder lineBuilder;
10 |
11 | public HTTPRequest(HTTPServer server)
12 | {
13 | readBuffer = ByteBuffer.allocate(server.readBufferSize);
14 | lineBuilder = new StringBuilder(server.lineBuilderSize);
15 | }
16 |
17 | public HTTPRequestMethod method;
18 | public String path;
19 | public String version;
20 |
21 | public HashMap headers = new HashMap();
22 | public ByteBuffer body;
23 |
24 | @Override
25 | public String toString()
26 | {
27 | String text = this.method.name() + " " + this.path + " " + this.version + "\r\n";
28 | for(String key : this.headers.keySet())
29 | {
30 | String value = this.headers.get(key);
31 | text += key + ": " + value + "\r\n";
32 | }
33 | text += "\r\n";
34 | text += "body -> " + this.body;
35 |
36 | return text;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/http/HTTPRequestMethod.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.http;
2 |
3 |
4 | public enum HTTPRequestMethod
5 | {
6 | GET, POST, HEAD;
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/http/HTTPResponse.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.http;
2 |
3 | import java.nio.ByteBuffer;
4 | import java.text.DateFormat;
5 | import java.text.SimpleDateFormat;
6 | import java.util.Calendar;
7 | import java.util.HashMap;
8 | import java.util.Locale;
9 | import java.util.TimeZone;
10 |
11 | public class HTTPResponse
12 | {
13 | private static DateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
14 |
15 | protected ByteBuffer buffer;
16 | protected AccessPoint accessPoint;
17 | protected long contextPosition = 0;
18 |
19 | public String version = "HTTP/1.1";
20 | public int code = 200;
21 | public String reason = "OK";
22 |
23 | public HashMap headers = new HashMap();
24 |
25 | public HTTPContext context;
26 |
27 | public HTTPResponse(ResponseCode code, HTTPContext context)
28 | {
29 | if(code != null)
30 | {
31 | this.code = code.getCode();
32 | this.reason = code.toString();
33 | }
34 |
35 | this.context = context;
36 |
37 | //default headers
38 | String time = dateFormat.format(Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime());
39 | headers.put("Date", time);
40 | headers.put("Server", "fihgu's HTTP Server/1.0");
41 | headers.put("Connection", "close");
42 |
43 | if(this.context != null)
44 | {
45 | if(context instanceof IReleasable)
46 | {
47 | if(accessPoint == null)
48 | {
49 | IReleasable releasable = (IReleasable)context;
50 | this.accessPoint = releasable.aquireAccess();
51 | }
52 | }
53 |
54 | headers.put("Content-Length", "" + context.getSize());
55 | }
56 | }
57 |
58 | @Override
59 | public String toString()
60 | {
61 | StringBuilder builder = new StringBuilder(this.getHeaderString());
62 |
63 | builder.append("Context -> ").append(this.context);
64 |
65 | return builder.toString();
66 | }
67 |
68 | /**
69 | *
70 | * @return the header of this response, ready to be encoded and sent.
71 | */
72 | public String getHeaderString()
73 | {
74 | StringBuilder builder = new StringBuilder(128);
75 |
76 | builder.append(this.version).append(" ").append(code).append(" ").append(reason).append("\r\n");
77 | for(String key: this.headers.keySet())
78 | {
79 | String value = this.headers.get(key);
80 | builder.append(key).append(": ").append(value).append("\r\n");
81 | }
82 | builder.append("\r\n");
83 |
84 |
85 |
86 | return builder.toString();
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/http/IContextGenerator.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.http;
2 |
3 | public interface IContextGenerator
4 | {
5 | HTTPContext generateContext(HTTPRequest request);
6 | }
7 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/http/IReleasable.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.http;
2 |
3 | /**
4 | * A resource that can be released, reconstructed.
5 | * An implementation should keep a track of all access points that uses this resource
6 | * When all access points are released, it should release resource used.
7 | * @author fihgu
8 | */
9 | public interface IReleasable
10 | {
11 | /**
12 | * Open an new access point, register and return it.
13 | * implementation should check and reconstruct the resource if needed.
14 | */
15 | AccessPoint aquireAccess();
16 |
17 | /**
18 | * release a registered accessPoint.
19 | * implementation should check if there is any accessPoint left, and release the resource accordingly.
20 | */
21 | void removeAccessPoint(AccessPoint accessPoint);
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/http/ResponseCode.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.http;
2 |
3 |
4 | public enum ResponseCode
5 | {
6 | /**
7 | * The request has succeeded
8 | */
9 | OK(200),
10 | /**
11 | * The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.
12 | */
13 | BAD_REQUEST(400),
14 | /**
15 | * The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable.
16 | */
17 | NOT_FOUND(404),
18 | /**
19 | * The server encountered an unexpected condition which prevented it from fulfilling the request.
20 | */
21 | INTERNAL_SERVER_ERROR(500),
22 | /**
23 | * The server does not support, or refuses to support, the HTTP protocol version that was used in the request message.
24 | */
25 | HTTP_VERSION_NOT_SUPPORTED(505),
26 | /**
27 | * The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat the request without modifications at any later time.
28 | */
29 | REQUEST_TIMEOUT(408);
30 | private int code;
31 | ResponseCode(int code)
32 | {
33 | this.code = code;
34 | }
35 |
36 | public int getCode()
37 | {
38 | return this.code;
39 | }
40 |
41 | @Override
42 | public String toString()
43 | {
44 | return this.name().replace('_', ' ');
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/http/StaticContextGenerator.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.http;
2 |
3 |
4 | public class StaticContextGenerator implements IContextGenerator
5 | {
6 | HTTPContext context;
7 | public StaticContextGenerator(HTTPContext context)
8 | {
9 | this.context = context;
10 | }
11 |
12 | @Override
13 | public HTTPContext generateContext(HTTPRequest request)
14 | {
15 | return context;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/item/BowModelInjection.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.item;
2 |
3 | import us.fihgu.toolbox.resourcepack.model.ItemModel;
4 | import us.fihgu.toolbox.resourcepack.model.Predicate;
5 |
6 | public class BowModelInjection extends ModelInjection {
7 |
8 | private boolean isStandby;
9 |
10 | public BowModelInjection(Predicate predicate, String modelName, ItemModel model, boolean isStandby) {
11 | super(predicate, modelName, model);
12 | this.setStandby(isStandby);
13 | }
14 |
15 | /**
16 | * @return the isStandby
17 | */
18 | public boolean isStandby() {
19 | return isStandby;
20 | }
21 |
22 | /**
23 | * @param isStandby the isStandby to set
24 | */
25 | public BowModelInjection setStandby(boolean isStandby) {
26 | this.isStandby = isStandby;
27 | return this;
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/item/ModelInjection.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.item;
2 |
3 | import us.fihgu.toolbox.resourcepack.model.ItemModel;
4 | import us.fihgu.toolbox.resourcepack.model.Predicate;
5 |
6 | /**
7 | * Used for injecting custom item model.
8 | */
9 | public class ModelInjection {
10 | /**
11 | * when to use this model, can be an empty instance, but should never be
12 | * null.
13 | */
14 | private Predicate predicate;
15 |
16 | /**
17 | * The name of the model (ex: 'item/example'), if the same name is already
18 | * used, the older model will be overrode.
19 | *
20 | * The best way to ensure your model name is unique is to prefix it with
21 | * your plugin's name
22 | *
23 | */
24 | private String modelName;
25 |
26 | /**
27 | * The model to use.
28 | *
29 | * Hint: use {@link ItemModel#createSimpleItemModel(String, String)} to
30 | * quickly create a model.
31 | *
32 | */
33 | private ItemModel model;
34 |
35 | /**
36 | * @param predicate
37 | * See {@link #predicate}
38 | * @param modelName
39 | * See {@link #modelName}
40 | * @param model
41 | * See {@link #model}
42 | */
43 | public ModelInjection(Predicate predicate, String modelName, ItemModel model) {
44 | this.predicate = predicate;
45 | this.modelName = modelName;
46 | this.model = model;
47 | }
48 |
49 | /**
50 | * @return See {@link #predicate}
51 | */
52 | public Predicate getPredicate() {
53 | return predicate;
54 | }
55 |
56 | /**
57 | * @return See {@link #modelName}
58 | */
59 | public String getModelName() {
60 | return modelName;
61 | }
62 |
63 | /**
64 | * @return See {@link #model}
65 | */
66 | public ItemModel getModel() {
67 | return model;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/json/JsonUtils.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.json;
2 |
3 |
4 | import java.io.File;
5 | import java.io.FileInputStream;
6 | import java.io.FileNotFoundException;
7 | import java.io.FileOutputStream;
8 | import java.io.IOException;
9 | import java.io.PrintWriter;
10 | import java.util.Scanner;
11 |
12 | import com.google.gson.Gson;
13 | import com.google.gson.GsonBuilder;
14 | import com.google.gson.JsonSyntaxException;
15 |
16 | import us.fihgu.toolbox.file.FileUtils;
17 |
18 | public class JsonUtils
19 | {
20 | static Gson gson = new GsonBuilder().setPrettyPrinting().create();
21 |
22 | /**
23 | * Read a json object from the given file, and try to cast the read object to the given class.
24 | * @return the read object, or null if the file doesn't exist.
25 | * @throws JsonSyntaxException when there is a syntax error in this json file
26 | */
27 | public static T fromFile(File file, Class type)
28 | {
29 | if(file.exists())
30 | {
31 | StringBuilder str = new StringBuilder();
32 | try(Scanner scan = new Scanner(new FileInputStream(file)))
33 | {
34 | while(scan.hasNextLine())
35 | {
36 | str.append(scan.nextLine());
37 | }
38 |
39 | return gson.fromJson(str.toString(), type);
40 | }
41 | catch (FileNotFoundException e)
42 | {
43 | //should never happen
44 | e.printStackTrace();
45 | }
46 | }
47 | return null;
48 | }
49 |
50 | /**
51 | * Write the given object to the given file.
52 | * Note: If file already contain data, the old data will be discarded.
53 | */
54 | public static void toFile(File file, Object obj)
55 | {
56 | if(!file.exists())
57 | {
58 | try
59 | {
60 | FileUtils.createFileAndPath(file);
61 | }
62 | catch (IOException e)
63 | {
64 | e.printStackTrace();
65 | }
66 | }
67 |
68 | String str = toJson(obj);
69 | try(PrintWriter out = new PrintWriter(new FileOutputStream(file, false)))
70 | {
71 | out.print(str);
72 | out.flush();
73 | }
74 | catch (FileNotFoundException e)
75 | {
76 | e.printStackTrace();
77 | }
78 | }
79 |
80 | /**
81 | * @return A json string representation of this object.
82 | */
83 | public static String toJson(Object obj)
84 | {
85 | return gson.toJson(obj);
86 | }
87 |
88 | /**
89 | * See {@link Gson#fromJson(String, Class)}
90 | */
91 | public static T fromJson(String json, Class type)
92 | {
93 | return gson.fromJson(json, type);
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/network/NetworkUtils.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.network;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.IOException;
5 | import java.io.InputStreamReader;
6 | import java.net.InetAddress;
7 | import java.net.NetworkInterface;
8 | import java.net.SocketException;
9 | import java.net.URL;
10 | import java.net.URLConnection;
11 | import java.net.UnknownHostException;
12 | import java.util.Enumeration;
13 |
14 | import com.chrismin13.additionsapi.utils.Debug;
15 |
16 | public class NetworkUtils {
17 |
18 | /**
19 | * @return the non loop back LAN IP of this computer.
20 | */
21 | public static InetAddress getLocalIP() {
22 | try {
23 | Enumeration interfaces = NetworkInterface.getNetworkInterfaces();
24 | while (interfaces.hasMoreElements()) {
25 | NetworkInterface networkInterface = interfaces.nextElement();
26 | if (!networkInterface.isLoopback()) {
27 | Enumeration addresses = networkInterface.getInetAddresses();
28 | while (addresses.hasMoreElements()) {
29 | InetAddress address = addresses.nextElement();
30 | if (address.isSiteLocalAddress()) {
31 | return address;
32 | }
33 | }
34 | }
35 | }
36 | } catch (SocketException e1) {
37 | e1.printStackTrace();
38 | }
39 |
40 | try {
41 | return InetAddress.getLocalHost();
42 | } catch (UnknownHostException e) {
43 | e.printStackTrace();
44 | }
45 |
46 | return InetAddress.getLoopbackAddress();
47 | }
48 |
49 | /**
50 | *
51 | * @return
52 | */
53 | public static String getExternalIP() {
54 | String ip = null;
55 | try {
56 | URL whatismyip = new URL("http://agentgatech.appspot.com");
57 | URLConnection connection = whatismyip.openConnection();
58 | BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
59 | ip = in.readLine();
60 | } catch (IOException e) {
61 | try {
62 | // appspot.com is blocked in China as it is from Google. The following is a good alternative.
63 | URL whatismyip2 = new URL("http://checkip.amazonaws.com/");
64 | URLConnection connection2 = whatismyip2.openConnection();
65 | BufferedReader in2 = new BufferedReader(new InputStreamReader(connection2.getInputStream()));
66 | ip = in2.readLine();
67 | } catch (IOException e2) {
68 | Debug.sayError(
69 | "A connection to agentgatech.appspot.com or checkip.amazonaws.com could not be achieved! Please check your internet connection and if the website is down!");
70 | Debug.sayError("Localhost will be used instead.");
71 | }
72 |
73 | }
74 |
75 | return ip;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/reflection/ReflectionUtils.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.reflection;
2 |
3 | import java.lang.reflect.Field;
4 |
5 | import org.bukkit.Bukkit;
6 |
7 | public class ReflectionUtils {
8 | final public static String NMSPath = "net.minecraft.server.";
9 | final public static String craftbukkitPath = "org.bukkit.craftbukkit.";
10 |
11 | /**
12 | * gets the current version of minecraft.
13 | */
14 | public static String getMinecraftVersion() {
15 | return Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
16 | }
17 |
18 | public static Class> getClass(String className) {
19 | try {
20 | Class> result = Class.forName(className);
21 | return result;
22 | } catch (ClassNotFoundException e) {
23 | e.printStackTrace();
24 | }
25 |
26 | return null;
27 | }
28 |
29 | public static Class> getNMSClass(String className) {
30 | return getClass(NMSPath + getMinecraftVersion() + "." + className);
31 | }
32 |
33 | public static Class> getCraftBukkitClass(String className) {
34 | return getClass(craftbukkitPath + getMinecraftVersion() + "." + className);
35 | }
36 |
37 | public static Field findUnderlyingField(Class> clazz, String fieldName) {
38 | Class> current = clazz;
39 | do {
40 | try {
41 | return current.getDeclaredField(fieldName);
42 | } catch (Exception e) {
43 | }
44 | } while ((current = current.getSuperclass()) != null);
45 | return null;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/resourcepack/model/BlockModel.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.resourcepack.model;
2 |
3 | /**
4 | * A block model, can be used to generate json string to be used in the resource pack.
5 | */
6 | public class BlockModel extends Model
7 | {
8 | /**
9 | * Whether to use ambient occlusion
10 | * Default : true
11 | */
12 | protected Boolean ambientocclusion;
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/resourcepack/model/DisplayOptions.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.resourcepack.model;
2 |
3 | /**
4 | * Defines how this model look in different perspectives
5 | */
6 | public class DisplayOptions
7 | {
8 | private DisplayEntry thirdperson_righthand;
9 | private DisplayEntry thirdperson_lefthand;
10 | private DisplayEntry firstperson_righthand;
11 | private DisplayEntry firstperson_lefthand;
12 | private DisplayEntry gui;
13 | private DisplayEntry head;
14 | private DisplayEntry ground;
15 | private DisplayEntry fixed;
16 |
17 | public DisplayEntry getThirdperson_righthand()
18 | {
19 | return thirdperson_righthand;
20 | }
21 |
22 | public void setThirdperson_righthand(DisplayEntry thirdperson_righthand)
23 | {
24 | this.thirdperson_righthand = thirdperson_righthand;
25 | }
26 |
27 | public DisplayEntry getThirdperson_lefthand()
28 | {
29 | return thirdperson_lefthand;
30 | }
31 |
32 | public void setThirdperson_lefthand(DisplayEntry thirdperson_lefthand)
33 | {
34 | this.thirdperson_lefthand = thirdperson_lefthand;
35 | }
36 |
37 | public DisplayEntry getFirstperson_righthand()
38 | {
39 | return firstperson_righthand;
40 | }
41 |
42 | public void setFirstperson_righthand(DisplayEntry firstperson_righthand)
43 | {
44 | this.firstperson_righthand = firstperson_righthand;
45 | }
46 |
47 | public DisplayEntry getFirstperson_lefthand()
48 | {
49 | return firstperson_lefthand;
50 | }
51 |
52 | public void setFirstperson_lefthand(DisplayEntry firstperson_lefthand)
53 | {
54 | this.firstperson_lefthand = firstperson_lefthand;
55 | }
56 |
57 | public DisplayEntry getGui()
58 | {
59 | return gui;
60 | }
61 |
62 | public void setGui(DisplayEntry gui)
63 | {
64 | this.gui = gui;
65 | }
66 |
67 | public DisplayEntry getHead()
68 | {
69 | return head;
70 | }
71 |
72 | public void setHead(DisplayEntry head)
73 | {
74 | this.head = head;
75 | }
76 |
77 | public DisplayEntry getGround()
78 | {
79 | return ground;
80 | }
81 |
82 | public void setGround(DisplayEntry ground)
83 | {
84 | this.ground = ground;
85 | }
86 |
87 | public DisplayEntry getFixed()
88 | {
89 | return fixed;
90 | }
91 |
92 | /**
93 | * @param fixed refers to item frames
94 | */
95 | public void setFixed(DisplayEntry fixed)
96 | {
97 | this.fixed = fixed;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/resourcepack/model/ElementFaceOptions.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.resourcepack.model;
2 |
3 | /**
4 | * Holds all the faces of the cube. If a face is left out, it will not be rendered.
5 | */
6 | public class ElementFaceOptions
7 | {
8 | protected ElementFaceEntry down;
9 | protected ElementFaceEntry up;
10 | protected ElementFaceEntry north;
11 | protected ElementFaceEntry south;
12 | protected ElementFaceEntry west;
13 | protected ElementFaceEntry east;
14 |
15 | public ElementFaceEntry getDown()
16 | {
17 | return down;
18 | }
19 |
20 | public void setDown(ElementFaceEntry down)
21 | {
22 | this.down = down;
23 | }
24 |
25 | public ElementFaceEntry getUp()
26 | {
27 | return up;
28 | }
29 |
30 | public void setUp(ElementFaceEntry up)
31 | {
32 | this.up = up;
33 | }
34 |
35 | public ElementFaceEntry getNorth()
36 | {
37 | return north;
38 | }
39 |
40 | public void setNorth(ElementFaceEntry north)
41 | {
42 | this.north = north;
43 | }
44 |
45 | public ElementFaceEntry getSouth()
46 | {
47 | return south;
48 | }
49 |
50 | public void setSouth(ElementFaceEntry south)
51 | {
52 | this.south = south;
53 | }
54 |
55 | public ElementFaceEntry getWest()
56 | {
57 | return west;
58 | }
59 |
60 | public void setWest(ElementFaceEntry west)
61 | {
62 | this.west = west;
63 | }
64 |
65 | public ElementFaceEntry getEast()
66 | {
67 | return east;
68 | }
69 |
70 | public void setEast(ElementFaceEntry east)
71 | {
72 | this.east = east;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/resourcepack/model/ElementRotation.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.resourcepack.model;
2 |
3 | /**
4 | * describes how a {@link ModelElement} rotates.
5 | */
6 | public class ElementRotation
7 | {
8 | /**
9 | * Sets the center of the rotation according to the scheme [x, y, z], defaults to [8, 8, 8].
10 | */
11 | protected double[] origin;
12 |
13 | /**
14 | * Specifies the direction of rotation
15 | */
16 | protected ModelAxis axis;
17 |
18 | /**
19 | * Specifies the angle of rotation. Can be 45 through -45 degrees in 22.5 degree increments. Defaults to 0.
20 | */
21 | protected Double angle;
22 |
23 | /**
24 | * Specifies whether or not to scale the faces across the whole block. Can be true or false. Defaults to false.
25 | */
26 | protected Boolean rescale;
27 |
28 | public ElementRotation()
29 | {
30 | }
31 |
32 | /**
33 | * @param origin See {@link #origin}
34 | * @param axis See {@link #axis}
35 | * @param angle See {@link #angle}
36 | * @param rescale See {@link #rescale}
37 | */
38 | public ElementRotation(double[] origin, ModelAxis axis, Double angle, Boolean rescale)
39 | {
40 | this.setOrigin(origin);
41 | this.setAxis(axis);
42 | this.setAngle(angle);
43 | this.setRescale(rescale);
44 | }
45 |
46 | /**
47 | * See {@link #origin}
48 | */
49 | public double[] getOrigin()
50 | {
51 | return origin;
52 | }
53 |
54 | /**
55 | * See {@link #origin}
56 | */
57 | public void setOrigin(double[] origin)
58 | {
59 | this.origin = origin;
60 | }
61 |
62 | /**
63 | * See {@link #axis}
64 | */
65 | public ModelAxis getAxis()
66 | {
67 | return axis;
68 | }
69 |
70 | /**
71 | * See {@link #axis}
72 | */
73 | public void setAxis(ModelAxis axis)
74 | {
75 | this.axis = axis;
76 | }
77 |
78 | /**
79 | * See {@link #angle}
80 | */
81 | public Double getAngle()
82 | {
83 | return angle;
84 | }
85 |
86 | /**
87 | * See {@link #angle}
88 | */
89 | public void setAngle(Double angle)
90 | {
91 | this.angle = angle;
92 | }
93 |
94 | /**
95 | * See {@link #rescale}
96 | */
97 | public Boolean getRescale()
98 | {
99 | return rescale;
100 | }
101 |
102 | /**
103 | * See {@link #rescale}
104 | */
105 | public void setRescale(Boolean rescale)
106 | {
107 | this.rescale = rescale;
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/resourcepack/model/ItemModel.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.resourcepack.model;
2 |
3 | import java.util.LinkedList;
4 | import java.util.List;
5 |
6 | /**
7 | * A model used for an item
8 | */
9 | @SuppressWarnings("unused")
10 | public class ItemModel extends Model {
11 | /**
12 | * determine which item model should be used base on the predicate values
13 | */
14 | protected List overrides;
15 |
16 | /**
17 | * See {@link #overrides}
18 | */
19 | public List getOverrides() {
20 | return overrides;
21 | }
22 |
23 | /**
24 | * See {@link #overrides}
25 | */
26 | public void setOverrides(List overrides) {
27 | this.overrides = overrides;
28 | }
29 |
30 | /**
31 | * See {@link #overrides}
32 | * creates a new Override list if one is not present
33 | */
34 | public void addOverride(OverrideEntry entry) {
35 | if (this.overrides == null) {
36 | this.overrides = new LinkedList<>();
37 | }
38 |
39 | this.overrides.add(entry);
40 | }
41 |
42 | /**
43 | * create a simple item model with a parent and texture.
44 | */
45 | public static ItemModel createSimpleItemModel(String parent, String texture) {
46 | ItemModel model = new ItemModel();
47 | model.setParent(parent);
48 | model.putTexture("layer0", texture);
49 | return model;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/resourcepack/model/ModelAxis.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.resourcepack.model;
2 |
3 | /**
4 | * the axises used by the model system.
5 | */
6 | public enum ModelAxis
7 | {
8 | x,y,z
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/resourcepack/model/ModelFace.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.resourcepack.model;
2 |
3 | /**
4 | * Faces of a model
5 | */
6 | public enum ModelFace
7 | {
8 | down, up, north, south, west, east
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/web/SelectionHandler.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.web;
2 |
3 | import java.nio.channels.SelectionKey;
4 |
5 | public interface SelectionHandler
6 | {
7 | void handleSelection(SelectionKey selectionKey);
8 | int getDefaultInterestSet();
9 | void onRegister(SelectionKey key);
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/web/SelectorThreadPool.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.web;
2 |
3 | import java.io.IOException;
4 | import java.util.Iterator;
5 | import java.util.LinkedList;
6 |
7 | /**
8 | * A SelectorThreadPool holds a number of {@link SelectorThread}
9 | * It is responsible for balancing the work load of each Selector Thread.
10 | * All SelectorThreads under the same SelectorThreadPool is expected to be using the same SelectionHandler and do the same task
11 | */
12 | public class SelectorThreadPool
13 | {
14 | LinkedList pool = new LinkedList();
15 |
16 | /**
17 | * @param numThreads the number of SelectorThreads in this pool
18 | * @throws IOException
19 | */
20 | public SelectorThreadPool(SelectionHandler handler, int numThreads) throws IOException
21 | {
22 | for(int i = 0; i < numThreads; i++)
23 | {
24 | pool.add(new SelectorThread(handler));
25 | }
26 | }
27 |
28 | /**
29 | * @return a valid SelectorThread with the Lightest work load.
30 | * return null if this pool is empty or no valid SelectorThread exists.
31 | */
32 | public SelectorThread getLightest()
33 | {
34 | SelectorThread lightest = null;
35 |
36 | Iterator iterator = this.pool.iterator();
37 | while(iterator.hasNext())
38 | {
39 | SelectorThread thread = iterator.next();
40 | if(thread.isValid())
41 | {
42 | if(lightest == null)
43 | {
44 | lightest = thread;
45 | }
46 | else if(lightest.getKeySize() > thread.getKeySize())
47 | {
48 | lightest = thread;
49 | }
50 | }
51 | }
52 |
53 | return lightest;
54 | }
55 |
56 | public void startAll()
57 | {
58 | for(SelectorThread thread : this.pool)
59 | {
60 | thread.start();
61 | }
62 | }
63 |
64 | /**
65 | * close all SelectorThreads in this pool.
66 | * this method will block until all Threads are closed.
67 | */
68 | public void closeAll()
69 | {
70 | for(SelectorThread thread : this.pool)
71 | {
72 |
73 | try
74 | {
75 | synchronized (thread)
76 | {
77 | if(!thread.isStopped())
78 | {
79 | thread.closeSelector();
80 | thread.wait();
81 | }
82 | }
83 | }
84 | catch (InterruptedException e)
85 | {
86 | e.printStackTrace();
87 | }
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/src/main/java/us/fihgu/toolbox/web/TimerThread.java:
--------------------------------------------------------------------------------
1 | package us.fihgu.toolbox.web;
2 |
3 | import java.nio.channels.SelectionKey;
4 | import java.util.Calendar;
5 | import java.util.HashMap;
6 | import java.util.Iterator;
7 |
8 | public class TimerThread extends Thread
9 | {
10 |
11 | private boolean isRunning = true;
12 | private WebServer server;
13 |
14 | private HashMap dueTimes = new HashMap();
15 |
16 | public TimerThread(WebServer server)
17 | {
18 | this.server = server;
19 | }
20 |
21 | @Override
22 | public void run()
23 | {
24 | while(isRunning)
25 | {
26 | synchronized(this.dueTimes)
27 | {
28 | long now = Calendar.getInstance().getTimeInMillis();
29 | Iterator iterator = dueTimes.keySet().iterator();
30 | while(iterator.hasNext())
31 | {
32 | SelectionKey key = iterator.next();
33 | Long dueTime = dueTimes.get(key);
34 | if(now >= dueTime)
35 | {
36 | iterator.remove();
37 | server.onTimeOut(key);
38 | }
39 | }
40 | }
41 |
42 |
43 | try
44 | {
45 | Thread.sleep(1000);
46 | }
47 | catch (InterruptedException e)
48 | {
49 | e.printStackTrace();
50 | }
51 | }
52 | }
53 |
54 | public void putTimer(SelectionKey selectionKey, long timeOutTime)
55 | {
56 | synchronized(this.dueTimes)
57 | {
58 | this.dueTimes.put(selectionKey, timeOutTime);
59 | }
60 | }
61 |
62 | public void removeTimer(SelectionKey selectionKey)
63 | {
64 | synchronized(this.dueTimes)
65 | {
66 | this.dueTimes.remove(selectionKey);
67 | }
68 | }
69 |
70 | public void stopThread()
71 | {
72 | this.isRunning = false;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/resources/plugin.yml:
--------------------------------------------------------------------------------
1 | name: AdditionsAPI
2 | version: 1.3.3
3 | main: com.chrismin13.additionsapi.AdditionsAPI
4 | author: chrismin13
5 | api-version: 1.13
6 |
7 | commands:
8 | additions:
9 | description: Main Command of the Additions API.
10 | usage: /
11 | permission: additionsapi
12 | permission-message: You don't have permission to use this command!
--------------------------------------------------------------------------------
/src/main/resources/resource/no_hoe_sound.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chrismin13/AdditionsAPI/65afcc782d66700372f7687f8ab40b10b3203252/src/main/resources/resource/no_hoe_sound.zip
--------------------------------------------------------------------------------
/src/main/resources/resource/pack.mcmeta:
--------------------------------------------------------------------------------
1 | {
2 | "pack":{
3 | "pack_format":3,
4 | "description":"Required for the Custom Items."
5 | }
6 | }
--------------------------------------------------------------------------------
/src/main/resources/resource/pack.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chrismin13/AdditionsAPI/65afcc782d66700372f7687f8ab40b10b3203252/src/main/resources/resource/pack.png
--------------------------------------------------------------------------------
/src/main/resources/resource/smooth_armor.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chrismin13/AdditionsAPI/65afcc782d66700372f7687f8ab40b10b3203252/src/main/resources/resource/smooth_armor.zip
--------------------------------------------------------------------------------