-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
90 additions
and
29 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
27 changes: 27 additions & 0 deletions
27
common/src/main/java/sereneseasons/command/SeasonArgument.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,27 @@ | ||
/******************************************************************************* | ||
* Copyright 2024, the Glitchfiend Team. | ||
* All rights reserved. | ||
******************************************************************************/ | ||
package sereneseasons.command; | ||
|
||
import com.mojang.brigadier.context.CommandContext; | ||
import net.minecraft.commands.CommandSourceStack; | ||
import net.minecraft.commands.arguments.StringRepresentableArgument; | ||
import sereneseasons.api.season.Season; | ||
|
||
public class SeasonArgument extends StringRepresentableArgument<Season.SubSeason> | ||
{ | ||
private SeasonArgument() { | ||
super(Season.SubSeason.CODEC, Season.SubSeason::values); | ||
} | ||
|
||
public static StringRepresentableArgument<Season.SubSeason> season() | ||
{ | ||
return new SeasonArgument(); | ||
} | ||
|
||
public static Season.SubSeason getSeason(CommandContext<CommandSourceStack> context, String s) { | ||
return context.getArgument(s, Season.SubSeason.class); | ||
} | ||
} | ||
|
39 changes: 39 additions & 0 deletions
39
common/src/main/java/sereneseasons/command/SeasonCommands.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,39 @@ | ||
package sereneseasons.command; | ||
|
||
import com.mojang.brigadier.builder.LiteralArgumentBuilder; | ||
import glitchcore.event.server.RegisterCommandsEvent; | ||
import net.minecraft.commands.CommandSourceStack; | ||
import net.minecraft.commands.arguments.TemplateMirrorArgument; | ||
import net.minecraft.commands.synchronization.ArgumentTypeInfo; | ||
import net.minecraft.commands.synchronization.ArgumentTypeInfos; | ||
import net.minecraft.commands.synchronization.SingletonArgumentInfo; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.level.block.Block; | ||
import sereneseasons.core.SereneSeasons; | ||
|
||
import java.util.function.BiConsumer; | ||
|
||
public class SeasonCommands | ||
{ | ||
public static void onRegisterCommands(RegisterCommandsEvent event) | ||
{ | ||
event.getDispatcher().register( | ||
LiteralArgumentBuilder.<CommandSourceStack>literal("season") | ||
.requires(cs -> cs.hasPermission(2)) | ||
.then(CommandSetSeason.register()) | ||
.then(CommandGetSeason.register()) | ||
); | ||
} | ||
|
||
public static void registerArguments(BiConsumer<ResourceLocation, ArgumentTypeInfo<?, ?>> func) | ||
{ | ||
register(func, "season", SeasonArgument.class, SingletonArgumentInfo.contextFree(SeasonArgument::season)); | ||
} | ||
|
||
private static ArgumentTypeInfo<?, ?> register(BiConsumer<ResourceLocation, ArgumentTypeInfo<?, ?>> func, String name, Class<?> clazz, ArgumentTypeInfo<?, ?> typeInfo) | ||
{ | ||
func.accept(new ResourceLocation(SereneSeasons.MOD_ID, name), typeInfo); | ||
ArgumentTypeInfos.BY_CLASS.put(clazz, typeInfo); | ||
return typeInfo; | ||
} | ||
} |
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
22 changes: 0 additions & 22 deletions
22
forge/src/main/java/sereneseasons/forge/command/SeasonCommands.java
This file was deleted.
Oops, something went wrong.
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