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

I need help to editi my plugin

Comments in 'Plugin Development' started by PolskiTHEPLAYER, Jun 10, 2016.

  1. PolskiTHEPLAYER
    Offline

    PolskiTHEPLAYER New Member

    Joined:
    Apr 1, 2015
    Posts:
    55
    Minecraft User:
    Flsmers
    PHP:
    <?php

    namespace Flsmers;

    use 
    pocketmine\plugin\PluginBase as P;
    use 
    pocketmine\event\Listener as L;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\utils\MainLogger;
    use 
    pocketmine\event\block\BlockBreakEvent as BBL;
    use 
    pocketmine\level\sound\PopSound as Pop;
    use 
    pocketmine\level\particle\ExplodeParticle as Explode;
    use 
    pocketmine\block\Block;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\item\Item;

    class 
    Main extends implements L{
       
        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this,$this);
            
    $this->saveDefaultConfig();
            
    $this->getServer()->getLogger()->info(TextFormat::GREEN."[DropInStone] Włączony!");
        }

        public function 
    onBreak(BBL $e){
            if(
    $e->getBlock()->getId() == && mt_rand(0,$this->getConfig()->get("t1-chance")) == "1"){
                
    $p $e->getPlayer();
                            
    $p->getLevel()->addParticle(new Explode($e->getBlock(), 2));
                
    $p->getLevel()->addParticle(new Explode($e->getBlock(), 2));
                
    $p->getLevel()->addParticle(new Explode($e->getBlock(), 2));
                
    $p->sendMessage("§a • Wydropiłeś z stone'a - Coal • ");
                foreach(
    $this->getConfig()->get("t1-loot") as $loot){
                        
    $p->getInventory()->addItem(Item::get($loot,0,mt_rand(1,$this->getConfig()->get("t1-item-max"))));
                }
            }
            else{
            }
    How to add exp Stone's break and get 0.2 exp?
  2. Extreme_Heat
    Offline

    Extreme_Heat Active Member

    Joined:
    Apr 19, 2016
    Posts:
    76
    Minecraft User:
    Extreme_Heat
    PocketMine does not have an experience API as far as I am aware. So you will have to handle it via direct packets to the players.
    applqpak likes this.
  3. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Yes it does: https://github.com/PocketMine/PocketMine-MP/blob/master/src/pocketmine/entity/Attribute.php
    To change experience:
    PHP:
    $player->getAttributeMap()->getAttribute(pocketmine\entity\Attribute::EXPERIENCE)->setValue($value);
    To change experience level:
    PHP:
    $player->getAttributeMap()->getAttribute(pocketmine\entity\Attribute::EXPERIENCE_LEVEL)->setValue($value);
    Last edited: Jun 10, 2016
  4. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    Why :sob:

    https://github.com/PocketMine/PocketMine-MP/blob/master/src/pocketmine/entity/Human.php#L217
    https://github.com/PocketMine/PocketMine-MP/blob/master/src/pocketmine/entity/Human.php#L225
  5. PolskiTHEPLAYER
    Offline

    PolskiTHEPLAYER New Member

    Joined:
    Apr 1, 2015
    Posts:
    55
    Minecraft User:
    Flsmers
    I need add loot lvl exp for drop stone
  6. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    @Hotshot_9930 already told you what you need to use.
    Last edited: Jun 11, 2016
    KubixQ and applqpak like this.
  7. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    What? Loot lvl? Sounds like a feature you must code on your own.

Share This Page

Advertisement