-
Notifications
You must be signed in to change notification settings - Fork 0
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
a84774e
commit 15a11d2
Showing
17 changed files
with
160 additions
and
26 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
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
49 changes: 49 additions & 0 deletions
49
...c/src/main/java/ca/sperrer/p0t4t0sandwich/lppronouns/fabric/commands/PronounsCommand.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 ca.sperrer.p0t4t0sandwich.lppronouns.fabric.commands; | ||
|
||
import ca.sperrer.p0t4t0sandwich.lppronouns.fabric.FabricMain; | ||
import com.mojang.brigadier.CommandDispatcher; | ||
import com.mojang.brigadier.arguments.StringArgumentType; | ||
import net.minecraft.command.CommandRegistryAccess; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.server.command.CommandManager.RegistrationEnvironment; | ||
import net.minecraft.server.command.ServerCommandSource; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.text.Text; | ||
|
||
import static ca.sperrer.p0t4t0sandwich.lppronouns.common.Utils.ansiiParser; | ||
import static ca.sperrer.p0t4t0sandwich.lppronouns.common.Utils.runTaskAsync; | ||
import static ca.sperrer.p0t4t0sandwich.lppronouns.fabric.FabricUtils.mapPlayer; | ||
import static net.minecraft.server.command.CommandManager.argument; | ||
import static net.minecraft.server.command.CommandManager.literal; | ||
|
||
|
||
public final class PronounsCommand { | ||
private static final FabricMain mod = FabricMain.getInstance(); | ||
|
||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess, RegistrationEnvironment environment) { | ||
dispatcher.register(literal("pronouns") | ||
.requires(source -> source.hasPermissionLevel(0)) | ||
.then(argument("pronouns", StringArgumentType.greedyString()) | ||
.executes(context -> { | ||
runTaskAsync(() -> { | ||
try { | ||
String[] args = new String[] {context.getArgument("pronouns", String.class)}; | ||
|
||
// Send message to player or console | ||
Entity entity = context.getSource().getEntity(); | ||
if (entity instanceof ServerPlayerEntity) { | ||
String text = mod.LPPronouns.commandHandler(mapPlayer((ServerPlayerEntity) entity), args); | ||
entity.sendMessage(Text.literal(text)); | ||
} else { | ||
mod.logger.info(ansiiParser("§cYou must be a player to use this command.")); | ||
} | ||
} catch (Exception e) { | ||
System.err.println(e); | ||
e.printStackTrace(); | ||
} | ||
}); | ||
return 1; | ||
}) | ||
)); | ||
} | ||
} |
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
48 changes: 48 additions & 0 deletions
48
forge/src/main/java/ca/sperrer/p0t4t0sandwich/lppronouns/forge/commands/PronounsCommand.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 ca.sperrer.p0t4t0sandwich.lppronouns.forge.commands; | ||
|
||
import ca.sperrer.p0t4t0sandwich.lppronouns.forge.ForgeMain; | ||
import com.mojang.brigadier.arguments.StringArgumentType; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraftforge.event.RegisterCommandsEvent; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
|
||
import static ca.sperrer.p0t4t0sandwich.lppronouns.common.Utils.ansiiParser; | ||
import static ca.sperrer.p0t4t0sandwich.lppronouns.common.Utils.runTaskAsync; | ||
import static ca.sperrer.p0t4t0sandwich.lppronouns.forge.ForgeUtils.mapPlayer; | ||
import static net.minecraft.commands.Commands.argument; | ||
import static net.minecraft.commands.Commands.literal; | ||
|
||
|
||
public final class PronounsCommand { | ||
private static final ForgeMain mod = ForgeMain.getInstance(); | ||
|
||
@SubscribeEvent | ||
public static void registerCommand(RegisterCommandsEvent event) { | ||
event.getDispatcher().register(literal("pronouns") | ||
.requires(source -> source.hasPermission(0)) | ||
.then(argument("pronouns", StringArgumentType.greedyString()) | ||
.executes(context -> { | ||
runTaskAsync(() -> { | ||
try { | ||
String[] args = new String[] {context.getArgument("pronouns", String.class)}; | ||
|
||
// Send message to player or console | ||
Entity entity = context.getSource().getEntity(); | ||
if (entity instanceof ServerPlayer) { | ||
String text = mod.LPPronouns.commandHandler(mapPlayer((ServerPlayer) entity), args); | ||
((ServerPlayer) entity).displayClientMessage(Component.empty().append(text), false); | ||
} else { | ||
mod.logger.info(ansiiParser("§cYou must be a player to use this command.")); | ||
} | ||
} catch (Exception e) { | ||
System.err.println(e); | ||
e.printStackTrace(); | ||
} | ||
}); | ||
return 1; | ||
}) | ||
)); | ||
} | ||
} |
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