Skip to content

Instantly share code, notes, and snippets.

View jasonw4331's full-sized avatar

Jason Wynn jasonw4331

View GitHub Profile
@jasonw4331
jasonw4331 / plugin.yml
Last active September 6, 2018 17:03
Test - Auto-generated gist plugin stub by pmt.mcpe.me InstaPlugin
name: Temp
author: "jasonwynn10"
version: 0.1.0
api:
- 2.1.0
- 3.0.0-ALPHA1
- 3.0.0-ALPHA2
- 3.0.0-ALPHA3
- 3.0.0-ALPHA4
- 3.0.0-ALPHA5
@jasonw4331
jasonw4331 / PngToPlayer.php
Last active August 3, 2018 21:26
Set a player's skin in PMMP
<?php
$path = 'your/path/to/skin.png';
$img = @imagecreatefrompng($path);
$bytes = '';
$l = (int)@getimagesize($path)[1];
for ($y = 0; $y < $l; $y++) {
for ($x = 0; $x < 64; $x++) {
$rgba = @imagecolorat($img, $x, $y);
<?php
/**
* Event call is of very low importance and should be ran first, to allow
* other plugins to further customise the outcome
*/
const LOWEST = 5;
/**
* Event call is of low importance
*/
const LOW = 4;
<?php
#Adding NBT tag "test" (string), which has a value of "hey"
/** @var Item $item */
$nbt = $item->getNamedTag() ?? new CompoundTag("", []);
$nbt->test = new StringTag("test", "hey");
$item->setNamedTag($nbt);
#If item has NBT tag "test", do something
/** @var Item $item */
@jasonw4331
jasonw4331 / MyPlugin.php
Last active April 18, 2017 23:50 — forked from shoghicp/MyPlugin.php
Example of new plugin format aimed for easy scripting.
<?php
/**
* This file is an example of a compressed plaintext plugin format for PocketMine
* It's aimed towards easy scripting, but not for normal plugin development.
*
* This kind of plugin won't be able to embed/load resources,
* nor have access to some features like fast permission/command integration.
*
* This first comment is used to define the properties like on plugin.yml,
@jasonw4331
jasonw4331 / commands.md
Last active April 1, 2017 20:15 — forked from shoghicp/commands.md
Some interesting commands to play with item NBT.

Items with custom name

give jasonwynn10 stick 1 {display:{Name:"§r§6§lNormal stick"}}

Items with enchantments

give jasonwynn10 stick 1 {ench:[{id:12s,lvl:10s}]}
@jasonw4331
jasonw4331 / WorldShift.php
Last active May 2, 2017 17:32
A PocketMine Plugin script which allows players to teleport across worlds
<?php
/**
* @name WorldShift
* @main jasonwynn10\WorldShift\MainClass
* @version 0.1.0
* @api 3.0.0-ALPHA5
* @description A script to allow teleportation across worlds
* @author jasonwynn10
*/
<?php
public function fixBlockIds() {
foreach($this->blocks as $k => $block) {
$replace = null;
switch($block->getId()) {
case 126:
$replace = Block::get(Block::WOOD_SLAB, $block->getDamage());
break;
case 95:
$replace = Block::get(Block::GLASS);
@jasonw4331
jasonw4331 / translate.php
Last active July 27, 2019 23:32
Simple translation function which utilises google translate's API
<?php
declare('KEY','insert google API key here');
function translate($langA, $langB, $text){
$json = json_decode(file_get_contents('https://translation.googleapis.com/language/translate/v2?key='.KEY.'&q=' . urlencode($text) . '&target=' . $langB . '&format=text'));
$translated_text = $json->data->translations[0]->translatedText;
return $translated_text;
}
public function foo(){

How it works

How a Virion is developed

  • The library is identified by a species, which is a namespace unique to the library. The namespace must not be a super-namespace for other libraries or plugins in the future. The species should contain the author name (or organization name), a namespace separator (backslash ), then the library name. For the library name, the longer the better.
  • All classes, namespace constants and namespace functions declared by the library must be under the namespace of the species, or its sub-namespaces.
  • Use of global variables is strongly discouraged, except for temporary global variables (where the global variable can be safely deleted or overwritten when another plugin executes something).
  • How to support use of resource files in libraries is not finalized yet.

How a Virion is debugged