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

[HELP]undefined constant.

Comments in 'Plugin Development' started by IcePL, Feb 21, 2016.

  1. IcePL
    Offline

    IcePL New Member

    Joined:
    Feb 16, 2016
    Posts:
    73
    Minecraft User:
    IcePL
    Hi what is wrong in this code?
    I have the crash undefined constant.
    PHP:
    <?php

    namespace NoCMD;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerCommandPreprocessEvent;

    class 
    Main extends PluginBase implements Listener{
        public function 
    onEnable(){
                        
    $this->getLogger()->info("Plugin Online");
                        
    $this->getServer()->getPluginManager()->registerEvents($this$this);
                        }
        public function 
    onCommandChat(PlayerCommandPreprocessEvent $event){
        
    $player $event->getPlayer();
        
    $cmd explode(" ",strtolower($event->getmessage()));
        if(
    $cmd[0] == "/f claim"){
        if(
    $player->getLevel()->getName() == "world"){
        
    $player->sendMessage("Nie możesz użyć tej komendy na spawnie!");
        
    $event->sendCancelled(true);
            }
            }
        }
        }
  2. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    PHP:
    <?php

    namespace NoCMD;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerCommandPreprocessEvent;

    class 
    Main extends PluginBase implements Listener{
        public function 
    onEnable(){
                        
    $this->getLogger()->info("Plugin Online");
                        
    $this->getServer()->getPluginManager()->registerEvents($this$this);
                        }
        public function 
    onCommandChat(PlayerCommandPreprocessEvent $event){
        
    $player $event->getPlayer();
        
    $cmd explode(" ",strtolower($event->getmessage()));
        if(
    $cmd[0] === "/f" && $cmd[1] === "claim"){//you used explode
        
    if($player->getLevel()->getName() == "world"){
        
    $player->sendMessage("Nie możesz użyć tej komendy na spawnie!");
        
    $event->setCancelled(true);//this part you put `sendCancelled` and its `setCancelled`
            
    }
            }
        }
        }
    PocketKiller, applqpak and Vaivez66 like this.
  3. IcePL
    Offline

    IcePL New Member

    Joined:
    Feb 16, 2016
    Posts:
    73
    Minecraft User:
    IcePL
    I have this crash
    Code:
    [PocketMine] Server is starting...
    [PocketMine] Server was started.
    [Server] [00:13:54] [Server thread/WARNING]: Timezone could not be automatically determined. An incorrect timezone will result in incorrect timestamps on console logs. It has been set to "UTC" by default. You can change it on the php.ini file.
    [Server] [00:13:54] [Server thread/INFO]: Loading pocketmine.yml...
    [Server] [00:13:54] [Server thread/INFO]: Loading server properties...
    [Server] [00:13:54] [Server thread/INFO]: Enable MainLogger to file
    [Server] [00:13:54] [Server thread/INFO]: Selected English (eng) as the base language
    [Server] [00:13:54] [Server thread/INFO]: Starting Minecraft: PE server version v0.14.x beta/alpha
    [Server] [00:13:54] [Server thread/INFO]: Opening server on 0.0.0.0:19132
    [Server] [00:13:54] [Server thread/INFO]: This server is running ClearSky-Sunrise version 1.1 (API 1.13.1) Build 153
    [Server] [00:13:54] [Server thread/INFO]: ClearSky is distributed under the LGPL License
    [Server] [00:13:56] [Server thread/INFO]: Loading ZipPluginLoader v1.1.3
    [Server] [00:13:56] [Server thread/INFO]: Loading EmptyWorld v1.0.0
    [Server] [00:13:56] [Server thread/INFO]: Loading ManyWorlds v2.0.3
    [Server] [00:13:56] [Server thread/INFO]: Loading EconomyAPI v2.0.9
    [Server] [00:13:56] [Server thread/INFO]: Loading ArtificialIntelligent v0.2
    [Server] [00:13:56] [Server thread/INFO]: Loading DevTools v1.10.0
    [Server] [00:13:56] [Server thread/INFO]: Enabling ZipPluginLoader v1.1.3
    [Server] [00:13:56] [Server thread/INFO]: [ZipPluginLoader] Loading zip plugin NoCMD v1.0.0
    [Server]
    [Server] Fatal error: Undefined constant 'NoCMD\use pocketmine\event\player\PlayerCommandPreprocessEvent' in myzip:///storage/sdcard0/PocketMine/plugins/NoCMD.zip#src/NoCMD/Main.php on line 7
    [Server] [00:13:56] [Server thread/EMERGENCY]: An unrecoverable error has occurred and the server has crashed. Creating a crash dump
    [Server] [00:13:56] [Server thread/EMERGENCY]: Please upload the "/storage/sdcard0/PocketMine/crashdumps/CrashDump_Tue_Feb_23-00.13.56-UTC_2016.log" file to the Crash Archive and submit the link to the Bug Reporting page. Give as much info as you can.
    [Server] [00:13:58] [Server thread/INFO]: Disabling ZipPluginLoader v1.1.3
    [Server]
    [Server] Took too long to stop, server was killed forcefully!
    
  4. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    That's weird. xD
    Instead of 'use' add it directly:
    PHP:
        public function onCommandChat(\pocketmine\event\player\PlayerCommandPreprocessEvent $event){
    applqpak likes this.
  5. IcePL
    Offline

    IcePL New Member

    Joined:
    Feb 16, 2016
    Posts:
    73
    Minecraft User:
    IcePL
    Xd
    I have this crash plugin
    Code:
    [PocketMine] Server is starting...
    [PocketMine] Server was started.
    [Server] [00:32:33] [Server thread/WARNING]: Timezone could not be automatically determined. An incorrect timezone will result in incorrect timestamps on console logs. It has been set to "UTC" by default. You can change it on the php.ini file.
    [Server] [00:32:33] [Server thread/INFO]: Loading pocketmine.yml...
    [Server] [00:32:33] [Server thread/INFO]: Loading server properties...
    [Server] [00:32:33] [Server thread/INFO]: Enable MainLogger to file
    [Server] [00:32:33] [Server thread/INFO]: Selected English (eng) as the base language
    [Server] [00:32:33] [Server thread/INFO]: Starting Minecraft: PE server version v0.14.x beta/alpha
    [Server] [00:32:33] [Server thread/INFO]: Opening server on 0.0.0.0:19132
    [Server] [00:32:33] [Server thread/INFO]: This server is running ClearSky-Sunrise version 1.1 (API 1.13.1) Build 153
    [Server] [00:32:33] [Server thread/INFO]: ClearSky is distributed under the LGPL License
    [Server] [00:32:35] [Server thread/INFO]: Loading ZipPluginLoader v1.1.3
    [Server] [00:32:35] [Server thread/INFO]: Loading EmptyWorld v1.0.0
    [Server] [00:32:35] [Server thread/INFO]: Loading ManyWorlds v2.0.3
    [Server] [00:32:35] [Server thread/INFO]: Loading EconomyAPI v2.0.9
    [Server] [00:32:35] [Server thread/INFO]: Loading ArtificialIntelligent v0.2
    [Server] [00:32:35] [Server thread/INFO]: Loading DevTools v1.10.0
    [Server] [00:32:35] [Server thread/INFO]: Enabling ZipPluginLoader v1.1.3
    [Server] [00:32:35] [Server thread/INFO]: [ZipPluginLoader] Loading zip plugin NoCMD v1.0.0
    [Server] [00:32:35] [Server thread/INFO]: [ZipPluginLoader] Loading zip plugin drop v1.0.0
    [Server] [00:32:35] [Server thread/INFO]: [ZipPluginLoader] Loading zip plugin FactionsPro v1.3.2
    [Server] [00:32:35] [Server thread/INFO]: Enabling EmptyWorld v1.0.0
    [Server] [00:32:35] [Server thread/INFO]: Enabling DevTools v1.10.0
    [Server] [00:32:35] [Server thread/INFO]: [DevTools] Registered folder plugin loader
    [Server] [00:32:35] [Server thread/INFO]: Preparing level "world"
    [Server] [00:32:35] [Server thread/INFO]: Enabling ManyWorlds v2.0.3
    [Server] [00:32:36] [Server thread/INFO]: Enabling EconomyAPI v2.0.9
    [Server] [00:32:36] [Server thread/NOTICE]: [EconomyAPI] Auto save has been set to interval : 10 min(s)
    [Server] [00:32:36] [Server thread/INFO]: [EconomyAPI] Checking for updates... It may be take some while.
    [Server] [00:32:38] [Server thread/NOTICE]: [EconomyAPI] Thank you for using EconomyS plugin.
    [Server] [00:32:38] [Server thread/INFO]: Enabling ArtificialIntelligent v0.2
    [Server] [00:32:39] [Server thread/NOTICE]: [ArtificialIntelligent] ArtificialIntelligent is currently up-to-date.
    [Server] [00:32:39] [Server thread/NOTICE]: [ArtificialIntelligent] 이 플러그인은 수정할 경우 지원이 불가능합니다.
    [Server] [00:32:39] [Server thread/INFO]: [ZipPluginLoader] Enabling NoCMD v1.0.0
    [Server] [00:32:39] [Server thread/INFO]: [NoCMD] Plugin Online
    [Server] [00:32:39] [Server thread/CRITICAL]: ReflectionException: "Class NoCMD\pocketmine\event\player\PlayerCommandPreprocessEvent  does not exist" (EXCEPTION) in "/src/pocketmine/plugin/PluginManager" at line 2
    [Server] [00:32:39] [Server thread/INFO]: [ZipPluginLoader] Disabling NoCMD v1.0.0
    [Server] [00:32:39] [Server thread/INFO]: [ZipPluginLoader] Enabling drop v1.0.0
    [Server] [00:32:39] [Server thread/INFO]: [drop] Plugin Online
    [Server] [00:32:39] [Server thread/CRITICAL]: ReflectionException: "Class pocketmine\event\BlockBreakEvent does not exist" (EXCEPTION) in "/src/pocketmine/plugin/PluginManager" at line 2
    [Server] [00:32:39] [Server thread/INFO]: [ZipPluginLoader] Disabling drop v1.0.0
    [Server] [00:32:39] [Server thread/INFO]: [ZipPluginLoader] Enabling FactionsPro v1.3.2
    [Server] [00:32:40] [Server thread/INFO]: Starting GS4 status listener
    [Server] [00:32:40] [Server thread/INFO]: Setting query port to 19132
    [Server] [00:32:40] [Server thread/INFO]: Query running on 0.0.0.0:19132
    [Server] [00:32:40] [Server thread/INFO]: Default game type: Survival Mode
    [Server] [00:32:40] [Server thread/INFO]: Done (17.495s)! For help, type "help" or "?"
    
  6. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    Switch to DevTools, it's better.
    applqpak likes this.
  7. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    Huh? What do you mean?
  8. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    Wtf?¿?
    It's command pre process, no block break.
  9. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    I don't know, I imported it from phpstorm.

Share This Page

Advertisement