#432 Create custom dependency injector
This commit is contained in:
@@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
@@ -28,6 +29,7 @@ public class PluginHooks {
|
||||
*
|
||||
* @param pluginManager The server's plugin manager
|
||||
*/
|
||||
@Inject
|
||||
public PluginHooks(PluginManager pluginManager) {
|
||||
this.pluginManager = pluginManager;
|
||||
tryHookToCombatPlus();
|
||||
@@ -75,13 +77,23 @@ public class PluginHooks {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the player is an NPC.
|
||||
*
|
||||
* @param player The player to process
|
||||
* @return True if player is NPC, false otherwise
|
||||
*/
|
||||
public boolean isNpc(Player player) {
|
||||
return player.hasMetadata("NPC") || isNpcInCombatTagPlus(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the CombatTagPlus plugin whether the given player is an NPC.
|
||||
*
|
||||
* @param player The player to verify
|
||||
* @return True if the player is an NPC according to CombatTagPlus, false if not or if the plugin is unavailable
|
||||
*/
|
||||
public boolean isNpcInCombatTagPlus(Player player) {
|
||||
private boolean isNpcInCombatTagPlus(Player player) {
|
||||
return combatTagPlus != null && combatTagPlus.getNpcPlayerHelper().isNpc(player);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user