Solved Player.GetLocation not working?

Discussion in 'Plugin Help/Development/Requests' started by minecrft, Apr 3, 2016.

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

    minecrft

    Hello,

    I would like to say I'm fairly new to java (know the basics) and I have been working on a trampoline plugin (I understand their are multiple already created, I need it for other things). I'm trying to detect what block the player is standing on, and I have followed various tutorials/help on how to do it. I have done those things and still not working?
    Code:
    package me.bukkit.minecrft;
    
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerMoveEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.util.Vector;
    
    public class Trampolines extends JavaPlugin implements Listener {
       
            public void OnEnable() {
        }
           
            @EventHandler
            public void onMove(PlayerMoveEvent e)
            {
                Player p = e.getPlayer();
                Location l = p.getLocation();
                Vector v = p.getVelocity();
                Location d = new Location(l.getWorld(), l.getX(), l.getY() - 1, l.getZ());
        
                if(d.getBlock().getType() == Material.SPONGE)
                {
                    p.setVelocity(new Vector(v.getX(), 10.0D, v.getZ()));
                }
            }
           
            public void onDisable() {
               
            }
    }
    
    Sorry if this is a noobs mistake, I'm pretty new. ^.^

    Thanks, Jake B.
     
  2. Offline

    The_Nesko

    You didn't register listener so all the code that is in the onMove() event will not work.
     
  3. Offline

    minecrft

    Hello,

    Thanks so much for this, very noob mistake.

    Thanks, Jake B.
     
  4. Offline

    minecrft

    @The_Nesko, I registered the listener with methods I had been previously using. Didn't seem to work. Could you tell me how you would do it?

    Thanks, Jake B.
     
  5. Offline

    The_Nesko

    @minecrft
    You can just type:
    Code:
    Bukkit.getServer().getPluginManager().registerEvents(this, this);
    
    If the event is in the JavaPlugin class.
     
  6. Offline

    minecrft

    Hello,

    Thanks for you help!

    Thanks, Jake B.
     
    Last edited: Apr 6, 2016
Thread Status:
Not open for further replies.

Share This Page