generated from FabricMC/fabric-example-mod
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from misode/fake-players
Dummy players
- Loading branch information
Showing
16 changed files
with
685 additions
and
37 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
5 changes: 5 additions & 0 deletions
5
src/main/java/io/github/misode/packtest/PackTestPlayerName.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,5 @@ | ||
package io.github.misode.packtest; | ||
|
||
public interface PackTestPlayerName { | ||
String packtest$getPlayerName(); | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/io/github/misode/packtest/commands/DirectionArgument.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,45 @@ | ||
package io.github.misode.packtest.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 net.minecraft.commands.CommandSourceStack; | ||
import net.minecraft.commands.SharedSuggestionProvider; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.network.chat.Component; | ||
|
||
import java.util.Arrays; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class DirectionArgument implements ArgumentType<Direction> { | ||
private static final DynamicCommandExceptionType ERROR_UNKNOWN_DIRECTION = new DynamicCommandExceptionType( | ||
dir -> Component.literal("Unknown direction " + dir) | ||
); | ||
|
||
public static DirectionArgument direction() { | ||
return new DirectionArgument(); | ||
} | ||
|
||
public static Direction getDirection(CommandContext<CommandSourceStack> ctx, String name) { | ||
return ctx.getArgument(name, Direction.class); | ||
} | ||
|
||
@Override | ||
public Direction parse(StringReader reader) throws CommandSyntaxException { | ||
String str = reader.readUnquotedString(); | ||
Direction direction = Direction.byName(str); | ||
if (direction == null) { | ||
throw ERROR_UNKNOWN_DIRECTION.create(str); | ||
} | ||
return direction; | ||
} | ||
|
||
@Override | ||
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> ctx, SuggestionsBuilder builder) { | ||
return SharedSuggestionProvider.suggest(Arrays.stream(Direction.values()).map(Direction::getName), builder); | ||
} | ||
} |
Oops, something went wrong.