diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/BoosterCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/BoosterCommand.java index 216130e12..44a429ac6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/BoosterCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/BoosterCommand.java @@ -15,11 +15,12 @@ public class BoosterCommand extends MultiCommandBase { 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 { UtilPlayer.message(caller, F.help("amplifier add ", "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 ", "Thank an Amplifier for a specific Booster Group", Rank.ALL)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ThankCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ThankCommand.java new file mode 100644 index 000000000..686fd9c58 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ThankCommand.java @@ -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 +{ + 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())); + } + }); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterTipManager.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterTipManager.java index be7f28ca9..ff31ce07e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterTipManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterTipManager.java @@ -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 public void addTip(Player player, Booster booster, Callback 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; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java index 764fc09ef..7c88911ff 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java @@ -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()); } }