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

Is there a way to remove items?

Comments in 'Plugin Development' started by Andrey Nazarchuk, Apr 23, 2014.

  1. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    Hey People,
    I have a question: can items be removed so when a player uses lava it disappears? I tried the BanItem plugin but its still 1.3.9 and if you ban TNT it bans sticks and so on
    I figured out how to modify the TNT so its not activible and explode=0
    I have a FreeBuild server so using white-world is not an option
    I have lots of new players everyday that i dint have the time to teach how to use BeAreaGaurd
    so is there a way to modify the code so lava does not work?
    Thanks so much!
  2. luca28pet
    Offline

    luca28pet Active Member

    Joined:
    Feb 20, 2014
    Posts:
    251
    Minecraft User:
    luca28pet
    What? BanItem bans sticks?
    However, you should try this:
    PHP:
    <?php

    /*
    __PocketMine Plugin__
    name=NoMoreLava
    description=No more lava in your server!
    version=0.1b
    author=luca28pet
    class=nomorelava
    apiversion=11,12
    */

        
    class nomorelava implements plugin{

        private 
    $api;

        public function 
    __construct(ServerAPI $api$server false){

                    
    $this->api $api;

            }

            public function 
    init(){

        
    $this->api->addHandler("player.block.place", array($this"eventHandler"), 100);

        }
       
        public function 
    eventHandler($data$event)
        {
        switch(
    $event)
        {
            case 
    "player.block.place":
            if(
    $data["block"]->getID() === 10)
               return 
    false;
            if (
    $data["block"]->getID() === 11)
               return 
    false
            
    break;

        }

        public function 
    __destruct(){

        }

    }
    ?>
    I haven't tested it, so it may not works. Anyway it doesn't remove lava, only if you place it it will disappear.
    Hope I helped :D
    Andrey Nazarchuk likes this.
  3. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    Wow thanks for the reply i will try to use that code thanks again!
  4. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    hey just tried it and it says "unexpected "break" (T-BREAK)" and stuff like that
  5. luca28pet
    Offline

    luca28pet Active Member

    Joined:
    Feb 20, 2014
    Posts:
    251
    Minecraft User:
    luca28pet
    Try without the ?> at the end.
    Also can I have the exact error message?
  6. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    435
    Plugins:
    4
    Minecraft User:
    Lambo
    just add a bracket at the eventhandler function :p
    PHP:
    <?php/*
    __PocketMine Plugin__
    name=NoMoreLava
    description=No more lava in your server!
    version=0.1b
    author=luca28pet
    class=nomorelava
    apiversion=11,12
    */
    class nomorelava implements plugin{

     private 
    $api;

     public function 
    __construct(ServerAPI $api$server false){
    $this->api $api;

     }

     public function 
    init(){
    $this->api->addHandler("player.block.place", array($this"eventHandler"), 100);

     }
     
     public function 
    eventHandler($data$event)
     {
     switch(
    $event)
     {
     case 
    "player.block.place":
     if(
    $data["block"]->getID() === 10)
     return 
    false;
     if (
    $data["block"]->getID() === 11)
     return 
    false
    break;

     }
    }

     public function 
    __destruct(){

     }

    }
    ?>
    Andrey Nazarchuk and luca28pet like this.
  7. luca28pet
    Offline

    luca28pet Active Member

    Joined:
    Feb 20, 2014
    Posts:
    251
    Minecraft User:
    luca28pet
    Thanks! I forgot it! I did that with my iPhone so I had no Notepad++.
  8. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    435
    Plugins:
    4
    Minecraft User:
    Lambo
    Use Sublime Text :)
  9. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
    The second return false is missing a semi-colon :)
    Andrey Nazarchuk likes this.
  10. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    Thanks!
    Thanks!
    And Thanks!
  11. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    Wait sorry it still does not work i used the code from @Lambo post and added a simicolin:
    <?php/*
    __PocketMine Plugin__
    name=NoMoreLava
    description=No more lava in your server!
    version=0.1b
    author=luca28pet
    class=nomorelava
    apiversion=11,12
    */
    class nomorelava implements plugin{

    private $api;

    public function __construct(ServerAPI $api, $server = false){
    $this->api = $api;

    }

    public function init(){
    $this->api->addHandler("player.block.place", array($this, "eventHandler"), 100);

    }

    public function eventHandler($data, $event)
    {
    switch($event)
    {
    case "player.block.place":
    if($data["block"]->getID() === 10)
    return false;
    if ($data["block"]->getID() === 11)
    return false;
    break;

    }
    }

    public function __destruct(){

    }

    }
    ?>
    Fatal error: Class 'nomorelava' not found in C:\Users\Parents\Downloads\PocketMine-MP\src\API\PluginAPI.php on line 109
    bin\php\php.exe: Exit 255
  12. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    Please help people are still greifing with lava and sheep(they lag the server very much and so do other animals)
    thanks!
  13. PluginMastered
    Offline

    PluginMastered Active Member

    Joined:
    Mar 1, 2014
    Posts:
    161
    Minecraft User:
    Flexa33
    Use a ban item plugin and ban lava bukkits and lava and any other type BTW how did they get sheep in spawn when they stand still?
  14. luca28pet
    Offline

    luca28pet Active Member

    Joined:
    Feb 20, 2014
    Posts:
    251
    Minecraft User:
    luca28pet
    I don't know what is the issue with the class of the plugin, you could ask to someone more expert with php than me ;)
  15. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    They just use the spawn eggs
  16. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    Hey Falk can you help with seeing what the problem is?
    Thanks!
  17. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    Please help me where do i put the bracket?
    I tried putting it in like 20 places and it still says
    "Fatal error: Class 'nomorelava' not found in C:\Users\Parents\Downloads\PocketMine-MP\src\API\PluginAPI.php on line 109
    bin\php\php.exe: Exit 255"
  18. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,132
    Plugins:
    4
    Minecraft User:
    iksaku
    For iOS, not OS X xD
    Use Textastic ;)
  19. THE6walcybba
    Offline

    THE6walcybba New Member

    Joined:
    May 3, 2014
    Posts:
    5
    Minecraft User:
    6walcybba
    PHP:
    <?php/*
    __PocketMine Plugin__
    name=NoMoreLava
    description=No more lava in your server!
    version=0.1b
    author=luca28pet
    class=nomorelava
    apiversion=11,12
    */
    class nomorelava implements plugin{

    private 
    $api;

    public function 
    __construct(ServerAPI $api$server false){
    $this->api $api;

    }

    public function 
    init(){
    $this->api->addHandler("player.block.place", array($this"eventHandler"), 100);

    }

    public function 
    eventHandler($data$event//Put a bracket here
    {
    switch(
    $event)
    {
    case 
    "player.block.place":
    if(
    $data["block"]->getID() === 10)
    return 
    false;
    if (
    $data["block"]->getID() === 11)
    return 
    false
    break;

    }
    }

    public function 
    __destruct(){

    }

    }
    ?>
    I am no expert, but where I said to put it, I think you should put it there
  20. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    oh okay thanks cause im not good at php :p

Share This Page

Advertisement