77import de .erethon .questsxl .common .QConfigLoader ;
88import de .erethon .questsxl .common .QRegistries ;
99import de .erethon .questsxl .common .Quester ;
10+ import de .erethon .questsxl .condition .QCondition ;
1011import de .erethon .questsxl .error .FriendlyError ;
12+ import de .erethon .questsxl .player .QPlayer ;
1113import org .bukkit .Location ;
1214import org .bukkit .configuration .ConfigurationSection ;
15+ import org .bukkit .entity .Player ;
1316
1417import java .util .HashSet ;
1518import java .util .Set ;
@@ -18,13 +21,37 @@ public class AetherHolder implements QComponent, Quester {
1821
1922 private AetherBaseMob mob ;
2023
24+ private Set <QCondition > visibilityConditions = new HashSet <>();
25+ private Set <QCondition > spawnConditions = new HashSet <>();
2126 private Set <QAction > rightClickActions = new HashSet <>();
2227 private Set <QAction > leftClickActions = new HashSet <>();
2328 private Set <QAction > deathActions = new HashSet <>();
2429 private Set <QAction > spawnActions = new HashSet <>();
2530 private Set <QAction > damageActions = new HashSet <>();
2631 private Set <QAction > attackActions = new HashSet <>();
2732
33+ public boolean checkVisibilityConditions (Player player ) {
34+ QPlayer qPlayer = QuestsXL .get ().getDatabaseManager ().getCurrentPlayer (player );
35+ if (qPlayer == null ) {
36+ return false ;
37+ }
38+ for (QCondition condition : visibilityConditions ) {
39+ if (!condition .check (qPlayer )) {
40+ return false ;
41+ }
42+ }
43+ return true ;
44+ }
45+
46+ public boolean checkSpawnConditions () {
47+ for (QCondition condition : spawnConditions ) {
48+ if (!condition .check (this )) {
49+ return false ;
50+ }
51+ }
52+ return true ;
53+ }
54+
2855 public void onDeath () {
2956 if (deathActions == null || deathActions .isEmpty ()) {
3057 return ;
@@ -123,6 +150,8 @@ public static AetherHolder loadFromConfigSection(ConfigurationSection section, A
123150 String mobID = mob .getData ().getID ();
124151 holder .mob = mob ;
125152 try {
153+ holder .visibilityConditions = (Set <QCondition >) QConfigLoader .load (holder , "visibilityConditions" , section , QRegistries .CONDITIONS );
154+ holder .spawnConditions = (Set <QCondition >) QConfigLoader .load (holder , "spawnConditions" , section , QRegistries .CONDITIONS );
126155 holder .rightClickActions = (Set <QAction >) QConfigLoader .load (holder , "rightClickActions" , section , QRegistries .ACTIONS );
127156 holder .leftClickActions = (Set <QAction >) QConfigLoader .load (holder , "leftClickActions" , section , QRegistries .ACTIONS );
128157 holder .deathActions = (Set <QAction >) QConfigLoader .load (holder , "deathActions" , section , QRegistries .ACTIONS );
0 commit comments