Skip to content

Commit 797b87d

Browse files
committed
linting modules
1 parent 0576344 commit 797b87d

38 files changed

+458
-434
lines changed

.eslintrc.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
module.exports = {
2+
"env": {
3+
"browser": true,
4+
"commonjs": true,
5+
"nashorn": true
6+
},
7+
"globals": {
8+
"__plugin": true,
9+
"server": true,
10+
"events": true,
11+
"addUnloadHandler": true,
12+
"__dirname": true,
13+
"persist": true,
14+
"isOp": true,
15+
"echo": true
16+
},
17+
"extends": "eslint:recommended",
18+
"rules": {
19+
"indent": [
20+
"error",
21+
2
22+
],
23+
"no-fallthrough": [
24+
0
25+
],
26+
"no-useless-escape": [
27+
0
28+
],
29+
"quotes": [
30+
"error",
31+
"single"
32+
],
33+
"no-console": [
34+
0
35+
],
36+
"semi": [
37+
"error",
38+
"always"
39+
]
40+
}
41+
};

src/main/js/modules/at.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
'use strict';
2-
/*global events, module, require, __plugin, setInterval, clearInterval, setTimeout, addUnloadHandler*/
32
var utils = require('utils');
43
/************************************************************************
54
## The at Module
@@ -14,11 +13,11 @@ The utils.at() function will perform a given task at a given time in the
1413
1514
#### Parameters
1615
17-
* time24hr : The time in 24hr form - e.g. 9:30 in the morning is '09:30' while
16+
* time24hr : The time in 24hr form - e.g. 9:30 in the morning is '09:30' while
1817
9:30 pm is '21:30', midnight is '00:00' and midday is '12:00'
19-
* callback : A javascript function which will be invoked at the given time.
20-
* worlds : (optional) An array of worlds. Each world has its own clock. If no array of worlds is specified, all the server's worlds are used.
21-
* repeat : (optional) true or false, default is true (repeat the task every day)
18+
* callback : A javascript function which will be invoked at the given time.
19+
* worlds : (optional) An array of worlds. Each world has its own clock. If no array of worlds is specified, all the server's worlds are used.
20+
* repeat : (optional) true or false, default is true (repeat the task every day)
2221
2322
#### Example
2423
@@ -67,7 +66,7 @@ function at(time24hr, callback, pWorlds, repeat) {
6766
utils.foreach( pWorlds, function ( world ) {
6867
atAddTask( timeMins, callback, world, repeat);
6968
});
70-
};
69+
}
7170
var atTasks = {};
7271

7372
function tasksToString(){
@@ -77,16 +76,16 @@ function tasksToString(){
7776
for (var time in atTasks[world]){
7877
var scheduledFuncs = atTasks[world][time];
7978
for (var i = 0;i < scheduledFuncs.length; i++){
80-
result += ' ' + time + ': ' + scheduledFuncs[i].constructor + '\n';
79+
result += ' ' + time + ': ' + scheduledFuncs[i].constructor + '\n';
8180
}
8281
}
8382
result += '(current world time: ' + utils.time24(world) + ')\n';
8483
}
8584
return result;
8685
}
8786
/*
88-
constructs a function which will be called every x ticks to
89-
track the schedule for a given world
87+
constructs a function which will be called every x ticks to
88+
track the schedule for a given world
9089
*/
9190
function atMonitorFactory(world){
9291
var worldName = ''+ world.name;
@@ -110,16 +109,16 @@ function atMonitorFactory(world){
110109

111110
var tasks = worldSchedule[lastRun++];
112111
if (!tasks){
113-
continue;
112+
continue;
114113
}
115114
utils.foreach(tasks, function(task, i){
116-
if (!task){
117-
return;
118-
}
119-
setTimeout(task.callback.bind(null, timeMins, world), 1);
120-
if (!task.repeat){
121-
tasks[i] = null;
122-
}
115+
if (!task){
116+
return;
117+
}
118+
setTimeout(task.callback.bind(null, timeMins, world), 1);
119+
if (!task.repeat){
120+
tasks[i] = null;
121+
}
123122
});
124123
}
125124
};

src/main/js/modules/blockhelper.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22
/*global module, exports, require, Packages, __plugin, server*/
33
var blocks = require('blocks'),
4-
bountiful = false;
4+
bountiful = false;
55

66
if (__plugin.canary){
77
bountiful = parseFloat(server.canaryModVersion) > 1.7;
@@ -78,11 +78,11 @@ function property( block ){
7878
set: function(name,value){
7979
var bp = block.getPropertyForName(name);
8080
if (bp === null){
81-
console.warn(block + ' has no property named ' + name);
82-
return result;
81+
console.warn(block + ' has no property named ' + name);
82+
return result;
8383
}
8484
if (lookup[bp.name]){
85-
value = lookup[bp.name][value];
85+
value = lookup[bp.name][value];
8686
}
8787
block.setPropertyValue(bp, value);
8888
return result;
@@ -104,12 +104,12 @@ function applyFacing( block, metadata ){
104104
switch( block.typeId ){
105105
case blocks.sign:
106106
case blocks.ladder:
107-
// bug: furnace, chest, dispenser don't always use the right metadata
108107
case blocks.furnace:
109108
case blocks.furnace_burning:
110109
case blocks.chest:
111110
case blocks.enderchest:
112111
case blocks.dispenser:
112+
// bug: furnace, chest, dispenser don't always use the right metadata
113113
face( [null,null,'north','south','west','east'][metadata] );
114114
break;
115115
case blocks.torch:
@@ -144,9 +144,9 @@ function applyRotation( block, metadata ){
144144
function applyVariant( block, metadata ){
145145
var cmQuartzProperties = Packages.net.canarymod.api.world.blocks.properties.helpers.QuartzProperties;
146146
switch (block.typeId){
147-
case blocks.quartz:
148-
cmQuartzProperties.applyVariant(block, cmQuartzProperties.Variant.valueOf(metadata));
149-
break;
147+
case blocks.quartz:
148+
cmQuartzProperties.applyVariant(block, cmQuartzProperties.Variant.valueOf(metadata));
149+
break;
150150
}
151151
}
152152
function applyProperties( block, metadata ){

src/main/js/modules/blocks.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ var blocks = {
121121
dark_oak: '126:13'
122122
},
123123
snow: 78,
124-
stone: 44,
125124
oak: 126,
126125
spruce: '126:1',
127126
birch: '126:2',
@@ -184,7 +183,6 @@ var blocks = {
184183
clay: 82,
185184
sugar_cane: 83,
186185
jukebox: 84,
187-
fence: 85,
188186
pumpkin: 86,
189187
netherrack: 87,
190188
soulsand: 88,
@@ -218,7 +216,6 @@ var blocks = {
218216
mycelium: 110,
219217
lily_pad: 111,
220218
nether: 112,
221-
nether_fence: 113,
222219
netherwart: 115,
223220
table_enchantment: 116,
224221
brewing_stand: 117,
@@ -321,10 +318,12 @@ var blocks = {
321318
acacia: 187
322319
},
323320
fence: {
321+
oak: 85,
322+
nether: 113,
324323
spruce: 188,
325324
birch: 189,
326325
jungle: 190,
327-
oak: 191,
326+
darkoak: 191,
328327
acacia: 192
329328
}
330329
};
@@ -341,12 +340,12 @@ var colorized_blocks = [
341340

342341
for (var i = 0, len = colorized_blocks.length; i < len; i++) {
343342
var block = colorized_blocks[i],
344-
data_value = blocks[block].white;
343+
data_value = blocks[block].white;
345344

346345
for (var color in colors) {
347346
blocks[block][color] = data_value + ':' + colors[color];
348347
}
349-
};
348+
}
350349

351350
/*
352351
rainbow colors - a convenience

src/main/js/modules/bukkit/fireworks.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ function bukkitFirework( location ) {
3333
var c1 = getColor( r1i );
3434
var c2 = getColor( r2i );
3535
var effectBuilder = bkFireworkEffect.builder()
36-
.flicker( Math.round( Math.random() ) == 0 )
37-
.withColor( c1 )
38-
.withFade( c2 )
39-
.trail( Math.round( Math.random() ) == 0 );
36+
.flicker( Math.round( Math.random() ) == 0 )
37+
.withColor( c1 )
38+
.withFade( c2 )
39+
.trail( Math.round( Math.random() ) == 0 );
4040
effectBuilder['with']( type );
4141
var effect = effectBuilder.build();
4242
fwm.addEffect( effect );

src/main/js/modules/bukkit/input.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
var bkPrompt = org.bukkit.conversations.Prompt,
2-
bkConversationFactory = org.bukkit.conversations.ConversationFactory;
2+
bkConversationFactory = org.bukkit.conversations.ConversationFactory;
33

44
function bukkitAsyncInput( sender, promptMesg, callback) {
55
var repeat = function(){
66
bukkitAsyncInput( sender, promptMesg, callback);
77
};
88
var prompt = new bkPrompt( {
9-
getPromptText: function( ctx ) {
9+
getPromptText: function(/* ctx */) {
1010
return promptMesg;
1111
},
1212
acceptInput: function( ctx, value ) {
1313
callback.apply( { repeat: repeat, sender: sender, message: promptMesg, value: value },
14-
[value, sender, repeat]);
14+
[value, sender, repeat]);
1515
return null;
1616
},
17-
blocksForInput: function( ctx ) {
17+
blocksForInput: function(/* ctx */) {
1818
return true;
1919
}
2020
});

src/main/js/modules/bukkit/items.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ for (var i = 0;i < materials.length; i++ ){
1515
items[name] = (function(material){
1616
return function(amount){
1717
if (typeof amount == 'undefined'){
18-
return material;
18+
return material;
1919
}
2020
if (typeof amount == 'number'){
21-
return new bkItemStack(material, amount);
21+
return new bkItemStack(material, amount);
2222
} else {
23-
return amount == material;
23+
return amount == material;
2424
}
2525
};
2626
})(materials[i]);

src/main/js/modules/bukkit/recipes.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
var items = require('items');
21
var bkShapedRecipe = org.bukkit.inventory.ShapedRecipe;
32

43
exports.add = function( recipe ){

src/main/js/modules/bukkit/sounds.js

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,27 @@ for ( ; i < len; i++ ) {
1414
return function()
1515
{
1616
switch (arguments.length) {
17-
case 3:
18-
exports.play(sound, arguments[0], arguments[1], arguments[2]);
19-
break;
20-
case 2:
21-
// TODO: possible combinations:
22-
// location, volume,
23-
// volume pitch
24-
exports.play(sound, arguments[0],arguments[1]);
25-
break;
26-
case 1:
27-
exports.play(sound, arguments[0]);
28-
break;
29-
case 0:
30-
// play the sound at full vol, medium pitch for all players
31-
//
32-
foreach(server.onlinePlayers,function(player){
33-
exports.play(sound, player, 1, 0);
34-
});
35-
default:
36-
}
17+
case 3:
18+
exports.play(sound, arguments[0], arguments[1], arguments[2]);
19+
break;
20+
case 2:
21+
// TODO: possible combinations:
22+
// location, volume,
23+
// volume pitch
24+
exports.play(sound, arguments[0],arguments[1]);
25+
break;
26+
case 1:
27+
exports.play(sound, arguments[0]);
28+
break;
29+
case 0:
30+
// play the sound at full vol, medium pitch for all players
31+
//
32+
foreach(server.onlinePlayers,function(player){
33+
exports.play(sound, player, 1, 0);
34+
});
35+
break;
36+
default:
37+
}
3738
};
3839
})(sound);
3940
}

src/main/js/modules/canary/input.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ function canaryAsyncInput( sender, promptMesg, callback) {
1111
if (event.player == sender) {
1212
var receivers = event.getReceiverList();
1313
if (receivers.size() == 1 && receivers.contains(sender)){
14-
var value = event.message;
15-
var that = this;
16-
event.setCanceled();
17-
callback.apply( { repeat: repeat, sender: sender, message: promptMesg, value: value },
18-
[value, sender, repeat]);
19-
setTimeout(function(){that.unregister();},10);
14+
var value = event.message;
15+
var that = this;
16+
event.setCanceled();
17+
callback.apply( { repeat: repeat, sender: sender, message: promptMesg, value: value },
18+
[value, sender, repeat]);
19+
setTimeout(function(){that.unregister();},10);
2020
}
2121
}
2222
},'CRITICAL');

0 commit comments

Comments
 (0)