Okay so i tried to make this tpa command but i just cant get it to work... heres the code: Code: package me.zderki.zderkistpa; import java.util.HashMap; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @SuppressWarnings("unused") public class Main extends JavaPlugin { public HashMap<Player, Player> tpa = new HashMap<Player, Player>(); @Override public void onEnable(){ } public void onDisable() { } public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; if(label.equalsIgnoreCase("tpa")) { if(args.length == 1) { try { Player player2 = Bukkit.getPlayer(args[0]); tpa.put(player2, player); player2.sendMessage("acc/deny"); player.sendMessage("req sent"); } catch (Exception e) { player.sendMessage("error lol idk use args"); } } if(label.equalsIgnoreCase("tpaccept")) { } Player player2 = tpa.get(player); player2.teleport(player.getLocation()); player.sendMessage("tping"); player2.sendMessage("tping"); } return true;} } Please help. PS: im gonna change the messeges when im done ofc lol
@ZderKi Change the tpa map so it uses UUID's instead of Player objects, then it is way less vulnerable for memory leaks. And what exactly isn't working then?
Okay, i will try... well basically /tpaccept isnt working EDIT: how am i meant to change it to UUID tho cuz like i need to teleport the player that is stored in the hash map later, right? sorry if im not understanding something correctly... im new to coding
@ZderKi And how isn't it working? What is it doing? What do you think that it should be doing? You can use Bukkit.getPlayer(UUID) for that
Okay look, i want it to do that when player 1 types "/tpa player2" and player 2 types "/tpaccept" player 1 gets teleported to player 2
It only sends the player that i want to teleport to the "acc/den" message but when he does /tpaccept nothing happens