aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/los/numeros
diff options
context:
space:
mode:
authorSquibid <me@zacharyscheiman.com>2024-06-04 17:53:59 -0400
committerSquibid <me@zacharyscheiman.com>2024-06-04 17:53:59 -0400
commit16a59696e8cca775d17327bddac8b36ecab6e729 (patch)
tree3198967b8ecf1891bcf8923c0b981fb8467ecd15 /src/main/java/los/numeros
parent32bc1b99866518bda03409dd8c81a2756656f44f (diff)
downloadlnm-16a59696e8cca775d17327bddac8b36ecab6e729.tar.gz
lnm-16a59696e8cca775d17327bddac8b36ecab6e729.tar.bz2
lnm-16a59696e8cca775d17327bddac8b36ecab6e729.zip
add hiders and diggers game init
Diffstat (limited to '')
-rw-r--r--src/main/java/los/numeros/HidersAndDiggers/Main.java17
-rw-r--r--src/main/java/los/numeros/HidersAndDiggers/modules/DeathWatcherModule.java17
-rw-r--r--src/main/java/los/numeros/command/HidersAndDiggersCommand.java31
-rw-r--r--src/main/java/los/numeros/utils/ModRegistries.java3
4 files changed, 65 insertions, 3 deletions
diff --git a/src/main/java/los/numeros/HidersAndDiggers/Main.java b/src/main/java/los/numeros/HidersAndDiggers/Main.java
index bfcbf81..f5fb21c 100644
--- a/src/main/java/los/numeros/HidersAndDiggers/Main.java
+++ b/src/main/java/los/numeros/HidersAndDiggers/Main.java
@@ -1,15 +1,28 @@
package los.numeros.HidersAndDiggers;
+import java.util.Collection;
import java.util.function.BooleanSupplier;
import los.numeros.GameEngine.Engine;
import los.numeros.GameEngine.Module;
+import net.fabricmc.fabric.api.networking.v1.PlayerLookup;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.network.ServerPlayerEntity;
+import los.numeros.HidersAndDiggers.modules.*;
public class Main implements Engine {
- BooleanSupplier running = () -> true;
+ BooleanSupplier running = () -> { return true; };
Module modules[];
- public Main() {
+ public Main(MinecraftServer server) {
+ /* get all the players on the server */
+ Collection<ServerPlayerEntity> players = PlayerLookup.all(server);
+
+ /* print out all players on the server */
+ for (ServerPlayerEntity p : players) {
+ System.out.println(p.getEntityName());
+ }
+
/* start the game */
Engine.StartEngine(running, modules);
}
diff --git a/src/main/java/los/numeros/HidersAndDiggers/modules/DeathWatcherModule.java b/src/main/java/los/numeros/HidersAndDiggers/modules/DeathWatcherModule.java
new file mode 100644
index 0000000..ea972c8
--- /dev/null
+++ b/src/main/java/los/numeros/HidersAndDiggers/modules/DeathWatcherModule.java
@@ -0,0 +1,17 @@
+package los.numeros.HidersAndDiggers.modules;
+
+import los.numeros.GameEngine.Module;
+
+public class DeathWatcherModule implements Module {
+ @Override
+ public int init()
+ {
+ return 0;
+ }
+
+ @Override
+ public int end()
+ {
+ return 0;
+ }
+}
diff --git a/src/main/java/los/numeros/command/HidersAndDiggersCommand.java b/src/main/java/los/numeros/command/HidersAndDiggersCommand.java
new file mode 100644
index 0000000..eed4eed
--- /dev/null
+++ b/src/main/java/los/numeros/command/HidersAndDiggersCommand.java
@@ -0,0 +1,31 @@
+package los.numeros.command;
+
+import com.mojang.brigadier.CommandDispatcher;
+import com.mojang.brigadier.context.CommandContext;
+import com.mojang.brigadier.exceptions.CommandSyntaxException;
+
+import los.numeros.HidersAndDiggers.Main;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.command.CommandManager;
+import net.minecraft.server.command.ServerCommandSource;
+
+public class HidersAndDiggersCommand {
+ public static void
+ register(CommandDispatcher<ServerCommandSource> dispatcher, boolean dedicated)
+ {
+ dispatcher.register(CommandManager.literal("hiders")
+ .then(CommandManager.literal("start").executes(HidersAndDiggersCommand::run)));
+ }
+
+ public static int
+ run(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException
+ {
+ /* get the minecraft server object */
+ MinecraftServer server = ctx.getSource().getMinecraftServer();
+
+ /* pass in the minecraft server object and start it */
+ new Main(server);
+
+ return 0;
+ }
+}
diff --git a/src/main/java/los/numeros/utils/ModRegistries.java b/src/main/java/los/numeros/utils/ModRegistries.java
index faeb2d6..29aee63 100644
--- a/src/main/java/los/numeros/utils/ModRegistries.java
+++ b/src/main/java/los/numeros/utils/ModRegistries.java
@@ -1,6 +1,6 @@
package los.numeros.utils;
-import los.numeros.command.TestCommand;
+import los.numeros.command.*;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
public class ModRegistries {
@@ -14,5 +14,6 @@ public class ModRegistries {
registerCommands()
{
CommandRegistrationCallback.EVENT.register(TestCommand::register);
+ CommandRegistrationCallback.EVENT.register(HidersAndDiggersCommand::register);
}
}