Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Colors in chat

Comments in 'Plugin Development' started by onebone, Dec 19, 2013.

?

What do you think?

  1. He is lying ...

    30.8%
  2. I belive you !

    73.1%
Multiple votes are allowed.
  1. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    thats's not needed, Block Launcher already have a built in option to enable colored chat messages
  2. Jon
    Offline

    Jon Active Member Plugin Developer

    Joined:
    Sep 1, 2013
    Posts:
    201
    Plugins:
    3
    Minecraft User:
    Heromine14
    Not in servers
    PEMapModder likes this.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    BlockLauncher disables all ModPE script functions like screen recording and colored chat in external servers. Which means, servers joined by tapping servers added using the "edit external" button cannot have colored chat. In the other hand, servers joined with blue colored LAN connection have ModPE script support. This difference is made for griefing prevention on public servers, as I recall.

    Therefore, whether it is a PocketMine server doesn't matter, since PocketMine-MP is just a fake imitation of MCPE vanilla servers. (The words "fake imitation" carry no negative meaning. They are spoken merely out of technical perspective)
    Jon likes this.
  4. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    No, I tested today, colored chat works. Color chat is added in BlockLauncher and ModPE scripts aren't needed for it to work.
  5. Jon
    Offline

    Jon Active Member Plugin Developer

    Joined:
    Sep 1, 2013
    Posts:
    201
    Plugins:
    3
    Minecraft User:
    Heromine14
    Me too tested it but i see the colors only in the keyboard, how to see in the messages?
  6. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    Example:
    PHP:
    private $coloredChatPlayers=array();

    /**
         * @param PlayerChatEvent $event
         *
         * @priority HIGHEST
         * @ignoreCancelled true
    */
    public function onChat(PlayerChatEvent $event){
       
    $player $event->getPlayer();
       
    $message $event->getMessage();
       foreach(
    $this->getServer()->getOnlinePlayers() as $players){
          if(isset(
    $this->coloredChatPlayers[$players])){
             
    $players->setRemoveFormat(false);
             
    $players->sendMessage("§7<".$player->getName()."> ".$message);//should send message in grey
          
    }else{
             
    $players->sendMessage("<".$player->getName()."> ".$message);
          }
       }
    }

    public function 
    onCommand(CommandSender $senderCommand $command$label, array $args){
       
    $cmd $command->getName();
       if(
    $sender instanceof Player){
          if(
    $cmd=="color"){
             if(
    in_array($sender->getName(),$this->coloredChatPlayers)){
                unset(
    $this->coloredChatPlayers[$sender->getName()]);
                
    $sender->sendMessage("You have disabled color chat!");
             }else{
                
    array_push($this->coloredChatPlayers,$sender->getName());
                
    $sender->sendMessage("You have enabled color chat!");
             }
          }
       }
    }
    I used something like this for my plugin.
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Use $event->setMessage() for compatibility.
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You mean you tested it such that colored chat works with "Enable ModPE Scripts support" unchecked?
  9. Jon
    Offline

    Jon Active Member Plugin Developer

    Joined:
    Sep 1, 2013
    Posts:
    201
    Plugins:
    3
    Minecraft User:
    Heromine14
    no, modpe scripts disabled
  10. Jon
    Offline

    Jon Active Member Plugin Developer

    Joined:
    Sep 1, 2013
    Posts:
    201
    Plugins:
    3
    Minecraft User:
    Heromine14
    this for the console or with blocklauncher too? because on console if you type say §2 the messagge will be colored but not in the players chat
  11. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    That sets the message for everyone?
  12. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    You don't need to use any ModPE scripts. It worked with and without ModPE scripts.
  13. Jon
    Offline

    Jon Active Member Plugin Developer

    Joined:
    Sep 1, 2013
    Posts:
    201
    Plugins:
    3
    Minecraft User:
    Heromine14
    But it will be showed only in the console?
  14. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Yes. It changes the message to be sent, and the message will be sent after the function call, if it is not cancelled.

    This is what I have been talking about for months... plugin compatibility.
  15. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    ModPE Scripts support != ModPE Scripts
    Screenshooting the screen via BlockLauncher requires ModPE Scripts support, which is disabled when playing on external servers.
  16. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    The point is, it works.
    Jon and PEMapModder like this.
  17. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    With "Enable ModPE Scripts" unchecked? (I don't care whether you have any scripts)
  18. onebone
    Offline

    onebone Notable Member Plugin Developer

    Joined:
    Aug 31, 2013
    Posts:
    330
    Plugins:
    7
    Minecraft User:
    onebone
    Hm. My way of sending color chat is sending packet directly, not via Player#sendChat()
  19. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
  20. onebone
    Offline

    onebone Notable Member Plugin Developer

    Joined:
    Aug 31, 2013
    Posts:
    330
    Plugins:
    7
    Minecraft User:
    onebone
    If you are filtering color chats, maybe it will be better if you use regular expression.
    PEMapModder likes this.

Share This Page

Advertisement