Implement local gem boosters that can be activated on a joined arcade server.
This commit is contained in:
parent
9b65926d42
commit
4899d56c09
@ -200,7 +200,8 @@ public class GadgetManager extends MiniPlugin
|
|||||||
addGadget(new ItemBow(this));
|
addGadget(new ItemBow(this));
|
||||||
addGadget(new ItemLovePotion(this));
|
addGadget(new ItemLovePotion(this));
|
||||||
addGadget(new ItemFlowerGift(this));
|
addGadget(new ItemFlowerGift(this));
|
||||||
|
addGadget(new ItemGemBooster(this));
|
||||||
|
|
||||||
// Costume
|
// Costume
|
||||||
addGadget(new OutfitRaveSuitHelmet(this));
|
addGadget(new OutfitRaveSuitHelmet(this));
|
||||||
addGadget(new OutfitRaveSuitChestplate(this));
|
addGadget(new OutfitRaveSuitChestplate(this));
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
package mineplex.core.gadget.gadgets.item;
|
||||||
|
|
||||||
|
import mineplex.core.cosmetic.event.ActivateGemBoosterEvent;
|
||||||
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
import mineplex.core.gadget.types.ItemGadget;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ItemGemBooster extends ItemGadget
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final String NAME = "Gem Booster";
|
||||||
|
|
||||||
|
public ItemGemBooster(GadgetManager manager)
|
||||||
|
{
|
||||||
|
super(manager, NAME, new String[]
|
||||||
|
{
|
||||||
|
"Get triple gems in any game on this server!"
|
||||||
|
}, 1, Material.EMERALD, 0, 0, new Ammo(NAME, new String[]
|
||||||
|
{
|
||||||
|
}, 1, Material.EMERALD, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ActivateCustom(Player player)
|
||||||
|
{
|
||||||
|
player.getServer().getPluginManager().callEvent(new ActivateGemBoosterEvent(player));
|
||||||
|
}
|
||||||
|
}
|
@ -23,6 +23,7 @@ import mineplex.core.common.util.Callback;
|
|||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.common.util.UUIDFetcher;
|
import mineplex.core.common.util.UUIDFetcher;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.gadget.gadgets.item.ItemGemBooster;
|
||||||
import mineplex.core.inventory.InventoryManager;
|
import mineplex.core.inventory.InventoryManager;
|
||||||
import mineplex.core.punish.Punish;
|
import mineplex.core.punish.Punish;
|
||||||
import mineplex.core.server.util.TransactionResponse;
|
import mineplex.core.server.util.TransactionResponse;
|
||||||
@ -122,19 +123,26 @@ public class Enjin extends MiniPlugin implements CommandExecutor
|
|||||||
|
|
||||||
_cachedUUIDs.put(name, new AbstractMap.SimpleEntry<UUID, Long>(playerUUID, System.currentTimeMillis() + 240000));
|
_cachedUUIDs.put(name, new AbstractMap.SimpleEntry<UUID, Long>(playerUUID, System.currentTimeMillis() + 240000));
|
||||||
|
|
||||||
if (!checkForCoinPurchase(args, name, playerUUID, client))
|
if (!checkForBoosterPurchase(args, name, playerUUID, client))
|
||||||
if (!checkForRankPurchase(args, name, playerUUID, client))
|
{
|
||||||
if(!checkForPurchase(args, name, client))
|
if (!checkForCoinPurchase(args, name, playerUUID, client))
|
||||||
|
{
|
||||||
|
if (!checkForRankPurchase(args, name, playerUUID, client))
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
if (!checkForPurchase(args, name, client))
|
||||||
|
|
||||||
for (String arg : args)
|
|
||||||
{
|
{
|
||||||
sb.append(arg + " ");
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
for (String arg : args)
|
||||||
|
{
|
||||||
|
sb.append(arg + " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Received Command : " + sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Received Command : " + sb.toString());
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -264,4 +272,27 @@ public class Enjin extends MiniPlugin implements CommandExecutor
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
protected boolean checkForBoosterPurchase(String[] args, final String name, final UUID playerUUID, final CoreClient client)
|
||||||
|
{
|
||||||
|
if (args.length != 3 || !args[0].equalsIgnoreCase("booster"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
final int amount = Integer.parseInt(args[2]);
|
||||||
|
|
||||||
|
_inventoryManager.addItemToInventoryForOffline(new Callback<Boolean>()
|
||||||
|
{
|
||||||
|
public void run (Boolean response)
|
||||||
|
{
|
||||||
|
if (response)
|
||||||
|
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " gem boosters.");
|
||||||
|
else
|
||||||
|
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " gem boosters. Queuing for run later.");
|
||||||
|
|
||||||
|
_purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), "Gem Boosters", amount, response);
|
||||||
|
}
|
||||||
|
}, client.getAccountId(), ItemGemBooster.NAME, amount);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -77,6 +77,7 @@ import nautilus.game.arcade.command.DisguiseCommand;
|
|||||||
import nautilus.game.arcade.command.GameCommand;
|
import nautilus.game.arcade.command.GameCommand;
|
||||||
import nautilus.game.arcade.command.KitUnlockCommand;
|
import nautilus.game.arcade.command.KitUnlockCommand;
|
||||||
import nautilus.game.arcade.command.RequiredRankCommand;
|
import nautilus.game.arcade.command.RequiredRankCommand;
|
||||||
|
import nautilus.game.arcade.command.TipCommand;
|
||||||
import nautilus.game.arcade.command.WriteCommand;
|
import nautilus.game.arcade.command.WriteCommand;
|
||||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
import nautilus.game.arcade.game.Game;
|
import nautilus.game.arcade.game.Game;
|
||||||
@ -358,6 +359,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
addCommand(new KitUnlockCommand(this));
|
addCommand(new KitUnlockCommand(this));
|
||||||
addCommand(new DisguiseCommand(this));
|
addCommand(new DisguiseCommand(this));
|
||||||
addCommand(new RequiredRankCommand(this));
|
addCommand(new RequiredRankCommand(this));
|
||||||
|
addCommand(new TipCommand(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameChatManager getGameChatManager()
|
public GameChatManager getGameChatManager()
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package nautilus.game.arcade.command;
|
||||||
|
|
||||||
|
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 mineplex.core.donation.Donor;
|
||||||
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class TipCommand extends CommandBase<ArcadeManager>
|
||||||
|
{
|
||||||
|
|
||||||
|
public TipCommand(ArcadeManager plugin)
|
||||||
|
{
|
||||||
|
super(plugin, Rank.ALL, "tip");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Execute(Player player, String[] args)
|
||||||
|
{
|
||||||
|
if (!Plugin.GetGame().GemBoosterEnabled)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, F.main("Game", F.elem("Gem Boosters")) + " are not enabled for this game.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Plugin.GetGame().GetGemBoostAmount() == 0)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, F.main("Game", "No one has " + F.elem("Gem Boosted")) + " this game yet.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Donor donor = Plugin.GetDonation().Get(player);
|
||||||
|
if (donor.GetBalance(CurrencyType.Coins) < 3)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, F.main("Game", "You do not have at least" + F.elem("three") + F.elem("Gem Boosters") + " to tip!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (String booster : Plugin.GetGame().GemBoosters)
|
||||||
|
{
|
||||||
|
Donor boost = Plugin.GetDonation().Get(booster);
|
||||||
|
boost.addCoins(3);
|
||||||
|
Player other = Bukkit.getPlayerExact(booster);
|
||||||
|
if (other != null)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(other, F.main("Game", "You have received a " + F.elem("three shard") + " tip from " + F.elem(player.getName()) + " for boosting this game!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
donor.DeductCost(3, CurrencyType.Coins);
|
||||||
|
UtilPlayer.message(player, F.main("Game", F.elem(booster) + " has received " + F.elem("three shards") + " from your tip. Thanks!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package nautilus.game.arcade.game;
|
package nautilus.game.arcade.game;
|
||||||
|
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -55,6 +56,8 @@ import mineplex.core.common.util.UtilTabTitle;
|
|||||||
import mineplex.core.common.util.UtilTextMiddle;
|
import mineplex.core.common.util.UtilTextMiddle;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||||
|
import mineplex.core.gadget.gadgets.item.ItemGemBooster;
|
||||||
|
import mineplex.core.giveaway.redis.GiveawayMessage;
|
||||||
import mineplex.core.itemstack.ItemBuilder;
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
import mineplex.core.packethandler.IPacketHandler;
|
import mineplex.core.packethandler.IPacketHandler;
|
||||||
import mineplex.core.packethandler.PacketInfo;
|
import mineplex.core.packethandler.PacketInfo;
|
||||||
@ -1365,34 +1368,30 @@ public abstract class Game implements Listener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GemBoosters.size() >= 4)
|
if (!GemBoosters.isEmpty())
|
||||||
{
|
{
|
||||||
UtilPlayer.message(player, F.main("Game", "Games cannot have more than " + F.elem("4 Gem Boosters")) + ".");
|
UtilPlayer.message(player, F.main("Game", "This game has already been boosted by " + F.elem(getBoosters())) + ".");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GemBoosters.contains(player.getName()))
|
Manager.getInventoryManager().addItemToInventory(player, ItemGemBooster.NAME, -1);
|
||||||
{
|
|
||||||
UtilPlayer.message(player, F.main("Game", "You can only use " + F.elem("1 Gem Booster")) + " per game.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Announce(F.elem(player.getName()) + " used a " + F.elem(C.cGreen + "Gem Booster") + " for "
|
new GiveawayMessage("GemBooster", player.getName(), "%p has used a gem booster on " + Manager.getPlugin().getConfig().getString("serverstatus.name")
|
||||||
+ F.elem("+" + (100 - (GemBoosters.size() * 25)) + "% Gems") + "!");
|
+ " join now for " + F.elem("triple") + " coins!", "Gem Boosted Game!").publish();
|
||||||
|
|
||||||
|
Bukkit.broadcastMessage("Gem boosters are now active on this server thanks to " + F.elem(player.getName()) + "! Use /tip " + player.getName() + " to give three shards as thanks!");
|
||||||
GemBoosters.add(player.getName());
|
GemBoosters.add(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getBoosters()
|
||||||
|
{
|
||||||
|
return Joiner.on(", ").join(GemBoosters);
|
||||||
|
}
|
||||||
|
|
||||||
public double GetGemBoostAmount()
|
public double GetGemBoostAmount()
|
||||||
{
|
{
|
||||||
if (GemBoosters.size() == 1)
|
if (!GemBoosters.isEmpty())
|
||||||
return 1;
|
return 3;
|
||||||
if (GemBoosters.size() == 2)
|
|
||||||
return 1.75;
|
|
||||||
if (GemBoosters.size() == 3)
|
|
||||||
return 2.25;
|
|
||||||
if (GemBoosters.size() == 4)
|
|
||||||
return 2.5;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -292,10 +292,11 @@ public class GameGemManager implements Listener
|
|||||||
int totalGems = earnedGems;
|
int totalGems = earnedGems;
|
||||||
|
|
||||||
//Gem Booster
|
//Gem Booster
|
||||||
if (game.GetGemBoostAmount() > 0 && game.GemBoosterEnabled)
|
if (game.GetGemBoostAmount() > 0 && game.GemBoosterEnabled)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(player, F.elem(C.cGreen + "+" + (int)(earnedGems*game.GetGemBoostAmount()) + " Gems") + " for " +
|
UtilPlayer.message(player, F.elem(C.cGreen + "+" + (int) (earnedGems * game.GetGemBoostAmount()) + " Gems") + " for gem boosters from"
|
||||||
F.elem(game.GemBoosters.size() + " Gem Boosters " + C.cGreen + "+" + (int)(game.GetGemBoostAmount()*100) + "%"));
|
+ F.elem(game.getBoosters()));
|
||||||
|
UtilPlayer.message(player, "Use /tip " + game.getBoosters() + " to tip three shards and say thanks!");
|
||||||
|
|
||||||
totalGems += earnedGems * game.GetGemBoostAmount();
|
totalGems += earnedGems * game.GetGemBoostAmount();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user