Help with CourceObject classes

Discussion in 'Plugin Development' started by GeekyCompz, Jul 4, 2014.

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

    GeekyCompz

    Hello, I am having difficulty creating a plugin for my future server which is complete. It just needs this final plugin. I have the basis of the plugin setup, (I think) and just need someone to help code the rest of the plugin. I have skype, but am not willing to voice chat. I have github setup aswell. I will give more information if you message through skype.

    Skype: Open-Bytes

    ~OpenBytes
     
  2. Offline

    xTigerRebornx

    GeekyCompz Why not just ask for help on here rather then asking for private help? There are many members who spend their time here and will help you here if you post your problem, relevant code, and any other relevant things (such as a stacktrace, video, screenshot, description of problem, etc).
     
  3. Offline

    GeekyCompz

  4. Offline

    AoH_Ruthless

    xTigerRebornx
    Not to mention it's probably faster and in some cases, more reliable.

    GeekyCompz
    Can you tell us what is actually wrong, or what you need help with? You can't give us a Git Repo full of code and say "Help me, I can't figure out what to do".

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  5. Offline

    GeekyCompz

    AoH_Ruthless Basically I am unsure of how to load data from the courses file (coursesF) and through the CourseManager load the data into each parkour courses individual class with all the data.

    For example; a course has a name of EASY and another of HARD in the coursesF config file. When the plugin starts the class CoursesManager begins to load the data from the EASY and HARD and put it into its own CoursesObject class, so EASY and HARD both have their own CourseObject class. This allows me to get the correct CourseObject class and get the data from it.

    I hope you understand all that :p xD

    ~OpenBytes

    This is the CourseManager class which loads all the courses.
    Code:
    public class CourseManager {
     
        private CourseManager() { }
       
        private static CourseManager instance = new CourseManager();
       
        public static CourseManager getInstance() {
            return instance;
        }
       
        private ArrayList<CourseObject> courses = new ArrayList<CourseObject>();
       
        public void setup() {
            //TODO Create the course classes.
        }
       
        public CourseObject getCourse(Player p) {
            for (CourseObject cO : courses) {
                if (cO.containsPlayer(p)) return cO;
            }
            return null;
        }
       
        public CourseObject getCourse(String n) {
            for (CourseObject cO : courses) {
                if (cO.getName() == n) return cO;
            }
            return null;
        }
       
    }
    
    This is the CourseObject class.
    Code:
    public class CourseObject {
     
        private CourseObject() { }
       
        private static CourseObject instance = new CourseObject();
       
        public static CourseObject getInstance() {
            return instance;
        }
       
        EnhancedParkour plugin;
        CourseObject (EnhancedParkour plugin) {
            this.plugin = plugin;
        }
       
        protected String name;
        protected String group;
        protected Location start, end;
        protected ArrayList<Player> players = new ArrayList<Player>();
       
        public void Arena(String n) {
            this.name = n;
           
            ConfigurationSection cs = plugin.courses.getConfigurationSection(n);
           
            this.start = getLocation(cs.getConfigurationSection("start"));
            this.start = getLocation(cs.getConfigurationSection("end"));
        }
       
        public Location getLocation(ConfigurationSection path) {
            return new Location(
                    Bukkit.getWorld(path.getString("World")),
                    path.getDouble("X"),
                    path.getDouble("Y"),
                    path.getDouble("Z"),
                    (float)path.getInt("Yaw"),
                    (float)path.getInt("Pitch"));
        }
       
        public String getName() {
            return name;
        }
       
        public String getGroup() {
            return group;
        }
       
        public Location getStart() {
            return start;
        }
       
        public Location getEnd() {
            return end;
        }
       
        public boolean containsPlayer(Player p) {
            if (players.contains(p)) return true;
            return false;
        }
       
    }
    
    And this is how I am getting the CourseObject for a specific course.
    Code:
    CourseObject course = CourseManager.getInstance().getCourse(e.getPlayer());
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
Thread Status:
Not open for further replies.

Share This Page