@@ -27,10 +27,11 @@ namespace Exiled.Events.Patches.Events.Player
27
27
28
28
/// <summary>
29
29
/// Patches <see cref="DisarmingHandlers.ServerProcessDisarmMessage" />.
30
- /// Adds the <see cref="Handlers.Player.Handcuffing" /> and <see cref="Handlers.Player.RemovingHandcuffs " /> events.
30
+ /// Adds the <see cref="Handlers.Player.Handcuffing" />, <see cref="Handlers.Player.RemovingHandcuffs" />, and <see cref="Handlers.Player.RemovedHandcuffs " /> events.
31
31
/// </summary>
32
32
[ EventPatch ( typeof ( Handlers . Player ) , nameof ( Handlers . Player . Handcuffing ) ) ]
33
33
[ EventPatch ( typeof ( Handlers . Player ) , nameof ( Handlers . Player . RemovingHandcuffs ) ) ]
34
+ [ EventPatch ( typeof ( Handlers . Player ) , nameof ( Handlers . Player . RemovedHandcuffs ) ) ]
34
35
[ HarmonyPatch ( typeof ( DisarmingHandlers ) , nameof ( DisarmingHandlers . ServerProcessDisarmMessage ) ) ]
35
36
internal static class ProcessDisarmMessage
36
37
{
@@ -47,6 +48,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
47
48
index ,
48
49
new [ ]
49
50
{
51
+ // Invoking RemovingHandcuffs event
50
52
// Player.Get(referenceHub)
51
53
new CodeInstruction ( OpCodes . Ldloc_0 ) ,
52
54
new ( OpCodes . Call , Method ( typeof ( Player ) , nameof ( Player . Get ) , new [ ] { typeof ( ReferenceHub ) } ) ) ,
@@ -73,6 +75,25 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
73
75
// return;
74
76
new ( OpCodes . Callvirt , PropertyGetter ( typeof ( RemovingHandcuffsEventArgs ) , nameof ( RemovingHandcuffsEventArgs . IsAllowed ) ) ) ,
75
77
new ( OpCodes . Brfalse_S , returnLabel ) ,
78
+
79
+ // Invoking RemovedHandcuffs event
80
+ // Player.Get(referenceHub)
81
+ new ( OpCodes . Ldloc_0 ) ,
82
+ new ( OpCodes . Call , Method ( typeof ( Player ) , nameof ( Player . Get ) , new [ ] { typeof ( ReferenceHub ) } ) ) ,
83
+
84
+ // Player.Get(msg.PlayerToDisarm)
85
+ new ( OpCodes . Ldarg_1 ) ,
86
+ new ( OpCodes . Ldfld , Field ( typeof ( DisarmMessage ) , nameof ( DisarmMessage . PlayerToDisarm ) ) ) ,
87
+ new ( OpCodes . Call , Method ( typeof ( Player ) , nameof ( Player . Get ) , new [ ] { typeof ( ReferenceHub ) } ) ) ,
88
+
89
+ // UncuffReason.Player
90
+ new ( OpCodes . Ldc_I4_0 ) ,
91
+
92
+ // RemovedHandcuffsEventArgs ev = new(Player, Player, UncuffReason.Player)
93
+ new ( OpCodes . Newobj , GetDeclaredConstructors ( typeof ( RemovedHandcuffsEventArgs ) ) [ 0 ] ) ,
94
+
95
+ // Handlers.Player.OnRemovedHandcuffs(ev)
96
+ new ( OpCodes . Call , Method ( typeof ( Handlers . Player ) , nameof ( Handlers . Player . OnRemovedHandcuffs ) ) ) ,
76
97
} ) ;
77
98
78
99
offset = - 3 ;
@@ -83,6 +104,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
83
104
index ,
84
105
new [ ]
85
106
{
107
+ // Invoking Handcuffing event
86
108
// Player.Get(referenceHub)
87
109
new CodeInstruction ( OpCodes . Ldloc_0 ) . MoveLabelsFrom ( newInstructions [ index ] ) ,
88
110
new ( OpCodes . Call , Method ( typeof ( Player ) , nameof ( Player . Get ) , new [ ] { typeof ( ReferenceHub ) } ) ) ,
@@ -119,9 +141,10 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
119
141
120
142
/// <summary>
121
143
/// Patches <see cref="DisarmedPlayers.ValidateEntry(DisarmedPlayers.DisarmedEntry)" />.
122
- /// Invokes <see cref="Handlers.Player.RemovingHandcuffs" /> event.
144
+ /// Invokes <see cref="Handlers.Player.RemovingHandcuffs" /> and <see cref="Handlers.Player.RemovedHandcuffs" /> event.
123
145
/// </summary>
124
146
[ EventPatch ( typeof ( Handlers . Player ) , nameof ( Handlers . Player . RemovingHandcuffs ) ) ]
147
+ [ EventPatch ( typeof ( Handlers . Player ) , nameof ( Handlers . Player . RemovedHandcuffs ) ) ]
125
148
[ HarmonyPatch ( typeof ( DisarmedPlayers ) , nameof ( DisarmedPlayers . ValidateEntry ) ) ]
126
149
internal static class Uncuff
127
150
{
@@ -138,6 +161,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
138
161
index ,
139
162
new [ ]
140
163
{
164
+ // Invoking RemovingHandcuffs event
141
165
// Player.Get(Cuffer)
142
166
new CodeInstruction ( OpCodes . Ldloc_1 ) ,
143
167
new ( OpCodes . Call , Method ( typeof ( Player ) , nameof ( Player . Get ) , new [ ] { typeof ( ReferenceHub ) } ) ) ,
@@ -154,15 +178,36 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
154
178
155
179
// RemovingHandcuffsEventArgs ev = new(Cuffer, Target, UncuffReason.CufferDied, true)
156
180
new ( OpCodes . Newobj , GetDeclaredConstructors ( typeof ( RemovingHandcuffsEventArgs ) ) [ 0 ] ) ,
157
- new ( OpCodes . Dup ) ,
181
+
182
+ // TODO: Uncomment this part in next major update to prevent breaking changes
183
+ // new(OpCodes.Dup),
158
184
159
185
// Handlers.Player.OnRemovingHandcuffs(ev)
160
186
new ( OpCodes . Call , Method ( typeof ( Handlers . Player ) , nameof ( Handlers . Player . OnRemovingHandcuffs ) ) ) ,
161
187
188
+ // TODO: Uncomment this part in next major update to prevent breaking changes
162
189
// if (!ev.IsAllowed)
163
190
// return true;
164
- new ( OpCodes . Callvirt , PropertyGetter ( typeof ( RemovingHandcuffsEventArgs ) , nameof ( RemovingHandcuffsEventArgs . IsAllowed ) ) ) ,
165
- new ( OpCodes . Brfalse_S , returnLabel ) ,
191
+ // new(OpCodes.Callvirt, PropertyGetter(typeof(RemovingHandcuffsEventArgs), nameof(RemovingHandcuffsEventArgs.IsAllowed))),
192
+ // new(OpCodes.Brfalse_S, returnLabel),
193
+
194
+ // Invoking RemovedHandcuffs event
195
+ // Player.Get(Cuffer)
196
+ new CodeInstruction ( OpCodes . Ldloc_1 ) ,
197
+ new ( OpCodes . Call , Method ( typeof ( Player ) , nameof ( Player . Get ) , new [ ] { typeof ( ReferenceHub ) } ) ) ,
198
+
199
+ // Player.Get(Target)
200
+ new ( OpCodes . Ldloc_0 ) ,
201
+ new ( OpCodes . Call , Method ( typeof ( Player ) , nameof ( Player . Get ) , new [ ] { typeof ( ReferenceHub ) } ) ) ,
202
+
203
+ // UncuffReason.CufferDied
204
+ new ( OpCodes . Ldc_I4_2 ) ,
205
+
206
+ // RemovedHandcuffsEventArgs ev = new(Cuffer, Target, UncuffReason.CufferDied)
207
+ new ( OpCodes . Newobj , GetDeclaredConstructors ( typeof ( RemovedHandcuffsEventArgs ) ) [ 0 ] ) ,
208
+
209
+ // Handlers.Player.OnRemovedHandcuffs(ev)
210
+ new ( OpCodes . Call , Method ( typeof ( Handlers . Player ) , nameof ( Handlers . Player . OnRemovedHandcuffs ) ) ) ,
166
211
} ) ;
167
212
168
213
offset = 5 ;
@@ -173,6 +218,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
173
218
index ,
174
219
new [ ]
175
220
{
221
+ // Invoking RemovingHandcuffs event
176
222
// Player.Get(Cuffer)
177
223
new CodeInstruction ( OpCodes . Ldloc_1 ) ,
178
224
new ( OpCodes . Call , Method ( typeof ( Player ) , nameof ( Player . Get ) , new [ ] { typeof ( ReferenceHub ) } ) ) ,
@@ -189,15 +235,36 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
189
235
190
236
// RemovingHandcuffsEventArgs ev = new(Cuffer, Target, UncuffReason.CufferDied, true)
191
237
new ( OpCodes . Newobj , GetDeclaredConstructors ( typeof ( RemovingHandcuffsEventArgs ) ) [ 0 ] ) ,
192
- new ( OpCodes . Dup ) ,
238
+
239
+ // TODO: Uncomment this part in next major update to prevent breaking changes
240
+ // new(OpCodes.Dup),
193
241
194
242
// Handlers.Player.OnRemovingHandcuffs(ev)
195
243
new ( OpCodes . Call , Method ( typeof ( Handlers . Player ) , nameof ( Handlers . Player . OnRemovingHandcuffs ) ) ) ,
196
244
245
+ // TODO: Uncomment this part in next major update to prevent breaking changes
197
246
// if (!ev.IsAllowed)
198
247
// return true;
199
- new ( OpCodes . Callvirt , PropertyGetter ( typeof ( RemovingHandcuffsEventArgs ) , nameof ( RemovingHandcuffsEventArgs . IsAllowed ) ) ) ,
200
- new ( OpCodes . Brfalse_S , returnLabel ) ,
248
+ // new(OpCodes.Callvirt, PropertyGetter(typeof(RemovingHandcuffsEventArgs), nameof(RemovingHandcuffsEventArgs.IsAllowed))),
249
+ // new(OpCodes.Brfalse_S, returnLabel),
250
+
251
+ // Invoking RemovedHandcuffs event
252
+ // Player.Get(Cuffer)
253
+ new CodeInstruction ( OpCodes . Ldloc_1 ) ,
254
+ new ( OpCodes . Call , Method ( typeof ( Player ) , nameof ( Player . Get ) , new [ ] { typeof ( ReferenceHub ) } ) ) ,
255
+
256
+ // Player.Get(Target)
257
+ new ( OpCodes . Ldloc_0 ) ,
258
+ new ( OpCodes . Call , Method ( typeof ( Player ) , nameof ( Player . Get ) , new [ ] { typeof ( ReferenceHub ) } ) ) ,
259
+
260
+ // UncuffReason.CufferDied
261
+ new ( OpCodes . Ldc_I4_2 ) ,
262
+
263
+ // RemovedHandcuffsEventArgs ev = new(Cuffer, Target, UncuffReason.CufferDied)
264
+ new ( OpCodes . Newobj , GetDeclaredConstructors ( typeof ( RemovedHandcuffsEventArgs ) ) [ 0 ] ) ,
265
+
266
+ // Handlers.Player.OnRemovedHandcuffs(ev)
267
+ new ( OpCodes . Call , Method ( typeof ( Handlers . Player ) , nameof ( Handlers . Player . OnRemovedHandcuffs ) ) ) ,
201
268
} ) ;
202
269
203
270
offset = 3 ;
@@ -208,6 +275,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
208
275
index ,
209
276
new [ ]
210
277
{
278
+ // Invoking RemovingHandcuffs event
211
279
// Player.Get(Cuffer)
212
280
new CodeInstruction ( OpCodes . Ldloc_1 ) ,
213
281
new ( OpCodes . Call , Method ( typeof ( Player ) , nameof ( Player . Get ) , new [ ] { typeof ( ReferenceHub ) } ) ) ,
@@ -224,15 +292,36 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
224
292
225
293
// RemovingHandcuffsEventArgs ev = new(Cuffer, Target, UncuffReason.OutOfRange, true)
226
294
new ( OpCodes . Newobj , GetDeclaredConstructors ( typeof ( RemovingHandcuffsEventArgs ) ) [ 0 ] ) ,
227
- new ( OpCodes . Dup ) ,
295
+
296
+ // TODO: Uncomment this part in next major update to prevent breaking changes
297
+ // new(OpCodes.Dup),
228
298
229
299
// Handlers.Player.OnRemovingHandcuffs(ev)
230
300
new ( OpCodes . Call , Method ( typeof ( Handlers . Player ) , nameof ( Handlers . Player . OnRemovingHandcuffs ) ) ) ,
231
301
302
+ // TODO: Uncomment this part in next major update to prevent breaking changes
232
303
// if (!ev.IsAllowed)
233
304
// return true;
234
- new ( OpCodes . Callvirt , PropertyGetter ( typeof ( RemovingHandcuffsEventArgs ) , nameof ( RemovingHandcuffsEventArgs . IsAllowed ) ) ) ,
235
- new ( OpCodes . Brfalse_S , returnLabel ) ,
305
+ // new(OpCodes.Callvirt, PropertyGetter(typeof(RemovingHandcuffsEventArgs), nameof(RemovingHandcuffsEventArgs.IsAllowed))),
306
+ // new(OpCodes.Brfalse_S, returnLabel),
307
+
308
+ // Invoking RemovedHandcuffs event
309
+ // Player.Get(Cuffer)
310
+ new CodeInstruction ( OpCodes . Ldloc_1 ) ,
311
+ new ( OpCodes . Call , Method ( typeof ( Player ) , nameof ( Player . Get ) , new [ ] { typeof ( ReferenceHub ) } ) ) ,
312
+
313
+ // Player.Get(Target)
314
+ new ( OpCodes . Ldloc_0 ) ,
315
+ new ( OpCodes . Call , Method ( typeof ( Player ) , nameof ( Player . Get ) , new [ ] { typeof ( ReferenceHub ) } ) ) ,
316
+
317
+ // UncuffReason.CufferDied
318
+ new ( OpCodes . Ldc_I4_2 ) ,
319
+
320
+ // RemovedHandcuffsEventArgs ev = new(Cuffer, Target, UncuffReason.OutOfRange)
321
+ new ( OpCodes . Newobj , GetDeclaredConstructors ( typeof ( RemovedHandcuffsEventArgs ) ) [ 0 ] ) ,
322
+
323
+ // Handlers.Player.OnRemovedHandcuffs(ev)
324
+ new ( OpCodes . Call , Method ( typeof ( Handlers . Player ) , nameof ( Handlers . Player . OnRemovedHandcuffs ) ) ) ,
236
325
} ) ;
237
326
238
327
newInstructions [ newInstructions . Count - 2 ] . labels . Add ( returnLabel ) ;
0 commit comments