/server does not work

Discussion in 'Spigot Plugin Development' started by Tomdaarom, Feb 22, 2018.

  1. Hello, I have a question. I'm trying to have a player teleport to another server by using an inventory menu and an InventoryClickEvent.

    Code (Text):
    String server = this.config.getString("slot." + (slot + 1) + ".server");
        if (server != null)
        {
          if (p.getServer().getName().equalsIgnoreCase(server))
          {
            p.sendMessage(ChatColor.RED + "You are already connected to " + ChatColor.YELLOW + server);
            return;
          }
          p.chat("/server " + server);
          ((Player)event.getWhoClicked()).playSound(event.getWhoClicked().getLocation(), Sound.BLOCK_NOTE_PLING, 10.0F, 1.0F);
          return;
        }
    Whenever someone clicks the item, I can see from the console that this person runs the command. /server <name>. But in game it still says unknown command. I'm not sure what to do here. I hope someone can help me
     
  2. you’re connected to the bungee and not the spigot sever right? Also is it not player#performCommand() ?
     
  3. It is a spigot plugin, not a Bungee plugin. I tried p.performCommand, did not work. The point is, according to the console, the player runs the command, but nothing happends
     
  4. ScarabCoder

    ScarabCoder Retired Resource Staff
    Retired

    Why don't you use the BungeeCord messaging channels? Also, try performCommand without the slash.
     
  5. I already tried the performCommand, with and without /. I just wonder if there is something I can add to the event that will make it work. I think the problem is that I try to run a BungeeCord command on a spigot server.
     
  6. 0yd

    0yd

    @Tomdaarom Are you using BungeeCord for your hub and have you looked up how to set up a BungeeCord network? I think that'll help you a lot, because what it seems like is that, like you said, you're trying to run a BungeeCord command on a Spigot server.
     
  7. I do have an Hub, I'm actually testing the plugin on a BungeeCord server, but in one of the server's plugins map. I'm kind of in a rush, we are about to launch Factions on our server, and quite a few people are waiting for it to go live, but I want to finish this first.. So all help is welcome.
     
  8. 0yd

    0yd

    @Tomdaarom Are your connecting servers cracked/also running Spigot? Also, like I said, try looking up how to set up a BungeeCord network.
     
  9. I do have a BungeeCord network, but has that anything to do with my question in the first place?
     
  10. ScarabCoder

    ScarabCoder Retired Resource Staff
    Retired

  11. Bungee stealing players command from Chat , but p#prefercommand only make the command to spigot, bungee cant "steal" it, so u must use a bungee message channel for that