mirror of https://github.com/LOOHP/Limbo.git
Fixed some platforms unable to read limbo version from manifest
This commit is contained in:
parent
6463e3d820
commit
4d8a5951f6
|
|
@ -15,10 +15,12 @@ import java.nio.channels.ReadableByteChannel;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
@ -102,6 +104,7 @@ public class Limbo {
|
||||||
|
|
||||||
public final String serverImplementationVersion = "1.16.3";
|
public final String serverImplementationVersion = "1.16.3";
|
||||||
public final int serverImplmentationProtocol = 753;
|
public final int serverImplmentationProtocol = 753;
|
||||||
|
public final String limboImplementationVersion;
|
||||||
|
|
||||||
private ServerConnection server;
|
private ServerConnection server;
|
||||||
private Console console;
|
private Console console;
|
||||||
|
|
@ -140,8 +143,9 @@ public class Limbo {
|
||||||
} else {
|
} else {
|
||||||
console = new Console(System.in, System.out, System.err);
|
console = new Console(System.in, System.out, System.err);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.sendMessage("Loading Limbo Version " + new BufferedReader(new InputStreamReader(Limbo.class.getClassLoader().getResourceAsStream("META-INF/MANIFEST.MF"))).lines().filter(each -> each.startsWith("Limbo-Version:")).findFirst().orElse("Limbo-Version: unknown").substring(14).trim());
|
limboImplementationVersion = getLimboVersion();
|
||||||
|
console.sendMessage("Loading Limbo Version " + limboImplementationVersion);
|
||||||
|
|
||||||
String spName = "server.properties";
|
String spName = "server.properties";
|
||||||
File sp = new File(spName);
|
File sp = new File(spName);
|
||||||
|
|
@ -487,5 +491,19 @@ public class Limbo {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getLimboVersion() throws IOException {
|
||||||
|
Enumeration<URL> manifests = getClass().getClassLoader().getResources("META-INF/MANIFEST.MF");
|
||||||
|
while (manifests.hasMoreElements()) {
|
||||||
|
URL url = manifests.nextElement();
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
|
||||||
|
Optional<String> line = br.lines().filter(each -> each.startsWith("Limbo-Version:")).findFirst();
|
||||||
|
br.close();
|
||||||
|
if (line.isPresent()) {
|
||||||
|
return line.get().substring(14).trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,10 @@
|
||||||
package com.loohp.limbo.Metrics;
|
package com.loohp.limbo.Metrics;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -95,7 +93,7 @@ public class Metrics {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
limboVersion = new BufferedReader(new InputStreamReader(Limbo.class.getClassLoader().getResourceAsStream("META-INF/MANIFEST.MF"))).lines().filter(each -> each.startsWith("Limbo-Version:")).findFirst().orElse("Limbo-Version: unknown").substring(14).trim();
|
limboVersion = Limbo.getInstance().limboImplementationVersion;
|
||||||
|
|
||||||
// Load the data
|
// Load the data
|
||||||
serverUUID = config.get("serverUuid", String.class);
|
serverUUID = config.get("serverUuid", String.class);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue