Skip to content

Commit 545ca3f

Browse files
committed
refactor(GM): Convertions to generics
1 parent 823899b commit 545ca3f

2 files changed

Lines changed: 176 additions & 188 deletions

File tree

Commands/Commands_Main.lua

Lines changed: 146 additions & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
[GENERICS_message] = "messageID"
2626
}
2727
]]
28-
2928
GM_genericCommands = {
30-
[GENERICS_parametersGet] = function() return ma_gmParametersInput:GetText() end,
29+
[GENERICS_parametersGet] = function()
30+
return ma_gmParametersInput:GetText()
31+
end,
3132
[GM_displayAccountGMLevel] = {
3233
[GENERICS_command] = ".account",
3334
[GENERICS_message] = "ma_displayleveloutput"
@@ -57,52 +58,155 @@ GM_genericCommands = {
5758
[GENERICS_isTargetCheckNeeded] = true,
5859
[GENERICS_command] = ".cheat taxi ",
5960
[GENERICS_message] = "ma_TaxiOnoutput"
61+
},
62+
[GM_cheatExploreMaps] = {
63+
[GENERICS_isValueNeeded] = true,
64+
[GENERICS_isTargetCheckNeeded] = true,
65+
[GENERICS_command] = ".cheat explore ",
66+
[GENERICS_message] = "ma_mapsoutput"
67+
},
68+
[GM_cheatWaterWalk] = {
69+
[GENERICS_isValueNeeded] = true,
70+
[GENERICS_isTargetCheckNeeded] = true,
71+
[GENERICS_command] = ".cheat waterwalk ",
72+
[GENERICS_message] = "ma_waterwalkoutput"
73+
},
74+
[GM_cheatNoCastTime] = {
75+
[GENERICS_isValueNeeded] = true,
76+
[GENERICS_command] = ".cheat casttime ",
77+
[GENERICS_message] = "ma_NoCastTimeOnoutput"
78+
},
79+
[GM_cheatNoCooldown] = {
80+
[GENERICS_isValueNeeded] = true,
81+
[GENERICS_command] = ".cheat cooldown ",
82+
[GENERICS_message] = "ma_NoCooldownOnoutput"
83+
},
84+
[GM_accountIPLock] = {
85+
[GENERICS_isValueNeeded] = true,
86+
[GENERICS_command] = ".account lock ip ",
87+
[GENERICS_message] = "ma_accountlockipoutput"
88+
},
89+
[GM_GMList] = {
90+
[GENERICS_command] = ".gm list",
91+
[GENERICS_message] = "ma_gmListoutput"
92+
},
93+
[GM_GMInGame] = {
94+
[GENERICS_command] = ".gm ingame",
95+
[GENERICS_message] = "ma_gmInGameoutput"
96+
},
97+
[GM_GMNotify] = {
98+
[GENERICS_isParametersNeeded] = true,
99+
[GENERICS_command] = ".gmnotify ",
100+
[GENERICS_message] = "ma_gmNotifyOutput"
101+
},
102+
[GM_GMMessage] = {
103+
[GENERICS_isParametersNeeded] = true,
104+
[GENERICS_command] = ".gmnameannounce ",
105+
[GENERICS_message] = "ma_gmMessageOutput"
106+
},
107+
[GM_Cast] = {
108+
[GENERICS_isParametersNeeded] = true,
109+
[GENERICS_command] = ".cast ",
110+
[GENERICS_message] = "ma_gmCastSpellOutput"
111+
},
112+
[GM_CastBack] = {
113+
[GENERICS_isParametersNeeded] = true,
114+
[GENERICS_command] = ".cast back ",
115+
[GENERICS_message] = "ma_gmCastBackSpellOutput"
116+
},
117+
[GM_CastDist] = {
118+
[GENERICS_isParametersNeeded] = true,
119+
[GENERICS_command] = ".cast dist ",
120+
[GENERICS_message] = "ma_gmCastDistSpellOutput"
121+
},
122+
[GM_CastSelf] = {
123+
[GENERICS_isParametersNeeded] = true,
124+
[GENERICS_command] = ".cast self ",
125+
[GENERICS_message] = "ma_gmCastSelfSpellOutput"
126+
},
127+
[GM_CastTarget] = {
128+
[GENERICS_isParametersNeeded] = true,
129+
[GENERICS_command] = ".cast target ",
130+
[GENERICS_message] = "ma_gmCastTargetSpellOutput"
131+
},
132+
[GM_TeleportAdd] = {
133+
[GENERICS_isParametersNeeded] = true,
134+
[GENERICS_command] = ".tele add ",
135+
[GENERICS_message] = "ma_gmTeleAddOutput"
136+
},
137+
[GM_TeleportDel] = {
138+
[GENERICS_isParametersNeeded] = true,
139+
[GENERICS_command] = ".tele del ",
140+
[GENERICS_message] = "ma_gmTeleDelOutput"
141+
},
142+
[GM_ListItem] = {
143+
[GENERICS_isParametersNeeded] = true,
144+
[GENERICS_command] = ".list item ",
145+
[GENERICS_message] = "ma_gmListItemOutput"
146+
},
147+
[GM_LookupTaxi] = {
148+
[GENERICS_isParametersNeeded] = true,
149+
[GENERICS_command] = ".lookup taxi ",
150+
[GENERICS_message] = "ma_gmLookTaxiOutput"
151+
},
152+
[GM_LookupZone] = {
153+
[GENERICS_isParametersNeeded] = true,
154+
[GENERICS_command] = ".lookup area ",
155+
[GENERICS_message] = "ma_gmLookZoneOutput"
156+
},
157+
[GM_GoTaxiNode] = {
158+
[GENERICS_isParametersNeeded] = true,
159+
[GENERICS_command] = ".go taxinode ",
160+
[GENERICS_message] = "ma_gmGoTaxiOutput"
161+
},
162+
[GM_GoTrigger] = {
163+
[GENERICS_isParametersNeeded] = true,
164+
[GENERICS_command] = ".go trigger ",
165+
[GENERICS_message] = "ma_gmGoTriggerOutput"
166+
},
167+
[GM_GoXY] = {
168+
[GENERICS_isParametersNeeded] = true,
169+
[GENERICS_command] = ".go xy ",
170+
[GENERICS_message] = "ma_gmGoXYOutput"
171+
},
172+
[GM_GoXYZ] = {
173+
[GENERICS_isParametersNeeded] = true,
174+
[GENERICS_command] = ".go xyz ",
175+
[GENERICS_message] = "ma_gmGoXYZOutput"
176+
},
177+
[GM_GoZoneXY] = {
178+
[GENERICS_isParametersNeeded] = true,
179+
[GENERICS_command] = ".go zonexy ",
180+
[GENERICS_message] = "ma_gmZoneXYOutput"
181+
},
182+
[GM_PetCreate] = {
183+
[GENERICS_command] = ".pet create",
184+
[GENERICS_message] = "ma_gmPetCreateOutput"
185+
},
186+
[GM_PetLearn] = {
187+
[GENERICS_isParametersNeeded] = true,
188+
[GENERICS_command] = ".pet learn ",
189+
[GENERICS_message] = "ma_gmPetLearnOutput"
190+
},
191+
[GM_PetUnLearn] = {
192+
[GENERICS_isParametersNeeded] = true,
193+
[GENERICS_command] = ".pet unlearn ",
194+
[GENERICS_message] = "ma_gmPetUnlearnOutput"
195+
},
196+
[GM_PetTalentsLearn] = {
197+
[GENERICS_command] = ".learn all my pettalents",
198+
[GENERICS_message] = "ma_gmPetTalentsOutput"
199+
},
200+
[GM_DismountPlayer] = {
201+
[GENERICS_command] = ".dismount",
202+
[GENERICS_message] = "ma_gmDismountOutput"
60203
}
61204
}
62205

63206
function ToggleGMMode(value)
64207
MangAdmin:ChatMsg(".gm " .. value)
65208
MangAdmin:ChatMsg(".gm chat " .. value)
66-
MangAdmin:LogAction(genericLogGenerator("ma_GMOnoutput",value))
67-
end
68-
69-
function ToggleMaps(value)
70-
if commandTargetCheck() then
71-
MangAdmin:ChatMsg(".cheat explore " .. value)
72-
MangAdmin:LogAction(
73-
(value == 1 and Locale["genericEnabledText"] or Locale["genericDisabledText"]) ..
74-
Locale["ma_mapsoutput"] .. getCommandTargetName()
75-
)
76-
else
77-
MangAdmin:Print(Locale["selectionError"])
78-
end
79-
end
80-
81-
function ToggleWaterwalk(value)
82-
if commandTargetCheck() then
83-
MangAdmin:ChatMsg(".cheat waterwalk " .. value)
84-
MangAdmin:LogAction(
85-
(value == "on" and Locale["genericEnabledText"] or Locale["genericDisabledText"]) ..
86-
Locale["ma_waterwalkoutput"] .. getCommandTargetName()
87-
)
88-
else
89-
MangAdmin:Print(Locale["selectionError"])
90-
end
91-
end
92-
93-
function ToggleNoCastTime(value)
94-
MangAdmin:ChatMsg(".cheat casttime " .. value)
95-
MangAdmin:LogAction(Locale["ma_NoCastTimeOnoutput"] .. value)
96-
end
97-
98-
function ToggleNoCooldown(value)
99-
MangAdmin:ChatMsg(".cheat cooldown " .. value)
100-
MangAdmin:LogAction(Locale["ma_NoCooldownOnoutput"] .. value)
101-
end
102-
103-
function ToggleAccountlockIP(value)
104-
MangAdmin:ChatMsg(".account lock ip " .. value)
105-
MangAdmin:LogAction(Locale["ma_accountlockipoutput"] .. value)
209+
MangAdmin:LogAction(genericLogGenerator("ma_GMOnoutput", value))
106210
end
107211

108212
function AcctCreate()
@@ -242,118 +346,6 @@ function AcctAddon()
242346
print(Locale["operationCompleted"])
243347
end
244348

245-
function GMList()
246-
MangAdmin:ChatMsg(".gm list")
247-
MangAdmin:LogAction(Locale["ma_gmListoutput"])
248-
end
249-
250-
function GMInGame()
251-
MangAdmin:ChatMsg(".gm ingame")
252-
MangAdmin:LogAction(Locale["ma_gmInGameoutput"])
253-
end
254-
255-
function GMNotify()
256-
local param = ma_gmParametersInput:GetText()
257-
MangAdmin:ChatMsg(".gmnotify " .. param)
258-
MangAdmin:LogAction(Locale["ma_gmNotifyOutput"] .. param)
259-
end
260-
261-
function GMMessage()
262-
local param = ma_gmParametersInput:GetText()
263-
MangAdmin:ChatMsg(".gmnameannounce " .. param)
264-
MangAdmin:LogAction(Locale["ma_gmMessageOutput"] .. param)
265-
end
266-
267-
function Cast()
268-
local param = ma_gmParametersInput:GetText()
269-
MangAdmin:ChatMsg(".cast " .. param)
270-
MangAdmin:LogAction(Locale["ma_gmCastSpellOutput"] .. param)
271-
end
272-
273-
function CastBack()
274-
local param = ma_gmParametersInput:GetText()
275-
MangAdmin:ChatMsg(".cast back " .. param)
276-
MangAdmin:LogAction(Locale["ma_gmCastBackSpellOutput"] .. param)
277-
end
278-
279-
function CastDist()
280-
local param = ma_gmParametersInput:GetText()
281-
MangAdmin:ChatMsg(".cast dist " .. param)
282-
MangAdmin:LogAction(Locale["ma_gmCastDistSpellOutput"] .. param)
283-
end
284-
285-
function CastSelf()
286-
local param = ma_gmParametersInput:GetText()
287-
MangAdmin:ChatMsg(".cast self " .. param)
288-
MangAdmin:LogAction(Locale["ma_gmCastSelfSpellOutput"] .. param)
289-
end
290-
291-
function CastTarget()
292-
local param = ma_gmParametersInput:GetText()
293-
MangAdmin:ChatMsg(".cast target " .. param)
294-
MangAdmin:LogAction(Locale["ma_gmCastTargetSpellOutput"] .. param)
295-
end
296-
297-
function TeleAddButton()
298-
local cname = ma_gmParametersInput:GetText()
299-
MangAdmin:ChatMsg(".tele add " .. cname)
300-
MangAdmin:LogAction(cname .. Locale["ma_gmTeleAddOutput"])
301-
end
302-
303-
function TeleDelButton()
304-
local cname = ma_gmParametersInput:GetText()
305-
MangAdmin:ChatMsg(".tele del " .. cname)
306-
MangAdmin:LogAction(cname .. Locale["ma_gmTeleDelOutput"])
307-
end
308-
309-
function ListItem()
310-
local param = ma_gmParametersInput:GetText()
311-
MangAdmin:ChatMsg(".list item " .. param)
312-
MangAdmin:LogAction(Locale["ma_gmListItemOutput"] .. param)
313-
end
314-
315-
function LookupTaxi()
316-
local param = ma_gmParametersInput:GetText()
317-
MangAdmin:ChatMsg(".lookup taxi " .. param)
318-
MangAdmin:LogAction(Locale["ma_gmLookTaxiOutput"] .. param)
319-
end
320-
321-
function LookupZone()
322-
local param = ma_gmParametersInput:GetText()
323-
MangAdmin:ChatMsg(".lookup area " .. param)
324-
MangAdmin:LogAction(Locale["ma_gmLookZoneOutput"] .. param)
325-
end
326-
327-
function GoTaxiNode()
328-
local param = ma_gmParametersInput:GetText()
329-
MangAdmin:ChatMsg(".go taxinode " .. param)
330-
MangAdmin:LogAction(Locale["ma_gmGoTaxiOutput"] .. param)
331-
end
332-
333-
function GoTrigger()
334-
local param = ma_gmParametersInput:GetText()
335-
MangAdmin:ChatMsg(".go trigger " .. param)
336-
MangAdmin:LogAction(Locale["ma_gmGoTriggerOutput"] .. param)
337-
end
338-
339-
function GoXY()
340-
local param = ma_gmParametersInput:GetText()
341-
MangAdmin:ChatMsg(".go xy " .. param)
342-
MangAdmin:LogAction(Locale["ma_gmGoXYOutput"] .. param)
343-
end
344-
345-
function GoXYZ()
346-
local param = ma_gmParametersInput:GetText()
347-
MangAdmin:ChatMsg(".go xyz " .. param)
348-
MangAdmin:LogAction(Locale["ma_gmGoXYZOutput"] .. param)
349-
end
350-
351-
function GoZoneXY()
352-
local param = ma_gmParametersInput:GetText()
353-
MangAdmin:ChatMsg(".go zonexy " .. param)
354-
MangAdmin:LogAction(Locale["ma_gmZoneXYOutput"] .. param)
355-
end
356-
357349
function SetJail_A()
358350
MangAdmin:ChatMsg(".tele del ma_AllianceJail")
359351
local i = 1
@@ -375,46 +367,13 @@ function SetJail_H()
375367
MangAdmin:ChatMsg(".tele add ma_HordeJail")
376368
MangAdmin:LogAction(Locale["ma_gmSetJailHOutput"])
377369
end
378-
379-
function PetCreate()
380-
MangAdmin:ChatMsg(".pet create")
381-
MangAdmin:LogAction(Locale["ma_gmPetCreateOutput"])
382-
end
383-
384-
function PetLearn()
385-
local param = ma_gmParametersInput:GetText()
386-
MangAdmin:ChatMsg(".pet learn " .. param)
387-
MangAdmin:LogAction(Locale["ma_gmPetLearnOutput"] .. param)
388-
end
389-
390-
function PetUnLearn()
391-
local param = ma_gmParametersInput:GetText()
392-
MangAdmin:ChatMsg(".pet unlearn " .. param)
393-
MangAdmin:LogAction(Locale["ma_gmPetUnlearnOutput"] .. param)
394-
end
395-
396-
function PetTalentsLearn()
397-
MangAdmin:ChatMsg(".learn all my pettalents")
398-
MangAdmin:LogAction(Locale["ma_gmPetTalentsOutput"])
399-
end
400-
401-
function ShowBank()
402-
MangAdmin:ChatMsg(".character check bank")
403-
MangAdmin:LogAction(Locale["ma_gmBankOutput"])
404-
end
405-
406370
function Screenie()
407371
UIParent:Hide()
408372
Screenshot()
409373
UIParent:Show()
410374
MangAdmin:LogAction(Locale["ma_gmScreenieOutput"])
411375
end
412376

413-
function DismountPlayer()
414-
MangAdmin:ChatMsg(".dismount")
415-
MangAdmin:LogAction(Locale["ma_gmDismountOutput"])
416-
end
417-
418377
function InstantKill()
419378
MangAdmin.db.char.instantKillMode = ma_instantkillbutton:GetChecked()
420379
MangAdmin:LogAction(

0 commit comments

Comments
 (0)