Teleport plugin not working

Discussion in 'Plugin Development' started by Fullzer0, Dec 15, 2018.

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

    Fullzer0

    Hello! I'm really new to making plugins, just wanted to make that clear! So I tried to make a plugin that teleported you to the spawn area when you joined the server and if you had joined the server before it would send you a message that said Welcome back and if you hadn't joined before it would say welcome to the server! But nothing worked I don't know what I did wrong. Please help!
    Code:
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
      
        Location location = new Location(getServer().getWorld("world"),513557, 50, 58133);
          
        Player plr = (Player) sender;
      
        if (plr.hasPlayedBefore()){
            plr.sendMessage("Welcome back," + plr.getDisplayName() + "!");
            plr.teleport(location);
        } else {
            plr.teleport(location);
            }
        return false;
        }
     
    Last edited by a moderator: Dec 15, 2018
  2. Online

    timtower Administrator Administrator Moderator

    @Fullzer0 You probably want to use the PlayerJoinEvent instead of the onCommand.
     
  3. Offline

    Fullzer0

    Why didn't I think of that! I'll try that right now if it doesn't work I guess I'll just like reply or something

    Still doesn't work..
    @EventHandler
    public void onPlayerJoinEvent(PlayerJoinEvent Joined) {

    Location location = new Location(getServer().getWorld("world"),513557, 50, 58133);

    if (Joined.getPlayer().hasPlayedBefore()){
    Joined.getPlayer().sendMessage("Welcome back," + Joined.getPlayer().getDisplayName() + "!");
    Joined.getPlayer().teleport(location);
    } else {
    Joined.getPlayer().sendMessage("Welcome" + Joined.getPlayer().getDisplayName() + "to Fullz Network!");
    Joined.getPlayer().teleport(location);
    }
    }
    }

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Dec 15, 2018
  4. Online

    timtower Administrator Administrator Moderator

  5. Offline

    Fullzer0

    No I don't think so can, can you help me register the event?
     
  6. Online

    timtower Administrator Administrator Moderator

  7. Offline

    Fullzer0

    Ok so it worked but when I tried to add color to the welcome messages it said Invalid plugin.yml
    Here is the plugin.yml
    Code:
    name: FullzSpawn
    main: me.Fullzer0.FullzSpawn.main
    version: 0.0.5
    author: Fullzer0
    
    commands:
     
    Last edited by a moderator: Dec 15, 2018
  8. Online

    timtower Administrator Administrator Moderator

    @Fullzer0 Fill the commands block or remove it.
     
  9. Offline

    Fullzer0

    Thank you so much! My plugin is now working! Thank you so much for helping me make my plugin!
     
Thread Status:
Not open for further replies.

Share This Page