PlayerPortalEvent dispatchCommand with playername (HELP PLSS)

Discussion in 'Spigot Plugin Help' started by Jeremy1501, Jul 27, 2018.

  1. I want to execute the command which is in the script (command: /warp 'playername' 'warpname') but what is the right way to put in the playername??

    Code (Text):
    package nl.OfficialHeroCraft.portals.Events;

    import org.bukkit.Bukkit;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerPortalEvent;

    public class EventsClass implements Listener {
          public int x;
          public int y;
          public int z;

    public int getX() {
      return getX();
    public int getY() {
      return getY();
    public int getZ() {
      return getZ();

        public void onPlayerPortal(PlayerPortalEvent event) {
            if(event.getPlayer().getLocation().getBlockX() == -71) {
                        Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "warp" + bukkit.getPlayer() + "warpname");
  2. "warp" + bukkit.getPlayer() + "warpname" will be executed as "warpJeremy1501warpname", so add spaces and it should work.