mirror of
https://github.com/PaperMC/Paper.git
synced 2024-09-12 15:08:27 +02:00
Implemented bukkit versioning
This commit is contained in:
parent
6c9cb5a95e
commit
b1671be875
@ -70,6 +70,7 @@ import org.bukkit.craftbukkit.inventory.CraftShapelessRecipe;
|
||||
import org.bukkit.craftbukkit.map.CraftMapView;
|
||||
import org.bukkit.scheduler.BukkitWorker;
|
||||
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
|
||||
import org.bukkit.craftbukkit.util.Versioning;
|
||||
import org.bukkit.util.permissions.DefaultPermissions;
|
||||
import org.bukkit.event.world.WorldInitEvent;
|
||||
import org.bukkit.permissions.Permission;
|
||||
@ -82,6 +83,7 @@ public final class CraftServer implements Server {
|
||||
private final String serverName = "Craftbukkit";
|
||||
private final String serverVersion;
|
||||
private final String protocolVersion = "1.8.1";
|
||||
private final String bukkitVersion = Versioning.getBukkitVersion();
|
||||
private final ServicesManager servicesManager = new SimpleServicesManager();
|
||||
private final BukkitScheduler scheduler = new CraftScheduler(this);
|
||||
private final SimpleCommandMap commandMap = new SimpleCommandMap(this);
|
||||
@ -191,6 +193,10 @@ public final class CraftServer implements Server {
|
||||
public String getVersion() {
|
||||
return serverVersion + " (MC: " + protocolVersion + ")";
|
||||
}
|
||||
|
||||
public String getBukkitVersion() {
|
||||
return bukkitVersion;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Player[] getOnlinePlayers() {
|
||||
|
29
src/main/java/org/bukkit/craftbukkit/util/Versioning.java
Normal file
29
src/main/java/org/bukkit/craftbukkit/util/Versioning.java
Normal file
@ -0,0 +1,29 @@
|
||||
package org.bukkit.craftbukkit.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public final class Versioning {
|
||||
public static String getBukkitVersion() {
|
||||
String result = "Unknown-Version";
|
||||
|
||||
InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/org.bukkit/bukkit/pom.properties");
|
||||
Properties properties = new Properties();
|
||||
|
||||
if (stream != null) {
|
||||
try {
|
||||
properties.load(stream);
|
||||
|
||||
result = properties.getProperty("version");
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(Versioning.class.getName()).log(Level.SEVERE, "Could not get Bukkit version!", ex);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user