How to make individual location for player?

Discussion in 'Plugin Development' started by makcoh2018, Jul 17, 2021.

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

    makcoh2018

    Hey. I need your help! I have a command for teleport and i need so that player teleport in his schematics. For example player sent command and teleport in individual location where is he alone. So that for all player who sent command teleport in individual location. Sorry for my English ^_^
     
  2. Offline

    KarimAKL

  3. Offline

    makcoh2018

    I need that players teleport in schematics where player be alone. I don't have an idea how to do
     
  4. Offline

    KarimAKL

    @makcoh2018 What exactly is the problem? I already told you how to have different locations for each player.
     
  5. Offline

    makcoh2018

    @KarimAKL I don't know how to realize it with a Map
     
  6. Offline

    KarimAKL

    @makcoh2018 Map is an interface implemented by several classes, but the most commonly used one would probably be the HashMap, so you can start by creating an instance of that class.
    Code:Java
    1. Map<?, ?> map = new HashMap<>();


    Now, you want to map a location to a player, so we want the player as the key and the location as the value.
    Code:Java
    1. Map<Player, Location> map = new HashMap<>();

    These are called generics; you can read up on them here.

    To avoid future problems, we can use UUID instead of Player.
    Code:Java
    1. Map<UUID, Location> map = new HashMap<>();


    Now, to actually add entries to this map, we can use the #put method.
    Code:Java
    1. Player player = /* Your player */;
    2. Location location = /* Your location */;
    3.  
    4. map.put(player.getUniqueId(), location);

    That just about sums it up. I already linked you to the Javadocs for Map, so you can read up on how to use them there.

    Let me know if you have any questions.
     
  7. Offline

    Onisim

    Thanks! I also needed this clue
     
Thread Status:
Not open for further replies.

Share This Page