Solved how to use variables

Discussion in 'Plugin Development' started by nBlacky, Nov 22, 2019.

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


    Hello. Im new to Coding and I made a little plugin function in German but its not working can somebody help me please? Source Code:

    Last edited: Nov 22, 2019
  2. Offline


    1. You can read a tutorial on java here: It's recommended to read that before diving into any APIs.
    2. That code looks fine, did you register the command in your onEnable method? Also, remember to add the command to your plugin.yml file.
  3. Offline


  4. Offline


    Teleport needs to be a CommandExecutor, I.E. you need an instance of the teleport class, you do this by writing "new teleport()".

    That is of course provided that teleport is a class.

    EDIT: It could also be that teleport() is a method that returns a class, but I have no way of knowing.
  5. Offline


    Also remember in your command to check the args length rather than just assume one exists. Dunno if you did that before the bit you posted or not, figured I'd mention just in case. This is why it's better to post whole classes in code blocks or Pastebin rather than an image of a tiny portion of the code.

    I'd also argue that a switch would be cleaner, though that is just personal preference. Like:
    if (args.length == 0) {
      p.sendMessage("Bitte ├╝bergeben Sie einen Unterbefehl!");
      return true;
    switch (args[0].toLowerCase()) {
    case "youtube":
      p.sendMessage("Das ist der YT channel");
    case "discord":
      p.sendMessage("Das ist der Discord");
      p.sendMessage("Ung├╝ltiger Unterbefehl!");
    Also if daten is the only command the teleport() class handles, then there is no need to check if the name matches as the code will only be ran when that command is the one in use.
  6. Offline


    Thank you all it helped me a lot
Thread Status:
Not open for further replies.

Share This Page