Solved ****** cannot be resolved or is not a field

Discussion in 'Spigot Plugin Help' started by Phraktures, May 3, 2017.

  1. Hello guys, you speak here with Phraktures i need to solve a problem but i don't now how its possible I made this plugin three years ago but do not work right now

    What is the problem is a basic line about cannot resolved

    Here a example: WALL_SIGN cannot be resolved or is not a field

    Everything what red is cannot be resolved how can I fix this or can somebody fix this for me thank you
    You get the credits when i'm going to upload the source

    Screen of my code
    http://prntscr.com/f3hiln

    Code (Text):
    package gravityfun.screen;

    import java.util.ArrayList;
    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;

    public class GreenScreen
    {
      public static void EnableGreenScreen(Player player)
      {
        player.setResourcePack("https://www.dropbox.com/s/92gmru3om50v1x6/GreenScreenOn.zip?dl=1");
        player.sendMessage(Main.Prefix + ChatColor.DARK_GREEN + "Your GreenScreen has been Enabled!");
        Main.greenscreen.add(player);
      }

      public static void DisableGreenScreen(Player player)
      {
        player.setResourcePack("https://www.dropbox.com/s/n2898enmycbupxr/GreenScreenOff.rar?dl=1");
        player.sendMessage(Main.Prefix + ChatColor.RED + "Your GreenScreen has been disabled!");
        Main.greenscreen.remove(player);
      }

      public static void OpenGUI(Player player)
      {
        player.openInventory(Gui.GUI);
      }

      public static boolean CheckGreenScreen(Player player)
      {
        if (Main.greenscreen.contains(player)) {
          return true;
        }
        return false;
      }
    }
     
     
    #1 Phraktures, May 3, 2017
    Last edited: May 3, 2017
  2. Can you post Also the main class?
     
  3. I can do it for you here under below this text
    Code (Text):
    package gravityfun.screen;

    import java.util.ArrayList;

    import org.bukkit.Bukkit;
    import org.bukkit.block.Sign;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockBreakEvent;
    import org.bukkit.event.block.SignChangeEvent;
    import org.bukkit.event.inventory.InventoryClickEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.plugin.java.JavaPlugin;

    import com.sun.corba.se.spi.orbutil.fsm.Action;
    import com.sun.prism.Material;

    import net.md_5.bungee.api.ChatColor;

    public class Main
      extends JavaPlugin
      implements Listener
    {
      public static final String greenscreen = null;
    static String Prefix = "�9[�aGreenScreen�9] ";
      static ArrayList<Player> greenscreen = new ArrayList();
    public static Object greenscreen1;
    public static ChatColor Prefix1;
     
      public void onEnable()
      {
        Bukkit.getServer().getPluginManager().registerEvents(this, this);
        new Gui();
      }
     
      public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
      {
        Player p = (Player)sender;
        if (label.equalsIgnoreCase("greenscreen")) {
          if ((args.length == 0) || (args[0].equalsIgnoreCase("help")))
          {
            sender.sendMessage(Prefix + ChatColor.DARK_GREEN + "GreenScreen v1.2 by TheIndra");
            sender.sendMessage("�9- /GreenScreen Help");
            sender.sendMessage("�9- /GreenScreen Enable");
            sender.sendMessage("�9- /GreenScreen Disable");
            sender.sendMessage("�9- /GreenScreen Items");
          }
          else if (args[0].equalsIgnoreCase("Enable"))
          {
            if (sender.hasPermission("GreenScreen.Use")) {
              GreenScreen.EnableGreenScreen(p);
            } else {
              sender.sendMessage(Prefix + ChatColor.RED + "You dont have the permission to do this!");
            }
          }
          else if (args[0].equalsIgnoreCase("Disable"))
          {
            if (sender.hasPermission("GreenScreen.Use")) {
              GreenScreen.DisableGreenScreen(p);
            } else {
              sender.sendMessage(Prefix + ChatColor.RED + "You dont have the permission to do this!");
            }
          }
          else if (args[0].equalsIgnoreCase("Items"))
          {
            if (sender.hasPermission("GreenScreen.Use"))
            {
              GreenScreen.OpenGUI(p);
              sender.sendMessage(Prefix + ChatColor.BLUE + "Showing items you can use...");
            }
            else
            {
              sender.sendMessage(Prefix + ChatColor.RED + "You dont have the permission to do this!");
            }
          }
          else
          {
            sender.sendMessage(Prefix + ChatColor.RED + "Subcommand not found! Try /greenscreen help");
          }
        }
        return false;
      }
     
      @EventHandler
      public void onInventoryClick(InventoryClickEvent e)
      {
        if (e.getInventory().getName().equalsIgnoreCase(Gui.GUI.getName()))
        {
          e.setCancelled(true);
          e.getWhoClicked().sendMessage(Prefix + ChatColor.RED + "You cant export items from this menu, Search them in your inventory ;)");
        }
      }
     
      @EventHandler
      public void Sign(SignChangeEvent e)
      {
        Player p = e.getPlayer();
        if (e.getLine(0).equalsIgnoreCase("[GreenScreen]")) {
          if (p.hasPermission("GreenScreen.Sign"))
          {
            e.setLine(0, "�2[GreenScreen]");
            e.setLine(1, "Toggle");
          }
          else
          {
            p.sendMessage(Prefix + ChatColor.RED + "You dont have the permissions to make a greenscreen sign");
          }
        }
      }
     
      @EventHandler(priority=EventPriority.HIGHEST)
      public void SignClick(PlayerInteractEvent event)
      {
        if (((event.getAction() == Action.RIGHT_CLICK_BLOCK) && (event.getClickedBlock().getType() == Material.WALL_SIGN)) || (event.getClickedBlock().getType() == Material.SIGN_POST))
        {
          Sign sign = (Sign)event.getClickedBlock().getState();
          if (sign.getLine(0).equalsIgnoreCase("�2[GreenScreen]")) {
            if (event.getPlayer().hasPermission("GreenScreen.Use"))
            {
              if (greenscreen.contains(event.getPlayer())) {
                GreenScreen.DisableGreenScreen(event.getPlayer());
              } else {
                GreenScreen.EnableGreenScreen(event.getPlayer());
              }
            }
            else {
              event.getPlayer().sendMessage(Prefix + ChatColor.RED + "You dont have the permissions to do this!");
            }
          }
        }
      }
     
      @EventHandler
      public void SignBreak(BlockBreakEvent e)
      {
        if ((e.getBlock().getType() == Material.WALL_SIGN) || (e.getBlock().getType() == Material.SIGN_POST))
        {
          Sign sign = (Sign)e.getBlock().getState();
          if ((sign.getLine(0).equalsIgnoreCase("�2[GreenScreen]")) &&
            (!e.getPlayer().hasPermission("GreenScreen.Sign")))
          {
            e.getPlayer().sendMessage(Prefix + ChatColor.RED + "You dont have the permissions to break a greenscreen sign");
            e.setCancelled(true);
          }
        }
      }
    }
     
     
  4. Its a old plugin that is the reason why this is: � I was already to fix it but I can't solve my command line
     
  5. Try to change in the main class the arraylist in:
    Code (Text):
    public static ArrayList<Player> greenscreen = new ArrayList<Player>();
    And what's the problem for the commands?
     
  6. I already fix it self ;) [Solved]
     
  7. Code (Text):
    package me.gravity.staff;

    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.SkullType;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.command.PluginCommand;
    import org.bukkit.configuration.ConfigurationSection;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.HumanEntity;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.inventory.InventoryClickEvent;
    import org.bukkit.event.inventory.InventoryInteractEvent;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.inventory.meta.SkullMeta;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;

    public class Core
      extends JavaPlugin
      implements Listener, CommandExecutor
    {
      private Inventory gui;
      private Inventory desc;
     
      public void onEnable()
      {
        Bukkit.getPluginManager().registerEvents(this, this);
        if (!getConfig().isSet("Menu-Settings.Title"))
        {
          getConfig().set("Menu-Settings.Title", "&6Gravity&fMC &9Staff list");
          saveConfig();
        }
        if (!getConfig().isSet("Menu-Settings.Rows"))
        {
          getConfig().set("Menu-Settings.Rows", Integer.valueOf(4));
          saveConfig();
        }
        String guiname = getConfig().getString("Menu-Settings.Title");
        int rows = getConfig().getInt("Menu-Settings.Rows");
        this.gui = Bukkit.createInventory(null, 9 * rows, ChatColor.translateAlternateColorCodes('&', guiname));
        this.desc = Bukkit.createInventory(null, 9, "");
       
        getCommand("staff").setExecutor(this);
      }
     
      @EventHandler
      private void onInvvInteract(InventoryClickEvent event)
      {
        if (event.getInventory().getName() == this.gui.getName())
        {
          event.setCancelled(true);
          if (event.getCurrentItem().getItemMeta() == null) {
            return;
          }
          String name = ChatColor.stripColor(event.getCurrentItem().getItemMeta().getDisplayName());
          if (getConfig().isSet("Staff." + name + ".Description"))
          {
            event.getWhoClicked().closeInventory();
            ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short)SkullType.PLAYER.ordinal());
            Player p = Bukkit.getPlayer(name);
            SkullMeta meta = (SkullMeta)skull.getItemMeta();
            meta.setOwner(p.getName());
            meta.setDisplayName(ChatColor.YELLOW + "StaffMember");
            ArrayList<String> lore = new ArrayList();
            for (String s : getConfig().getStringList("Staff." + p.getName() + ".Description")) {
              lore.add(ChatColor.translateAlternateColorCodes('&', s));
            }
            meta.setLore(lore);
            skull.setItemMeta(meta);
            this.desc = Bukkit.createInventory(null, 9, ChatColor.GRAY + "[" + ChatColor.DARK_AQUA + "StaffMember" + ChatColor.GRAY + "]" + " Reason list ");
            this.desc.setItem(4, skull);
           
            event.getWhoClicked().openInventory(this.desc);
            return;
          }
          event.getWhoClicked().closeInventory();
          event.getWhoClicked().sendMessage(ChatColor.GOLD + "Gravity"+ ChatColor.WHITE +"MC"+ ChatColor.GRAY + "»"+ ChatColor.RED + " They do not have a description added!");
        }
        if (event.getInventory().getName() == this.desc.getName())
        {
          event.setCancelled(true);
          if (event.getCurrentItem().getItemMeta() == null) {}
        }
      }
     
      @EventHandler
      private void onJoin(PlayerJoinEvent e)
      {
        if ((!getConfig().isSet("Staff." + e.getPlayer().getName() + ".Description")) &&
          (getConfig().isSet("Staff" + e.getPlayer().getName() + ".Rank")))
           
        {
          List<String> basicdesc = new ArrayList();
          basicdesc.add("�aThis is an automatically generated description");
          basicdesc.add("�aThis is an automatically generated description");
          basicdesc.add("�aThis is an automatically generated description");
          getConfig().set("Staff." + e.getPlayer().getName() + ".Description", basicdesc);
          saveConfig();
        }
      }
     
      @EventHandler
      private void onInvInteract(InventoryInteractEvent event)
      {
        if (event.getInventory().getName() == this.gui.getName()) {
          event.setCancelled(true);
        }
        if (event.getInventory().getName() == this.desc.getName()) {
          event.setCancelled(true);
        }
      }
     
      public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
      {
        if (!(sender instanceof Player)) {
          return true;
        }
        Player p = (Player)sender;
        String rank;
        String lorerank;
        if (args.length < 1)
        {
          p.sendMessage(ChatColor.GOLD + "Gravity"+ ChatColor.WHITE +"MC"+ ChatColor.GRAY + "»"+ ChatColor.DARK_AQUA + " Thank you, to open the StaffList GUI.");
          this.gui.clear();
          for (Player pp : Bukkit.getOnlinePlayers()) {
            if (getConfig().isSet("Staff." + pp.getName() + ".Rank"))
            {
              rank = getConfig().getString("Staff." + pp.getName() + ".Rank");
              ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short)SkullType.PLAYER.ordinal());
             
              SkullMeta meta = (SkullMeta)skull.getItemMeta();
              meta.setOwner(pp.getName());
              if (!getConfig().isSet("Menu-Settings.UserName"))
              {
                getConfig().set("Menu-Settings.UserName", "&e&l{USERNAME}");
                saveConfig();
              }
              if (!getConfig().isSet("Menu-Settings.Rank"))
              {
                getConfig().set("Menu-Settings.Rank", "&5&lRank : {RANK}");
                saveConfig();
              }
              String name = getConfig().getString("Menu-Settings.UserName");
              String varname = ChatColor.translateAlternateColorCodes('&',
                name.replace("{USERNAME}", pp.getName()));
              meta.setDisplayName(varname);
              ArrayList<String> lore = new ArrayList();
              lorerank = getConfig().getString("Menu-Settings.Rank");
              String varrank = ChatColor.translateAlternateColorCodes('&', lorerank.replace("{RANK}", rank));
              lore.add(varrank);
              meta.setLore(lore);
              skull.setItemMeta(meta);
              this.gui.addItem(new ItemStack[] { skull });
            }
          }
          p.openInventory(this.gui);
          return true;
        }
        if ((args[0].equalsIgnoreCase("reload")) &&
          (p.hasPermission("StaffGUI.edit")))
        {
          reloadConfig();
          p.sendMessage(ChatColor.GOLD + "Gravity"+ ChatColor.WHITE +"MC"+ ChatColor.GRAY + "»"+ ChatColor.DARK_AQUA +" You have reloaded GMCStaffGUI " + ChatColor.GREEN + "Config");
          if (!getConfig().isSet("Menu-Settings.Title"))
          {
            getConfig().set("Menu-Settings.Title", "&6Gravity&fMC &a&lOnline Staff");
            saveConfig();
          }
          if (!getConfig().isSet("Menu-Settings.Rows"))
          {
            getConfig().set("Menu-Settings.Rows", Integer.valueOf(6));
            saveConfig();
          }
          String guiname = getConfig().getString("Menu-Settings.Title");
          int rows = getConfig().getInt("Menu-Settings.Rows");
          this.gui = Bukkit.createInventory(null, 9 * rows, ChatColor.translateAlternateColorCodes('&', guiname));
          return true;
        }
        if (args[0].equalsIgnoreCase("list"))
        {
          @SuppressWarnings("rawtypes")
        HashMap<String, List<String>> staff = new HashMap();
          String rank1;
          for (String s : getConfig().getConfigurationSection("Staff").getKeys(false)) {
            if (getConfig().isSet("Staff." + s + ".Rank"))
            {
              rank1 = getConfig().getString("Staff." + s + ".Rank");
              if (staff.containsKey(rank1))
              {
                List<String> players = (List)staff.get(rank1);
                players.add(s);
              }
              else
              {
                List<String> players = new ArrayList();
                players.add(s);
                staff.put(rank1, players);
              }
            }
          }
          Object messages = new ArrayList();
          for (String s : staff.keySet())
          {
            String message = "";
            message = s + " �6�l���r �a";
            List<String> players = (List)staff.get(s);
            String listofplayers = "";
            for (String pl : players) {
              listofplayers = listofplayers + " " + pl + ",";
            }
            message = message + listofplayers;
            message = message.substring(0, message.length() - 1);
            ((List)messages).add(message);
          }
        }
        if (args[0].equalsIgnoreCase("remove"))
        {
          if (args.length < 2)
          {
            p.sendMessage(ChatColor.GOLD + "Gravity"+ ChatColor.WHITE +"MC"+ ChatColor.GRAY + "»"+ ChatColor.RED + " Not enough args.");
            return true;
          }
          if (p.hasPermission("StaffGUI.edit"))
          {
            if (getConfig().contains("Staff." + args[1]))
            {
              getConfig().set("Staff." + args[1] + ".Rank", null);
              getConfig().set("Staff." + args[1] + ".Description", null);
             
              p.sendMessage(ChatColor.GOLD + "Gravity"+ ChatColor.WHITE +"MC"+ ChatColor.GRAY + "»"+ ChatColor.DARK_AQUA + " You have" + ChatColor.RED + " removed" + " a staff member" +  " from the"+ ChatColor.DARK_AQUA + " GMCStaffGUI!");
             
              saveConfig();
              return true;
            }
            p.sendMessage(ChatColor.GOLD + "Gravity"+ ChatColor.WHITE +"MC"+ ChatColor.GRAY + "»"+ ChatColor.RED + " Could not find player in our data-bases!");
            return true;
          }
        }
        if (args[0].equalsIgnoreCase("deldesc"))
        {
          if (args.length < 2)
          {
            p.sendMessage(ChatColor.GOLD + "Gravity"+ ChatColor.WHITE +"MC"+ ChatColor.GRAY + "»"+ ChatColor.RED + " Not enough args.");
            return true;
          }
          if (p.hasPermission("StaffGUI.edit"))
          {
            if (getConfig().isSet("Staff." + args[1] + ".Rank"))
            {
              getConfig().set("Staff." + args[1] + ".Description", null);
              p.sendMessage(ChatColor.GOLD + "Gravity"+ ChatColor.WHITE +"MC"+ ChatColor.GRAY + "»"+ ChatColor.RED + " You have reset " + args[1] + " description!");
              saveConfig();
              return true;
            }
            p.sendMessage(ChatColor.GOLD + "Gravity"+ ChatColor.WHITE +"MC"+ ChatColor.GRAY + "»"+ ChatColor.RED + " Could not find player in our data-bases!");
            return true;
          }
          p.sendMessage(ChatColor.GOLD + "Gravity"+ ChatColor.WHITE +"MC"+ ChatColor.GRAY + "»"+ ChatColor.RED + " You do not have permissions!");
          return true;
        }
        if (args[0].equalsIgnoreCase("adddesc"))
        {
          if (args.length < 3)
          {
            p.sendMessage(ChatColor.GOLD + "Gravity"+ ChatColor.WHITE +"MC"+ ChatColor.GRAY + "»"+ ChatColor.RED + " Not enough args.");
            return true;
          }
          if (p.hasPermission("StaffGUI.edit"))
          {
            String desc = "";
            for (int i = 2; i < args.length; i++)
            {
              String arg = args[i] + " ";
              desc = desc + arg;
            }
            if (getConfig().isSet("Staff." + args[1] + ".Rank"))
            {
              if (!getConfig().isSet("Staff." + args[1] + ".Description"))
              {
                Object pdesc = new ArrayList();
                ((List)pdesc).add(ChatColor.translateAlternateColorCodes('&', desc));
                getConfig().set("Staff." + args[1] + ".Description", pdesc);
                p.sendMessage(ChatColor.GOLD + "Gravity"+ ChatColor.WHITE +"MC"+ ChatColor.GRAY + "»"+ ChatColor.RED + " You have edited " + args[1] + " description!");
                saveConfig();
                return true;
              }
              Object pdesc = getConfig().getStringList("Staff." + args[1] + ".Description");
              ((List)pdesc).add(desc);
              getConfig().set("Staff." + args[1] + ".Description", pdesc);
              p.sendMessage(ChatColor.GOLD + "Gravity"+ ChatColor.WHITE + "MC"+ ChatColor.GRAY + "»"+ ChatColor.RED + "You have edited " + args[1] + " description!");
              saveConfig();
              return true;
            }
            p.sendMessage(ChatColor.GOLD + "Gravity"+ ChatColor.WHITE + "MC"+ ChatColor.GRAY + "»"+ ChatColor.RED + "Could not find player in our data-bases!");
            return true;
          }
          p.sendMessage(ChatColor.GOLD + "Gravity"+ ChatColor.WHITE + "MC"+ ChatColor.GRAY + "»"+ ChatColor.RED + "You do not have permissions!");
          return true;
        }
        if (args.length == 2) {
          if ((p.hasPermission("StaffGUI.edit")) && (!args[0].equalsIgnoreCase("list")) &&
            (!args[0].equalsIgnoreCase("remove")) && (!args[0].equalsIgnoreCase("deldesc")) &&
            (!args[0].equalsIgnoreCase("adddesc")))
          {
            Player target = Bukkit.getPlayer(args[0]);
            if (target == null)
            {
              p.sendMessage(ChatColor.GOLD + "Gravity"+ ChatColor.WHITE + "MC"+ ChatColor.GRAY + "»"+ ChatColor.RED + "Could not find player data with the name : " + args[0]);
              return true;
            }
            if (getConfig().isSet("Staff." + target.getName() + ".Rank"))
            {
              getConfig().set("Staff." + target.getName() + ".Rank", args[1].replace("_", " "));
             
              p.sendMessage(ChatColor.GOLD + "Gravity"+ ChatColor.WHITE + "MC"+ ChatColor.GRAY + "»"+ ChatColor.DARK_AQUA + "You have changed " + ChatColor.GREEN + target.getName() + ChatColor.DARK_AQUA + " staff-rank to " + ChatColor.GREEN + args[1]);
              saveConfig();
              return true;
            }
            getConfig().set("Staff." + target.getName() + ".Rank", args[1].replace("_", " "));
            p.sendMessage(ChatColor.GOLD + "Gravity"+ ChatColor.WHITE + "MC"+ ChatColor.GRAY + "»"+ ChatColor.DARK_AQUA + "You have changed " + ChatColor.GREEN + target.getName() + ChatColor.DARK_AQUA + " staff-rank to " + ChatColor.GREEN + args[1]);
            saveConfig();
            return true;
          }
        }
        return true;
      }
    }
     
     
    • Like Like x 1