Skip to content

Commit

Permalink
custom map loader vote end and lobby unload command no longer require…
Browse files Browse the repository at this point in the history
… a functionCallback
  • Loading branch information
kyrptonaught committed Feb 6, 2024
1 parent 3bb274b commit a7e4faa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,16 @@ public static void registerCommands(CommandDispatcher<ServerCommandSource> dispa
Identifier winner = Voter.endVote(context.getSource().getServer());
CustomMapLoaderMod.prepareBattleMap(context.getSource().getServer(), winner, id, centralSpawnEnabled, players, CommandFunctionArgumentType.getFunctions(context, "callbackFunction"));
return 1;
})))))));
}))
.executes(context -> {
Identifier id = IdentifierArgumentType.getIdentifier(context, "dimID");
boolean centralSpawnEnabled = BoolArgumentType.getBool(context, "centralSpawnEnabled");
Collection<ServerPlayerEntity> players = EntityArgumentType.getPlayers(context, "players");

Identifier winner = Voter.endVote(context.getSource().getServer());
CustomMapLoaderMod.prepareBattleMap(context.getSource().getServer(), winner, id, centralSpawnEnabled, players, null);
return 1;
}))))));

for (MapSize mapSize : MapSize.values()) {
cmd.then(CommandManager.literal("hostOptions")
Expand All @@ -105,7 +114,12 @@ public static void registerCommands(CommandDispatcher<ServerCommandSource> dispa
Identifier id = IdentifierArgumentType.getIdentifier(context, "dimID");
CustomMapLoaderMod.unloadMap(context.getSource().getServer(), id, CommandFunctionArgumentType.getFunctions(context, "callbackFunction"));
return 1;
}))));
}))
.executes(context -> {
Identifier id = IdentifierArgumentType.getIdentifier(context, "dimID");
CustomMapLoaderMod.unloadMap(context.getSource().getServer(), id, null);
return 1;
})));

cmd.then(CommandManager.literal("lobby")
.then(CommandManager.literal("load")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@
import net.kyrptonaught.serverutils.dimensionLoader.CustomDimHolder;
import net.kyrptonaught.serverutils.dimensionLoader.DimensionLoaderMod;
import net.kyrptonaught.serverutils.playerlockdown.PlayerLockdownMod;
import net.minecraft.command.argument.EntityAnchorArgumentType;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.command.TeleportCommand;
import net.minecraft.server.function.CommandFunction;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier;
import net.minecraft.util.WorldSavePath;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.dimension.DimensionType;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
Expand Down Expand Up @@ -84,12 +83,12 @@ public static void prepareBattleMap(MinecraftServer server, Identifier addon, Id
Collection<ServerPlayerEntity> single = Collections.singleton(player);
ParsedPlayerCoords playerPos = centerPos.fillPlayer(player);

ServerUtilsMod.SwitchableResourcepacksModule.execute(config.resource_pack, single);
//ServerUtilsMod.SwitchableResourcepacksModule.execute(config.resource_pack, single);

player.teleport(world, playerPos.x(), playerPos.y(), playerPos.z(), 0, 0);
player.teleport(world, playerPos.x(), playerPos.y(), playerPos.z(), 90, 0);
player.teleport(world, playerPos.x(), playerPos.y(), playerPos.z(), 180, 0);
player.teleport(world, playerPos.x(), playerPos.y(), playerPos.z(), 270, 0);
//player.teleport(world, playerPos.x(), playerPos.y(), playerPos.z(), 90, 0);
//player.teleport(world, playerPos.x(), playerPos.y(), playerPos.z(), 180, 0);
//player.teleport(world, playerPos.x(), playerPos.y(), playerPos.z(), 270, 0);

PlayerLockdownMod.executeLockdown(single, true);
PlayerLockdownMod.executeFreeze(single, playerPos.pos, true);
Expand Down Expand Up @@ -124,10 +123,9 @@ public static void battleSpawn(ServerWorld world, Collection<ServerPlayerEntity>
raw = randomSpawns.remove(random.nextInt(randomSpawns.size()));
}
ParsedPlayerCoords playerPos = parseVec3D(raw);

player.teleport(world, playerPos.x(), playerPos.y(), playerPos.z(), 0, 0);
float yaw = MathHelper.wrapDegrees((float) (MathHelper.atan2(centerPos.z() - playerPos.z(), centerPos.x() - playerPos.x()) * 57.2957763671875) - 90.0f);
player.teleport(world, playerPos.x(), playerPos.y(), playerPos.z(), yaw, 0);
PlayerLockdownMod.executeFreeze(Collections.singleton(player), playerPos.pos, true);
player.lookAt(EntityAnchorArgumentType.EntityAnchor.EYES, centerPos.pos);
}
}

Expand Down

0 comments on commit a7e4faa

Please sign in to comment.