How to make individual location for player?

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

  1. Offline


    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


  3. Offline


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


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


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


    @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.
    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.
    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.
    1. Map<UUID, Location> map = new HashMap<>();

    Now, to actually add entries to this map, we can use the #put method.
    1. Player player = /* Your player */;
    2. Location location = /* Your location */;
    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


    Thanks! I also needed this clue

Share This Page