touch up the server network io mixin and restrict /e4mc stop #19
3 changed files with 11 additions and 3 deletions
0
gradlew
vendored
Normal file → Executable file
0
gradlew
vendored
Normal file → Executable file
|
@ -11,6 +11,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
|||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import vg.skye.e4mc_minecraft.E4mcClient;
|
||||
|
@ -45,9 +46,9 @@ public abstract class ServerNetworkIoMixin {
|
|||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "bind", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/ServerBootstrap;channel(Ljava/lang/Class;)Lio/netty/bootstrap/AbstractBootstrap;", remap = false))
|
||||
private AbstractBootstrap<ServerBootstrap, ServerChannel> redirectChannel(ServerBootstrap instance, Class<? extends ServerSocketChannel> aClass) {
|
||||
return initializingE4mc.get() ? instance.channel(LocalServerChannel.class) : instance.channel(aClass);
|
||||
@ModifyArg(method = "bind", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/ServerBootstrap;channel(Ljava/lang/Class;)Lio/netty/bootstrap/AbstractBootstrap;", remap = false))
|
||||
private Class<? extends ServerChannel> redirectChannel(Class<? extends ServerChannel> aClass) {
|
||||
return initializingE4mc.get() ? LocalServerChannel.class : aClass;
|
||||
}
|
||||
|
||||
@Redirect(method = "bind", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/ServerBootstrap;localAddress(Ljava/net/InetAddress;I)Lio/netty/bootstrap/AbstractBootstrap;", remap = false))
|
||||
|
|
|
@ -49,6 +49,13 @@ object E4mcClient : ModInitializer {
|
|||
dispatcher.register(literal("e4mc")
|
||||
.then(
|
||||
literal("stop")
|
||||
.requires { src ->
|
||||
if (src.server.isDedicated) {
|
||||
src.hasPermissionLevel(4)
|
||||
} else {
|
||||
src.server.isHost((src.player ?: return@requires false).gameProfile)
|
||||
}
|
||||
}
|
||||
.executes { context ->
|
||||
if (HANDLER != null) {
|
||||
HANDLER!!.close()
|
||||
|
|
Loading…
Reference in a new issue