1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Delete Floating text

Discussion in 'Development' started by Notjblus, Feb 29, 2020.

  1. Notjblus

    Notjblus Spider Jockey

    Messages:
    28
    GitHub:
    JblusItsMe
    I brought up a floating text with an order I created, but now I have no idea how I could delete it.

    PHP:
    <?php

    namespace DevAkya\Commands\Staff\Admin;

    use 
    DevAkya\Main;

    use 
    pocketmine\level\particle\FloatingTextParticle;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\level\Position;

    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\PluginCommand;
    use 
    pocketmine\Player;

    use 
    jojoe77777\FormAPI;
    use 
    jojoe77777\FormAPI\SimpleForm;

    class 
    FloatText extends PluginCommand {

         
    /** @var Main $plugin */
         
    private $plugin;

         const 
    PREFIX "§l§f[§l§4PRIVATE§f]§r ";
         const 
    ADD "§3Cliquer pour ajouter";

         public function 
    __construct(Main $plugin) {
              
    parent::__construct("ft"$plugin);
              
    $this->setDescription("§4Floating Text");
              
    $this->setPermission("perm.admin");
              
    $this->plugin $plugin;
         }

         public function 
    execute(CommandSender $senderstring $commandLabel, array $args) {
              if(
    $sender instanceof Player) {
                   if(
    $sender->hasPermission("perm.admin")) {
                        
    $api $this->plugin->getServer()->getPluginManager()->getPlugin("FormAPI");

                        if(
    $api === null || $api->isDisabled()) {
                             return 
    true;
                        }

                        
    $form $api->createSimpleForm(function(Player $sender$data) {
                             
    $result $data;

                             if(
    $result === null) {
                                  return;
                             }
                             switch(
    $result) {
                                  case 
    0// Entity 1
                                       
    $n $sender->getPlayer();
                                       
    $name $n->getName();
                                       
    $money "§61500ec";
                                       
    $online $this->plugin->getServer()->getOnlinePlayers();

                                       
    $x $sender->x;
                                       
    $y $sender->y;
                                       
    $z $sender->z;

                                       
    $title "§7-=-=-=- §l§9Extoria§fNetwork§r §7-=-=-=";
                                       
    $text "test";

                                       
    $fentityone = new FloatingTextParticle(new Vector3($x,$y,$z), $text$title);
                                       
    $sender->getLevel()->addParticle($fentityone);
                                  break;
                             }
                        });
                        
    $form->setTitle(self::PREFIX);
                        
    $form->setContent(self::PREFIX "§cMerci de n'utiliser cette UI seulement si vous êtes l'utilisateur \n \n§7- §aAkyaSurMc \n \n ");
                        
    $form->addButton("§2Entity 1 \n " self::ADD);
                        
    $form->sendToPlayer($sender);
                   } else {
                        
    $sender->sendMessage("§cError ...");
                   }
              } else {
                   
    $this->plugin->getLogger()->info("Vous ne pouvez pas utiliser cette commande dans la console.");
              }
         }
    }
     
  2. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    I don't think it is possible to delete particle. It's better to make floating texts using entities. Here is my api which allows to remove texts too.

     
  3. Notjblus

    Notjblus Spider Jockey

    Messages:
    28
    GitHub:
    JblusItsMe
    Can you explain to me from this API how a floating text spawn
     
  4. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    PHP:
    // Spawning text
    $textId FloatingTextApi::createText($vector3); // $vector3 -> position of floating text, This function is just for initialize
    FloatingTextApi::sendText($textId$player"YourTextHere\nSecondLine"); // This you can use to spawn text, and for update too

    // Removing text
    FloatingTextApi::removeText($textId$player); // It removes text just for the specified player..
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.