Solved Get name of Selection

Discussion in 'Plugin Development' started by Irantwomiles, Nov 7, 2016.

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

    Irantwomiles

    [Removed]
     
    Last edited: Nov 10, 2016
  2. Offline

    Zombie_Striker

    @Irantwomiles
    1. Get the section the player is currently in.
    2. Loop through all the "hills" in the config.
    3. If the config's section is equal to #1's section, then the player is on that hill.
     
  3. Offline

    Irantwomiles

    I didn't understand the 3rd point
     
  4. Offline

    Zombie_Striker

    @Irantwomiles
    I'm assuming you are storing the hill's section to the config. If you do that, what you want to do is see if the section from the config is equal to the on the player is standing in.
     
  5. Offline

    Irantwomiles

    So like check if the player is standing within a cuboid i have specified in the config and get the name that way?

    EDIT: So I did what you said @Zombie_Striker and it worked! But now I'm getting this really weird bug. So I'm using the event.getTo() and event.getFrom() to check if the players goes into or out of the cuboid, but it only works when the player comes out the cuboid.

    Code:
    
    into a region: location.contains(event.getTo()) && !location.contain(event.getFrom()); That is the simple way of writing it just in case you needed to know.
        @EventHandler
        public void onMove(PlayerMoveEvent event) {
            Player player = event.getPlayer();
          
            if (HillManager.getManager().hillByPlayer(player) != null) {
                if(!HillManager.getManager().hillByPlayer(player).getSelection().contains(event.getFrom())
                        && HillManager.getManager().hillByPlayer(player).getSelection().contains(event.getTo())) {
                    System.out.println("Inside");
                }
            }
    
        }
    
    I'm actually confused. I don't get any errors.
    TD;LR: it only works when the player comes out the region but doesn't when player goes into the region.

    EDIT: HillManager.getManager().hillByPlayer(player).getSelection() returns a CuboidSelection
     
    Last edited: Nov 9, 2016
  6. Offline

    Irantwomiles

    anyone have any ideas? I've tried everything and anything. It works if I put the name of a capture zone manually in my code but even thought using the hillByPlayer() method to get the name (Gives it correctly) it wont run that code and wont through any errors.
     
Thread Status:
Not open for further replies.

Share This Page