Fixed callbacks for gem/coin rewards.
This commit is contained in:
parent
526b0dadb6
commit
86e2514e37
@ -139,10 +139,10 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
donor.AddGems(amount);
|
||||
}
|
||||
}
|
||||
|
||||
if (callback != null)
|
||||
callback.run(true);
|
||||
}
|
||||
|
||||
if (callback != null)
|
||||
callback.run(success);
|
||||
}
|
||||
}, caller, name, uuid.toString(), amount);
|
||||
}
|
||||
@ -221,10 +221,10 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
donor.addCoins(amount);
|
||||
}
|
||||
}
|
||||
|
||||
if (callback != null)
|
||||
callback.run(true);
|
||||
}
|
||||
|
||||
if (callback != null)
|
||||
callback.run(success);
|
||||
}
|
||||
}, caller, name, accountId, amount);
|
||||
}
|
||||
|
@ -75,11 +75,18 @@ public class CoinCommand extends CommandBase<DonationManager>
|
||||
{
|
||||
public void run(Boolean completed)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Coin", "You gave " + F.elem(coins + " Coins") + " to " + F.name(targetName) + "."));
|
||||
|
||||
if (target != null)
|
||||
if (completed)
|
||||
{
|
||||
UtilPlayer.message(target, F.main("Coin", F.name(caller.getName()) + " gave you " + F.elem(coins + " Coins") + "."));
|
||||
UtilPlayer.message(caller, F.main("Coin", "You gave " + F.elem(coins + " Coins") + " to " + F.name(targetName) + "."));
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
UtilPlayer.message(target, F.main("Coin", F.name(caller.getName()) + " gave you " + F.elem(coins + " Coins") + "."));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Coin", "There was an error giving " + F.elem(coins + "Coins") + " to " + F.name(targetName) + "."));
|
||||
}
|
||||
}
|
||||
}, caller.getName(), targetName, accountId, coins);
|
||||
|
@ -69,11 +69,18 @@ public class GemCommand extends CommandBase<DonationManager>
|
||||
{
|
||||
public void run(Boolean completed)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("gem", "You gave " + F.elem(gems + " gems") + " to " + F.name(targetName) + "."));
|
||||
|
||||
if (target != null)
|
||||
if (completed)
|
||||
{
|
||||
UtilPlayer.message(target, F.main("gem", F.name(caller.getName()) + " gave you " + F.elem(gems + " gems") + "."));
|
||||
UtilPlayer.message(caller, F.main("gem", "You gave " + F.elem(gems + " gems") + " to " + F.name(targetName) + "."));
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
UtilPlayer.message(target, F.main("gem", F.name(caller.getName()) + " gave you " + F.elem(gems + " gems") + "."));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("gem", "There was an error giving " + F.elem(gems + " gems") + " to " + F.name(targetName) + "."));
|
||||
}
|
||||
}
|
||||
}, caller.getName(), targetName, uuid, gems);
|
||||
|
@ -144,4 +144,12 @@ public class TaskManager extends MiniDbClientPlugin<TaskClient>
|
||||
{
|
||||
return "SELECT taskId FROM accountTasks WHERE accountId = '" + accountId + "';";
|
||||
}
|
||||
|
||||
public Integer getTaskId(String taskName)
|
||||
{
|
||||
synchronized (_taskLock)
|
||||
{
|
||||
return _tasks.get(taskName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -398,10 +398,18 @@ public class ParkourManager extends MiniPlugin
|
||||
{
|
||||
public void run(Boolean completed)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Parkour", "You received " + F.elem(C.cGreen + fData.Gems + " Gems") + "."));
|
||||
if (completed)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Parkour", "You received " + F.elem(C.cGreen + fData.Gems + " Gems") + "."));
|
||||
|
||||
//Sound
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
|
||||
//Sound
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
_taskManager.Get(player).TasksCompleted.remove(_taskManager.getTaskId(fData.Name));
|
||||
UtilPlayer.message(player, F.main("Parkour", "There as an error giving " + F.elem(C.cGreen + fData.Gems + " gems to you. Please click the NPC again.") + "."));
|
||||
}
|
||||
}
|
||||
}, "Parkour " + fData.Name, player.getName(), player.getUniqueId(), fData.Gems);
|
||||
|
||||
|
@ -150,9 +150,6 @@ public class PollManager extends MiniDbClientPlugin<PlayerPollData>
|
||||
// First update answer locally so we know it was answered
|
||||
Get(player).addAnswer(poll.getId(), answer);
|
||||
|
||||
UtilPlayer.message(player, F.main("Poll", "Thanks for your response!"));
|
||||
player.playSound(player.getEyeLocation(), Sound.LEVEL_UP, 1F, 0);
|
||||
|
||||
// Here we add the answer into the database, and once that is successful we give the coin reward
|
||||
_plugin.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable()
|
||||
{
|
||||
@ -167,15 +164,20 @@ public class PollManager extends MiniDbClientPlugin<PlayerPollData>
|
||||
@Override
|
||||
public void run(Boolean completed)
|
||||
{
|
||||
// Need to get out of Async code
|
||||
_plugin.getServer().getScheduler().runTask(_plugin, new Runnable()
|
||||
if (completed)
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
// Need to get out of Async code
|
||||
_plugin.getServer().getScheduler().runTask(_plugin, new Runnable()
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Gem", "You received " + F.elem(poll.getCoinReward() + "") + " Gems!"));
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Poll", "Thanks for your response!"));
|
||||
player.playSound(player.getEyeLocation(), Sound.LEVEL_UP, 1F, 0);
|
||||
UtilPlayer.message(player, F.main("Gem", "You received " + F.elem(poll.getCoinReward() + "") + " Gems!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}, "Poll", name, uuid, poll.getCoinReward());
|
||||
}
|
||||
|
@ -137,10 +137,13 @@ public class TutorialManager extends MiniPlugin
|
||||
{
|
||||
public void run(Boolean completed)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Tutorial", "You received " + F.elem(C.cGreen + tut.GetGems() + " Gems") + "."));
|
||||
if (completed)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Tutorial", "You received " + F.elem(C.cGreen + tut.GetGems() + " Gems") + "."));
|
||||
|
||||
//Sound
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
|
||||
//Sound
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
|
||||
}
|
||||
}
|
||||
}, "Tutorial " + tut.GetTutName(), player.getName(), player.getUniqueId(), tut.GetGems());
|
||||
}
|
||||
|
@ -7,8 +7,10 @@ import org.bukkit.entity.Player;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
public class CoinCommand extends CommandBase<SalesPackageManager>
|
||||
@ -35,8 +37,21 @@ public class CoinCommand extends CommandBase<SalesPackageManager>
|
||||
|
||||
if (client != null)
|
||||
{
|
||||
Plugin.getDonationManager().RewardCoins(null, caller.getName(), playerName, client.getAccountId(), amount);
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " coins to " + playerName + "'s account!"));
|
||||
Plugin.getDonationManager().RewardCoins(new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean completed)
|
||||
{
|
||||
if (completed)
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " coins to " + playerName + "'s account!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "There was an error giving " + F.elem(amount + "Coins") + " to " + F.name(playerName) + "."));
|
||||
}
|
||||
}
|
||||
}, caller.getName(), playerName, client.getAccountId(), amount);
|
||||
|
||||
}
|
||||
else
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!"));
|
||||
|
Loading…
Reference in New Issue
Block a user