Moved ShopkeepersAPI reference to listener

pull/18/head
Joey Hines 2021-08-09 19:27:11 -06:00
parent 006a3a2c0d
commit e036627fb1
No known key found for this signature in database
GPG Key ID: 80F567B5C968F91B
2 changed files with 4 additions and 12 deletions

View File

@ -1,6 +1,5 @@
package xyz.etztech.qol;
import com.nisovin.shopkeepers.api.ShopkeepersAPI;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import github.scarsz.discordsrv.DiscordSRV;
import net.md_5.bungee.api.chat.BaseComponent;
@ -10,7 +9,6 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.dynmap.DynmapAPI;
import org.dynmap.markers.Marker;
import org.dynmap.markers.MarkerAPI;
@ -40,7 +38,6 @@ public class QoL extends JavaPlugin {
private MarkerSet playerMarkerSet = null;
private boolean qolMarkerLayerShow = false;
private String qolMarkerSetLabel = null;
private ShopkeepersPlugin shopkeepersAPI = null;
public static FileConfiguration config;
private Logger log = Logger.getLogger( "Minecraft" );
@ -101,10 +98,7 @@ public class QoL extends JavaPlugin {
// Shopkeepers Hook
if (Bukkit.getPluginManager().isPluginEnabled("Shopkeepers")) {
shopkeepersAPI = ShopkeepersPlugin.getInstance();
new HeadShopListener(this);
log("Hooked in Shopkeepers for the head shop");
}
@ -359,9 +353,5 @@ public class QoL extends JavaPlugin {
public Spark getSpark() {
return spark;
}
public ShopkeepersPlugin getShopkeepersAPI() {
return shopkeepersAPI;
}
}

View File

@ -18,18 +18,20 @@ import java.util.List;
public class HeadShopListener implements Listener{
private QoL plugin;
private final QoL plugin;
private final ShopkeepersPlugin shopkeepersAPI;
public HeadShopListener(QoL plugin) {
this.plugin = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
this.shopkeepersAPI = ShopkeepersPlugin.getInstance();
}
@EventHandler
public void onJoin(PlayerJoinEvent event) {
final Player player = event.getPlayer();
ShopkeepersPlugin shopkeepersAPI = plugin.getShopkeepersAPI();
if (shopkeepersAPI != null && player.hasPermission("qol.head_shop")) {
int shopKeeperID = plugin.getConfig().getInt("head_shop.id", -1);