forked from sorceress/EasyAuth
Merge branch 'archi-snapshot' into architectury
# Conflicts: # common/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandler.java # common/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerPlayNetworkHandler.java # common/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerPlayerEntity.java # common/src/main/java/org/samo_lego/simpleauth/storage/PlayerCache.java
This commit is contained in:
commit
1c15f9ea98
23
build.gradle
23
build.gradle
|
@ -10,8 +10,8 @@ buildscript {
|
||||||
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id "architectury-plugin" version "3.0.94"
|
id "architectury-plugin" version "3.1-SNAPSHOT"
|
||||||
id "forgified-fabric-loom" version "0.6.72" apply false
|
id "dev.architectury.loom" version "0.8.0-SNAPSHOT" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ architectury {
|
||||||
}
|
}
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
apply plugin: "forgified-fabric-loom"
|
apply plugin: "dev.architectury.loom"
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
|
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
|
||||||
mappings("net.fabricmc:yarn:${rootProject.yarn_mappings}:v2")
|
mappings("net.fabricmc:yarn:${rootProject.yarn_mappings}:v2")
|
||||||
|
@ -36,16 +36,15 @@ allprojects {
|
||||||
version = rootProject.mod_version
|
version = rootProject.mod_version
|
||||||
group = rootProject.maven_group
|
group = rootProject.maven_group
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile).configureEach {
|
||||||
options.encoding = "UTF-8"
|
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
||||||
|
// this fixes some edge cases with special characters not displaying correctly
|
||||||
|
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
||||||
|
// If Javadoc is generated, this must be specified in that task too.
|
||||||
|
it.options.encoding = "UTF-8"
|
||||||
|
|
||||||
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
|
// Minecraft 1.17 (21w19a) upwards uses Java 16.
|
||||||
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
|
it.options.release = 8
|
||||||
// We'll use that if it's available, but otherwise we'll use the older option.
|
|
||||||
def targetVersion = 8
|
|
||||||
if (JavaVersion.current().isJava9Compatible()) {
|
|
||||||
options.release = targetVersion
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class SimpleAuth {
|
||||||
/**
|
/**
|
||||||
* HashMap of players that have joined the server.
|
* HashMap of players that have joined the server.
|
||||||
* It's cleared on server stop in order to save some interactions with database during runtime.
|
* It's cleared on server stop in order to save some interactions with database during runtime.
|
||||||
* Stores their data as {@link org.samo_lego.simpleauth.storage.PlayerCache PlayerCache} object.
|
* Stores their data as {@link PlayerCache PlayerCache} object.
|
||||||
*/
|
*/
|
||||||
public static final HashMap<String, PlayerCache> playerCacheMap = new HashMap<>();
|
public static final HashMap<String, PlayerCache> playerCacheMap = new HashMap<>();
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,8 @@ public class AuthCommand {
|
||||||
ctx.getSource().getEntityOrThrow().getX(),
|
ctx.getSource().getEntityOrThrow().getX(),
|
||||||
ctx.getSource().getEntityOrThrow().getY(),
|
ctx.getSource().getEntityOrThrow().getY(),
|
||||||
ctx.getSource().getEntityOrThrow().getZ(),
|
ctx.getSource().getEntityOrThrow().getZ(),
|
||||||
ctx.getSource().getEntityOrThrow().yaw,
|
ctx.getSource().getEntityOrThrow().getYaw(),
|
||||||
ctx.getSource().getEntityOrThrow().pitch
|
ctx.getSource().getEntityOrThrow().getPitch()
|
||||||
))
|
))
|
||||||
.then(argument("dimension", DimensionArgumentType.dimension())
|
.then(argument("dimension", DimensionArgumentType.dimension())
|
||||||
.then(argument("position", BlockPosArgumentType.blockPos())
|
.then(argument("position", BlockPosArgumentType.blockPos())
|
||||||
|
@ -145,7 +145,7 @@ public class AuthCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets {@link org.samo_lego.simpleauth.storage.AuthConfig.MainConfig.WorldSpawn global spawn}.
|
* Sets {@link AuthConfig.MainConfig.WorldSpawn global spawn}.
|
||||||
*
|
*
|
||||||
* @param source executioner of the command
|
* @param source executioner of the command
|
||||||
* @param world world id of global spawn
|
* @param world world id of global spawn
|
||||||
|
|
|
@ -94,8 +94,7 @@ public class AuthEventHandler {
|
||||||
|
|
||||||
|
|
||||||
// Tries to rescue player from nether portal
|
// Tries to rescue player from nether portal
|
||||||
//if(config.main.tryPortalRescue && player.getBlockState().getBlock().equals(Blocks.NETHER_PORTAL)) {
|
if(config.main.tryPortalRescue && player.getBlockStateAtPos().getBlock().equals(Blocks.NETHER_PORTAL)) {
|
||||||
if(config.main.tryPortalRescue && player.getServerWorld().getBlockState(player.getBlockPos()).getBlock().equals(Blocks.NETHER_PORTAL)) {
|
|
||||||
BlockPos pos = player.getBlockPos();
|
BlockPos pos = player.getBlockPos();
|
||||||
|
|
||||||
// Teleporting player to the middle of the block
|
// Teleporting player to the middle of the block
|
||||||
|
@ -118,8 +117,8 @@ public class AuthEventHandler {
|
||||||
|
|
||||||
if(playerCache.isAuthenticated) {
|
if(playerCache.isAuthenticated) {
|
||||||
playerCache.lastIp = player.getIp();
|
playerCache.lastIp = player.getIp();
|
||||||
//playerCache.wasInPortal = player.getBlockState().getBlock().equals(Blocks.NETHER_PORTAL);
|
playerCache.wasInPortal = player.getBlockStateAtPos().getBlock().equals(Blocks.NETHER_PORTAL);
|
||||||
playerCache.wasInPortal = player.getServerWorld().getBlockState(player.getBlockPos()).getBlock().equals(Blocks.NETHER_PORTAL);
|
|
||||||
// Setting the session expire time
|
// Setting the session expire time
|
||||||
if(config.main.sessionTimeoutTime != -1)
|
if(config.main.sessionTimeoutTime != -1)
|
||||||
playerCache.validUntil = System.currentTimeMillis() + config.main.sessionTimeoutTime * 1000L;
|
playerCache.validUntil = System.currentTimeMillis() + config.main.sessionTimeoutTime * 1000L;
|
||||||
|
|
|
@ -22,7 +22,7 @@ public abstract class MixinServerPlayNetworkHandler {
|
||||||
public ServerPlayerEntity player;
|
public ServerPlayerEntity player;
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "method_31286(Lnet/minecraft/server/filter/TextStream$Message;)V",
|
method = "handleMessage(Lnet/minecraft/server/filter/TextStream$Message;)V",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Lnet/minecraft/server/network/ServerPlayerEntity;updateLastActionTime()V",
|
target = "Lnet/minecraft/server/network/ServerPlayerEntity;updateLastActionTime()V",
|
||||||
|
@ -68,7 +68,7 @@ public abstract class MixinServerPlayNetworkHandler {
|
||||||
ActionResult result = AuthEventHandler.onPlayerMove(player);
|
ActionResult result = AuthEventHandler.onPlayerMove(player);
|
||||||
if (result == ActionResult.FAIL) {
|
if (result == ActionResult.FAIL) {
|
||||||
// A bit ugly, I know. (we need to update player position)
|
// A bit ugly, I know. (we need to update player position)
|
||||||
player.networkHandler.requestTeleport(player.getX(), player.getY(), player.getZ(), player.getYaw(0), player.getPitch(0));
|
player.networkHandler.requestTeleport(player.getX(), player.getY(), player.getZ(), player.getYaw(), player.getPitch());
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,12 +52,12 @@ public class MixinServerPlayerEntity implements PlayerAuth {
|
||||||
// Saving position
|
// Saving position
|
||||||
cache.lastLocation.dimension = player.getServerWorld();
|
cache.lastLocation.dimension = player.getServerWorld();
|
||||||
cache.lastLocation.position = player.getPos();
|
cache.lastLocation.position = player.getPos();
|
||||||
cache.lastLocation.yaw = player.getYaw(0);
|
cache.lastLocation.yaw = player.getYaw();
|
||||||
cache.lastLocation.pitch = player.getPitch(0);
|
cache.lastLocation.pitch = player.getPitch();
|
||||||
|
|
||||||
// Teleports player to spawn
|
// Teleports player to spawn
|
||||||
player.teleport(
|
player.teleport(
|
||||||
server.getWorld(RegistryKey.of(Registry.DIMENSION, new Identifier(config.worldSpawn.dimension))),
|
server.getWorld(RegistryKey.of(Registry.WORLD_KEY, new Identifier(config.worldSpawn.dimension))),
|
||||||
config.worldSpawn.x,
|
config.worldSpawn.x,
|
||||||
config.worldSpawn.y,
|
config.worldSpawn.y,
|
||||||
config.worldSpawn.z,
|
config.worldSpawn.z,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.samo_lego.simpleauth.mixin;
|
package org.samo_lego.simpleauth.mixin;
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.nbt.NbtIo;
|
import net.minecraft.nbt.NbtIo;
|
||||||
import net.minecraft.world.WorldSaveHandler;
|
import net.minecraft.world.WorldSaveHandler;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
@ -46,14 +46,14 @@ public class MixinWorldSaveHandler {
|
||||||
* @param file
|
* @param file
|
||||||
*/
|
*/
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "loadPlayerData(Lnet/minecraft/entity/player/PlayerEntity;)Lnet/minecraft/nbt/CompoundTag;",
|
method = "loadPlayerData(Lnet/minecraft/entity/player/PlayerEntity;)Lnet/minecraft/nbt/NbtCompound;",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Ljava/io/File;exists()Z"
|
target = "Ljava/io/File;exists()Z"
|
||||||
),
|
),
|
||||||
locals = LocalCapture.CAPTURE_FAILHARD
|
locals = LocalCapture.CAPTURE_FAILHARD
|
||||||
)
|
)
|
||||||
private void fileExists(PlayerEntity playerEntity, CallbackInfoReturnable<CompoundTag> cir, CompoundTag compoundTag, File file) {
|
private void fileExists(PlayerEntity playerEntity, CallbackInfoReturnable<NbtCompound> cir, NbtCompound compoundTag, File file) {
|
||||||
// @ModifyVariable cannot capture locals
|
// @ModifyVariable cannot capture locals
|
||||||
this.fileExists = file.exists();
|
this.fileExists = file.exists();
|
||||||
}
|
}
|
||||||
|
@ -66,13 +66,13 @@ public class MixinWorldSaveHandler {
|
||||||
* @return compoundTag containing migrated data.
|
* @return compoundTag containing migrated data.
|
||||||
*/
|
*/
|
||||||
@ModifyVariable(
|
@ModifyVariable(
|
||||||
method = "loadPlayerData(Lnet/minecraft/entity/player/PlayerEntity;)Lnet/minecraft/nbt/CompoundTag;",
|
method = "loadPlayerData(Lnet/minecraft/entity/player/PlayerEntity;)Lnet/minecraft/nbt/NbtCompound;",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Ljava/io/File;exists()Z"
|
target = "Ljava/io/File;exists()Z"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
private CompoundTag migratePlayerData(CompoundTag compoundTag, PlayerEntity player) {
|
private NbtCompound migratePlayerData(NbtCompound compoundTag, PlayerEntity player) {
|
||||||
// Checking for offline player data only if online doesn't exist yet
|
// Checking for offline player data only if online doesn't exist yet
|
||||||
String playername = player.getGameProfile().getName().toLowerCase();
|
String playername = player.getGameProfile().getName().toLowerCase();
|
||||||
if(config.main.premiumAutologin && mojangAccountNamesCache.contains(playername) && !this.fileExists) {
|
if(config.main.premiumAutologin && mojangAccountNamesCache.contains(playername) && !this.fileExists) {
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class PlayerCache {
|
||||||
public float pitch;
|
public float pitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final PlayerCache.LastLocation lastLocation = new PlayerCache.LastLocation();
|
public final LastLocation lastLocation = new LastLocation();
|
||||||
|
|
||||||
|
|
||||||
private static final Gson gson = new GsonBuilder()
|
private static final Gson gson = new GsonBuilder()
|
||||||
|
@ -94,11 +94,10 @@ public class PlayerCache {
|
||||||
// Setting position cache
|
// Setting position cache
|
||||||
playerCache.lastLocation.dimension = player.getServerWorld();
|
playerCache.lastLocation.dimension = player.getServerWorld();
|
||||||
playerCache.lastLocation.position = player.getPos();
|
playerCache.lastLocation.position = player.getPos();
|
||||||
playerCache.lastLocation.yaw = player.getYaw(0);
|
playerCache.lastLocation.yaw = player.getYaw();
|
||||||
playerCache.lastLocation.pitch = player.getPitch(0);
|
playerCache.lastLocation.pitch = player.getPitch();
|
||||||
|
|
||||||
playerCache.wasInPortal = player.getServerWorld().getBlockState(player.getBlockPos()).getBlock().equals(Blocks.NETHER_PORTAL);
|
playerCache.wasInPortal = player.getBlockStateAtPos().getBlock().equals(Blocks.NETHER_PORTAL);
|
||||||
//playerCache.wasInPortal = player.getBlockState().getBlock().equals(Blocks.NETHER_PORTAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return playerCache;
|
return playerCache;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"required": true,
|
"required": true,
|
||||||
"package": "org.samo_lego.simpleauth.mixin",
|
"package": "org.samo_lego.simpleauth.mixin",
|
||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_16",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"MixinPlayerAdvancementTracker",
|
"MixinPlayerAdvancementTracker",
|
||||||
"MixinPlayerEntity",
|
"MixinPlayerEntity",
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
accessWidener v1 named
|
accessWidener v1 named
|
||||||
|
|
||||||
accessible class net/minecraft/server/network/ServerLoginNetworkHandler$State
|
accessible class net/minecraft/server/network/ServerLoginNetworkHandler$State
|
||||||
accessible field net/minecraft/entity/Entity yaw F
|
|
|
@ -2,12 +2,12 @@
|
||||||
org.gradle.jvmargs=-Xmx1G
|
org.gradle.jvmargs=-Xmx1G
|
||||||
|
|
||||||
# Fabric properties
|
# Fabric properties
|
||||||
minecraft_version=21w10a
|
minecraft_version=1.17
|
||||||
yarn_mappings=21w10a+build.1
|
yarn_mappings=1.17+build.13
|
||||||
loader_version=0.11.2
|
loader_version=0.11.6
|
||||||
|
|
||||||
#Fabric api
|
#Fabric api
|
||||||
fabric_version=0.28.5+1.15
|
fabric_version=0.36.0+1.17
|
||||||
|
|
||||||
# Forge
|
# Forge
|
||||||
forge_version=36.0.4
|
forge_version=36.0.4
|
||||||
|
|
Loading…
Reference in New Issue