A rewrite of winescript in Java