This repository has been archived by the owner on Feb 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added command handler until I actually fix the bug
- Loading branch information
1 parent
9b8b993
commit efc37cc
Showing
8 changed files
with
99 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using CommandSystem; | ||
using Exiled.Events.EventArgs; | ||
using RemoteAdmin; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Buddy | ||
{ | ||
class CommandHandler | ||
{ | ||
private static Dictionary<string, ICommandPint> commands = new Dictionary<string, ICommandPint>(); | ||
|
||
public static bool isEnabled = false; | ||
|
||
public static void Register(ICommandPint cmd) | ||
{ | ||
string commandStr = cmd.Command; | ||
commands.Add(commandStr, cmd); | ||
} | ||
|
||
public static void RunCommand(SendingConsoleCommandEventArgs ev) | ||
{ | ||
if (!isEnabled) return; | ||
ICommandPint cmd = null; | ||
if (!commands.TryGetValue(ev.Name, out cmd) || cmd == null) return; | ||
string outText = ev.ReturnMessage; | ||
cmd.Execute(new ArraySegment<string>(ev.Arguments.ToArray()), ev.Player, out outText); | ||
ev.ReturnMessage = outText; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Exiled.API.Features; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Buddy | ||
{ | ||
interface ICommandPint | ||
{ | ||
string Command { get; } | ||
|
||
string[] Aliases { get; } | ||
|
||
string Description { get; } | ||
|
||
bool Execute(ArraySegment<string> arguments, Player sender, out string response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters