Solved The method is undefined for the type

Discussion in 'Plugin Development' started by jasondorson, Jan 18, 2021.

  1. Offline

    jasondorson

    This is my code:
    Code:
    package me.test.HelloWorld;
    
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.player.PlayerMoveEvent;
    import org.bukkit.event.Listener;
    import org.bukkit.entity.Player;
    
    public class Main extends JavaPlugin implements Listener{
        @Override
        public void onEnable() {
            getServer().getPluginManager().registerEvents(this, this);
        }
        @Override
        public void onDisable() {
        }
        @EventHandler(priority = EventPriority.HIGH)
        public void onPlayerMove(PlayerMoveEvent e) {
            getLogger().info("player moved");
            if((int) e.getPlayer().getLocation().getX() == -2) {
                if((int) e.getPlayer().getLocation().getZ() == 0) {
                    e.sendTitle("Hello!", "This is a test.", 1, 20, 1);
    
                }
                if((int) e.getPlayer().getLocation().getZ() == 1) {
                    e.sendTitle("Great Job!", "You did it!", 1, 4, 1);
    
    
                }
               
            }
           
        }
    }
    
    But it gives the errors:
    upload_2021-1-18_18-41-11.png
    I tried changing it to:
    Code:
    public void onPlayerMove(PlayerMoveEvent e, Player a ) {
            getLogger().info("player moved");
            if((int) e.getPlayer().getLocation().getZ() == 6){
                getLogger().info("got location 6");
                e.getPlayer().teleport(new Location(Bukkit.getWorld("world"), -11.5, 100, -9.5));
                }
            if((int) e.getPlayer().getLocation().getZ() == 5) {
                getLogger().info("got location 5");
                e.getPlayer().teleport(new Location(Bukkit.getWorld("world"), -11.5, 100, -9.5));
                }
            if((int) e.getPlayer().getLocation().getZ() == 4)    {
                getLogger().info("got location 4");
                e.getPlayer().teleport(new Location(Bukkit.getWorld("world"), -11.5, 100, -9.5));
              }
            //divide`
            if((int) e.getPlayer().getLocation().getX() == -2) {
                if((int) e.getPlayer().getLocation().getZ() == 0) {
                    a.sendTitle("Hello!", "This is a test.", 1, 20, 1);
    
                }
                if((int) e.getPlayer().getLocation().getZ() == 1) {
                    a.sendTitle("Hello!", "This is a test.", 1, 20, 1);
    
    
                }
               
            }
           
        }
    
    But it still doesn't work, what can I do?

    What I did to solve it is change:
    Code:
    e.sendTitle("Hello!", "This is a test.", 1, 20, 1);
    
    to:
    Code:
    e.getPlayer().sendTitle("Hello!", "This is a test.", 20, 80, 20);
    
     
    Last edited by a moderator: Jan 18, 2021

Share This Page