Never reset a player's YouTube click time locally

This commit is contained in:
cnr 2016-06-24 16:59:27 -05:00
parent 94fe9f57d2
commit c430566c6d
3 changed files with 6 additions and 30 deletions

View File

@ -1,13 +1,7 @@
package mineplex.core.bonuses.gui;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.bonuses.gui.buttons.CarlSpinButton;
import mineplex.core.bonuses.gui.buttons.ClaimTipsButton;
import mineplex.core.bonuses.gui.buttons.DailyBonusButton;
import mineplex.core.bonuses.gui.buttons.FacebookButton;
import mineplex.core.bonuses.gui.buttons.PollButton;
import mineplex.core.bonuses.gui.buttons.RankBonusButton;
import mineplex.core.bonuses.gui.buttons.VoteButton;
import mineplex.core.bonuses.gui.buttons.*;
import mineplex.core.boosters.BoosterManager;
import mineplex.core.facebook.FacebookManager;
import mineplex.core.gui.SimpleGui;
@ -37,9 +31,9 @@ public class BonusGui extends SimpleGui
setItem(19, new FacebookButton(player, facebookManager));
//setItem(21, new YoutubeButton(player, youtubeManager));
setItem(21, new YoutubeButton(player, youtubeManager));
//setItem(23, new TwitterButton(player));
setItem(23, new TwitterButton(player));
setItem(25, new ClaimTipsButton(getPlugin(), player, this, manager, boosterManager));

View File

@ -48,16 +48,7 @@ public class YoutubeManager extends MiniDbClientPlugin<YoutubeClient>
}
YoutubeClient client = Get(player);
client.setClickDate(ZonedDateTime.now(ZoneOffset.UTC).toLocalDate());
_repository.attemptYoutube(player, client, success ->
{
if (success)
{
_donationManager.RewardCoinsLater("YouTube", player, 250);
} else
{
client.setClickDate(null);
}
});
_repository.attemptYoutube(player, client, () -> _donationManager.RewardCoinsLater("YouTube", player, 250));
}
@Override

View File

@ -1,6 +1,5 @@
package mineplex.core.youtube;
import mineplex.core.common.util.Callback;
import mineplex.serverdata.database.DBPool;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -19,7 +18,7 @@ public class YoutubeRepository
_manager = manager;
}
public void attemptYoutube(Player player, YoutubeClient client, Callback<Boolean> callback)
public void attemptYoutube(Player player, YoutubeClient client, Runnable runnable)
{
int accountId = _manager.getClientManager().Get(player).getAccountId();
@ -32,20 +31,12 @@ public class YoutubeRepository
statement.setDate(2, Date.valueOf(client.getClickDate()));
statement.executeUpdate();
if (callback != null)
{
callback.run(true);
}
runnable.run();
}
catch (SQLException e)
{
e.printStackTrace();
}
if (callback != null)
{
callback.run(false);
}
});
}