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

Solved Problem with converting from folder to phar plugin

Comments in 'Plugin Development' started by Rspuds, Aug 7, 2015.

  1. Rspuds
    Offline

    Rspuds New Member

    Joined:
    Aug 4, 2015
    Posts:
    53
    I made a plugin and it works perfectly fine in folder form with dev tools but when i converted using dev tools to a phar file it wouldn't load the plugin. No error messages, it didn't even seem to register it. So I then try converting one of my other plugins and it works fine. I noticed there is a difference in the phar files but I don't know why.

    heres the not working phar file

    Code:
    <?php echo "PocketMine-MP plugin GoldenAppleEffects v1\nThis file has been generated using DevTools v1.10.0 at Fri, 07 Aug 2015 15:18:14 -0500\n----------------\n";if(extension_loaded("phar")){$phar = new \Phar(__FILE__);foreach($phar->getMetadata() as $key => $value){echo ucfirst($key).": ".(is_array($value) ? implode(", ", $value):$value)."\n";}} __HALT_COMPILER(); ?>
                   a:9:{s:4:"name";s:18:"GoldenAppleEffects";s:7:"version";d:1;s:4:"main";s:23:"GoldenAppleEffects\Main";s:3:"api";a:1:{i:0;s:6:"1.12.0";}s:6:"depend";a:0:{}s:11:"description";N;s:7:"authors";a:1:{i:0;s:6:"Rspuds";}s:7:"website";N;s:12:"creationDate";i:1438978694;}   nbproject/project.properties  †ÅU  U!¸Z¶         nbproject/project.xmlI  †ÅUI  oY¶     
       Plugin.yml°   †ÅU°   1£˜”¶         resources/config.yml  †ÅU  dӁ¶         src/GoldenAppleEffects/Main.php˜
      †ÅU˜
      KÖ{¶      file.reference.src-pocketmine=../../../Desktop/Eclipse/src/PocketMine-MP-master/src/pocketmine
    include.path=\
        ${php.global.include.path}:\
        ${file.reference.src-pocketmine}
    php.version=PHP_56
    source.encoding=UTF-8
    src.dir=.
    tags.asp=false
    tags.short=false
    web.root=.
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://www.netbeans.org/ns/project/1">
        <type>org.netbeans.modules.php.project</type>
        <configuration>
            <data xmlns="http://www.netbeans.org/ns/php-project/1">
                <name>GoldenAppleEffects</name>
            </data>
        </configuration>
    </project>
    name: GoldenAppleEffects
    version: 1.0
    api: [1.12.0]
    main: GoldenAppleEffects\Main
    
    load: STARTUP
    author: Rspuds
    discription: gives players effects when they eat a golden apple
    #this is the configs file for GoldenAppleEffect
    
                # "normal" for regular golden apple effects. "enchanted" for enchanted/notch apple effects
                apple: enchanted
       
                # set true to see effects. set false to not see effects
       
                show: true<?php
    
    namespace GoldenAppleEffects;
    
    use pocketmine\Player;
    use pocketmine\entity\Effect;
    use pocketmine\event\player\PlayerItemConsumeEvent;
    use pocketmine\event\Listener;
    use pocketmine\plugin\PluginBase;
    use pocketmine\utils\Config;
    use pocketmine\utils\TextFormat;
    
    class main extends PluginBase implements Listener{
       
        public function onEnable() {
            $this->getServer()->getPluginManager()->registerEvents($this, $this);
            $this->saveDefaultConfig();
            $this->reloadConfig();
            $this->getLogger()->info(TextFormat::GREEN."GoldenAppleEffects enabled");
        }
       
        public function onDisable() {
            $this->getConfig()->save();
            $this->getLogger()->info(TextFormat::RED."GoldenAppleEffects disabled");
        }
       
        public function onEat(PlayerItemConsumeEvent $event){
            $item = $event->getItem();
            $iid = $item->getId();
            $player = $event->getPlayer();
                if($iid === 260){
                    switch ($this->getConfig()->get('apple')){
                       
                        case "normal":
                            $id = array(21, 10);
                            $duration = array(2400, 100);
                            $amplifier = array(1, 1);
                            $show = $this->getConfig()->get('show');
                            $this->applyEffects($player, $id[0], $duration[0], $amplifier[0], $show);
                            $this->applyEffects($player, $id[1], $duration[1], $amplifier[1], $show);
                            break;
    
                        case "enchanted":
                            $id = array(21, 10, 12, 11);
                            $duration = array(2400, 600, 6000, 6000);
                            $amplifier = array(1, 4, 0, 0);
                            $show = $this->getConfig()->get('show');
                            $this->applyEffects($player, $id[0], $duration[0], $amplifier[0], $show);
                            $this->applyEffects($player, $id[1], $duration[1], $amplifier[1], $show);
                            $this->applyEffects($player, $id[2], $duration[2], $amplifier[2], $show);
                            $this->applyEffects($player, $id[3], $duration[3], $amplifier[3], $show);
                            break;
                    }
                }
            }
       
       
        public function applyEffects($player, $id, $duration, $amplifier, $show){
            if($player instanceof Player){
                $effect = Effect::getEffect($id);
                $effect->setDuration($duration);
                $effect->setAmplifier($amplifier);
                $effect->setVisible($show);
                $player->addEffect($effect);
            }
        }
    }
               
           
    
    
    :’\s}WIxâXö'õÀ~öæZ   GBMB
    and here is the working one

    Code:
    <?php echo "PocketMine-MP plugin EffectsManager v0.9\nThis file has been generated using DevTools v1.10.0 at Fri, 07 Aug 2015 14:58:29 -0500\n----------------\n";if(extension_loaded("phar")){$phar = new \Phar(__FILE__);foreach($phar->getMetadata() as $key => $value){echo ucfirst($key).": ".(is_array($value) ? implode(", ", $value):$value)."\n";}} __HALT_COMPILER(); ?>
                 +  a:9:{s:4:"name";s:14:"EffectsManager";s:7:"version";d:0.90000000000000002;s:4:"main";s:19:"EffectsManager\Main";s:3:"api";a:1:{i:0;s:6:"1.12.0";}s:6:"depend";a:0:{}s:11:"description";s:21:"Manage player effects";s:7:"authors";a:1:{i:0;s:6:"Rspuds";}s:7:"website";N;s:12:"creationDate";i:1438977509;}   nbproject/project.propertiesP  å
    ÅUP  '™uè¶         nbproject/project.xmlE  å
    ÅUE  óà×(¶     
       plugin.yml®  å
    ÅU®  “¿ØÞ¶         src/EffectsManager/Main.php…
      å
    ÅU…
      ŏ~¶      code.analysis.excludes=
    file.reference.src-pocketmine=../../../Desktop/src/PocketMine-MP-master/PocketMine-MP-master/src/pocketmine
    file.reference.src-pocketmine-1=../../../Desktop/src/pocketmine
    file.reference.src-pocketmine-2=../../../Desktop/test/PocketMine-MP-master/src/pocketmine
    file.reference.src-pocketmine-3=../../../Desktop/Eclipse/src/PocketMine-MP-master/src/pocketmine
    ignore.path=
    include.path=\
        ${php.global.include.path}:\
        ${file.reference.src-pocketmine-3}
    php.version=PHP_56
    source.encoding=UTF-8
    src.dir=.
    tags.asp=false
    tags.short=false
    web.root=.
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://www.netbeans.org/ns/project/1">
        <type>org.netbeans.modules.php.project</type>
        <configuration>
            <data xmlns="http://www.netbeans.org/ns/php-project/1">
                <name>EffectsManager</name>
            </data>
        </configuration>
    </project>
    name: EffectsManager
    version: 0.9
    api: [1.12.0]
    main: EffectsManager\Main
    
    load: STARTUP
    author: Rspuds
    description: Manage player effects
    commands:
            remove:
                description: removes all effects
                usage: "/remove"
                permission: EffectsManager.command.remove
            add:
                description: adds listed effects
                usage: "/add <effectID>"
                permission: EffectsManager.command.add
    permissions:
            EffectManager.command.remove:
                default: true
                description: "allows use of remove command"
            EffectsManager.command.add:
                default: true
                description: "allows use of add command"<?php
    
    namespace EffectsManager;
    
    use pocketmine\plugin\PluginBase;
    use pocketmine\Player;
    use pocketmine\utils\TextFormat;
    use pocketmine\Server;
    use pocketmine\entity\Effect;
    use pocketmine\command\Command;
    use pocketmine\command\CommandSender;
    
    class Main extends PluginBase {
       
        public function onLoad() {
            $this->getLogger()->info(TextFormat::GREEN."EffectsManager Loaded");
        }
       
        public function onEnable() {
            $this->getLogger()->info(TextFormat::GREEN."EffectsManager Enabled");
        }
       
        public function onDisable() {
            $this->getLogger()->info(TextFormat::RED."EffectsManager Disabled");
            }
       
        public function onCommand(\pocketmine\command\CommandSender $sender, \pocketmine\command\Command $command, $label, array $args) {
           
            switch ($command->getName()){
           
                case "remove":
                        if($sender instanceof Player) {
                            $effect = array($sender->getEffects());
                                if (count($effect)>0){
                                    $sender->removeAllEffects();
                                    $sender->sendMessage(TextFormat::GREEN."All effects have been removed");
                                   
                    } else {
                        $sender->sendMessage(TextFormat::RED."You have no effects to remove");
                    }
                } else {
                    $sender->sendMessage(TextFormat::RED."You can only use this command in-game");
                }
                break;
               
                case "add":
                      
                        if($sender instanceof Player) {
                            $EffectID = $args[0];
                            switch ($EffectID) {
                                case "1" :
                                    $id = 1;
                                    $Effect = Effect::getEffect($id);
                                    $Effect->setVisible(true);
                                    $Effect->setAmplifier($args[1]);
                                    $Effect->setDuration($args[2]);
                                    $sender->addEffect(Effect::getEffect($id));
                                    $sender->sendMessage(TextFormat::GREEN."Speed has been applyed");
                                    break;
                                default:
                                    $sender->sendMessage(TextFormat::RED."Not a valid Effect ID");
                            }
                           
                } else {
                    $sender->sendMessage(TextFormat::RED."You can only use this command in-game");
                }
                break;
            }
        }
    }
    
    
    
    ‰è*XO!¡9º»À¤×É`   GBMB
    Thanks for any help
  2. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    You must put the .phar file from ~/plugins/DevTools to ~/plugins
  3. Rspuds
    Offline

    Rspuds New Member

    Joined:
    Aug 4, 2015
    Posts:
    53
    can you explain that more. I don't get what you are saying
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    After you convert your source file to .phar it will put it inside DevTools folder thats locaded in pocketmine/plugins cut it out to parent folder !
  5. Rspuds
    Offline

    Rspuds New Member

    Joined:
    Aug 4, 2015
    Posts:
    53
    if you mean move it out of the devtools folder and into the plugins folder I did that. look at the top of the phar files one has this:

    code.analysis.excludes=
    file.reference.src-pocketmine=../../../Desktop/src/PocketMine-MP-master/PocketMine-MP-master/src/pocketmine
    file.reference.src-pocketmine-1=../../../Desktop/src/pocketmine
    file.reference.src-pocketmine-2=../../../Desktop/test/PocketMine-MP-master/src/pocketmine
    file.reference.src-pocketmine-3=../../../Desktop/Eclipse/src/PocketMine-MP-master/src/pocketmine

    the other doesn't. not sure why that is but when i copyed and pasted it in the other phar file pocketmine recognized it but it gave me an error
  6. Rspuds
    Offline

    Rspuds New Member

    Joined:
    Aug 4, 2015
    Posts:
    53
    this is the error it gave me when i pasted that into the other phar file

    [15:43:04] [Server thread/ERROR]: Could not load 'C:\Users\Ryan\Desktop\Pocket mine\PocketMine-MP Tester\plugins\GoldenAppleEffects_v1.phar' in folder 'C:\Users\Ryan\Desktop\Pocket mine\PocketMine-MP Tester\plugins\': manifest cannot be larger than 100 MB in phar "C:\Users\Ryan\Desktop\Pocket mine\PocketMine-MP Tester\plugins\GoldenAppleEffects_v1.phar"
    [15:43:04] [Server thread/CRITICAL]: UnexpectedValueException: "manifest cannot be larger than 100 MB in phar "C:\Users\Ryan\Desktop\Pocket mine\PocketMine-MP Tester\plugins\GoldenAppleEffects_v1.phar"" (EXCEPTION) in "/src/pocketmine/plugin/PharPluginLoader" at line 85
  7. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    WTF O.0 Your .phar file size is larger then 100 MB???
  8. Rspuds
    Offline

    Rspuds New Member

    Joined:
    Aug 4, 2015
    Posts:
    53
    Idk that's what happens when I posted that part into the phar. I really don't know what the problem is.
  9. Intyre
    Offline

    Intyre Staff Member PocketMine Team

    Joined:
    Aug 24, 2013
    Posts:
    118
    Minecraft User:
    Intyre
  10. Rspuds
    Offline

    Rspuds New Member

    Joined:
    Aug 4, 2015
    Posts:
    53
    I did as it says for both plugins yet the one doesn't work.

    And ya I didn't think it would work but tryed anyways. I'm just confused as to why one plugin would work and the other wouldn't when I created both the same way.

Share This Page

Advertisement