- Building Minecraft Server Modifications(Second Edition)
- Cody M. Sommer
- 532字
- 2021-07-30 09:52:21
Exploring the Bukkit API
Now that you are familiar with the Bukkit API documentation, I advise you to look through it on your own. You will find interesting methods; many of these methods will spark ideas for cool plugins that you may want to make. Note that there may be additional links to view more methods for an object. For example, a Player
is a type of LivingEntity. Therefore, you can call a LivingEntity method on a Player
object. This inheritance is shown after the method summary, as shown in the following screenshot:

If you are ever going to try and think up an idea for a plugin, browsing through the API documentation will surely give you some ideas. I suggest reading the class pages, listed as follows, as they will be the classes that you will frequently use in your future plugins:

Now that you understand how to read the Bukkit Java documentation, you can find answers to the various questions that you may have. For example, what if you want to find out which methods you would call to get the Block that is at x:20 y:64 z:14
in the world that is named "world"?
First, you will need to retrieve the correct World
object. The initial place that you may check is the Bukkit class, as listed in the previous table. You may check there because you can call these methods from anywhere in your code. Another option is to view the uses of the World
class. This can be done by clicking on the Use link at the top of the World page. There, you can see all the methods that return a World
object as well as methods that accept a World
object as a parameter. To aid in searching through a page, remember that you can use Ctrl + F. Searching for name will lead you to the Bukkit.getWorld
method, which takes the name of the world as a parameter and returns the actual World
object.
Once you have the World
object, you will want to find a method that will give you the Block
at a specific location. You could navigate to the World page and use Ctrl + F to search for block, location, x, y, or z. If none of these help you find a useful method, then you can always view the uses of Block in a way that is similar to how we viewed the uses of World. Either way, you will find the World.getBlockAt
method, which can be called on the World
object that you discovered in the previous step.
The following are a few additional challenges to guide you while exploring the Bukkit API on your own and becoming familiar with it:
- Which method would you call to check what time it is in a world?
- Which methods would you call to send a message to the player whose name is Steve?
- Which methods would you call to check whether the material of a block is flammable?
- Which method would you call to check whether a player has diamonds in their inventory?
- Which methods would you call to check whether a player is holding an item that is edible?
- 程序員面試筆試寶典(第3版)
- Learning PostgreSQL
- 高級(jí)C/C++編譯技術(shù)(典藏版)
- 手把手教你學(xué)C語(yǔ)言
- Java項(xiàng)目實(shí)戰(zhàn)精編
- Highcharts Cookbook
- C語(yǔ)言程序設(shè)計(jì)教程
- Python算法指南:程序員經(jīng)典算法分析與實(shí)現(xiàn)
- Swift Playgrounds少兒趣編程
- OpenCV 4計(jì)算機(jī)視覺(jué)項(xiàng)目實(shí)戰(zhàn)(原書(shū)第2版)
- Visual C#.NET Web應(yīng)用程序設(shè)計(jì)
- .NET Standard 2.0 Cookbook
- Java程序設(shè)計(jì)教程
- 軟件工程與UML案例解析(第三版)
- 算法秘籍