Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Click on particles...
HashMap<UUID,Location> stands = new HashMap<UUID, Location>();
double particleHeight = 1.5;
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
public void run() {
for(Location loc : stands.values()) {
loc.getWorld().spigot().playEffect(loc, Effect.COLOURED_DUST, 0, 0, 0f, 0f, 0f, 30, 2, 64);
}, 20L, 10L);
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(sender instanceof Player) {
Player p = (Player) sender;
ArmorStand as = (ArmorStand) p.getLocation().getWorld().spawnEntity(p.getLocation(), EntityType.ARMOR_STAND);
stands.put(as.getUniqueId(), as.getLocation().add(0, particleHeight, 0));
return false;
public void onStandClick(PlayerInteractAtEntityEvent event) {
if(event.getRightClicked().getType() == EntityType.ARMOR_STAND && stands.containsKey(event.getRightClicked().getUniqueId())) {
Location clicked = event.getRightClicked().getLocation().add(event.getClickedPosition());
Location loc = event.getRightClicked().getLocation().add(0, particleHeight, 0);
double distance = clicked.distance(loc);
this.getLogger().info("Distance: " + distance);
if (distance < 0.39) // max distance e.g. volume depends on the particle!
event.getPlayer().sendMessage(ChatColor.GREEN + "[Particle] You clicked me!");

This comment has been minimized.

Copy link
Owner Author

@Phoenix616 Phoenix616 commented Feb 24, 2015

The clicked position is a strange one... this is not really that usable as the distance to the particles point varies. Maybe there is a better entity for this job? Or could just use vectors properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment