1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

setText() on null, setBlockIdAt() glitching and newExplosion not working

Discussion in 'Development' started by Jose Antonio, May 25, 2017.

  1. Jose Antonio

    Jose Antonio Spider

    Messages:
    13
    First of all I wish to say it is my first pocketmine plugin i ever developed, second i've been spent almost 8 hours in finding a solution, 3+ days, im also a student and i dont have lot of time.

    I cannot find that three problems, i may have included some classes that arent even used, i've been a lot learning pocketmine api and im so much better than before.

    Im hispanic also. So i have my plugin RaidCommand and i am having the three issues... running pocketmine for version v1.0.8, would love if you guys can also test it yourself the errors!

    Main file, RaidCommand.php, and the only one

    PHP:
    <?php

    namespace RaidCommand;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\CommandExecutor;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\level\Level;
    use 
    pocketmine\tile\Sign;
    use 
    pocketmine\level\Explosion;
    use 
    pocketmine\block\Block;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\Server;
    use 
    onebone\economyapi\EconomyAPI;

    class 
    RaidCommand extends PluginBase implements Listener
    {

    public function 
    onEnable()
    {
    $this->getServer()->getPluginManager()->registerEvents($this$this);
    $this->getLogger()->info("§aEnabling " $this->getDescription()->getFullName() . "...");

    }

    public function 
    onDisable()
    {
    $this->getLogger()->info("§cDisabling " $this->getDescription()->getFullName() . "...");
    }

    public function 
    onCommand(CommandSender $senderCommand $command$label, array $args)
    {

    if (
    $command->getName() === "raid") {
    if (
    EconomyAPI::getInstance()->reduceMoney($sender35000) == false) {
    $sender->sendMessage("§cYou need at least §a35000$ §cto use the raid command.");
    return 
    true;
    } else {
    global 
    $tapRaid;
    $name $sender->getName();
    $hand $sender->getInventory()->getItemInHand();
    $sender->sendMessage("§2Touch with a diamond pickaxe the area that you want to do more damage in the land.");
    // it should now define $tapRaid to true so that it can end up raiding.. but the variable is lost on the touch public function
    $tapRaid "true";
    return 
    true;

    }

    }
    }

    public function 
    onTouch(PlayerInteractEvent $event)
    {
    global 
    $tapRaid;
    $player $event->getPlayer();
    $block $event->getBlock();
    $itemTapped $event->getItem();
    $level $player->getLevel();
    if (
    $itemTapped->getId() == "278:0") {
    if (
    $player->getLevel()->getName() == "homestead") {
    if (!empty(
    $tapRaid)) {
    if (
    $tapRaid == "true") {
    // what i gotto add here is check the land is on the tapped block, then check its owner and check if the land owner has raidcommand.protection perm or return error message

    $x $block->getX();
    $stoneY $block->getY();
    $signY $stoneY 1;
    $z $block->getZ();

    $explosion = new Explosion(new Position($x$stoneY$z$player->getLevel()), 5);
    $explosion->explodeA();

    $stoneId "1";
    $signId "323";
    $level->setBlockIdAt($x$stoneY$z$stoneId);
    $level->setBlockIdAt($x$signY$z$signId);
    $getTile $level->getTile(new Vector3($x,$signY,$z));
    $getTile->setText("§c[RAIDED]""§b" "$player was""§bhere""");

    }
    }
    }
    }
    }


    }


    PS: I forgot say title the glitching part is incomplete, what happens is that the first block sets but it sets a cobblestone stair instead of a stone and the sign isnt setting anywhere
     
  2. Jose Antonio

    Jose Antonio Spider

    Messages:
    13
    So anyone can help?
     
  3. Thouv

    Thouv Slime

    Messages:
    84
    GitHub:
    adeynes
    What errors are you getting?
     
  4. Jose Antonio

    Jose Antonio Spider

    Messages:
    13
    The errors is the title of this post.. and the,description of it
     
  5. Thouv

    Thouv Slime

    Messages:
    84
    GitHub:
    adeynes
    Can you paste the exact error you're getting?
     
  6. Jose Antonio

    Jose Antonio Spider

    Messages:
    13
    setText():
    Error found: sign isn't setted one Y more than the stone
    [​IMG]

    setBlockIdAt() (I tapped two times two blocks using the Diamond Pickaxe) and this is what I got, it was supposed to set stone
    Error found:
    - Placed one block more
    - didnt place stone
    [​IMG]

    newExplosion simply no explosion happens and no error in console check the code in the post description

    Oh and I wish the player after using /raid to do all once because i were able to place more than once and if newexplosion were working it would explode two times or the amount of times i tap a block so you can help with that
     
  7. Jose Antonio

    Jose Antonio Spider

    Messages:
    13
    Sorry but that doesnt help me, im new to this and i dont know what i got to do, can you give me the correct code just..
     
  8. BEcraft

    BEcraft Slime

    Messages:
    79
    GitHub:
    BEcraft
    Try checking if $getTile is instance of Sign tile
    PHP:
    $getTile $level->getTile(new Vector3($x,$signY,$z));
    if(
    $getTile instanceof Sign){
    $getTile->setText("§c[RAIDED]""§b" "$player was""§bhere""");
    }
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.