Minecraft Blogs

Bukkit Plugin Coding

  • 3
  • 1
avatar EnderAnimationz
Level 4 : Apprentice Modder
Welcome to EnderAnimationz96/Notorious_CEO's Bukkit Plugin Coding.

On this blog i will be posting some coding for bukkit plugins with pretty much fill in the blank set up.

The fill in part will be surrounded by carrots or <> or less than/greater than signs.

I do not take any credit for doing/finding out the code myself I had a mentor on youtube. I did put the code in a nice format with explanations.


He does bukkit plugin tutorials and helped me get started programing plugins.

For more coding comment on this post.

//Instructions for some Stuff.

// Basic program for a Bukkit plugin.

package <name>;

import java.util.logging.Logger;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;

public class <.java file name> extends JavaPlugin
public static <.java file Name> plugin;

public final Logger logger = Logger.getLogger("Minecraft");
//Create Variables here.

public void onDisable()
PluginDescriptionFile pdfFile = this.getDescription();
this.logger.info(pdfFile.getName() + ChatColor.GOLD + " Has Been Disabled!");

public void onEnable()
PluginDescriptionFile pdfFile = this.getDescription();
this.logger.info(pdfFile.getName() + ChatColor.GOLD + " Version " + pdfFile.getVersion() + " Has Been Enabled!");
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
Player player = (Player) sender;
if(commandLabel.equalsIgnoreCase("<command name goes here leave out the />"))
if(args.length == 0)
player.sendMessage("----" + ChatColor.GOLD + "Help (Admin)" + ChatColor.WHITE + "----");//commands shown to all ops
//player.sendMessage(ChatColor.AQUA + "" + ChatColor.WHITE + ": " + ChatColor.GREEN + "<message goes here>");
player.sendMessage("----" + ChatColor.GOLD + "Help" + ChatColor.WHITE + "----");//commands shown to none ops
//player.sendMessage(ChatColor.AQUA + "" + ChatColor.WHITE + ": " + ChatColor.GREEN + "<message goes here>");

return false;

// Player variable name.

Player <name the variable> = (Player) sender;

// Send a player a message.

<player variable name>.sendMessage(ChatColor.AQUA + "<Message>");

// Timer

//Must Be this instead of a while, for, dowhile, or any other standered java loop because java loops will pause the server till it is done.
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable()
//put variables here.
public void run()
<Stuff you want to run in a loop goes here>
}, 0L, 20L);// 20 = 1 minute Must have L.

//Broadcasting a message.

getServer().broadcastMessage(ChatColor.GOLD + "");

//Looking at a location and finding the block there and breaking it.

<Location variable name>.getBlock().breakNaturally();

// Spawning a item at a location

ItemStack <Name the variable> = new ItemStack(Material.<Item/Block Name>);
World World = <Location>.getWorld();//Has to be a location that has aready been made.
World.dropItemNaturally(<location from above>, <Name of the ItemStack from above>);

//Enchanting a item

int <Enchantment Name> = <Enchantment ID>;
int enchantmentLevel = <Level must be Valid with the enchantment>;
PlayerInventory <Name the Inventory Variable> = <Player variable>.getInventory();
ItemStack itemstack = new ItemStack(Material.<Item Name>, <number in the stack>);
Enchantment <Variable name Ex. Sharpnes5> = new EnchantmentWrapper(Enchantment Name);
itemstack.addEnchantment(<Enchantment Variable Name Ex. Sharpness5>, enchantmentLevel);
<Inventory Variable>.addItem(itemstack);

// Variables that come with Bukkit

Player <Variable Name>;
Location <Variable Name>;
World <Variable Name>;

//There may be more.

All things in here are fully copyable. I do not take any creadit for this. I learned from: TheBCBroz
You can find him on youtube for more bukkit tutorials.
Planet Minecraft Logo


© 2010 - 2020