Tired of same old boring kits? try this!
Every kit has it's own ability, which you can do by doing certain things like right clicking
an item in hand or hitting another player, these are called "modes".
Each kit can also be configured to a custom cooldown, items, effects, commands, etc...
All kits that come with this plugin require a special configurable item to activate the ability, except for iceman.
All kit permissions are set to gear.<the kits name all lowercase>
/gear <kit name>
/gear
it will show all kits available to the sender./gear reset
Example:
ability_item: 288:0:1:&bAcrobat &a| Click with this to use ability
cooldown: 10s
deactivate_time: -1s
helmet: "298:0:1:default"
chest: 299:0:1:default:protection:1
legs: "300:0:1:default"
items:
- 268:0:1:default:sharpness:1
commands:
- tell @player &5You equipped the @kit kit.
effects:
- strength:1:30
id:damage:amount:display name:enchanments...
example (Diamond sword with sharpness & unbreaking): 276:0:1:default:sharpness:4:unbreaking:3
other: if display name is set to default
the item display name will be set to it's default minecraft name.
The enchantments are optional.
@player
and the kit name with @kit
effect name:amplifier:duration in seconds
strength:1:30
integer(s) followed by the letter(s) for each time frame.
y
w
d
no
h
m
s
1m30s
1w3d
1y3mo
First create a class which extends the Gears\Kit\Kit
class:
namespace mykitsplugin;
use Gears\Kit\Kit;
class MyCustomKit extends Kit{
}
in the class constructor call the parent constructor with your kit configuration:
namespace mykitsplugin;
use pocketmine\item\Item;
use Gears\Kit\Kit;
class RandomTeleportKit extends Kit{
public function __construct(){
$kitName = "RandomTeleportKit";
$specialItem = Item::get(345, 0, 1); //compass
$items = [
Item::get(276, 0, 1) // diamond sword
]; // generic items
$clickMode = Kit::ALL_CLICK_MODE; // check all click modes in the Kit class
$coolDown = 30; // in seconds
$deactivateTime = -1; // in seconds, not needed in this case
parent::__construct($kitName, $specialItem, $items, $clickMode, $coolDown, $deactivateTime);
}
}
Now add the onUseSpecialItem
function:
namespace mykitsplugin;
use pocketmine\item\Item;
use Gears\Kit\Kit;
class RandomTeleportKit extends Kit{
public function __construct(){
$kitName = "RandomTeleportKit";
$specialItem = Item::get(345, 0, 1); //compass
$items = [
Item::get(276, 0, 1) // diamond sword
]; // generic items
$clickMode = Kit::ALL_CLICK_MODE; // check all click modes in the Kit class
$coolDown = 30; // in seconds
$deactivateTime = -1; // in seconds, not needed in this case
parent::__construct($kitName, $specialItem, $items, $clickMode, $coolDown, $deactivateTime);
}
public function onUseSpecialItem(array $data){
}
}
The $data
argument is different for each mode, check the plugin kits for examples.
Now make sure the string tag named kit_name
from the special item is equal to your kits name,
check the cooldown, then you can make things work your way.
You can also use $this->getGearsInstance()
to get the instance of the plugin's base.
namespace mykitsplugin;
use pocketmine\item\Item;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\Player;
class RandomTeleportKit extends Kit{
public function __construct(){
$kitName = "RandomTeleportKit";
$specialItem = Item::get(345, 0, 1); //compass
$items = [
Item::get(276, 0, 1) // diamond sword
]; // generic items
$clickMode = Kit::ALL_CLICK_MODE; // check all click modes in the Kit class
$coolDown = 30; // in seconds
$deactivateTime = -1; // in seconds, not needed in this case
parent::__construct($kitName, $specialItem, $items, $clickMode, $coolDown, $deactivateTime);
}
public function onUseSpecialItem(array $data){
$player = $data['Player'];
$item = $data['Item'];
if(($player instanceof Player) and ($item instanceof Item)){
if(!$item->hasCustomBlockData()) return false;
/** @var CompoundTag $data */
$data = $item->getCustomBlockData();
if(!$data->hasTag("kit_name")) return false;
if(strtolower($data->getString("kit_name")) === "randomteleportkit"){
if($this->checkCoolDown($player)){
$randomX = mt_rand(0, 1000);
$randomY = mt_rand(0, 256);
$randomZ = mt_rand(0, 1000);
$v3 = new Vector3($randomX, $randomY, $randomZ);
$safeSpawn = $player->level->getSafeSpawn($v3);
$player->teleport($safeSpawn);
}
}
}
return true;
}
}
Finally register the kit to the kit manager from your plugin, make sure to have the server instance.
$randomTeleportKit = new RandomTeleportKit();
$plugin = $server->getPluginManager()->getPlugin('Gears');
if($plugin !== null){
$plugin->getKitManager()->registerKit($randomTeleportKit);
}
You can also optionally add the following functions to your custom kit:
onQuit()
called when player quits the server.onDeath()
called when player dies.onUnload()
called when player unloads the kit.