Cannot Find Symbol Compiler Error

Discussion in 'Plugin Development' started by Ice_Sword, Jan 25, 2012.

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

    Ice_Sword

    So, I'm attempting to create a plugin for my own server to mess with my friends. I'm using NetBeans 7.1. I get an error saying it can't find the symbol. Here's the code: (I realize I need to clean it up, rename the package, etc.)

    Code:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package ditch;
    
    import java.util.logging.Logger;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    /**
     *
     * @author Ice_sword
     */
    public class Ditch extends JavaPlugin {
        
        
        
        public static void main(String[] args) {
        }
        static final Logger log = Logger.getLogger("Minecraft");
    
        public Player getEventname(Player other) {
            return other;
        }
        
        
        
    
        @Override
        public void onEnable(){
                    PluginManager pm = this.getServer().getPluginManager();
        }
     
       
    
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            Player player = null;
            
            
            if (sender instanceof Player) {
                player = (Player) sender;
            }
         
            if (cmd.getName().equalsIgnoreCase("Q?")) {
                if (player == null) {
                    sender.sendMessage("Hey look, a bird.");
                } else {
                    log.info(player.getName() + ": Q?");
                            sender.sendMessage("Hey look, a bird.");
                            return true;
                }
            }
            else if(cmd.getName().equalsIgnoreCase("ag")){
                Player other = (Player) sender;
                Player target = other.getWorld().getPlayer(args[0]);
                broadcastMessage("Test....");
                return true;
                    
            
            }
         
    return false;
    }
        
        @Override
        public void onDisable(){
        }
    
    
    
    }
    

    So, the two issues I get are from broadcastMessage, and getPlayer. The errors I get are:

    cannot find symbol
    symbol: method getPlayer(java.lang.String)
    location: interface org.bukkit.World

    and

    cannot find symbol
    symbol: method broadcastMessage(java.lang.String)
    location: ditch.Ditch


    It's probably simple, but, I haven't been programing very long...

    So, what I'm wanting to happen is when someone types "/ag <playername> <string>" It will broadcast a message to the server saying something like, "Achievement get! <playername> just got an achievement for <string>."

    I'm stumbling my way through this, and I realize the code above won't do exactly what I want. I'm trying to work in steps so I understand the code better. I'm one of those guys that has to fiddle with something like this to understand it.

    I hope that made sense, and I'd appreciate any help or suggestions you can offer.
     
  2. Offline

    DarkBoni

    well, the errory basicly say that the compiler cant find the methods "getPlayer" and "broadcastMessage".
    the solution is pretty simple:
    the method "getPlayer" isn't defined in a world on the server, but IN the server, so simply use "this.getServer().getPlayer(args[0]);"
    same with "broadcastMessage": "this.getServer().broadcastMessage("Test....");"
     
    Ice_Sword likes this.
  3. Offline

    Ice_Sword

    Thank you sir! Works fine. I've already spent a long time looking for the solution and you gave it to me in a flash.
     
  4. Offline

    DarkBoni

    Im glad i was able to help ;)
     
Thread Status:
Not open for further replies.

Share This Page