Skip to content

Instantly share code, notes, and snippets.

@nitrog0d
Last active December 29, 2020 23:47
Show Gist options
  • Save nitrog0d/006a0174931557593e50dceecd93a348 to your computer and use it in GitHub Desktop.
Save nitrog0d/006a0174931557593e50dceecd93a348 to your computer and use it in GitHub Desktop.
"Rede Obscure" Rankup Spawner Auto Buy
// I made this script to automatically buy spawners in some trash ass Brazilian rankup server called "Rede Obscure"
// Scaffold was used as "auto place"
// It uses LiquidBounce ScriptAPI and needs https://github.com/CzechHek/Core to run, also fuck Nashorn goddamn wtf is this JavaScript
// At the end we got banned but it was fun while it lasted, we broke the economy
// First Minecraft Script, 29/12/20
///api_version=2
var script = registerScript({
name: 'ROSpawnerAutoBuy',
version: '1.0',
authors: ['nitro.']
});
script.import('Core.lib');
var System = Java.type('java.lang.System');
var Arrays = Java.type('java.util.Arrays');
var Integer = Java.type('java.lang.Integer');
var LiquidBounce = Java.type('net.ccbluex.liquidbounce.LiquidBounce');
var prefix = '§7[§bROSpawnerAutoBuy§7] ';
var enabled = false;
var shouldRun = false;
var expectOpenPacket = false;
var expectItemsPacket = false;
var expectClosePacket = false;
var savedWindowId = 0;
module = {
category: 'Nitro',
description: 'Automatically buys spawners in Rede Obscure server',
values: [
buyDelay = value.createInteger('BuyDelay', 0, 0, 0),
buyAmount = value.createInteger('BuyAmount', 1, 0, 1),
buyIndex = value.createInteger('BuyIndex', 19, 0, 19)
],
onEnable: function() {
Chat.print(prefix + '§aModule initialized! Created by §dnitro.#0007');
Chat.print(prefix + '§b§lUse .spawnerautobuy to start!');
enabled = false;
shouldRun = true;
expectOpenPacket = false;
expectItemsPacket = false;
expectClosePacket = false;
savedWindowId = 0;
},
onDisable: function() {
Chat.print(prefix + '§cModule disabled.');
},
onUpdate: function() {
if (enabled) {
if (shouldRun) {
shouldRun = false;
mc.thePlayer.sendChatMessage('/spawners');
expectOpenPacket = true;
}
}
},
onPacket: function(e) {
var packet = e.getPacket().wrapped;
if (packet instanceof S2DPacketOpenWindow && expectOpenPacket) {
if (packet.getWindowTitle().getUnformattedText() === 'Compra de Geradores') {
expectOpenPacket = false;
savedWindowId = packet.getWindowId();
expectItemsPacket = true;
e.cancelEvent();
}
}
if (packet instanceof S30PacketWindowItems && expectItemsPacket && savedWindowId === packet.func_148911_c()) {
expectItemsPacket = false;
sendPacket(new C0EPacketClickWindow(savedWindowId, buyIndex.get(), 0, 0, packet.getItemStacks()[buyIndex.get()], 1));
expectClosePacket = true;
e.cancelEvent();
}
if (packet instanceof S2EPacketCloseWindow && expectClosePacket && savedWindowId === packet.windowId) {
expectClosePacket = false;
e.cancelEvent();
mc.thePlayer.sendChatMessage(buyAmount.get());
timeout(buyDelay.get(), function() {
shouldRun = true;
});
}
}
}
script.registerCommand({
name: 'spawnerautobuy',
aliases: [ 'sautobuy', 'sabuy', 'sab' ]
}, function(command) {
command.on('execute', function(args) {
if (args.length === 1) return Chat.print(prefix + '§cWrong syntax! Use ' + args[0] + ' (toggle | delay (number) | amount (number) | index (number))');
switch (args[1].toLowerCase()) {
case 'toggle':
enabled = !enabled;
if (enabled) {
Chat.print(prefix + '§bAutobuy is now §a§lEnabled');
} else {
Chat.print(prefix + '§bAutobuy is now §c§lDisabled');
}
break;
case 'delay':
var buyDelayValue = LiquidBounce.moduleManager.getModule('ROSpawnerAutoBuy').getValue('buyDelay');
if (args.length < 3) {
Chat.print(prefix + '§bBuy Delay is currently §a' + buyDelayValue.get());
} else {
buyDelayValue.set(Integer.parseInt(args[2]));
Chat.print(prefix + '§bBuy Delay is now set to §a' + args[2]);
}
break;
case 'amount':
var buyAmountValue = LiquidBounce.moduleManager.getModule('ROSpawnerAutoBuy').getValue('buyAmount');
if (args.length < 3) {
Chat.print(prefix + '§bBuy Amount is currently §a' + buyAmountValue.get());
} else {
buyAmountValue.set(Integer.parseInt(args[2]));
Chat.print(prefix + '§bBuy Amount is now set to §a' + args[2]);
}
break;
case 'index':
var buyIndexValue = LiquidBounce.moduleManager.getModule('ROSpawnerAutoBuy').getValue('buyIndex');
if (args.length < 3) {
Chat.print(prefix + '§bBuy Index is currently §a' + buyIndexValue.get());
} else {
buyIndexValue.set(Integer.parseInt(args[2]));
Chat.print(prefix + '§bBuy Index is now set to §a' + args[2]);
}
break;
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment