Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 0 additions & 65 deletions Essentials/EssentialsConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,71 +98,6 @@ public int BackpackLimit
[Display(Visible=false)]
public ObservableCollection<ulong> KnownSteamIds { get; } = new ObservableCollection<ulong>();

private bool _packRespawn;
[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.")]
public bool PackRespawn
{
get => _packRespawn;
set => SetValue(ref _packRespawn, value);
}

private int _maxRespawnSize;
[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.")]
public int MaxPackedRespawnSize
{
get => _maxRespawnSize;
set => SetValue(ref _maxRespawnSize, value);
}

private string _loadingText;
[Display(Name = "Loading Text", GroupName = "Client Join Tweaks", Order = 3, Description = "Text displayed on the loading screen while the client is joining.")]
public string LoadingText
{
get => _loadingText;
set => SetValue(ref _loadingText, string.IsNullOrEmpty(value) ? null : value);
}

private bool _enableClientTweaks = false;

[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.")]
public bool EnableClientTweaks
{
get => _enableClientTweaks;
set => SetValue(ref _enableClientTweaks, value);
}

private bool _enableToolbarOverride;
[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.")]
public bool EnableToolbarOverride
{
get => _enableToolbarOverride;
set => SetValue(ref _enableToolbarOverride, value);
}

private CompressionLevel _compression = CompressionLevel.Optimal;
[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'")]
public CompressionLevel CompressionLevel
{
get => _compression;
set => SetValue(ref _compression, value);
}

private bool _asyncJoin;
[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'")]
public bool AsyncJoin
{
get => _asyncJoin;
set => SetValue(ref _asyncJoin, value);
}

private bool _packPlanets;
[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!")]
public bool PackPlanets
{
get => _packPlanets;
set => SetValue(ref _packPlanets, value);
}

private bool _cutGameTags;
[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'.")]
public bool CutGameTags
Expand Down
25 changes: 20 additions & 5 deletions Essentials/EssentialsPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ public class EssentialsPlugin : TorchPluginBase, IWpfPlugin
private HashSet<ulong> _motdOnce = new HashSet<ulong>();
private PatchManager _pm;
private PatchContext _context;


public static EssentialsPlugin Instance { get; private set; }
public PlayerAccountModule AccModule = new PlayerAccountModule();
RanksAndPermissionsModule RanksAndPermissions = new RanksAndPermissionsModule();
private static bool _initilized = false;


/// <inheritdoc />
public UserControl GetControl() => _control ?? (_control = new PropertyGrid(){DataContext=Config/*, IsEnabled = false*/});
Expand Down Expand Up @@ -139,13 +142,25 @@ private void SessionChanged(ITorchSession session, TorchSessionState state)
});
AutoCommands.Instance.Start();
InfoModule.Init();
_initilized = true;


break;


case TorchSessionState.Unloading:
Log.Info("Unloading rank data into JSON");
RanksAndPermissions.SaveRankData();
mpMan.PlayerLeft -= ResetMotdOnce;
mpMan.PlayerJoined -= MotdOnce;
MyEntities.OnEntityAdd -= EntityAdded;

if (_initilized)
{
//Dont try and remove these unless server was actually fully initlized
Log.Info("Unloading rank data into JSON");
RanksAndPermissions.SaveRankData();
mpMan.PlayerLeft -= ResetMotdOnce;
mpMan.PlayerJoined -= MotdOnce;
MyEntities.OnEntityAdd -= EntityAdded;
}


_bagTracker.Clear();
_removalTracker.Clear();
break;
Expand Down
Loading