small medium large xlarge

Generic-user-small
24 Jun 2014, 01:59
Chris Robinson (2 posts)

I finished putting in the code as per the instructions

package simple;

import java.util.logging.Logger;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.Sound;

public class Simple extends JavaPlugin {
  public static Logger log = Logger.getLogger("Minecraft");
  public void onEnable() {
    log.info("[Simple] Start up.");
  }
  public void onReload() {
    log.info("[Simple] Server reloaded.");
  }
  public void onDisable() {
    log.info("[Simple] Server stopping.");
  }

  public boolean onCommand(CommandSender sender, Command command, 
                           String commandLabel, String[] args) {         
    if (commandLabel.equalsIgnoreCase("simple")) {
      if (sender instanceof Player) { 
        Player me = (Player)sender;
        // Put your code after this line:
        int myAge = 18;
        int twiceMyAge = myAge * 2;
        float volume = 0.1;
        float pitch = 1.0;
        double dayOnIo = 152853.5047;
        String myName = "Chris Robinson";
        me.sendMessage("My age is " + myAge);
        me.sendMessage("Twice my age is " + twiceMyAge);
        me.sendMessage("The volume is " + volume);
        me.sendMessage("The pitch is " + pitch);
        me.sendMessage("The day on Io is " + dayOnIo);
        me.sendMessage("My name is " + myName);
        me.playSound(me.getLocation(), Sound.GHAST_SCREAM, volume, pitch);
        // ...and finish your code before this line.
        return true;
        }
    }
    return false;
  }
}

but I keep getting the error:

 Ze-MacBook-Pro:Simple Chris$ ./build.sh
Compiling with javac...
warning: [options] bootstrap class path not set in conjunction with -source 1.6
src/simple/Simple.java:31: error: incompatible types: possible lossy conversion from double to float
        float volume = 0.1;
                       ^
src/simple/Simple.java:32: error: incompatible types: possible lossy conversion from double to float
        float pitch = 1.0;
                      ^
2 errors
1 warning

Could someone help me out :)

EDIT: I did change volume to 10 and pitch to 1 and it worked fine

EDIT & Facepalm: I added an “f” to the end of 1.0 and 0.1 and it worked fine

Andy-talking_pragsmall
24 Jun 2014, 17:12
Andrew Hunt (214 posts)

Yeah, ya need the f. It would be better if the Bukkit API just used a double, but since they don’t, you need the ‘f’ for any literals.

/\ndy

Generic-user-small
14 Jul 2014, 18:54
Scott Maxwell (1 post)

We are running into an issue where the simple jar was created successfully. Everything looks good in the code, but when the /simple command is executed on the client it does nothing. There server shows the command was issued “issued server command: /simple” and when starting the server it shows [Simple] Enabling Simple v0.1 and [Simple] Start up. I reviewed the mySimple java and the code as written above and everything looks identical but nothing appears on the screen and no sound occurs when the command is executed. Helloworld works however.

Andy-talking_pragsmall
14 Jul 2014, 19:02
Andrew Hunt (214 posts)

Make you have the correct entries in the plugin.yml file, especially make sure the command for “simple” is spelled correctly, etc., and that you have spaces, not tabs in the yml file.

If the plugin.yml file doesn’t match the command, ain’t nuthin’ gonna work…

/\ndy

  You must be logged in to comment