Plugin Development Video Tutorial Series

Discussion in 'Resources' started by Jacek, Sep 8, 2011.

Thread Status:
Not open for further replies.
  1. name: TNTNotifier
    version: 0.1
    main: fr.astaen.bukkit

    ?
     
  2. Offline

    Jacek

    The main setting should be the path to the main class (the one that extends JavaPlugin). So if you class was called TNTNotifier like I used it should be fr.astaen.bukkit.TNTNotifier. Or if you prefer it should be package_name.class_name
     
  3. Thanks, it works.
     
  4. Offline

    cocoson

    @Jacek
    yo man this is a sweet tutorial i just started making a plugin for bukkit so my commands would be easier on my server and when i found this page it has made it alot easier for me to go about creating it theses videos are showing me alot of stuff i left out.

    so thanks for making them

     
  5. Offline

    Jacek

    :D Thanks, glad I helped.
     
  6. Offline

    garbagemule

    Hi Jacek,

    Loving the clarity in your voice and the quality of the videos! Keep it up. It's also nice to see some decent code conventions in a tutorial series (I see way too many oddities and straight out silly things in some of the other tutorials) :) I have a couple of things I think are very important in using the Bukkit API (which unfortunately a lot of plugin developers ignore/don't know about) that I'd love to see you go over (even just shortly).
    • Event priorities: Some developers seem to think that if their plugin isn't the first to handle an event, or in the case an even is cancelled, they can't do what they want. In some cases, developers use Priority.Lowest when in fact Priority.High is more appropriate (such as letting other plugins manipulate drops in a death event before handling the inventory (looking at you, Tombstone)), and in other cases, they use Priority.Highest, when Priority.Low is actually what they want (making sure to override any event settings in highly specific events). Also, it appears that Priority.High and Priority.Low are ignored a lot. Perhaps you could go over the effects and consequences of using different priorities.
    • Ramifications of certain listener methods: I've seen too many plugins use onPlayerMove (potentially fired 20 times a second for EVERY player on the server) when it would be so much more efficient or performance-friendly to use repeating scheduled tasks. Plugins like War are notorious for bringing servers to their knees due to excruciatingly huge onPlayerMove methods full of extended for loops.
    Anyway, gonna watch the rest of the videos when I find some spare time. Again, keep up the good work, and keep that audible chocolate flowin'! ;)
     
  7. Offline

    Jacek

    Thanks :D

    I mentioned the priorities thing briefly but you make a good point and I have seen it used incorrectly a lot of times too. Perhaps I should do some videos on smaller things like this.

    I was actually thinking of doing a new playlist on some of the most interesting / useful events you can use so that would go well in there. Again, the performance impact of what some people do is often ignored.
     
    garbagemule likes this.
  8. Offline

    SirM3aky

    Thanks for these videos, I have subscribed and I am working my way through them at the moment.:)
     
  9. Offline

    Jacek

    Added a second commands series, I think that is covered properly now :)
     
  10. hmmm, is it possible to make a favorite thread list?
     
  11. Offline

    saul100

    You can 'watch' a thread
    Top right of the thread.
     
  12. Offline

    iffa

    Isn't using bukkit in the namespace bad? Or is it just org.bukkit?
     
  13. Offline

    Jacek

    It's *.bukkit, anything that ends with .bukkit that you are not meant to use. something.bukkit.something_else is okay. I think :s
     
  14. Offline

    cliff777

    I followed your first two tutorials (great job!) but my plugin does not work. I get the error messages, but when the diamond ore is destroyed, nothing happens...no block type change, no message. And ideas what I did wrong?

    Code:
    package me.cliff777.plugin;
    
    import java.util.logging.Logger;
    
    import org.bukkit.event.Event;
    import org.bukkit.event.Event.Priority;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class OreNotifier extends JavaPlugin {
    
        private Logger log = Logger.getLogger("Minecraft");
        public void onDisable(){
            this.logMessage("Disabled");
        }
    
        public void onEnable(){
            PluginManager pm = this.getServer().getPluginManager();
            pm.registerEvent(Event.Type.BLOCK_BREAK, new OreNotifierBlockListener(), Priority.Highest, this);
            this.logMessage("Enabled");
    
        }
    
    
        protected void logMessage(String msg){
            // OreNotifier 0.1: msg
            PluginDescriptionFile pdFile = this.getDescription();
            this.log.info(pdFile.getName() + " " + pdFile.getVersion() + " " + msg);
        }
    }
    
    Code:
    name: OreNotifier
    version: 0.1
    main: me.cliff777.plugin.OreNotifier

    Code:
    package me.cliff777.plugin;
    
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.entity.Player;
    import org.bukkit.event.block.BlockBreakEvent;
    import org.bukkit.event.block.BlockListener;
    
    public class OreNotifierBlockListener extends BlockListener {
    
        public void onBlockDestroy(BlockBreakEvent event){
            if (event.isCancelled()) return;
    
            Block block = event.getBlock();
            Player player = event.getPlayer();
    
            if (block.getType() == Material.DIAMOND_ORE){
                block.setType(Material.SAND);
    
                player.sendMessage(ChatColor.DARK_GREEN + "You are lucky!");
    
            }
        }
    
    }
    
    Thanks,

    Cliff
     
  15. Offline

    Jacek

    Your method name it wrong in your block listener, it should be onBlockBreak() not onBlockDestroy()
     
  16. Offline

    cliff777

    It works! Thank you very much.
     
  17. Offline

    cliff777

    Hmm...have another problem...maybe someone can tell me whats up?

    Main class:


    Code:
    package me.cliff777.plugin;
    
    import java.util.logging.Logger;
    
    import org.bukkit.event.Event;
    import org.bukkit.event.Event.Priority;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class OreNotifier extends JavaPlugin {
    
        private Logger log = Logger.getLogger("Minecraft");
    
        public void onDisable(){
            this.logMessage("Disabled");
        }
    
        public void onEnable(){
            PluginManager pm = this.getServer().getPluginManager();
    
            pm.registerEvent(Event.Type.BLOCK_BREAK, new OreNotifierBlockListener(this), Priority.Highest, this);
    
            this.logMessage("Enabled");
    
        }
    
    
        protected void logMessage(String msg){
            // OreNotifier 0.1: msg
            PluginDescriptionFile pdFile = this.getDescription();
            this.log.info(pdFile.getName() + " " + pdFile.getVersion() + " " + msg);
        }
    }
    

    Listener class:

    Code:
    package me.cliff777.plugin;
    
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.entity.Player;
    import org.bukkit.event.block.BlockBreakEvent;
    import org.bukkit.event.block.BlockListener;
    
    public class OreNotifierBlockListener extends BlockListener {
    
        private OreNotifier plugin;
    
        public OreNotifierBlockListener(OreNotifier instance){
            this.plugin = instance;
    
        }
    
        public void onBlockBreak(BlockBreakEvent event){
            if (event.isCancelled()) return;
    
            Block block = event.getBlock();
            Player player = event.getPlayer();
    
            if (block.getType() == Material.GRASS){
    
                player.sendMessage(ChatColor.DARK_GREEN + "You are lucky!");
    
                plugin.getServer().broadcastMessage(player.getName() + ChatColor.BLUE + " Broke some grass!");
    
            }
    
            }
        }
    
    Thanks,
    Cliff
     
  18. Offline

    Jacek

    Only if you say what the problem is ...
     
  19. Offline

    cliff777

    hehe, that would be a good thing to start off with..When I start the server, the plugin comes up the with enabled message, but when I break any grass block, no messages appear (I have tried this with other blocks as well.
     
  20. Offline

    Jacek

    I just tried your code, and it seems to work fine :s

    Are you sure you exported it properly ? And that it is the latest version in the plugins folder ?
     
  21. Offline

    Tomaz

    @Jacek, i love you're video tutorials. could you make more please, would really appriciate it. WGEN :)
    You're PHP tutorials are quite fun too :)
     
  22. Offline

    cliff777

    I did that...but no messages appear..this is what I do when I export:

    [​IMG]
     
  23. Offline

    Jacek

    I will if I think of some :D

    put the jar in your plugins folder ?
     
  24. Offline

    Doc

    Jacek Your youtube vids have been "removed by user". Can you please post updated URLs.
    Thanks!
    -Doc
     
  25. Offline

    Jacek

    I'm re-doing a lot of them for the new event system, check out the channel that removed them :)
     
  26. Offline

    RiotShielder

    Will the TNT Notifier ever be updated? I would really like to start learning a bit of Java.
     
  27. Offline

    Jacek

    There is an updated version on my channel, I keep meaning to update this thread.
     
  28. Offline

    OrangeCrush

    Will this continue to be updated, I thought it was amazing :D
     
  29. Offline

    Jacek

    It will :) There are a few more on my channel. I just need to get around to updating this topic.
     
  30. Offline

    OrangeCrush

    Alright, in that case, I will get around to subscribing to you sooner :p
     
Thread Status:
Not open for further replies.

Share This Page