Skip to content

Commit 76dd318

Browse files
authored
Gracefully fail drone module on 1.15.2+
While we figure out what to do about drone and the new Block API, this gracefully fails on 1.15.2 with a helpful message.
1 parent dae0f9d commit 76dd318

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

src/main/js/modules/drone/index.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,11 +345,22 @@ function makeTypeIdAndDataSetter() {
345345
block.setTypeIdAndData(typeId, data, applyPhysics);
346346
};
347347
} else {
348-
console.log('Drone using CraftEvil.setTypeIdAndData method');
349-
var CraftEvil = Java.type(server.class.package.name + '.util.CraftEvil');
350-
return function(block, typeId, data, applyPhysics) {
351-
CraftEvil.setTypeIdAndData(block, typeId, data, applyPhysics);
352-
};
348+
try {
349+
var CraftEvil = Java.type(server.class.package.name + '.util.CraftEvil');
350+
console.log('Drone using CraftEvil.setTypeIdAndData method');
351+
return function(block, typeId, data, applyPhysics) {
352+
CraftEvil.setTypeIdAndData(block, typeId, data, applyPhysics);
353+
};
354+
} catch (e) {
355+
console.log(
356+
'Drone not available on this server - no setTypeIdAndData support'
357+
);
358+
return function(block, typeId, data, applyPhysics) {
359+
throw new Error(
360+
`Drone not supported on versions > 1.15.1 - no setTypeIdAndData support`
361+
);
362+
};
363+
}
353364
}
354365
}
355366

0 commit comments

Comments
 (0)