Last active
July 18, 2019 22:09
-
-
Save WouterG/036dc1136bc6b33f951795bdc3f955c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import net.menoni.rd.RuntimeDebugger; | |
import net.menoni.rd.model.Debugger; | |
import org.bukkit.Material; | |
import org.bukkit.command.CommandSender; | |
import org.bukkit.entity.EntityType; | |
import org.bukkit.entity.Player; | |
import org.bukkit.entity.Snowball; | |
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.inventory.ItemStack; | |
import org.bukkit.util.Vector; | |
public class Paintball implements Debugger, Listener, Debugger.Stoppable { | |
private Player p; | |
@Override | |
public void debug(RuntimeDebugger plugin, CommandSender cs) { | |
if (!(cs instanceof Player)) { | |
return; | |
} | |
this.p = (Player)cs; | |
} | |
@Override | |
public void stop() { | |
} | |
@EventHandler | |
public void onInteract(PlayerInteractEvent interactEvent) { | |
if (!interactEvent.getAction().equals(Action.RIGHT_CLICK_BLOCK) && !interactEvent.getAction().equals(Action.RIGHT_CLICK_AIR)) { | |
return; | |
} | |
if (interactEvent.getPlayer().getUniqueId() != this.p.getUniqueId()) { | |
return; | |
} | |
ItemStack mainHandItem = interactEvent.getPlayer().getInventory().getItemInMainHand(); | |
if (mainHandItem.getType() == Material.STICK) { | |
Vector playerVector = interactEvent.getPlayer().getEyeLocation().getDirection(); | |
playerVector.clone().normalize().multiply(125d); | |
Snowball snowball = (Snowball) interactEvent.getPlayer().getWorld().spawnEntity(interactEvent.getPlayer().getLocation().clone().add(0, 1.7, 0), EntityType.SNOWBALL); | |
snowball.setVelocity(playerVector); | |
snowball.setGlowing(true); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment