'String cannot be resolved to a type'

Discussion in 'Plugin Development' started by AwesomeUnicorn, Apr 23, 2012.

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

    AwesomeUnicorn

    Okay, so, I probably look like an idiot, but I just started learning Java, okay?
    So, anyways, I'm making a plugin, and everywhere where strings are used, I get the error that it cannot be resolved to a type.
    Is it something I have to import at the start, or..?
     
  2. Offline

    Ranzdo

    AwesomeUnicorn It would be helpful if you posted some code, but I suspect you might use
    Code:java
    1.  
    2. string s = "test";
    3.  

    However, it needs to be like this.
    Code:java
    1.  
    2. String s = "test";
    3.  

    Notice the capitalization.

    If this is not the case, then post some code so we can have an idea on what the problem is.

    Good luck with future coding :)
     
  3. Offline

    AwesomeUnicorn

    Ranzdo Doesn't work. This is my code:
    Code:
    package net.web44.aweuni.Emotes;
     
    import java.util.logging.Logger;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.entity.*;
    import org.bukkit.command.*;
    import org.bukkit.*;
     
    public class Emotes extends JavaPlugin {
     
    Logger log;
     
    public void onEnable() {
    log = this.getLogger();
    log.info("eMotes by AwesomeUnicorn has been enabled!");
    }
    public void onDisable() {
    log.info("eMotes by AwesomeUnicorn is now disabled.");
    }
     
    //Commands
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    Player player = null;
    if (sender instanceof Player) {
    player = (Player) sender;
    }
    //eHug: the hugging command
    if(cmd.getName().equalsIgnoreCase("ehug")) {
    if (args.lenght > 3) {
    sender.sendMessage(ChatColor.RED + "Wrong amount of arguments! Try /eHug <player> [private/all]!");
    return false;
    } else if (player == null){
    //The command is sent by the console
    Player other = (Bukkit.getServer().getPlayer(args[0]));
    if (other == null) {
    sender.sendMessage(ChatColor.RED + "That player is not online!");
    return false;
    } else {
    if (args[1] == "private" || args[1] == "p") {
    sender.sendMessage(ChatColor.AQUA + "You hugged " + other + "!");
    other.sendMessage(ChatColor.AQUA + "The Gods hugged you!");
    return true;
    } else if (args[1] == "all" || args[1] == "a")  {
    getServer().broadcastMessage(ChatColor.AQUA + "The Gods hugged " + other + "!");
    return true;
    } else if (args[1] == null) {
    sender.sendMessage(ChatColor.RED + "No target specified, using all.");
    getServer().broadcastMessage(ChatColor.AQUA + "The Gods hugged " + other + "!");
    return true;
    }
    }
    } else {
    //The command is sent by a player
    Player other = (Bukkit.getServer().getPlayer(args[0]));
    if (other == null) {
    sender.sendMessage(ChatColor.RED + "That player is not online!");
    return false;
    } else {
    if (args[1] == "private" || args[1] == "p") {
    sender.sendMessage(ChatColor.AQUA + "You hugged " + other + "!");
    other.sendMessage(ChatColor.AQUA + "" + sender + " hugged you!");
    return true;
    } else if (args[1] == "all" || args[1] == "a") {
    getServer().broadcastMessage(ChatColor.AQUA + "" + sender + " hugged " + other + "!");
    return true;
    } else if (args[1] == null) {
    sender.sendMessage(ChatColor.RED + "No target specified, using all.");
    getServer().broadcastMessage(ChatColor.AQUA + "" + sender + " hugged " + other + "!");
    return true;
    }
    }
    }
    }
    //eSlap: the slapping command
    else if (cmd.getName().equalsIgnoreCase("eslap")) {
    if (args.lenght > 3) {
    sender.sendMessage(ChatColor.RED + "Wrong amount of arguments! Try /eSlap <player> [private/all]!");
    return false;
    } else if (player == null) {
    //The command is sent by the console
    Player other = (Bukkit.getServer().getPlayer(args[0]));
    if (other == null) {
    sender.sendMessage(ChatColor.RED + "That player is not online!");
    } else {
    if (args[1] == "private" || args[1] == "p") {
    sender.sendMessage(ChatColor.AQUA + "You slapped " + other + "!");
    other.sendMessage(ChatColor.AQUA + "Ouch! The Gods slapped you!");
    } else if (args[1] == "all" || args[1] == "a") {
    getServer().broadcastMessage(ChatColor.AQUA + "Ouch, the Gods slapped " + other + "!");
    } else if (args[1] == null) {
    sender.sendMessage(ChatColor.RED + "No target specified, using all.");
    getServer().broadcastMessage(ChatColor.AQUA + "The Gods slapped " + other + "!");
    }
    } else {
    //The command is sent by a player
    Player other = (Bukkit.getServer().getPlayer(args[0]));
    if (other == null) {
    sender.sendMessage(ChatColor.RED + "That player is not online!");
    return false;
    } else {
    if (args[1] == "private" || args[1] == "p") {
    sender.sendMessage(ChatColor.AQUA + "You slapped " + other + "!");
    other.sendMessage(ChatColor.AQUA + "Ouch! " + sender + " slapped you!");
    return true;
    } else if (args[1] == "all" || args[1] == "a") {
    getServer().broadcastMessage(ChatColor.AQUA + "Ouch, " + sender + " slapped " + other + "!");
    return true;
    } else if (args[1] == null) {
    sender.sendMessage(ChatColor.RED + "No target specified, using all.");
    getServer().broadcastMessage(ChatColor.AQUA + "Ouch, " + sender + " slapped " + other + "!");
    return true;
    }
    }
    }
    }
    return false;
    }
    
    (I know there are probably some other mistakes, but right now, I'm only interested in the String-error)
    And even if I put
    Code:
    String test = "lmao";
    or something like it anywhere in the file, it gives me the exact same error: String cannot be resolved to a type.

    EDIT: I'd like to rephrase what I said in the first post. I didn't just start learning Java, I already knew the basics. (The VERY basic basics, that is.)

    Oh wait!
    I think I fixed it!
    There was an error with the library it used, turns out I just had to use Quick Fix and set it to jre6.
    Still, thanks :D

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
Thread Status:
Not open for further replies.

Share This Page