Fixed NPE error when dependency plugin not found

Fixed Chat error causing chat prefixes to stop working
Updated to QuickShop Reremake 3.0.2 API
Dropped filename versioning number.
This commit is contained in:
Judgetread 2020-01-08 00:56:55 +10:00
parent 3a05a15ac6
commit 5334d90daa
4 changed files with 18 additions and 11 deletions

Binary file not shown.

View File

@ -6,7 +6,7 @@
<groupId>com.github.judgetread</groupId>
<artifactId>GriefPreventionQuickShopBridge</artifactId>
<version>1.0.1</version>
<version>1.1.0</version>
<licenses>
<license>
@ -32,6 +32,7 @@
</scm>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -41,6 +42,7 @@
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<outputFileName>${project.artifactId}</outputFileName>
<!--Use this comments args when compiler is NullPointerException-->
<!--<forceJavacCompilerUse>true</forceJavacCompilerUse>-->
</configuration>
@ -143,7 +145,7 @@
<dependency>
<groupId>org.maxgamer</groupId>
<artifactId>QuickShop</artifactId>
<version>Reremake 2.4.9.1</version>
<version>Reremake 3.0.2</version>
<scope>system</scope>
<systemPath>${basedir}/lib/QuickShop-Reremake.2.4.9.jar</systemPath>
</dependency>

View File

@ -79,6 +79,11 @@ public class GriefPreventionQuickShopBridge extends JavaPlugin {
*/
private void startup() {
loadHooks();
if(griefPrevention == null || quickShop == null){
Bukkit.getConsoleSender().sendMessage(" Missing dependency of either GriefPrevention or QuickShop");
Bukkit.getConsoleSender().sendMessage(" Unable to ");
this.getPluginLoader().disablePlugin(this);
}
registerListeners();
}
@ -113,8 +118,8 @@ public class GriefPreventionQuickShopBridge extends JavaPlugin {
*/
private void loadHooks() {
Bukkit.getConsoleSender().sendMessage(" Loading Hooks...");
griefPrevention = hookPlugin(this.getName() + " GriefPrevention");
quickShop = hookPlugin(this.getName() + " QuickShop");
griefPrevention = hookPlugin("GriefPrevention");
quickShop = hookPlugin("QuickShop");
}
/**
@ -135,7 +140,7 @@ public class GriefPreventionQuickShopBridge extends JavaPlugin {
* @param pluginName String name of the plugin.
* @return Plugin
*/
private @Nullable Plugin hookPlugin(@NotNull @NonNull String pluginName) {
private @Nullable Plugin hookPlugin(@NotNull String pluginName) {
@Nullable Plugin thirdPlugin = Bukkit.getPluginManager().getPlugin(pluginName);
if (thirdPlugin != null) {
Bukkit.getConsoleSender().sendMessage(" Hooked: " + pluginName);

View File

@ -28,7 +28,7 @@ public class GriefPreventionListener implements Listener {
/**
* GriefPrevention Claim Delete Event
*
* @param event
* @param event ClaimDeletedEvent
*/
@EventHandler
public void onClaimDeleteEvent(ClaimDeletedEvent event) {
@ -40,7 +40,7 @@ public class GriefPreventionListener implements Listener {
/**
* GriefPrevention Claim Expire Event
*
* @param event
* @param event ClaimExpirationEvent
*/
@EventHandler
public void onClaimExpireEvent(ClaimExpirationEvent event) {
@ -55,8 +55,8 @@ public class GriefPreventionListener implements Listener {
*
* @param claim A GriefPrevention claim
*/
private void deleteAllShopsInClaim(final Claim claim) {
if(claim == null){
private void deleteAllShopsInClaim(Claim claim) {
if(claim == null || claim.equals(null)){
return;
}
@ -81,9 +81,9 @@ public class GriefPreventionListener implements Listener {
}
// Try force saving of chunk ???
loc.getChunk().addPluginChunkTicket(plugin);
//loc.getChunk().addPluginChunkTicket(plugin);
shop.delete(false);
loc.getChunk().removePluginChunkTicket(plugin);
//loc.getChunk().removePluginChunkTicket(plugin);
}
}