This commit is contained in:
samo_lego 2020-08-30 21:46:24 +02:00
parent aff0241049
commit f480e93ed2
6 changed files with 49 additions and 34 deletions

View File

@ -58,9 +58,9 @@ dependencies {
// carpetMod
// from masa's maven
//modImplementation "carpet:fabric-carpet:${project.minecraft_version}-${project.carpet_core_version}"
modImplementation "carpet:fabric-carpet:1.16-${project.carpet_core_version}"
//modImplementation "carpet:fabric-carpet:1.16-${project.carpet_core_version}"
// jitpack for quicker updating
//modImplementation "com.github.gnembon:fabric-carpet:${project.carpet_branch}-SNAPSHOT"
modImplementation "com.github.gnembon:fabric-carpet:${project.carpet_branch}-SNAPSHOT"
}
processResources {

View File

@ -21,4 +21,4 @@ bytes_version = 1.3.0
# Carpet for debugging
carpet_core_version = 1.4.0+v200623
carpet_branch = 1.16
carpet_branch = master

View File

@ -36,6 +36,7 @@ import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import static org.iq80.leveldb.impl.Iq80DBFactory.bytes;
import static org.samo_lego.simpleauth.utils.CarpetHelper.isPlayerCarpetFake;
@ -160,7 +161,21 @@ public class SimpleAuth implements DedicatedServerModInitializer {
logError("Error saving player data! " + e.getMessage());
}
// Closing DB connection
// Closing threads
try {
THREADPOOL.shutdownNow();
TIMER.cancel();
TIMER.purge();
if (!THREADPOOL.awaitTermination(100, TimeUnit.MICROSECONDS)) {
System.out.println("Still waiting...");
Thread.currentThread().interrupt();
}
} catch (InterruptedException e) {
logError(e.getMessage());
THREADPOOL.shutdownNow();
}
// Closing DB connection
DB.close();
}

View File

@ -20,40 +20,40 @@ public class AccountCommand {
public static void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher) {
// Registering the "/account" command
dispatcher.register(literal("account")
.then(literal("unregister")
.then(literal("unregister")
.executes(ctx -> {
ctx.getSource().getPlayer().sendMessage(
new LiteralText(config.lang.enterPassword),
false
);
return 1;
})
.then(argument("password", word())
.executes( ctx -> unregister(
ctx.getSource(),
getString(ctx, "password")
)
)
)
)
.then(literal("changePassword")
.then(argument("old password", word())
.executes(ctx -> {
ctx.getSource().getPlayer().sendMessage(
new LiteralText(config.lang.enterPassword),
false
);
new LiteralText(config.lang.enterNewPassword),
false);
return 1;
})
.then(argument("password", word())
.executes( ctx -> unregister(
.then(argument("new password", word())
.executes( ctx -> changePassword(
ctx.getSource(),
getString(ctx, "password")
getString(ctx, "old password"),
getString(ctx, "new password")
)
)
)
)
.then(literal("changePassword")
.then(argument("old password", word())
.executes(ctx -> {
ctx.getSource().getPlayer().sendMessage(
new LiteralText(config.lang.enterNewPassword),
false);
return 1;
})
.then(argument("new password", word())
.executes( ctx -> changePassword(
ctx.getSource(),
getString(ctx, "old password"),
getString(ctx, "new password")
)
)
)
)
)
)
);
}

View File

@ -99,15 +99,15 @@ public class AuthEventHandler {
if(config.main.tryPortalRescue && player.getBlockState().getBlock().equals(Blocks.NETHER_PORTAL)) {
BlockPos pos = player.getBlockPos();
// Teleporting player to the middle of the block
player.teleport(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
// Faking portal blocks to be air
BlockUpdateS2CPacket feetPacket = new BlockUpdateS2CPacket(pos, Blocks.AIR.getDefaultState());
player.networkHandler.sendPacket(feetPacket);
BlockUpdateS2CPacket headPacket = new BlockUpdateS2CPacket(pos.up(), Blocks.AIR.getDefaultState());
player.networkHandler.sendPacket(headPacket);
// Teleporting player to the middle of the block
player.teleport(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
}
}

View File

@ -68,10 +68,10 @@ public abstract class MixinServerPlayNetworkHandler {
cancellable = true
)
private void onPlayerMove(PlayerMoveC2SPacket playerMoveC2SPacket, CallbackInfo ci) {
ActionResult result = PlayerMoveCallback.EVENT.invoker().onPlayerMove(this.player);
ActionResult result = PlayerMoveCallback.EVENT.invoker().onPlayerMove(player);
if (result == ActionResult.FAIL) {
// A bit ugly, I know. (we need to update player position)
this.player.requestTeleport(this.player.getX(), this.player.getY(), this.player.getZ());
player.networkHandler.requestTeleport(player.getX(), player.getY(), player.getZ(), player.yaw, player.pitch);
ci.cancel();
}
}