Add api to get the build version of jail
More for future api usage for other plugins, to determine if the running version has certain features.
This commit is contained in:
parent
68e35ed271
commit
89f709390a
@ -21,6 +21,22 @@ public class JailsAPI {
|
||||
pl = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the build number, it will return <strong>-1</strong> if an errors occurs.
|
||||
*
|
||||
* @return the build number of jail or -1 if an error occurred.
|
||||
*/
|
||||
public static int getBuildNumber() {
|
||||
String v = pl.getDescription().getVersion();
|
||||
String[] split = v.split("-");
|
||||
|
||||
try {
|
||||
return Integer.parseInt(split[split.length - 1].replace("b", ""));
|
||||
}catch(NumberFormatException e) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The instance of the {@link JailManager} which contains all the jails and in return prisoners.
|
||||
*
|
||||
|
@ -5,6 +5,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@ -46,6 +47,11 @@ public class TestJailAPI {
|
||||
main = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildNumber() {
|
||||
assertSame("The build version from the api was not 0.", 0, JailsAPI.getBuildNumber());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManagersAreThere() {
|
||||
assertNotNull(main.getHandCuffManager());
|
||||
|
@ -92,7 +92,7 @@ public class TestInstanceCreator {
|
||||
suppress(constructor(JailMain.class));
|
||||
main = PowerMockito.spy(new JailMain());
|
||||
|
||||
PluginDescriptionFile pdf = PowerMockito.spy(new PluginDescriptionFile("Jail", "3.0.0-Test", "com.graywolf336.jail.JailMain"));
|
||||
PluginDescriptionFile pdf = PowerMockito.spy(new PluginDescriptionFile("Jail", "3.0.0-SNAPSHOT-b0", "com.graywolf336.jail.JailMain"));
|
||||
when(pdf.getPrefix()).thenReturn("Jail");
|
||||
List<String> authors = new ArrayList<String>();
|
||||
authors.add("matejdro");
|
||||
|
Loading…
Reference in New Issue
Block a user