typesforbukkit
Version:
Types For Bukkit
38 lines (23 loc) • 947 B
JavaScript
const fs = require('fs');
const crypto = require('crypto');
const filePath = 'data.js';
var currentHash = "";
function loop() {
var hash = crypto.createHash('sha1');
contents = fs.readFileSync(filePath).toString();
hash.update(contents);
hashOut = hash.digest('base64');
if (hashOut != currentHash) {
// file changed, run replace
console.log('File has changed! Replacing subclass definitions...');
contents = contents.replace(/_\$_/g,'.').replace(/_\$\$f/g,'').replace(/_\$\$r/g,'').replace(/org.bukkit.plugin.java_/g,'org.bukkit.plugin.java');
fs.writeFileSync(filePath,contents);
var newHash = crypto.createHash('sha1');
newHash.update(contents);
hashOut = newHash.digest('base64');
currentHash = hashOut;
}
setTimeout(loop,1000);
}
console.log('Replacer has started, waiting for changes...');
loop();