package parachute.scripts.pwoodcutter.strategies;

import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.framework.Strategy;
import org.rev317.min.api.methods.GroundItems;
import org.rev317.min.api.methods.Inventory;
import org.rev317.min.api.methods.Players;
import org.rev317.min.api.methods.SceneObjects;
import org.rev317.min.api.wrappers.GroundItem;
import org.rev317.min.api.wrappers.SceneObject;

import parachute.scripts.pwoodcutter.main.Data;

public class CutEvent implements Strategy {

	GroundItem[] nests;
	SceneObject[] chosen;

	@Override
	public boolean activate() {
		nests = GroundItems.getNearest(Data.nestids);
		chosen = SceneObjects.getNearest(Data.idchosen);
		return chosen.length > 0 && chosen[0] != null && !Inventory.isFull() && nestTrue() && Data.chosenRegion.isInRegion();
	}

	@Override
	public void execute() {
		SceneObject[] chosen = SceneObjects.getNearest(Data.idchosen);
		if (chosen[0] != null) {
			if (chosen[0].getLocation().distanceTo() < 20) {
				chosen[0].interact(1);
				Time.sleep(2000);
			}
			while (Players.getMyPlayer().getAnimation() != -1
					&& !Inventory.isFull() && nestTrue()
					&& chosen[0] != null && logErbij()) {
				nests = GroundItems.getNearest(Data.nestids);
				Time.sleep(10);
			}
		}
	}
	
	public boolean logErbij(){
		int Inventory1 = Inventory.getCount();
		Time.sleep(1500);
		int Inventory2 = Inventory.getCount();
		return Inventory1 < Inventory2;		
		
	}
	
	public boolean nestTrue(){
		if(Data.Method == "Banking"){
			if(nests.length <= 0){
				return true;
			}
		}
		if(Data.Method == "Empty"){
			return true;
		}
		return false;
	}

}

@@ -869,30 +869,16 @@
 e() %7B%0A%09%09
-SceneObject%5B%5D 
 chosen =
@@ -949,60 +949,8 @@
 ) %7B%0A
-%09%09%09if (chosen%5B0%5D.getLocation().distanceTo() %3C 20) %7B%0A
 %09%09%09%09
@@ -994,21 +994,16 @@
 (2000);%0A
-%09%09%09%7D%0A
 %09%09%09while
@@ -1210,24 +1210,25 @@
 %09%09%09%7D%0A%09%09%7D%0A%09%7D%0A
+%0A
 %09%0A%09public bo

Update CutEvent.java