forked from ChomeNS/chipmunkmod
Text i guess
This commit is contained in:
parent
54c3c4add1
commit
60a1074759
3 changed files with 5 additions and 32 deletions
|
@ -1,25 +0,0 @@
|
||||||
package land.chipmunk.chipmunkmod.command;
|
|
||||||
|
|
||||||
import com.mojang.brigadier.Message;
|
|
||||||
import lombok.Getter;
|
|
||||||
import net.minecraft.text.Text;
|
|
||||||
|
|
||||||
public class TextMessage implements Message {
|
|
||||||
@Getter private final Text text;
|
|
||||||
|
|
||||||
private TextMessage(Text text) {
|
|
||||||
this.text = text;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TextMessage wrap (Text text) {
|
|
||||||
return new TextMessage(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getString () {
|
|
||||||
return text.getString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString () {
|
|
||||||
return text.toString();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,7 +5,6 @@ import com.mojang.brigadier.arguments.ArgumentType;
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||||
import land.chipmunk.chipmunkmod.command.TextMessage;
|
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
@ -17,7 +16,7 @@ import java.util.Collection;
|
||||||
public class LocationArgumentType implements ArgumentType<Object> {
|
public class LocationArgumentType implements ArgumentType<Object> {
|
||||||
private static final Collection<String> EXAMPLES = Arrays.<String>asList("songs/amogus.mid", "images/cat.jpg", "videos/badapple.mp4");
|
private static final Collection<String> EXAMPLES = Arrays.<String>asList("songs/amogus.mid", "images/cat.jpg", "videos/badapple.mp4");
|
||||||
|
|
||||||
private static final SimpleCommandExceptionType OOB_FILEPATH = new SimpleCommandExceptionType(TextMessage.wrap(Text.translatable("The specified file path is outside of the allowed directory")));
|
private static final SimpleCommandExceptionType OOB_FILEPATH = new SimpleCommandExceptionType(Text.translatable("The specified file path is outside of the allowed directory"));
|
||||||
|
|
||||||
private boolean allowsUrls = false;
|
private boolean allowsUrls = false;
|
||||||
private boolean allowsPaths = false;
|
private boolean allowsPaths = false;
|
||||||
|
@ -52,7 +51,7 @@ public class LocationArgumentType implements ArgumentType<Object> {
|
||||||
try {
|
try {
|
||||||
return new URL(sb.toString());
|
return new URL(sb.toString());
|
||||||
} catch (MalformedURLException exception) {
|
} catch (MalformedURLException exception) {
|
||||||
throw new SimpleCommandExceptionType(TextMessage.wrap(Text.literal(exception.getMessage()))).create();
|
throw new SimpleCommandExceptionType(Text.literal(exception.getMessage())).create();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import com.mojang.brigadier.context.CommandContext;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||||
import land.chipmunk.chipmunkmod.command.CommandManager;
|
import land.chipmunk.chipmunkmod.command.CommandManager;
|
||||||
import land.chipmunk.chipmunkmod.command.TextMessage;
|
|
||||||
import land.chipmunk.chipmunkmod.modules.SongPlayer;
|
import land.chipmunk.chipmunkmod.modules.SongPlayer;
|
||||||
import land.chipmunk.chipmunkmod.song.Song;
|
import land.chipmunk.chipmunkmod.song.Song;
|
||||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||||
|
@ -34,9 +33,9 @@ import static land.chipmunk.chipmunkmod.command.arguments.LocationArgumentType.*
|
||||||
import static land.chipmunk.chipmunkmod.command.arguments.TimestampArgumentType.timestamp;
|
import static land.chipmunk.chipmunkmod.command.arguments.TimestampArgumentType.timestamp;
|
||||||
|
|
||||||
public class MusicCommand {
|
public class MusicCommand {
|
||||||
private static final SimpleCommandExceptionType NO_SONG_IS_CURRENTLY_PLAYING = new SimpleCommandExceptionType(TextMessage.wrap(Text.translatable("No song is currently playing")));
|
private static final SimpleCommandExceptionType NO_SONG_IS_CURRENTLY_PLAYING = new SimpleCommandExceptionType(Text.translatable("No song is currently playing"));
|
||||||
private static final SimpleCommandExceptionType OOB_TIMESTAMP = new SimpleCommandExceptionType(TextMessage.wrap(Text.translatable("Invalid timestamp for the current song")));
|
private static final SimpleCommandExceptionType OOB_TIMESTAMP = new SimpleCommandExceptionType(Text.translatable("Invalid timestamp for the current song"));
|
||||||
private static final SimpleCommandExceptionType DIRECTORY_DOES_NOT_EXIST = new SimpleCommandExceptionType(TextMessage.wrap(Text.translatable("The specified directory does not exist")));
|
private static final SimpleCommandExceptionType DIRECTORY_DOES_NOT_EXIST = new SimpleCommandExceptionType(Text.translatable("The specified directory does not exist"));
|
||||||
|
|
||||||
public static void register (CommandDispatcher<FabricClientCommandSource> dispatcher) {
|
public static void register (CommandDispatcher<FabricClientCommandSource> dispatcher) {
|
||||||
final MusicCommand instance = new MusicCommand();
|
final MusicCommand instance = new MusicCommand();
|
||||||
|
|
Loading…
Reference in a new issue