Skip to content

Instantly share code, notes, and snippets.

@zhuowei
Created May 17, 2013 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhuowei/5596536 to your computer and use it in GitHub Desktop.
Save zhuowei/5596536 to your computer and use it in GitHub Desktop.
Tap obsidian to teleport to Nether world on PocketMine
<?php
/*
__PocketMine Plugin__
name=NetherQuick
description=Tap on obsidian to go to the second world loaded or to the default world if already in second world
version=1.0
author=zhuowei
class=NetherQuick
apiversion=7
*/
/*
Small Changelog
===============
1.0: Initial release
*/
class NetherQuick implements Plugin{
private $api;
public function __construct(ServerAPI $api, $server = false){
$this->api = $api;
}
public function init(){
$this->api->addHandler("player.block.touch", array($this, "touchHandler"), 15);
}
public function touchHandler($data, $event) {
$dataTarget = $data["target"];
if ($dataTarget->getID() === OBSIDIAN) {
if ($data["player"]->level !== $this->api->level->getDefault()) {
$data["player"]->teleport($this->api->level->getDefault()->getSpawn());
} else {
$data["player"]->teleport($this->api->level->get("nether")->getSpawn());
}
return false;
}
return true;
}
public function __destruct(){
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment