Fixing #16
This commit is contained in:
parent
aff0241049
commit
f480e93ed2
|
@ -58,9 +58,9 @@ dependencies {
|
||||||
// carpetMod
|
// carpetMod
|
||||||
// from masa's maven
|
// from masa's maven
|
||||||
//modImplementation "carpet:fabric-carpet:${project.minecraft_version}-${project.carpet_core_version}"
|
//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
|
// 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 {
|
processResources {
|
||||||
|
|
|
@ -21,4 +21,4 @@ bytes_version = 1.3.0
|
||||||
|
|
||||||
# Carpet for debugging
|
# Carpet for debugging
|
||||||
carpet_core_version = 1.4.0+v200623
|
carpet_core_version = 1.4.0+v200623
|
||||||
carpet_branch = 1.16
|
carpet_branch = master
|
|
@ -36,6 +36,7 @@ import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static org.iq80.leveldb.impl.Iq80DBFactory.bytes;
|
import static org.iq80.leveldb.impl.Iq80DBFactory.bytes;
|
||||||
import static org.samo_lego.simpleauth.utils.CarpetHelper.isPlayerCarpetFake;
|
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());
|
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();
|
DB.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,40 +20,40 @@ public class AccountCommand {
|
||||||
public static void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher) {
|
public static void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||||
// Registering the "/account" command
|
// Registering the "/account" command
|
||||||
dispatcher.register(literal("account")
|
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 -> {
|
.executes(ctx -> {
|
||||||
ctx.getSource().getPlayer().sendMessage(
|
ctx.getSource().getPlayer().sendMessage(
|
||||||
new LiteralText(config.lang.enterPassword),
|
new LiteralText(config.lang.enterNewPassword),
|
||||||
false
|
false);
|
||||||
);
|
|
||||||
return 1;
|
return 1;
|
||||||
})
|
})
|
||||||
.then(argument("password", word())
|
.then(argument("new password", word())
|
||||||
.executes( ctx -> unregister(
|
.executes( ctx -> changePassword(
|
||||||
ctx.getSource(),
|
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")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,15 +99,15 @@ public class AuthEventHandler {
|
||||||
if(config.main.tryPortalRescue && player.getBlockState().getBlock().equals(Blocks.NETHER_PORTAL)) {
|
if(config.main.tryPortalRescue && player.getBlockState().getBlock().equals(Blocks.NETHER_PORTAL)) {
|
||||||
BlockPos pos = player.getBlockPos();
|
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
|
// Faking portal blocks to be air
|
||||||
BlockUpdateS2CPacket feetPacket = new BlockUpdateS2CPacket(pos, Blocks.AIR.getDefaultState());
|
BlockUpdateS2CPacket feetPacket = new BlockUpdateS2CPacket(pos, Blocks.AIR.getDefaultState());
|
||||||
player.networkHandler.sendPacket(feetPacket);
|
player.networkHandler.sendPacket(feetPacket);
|
||||||
|
|
||||||
BlockUpdateS2CPacket headPacket = new BlockUpdateS2CPacket(pos.up(), Blocks.AIR.getDefaultState());
|
BlockUpdateS2CPacket headPacket = new BlockUpdateS2CPacket(pos.up(), Blocks.AIR.getDefaultState());
|
||||||
player.networkHandler.sendPacket(headPacket);
|
player.networkHandler.sendPacket(headPacket);
|
||||||
|
|
||||||
// Teleporting player to the middle of the block
|
|
||||||
player.teleport(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,10 +68,10 @@ public abstract class MixinServerPlayNetworkHandler {
|
||||||
cancellable = true
|
cancellable = true
|
||||||
)
|
)
|
||||||
private void onPlayerMove(PlayerMoveC2SPacket playerMoveC2SPacket, CallbackInfo ci) {
|
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) {
|
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)
|
||||||
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();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue