1.16.3 Update / Added bstats Metrics

This commit is contained in:
LOOHP 2020-09-11 11:02:35 +08:00
parent 10789c3c60
commit 26c4b9d960
6 changed files with 1001 additions and 958 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>Limbo</groupId>
<artifactId>Limbo</artifactId>
<version>0.3.2-ALPHA</version>
<version>0.3.3-ALPHA</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
@ -53,7 +53,7 @@
</configuration>
</plugin>
</plugins>
<finalName>${project.artifactId}-${project.version}-1.16.2</finalName>
<finalName>${project.artifactId}-${project.version}-1.16.3</finalName>
</build>
<repositories>

View File

@ -18,26 +18,30 @@ import com.loohp.limbo.Utils.YamlOrder;
public class FileConfiguration {
File file;
Map<String, Object> mapping;
String header;
public FileConfiguration(File file) {
public FileConfiguration(File file) throws FileNotFoundException {
this.file = file;
if (file.exists()) {
try {
reloadConfig(new FileInputStream(file));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
reloadConfig();
} else {
mapping = new LinkedHashMap<>();
}
}
@Deprecated
public FileConfiguration(InputStream input){
reloadConfig(input);
}
public FileConfiguration reloadConfig(InputStream input) {
public FileConfiguration reloadConfig() throws FileNotFoundException {
return reloadConfig(new FileInputStream(file));
}
private FileConfiguration reloadConfig(InputStream input) {
Yaml yml = new Yaml();
mapping = yml.load(input);
return this;
@ -76,7 +80,7 @@ public class FileConfiguration {
}
map = map1;
}
if (value == null) {
if (value != null) {
map.put(tree[tree.length - 1], (T) value);
} else {
map.remove(tree[tree.length - 1]);
@ -93,9 +97,13 @@ public class FileConfiguration {
customRepresenter.setPropertyUtils(customProperty);
Yaml yaml = new Yaml(customRepresenter, options);
if (file.getParentFile() != null) {
file.getParentFile().mkdirs();
}
PrintWriter pw = new PrintWriter(file, StandardCharsets.UTF_8.toString());
if (header != null) {
pw.println(header);
pw.println("#" + header.replace("\n", "\n#"));
}
yaml.dump(mapping, pw);
pw.flush();

View File

@ -17,8 +17,6 @@ import com.loohp.limbo.World.World;
public class ServerProperties {
public static final String JSON_BASE_RESPONSE = "{\"version\":{\"name\":\"%VERSION%\",\"protocol\":%PROTOCOL%},\"players\":{\"max\":%MAXPLAYERS%,\"online\":%ONLINECLIENTS%},\"description\":%MOTD%,%FAVICON%\"modinfo\":{\"type\":\"FML\",\"modList\":[]}}";
File file;
int maxPlayers;
int serverPort;
@ -146,10 +144,6 @@ public class ServerProperties {
return allowFlight;
}
public static String getJsonBaseResponse() {
return JSON_BASE_RESPONSE;
}
public String getMotdJson() {
return motdJson;
}

View File

@ -2,11 +2,13 @@ package com.loohp.limbo;
import java.awt.GraphicsEnvironment;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
@ -36,6 +38,7 @@ import com.loohp.limbo.Events.EventsManager;
import com.loohp.limbo.File.ServerProperties;
import com.loohp.limbo.GUI.GUI;
import com.loohp.limbo.Location.Location;
import com.loohp.limbo.Metrics.Metrics;
import com.loohp.limbo.Permissions.PermissionsManager;
import com.loohp.limbo.Player.Player;
import com.loohp.limbo.Plugins.LimboPlugin;
@ -97,8 +100,8 @@ public class Limbo {
//===========================
public final String serverImplementationVersion = "1.16.2";
public final int serverImplmentationProtocol = 751;
public final String serverImplementationVersion = "1.16.3";
public final int serverImplmentationProtocol = 753;
private ServerConnection server;
private Console console;
@ -118,6 +121,8 @@ public class Limbo {
private DimensionRegistry dimensionRegistry;
private Metrics metrics;
public AtomicInteger entityIdCount = new AtomicInteger();
@SuppressWarnings("deprecation")
@ -136,6 +141,8 @@ public class Limbo {
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());
String spName = "server.properties";
File sp = new File(spName);
if (!sp.exists()) {
@ -283,6 +290,8 @@ public class Limbo {
server = new ServerConnection(properties.getServerIp(), properties.getServerPort());
metrics = new Metrics();
console.run();
}
@ -354,6 +363,10 @@ public class Limbo {
return console;
}
public Metrics getMetrics() {
return metrics;
}
public Set<Player> getPlayers() {
return new HashSet<>(playersByUUID.values());
}

File diff suppressed because it is too large Load Diff

View File

@ -43,6 +43,7 @@ public class PluginManager {
if (name.endsWith("plugin.yml") || name.endsWith("limbo.yml")) {
found = true;
@SuppressWarnings("deprecation")
FileConfiguration pluginYaml = new FileConfiguration(zip);
String main = pluginYaml.get("main", String.class);
String pluginName = pluginYaml.get("name", String.class);