Merge pull request #39 from ORelio/Indev

Merging changes from Indev for 1.7.3 release
This commit is contained in:
ORelio 2014-05-14 22:07:46 +02:00
commit 1225a2964e
12 changed files with 403 additions and 198 deletions

View file

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
namespace MinecraftClient
{
@ -9,7 +10,17 @@ namespace MinecraftClient
/// Welcome to the Bot API file !
/// The virtual class "ChatBot" contains anything you need for creating chat bots
/// Inherit from this class while adding your bot class to the namespace "Bots", below.
/// Once your bot is created, simply edit the switch in Program.cs to add the corresponding command-line argument!
/// Once your bot is created, read the explanations below to start using it in the MinecraftClient app.
///
/// Pieces of code to add in other parts of the program for your bot. Line numbers are approximative.
/// Program.cs:166 | if (Settings.YourBot_Enabled){ handler.BotLoad(new Bots.YourBot()); }
/// Settings.cs:73 | public static bool YourBot_Enabled = false;
/// Settings.cs:74 | private enum ParseMode { /* [...] */, YourBot };
/// Settings.cs:106| case "yourbot": pMode = ParseMode.YourBot; break;
/// Settings.cs:197| case ParseMode.YourBot: switch (argName.ToLower()) { case "enabled": YourBot_Enabled = str2bool(argValue); break; } break;
/// Settings.cs:267| + "[YourBot]\r\n" + "enabled=false\r\n"
/// Here your are. Now you will have a setting in MinecraftClient.ini for enabling your brand new bot.
/// Delete MinecraftClient.ini to re-generate it or add the lines [YourBot] and enabled=true to the existing one.
///
/// <summary>
@ -235,6 +246,28 @@ namespace MinecraftClient
handler.BotUnLoad(this);
}
/// <summary>
/// Send a private message to a player
/// </summary>
/// <param name="player">Player name</param>
/// <param name="message">Message</param>
protected void SendPrivateMessage(string player, string message)
{
SendText("/tell " + player + ' ' + message);
}
/// <summary>
/// Run a script from a file using a Scripting bot
/// </summary>
/// <param name="filename">File name</param>
/// <param name="playername">Player name to send error messages, if applicable</param>
protected void RunScript(string filename, string playername = "")
{
handler.BotLoad(new Bots.Script(filename, playername));
}
#endregion
}
@ -355,7 +388,6 @@ namespace MinecraftClient
private bool[] discovered;
private string word = "";
private string letters = "";
private string[] owners;
private bool English;
/// <summary>
@ -368,11 +400,6 @@ namespace MinecraftClient
English = english;
}
public override void Initialize()
{
owners = getowners();
}
public override void Update()
{
if (running)
@ -398,7 +425,7 @@ namespace MinecraftClient
if (isPrivateMessage(text, ref message, ref username))
{
if (owners.Contains(username.ToUpper()))
if (Settings.Bots_Owners.Contains(username.ToLower()))
{
switch (message)
{
@ -495,21 +522,6 @@ namespace MinecraftClient
}
}
private string[] getowners()
{
List<string> owners = new List<string>();
owners.Add("CONSOLE");
if (System.IO.File.Exists(Settings.Bots_OwnersFile))
{
foreach (string s in System.IO.File.ReadAllLines(Settings.Bots_OwnersFile))
{
owners.Add(s.ToUpper());
}
}
else LogToConsole(English ? "File not found: " + Settings.Bots_OwnersFile : "Fichier introuvable : " + Settings.Bots_OwnersFile);
return owners.ToArray();
}
private string word_cached
{
get
@ -598,7 +610,7 @@ namespace MinecraftClient
if (ok)
{
Console.Beep(); //Text found !
if (Settings.Alerts_Beep_Enabled) { Console.Beep(); } //Text found !
if (ConsoleIO.basicIO) { ConsoleIO.WriteLine(comp.Replace(alert, "§c" + alert + "§r")); } else {
@ -830,78 +842,69 @@ namespace MinecraftClient
}
}
/// <summary>
/// Automatically send login command on servers usign the xAuth plugin
/// </summary>
public class xAuth : ChatBot
{
private string password;
private int countdown = 50;
public xAuth(string pass)
{
password = pass;
}
public override void Update()
{
countdown--;
if (countdown == 0)
{
SendText("/login " + password);
UnloadBot(); //This bot is no more needed.
}
}
}
/// <summary>
/// Runs a list of commands
/// Usage: bot:scripting:filename
/// Script must be placed in the config directory
/// </summary>
public class Scripting : ChatBot
public class Script : ChatBot
{
private string file;
private string[] lines = new string[0];
private int sleepticks = 10;
private int sleepticks_interval = 10;
private int nextline = 0;
public Scripting(string filename)
private string owner;
public Script(string filename)
{
file = filename;
}
public override void Initialize()
public Script(string filename, string ownername)
:this(filename)
{
if (ownername != "")
owner = ownername;
}
public static bool lookForScript(ref string filename)
{
//Load the given file from the startup parameters
//Automatically look in subfolders and try to add ".txt" file extension
string[] files = new string[]
{
file,
file + ".txt",
"scripts\\" + file,
"scripts\\" + file + ".txt",
"config\\" + file,
"config\\" + file + ".txt",
filename,
filename + ".txt",
"scripts\\" + filename,
"scripts\\" + filename + ".txt",
"config\\" + filename,
"config\\" + filename + ".txt",
};
bool file_found = false;
foreach (string possible_file in files)
{
if (System.IO.File.Exists(possible_file))
{
lines = System.IO.File.ReadAllLines(possible_file);
file_found = true;
break;
filename = possible_file;
return true;
}
}
if (!file_found)
return false;
}
public override void Initialize()
{
//Load the given file from the startup parameters
if (lookForScript(ref file))
{
lines = System.IO.File.ReadAllLines(file);
if (owner != null) { SendPrivateMessage(owner, "Script '" + file + "' loaded."); }
}
else
{
LogToConsole("File not found: '" + file + "'");
if (owner != null)
SendPrivateMessage(owner, "File not found: '" + file + "'");
UnloadBot(); //No need to keep the bot active
}
}
@ -942,6 +945,13 @@ namespace MinecraftClient
case "exit": //Exit bot & stay connected to the server
UnloadBot();
break;
case "connect":
if (instruction_line.Length >= 9)
{
Settings.ServerIP = instruction_line.Substring(8);
ReconnectToTheServer();
}
break;
default:
sleepticks = 0; Update(); //Unknown command : process next line immediately
break;
@ -958,5 +968,200 @@ namespace MinecraftClient
}
}
}
/// <summary>
/// Trigger scripts on specific events
/// </summary>
public class ScriptScheduler : ChatBot
{
private class TaskDesc
{
public string script_file = null;
public bool triggerOnFirstLogin = false;
public bool triggerOnLogin = false;
public bool triggerOnTime = false;
public List<DateTime> triggerOnTime_Times = new List<DateTime>();
public bool alreadyTriggered = false;
}
private static bool firstlogin_done = false;
private string tasksfile;
private bool serverlogin_done;
private List<TaskDesc> tasks = new List<TaskDesc>();
private int verifytasks_timeleft = 10;
private int verifytasks_delay = 10;
public ScriptScheduler(string tasksfile)
{
this.tasksfile = tasksfile;
serverlogin_done = false;
}
public override void Initialize()
{
//Load the given file from the startup parameters
if (System.IO.File.Exists(tasksfile))
{
TaskDesc current_task = null;
String[] lines = System.IO.File.ReadAllLines(tasksfile);
foreach (string lineRAW in lines)
{
string line = lineRAW.Split('#')[0].Trim();
if (line.Length > 0)
{
if (line[0] == '[' && line[line.Length - 1] == ']')
{
switch (line.Substring(1, line.Length - 2).ToLower())
{
case "task":
checkAddTask(current_task);
current_task = new TaskDesc(); //Create a blank task
break;
}
}
else if (current_task != null)
{
string argName = line.Split('=')[0];
if (line.Length > (argName.Length + 1))
{
string argValue = line.Substring(argName.Length + 1);
switch (argName.ToLower())
{
case "triggeronfirstlogin": current_task.triggerOnFirstLogin = Settings.str2bool(argValue); break;
case "triggeronlogin": current_task.triggerOnLogin = Settings.str2bool(argValue); break;
case "triggerontime": current_task.triggerOnTime = Settings.str2bool(argValue); break;
case "timevalue": try { current_task.triggerOnTime_Times.Add(DateTime.ParseExact(argValue, "HH:mm", CultureInfo.InvariantCulture)); } catch { } break;
case "script": current_task.script_file = argValue; break;
}
}
}
}
}
checkAddTask(current_task);
}
else
{
LogToConsole("File not found: '" + tasksfile + "'");
UnloadBot(); //No need to keep the bot active
}
}
private void checkAddTask(TaskDesc current_task)
{
if (current_task != null)
{
//Check if we built a valid task before adding it
if (current_task.script_file != null && Script.lookForScript(ref current_task.script_file) //Check if file exists
&& (current_task.triggerOnLogin || (current_task.triggerOnTime && current_task.triggerOnTime_Times.Count > 0))) //Look for a valid trigger
{
tasks.Add(current_task);
}
}
}
public override void Update()
{
if (verifytasks_timeleft <= 0)
{
verifytasks_timeleft = verifytasks_delay;
if (serverlogin_done)
{
foreach (TaskDesc task in tasks)
{
if (task.triggerOnTime)
{
foreach (DateTime time in task.triggerOnTime_Times)
{
if (time.Hour == DateTime.Now.Hour && time.Minute == DateTime.Now.Minute)
{
if (!task.alreadyTriggered)
{
task.alreadyTriggered = true;
RunScript(task.script_file);
}
}
}
}
else task.alreadyTriggered = false;
}
}
else
{
foreach (TaskDesc task in tasks)
{
if (task.triggerOnLogin || (firstlogin_done == false && task.triggerOnFirstLogin))
RunScript(task.script_file);
}
firstlogin_done = true;
serverlogin_done = true;
}
}
else verifytasks_timeleft--;
}
}
/// <summary>
/// Allow to perform operations using whispers to the bot
/// </summary>
public class RemoteControl : ChatBot
{
public override void GetText(string text)
{
text = getVerbatim(text);
string command = "", sender = "";
if (isPrivateMessage(text, ref command, ref sender) && Settings.Bots_Owners.Contains(sender.ToLower()))
{
string cmd_name = command.Split(' ')[0];
switch (cmd_name.ToLower())
{
case "exit":
DisconnectAndExit();
break;
case "reco":
ReconnectToTheServer();
break;
case "script":
if (command.Length >= 8)
RunScript(command.Substring(7), sender);
break;
case "send":
if (command.Length >= 6)
SendText(command.Substring(5));
break;
case "connect":
if (command.Length >= 9)
{
Settings.ServerIP = command.Substring(8);
ReconnectToTheServer();
}
break;
case "help":
if (command.Length >= 6)
{
string help_cmd_name = command.Substring(5).ToLower();
switch (help_cmd_name)
{
case "exit": SendPrivateMessage(sender, "exit: disconnect from the server."); break;
case "reco": SendPrivateMessage(sender, "reco: restart and reconnct to the server."); break;
case "script": SendPrivateMessage(sender, "script <scriptname>: run a script file."); break;
case "send": SendPrivateMessage(sender, "send <text>: send a chat message or command."); break;
case "connect": SendPrivateMessage(sender, "connect <serverip>: connect to the specified server."); break;
case "help": SendPrivateMessage(sender, "help <cmdname>: show brief help about a command."); break;
default: SendPrivateMessage(sender, "help: unknown command '" + help_cmd_name + "'."); break;
}
}
else SendPrivateMessage(sender, "help <cmdname>. Available commands: exit, reco, script, send, connect.");
break;
default:
SendPrivateMessage(sender, "Unknown command '" + cmd_name + "'. Use 'help' for help.");
break;
}
}
}
}
}
}

View file

@ -60,8 +60,11 @@ namespace MinecraftClient
break;
default:
Console.Write('*');
password += k.KeyChar;
if (k.KeyChar != 0)
{
Console.Write('*');
password += k.KeyChar;
}
break;
}
}
@ -159,7 +162,8 @@ namespace MinecraftClient
}
break;
default:
AddChar(k.KeyChar);
if (k.KeyChar != 0)
AddChar(k.KeyChar);
break;
}
}

View file

@ -119,7 +119,7 @@ namespace MinecraftClient
else
{
Console.WriteLine("Login failed.");
if (!singlecommand) { Program.ReadLineReconnect(); }
if (!singlecommand && !handler.OnConnectionLost(ChatBot.DisconnectReason.LoginRejected, "Login failed.")) { Program.ReadLineReconnect(); }
}
}
catch (SocketException)
@ -175,7 +175,7 @@ namespace MinecraftClient
}
else if (text.ToLower().StartsWith("/script "))
{
handler.BotLoad(new Bots.Scripting(text.Substring(8)));
handler.BotLoad(new Bots.Script(text.Substring(8)));
}
else if (text != "")
{
@ -235,7 +235,7 @@ namespace MinecraftClient
if (!handler.HasBeenKicked)
{
ConsoleIO.WriteLine("Connection has been lost.");
if (!handler.OnConnectionLost() && !Program.ReadLineReconnect()) { t_sender.Abort(); }
if (!handler.OnConnectionLost(ChatBot.DisconnectReason.ConnectionLost, "Connection has been lost.") && !Program.ReadLineReconnect()) { t_sender.Abort(); }
}
else if (Program.ReadLineReconnect()) { t_sender.Abort(); }
}

View file

@ -15,7 +15,7 @@ namespace MinecraftClient
{
#region Login to Minecraft.net and get a new session ID
public enum LoginResult { OtherError, SSLError, Success, WrongPassword, Blocked, AccountMigrated, NotPremium };
public enum LoginResult { OtherError, ServiceUnavailable, SSLError, Success, WrongPassword, Blocked, AccountMigrated, NotPremium };
/// <summary>
/// Allows to login to a premium Minecraft account using the Yggdrasil authentication scheme.
@ -66,6 +66,10 @@ namespace MinecraftClient
else return LoginResult.WrongPassword;
}
}
else if ((int)response.StatusCode == 503)
{
return LoginResult.ServiceUnavailable;
}
else return LoginResult.Blocked;
}
else if (e.Status == WebExceptionStatus.SendFailure)
@ -110,6 +114,11 @@ namespace MinecraftClient
bool encrypted = false;
int protocolversion;
public MinecraftCom()
{
foreach (ChatBot bot in scripts_on_hold) { bots.Add(bot); }
scripts_on_hold.Clear();
}
public bool Update()
{
for (int i = 0; i < bots.Count; i++) { bots[i].Update(); }
@ -174,14 +183,14 @@ namespace MinecraftClient
System.IO.File.WriteAllText("debug.txt", dump);
System.Diagnostics.Process.Start("debug.txt");
}
public bool OnConnectionLost()
public bool OnConnectionLost(ChatBot.DisconnectReason reason, string reason_message)
{
if (!connectionlost)
{
connectionlost = true;
for (int i = 0; i < bots.Count; i++)
{
if (bots[i].OnDisconnect(ChatBot.DisconnectReason.ConnectionLost, "Connection has been lost."))
if (bots[i].OnDisconnect(reason, reason_message))
{
return true; //The client is about to restart
}
@ -302,6 +311,11 @@ namespace MinecraftClient
{
if (!String.IsNullOrEmpty(str))
{
if (Settings.chatTimeStamps)
{
int hour = DateTime.Now.Hour, minute = DateTime.Now.Minute, second = DateTime.Now.Second;
ConsoleIO.Write(hour.ToString("00") + ':' + minute.ToString("00") + ':' + second.ToString("00") + ' ');
}
if (!acceptnewlines) { str = str.Replace('\n', ' '); }
if (ConsoleIO.basicIO) { ConsoleIO.WriteLine(str); return; }
string[] subs = str.Split(new char[] { '§' });
@ -450,7 +464,7 @@ namespace MinecraftClient
public bool Login(string username, string uuid, string sessionID, string host, int port)
{
byte[] packet_id = getVarInt(0);
byte[] protocol_version = getVarInt(4);
byte[] protocol_version = getVarInt(protocolversion);
byte[] server_adress_val = Encoding.UTF8.GetBytes(host);
byte[] server_adress_len = getVarInt(server_adress_val.Length);
byte[] server_port = BitConverter.GetBytes((ushort)port); Array.Reverse(server_port);
@ -580,9 +594,15 @@ namespace MinecraftClient
catch (SocketException) { }
catch (System.IO.IOException) { }
catch (NullReferenceException) { }
catch (ObjectDisposedException) { }
foreach (ChatBot bot in bots)
if (bot is Bots.Script)
scripts_on_hold.Add((Bots.Script)bot);
}
private List<ChatBot> bots = new List<ChatBot>();
private static List<Bots.Script> scripts_on_hold = new List<Bots.Script>();
public void BotLoad(ChatBot b) { b.SetHandler(this); bots.Add(b); b.Initialize(); Settings.SingleCommand = ""; }
public void BotUnLoad(ChatBot b) { bots.RemoveAll(item => object.ReferenceEquals(item, b)); }
public void BotClear() { bots.Clear(); }

View file

@ -15,7 +15,7 @@ namespace MinecraftClient
{
private static McTcpClient Client;
public static string[] startupargs;
public const string Version = "1.7.2";
public const string Version = "1.7.3";
/// <summary>
/// The main entry point of Minecraft Console Client
@ -23,7 +23,7 @@ namespace MinecraftClient
static void Main(string[] args)
{
Console.WriteLine("Console Client for MC 1.7.2 to 1.7.5 - v" + Version + " - By ORelio & Contributors");
Console.WriteLine("Console Client for MC 1.7.2 to 1.7.9 - v" + Version + " - By ORelio & Contributors");
//Basic Input/Output ?
if (args.Length >= 1 && args[args.Length - 1] == "BasicIO")
@ -65,91 +65,6 @@ namespace MinecraftClient
{
Settings.SingleCommand = args[3];
}
//Use bots? (will disable single command)
for (int i = 3; i < args.Length; i++)
{
if (args[i].Length > 4 && args[i].Substring(0, 4).ToLower() == "bot:")
{
Settings.SingleCommand = "";
string[] botargs = args[i].ToLower().Split(':');
switch (botargs[1])
{
#region Process bots settings
case "antiafk":
Settings.AntiAFK_Enabled = true;
if (botargs.Length > 2)
{
try { Settings.AntiAFK_Delay = Convert.ToInt32(botargs[2]); }
catch (FormatException) { }
} break;
case "pendu":
Settings.Hangman_Enabled = true;
Settings.Hangman_English = false;
break;
case "hangman":
Settings.Hangman_Enabled = true;
Settings.Hangman_English = true;
break;
case "alerts":
Settings.Alerts_Enabled = true;
break;
case "log":
Settings.ChatLog_Enabled = true;
Settings.ChatLog_DateTime = true;
Settings.ChatLog_File = "chat-" + Settings.ServerIP.Replace(':', '-') + ".log";
if (botargs.Length > 2)
{
Settings.ChatLog_DateTime = Settings.str2bool(botargs[2]);
if (botargs.Length > 3)
{
Settings.ChatLog_Filter = Bots.ChatLog.str2filter(botargs[3]);
if (botargs.Length > 4 && botargs[4] != "") { Settings.ChatLog_File = botargs[4]; }
}
} break;
case "logplayerlist":
Settings.PlayerLog_File = "connected-" + Settings.ServerIP.Replace(':', '-') + ".log";
if (botargs.Length > 2)
{
try { Settings.PlayerLog_Delay = Convert.ToInt32(botargs[2]); }
catch (FormatException) { }
} break;
case "autorelog":
if (botargs.Length > 2)
{
try { Settings.AutoRelog_Delay = Convert.ToInt32(botargs[2]); }
catch (FormatException) { }
if (botargs.Length > 3)
{
try { Settings.AutoRelog_Retries = Convert.ToInt32(botargs[3]); }
catch (FormatException) { }
}
} break;
case "xauth":
if (botargs.Length > 2)
{
Settings.xAuth_Enabled = true;
Settings.xAuth_Password = botargs[2];
} break;
case "scripting":
if (botargs.Length > 2)
{
Settings.Scripting_Enabled = true;
Settings.Scripting_ScriptFile = botargs[2];
} break;
#endregion
}
}
}
}
}
}
@ -228,7 +143,7 @@ namespace MinecraftClient
if (MinecraftCom.GetServerInfo(Settings.ServerIP, ref protocolversion, ref version))
{
//Supported protocol version ?
int[] supportedVersions = { 4 };
int[] supportedVersions = { 4, 5 };
if (Array.IndexOf(supportedVersions, protocolversion) > -1)
{
//Load translations (Minecraft 1.6+)
@ -241,14 +156,14 @@ namespace MinecraftClient
handler.setVersion(protocolversion);
//Load & initialize bots if needed
if (Settings.AntiAFK_Enabled) { handler.BotLoad(new Bots.AntiAFK(Settings.AntiAFK_Delay)); }
if (Settings.Hangman_Enabled) { handler.BotLoad(new Bots.Pendu(Settings.Hangman_English)); }
if (Settings.Alerts_Enabled) { handler.BotLoad(new Bots.Alerts()); }
if (Settings.ChatLog_Enabled) { handler.BotLoad(new Bots.ChatLog(Settings.ChatLog_File, Settings.ChatLog_Filter, Settings.ChatLog_DateTime)); }
if (Settings.PlayerLog_Enabled) { handler.BotLoad(new Bots.PlayerListLogger(Settings.PlayerLog_Delay, Settings.PlayerLog_File)); }
if (Settings.AutoRelog_Enabled) { handler.BotLoad(new Bots.AutoRelog(Settings.AutoRelog_Delay, Settings.AutoRelog_Retries)); }
if (Settings.xAuth_Enabled) { handler.BotLoad(new Bots.xAuth(Settings.xAuth_Password)); }
if (Settings.Scripting_Enabled) { handler.BotLoad(new Bots.Scripting(Settings.Scripting_ScriptFile)); }
if (Settings.AntiAFK_Enabled) { handler.BotLoad(new Bots.AntiAFK(Settings.AntiAFK_Delay)); }
if (Settings.Hangman_Enabled) { handler.BotLoad(new Bots.Pendu(Settings.Hangman_English)); }
if (Settings.Alerts_Enabled) { handler.BotLoad(new Bots.Alerts()); }
if (Settings.ChatLog_Enabled) { handler.BotLoad(new Bots.ChatLog(Settings.ChatLog_File.Replace("%username%", Settings.Username), Settings.ChatLog_Filter, Settings.ChatLog_DateTime)); }
if (Settings.PlayerLog_Enabled) { handler.BotLoad(new Bots.PlayerListLogger(Settings.PlayerLog_Delay, Settings.PlayerLog_File.Replace("%username%", Settings.Username))); }
if (Settings.AutoRelog_Enabled) { handler.BotLoad(new Bots.AutoRelog(Settings.AutoRelog_Delay, Settings.AutoRelog_Retries)); }
if (Settings.ScriptScheduler_Enabled) { handler.BotLoad(new Bots.ScriptScheduler(Settings.ScriptScheduler_TasksFile.Replace("%username%", Settings.Username))); }
if (Settings.RemoteCtrl_Enabled) { handler.BotLoad(new Bots.RemoteControl()); }
//Start the main TCP client
if (Settings.SingleCommand != "")
@ -277,6 +192,7 @@ namespace MinecraftClient
{
case MinecraftCom.LoginResult.AccountMigrated: Console.WriteLine("Account migrated, use e-mail as username."); break;
case MinecraftCom.LoginResult.Blocked: Console.WriteLine("Too many failed logins. Please try again later."); break;
case MinecraftCom.LoginResult.ServiceUnavailable: Console.WriteLine("Login servers are unavailable. Please try again later."); break;
case MinecraftCom.LoginResult.WrongPassword: Console.WriteLine("Incorrect password."); break;
case MinecraftCom.LoginResult.NotPremium: Console.WriteLine("User not premium."); break;
case MinecraftCom.LoginResult.OtherError: Console.WriteLine("Network error."); break;

View file

@ -27,8 +27,9 @@ namespace MinecraftClient
public static string TranslationsFile_FromMCDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\.minecraft\assets\objects\9e\9e2fdc43fc1c7024ff5922b998fadb2971a64ee0"; //MC 1.7.4 en_GB.lang
public static string TranslationsFile_Website_Index = "https://s3.amazonaws.com/Minecraft.Download/indexes/1.7.4.json";
public static string TranslationsFile_Website_Download = "http://resources.download.minecraft.net";
public static string Bots_OwnersFile = "bot-owners.txt";
public static List<string> Bots_Owners = new List<string>();
public static string Language = "en_GB";
public static bool chatTimeStamps = false;
//AntiAFK Settings
public static bool AntiAFK_Enabled = false;
@ -43,6 +44,7 @@ namespace MinecraftClient
//Alerts Settings
public static bool Alerts_Enabled = false;
public static bool Alerts_Beep_Enabled = true;
public static string Alerts_MatchesFile = "alerts.txt";
public static string Alerts_ExcludesFile = "alerts-exclude.txt";
@ -63,16 +65,14 @@ namespace MinecraftClient
public static int AutoRelog_Retries = 3;
public static string AutoRelog_KickMessagesFile = "kickmessages.txt";
//xAuth Settings
public static bool xAuth_Enabled = false;
public static string xAuth_Password = "";
//Script Scheduler Settings
public static bool ScriptScheduler_Enabled = false;
public static string ScriptScheduler_TasksFile = "tasks.ini";
//Scripting Settings
public static bool Scripting_Enabled = false;
public static string Scripting_ScriptFile = "script.txt";
//Remote Control
public static bool RemoteCtrl_Enabled = false;
private enum ParseMode { Default, Main, AntiAFK, Hangman, Alerts, ChatLog, AutoRelog, Scripting };
private enum ParseMode { Default, Main, AntiAFK, Hangman, Alerts, ChatLog, AutoRelog, ScriptScheduler, RemoteControl };
/// <summary>
/// Load settings from the give INI file
@ -102,7 +102,8 @@ namespace MinecraftClient
case "chatlog": pMode = ParseMode.ChatLog; break;
case "hangman": pMode = ParseMode.Hangman; break;
case "main": pMode = ParseMode.Main; break;
case "scripting": pMode = ParseMode.Scripting; break;
case "scriptscheduler": pMode = ParseMode.ScriptScheduler; break;
case "remotecontrol": pMode = ParseMode.RemoteControl; break;
default: pMode = ParseMode.Default; break;
}
}
@ -122,8 +123,13 @@ namespace MinecraftClient
case "serverip": ServerIP = argValue; break;
case "singlecommand": SingleCommand = argValue; break;
case "language": Language = argValue; break;
case "botownersfile": Bots_OwnersFile = argValue; break;
case "consoletitle": ConsoleTitle = argValue; break;
case "timestamps": chatTimeStamps = str2bool(argValue); break;
case "botowners":
Bots_Owners.Clear();
foreach (string name in argValue.ToLower().Replace(" ", "").Split(','))
Bots_Owners.Add(name);
break;
}
break;
@ -133,6 +139,7 @@ namespace MinecraftClient
case "enabled": Alerts_Enabled = str2bool(argValue); break;
case "alertsfile": Alerts_MatchesFile = argValue; break;
case "excludesfile": Alerts_ExcludesFile = argValue; break;
case "beeponalert": Alerts_Beep_Enabled = str2bool(argValue); break;
}
break;
@ -175,11 +182,18 @@ namespace MinecraftClient
}
break;
case ParseMode.Scripting:
case ParseMode.ScriptScheduler:
switch (argName.ToLower())
{
case "enabled": Scripting_Enabled = str2bool(argValue); break;
case "scriptfile": Scripting_ScriptFile = argValue; break;
case "enabled": ScriptScheduler_Enabled = str2bool(argValue); break;
case "tasksfile": ScriptScheduler_TasksFile = argValue; break;
}
break;
case ParseMode.RemoteControl:
switch (argName.ToLower())
{
case "enabled": RemoteCtrl_Enabled = str2bool(argValue); break;
}
break;
}
@ -205,7 +219,7 @@ namespace MinecraftClient
+ "[Main]\r\n"
+ "\r\n"
+ "#General settings\r\n"
+ "#leave blank = prompt user on startup\r\n"
+ "#leave blank to prompt user on startup\r\n"
+ "#Use \"-\" as password for offline mode\r\n"
+ "\r\n"
+ "login=\r\npassword=\r\nserverip=\r\n"
@ -213,8 +227,9 @@ namespace MinecraftClient
+ "#Advanced settings\r\n"
+ "\r\n"
+ "language=en_GB\r\n"
+ "botownersfile=bot-owners.txt\r\n"
+ "botowners=Player1,Player2,Player3\r\n"
+ "consoletitle=%username% - Minecraft Console Client\r\n"
+ "timestamps=false\r\n"
+ "\r\n"
+ "#Bot Settings\r\n"
+ "\r\n"
@ -222,6 +237,7 @@ namespace MinecraftClient
+ "enabled=false\r\n"
+ "alertsfile=alerts.txt\r\n"
+ "excludesfile=alerts-exclude.txt\r\n"
+ "beeponalert=true\r\n"
+ "\r\n"
+ "[AntiAFK]\r\n"
+ "enabled=false\r\n"
@ -246,9 +262,12 @@ namespace MinecraftClient
+ "wordsfile=hangman-en.txt\r\n"
+ "fichiermots=hangman-fr.txt\r\n"
+ "\r\n"
+ "[Scripting]\r\n"
+ "[ScriptScheduler]\r\n"
+ "enabled=false\r\n"
+ "scriptfile=testscript.txt\r\n", Encoding.UTF8);
+ "tasksfile=tasks.ini\r\n"
+ "\r\n"
+ "[RemoteControl]\r\n"
+ "enabled=false\r\n", Encoding.UTF8);
}
public static int str2int(string str) { try { return Convert.ToInt32(str); } catch { return 0; } }

View file

@ -1,2 +0,0 @@
ORelio
PutYourNameHere

View file

@ -20,7 +20,7 @@ CHURCH
OFFICE
APRICOT
PLANISPHERE
WORLDWIDE
WORLD MAP
FISHING
CASE
SADDLE

View file

@ -0,0 +1,13 @@
# This is a sample script for Minecraft Console Client
# Any line beginning with "#" is ignored and treated as a comment.
# Allowed instructions: send, wait, disconnect, exit
# send <text> : send a message or a command to the server
# wait <time> : wait X ticks (10 ticks = 1 second)
# connect <serverip> : go to the given server and resume the script
# disconnect : disconnect from the server and exit the client
# exit : exit this script but stay connected to the server
send Hello World! I'm a bot scripted using Minecraft Console Client.
wait 60
send Now quitting. Bye :)
disconnect

View file

@ -0,0 +1,34 @@
# Minecraft Console Client
# ScriptScheduler Tasks
# Example config file
# Structure of a task: [Task] Followed by triggers and other settings.
# The example below contains all the possible fields for a task
# Time is HH:mm format, several different hours can be provided
[Task]
triggerOnFirstLogin=false
triggerOnLogin=false
triggerOnTime=true
timeValue=19:30
timeValue=08:10
script=event.txt
# Another minimal example: some properties may be omitted
# This is highly recommended for improving task readability
[Task]
triggerOnFirstLogin=true
script=startup.txt
# Of course, the tasks file can contain as much tasks as you want.
# Another example tiggered on logging in and every night at midnight:
[Task]
triggerOnLogin=true
triggerOnTime=true
timeValue=00:00
script=midnight.txt
# Enjoy!
# - ORelio

View file

@ -1,4 +0,0 @@
send Hello World! I'm a bot.
wait 60
send Now quitting :)
disconnect