Command always returning false?

Discussion in 'Plugin Development' started by herghost, Nov 28, 2011.

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

    herghost

    Hi all, I am having some issues with my sethome command:

    Code:
    package me.herghost.Fiery.commands;
    
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    import java.util.logging.Logger;
    
    import me.herghost.Fiery.util.Configuration;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    public class sethomeCommand implements CommandExecutor {
    	Logger log = Logger.getLogger("Minecraft");
    
    	public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
    	{
    		readCommand((Player) sender, commandLabel, args);
    		return true;
    	}
    	private void readCommand(Player player, String cmd, String[] args )
    	{
    		if(cmd.equalsIgnoreCase("sethome")&& player instanceof Player)
    		{
    			if(args.length == 0)
    			{
    				Player p = (Player) player;
    				double x = p.getLocation().getX();
    				double y = p.getLocation().getY();
    				double z = p.getLocation().getZ();
    				String world = p.getWorld().getName();
    				try
    					{
    						String user = Configuration.getString("settings.mysql.user");
    						String pass = Configuration.getString("settings.mysql.pass");
    						String url = "jdbc:mysql://localhost:3306/Fiery";
    						Connection conn = DriverManager.getConnection(url, user, pass);
    						PreparedStatement sampleQueryStatement = conn.prepareStatement("REPLACE INTO userhomes SET world = '" + world + "', p_name = '" + p.getName() + "', home_x = '" + x + "', home_y = '" + y + "', home_z = '" + z + "'");
    						sampleQueryStatement.executeUpdate();
    						sampleQueryStatement.close();
    						p.sendMessage("Home Set Successfully");
    					}
    				catch
    				(SQLException e1)
    					{
    						e1.printStackTrace();
    					}
    		}
    on executing the command it returns false and and just gives me the usage, nothing added to database and no errors in console?
     
  2. Offline

    bleachisback

    in your main class do you have
    Code:JAVA
    1. getServer().getPluginCommand("sethome").setExecutor(new sethomeCommand());
     
  3. Offline

    herghost

    D'oh, worse than that :p I had it commented out as I was working on it earlier :( - Thanks for inadvertently helping the retard!
     
Thread Status:
Not open for further replies.

Share This Page