Files
KeYiMC/patches/server/0008-Add-global-eula-file-feature.patch
2022-12-09 23:36:52 +08:00

40 lines
1.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
Date: Sat, 25 Jul 2020 17:16:18 +0200
Subject: [PATCH] Add global eula file feature
Original code by YatopiaMC, licensed under MIT
You can find the original code on https://github.com/YatopiaMC/Yatopia
diff --git a/src/main/java/net/minecraft/server/Eula.java b/src/main/java/net/minecraft/server/Eula.java
index 5528a4b7a67e0c257966c587437006004a2e1292..032e45e0addd89ad8b028803ea6d2135ffed5c05 100644
--- a/src/main/java/net/minecraft/server/Eula.java
+++ b/src/main/java/net/minecraft/server/Eula.java
@@ -16,10 +16,24 @@ public class Eula {
public Eula(Path eulaFile) {
this.file = eulaFile;
- this.agreed = SharedConstants.IS_RUNNING_IN_IDE || this.readFile();
+ this.agreed = SharedConstants.IS_RUNNING_IN_IDE || globalEula() || this.readFile(eulaFile);
}
- private boolean readFile() {
+ // Yatopia start - global eula file
+ private boolean globalEula() {
+ java.io.File globalEula = new java.io.File(System.getProperty("user.home"), "eula.txt");
+
+ if (globalEula.exists()) {
+ System.out.println("Loaded global eula file from " + globalEula.getAbsolutePath());
+ return readFile(globalEula.toPath());
+ } else {
+ System.out.println("No global eula file found at " + globalEula.getAbsolutePath());
+ }
+ return false;
+ }
+ // Yatopia end
+
+ private boolean readFile(java.nio.file.Path path) {
try {
boolean var3;
try (InputStream inputStream = Files.newInputStream(this.file)) {