diff --git a/README.md b/README.md index 6c451b1..6fe92b2 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ TrafficerMC has a variety of features. Some of them are: - Auto Reconnect - and way more! +#### Minecraft Version 1.8.x - 1.20 + ## Media ![](https://media.discordapp.net/attachments/1101173583956422736/1105880170751078400/image.png) @@ -42,7 +44,7 @@ TrafficerMC v2.1 TrafficerMC v0.4 # Scripting -Scripting can allow the bot to do things automatically without any user input. It can also help if you are making multiple bots do the same things. To make a script, you would need to go into a text file editor, and apon finishing the script, you save it as a `.txt` file. You can name it anything. Scripts will run after the bot has spawned in. +Scripting can allow the bot to do things automatically without any user input. It can also help if you are making multiple bots do the same things. ## What a script would look like ``` @@ -142,7 +144,7 @@ delay 1200 chat Hello ``` # Account File -Account filing connects the bots with certain names that aren't set in General tab. It can be useful if you want to bot a server with NameMC names, for example. To make a account file, you would need to go into a text file editor, and apon entering all the usernames, you save it as a `.txt` file. You can name it anything. **Please note that you will still need to set the Max Accounts in General Tab for the bots to join!** +Account filing connects the bots with certain names that aren't set in General tab. It can be useful if you want to bot a server with NameMC names, for example. To make a account file, you would need to go into a text file editor, and apon entering all the usernames, you save it as a `.txt` file. You can name it anything. **Please note that you can set Max Accounts in General Tab or it will use all the names** ## What an account file would look like ``` vampers diff --git a/assets/icons/app/clipboard.svg b/assets/icons/app/clipboard.svg new file mode 100644 index 0000000..c19b44c --- /dev/null +++ b/assets/icons/app/clipboard.svg @@ -0,0 +1,7 @@ + + + + + Svg Vector Icons : http://www.onlinewebfonts.com/icon + + \ No newline at end of file diff --git a/assets/js/botMain.js b/assets/js/botMain.js index 33101af..95eec57 100644 --- a/assets/js/botMain.js +++ b/assets/js/botMain.js @@ -1,5 +1,5 @@ const { ipcRenderer, shell } = require("electron") -const { connectBot, delay, salt, addPlayer, rmPlayer, errBot, botApi, sendLog, exeAll, checkVer, startScript, mineflayer, loadTheme, createPopup, formatText } = require( __dirname + '/assets/js/cf.js') +const { connectBot, delay, salt, addPlayer, rmPlayer, errBot, botApi, sendLog, exeAll, checkVer, startScript, mineflayer, loadTheme, createPopup, formatText, selectedList } = require( __dirname + '/assets/js/cf.js') const antiafk = require( __dirname + '/assets/plugins/antiafk') process.NODE_TLS_REJECT_UNAUTHORIZED = "0" let currentTime = Date.now() @@ -78,6 +78,10 @@ let idTmob = document.getElementById('kaTm') let idTanimal = document.getElementById('kaTa') let idKaToggle = document.getElementById('toggleka') let idKaLook = document.getElementById('toggleKaLook') +let idAutoSelect = document.getElementById('toggleAutoSelect') +let idCheckOnRespawn = document.getElementById('scriptCheckOnRespawn') +let idCheckOnDeath = document.getElementById('scriptCheckOnDeath') +let idCheckIgnoreFriends = document.getElementById('checkKaIgnoreSelected') //button listeners window.addEventListener('DOMContentLoaded', () => { @@ -98,7 +102,13 @@ window.addEventListener('DOMContentLoaded', () => { idBtnLookAt.addEventListener('click', () => {exeAll("look", idLookValue.value)}) idCheckSprint.addEventListener('click', () => {exeAll("sprintcheck", idCheckSprint.checked)}) idBtnDrop.addEventListener('click', () => {exeAll("drop", idDropValue.value)}) - idBtnStartScript.addEventListener('click', () => {exeAll('startscript')}) + idBtnStartScript.addEventListener('click', () => { + const list = selectedList() + if(list.length === 0) return createPopup("No bot selected") + list.forEach(name => { + startScript(name, idScriptPath.value) + }); + }) idStartAfk.addEventListener('click', () => {exeAll('afkon')}) idStopAfk.addEventListener('click', () => {exeAll('afkoff')}) idBtnC.addEventListener('click', () => {saveData(); window.close()}) @@ -120,7 +130,7 @@ window.addEventListener('DOMContentLoaded', () => { }) -async function newBot(options) { +function newBot(options) { const bot = mineflayer.createBot(options) let afkLoaded = false @@ -130,7 +140,7 @@ async function newBot(options) { bot.once('spawn', ()=> { botApi.emit("spawn", bot.username) if(idJoinMessage) {bot.chat(idJoinMessage.value)} - if(idScriptCheck.checked && idScriptPath.value) { startScript(bot.username, idScriptPath.files[0].path)} + if(idScriptCheck.checked && idScriptPath.value) { startScript(bot.username, idScriptPath.value)} }); bot.once('kicked', (reason)=> { botApi.emit("kicked", options.username, reason) @@ -157,31 +167,18 @@ async function newBot(options) { }); bot.on('windowOpen', (window) => { - idWindow.innerHTML = "" - idWindowTitle.innerHTML = formatText(JSON.parse(window.title)) - for (var i = 0; i < window.slots.length; i++) { - const item = window.slots[i] - let dname = "" - if (item) { - if (item.nbt.value.display.value.Name.value) { - displayname = JSON.parse(item.nbt.value.display.value.Name.value) - - if (displayname.extra) { - var ext = displayname.extra - ext.forEach(e => { - dname += formatText(e) - }); - } else { - dname += formatText(displayname) - } - } - const b = document.createElement("li") - b.innerHTML = `${i} ${dname} ${item.count}x` - idWindow.appendChild(b) - } - } sendLog(`[${bot.username}] Window opened`) }) + bot.on('death', function() { + botApi.emit('death', options.username) + bot.once('respawn', function() { + if(idCheckOnDeath.checked && idScriptPath.value) { startScript(bot.username, idScriptPath.value)} + }) + }) + bot.on('respawn', function() { + botApi.emit('respawn', options.username) + if(idCheckOnRespawn.checked && idScriptPath.value) { startScript(bot.username, idScriptPath.value)} + }) botApi.once(options.username+'disconnect', () => {bot.quit()}) botApi.once(options.username+'reconnect', () => {newBot(options)}) @@ -193,7 +190,7 @@ async function newBot(options) { botApi.on(options.username+'stopcontrol', (o) => {bot.setControlState(o, false)}) botApi.on(options.username+'look', (o) => {bot.look(o, 0)}) botApi.on(options.username+'sprintcheck', (o) => {bot.setControlState('sprint', o)}) - botApi.on(options.username+'startscript', () => {startScript(bot.username, idScriptPath.files[0].path)}) + botApi.on(options.username+'startscript', () => {startScript(bot.username, idScriptPath.value)}) botApi.on(options.username+'afkon', () => { if(!afkLoaded) { @@ -242,6 +239,7 @@ async function newBot(options) { } else { bot.attack(entity); } + sendLog(`
  • [hit] ${entity.displayName ? entity.displayName : "Unknown Entity"}
  • `) } if (entity.kind === "Passive mobs" && idTanimal.checked) { if (idKaLook.checked) { @@ -250,6 +248,7 @@ async function newBot(options) { } else { bot.attack(entity); } + sendLog(`
  • [hit] ${entity.displayName ? entity.displayName : "Unknown Entity"}
  • `) } if (entity.kind === "Vehicles" && idTvehicle.checked) { if (idKaLook.checked) { @@ -258,14 +257,18 @@ async function newBot(options) { } else { bot.attack(entity); } + sendLog(`
  • [hit] ${entity.displayName ? entity.displayName : "Unknown Entity"}
  • `) } if (entity.type === "player" && entity.username !== bot.username && idTplayer.checked) { + const list = selectedList() + if(list.includes(entity.username) && idCheckIgnoreFriends.checked) return; if (idKaLook.checked) { bot.lookAt(entity.position, true); bot.attack(entity); } else { bot.attack(entity); } + sendLog(`
  • [hit] ${entity.username}
  • `) } } }); @@ -290,33 +293,36 @@ botApi.on("login", (name)=> { addPlayer(name) sendLog(`
  • ${name} Logged in.
  • `) if(idConnectSound.checked === true) { - var audio = new Audio( __dirname + '/assets/audios/connected.mp3'); - audio.play(); + playAudio("connected.mp3") } }) -botApi.on("spawn", (name)=> { - sendLog(`
  • ${name} Spawned.
  • `) -}) -botApi.on("kicked", (name, reason)=> { - rmPlayer(name) - sendLog(`
  • [${name}] : ${formatText(JSON.parse(reason))}
  • `) -}) botApi.on("end", (name, reason)=> { rmPlayer(name) sendLog(`
  • [${name}] ${reason}
  • `) if(idDiconnectSound.checked === true) { - var audio = new Audio( __dirname + '/assets/audios/disconnected.wav'); - audio.play(); + playAudio("") } }) botApi.on("error", (name, err)=> { errBot(name) sendLog(`
  • [${name}] ${err}
  • `) if(idErrorSound.checked === true) { - var audio = new Audio( __dirname + '/assets/audios/error.wav'); - audio.play(); + playAudio("error.wav") } }) +botApi.on("spawn", (name)=> { + sendLog(`
  • ${name} Spawned.
  • `) +}) +botApi.on("death", (name)=> { + sendLog(`
  • ${name} Died.
  • `) +}) +botApi.on("respawn", (name)=> { + sendLog(`
  • ${name} Respawned.
  • `) +}) +botApi.on("kicked", (name, reason)=> { + rmPlayer(name) + sendLog(`
  • [${name}] : ${formatText(JSON.parse(reason))}
  • `) +}) // uptime counter idBtnStart.addEventListener('click', () => { @@ -341,7 +347,9 @@ function formatTime(time) { if (10 > time) return "0" + time; return time; } - +function playAudio(filename) { + new Audio( __dirname + `./assets/audios/${filename}`).play(); +} // save and restore config ipcRenderer.on('restore', (event, data) => { Object.keys(data).forEach(v => { @@ -359,7 +367,8 @@ function saveData() { "botversion": document.getElementById('botversion').value, "botCount": document.getElementById('botCount').value, "joinDelay": document.getElementById('joinDelay').value, - "joinMessage": document.getElementById('joinMessage').value + "joinMessage": document.getElementById('joinMessage').value, + 'scriptPath': document.getElementById('scriptPath').value })) } diff --git a/assets/js/cf.js b/assets/js/cf.js index ccc7b8d..c64c221 100644 --- a/assets/js/cf.js +++ b/assets/js/cf.js @@ -5,7 +5,7 @@ const ProxyAgent = require('proxy-agent') const botApi = new EventEmitter() const fetch = require('node-fetch') const fs = require('fs') -const currentVersion = "2.1" +const currentVersion = "2.2" let stopBot = false //bot connect method @@ -106,7 +106,8 @@ function getBotInfo(botName, n) { version: idBotVersion.value, auth: idAuthType.value, onMsaCode: function(data) { - sendLog(`
  • [${botName}] First time signing in. Please authenticate now: To sign in, use a web browser to open the page https://www.microsoft.com/link and enter the code: ${data.user_code} to authenticate.
  • `) + const code = data.user_code + sendLog(`
  • [${botName}] First time signing in. Please authenticate now: To sign in, use a web browser to open the page https://www.microsoft.com/link and enter the code: ${code} to authenticate.
  • `) } }; return options; @@ -118,7 +119,8 @@ function getBotInfo(botName, n) { version: idBotVersion.value, auth: idAuthType.value, onMsaCode: function(data) { - sendLog(`
  • [${botName}] First time signing in. Please authenticate now: To sign in, use a web browser to open the page https://www.microsoft.com/link and enter the code: ${data.user_code} to authenticate.
  • `) + const code = data.user_code + sendLog(`
  • [${botName}] First time signing in. Please authenticate now: To sign in, use a web browser to open the page https://www.microsoft.com/link and enter the code: ${code} to authenticate.
  • `) } }; return options; @@ -169,12 +171,14 @@ function addPlayer(name) { idBotList.appendChild(b) idBotList.scrollTop = idBotList.scrollHeight updateBotCount() + if(idAutoSelect.checked) {selectAll()} } //remove player from list function rmPlayer(name) { if (document.getElementById("list" + name)) document.getElementById("list" + name).remove() updateBotCount() + if(idAutoSelect.checked) {selectAll()} } //log error @@ -194,23 +198,15 @@ function sendLog(log) { //execute command all bots async function exeAll(command, ...args) { - var sels = document.getElementsByClassName("botSelected"); - if (sels.length === 0) return sendLog(`
  • No bots selected!
  • `); - let list = ["BLANK"] - - var liElements = Array.from(sels).filter(function(element) { - return element.tagName === "LI"; - }); - - liElements.forEach(e => { - list.push(e.innerHTML + command) - }) - + + const list = selectedList() + if(list.length === 0) return sendLog(`
  • No bots selected!
  • `); + for (var i = 0; i < list.length; i++) { - botApi.emit(list[i], ...args) + botApi.emit(list[i] + command, ...args) await delay(idLinearValue.value) } - + if(command === "hit") return; sendLog(`
  • [${command}] ${args}
  • `) } @@ -221,12 +217,13 @@ function updateBotCount() { //script controler async function startScript(botId, script) { sendLog(`
  • [${botId}] Script started.
  • `) - const file = fs.readFileSync(script) - const lines = file.toString().split(/\r?\n/) + + const lines = script.toString().split(/\r?\n/) for (var i = 0; i < lines.length; i++) { const args = lines[i].split(" ") const command = args.shift().toLowerCase(); + if (command === "delay") { await delay(args[0]) } @@ -302,6 +299,7 @@ function createPopup(text, color) { popup.remove() }, 300); }, 3000); + playAudio("error.wav") } // json to html format @@ -310,6 +308,22 @@ function formatText(json) { return `${c.text}`; } +// Gets list of selected bots +function selectedList() { + var sels = document.getElementsByClassName("botSelected"); + let list = new Array; + + var liElements = Array.from(sels).filter(function(element) { + return element.tagName === "LI"; + }); + + liElements.forEach(e => { + list.push(e.innerHTML) + }) + + return list; +} + module.exports = { getBotInfo, connectBot, @@ -326,6 +340,7 @@ module.exports = { loadTheme, createPopup, formatText, + selectedList, mineflayer, botApi } \ No newline at end of file diff --git a/assets/js/htmlcontrol.js b/assets/js/htmlcontrol.js index 7fa1773..88829fb 100644 --- a/assets/js/htmlcontrol.js +++ b/assets/js/htmlcontrol.js @@ -3,11 +3,6 @@ for (const button of buttons) { button.addEventListener('click', showHideDiv); } -const tabbuttons = document.querySelectorAll('.tab-selectors button'); -for (const button of tabbuttons) { - button.addEventListener('click', tabShowHideDiv); -} - function showHideDiv(event) { const targetDiv = event.target.dataset.target; const divElements = document.querySelectorAll('.functsBtn'); @@ -56,6 +51,7 @@ function selectAll() { e.classList.add("botSelected") }); } + function selectRemove() { const list = document.getElementById("botList").querySelectorAll('li') list.forEach(e => { @@ -77,4 +73,17 @@ triggers.forEach(function (trigger) { const popup = document.getElementById(popupId); popup.style.display = 'none'; }); -}); \ No newline at end of file +}); + +function openTab(tabName) { + var tabContent = document.getElementsByClassName("tab-pane"); + for (var i = 0; i < tabContent.length; i++) { + tabContent[i].style.display = "none"; + } + var tabs = document.getElementsByClassName("tab"); + for (var i = 0; i < tabs.length; i++) { + tabs[i].classList.remove("active"); + } + document.getElementById(tabName).style.display = "block"; + event.currentTarget.classList.add("active"); +} \ No newline at end of file diff --git a/assets/style/style.css b/assets/style/style.css index 27badb6..4a739ef 100644 --- a/assets/style/style.css +++ b/assets/style/style.css @@ -1,5 +1,4 @@ -html, -body { +html, body { margin: 0; padding: 0; overflow: hidden; @@ -7,34 +6,27 @@ body { color: var(--text-color); background-color: var(--bg-color); } - -input::-webkit-outer-spin-button, -input::-webkit-inner-spin-button { +input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { appearance: none; margin: 0; } - ::-webkit-scrollbar { width: 5px; height: 0px; } - ::-webkit-scrollbar-thumb { background: var(--selected-item-color); } - img { -webkit-user-drag: none; } - .titlebar { position: fixed; width: 100%; height: 30px; box-sizing: border-box; - background-color: rgb(var(--topbar-color) / var(--topbar-opacity)) + background-color: rgb(var(--topbar-color) / var(--topbar-opacity)) } - .sidebar { position: fixed; top: 20px; @@ -42,9 +34,8 @@ img { width: 110px; box-sizing: border-box; user-select: none; - background-color: rgb(var(--sidebar-color) / var(--sidebar-opacity)) + background-color: rgb(var(--sidebar-color) / var(--sidebar-opacity)) } - .downbar { background: var(--downbar-color); opacity: var(--downbar-opacity); @@ -55,7 +46,6 @@ img { height: 20px; user-select: none; } - .draggable { display: flex; padding: 5pt; @@ -63,11 +53,9 @@ img { user-select: none; -webkit-app-region: drag; } - .nodrag { -webkit-app-region: no-drag; } - input[type=file]::file-selector-button { color: var(--text-color); background-color: var(--button-color); @@ -76,11 +64,9 @@ input[type=file]::file-selector-button { border-width: 1px; cursor: pointer; } - input[type=file]::file-selector-button:hover { filter: brightness(150%) } - .button { color: var(--button-text-color); background-color: var(--button-color); @@ -90,44 +76,45 @@ input[type=file]::file-selector-button:hover { border-width: 1px; border-color: var(--button-border-color); } - .button-selected { border-color: var(--selected-item-color); border-left: 5px solid; } - .button:hover { - filter: brightness(110%) + filter: brightness(110%) } - .input-group { display: flex; width: 100%; align-items: stretch; } - .btn.close:hover { - filter: brightness(0) saturate(100%) invert(16%) sepia(85%) saturate(7467%) hue-rotate(359deg) brightness(97%) contrast(108%) + filter: brightness(0) saturate(100%) invert(16%) sepia(85%) saturate(7467%) hue-rotate(359deg) brightness(97%) contrast(108%) } - .btn.minimize:hover { - filter: brightness(0) saturate(100%) invert(75%) sepia(96%) saturate(548%) hue-rotate(3deg) brightness(108%) contrast(103%) + filter: brightness(0) saturate(100%) invert(75%) sepia(96%) saturate(548%) hue-rotate(3deg) brightness(108%) contrast(103%) } - - - .center-elements { display: inline-flex; align-items: center; justify-content: center; } - .tab-selected { border-left: 5px solid; color: var(--selected-item-color); opacity: var(--selected-item-opacity); } - +.tab.active { + border-color: var(--selected-item-color); + border-left: solid 5px var(--selected-item-color); +} +.tab-pane { + display: none; + margin-top: 10px; +} +.tab-pane.active { + display: block; +} .contentArea { user-select: none; position: fixed; @@ -136,14 +123,12 @@ input[type=file]::file-selector-button:hover { width: 100%; height: 100%; } - .bottingContentArea { user-select: none; margin-top: 205px; width: 200px; height: 100%; } - .input { color: rgb(var(--text-color) / var(--text-opacity)); position: relative; @@ -158,14 +143,12 @@ input[type=file]::file-selector-button:hover { border-color: var(--button-border-color); background-color: transparent; } - .input-sm { color: rgb(var(--text-color) / var(--text-opacity)); position: relative; - top: -8px; - height: 2rem; + top: -2px; width: 5rem; - font-size: 0.875rem; + font-size: 0.8rem; border-width: 1px; border-top: 0px; border-left: 0px; @@ -173,17 +156,13 @@ input[type=file]::file-selector-button:hover { border-color: var(--button-border-color); background-color: transparent; } - input:focus { outline: none; } - -input::placeholder, -textarea::placeholder { +input::placeholder, textarea::placeholder { opacity: 0.5; color: var(--text-color); } - .select { color: var(--button-text-color); background-color: var(--button-color); @@ -192,15 +171,30 @@ textarea::placeholder { border: none; height: 33px; } - .bgimg { - content: var(--background-image) + content: var(--background-image) +} +.select-input { + color: var(--text-color); + background-color: var(--bg-color); + cursor: pointer; + user-select: none; + border: none; } - select:focus { outline: none; } - +.text-input { + color: rgb(var(--text-color) / var(--text-opacity)); + border-top: 0px; + border-left: 0px; + border-right: 0px; + border-color: var(--button-border-color); + background-color: transparent; +} +input:focus { + outline: none; +} .label { display: flex; -webkit-user-select: none; @@ -212,16 +206,13 @@ select:focus { padding-top: 0.5rem; padding-bottom: 0.5rem; } - .label-text { font-size: 20px; line-height: 1rem; } - .error-text { color: #ff0000; } - ul { background-color: var(--ul-bg-color); opacity: var(--ul-opacity); @@ -232,58 +223,55 @@ ul { border-width: 1px; list-style-type: none; } - ul li { overflow-wrap: break-word; border: var(--button-border-color); border-bottom: 1px solid; } - +.textbox { + height: 400px; + width: 300px; + background-color: var(--bg-color); + color: var(--text-color); + border: solid var(--button-border-color) 1px; + padding: 10px; + resize: none; + outline: none; +} .m-1 { margin-left: 0.25rem; } - .m-4 { margin-left: 1rem; } - .m-8 { margin-left: 2rem; } - .mu-4 { margin-top: 1rem; } - .p-4 { padding: 1rem; } - .pl-4 { padding-left: 1rem; } - .p-1 { padding: 0.25rem; } - .p-0 { padding: 0px; } - .flex { display: flex; } - .flex-colum { flex-direction: column; } - .border { padding: 10px; border: 2px solid #bac0f21a; } - .border-sm { border: 2px solid #bac0f21a; } @@ -294,7 +282,6 @@ ul li { cursor: pointer; font-size: 22px; } - .container input { position: absolute; opacity: 0; @@ -302,7 +289,6 @@ ul li { height: 0; width: 0; } - .checkmark { background-color: var(--bg-color); position: absolute; @@ -313,7 +299,6 @@ ul li { opacity: 0.5; transition: ease-in-out 0.2s; } - .container input:checked~.checkmark { background-color: var(--bg-color); border: solid var(--button-color); @@ -325,29 +310,24 @@ ul li { border-width: 0 3px 3px 0; transform: rotate(45deg); } - .icon-sm { width: 18px; margin-left: 3px; margin-right: 3px; padding: 1px; } - .error-icon { filter: brightness(0) saturate(100%) invert(13%) sepia(95%) saturate(6636%) hue-rotate(1deg) brightness(107%) contrast(97%); } - .icon { width: 50px; height: 50px; margin: 5px; filter: brightness(0) saturate(100%) invert(100%) sepia(0%) saturate(7442%) hue-rotate(318deg) brightness(95%) contrast(109%); } - .icon:hover { filter: brightness(0) saturate(100%) invert(85%) sepia(6%) saturate(4808%) hue-rotate(189deg) brightness(100%) contrast(90%); } - .botSelected { background-color: var(--selected-item-color); } @@ -366,7 +346,6 @@ ul li { opacity: 0; pointer-events: none; } - .popup { display: none; position: absolute; @@ -375,11 +354,10 @@ ul li { background-color: var(--bg-color); color: var(--text-color); border-radius: 5px; - } - .popup:hover { +} +.popup:hover { display: block; - } - +} :root { --background-image: url('../icons/app/Background.svg'); --bg-color: #0c0d11; @@ -387,7 +365,7 @@ ul li { --button-color: #5b8191; --button-text-color: #f6f5f5; --button-opacity: 1; - --button-border-color: #454864;; + --button-border-color: #454864; --ul-bg-color: #171a25; --ul-opacity: 0.7; --downbar-color: #3D75C9; @@ -398,4 +376,4 @@ ul li { --sidebar-opacity: 0.2; --topbar-color: 0 0 0; --topbar-opacity: 0.6; -} \ No newline at end of file +} diff --git a/index.html b/index.html index a0da5d4..23f36ce 100644 --- a/index.html +++ b/index.html @@ -1,509 +1,525 @@ - - - - -
    -
    - - - -
    -
    - - -
    + + + + +
    +
    + + +
    -