How to make plugin for Craftsman
- Get link
- X
- Other Apps
Hello there I am PAgaming An Indian Minecraft youtuber and gamer
Today I will teach yah all how to make your own plugin for Craftsman/Mastercraft/Minecraft
But in this video I will specially tell you how to make plugin for pocketmine
It's Very necessary to know some basic features first before making a plugin like event handling, command handler, learning pocketmine etc
Ok so I will give you a link to learn some basics first click here.. https://malink.in/vD13Dpe and then you will learn a lot of new things
Ok so let's assume you have learnt all the basics from the link I have given but as you all know writing a code is too much hard and time taking specially in cases like plugin development
Here I will tell you also
How to make plugin without coding
Ok so again let's come to our point, first of all you all need to setup plugin idea in mind, like what is the topic of your plugin and what should it do let's suppose I am making a plugin where if player type /op (player) then he get kicked after 3 warnings and the warning message looks like this :- Don't try to execute illegal command \n you got the warning {warning number}/3
Ok so it's the warning message and if the 3 tries reaches out then server kick that player by saying this :- You have been kicked for typing illigal commands after many warnings
Do just like this you have to decide all things which happen in code first
Like error messages it's functionality etc then all you have to do is open Chat Gpt and paste your all prompt request there
And say it to generate codes for your api version of pocketmine
What is API?
Api ,to understand it let's assume it's a version of pocketmine basically there are different types of api which supports different game version of pocketmine like
Api 2.0.0 is for mcpe version 0.14.3-0.15.10
Api 3.0.0 is for mcpe version 1.1.1-1.1.7
And vice versa you can search for api of different game version at chat gpt
How's the final message looks like that you will request from chat gpt
Hii chat gpt pls generate a plugin for me in php7 language for api 2.0.0 make the plugin full optimised so that it not cause any lag.. ok so in this code you have add a feature where if player try to execute /op (player) then he get a warning message 3 times and after that he get kicked from server if 3 warning get exceeds by him
that warning message looks like this §ayou executed an illegal command and get your (warning number)/3 warning
And the kick message looks like this §e{player name} §7 you get kicked for executing illigal commands after getting warnings
Ok gpt pls generate it for me and use onplayercommandpreprocess for command purpose and as you know onplayercommandpreprocess not directly listen to command so make it that it directly listen to it
Ok so now you think what is the §7 §e §a here actually it's the symbol which can change the colour of your message
To change message colours you can use §a-§f
And §1-§0
And now you think of another thing what is php7 here actually all the codes for different game version should be written in different php languages like if I want to generate codes for latest version then I cannot type any php7 etc version if it's for 0.15.10 or 0.14.3 we use php7 and if it's for 1.1.5 then we use php7+
The last and biggest issue that you will find here is what is onplayercommandpreprocess?
So actually if you are generating code for craftsman 0.14-0.15 plugin then onplayer command purpose didn't work you have to use onplayercommandpreprocess instead of that
You will learn what is these terms in the guide that I gave you above
Ok so now your plugin source code is generated now you have to generate plugin.yml
plugin.yml is again a very necessary file where all your plugin general information gets stored
It's looking like this
name: ExamplePlugin
main: ExamplePlugin\Main
version: 1.0.0
api: 2.0.0
author: YourName
description: A simple example plugin for PocketMine-MP.
commands:
example:
description: An example command.
usage: "/example"
permission: exampleplugin.command.example
permissions:
exampleplugin.command.example:
description: Allows the use of the /example command.
default: true
Ok so here I hope you get everything if you don't know how to write these .yml so you just have to do is
Copy and paste this that I am giving you in plugin.yml section
name: your_plugin_name
api: 2.0.0 # your api version
Version: 12.1.0 # it should be anything you want as it's version
author: PAgamingOP # your name
main: Yourpluginnamespace\Main
Ok so here you are seeing a namespace now what is this and what is this Main here?
namespace is the name of final folder where your Main.php is kept and Main stands for Main.php if you write your source code in xyz.php then instead of Main you will write main: yourpluginnamespace\xyz
Now to make it clear let's see what your plugin structure looks like
Your plugin name (📂)
├── src (📂) and plugin.yml (🗄️)
└── Subscribe (📁) #this is namespace
├── Main.php (🗄️)
Ok so your structure is completed here 📂 stands for folder and 🗄️ stands for file
Ok so now let's see how's our Main.php look like with the Main.php source code file and Subscribe namespace
<?php
namespace Subscribe
use ............
use ............
use .............
Class Main extends pluginbase
Ok so here our plugin development course completed let's see a quick summary but before that make sure you are using devtools plugin to make that plugin execute without in phar format
Creating a plugin for PocketMine-MP involves several key steps:
1. Set Up Your Development Environment: Ensure you have PHP installed and a good code editor like Visual Studio Code. You'll also need PocketMine-MP and its API documentation.
2. Create Your Plugin Folder: Start by creating a new folder for your plugin. Inside, create a `src/` directory for your PHP files and a `plugin.yml` file to define your plugin's metadata.
3. Define Your Plugin in `plugin.yml`: This file describes your plugin's name, version, main class, commands, and permissions. It’s essential for PocketMine to recognize and load your plugin.
4. Write Your Main Class: In the `src/` directory, create a PHP file for your main plugin class, typically named `Main.php`. This class should extend `PluginBase` and include essential methods like `onEnable()` and `onDisable()` to control your plugin’s behavior when the server starts or stops.
5. Implement Plugin Features: Add event listeners, commands, and other logic to make your plugin functional. For example, you can listen for player actions, create custom commands, or interact with the game world.
6. Test Your Plugin: Load your plugin onto a PocketMine server and test it thoroughly to ensure it works as expected. Debug any issues that arise.
7. Package and Share: Once your plugin is complete, you can package it for distribution by including a README and LICENSE file, then share it with the community.
Creating plugins for PocketMine-MP is a great way to customize and enhance your Minecraft server. By following these steps, you can develop and deploy your own unique features.
- Get link
- X
- Other Apps
Comments
Post a Comment