Solved Class Issue, I don't understand!

Discussion in 'Plugin Help/Development/Requests' started by arsenalfcgunners, May 8, 2015.

Thread Status:
Not open for further replies.
  1. If you need any more information just ask!
    Error I am getting:
    This code is from my Battle class where the error occurs. The error occurs where I create the new Arena and add it to the ArrayList.
    Code:
    if(cmd.getName().equalsIgnoreCase("arenacreate")){
                Player player = (Player) sender;
                if(player.hasPermission("1v1.manage")){
                    Boolean found = false;
                    int length = args.length;
                    if(length == 1){
                        for(Arena arena : arenas) {
                            if(arena.getName().equalsIgnoreCase(args[0])){
                                found = true;
                            }
                        }
                        if(found){
                            player.sendMessage(tag+""+ChatColor.YELLOW+"ERROR: That arena already exists!");
                        }
                        else{
                            arenas.add(new Arena(args[0]));
                            config.set("1v1."+"Arenas", arenas);
                            player.sendMessage(tag+""+ChatColor.GREEN+"You have created the arena!");
                        }
                    }
                    else{
                        player.sendMessage(tag+""+ChatColor.RED+"Proper usage: /arenacreate <Arena Name>");
                    }
                }
                else{
                    player.sendMessage(tag+""+ChatColor.YELLOW+"ERROR: You don't have permission!");
                }
                return true;
            }
    Important code from Arena Class:
    Code:
    package me.arsenalfcgunners;
    
    import java.util.ArrayList;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.entity.Damageable;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.ItemStack;
    
    public class Arena extends Battle{
        String name;
        Location spawn1;
        Location spawn2;
        static boolean ingame = false;
        static ArrayList<Player> players = new ArrayList<Player>();
        static String tag = ChatColor.DARK_GREEN+"["+ChatColor.GREEN+"1v1"+ChatColor.DARK_GREEN+"]";
       
        public Arena(String arenaName){
            name = arenaName;
        }
    Any help is appreciated. Thanks!
     
    Last edited: May 8, 2015
  2. Offline

    timtower Administrator Administrator Moderator

  3. Just updated the code. Some of them should have not been, that was a mistake. The reason that the other ones are is so that I can access them from the Battle class.
     
  4. Offline

    timtower Administrator Administrator Moderator

    Moved to Bukkit alternatives
    @arsenalfcgunners When you extend it then you shouldn't access them from the battle class anymore, and if you still access it then you use getters and setters for it.
    EDIT: Are you extending the main class? Never do that please.
     
  5. k, I will fix that. But that's not causing the problem is it?
     
  6. Offline

    timtower Administrator Administrator Moderator

    Yes it is.
     
  7. Thanks so much! Got rid of all my static variables, and I no longer extend the Battle class. It worked! :)
     
  8. Offline

    timtower Administrator Administrator Moderator

Thread Status:
Not open for further replies.

Share This Page