Public type must be defined as its own file?

Discussion in 'Plugin Development' started by EpicDinosaurz, Apr 26, 2014.

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

    EpicDinosaurz

    Hi there!

    I finished writing a plugin recently, but I have just one error. Here is what it looks like:
    http://prntscr.com/3drnlu

    I am sure this is a small mistake except I have triple checked and I am not sure where I went wrong. Here is my build path:

    http://prntscr.com/3drnyg
     
  2. Offline

    Glumpz

    EpicDinosaurz Please provide full code, the line(s) that the error is occuring on, and, if needed, an error log.
     
  3. Offline

    epicfacecreeper

    Is your class name the same as the file name?
     
  4. Offline

    EpicDinosaurz

    Glumpz Line 14; here is the code

    package me.contrabandcount.epicdinosaurz;

    import java.util.logging.Logger;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Server;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scheduler.BukkitRunnable;

    public class CountrabandCount extends JavaPlugin
    {
    public final Logger logger = Logger.getLogger("Minecraft");
    public static ContrabandCount plugin;
    public Player target;
    public String contra = ChatColor.RED + "[PRISON] " + ChatColor.RESET;

    public void onDisable()
    {
    PluginDescriptionFile pdfFile = getDescription();
    this.logger.info(pdfFile.getName() + " has been disabled.");
    }

    public void onEnable()
    {
    PluginDescriptionFile pdfFile = getDescription();
    this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " has been enabled.");
    }

    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    if ((commandLabel.equalsIgnoreCase("sword")) ||
    (commandLabel.equalsIgnoreCase("bow")) ||
    (commandLabel.equalsIgnoreCase("armor")) ||
    (commandLabel.equalsIgnoreCase("drugs"))) {
    String item = commandLabel.toLowerCase();
    if (sender.hasPermission("ContrabandCount." + item)) {
    if (args.length < 1) {
    sender.sendMessage(this.contra + ChatColor.RED + "syntax: " + ChatColor.RED + "/" + item + " <player>");
    return true;
    }
    this.target = sender.getServer().getPlayer(args[0]);
    if (this.target == null) {
    sender.sendMessage(this.contra + ChatColor.RED + "ERROR: " + ChatColor.RED + "player not found.");
    return true;
    }
    if (sender != this.target) sender.sendMessage(this.contra + "You have asked " + ChatColor.YELLOW + this.target.getName() + ChatColor.RESET + " for his " + ChatColor.YELLOW + item + ChatColor.RESET + ".");
    this.target.sendMessage(this.contra + ChatColor.YELLOW + sender.getName() + ChatColor.RESET + " has asked for your " + ChatColor.YELLOW + item + ChatColor.RESET + ".");

    broadcastMsg(this.contra + ChatColor.YELLOW + sender.getName() + ChatColor.GRAY + " has asked " + ChatColor.YELLOW + this.target.getName() + ChatColor.GRAY + " for his " + ChatColor.YELLOW + item + ChatColor.GRAY + ".", sender);

    new BukkitRunnable() { int n;
    Player t;
    CommandSender s;

    public void run() { if (this.n > 0) {
    this.t.sendMessage(ContrabandCount.this.contra + this.n);
    if (this.s != this.t) this.s.sendMessage(ContrabandCount.this.contra + this.n);
    }
    else if (this.n > -1) {
    this.t.sendMessage(ContrabandCount.this.contra + "If you have not dropped the contraband item, you may be jailed or killed.");
    if (this.s != this.t) this.s.sendMessage(ContrabandCount.this.contra + "If " + ChatColor.YELLOW + this.t.getName() + ChatColor.RESET + " has not dropped the contraband item, you may jail or kill him.");
    }
    else { cancel(); }

    this.n -= 1; }
    }
    .runTaskTimer(this, 0L, 22L);

    return true;
    }noPerms(sender);
    } else if (commandLabel.equalsIgnoreCase("out")) {
    if (sender.hasPermission("ContrabandCount.out")) {
    if (args.length < 1) {
    sender.sendMessage(this.contra + ChatColor.RED + "syntax: " + ChatColor.RED + "/out <player>");
    return true;
    }
    this.target = sender.getServer().getPlayer(args[0]);
    if (this.target == null) {
    sender.sendMessage(this.contra + ChatColor.RED + "ERROR: " + ChatColor.RED + "player not found.");
    return true;
    }
    if (sender != this.target) sender.sendMessage(this.contra + ChatColor.GRAY + "You have asked " + ChatColor.YELLOW + this.target.getName() + ChatColor.GRAY + " to leave the safe zone area.");
    this.target.sendMessage(this.contra + ChatColor.YELLOW + sender.getName() + ChatColor.RESET + " has asked you to leave the safe zone.");

    broadcastMsg(this.contra + ChatColor.YELLOW + sender.getName() + ChatColor.GRAY + " has asked " + ChatColor.YELLOW + this.target.getName() + ChatColor.GRAY + " to leave the safe zone.", sender);

    new BukkitRunnable() { int n;
    Player t;
    CommandSender s;

    public void run() { if (this.n > 0) {
    this.t.sendMessage(ContrabandCount.this.contra + this.n);
    if (this.s != this.t) this.s.sendMessage(ContrabandCount.this.contra + this.n);
    }
    else if (this.n > -1) {
    this.t.sendMessage(ContrabandCount.this.contra + ChatColor.RED + "If you have not left the safe zone, you may be jailed or killed.");
    if (this.s != this.t) this.s.sendMessage(ContrabandCount.this.contra + "If " + ChatColor.YELLOW + this.t.getName() + ChatColor.RESET + " has not left the safe zone, you may jail or kill him.");
    }
    else { cancel(); }

    this.n -= 1; }
    }
    .runTaskTimer(this, 0L, 22L);

    return true;
    }noPerms(sender);
    } else if (commandLabel.equalsIgnoreCase("ask")) {
    if (sender.hasPermission("ContrabandCount.ask")) {
    if (args.length < 2) {
    sender.sendMessage(this.contra + ChatColor.RED + "syntax: " + ChatColor.RESET + "/ask <player> <item>");
    return true;
    }
    this.target = sender.getServer().getPlayer(args[0]);
    String item = args[1];
    if (this.target == null) {
    sender.sendMessage(this.contra + ChatColor.RED + "ERROR: " + ChatColor.RESET + "player not found.");
    return true;
    }
    if (sender != this.target) sender.sendMessage(this.contra + "You have asked " + ChatColor.YELLOW + this.target.getName() + ChatColor.RESET + " for his " + ChatColor.YELLOW + item + ChatColor.RESET + ".");
    this.target.sendMessage(this.contra + ChatColor.YELLOW + sender.getName() + ChatColor.RESET + " has asked for your " + ChatColor.YELLOW + item + ChatColor.RESET + ".");

    broadcastMsg(this.contra + ChatColor.YELLOW + sender.getName() + ChatColor.RESET + " has asked " + ChatColor.YELLOW + this.target.getName() + ChatColor.RESET + " for his " + ChatColor.YELLOW + item + ChatColor.RESET + ".", sender);

    new BukkitRunnable() { int n;
    Player t;
    CommandSender s;

    public void run() { if (this.n > 0) {
    this.t.sendMessage(ContrabandCount.this.contra + this.n);
    if (this.s != this.t) this.s.sendMessage(ContrabandCount.this.contra + this.n);
    }
    else if (this.n > -1) {
    this.t.sendMessage(ContrabandCount.this.contra + ChatColor.RED + "If you have not dropped the contraband item, you may be jailed or killed.");
    if (this.s != this.t) this.s.sendMessage(ContrabandCount.this.contra + "If " + ChatColor.YELLOW + this.t.getName() + ChatColor.RESET + " has not dropped the contraband item, you may jail or kill him.");
    }
    else { cancel(); }

    this.n -= 1; }
    }
    .runTaskTimer(this, 0L, 22L);

    return true;
    }noPerms(sender);
    }
    returntrue;
    }

    public void broadcastMsg(String str, CommandSender sender) {
    for (Player online : Bukkit.getServer().getOnlinePlayers())
    if ((online.hasPermission("ContrabandCount.msg")) &&
    (online != this.target) && (online != sender))
    online.sendMessage(str);
    }

    public void noPerms(CommandSender sender)
    {
    sender.sendMessage(this.contra + "[PRISON] You do not have permission to use this command.");

    }
     
Thread Status:
Not open for further replies.

Share This Page