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; return;
} }
boolean properId = false; // Check if class id is valid.
boolean canChange = false;
for (ClassId cId : player.getClassId().getNextClassIds()) for (ClassId cId : player.getClassId().getNextClassIds())
{ {
if (cId.getId() == _classId) if (cId.getId() == _classId)
{ {
properId = true; canChange = true;
break; break;
} }
} }
if (!properId) if (!canChange)
{ {
LOGGER.warning(player + " tried to change class from " + player.getClassId() + " to " + ClassId.getClassId(_classId) + "."); LOGGER.warning(player + " tried to change class from " + player.getClassId() + " to " + ClassId.getClassId(_classId) + ".");
return; return;
} }
boolean canChange = false; // Check for player proper class group and level.
canChange = false;
final int playerLevel = player.getLevel(); final int playerLevel = player.getLevel();
if (player.isInCategory(CategoryType.FIRST_CLASS_GROUP) && (playerLevel >= 18)) 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); canChange = CategoryData.getInstance().isInCategory(CategoryType.SIXTH_CLASS_GROUP, _classId);
} }
// Change class.
if (canChange) if (canChange)
{ {
player.setClassId(_classId); player.setClassId(_classId);

View File

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