Minor improvements for previous commit.

This commit is contained in:
MobiusDevelopment
2019-10-11 23:15:34 +00:00
parent ec6ebff881
commit 53454558b2
2 changed files with 14 additions and 8 deletions

View File

@@ -52,22 +52,24 @@ public class ExRequestClassChange implements IClientIncomingPacket
return;
}
boolean properId = false;
// Check if class id is valid.
boolean canChange = false;
for (ClassId cId : player.getClassId().getNextClassIds())
{
if (cId.getId() == _classId)
{
properId = true;
canChange = true;
break;
}
}
if (!properId)
if (!canChange)
{
LOGGER.warning(player + " tried to change class from " + player.getClassId() + " to " + ClassId.getClassId(_classId) + ".");
return;
}
boolean canChange = false;
// Check for player proper class group and level.
canChange = false;
final int playerLevel = player.getLevel();
if (player.isInCategory(CategoryType.FIRST_CLASS_GROUP) && (playerLevel >= 18))
{
@@ -86,6 +88,7 @@ public class ExRequestClassChange implements IClientIncomingPacket
canChange = CategoryData.getInstance().isInCategory(CategoryType.SIXTH_CLASS_GROUP, _classId);
}
// Change class.
if (canChange)
{
player.setClassId(_classId);