Properly disable plugin, throw custom exception when plugin is incompatible
This commit is contained in:
parent
185b70cf54
commit
8232518abb
@ -64,7 +64,6 @@ public class Chairs extends JavaPlugin {
|
|||||||
nmsaccess.setupVehicleArrow();
|
nmsaccess.setupVehicleArrow();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
log.severe("Failed to generate VehicleArrow class, exiting");
|
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -91,6 +90,7 @@ public class Chairs extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
if (psitdata != null) {
|
||||||
for (Player player : getServer().getOnlinePlayers()) {
|
for (Player player : getServer().getOnlinePlayers()) {
|
||||||
if (psitdata.isSitting(player)) {
|
if (psitdata.isSitting(player)) {
|
||||||
PlayerChairUnsitEvent playerunsitevent = new PlayerChairUnsitEvent(player, false);
|
PlayerChairUnsitEvent playerunsitevent = new PlayerChairUnsitEvent(player, false);
|
||||||
@ -98,6 +98,7 @@ public class Chairs extends JavaPlugin {
|
|||||||
psitdata.unsitPlayerNow(player);
|
psitdata.unsitPlayerNow(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (ignoreList != null) {
|
if (ignoreList != null) {
|
||||||
ignoreList.save();
|
ignoreList.save();
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ public class NMSAccess {
|
|||||||
|
|
||||||
private Class<?> nmsArrowClass;
|
private Class<?> nmsArrowClass;
|
||||||
|
|
||||||
public void setupVehicleArrow() throws Exception {
|
public void setupVehicleArrow() throws NMSAccessException, ClassNotFoundException {
|
||||||
String pkgname = getClass().getPackage().getName();
|
String pkgname = getClass().getPackage().getName();
|
||||||
String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
||||||
String nmspackageversion = packageName.substring(packageName.lastIndexOf('.') + 1);
|
String nmspackageversion = packageName.substring(packageName.lastIndexOf('.') + 1);
|
||||||
@ -26,7 +26,7 @@ public class NMSAccess {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception("ChairsReloaded is not compatible with your server version");
|
throw new NMSAccessException("ChairsReloaded is not compatible with your server version");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Arrow spawnArrow(Location location) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
public Arrow spawnArrow(Location location) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
11
src/com/cnaude/chairs/vehiclearrow/NMSAccessException.java
Normal file
11
src/com/cnaude/chairs/vehiclearrow/NMSAccessException.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package com.cnaude.chairs.vehiclearrow;
|
||||||
|
|
||||||
|
public class NMSAccessException extends Exception {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -839103433400420225L;
|
||||||
|
|
||||||
|
public NMSAccessException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user