Skip to content

Commit badb237

Browse files
committed
refactor: Generics for some CHAR commands
1 parent 1458f69 commit badb237

File tree

7 files changed

+133
-190
lines changed

7 files changed

+133
-190
lines changed

AzerothCoreAdmin.lua

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -276,41 +276,41 @@ function MangAdmin:PLAYER_TARGET_CHANGED()
276276
ModelChanged()
277277
NpcModelChanged()
278278
if UnitIsPlayer("target") then
279-
ma_savebutton:Enable()
279+
CHAR_saveButton:Enable()
280280
if UnitIsDead("target") then
281-
ma_revivebutton:Enable()
282-
ma_killbutton:Disable()
281+
CHAR_reviveButton:Enable()
282+
CHAR_killButton:Disable()
283283
else
284284
--ma_revivebutton:Disable()
285-
ma_killbutton:Enable()
285+
CHAR_killButton:Enable()
286286
end
287287
if not UnitIsUnit("target", "player") then
288-
ma_kickbutton:Enable()
288+
CHAR_kickButton:Enable()
289289
else
290-
ma_kickbutton:Disable()
290+
CHAR_kickButton:Disable()
291291
end
292292
--ma_respawnbutton:Disable()
293293
elseif not UnitName("target") then
294-
ma_savebutton:Enable()
294+
CHAR_saveButton:Enable()
295295
--ma_revivebutton:Disable()
296-
ma_killbutton:Disable()
297-
ma_kickbutton:Disable()
296+
CHAR_killButton:Disable()
297+
CHAR_kickButton:Disable()
298298
--ma_respawnbutton:Disable()
299299
else
300-
ma_savebutton:Disable()
300+
CHAR_saveButton:Disable()
301301
--ma_revivebutton:Disable()
302-
ma_kickbutton:Disable()
302+
CHAR_kickButton:Disable()
303303
if UnitIsDead("target") then
304304
--ma_respawnbutton:Enable()
305-
ma_killbutton:Disable()
305+
CHAR_killButton:Disable()
306306
else
307307
if self.db.char.instantKillMode then
308308
if not UnitIsFriend("player", "target") then
309309
KillSomething()
310310
end
311311
end
312312
--ma_respawnbutton:Disable()
313-
ma_killbutton:Enable()
313+
CHAR_killButton:Enable()
314314
end
315315
end
316316
end
@@ -1640,7 +1640,7 @@ end
16401640
function MangAdmin:InitButtons()
16411641
-- start tab buttons
16421642
self:PrepareScript(ma_tabbutton_main , Locale["ttGM_tabButton"] , function() MangAdmin:InstantGroupToggle("main") end)
1643-
self:PrepareScript(ma_tabbutton_char , Locale["tt_CharButton"] , function() MangAdmin:InstantGroupToggle("char") end)
1643+
self:PrepareScript(ma_tabbutton_char , Locale["ttCHAR_CharButton"] , function() MangAdmin:InstantGroupToggle("char") end)
16441644
self:PrepareScript(ma_tabbutton_npc , Locale["tt_NpcButton"] , function() MangAdmin:InstantGroupToggle("npc"); end)
16451645
self:PrepareScript(ma_tabbutton_go , Locale["tt_GOButton"] , function() MangAdmin:InstantGroupToggle("go"); end)
16461646
self:PrepareScript(ma_tabbutton_tele , Locale["tt_TeleButton"] , function() MangAdmin:InstantGroupToggle("tele"); end)
@@ -1652,7 +1652,7 @@ function MangAdmin:InitButtons()
16521652
-- start mini buttons
16531653
self:PrepareScript(ma_mm_logoframe , nil , function() MangAdmin:OnClick() end)
16541654
self:PrepareScript(ma_mm_mainbutton , Locale["ttGM_tabButton"] , function() MangAdmin:InstantGroupToggle("main") end)
1655-
self:PrepareScript(ma_mm_charbutton , Locale["tt_CharButton"] , function() MangAdmin:InstantGroupToggle("char") end)
1655+
self:PrepareScript(ma_mm_charbutton , Locale["ttCHAR_CharButton"] , function() MangAdmin:InstantGroupToggle("char") end)
16561656
self:PrepareScript(ma_mm_npcbutton , Locale["tt_NpcButton"] , function() MangAdmin:InstantGroupToggle("npc") end)
16571657
self:PrepareScript(ma_mm_gobutton , Locale["tt_GOButton"] , function() MangAdmin:InstantGroupToggle("go") end)
16581658
self:PrepareScript(ma_mm_telebutton , Locale["tt_TeleButton"] , function() MangAdmin:InstantGroupToggle("tele") end)

Commands/Commands_Char.lua

Lines changed: 28 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
[GENERICS_isValueNeeded] = false|true,
2121
[GENERICS_isParametersNeeded] = false|true,
2222
[GENERICS_isTargetCheckNeeded] = false|true,
23+
[GENERICS_canTargetBeACreature] = false|true,
2324
[GENERICS_command] = "command",
2425
[GENERICS_message] = "messageID"
2526
}
@@ -50,23 +51,26 @@ CHAR_genericCommands = {
5051
},
5152
[CHAR_GUIDCommand] = {
5253
[GENERICS_isTargetCheckNeeded] = true,
54+
[GENERICS_canTargetBeACreature] = true,
5355
[GENERICS_command] = ".guid",
5456
[GENERICS_message] = "logCHAR_guid"
5557
},
5658
[CHAR_playerInfoCommand] = {
5759
[GENERICS_isTargetCheckNeeded] = true,
5860
[GENERICS_command] = ".pinfo",
59-
[GENERICS_message] = "logCHAR_playerInfo"
61+
[GENERICS_message] = "logCHAR_pInfo"
6062
},
6163
[CHAR_distanceCommand] = {
6264
[GENERICS_isTargetCheckNeeded] = true,
65+
[GENERICS_canTargetBeACreature] = true,
6366
[GENERICS_command] = ".distance",
6467
[GENERICS_message] = "logCHAR_distance"
6568
},
66-
[CHAR_dieCommand] = {
69+
[CHAR_killCommand] = {
6770
[GENERICS_isTargetCheckNeeded] = true,
71+
[GENERICS_canTargetBeACreature] = true,
6872
[GENERICS_command] = ".die",
69-
[GENERICS_message] = "logCHAR_die"
73+
[GENERICS_message] = "logCHAR_kill"
7074
},
7175
[CHAR_recallCommand] = {
7276
[GENERICS_isTargetCheckNeeded] = true,
@@ -164,89 +168,37 @@ end
164168

165169
-- Delete
166170

167-
function RevivePlayer()
168-
if MangAdmin:Selection("player") or MangAdmin:Selection("self") or MangAdmin:Selection("none") then
169-
local player = UnitName("target") or UnitName("player")
170-
MangAdmin:ChatMsg(".revive")
171-
MangAdmin:LogAction("Revived player "..player..".")
172-
else
173-
MangAdmin:Print(Locale["selectionError"])
174-
end
175-
end
176-
177-
function SavePlayer()
178-
if MangAdmin:Selection("player") or MangAdmin:Selection("self") or MangAdmin:Selection("none") then
179-
local player = UnitName("target") or UnitName("player")
180-
MangAdmin:ChatMsg(".save")
181-
MangAdmin:LogAction("Saved player "..player..".")
182-
else
183-
MangAdmin:Print(Locale["selectionError"])
184-
end
185-
end
186-
187-
function KickPlayer()
188-
if MangAdmin:Selection("player") or MangAdmin:Selection("self") or MangAdmin:Selection("none") then
189-
local player = UnitName("target") or UnitName("player")
190-
MangAdmin:ChatMsg(".kick")
191-
MangAdmin:LogAction("Kicked player "..player..".")
192-
else
193-
MangAdmin:Print(Locale["selectionError"])
194-
end
195-
end
196171

197-
function Cooldown()
198-
if MangAdmin:Selection("player") or MangAdmin:Selection("self") or MangAdmin:Selection("none") then
199-
local player = UnitName("target") or UnitName("player")
200-
MangAdmin:ChatMsg(".cooldown")
201-
MangAdmin:LogAction("Cooled player "..player..".")
202-
else
203-
MangAdmin:Print(Locale["selectionError"])
204-
end
205-
end
206-
207-
function ShowGUID()
172+
function Demorph()
208173
local player = UnitName("target") or UnitName("player")
209-
MangAdmin:ChatMsg(".guid")
210-
MangAdmin:LogAction("Got GUID for player "..player..".")
174+
MangAdmin:ChatMsg(".morph reset")
175+
MangAdmin:LogAction("Demorphed player "..player..".")
211176
end
212177

213-
function Pinfo()
214-
if MangAdmin:Selection("player") or MangAdmin:Selection("self") or MangAdmin:Selection("none") then
215-
local player = UnitName("target") or UnitName("player")
216-
MangAdmin:ChatMsg(".pinfo")
217-
MangAdmin:LogAction("Got Player Info for player "..player..".")
218-
else
219-
MangAdmin:Print(Locale["selectionError"])
220-
end
221-
end
178+
function CharMorphButton()
179+
local player = UnitName("target") or UnitName("player")
180+
local diplayID = ma_charactertarget:GetText()
181+
MangAdmin:ChatMsg(".morph target "..diplayID)
182+
MangAdmin:LogAction("Morph applied to "..player..".")
222183

223-
function Distance()
224-
local player = UnitName("target") or UnitName("player")
225-
MangAdmin:ChatMsg(".distance")
226-
MangAdmin:LogAction("Got distance to player "..player..".")
227184
end
228185

229-
230-
function KillSomething()
231-
local target = UnitName("target") or UnitName("player")
232-
MangAdmin:ChatMsg(".die")
233-
MangAdmin:LogAction("Killed "..target..".")
186+
function GetGPSInfo()
187+
local player = UnitName("target") or UnitName("player")
188+
MangAdmin:ChatMsg(".gps")
189+
MangAdmin:LogAction("Got GPS coordinates for player "..player..".")
234190
end
235191

236-
function Recall()
237-
if MangAdmin:Selection("player") or MangAdmin:Selection("self") or MangAdmin:Selection("none") then
238-
local player = UnitName("target") or UnitName("player")
239-
MangAdmin:ChatMsg(".recall")
240-
MangAdmin:LogAction("Recalled player "..player..".")
241-
else
242-
MangAdmin:Print(Locale["selectionError"])
243-
end
192+
function CharBindSight()
193+
local cname = ma_charactertarget:GetText()
194+
MangAdmin:ChatMsg(".bindsight")
195+
MangAdmin:LogAction("Sight bound to "..cname)
244196
end
245197

246-
function Demorph()
247-
local player = UnitName("target") or UnitName("player")
248-
MangAdmin:ChatMsg(".morph reset")
249-
MangAdmin:LogAction("Demorphed player "..player..".")
198+
function CharUnBindSight()
199+
local cname = ma_charactertarget:GetText()
200+
MangAdmin:ChatMsg(".unbindsight")
201+
MangAdmin:LogAction("Sight unbound to "..cname)
250202
end
251203

252204
--
@@ -260,11 +212,7 @@ function ToggleMapsChar(value)
260212
end
261213
end
262214

263-
function GetGPSInfo()
264-
local player = UnitName("target") or UnitName("player")
265-
MangAdmin:ChatMsg(".gps")
266-
MangAdmin:LogAction("Got GPS coordinates for player "..player..".")
267-
end
215+
268216

269217
function LearnSpell(value, state)
270218
if MangAdmin:Selection("player") or MangAdmin:Selection("self") or MangAdmin:Selection("none") then
@@ -487,17 +435,6 @@ function ResetDropDownInitialize()
487435
UIDropDownMenu_SetSelectedValue(ma_resetdropdown, "talents")
488436
end
489437

490-
function CharBindSight()
491-
local cname = ma_charactertarget:GetText()
492-
MangAdmin:ChatMsg(".bindsight")
493-
MangAdmin:LogAction("Sight bound to "..cname)
494-
end
495-
496-
function CharUnBindSight()
497-
local cname = ma_charactertarget:GetText()
498-
MangAdmin:ChatMsg(".unbindsight")
499-
MangAdmin:LogAction("Sight unbound to "..cname)
500-
end
501438

502439
function CharRename()
503440
local cname = ma_charactertarget:GetText()
@@ -697,14 +634,6 @@ function MuteButton()
697634

698635
end
699636

700-
function CharMorphButton()
701-
local player = UnitName("target") or UnitName("player")
702-
local diplayID = ma_charactertarget:GetText()
703-
MangAdmin:ChatMsg(".morph target "..diplayID)
704-
MangAdmin:LogAction("Morph applied to "..player..".")
705-
706-
end
707-
708637
function CharAuraButton()
709638
local cname = ma_charactertarget:GetText()
710639
local npccname = ma_npccharactertarget:GetText()

Commands/Commands_Generics.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function genericCaller(dictionaryID, callID, value)
8383
data['value'] = dictionary[GENERICS_parametersGet]()
8484
end
8585
if call[GENERICS_isTargetCheckNeeded] then
86-
if commandTargetCheck() then
86+
if commandTargetCheck() or call[GENERICS_canTargetBeACreature] then
8787
data['target'] = getCommandTargetName()
8888
else
8989
MangAdmin:Print(Locale["selectionError"])

Commands/declarations/command_keys.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ GENERICS_parametersGet = "parametersGet"
1111
GENERICS_isValueNeeded = "isValueNeeded"
1212
GENERICS_isParametersNeeded = "isParametersNeeded"
1313
GENERICS_isTargetCheckNeeded = "isTargetCheckNeeded"
14+
GENERICS_canTargetBeACreature = "canTargetBeACreature"
1415
GENERICS_command = "command"
1516
GENERICS_message = "message"
1617

@@ -63,7 +64,7 @@ CHAR_cooldownCommand = "cooldown"
6364
CHAR_GUIDCommand = "GUID"
6465
CHAR_playerInfoCommand = "playerInfo"
6566
CHAR_distanceCommand = "distance"
66-
CHAR_dieCommand = "die"
67+
CHAR_killCommand = "kill"
6768
CHAR_recallCommand = "recall"
6869
CHAR_morphCommand = "morph"
6970
CHAR_morphResetCommand = "morphReset"

0 commit comments

Comments
 (0)