mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-22 02:25:49 +01:00
Now gets mc version from spigot
This commit is contained in:
parent
3e34ea8a0d
commit
ed3c28faee
@ -138,10 +138,8 @@ public class DataStorage {
|
||||
File inFile = new File(dataFolder, location);
|
||||
if (inFile.exists() && !inFile.isDirectory()) {
|
||||
try {
|
||||
System.out.println("OUTPUT 1");
|
||||
return new FileInputStream(inFile);
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("OUTPUT 2");
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
@ -150,7 +148,6 @@ public class DataStorage {
|
||||
copyDefaultFile(location, false);
|
||||
return this.getClass().getClassLoader().getResourceAsStream(location);
|
||||
} catch (NullPointerException e) {
|
||||
System.out.println("OUTPUT 4");
|
||||
e.printStackTrace();
|
||||
this.portalsCore.getInfoLogger().logWarning("Could not load " + location + ". The file does" +
|
||||
"not exist or there has been an error reading the file.");
|
||||
|
@ -10,6 +10,10 @@ import com.sekwah.advancedportals.metrics.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
|
||||
private AdvancedPortalsCore portalsCore;
|
||||
@ -24,9 +28,23 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
|
||||
Metrics metrics = new Metrics(this);
|
||||
|
||||
Pattern p = Pattern.compile("\\(MC:\\s([0-9].[0-9]+.[0-9]+)\\)");
|
||||
Matcher m = p.matcher(Bukkit.getVersion());
|
||||
if(m.find()) {
|
||||
String version = m.group(1);
|
||||
String[] versionNums = version.split("\\.");
|
||||
int[] versionInts = new int[versionNums.length];
|
||||
for(int i=0;i <versionNums.length; i++) {
|
||||
versionInts[i] = Integer.parseInt(versionNums[i]);
|
||||
}
|
||||
this.portalsCore = new AdvancedPortalsCore(this.getDataFolder(),
|
||||
new SpigotInfoLogger(this), new CommandRegister(this), new ConnectorDataCollector(), versionInts);
|
||||
}
|
||||
else {
|
||||
this.getLogger().warning("Could not parse mc version from: " + Bukkit.getVersion());
|
||||
this.setEnabled(false);
|
||||
}
|
||||
// TODO actually get the minecraft version
|
||||
this.portalsCore = new AdvancedPortalsCore(this.getDataFolder(),
|
||||
new SpigotInfoLogger(this), new CommandRegister(this), new ConnectorDataCollector(), new int[]{1,12,2});
|
||||
//injector = Guice.createInjector(new RepositoryModule(this.portalsCore));
|
||||
this.getServer().getPluginManager().registerEvents(new Listeners(), this);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user