Finalising 20w22a, hooray

This commit is contained in:
samo_lego 2020-06-01 21:50:11 +02:00
parent 96bf9a52de
commit 27a5fa25fb
4 changed files with 18 additions and 38 deletions

View File

@ -3,11 +3,11 @@ org.gradle.jvmargs=-Xmx1G
# Fabric properties # Fabric properties
minecraft_version=20w22a minecraft_version=20w22a
yarn_mappings=20w22a+build.1 yarn_mappings=20w22a+build.5
loader_version=0.8.4+build.198 loader_version=0.8.5+build.199
#Fabric api #Fabric api
fabric_version=0.11.0+build.349-1.16 fabric_version=0.11.2+build.351-1.16
# Mod Properties # Mod Properties
mod_version = 1.4.3 mod_version = 1.4.3

View File

@ -9,8 +9,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.World;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.samo_lego.simpleauth.SimpleAuth; import org.samo_lego.simpleauth.SimpleAuth;
@ -47,28 +45,22 @@ public class AuthCommand {
) )
.then(literal("setSpawn") .then(literal("setSpawn")
.executes( ctx -> setSpawn( .executes( ctx -> setSpawn(
ctx.getSource(), ctx.getSource(),
new Identifier(String.valueOf(ctx.getSource().getWorld().getDimension())), ctx.getSource().getEntityOrThrow().getEntityWorld().method_27983().getValue(),
ctx.getSource().getEntityOrThrow().getX(), ctx.getSource().getEntityOrThrow().getX(),
ctx.getSource().getEntityOrThrow().getY(), ctx.getSource().getEntityOrThrow().getY(),
ctx.getSource().getEntityOrThrow().getZ() ctx.getSource().getEntityOrThrow().getZ()
)) ))
.then(argument("dimension", DimensionArgumentType.dimension()) .then(argument("dimension", DimensionArgumentType.dimension())
.then(argument("position", BlockPosArgumentType.blockPos()) .then(argument("position", BlockPosArgumentType.blockPos())
.executes(ctx -> { .executes(ctx -> setSpawn(
RegistryKey<World> worldRegistryKey = DimensionArgumentType.getDimensionArgument(ctx, "dimension"); ctx.getSource(),
//Registry<DimensionType> registry = ctx.getSource().getWorld().getServer().method_29174().getRegistry(); DimensionArgumentType.getDimensionArgument(ctx, "dimension").getValue(),
return setSpawn( BlockPosArgumentType.getLoadedBlockPos(ctx, "position").getX(),
ctx.getSource(), // +1 to not spawn player in ground
//Objects.requireNonNull(registry.get(dimension.getValue())), BlockPosArgumentType.getLoadedBlockPos(ctx, "position").getY() + 1,
worldRegistryKey.getValue(), BlockPosArgumentType.getLoadedBlockPos(ctx, "position").getZ()
//(ctx, "dimension id"), )
BlockPosArgumentType.getLoadedBlockPos(ctx, "position").getX(),
// +1 to not spawn player in ground
BlockPosArgumentType.getLoadedBlockPos(ctx, "position").getY() + 1,
BlockPosArgumentType.getLoadedBlockPos(ctx, "position").getZ()
);
}
) )
) )
) )
@ -136,9 +128,6 @@ public class AuthCommand {
// //
private static int setSpawn(ServerCommandSource source, Identifier world, double x, double y, double z) { private static int setSpawn(ServerCommandSource source, Identifier world, double x, double y, double z) {
// Getting dimension registry
//Registry<DimensionType> registry = source.getWorld().getServer().method_29435();
// Setting config values and saving // Setting config values and saving
config.worldSpawn.dimension = String.valueOf(world); config.worldSpawn.dimension = String.valueOf(world);
config.worldSpawn.x = x; config.worldSpawn.x = x;

View File

@ -83,7 +83,7 @@ public class AuthEventHandler {
if ( if (
playerCache.wasAuthenticated && playerCache.wasAuthenticated &&
playerCache.validUntil >= System.currentTimeMillis() && playerCache.validUntil >= System.currentTimeMillis() &&
playerCache.lastIp.equals(player.getIp()) player.getIp().equals(playerCache.lastIp)
) { ) {
deauthenticatedUsers.remove(uuid); // Makes player authenticated deauthenticatedUsers.remove(uuid); // Makes player authenticated
return; return;

View File

@ -5,7 +5,6 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Identifier;
import static org.samo_lego.simpleauth.SimpleAuth.config; import static org.samo_lego.simpleauth.SimpleAuth.config;
import static org.samo_lego.simpleauth.SimpleAuth.db; import static org.samo_lego.simpleauth.SimpleAuth.db;
@ -34,18 +33,12 @@ public class PlayerCache {
if(player != null) { if(player != null) {
this.lastIp = player.getIp(); this.lastIp = player.getIp();
// Getting dimension registry
//Registry<DimensionType> registry = Objects.requireNonNull(player.getServer()).method_29435().getRegistry();
// Setting position cache // Setting position cache
this.lastDim = String.valueOf(new Identifier(String.valueOf(player.getEntityWorld().getDimension()))); this.lastDim = String.valueOf(player.getEntityWorld().getDimension());
this.lastX = player.getX(); this.lastX = player.getX();
this.lastY = player.getY(); this.lastY = player.getY();
this.lastZ = player.getZ(); this.lastZ = player.getZ();
} }
else {
this.lastIp = "";
}
if(db.isUserRegistered(uuid)) { if(db.isUserRegistered(uuid)) {
String data = db.getData(uuid); String data = db.getData(uuid);
@ -62,8 +55,6 @@ public class PlayerCache {
if (lastLoc != null) { if (lastLoc != null) {
// Getting DB coords // Getting DB coords
JsonObject lastLocation = gson.fromJson(lastLoc.getAsString(), JsonObject.class); JsonObject lastLocation = gson.fromJson(lastLoc.getAsString(), JsonObject.class);
//String dim = Objects.requireNonNull(Objects.requireNonNull(player).getServer()).method_29174().getRegistry().get(new Identifier(dim));
// Extra long line to get dimension from string
this.lastDim = lastLocation.get("dim").getAsString(); this.lastDim = lastLocation.get("dim").getAsString();
this.lastX = lastLocation.get("x").getAsDouble(); this.lastX = lastLocation.get("x").getAsDouble();
this.lastY = lastLocation.get("y").getAsDouble(); this.lastY = lastLocation.get("y").getAsDouble();