官术网_书友最值得收藏!

Introduction to APIs

API is an acronym for Application Programming Interface. An API helps to control how various software components are used. As mentioned in the previous chapter, CraftBukkit includes the Minecraft code in a form that is easier for developers to utilize in creating plugins. CraftBukkit has a lot of code that we do not need to access for creating plugins. It also includes code that we should not use as it could cause the server to become unstable. Bukkit provides us with the classes that we can use to properly modify the game. Basically, Bukkit acts as a bridge between our plugin and the CraftBukkit server. The Bukkit team adds new classes, methods, and so on, to the API as new features develop in Minecraft, but the preexisting code rarely changes. This ensures that our Bukkit plugins will still function correctly months or even years from now. Even though new versions of Minecraft/CraftBukkit are being released. For example, if Minecraft were to change how an entity's health is handled, we would notice no difference.

The CraftBukkit jar would account for this change and when our plugin calls the getHealth() method it would function exactly as it had before the update. Another example of how great the Bukkit API is would be the addition of new Minecraft features, such as new items. Let's say that we've created a plugin that gives food an expiration date. To see if an item is food we'd use the isEdible() method. Minecraft continues to create new items. If one of these new items was Pumpkin Bread, CraftBukkit would flag that type of item as edible and would therefore be given an expiration date by our plugin. A year from now, any new food items would still be given expiration dates without us needing to change any of our code.

主站蜘蛛池模板: 方正县| 阳东县| 浪卡子县| 远安县| 营口市| 丰宁| 遂溪县| 富锦市| 乐清市| 博湖县| 莎车县| 镶黄旗| 双桥区| 嵊泗县| 淮滨县| 新乐市| 师宗县| 余干县| 双流县| 日照市| 蓬安县| 禹州市| 曲阜市| 凤冈县| 甘泉县| 安远县| 永平县| 镇安县| 昆山市| 仙游县| 京山县| 浑源县| 成安县| 巴林右旗| 赤壁市| 峨山| 伊宁市| 塔河县| 开封县| 保康县| 璧山县|