mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-04 23:32:55 +08:00
refactor: unwrap redundant code block
This commit is contained in:
parent
029ef823e1
commit
9fa0f2bcad
@ -63,9 +63,7 @@ public final class GroupCommand implements CommandHandler {
|
||||
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.group.refreshed", groupId));
|
||||
}
|
||||
default -> {
|
||||
sendUsageMessage(sender);
|
||||
}
|
||||
default -> sendUsageMessage(sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,14 +106,12 @@ public final class SendMailCommand implements CommandHandler {
|
||||
getConstructionArgs(mailBuilder.constructionStage, sender)));
|
||||
}
|
||||
}
|
||||
case "help" -> {
|
||||
CommandHandler.sendMessage(
|
||||
sender,
|
||||
translate(
|
||||
sender,
|
||||
"commands.sendMail.please_use",
|
||||
getConstructionArgs(mailBuilder.constructionStage, sender)));
|
||||
}
|
||||
case "help" -> CommandHandler.sendMessage(
|
||||
sender,
|
||||
translate(
|
||||
sender,
|
||||
"commands.sendMail.please_use",
|
||||
getConstructionArgs(mailBuilder.constructionStage, sender)));
|
||||
default -> {
|
||||
switch (mailBuilder.constructionStage) {
|
||||
case 0 -> {
|
||||
|
@ -45,9 +45,7 @@ public final class TalentCommand implements CommandHandler {
|
||||
|
||||
String cmdSwitch = args.get(0).toLowerCase();
|
||||
switch (cmdSwitch) {
|
||||
default -> {
|
||||
sendUsageMessage(sender);
|
||||
}
|
||||
default -> sendUsageMessage(sender);
|
||||
case "set" -> {
|
||||
if (args.size() < 3) {
|
||||
sendUsageMessage(sender);
|
||||
|
@ -48,16 +48,14 @@ public class PlayerCodex {
|
||||
val itemData = item.getItemData();
|
||||
val itemId = item.getItemId();
|
||||
switch (itemData.getItemType()) {
|
||||
case ITEM_WEAPON -> {
|
||||
Optional.ofNullable(GameData.getCodexWeaponDataIdMap().get(itemId))
|
||||
.ifPresent(
|
||||
codexData -> {
|
||||
if (this.getUnlockedWeapon().add(itemId)) {
|
||||
this.player.save();
|
||||
this.player.sendPacket(new PacketCodexDataUpdateNotify(2, codexData.getId()));
|
||||
}
|
||||
});
|
||||
}
|
||||
case ITEM_WEAPON -> Optional.ofNullable(GameData.getCodexWeaponDataIdMap().get(itemId))
|
||||
.ifPresent(
|
||||
codexData -> {
|
||||
if (this.getUnlockedWeapon().add(itemId)) {
|
||||
this.player.save();
|
||||
this.player.sendPacket(new PacketCodexDataUpdateNotify(2, codexData.getId()));
|
||||
}
|
||||
});
|
||||
case ITEM_MATERIAL -> {
|
||||
switch (itemData.getMaterialType()) {
|
||||
// Is this check even needed?
|
||||
@ -65,17 +63,15 @@ public class PlayerCodex {
|
||||
MATERIAL_WIDGET,
|
||||
MATERIAL_EXCHANGE,
|
||||
MATERIAL_AVATAR_MATERIAL,
|
||||
MATERIAL_NOTICE_ADD_HP -> {
|
||||
Optional.ofNullable(GameData.getCodexMaterialDataIdMap().get(itemId))
|
||||
.ifPresent(
|
||||
codexData -> {
|
||||
if (this.getUnlockedMaterial().add(itemId)) {
|
||||
this.player.save();
|
||||
this.player.sendPacket(
|
||||
new PacketCodexDataUpdateNotify(4, codexData.getId()));
|
||||
}
|
||||
});
|
||||
}
|
||||
MATERIAL_NOTICE_ADD_HP -> Optional.ofNullable(GameData.getCodexMaterialDataIdMap().get(itemId))
|
||||
.ifPresent(
|
||||
codexData -> {
|
||||
if (this.getUnlockedMaterial().add(itemId)) {
|
||||
this.player.save();
|
||||
this.player.sendPacket(
|
||||
new PacketCodexDataUpdateNotify(4, codexData.getId()));
|
||||
}
|
||||
});
|
||||
default -> {}
|
||||
}
|
||||
}
|
||||
|
@ -43,24 +43,20 @@ public class HandlerTryEnterHomeReq extends PacketHandler {
|
||||
}
|
||||
}
|
||||
case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption
|
||||
.FRIEND_ENTER_HOME_OPTION_REFUSE_VALUE -> {
|
||||
session.send(
|
||||
new PacketTryEnterHomeRsp(
|
||||
RetcodeOuterClass.Retcode.RET_HOME_HOME_REFUSE_GUEST_ENTER_VALUE,
|
||||
req.getTargetUid()));
|
||||
}
|
||||
.FRIEND_ENTER_HOME_OPTION_REFUSE_VALUE -> session.send(
|
||||
new PacketTryEnterHomeRsp(
|
||||
RetcodeOuterClass.Retcode.RET_HOME_HOME_REFUSE_GUEST_ENTER_VALUE,
|
||||
req.getTargetUid()));
|
||||
|
||||
case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption
|
||||
.FRIEND_ENTER_HOME_OPTION_DIRECT_VALUE -> {
|
||||
session
|
||||
.getServer()
|
||||
.getHomeWorldMPSystem()
|
||||
.enterHome(
|
||||
session.getPlayer(),
|
||||
targetPlayer,
|
||||
req.getTargetPoint(),
|
||||
req.getIsTransferToSafePoint());
|
||||
}
|
||||
.FRIEND_ENTER_HOME_OPTION_DIRECT_VALUE -> session
|
||||
.getServer()
|
||||
.getHomeWorldMPSystem()
|
||||
.enterHome(
|
||||
session.getPlayer(),
|
||||
targetPlayer,
|
||||
req.getTargetPoint(),
|
||||
req.getIsTransferToSafePoint());
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -37,9 +37,7 @@ public class PacketVehicleInteractRsp extends BasePacket {
|
||||
QuestContent.QUEST_CONTENT_ENTER_VEHICLE,
|
||||
((EntityVehicle) vehicle).getGadgetId());
|
||||
}
|
||||
case VEHICLE_INTERACT_TYPE_OUT -> {
|
||||
((EntityVehicle) vehicle).getVehicleMembers().remove(vehicleMember);
|
||||
}
|
||||
case VEHICLE_INTERACT_TYPE_OUT -> ((EntityVehicle) vehicle).getVehicleMembers().remove(vehicleMember);
|
||||
default -> {}
|
||||
}
|
||||
}
|
||||
@ -57,12 +55,8 @@ public class PacketVehicleInteractRsp extends BasePacket {
|
||||
proto.setMember(vehicleMember);
|
||||
|
||||
switch (interactType) {
|
||||
case VEHICLE_INTERACT_TYPE_IN -> {
|
||||
vehicle.getVehicleMembers().add(vehicleMember);
|
||||
}
|
||||
case VEHICLE_INTERACT_TYPE_OUT -> {
|
||||
vehicle.getVehicleMembers().remove(vehicleMember);
|
||||
}
|
||||
case VEHICLE_INTERACT_TYPE_IN -> vehicle.getVehicleMembers().add(vehicleMember);
|
||||
case VEHICLE_INTERACT_TYPE_OUT -> vehicle.getVehicleMembers().remove(vehicleMember);
|
||||
default -> {}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user