-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more commands, need to list devices and create configuration card next
- Loading branch information
Showing
25 changed files
with
720 additions
and
99 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
common/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// 1.20.2 2024-07-20T12:53:36.9764242 Languages: en_us | ||
e3979f69d6f26453fdf1227dc1d640cc4143c3ff assets/theatrical/lang/en_us.json | ||
// 1.20.2 2024-07-29T23:11:39.1659592 Languages: en_us | ||
51f24e3b8b2d0667dec3cce6b38b13b241264dc8 assets/theatrical/lang/en_us.json |
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
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
15 changes: 15 additions & 0 deletions
15
common/src/main/java/dev/imabad/theatrical/commands/CommandArguments.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,15 @@ | ||
package dev.imabad.theatrical.commands; | ||
|
||
import dev.architectury.registry.registries.DeferredRegister; | ||
import dev.architectury.registry.registries.RegistrySupplier; | ||
import dev.imabad.theatrical.TheatricalRegistry; | ||
import net.minecraft.commands.synchronization.ArgumentTypeInfo; | ||
import net.minecraft.commands.synchronization.SingletonArgumentInfo; | ||
import net.minecraft.core.registries.Registries; | ||
|
||
public class CommandArguments { | ||
|
||
public static final DeferredRegister<ArgumentTypeInfo<?, ?>> ARGUMENTS = TheatricalRegistry.get(Registries.COMMAND_ARGUMENT_TYPE); | ||
|
||
public static final RegistrySupplier<ArgumentTypeInfo<DMXNetworkModeArgument, ?>> NETWORK_MODE = ARGUMENTS.register("network_mode", () -> SingletonArgumentInfo.contextFree(DMXNetworkModeArgument::networkMode)); | ||
} |
48 changes: 48 additions & 0 deletions
48
common/src/main/java/dev/imabad/theatrical/commands/DMXNetworkModeArgument.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,48 @@ | ||
package dev.imabad.theatrical.commands; | ||
|
||
import com.mojang.brigadier.StringReader; | ||
import com.mojang.brigadier.arguments.ArgumentType; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; | ||
import com.mojang.brigadier.suggestion.Suggestions; | ||
import com.mojang.brigadier.suggestion.SuggestionsBuilder; | ||
import dev.imabad.theatrical.dmx.DMXNetworkMode; | ||
import net.minecraft.commands.CommandSourceStack; | ||
import net.minecraft.commands.SharedSuggestionProvider; | ||
import net.minecraft.network.chat.Component; | ||
|
||
import java.util.Arrays; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class DMXNetworkModeArgument implements ArgumentType<DMXNetworkMode> { | ||
private static final DynamicCommandExceptionType ERROR_INVALID = new DynamicCommandExceptionType( | ||
object -> Component.translatable("commands.network.invalid", object) | ||
); | ||
private static final DMXNetworkMode[] VALUES = DMXNetworkMode.values(); | ||
|
||
@Override | ||
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> commandContext, SuggestionsBuilder suggestionsBuilder) { | ||
return commandContext.getSource() instanceof SharedSuggestionProvider | ||
? SharedSuggestionProvider.suggest(Arrays.stream(VALUES).map(DMXNetworkMode::getName), suggestionsBuilder) | ||
: Suggestions.empty(); | ||
} | ||
|
||
@Override | ||
public DMXNetworkMode parse(StringReader reader) throws CommandSyntaxException { | ||
String string = reader.readUnquotedString(); | ||
DMXNetworkMode networkMode = DMXNetworkMode.byName(string); | ||
if (networkMode == null) { | ||
throw ERROR_INVALID.createWithContext(reader, string); | ||
} else { | ||
return networkMode; | ||
} | ||
} | ||
|
||
public static DMXNetworkModeArgument networkMode() { | ||
return new DMXNetworkModeArgument(); | ||
} | ||
public static DMXNetworkMode getMode(CommandContext<CommandSourceStack> context, String name) { | ||
return context.getArgument(name, DMXNetworkMode.class); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
common/src/main/java/dev/imabad/theatrical/commands/MemberRoleArgument.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,49 @@ | ||
package dev.imabad.theatrical.commands; | ||
|
||
import com.mojang.brigadier.StringReader; | ||
import com.mojang.brigadier.arguments.ArgumentType; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; | ||
import com.mojang.brigadier.suggestion.Suggestions; | ||
import com.mojang.brigadier.suggestion.SuggestionsBuilder; | ||
import dev.imabad.theatrical.dmx.DMXNetworkMemberRole; | ||
import dev.imabad.theatrical.dmx.DMXNetworkMode; | ||
import net.minecraft.commands.CommandSourceStack; | ||
import net.minecraft.commands.SharedSuggestionProvider; | ||
import net.minecraft.network.chat.Component; | ||
|
||
import java.util.Arrays; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class MemberRoleArgument implements ArgumentType<DMXNetworkMemberRole> { | ||
private static final DynamicCommandExceptionType ERROR_INVALID = new DynamicCommandExceptionType( | ||
object -> Component.translatable("commands.network.role.invalid", object) | ||
); | ||
private static final DMXNetworkMemberRole[] VALUES = DMXNetworkMemberRole.values(); | ||
|
||
@Override | ||
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> commandContext, SuggestionsBuilder suggestionsBuilder) { | ||
return commandContext.getSource() instanceof SharedSuggestionProvider | ||
? SharedSuggestionProvider.suggest(Arrays.stream(VALUES).map(DMXNetworkMemberRole::getName), suggestionsBuilder) | ||
: Suggestions.empty(); | ||
} | ||
|
||
@Override | ||
public DMXNetworkMemberRole parse(StringReader reader) throws CommandSyntaxException { | ||
String string = reader.readUnquotedString(); | ||
DMXNetworkMemberRole networkMode = DMXNetworkMemberRole.byName(string); | ||
if (networkMode == null) { | ||
throw ERROR_INVALID.createWithContext(reader, string); | ||
} else { | ||
return networkMode; | ||
} | ||
} | ||
|
||
public static MemberRoleArgument memberRole() { | ||
return new MemberRoleArgument(); | ||
} | ||
public static DMXNetworkMemberRole getMode(CommandContext<CommandSourceStack> context, String name) { | ||
return context.getArgument(name, DMXNetworkMemberRole.class); | ||
} | ||
} |
Oops, something went wrong.