Solved Plugin not working

Discussion in 'Plugin Development' started by ThePorkChopFilms, Jun 1, 2013.

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

    I am new to bukkit development and have tried to create a simple plugin that posts an announcement when the player types /announce <message>. (I also added another command that posts an announcement that doesnt have a prefix, /ab <message>)

    Here is my main java class:
    Code:
    package com.theporkchopfilms.zxeplug;
     
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class zXePlug extends JavaPlugin {
     
        public void onEnable(){ System.out.println("[zXePlug] Enabled"); }
     
        public void onDisable(){ System.out.println("[zXePlug] Disabled"); }
       
        public boolean onCommand(CommandSender sender, Command cmd, String Label, String[] args) {
            String commandName = cmd.getName().toLowerCase();
            String[] trimmedArgs = args;
           
            if (commandName.equals("announce")) {
                return announce(sender, trimmedArgs);
            }
           
            if (commandName.equals("ab")) {
                return ab(Label);
            }
           
            return false;
        }
       
        public String formatMessage(String str) {
            String funnyChar = new Character((char) 167).toString();
            str = str.replaceAll("&", funnyChar);
            return str;
        }
       
        private boolean announce(CommandSender sender, String[] trimmedArgs) {
            String announcement = ("[&cAnnouncement&f] &d" + trimmedArgs);
            this.getServer().broadcastMessage(formatMessage(announcement));
            return true;
        }
       
        private boolean ab(String label) {
            String abroadcast = ("&e" + label);
            this.getServer().broadcastMessage(formatMessage(abroadcast));
            return true;
        }
    }
    
    Here is plugin.yml:
    Code:
        name: zXePlug
        main: com.theporkchopfilms.zxeplug.zXePlug
        version: 1.0.16
        website: http://www.theporkchopfilms.com
        author: zXePhonic
        description: >
                Announcement plugin for admins
       
        commands:
      announce:
        description: Announces a message
        usage: /<command> message - Announces a message
         
      ab:
        description: Announce a message without [Announce] attached on the front of it
        usage: /<command> message
    When I export and install it to my server then reload, it doesn't say anything in console, and the commands dont work in game or in the console. (It also doesnt appear when i type /plugins)

    I know its probably something stupid but thanks in advance :)
     
  2. Offline

    vemacs

    Mind posting your JAR and server.log?
     
  3. Offline

    AmShaegar

    Did you restart the server? :D

    I guess your plugin.yml is wrong. You have to be very specific with your syntax especially with spaces. No tabs! It should look like this:
    Code:
    name: ...
    main: ...
    author: AmShaegar
    website: ...
    version: ...
    description: ...
    commands:
      all:
        description: "Let's you chat with everyone."
        usage: "Usage: /all [message]"
     

  4. Ah! That would explain it!

    Thanks.
     
  5. Offline

    themadman300

    ThePorkChopFilms

    Not all of that is necessary. What you MUST have in your plugin.yml is main, name and version. I like to include description, author and website but that's optional. If you have commands or permissions you need commands and permissions, self explanatory. I recommend reading the bukkit wiki guide for Plugin YAML if you need more information.
     
Thread Status:
Not open for further replies.

Share This Page