Skip to content

Commit a15d85a

Browse files
committed
fix: sentvalidcommand event
1 parent 5a599ff commit a15d85a

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

EXILED/Exiled.Events/Patches/Events/Player/SendingValidGameConsoleCommand.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,22 +130,17 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
130130
});
131131

132132
offset = 1;
133-
index = newInstructions.FindIndex(instrction => instrction.Calls(Method(typeof(GameConsoleTransmission), nameof(GameConsoleTransmission.SendToClient)))) + offset;
133+
index = newInstructions.FindLastIndex(i => i.Calls(Method(typeof(GameConsoleTransmission), nameof(GameConsoleTransmission.SendToClient)))) + offset;
134134
newInstructions.InsertRange(
135135
index,
136136
new CodeInstruction[]
137137
{
138-
// this
139-
new(OpCodes.Ldarg_0),
140-
141-
// this._hub
142-
new(OpCodes.Ldfld, Field(typeof(QueryProcessor), nameof(QueryProcessor._hub))),
143-
144-
// Player.Get(Hub)
145-
new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new Type[] { typeof(ReferenceHub) })),
138+
// Player.Get(sender)
139+
new(OpCodes.Ldloc_0),
140+
new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(CommandSender) })),
146141

147142
// command
148-
new(OpCodes.Ldloc_1),
143+
new(OpCodes.Ldloc_S, 4),
149144

150145
// CommandType.Client
151146
new (OpCodes.Ldc_I4_S, (sbyte)CommandType.Client),

EXILED/Exiled.Events/Patches/Events/Player/SendingValidRACommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,16 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
128128
});
129129

130130
offset = 1;
131-
index = newInstructions.FindIndex(instrction => instrction.Calls(Method(typeof(CommandSender), nameof(CommandSender.RaReply)))) + offset;
131+
index = newInstructions.FindIndex(i => i.Calls(Method(typeof(CommandSender), nameof(CommandSender.RaReply)))) + offset;
132132
newInstructions.InsertRange(
133133
index,
134-
new CodeInstruction[]
134+
new[]
135135
{
136136
// sender
137-
new (OpCodes.Ldarg_1),
137+
new CodeInstruction(OpCodes.Ldarg_1).MoveLabelsFrom(newInstructions[index]),
138138

139139
// Player.get(sender)
140-
new (OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new Type[] { typeof(CommandSender) })),
140+
new (OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(CommandSender) })),
141141

142142
// command
143143
new (OpCodes.Ldloc_2),

0 commit comments

Comments
 (0)