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

RemoveArrow

Discussion in 'Plugin Help' started by Howtodoit, Aug 12, 2020.

Thread Status:
Not open for further replies.
  1. Primus

    Primus Zombie Pigman

    Messages:
    749
    I posted a code that is ready to run as is. Save it as fileName.php in ~/plugins folder, run the server. It's ridiculous to claim ownership over publicly available few lines of code on a forums. I just wrote script file and tested said method. This is throwback to: https://forums.pocketmine.net/threads/new-plugin-scripting-format-draft.8335/

    Talking about the status of posting more, but less quality posts - it makes you a douchebag!
    Little math: I've been here since Nov 12, 2016 and only accumulated little over 400 messages. Whats your point?
     
    GodWeedZao and Diduhless like this.
  2. Howtodoit

    Howtodoit Spider Jockey

    Messages:
    35
    I got Error. how to fix it.????
    Code:
    [22:25:14] [Server thread/CRITICAL]: ReflectionException: "Class pocketmine\event\entity\ProjectileHitBlockEvent does not exist" (EXCEPTION) in "/src/pocketmine/plugin/PluginManager" at line 766
     
  3. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    xd, you right
     
  4. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    what is your version (your server version)
     
  5. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    use this after your namespace in your plugin :
    PHP:
    use pocketmine\entity\projectile\Arrow;
    use 
    pocketmine\event\entity\ProjectileHitBlockEvent;
    so now drop this piece of code to your plugin in
    PHP:
    class Main extends PluginBase implements Listener{
    //function here
    }
    drop this function:
    PHP:
    /**
    * @param ProjectileHitBlockEvent $event
    */

    public function Shoot(ProjectileHitBlockEvent $event) {
        
    $arrow $event->getEntity();
        if (
    $arrow instanceof Arrow) {
            
    $arrow->flagForDespawn();
        }
    }
    and in the end, dont forget to registerEvents:

    PHP:
    public function onEnable() {
    $this->getServer()->getPluginManager()->registerEvents($this$this);
    }
    if you have a new error just send me your namespaces, i'll create plugin for you. ;)
     
    Last edited: Aug 12, 2020
    Primus likes this.
  6. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    also use Listener after namespace :)
     
    Howtodoit likes this.
  7. Primus

    Primus Zombie Pigman

    Messages:
    749
    You should register listener once. I suppose you misspelled, it must be onEnable() instead.

    Also, I admire your desire to help.
     
    Howtodoit likes this.
  8. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    yes, sorry i wrote wrong LMAO, i edit that now
     
    Howtodoit likes this.
  9. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    thank you :)
     
    Howtodoit and Primus like this.
  10. JviguyGamesYT

    JviguyGamesYT Baby Zombie

    Messages:
    113
    GitHub:
    jviguy
    man i swear INCORRECT CODING confusing lmaaoo :facepalm: tells someone not to help if they dont have enough "XP" please calm down mister big man u dont even know the difference between params and function names apperantly let me explain to the guy who thinks he has the right to stop others from helping because he knows better well atleast thinks he is
    PHP:
    <?php
    //A Type hint follows a parameter to show what goes
    //there u can also leave it empty
    function FunctionNameIsHere(HEYIAMATYPEHINT $IAMAPARAMETER){
       echo 
    $IAMAPARAMETER;
    }
    //this is a function call
    FunctionNameIsHere("i am the param passed to the function");
    //now in the console it will print the given string
    You May Have A Desire to help but that wont overshadow ur cruelty to others the guy was just trying to help not get told by a person who is possible worse at coding then him to get more "xp" on that topic what tf do u mean by "xp" ur imaginary counter of every ones skill??? cause if so urs has to be pretty low. I know that u think that this message is probally just to make this thread more notable as u assumed before when someone brought up ur issues. but this is more of just a way to get to u and have context on the bullshit u do. sorry not sorry;)
     
    Last edited: Aug 13, 2020
  11. Howtodoit

    Howtodoit Spider Jockey

    Messages:
    35
    Not work
    PHP:
    <?php
    namespace noarrow;

    use 
    pocketmine\event\Listener;
    use 
    pocketmine\Server;
    use 
    pocketmine\event\entity;
    use 
    pocketmine\entity\projectile\Arrow;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\entity\ProjectileHitBlockEvent;
    use 
    pocketmine\event\entity\ProjectileHitEvent;

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

    public function 
    Noarrow(ProjectileHitEvent $event) {
        if(
    $event instanceof ProjectileHitBlockEvent){
        
    $arrow $event->getEntity();
        if (
    $arrow instanceof Arrow){
            
    $this->getServer()->broadcastMessage("§c§lArrows are Removed");
            
    $arrow->flagForDespawn();
            }
        }
    }
    }
     
  12. Howtodoit

    Howtodoit Spider Jockey

    Messages:
    35
    Not remove and server not say arrows are Removed
     
  13. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    :| why you are using if ($event instanceof ProjectileHitEvent) ????o_Oo_O:facepalm::facepalm:
     
  14. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    i maked a plugin for you, wait for approving on poggit.
     
    Howtodoit likes this.
  15. Howtodoit

    Howtodoit Spider Jockey

    Messages:
    35
    Because It get Error in pluginmanager at line 766
     
  16. Howtodoit

    Howtodoit Spider Jockey

    Messages:
    35
    Thanks you
     
  17. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    d
    did you use:
    PHP:
    class Main extends PluginBase implements Listener {}
    ??
     
  18. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    no problem, download it Here, if you have problem, tag me here.

    DOWNLOAD PLUGIN

    i love this color and for this im using this in my post XD :p;)
     
    Howtodoit likes this.
  19. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    o_Oo_O whay you thinking that? hexmor is a frind, pls if you dont know about people dont replay and send wall of text, he is my friend and you can see my location and his location, we are iranian, so always we joke, its really bad you write a harmful txt about other people and other people liking your post :facepalm: its really bad, pls change your
    Thoughts, first think, second guess, third write harmful posts, thank you for underestanding :(.
     
  20. Primus

    Primus Zombie Pigman

    Messages:
    749
    Why can't you combine the last two messages into one? If you have anything to add then use the 'edit' button. There is no need to spam the thread. I feel bad for going off-topic. But I guess that I can afford that as no one is moderating this.
     
    Diduhless likes this.
Thread Status:
Not open for further replies.
  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.