use of com.bencodez.advancedcore.api.rewards.RewardOptions in project VotingPlugin by Ben12345rocks.
the class SpecialRewards method giveFirstVoteTodayRewards.
public void giveFirstVoteTodayRewards(VotingPluginUser user, boolean online, boolean forceBungee) {
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user, SpecialRewardType.FIRSTVOTETODAY);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
RewardHandler.getInstance().giveReward(user, plugin.getSpecialRewardsConfig().getData(), plugin.getSpecialRewardsConfig().getFirstVoteTodayRewardsPath(), new RewardOptions().setServer(forceBungee).setOnline(online));
}
use of com.bencodez.advancedcore.api.rewards.RewardOptions in project VotingPlugin by Ben12345rocks.
the class SpecialRewards method giveFirstVoteRewards.
public void giveFirstVoteRewards(VotingPluginUser user, boolean online, boolean forceBungee) {
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user, SpecialRewardType.FIRSTVOTE);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
RewardHandler.getInstance().giveReward(user, plugin.getSpecialRewardsConfig().getData(), plugin.getSpecialRewardsConfig().getFirstVoteRewardsPath(), new RewardOptions().setServer(forceBungee).setOnline(online));
}
use of com.bencodez.advancedcore.api.rewards.RewardOptions in project VotingPlugin by Ben12345rocks.
the class VoteTester method testRewards.
public void testRewards(int amount, String name, String rewardName) {
long time1 = System.currentTimeMillis();
ArrayList<Long> timesPerReward = new ArrayList<Long>();
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(name);
Reward reward = RewardHandler.getInstance().getReward(rewardName);
int rewardsGiven = 0;
for (int i = 0; i < amount; i++) {
long start1 = System.currentTimeMillis();
if (reward.canGiveReward(user, new RewardOptions())) {
rewardsGiven++;
RewardHandler.getInstance().giveReward(user, reward, new RewardOptions().setIgnoreRequirements(true));
}
long start2 = System.currentTimeMillis();
timesPerReward.add(start2 - start1);
}
long time2 = System.currentTimeMillis();
long time = time2 - time1;
long timeTotal = 0;
for (Long t : timesPerReward) {
timeTotal += t.longValue();
}
long timePerRewardAvg = timeTotal / timesPerReward.size();
VotingPluginMain.plugin.getLogger().info("Time to process rewards (" + amount + "): " + time + " ms, average per reward " + timePerRewardAvg + " ms. " + VotingPluginMain.plugin.getStorageType() + ", " + UserManager.getInstance().getAllUUIDs().size() + " users. " + rewardsGiven + " rewards given");
}
use of com.bencodez.advancedcore.api.rewards.RewardOptions in project VotingPlugin by Ben12345rocks.
the class VoteShopConfirm method onChest.
@Override
public void onChest(Player player) {
PlayerUtils.getInstance().setPlayerMeta(player, "ident", identifier);
BInventory inv = new BInventory(plugin.getGui().getChestShopConfirmPurchaseTitle());
inv.dontClose();
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopConfirmPurchaseYesItem())) {
@Override
public void onClick(ClickEvent event) {
user.clearCache();
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
HashMap<String, String> placeholders = new HashMap<String, String>();
placeholders.put("identifier", identifier);
placeholders.put("points", "" + points);
placeholders.put("limit", "" + limit);
if (user.removePoints(points)) {
plugin.getLogger().info("VoteShop: " + user.getPlayerName() + "/" + user.getUUID() + " bought " + identifier + " for " + points);
RewardHandler.getInstance().giveReward(user, plugin.getGui().getData(), plugin.getGui().getChestShopIdentifierRewardsPath(identifier), new RewardOptions().setPlaceholders(placeholders));
user.sendMessage(StringParser.getInstance().replacePlaceHolder(plugin.getGui().getCHESTVoteShopPurchase(identifier), placeholders));
if (limit > 0) {
user.setVoteShopIdentifierLimit(identifier, user.getVoteShopIdentifierLimit(identifier) + 1);
}
} else {
user.sendMessage(StringParser.getInstance().replacePlaceHolder(plugin.getConfigFile().getFormatShopFailedMsg(), placeholders));
}
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
event.getButton().getInv().closeInv(player, null);
} else {
new VoteShop(plugin, event.getPlayer(), user).open();
}
}
});
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopConfirmPurchaseNoItem())) {
@Override
public void onClick(ClickEvent event) {
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
event.getButton().getInv().closeInv(player, null);
} else {
new VoteShop(plugin, event.getPlayer(), user).open();
}
}
});
inv.openInventory(player);
}
Aggregations