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

[New API] Need help porting plugin

Comments in 'Plugin Development' started by Legomite, Jul 2, 2014.

  1. Legomite
    Offline

    Legomite Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    470
    Plugins:
    2
    Minecraft User:
    Legomite
    I need help porting a pocketmine plugin! It's very simple and short and shoudn't be that hard. Can someone help guide me?

    PHP:
    <?php

    namespace Legomite\SpecialText;

    use 
    pocketmine\plugin\PluginBase;

    class 
    color extends PluginBase {
        private 
    $api;
        private 
    $message;
        private 
    $player;
       

        public function 
    onEnable() {
            
    $cmd = new PluginCommand("text"$this);
            
    $cmd->setDescription("Info on SpecialText");
            
    $cmd->setUsage("/text");
            
    $this -> api -> console -> register("texthelp""Help on Special Text", array($this"cmd"));
            
    $this -> api -> console -> register("text1""Write in Gray font!", array($this"cmd"));
            
    $this -> api -> console -> register("text2""Write in skinny font!", array($this"cmd"));
            
    $this -> api -> console -> register("text3""Write in skinny and gray font!", array($this"cmd"));
            
    $this -> api -> ban -> cmdWhitelist("text");
            
    $this -> api -> ban -> cmdWhitelist("texthelp");
            
    $this -> api -> ban -> cmdWhitelist("text1");
            
    $this -> api -> ban -> cmdWhitelist("text2");
            
    $this -> api -> ban -> cmdWhitelist("text3");
            
    $this -> api -> console -> alias("t""text");
            
    $this -> api -> console -> alias("t?""texthelp");
            
    $this -> api -> console -> alias("t1""text1");
            
    $this -> api -> console -> alias("t2""text2");
            
    $this -> api -> console -> alias("t3""text3");
            
    $this->api->addHandler("player.chat", array($this"eventHandler"), 100);
        
    console("§a[SpecialText] loading...");
            
    console("§a[SpecialText] §dThis plugin is created by §cLegomite.§dCheck if you have the latest version of this plugin!");
        }
        public function 
    cmd($cmd$args$issuer) {
            switch(
    $cmd) {
                case 
    "text" :
                    
    $issuer -> sendChat("/Version 1.0.0 By Legomite [email protected]\n");
                    break;
                case 
    "texthelp" :
                    
    $issuer -> sendChat("/text1 ::Does the gray color\n");
                    
    $issuer -> sendChat("/text2 ::Does the skinny font\n");
                    
    $issuer -> sendChat("/text3 ::Does the gray color and the skinny font\n");
                    break;
                case 
    "text1" :
                    if (
    $args[0] == "") {
                        
    $output "Usage: /text1 (Message)";
                    } else {
                        
    $name $issuer -> username;
                        
    $msg implode(" "$args);
                        
    //Todo:
                        //Remove Random slash
                        
    $this -> api -> chat -> broadcast("/<$name$msg\n");
                        break;
                    }
                case 
    "text2" :
                    if (
    $args[0] == "") {
                        
    $output .= "Usage: /text2 (Message)";
                    } else {
                        
    $name $issuer -> username;
                        
    $msg2 implode(" "$args);
                        
    $this -> api -> chat -> broadcast("<$name>“ $msg2 ” ");
                        break;
                    }
                case 
    "text3" :
                    if (
    $args[0] == "") {
                        
    $issuer -> sendChat("Usage: /text3 (Message)");
                    } else {
                        
    $name $issuer -> username;
                        
    $msg3 implode(" "$args);
                        
    $this -> api -> chat -> broadcast("/<$name>“ $msg3 ” \n" );
                            break;
                            }
                            }
                            }
                            public function 
    eventHandler($data$event){
                            
    $player $data['player'];
                            
    $username $player->username;
                            
    $msg4 $data['message'];
                            
    $this -> api -> chat -> broadcast("<$username> “ $msg4 ” ");
                    return 
    false;
                    }
                            public function 
    __destruct() {
                           

                            }
                            }
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    There will be color codes in 0.9.0 so we won't need this ;)
    64FF00 likes this.
  3. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    THERE IS?!
    Comedyman937 likes this.
  4. KnownUnown
    Offline

    KnownUnown Active Member Plugin Developer

    Joined:
    Aug 22, 2013
    Posts:
    65
    Plugins:
    1
    Minecraft User:
    KnownUnown
  5. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    @PEMapModder that's who :).
    PEMapModder likes this.
  6. KnownUnown
    Offline

    KnownUnown Active Member Plugin Developer

    Joined:
    Aug 22, 2013
    Posts:
    65
    Plugins:
    1
    Minecraft User:
    KnownUnown


    • Chat formatting and colors (Expected on 1.0.x or 1.1.x)
    ^^^^^^^^^^^^^^^^^^

    Also, I asked shoghicp about the matter...

  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Aww GitHub gist... Last night on IRC...
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
  9. KnownUnown
    Offline

    KnownUnown Active Member Plugin Developer

    Joined:
    Aug 22, 2013
    Posts:
    65
    Plugins:
    1
    Minecraft User:
    KnownUnown
  10. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    755
    Plugins:
    2
    Minecraft User:
    Darunia18
    Color codes are being added to PocketMine 1.4, but not in MCPE until a 1.0 or 1.1 sub-update. If PM servers used the plugin BigBrother to allow PC clients to connect to the server, though, these color codes will still work for the PC client. These color codes also work for the server console.
  11. Legomite
    Offline

    Legomite Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    470
    Plugins:
    2
    Minecraft User:
    Legomite
    So the plugin could still be a bit useful?
  12. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    @PEMapModder I'm trying to add it just to have it ready when it's available, anyways it may work for BigBrother ;)
    Yes, it could be fun :D
    Darunia18 likes this.
  13. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    @Legomite You may use a structure like this for your plugin ;) it's easier :D
  14. Legomite
    Offline

    Legomite Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    470
    Plugins:
    2
    Minecraft User:
    Legomite
    I heard you were making a converter for the new API? You said something like it would be possible.
  15. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku

Share This Page

Advertisement