Skip to content

Commit ff57ef3

Browse files
committed
Log message when tp player.
1 parent 17ce981 commit ff57ef3

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

src/main/java/io/github/optijava/opt_carpet_addition/OptCarpetAddition.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
public class OptCarpetAddition implements CarpetExtension, ModInitializer {
1919
public static final Logger LOGGER = CarpetSettings.LOG;
2020

21+
public static final OptCarpetAddition additionInstance = new OptCarpetAddition();
22+
2123
@Override
2224
public void onInitialize() {
23-
CarpetServer.manageExtension(new OptCarpetAddition());
25+
CarpetServer.manageExtension(additionInstance);
2426
}
2527

2628
@Override

src/main/java/io/github/optijava/opt_carpet_addition/command/ListAdvanceCommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
public class ListAdvanceCommand {
1515
private ListAdvanceCommand() {
16-
16+
1717
}
1818

1919
public static void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher) {
@@ -33,6 +33,7 @@ public static int listAdvance(CommandContext<ServerCommandSource> context) {
3333
context.getSource().sendFeedback(new LiteralText(sb.toString()), false);
3434
} catch (Exception e) {
3535
context.getSource().sendError(new LiteralText("Unexpected exception occurred when command list advance executed."));
36+
OptCarpetAddition.LOGGER.error("Unexpected exception occurred when command list advance executed.", e);
3637
return 0;
3738
}
3839
return 1;

src/main/java/io/github/optijava/opt_carpet_addition/command/PlayerTpCommand.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
1010
import com.mojang.brigadier.context.CommandContext;
1111
import com.mojang.brigadier.exceptions.CommandSyntaxException;
12+
import io.github.optijava.opt_carpet_addition.OptCarpetAddition;
1213
import io.github.optijava.opt_carpet_addition.OptCarpetSettings;
1314
import net.minecraft.server.MinecraftServer;
1415
import net.minecraft.server.command.ServerCommandSource;
@@ -44,6 +45,8 @@ private static int teleport(CommandContext<ServerCommandSource> context) {
4445
try {
4546
final String commandSourcePlayerName = context.getSource().getPlayer().getGameProfile().getName();
4647

48+
OptCarpetAddition.LOGGER.info(commandSourcePlayerName + " submit command: /player " + StringArgumentType.getString(context, COMMAND_PREFIX) + " tp");
49+
4750
if (server.getPlayerManager().getPlayer(StringArgumentType.getString(context, COMMAND_PREFIX)) instanceof EntityPlayerMPFake) {
4851
if (OptCarpetSettings.commandTpToFakePlayer.equals("true")) {
4952
server.getCommandManager().execute(server.getCommandSource(), "tp " + commandSourcePlayerName + " " + StringArgumentType.getString(context, "player"));
@@ -93,6 +96,8 @@ private static int teleportHere(CommandContext<ServerCommandSource> context) {
9396
try {
9497
final String commandSourcePlayerName = context.getSource().getPlayer().getGameProfile().getName();
9598

99+
OptCarpetAddition.LOGGER.info(commandSourcePlayerName + " submit command: /player " + StringArgumentType.getString(context, COMMAND_PREFIX) + " tphere");
100+
96101
if (server.getPlayerManager().getPlayer(StringArgumentType.getString(context, COMMAND_PREFIX)) instanceof EntityPlayerMPFake) {
97102
if (OptCarpetSettings.commandTpHereFakePlayer.equals("true")) {
98103
server.getCommandManager().execute(server.getCommandSource(), "tp " + StringArgumentType.getString(context, COMMAND_PREFIX) + " " + commandSourcePlayerName);
@@ -122,7 +127,7 @@ private static int teleportHere(CommandContext<ServerCommandSource> context) {
122127

123128
} catch (CommandSyntaxException e) {
124129
Messenger.m(context.getSource(), "r Unknown error occurred when execute command : com.mojang.brigadier.exceptions.CommandSyntaxException");
125-
e.printStackTrace();
130+
OptCarpetAddition.LOGGER.error("Unknown error occurred when execute command.", e);
126131
}
127132
return 1;
128133
}

0 commit comments

Comments
 (0)