Add Amplifier thank button
This commit is contained in:
parent
5d0b5f80c0
commit
0d46bc4609
@ -15,11 +15,12 @@ public class BoosterCommand extends MultiCommandBase<BoosterManager>
|
||||
{
|
||||
public BoosterCommand(BoosterManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "amplifier", "booster");
|
||||
super(plugin, Rank.ALL, "amplifier", "booster");
|
||||
|
||||
AddCommand(new AddCommand(plugin));
|
||||
AddCommand(new GuiCommand(plugin));
|
||||
AddCommand(new ReloadCommand(plugin));
|
||||
AddCommand(new ThankCommand(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -27,5 +28,6 @@ public class BoosterCommand extends MultiCommandBase<BoosterManager>
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("amplifier add <group>", "Add an amplifier to that group", Rank.DEVELOPER));
|
||||
UtilPlayer.message(caller, F.help("amplifier gui", "Open Amplifier GUI", Rank.DEVELOPER));
|
||||
UtilPlayer.message(caller, F.help("amplifier thank <group>", "Thank an Amplifier for a specific Booster Group", Rank.ALL));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,74 @@
|
||||
package mineplex.core.boosters.command;
|
||||
|
||||
import mineplex.core.boosters.Booster;
|
||||
import mineplex.core.boosters.BoosterManager;
|
||||
import mineplex.core.boosters.tips.BoosterTipManager;
|
||||
import mineplex.core.boosters.tips.TipAddResult;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Shaun Bennett
|
||||
*/
|
||||
public class ThankCommand extends CommandBase<BoosterManager>
|
||||
{
|
||||
public ThankCommand(BoosterManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "thank");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null || args.length == 0)
|
||||
{
|
||||
// try to thank the current amplifier group
|
||||
String boosterGroup = Plugin.getBoosterGroup();
|
||||
if (boosterGroup == null || boosterGroup.length() <= 0)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Amplifier", "You must specify an Amplifier Group"));
|
||||
return;
|
||||
}
|
||||
|
||||
attemptToTipGroup(caller, boosterGroup);
|
||||
}
|
||||
else
|
||||
{
|
||||
String boosterGroup = StringUtils.join(args, ' ');
|
||||
attemptToTipGroup(caller, boosterGroup);
|
||||
}
|
||||
}
|
||||
|
||||
private void attemptToTipGroup(Player caller, String boosterGroup)
|
||||
{
|
||||
Booster booster = Plugin.getActiveBooster(boosterGroup);
|
||||
if (booster == null)
|
||||
{
|
||||
// Give a friendly oops message
|
||||
UtilPlayer.message(caller, F.main("Amplifier", "There was an error handling your request. Try again later"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.getTipManager().addTip(caller, booster, result ->
|
||||
{
|
||||
if (result == TipAddResult.SUCCESS)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Tip", "You thanked " + F.name(booster.getPlayerName()) + ". They earned " + F.currency(CurrencyType.TREASURE_SHARD, BoosterTipManager.TIP_FOR_SPONSOR) + " and you got "
|
||||
+ F.currency(CurrencyType.TREASURE_SHARD, BoosterTipManager.TIP_FOR_TIPPER)) + " in return!");
|
||||
caller.playSound(caller.getLocation(), Sound.LEVEL_UP, 1f, 1f);
|
||||
}
|
||||
else if (result.getFriendlyMessage() != null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Amplifier", result.getFriendlyMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,8 @@ import mineplex.core.MiniDbClientPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.boosters.Booster;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -33,8 +35,9 @@ public class BoosterTipManager extends MiniDbClientPlugin<PlayerTipData>
|
||||
|
||||
public void addTip(Player player, Booster booster, Callback<TipAddResult> callback)
|
||||
{
|
||||
if (!Recharge.Instance.use(player, "Amplifier Thanks", 1000 * 60 * 10, true, false))
|
||||
if (!Recharge.Instance.use(player, "Amplifier Thanks", 1000 * 5, false, false))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Amplifier", "Please wait before trying that again"));
|
||||
callback.run(TipAddResult.ON_COOLDOWN);
|
||||
return;
|
||||
}
|
||||
|
@ -8,9 +8,10 @@ import mineplex.core.boosters.event.BoosterExpireEvent;
|
||||
import mineplex.core.boosters.tips.BoosterTipManager;
|
||||
import mineplex.core.boosters.tips.TipAddResult;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.common.jsonchat.ClickEvent;
|
||||
import mineplex.core.common.jsonchat.HoverEvent;
|
||||
import mineplex.core.common.jsonchat.JsonMessage;
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
@ -86,5 +87,10 @@ public class GameBoosterManager extends MiniPlugin
|
||||
{
|
||||
Bukkit.broadcastMessage(F.main("Amplifier", F.name(booster.getPlayerName()) + " has activated a Game Amplifier on " + F.elem(event.getBoosterGroup().replaceAll("_", " ")) + "!"));
|
||||
}
|
||||
|
||||
JsonMessage message = new JsonMessage(F.main("Amplifier", F.elem("Click here") + " to thank them and receive " + F.currency(CurrencyType.TREASURE_SHARD, BoosterTipManager.TIP_FOR_TIPPER) + "!"));
|
||||
message.click(ClickEvent.RUN_COMMAND, "/amplifier thank " + _boosterGroup);
|
||||
message.hover(HoverEvent.SHOW_TEXT, C.cGreen + "Click to Thank");
|
||||
message.send(JsonMessage.MessageType.CHAT_BOX, UtilServer.getPlayers());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user