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

Solved How to return to the line on textarea

Discussion in 'Development' started by armagadon159753, Oct 16, 2017.

  1. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    PHP:
    <?php

    namespace ArmTheDev\customuitest;

    #pocketmine
    use pocketmine\plugin\PluginBase;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\scheduler\PluginTask;
    use 
    pocketmine\Server;
    use 
    pocketmine\Player;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\network\mcpe\protocol\PacketPool;

    #xenialdan
    use xenialdan\customui\API as UIAPI;
    use 
    xenialdan\customui\elements\Button;
    use 
    xenialdan\customui\network\ModalFormRequestPacket;
    use 
    xenialdan\customui\network\ModalFormResponsePacket;
    use 
    xenialdan\customui\network\ServerSettingsRequestPacket;
    use 
    xenialdan\customui\network\ServerSettingsResponsePacket;
    use 
    xenialdan\customui\windows\SimpleForm;

    class 
    Loader extends PluginBase{

        public static 
    $uis;

        public function 
    onEnable(){
            
    $this->getServer()->getScheduler()->scheduleRepeatingTask(new TTask($this), 4);
            
    PacketPool::registerPacket(new ModalFormRequestPacket());
            
    PacketPool::registerPacket(new ModalFormResponsePacket());
            
    PacketPool::registerPacket(new ServerSettingsRequestPacket());
            
    PacketPool::registerPacket(new ServerSettingsResponsePacket());
            
    $this->reloadUIs();
        }

        public function 
    reloadUIs(){
            
    UIAPI::resetUIs($this);
         
            
    $ui = new SimpleForm('Serveur List');
         
            
    $playersOnline count($this->getServer()->getOnlinePlayers());
            
    $maxOnline $this->getServer()->getMaxPlayers();
         
            
    $button = new Button($playersOnline '/' $maxOnline);
            
    //     $playersOnline . "/" . $maxOnline
            //                    Return to the line  <-------How to
            //                        "Server-1"
            
    $ui->addButton($button);
         
            
    self::$uis['simpleUI'] = UIAPI::addUI($this$ui);
        }
    }

    class 
    TTask extends PluginTask{
     
        public function 
    onRun(int $currentTick){
            
    $this->getOwner()->reloadUIs();
        }
    }


    I can use PHP_EOL but I used it very little
    (\n explode and implode )
     
  2. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Don't use PHP_EOL. The value changes depending on if the server is run on Windows or Linux/Mac
     
    Muqsit and HimbeersaftLP like this.
  3. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    I use linux
     
  4. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Don't assume the EOL. Why use something that might be uncertain when you can simply use "\n"?
     
    Jack Noordhuis, Levi, Muqsit and 3 others like this.
  5. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    That correct exemple?
    PHP:
    $this->message("Hello" str_replace('\n'PHP_EOL"World"));
     
  6. Kabluinc

    Kabluinc Baby Zombie

    Messages:
    129
    PHP:
    $this->message(“Hello\nWorld”);
     
  7. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    Dame thing with variable ?
    PHP:
    $this->message($variable1 \n $variable2);
     
  8. Kabluinc

    Kabluinc Baby Zombie

    Messages:
    129
    No \n must be in “” so it wud be

    PHP:
    $this->message($variable1 \n” $variable2);
     
  9. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    Thx ^~^
     
  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.