Skip to content

Commit 809bef7

Browse files
committed
Merge branch 'master' of https://github.com/TorchAPI/Essentials
2 parents 05ade45 + 2b3d43e commit 809bef7

3 files changed

Lines changed: 79 additions & 494 deletions

File tree

‎Essentials/EssentialsConfig.cs‎

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -98,71 +98,6 @@ public int BackpackLimit
9898
[Display(Visible=false)]
9999
public ObservableCollection<ulong> KnownSteamIds { get; } = new ObservableCollection<ulong>();
100100

101-
private bool _packRespawn;
102-
[Display(Name = "Pack Respawn", GroupName = "Client Join Tweaks", Order = 1, Description = "Packs ships which the client could respawn at into the initial world send. Will significantly decrease time waiting for ships to sync from the respawn menu, at the cost of slightly increased server load during client join.")]
103-
public bool PackRespawn
104-
{
105-
get => _packRespawn;
106-
set => SetValue(ref _packRespawn, value);
107-
}
108-
109-
private int _maxRespawnSize;
110-
[Display(Name = "Max Packed Respawn Size", GroupName = "Client Join Tweaks", Order = 2, Description = "Maximum size, in total block count, of ships that can be packed into the world send. Useful if your players often have very large grids. Will slightly lower performance impact of Pack Respawn option, by forcing clients to wait for very large grids the old way.")]
111-
public int MaxPackedRespawnSize
112-
{
113-
get => _maxRespawnSize;
114-
set => SetValue(ref _maxRespawnSize, value);
115-
}
116-
117-
private string _loadingText;
118-
[Display(Name = "Loading Text", GroupName = "Client Join Tweaks", Order = 3, Description = "Text displayed on the loading screen while the client is joining.")]
119-
public string LoadingText
120-
{
121-
get => _loadingText;
122-
set => SetValue(ref _loadingText, string.IsNullOrEmpty(value) ? null : value);
123-
}
124-
125-
private bool _enableClientTweaks = false;
126-
127-
[Display(Name = "Enable", GroupName = "Client Join Tweaks", Order = 0, Description = "Enables the client join tweak system. None of the options in this section will work if this is unchecked.")]
128-
public bool EnableClientTweaks
129-
{
130-
get => _enableClientTweaks;
131-
set => SetValue(ref _enableClientTweaks, value);
132-
}
133-
134-
private bool _enableToolbarOverride;
135-
[Display(Name = "Override Default Toolbar", GroupName = "Client Join Tweaks", Order = 4, Description = "Allows you to set a default toolbar for new players on the server. You can set the toolbar ingame with the !admin set toolbar command. This will make your current toolbar the new default.")]
136-
public bool EnableToolbarOverride
137-
{
138-
get => _enableToolbarOverride;
139-
set => SetValue(ref _enableToolbarOverride, value);
140-
}
141-
142-
private CompressionLevel _compression = CompressionLevel.Optimal;
143-
[Display(Name = "Compression Level", GroupName = "Client Join Tweaks", Order = 5, Description = "Sets the level of compression applied to client data. Higher compression takes more CPU, but less network bandwidth. Recommended to leave this at 'Optimal'")]
144-
public CompressionLevel CompressionLevel
145-
{
146-
get => _compression;
147-
set => SetValue(ref _compression, value);
148-
}
149-
150-
private bool _asyncJoin;
151-
[Display(Name = "Async Join", GroupName = "Client Join Tweaks", Order = 6, Description = "Speeds up client joining by moving almost all of the logic out of the game thread. Disable this if you get 'CollectionModifiedException'")]
152-
public bool AsyncJoin
153-
{
154-
get => _asyncJoin;
155-
set => SetValue(ref _asyncJoin, value);
156-
}
157-
158-
private bool _packPlanets;
159-
[Display(Name = "Pack Planets", GroupName = "Client Join Tweaks", Order = 7, Description = "Packs planet data into initial world download. Can speed up spawning in some cases. CAUTION: Planet data is very large! You should use Compression Level 'Optimal' and the Async Join option!")]
160-
public bool PackPlanets
161-
{
162-
get => _packPlanets;
163-
set => SetValue(ref _packPlanets, value);
164-
}
165-
166101
private bool _cutGameTags;
167102
[Display(Name = "Cut Game Tags", GroupName = "Client Join Tweaks", Order = 8, Description = "Cuts mods and blocks limits from matchmaking server info. Prevents from 'error downloading session settings'.")]
168103
public bool CutGameTags

‎Essentials/EssentialsPlugin.cs‎

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,13 @@ public class EssentialsPlugin : TorchPluginBase, IWpfPlugin
5454
private HashSet<ulong> _motdOnce = new HashSet<ulong>();
5555
private PatchManager _pm;
5656
private PatchContext _context;
57+
5758

5859
public static EssentialsPlugin Instance { get; private set; }
5960
public PlayerAccountModule AccModule = new PlayerAccountModule();
6061
RanksAndPermissionsModule RanksAndPermissions = new RanksAndPermissionsModule();
62+
private static bool _initilized = false;
63+
6164

6265
/// <inheritdoc />
6366
public UserControl GetControl() => _control ?? (_control = new PropertyGrid(){DataContext=Config/*, IsEnabled = false*/});
@@ -127,9 +130,11 @@ private void SessionChanged(ITorchSession session, TorchSessionState state)
127130
mpMan.PlayerJoined += AccModule.GenerateAccount;
128131
mpMan.PlayerJoined += AccModule.CheckIp;
129132
mpMan.PlayerJoined += MotdOnce;
130-
RanksAndPermissions.GenerateRank(Config.DefaultRank);
131-
mpMan.PlayerJoined += RanksAndPermissions.RegisterInheritedRanks;
132-
AccModule.ValidateRanks();
133+
if (Config.EnableRanks) {
134+
RanksAndPermissions.GenerateRank(Config.DefaultRank);
135+
mpMan.PlayerJoined += RanksAndPermissions.RegisterInheritedRanks;
136+
AccModule.ValidateRanks();
137+
}
133138

134139
mpMan.PlayerLeft += ResetMotdOnce;
135140
cmdMan.OnCommandExecuting +=RanksAndPermissions.HasCommandPermission;
@@ -143,13 +148,25 @@ private void SessionChanged(ITorchSession session, TorchSessionState state)
143148
});
144149
AutoCommands.Instance.Start();
145150
InfoModule.Init();
151+
_initilized = true;
152+
153+
146154
break;
155+
156+
147157
case TorchSessionState.Unloading:
148-
Log.Info("Unloading rank data into JSON");
149-
RanksAndPermissions.SaveRankData();
150-
mpMan.PlayerLeft -= ResetMotdOnce;
151-
mpMan.PlayerJoined -= MotdOnce;
152-
MyEntities.OnEntityAdd -= EntityAdded;
158+
159+
if (_initilized)
160+
{
161+
//Dont try and remove these unless server was actually fully initlized
162+
Log.Info("Unloading rank data into JSON");
163+
RanksAndPermissions.SaveRankData();
164+
mpMan.PlayerLeft -= ResetMotdOnce;
165+
mpMan.PlayerJoined -= MotdOnce;
166+
MyEntities.OnEntityAdd -= EntityAdded;
167+
}
168+
169+
153170
_bagTracker.Clear();
154171
_removalTracker.Clear();
155172
break;

0 commit comments

Comments
 (0)