Both can start!
This commit is contained in:
parent
ece685bfe4
commit
6e5257514e
|
@ -4,6 +4,10 @@ repositories {
|
|||
}
|
||||
}
|
||||
|
||||
loom {
|
||||
accessWidener("src/main/resources/simpleauth.accesswidener")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
|
||||
mappings("net.fabricmc:yarn:${rootProject.yarn_mappings}:v2")
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.samo_lego.simpleauth.mixin;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import org.samo_lego.simpleauth.event.AuthEventHandler;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -16,7 +15,7 @@ public class MixinPlayerEntity {
|
|||
// Player item dropping
|
||||
@Inject(method = "dropSelectedItem(Z)Z", at = @At("HEAD"), cancellable = true)
|
||||
private void dropSelectedItem(boolean dropEntireStack, CallbackInfoReturnable<Boolean> cir) {
|
||||
ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;
|
||||
PlayerEntity player = (PlayerEntity) (Object) this;
|
||||
ActionResult result = AuthEventHandler.onDropItem(player);
|
||||
|
||||
if (result == ActionResult.FAIL) {
|
||||
|
|
|
@ -27,31 +27,10 @@ public abstract class MixinServerLoginNetworkHandler {
|
|||
|
||||
@Shadow
|
||||
private GameProfile profile;
|
||||
@Shadow
|
||||
private int loginTicks;
|
||||
|
||||
@Shadow protected abstract GameProfile toOfflineProfile(GameProfile profile);
|
||||
|
||||
/**
|
||||
* Fake state of current player.
|
||||
*/
|
||||
@Unique
|
||||
private boolean acceptCrackedPlayer = false;
|
||||
|
||||
/**
|
||||
* Mimicks the ticking if autologin is enabled.
|
||||
* @param ci
|
||||
*/
|
||||
@Inject(method = "tick()V", at = @At("HEAD"), cancellable = true)
|
||||
private void preTick(CallbackInfo ci) {
|
||||
if (this.acceptCrackedPlayer && config.main.premiumAutologin) {
|
||||
((ServerLoginNetworkHandler) (Object) this).acceptPlayer();
|
||||
|
||||
if (this.loginTicks++ == 600)
|
||||
((ServerLoginNetworkHandler) (Object) this).disconnect(new TranslatableText("multiplayer.disconnect.slow_login"));
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
@Shadow private ServerLoginNetworkHandler.State state;
|
||||
|
||||
@Inject(method = "acceptPlayer()V", at = @At("HEAD"))
|
||||
private void acceptPlayer(CallbackInfo ci) {
|
||||
|
@ -84,7 +63,7 @@ public abstract class MixinServerLoginNetworkHandler {
|
|||
Matcher matcher = pattern.matcher(playername);
|
||||
if(playerCacheMap.containsKey(PlayerEntity.getOfflinePlayerUuid(playername).toString()) || !matcher.matches() || config.main.forcedOfflinePlayers.contains(playername)) {
|
||||
// Player definitely doesn't have a mojang account
|
||||
this.acceptCrackedPlayer = true;
|
||||
state = ServerLoginNetworkHandler.State.READY_TO_ACCEPT;
|
||||
|
||||
this.profile = packet.getProfile();
|
||||
ci.cancel();
|
||||
|
@ -109,7 +88,7 @@ public abstract class MixinServerLoginNetworkHandler {
|
|||
else if(response == HttpURLConnection.HTTP_NO_CONTENT) {
|
||||
// Player doesn't have a Mojang account
|
||||
httpsURLConnection.disconnect();
|
||||
this.acceptCrackedPlayer = true;
|
||||
state = ServerLoginNetworkHandler.State.READY_TO_ACCEPT;
|
||||
|
||||
this.profile = packet.getProfile();
|
||||
ci.cancel();
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
"required": true,
|
||||
"package": "org.samo_lego.simpleauth.mixin",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [],
|
||||
"server": [
|
||||
"mixins": [
|
||||
"MixinPlayerAdvancementTracker",
|
||||
"MixinPlayerEntity",
|
||||
"MixinPlayerManager",
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
accessWidener v1 named
|
||||
|
||||
accessible class net/minecraft/server/network/ServerLoginNetworkHandler$State
|
|
@ -25,8 +25,6 @@ dependencies {
|
|||
mappings("net.fabricmc:yarn:${rootProject.yarn_mappings}:v2")
|
||||
modImplementation("net.fabricmc:fabric-loader:${rootProject.loader_version}")
|
||||
modImplementation("net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_version}")
|
||||
// Remove the next line if you don't want to depend on the API
|
||||
modImplementation("me.shedaniel:architectury:${rootProject.architectury_version}:fabric")
|
||||
|
||||
compileOnly(project(path: ":common")) {
|
||||
transitive = false
|
||||
|
@ -44,6 +42,31 @@ dependencies {
|
|||
//modImplementation "carpet:fabric-carpet:${project.minecraft_version}-${project.carpet_core_version}"
|
||||
// jitpack for quicker updating
|
||||
modImplementation "com.github.gnembon:fabric-carpet:${project.carpet_branch}-SNAPSHOT"
|
||||
|
||||
// Password hashing
|
||||
// Argon2
|
||||
implementation "de.mkammerer:argon2-jvm:${argon2_version}"
|
||||
include "de.mkammerer:argon2-jvm:${argon2_version}"
|
||||
|
||||
// BCrypt
|
||||
implementation "at.favre.lib:bcrypt:${bcrypt_version}"
|
||||
implementation "at.favre.lib:bytes:${bytes_version}"
|
||||
include "at.favre.lib:bcrypt:${bcrypt_version}"
|
||||
include "at.favre.lib:bytes:${bytes_version}"
|
||||
|
||||
// Storage
|
||||
// LevelDB database
|
||||
implementation 'org.iq80.leveldb:leveldb:0.12'
|
||||
implementation 'org.iq80.leveldb:leveldb-api:0.12'
|
||||
include 'org.iq80.leveldb:leveldb:0.12'
|
||||
include 'org.iq80.leveldb:leveldb-api:0.12'
|
||||
|
||||
// MongoDB driver
|
||||
implementation 'org.mongodb:mongodb-driver-sync:4.1.0'
|
||||
include 'org.mongodb:mongodb-driver-sync:4.1.0'
|
||||
|
||||
// JNA lib
|
||||
include 'net.java.dev.jna:jna:5.5.0'
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.samo_lego.simpleauth;
|
||||
|
||||
import net.fabricmc.api.DedicatedServerModInitializer;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.fabric.api.event.player.*;
|
||||
|
@ -9,10 +9,10 @@ import net.minecraft.server.MinecraftServer;
|
|||
import org.samo_lego.simpleauth.commands.*;
|
||||
import org.samo_lego.simpleauth.event.AuthEventHandler;
|
||||
|
||||
public class SimpleAuthFabric implements DedicatedServerModInitializer {
|
||||
public class SimpleAuthFabric implements ModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitializeServer() {
|
||||
public void onInitialize() {
|
||||
SimpleAuth.init(FabricLoader.getInstance().getGameDir());
|
||||
//FabricLoader.getInstance().isModLoaded("carpet");
|
||||
|
||||
|
|
|
@ -14,16 +14,12 @@
|
|||
},
|
||||
|
||||
"license": "MIT",
|
||||
"environment": "server",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"server": [
|
||||
"org.samo_lego.simpleauth.SimpleAuth"
|
||||
"main": [
|
||||
"org.samo_lego.simpleauth.SimpleAuthFabric"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"mixins.simpleauth.json"
|
||||
],
|
||||
|
||||
"depends": {
|
||||
"fabricloader": ">=0.8.8",
|
||||
"fabric": "*"
|
|
@ -21,7 +21,6 @@ dependencies {
|
|||
minecraft("com.mojang:minecraft:${rootProject.minecraft_version}")
|
||||
mappings("net.fabricmc:yarn:${rootProject.yarn_mappings}:v2")
|
||||
forge("net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}")
|
||||
// Remove the next line if you don't want to depend on the API
|
||||
modCompile("me.shedaniel:architectury:${rootProject.architectury_version}:forge")
|
||||
|
||||
compileOnly(project(path: ":common")) {
|
||||
|
@ -33,6 +32,31 @@ dependencies {
|
|||
shadow(project(path: ":common", configuration: "transformProductionForge")) {
|
||||
transitive = false
|
||||
}
|
||||
|
||||
// Password hashing
|
||||
// Argon2
|
||||
implementation "de.mkammerer:argon2-jvm:${argon2_version}"
|
||||
include "de.mkammerer:argon2-jvm:${argon2_version}"
|
||||
|
||||
// BCrypt
|
||||
implementation "at.favre.lib:bcrypt:${bcrypt_version}"
|
||||
implementation "at.favre.lib:bytes:${bytes_version}"
|
||||
include "at.favre.lib:bcrypt:${bcrypt_version}"
|
||||
include "at.favre.lib:bytes:${bytes_version}"
|
||||
|
||||
// Storage
|
||||
// LevelDB database
|
||||
implementation 'org.iq80.leveldb:leveldb:0.12'
|
||||
implementation 'org.iq80.leveldb:leveldb-api:0.12'
|
||||
include 'org.iq80.leveldb:leveldb:0.12'
|
||||
include 'org.iq80.leveldb:leveldb-api:0.12'
|
||||
|
||||
// MongoDB driver
|
||||
implementation 'org.mongodb:mongodb-driver-sync:4.1.0'
|
||||
include 'org.mongodb:mongodb-driver-sync:4.1.0'
|
||||
|
||||
// JNA lib
|
||||
include 'net.java.dev.jna:jna:5.5.0'
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
|
|
|
@ -19,7 +19,6 @@ public class SimpleAuthForge {
|
|||
SimpleAuth.init(FMLPaths.GAMEDIR.get());
|
||||
}
|
||||
|
||||
// Registering the commands
|
||||
@SubscribeEvent
|
||||
public void registerCommands(RegisterCommandsEvent event) {
|
||||
CommandDispatcher<ServerCommandSource> dispatcher = event.getDispatcher();
|
||||
|
@ -31,9 +30,7 @@ public class SimpleAuthForge {
|
|||
AuthCommand.registerCommand(dispatcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on server stop.
|
||||
*/
|
||||
|
||||
@SubscribeEvent
|
||||
public void onStopServer(FMLServerStoppedEvent event) {
|
||||
SimpleAuth.stop();
|
||||
|
|
|
@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx1G
|
|||
|
||||
# Fabric properties
|
||||
minecraft_version=1.16.5
|
||||
yarn_mappings=1.16.5+build.1
|
||||
yarn_mappings=1.16.5+build.3
|
||||
loader_version=0.11.1
|
||||
|
||||
#Fabric api
|
||||
fabric_version=0.29.3+1.16
|
||||
fabric_version=0.29.4+1.16
|
||||
|
||||
# Forge
|
||||
forge_version=36.0.1
|
||||
forge_version=36.0.4
|
||||
|
||||
|
||||
# Mod Properties
|
||||
|
|
Loading…
Reference in New Issue