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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const mineflayer = require("mineflayer");
|
| 2 |
+
const Movements = require("mineflayer-pathfinder").Movements;
|
| 3 |
+
const pathfinder = require("mineflayer-pathfinder").pathfinder;
|
| 4 |
+
const { GoalBlock, GoalXZ, GoalNear } = require("mineflayer-pathfinder").goals;
|
| 5 |
+
|
| 6 |
+
const config = require("./settings.json");
|
| 7 |
+
|
| 8 |
+
const loggers = require("./logging.js");
|
| 9 |
+
const logger = loggers.logger;
|
| 10 |
+
|
| 11 |
+
function createBot() {
|
| 12 |
+
const bot = mineflayer.createBot({
|
| 13 |
+
username: config["bot-account"]["username"],
|
| 14 |
+
auth: config["bot-account"]["type"],
|
| 15 |
+
host: config.server.ip,
|
| 16 |
+
port: config.server.port,
|
| 17 |
+
version: config.server.version,
|
| 18 |
+
});
|
| 19 |
+
|
| 20 |
+
bot.loadPlugin(pathfinder);
|
| 21 |
+
|
| 22 |
+
bot.once("spawn", async() => {
|
| 23 |
+
const defaultMove = new Movements(bot);
|
| 24 |
+
bot.pathfinder.setMovements(defaultMove);
|
| 25 |
+
bot.settings.colorsEnabled = false;
|
| 26 |
+
logger.info("Bot sunucuya giriş yaptı.");
|
| 27 |
+
|
| 28 |
+
if (config.utils["auto-auth"].enabled) {
|
| 29 |
+
|
| 30 |
+
let password = config.utils["auto-auth"].password;
|
| 31 |
+
setTimeout(() => {
|
| 32 |
+
bot.chat(`/login ${password}`);
|
| 33 |
+
logger.info(`[${config["bot-account"]["username"]}] Login komutu kullanıldı.`);
|
| 34 |
+
}, 500);
|
| 35 |
+
|
| 36 |
+
setTimeout(async () => {
|
| 37 |
+
bot.chat(`/skyblock`);
|
| 38 |
+
logger.info(`[${config["bot-account"]["username"]}] Skyblock'a ışınlanma komutu kullanıldı.`);
|
| 39 |
+
}, 5000);
|
| 40 |
+
setTimeout(async () => {
|
| 41 |
+
bot.chat(`/home`);
|
| 42 |
+
logger.info(`[${config["bot-account"]["username"]}] Home konumuna ışınlanma komutu kullanıldı.`);
|
| 43 |
+
}, 10000);
|
| 44 |
+
setInterval(async () => {
|
| 45 |
+
if(Object.keys(bot.entities).filter(ff => JSON.stringify(bot.entities[ff]).includes("ʙᴇsʟᴇʏiᴄi ")).length > 0){
|
| 46 |
+
bot.activateEntityAt(bot.entities[Object.keys(bot.entities).filter(ff => JSON.stringify(bot.entities[ff]).includes("ʙᴇsʟᴇʏiᴄi "))[0]], bot.entities[Object.keys(bot.entities).filter(ff => JSON.stringify(bot.entities[ff]).includes("ʙᴇsʟᴇʏiᴄi "))[0]].position)
|
| 47 |
+
};
|
| 48 |
+
}, 30000);
|
| 49 |
+
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
if (config.utils["chat-messages"].enabled) {
|
| 53 |
+
logger.info("Started chat-messages module");
|
| 54 |
+
|
| 55 |
+
let messages = config.utils["chat-messages"]["messages"];
|
| 56 |
+
|
| 57 |
+
if (config.utils["chat-messages"].repeat) {
|
| 58 |
+
let delay = config.utils["chat-messages"]["repeat-delay"];
|
| 59 |
+
let i = 0;
|
| 60 |
+
|
| 61 |
+
setInterval(() => {
|
| 62 |
+
bot.chat(`${messages[i]}`);
|
| 63 |
+
|
| 64 |
+
if (i + 1 === messages.length) {
|
| 65 |
+
i = 0;
|
| 66 |
+
} else i++;
|
| 67 |
+
}, delay * 1000);
|
| 68 |
+
} else {
|
| 69 |
+
messages.forEach((msg) => {
|
| 70 |
+
bot.chat(msg);
|
| 71 |
+
});
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
const pos = config.position;
|
| 76 |
+
|
| 77 |
+
if (config.position.enabled) {
|
| 78 |
+
logger.info(
|
| 79 |
+
`Starting moving to target location (${pos.x}, ${pos.y}, ${pos.z})`,
|
| 80 |
+
);
|
| 81 |
+
bot.pathfinder.setGoal(new GoalBlock(pos.x, pos.y, pos.z));
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
if (config.utils["anti-afk"].enabled) {
|
| 85 |
+
if (config.utils["anti-afk"].sneak) {
|
| 86 |
+
bot.setControlState("sneak", true);
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
if (config.utils["anti-afk"].jump) {
|
| 90 |
+
bot.setControlState("jump", true);
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
if (config.utils["anti-afk"]["hit"].enabled) {
|
| 94 |
+
let delay = config.utils["anti-afk"]["hit"]["delay"];
|
| 95 |
+
let attackMobs = config.utils["anti-afk"]["hit"]["attack-mobs"];
|
| 96 |
+
|
| 97 |
+
setInterval(() => {
|
| 98 |
+
if (attackMobs) {
|
| 99 |
+
let entity = bot.nearestEntity(
|
| 100 |
+
(e) =>
|
| 101 |
+
e.type !== "object" &&
|
| 102 |
+
e.type !== "player" &&
|
| 103 |
+
e.type !== "global" &&
|
| 104 |
+
e.type !== "orb" &&
|
| 105 |
+
e.type !== "other",
|
| 106 |
+
);
|
| 107 |
+
|
| 108 |
+
if (entity) {
|
| 109 |
+
bot.attack(entity);
|
| 110 |
+
return;
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
bot.swingArm("right", true);
|
| 115 |
+
}, delay);
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
if (config.utils["anti-afk"].rotate) {
|
| 119 |
+
setInterval(() => {
|
| 120 |
+
bot.look(bot.entity.yaw + 1, bot.entity.pitch, true);
|
| 121 |
+
}, 100);
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
if (config.utils["anti-afk"]["circle-walk"].enabled) {
|
| 125 |
+
let radius = config.utils["anti-afk"]["circle-walk"]["radius"];
|
| 126 |
+
setInterval(() => {
|
| 127 |
+
circleWalk(bot, radius);
|
| 128 |
+
}, 30000);
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
});
|
| 132 |
+
|
| 133 |
+
bot.on('windowOpen', function (window) {
|
| 134 |
+
if(window.title.includes("ʙᴇsʟᴇʏiᴄi ᴍiɴʏᴏɴ ᴘᴀɴᴇʟi")){
|
| 135 |
+
//Besleyici minyon paneli
|
| 136 |
+
if(window.slots.filter(xx => xx?.name && xx?.name == "cooked_beef").length > 0){
|
| 137 |
+
var minyoncani = Number((JSON.parse(window.slots.filter(xx => xx?.name && xx?.name == "cooked_beef")[0]?.nbt?.value?.display?.value?.Lore?.value?.value[1])?.extra[0].text).split("/")[0]);
|
| 138 |
+
if(minyoncani <= 2){
|
| 139 |
+
bot.clickWindow(36,0,0);
|
| 140 |
+
logger.info(`[${config["bot-account"]["username"]}] Minyon canı ${minyoncani} olduğu için besleyici minyon beslendi.`);
|
| 141 |
+
bot.closeWindow(window);
|
| 142 |
+
}else{
|
| 143 |
+
bot.closeWindow(window);
|
| 144 |
+
}
|
| 145 |
+
}else{
|
| 146 |
+
bot.closeWindow(window);
|
| 147 |
+
}
|
| 148 |
+
}else{
|
| 149 |
+
bot.closeWindow(window);
|
| 150 |
+
}
|
| 151 |
+
});
|
| 152 |
+
|
| 153 |
+
bot.on("chat", (username, message) => {
|
| 154 |
+
if (config.utils["chat-log"]) {
|
| 155 |
+
logger.info(`<${username}> ${message}`);
|
| 156 |
+
}
|
| 157 |
+
});
|
| 158 |
+
|
| 159 |
+
bot.on("goal_reached", () => {
|
| 160 |
+
if (config.position.enabled) {
|
| 161 |
+
logger.info(`Bot arrived to target location. ${bot.entity.position}`);
|
| 162 |
+
}
|
| 163 |
+
});
|
| 164 |
+
|
| 165 |
+
bot.on("death", () => {
|
| 166 |
+
logger.warn(
|
| 167 |
+
`Bot has been died and was respawned at ${bot.entity.position}`,
|
| 168 |
+
);
|
| 169 |
+
});
|
| 170 |
+
|
| 171 |
+
if (config.utils["auto-reconnect"]) {
|
| 172 |
+
bot.on("end", () => {
|
| 173 |
+
setTimeout(() => {
|
| 174 |
+
createBot();
|
| 175 |
+
}, config.utils["auto-reconnect-delay"]);
|
| 176 |
+
});
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
bot.on("kicked", (reason) => {
|
| 180 |
+
let reasonText = JSON.parse(reason).text;
|
| 181 |
+
if (reasonText === "") {
|
| 182 |
+
reasonText = JSON.parse(reason).extra[0].text;
|
| 183 |
+
}
|
| 184 |
+
try{
|
| 185 |
+
reasonText = reasonText?.replace(/§./g, "");
|
| 186 |
+
logger.warn(`Bot sunucudan atıldı.Sebep: ${reasonText}`);
|
| 187 |
+
}catch{
|
| 188 |
+
logger.warn(`Bot sunucudan atıldı.Sebep: Bulunamadı.`);
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
});
|
| 192 |
+
|
| 193 |
+
bot.on("error", (err) => logger.error(`${err.message}`));
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
function circleWalk(bot, radius) {
|
| 198 |
+
// Make bot walk in square with center in bot's wthout stopping
|
| 199 |
+
return new Promise(() => {
|
| 200 |
+
const pos = bot.entity.position;
|
| 201 |
+
const x = pos.x;
|
| 202 |
+
const y = pos.y;
|
| 203 |
+
const z = pos.z;
|
| 204 |
+
|
| 205 |
+
const points = [
|
| 206 |
+
[x + radius, y, z],
|
| 207 |
+
[x, y, z + radius],
|
| 208 |
+
[x - radius, y, z],
|
| 209 |
+
[x, y, z - radius],
|
| 210 |
+
];
|
| 211 |
+
|
| 212 |
+
let i = 0;
|
| 213 |
+
setTimeout(() => {
|
| 214 |
+
if (i === points.length) i = 0;
|
| 215 |
+
const defaultMove = new Movements(bot);
|
| 216 |
+
bot.pathfinder.setMovements(defaultMove);
|
| 217 |
+
bot.pathfinder.setGoal(new GoalXZ(points[i][0], points[i][2]));
|
| 218 |
+
i++;
|
| 219 |
+
}, 1000);
|
| 220 |
+
});
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
createBot();
|
| 224 |
+
|
| 225 |
+
const express = require("express");
|
| 226 |
+
const app = express();
|
| 227 |
+
const port = process.env.PORT || 7860; //buraya karışmayın.
|
| 228 |
+
|
| 229 |
+
app.get("/", (req, res) => res.send("Pinglendi")); //değiştirebilirsiniz.
|
| 230 |
+
|
| 231 |
+
app.listen(
|
| 232 |
+
port,
|
| 233 |
+
() =>
|
| 234 |
+
console.log(`Bot bu adres üzerinde çalışıyor: http://localhost:${port}`), //port
|
| 235 |
+
);
|
| 236 |
+
|
| 237 |
+
process.on('uncaughtException', function (err) {
|
| 238 |
+
console.error("Hata aldım!");
|
| 239 |
+
console.log(err)
|
| 240 |
+
})
|
logging.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const log4js = require("log4js");
|
| 2 |
+
log4js.configure({
|
| 3 |
+
appenders: {
|
| 4 |
+
console: { type: "console" },
|
| 5 |
+
},
|
| 6 |
+
categories: {
|
| 7 |
+
default: {
|
| 8 |
+
appenders: ["console"],
|
| 9 |
+
level: "info"
|
| 10 |
+
}
|
| 11 |
+
},
|
| 12 |
+
layouts: {
|
| 13 |
+
customLayout: {
|
| 14 |
+
type: 'pattern',
|
| 15 |
+
pattern: '%d{hh:mm:ss} %-5p %c - %m',
|
| 16 |
+
}
|
| 17 |
+
}
|
| 18 |
+
});
|
| 19 |
+
|
| 20 |
+
const logger = log4js.getLogger();
|
| 21 |
+
|
| 22 |
+
module.exports = {
|
| 23 |
+
logger
|
| 24 |
+
}
|
package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "ai-bot",
|
| 3 |
+
"version": "1.3.2",
|
| 4 |
+
"description": "System",
|
| 5 |
+
"main": "node bot.js",
|
| 6 |
+
"scripts": {
|
| 7 |
+
"test": "echo \"Error: no test specified\" && exit 1"
|
| 8 |
+
},
|
| 9 |
+
"author": "Suvari",
|
| 10 |
+
"license": "MIT",
|
| 11 |
+
"dependencies": {
|
| 12 |
+
"express": "^4.21.0",
|
| 13 |
+
"log4js": "^6.7.1",
|
| 14 |
+
"minecraft-data": "^3.69.0",
|
| 15 |
+
"mineflayer": "github:PrismarineJS/mineflayer#89686596c8de1091bf45104ba3230a5e87707a20",
|
| 16 |
+
"mineflayer-pathfinder": "github:PrismarineJS/mineflayer-pathfinder#874949196ac15a7bca23ac54b403b7a8c8bc71be"
|
| 17 |
+
}
|
| 18 |
+
}
|
settings.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bot-account": {
|
| 3 |
+
"username": "RazAssassins",
|
| 4 |
+
"type": "offline"
|
| 5 |
+
},
|
| 6 |
+
|
| 7 |
+
"server": {
|
| 8 |
+
"ip": "play.reborncraft.pw",
|
| 9 |
+
"port": 25565,
|
| 10 |
+
"version": "1.21"
|
| 11 |
+
},
|
| 12 |
+
|
| 13 |
+
"position": {
|
| 14 |
+
"enabled": false,
|
| 15 |
+
"x": 0,
|
| 16 |
+
"y": 0,
|
| 17 |
+
"z": 0
|
| 18 |
+
},
|
| 19 |
+
|
| 20 |
+
"utils": {
|
| 21 |
+
"auto-auth": {
|
| 22 |
+
"enabled": true,
|
| 23 |
+
"password": "Qweasd123"
|
| 24 |
+
},
|
| 25 |
+
|
| 26 |
+
"anti-afk": {
|
| 27 |
+
"enabled": false,
|
| 28 |
+
"sneak": false,
|
| 29 |
+
"jump": false,
|
| 30 |
+
"rotate": false,
|
| 31 |
+
|
| 32 |
+
"hit": {
|
| 33 |
+
"enabled": false,
|
| 34 |
+
"delay": 1000,
|
| 35 |
+
"attack-mobs": false
|
| 36 |
+
},
|
| 37 |
+
|
| 38 |
+
"circle-walk": {
|
| 39 |
+
"enabled": false,
|
| 40 |
+
"radius": 1
|
| 41 |
+
}
|
| 42 |
+
},
|
| 43 |
+
|
| 44 |
+
"chat-messages": {
|
| 45 |
+
"enabled": false,
|
| 46 |
+
"repeat": false,
|
| 47 |
+
"repeat-delay": 60,
|
| 48 |
+
|
| 49 |
+
"messages": []
|
| 50 |
+
},
|
| 51 |
+
|
| 52 |
+
"chat-log": true,
|
| 53 |
+
"auto-reconnect": true,
|
| 54 |
+
"auto-reconnect-delay": 5000
|
| 55 |
+
}
|
| 56 |
+
}
|