diff --git a/MiraiMC-Base/src/main/java/me/dreamvoid/miraimc/Platform.java b/MiraiMC-Base/src/main/java/me/dreamvoid/miraimc/Platform.java index c0dbde0f..a798f131 100644 --- a/MiraiMC-Base/src/main/java/me/dreamvoid/miraimc/Platform.java +++ b/MiraiMC-Base/src/main/java/me/dreamvoid/miraimc/Platform.java @@ -37,4 +37,6 @@ public interface Platform { PluginConfig getPluginConfig(); LibraryLoader getLibraryLoader(); + + String getType(); } diff --git a/MiraiMC-Base/src/main/java/me/dreamvoid/miraimc/internal/Utils.java b/MiraiMC-Base/src/main/java/me/dreamvoid/miraimc/internal/Utils.java index f8849565..fbffaeda 100644 --- a/MiraiMC-Base/src/main/java/me/dreamvoid/miraimc/internal/Utils.java +++ b/MiraiMC-Base/src/main/java/me/dreamvoid/miraimc/internal/Utils.java @@ -2,6 +2,7 @@ import com.google.gson.Gson; import com.google.gson.JsonObject; +import me.dreamvoid.miraimc.LifeCycle; import me.dreamvoid.miraimc.internal.config.PluginConfig; import org.jetbrains.annotations.NotNull; @@ -123,7 +124,7 @@ public static String get(String url) throws IOException { connection.setDoInput(true); connection.setRequestMethod("GET"); - connection.setRequestProperty("User-Agent", "Mozilla/5.0 DreamVoid MiraiMC"); + connection.setRequestProperty("User-Agent", String.format("MiraiMC/%s (%s; %s)", LifeCycle.getPlatform().getPluginVersion(), LifeCycle.getPlatform().getType(), System.getProperty("os.name"))); connection.setConnectTimeout(5000); connection.setReadTimeout(10000); @@ -152,7 +153,7 @@ public static String post(JsonObject json, String url) throws IOException { connection.setDoInput(true); connection.setRequestMethod("POST"); - connection.setRequestProperty("User-Agent", "Mozilla/5.0 DreamVoid MiraiMC"); + connection.setRequestProperty("User-Agent", String.format("MiraiMC/%s (%s; %s)", LifeCycle.getPlatform().getPluginVersion(), LifeCycle.getPlatform().getType(), System.getProperty("os.name"))); connection.setRequestProperty("Content-Type", "application/json"); connection.setRequestProperty("Authorization", "Basic YWRtaW46"); connection.setConnectTimeout(5000); diff --git a/MiraiMC-Bukkit/src/main/java/me/dreamvoid/miraimc/bukkit/BukkitPlugin.java b/MiraiMC-Bukkit/src/main/java/me/dreamvoid/miraimc/bukkit/BukkitPlugin.java index fb2389a2..7f0a794e 100644 --- a/MiraiMC-Bukkit/src/main/java/me/dreamvoid/miraimc/bukkit/BukkitPlugin.java +++ b/MiraiMC-Bukkit/src/main/java/me/dreamvoid/miraimc/bukkit/BukkitPlugin.java @@ -297,4 +297,9 @@ public PluginConfig getPluginConfig() { public LibraryLoader getLibraryLoader() { return loader; } + + @Override + public String getType() { + return "Bukkit"; + } } diff --git a/MiraiMC-Bukkit/src/main/java/me/dreamvoid/miraimc/paper/PaperPlugin.java b/MiraiMC-Bukkit/src/main/java/me/dreamvoid/miraimc/paper/PaperPlugin.java index 9417a7c4..7ff35d1f 100644 --- a/MiraiMC-Bukkit/src/main/java/me/dreamvoid/miraimc/paper/PaperPlugin.java +++ b/MiraiMC-Bukkit/src/main/java/me/dreamvoid/miraimc/paper/PaperPlugin.java @@ -124,4 +124,9 @@ public ClassLoader getPluginClassLoader() { public LibraryLoader getLibraryLoader() { return loader; } + + @Override + public String getType() { + return "Paper"; + } } diff --git a/MiraiMC-Bungee/src/main/java/me/dreamvoid/miraimc/bungee/BungeePlugin.java b/MiraiMC-Bungee/src/main/java/me/dreamvoid/miraimc/bungee/BungeePlugin.java index c2c55e35..ff72180d 100644 --- a/MiraiMC-Bungee/src/main/java/me/dreamvoid/miraimc/bungee/BungeePlugin.java +++ b/MiraiMC-Bungee/src/main/java/me/dreamvoid/miraimc/bungee/BungeePlugin.java @@ -164,6 +164,11 @@ public LibraryLoader getLibraryLoader() { return loader; } + @Override + public String getType() { + return "BungeeCord"; + } + @Override public void runTaskLaterAsync(Runnable task, long delay) { getProxy().getScheduler().schedule(this,task, delay * 50, TimeUnit.MILLISECONDS); diff --git a/MiraiMC-Nukkit/src/main/java/me/dreamvoid/miraimc/nukkit/NukkitPlugin.java b/MiraiMC-Nukkit/src/main/java/me/dreamvoid/miraimc/nukkit/NukkitPlugin.java index 711a1bef..1011f525 100644 --- a/MiraiMC-Nukkit/src/main/java/me/dreamvoid/miraimc/nukkit/NukkitPlugin.java +++ b/MiraiMC-Nukkit/src/main/java/me/dreamvoid/miraimc/nukkit/NukkitPlugin.java @@ -167,4 +167,9 @@ public PluginConfig getPluginConfig() { public LibraryLoader getLibraryLoader() { return loader; } + + @Override + public String getType() { + return "Nukkit"; + } } diff --git a/MiraiMC-Sponge/src/main/java/me/dreamvoid/miraimc/sponge/SpongePlugin.java b/MiraiMC-Sponge/src/main/java/me/dreamvoid/miraimc/sponge/SpongePlugin.java index 6ebd4a95..985b5da9 100644 --- a/MiraiMC-Sponge/src/main/java/me/dreamvoid/miraimc/sponge/SpongePlugin.java +++ b/MiraiMC-Sponge/src/main/java/me/dreamvoid/miraimc/sponge/SpongePlugin.java @@ -295,4 +295,9 @@ public PluginConfig getPluginConfig() { public LibraryLoader getLibraryLoader() { return loader; } + + @Override + public String getType() { + return "Sponge"; + } } diff --git a/MiraiMC-Velocity/src/main/java/me/dreamvoid/miraimc/velocity/VelocityPlugin.java b/MiraiMC-Velocity/src/main/java/me/dreamvoid/miraimc/velocity/VelocityPlugin.java index 7f5e4874..18c36571 100644 --- a/MiraiMC-Velocity/src/main/java/me/dreamvoid/miraimc/velocity/VelocityPlugin.java +++ b/MiraiMC-Velocity/src/main/java/me/dreamvoid/miraimc/velocity/VelocityPlugin.java @@ -228,4 +228,9 @@ public PluginConfig getPluginConfig() { public LibraryLoader getLibraryLoader() { return loader; } + + @Override + public String getType() { + return "Velocity"; + } }