Skip to content

Commit 0a80203

Browse files
committed
0.3.1
Updated Yarn, changed logging, added ability to clear speedrunner, log warnings if speedrunner is null.
1 parent 93cfa55 commit 0a80203

File tree

4 files changed

+53
-23
lines changed

4 files changed

+53
-23
lines changed

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ org.gradle.jvmargs = -Xmx1G
22

33
#Fabric properties
44
minecraft_version = 1.16.3
5-
yarn_mappings = 1.16.3+build.45
5+
yarn_mappings = 1.16.3+build.46
66
loader_version = 0.10.1+build.209
77

88
#Mod properties
9-
mod_version = 0.3.0
9+
mod_version = 0.3.1
1010
maven_group = com.ytg123
1111
archives_base_name = manhunt
1212

src/main/java/com/ytg123/manhunt/Manhunt.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,19 @@
66
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
77
import me.sargunvohra.mcmods.autoconfig1u.serializer.JanksonConfigSerializer;
88
import net.fabricmc.api.ModInitializer;
9-
109
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
1110
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
1211
import org.apache.logging.log4j.Level;
1312
import org.apache.logging.log4j.LogManager;
1413
import org.apache.logging.log4j.Logger;
1514

1615
public class Manhunt implements ModInitializer {
17-
public static Logger LOGGER = LogManager.getLogger();
18-
1916
public static final String MOD_ID = "manhunt";
2017
public static final String MOD_NAME = "Manhunt Fabric";
2118
public static ManhuntConfig CONFIG;
2219

20+
public static Logger LOGGER = LogManager.getLogger(MOD_NAME);
21+
2322
/**
2423
* Initializes the mod.
2524
*/
@@ -39,10 +38,11 @@ public void onInitialize() {
3938

4039
/**
4140
* Logs a message to the console.
42-
* @param level The log level
41+
*
42+
* @param level The log level
4343
* @param message The message being logged
4444
*/
45-
public static void log(Level level, String message){
46-
LOGGER.log(level, "["+MOD_NAME+"] " + message);
45+
public static void log(Level level, String message) {
46+
LOGGER.log(level, message);
4747
}
4848
}

src/main/java/com/ytg123/manhunt/ManhuntUtils.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import net.minecraft.server.MinecraftServer;
99
import net.minecraft.server.command.ServerCommandSource;
1010
import net.minecraft.server.network.ServerPlayerEntity;
11+
import org.apache.logging.log4j.Level;
1112
import org.jetbrains.annotations.NotNull;
1213
import org.jetbrains.annotations.Nullable;
1314

@@ -42,11 +43,12 @@ public final class ManhuntUtils {
4243
public static UUID speedrunner;
4344
public static List<UUID> hunters;
4445

45-
public static List<PlayerEntity> haveMod = new ArrayList<>();
46+
public static List<PlayerEntity> haveMod;
4647

4748
static {
4849
hunters = new ArrayList<>();
4950
speedrunner = null;
51+
haveMod = new ArrayList<>();
5052
}
5153

5254
private ManhuntUtils() {}
@@ -64,6 +66,10 @@ public static ServerPlayerEntity fromServer(MinecraftServer server, UUID uuid) {
6466
}
6567

6668
public static ItemStack updateCompass(ItemStack compass, ServerPlayerEntity target) {
69+
if(target == null) {
70+
Manhunt.log(Level.WARN, "Compass target is null, cannot update compass! Please fix!");
71+
return compass;
72+
}
6773
CompoundTag itemTag = compass.getTag() == null ? new CompoundTag() : compass.getTag().copy();
6874
itemTag.putBoolean("LodestoneTracked", false);
6975
itemTag.putString(

src/main/java/com/ytg123/manhunt/command/SpeedrunnerCommand.java

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,47 +10,71 @@
1010
import net.minecraft.text.LiteralText;
1111
import net.minecraft.text.TranslatableText;
1212

13-
import static net.minecraft.server.command.CommandManager.*;
13+
import static net.minecraft.server.command.CommandManager.argument;
14+
import static net.minecraft.server.command.CommandManager.literal;
1415

1516
public class SpeedrunnerCommand {
1617
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
1718
dispatcher.register(
1819
literal("speedrunner").then(
19-
argument("target", EntityArgumentType.player()).executes(SpeedrunnerCommand::execute)
20+
literal("set").then(
21+
argument("target", EntityArgumentType.player()).executes(SpeedrunnerCommand::executeSet)
22+
)
2023
).then(
2124
literal("get").executes(SpeedrunnerCommand::executeGet)
25+
).then(
26+
literal("clear").executes(SpeedrunnerCommand::executeClear)
2227
)
2328
);
2429
}
2530

26-
private static int execute(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
31+
private static int executeSet(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
2732
boolean playerHasMod = ManhuntUtils.playerHasMod(context);
2833
ServerPlayerEntity target = EntityArgumentType.getPlayer(context, "target");
2934

3035
if (ManhuntUtils.hunters.contains(target.getUuid())) {
31-
if (playerHasMod)
36+
if (playerHasMod) {
3237
context.getSource().sendError(new TranslatableText("text.manhunt.command.speedrunner.error.hunter", target.getDisplayName()));
33-
else
34-
context.getSource().sendError(new LiteralText("Cannot set speedrunner to ").append(target.getDisplayName()).append(new LiteralText(" because they are a hunter!")));
38+
} else {
39+
context.getSource()
40+
.sendError(new LiteralText("Cannot set speedrunner to ").append(target.getDisplayName())
41+
.append(new LiteralText(" because they are a hunter!")));
42+
}
3543
return 1;
3644
}
3745

3846
ManhuntUtils.speedrunner = target.getUuid();
39-
if (playerHasMod)
40-
context.getSource().sendFeedback(new TranslatableText("text.manhunt.command.speedrunner.set", ManhuntUtils.fromCmdContext(context, ManhuntUtils.speedrunner).getDisplayName()), true);
41-
else
42-
context.getSource().sendFeedback(new LiteralText("Set speedrunner to ").append(target.getDisplayName()).append(new LiteralText("!")), true);
47+
if (playerHasMod) {
48+
context.getSource()
49+
.sendFeedback(new TranslatableText("text.manhunt.command.speedrunner.set",
50+
ManhuntUtils.fromCmdContext(context, ManhuntUtils.speedrunner).getDisplayName()
51+
), true);
52+
} else {
53+
context.getSource()
54+
.sendFeedback(new LiteralText("Set speedrunner to ").append(target.getDisplayName()).append(new LiteralText("!")), true);
55+
}
4356
return 1;
4457
}
4558

4659
private static int executeGet(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
4760
boolean playerHasMod = ManhuntUtils.playerHasMod(context);
4861
if (ManhuntUtils.speedrunner == null) return 1;
4962

50-
if (playerHasMod)
51-
context.getSource().sendFeedback(new TranslatableText("text.manhunt.command.speedrunner.get", ManhuntUtils.fromCmdContext(context, ManhuntUtils.speedrunner).getDisplayName()), false);
52-
else
53-
context.getSource().sendFeedback(new LiteralText("Speedrunner is currently: ").append(ManhuntUtils.fromCmdContext(context, ManhuntUtils.speedrunner).getDisplayName()), true);
63+
if (playerHasMod) {
64+
context.getSource()
65+
.sendFeedback(new TranslatableText("text.manhunt.command.speedrunner.get",
66+
ManhuntUtils.fromCmdContext(context, ManhuntUtils.speedrunner).getDisplayName()
67+
), false);
68+
} else {
69+
context.getSource()
70+
.sendFeedback(new LiteralText("Speedrunner is currently: ").append(ManhuntUtils.fromCmdContext(context, ManhuntUtils.speedrunner)
71+
.getDisplayName()), true);
72+
}
73+
return 1;
74+
}
75+
76+
private static int executeClear(CommandContext<ServerCommandSource> context) {
77+
ManhuntUtils.speedrunner = null;
5478
return 1;
5579
}
5680
}

0 commit comments

Comments
 (0)