Plugin Coding Examples

Discussion in 'Plugin Development' started by Brett_Haythorpe, Mar 23, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Brett_Haythorpe

    I have been trying to code for a number of months but finding it really hard, I think it would help me if someone posted a plugin and the code with it just, so I can get an example of what a final plugin looks like.
     
  2. Offline

    Arcoz

    Take a look on public source codes >_>?
     
  3. Offline

    Konkz

    Multiple plugins are open source so you can see the code that way.
    JD-GUI can decompile a plugin so you can see the source, it is buggy though.

    Java tutorials, Bukkit tutorials - both website and video can be found here on Bukkit forums.

    Brett_Haythorpe

    EDIT: Also, if I was to give you my minigame code seeing you struggle to understand code you'd take hours to understand a simple feature as they connect through multiple classes etc. which you may find hard.
     
  4. Offline

    skyrimfan1

    Search around on BukkitDev; there's lots of open-source plugins out there that share links to their code.

    Just don't copy any methods from them without giving due credit in your code. Copying code without permission/explicit reference to the author is a crime.
     
  5. Offline

    phildachil

    Ehm, well you should watch some videos or read books. But sure.

    Code:java
    1.  
    2. package me.phildachil.test;
    3.  
    4. import org.bukkit.Bukkit;
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.plugin.java.JavaPlugin;
    10.  
    11. public class Plugin extends JavaPlugin {
    12.  
    13. public void onEnable() {
    14. Bukkit.getServer().getLogger().info("Plugin Enabled!");
    15. }
    16.  
    17. public void onDisable() {
    18. Bukkit.getServer().getLogger().info("Plugin Disabled!");
    19. }
    20.  
    21. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    22.  
    23. if (!(sender instanceof Player)) {
    24. sender.sendMessage(ChatColor.AQUA + "The console ran the test command.");
    25. return true;
    26. }
    27.  
    28. Player p = (Player) sender;
    29.  
    30. if (cmd.getName().equalsIgnoreCase("test")) {
    31. p.sendMessage(ChatColor.GOLD + "You ran the test command.");
    32. }
    33. return true;
    34. }
    35. }
    36.  
     
Thread Status:
Not open for further replies.

Share This Page