-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
only actually initialize item groups on the client to avoid crashing …
…servers and close #9, allow agreeing to the eula in the server console instead of restarting
- Loading branch information
Showing
6 changed files
with
95 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
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
49 changes: 49 additions & 0 deletions
49
src/main/java/io/wispforest/owo/mixin/EulaReaderMixin.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,49 @@ | ||
package io.wispforest.owo.mixin; | ||
|
||
import net.minecraft.server.dedicated.EulaReader; | ||
import org.apache.logging.log4j.Logger; | ||
import org.spongepowered.asm.mixin.Final; | ||
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.callback.CallbackInfoReturnable; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Properties; | ||
import java.util.Scanner; | ||
|
||
@Mixin(EulaReader.class) | ||
public class EulaReaderMixin { | ||
|
||
@Shadow | ||
@Final | ||
private static Logger LOGGER; | ||
|
||
@Shadow | ||
@Final | ||
private Path eulaFile; | ||
|
||
@Inject(method = "checkEulaAgreement", at = @At(value = "TAIL"), cancellable = true) | ||
private void overrideEulaAgreement(CallbackInfoReturnable<Boolean> cir) { | ||
var scanner = new Scanner(System.in); | ||
LOGGER.info("By answering 'true' to this prompt you are indicating your agreement to Minecraft's EULA (https://account.mojang.com/documents/minecraft_eula)\nEULA:"); | ||
|
||
var input = scanner.next(); | ||
if (!input.equalsIgnoreCase("true")) return; | ||
|
||
try (var inStream = Files.newInputStream(this.eulaFile); var outStream = Files.newOutputStream(this.eulaFile)) { | ||
var properties = new Properties(); | ||
properties.load(inStream); | ||
properties.setProperty("eula", "true"); | ||
properties.store(outStream, "By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula)."); | ||
} catch (IOException e) { | ||
LOGGER.info("Could not accept eula", e); | ||
} | ||
|
||
LOGGER.info("EULA accepted"); | ||
cir.setReturnValue(true); | ||
} | ||
} |
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