-
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.
- Loading branch information
1 parent
2ea822c
commit c3ca5fe
Showing
7 changed files
with
170 additions
and
8 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
45 changes: 45 additions & 0 deletions
45
src/main/java/io/github/itzispyder/funnysentences/commands/Command.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.itzispyder.funnysentences.commands; | ||
|
||
import com.mojang.brigadier.CommandDispatcher; | ||
import com.mojang.brigadier.arguments.ArgumentType; | ||
import com.mojang.brigadier.builder.LiteralArgumentBuilder; | ||
import com.mojang.brigadier.builder.RequiredArgumentBuilder; | ||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; | ||
import net.minecraft.command.CommandRegistryAccess; | ||
|
||
/** | ||
* Command | ||
*/ | ||
public abstract class Command { | ||
|
||
public static final int SINGLE_SUCCESS = 1; | ||
public static final int COMMAND_FAIL = -1; | ||
public static final int COMMAND_PASS = 0; | ||
|
||
/** | ||
* On command run | ||
* @param dispatcher command dispatcher | ||
* @param access accessor | ||
*/ | ||
public abstract void onCommand(CommandDispatcher<FabricClientCommandSource> dispatcher, CommandRegistryAccess access); | ||
|
||
/** | ||
* Command literal argument builder | ||
* @param name name | ||
* @return argument builder | ||
*/ | ||
public static LiteralArgumentBuilder<FabricClientCommandSource> literal(String name) { | ||
return LiteralArgumentBuilder.literal(name); | ||
} | ||
|
||
/** | ||
* Command required argument builder | ||
* @param name name | ||
* @param type argument type | ||
* @return argument builder | ||
* @param <T> argument object | ||
*/ | ||
public static <T> RequiredArgumentBuilder<FabricClientCommandSource,T> argument(String name, ArgumentType<T> type) { | ||
return RequiredArgumentBuilder.argument(name, type); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/io/github/itzispyder/funnysentences/commands/Commands.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,19 @@ | ||
package io.github.itzispyder.funnysentences.commands; | ||
|
||
import io.github.itzispyder.funnysentences.commands.commands.SentenceCommand; | ||
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; | ||
import net.fabricmc.fabric.api.event.Event; | ||
|
||
/** | ||
* Commands registry | ||
*/ | ||
public abstract class Commands { | ||
|
||
/** | ||
* Registers all the commands from this mod | ||
*/ | ||
public static void registerAll() { | ||
Event<ClientCommandRegistrationCallback> cmd = ClientCommandRegistrationCallback.EVENT; | ||
cmd.register(new SentenceCommand()::onCommand); | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
src/main/java/io/github/itzispyder/funnysentences/commands/commands/SentenceCommand.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,91 @@ | ||
package io.github.itzispyder.funnysentences.commands.commands; | ||
|
||
import com.mojang.brigadier.CommandDispatcher; | ||
import com.mojang.brigadier.arguments.IntegerArgumentType; | ||
import com.mojang.brigadier.arguments.StringArgumentType; | ||
import io.github.itzispyder.funnysentences.commands.Command; | ||
import io.github.itzispyder.funnysentences.data.sentences.SentenceConstructor; | ||
import io.github.itzispyder.funnysentences.data.sentences.SentenceFeature; | ||
import io.github.itzispyder.funnysentences.data.sentences.SentenceGenerator; | ||
import io.github.itzispyder.funnysentences.util.ChatUtils; | ||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; | ||
import net.minecraft.command.CommandRegistryAccess; | ||
|
||
import static io.github.itzispyder.funnysentences.FunnySentences.starter; | ||
|
||
public class SentenceCommand extends Command { | ||
|
||
@Override | ||
public void onCommand(CommandDispatcher<FabricClientCommandSource> dispatcher, CommandRegistryAccess access) { | ||
// fs | ||
dispatcher.register(literal("fs").executes(cxt -> { | ||
SentenceFeature feature = new SentenceFeature(); | ||
String sentence = SentenceConstructor.generate(SentenceGenerator.NORMAL,feature); | ||
ChatUtils.sendChatMessage(sentence); | ||
return SINGLE_SUCCESS; | ||
})); | ||
for (SentenceGenerator gen : SentenceGenerator.values()) { | ||
// fs <type> | ||
dispatcher.register(literal("fs").then(literal(gen.name().toLowerCase()).executes(cxt -> { | ||
SentenceFeature feature = new SentenceFeature(); | ||
String sentence = SentenceConstructor.generate(gen, feature); | ||
ChatUtils.sendChatMessage(sentence); | ||
return SINGLE_SUCCESS; | ||
}))); | ||
// fs <type> spam <times> | ||
dispatcher.register(literal("fs").then(literal(gen.name().toLowerCase()).then(literal("spam").then(argument("times", IntegerArgumentType.integer()).executes(cxt -> { | ||
int times = cxt.getArgument("times",Integer.class); | ||
SentenceFeature feature = new SentenceFeature(); | ||
for (int i = 0; i < times; i++) { | ||
String sentence = SentenceConstructor.generate(gen, feature); | ||
ChatUtils.sendChatMessage(sentence); | ||
} | ||
return SINGLE_SUCCESS; | ||
}))))); | ||
// fs <type> words <count> | ||
dispatcher.register(literal("fs").then(literal(gen.name().toLowerCase()).then(literal("words").then(argument("count", IntegerArgumentType.integer()).executes(cxt -> { | ||
int count = cxt.getArgument("count",Integer.class); | ||
SentenceFeature feature = new SentenceFeature(); | ||
feature.setWordCount(count); | ||
String sentence = SentenceConstructor.generate(gen, feature); | ||
ChatUtils.sendChatMessage(sentence); | ||
return SINGLE_SUCCESS; | ||
}))))); | ||
// fs <type> words <count> spam <times> | ||
dispatcher.register(literal("fs").then(literal(gen.name().toLowerCase()).then(literal("words").then(argument("count", IntegerArgumentType.integer()).then(literal("spam").then(argument("times",IntegerArgumentType.integer()).executes(cxt -> { | ||
int count = cxt.getArgument("count",Integer.class); | ||
int times = cxt.getArgument("times",Integer.class); | ||
SentenceFeature feature = new SentenceFeature(); | ||
feature.setWordCount(count); | ||
for (int i = 0; i < times; i++) { | ||
String sentence = SentenceConstructor.generate(gen, feature); | ||
ChatUtils.sendChatMessage(sentence); | ||
} | ||
return SINGLE_SUCCESS; | ||
}))))))); | ||
} | ||
// fs spam <times> | ||
dispatcher.register(literal("fs").then(literal("spam").then(argument("times",IntegerArgumentType.integer()).then(argument("message", StringArgumentType.greedyString()).executes(cxt -> { | ||
int times = cxt.getArgument("times",Integer.class); | ||
String message = cxt.getArgument("message",String.class); | ||
for (int i = 0; i < times; i++) ChatUtils.sendChatMessage(message); | ||
return SINGLE_SUCCESS; | ||
}))))); | ||
// fs help | ||
dispatcher.register(literal("fs").then(literal("help").executes(cxt -> { | ||
ChatUtils.sendMessage( | ||
"", | ||
starter + "§bThe Ultimate Chat Spam Troll", | ||
" §f/fs §8| §7Send random sentence", | ||
" §f/fs §e<type> §8| §7Sends sentences", | ||
" §f/fs §e<type> §fspam §e<times> §8| §7Spams sentences", | ||
" §f/fs §e<type> §fword §e<amount> §8| §7Sends sentences with custom word count", | ||
" §f/fs §e<type> §fword §e<amount> §fspam §e<times> §8| §7Spams sentences with custom word count", | ||
" §f/fs spam §e<times> <message> §8| §7Spams custom message", | ||
" §f/fs help §8| §7Command help", | ||
"" | ||
); | ||
return SINGLE_SUCCESS; | ||
}))); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
public enum SentenceGenerator { | ||
|
||
NORMAL, | ||
UNICODE_SPAM, | ||
LETTER_SPAM, | ||
EMOJI_SPAM | ||
UNICODE, | ||
RAGE, | ||
EMOJI | ||
} |
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