Skip to content

Commit

Permalink
For state bot AI instruction, reduce default search distance for play…
Browse files Browse the repository at this point in the history
…ers to at most 1000 blocks away (was 20000)
  • Loading branch information
UnknownShadow200 committed Oct 31, 2023
1 parent ff95880 commit 4560ac8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
4 changes: 2 additions & 2 deletions MCGalaxy/Bots/Instructions/HunterInstructions.cs
Expand Up @@ -133,7 +133,7 @@ public sealed class StareInstruction : BotInstruction {
public StareInstruction() { Name = "stare"; }

public override bool Execute(PlayerBot bot, InstructionData data) {
int search = 20000;
int search = 1000;
if (data.Metadata != null) search = (ushort)data.Metadata;
Player closest = HuntInstruction.ClosestPlayer(bot, search);

Expand Down Expand Up @@ -170,7 +170,7 @@ public sealed class StareInstruction : BotInstruction {
static string[] help = new string[] {
"&T/BotAI add [name] stare <radius>",
"&HCauses the bot to stare at the closest player in the search radius.",
"&H <radius> defaults to 20000 blocks.",
"&H <radius> defaults to 1000 blocks.",
};
}
}
2 changes: 1 addition & 1 deletion MCGalaxy/Network/Heartbeat/Heartbeat.cs
Expand Up @@ -115,7 +115,7 @@ public abstract class Heartbeat


static string lastUrls;
public static void ReloadDefault() {
internal static void ReloadDefault() {
string urls = Server.Config.HeartbeatURL;
// don't reload heartbeats unless absolutely have to
if (urls == lastUrls) return;
Expand Down
24 changes: 7 additions & 17 deletions MCGalaxy/Server/Authentication/AuthService.cs
Expand Up @@ -66,25 +66,15 @@ public static AuthService GetOrCreate(string url, bool canSave = true)
}


static string lastUrls;
/// <summary> Reloads list of authentication services from server config </summary>
public static void UpdateList() {
string urls = Server.Config.HeartbeatURL;
LoadServices();

if (urls == lastUrls) return;
lastUrls = urls;

// only update services with defaults when absolutely have to
foreach (string url in urls.SplitComma())
{
GetOrCreate(url);
}
}

static void LoadServices() {
/// <summary> Updates list of authentication services from authservices.properties </summary>
internal static void UpdateList() {
AuthService cur = null;
PropertiesFile.Read(Paths.AuthServicesFile, ref cur, ParseProperty, '=', true);

// NOTE: Heartbeat.ReloadDefault will call GetOrCreate for all of the
// URLs specified in the HeartbeatURL server configuration property
// Therefore it is unnecessary to create default AuthServices here
// (e.g. for when authservices.properties is empty or is missing a URL)
}

static void ParseProperty(string key, string value, ref AuthService cur) {
Expand Down

0 comments on commit 4560ac8

Please sign in to comment.