From 9ead72b356b2d152be13981d835206323753217d Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 13 Dec 2023 19:32:01 +1100 Subject: [PATCH] Change Warps to be an internal module, and lazy load warps/waypoints only when actually required --- MCGalaxy/Commands/Command.cs | 2 +- MCGalaxy/CorePlugin/ConnectHandler.cs | 10 ---- MCGalaxy/MCGalaxy_.csproj | 12 +++-- MCGalaxy/Modules/Awards/AwardsList.cs | 9 ++++ MCGalaxy/Modules/Awards/CmdAward.cs | 6 ++- MCGalaxy/Modules/Warps/CmdWarp.cs | 46 ++++++++++++++++++ .../World => Modules/Warps}/CmdWaypoint.cs | 17 +++++-- MCGalaxy/{Player => Modules/Warps}/Warp.cs | 25 +++++++--- .../Warps/WarpCommand.cs} | 38 +++++++-------- MCGalaxy/Modules/Warps/WarpPlugin.cs | 48 +++++++++++++++++++ MCGalaxy/Player/Player.Fields.cs | 1 - MCGalaxy/Player/Player.cs | 1 - MCGalaxy/Scripting/Plugin.cs | 30 +++++------- MCGalaxy/Server/Paths.cs | 2 +- MCGalaxy/Server/Server.cs | 3 -- MCGalaxy/util/Formatting/Matcher.cs | 17 ------- 16 files changed, 175 insertions(+), 92 deletions(-) create mode 100644 MCGalaxy/Modules/Warps/CmdWarp.cs rename MCGalaxy/{Commands/World => Modules/Warps}/CmdWaypoint.cs (75%) rename MCGalaxy/{Player => Modules/Warps}/Warp.cs (85%) rename MCGalaxy/{Commands/World/CmdWarp.cs => Modules/Warps/WarpCommand.cs} (71%) create mode 100644 MCGalaxy/Modules/Warps/WarpPlugin.cs diff --git a/MCGalaxy/Commands/Command.cs b/MCGalaxy/Commands/Command.cs index ac34ec835..91e3746c9 100644 --- a/MCGalaxy/Commands/Command.cs +++ b/MCGalaxy/Commands/Command.cs @@ -32,7 +32,7 @@ namespace MCGalaxy public virtual string shortcut { get { return ""; } } /// The type/group of this command (see `CommandTypes` class) public abstract string type { get; } - /// Whether this comand can be used in museums + /// Whether this command can be used in museums /// Level altering (e.g. places a block) commands should return false public virtual bool museumUsable { get { return true; } } /// The default minimum rank that is required to use this command diff --git a/MCGalaxy/CorePlugin/ConnectHandler.cs b/MCGalaxy/CorePlugin/ConnectHandler.cs index 338201bbb..f9b98b35f 100644 --- a/MCGalaxy/CorePlugin/ConnectHandler.cs +++ b/MCGalaxy/CorePlugin/ConnectHandler.cs @@ -25,7 +25,6 @@ namespace MCGalaxy.Core { CheckReviewList(p); if (p.CanUse("ReachDistance")) LoadReach(p); - LoadWaypoints(p); p.Ignores.Load(p); } @@ -51,14 +50,5 @@ namespace MCGalaxy.Core { p.ReachDistance = reachDist / 32f; p.Session.SendSetReach(p.ReachDistance); } - - static void LoadWaypoints(Player p) { - try { - p.Waypoints.Filename = Paths.WaypointsDir + p.name + ".save"; - p.Waypoints.Load(); - } catch (Exception ex) { - Logger.LogError("Error loading waypoints", ex); - } - } } } diff --git a/MCGalaxy/MCGalaxy_.csproj b/MCGalaxy/MCGalaxy_.csproj index 06a0f9155..f6f346a6c 100644 --- a/MCGalaxy/MCGalaxy_.csproj +++ b/MCGalaxy/MCGalaxy_.csproj @@ -317,8 +317,6 @@ - - @@ -604,6 +602,11 @@ + + + + + @@ -634,7 +637,6 @@ - @@ -710,7 +712,9 @@ Always - + + +