Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
86be6f6
Add cleanup filters "nopower" and "haspower". Add option to stop all …
rexxar-tc Jun 4, 2018
8773f93
Ask Jenkins to please build this against the Torch/client-mod branch.…
rexxar-tc Jun 11, 2018
2121aa6
Add !utility listgrids command to show the user all grids they own. C…
rexxar-tc Jun 11, 2018
e177313
Put MOTD in a dialog because that's nicer than chat.
rexxar-tc Jun 11, 2018
aa8322f
Add 'insideplanet' argument to grid cleanup. Finds grids that are mor…
rexxar-tc Jun 11, 2018
b3ed0f9
Add logging to cleanup
rexxar-tc Jun 11, 2018
250a28d
Remove !utlity listrids because !grids list is apparently a thing.
rexxar-tc Jun 11, 2018
661c8e7
Fix #25 !grids static large command not syncing
rexxar-tc Jun 11, 2018
fdb825a
Implement #38 : cleanup voxels with no grids nearby.
rexxar-tc Jun 11, 2018
10d2567
Add separate MOTD for new users.
rexxar-tc Jun 11, 2018
dfbc5dd
Make AutoCommands suck less.
rexxar-tc Jun 14, 2018
73053d2
Add !cleanup help command.
rexxar-tc Jun 16, 2018
2d9b0fe
Un-break cleanup.
rexxar-tc Jun 18, 2018
dd5b48c
Remove global static logger to make Equinox happy
rexxar-tc Jun 18, 2018
f7a9a21
Complete refactor of auto commands! I even tested it this time!
rexxar-tc Jul 3, 2018
5af3086
Fix a typo in autocommand helptext
rexxar-tc Jul 4, 2018
300dfea
!cleanup list now prints to a dialog window.
rexxar-tc Jul 4, 2018
8c05800
Implement info commands
rexxar-tc Jul 6, 2018
770f7d0
Fix crashes in autocommands
rexxar-tc Jul 6, 2018
6928828
client-mod branch deleted, build against master again
rexxar-tc Jul 7, 2018
58122b0
Add !voxels reset planets
rexxar-tc Jul 8, 2018
dcee1aa
Change cleanup conditions to public. Might change behavior??
rexxar-tc Jul 8, 2018
cf47d52
Fix borked cleanup
rexxar-tc Jul 9, 2018
d726efd
Add %player% wildcard to MOTD. Replaces with receiving player's name.
rexxar-tc Jul 9, 2018
085796f
Fix haspower check crashing with a key not present error
rexxar-tc Jul 9, 2018
de1542c
Add DayOfWeek option to auto commands.
rexxar-tc Jul 9, 2018
9921a0e
Don't be stupid and use ViewModels
rexxar-tc Jul 10, 2018
111442e
Default cleanup to not search for grids with pilots.
rexxar-tc Jul 18, 2018
ece8376
Delay sending MOTD until the player spawns with a character.
rexxar-tc Jul 18, 2018
d695c86
Be careful using copy and paste
Jimmacle Jul 19, 2018
9220a94
Fix entity refresh reflection
Jimmacle Jul 19, 2018
0bc78d2
Actually fix entities refresh command
Jimmacle Jul 19, 2018
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
Prev Previous commit
Next Next commit
Make AutoCommands suck less.
Throw away xaml UI and just use a property grid.
  • Loading branch information
rexxar-tc committed Jun 14, 2018
commit dfbc5dd8ff96d6394a3f8c3a24a030ac44bc9950
32 changes: 23 additions & 9 deletions Essentials/AutoCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Torch.Commands;
using Torch.API.Managers;
using Torch.Server;
using Torch.Views;

namespace Essentials
{
Expand All @@ -20,27 +21,40 @@ public class AutoCommand : ViewModel, IDisposable
public bool Enabled { get => _enabled; set { _enabled = value; OnTimerChanged(); OnPropertyChanged(); } }
private string _command;
public string Command { get => _command; set { _command = value; OnTimerChanged(); OnPropertyChanged(); } }
private int _dueTime;
public int DueTime { get => _dueTime / 1000; set { _dueTime = value * 1000; OnTimerChanged(); OnPropertyChanged(); } }
private int _period;
public int Period { get => _period / 1000; set { _period = value * 1000; OnTimerChanged(); OnPropertyChanged(); } }
private TimeSpan _initialDelay;

[Display(Name = "Initial Delay", Description = "Sets the initial delay after server start before this command is run.")]
public string InitialDelay
{
get => _initialDelay.ToString();
set => _initialDelay = TimeSpan.Parse(value);
}

private TimeSpan _repeatInterval;

[Display(Name = "Repeat Interval", Description = "Sets the interval on which this command will be repeated after the first run.")]
public string RepeatInterval
{
get => _repeatInterval.ToString();
set => _repeatInterval = TimeSpan.Parse(value);
}

private void OnTimerChanged()
{
_timer?.Dispose();
if (Enabled && Period > 0)
_timer = new Timer(RunCommand, this, _dueTime, _period);
if (Enabled && _repeatInterval.TotalMilliseconds > 0)
_timer = new Timer(RunCommand, this, _initialDelay, _repeatInterval);
}

private void RunCommand(object state)
{
if (((TorchServer)TorchBase.Instance).State != ServerState.Running)
if (((TorchServer)EssentialsPlugin.Instance.Torch).State != ServerState.Running)
return;

var autoCommand = (AutoCommand)state;
TorchBase.Instance.Invoke(() =>
EssentialsPlugin.Instance.Torch.Invoke(() =>
{
var manager = TorchBase.Instance.CurrentSession.Managers.GetManager<CommandManager>();
var manager = EssentialsPlugin.Instance.Torch.CurrentSession.Managers.GetManager<CommandManager>();
manager?.HandleCommandFromServer(autoCommand.Command);
});
}
Expand Down
15 changes: 13 additions & 2 deletions Essentials/EssentialsConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,43 @@
using System.Text;
using System.Threading.Tasks;
using Torch;
using Torch.Views;

namespace Essentials
{
public class EssentialsConfig : ViewModel
{
public ObservableCollection<AutoCommand> AutoCommands { get; } = new ObservableCollection<AutoCommand>();

public ObservableCollection<AutoCommand> AutoCommands
{
get { return _autoCommands; }
set { SetValue(ref _autoCommands, value); }
}

private string _motd;
public string Motd { get => _motd; set => SetValue(ref _motd, value); }

private string _newUserMotd;
public string NewUserMotd { get => _newUserMotd; set => SetValue(ref _newUserMotd, value); }

private string _motdUrl;
[Display(Name = "MotdURL", Description = "Sets a URL to show to players when they connect. Opens in the steam overlay, if enabled.")]
public string MotdUrl { get => _motdUrl; set => SetValue(ref _motdUrl, value); }

private bool _stopShips;
[Display(Name = "Stop entities on start", Description = "Stop all entities in the world when the server starts.")]
public bool StopShipsOnStart { get => _stopShips; set => SetValue(ref _stopShips, value); }

private bool _utilityShowPosition;
private ObservableCollection<AutoCommand> _autoCommands = new ObservableCollection<AutoCommand>();

[Display(Name = "Grid list show position",Description = "Show users the position of all grids they own in the grids list command.")]
public bool UtilityShowPosition
{
get => _utilityShowPosition;
set => SetValue(ref _utilityShowPosition, value);
}

[Display(Visible=false)]
public ObservableCollection<ulong> KnownSteamIds { get; } = new ObservableCollection<ulong>();
}
}
10 changes: 8 additions & 2 deletions Essentials/EssentialsPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Torch.Mod;
using Torch.Mod.Messages;
using Torch.Session;
using Torch.Views;
using VRage.Game;
using VRage.Game.Entity;
using VRage.Game.ModAPI;
Expand All @@ -35,15 +36,15 @@ public class EssentialsPlugin : TorchPluginBase, IWpfPlugin

private TorchSessionManager _sessionManager;

private EssentialsControl _control;
private UserControl _control;
private Persistent<EssentialsConfig> _config;
public static readonly Logger Log = LogManager.GetLogger("Essentials");
private HashSet<ulong> _motdOnce = new HashSet<ulong>();

public static EssentialsPlugin Instance { get; private set; }

/// <inheritdoc />
public UserControl GetControl() => _control ?? (_control = new EssentialsControl(this));
public UserControl GetControl() => _control ?? (_control = new PropertyGrid(){DataContext=Config, IsEnabled = false});

public void Save()
{
Expand Down Expand Up @@ -74,6 +75,11 @@ private void SessionChanged(ITorchSession session, TorchSessionState state)
MyEntities.OnEntityAdd += MotdOnce;
if(Config.StopShipsOnStart)
StopShips();
_control.Dispatcher.Invoke(() =>
{
_control.IsEnabled = true;
_control.DataContext = Config;
});
break;
case TorchSessionState.Unloading:
mpMan.PlayerLeft -= ResetMotdOnce;
Expand Down