Ok. Let me get this straight. This tutorial just lists some common mistakes I have seen in this forums Plugin Development section or Plugin repo. Remember to comment if you have suggestions. Don't blame me for creating the mistake. (What am I talking about ) 1. 323, my love. Well, if you have been on this forums for a few months, you should have seen this even if you did not notice it. Usual code: PHP: public function onTap(PlayerInteractEvent $event){ $player = $event->getPlayer(); $sign = $event->getBlock(); $id = $sign->getId(); if($id === Block::SIGN_POST || $id === Block::WALL_SIGN || $id === 323){ //Imagine something... }} What's the problem? WAIT. ISN'T 323 an item id? Yep. This is not really an error, but just plain old bad practice. 2. Can't find my class. Do I have english now? Classes are basic stuff in OOP. But when PocketMine can't find them, you're in big trouble. Simple. No code examples here. Just check your namespace in the file. the main in plugin.yml and the folder structure. For example: Code: Example: --- src --- Legoboy --- Example --- Main.php --- AnotherClass.php --- plugin.yml In the structure above, main inside the plugin.yml should be: Code: main: Legoboy\Example\Main And the namespace code should be: PHP: <?phpnamespace Legoboy\Example;//Code here. 3. Code error. WTF is this? Come on. Every programming language will out put an HUMAN READABLE error so that we can fix it, obviously. Here is one error for you to think of: Code: UndefinedVariableException: "Undefined variable: hi" (E_NOTICE) in "/plugins/Example/src/Legoboy/Example/Main" at line 18 What is this error about? Oh. Obviously PM has a massive bug! Go on GitHub and report the issue, then open a thread named "PM MASSIVE ISSUE". Now, lets be serious. Read the first word in the message: UndefinedVariableException. Un-defined variable. A variable has not been defined. It even mentions which file and which line the error occurs in!!! *facepalm* 4. Two PHP files. Simple. They are classes, not files. http://forums.pocketmine.net/threads/create-two-php-files-in-a-plugin.12728/ 5. Any things? Comment below!!! Simple advice: Additional resources: http://forums.pocketmine.net/threads/debugging-cheat-sheet.4532/ Like and DON'T follow if you think this helped you!
Also note this slightly outdated debugging cheatsheet. Simple reason why 323 is wrong: 323*2=646, rotate 4 and you will get a 6. Whoever writes $block->getId() === 323 is a beast of 666.
Actually, there are very few. I actually tried using them in my first old API plugins, but at that time I only knew $GLOBALS and PocketMine disabled it
Why does everyone on PocketMine hate IDs? IDs are shorter and better to mind (because everybody has different calls to an item/block).
We are saying that people are checking a block ID to be an item ID, because they copied code. It is definitely most efficient to check by ID, (and damage if you need).
can anyone explain why 1 is bad and what is a hotfix then if you say 1 is bad?(if there no hot fix i guess that is the only way we will roll)
http://programmers.stackexchange.com/q/70270/234322 Read this question about how to write clean PHP code!
My name is saed.i downloaded netbeans and I like make plugin but I don't know to use which codes to make plugin. Please help me.(sorry for my bad English).