Update some commands to new system
Port From (https://github.com/TrinityCore/TrinityCore/commit/3260b94dd627b7b0c7114f94bb97d108b005af3e)
This commit is contained in:
@@ -62,7 +62,7 @@ namespace Game.Chat
|
||||
}
|
||||
|
||||
[Command("learn", RBACPermissions.CommandPetLearn)]
|
||||
static bool HandlePetLearnCommand(CommandHandler handler, uint spellId)
|
||||
static bool HandlePetLearnCommand(CommandHandler handler, SpellInfo spellInfo)
|
||||
{
|
||||
Pet pet = GetSelectedPlayerPetOrOwn(handler);
|
||||
if (!pet)
|
||||
@@ -71,8 +71,7 @@ namespace Game.Chat
|
||||
return false;
|
||||
}
|
||||
|
||||
if (spellId == 0 || !Global.SpellMgr.HasSpellInfo(spellId, Difficulty.None))
|
||||
return false;
|
||||
uint spellId = spellInfo.Id;
|
||||
|
||||
// Check if pet already has it
|
||||
if (pet.HasSpell(spellId))
|
||||
@@ -82,8 +81,7 @@ namespace Game.Chat
|
||||
}
|
||||
|
||||
// Check if spell is valid
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, Difficulty.None);
|
||||
if (spellInfo == null || !Global.SpellMgr.IsSpellValid(spellInfo))
|
||||
if (!Global.SpellMgr.IsSpellValid(spellInfo))
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.CommandSpellBroken, spellId);
|
||||
return false;
|
||||
@@ -96,7 +94,7 @@ namespace Game.Chat
|
||||
}
|
||||
|
||||
[Command("unlearn", RBACPermissions.CommandPetUnlearn)]
|
||||
static bool HandlePetUnlearnCommand(CommandHandler handler, uint spellId)
|
||||
static bool HandlePetUnlearnCommand(CommandHandler handler, SpellInfo spellInfo)
|
||||
{
|
||||
Pet pet = GetSelectedPlayerPetOrOwn(handler);
|
||||
if (!pet)
|
||||
@@ -105,6 +103,8 @@ namespace Game.Chat
|
||||
return false;
|
||||
}
|
||||
|
||||
uint spellId = spellInfo.Id;
|
||||
|
||||
if (pet.HasSpell(spellId))
|
||||
pet.RemoveSpell(spellId, false);
|
||||
else
|
||||
@@ -114,7 +114,7 @@ namespace Game.Chat
|
||||
}
|
||||
|
||||
[Command("level", RBACPermissions.CommandPetLevel)]
|
||||
static bool HandlePetLevelCommand(CommandHandler handler, int level)
|
||||
static bool HandlePetLevelCommand(CommandHandler handler, int? level)
|
||||
{
|
||||
Pet pet = GetSelectedPlayerPetOrOwn(handler);
|
||||
Player owner = pet ? pet.GetOwner() : null;
|
||||
@@ -124,15 +124,16 @@ namespace Game.Chat
|
||||
return false;
|
||||
}
|
||||
|
||||
if (level == 0)
|
||||
if (!level.HasValue)
|
||||
level = (int)(owner.GetLevel() - pet.GetLevel());
|
||||
|
||||
if (level == 0 || level < -SharedConst.StrongMaxLevel || level > SharedConst.StrongMaxLevel)
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.BadValue);
|
||||
return false;
|
||||
}
|
||||
|
||||
int newLevel = (int)pet.GetLevel() + level;
|
||||
int newLevel = (int)pet.GetLevel() + level.Value;
|
||||
if (newLevel < 1)
|
||||
newLevel = 1;
|
||||
else if (newLevel > owner.GetLevel())
|
||||
|
||||
Reference in New Issue
Block a user