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

Could someone help with this plugin?

Comments in 'Plugin Development' started by SliperyPlayz, Mar 22, 2016.

  1. SliperyPlayz
    Offline

    SliperyPlayz New Member

    Joined:
    Feb 16, 2016
    Posts:
    12
    Minecraft User:
    SliperyPlayz
    If someone could point out what I have done wrong and how to update it to php7, that would be greatly appreciated!

    <?php __HALT_COMPILER(); ?>

    name: hoegunplugin
    main: sliperyplayz/hoegunplugin/hoegunplugin
    version: 2.0
    api: [1.4.1]<?php

    namespace hoegunplugin;

    use pocketmine\plugin\PluginBase;
    use pocketmine\block\Air;
    use pocketmine\block\Block;
    use pocketmine\entity\Entity;
    use pocketmine\event\block\BlockBreakEvent;
    use pocketmine\event\block\BlockPlaceEvent;
    use pocketmine\event\Listener;
    use pocketmine\event\player\PlayerInteractEvent;
    use pocketmine\event\player\PlayerQuitEvent;
    use pocketmine\event\server\DataPacketReceiveEvent;
    use pocketmine\level\Position;
    use pocketmine\math\Vector3;
    use pocketmine\network\protocol\UseItemPacket;
    use pocketmine\Player;
    use pocketmine\nbt\tag\Compound;
    use pocketmine\nbt\tag\Enum;
    use pocketmine\nbt\tag\Double;
    use pocketmine\nbt\tag\Float;
    use pocketmine\item\Item;
    use pocketmine\event\entity\EntityDamageEvent;
    use pocketmine\event\entity\EntityDamageByEntityEvent;
    use pocketmine\event\entity\ProjectileLaunchEvent;
    use pocketmine\event\player\PlayerItemConsumeEvent;
    use pocketmine\entity\Snowball;
    use pocketmine\event\entity\EntityDespawnEvent;
    use pocketmine\scheduler\CallbackTask;
    use pocketmine\event\entity\EntityDeathEvent;
    use pocketmine\event\player\PlayerDeathEvent;
    use pocketmine\Server;
    use pocketmine\entity\Living;

    class hoegunplugin extends PluginBase implements Listener {
    public function onEnable() {
    $this->getServer ()->getPluginManager ()->registerEvents ( $this, $this );
    }

    public function onPacketReceived(DataPacketReceiveEvent $event){

    if($event->getPlayer()->getLevel()->getName() == "world"){

    $pk = $event->getPacket();
    $player = $event->getPlayer();
    if($pk instanceof UseItemPacket and $pk->face === 0xff) {
    $item = $player->getInventory()->getItemInHand();
    if($item->getId() == 292){
    foreach($player->getInventory()->getContents() as $item){
    if ($item->getID() == 289 && $item->getDamage() == 3 && $item->getCount() > 0){
    $nbt = new Compound ( "", [
    "Pos" => new Enum ( "Pos", [
    new Double ( "", $player->x ),
    new Double ( "", $player->y + $player->getEyeHeight () ),
    new Double ( "", $player->z )
    ] ),
    "Motion" => new Enum ( "Motion", [
    new Double ( "", - \sin ( $player->yaw / 180 * M_PI ) *\cos ( $player->pitch / 180 * M_PI ) ),
    new Double ( "", - \sin ( $player->pitch / 180 * M_PI ) ),
    new Double ( "",\cos ( $player->yaw / 180 * M_PI ) *\cos ( $player->pitch / 180 * M_PI ) )
    ] ),
    "Rotation" => new Enum ( "Rotation", [
    new Float ( "", $player->yaw ),
    new Float ( "", $player->pitch )
    ] )
    ] );

    $f = 2.0;
    $snowball = Entity::createEntity ( "Snowball", $player->chunk, $nbt, $player );
    $snowball->setMotion ( $snowball->getMotion ()->multiply ( $f ) );
    $snowball->spawnToAll ();
    $player->getInventory ()->removeItem ( Item::get(289) );
    }
    }
    Last edited by a moderator: Mar 22, 2016
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You're uploading the raw contents of a phar file?
    PocketKiller, applqpak and KubixQ like this.
  3. CookieSteve
    Offline

    CookieSteve Active Member

    Joined:
    Apr 22, 2014
    Posts:
    132
    Minecraft User:
    iStrqfeChris
    Code:
    <?php
    
    namespace hoegunplugin;
    
    use pocketmine\plugin\PluginBase;
    use pocketmine\block\Air;
    use pocketmine\block\Block;
    use pocketmine\entity\Entity;
    use pocketmine\event\block\BlockBreakEvent;
    use pocketmine\event\block\BlockPlaceEvent;
    use pocketmine\event\Listener;
    use pocketmine\event\player\PlayerInteractEvent;
    use pocketmine\event\player\PlayerQuitEvent;
    use pocketmine\event\server\DataPacketReceiveEvent;
    use pocketmine\level\Position;
    use pocketmine\math\Vector3;
    use pocketmine\network\protocol\UseItemPacket;
    use pocketmine\Player;
    use pocketmine\nbt\tag\CompoundTag;
    use pocketmine\nbt\tag\ListTag;
    use pocketmine\nbt\tag\DoubleTag;
    use pocketmine\nbt\tag\FloatTag;
    use pocketmine\item\Item;
    use pocketmine\event\entity\EntityDamageEvent;
    use pocketmine\event\entity\EntityDamageByEntityEvent;
    use pocketmine\event\entity\ProjectileLaunchEvent;
    use pocketmine\event\player\PlayerItemConsumeEvent;
    use pocketmine\entity\Snowball;
    use pocketmine\event\entity\EntityDespawnEvent;
    use pocketmine\scheduler\CallbackTask;
    use pocketmine\event\entity\EntityDeathEvent;
    use pocketmine\event\player\PlayerDeathEvent;
    use pocketmine\Server;
    use pocketmine\entity\Living;
    
    class hoegunplugin extends PluginBase implements Listener {
        public function onEnable() {
            $this->getServer ()->getPluginManager ()->registerEvents ( $this, $this );
        }
     
        public function onPacketReceived(DataPacketReceiveEvent $event){
    
    if($event->getPlayer()->getLevel()->getName() == "world"){
    
            $pk = $event->getPacket();
            $player = $event->getPlayer();
            if($pk instanceof UseItemPacket and $pk->face === 0xff) {
            $item = $player->getInventory()->getItemInHand();
            if($item->getId() == 292){
            foreach($player->getInventory()->getContents() as $item){
                    if ($item->getID() == 289 && $item->getDamage() == 3 && $item->getCount() > 0){
                            $nbt = new CompoundTag ( "", [
                    "Pos" => new ListTag ( "Pos", [
                            new DoubleTag ( "", $player->x ),
                            new DoubleTag ( "", $player->y + $player->getEyeHeight () ),
                            new DoubleTag ( "", $player->z )
                    ] ),
                    "Motion" => new ListTag ( "Motion", [
                            new DoubleTag ( "", - \sin ( $player->yaw / 180 * M_PI ) *\cos ( $player->pitch / 180 * M_PI ) ),
                            new DoubleTag ( "", - \sin ( $player->pitch / 180 * M_PI ) ),
                            new DoubleTag ( "",\cos ( $player->yaw / 180 * M_PI ) *\cos ( $player->pitch / 180 * M_PI ) )
                    ] ),
                    "Rotation" => new ListTag ( "Rotation", [
                            new FloatTag ( "", $player->yaw ),
                            new FloatTag ( "", $player->pitch )
                    ] )
            ] );
         
            $f = 2.0;
            $snowball = Entity::createEntity ( "Snowball", $player->chunk, $nbt, $player );
            $snowball->setMotion ( $snowball->getMotion ()->multiply ( $f ) );
            $snowball->spawnToAll ();
            $player->getInventory ()->removeItem ( Item::get(289) );
            }
        }
    Tried my best to fix it was hard to read :p
  4. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    Can you upload the zip of your plugin? You can't modify a plugin when it's in phar format.
  5. SliperyPlayz
    Offline

    SliperyPlayz New Member

    Joined:
    Feb 16, 2016
    Posts:
    12
    Minecraft User:
    SliperyPlayz
    Thank you so much!!!
    CookieSteve likes this.
  6. SliperyPlayz
    Offline

    SliperyPlayz New Member

    Joined:
    Feb 16, 2016
    Posts:
    12
    Minecraft User:
    SliperyPlayz
    Hey,u would not believe how little I know about this stuff. I started 5 days ago... I have yet to learn what u r talking about :) thank you anyway!!
  7. SliperyPlayz
    Offline

    SliperyPlayz New Member

    Joined:
    Feb 16, 2016
    Posts:
    12
    Minecraft User:
    SliperyPlayz
    I am HUUGGE nube at this. I started a few days ago,I definitely need some coaching :)
  8. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    @SliperyPlayz You compiled the plugin right? Or did you put all your code into a .phar file?
  9. SliperyPlayz
    Offline

    SliperyPlayz New Member

    Joined:
    Feb 16, 2016
    Posts:
    12
    Minecraft User:
    SliperyPlayz
    Exactly how u see it,that's how I built it
  10. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    Ok so you saved it as a .phar file?
  11. SliperyPlayz
    Offline

    SliperyPlayz New Member

    Joined:
    Feb 16, 2016
    Posts:
    12
    Minecraft User:
    SliperyPlayz
    Yeeeeaaaahhhhhh.sorta I have just looked at a bunch of other similar plugins and tried to stitch this together (#nocomputer) and I am on IOS sooooo... I know it's pretty hooky but ya know,work with what ya can right?
  12. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    The source code needs to be put in the right plugin format and them compiled into a .phar with DevTools or go to pmt.mcpe.me
  13. SliperyPlayz
    Offline

    SliperyPlayz New Member

    Joined:
    Feb 16, 2016
    Posts:
    12
    Minecraft User:
    SliperyPlayz
    I don't suppose u are able to do that,are you :/ :)
  14. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    A phar file contains a lot of binary bytes. You can't edit it directly (at least not through conventional editors), just like you can't edit a Microsoft Word file directly.

Share This Page

Advertisement