You can spawn a floating text to a player when they join. PHP: public function onJoin(PlayerJoinEvent $event) { $player = $event->getPlayer(); $text = "Example text for the Floating Text"; $position = $player->getPosition()->asVector3()->add(0.5, 0, 0.5); //Where you want to spawn the floating text as a Position, to center the floating text I add 0.5 to x and z. (Not required, you can use the direct position) $player->getLevel()->addParticle(new FloatingTextParticle($position, "", $text));}
PHP: /** * @param BlockPlaceEvent $event */ public function onPlace(BlockPlaceEvent $event) { $block = $event->getBlock(); $player = $event->getPlayer(); $vector = new Vector3($block->x + 0.5, $block->y + 0.8, $block->z + 0.5); $particle = new FloatingTextParticle($vector, "", TextFormat::colorize(".a".$block->getName(), ".")); $player->getLevel()->addParticle($particle, [$player]); // Remove the array if you want all the players to see the Particle. }
this is what i've done so far PHP: public function onPlace(BlockPlaceEvent $e) { $item = $event->getItem(); if ($e->getBlock()->getId() == 54) { $damage = $event->getItem()->getDamage(); switch($damage){ case "1" $item = Item::get(54, 1, 1); $player = $e->getPlayer(); $block = $e->getBlock(); $x = $block->getX(); $y = $block->getY(); $z = $block->getZ(); $block->getLevel()->addParticle(new FloatingTextParticle(new Vector3($x + 0.5, $y + 1.5, $z + 0.5), "", "§l§6Common §r§7Crate"), [$player]); $block->getLevel()->addParticle(new FloatingTextParticle(new Vector3($x + 0.5, $y + 1.25, $z + 0.5), "", "§7Right-Click with a §6Common §7Key to redeem rewards"), [$player]); $block->getLevel()->addParticle(new FloatingTextParticle(new Vector3($x + 0.5, $y + 1, $z + 0.5), "", "§7You can buy §6Common §7Keys from §eHestraPE.buycraft.net"), [$player]); break; } } }} But is there a way to make the text not get removed when restarting server?