Basic BUKKIT plugin Tutorial

Discussion in 'Resources' started by Samkio, Jan 20, 2011.

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

    nickthemenace

    @LukeZaz
    I think these are the lines you're talking about:
    pm.registerEvent(Event.Type.PLAYER_COMMAND, this.playerListener, Event.Priority.Normal, this);
    pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Event.Priority.Normal, this);
     
  2. Offline

    LukeZaz

    Thanks, works,

    You know, after just 25-35% through the tutorial, I can already tell programming plugins in Bukkit takes more patience and code to make then Hey0, I hope this changes,

    I love the numbers here...What font is this?

    Repeated in 1337 speak cause i love the numbers:

    Y0u kn0w, 4f73r ju57 25-35% 7hr0u6h 7h3 7u80r141, 1 c4n 41r34dy 7311 pr06r4mm1n6 p1u61n5 1n Bukk17 74k35 m0r3 p4713nc3 4nd c0d3 70 m4k3 7h3n H3y0, 1 h0p3 7h15 ch4ng3s,

    1 10v3 7h3 numb3r5 h3r3...Wh47 f0n7 15 7h15?



    EDIT: Finished the tutorial, Plugin worked like a charm, Thanks!
     
  3. Offline

    Colecf

    I can't get it to work, this error shows up on a craftbukkit build 241 with only essentials and this plugin installed.
    Code:
    SEVERE: Could not load plugins/basic.jar in plugins: null
    org.bukkit.plugin.InvalidPluginException
    	at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:78)
    	at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:117)
    	at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:82)
    	at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:42)
    	at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:156)
    	at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:143)
    	at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:104)
    	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:186)
    	at net.minecraft.server.ThreadServerApplication.run(SourceFile:512)
    Caused by: java.lang.ClassNotFoundException: com.bukkit.samkio.Basic.Basic
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    	at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:30)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    	at java.lang.Class.forName0(Native Method)
    	at java.lang.Class.forName(Class.java:247)
    	at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:72)
    	... 8 more
    
    I also saw a forum topic asking to change the namespace from com.bukkit.colecf.Basic (but more general) to something else, so I first tried colecf.Basic but that caused more problems in addition to this.
     
  4. Offline

    Acru

    Thanks btw, this helped bootstrap me into plugin development. :3
     
  5. Offline

    Samkio

    @Colecf
    Yes if you change the package name you will have to change the yml file accordingly.
    Remeber it is case sensative. :)
     
  6. Offline

    bradcland

    If you make another vid, please don't copy and paste as much. I have to type stuff out to remember it and with you copying and pasting I got behind fast.
     
  7. Offline

    Samkio

    See intermediate plugin.
     
  8. Offline

    bradcland

    Oh, I didn't see that one. Thanks.
     
  9. Offline

    ki113d

    Hey there. First of all I would like to thank you for your wonderful tutorial as it has taught me a fair bit and has strengthened my will and determination regarding the coding of Bukkit plugins.

    Now the only issue I am having is to catching an event when any user places a block and broadcasting it to the server admins. I also can't seem to use getOnlinePlayers().

    Any help regarding these issues would be greatly appreciated.

    Thanks in advance.

    Ki113d
     
  10. Offline

    Samkio

    @ki113d
    try:
    plugin.this.getServer().broadcastMessage("Message");
    That will broadcast a message to the whole server.
     
  11. Offline

    samsoccerboyz

    Ok so im looking at this with a good understanding of java and im wondering where i can find the list of events like player deaths etc because i want to make a bounty hunter plugin

    --------Edit---------
    Found a list of events on the wiki like 5 mins after i posted but now i have another question its there a way to derive the killer in Entity Death so that i can award players for winning PvP fights?
     
  12. Offline

    Samkio

    EntiyDeath is not currently implemented i believe.
    Try The entitydamaged events to create an on Death hook.
     
  13. Offline

    samsoccerboyz

    Sigh that makes my job alot harder and how would i go about making hooks in eclipse i usually hard code in notepad straight to a compiler ;P
     
  14. Offline

    Samkio

    @samsoccerboyz
    highz has made a death hook. I would recommend talking to him.
    Also it is good to learn eclipse as it makes things so much easier :p
     
  15. Offline

    Colecf

    Could you explain hashmaps a little more? From what I understand they're necessary to keep your server from lagging really badly from a plugin. I know arrays, but hashmaps (especially the ArrayList<Block> part) confuse me.
     
  16. Offline

    NEO

    Not sure where you got everything you copy and pasted. I manually typed everything you copy and pasted. New to eclipse and java so I have no idea whats going on. I have been able to follow the tutorial though and am about half done.
     
  17. Offline

    Sammy

    Watch this video

    I think (I'm a newbie on bukkit too) the general idea is because hash maps are a bidimencional containers you can have a better way to search for a player, for instance:
    Here you can get the player and a ArrayList of the type "block" associated to him.

    Please correct me if I'm wrong =)
     
  18. Offline

    samsoccerboyz

    I messaged highz and got no response any alternitives?
     
  19. Offline

    hudson

    Now teach us how to make a plugin
     
  20. Offline

    Colecf

    I watched the video and it answered a lot of questions, but it didn't answer the Arraylist<Block> question, because that was a general java tutorial.
     
  21. Offline

    Sammy

    @MasterMind555

    The New Boston
    I started learning java from this guy, took me 1week to learn how java works, and like you I only know a little of lua, vb and c.
    After that I made a raffle program, watched samkios videos, and implemented it to bukkit...
    SO go for it, it's not that hard to make an easy plugin if you have the will [​IMG]
     
  22. Offline

    Soywatman2

    statement blocks say " //compiled code
    throw new RuntimeException("Compiled Code");" in source code
     
  23. Offline

    Kirena

    Thx for this video, nice tutorial.

    But i meet some problem in the code, can you help me please?

    I've got an error on:

    "if (debugees.containsKey(player)) {" ---> debugees ( debugees cannot be resolved )
    and
    "if (enabled(player)) {" ---> enabled ( The methode enabled(player) is undefined for the type Basic )

    When exported in .JAR and tested in the server, i have an error at toggleVision when i try "/basic" xD

    I have watch your video so manytime and think have missed nothing but i cant fix thes errors...

    Edit: I have read that on oracle: ( http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Component.html )

    void enable()
    Deprecated. As of JDK version 1.1, replaced by setEnabled(boolean).
     
  24. Offline

    Lee Hayward

    Great video tutorial, I'm already planning out some useful plugins for my server. Thanks, wouldn't have a clue without your help :)
     
  25. Offline

    asd4gff5

    I am having tons of errors when loading the plugin with the server.
    Samio could you please tell us which bukkit version to use? So that it works with the sources you attached in your first post? Or maybe upload a archive including bukkit lib + your sources? I am new to this whole plugin development thing and I can't just find a template (or basic plugin) that just loads without errors. Everywhere I see the library without a template or a template without the used library. See: you tell us to use the newest build which changes every few hours - so it doesn't really work with your code except when your code would also change every few hours.

    Thanks in advance.
     
  26. Offline

    Samkio

  27. Offline

    Zinth

    First let me start by saying thanks for the tutorial, with out it I would be even more lost then I am now. I do have a problem however and I know this was mentioned before and the person must of solved his problem but I can't figure it out. My problem is i'm getting an error on super(pluginLoader, instance, desc, folder, plugin, cLoader); It keeps telling my that "The constructor JavaPlugin(PluginLoader, Server, PluginDescriptionFile, File, File, ClassLoader) is undefined"

    here's my code:
    Code:
    package com.bukkit.zinth.basic;
    
    import java.io.File;
    import java.util.ArrayList;
    import java.util.HashMap;
    import org.bukkit.Server;
    import org.bukkit.block.Block;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Event;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.PluginLoader;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.plugin.PluginManager;
    
    public class Basic extends JavaPlugin{
        public Basic(PluginLoader pluginLoader, Server instance,
        PluginDescriptionFile desc, File folder, File plugin,
        ClassLoader cLoader){
            super(pluginLoader, instance, desc, folder, plugin, cLoader);
            }
    
        @Override
        public void onDisable() {
            // TODO Auto-generated method stub
    
        }
    
        @Override
        public void onEnable() {
            // TODO Auto-generated method stub
    
        }
    
    }
    
    I have checked it several times for spelling and syntax errors but I can't find any. I am very new to programing and have only done "HelloWorld" and a quick number adder in java before. I have taken a class on C# programing but it was a couple of years ago and I only remember the basics. If you could help me figure this out I would greatly appreciate it.
     
  28. Offline

    Samkio

  29. Offline

    Zinth

    Thank you Samkio, I think I also found another thing I was doing wrong was using CraftBukkit and not just Bukkit as the reference source. I hope that and the removal of the constructor will let me remake your Basic plugin I'm learning a lot [​IMG].
     
  30. Offline

    THEK

    Forgive me if I'm being stupid. Is there a list of hooks available?
     
Thread Status:
Not open for further replies.

Share This Page