Tips on creating your very first plugin!
-
Well,
Learning to code plugins is hard. This post should help you!
Well, your gonna wanna know the Spigot Javadocs.
https://hub.spigotmc.org/javadocs/bukkit
CODING:
Well, you want to know some basics of the plugin development.
Here is some example code:
Please note that this code does nothing:
START OF CODE:
Code (Java):package example.example.example;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class Example extends JavaPlugin {
@Override
public void onEnable() {
Bukkit.getServer().getLogger().info("ExampleCode is now Enabled.");
}
@Override
public void onDisable() {
Bukkit.getServer().getLogger().info("ExampleCode is now Disabled.");
}
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (cmd.getName().equalsIgnoreCase("example") && sender instanceof Player) {
Player player = (Player) sender;
player.sendMessage(cmd.getName() + " You used a Example" + "!");
return true;
}
return false;
}
}
now lets decode this.
The "public boolean" is what controls commands, etc.
Code (Java):@Override
public void onDisable() {
Bukkit.getServer().getLogger().info("ExampleCode is now Disabled.");
PLUGIN.YML
ahhh. the plugin.yml. The plugin.yml is what tells the server the name, commands, and sometimes permissions, of your plugin. Here's a example:
N.B. Remember that this file should always follow the YAML syntax rules. This means that no tabs are allowed... Never! To indent, hit [SPACE] twice. To indent again, hit [SPACE] two more times:
Code (YAML):level-1:
level-2:
level-3: 'Hello World!'
Code (YAML):name: Example
main: example.example.example
version: 1.0
commands:
example:
aliases: [[U]examplecode[/U]]
description: It replies with a message!
usage: /<command>
LICENSING:
Licensing tells the end user what they are and aren't allowed to do with your plugin.
If you have no explicit license in your code, it is under all rights reserved by default under the creator.
While this does say that you are the creator and owner of the plugin, it is still your duty to make clear what a person with access to the plugin can and can't do. This can be done with an external file to the plugin, or in the comments in the head of a class file.
sender.sendMessage("THE END")
THE END - Loading...
- Loading...
XenCarta PRO
© Jason Axelrod from 8WAYRUN.COM