How do I make a target

Discussion in 'Plugin Development' started by Tzipi, Jul 7, 2020.

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

    Tzipi

    Code:
        private Main plugin;
        public TeleportListener(Main plugin) {
        this.plugin = plugin;
        Bukkit.getPluginManager().registerEvents(this, plugin);
        }
        @EventHandler
        public void onTeleport(PlayerTeleportEvent e) {
            Player p = e.getPlayer();
            if (!p.isOp()) {
            p.sendMessage(Utils.chat(plugin.getConfig().getString("not_op_message")));
        } else {   
            p.sendMessage(Utils.chat(plugin.getConfig().getString("teleport_message").replace("<player>", p.getName())));
           
        }   
        }
    }
    Ok so basically I'm trying to make a custom Teleport reply but when I do /tp <player> it says my IGN I know it's because I have p.getName but how do I make it say the target's name?
     
  2. Offline

    KarimAKL

    @Tzipi I'm not sure i understand what you mean but, you can get a player using Bukkit#getPlayer(String name)
     
  3. Offline

    Tzipi

    I mean it says You have tp'd to bhop_atom (my IGN)
    instead of the target
     
  4. Offline

    KarimAKL

    @Tzipi The player in the event is the one that got teleported. You probably want to send the message in the command method, not the teleport event.
     
  5. Offline

    Tzipi

    ok thx
     
Thread Status:
Not open for further replies.

Share This Page