Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to add another 'case' value to a 'switch' statement #651

Closed
Attack8 opened this issue Dec 2, 2023 · 0 comments
Closed

Trying to add another 'case' value to a 'switch' statement #651

Attack8 opened this issue Dec 2, 2023 · 0 comments

Comments

@Attack8
Copy link

Attack8 commented Dec 2, 2023

The method that I want to inject into reads:

     public Quest build() {
        if (this.id != null && !this.id.isBlank()) {
            if (this.name != null && !this.name.isBlank()) {
                if (this.descriptionData == null) {
                    throw new IllegalStateException("Attempted to create a Quest with invalid DESCRIPTION. DESCRIPTION must not be null or empty.");
                } else if (this.icon == null) {
                    throw new IllegalStateException("Attempted to create a Quest with invalid ICON. ICON must not be null.");
                } else if (this.targetId == null) {
                    throw new IllegalStateException("Attempted to create a Quest with invalid TARGET. TARGET must not be null.");
                } else if (this.targetProgress < 1.0F) {
                    throw new IllegalStateException("Attempted to create a Quest with invalid TARGET PROGRESS. Must be greater than 0.");
                } else if (this.reward == null) {
                    throw new IllegalStateException("Attempted to create a Quest with invalid REWARD. REWARD must not be null.");
                } else {
                    switch (this.type) {
                        case "anvil":
                            return new AnvilQuest(this.id, this.name, this.descriptionData, this.icon, this.targetId, this.targetProgress, this.unlockedBy, this.reward);
                        case "block_interact":
                            return new BlockInteractionQuest(this.id, this.name, this.descriptionData, this.icon, this.targetId, this.targetProgress, this.unlockedBy, this.reward);
                        case "bounty_complete":
                            return new BountyCompleteQuest(this.id, this.name, this.descriptionData, this.icon, this.targetId, this.targetProgress, this.unlockedBy, this.reward);
                        case "checkmark":
                            return new CheckmarkQuest(this.id, this.name, this.descriptionData, this.icon, this.targetId, this.targetProgress, this.unlockedBy, this.reward);
                        case "collection":
                            return new CollectionQuest(this.id, this.name, this.descriptionData, this.icon, this.targetId, this.targetProgress, this.unlockedBy, this.reward);
                        case "craft_crystal":
                            return new CraftCrystalQuest(this.id, this.name, this.descriptionData, this.icon, this.targetId, this.targetProgress, this.unlockedBy, this.reward);
                        case "crafting":
                            return new CraftingQuest(this.id, this.name, this.descriptionData, this.icon, this.targetId, this.targetProgress, this.unlockedBy, this.reward);
                        case "enter_vault":
                            return new EnterVaultQuest(this.id, this.name, this.descriptionData, this.icon, this.targetId, this.targetProgress, this.unlockedBy, this.reward);
                        case "forge_gear":
                            return new ForgeGearQuest(this.id, this.name, this.descriptionData, this.icon, this.targetId, this.targetProgress, this.unlockedBy, this.reward);
                        case "level_up":
                            return new LevelUpQuest(this.id, this.name, this.descriptionData, this.icon, this.targetId, this.targetProgress, this.unlockedBy, this.reward);
                        case "mining":
                            return new MiningQuest(this.id, this.name, this.descriptionData, this.icon, this.targetId, this.targetProgress, this.unlockedBy, this.reward);
                        case "modify_gear":
                            return new ModifyGearQuest(this.id, this.name, this.descriptionData, this.icon, this.targetId, this.targetProgress, this.unlockedBy, this.reward);
                        case "survive":
                            return new SurviveQuest(this.id, this.name, this.descriptionData, this.icon, this.targetId, this.targetProgress, this.unlockedBy, this.reward);
                        default:
                            return null;
                    }
                }
            } else {
                throw new IllegalStateException("Attempted to create a Quest with invalid NAME. NAME must not be null or empty.");
            }
        } else {
            throw new IllegalStateException("Attempted to create a Quest with invalid ID. ID must not be null or empty.");
        }
    }

But I want to add

    case "jar_pickup":
            return new AnimajJarPickupQuest(this.id, this.name, this.descriptionData, this.icon, this.targetId, this.targetProgress, this.unlockedBy, this.reward);

How could I go about dong this? I've tried @Inject with an @At of HEAD and CallbackInfoReturnable, but haven't had any luck

Thanks in advance!

@Attack8 Attack8 closed this as completed Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant