I'm not exactly sure what "this" refers to in your first snippet so I can't help you with that but when you call interact() on anything, an InteractionEvent instance is created with a default threshold of 5 attempts so it may execute the same action up to 5 times and it's equivalent to
InteractionEvent e = new InteractionEvent(someEntity, someAction);
e.setCameraDistance(14);
e.setHover(false);
e.setMaximumAttempts(5);
e.setOperateCamera(true);
script.execute(e);
In java we use the equals() method to compare 2 non-primitives like String instances so your condition should be
@Override
public boolean condition() throws InterruptedException {
return script.inventory.getItemInSlot(27).getName().equals("Jug of water");
}
But you should take into consideration this will throw a NullPointerException if there is no item in that slot, eg when you don't have 28 jugs left and you only go to fountain with 20, so maybe this may work better
@Override
public boolean condition() {
return !script.inventory.contains("Jug");
}
Also void using any animations as they are not continuous and therefore not reliable (there is a short transition time between animations when the method returns false)