diff --git a/MinecraftClient/MinecraftClient.csproj b/MinecraftClient/MinecraftClient.csproj index 013e6801..3fd436e6 100644 --- a/MinecraftClient/MinecraftClient.csproj +++ b/MinecraftClient/MinecraftClient.csproj @@ -50,11 +50,12 @@ + - + diff --git a/MinecraftClient/config/ChatBots/AutoLeaveOnLowHp.cs b/MinecraftClient/config/ChatBots/AutoLeaveOnLowHp.cs new file mode 100644 index 00000000..f60453e4 --- /dev/null +++ b/MinecraftClient/config/ChatBots/AutoLeaveOnLowHp.cs @@ -0,0 +1,22 @@ +//MCCScript 1.0 + +MCC.LoadBot(new AutoLeaveOnLowHp()); + +//MCCScript Extensions + +namespace MinecraftClient.ChatBots +{ + public class AutoLeaveOnLowHp : ChatBot + { + private float HEALTH_BOUNDARY = 10.0f; // 10 HP + + public override void OnHealthUpdate(float health, int food) + { + if (health <= HEALTH_BOUNDARY) + { + LogToConsole("Leaving because of low HP (Reconnecting in 5 minutes)!"); + ReconnectToTheServer(-1, 300); // Disconnect and reconnect after 5 minutes (300 seconds) + } + } + } +} \ No newline at end of file diff --git a/MinecraftClient/config/ChatBots/ClckRuAPI.cs b/MinecraftClient/config/ChatBots/ClckRuAPI.cs deleted file mode 100644 index 3e20792e..00000000 --- a/MinecraftClient/config/ChatBots/ClckRuAPI.cs +++ /dev/null @@ -1,29 +0,0 @@ -//MCCScript 1.0 -//using System.Threading.Tasks; - -MCC.LoadBot(new ClckRuAPIBot()); - -//MCCScript Extensions - -public class ClckRuAPIBot : ChatBot -{ - private PayKassaSCI clckapi { get; set; } - - public ClckRuAPIBot() - { - clckapi = new ClckRuAPI(); - } - -} - -internal class ClckRuAPI - { - public string ToCutURl(string url) - { - - WebClient webClient = new WebClient(); - string done = webClient.DownloadString("https://clck.ru/--?url=" + url); - return done; - } - } - diff --git a/MinecraftClient/config/ChatBots/EntityCount.cs b/MinecraftClient/config/ChatBots/EntityCount.cs new file mode 100644 index 00000000..38375367 --- /dev/null +++ b/MinecraftClient/config/ChatBots/EntityCount.cs @@ -0,0 +1,49 @@ +//MCCScript 1.0 + +MCC.LoadBot(new EntityCount()); + +//MCCScript Extensions + +class EntityCount : ChatBot +{ + public override void Initialize() + { + LogToConsole("Entity Count chat bot loaded!"); + RegisterChatBotCommand("entitycount", "Counts entities of a provided type", "entitycount [ ]", OnCommand); + } + + public string OnCommand(string cmd, string[] args) + { + if (args.Length < 1) + return "Invalid usage! Usage: /entitycount [ ]"; + + if (!Enum.TryParse(args[0], out EntityType entityType)) + return "Invalid entity type provided!\nSee: https://bit.ly/3NgSIFu"; + + Location? location = null; + + if (args.Length >= 4) + { + if (!Location.TryParse(GetCurrentLocation().ToFloor(), args[1], args[2], args[3], out location)) + return "Invalid location provided, check your input!"; + } + + int counter = 0; + + foreach (var (id, entity) in GetEntities()) + { + if (entity.Type == entityType) + { + if (location != null) + { + if (entity.Location.ToFloor() != ((Location)location).ToFloor()) + continue; + } + + counter++; + } + } + + return $"Found {counter} of entity type: {args[0]}"; + } +} \ No newline at end of file