use of pw.codehusky.huskycrates.crate.CrateCommandSource in project HuskyCrates-Sponge by codeHusky.
the class SpinnerCrateView method updateTick.
private void updateTick() {
//revDampening = 1.15;
waitCurrent++;
//once clicks is greater than offset we stop the spinner
if (waitCurrent == Math.round(updateMax) && clicks < offset && tickerState == 0) {
//System.out.println(clicks + " : " + offset);
waitCurrent = 0;
updateMax *= dampening;
updateInv(-1);
ourplr.playSound(SoundTypes.UI_BUTTON_CLICK, ourplr.getLocation().getPosition(), 0.25);
clicks++;
trueclicks++;
//HuskyCrates.instance.logger.info(maxClicks + " : " + trueclicks);
} else if (clicks >= offset && updateMax != 100 && tickerState == 0) {
ourplr.openInventory(disp, plugin.genericCause);
tickerState = 1;
ourplr.playSound(SoundTypes.ENTITY_FIREWORK_LAUNCH, ourplr.getLocation().getPosition(), 1);
updateMax = 100;
waitCurrent = 0;
} else if (tickerState == 1) {
if (waitCurrent == Math.round(updateMax)) {
updater.cancel();
ourplr.closeInventory(plugin.genericCause);
if (giveToPlayer.getReward().getReward() instanceof String) {
Sponge.getCommandManager().process(new CrateCommandSource(), giveToPlayer.getReward().getReward().toString().replace("%p", ourplr.getName()));
} else {
//System.out.println(giveToPlayer.getReward().treatAsSingle());
ourplr.getInventory().offer((ItemStack) giveToPlayer.getReward().getReward());
}
boolean mult = false;
if (!giveToPlayer.getReward().treatAsSingle() && giveToPlayer.getReward().getReward() instanceof ItemStack) {
if (((ItemStack) giveToPlayer.getReward().getReward()).getQuantity() > 1) {
/*ourplr.sendMessage(Text.of("You won ", TextColors.YELLOW,
((ItemStack) giveToPlayer.getReward().getReward()).getQuantity() + " ",
TextSerializers.FORMATTING_CODE.deserialize(giveToPlayer.getReward().getRewardName()), TextColors.RESET, " from a ",
TextSerializers.FORMATTING_CODE.deserialize(vc.displayName), TextColors.RESET, "!"));*/
ourplr.sendMessage(TextSerializers.FORMATTING_CODE.deserialize(vc.langData.formatter(vc.langData.prefix + vc.langData.rewardMessage, ((ItemStack) giveToPlayer.getReward().getReward()).getQuantity() + "", ourplr, vc, giveToPlayer)));
mult = true;
}
}
if (!mult) {
String[] vowels = { "a", "e", "i", "o", "u" };
if (Arrays.asList(vowels).contains(giveToPlayer.getReward().getRewardName().substring(0, 1).toLowerCase())) {
ourplr.sendMessage(TextSerializers.FORMATTING_CODE.deserialize(vc.langData.formatter(vc.langData.prefix + vc.langData.rewardMessage, "an", ourplr, vc, giveToPlayer)));
} else {
ourplr.sendMessage(TextSerializers.FORMATTING_CODE.deserialize(vc.langData.formatter(vc.langData.prefix + vc.langData.rewardMessage, "a", ourplr, vc, giveToPlayer)));
}
}
ourplr.playSound(SoundTypes.ENTITY_EXPERIENCE_ORB_PICKUP, ourplr.getLocation().getPosition(), 1);
} else if (waitCurrent % 5 == 0) {
updateInv(2);
}
}
}
Aggregations