Last active
October 9, 2017 10:56
-
-
Save jwulf/17c6151ee47c7972f3523d84f5f52e78 to your computer and use it in GitHub Desktop.
Magikcraft Spells, by jwulf.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function _0() { | |
magik.doAfter(2, () => console.log('Hello')); | |
magik.Events.on('CreatureSpawnEvent', evt => magik.dixit(evt.getEntity().getName())); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function _fb(n=10) { | |
magik.doNTimes(()=> magik.infierno(), n, 300); | |
magik.dixit('FIREBALLZ!!'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Do = require('magikcraft-lore-do').Do; | |
const magik = magikcraft.io; | |
function _sb() { | |
Do(20).times(magik.viburnum).withDelay(300).now(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function a() { | |
const x = 5; | |
const y = 3; | |
const logan = 12; | |
const z = x + logan; | |
// What is x? | |
http.get('http://www.google.com', (err, result) => { | |
if (err) { | |
magik.dixit("Error!"); | |
magik.dixit(err.toString()); | |
} | |
magik.dixit("Result"); | |
magik.dixit(result.toString()); | |
}) | |
magik.dixit("Sebastien"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var magik = magikcraft.io; | |
// anvil rain | |
// | |
//TODO: is runif better than rnom? | |
function arain(radius, typ){ | |
radius = parseInt(radius) || 20; | |
typ = typ || "ANVIL"; | |
const a = d; | |
a =3; | |
for (var i = 0; i < 200; i++) { | |
rndAnvil(radius, typ); | |
} | |
} | |
function rndAnvil(radius,typ) { | |
var height = radius; | |
rndBlock(radius, height).setType(org.bukkit.Material[typ]) | |
} | |
// Standard Normal variate using Box-Muller transform. | |
//http://stackoverflow.com/questions/25582882/javascript-math-random-normal-distribution-gaussian-bell-curve | |
function randn_bm() { | |
var u = 1 - Math.random(); // Subtraction to flip [0, 1) to (0, 1]. | |
var v = 1 - Math.random(); | |
return Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v ); | |
} | |
function rnorm_unit(count) { | |
var ret = 0; | |
for (var i = 0; i < count; i++) { | |
ret += Math.random(); | |
} | |
return ret/count; | |
} | |
function rnorm(mean, sd) { | |
return randn_bm() * sd + mean; | |
} | |
function runif(from, to) { | |
return scale(Math.random(), from, to); | |
} | |
function scale(r, from, to) { | |
return Math.floor(r*(to - from)+from) | |
} | |
function rndBlock(radius, height) { | |
return magik.getSender().location.getBlock().getRelative(rnorm(0, radius/5), height+runif(0, radius*3), rnorm(0, radius/5)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function blink() { | |
const there = magik.aspecto(); | |
magik.ianuae(there); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Border mini-game | |
* | |
* This is a cool little mini-game where the world border | |
* shrinks, and you have to stay inside it to stay alive. | |
* | |
* Note: to play, you need to add magikcraft-lore-ui-bar to your package.json file. | |
* | |
* Usage: | |
* /cast border - start a new game | |
* /cast border <number> - specify the initial border size (deault is 200) | |
* /cast border reset - stop a game in-progress | |
* | |
*/ | |
const magik = magikcraft.io; | |
const { bar, color, style } = require('magikcraft-lore-ui-bar'); | |
const finalsize = 5; | |
const blocksPerSecond = 5; | |
const STATE = { | |
PROGRESS: 'border.game.progress', | |
RUNNING: 'border.game.mutex', | |
BAR: 'border.game.persistence.bar', | |
LISTENER: 'border.game.progress.listener' | |
}; | |
const TEXT = { | |
INITIAL: 'RUN 4 YR LYFE!!!', | |
HALFWAY: 'HURRY!!', | |
URGENT: 'HURRY!!!!!!!', | |
GAMEOVER: 'GAME OVER!' | |
}; | |
function border(size = 200) { | |
if (size == 'reset') { | |
// Use this to halt a game | |
gameOver(); | |
return; | |
} | |
if (size == 'clear') { | |
// Use this when the UI bar has disappeared | |
magik.playerMap.remove(STATE.BAR); | |
magik.playerMap.remove(STATE.LISTENER); | |
return; | |
} | |
magik.dixit('Setting up...'); | |
function getBar() { | |
if (magik.playerMap.containsKey(STATE.BAR)) { | |
// Return a reference to the existing UI Bar | |
return magik.playerMap.get(STATE.BAR); | |
} else { | |
// Or create a new UI bar | |
magik.dixit('Creating UI bar...'); | |
const _b = bar(); | |
// Stash a reference to it | |
magik.playerMap.put(STATE.BAR, _b); | |
return _b; | |
} | |
} | |
const b = getBar() | |
.text(TEXT.INITIAL) | |
.color(color.GREEN) | |
.style(style.NOTCHED_20) | |
.progress(100) | |
.show(); | |
function getBorder() { | |
return magik.getSender().getWorld().getWorldBorder(); | |
} | |
function initialiseBorder() { | |
const border = getBorder(); | |
const here = magik.hic(); | |
const zDelta = Math.random() * 100 - 50; | |
const xDelta = Math.random() * 100 - 50; | |
here.setZ(here.getZ() + zDelta); | |
here.setX(here.getX() + xDelta); | |
border.setCenter(here); | |
border.setSize(size); | |
return border; | |
} | |
function shrink(border) { | |
const newSize = border.getSize() - blocksPerSecond; | |
if (newSize === finalsize) { | |
magik.clearInterval(loop); | |
} | |
const barProgress = ((newSize - finalsize) / size) * 100; | |
eventbus.publish(STATE.PROGRESS, barProgress); | |
border.setSize(newSize); | |
return newSize; | |
} | |
function endGame(countdown) { | |
if (countdown < 0) { | |
magik.setTimeout(() => endGame(countdown + 1), 1000); | |
eventbus.publish(STATE.PROGRESS, countdown); | |
} else { | |
gameOver(); | |
} | |
} | |
function gameOver() { | |
magik.dixit('Game Over!'); | |
getBorder().setSize(600000); | |
magik.globalMap.put(STATE.RUNNING, false); | |
eventbus.publish(STATE.PROGRESS, false); | |
getBar().text(TEXT.GAMEOVER).progress(0); | |
} | |
function listenProgress(msg) { | |
const barProgress = msg.data; | |
// magik.getSender().sendMessage(msg); | |
const b = magik.playerMap.get(STATE.BAR); | |
if (barProgress == 0) { | |
endGame(-10); | |
return; | |
} | |
if (barProgress < 0) { | |
// Final countdown | |
b.color(color.PURPLE) | |
.progress(-barProgress * 10) | |
.text(`Safe in ${-barProgress}s`); | |
return; | |
} | |
if (barProgress > 50) { | |
b.color(color.GREEN) | |
.progress(barProgress) | |
.text(TEXT.INITIAL); | |
return; | |
} | |
if (barProgress < 50) { | |
b.color(color.YELLOW) | |
.progress(barProgress) | |
.text(TEXT.HALFWAY); | |
return; | |
} | |
if (barProgress < 25) { | |
b.color(color.RED) | |
.progress(barProgress) | |
.text(TEXT.URGENT); | |
return; | |
} | |
} | |
function isRunning() { | |
if (magik.globalMap.containsKey(STATE.RUNNING)) { | |
return magik.globalMap.get(STATE.RUNNING); | |
} else { | |
return false; | |
} | |
} | |
function startGame() { | |
joinGameTopic(); | |
if (isRunning()) { | |
magik.dixit('Game running, I\'ved joined!'); | |
return; | |
} | |
const border = initialiseBorder(); | |
magik.globalMap.put(STATE.RUNNING, true); | |
magik.dixit('Let the game begin!'); | |
return magik.setInterval(() => shrink(border), 1000); | |
} | |
function joinGameTopic() { | |
if (magik.playerMap.containsKey(STATE.LISTENER)) { | |
return magik.playerMap.get(STATE.LISTENER); | |
} else { | |
const listener = eventbus.subscribe(STATE.PROGRESS, listenProgress); | |
magik.playerMap.put(STATE.LISTENER, listener); | |
return listener; | |
} | |
} | |
// Start a game if one isn't running | |
const loop = startGame(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// LoL! | |
const magik = magikcraft.io; | |
const strings = require("testing"); | |
function BrisJS() { | |
strings.forEach(s => magik.dixit(s)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function call(module, spell = '_default') { | |
let char; | |
[':', '.'].forEach(_char => { | |
if (module.indexOf(_char) != -1) { | |
char = _char; | |
} | |
}); | |
if (char) { | |
const _args = module.split(char); | |
module = _args[0]; | |
spell = _args[1]; | |
} | |
require(module).spells[spell](); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Capture a video of your movement in Minecraft. | |
*/ | |
const magik = magikcraft.io; | |
function cam_capture(seconds = "--help", fps = 20) { | |
if (seconds === "--help") { | |
magik.dixit("Usage: /cast cam_capture [secs]"); | |
magik.dixit("Usage: /cast cam_capture [secs] [fps]"); | |
return; | |
} | |
global.film = {}; | |
film.frames = []; | |
film.metadata = { | |
fps, | |
seconds | |
}; | |
const interval = 1000 / fps; | |
const totalFrames = fps * seconds; | |
magik.dixit(`Recording ${seconds}s at ${fps} fps`); | |
let count = 0; | |
const camera = magik.setInterval(()=>{ | |
const location = magik.getSender().getLocation(); | |
film.frames.push(location); | |
count ++; | |
if (count > totalFrames) { | |
magik.clearInterval(camera); | |
magik.dixit('Finished recording!'); | |
} | |
}, interval); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Replay a sequence recorded with cam_capture. | |
* Optionally takes a playback speed, for example: | |
* /cast cam_replay(2) for 2x playback. | |
* Cast cam_replay while it is replaying to halt playback. | |
*/ | |
const magik = magikcraft.io; | |
magik.dixit('Replaying...'); | |
function cam_replay(speedx = 1) { | |
// Cancel playback if we're called while replaying | |
// Doesn't work, because you can't cast anything during playback | |
// because teleporting | |
if (global._playing == true) { | |
global._cancelPlayback = true; | |
global._playing = false; | |
magik.dixit('Cancelling playback...'); | |
return; | |
} | |
const film = global.film; | |
const { fps } = film.metadata; | |
// Scale playback rate | |
magik.dixit(`Playing at ${speedx}x`); | |
const interval = 1000 / (fps * speedx); | |
global._cancelPlayback = false; | |
global._playing = true; | |
const playback = film.frames.map((frame, index) => { | |
magik.setTimeout(function (){ | |
magik.ianuae(frame); | |
// This allows us to cancel playback mid-way through | |
if (global._cancelPlayback) { | |
playback.forEach(frame => magik.clearTimeout(frame)); | |
global._playing = false; | |
global._cancelPlayback = false; | |
} | |
}, interval * index); | |
}); | |
// This final task resets the system state to "not playing" | |
playback.push(magik.setTimeout(() => { | |
global._cancelPlayback = false; | |
global._playing = false; | |
}, interval * playback.length)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function cl() { | |
const Material = magik.type('Material'); | |
const world = magik.getSender().getWorld(); | |
function p5() { | |
const x0 = looking.getX(); | |
const y0 = looking.getY(); | |
const z0 = looking.getZ(); | |
function blast(X,Z, Y) { | |
const looking = magik.aspecto(); | |
const location = looking; | |
location.setX(X); | |
location.setZ(Z); | |
world.strikeLightning(location); | |
let b = world.getBlockAt(location); | |
while(b.getType().equals(Material.AIR)){ | |
Y--; | |
location.setY(Y); | |
b = location.getBlock(); | |
} | |
world.getBlockAt(location).setType(Material.OBSIDIAN); | |
} | |
const r = 8; | |
const items = 40; | |
for(let i = 0; i < items; i++) { | |
const x = x0 + r * Math.cos(2 * Math.PI * i / items); | |
const z = z0 + r * Math.sin(2 * Math.PI * i / items); | |
blast(x,z,y0); | |
} | |
} | |
// const x = looking.getX(); | |
// const y = looking.getY(); | |
// const z = looking.getZ(); | |
function blast() { | |
const looking = magik.aspecto(); | |
const X = looking.getX(); | |
const Y = looking.getY(); | |
const Z = looking.getZ(); | |
const location = looking; | |
location.setX(X + Math.random() * 10 - 5); | |
location.setZ(Z + Math.random() * 10 - 5); | |
world.strikeLightning(location); | |
} | |
magik.doNTimes(() => { | |
magik.doNTimes(() => { | |
magik.doNTimes(() => {blast()}, 15, 500)}, | |
15)}, | |
15, p5); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function clearTimers() { | |
magik.getPlugin().scheduler.cancelAllTasks(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function comet(){ | |
const Fireball = magik.type('entity.Fireball'); | |
const TNT = magik.type("entity.EntityType").PRIMED_TNT; | |
const sender = magik.getSender(); | |
//var arrow = player.getWorld().spawnEntity(sender.location, org.bukkit.entity.EntityType.ZOMBIE); | |
for (var i = 0; i < 50; i++) { | |
const loc = rndBlock(15,15).location; | |
const arrow = sender.getWorld().spawnEntity(loc, TNT); | |
//arrow.setShooter(sender); | |
var v = sender.getEyeLocation().getDirection().multiply(2); | |
v.setX(0); | |
v.setY(0); | |
v.setZ(0); | |
//magik.dixit(loc); | |
arrow.setVelocity(v); | |
//arrow.setMetadata("ArrowType", new MyMetadata(this, "stick")); | |
} | |
} | |
function randn_bm() { | |
const u = 1 - Math.random(); // Subtraction to flip [0, 1) to (0, 1]. | |
const v = 1 - Math.random(); | |
return Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v ); | |
} | |
function rnorm_unit(count) { | |
let ret = 0; | |
for (let i = 0; i < count; i++) { | |
ret += Math.random(); | |
} | |
return ret/count; | |
} | |
function rnorm(mean, sd) { | |
return randn_bm() * sd + mean; | |
} | |
function runif(from, to) { | |
return scale(Math.random(), from, to); | |
} | |
function scale(r, from, to) { | |
return Math.floor(r*(to - from)+from) | |
} | |
function rndBlock(radius, height) { | |
return magik.getSender().getLocation().getBlock().getRelative(rnorm(0, radius/5), rnorm(0, radius/5), rnorm(0, radius/5)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function countdown(time = 60) { | |
const bars = magik.Bars.addBar(magik.getSender(), magik.TextComponent("Countdown!"), magik.Bars.Color.GREEN, magik.Bars.Style.NOTCHED_20, 0.99); | |
let progress = 0.99; | |
magik.setInterval(()=> { bars.setProgress(progress); progress -= 0.01 }, 1000); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var magik = magikcraft.io; | |
//debug | |
function d(spell){ | |
let thing= magik; //magik.dixit | |
//thing = keys.map(function(k) {return magik[k].toString();}); //obviously going to be too long | |
const keys = getKeys(magik); | |
if (isNumeric(spell)) { | |
thing = magik[keys[parseInt(spell)]]; | |
} else if (typeof(spell) == 'string') { | |
thing = magik[spell]; | |
if (typeof(thing) == 'undefined') { | |
thing = eval(spell); | |
/*if (typeof(thing) == 'object') { | |
magik.dixit("nested"); | |
thing = getKeys(thing); | |
}*/ | |
} | |
} else { | |
thing = keys; | |
} | |
const msg = thing.toString(); | |
magik.dixit(msg); | |
magik.dixit(encodeURI("http://abznak.com/echo?q="+msg)); | |
} | |
function getKeys(obj) { | |
var keys = []; | |
for (var key in obj) { | |
// if (obj.hasOwnProperty(key)) { | |
keys.push(key); | |
// } | |
} | |
return keys; | |
} | |
function isNumeric(n) { | |
return !isNaN(parseFloat(n)) && isFinite(n); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var magik = magikcraft.io; | |
magik.dixit('Initiating Game Loop'); | |
if (gameloop) { | |
magik.clearInterval(gameloop); | |
} | |
let T1, BossBarAPI; | |
var gameloop = magik.setInterval(doLoop, 1000); | |
function doLoop() { | |
const state = T1.state; | |
let bgl = T1.state.bgl; | |
const insulinOnBoard = T1.state.insulinOnBoard; | |
const carbsOnBoard = T1.state.carbsOnBoard; | |
const insulinAbsorptionRate = insulinOnBoard / 80 + 0.0025; | |
if (insulinAbsorptionRate>0){ | |
// magik.dixit("AbsorptionRate: " + insulinAbsorptionRate); | |
} | |
// do Insulin Absorption | |
if (insulinOnBoard > 0) { | |
const newInsulin = insulinOnBoard - insulinAbsorptionRate; | |
if (newInsulin > 0) { | |
T1.state.insulinOnBoard = newInsulin; | |
} else { | |
T1.state.insulinOnBoard = 0; | |
} | |
// do BGL Absorption | |
if (T1.state.bgl > 0) { | |
const bglAbsorbed = insulinAbsorptionRate * 0.8; | |
const newBGL = T1.state.bgl - bglAbsorbed; | |
if (newBGL > 0) { | |
T1.state.bgl = newBGL; | |
} else { | |
magik.dixit("Aaaaaarggggh!"); | |
T1.state.bgl = 0; | |
} | |
} | |
} | |
// Do BGL increase | |
if (T1.state.insulinOnBoard == 0) { | |
T1.state.bgl += 0.1; | |
} | |
// magik.dixit("Insulin: " + T1.state.insulinOnBoard); | |
const insulin = T1.state.insulinOnBoard; | |
T1.bars.insulin.setProgress(insulin); | |
bgl = T1.state.bgl; | |
T1.bars.bgl.setProgress(bgl); | |
if (bgl > 0.2 && bgl < 0.4) { | |
T1.bars.bgl.setColor(BossBarAPI.Color.GREEN); | |
} else { | |
T1.bars.bgl.setColor(BossBarAPI.Color.RED); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var magik = magikcraft.io; | |
// explode | |
function e(n=30, repeats=1, delay=200) { | |
const sender = magik.getSender(); | |
sender.getLocation().getWorld().createExplosion(magik.aspecto(),n); | |
repeats--; | |
//magik.dixit(sender.isSneaking() ? "yes" : "no"); | |
if (sender.isSneaking()) { | |
magik.dixit("e done via sneak"); | |
return; | |
} | |
if (repeats > 0) { | |
var task = magik.setTimeout( | |
() => { | |
e(n, repeats, delay); | |
}, | |
delay | |
); | |
} else { | |
magik.dixit("e done"); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function ee() { | |
const e = new EventEmitter(); | |
e.on('_event', (data) => { | |
magik.dixit(`Event triggered with ${data}`); | |
}); | |
e.emit('_event', 'test data'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function el() { | |
const Material = magik.type('Material'); | |
const world = magik.getSender().getWorld(); | |
function p5() { | |
const x0 = looking.getX(); | |
const y0 = looking.getY(); | |
const z0 = looking.getZ(); | |
function blast(X,Z, Y) { | |
const looking = magik.aspecto(); | |
const location = looking; | |
location.setX(X); | |
location.setZ(Z); | |
world.strikeLightning(location); | |
let b = world.getBlockAt(location); | |
while(b.getType().equals(Material.AIR)){ | |
Y--; | |
location.setY(Y); | |
b = location.getBlock(); | |
} | |
world.getBlockAt(location).setType(Material.OBSIDIAN); | |
} | |
const r = 8; | |
const items = 40; | |
for(let i = 0; i < items; i++) { | |
const x = x0 + r * Math.cos(2 * Math.PI * i / items); | |
const z = z0 + r * Math.sin(2 * Math.PI * i / items); | |
blast(x,z,y0); | |
} | |
} | |
// const x = looking.getX(); | |
// const y = looking.getY(); | |
// const z = looking.getZ(); | |
function blast() { | |
const looking = magik.aspecto(); | |
const X = looking.getX(); | |
const Y = looking.getY(); | |
const Z = looking.getZ(); | |
const location = looking; | |
location.setX(X + Math.random() * 10 - 5); | |
location.setZ(Z + Math.random() * 10 - 5); | |
world.strikeLightning(location); | |
world.createExplosion(looking,4); | |
} | |
magik.doNTimes(() => { | |
magik.doNTimes(() => { | |
magik.doNTimes(() => {blast()}, 15, 500)}, | |
15)}, | |
15, p5); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function evt() { | |
magik.registerEvent(Java.type("org.bukkit.event.player.PlayerItemConsumeEvent"), evt => { | |
magik.getPlugin().getServer().getPlayer('sitapati').sendMessage('hello') | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function exec(cmd) { | |
const args = [].slice.call(arguments).join(' '); | |
eval(args); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function fast() { | |
magik.celeritate(); | |
magik.getSender().setFlySpeed(1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function fb(repeats = 5, delay = 400) { | |
magik.dixit('Fireball!'); | |
const sender = magik.getSender(); | |
const fireball = magik.type("entity.Fireball").class; | |
const hurl = thing => () => sender.launchProjectile(thing) | |
const volley = () => magik.doNTimes(hurl(fireball), repeats, delay, null); | |
magik.doNTimes(volley, repeats, delay*10, null); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function fireball() { | |
magik.infierno(6); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function fireworks(name) { | |
var there = magik.aspecto(); | |
magik.doNTimes(function () { magik.stella(there); | |
magik.iacta(name);}, 1000, 300); | |
magik.iacta(name); | |
magik.stella(there); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function fly() { | |
magik.valare(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function fz() { | |
function run(cmd) { | |
var sudo = magik.getPlugin().getServer().getConsoleSender(); | |
magik.getPlugin().getServer().dispatchCommand(sudo, cmd); | |
} | |
const flyingZombieCmd = 'summon minecraft:zombie ~ ~ ~ {ArmorItems:[{},{},{id:"minecraft:elytra",Count:1b},{}]}'; | |
run(flyingZombieCmd); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function game(module, spell = '_default') { | |
const _module = `magikcraft-minigame-${module}`; | |
require(_module).spells[spell](); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
const material = org.bukkit.Material; | |
const player = magik.getSender(); | |
function gd() { | |
const X = "X"; | |
const array = [ | |
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0], | |
[0,0,0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0,0,0], | |
[0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0], | |
[0,0,0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0,0,0], | |
[0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0], | |
[0,0,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X,0,0], | |
[X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X], | |
[X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,X,X], | |
[X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X], | |
[X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X], | |
].map(row => row.map(col => { return col === X ? 'AIR' : 'BEDROCK'; })); | |
const numRows = array.length; | |
const numCols = array[0].length; | |
const height = 5; | |
for (let h = 0; h < height; h++) { | |
for (let i = 0; i < numRows; i++) { | |
for (let j = 0; j < numCols; j++) { | |
const zCoord = Math.floor(numRows / 2) - i; | |
const xCoord = Math.floor(numCols / 2) - j; | |
spawnAtPoint3d(zCoord, xCoord, h, array[i][j]); | |
} | |
} | |
} | |
} | |
function spawnAtPoint3d(zCoord, xCoord, yCoord, element) { | |
// get final location with zCoord, | |
// use final zCoord location as start location for xCoord | |
const startLocation = player.getTargetBlock(null, 100).getLocation(); | |
const zYaw = zCoord > 0 ? 0 : 180; | |
const zLocation = getFinalLocation(startLocation, zYaw, Math.abs(zCoord)); | |
const xYaw = xCoord > 0 ? 90 : -90; | |
const xLocation = getFinalLocation(zLocation, xYaw, Math.abs(xCoord)); | |
const yYaw = 0; | |
const yPitch = yCoord > 0 ? 90 : -90; | |
const yLocation = getVerticalLocation(xLocation, yYaw, Math.abs(yCoord)); | |
setBlock(yLocation, element); | |
} | |
function getVerticalLocation(startLoc, pitch, distance) { | |
const loc = startLoc; | |
loc.setPitch(-90); // straight up | |
return loc.add(loc.getDirection().setX(0).normalize().multiply(distance)); | |
} | |
function getFinalLocation(startLoc, yaw, distance) { | |
return normalizedStartLocation(startLoc, yaw).add(getDirectionToAddToStartLocation(yaw, distance)); | |
} | |
function getDirectionToAddToStartLocation(yaw, distance) { | |
const loc = player.getLocation(); | |
loc.setYaw(loc.getYaw() + yaw); | |
return loc.getDirection().setY(0).normalize().multiply(distance); | |
} | |
function normalizedStartLocation(startLoc, yaw) { | |
const loc = startLoc; | |
loc.setYaw(loc.getYaw() + yaw); | |
return loc; | |
} | |
function setBlock(location, element) { | |
location.getBlock().setType(getBlockObject(element)); | |
} | |
function getBlockObject(element) { | |
switch (element) { | |
case 'LOG': | |
return material.LOG; | |
case 'BEDROCK': | |
return material.BEDROCK; | |
case 'AIR': | |
return material.AIR; | |
} | |
} | |
function spawnObject(object, location) { | |
player.getWorld().spawn(location, object.class); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function getScriptTrace() { | |
try { | |
throw new Error(); | |
} catch (e) { | |
magik.dixit(e.stack); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
let T1; | |
function getState() { | |
magik.dixit(JSON.stringify(T1)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function ghost() { | |
const a = new magik.type('Player'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function glow(name) { | |
magik.radiatum(name); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This spell will change your game mode. | |
* It will only work if the Magikcraft server is in Creative mode. | |
*/ | |
function GM(mode="creative") { | |
const me = magik.getSender(); | |
const GameMode = Java.type("org.bukkit.GameMode"); | |
const modes = { | |
c: GameMode.CREATIVE, | |
s: GameMode.SURVIVAL, | |
x: GameMode.SPECTATOR | |
} | |
const firstChar = mode.substr(0,1) | |
const newMode = modes[firstChar]; | |
me.setGameMode(newMode) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function h() { | |
magik.dixit(__http__); | |
magik.dixit(__http__.httpGet); | |
const http = { get: __http__.httpGet}; | |
magik.dixit(http); | |
magik.dixit(http.get); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function heal(name) { | |
magik.auxilium(name); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function helloworld() { | |
magik.dixit("¡Hello Tim!"); | |
magik.doNTimes((count) => {magik.dixit(count)}, 5); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
const WonderHUD = Java.type("com.antarescraft.kloudy.wonderhudapi.WonderHUD"); | |
const HUDPosition = Java.type("com.antarescraft.kloudy.wonderhudapi.HUDPosition"); | |
const ArrayList = Java.type('java.util.ArrayList') | |
function hud() { | |
const strings = new ArrayList(); | |
["Blood Glucose: 6.7", "Insulin: 5u", "Carbohydrates: 15g"].forEach(str => strings.add(str)); | |
magik.dixit(strings.toString()); | |
WonderHUD.spawnHUD(magik.getSender(), HUDPosition.TOP_CENTER, 3, strings); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function hw() { | |
magik.dixit("Hello world"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function impersonate(newname) { | |
if (!newname) { | |
magik.dixit('Pass in a name!'); | |
return; | |
} | |
const player = magik.getSender(); | |
const world = player.getWorld(); | |
const tracker = world.tracker; | |
tracker.untrackEntity(player); | |
player.name = newname; | |
tracker.track(player); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function inspect(module) { | |
const spells = require(module).spells; | |
magik.dixit(`Module ${module} contains the following spells:`); | |
magik.dixit(Object.keys(spells)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function inspectMemory() { | |
magik.durablePlayerMap.keySet().forEach(key => magik.dixit(key)); | |
magik.dixit(`Memory has ${magik.durablePlayerMap.size()} items`); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function insulin() { | |
const item = 'POTION' | |
const AWKWARD = magik.type('potion.PotionType').AWKWARD; | |
const MATERIAL = magik.type("Material"); | |
const Potion = magik.type("potion.Potion"); | |
const i = new Potion(AWKWARD); | |
const ItemStack = magik.type("inventory.ItemStack"); | |
const thing = new ItemStack(i); | |
magik.getSender().getInventory().addItem(Potion); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var magik = magikcraft.io; | |
function jail(r, typ, force, fire) { | |
if (r == '?') { | |
magik.dixit("/cast jail <r> <typ> <force> <fire>"); | |
magik.dixit("r - radius"); | |
magik.dixit("typ - material type (e.g. FIRE, TNT)"); | |
magik.dixit("force - "); | |
magik.dixit(" 1 - replace even solid blocks"); | |
magik.dixit(" ! - replace only solid blocks"); | |
magik.dixit("fire - "); | |
magik.dixit(" 1 - set the resulting sphere on fire"); | |
magik.dixit(" o - surround the resulting sphere in obsidian"); | |
return; | |
} | |
r = parseInt(r) || 10; | |
typ = typ || 'LEAVES'; | |
var block = magik.aspecto().getBlock(); | |
drawSphere(block, r, typ, force); | |
if (fire) { | |
if (fire == 'o') { | |
drawSphere(block, r+2, 'OBSIDIAN', false); | |
} else if (fire == 'g') { | |
drawSphere(block, r+2, 'GLASS', false); | |
} else { | |
drawSphere(block.getRelative(0, 2, 0), r, 'FIRE', false); | |
} | |
} | |
} | |
function drawSphere(block, r, typ, force) { | |
const Material = magik.type("Material"); | |
sphere(block, r, function(block, x,y,z) { | |
var doit = false; | |
if (force == '1') { | |
doit = true; | |
} else { | |
doit = !block.getType().isSolid(); | |
if (force == '!') { | |
doit = !doit; | |
} | |
} | |
if (doit) { | |
block.setType(Material[typ]); | |
} | |
}); | |
} | |
function sphere(block, r, fn) { | |
var max2 = (r+1) * (r+1); | |
var min2 = (r-1) * (r-1); | |
for (var x = -r; x < r+1; x++) { | |
for (var y = -r; y < r+1; y++) { | |
for (var z = -r; z < r+1; z++) { | |
var dist2 = x*x+y*y+z*z; | |
if (min2 <= dist2 && dist2 <= max2) { | |
fn(block.getRelative(x,y,z), x,y,z); | |
} | |
} | |
} | |
} | |
} | |
function randn_bm() { | |
var u = 1 - Math.random(); // Subtraction to flip [0, 1) to (0, 1]. | |
var v = 1 - Math.random(); | |
return Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v ); | |
} | |
function rnorm_unit(count) { | |
var ret = 0; | |
for (var i = 0; i < count; i++) { | |
ret += Math.random(); | |
} | |
return ret/count; | |
} | |
function rnorm(mean, sd) { | |
return randn_bm() * sd + mean; | |
} | |
function runif(from, to) { | |
return scale(Math.random(), from, to); | |
} | |
function scale(r, from, to) { | |
return Math.floor(r*(to - from)+from) | |
} | |
function rndBlock(loc, radius, height) { | |
return loc.getBlock().getRelative(rnorm(0, radius/5), runif(0, height), rnorm(0, radius/5)); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
const jwulf = require('jwulf'); | |
let globalVar; | |
function jayz() { | |
jwulf.test(); | |
magik.dixit(`Global var: ${JSON.stringify(globalVar)}`); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function jesus(sampleRate = 50) { | |
const duration = 10000; | |
const times = duration / sampleRate; | |
let reps = 0; | |
let oldBlock; | |
const loop = magik.setInterval(function(){ | |
reps ++; | |
if (reps > times) { | |
magik.clearInterval(loop); | |
return; | |
} | |
const here = magik.hic(); | |
const block = here.getWorld().getBlockAt(here.getX(), here.getY() - 1, here.getZ()); | |
const _type = block.getType(); | |
if (_type === Material.WATER || _type === Material.STATIONARY_WATER) { | |
block.setType(Material.ICE); | |
let oldBlock = block; | |
} | |
if (oldBlock && oldBlock !== block) { | |
oldBlock.setType(Material.WATER); | |
oldBlock = undefined; | |
} | |
}, sampleRate) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function jump(power = 100) { | |
magik.exsultus(power); | |
magik.dixit("Yo, wassup dawg!"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function l() { | |
const Material = magik.type('Material'); | |
const looking = magik.aspecto(); | |
const world = magik.getSender().getWorld(); | |
function p5() { | |
const x0 = looking.getX(); | |
const y0 = looking.getY(); | |
const z0 = looking.getZ(); | |
function blast(X,Z, Y) { | |
const location = looking; | |
location.setX(X); | |
location.setZ(Z); | |
world.strikeLightning(location); | |
let b = world.getBlockAt(location); | |
while(b.getType().equals(Material.AIR)){ | |
Y--; | |
location.setY(Y); | |
b = location.getBlock(); | |
} | |
world.getBlockAt(location).setType(Material.OBSIDIAN); | |
} | |
const r = 8; | |
const items = 40; | |
for(let i = 0; i < items; i++) { | |
const x = x0 + r * Math.cos(2 * Math.PI * i / items); | |
const z = z0 + r * Math.sin(2 * Math.PI * i / items); | |
blast(x,z,y0); | |
} | |
} | |
const x = looking.getX(); | |
const y = looking.getY(); | |
const z = looking.getZ(); | |
function blast(X, Z) { | |
const location = looking; | |
location.setX(X + Math.random() * 10 - 5); | |
location.setZ(Z + Math.random() * 10 - 5); | |
world.strikeLightning(location); | |
} | |
magik.doNTimes(() => { | |
magik.doNTimes(() => { | |
magik.doNTimes(() => {blast(x,z)}, 15)}, | |
15)}, | |
15, p5); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
// lightning | |
// lpc - lightning per circle | |
// cc - circle count | |
function l2(lpc = 10, cc = 3, i = 0, delay = 100) { | |
const m = 30; | |
const sender = magik.getSender(); | |
magik.dixit("l2 - "+ m + " " + i + " " + delay); | |
const oldloc = magik.hic(); | |
const target = magik.hic(); | |
i++; | |
for (var k = 0; k < m; k++) { | |
target.setYaw(360/m*k); | |
target.setPitch(90 - i * 5); | |
magik.ianuae(target); | |
magik.shakti(); | |
} | |
if (sender.isSneaking()) { | |
magik.dixit("l2 done via sneak"); | |
return; | |
} | |
if (i < cc) { | |
var task = magik.setTimeout( | |
() => { | |
l2(lpc, cc, i, delay); | |
}, | |
delay | |
); | |
} else { | |
magik.dixit("l2 done"); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function listen() { | |
const user = magik.getSender().getName(); | |
const EventCallback = Java.type("io.magikcraft.EventCallback"); | |
const PlayerInteractEvent = magik.type("event.player.PlayerInteractEvent"); | |
const EventPriority = magik.type("event.EventPriority"); | |
magik.getPlugin().registerEvent( | |
PlayerInteractEvent.class, | |
EventPriority.MONITOR, | |
true, | |
new EventCallback({ | |
callback: function(event) { | |
const username = event.player.getName(); | |
if (username !== user) { | |
return; | |
} | |
magik.getPlugin().getServer().getPlayer(username).sendMessage(`Interact event: ${username} : ${user}`); | |
} | |
})); | |
magik.dixit(PlayerInteractEvent); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var magik = magikcraft.io; | |
function localise(lang = 'en') { | |
const nextTick = magik.setTimeout; | |
function series(arr, ready = null, safe = true) { | |
var length = arr.length | |
, orig | |
if (!length) return nextTick(ready, 1) | |
let handleItem = (idx) => { | |
arr[idx]((err) => { | |
if (err) return ready(err) | |
if (idx < length - 1) return handleItem(idx + 1) | |
return ready() | |
}) | |
} | |
if (safe) { | |
orig = handleItem | |
handleItem = (idx) => { | |
nextTick(() => { | |
orig(idx) | |
}, 1) | |
} | |
} | |
handleItem(0) | |
} | |
function run(cmd) { | |
var sudo = magik.getPlugin().getServer().getConsoleSender(); | |
magik.getPlugin().getServer().dispatchCommand(sudo, cmd); | |
} | |
const strings = [ | |
{ | |
name: 'tutorial_welcome', | |
strings: | |
{ | |
no: | |
[ | |
'Velkommen til', | |
'&6The Land of Kigam&r', | |
'i', | |
'&3The World of &4&uMagikcraft' | |
], | |
en: [ | |
'Welcome to', | |
'&6The Land of Kigam&r', | |
'in', | |
'&3The World of&r &4&uMagikcraft' | |
], | |
ja: [ | |
'ようこそ', | |
'これは &6"キガム"&r の土地です。', | |
'&uMagikcraft&rの世界で' | |
] | |
} | |
}, | |
{ | |
name: 'tutorial_magik', | |
strings: | |
{ | |
no: [ | |
'--- &4&uMagi&r ---', | |
'er en kraft som lar folk', | |
'gj[ø]re &6umulige ting&r', | |
'ved [å] si &6spesielle ord&r' | |
], | |
en: [ | |
'--- &4&uMagik&r ---', | |
'Is a power that allows people', | |
'to do &6impossible things&r', | |
'by saying &6special words&r' | |
], | |
ja: [ | |
'&4&uマジックは&r、', | |
'人が不可能なことをすることを可能にする力です', | |
'特別な言葉を言って' | |
] | |
} | |
}, | |
{ | |
name: 'tutorial_chap_01', | |
strings: { | |
no: [ | |
'Hei, jeg heter M.', | |
'&4&u¡¡¡¡¡¡Hjelp!!!!!!&r', | |
'&dSuperMegaCorp&r', | |
'stjal all &4&magien&r', | |
'i Kigamriket.' | |
], | |
en: [ | |
'Hello, my name is &aM&r.', | |
'&4&u¡¡¡¡¡¡Help!!!!!!&r', | |
'&dSuperMegaCorp&r', | |
'stole all the &4&umagik', | |
'in the realm of Kigam.' | |
], | |
ja: [ | |
'こんにちは、私の名前は "M"', | |
'助けてください!', | |
'SuperMegaCorpはすべての魔法を盗んだ!' | |
] | |
} | |
}, | |
{ | |
name: 'tutorial_chap_02', | |
strings: { | |
no: [ | |
'Modige mennesker ble med', | |
'og sammen slo vi', | |
'SuperMegaCorp.', | |
'Men &4&umagien&r ble tapt!!!' | |
], | |
en: [ | |
'Brave people joined me', | |
'and together we beat', | |
'&dSuperMegaCorp&r.', | |
'But &4&umagik&r was lost!!!' | |
], | |
ja: [ | |
'勇敢なヒーローがSuperMegaCorpを破った', | |
'しかし、魔法は失われました!' | |
] | |
} | |
}, | |
{ | |
name: 'tutorial_chap_03', | |
strings: { | |
no: [ | |
'Nå ønsker &dSuperMegaCorp&r', | |
'å få tilbake magien.', | |
'Finn trylleformlene før de finner dem,', | |
'og ta dem med tilbake til', | |
'&a&uAsgard Romstasjon&r!' | |
], | |
en: [ | |
'Now &dSuperMegaCorp&r', | |
'wants to get the &4&umagik&r back.', | |
'Find the magik words before they do', | |
'and bring them to', | |
'the &a&uAsgard Space Station&r!' | |
], | |
ja: [ | |
'今すぐSuperMegaCorpが魔法を手に入れたい', | |
'彼らがする前に魔法を見つける', | |
'魔法を「アスガード」宇宙ステーションに持って行きなさい' | |
] | |
} | |
}, | |
{ | |
name: 'tutorial_chap_04', | |
strings: { | |
no: [ | |
'--- &dSuperMegaCorp&r ---', | |
'vær advart:', | |
'All &4&umagi&r tilhører', | |
'&dSuperMegaCorp&r.', | |
'Inntrengere vil bli forfulgt.' | |
], | |
en: [ | |
'--- &dSuperMegaCorp&r ---', | |
'Be Warned:', | |
'All &4&umagik&r is the property of', | |
'&dSuperMegaCorp&r.', | |
'Trespassers will be persecuted.' | |
], | |
ja: [ | |
'--- &dSuperMegaCorp&r ---', | |
'警告してください!', | |
'All &4&umagik&r is the property of', | |
'&dSuperMegaCorp&r.', | |
'他の人は罰せられる!' | |
] | |
} | |
}, | |
{ | |
name: 'tutorial_chap_05', | |
strings: { | |
no: [ | |
'Du må bruke &4&umagi&r', | |
'for å komme ut herfra', | |
'&f[|||] &4[|||] &f[|||]', | |
'Finn det magiske ordet.' | |
], | |
en: [ | |
'You need to use &4&umagik&r', | |
'to get out of here', | |
'&f[|||] &4[|||] &f[|||]', | |
'Find the magik word' | |
], | |
ja: [ | |
'あなたは出かけるのに魔法を使う必要があります', | |
'魔法の言葉を見つける' | |
] | |
} | |
}, | |
{ | |
name: 'tutorialwarp', | |
strings: { | |
no: [ | |
'--- &aM&r ---', | |
'Takk for den du er, og hva du gjør', | |
'for folket i Kigam.', | |
'Skriv inn /warp Lounge', | |
'det vil ta deg til det neste området.', | |
'Fortsett med det, og så ses vi snart!' | |
], | |
en: [ | |
'--- &aM&r ---', | |
'Thank you for who you are', | |
'and what you are doing', | |
'for the people of Kigam.', | |
'Type in &u/warp Lounge', | |
'it will take you to the next area.', | |
'Keep doing you, and see you soon!' | |
] | |
} | |
}, | |
{ | |
name: 'congrats', | |
strings: { | |
no: [ | |
'Gratulerer!!!' | |
], | |
en: [ | |
'&4&uCongratulations!!!&r' | |
], | |
ja: ['&4&u御目出度う!&r'] | |
} | |
}, | |
{ | |
name: 'arthur', | |
strings: { | |
no: [ | |
], | |
en: [ | |
"'''Any sufficiently advanced technology", | |
'is indistinguishable from magic', | |
'- Arthur C. Clarke' | |
] | |
} | |
}, | |
{ | |
name: 'jungle-instructions', | |
strings: { | |
no: [ | |
'Finn ingrediensene for trylleformelen', | |
'Det finnes fem stykk...', | |
'Du trenger bare tre stykk til en trylleformel' | |
], | |
en: [ | |
'Find the ingredients to make spell with', | |
'&aThere are five of them...&r', | |
'&aYou only need three for a spell&r' | |
] | |
} | |
}, | |
{ | |
name: 'flight_cast', | |
strings: { | |
no: [ | |
'Bluk "remember"-trylleformelen her' | |
], | |
en: [ | |
'Cast your remember spell here' | |
] | |
} | |
}, | |
{ | |
name: 'flight-goback', | |
strings: { | |
no: [ | |
'Fant du det magiske ordet? Det er tilbake, bak deg...' | |
], | |
en: [ | |
"Did you find the magik word? It's back, behind you..." | |
] | |
} | |
}, | |
{ | |
name: 'flight-end-menu', | |
strings: { | |
no: [ | |
'Fant du den hemmelige passasjen gjennom fossen?', | |
'Gå tilbake for å finne den: &4&u/warp lounge&r', | |
'Gå videre til neste eventyr: &4&u/warp flight2&r' | |
], | |
en: [ | |
'Did you find the secret passage through the waterfall?', | |
'To go back to find it: &4&u/warp lounge&r', | |
'To go on to the next adventure: &4&u/warp flight2&r' | |
] | |
} | |
}, | |
{ | |
name: 'flight2-instructions', | |
strings: { | |
no: [ | |
'Fly hele veien i ett hopp!' | |
], | |
en: [ | |
'Fly all the way in one jump!' | |
] | |
} | |
}, | |
{ | |
name: 'flight2-end', | |
strings: { | |
no: [ | |
'Gratulerer!', | |
'Prøv igjen: &4&u/warp flight2&r', | |
'Gå til neste eventyr: &4&u/warp jungle&r' | |
], | |
en: [ | |
'Congrats!', | |
'To try again: &4&u/warp flight2&r', | |
'To go to the next adventure: &4&u/warp jungle&r' | |
] | |
} | |
}, | |
{ | |
name: 'kigam-volcano-exit', | |
strings: { | |
no: [ | |
'Denne veien tilbake til Kigam Town!', | |
'/ \\ / \\' | |
], | |
en: [ | |
'Stairway' | |
] | |
} | |
}, | |
{ | |
name: 'initial_welcome', | |
strings: { | |
no: [ | |
'Velkommen til &uMagikcraft', | |
'Bruk W, A, S, D til å bevege deg.', | |
'Beveg musen for å kunne se deg rundt.', | |
'Når du er klar, følg stien' | |
], | |
en: [ | |
'Welcome to &uMagikcraft', | |
'Use W,A,S,D to move. Move your mouse to look', | |
'Once you get that, follow the path' | |
], | |
ja: [ | |
'&uMagikcraft&rへようこそ!', | |
'W、A、S、Dを使用して移動します。 見るためにマウスを使用してください。', | |
'準備が整ったら、パスに従ってください' | |
] | |
} | |
}, | |
{ | |
name: 'initial_jumping', | |
strings: { | |
no: [ | |
'Trykk på mellomromstasten for å hoppe' | |
], | |
en: [ | |
'Use the Spacebar to jump' | |
], | |
ja: [ | |
'スペースバーを押してジャンプする' | |
] | |
} | |
}, | |
{ | |
name: 'initial_portal', | |
strings: { | |
no: [ | |
'&uMagkicraft&r is connected with &uPortals', | |
'Gå gjennom her for å gå til opplæringsnivået' | |
], | |
en: [ | |
'&uMagkicraft&r is connected with &uPortals', | |
'Walk though, and it will take you to the tutorial level' | |
], | |
ja: [ | |
'Magikcraftは &uポータル&r', | |
'歩いてください。 チュートリアルのレベルに進みます。' | |
] | |
} | |
} | |
/*, | |
{ | |
name: '', | |
strings: { | |
no: [ | |
'' | |
], | |
en: [ | |
'' | |
] | |
} | |
}, | |
{ | |
name: '', | |
strings: { | |
no: [ | |
'' | |
], | |
en: [ | |
'' | |
] | |
} | |
}, | |
{ | |
name: '', | |
strings: { | |
no: [ | |
'' | |
], | |
en: [ | |
'' | |
] | |
} | |
}, | |
{ | |
name: '', | |
strings: { | |
no: [ | |
'' | |
], | |
en: [ | |
'' | |
] | |
} | |
}, | |
{ | |
name: '', | |
strings: { | |
no: [ | |
'' | |
], | |
en: [ | |
'' | |
] | |
} | |
} */ | |
]; | |
strings.forEach(hologram => { | |
if (hologram.strings[lang]) { | |
hologram.strings[lang].map((text, line) => | |
run(`hd setline ${hologram.name} ${line + 1} ${text}`) | |
); | |
} | |
}); | |
} | |
/* | |
Finn de tre ingrediensene - før Zombiene kommer!! | |
Si din huskeformel her | |
Fant du det magiske ordet? Det er tilbake, bak deg... | |
Fant du den hemmelige gangen gjennom fossen? | |
For å gå tilbake for å finne den: /warp lounge | |
For å gå videre til neste eventyr: /warp flight | |
Fly hele vegen i ett hopp! | |
Grattis! | |
For å prøve igjen: /warp flight | |
For å gå videre til neste eventyr: /warp jungle | |
] | |
} | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var magik = magikcraft.io; | |
function lol(name) { | |
const player = magik.getSender().getPlayer(name); | |
player.setHealth2(10); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function look() { | |
const where = magik.aspecto(); | |
magik.dixit(`X: ${where.getX()}`); | |
magik.dixit(`Y: ${where.getY()}`); | |
magik.dixit(`Z: ${where.getZ()}`); | |
magik.dixit(`Pitch: ${where.getPitch()}`); | |
magik.dixit(`Yaw: ${where.getYaw()}`); | |
magik.dixit(`World: ${where.getWorld()}`); | |
magik.dixit(`String: ${where.toString()}`); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function magikcarpet() { | |
magik.declaro('elytra'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
const server = magik.getPlugin().getServer(); | |
const player = magik.getSender(); | |
const world = player.getWorld(); | |
//const request = require("request"); | |
var cursor; | |
var direction; | |
function maze() { | |
//request.get("http://fun.mega-bot.com/maze/gen",function(e,r,b){magik.dixit(b);}) | |
var mazeData="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nXOOOOOOXXOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOXXOOOOOOOX\nXOOOOOOXXOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOXXOOOOOOOX\nXOOOOOOXXOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOXXOOOOOOOX\nXOOOOOOXXOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOXXOOOOOOOX\nXOOOOOOXXOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOOOOOOOOOOX\nXOOOOOOXXOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOXXOOOOOOOX\nXOOOOOOXXOOOOOOOOOOOOOOOXXXXXOXXXXXXXXXXXXOOOOOOOX\nXOOOOOOOOOOOOOOOOOOOOOOOXXXXXOXXXXXXXXXXXXOOOOOOOX\nXOOOOOOXXOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOXXXXXXXOXX\nXOOOOOOXXOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOXXXXXXXOXX\nXXXXXXOXXOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOXXOOOOOOOX\nXXXXXXOXXOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOXXOOOOOOOX\nXOOOOOOXXOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOXXOOOOOOOX\nXOOOOOOXXOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOXXOOOOOOOX\nXOOOOOOXXOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOXXOOOOOOOX\nXOOOOOOXXOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOXXOOOOOOOX\nXOOOOOOXXOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOXXOOOOOOOX\nXOOOOOOXXOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOXXOOOOOOOX\nXOOOOOOXXXXXXXXXXXXXXXOXXXOOOOOOOOOOOOOOXXOOOOOOOX\nXOOOOOOXXXXXXXXXXXXXXXOXXXOOOOOOOOOOOOOOXXOOOOOOOX\nXOOOOOOXXOOOOOOOOOOOOOOOXXXXXXXXXXXXXXXOXXOOOOOOOX\nXOOOOOOXXOOOOOOOOOOOOOOOXXXXXXXXXXXXXXXOXXOOOOOOOX\nXOOOOOOXXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXXOOOOOOOX\nXOOOOOOXXOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOXXOOOOOOOX\nXOOOOOOXXXXXXXOXXXXXXXXXXXOOOOOOOOOOOOOOXXOOOOOOOX\nXOOOOOOXXXXXXXOXXXXXXXXXXXOOOOOOOOOOOOOOXXOOOOOOOX\nXOOOOOOXXOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOXXOXXXXXXX\nXOOOOOOXXOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOXXOXXXXXXX\nXOOOOOOXXOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOXXOOOOOOOX\nXOOOOOOXXOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOXXOOOOOOOX\nXXXXXXXXXXXXXXXXXXXOXXXXXXOOOOOOOOOOOOOOXXOOOOOOOX\nXXXXXXXXXXXXXXXXXXXOXXXXXXOOOOOOOOOOOOOOXXOOOOOOOX\nXOOOOOOOOOOOXXOOOOOOOOOOXXOOOOOOOOOOOOOOXXOOOOOOOX\nXOOOOOOOOOOOXXOOOOOOOOOOXXXXXXXXXXXXXXXXXXXXXOXXXX\nXOOOOOOOOOOOXXOOOOOOOOOOXXXXXXXXXXXXXXXXXXXXXOXXXX\nXOOOOOOOOOOOXXOOOOOOOOOOXXOOOOOOOOOOOOOOOOOOOOOOOX\nXOOOOOOOOOOOXXOOOOOOOOOOXXOOOOOOOOOOOOOXXOOOOOOOOX\nXOOOOOOOOOOOXXOOOOOOOOOOXXOOOOOOOOOOOOOXXOOOOOOOOX\nXOOOOOOOOOOOXXOOOOOOOOOOXXOOOOOOOOOOOOOXXOOOOOOOOX\nXOOOOOOOOOOOXXOOOOOOOOOOXXOOOOOOOOOOOOOXXOOOOOOOOX\nXOOOOOOOOOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOXXOOOOOOOOX\nXOOOOOOOOOOOXXOOOOOOOOOOXXOOOOOOOOOOOOOXXOOOOOOOOX\nXOOOOOOOOOOOXXOOOOOOOOOOXXOOOOOOOOOOOOOXXOOOOOOOOX\nXOOOOOOOOOOOXXOOOOOOOOOOXXOOOOOOOOOOOOOXXOOOOOOOOX\nXOOOOOOOOOOOXXOOOOOOOOOOXXOOOOOOOOOOOOOXXOOOOOOOOX\nXOOOOOOOOOOOXXOOOOOOOOOOXXOOOOOOOOOOOOOXXOOOOOOOOX\nXOOOOOOOOOOOXXOOOOOOOOOOXXOOOOOOOOOOOOOXXOOOOOOOOX\nXOOOOOOOOOOOXXOOOOOOOOOOXXOOOOOOOOOOOOOXXOOOOOOOOX\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"; | |
mazeData=mazeData.split("\n") | |
//world.createExplosion(po,100); | |
initCursor(); | |
var initCur=new org.bukkit.Location(cursor.getWorld(),cursor.getX(),cursor.getY(),cursor.getZ()); | |
var height=mazeData.length; | |
var width=mazeData[0].length; | |
for(var i=0;i<width+2;i++){ | |
drawLine(height+2,true); | |
moveLeft(); | |
} | |
cursor=initCur; | |
cursor.add(0,1,0); | |
initCur=new org.bukkit.Location(cursor.getWorld(),cursor.getX(),cursor.getY(),cursor.getZ()); | |
//Draw Maze | |
moveFw(); | |
moveLeft(); | |
mazeData.forEach(function(row){ | |
row.split("").forEach(function(cell){ | |
if(cell=="X"){ | |
placeBlock(2); | |
} | |
moveLeft(); | |
}); | |
for(var i=0;i<width;i++){ | |
moveRight(); | |
} | |
moveFw(); | |
}); | |
//Draw Walls | |
cursor=initCur; | |
initCur=new org.bukkit.Location(cursor.getWorld(),cursor.getX(),cursor.getY(),cursor.getZ()); | |
for(i=0;i<height+2;i++){ | |
placeBlock(2); | |
moveFw(); | |
} | |
moveBk(); | |
for(i=0;i<width+1;i++){ | |
placeBlock(2); | |
moveLeft(); | |
} | |
for(i=0;i<height+1;i++){ | |
placeBlock(2); | |
moveBk(); | |
} | |
for(i=0;i<width+1;i++){ | |
placeBlock(2); | |
moveRight(); | |
} | |
}; | |
function initCursor(){ | |
cursor=player.getTargetBlock(null,100).getLocation(); | |
//cursor.add(0,1,0); | |
let playerPos=player.getLocation(); | |
//magik.dixit(cursor); | |
var xdiff=playerPos.getX()-cursor.getX(); | |
var ydiff=playerPos.getZ()-cursor.getZ(); | |
if( Math.abs(xdiff) > Math.abs(ydiff) ) | |
if(xdiff>0) | |
direction="West"; | |
else | |
direction="East"; | |
else | |
if(ydiff>0) | |
direction="North"; | |
else | |
direction="South"; | |
} | |
function moveRight(){ | |
if(direction=="North") | |
cursor.add(1,0,0); | |
if(direction=="South") | |
cursor.add(-1,0,0); | |
if(direction=="East") | |
cursor.add(0,0,1); | |
if(direction=="West") | |
cursor.add(0,0,-1); | |
} | |
function moveLeft(){ | |
if(direction=="North") | |
cursor.add(-1,0,0); | |
if(direction=="South") | |
cursor.add(1,0,0); | |
if(direction=="East") | |
cursor.add(0,0,-1); | |
if(direction=="West") | |
cursor.add(0,0,1); | |
} | |
function moveFw(){ | |
if(direction=="North") | |
cursor.add(0,0,-1); | |
if(direction=="South") | |
cursor.add(0,0,1); | |
if(direction=="East") | |
cursor.add(1,0,0); | |
if(direction=="West") | |
cursor.add(-1,0,0); | |
} | |
function moveBk(){ | |
if(direction=="North") | |
cursor.add(0,0,1); | |
if(direction=="South") | |
cursor.add(0,0,-1); | |
if(direction=="East") | |
cursor.add(-1,0,0); | |
if(direction=="West") | |
cursor.add(1,0,0); | |
} | |
function placeBlock(height){ | |
if(!height){ | |
var bl1=world.getBlockAt(cursor); | |
bl1.setType(org.bukkit.Material.GOLD_BLOCK); | |
} | |
else{ | |
for(var i=0;i<height;i++){ | |
var bl1=world.getBlockAt(cursor); | |
bl1.setType(org.bukkit.Material.GOLD_BLOCK); | |
cursor.add(0,1,0); | |
} | |
for(var i=0;i<height;i++){ | |
cursor.add(0,-1,0); | |
} | |
} | |
} | |
function drawLine(count,rtn){ | |
magik.dixit(direction); | |
if(rtn)//return cursor to start position | |
var initCur=new org.bukkit.Location(cursor.getWorld(),cursor.getX(),cursor.getY(),cursor.getZ()); | |
for(var i=0;i<count;i++){ | |
placeBlock(1); | |
moveFw(); | |
} | |
if(rtn) | |
cursor=initCur; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function mc() { | |
magik.declaro('elytra'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { bar, color, style, ComponentBuilder, ChatColor, version } = require('magikcraft-lore-ui-bar'); | |
const magik = magikcraft.io; | |
const setTimeout = magik.setTimeout; | |
function mct1() { | |
magik.dixit(`Bars version ${version}`); | |
const text = ComponentBuilder("Insulin | ").append("Basal: Active").color(ChatColor.GREEN).create(); | |
const b = bar() | |
.text(`BGL: 4.2`) | |
.color(color.GREEN) | |
.style(style.NOTCHED_20) | |
.progress(100/30*4.2) | |
.show(); | |
const i1 = bar() | |
.textComponent(text) | |
.color(magik.Bars.Color.BLUE) | |
.style(style.NOTCHED_20) | |
.progress(10) | |
.show(); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
var magik = magikcraft.io; | |
exports.ComponentBuilder = function (msg) { return Java.type('net.md_5.bungee.api.chat.ComponentBuilder')(msg); }; | |
var _ChatColor = Java.type('net.md_5.bungee.api.ChatColor'); | |
var ChatColor; | |
(function (ChatColor) { | |
ChatColor[ChatColor["AQUA"] = _ChatColor.AQUA] = "AQUA"; | |
ChatColor[ChatColor["BLACK"] = _ChatColor.BLACK] = "BLACK"; | |
ChatColor[ChatColor["BLUE"] = _ChatColor.BLUE] = "BLUE"; | |
ChatColor[ChatColor["BOLD"] = _ChatColor.BOLD] = "BOLD"; | |
ChatColor[ChatColor["DARK_AQUA"] = _ChatColor.DARK_AQUA] = "DARK_AQUA"; | |
ChatColor[ChatColor["DARK_BLUE"] = _ChatColor.DARK_BLUE] = "DARK_BLUE"; | |
ChatColor[ChatColor["DARK_GRAY"] = _ChatColor.DARK_GRAY] = "DARK_GRAY"; | |
ChatColor[ChatColor["DARK_GREEN"] = _ChatColor.DARK_GREEN] = "DARK_GREEN"; | |
ChatColor[ChatColor["DARK_PURPLE"] = _ChatColor.DARK_PURPLE] = "DARK_PURPLE"; | |
ChatColor[ChatColor["DARK_RED"] = _ChatColor.DARK_RED] = "DARK_RED"; | |
ChatColor[ChatColor["GOLD"] = _ChatColor.GOLD] = "GOLD"; | |
ChatColor[ChatColor["GRAY"] = _ChatColor.GRAY] = "GRAY"; | |
ChatColor[ChatColor["GREEN"] = _ChatColor.GREEN] = "GREEN"; | |
ChatColor[ChatColor["ITALIC"] = _ChatColor.ITALIC] = "ITALIC"; | |
ChatColor[ChatColor["LIGHT_PURPLE"] = _ChatColor.LIGHT_PURPLE] = "LIGHT_PURPLE"; | |
ChatColor[ChatColor["MAGIC"] = _ChatColor.MAGIC] = "MAGIC"; | |
ChatColor[ChatColor["RED"] = _ChatColor.RED] = "RED"; | |
ChatColor[ChatColor["RESET"] = _ChatColor.RESET] = "RESET"; | |
ChatColor[ChatColor["STRIKETHROUGH"] = _ChatColor.STRIKETHROUGH] = "STRIKETHROUGH"; | |
ChatColor[ChatColor["UNDERLINE"] = _ChatColor.UNDERLINE] = "UNDERLINE"; | |
ChatColor[ChatColor["WHITE"] = _ChatColor.WHITE] = "WHITE"; | |
ChatColor[ChatColor["YELLOW"] = _ChatColor.YELLOW] = "YELLOW"; | |
})(ChatColor = exports.ChatColor || (exports.ChatColor = {})); | |
var Color = magik.Bars.Color; | |
var color; | |
(function (color) { | |
color[color["BLUE"] = magik.Bars.Color.BLUE] = "BLUE"; | |
color[color["GREEN"] = magik.Bars.Color.GREEN] = "GREEN"; | |
color[color["PINK"] = magik.Bars.Color.PINK] = "PINK"; | |
color[color["PURPLE"] = magik.Bars.Color.PURPLE] = "PURPLE"; | |
color[color["RED"] = magik.Bars.Color.RED] = "RED"; | |
color[color["WHITE"] = magik.Bars.Color.WHITE] = "WHITE"; | |
color[color["YELLOW"] = magik.Bars.Color.YELLOW] = "YELLOW"; | |
})(color = exports.color || (exports.color = {})); | |
var Style = magik.Bars.Style; | |
var style; | |
(function (style) { | |
style[style["NOTCHED_10"] = magik.Bars.Style.NOTCHED_10] = "NOTCHED_10"; | |
style[style["NOTCHED_12"] = magik.Bars.Style.NOTCHED_12] = "NOTCHED_12"; | |
style[style["NOTCHED_20"] = magik.Bars.Style.NOTCHED_20] = "NOTCHED_20"; | |
})(style = exports.style || (exports.style = {})); | |
function bar(_msg, player) { | |
if (_msg === void 0) { _msg = ""; } | |
if (player === void 0) { player = magik.getSender(); } | |
var _bar, _color, _style; | |
var Bar = { | |
_bar: _bar, | |
_msg: _msg, | |
_color: magik.Bars.Color.RED, | |
_progress: 0.5, | |
_style: magik.Bars.Style.NOTCHED_20, | |
_init: false, | |
_textComponent: undefined, | |
player: player | |
}; | |
Bar.show = function () { | |
if (Bar._init) { | |
return Bar; | |
} | |
var textComponent = (Bar._textComponent) ? Bar._textComponent : magik.TextComponent(Bar._msg + ""); | |
Bar._bar = magik.Bars.addBar(player, textComponent, Bar._color, Bar._style, Bar._progress // Progress (0.0 - 1.0) | |
); | |
Bar._init = true; | |
return Bar; | |
}; | |
Bar.color = function (color) { | |
Bar._color = magik.Bars.Color[color]; | |
if (Bar._init) { | |
Bar._bar.setColor(Bar._color); | |
} | |
return Bar; | |
}; | |
Bar.style = function (style) { | |
Bar._style = magik.Bars.Style[style]; | |
return Bar; | |
}; | |
Bar.text = function (msg) { | |
if (typeof msg === 'string' || typeof msg === 'number') { | |
Bar._msg = msg + ''; | |
} | |
else { | |
Bar._msg = ''; | |
Bar._textComponent = msg; | |
} | |
if (Bar._init) { | |
Bar.destroy(); | |
Bar.show(); | |
} | |
return Bar; | |
}; | |
Bar.progress = function (progress) { | |
if (progress === void 0) { progress = 50; } | |
Bar._progress = Math.min(progress / 100, 0.99); | |
if (Bar._init) { | |
Bar._bar.setProgress(progress); | |
} | |
return Bar; | |
}; | |
Bar.addPlayer = function (player) { | |
if (Bar._init) { | |
Bar._bar.addPlayer(player); | |
} | |
return Bar; | |
}; | |
Bar.removePlayer = function (player) { | |
if (Bar._init) { | |
Bar._bar.removePlayer(player); | |
} | |
return Bar; | |
}; | |
Bar.destroy = function () { | |
if (Bar._init) { | |
Bar.removePlayer(player); | |
Bar._init = false; | |
} | |
return undefined; | |
}; | |
return Bar; | |
} | |
exports.bar = bar; | |
/** | |
* | |
* In this function we return a partially bound version of bar that can be loaded as a lore at boot time. This means that users can use magikcraft.io.lore.sitapati.bar and get a bar in the UI. | |
* | |
* @param {*} canon | |
* @returns | |
*/ | |
function barWithClosure(canon) { | |
var player = canon.sender; | |
return function (msg, _player) { | |
_player = (_player) ? _player : player; | |
return bar(msg, _player); | |
}; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Teleport to somewhere remembered using magik.playerMap | |
* | |
* This means you can remember things even when you leave the server and come back! | |
* | |
* Usage: | |
* `/cast mer` -- teleport to the default remembered place | |
* `/cast mer <name>` -- teleport to a named remembered place | |
*/ | |
const magik = magikcraft.io; | |
function mer(key="here") { | |
if (!magik.durablePlayerMap.containsKey(`memory.${key}`)) { | |
magik.dixit(`I don't remember a place "${key}`); | |
return; | |
} | |
const here = magik.durablePlayerMap.get(`memory.${key}`); | |
magik.ianuae(here); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
const Material = magik.type('Material'); | |
function moses(duration = 10000, radius = 1) { | |
const sampleRate = 50; // 100ms | |
const times = duration / sampleRate; | |
let repeats = 0; | |
const loop = magik.setInterval(function(){ | |
repeats ++; | |
if (repeats > times) { | |
magik.clearInterval(loop); | |
return; | |
} | |
const here = magik.hic(); | |
const xa = here.getX() - radius; | |
const xb = here.getX() + radius; | |
const ya = here.getY() - radius; | |
const yb = here.getY() + radius; | |
const za = here.getZ() - radius; | |
const zb = here.getZ() + radius; | |
const Blocks = []; | |
for (let x = xa; x < xb; x++) { | |
for (let y = ya; y < yb; y++) { | |
for (let z = za; z < zb; z++) { | |
const block = here.getWorld().getBlockAt(x,y,z); | |
if (block.getType() == Material.STATIONARY_WATER || block.getType() == Material.WATER) { | |
block.setType(Material.AIR); | |
} | |
} | |
} | |
} | |
}, times); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function mvtp(worldname) { | |
run("mv tp " + worldname); | |
function run(cmd) { | |
var sudo = magik.getPlugin().getServer().getConsoleSender(); | |
magik.getPlugin().getServer().dispatchCommand(sudo, cmd); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function myFirstSpell(name = 'stranger') { | |
if (!name) { | |
name = '' | |
} | |
magik.dixit(`Hello ${name}`); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function n() { | |
const Material = magik.type('Material'); | |
const here = magik.hic(); | |
const world = magik.getSender().getWorld(); | |
const x = here.getX(); | |
const y = here.getY(); | |
const z = here.getZ(); | |
/** | |
* Returns a random number that is not 0 - ie: doesn't strike the player | |
*/ | |
function getRandomDelta(X, Z) { | |
const delta = () => Math.random() * 10 - 5; | |
const dX = X + delta(); | |
const dZ = Z + delta(); | |
const dangerClose = (dX > X - 2 && dX < X + 2 && dZ > Z - 2 && dZ < Z + 2); | |
return { X: dX, Z: dZ, dangerClose } | |
} | |
function blast(X, Z) { | |
const location = magik.hic(); | |
const delta = getRandomDelta(X, Z); | |
location.setX(delta.X); | |
location.setZ(delta.Z); | |
if (!delta.dangerClose) { | |
world.strikeLightning(location); | |
} | |
} | |
magik.doNTimes(() => { | |
magik.doNTimes(() => { | |
magik.doNTimes(() => {blast(x,z)}, 15)}, | |
15)}, | |
15); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
let global_test_var = 0; | |
function newSpell() { | |
let n = magik.setInterval(()=> { | |
magik.dixit(`global_test_var: ${global_test_var}`); | |
global_test_var ++; | |
}, 1000); | |
magik.setTimeout( | |
()=> { | |
magik.dixit('Timer cancelled'); | |
magik.clearInterval(n); | |
}, | |
5000); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function p() { | |
magik.dixit("hello") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function path(typ = 'STONE'){ | |
const Material = magik.type("Material"); | |
const blocks = magik.getSender().getLineOfSight(null,50); | |
blocks.forEach(b => b.getRelative(0, -2, 0).setType(Material[typ])); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
// Don't use this spell - it is currently broken and will kill you!! | |
const platforms = magik.global('sitapati.platforms'); | |
const layers = []; | |
const say = magik.dixit; | |
function platformz(levels = 5, radius = 15, space = 4) { | |
function run(cmd) { | |
const sender = magik.getSender(); | |
magik.getPlugin().getServer().dispatchCommand(sender, cmd); | |
} | |
function addY(loc, y) { | |
const newLoc = loc.clone(); | |
newLoc.setY(newLoc.getY + y); | |
return newLoc; | |
} | |
if (!platforms.initialised) { | |
magik.dixit("Initialising..."); | |
platforms.initial_position = magik.hic().clone(); | |
layers[0] = platforms.initial_position; | |
layers[1] = addY(layers[0], 1); | |
for (let i = 2; i < levels + 2; i++) { | |
layers[i] = addY(layers[i-1], space); | |
say(layers[i]); | |
} | |
layer('bedrock', layers[0]) | |
layer('lava', layers[1]); | |
platforms.initialised = true; | |
} else { | |
magik.dixit("Already Initialised..."); | |
magik.ianuae(layers[0]); | |
} | |
for (let i = 2; i < levels + 2; i++) { | |
layer('glass', layers[i]) | |
} | |
function layer (material, location) { | |
magik.ianuae(location); | |
const cmd = `/cyl ${material} ${radius} 1` | |
run (cmd); | |
magik.dixit(cmd); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function prank(name) { | |
magik.iacta(name) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
const test = require('test3'); | |
function ps() { | |
magik.dixit(test); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function publish() { | |
eventbus.publish(`${global.PlayerName}.location`, magik.hic().toString()); | |
const here = magik.get; | |
if (isLocation(here)) { | |
magik.dixit(JSON.stringify(locationToJSON(here))); | |
} | |
here.setWorld(magik.getPlugin().getServer().getWorld('world-tutorial')); | |
magik.getSender().teleport(here); | |
} | |
function isLocation(thing) { | |
return (thing.toString().indexOf('Location') === 0); | |
} | |
function locationToJSON(location) { | |
return { | |
type: 'Location', | |
X: location.getX(), | |
Y: location.getY(), | |
Z: location.getZ(), | |
Yaw: location.getYaw(), | |
Pitch: location.getPitch(), | |
World: location.getWorld().getName() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
const locationTopic = 'locations'; | |
// Publish my location over the eventbus | |
function publishLocation() { | |
const here = magik.hic(); // get player current location | |
const hereJSON = magik.toJSON(here); // turn it into a JSON object | |
magik.dixit(`Published location for ${global.PlayerName} via eventbus`); | |
// magik.dixit(JSON.stringify(hereJSON)); // you can print it out | |
// Publish player location to 'locations' topic on the eventbus | |
eventbus.publish(locationTopic, {name: global.PlayerName, location: hereJSON}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function pubtest() { | |
eventbus.publish('sitapati.msg', 'Hello from the eventbus'); | |
eventbus.publish('sitapati.msg', {ok: true}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function r(t = 5) { | |
const times = t * 1000 / 300; // n seconds, every 300ms | |
let n = times; | |
magik.setTimeout(shield, 300); | |
magik.dixit('Magical shield!'); | |
function shield() { | |
n --; | |
const location = magik.hic(); | |
const nearbyEntities = location.getWorld().getNearbyEntities(location, 8, 8, 8); | |
nearbyEntities.forEach(entity => toss(entity)); | |
if (n>0) { | |
magik.setTimeout(shield, 300) | |
} else { | |
magik.dixit('Shield exhausted!'); | |
} | |
} | |
} | |
function toss(entity){ | |
if (entity.getName() == magik.getSender().getName()) { | |
return; | |
} | |
var Vector = Java.type('org.bukkit.util.Vector'); | |
entity.setVelocity(new Vector(2,2,2)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isNode = (eval(`typeof magikcraft == 'undefined'`)) | |
const say = (isNode) ? console.log : magikcraft.io.dixit; | |
const _setTimeout = (isNode) ? setTimeout : magikcraft.io.setTimeout; | |
const NanoFlux = require('nanoflux-fusion'); | |
function redux() { | |
const fusionStore = NanoFlux.getFusionStore(); | |
function init() { | |
NanoFlux.createFusionator({ | |
increment: state => ({ counter: state.counter + 1 }), | |
decrement: state => ({ counter: state.counter - 1 }), | |
add: (state, args) => ({counter: state.counter+args[0]}), | |
reset: state => ({ counter: 0 }) | |
}, | |
{ counter: 0}); | |
const subscription = fusionStore.subscribe(this, state => | |
say(`Counter: ${state.counter}`) | |
); | |
} | |
const initialised = (!!fusionStore.getState()); | |
if (!initialised) { | |
init(); | |
} | |
const increment = NanoFlux.getFusionActor("increment"); | |
const decrement = NanoFlux.getFusionActor("decrement"); | |
const add = NanoFlux.getFusionActor("add"); | |
const reset = NanoFlux.getFusionActor("reset"); | |
say('Start test'); | |
if (initialised) { | |
reset(); | |
} | |
[ | |
() => increment(), | |
() => increment(), | |
() => increment(), | |
() => decrement(), | |
() => decrement(), | |
() => increment(), | |
() => add(10), | |
() => say('Done!') | |
].forEach((fn, i) => _setTimeout(fn, i * 1000)); | |
} | |
(isNode && redux()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A persistent memory spell that uses magik.playerMap | |
* | |
* This means you can remember things even when you leave the server and come back! | |
* | |
* Usage: | |
* `/cast rem` -- remember this place as the default place | |
* `/cast rem <name>` -- remember this place as the name you give | |
*/ | |
const magik = magikcraft.io; | |
function rem(key="here") { | |
const here = magik.hic(); | |
magik.durablePlayerMap.put(`memory.${key}`, here); | |
magik.dixit(`Remembered this place as "${key}"`); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function remember(name = "default.place") { | |
const place = magik.hic(); | |
magik.memento.setItem(name, place); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function rsummon(name, mob = 'zombie') { | |
const run = (cmd) => { | |
const plugin = magik.getPlugin(); | |
const sender = magik.getSender(); | |
plugin.getServer().dispatchCommand(sender, cmd); | |
} | |
const sender = magik.getSender(); | |
const name = name || sender.name; | |
// run(`execute ${name} ~ ~ ~ summon ${mob} ~14 ~3 ~-10`); | |
// run(`execute ${name} ~ ~ ~ summon ${mob} ~5 ~3 ~-15`); | |
// run(`execute ${name} ~ ~ ~ summon ${mob} ~-6 ~1 ~-20`); | |
// run(`execute ${name} ~ ~ ~ summon ${mob} ~114 ~3 ~10`); | |
// run(`execute ${name} ~ ~ ~ summon ${mob} ~15 ~3 ~15`); | |
// run(`execute ${name} ~ ~ ~ summon ${mob} ~6 ~1 ~20`); | |
magik.dixit('rsummon! 2'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function runTests() { | |
let testCount, testRunning, asyncTest, currentTest, asyncTimeout; | |
const tests = []; | |
function runTest(){ | |
if (testRunning || tests.length == 0) { | |
return; | |
} | |
testRunning = true; | |
const test = tests.pop(); | |
_test(test.name, test.fn, (err, result) => { | |
if (err) { | |
magik.dixit('Error!'); | |
err.forEach(msg => magik.dixit(msg)); | |
} else { | |
magik.dixit(result); | |
} | |
testRunning = false; | |
runTest(); | |
}); | |
} | |
function _test(name, fn, cb) { | |
testCount = 0; | |
currentTest = name; | |
magik.dixit(`Testing ${name}...`); | |
try{ | |
if (fn) { | |
asyncTest = (fn.length > 0); | |
if (!asyncTest) { | |
fn(); | |
cb(null, `§a${name} passed ${testCount} assertions`); | |
} else { // asyncTest | |
asyncTimeout = magik.setTimeout(() => { | |
magik.dixit(`§6${currentTest} timed out on #${testCount}`); | |
}, 8000); | |
fn(() => { | |
cb(null, `§a${name} passed ${testCount} assertions`); | |
magik.clearTimeout(asyncTimeout); | |
}); | |
} | |
} else { | |
return; | |
} | |
} catch(e) { | |
cb([`§6${name} failed test #${testCount}`, e.message]); | |
} | |
} | |
const test = (name, fn) => { | |
tests.push({ name, fn }); | |
runTest(); | |
} | |
const expect = value => ({ | |
toBe: expected => { | |
testCount ++; | |
if (value !== expected) { | |
const msg = `Expected: ${expected}. Actual: ${value}`; | |
if (asyncTest) { | |
magik.dixit(`§6${currentTest} failed test #${testCount}`); | |
magik.dixit(msg); | |
} | |
throw new Error(msg); | |
} | |
return true; | |
} | |
}); | |
const run = cmd => { | |
const plugin = magik.getPlugin(); | |
const sender = magik.getSender(); | |
plugin.getServer().dispatchCommand(sender, cmd); | |
} | |
magik.dixit(`§6=============================`); | |
magik.dixit(`§3Testing Magik API version ${magik.version()}`); | |
test('magik.hic()', () => { | |
run(`mv tp world-intro`); | |
const here = magik.hic(); | |
expect(here.getX()).toBe(-258.0); | |
expect(here.getY()).toBe(71.0); | |
expect(here.getZ()).toBe(-70.0); | |
expect(here.getPitch()).toBe(0.0); | |
expect(here.getYaw()).toBe(0.0); | |
expect(here.getWorld().getName()).toBe('world-intro'); | |
}); | |
test('magik.aspecto()', () => { | |
run(`mv tp world-intro`); | |
const there = magik.aspecto(); | |
expect(there.getX()).toBe(-258.0); | |
expect(there.getY()).toBe(73.0); | |
expect(there.getZ()).toBe(-47.0); | |
expect(there.getPitch()).toBe(0.0); | |
expect(there.getYaw()).toBe(0.0); | |
}); | |
test('magik.ianuae()', done => { | |
run(`mv tp world-intro`); | |
const there = magik.aspecto(); | |
magik.ianuae(there); | |
magik.setTimeout(() => { | |
const here = magik.hic(); | |
expect(Math.round(here.getX())).toBe(-258); | |
expect(here.getY()).toBe(73.0); | |
expect(here.getZ()).toBe(-47.0); | |
done(); | |
}, 1000); | |
}); | |
test('magik.memento()', () => { | |
run(`mv tp world-intro`); | |
const _here = magik.hic(); | |
magik.memento('intro', _here); | |
const here = magik.exmemento('intro'); | |
expect(here.getX()).toBe(-258.0); | |
expect(here.getY()).toBe(71.0); | |
expect(here.getZ()).toBe(-70.0); | |
expect(here.getPitch()).toBe(0.0); | |
expect(here.getYaw()).toBe(0.0); | |
expect(here.getWorld().getName()).toBe('world-intro'); | |
}); | |
test('eventbus', () => { | |
const here = magik.hic(); | |
let _bridge; | |
const bridge = { | |
X: -264.30257126150656, | |
Y: 66, | |
Z: -34.658305468652806, | |
Yaw: -0.750007152557373, | |
Pitch: 8.850008010864258 | |
}; | |
here.setX(bridge.X); | |
here.setY(bridge.Y); | |
here.setZ(bridge.Z); | |
here.setYaw(bridge.Yaw); | |
here.setPitch(bridge.Pitch); | |
magik.ianuae(here); | |
const there = magik.hic(); | |
expect(there.getX()).toBe(bridge.X); | |
expect(there.getY()).toBe(bridge.Y); | |
expect(there.getZ()).toBe(bridge.Z); | |
expect(there.getYaw()).toBe(bridge.Yaw); | |
expect(there.getPitch()).toBe(bridge.Pitch); | |
eventbus.subscribe('_test', (msg) => { | |
_bridge = msg.data; | |
}); | |
eventbus.publish('_test', magik.toJSON(there)); | |
run(`mv tp world-intro`); | |
const _here = magik.hic(); | |
expect(_here.getX()).toBe(-258.0); | |
expect(_here.getY()).toBe(71.0); | |
expect(_here.getZ()).toBe(-70.0); | |
expect(_here.getPitch()).toBe(0.0); | |
expect(_here.getYaw()).toBe(0.0); | |
expect(_here.getWorld().getName()).toBe('world-intro'); | |
magik.ianuae(magik.fromJSON(_bridge)); | |
const _there = magik.hic(); | |
expect(_there.getX()).toBe(bridge.X); | |
expect(_there.getY()).toBe(bridge.Y); | |
expect(_there.getZ()).toBe(bridge.Z); | |
expect(_there.getYaw()).toBe(bridge.Yaw); | |
expect(_there.getPitch()).toBe(bridge.Pitch); | |
}); | |
test('Eventemitter', () => { | |
const e = new EventEmitter(), test_data = 'test data', event = '_event'; | |
let line; | |
expect(line).toBe(undefined); | |
e.on('_event', data => line = data); | |
e.emit('_event', test_data); | |
expect(line).toBe(test_data); | |
}); | |
test('Promise', done => { | |
const testString = "Hello World"; | |
const a = new Promise((resolve, reject) => resolve(testString)); | |
a.then(msg => { | |
expect(msg).toBe(testString); | |
done(); | |
}); | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function sb(repeats = 200, delay = 300) { | |
magik.dixit('Snowball!'); | |
const sender = magik.getSender(); | |
const snowball = magik.type("entity.Snowball").class; | |
const hurl = (thing) => () => sender.launchProjectile(thing) | |
const volley = () => magik.doNTimes(hurl(snowball), repeats, delay, null); | |
magik.doNTimes(volley, repeats, delay*10, null); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function sc() { | |
const player = magik.getSender(); | |
player.setGameMode(org.bukkit.GameMode.CREATIVE); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function see(duration = 500) { | |
magik.noxvida(duration); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function sendLoreToUser(username, lorename) { | |
const domain = 'http://localhost:8086'; | |
const route = 'api/v1/sendLoreToUser'; | |
const API_key = '6B73F512-5C17-431B-831D-F368BA6CC0D1'; | |
const url = `${domain}/${route}/${API_key}/${username}/${lorename}`; | |
http.dispatchMQ('GET', url, null); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function setFoodLevel(level) { | |
magik.getSender().setFoodLevel(level); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Set up health and food levels for testing MCT1 | |
*/ | |
const magik = magikcraft.io; | |
function smct1() { | |
const player = magik.getSender(); | |
const maxHealth = player.getMaxHealth(); | |
player.setHealth(maxHealth / 3); | |
magik.dixit('Setting health to 30%'); | |
magik.dixit('Setting food level to 3'); | |
magik.getSender().setFoodLevel(3); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function sname() { | |
magik.dixit(SERVERNAME); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var magik = magikcraft.io; | |
function spawnz(typ='ZOMBIE', n = 50, times = 5, baseloc){ | |
const EntityType = magik.type("entity.EntityType"); | |
const sender = magik.getSender(); | |
if (typ == '.') { | |
typ = undefined; | |
} | |
if (!baseloc) { | |
baseloc = create_spawn_point(magik.aspecto()); | |
} | |
for (let i = 0; i < n; i++) { | |
const loc = rndBlock(baseloc.getBlock().getRelative(0, 0, 0).location, 4,0).location; | |
const typ2 = typ || rnd_monster_type(); | |
const mob = loc.getWorld().spawnEntity(loc, EntityType[typ2]); | |
const v = sender.getEyeLocation().getDirection().multiply(2); | |
const dir = Math.PI*2*Math.random(); | |
const scale = 0.45; | |
v.setX(scale*Math.sin(dir)); | |
v.setY(scale*2); | |
v.setZ(scale*Math.cos(dir)); | |
mob.setVelocity(v); | |
} | |
times -= 1; | |
if (times > 0) { | |
const task = magik.setTimeout( | |
() => { | |
spawnz(typ, n, times, baseloc); | |
}, | |
200 | |
); | |
} | |
} | |
function create_spawn_point(loc) { | |
const block = loc.getBlock(); | |
const r = 1; | |
const depth = 3; | |
const Material = magik.type("Material"); | |
const spawnloc = block.getRelative(0, -depth, 0).getLocation(); | |
//explicitly clear a space | |
for (let y = -depth; y <= 0; y++) { | |
var rr = Math.floor(r); //for changing the shape of the hole. I liked no slope, in the end | |
for (let x = -rr; x <= rr; x++) { | |
for (let z = -rr; z <= rr; z++) { | |
block.getRelative(x,y,z).setType(Material['AIR']); | |
} | |
} | |
} | |
//explode that space, for effect and to mess up the shape a little | |
//spawnloc.getWorld().createExplosion(spawnloc,3); | |
return spawnloc; | |
} | |
function rnd_monster_type() { | |
return 'ZOMBIE' | |
} | |
function rnd_from_array(arry) { | |
return arry[Math.floor(Math.random()*arry.length)]; | |
} | |
function randn_bm() { | |
const u = 1 - Math.random(); // Subtraction to flip [0, 1) to (0, 1]. | |
const v = 1 - Math.random(); | |
return Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v ); | |
} | |
function rnorm_unit(count) { | |
let ret = 0; | |
for (let i = 0; i < count; i++) { | |
ret += Math.random(); | |
} | |
return ret/count; | |
} | |
function rnorm(mean, sd) { | |
return randn_bm() * sd + mean; | |
} | |
function runif(from, to) { | |
return scale(Math.random(), from, to); | |
} | |
function scale(r, from, to) { | |
return Math.floor(r*(to - from)+from) | |
} | |
function rndBlock(loc, radius, height) { | |
return loc.getBlock().getRelative(rnorm(0, radius/5), runif(0, height), rnorm(0, radius/5)); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function speed(s = 50) { | |
const velocity = s/100; | |
magik.getSender().setWalkSpeed(velocity); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Capture a video of your movement in Minecraft. | |
*/ | |
const magik = magikcraft.io; | |
function spy(name= "--help", seconds=20, fps = 20) { | |
if (name === "--help") { | |
magik.dixit("Usage: /cast spy [name] [secs]"); | |
magik.dixit("Usage: /cast spy [name] [secs] [fps]"); | |
return; | |
} | |
global.film = {}; | |
film.frames = []; | |
film.metadata = { | |
fps, | |
seconds | |
}; | |
const interval = 1000 / fps; | |
const totalFrames = fps * seconds; | |
magik.dixit(`Recording ${seconds}s at ${fps} fps`); | |
const player = magik.getPlugin().getServer().getPlayer(name); | |
let count = 0; | |
const camera = magik.setInterval(()=>{ | |
const location = player.getLocation(); | |
film.frames.push(location); | |
count ++; | |
if (count > totalFrames) { | |
magik.clearInterval(camera); | |
magik.dixit('Finished recording!'); | |
} | |
}, interval); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function stest() { | |
eventbus.subscribe('test.topic', msg => console.log(msg.data.toString())); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
const msg = require('testpkg'); | |
function straightOuttaGitHub() { | |
magik.dixit(msg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
const locationTopic = 'locations'; | |
// Consume player locations from eventbus | |
function subLocation(){ | |
// Create a local location registry | |
if (!global.locations) { | |
global.locations = {}; | |
} | |
eventbus.subscribe(locationTopic, event => { | |
const who = event.data.name; | |
const where = event.data.location; | |
global.locations[who] = where; | |
magik.dixit(`Received location for ${who}`); | |
magik.dixit(where); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
const topic = 'sitapati.msg'; | |
function subtest() { | |
const say = magik.dixit; | |
if (global.sub) { | |
say('Cancelling existing subscription'); | |
eventbus.unsubscribeFromTopic(topic); | |
global.sub = undefined; | |
} | |
say('Subscribing ') | |
global.sub = eventbus.subscribe( | |
topic, | |
data => { | |
magik.dixit(data.type); | |
eval('magik.dixit(typeof data.data);'); | |
if (typeof data.data == 'string') { | |
magik.dixit(data.data); | |
} else { | |
magik.dixit(JSON.parse(data.data)); | |
} | |
} | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
var _superb = require('superb'); | |
function superb(count = 1) { | |
const times = Math.min(20, count); | |
if (times == 0) { | |
return; | |
} | |
magik.setTimeout(() => magik.dixit(_superb()), times * 1600); | |
superb(times - 1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function sword() { | |
const MATERIAL = Java.type("org.bukkit.Material"); | |
const ItemStack = Java.type("org.bukkit.inventory.ItemStack"); | |
const thing = new ItemStack(MATERIAL.DIAMOND_SWORD); | |
magik.getSender().getInventory().addItem(thing); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
const Bars = magik.Bars; | |
const TextComponent = magik.TextComponent; | |
let T1; | |
function t1() { | |
T1 = { | |
state: | |
{ | |
insulinOnBoard: 0.2, | |
bgl: 0.4 | |
} | |
} | |
var insulinBar = Bars.addBar(magik.getSender(), | |
new TextComponent("Insulin"), | |
Bars.Color.BLUE, | |
Bars.Style.NOTCHED_20, | |
T1.state.insulinOnBoard, // Progress (0.0 - 1.0) | |
); | |
var bglBar = Bars.addBar(magik.getSender(), | |
new TextComponent("BGL"), | |
Bars.Color.RED, | |
Bars.Style.NOTCHED_20, | |
T1.state.bgl // Progress (0.0 - 1.0) | |
); | |
T1.bars = { | |
insulin: insulinBar, | |
bgl: bglBar | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function teleport(name = "default.place") { | |
const place = magik.memento.getItem(name); | |
if (place) { | |
magik.ianuae(place); | |
} else { | |
magik.dixit(`No place called "${name}"`); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { bar, color, style } = require('magikcraft-lore-ui-bar'); | |
const magik = magikcraft.io; | |
const setTimeout = magik.setTimeout; | |
magik.dixit('Hi3'); | |
function test() { | |
const b = bar() | |
.text("Hello") | |
.color(color.GREEN) | |
.style(style.NOTCHED_10) | |
.progress(50) | |
.show(); | |
setTimeout(() => b.color(color.RED), 2000); | |
setTimeout(() => b.progress(70), 4000); | |
setTimeout(() => b.text("Goodbye").progress(65).color(color.PURPLE), 6000); | |
setTimeout(() => b.destroy(), 8000); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
const msg = require('testpkg1'); | |
function test1() { | |
magik.dixit(msg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
const msg = require('testpkg2'); | |
function testor() { | |
magik.dixit(msg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function tloc() { | |
const here = magik.hic(); | |
here.setZ(here.getZ() + 5); | |
magik.ianuae(here); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
const locationTopic = 'locations'; | |
function tp2p(name = '@@INIT'){ | |
// If global.locations doesn't exist, we are not subscribed yet | |
if (!global.locations) { | |
global.locations = {}; | |
eventbus.subscribe(locationTopic, event => { | |
const who = event.data.name; | |
const where = event.data.location; | |
global.locations[who] = where; | |
magik.dixit(`Received location for ${who}`); | |
}); | |
magik.dixit(`Subscribed to ${locationTopic}`); | |
} | |
if (name === '@@INIT') { | |
return; | |
} | |
if (!global.locations[name]) { | |
magik.dixit(`No published location found for ${name}!`); | |
return; | |
} | |
const whereJSON = global.locations[name]; | |
// Turn the JSON into a BukkitLocation | |
const where = magik.fromJSON(whereJSON); | |
magik.ianuae(where); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function ttest() { | |
magik.setInterval(() => magik.dixit('Tick'), 1000); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function unsubscribe() { | |
global.sub.cancel(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function where() { | |
magik.dixit('Player locations:'); | |
magik.getPlugin().getServer().getOnlinePlayers().forEach(player => magik.dixit(`§6${player.getName()} : §a${player.getLocation().getWorld().getName()}`)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
const Do = require('magikcraft-lore-do').Do; | |
function yo() { | |
Do(15).times(magik.infierno).withDelay(300).now(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function z(n = 50) { | |
function run(cmd) { | |
const sudo = magik.getPlugin().getServer().getConsoleSender(); | |
magik.getPlugin().getServer().dispatchCommand(sudo, cmd); | |
} | |
for (let i = 0; i < n; i++) { | |
run('summon zombie'); | |
magik.dixit(`z ${i}`); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment