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

special characters in config

Comments in 'Plugin Development' started by Creeperface, May 31, 2015.

  1. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    please how to make that player can insert into config symbols like § or other?
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    § works without doing anything. You can use str_replace() for other symbols.
  3. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    THX so i can't insert to config.yml special symbols?
  4. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    What do you mean with special symbols?
  5. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    Special characters
  6. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
  7. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Ohh, just do
    PHP:
    $symbol $this->getConfig()->get("Symbol");
    and use $symbol instead of the hearts. Also create a new Folder in Source Files which is called resources. In there, create a config.yml File. In the config.yml file, add Symbol: ♥
  8. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    I know how to create config and thanks
  9. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    and can i use $this->getConfig("symbol") ?
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You can.
    If you put special characters into your config, Minecraft: PE will assume that you used UTF-8 because Config will just return the text in the config as-is, without any conversion, specification or assumption of characters sets.
    Same with putting special characters in quotes in PHP code.
    Therefore, always code in UTF-8 and edit configs using UTF-8 because that's what MCPE will assume it as.
    Creeperface likes this.
  11. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    OK thanks.
  12. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    so why when i set in config something with § so: yaml_parse(): reading error encountered during parsing: invalid leading UTF-8 octet (line 1, column 1)
  13. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Try to add "" like
    Symbol: "§"
  14. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    I solved this using {COLOR} instead of §
  15. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    using § in plugins is bad practice and can cause errors and sometimes dosen't work, use TextFormat::<color>. You can use a str_replace() if you want to use the symbol in a config and change it to TextFormat::<color>.
    Svile likes this.
  16. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
  17. TruDan
    Offline

    TruDan New Member

    Joined:
    Oct 24, 2014
    Posts:
    8
    Minecraft User:
    TruDan
    Usually, in MCPC a & is used instead of §, and then the plugin will str_replace("&","§",$string); so colours would be &a, &b, &c etc. You may find this easier than {COLOR} :)

    I actually use this function in my Utils class:

    PHP:
    public static function colour($string) {
            return 
    preg_replace("/&([0123456789abcdefklmnor])/i""§$1"$string);
    }
    This prevents strings like "Hi & Hello!" being changed to "Hi Hello", and it will only replace the & when there is a valid colour code after it.
    PEMapModder likes this.
  18. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    THX :)
  19. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,747
    Minecraft User:
    Legoboy0215
    Why is it &a &bWhat does those stand for? Sorry because I never used color codes like that.
  20. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    & is instead of § and using § you can make colors in mcpe

Share This Page

Advertisement