refactor: unwrap redundant code block

This commit is contained in:
Breno A. 2024-06-09 08:58:01 -03:00
parent 029ef823e1
commit 9fa0f2bcad
6 changed files with 40 additions and 60 deletions

View File

@ -63,9 +63,7 @@ public final class GroupCommand implements CommandHandler {
CommandHandler.sendMessage(sender, translate(sender, "commands.group.refreshed", groupId)); CommandHandler.sendMessage(sender, translate(sender, "commands.group.refreshed", groupId));
} }
default -> { default -> sendUsageMessage(sender);
sendUsageMessage(sender);
}
} }
} }
} }

View File

@ -106,14 +106,12 @@ public final class SendMailCommand implements CommandHandler {
getConstructionArgs(mailBuilder.constructionStage, sender))); getConstructionArgs(mailBuilder.constructionStage, sender)));
} }
} }
case "help" -> { case "help" -> CommandHandler.sendMessage(
CommandHandler.sendMessage(
sender, sender,
translate( translate(
sender, sender,
"commands.sendMail.please_use", "commands.sendMail.please_use",
getConstructionArgs(mailBuilder.constructionStage, sender))); getConstructionArgs(mailBuilder.constructionStage, sender)));
}
default -> { default -> {
switch (mailBuilder.constructionStage) { switch (mailBuilder.constructionStage) {
case 0 -> { case 0 -> {

View File

@ -45,9 +45,7 @@ public final class TalentCommand implements CommandHandler {
String cmdSwitch = args.get(0).toLowerCase(); String cmdSwitch = args.get(0).toLowerCase();
switch (cmdSwitch) { switch (cmdSwitch) {
default -> { default -> sendUsageMessage(sender);
sendUsageMessage(sender);
}
case "set" -> { case "set" -> {
if (args.size() < 3) { if (args.size() < 3) {
sendUsageMessage(sender); sendUsageMessage(sender);

View File

@ -48,8 +48,7 @@ public class PlayerCodex {
val itemData = item.getItemData(); val itemData = item.getItemData();
val itemId = item.getItemId(); val itemId = item.getItemId();
switch (itemData.getItemType()) { switch (itemData.getItemType()) {
case ITEM_WEAPON -> { case ITEM_WEAPON -> Optional.ofNullable(GameData.getCodexWeaponDataIdMap().get(itemId))
Optional.ofNullable(GameData.getCodexWeaponDataIdMap().get(itemId))
.ifPresent( .ifPresent(
codexData -> { codexData -> {
if (this.getUnlockedWeapon().add(itemId)) { if (this.getUnlockedWeapon().add(itemId)) {
@ -57,7 +56,6 @@ public class PlayerCodex {
this.player.sendPacket(new PacketCodexDataUpdateNotify(2, codexData.getId())); this.player.sendPacket(new PacketCodexDataUpdateNotify(2, codexData.getId()));
} }
}); });
}
case ITEM_MATERIAL -> { case ITEM_MATERIAL -> {
switch (itemData.getMaterialType()) { switch (itemData.getMaterialType()) {
// Is this check even needed? // Is this check even needed?
@ -65,8 +63,7 @@ public class PlayerCodex {
MATERIAL_WIDGET, MATERIAL_WIDGET,
MATERIAL_EXCHANGE, MATERIAL_EXCHANGE,
MATERIAL_AVATAR_MATERIAL, MATERIAL_AVATAR_MATERIAL,
MATERIAL_NOTICE_ADD_HP -> { MATERIAL_NOTICE_ADD_HP -> Optional.ofNullable(GameData.getCodexMaterialDataIdMap().get(itemId))
Optional.ofNullable(GameData.getCodexMaterialDataIdMap().get(itemId))
.ifPresent( .ifPresent(
codexData -> { codexData -> {
if (this.getUnlockedMaterial().add(itemId)) { if (this.getUnlockedMaterial().add(itemId)) {
@ -75,7 +72,6 @@ public class PlayerCodex {
new PacketCodexDataUpdateNotify(4, codexData.getId())); new PacketCodexDataUpdateNotify(4, codexData.getId()));
} }
}); });
}
default -> {} default -> {}
} }
} }

View File

@ -43,16 +43,13 @@ public class HandlerTryEnterHomeReq extends PacketHandler {
} }
} }
case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption
.FRIEND_ENTER_HOME_OPTION_REFUSE_VALUE -> { .FRIEND_ENTER_HOME_OPTION_REFUSE_VALUE -> session.send(
session.send(
new PacketTryEnterHomeRsp( new PacketTryEnterHomeRsp(
RetcodeOuterClass.Retcode.RET_HOME_HOME_REFUSE_GUEST_ENTER_VALUE, RetcodeOuterClass.Retcode.RET_HOME_HOME_REFUSE_GUEST_ENTER_VALUE,
req.getTargetUid())); req.getTargetUid()));
}
case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption
.FRIEND_ENTER_HOME_OPTION_DIRECT_VALUE -> { .FRIEND_ENTER_HOME_OPTION_DIRECT_VALUE -> session
session
.getServer() .getServer()
.getHomeWorldMPSystem() .getHomeWorldMPSystem()
.enterHome( .enterHome(
@ -61,7 +58,6 @@ public class HandlerTryEnterHomeReq extends PacketHandler {
req.getTargetPoint(), req.getTargetPoint(),
req.getIsTransferToSafePoint()); req.getIsTransferToSafePoint());
} }
}
return; return;
} }

View File

@ -37,9 +37,7 @@ public class PacketVehicleInteractRsp extends BasePacket {
QuestContent.QUEST_CONTENT_ENTER_VEHICLE, QuestContent.QUEST_CONTENT_ENTER_VEHICLE,
((EntityVehicle) vehicle).getGadgetId()); ((EntityVehicle) vehicle).getGadgetId());
} }
case VEHICLE_INTERACT_TYPE_OUT -> { case VEHICLE_INTERACT_TYPE_OUT -> ((EntityVehicle) vehicle).getVehicleMembers().remove(vehicleMember);
((EntityVehicle) vehicle).getVehicleMembers().remove(vehicleMember);
}
default -> {} default -> {}
} }
} }
@ -57,12 +55,8 @@ public class PacketVehicleInteractRsp extends BasePacket {
proto.setMember(vehicleMember); proto.setMember(vehicleMember);
switch (interactType) { switch (interactType) {
case VEHICLE_INTERACT_TYPE_IN -> { case VEHICLE_INTERACT_TYPE_IN -> vehicle.getVehicleMembers().add(vehicleMember);
vehicle.getVehicleMembers().add(vehicleMember); case VEHICLE_INTERACT_TYPE_OUT -> vehicle.getVehicleMembers().remove(vehicleMember);
}
case VEHICLE_INTERACT_TYPE_OUT -> {
vehicle.getVehicleMembers().remove(vehicleMember);
}
default -> {} default -> {}
} }
} }