PluginBugs / Issues-ItemsAdder

Repository used to keep track of issues of my plugin ItemsAdder
https://itemsadder.devs.beer
54 stars 21 forks source link

[Suggestion] The great java API update #534

Closed YouHaveTrouble closed 3 years ago

YouHaveTrouble commented 3 years ago

I'm opening this to list all methods that I'd see as useful to have in java API <3

CustomItem object that would hold all custom item methods.

     // Ideally you would want to extend ItemStack to allow casting like
    CustomItem customItem = (CustomItem) itemStack;

    // and have a costructor because why not
    CustomItem customItem = new CustomItem(itemStack);

    CustomItem.getMaxDurability() // Would get max custom durability
    CustomItem.getDurability() // Would get current custom durability
    CustomItem.setDurability(int) // Would set custom durability
    CustomItem.getUsages() // Would get custom usages
    CustomItem.setUsages(int) // Would set custom usages
    CustomItem.getBlockData() // Would get custom block data

CustomBlock would be same treatment as CustomItem, so:

    CustomBlock customBlock = new CustomBlock(block);

    CustomBlock.getItem() // Would get CustomItem object (replacement for current `ItemsAdder.getCustomBlock()`)
    CustomBlock.getBlockData() // would return blockdata
    CustomBlock.getLoot() // would return list of ItemStack
    CustomBlock.remove() // would remove custom block (replacement for current `ItemsAdder.removeCustomBlock()`)
    CustomBlock.getLightLevel() // would get block light level
    CustomBlock.setLightLevel() // would set block light level

CustomCrop would extend CustomBlock

    CustomCrop customCrop = (CustomCrop) customBlock;

    CustomCrop.getCustomGrowthStage() // Would get growth stage of crop
    CustomCrop.setCustomGrowthStage() // Would set growth stage of crop (for custom bonemeal behaviour etc)
    CustomCrop.grow() // Would advance crop growth by 1 stage
    CustomCrop.getSeed() // Would get CustomItem for crops seed

CustomMob woud extend Mob or Entity, or whatever, I don't really know how exaclty those work yet.

    CustomMob.getName() // Would return custom mob name (for custom AI stuff)

And icing on the cake, the ItemsAdder class itself! I'm assuming the current classes are staying as deprecated, so I'll only cover additional stuff.

    ItemsAdder.getEmojis() // would return a map of all available emojis as namespace:name as key and :emoji_string: as value
    ItemsAdder.playTotemAnimation(player, totem_id) // would play selected totem animation to player using namespace:name

That's all I can think of for now, will update this if I think of something more/better

LoneDev6 commented 3 years ago

Currently working on the CustomStack thing, today I will work on the other requests image

YouHaveTrouble commented 3 years ago

While rewriting items like that, can you make custom durability work on items with no normal durability? Basically just a number with no use of actual durability bar? Would that be possible?

LoneDev6 commented 3 years ago

While rewriting items like that, can you make custom durability work on items with no normal durability? Basically just a number with no use of actual durability bar? Would that be possible?

Not without a complete rewrite of the system. You can use "usages" for this purpose

LoneDev6 commented 3 years ago

Here are the changes of the new API: https://github.com/LoneDev6/ItemsAdder-API/commit/d54933a359730091fa0cdb2c990e93716a0d5a23

I will post also ItemsAdder jar update so you can actually use the API. For now you can code if you import the API from the repo I sent

YouHaveTrouble commented 3 years ago

Yes, maven api is a great option, I hope it will get updated with the api updates so I don't have to redownload the jar lol

LoneDev6 commented 3 years ago

Already did

<dependency>
    <groupId>com.github.LoneDev6</groupId>
    <artifactId>itemsadder-api</artifactId>
    <version>2.1.25</version>
    <scope>provided</scope>
</dependency>
YouHaveTrouble commented 3 years ago

oh, I meant the api updates in the future ;)

LoneDev6 commented 3 years ago

You have to download the itemsadder jar if you own the plugin and you want to test the API ingame. If you just want to add compatibility to your plugins you don't really have to install itemsadder jar in your server, you only have to import the maven api and code 😄