-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac56f85
commit cb16163
Showing
3 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
src/main/java/xyz/mangostudio/smp/bridge/MinecraftServerBridge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package xyz.mangostudio.smp.bridge; | ||
|
||
import java.util.List; | ||
|
||
public interface MinecraftServerBridge { | ||
List<String> getWhitelistNames(); | ||
|
||
void setWhitelistNames(List<String> whitelistNames); | ||
} |
17 changes: 16 additions & 1 deletion
17
src/main/java/xyz/mangostudio/smp/mixin/server/MinecraftServerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,31 @@ | ||
package xyz.mangostudio.smp.mixin.server; | ||
|
||
import java.util.List; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import xyz.mangostudio.smp.bridge.MinecraftServerBridge; | ||
|
||
import net.minecraft.server.MinecraftServer; | ||
import net.minecraft.server.world.ServerChunkManager; | ||
|
||
@Mixin(MinecraftServer.class) | ||
public class MinecraftServerMixin { | ||
public class MinecraftServerMixin implements MinecraftServerBridge { | ||
private List<String> whitelistNames; | ||
|
||
@Redirect(method = "prepareStartRegion", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ServerChunkManager;getTotalChunksLoadedCount()I")) | ||
public int onPrepareStartReg_redirectChunksLoaded(ServerChunkManager scm) { | ||
return 441; | ||
} | ||
|
||
@Override | ||
public List<String> getWhitelistNames() { | ||
return this.whitelistNames; | ||
} | ||
|
||
@Override | ||
public void setWhitelistNames(List<String> whitelistNames) { | ||
this.whitelistNames = whitelistNames; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,31 @@ | ||
package xyz.mangostudio.smp.mod; | ||
|
||
import java.io.FileInputStream; | ||
import java.util.List; | ||
import java.util.Properties; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import xyz.mangostudio.smp.bridge.MinecraftServerBridge; | ||
|
||
import net.fabricmc.api.DedicatedServerModInitializer; | ||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; | ||
|
||
public class SMPMod implements DedicatedServerModInitializer { | ||
private static final Logger LOGGER = LogManager.getLogger("MangoplexSMP"); | ||
|
||
@Override | ||
public void onInitializeServer() { | ||
Properties properties = new Properties(); | ||
|
||
try { | ||
properties.load(new FileInputStream("smp.properties")); | ||
} catch (Exception e) { | ||
LOGGER.error("Failed to load smp.properties", e); | ||
} | ||
|
||
ServerLifecycleEvents.SERVER_STARTING.register(server -> { | ||
((MinecraftServerBridge) server).setWhitelistNames(List.of(properties.getProperty("offline_users").split(","))); | ||
}); | ||
} | ||
} |