Plugin category: RPG (?) Suggested name: BlotheraAim What I want: When someone is aiming with a bow, they are running at full speed. Simple. Ideas for commands: No commands needed for this plugin. Ideas for permissions: BlotheraAim.Aim When I'd like it by: ASAP. PS: Add me on skype @ harrybridgen please.
Do you mind the effects a potion adds? (the particles mainly) as AFAIK no one has successfully achieved speed boost without adding a potion effect to the player
I think the request is to be able to shoot a bow while sprinting without potions. Tell me if im wrong.
I think that's what he wants too, just don't think it's possible without, from what I've been seeing around the forums at least people have really buggy velocity changes and eventually just give up
Could just figure out exactly how much drawing a bow slows you down, then find the level of speed that speeds you up that much. Only problem is knowing how long they draw the bow. You can't know how long they draw the bow as you can't tell if they are holding right click. And there is no DrawBowEvent to check if a bow is being drawn :\
Holding in right click, yes. I don't believe there is any other way to do it. With a mod you could also make it so their FOV doesn't change maybe? I've never worked with mods so I'm not sure.
But like I said, there is no EntityDrawBowEvent. Only PlayerInteractEvent then checking if it's a right click and item in hand.
Basicly i need it so when someone is aiming with the bow, you don't slow down. I don't mind the FOV change, just the speed change.
The speed change is client-sided and there is nothing that a server can do to cancel it. The only thing a server can do is to compensate the slowdown with a speed potion effect like this: Code: private HashMap<Player, PotionEffect> players; @EventHandler (ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onBowDraw(PlayerInteractEvent e) { if ((e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) && e.getMaterial().equals(Material.BOW) && e.getPlayer().getInventory().contains(Material.ARROW)) { PotionEffect current = null; int amplifier = 1; // FIXME calibrate this for (PotionEffect pe : e.getPlayer().getActivePotionEffects().toArray(new PotionEffect[0])) if (pe.getType().equals(PotionEffectType.SPEED)) { current = pe; amplifier += pe.getAmplifier(); break; } players.put(e.getPlayer(), current); e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1200, amplifier), true); } } @EventHandler (ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onShoot(EntityShootBowEvent e) { if (players.containsKey(e.getEntity())) { Player player = (Player)e.getEntity(); player.removePotionEffect(PotionEffectType.SPEED); if (players.get(player) == null) player.addPotionEffect(players.get(player)); players.remove(player); } } But this solution may be buggy and hacked clients can exploit it to get free speed potion effect. A much more elegant solution is to recommend a client-side mod to your players.
Sure, but it has a bug where if a player right clicks with a bow without holding it, the EntityShootBowEvent is never called, therefore the player just got a free 20 second speed boost. Download It has config.yml inside the jar if you need it. source code (Move your mouse to reveal the content) source code (open) source code (close) Code: package com.impress.privateplugins.NoBowSlowdown; import java.util.HashMap; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.Event.Result; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; public class NoBowSlowdown extends JavaPlugin implements Listener { private HashMap<Player, PotionEffect> players; private int amplifier, duration; @Override public void onEnable() { players = new HashMap<Player, PotionEffect>(4); amplifier = getConfig().getInt("effect-amplifier", 12); duration = getConfig().getInt("effect-duration", 400); getServer().getPluginManager().registerEvents(this, this); getLogger().info(getName() + " enabled"); } @Override public void onDisable() { getLogger().info(getName() + " disabled"); } @EventHandler (ignoreCancelled = false, priority = EventPriority.HIGHEST) public void onBowDraw(PlayerInteractEvent e) { if ((e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) && e.getMaterial() == Material.BOW && e.useItemInHand() != Result.DENY && e.getPlayer().hasPermission("nobowslowdown.use") && e.getPlayer().getInventory().contains(Material.ARROW)) { PotionEffect current = null; int a = amplifier; for (PotionEffect pe : e.getPlayer().getActivePotionEffects().toArray(new PotionEffect[0])) if (pe.getType().equals(PotionEffectType.SPEED)) { current = pe; a += pe.getAmplifier(); break; } players.put(e.getPlayer(), current); e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, duration, a), true); } } @EventHandler (ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onShoot(EntityShootBowEvent e) { if (players.containsKey(e.getEntity())) { Player player = (Player)e.getEntity(); player.removePotionEffect(PotionEffectType.SPEED); if (players.get(player) != null) player.addPotionEffect(players.get(player)); players.remove(player); } } }