Probably a newbish problem...

Discussion in 'Plugin Development' started by bigbeno37, Jun 1, 2012.

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

    bigbeno37

    Hey there!

    I know a fair bit of Java and so I have decided to learn how to code Bukkit plugins. So I tried having a look at the wiki, but I got WAY too confused with that, so I went to go watch some video tutorials. Here is the link to the first video:


    I have typed in the exact same code, but when I try to export it to the 'plugins' folder in the server folder, it comes up with a bunch of errors. Below you can find the related info:

    (To check for errors) server.log: http://pastie.org/4012331
    TestPlugin.jar:
    TestPlugin.java: http://pastie.org/4012329
    plugin.yml: http://pastie.org/4012234
    I am such a newb at the Bukkit API. Can you please help me and tell me what to fix?

    Thanks!

    EDIT: I have updated the links to show my current code. The error that displayed on the console can be seen by going to the server.log pastie. Please help me on this as I have no clue as to what the matter is.
     
  2. Offline

    chaseoes

    Can't help you if you don't tell us the errors!
     
  3. Offline

    bigbeno37

    Errors are inside the log file. Edited question to include my response.
     
  4. Offline

    RobotA69

    For one, I suggest as your starting out to use just one class unless your planning on making a real big plugin
    ISSUE : In the class where you initialize the Logger, change it to Logger log = this.getLogger("Minecraft");
    Otherwise, very good ;)
     
  5. Offline

    bigbeno37

    So include the listener into the TestPlugin class? Oh, and the Logger won't accept the String 'Minecraft'
     
  6. Offline

    RobotA69

    Yes, I would suggest that and if you have any troubles (pastie link with full code cause I'm awesome), but don't just copy and paste, write it and you learn :D
    EDIT : Also, you see how you have @EventHandler
    public void stopDiamondBlockBreak(BlockBreakEvent event){ if(event.getBlock().getType() == Material.DIAMOND_BLOCK){ event.setCancelled(true); event.getPlayer().sendMessage(ChatColor.RED+"You cannot break this block"); } }

    This would be more efficient

    @EventHandler
    public void sDBB(BlockBreakEvent e) {
    Player player = event.getPlayer();
    Block block = event.getBlock().getType();

    if(block == Material.DIAMOND_BLOCK) {
    event.setCancelled(true);
    player.sendMessage("FOOLISH!");
    }
    }
     
  7. Offline

    bigbeno37

    Okay, I merged the two classes together, imported everything that needed to be imported, and it still has errors. Links to my newly edited files below:

    (To check for errors) server.log: http://pastie.org/4012331
    TestPlugin.jar:
    TestPlugin.java: http://pastie.org/4012329

    Please help me further to find out what is wrong.

    EDIT: I didn't see the edit made by RobotA69. The changes have been edited in.

    Re-did my starting post so that people can have a look at that first.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  8. bigbeno37
    class TestPlugin extends JavaPlugin implements Listener{
    to
    public class TestPlugin extends JavaPlugin implements Listener{
     
    bigbeno37 likes this.
  9. Offline

    bigbeno37

    You sir are my savior. If you could could you please answer this last question for me:

    If I do 'class Test{}', does that just automatically assign it to being private? If not, what does it assign it to?

    Once again, thank you so much! It is now working for me and I shall indeed remember that I must ALWAYS make classes public.
     
  10. bigbeno37 It makes the it accessible from within the same package. You don't have to make all public, but the constructor of your main class has to be called from CraftBukkit. ;)

    //EDIT: A bit more info: This counts for classes, constructors, variables and functions:
    public = Accessible from any class in any package (so from CraftBukkit and other plugins).
    private = Accessible from the class it's in only.
    [none] = Accessible from classes in the same package only (so not from CraftBukkit nor other plugins).
     
  11. Offline

    VenomEater

    change class to public class for ure constructer also what if they place the diamondblock they cant pick it up also maybe do

    Code:
    if(block == Material.DIAMOND_BLOCK && player.hasPermission("TestPlugin.mine-diamond_block") == false){
                event.setCancelled(true);
                player.sendMessage("Fool!");
            }
    that would mean that if the person had TestPlugin.mine-diamond_block permission node it would let them mine the diamond block also maybe think about making it so that only people with TestPlugin.mine-diamond_block and the person who placed the block can mine it otherwise the person just lost a diamond block.
     
Thread Status:
Not open for further replies.

Share This Page