Saving Selected Locatoins

Discussion in 'Plugin Development' started by russ9929, Jun 25, 2012.

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

    russ9929

    I'm almost done with my dungeon plugin I am just stumped at one point. I used a wooden sword to select two points just like worldedit uses a wooden axe for a wand. Now how can I save these two points into permanant memory. The second point when stepped on will give a person 7 diamonds, but it won't work since I can't save them into the plugins memory.
     
  2. Offline

    hammale

    By this i assume you mean that when the server is restarted it will keep the data? If thats what you want you are going to have to write to a file.
     
  3. Offline

    evilmidget38

    russ9929
    You could save them as a string in the format x,y,z. Then you could convert that String into an array of strings, splitting it at the ","s. Once you split it into an array, try to parse all the values, and then you can construct a Location with them.
    Remember that Location's constructor requires a world, so you might have to save it in the format <worldname>,<x>,<y>,<z>. If you were saving the location of a player, you might also want to add in the yaw and the pitch.

    EDIT: Quoted the wrong post, my bad. Tagged the proper person instead.
     
  4. Offline

    hammale

    lol is that y i got an alert?
     
  5. Offline

    evilmidget38

    Yeah, I accidentally replied to your post. And I just realized I accidentally spelled his name wrong. Time for Edit number 2.
     
    hammale likes this.
  6. Offline

    russ9929

    Code:
        @EventHandler()
        public void onPlayerInteract(final PlayerInteractEvent event) {
            if (createSession.containsKey(event.getPlayer().getName())) {
                if (event.getPlayer().getItemInHand().getType() == Material.WOOD_SWORD) {
                    if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
                        event.getPlayer().sendMessage("Dungeon Start Set. Rick Click To Pick The End");
                        createSession.get(event.getPlayer().getName()).setStartBlock(event.getClickedBlock().getLocation());
                    } else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
                        createSession.get(event.getPlayer().getName()).setEndBlock(event.getClickedBlock().getLocation());
                        event.getPlayer().sendMessage("Dungeon End Set");
                    }
     
                }
            }
        }
    So should I change it?
    Right now what I have is:
     
  7. Offline

    evilmidget38

    I don't really see how that's related to your question above, unless I misunderstood what you were asking. If createSession's get method saves the location, then we'd have to see that.
     
  8. Offline

    russ9929

    I had someone help me with this and he told me to do this to select the location and I had to find out how to save it. If you know another way to do it please show me
     
Thread Status:
Not open for further replies.

Share This Page