Skip to content
This repository was archived by the owner on May 6, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AutoEvent/Commands/Config/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected override bool ExecuteParent(ArraySegment<string> arguments, ICommandSe

public override string Command => nameof(Config);
public override string[] Aliases => Array.Empty<string>();
public override string Description => "Allows modifying configs before and during events..";
public override string Description => "Allows modifying configs before and during events";
}

/*
Expand Down
2 changes: 1 addition & 1 deletion AutoEvent/Commands/Debug/Debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ protected override bool ExecuteParent(ArraySegment<string> arguments, ICommandSe

public override string Command => nameof(global::AutoEvent.Commands.Debug);
public override string[] Aliases => Array.Empty<string>();
public override string Description => "Runs various debug functions.";
public override string Description => "Runs various debug functions";
}
9 changes: 4 additions & 5 deletions AutoEvent/Commands/List.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public List()
// Log.Debug("Skipping Registering List Command");
}
public string Command => nameof(List);
public string Description => "Shows a list of all the events that can be started.";
public string Description => "Shows a list of all the events that can be started";
public string[] Aliases => new string[] { };
public string Permission { get; set; } = "ev.list";
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
Expand All @@ -28,6 +28,7 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
response = "<color=red>You do not have permission to use this command!</color>";
return false;
}

StringBuilder builder = new StringBuilder();
if (!IsConsoleCommandSender)
{
Expand Down Expand Up @@ -75,11 +76,10 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
builder.AppendLine($"{(!IsConsoleCommandSender ? "<color=white>" : "")}[{(!IsConsoleCommandSender ? $"<color={color}>" : "")}==Exiled Events=={(!IsConsoleCommandSender ? "<color=white>" : "")}]");
break;
}

foreach (Event ev in eventlist.Value)
{


if (ev is IHidden) continue;
if (!IsConsoleCommandSender)
builder.AppendLine(
$"<color={color}>{ev.Name}</color> [<color=yellow>{ev.CommandName}</color>]: <color=white>{ev.Description}</color>");
Expand All @@ -103,6 +103,5 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
response = builder.ToString();
return true;
}

}
}
66 changes: 66 additions & 0 deletions AutoEvent/Commands/Lobby.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using AutoEvent.Interfaces;
using CommandSystem;
using System;
using System.Linq;
using AutoEvent.API;
using MEC;
using PluginAPI.Core;
using Utils.NonAllocLINQ;
using PlayerRoles;
#if EXILED
using Exiled.Permissions.Extensions;
#endif

namespace AutoEvent.Commands
{
internal class Lobby// : ICommand, IPermission
{
public string Command => nameof(Lobby);
public string Description => "Starting a lobby in which the winner chooses a mini-game";
public string[] Aliases => new string[] { };
public string Permission { get; set; } = "ev.lobby";

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
if (!sender.CheckPermission(((IPermission)this).Permission, out bool IsConsoleCommandSender))
{
response = "<color=red>You do not have permission to use this command!</color>";
return false;
}
if (AutoEvent.ActiveEvent != null)
{
response = $"The mini-game {AutoEvent.ActiveEvent.Name} is already running!";
return false;
}

Event lobby = Event.GetEvent("Lobby");
if (lobby == null)
{
response = $"The lobby is not found.";
return false;
}

Round.IsLocked = true;

if (!Round.IsRoundStarted)
{
Round.Start();

Timing.CallDelayed(2f, () => {

lobby.StartEvent();
AutoEvent.ActiveEvent = lobby;
});
}
else
{
lobby.StartEvent();
AutoEvent.ActiveEvent = lobby;
}

response = $"The lobby event has started!";
return true;
}

}
}
2 changes: 2 additions & 0 deletions AutoEvent/Commands/MainCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public override void LoadGeneratedCommands()
RegisterCommand(new List());
RegisterCommand(new Run());
RegisterCommand(new Stop());
RegisterCommand(new Lobby());
RegisterCommand(new Vote());
RegisterCommand(new Volume());
RegisterCommand(new Reload.Reload());
RegisterCommand(new Debug.Debug());
Expand Down
2 changes: 1 addition & 1 deletion AutoEvent/Commands/Reload/Reload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ protected override bool ExecuteParent(ArraySegment<string> arguments, ICommandSe

public override string Command => nameof(Reload);
public override string[] Aliases => Array.Empty<string>();
public override string Description => "Reloads different aspects of the plugin and events.";
public override string Description => "Reloads different aspects of the plugin and events";
}
7 changes: 4 additions & 3 deletions AutoEvent/Commands/Run.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ namespace AutoEvent.Commands
internal class Run : ICommand, IUsageProvider, IPermission
{
public string Command => nameof(Run);
public string Description => "Run the event, takes on 1 argument - the command name of the event.";
public string Description => "Run the event, takes on 1 argument - the command name of the event";
public string[] Aliases => new []{ "start", "play", "begin" };
public string[] Usage => new string[] { "[Event Name]" };
public string[] Usage => new string[] { "Event Name" };
public string Permission { get; set; } = "ev.run";

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
Expand All @@ -40,11 +40,12 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
}

Event ev = Event.GetEvent(arguments.At(0));
if (ev == null)
if (ev == null || ev is IHidden)
{
response = $"The mini-game {arguments.At(0)} is not found.";
return false;
}

string conf = "";
EventConfig? config = null;
if (arguments.Count >= 2)
Expand Down
2 changes: 1 addition & 1 deletion AutoEvent/Commands/Volume.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace AutoEvent.Commands;
public class Volume : ICommand, IUsageProvider, IPermission
{
public string Command => nameof(Volume);
public string Description => "Set the global music volume, takes on 1 argument - the volume from 0% - 200%.";
public string Description => "Set the global music volume, takes on 1 argument - the volume from 0%-200%";
public string[] Aliases => new string[] { };
public string[] Usage => new string[] { "Volume %" };
public string Permission { get; set; } = "ev.volume";
Expand Down
88 changes: 88 additions & 0 deletions AutoEvent/Commands/Vote.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using AutoEvent.Interfaces;
using CommandSystem;
using System;
using System.Linq;
using AutoEvent.API;
using MEC;
using PluginAPI.Core;
using PlayerRoles;
#if EXILED
using Exiled.Permissions.Extensions;
#endif

namespace AutoEvent.Commands
{
internal class Vote// : ICommand, IUsageProvider, IPermission
{
public string Command => nameof(Vote);
public string Description => "Starts voting for mini-game, 1 argument - the command name of the event";
public string[] Aliases => new string[] { };
public string[] Usage => new string[] { "Event Name" };
public string Permission { get; set; } = "ev.vote";

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
if (!sender.CheckPermission(((IPermission)this).Permission, out bool IsConsoleCommandSender))
{
response = "<color=red>You do not have permission to use this command!</color>";
return false;
}
if (AutoEvent.ActiveEvent != null)
{
response = $"The mini-game {AutoEvent.ActiveEvent.Name} is already running!";
return false;
}

if (arguments.Count < 1)
{
response = "Only 1 argument is needed - the command name of the event!";
return false;
}

Event ev = Event.GetEvent(arguments.At(0));
if (ev == null || ev is IHidden)
{
response = $"The mini-game {arguments.At(0)} is not found.";
return false;
}

Event vote = Event.GetEvent("Vote");
if (vote == null)
{
response = $"The vote is not found.";
return false;
}

IVote comp = vote as IVote;
if (comp == null)
{
response = $"The IVote is not found.";
return false;
}

comp.NewEvent = ev;
Round.IsLocked = true;

if (!Round.IsRoundStarted)
{
Round.Start();

Timing.CallDelayed(2f, () => {

Extensions.TeleportEnd();
vote.StartEvent();
AutoEvent.ActiveEvent = vote;
});
}
else
{
vote.StartEvent();
AutoEvent.ActiveEvent = vote;
}

response = $"The vote {ev.Name} has started!";
return true;
}

}
}
32 changes: 20 additions & 12 deletions AutoEvent/Games/Lobby/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
using System.Linq;
using Event = AutoEvent.Interfaces.Event;
using Player = PluginAPI.Core.Player;
using PluginAPI.Core;
using MEC;

namespace AutoEvent.Games.Lobby
{
public class Plugin : Event, IEventMap, IEventSound, IInternalEvent
public class Plugin : Event, IEventMap, IEventSound, IHidden, IVote
{
public override string Name { get; set; } = "Lobby";
public override string Description { get; set; } = "A lobby in which one quick player chooses a mini-game.";
Expand All @@ -24,7 +26,9 @@ public class Plugin : Event, IEventMap, IEventSound, IInternalEvent
Player _chooser { get; set; }
List<GameObject> _spawnpoints { get; set; }
List<GameObject> _teleports { get; set; }
List<GameObject> _platformes { get; set; }
Dictionary<GameObject, string> _platformes { get; set; }
public List<string> _eventList { get; set; }
public Event NewEvent { get; set; }

protected override void RegisterEvents()
{
Expand Down Expand Up @@ -64,7 +68,7 @@ protected void InitGameObjects()
{
case "Spawnpoint": _spawnpoints.Add(obj); break;
case "Teleport": _teleports.Add(obj); break;
case "Platform": _platformes.Add(obj); break;
case "Platform": _platformes.Add(obj, obj.transform.parent.name); break;
}
}
catch (Exception e)
Expand All @@ -77,7 +81,7 @@ protected void InitGameObjects()

protected override bool IsRoundDone()
{
DebugLogger.LogDebug($"Lobby state is {_state}");
DebugLogger.LogDebug($"Lobby state is {_state} and {(NewEvent is null ? "null" : NewEvent.Name)}");

if (_state == LobbyState.Waiting)
return false;
Expand All @@ -94,9 +98,8 @@ protected override bool IsRoundDone()
protected override void ProcessFrame()
{
string message = "Get ready to run to the center and choose a mini game";
string time = $"{(16 - EventTime.Seconds):00}";

if (_state == LobbyState.Waiting && EventTime.TotalSeconds >= 15)
if (_state == LobbyState.Waiting && EventTime.TotalSeconds >= 5)
{
GameObject.Destroy(MapInfo.Map.AttachedBlocks.First(r => r.name == "Wall").gameObject);
EventTime = new();
Expand All @@ -106,7 +109,7 @@ protected override void ProcessFrame()
if (_state == LobbyState.Running)
{
message = "RUN";
if (EventTime.TotalSeconds <= 15)
if (EventTime.TotalSeconds <= 10)
{
foreach (Player player in Player.GetPlayers())
{
Expand Down Expand Up @@ -135,31 +138,36 @@ protected override void ProcessFrame()
{
foreach (var platform in _platformes)
{
if (Vector3.Distance(platform.transform.position, _chooser.Position) < 2)
if (Vector3.Distance(platform.Key.transform.position, _chooser.Position) < 2)
{
// ev run mg
NewEvent = Event.GetEvent(platform.Value);
_state = LobbyState.Ending;
}
}
}
else
{
// Random mg
NewEvent = Event.GetEvent(_platformes.ToList().RandomItem().Value);
_state = LobbyState.Ending;
}
}

Extensions.Broadcast($"Lobby\n" +
$"{message}\n" +
$"players = {Player.GetPlayers().Count()} | {time} seconds left!", 1);
$"{Player.GetPlayers().Count()} players in the lobby", 1);
}

protected override void OnFinished()
{
DebugLogger.LogDebug($"Lobby is finished");
Extensions.Broadcast($"The lobby is finished.\n" +
$"The player {_chooser.Nickname} chose the %name% mini-game.\n" +
$"The player {_chooser.Nickname} chose the {NewEvent.Name} mini-game.\n" +
$"Total {Player.GetPlayers().Count()} players in the lobby", 10);

Timing.CallDelayed(10.1f, () =>
{
Server.RunCommand($"ev run {NewEvent.CommandName}");
});
}
}
}
Expand Down
Loading