use of com.github.jikoo.planarwrappers.tuple.Pair in project Easterlyn by Easterlyn.
the class Dublexor method unCaptcha.
private Pair<ItemStack, Integer> unCaptcha(ItemStack potentialCaptcha) {
try {
Class.forName("com.easterlyn.EasterlynCaptchas");
} catch (ClassNotFoundException e) {
return new Pair<>(potentialCaptcha, 1);
}
RegisteredServiceProvider<EasterlynCaptchas> registration = getMachines().getServer().getServicesManager().getRegistration(EasterlynCaptchas.class);
if (registration == null) {
return new Pair<>(potentialCaptcha, 1);
}
int multiplier = 1;
while (EasterlynCaptchas.isUsedCaptcha(potentialCaptcha)) {
ItemStack newModInput = registration.getProvider().getItemByCaptcha(potentialCaptcha);
if (newModInput == null || potentialCaptcha.isSimilar(newModInput)) {
// Broken captcha, don't infinitely loop.
potentialCaptcha = barrier;
break;
}
multiplier = Math.multiplyExact(multiplier, Math.max(1, Math.abs(potentialCaptcha.getAmount())));
potentialCaptcha = newModInput;
}
return new Pair<>(potentialCaptcha, multiplier);
}
Aggregations