-
Notifications
You must be signed in to change notification settings - Fork 0
Intro
padreon edited this page Jun 2, 2018
·
12 revisions
Disini saya akan mengajarkan tentang dasar-dasar pembuatan plugin PocketMine-MP
Pertama yang harus disiapkan adalah sebuah software untuk menulis code, saya biasanya memakai Notepad++
Struktur dalam plugin Pocketmine
| Nama Plugin | |||
| plugin.yml | |||
| src | |||
| Padreon | |||
| Main.php | |||
| resource | |||
| config.yml |
name: NamaPlugin
author: Padreon
api: [3.0.0, 3.0.0-alpha6]
version: 1.0
main: Padreon/Main
#Untuk plugin yg memakai command
command:
test:
description: Deskripsi
usage: /test
test1:
description: Deskripsi
usage: /test1
permissions:
cmdname.command:
default: true
#bisa true/op
cmd2name.command:
default: true
<?php
namespace Padreon
use pocketmine\plugin\PluginBase;
use pocketmine\event\player\PlayerJoinEvent;
use pocketmine\event\player\PlayerQuitEvent;
use pocketmine\Player;
use pocketmine\Server;
use pocketmine\event\Listener;
use pocketmine\utils\TextFormat;
class Main extends PluginBase implements Listener{
public function onLoad(){
$this->getLogger()->info("Plugin Loading");
}
public function onEnable(){
$this->getServer()->getPluginManager()->registerEvents($this,$this);
$this->getLogger()->info("Enabled Plugin");
}
public function onDisable(){
$this->getLogger()->info("Plugin Disabled");
}
public function onJoin(PlayerJoinEvent $event){
$player = $event->getPlayer();
$name = $player->getName();
$this->getServer()->broadcastMessage(TextFormat::GREEN."$name Joined The server Adreon Network");
public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) : bool {
if($cmd->getName() == "test"){ #Nama command nya /test
$sender->sendMessage("Saya menggunakan command /test"); # dan akan mengirim pesan Saya menggunakan command /test
}
return true;
if($cmd->getName() == "test1"){
$sender->getInventory()->addItem(Item::get(1,0,2)); //1 = adalah id block dari stone
$sender->sendMessage(TextFormat::BOLD."Kamu mendapatkan stone");
}
return true;
}
}