Solved Speed up and Slow down on right click PLZ HELP!

Discussion in 'Plugin Development' started by RoBaMe, Jul 2, 2015.

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

    RoBaMe

    I'm making a plugin that makes you fly in what ever direction you're looking at, and if you left click on lime wool, you speed up, but when you left click on red wool, you slow down. but for some reason i won't speed up or slow down, here's my code:
    Code:
    package me.RoBaMe;
    
    import org.bukkit.DyeColor;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.event.player.PlayerMoveEvent;
    import org.bukkit.material.Wool;
    
    public class MCM implements Listener {
       
        public MCM (MainClass plugin) {
            plugin.getServer().getPluginManager().registerEvents(this, plugin);   
        }
        double VS = 1;
        @EventHandler
       
        public void MCE(PlayerMoveEvent e) {
           
            Player p = (Player)e.getPlayer();
            if(e.getFrom().getBlockY() != e.getTo().getBlockY()-1){
                if(p.getLocation().subtract(0, 1, 0).getBlock().getType() == Material.AIR){
                    p.setVelocity(p.getLocation().getDirection().multiply(VS));
                       
                }
                   
                   
                }
            }
        public void SU(PlayerInteractEvent u){
            if(u.getAction() == Action.LEFT_CLICK_BLOCK){
                Block b = u.getClickedBlock();
                if (b.getType() == Material.WOOL) {
                    Wool wool = new Wool(b.getType(), b.getData());
                if (wool.getColor() == DyeColor.LIME) {
                    VS = VS + 0.1;
                    }
                else if (wool.getColor() == DyeColor.RED) {
                    VS = VS - 0.1;
                    }
                }
                           
            }
        }
    }
    
     
  2. @RoBaMe You could just apply speed to the player via applyPotionEffect.
     
  3. Offline

    pie_flavor

    @CodePlaysMinecraft Yes, but he is making a plugin where the player flys in the direction they are looking.
    @RoBaMe What are you doing?
    Code:
    Wool wool = (wool) b.getState().getData();
     
  4. @RoBaMe You do not have @EventHandler over SU.
    On another note, what is with those class and method names?
     
  5. Offline

    webbhead

    Why don't you just p.setFlySpeed(float);?
     
  6. Offline

    RoBaMe

    Thx a lot all of you XD this is solved, but i have another problem:'( i'll make a thread for it
     
Thread Status:
Not open for further replies.

Share This Page