mirror of
https://github.com/danbulant/flying-squid
synced 2026-06-16 13:01:12 +00:00
Merge pull request #319 from PrismarineJS/remove-babel
Remove babel and unused dependencies
This commit is contained in:
commit
62ac46e8e3
7 changed files with 31 additions and 83 deletions
|
|
@ -1,3 +1,3 @@
|
|||
machine:
|
||||
node:
|
||||
version: 6
|
||||
version: 8
|
||||
|
|
|
|||
48
gulpfile.js
48
gulpfile.js
|
|
@ -1,48 +0,0 @@
|
|||
var gulp = require('gulp');
|
||||
|
||||
var plumber = require('gulp-plumber');
|
||||
var babel = require('gulp-babel');
|
||||
var options = {
|
||||
presets: ['babel-preset-stage-0','es2015'],
|
||||
plugins:['transform-runtime']
|
||||
};
|
||||
|
||||
var sourcemaps = require('gulp-sourcemaps');
|
||||
|
||||
gulp.task('compile', function() {
|
||||
return gulp
|
||||
.src('src/**/*.js')
|
||||
.pipe(plumber({
|
||||
errorHandler: function(err) {
|
||||
console.error(err.stack);
|
||||
this.emit('end');
|
||||
}
|
||||
}))
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(babel(options))
|
||||
.pipe(plumber.stop())
|
||||
.pipe(sourcemaps.write('maps/'))
|
||||
.pipe(gulp.dest('dist/'));
|
||||
});
|
||||
|
||||
gulp.task('compileTest', function() {
|
||||
return gulp
|
||||
.src('test/**/*.js')
|
||||
.pipe(plumber({
|
||||
errorHandler: function(err) {
|
||||
console.error(err.stack);
|
||||
this.emit('end');
|
||||
}
|
||||
}))
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(babel(options))
|
||||
.pipe(plumber.stop())
|
||||
.pipe(sourcemaps.write('maps/'))
|
||||
.pipe(gulp.dest('distTest/'));
|
||||
});
|
||||
|
||||
gulp.task('watch', function() {
|
||||
return gulp.watch('src/**/*.js', ['compile']);
|
||||
});
|
||||
|
||||
gulp.task('default', ['compile','compileTest']);
|
||||
2
index.js
2
index.js
|
|
@ -1 +1 @@
|
|||
module.exports = require('./dist/index.js');
|
||||
module.exports = require('./src/index.js');
|
||||
|
|
|
|||
25
package.json
25
package.json
|
|
@ -3,7 +3,7 @@
|
|||
"description": "A minecraft server written in node.js",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"author": "mhsjlw <mhsjlw@aol.com>",
|
||||
"author": "mhsjlw <mhsjlw@users.noreply.github.com>",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "rom1504",
|
||||
|
|
@ -11,21 +11,20 @@
|
|||
}
|
||||
],
|
||||
"bin": {
|
||||
"flying-squid": "./app.js"
|
||||
"flying-squid": "app.js"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "gulp && require-self",
|
||||
"test": "mocha --reporter spec distTest"
|
||||
"prepare": "require-self",
|
||||
"test": "mocha --reporter spec"
|
||||
},
|
||||
"keywords": [],
|
||||
"licenses": {
|
||||
"type": "MIT"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
"node": ">=8"
|
||||
},
|
||||
"dependencies": {
|
||||
"babel-runtime": "^6.5.0",
|
||||
"diamond-square": "1.0.0",
|
||||
"emit-then": "^2.0.0",
|
||||
"event-promise": "^0.0.1",
|
||||
|
|
@ -34,10 +33,7 @@
|
|||
"minecraft-protocol": "^1.0.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
"moment": "^2.10.6",
|
||||
"node-dir": "^0.1.9",
|
||||
"node-promise-es6": "^0.3.0",
|
||||
"node-uuid": "^1.4.3",
|
||||
"prismarine-block": "^1.0.1",
|
||||
"prismarine-chunk": "^1.0.1",
|
||||
"prismarine-entity": "^0.2.0",
|
||||
"prismarine-item": "^1.0.1",
|
||||
|
|
@ -46,6 +42,7 @@
|
|||
"prismarine-world": "^2.0.0",
|
||||
"random-seed": "^0.3.0",
|
||||
"range": "^0.0.3",
|
||||
"request": "^2.83.0",
|
||||
"request-promise": "^4.1.0",
|
||||
"requireindex": "~1.1.0",
|
||||
"spiralloop": "^1.0.2",
|
||||
|
|
@ -60,17 +57,9 @@
|
|||
"url": "http://github.com/PrismarineJS/flying-squid/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-plugin-transform-runtime": "^6.5.0",
|
||||
"babel-preset-es2015": "^6.5.0",
|
||||
"babel-preset-stage-0": "^6.5.0",
|
||||
"chai": "^3.2.0",
|
||||
"doctoc": "^1.0.0",
|
||||
"gulp": "^3.8.11",
|
||||
"gulp-babel": "^6.1.2",
|
||||
"gulp-plumber": "^1.0.1",
|
||||
"gulp-sourcemaps": "^2.0.0",
|
||||
"longjohn": "^0.2.8",
|
||||
"mineflayer": "^1.7.5",
|
||||
"mineflayer": "^2.6.1",
|
||||
"mocha": "^3.0.0",
|
||||
"require-self": "^0.1.0"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
const Behavior = require("flying-squid").Behavior;
|
||||
|
||||
module.exports.server = function(serv) {
|
||||
serv.behavior = new Behavior(serv);
|
||||
serv.behavior = Behavior(serv);
|
||||
};
|
||||
|
||||
module.exports.entity = function (entity) {
|
||||
entity.behavior = new Behavior(entity);
|
||||
};
|
||||
entity.behavior = Behavior(entity);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,8 +3,12 @@ const spiralloop = require('spiralloop');
|
|||
const World = require('prismarine-world')(require("../version"));
|
||||
|
||||
const generations=require("flying-squid").generations;
|
||||
import {fs} from 'node-promise-es6';
|
||||
import {level} from 'prismarine-provider-anvil';
|
||||
const { promisify } = require('util');
|
||||
const fs = require('fs');
|
||||
const { level } = require('prismarine-provider-anvil');
|
||||
|
||||
const fsStat = promisify(fs.stat);
|
||||
const fsMkdir = promisify(fs.mkdir);
|
||||
|
||||
module.exports.server=async function(serv,{worldFolder,generation={"name":"diamond_square","options":{"worldHeight":80}}}={}) {
|
||||
const newSeed=generation.options.seed || Math.floor(Math.random()*Math.pow(2, 31));
|
||||
|
|
@ -13,10 +17,10 @@ module.exports.server=async function(serv,{worldFolder,generation={"name":"diamo
|
|||
if(worldFolder) {
|
||||
regionFolder = worldFolder + "/region";
|
||||
try {
|
||||
const stats = await fs.stat(regionFolder);
|
||||
const stats = await fsStat(regionFolder);
|
||||
}
|
||||
catch (err) {
|
||||
await fs.mkdir(regionFolder);
|
||||
await fsMkdir(regionFolder);
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ const settings = require('../config/default-settings');
|
|||
const mineflayer = require("mineflayer");
|
||||
const assert = require('chai').assert;
|
||||
const Vec3 = require('vec3').Vec3;
|
||||
const Item = require('prismarine-item')("1.8");
|
||||
|
||||
function assertPosEqual(actual,expected) {
|
||||
assert.isBelow(actual.distanceTo(expected),1,"expected: "+expected+", actual: "+actual+"\n");
|
||||
|
|
@ -11,7 +12,7 @@ function assertPosEqual(actual,expected) {
|
|||
const once = require('event-promise');
|
||||
|
||||
describe("Server with mineflayer connection", function() {
|
||||
this.timeout(10 * 60 * 1000);
|
||||
this.timeout(60 * 1000);
|
||||
let bot;
|
||||
let bot2;
|
||||
let serv;
|
||||
|
|
@ -61,7 +62,7 @@ describe("Server with mineflayer connection", function() {
|
|||
}
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(10 * 60 * 1000);
|
||||
this.timeout(60 * 1000);
|
||||
const options = settings;
|
||||
options["online-mode"]=false;
|
||||
options["port"]=25566;
|
||||
|
|
@ -74,12 +75,14 @@ describe("Server with mineflayer connection", function() {
|
|||
bot = mineflayer.createBot({
|
||||
host: "localhost",
|
||||
port: 25566,
|
||||
username: "bot"
|
||||
username: "bot",
|
||||
version: "1.8"
|
||||
});
|
||||
bot2 = mineflayer.createBot({
|
||||
host: "localhost",
|
||||
port: 25566,
|
||||
username: "bot2"
|
||||
username: "bot2",
|
||||
version: "1.8"
|
||||
});
|
||||
|
||||
await Promise.all([once(bot,'login'),once(bot2,'login')]);
|
||||
|
|
@ -111,7 +114,7 @@ describe("Server with mineflayer connection", function() {
|
|||
}
|
||||
|
||||
it("can dig",async function () {
|
||||
this.timeout(10 * 60 * 1000);
|
||||
this.timeout(60 * 1000);
|
||||
await Promise.all([waitSpawnZone(bot,2),waitSpawnZone(bot2,2),onGround(bot),onGround(bot2)]);
|
||||
|
||||
const pos=bot.entity.position.offset(0,-1,0).floored();
|
||||
|
|
@ -124,7 +127,7 @@ describe("Server with mineflayer connection", function() {
|
|||
|
||||
|
||||
it("can place a block",async function () {
|
||||
this.timeout(10 * 60 * 1000);
|
||||
this.timeout(60 * 1000);
|
||||
await Promise.all([waitSpawnZone(bot,2),waitSpawnZone(bot2,2),onGround(bot),onGround(bot2)]);
|
||||
|
||||
const pos=bot.entity.position.offset(0,-2,0).floored();
|
||||
|
|
@ -134,7 +137,7 @@ describe("Server with mineflayer connection", function() {
|
|||
assertPosEqual(newBlock.position,pos);
|
||||
assert.equal(newBlock.type,0,"block "+pos+" should have been dug");
|
||||
|
||||
bot.creative.setInventorySlot(36,new mineflayer.Item(1,1));
|
||||
bot.creative.setInventorySlot(36, new Item(1,1));
|
||||
await new Promise((cb) => {
|
||||
bot.inventory.on("windowUpdate",(slot,oldItem,newItem) => {
|
||||
if(slot==36 && newItem && newItem.type==1)
|
||||
|
|
@ -231,7 +234,7 @@ describe("Server with mineflayer connection", function() {
|
|||
serv.getPlayer("bot").op=true;
|
||||
});
|
||||
it("can use /setblock",async() => {
|
||||
await once(bot,'chunkColumnLoad');
|
||||
await once(bot, 'chunkColumnLoad');
|
||||
bot.chat('/setblock 1 2 3 95 0');
|
||||
let [,newBlock]=await once(bot,'blockUpdate:'+new Vec3(1,2,3),{array:true});
|
||||
assert.equal(newBlock.type,95);
|
||||
|
|
|
|||
Loading…
Reference in a new issue