-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix "cost_function" being used in V1 configs
- and move current configs to legacy package
- Loading branch information
Showing
16 changed files
with
233 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/de/mschae23/grindenchantments/config/legacy/v1/DisenchantConfigV1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (C) 2024 mschae23 | ||
* | ||
* This file is part of Grind enchantments. | ||
* | ||
* Grind enchantments is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.mschae23.grindenchantments.config.legacy.v1; | ||
|
||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import de.mschae23.grindenchantments.config.DisenchantConfig; | ||
import de.mschae23.grindenchantments.cost.CostFunction; | ||
|
||
@Deprecated | ||
public record DisenchantConfigV1(boolean enabled, boolean consumeItem, CostFunction costFunction) { | ||
public static final Codec<DisenchantConfigV1> CODEC = RecordCodecBuilder.create(instance -> instance.group( | ||
Codec.BOOL.fieldOf("enabled").forGetter(DisenchantConfigV1::enabled), | ||
Codec.BOOL.fieldOf("consume_enchanted_item").forGetter(DisenchantConfigV1::consumeItem), | ||
CostFunction.TYPE_CODEC.fieldOf("cost_config").forGetter(DisenchantConfigV1::costFunction) | ||
).apply(instance, instance.stable(DisenchantConfigV1::new))); | ||
|
||
public DisenchantConfig latest() { | ||
return new DisenchantConfig(this.enabled, this.consumeItem, this.costFunction); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/main/java/de/mschae23/grindenchantments/config/legacy/v1/GrindEnchantmentsConfigV1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (C) 2024 mschae23 | ||
* | ||
* This file is part of Grind enchantments. | ||
* | ||
* Grind enchantments is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.mschae23.grindenchantments.config.legacy.v1; | ||
|
||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.MapCodec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import de.mschae23.config.api.ModConfig; | ||
import de.mschae23.grindenchantments.config.legacy.ClientConfig; | ||
import de.mschae23.grindenchantments.config.legacy.DedicatedServerConfig; | ||
import de.mschae23.grindenchantments.config.legacy.v2.GrindEnchantmentsConfigV2; | ||
import de.mschae23.grindenchantments.config.legacy.GrindEnchantmentsConfigV3; | ||
|
||
@Deprecated | ||
@SuppressWarnings("DeprecatedIsStillUsed") | ||
public record GrindEnchantmentsConfigV1(de.mschae23.grindenchantments.config.legacy.v1.DisenchantConfigV1 disenchant, MoveConfigV1 move, boolean allowCurses, | ||
DedicatedServerConfig dedicatedServerConfig, ClientConfig clientConfig) implements ModConfig<GrindEnchantmentsConfigV3> { | ||
public static final MapCodec<GrindEnchantmentsConfigV1> TYPE_CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( | ||
DisenchantConfigV1.CODEC.fieldOf("disenchant_to_book").forGetter(GrindEnchantmentsConfigV1::disenchant), | ||
MoveConfigV1.CODEC.fieldOf("move_enchantments").forGetter(GrindEnchantmentsConfigV1::move), | ||
Codec.BOOL.orElse(Boolean.FALSE).fieldOf("allow_removing_curses").forGetter(GrindEnchantmentsConfigV1::allowCurses), | ||
DedicatedServerConfig.CODEC.orElse(DedicatedServerConfig.DEFAULT).fieldOf("dedicated_server_options").forGetter(GrindEnchantmentsConfigV1::dedicatedServerConfig), | ||
ClientConfig.CODEC.fieldOf("client_options").forGetter(GrindEnchantmentsConfigV1::clientConfig) | ||
).apply(instance, instance.stable(GrindEnchantmentsConfigV1::new))); | ||
|
||
public static final Type<GrindEnchantmentsConfigV3, GrindEnchantmentsConfigV1> TYPE = new Type<>(1, TYPE_CODEC); | ||
|
||
@Override | ||
public Type<GrindEnchantmentsConfigV3, ?> type() { | ||
return TYPE; | ||
} | ||
|
||
@Override | ||
public GrindEnchantmentsConfigV3 latest() { | ||
return new GrindEnchantmentsConfigV2(this.disenchant.latest(), this.move.latest(), this.allowCurses, this.dedicatedServerConfig, this.clientConfig).latest(); | ||
} | ||
|
||
@Override | ||
public boolean shouldUpdate() { | ||
return true; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/de/mschae23/grindenchantments/config/legacy/v1/MoveConfigV1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (C) 2024 mschae23 | ||
* | ||
* This file is part of Grind enchantments. | ||
* | ||
* Grind enchantments is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.mschae23.grindenchantments.config.legacy.v1; | ||
|
||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import de.mschae23.grindenchantments.config.MoveConfig; | ||
import de.mschae23.grindenchantments.cost.CostFunction; | ||
|
||
@Deprecated | ||
public record MoveConfigV1(boolean enabled, CostFunction costFunction) { | ||
public static final Codec<MoveConfigV1> CODEC = RecordCodecBuilder.create(instance -> instance.group( | ||
Codec.BOOL.fieldOf("enabled").forGetter(MoveConfigV1::enabled), | ||
CostFunction.TYPE_CODEC.fieldOf("cost_config").forGetter(MoveConfigV1::costFunction) | ||
).apply(instance, instance.stable(MoveConfigV1::new))); | ||
|
||
public MoveConfig latest() { | ||
return new MoveConfig(this.enabled, this.costFunction); | ||
} | ||
} |
Oops, something went wrong.