Solved Help with Locations

Discussion in 'Plugin Development' started by GameLawl, May 10, 2015.

Thread Status:
Not open for further replies.
  1. I am receiving this error: "Type mismatch: cannot convert from element type org.bukkit.Location to Location"
    I dont know what i am doing wrong or what the problem is

    Code:
    public static void onPlay(int id){
            for(Location loc : PlotManager.getInstance().getPlot(id).particlelocations){
               
            }
        }
    
    And this is the class where getInstance().getPlot(id) references to:

    Code:
     public class SectionObject {
       
        public static ArrayList<SectionObject> sections = new ArrayList<SectionObject>();
        public static ArrayList<Player> players = new ArrayList<Player>();
        public static ArrayList<BlockState> allblocks = new ArrayList<BlockState>();
       
        private int id;
        private Player owner;
        public ArrayList<BlockState> blocks = new ArrayList<BlockState>();
        private int points;
        public ArrayList<Location> particlelocations = new ArrayList<Location>();
        public HashMap<Integer, String> particles = new HashMap<Integer, String>();
        private double x_start;
        private double y_start;
        private double z_start;
        private double x_end;
        private double y_end;
        private double z_end;
        private Location spawn;
       
        public SectionObject(double xs, double ys, double zs, double xe, double ye, double ze, Location s){
            this.x_start = xs;
            this.y_start = ys;
            this.z_start = zs;
            this.x_end = xe;
            this.y_end = ye;
            this.z_end = ze;
            this.spawn = s;
            this.id = sections.size() + 1;
            sections.add(this);
        }
       
        public void addPlayer(Player p){
            this.owner = p;
            players.add(p);
        }
       
        public int getId() {
            return id;
        }
        public void setId(int id) {
            this.id = id;
        }
        public Player getOwner() {
            return owner;
        }
        public void setOwner(Player owner) {
            this.owner = owner;
        }
        public int getPoints() {
            return points;
        }
        public void setPoints(int points) {
            this.points = points;
        }
        public double getX_start() {
            return x_start;
        }
        public void setX_start(double x_start) {
            this.x_start = x_start;
        }
        public double getY_start() {
            return y_start;
        }
        public void setY_start(double y_start) {
            this.y_start = y_start;
        }
        public double getZ_start() {
            return z_start;
        }
        public void setZ_start(double z_start) {
            this.z_start = z_start;
        }
        public double getX_end() {
            return x_end;
        }
        public void setX_end(double x_end) {
            this.x_end = x_end;
        }
        public double getZ_end() {
            return z_end;
        }
        public void setZ_end(double z_end) {
            this.z_end = z_end;
        }
        public double getY_end() {
            return y_end;
        }
        public void setY_end(double y_end) {
            this.y_end = y_end;
        }
        public Location getSpawn() {
            return spawn;
        }
        public void setSpawn(Location spawn) {
            this.spawn = spawn;
        }
       
    
           
    }
    
    I hope you guys can help :)
     
  2. It appears that there is a casting error, do you have a custom Location class?
     
  3. Offline

    blablubbabc

    Maybe you have messed up your imports.
     
  4. I only have one import in that class and that is: org.bukkit.Location;

    Not that i know, it goes into a constructor where it is registered with an Id and there i take the location from a ArrayList

    <Edit by mrCookieSlime: Merged posts. Please don't double post. There is an Edit Button right next to the Date.>
     
    Last edited by a moderator: May 10, 2015
  5. I have no clue, sometimes it helps restarting your IDE
     
  6. Maybe you have imported the net.minecraft.server.vx_x_x.Location instead of org.bukkit.location.Location
     
  7. Nope that doesnt work either

    I tried it but it doesnt work :(
     
  8. If you are using eclipse:
    1. Remove all imports
    2. Press Ctrl + Shift + O
    Do the same thing in the class where particlesLocation is
     
  9. Thanks! It worked. It is pretty weird because normaly i dont get any of these problems.
     
  10. Offline

    Tecno_Wizard

    @FishyLP, be careful with that function. It has a tendency to import the wrong classes.
     
  11. @Tecno_Wizard When there are multiple classes with the same name that could be imported, it shows you a window which one you want to import
     
  12. Offline

    Tecno_Wizard

    @FisheyLP
    That must have started in Luna because when I originally switched to intelliJ that was still an issue.
     
Thread Status:
Not open for further replies.

Share This Page