e cannot be resolved

Discussion in 'Spigot Plugin Development' started by JimmYTje, May 28, 2017.

  1. Player p = e.getPlayer();
    Im trying to do that but im getting
    E cannot be resolved?
  2. Have you cast e to something? Give us the full code please.
  3. Could you post your code please? Or at least the methode where you get this error.
  4. Code (Text):

    package me.iDevq.TestPlugin;

    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scoreboard.DisplaySlot;
    import org.bukkit.scoreboard.Objective;
    import org.bukkit.scoreboard.Score;
    import org.bukkit.scoreboard.Scoreboard;
    import org.bukkit.scoreboard.ScoreboardManager;

    import net.md_5.bungee.api.ChatColor;

    public class Main extends JavaPlugin implements Listener {
        public void onEnable() {
            Player p = e.getPlayer();
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
            getCommand("main").setExecutor(new BasisCommand());
            getCommand("hello").setExecutor(new CMessage());
            getCommand("fine").setExecutor(new Fine());
            ScoreboardManager manager = Bukkit.getScoreboardManager();
            Scoreboard board = manager.getNewScoreboard();
            Objective obj = board.registerNewObjective("test", "dummy");
            obj.setDisplayName(ChatColor.RED + "iDevq Scoreboard!" + ChatColor.RESET);
            Score score1 = obj.getScore(ChatColor.RED + "Speler Naam:" + ChatColor.RESET);
            Score score2 = obj.getScore(ChatColor.AQUA + p.getName());      
            Score score3 = obj.getScore(ChatColor.RED + "Deaths:" + ChatColor.RESET);    
            for (Player all : Bukkit.getOnlinePlayers()) {

  5. "e" doesn't have a value, also why are you implementing Listener?
  6. If i dont implementing Listener i will get a second error
  7. he method registerEvents(Listener, Plugin) in the type PluginManager is not applicable for the arguments (Main, Main)
  8. You don't actualy have any events in main, you should be fine if you just delete that line and stop implementing listener.
  9. Im still struggling with the error from e cannot be resolved.
  10. Strahan


    I seriously recommend learning Java before trying to make plugins. The fact that the e.getPlayer thing confused you is scary as hell.
    • Like Like x 1
  12. You're just throwing random shit around. There is no variable "e". You're literally trying to access something that is undefined. You can't just copy and paste code like that and expect it to work. If programming was that easy, developers would be out of a job.

    Follow @Strahan's advice. Learn Java before attempting to make this plugin.