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

[HELP] UndefinesConstantException

Comments in 'Plugin Development' started by Primus, Apr 11, 2015.

  1. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    This is the statement where it crashes:


    PHP:
        public function PlayerJoinEvent(PlayerJoinEvent $event){
            
    $p $event->getPlayer();
            
    $n $event->getPlayer()->getName();
            
    $tmp $this->getConfig()->getAll();
            
    $format $tmp[messages][join.message];
            
    $format str_replace("{PLAYER}"$n$format);
            if(
    $n === $tmp[vips][$n]){
            
    $p->setJoinMessage($format."");
            }
        }
    }
    Server crash info from console:
    [CRITICAL] Could not pass event pocketmine\event\player\PlayerJoinEvent to VipPlugin v1.0.1: Use of undefined constant messages - assumed 'messages' on VIP\VipPlugin [Server] 17:06:25 [NOTICE] UndefinedConstantException: "Use of undefined constant messages - assumed 'messages'" (E_NOTICE) in "/VipPlugin/src/VIP/VipPlugin" at line 43

    And my config file:
    # Customize your VIP!
    vip:
    prefix: "[VIP]"
    name-tag: "[VIP]"
    messages:
    message: "[VIP] {PLAYER} Joined the game!"
    vip-leave-message: "[VIP] {PLAYER} Leaved the game"
    vip-death-message: "[VIP] {PLAYER} Died"
    heal:
    # Set time period that VIP will recieve health (per-second)
    health-per-second: "2.5"

    # Config version (DO NOT CHANGE THIS)
    version: 1.0.1

    # List all your VIPs here
    vips:
    - PrimusLV
  2. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    $format = $tmp[messages][join.message];
    messages and join.message must be string. You must put them in quotes ($format = $tmp["messages"]["join.message"]; )
  3. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Sorry miss understood :D Works!
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Hm... when i'm trying to get if player is vip: if($n === $tmp["vips"]["$n"]){
    It's saying ArrayOutOfBounds: undefined index: PrimusLV.
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Because $tmp is not initialized with that player name?
  6. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Ok, got fixed i used other method :)
    If(in_array(......));
  7. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Code:
    [Server] 07:49:27 [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] 07:49:27 [INFO] Starting Minecraft: PE server version v0.10.5 alpha
    [Server] 07:49:27 [INFO] Loading pocketmine.yml...
    [Server] 07:49:27 [INFO] Loading server properties...
    [Server] 07:49:27 [INFO] Starting Minecraft PE server on 0.0.0.0:19132
    [Server] 07:49:27 [INFO] This server is running PocketMine-MP version 1.4.1-980 "絶好(Zekkou)ケーキ(Cake)" (API 1.11.0)
    [Server] 07:49:27 [INFO] PocketMine-MP is distributed under the LGPL License
    [Server] 07:49:28 [INFO] Loading DevTools v1.10.0
    [Server] 07:49:28 [INFO] Loading Specter v0.2
    [Server] 07:49:33 [INFO] ----- PocketMine-MP Auto Updater -----
    [Server] 07:49:33 [INFO] It appears you're running a Stable build, when you've specified that you prefer to run Beta builds.
    [Server] 07:49:33 [INFO] If you would like to be kept informed about new Stable builds only, it is recommended that you change 'preferred-channel' in your pocketmine.yml to 'stable'.
    [Server] 07:49:33 [INFO] ----- -------------------------- -----
    [Server] 07:49:33 [INFO] Enabling DevTools v1.10.0
    [Server] 07:49:33 [INFO] Loading source plugin SimpleVIP v0.0.1
    [Server] 07:49:33 [INFO] [DevTools] Registered folder plugin loader
    [Server] 07:49:33 [INFO] Preparing level "Core"
    [Server] 07:49:33 [INFO] Enabling Specter v0.2
    [Server] 07:49:34 [INFO] Enabling SimpleVIP v0.0.1
    [Server] 07:49:34 [INFO] [SVIP] Loading...
    [Server] 07:49:34 [INFO] [SVIP] Loaded!
    [Server] 07:49:34 [INFO] Starting GS4 status listener
    [Server] 07:49:34 [INFO] Setting query port to 19132
    [Server] 07:49:34 [INFO] Query running on 0.0.0.0:19132
    [Server] 07:49:34 [INFO] Default game type: ADVENTURE
    [Server] 07:49:34 [INFO] Done (13.488s)! For help, type "help" or "?"
    >s s PrimusLV
    [Server] 07:49:42 [INFO] PrimusLV[/SPECTER:19133] logged in with entity id 1 at (Core, 113.3, 66, 140.0172)
    [Server] 07:49:42 [CRITICAL] Could not pass event pocketmine\event\player\PlayerJoinEvent to SimpleVIP v0.0.1: Argument 1 passed to pocketmine\inventory\PlayerInventory::setHelmet() must be an instance of pocketmine\item\Item, boolean given, called in /mnt/sdcard/PocketMine/plugins/SimpleVIP/src/SimpleVIP/SVIP.php on line 70 and defined on SimpleVIP\SVIP
    [Server] 07:49:42 [NOTICE] InvalidArgumentException: "Argument 1 passed to pocketmine\inventory\PlayerInventory::setHelmet() must be an instance of pocketmine\item\Item, boolean given, called in /mnt/sdcard/PocketMine/plugins/SimpleVIP/src/SimpleVIP/SVIP.php on line 70 and defined" (E_RECOVERABLE_ERROR) in "/src/pocketmine/inventory/PlayerInventory" at line 196
    [Server] 07:49:42 [INFO] [VIP] PrimusLV Joined the g
    ame!
    [Server] 07:49:42 [INFO] [Specter] To PrimusLV: [VIP] PrimusLV Joined the game!
    [Server] 07:49:42 [INFO] Session started.
    
    [Server] 07:49:42 [INFO] There are 1/5 players online:
    [Server] 07:49:42 [INFO] PrimusLV
    Last edited: Apr 12, 2015
  8. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Maby its because im using
    PHP:
     $e->getPlayer()->getInventory()->setHelmet($this->getConfig()->get("Helmet"));
    Last edited: Apr 12, 2015
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Try containing logs inside [code][/code]
  10. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Done
  11. Angelo Vidrio
    Offline

    Angelo Vidrio Active Member Plugin Developer

    Joined:
    Jan 16, 2014
    Posts:
    123
    Plugins:
    5
    Minecraft User:
    LilCrispy45
    You need to give an instance of Item for setHelmet(), it says your giving a boolean.
  12. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    But i'm trying to get item from config.yml and config is everything ok
  13. Angelo Vidrio
    Offline

    Angelo Vidrio Active Member Plugin Developer

    Joined:
    Jan 16, 2014
    Posts:
    123
    Plugins:
    5
    Minecraft User:
    LilCrispy45
    Whats the config look like? Try
    Code:
    $e->getPlayer()->getInventory()->setHelmet(Item::get($this->getConfig()->get("Helmet")));
    
  14. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    My config for helmet:

    Helmet: "GoldHelmet"
  15. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Should i use item id instead?

Share This Page

Advertisement