Fix a lot more Booster cases

This commit is contained in:
Shaun Bennett 2016-06-19 19:48:17 -05:00
parent 63b7648608
commit bb8d94f38a
15 changed files with 28 additions and 243 deletions

View File

@ -84,10 +84,10 @@ public class ClaimTipsButton implements GuiItem, Listener
if (getPlayer().getOpenInventory() != null)
{
new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.LIME.getData(), 1, ChatColor.GREEN + "Booster Tips Collected"), "Tips Collected", 6*9, 20*3, getGui()).openInventory();
new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.LIME.getData(), 1, ChatColor.GREEN + "Amplifier Tips Collected"), "Tips Collected", 6*9, 20*3, getGui()).openInventory();
}
UtilPlayer.message(getPlayer(), F.main("Carl", "You collected " + F.currency(CurrencyType.TREASURE_SHARD, claimed) + " from Booster Tips!"));
UtilPlayer.message(getPlayer(), F.main("Carl", "You collected " + F.currency(CurrencyType.TREASURE_SHARD, claimed) + " from Amplifier Tips!"));
// Pending explosions are strange.. Not sure why we are using strings. Either way, lets display a rank reward effect
_bonusManager.addPendingExplosion(getPlayer(), "RANK");
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);
@ -133,7 +133,7 @@ public class ClaimTipsButton implements GuiItem, Listener
if (isAvailable())
{
material = Material.EMERALD;
itemName = C.cGreen + C.Bold + "Booster Tips";
itemName = C.cGreen + C.Bold + "Amplifier Tips";
lore.add(" ");
lore.add(C.cYellow + "Your Tips");
lore.add(" " + C.cWhite + getTips() + " Treasure Shards");
@ -143,10 +143,10 @@ public class ClaimTipsButton implements GuiItem, Listener
else
{
material = Material.REDSTONE_BLOCK;
itemName = C.cRed + C.Bold + "Booster Tips";
itemName = C.cRed + C.Bold + "Amplifier Tips";
lore.add(" ");
lore.add(C.Reset + "Activate Game Boosters to receive tips");
lore.add(C.Reset + "Activate Game Amplifiers to receive tips");
}
_item = new ShopItem(material, itemName, lore.toArray(new String[0]), 1, false, false);

View File

@ -31,21 +31,21 @@ public class BoosterProcessor implements ConfirmationProcessor
if (response.isSuccess())
{
long timeToStart = response.getStartTime().getTime() - System.currentTimeMillis();
if (timeToStart <= 0) _player.sendMessage(F.main("Booster", "Booster Activated!"));
else _player.sendMessage(F.main("Booster", "Booster Added. It will start in " + F.elem(UtilTime.convertString(timeToStart, 2, UtilTime.TimeUnit.FIT))));
if (timeToStart <= 0) _player.sendMessage(F.main("Amplifier", "Game Amplifier Activated!"));
else _player.sendMessage(F.main("Amplifier", "Game Amplifier Added. It will start in " + F.elem(UtilTime.convertString(timeToStart, 2, UtilTime.TimeUnit.FIT))));
callback.resolve("Success!");
}
else
{
_player.sendMessage(C.cRed + "There was an error trying to enable your booster :(");
callback.reject("Failed to Process");
_player.sendMessage(C.cRed + "There was an error trying to enable your Game Amplifier :(");
callback.reject("Failed. Try again later.");
}
});
}
else
{
callback.reject("Failed charging account.");
_player.sendMessage(F.main("Booster", "There was an error charging your account. Try again later!"));
_player.sendMessage(F.main("Amplifier", "There was an error charging your account. Try again later!"));
}
});
}

View File

@ -32,11 +32,11 @@ public class AddCommand extends CommandBase<BoosterManager>
{
if (response.isSuccess())
{
UtilPlayer.message(caller, F.main("Booster", "Successfully added booster to " + F.elem(serverGroup)));
UtilPlayer.message(caller, F.main("Amplifier", "Successfully added amplifier to " + F.elem(serverGroup)));
}
else
{
UtilPlayer.message(caller, F.main("Booster", "Failed to add booster. Error: " + F.elem(response.getError())));
UtilPlayer.message(caller, F.main("Amplifier", "Failed to add amplifier. Error: " + F.elem(response.getError())));
}
}
});
@ -49,6 +49,6 @@ public class AddCommand extends CommandBase<BoosterManager>
private void help(Player caller)
{
UtilPlayer.message(caller, F.help("booster add <servergroup>", "Add a booster to that server group", Rank.DEVELOPER));
UtilPlayer.message(caller, F.help("amplifier add <servergroup>", "Add an amplifier to that server group", Rank.DEVELOPER));
}
}

View File

@ -15,7 +15,7 @@ public class BoosterCommand extends MultiCommandBase<BoosterManager>
{
public BoosterCommand(BoosterManager plugin)
{
super(plugin, Rank.DEVELOPER, "booster");
super(plugin, Rank.DEVELOPER, "amplifier", "booster");
AddCommand(new AddCommand(plugin));
AddCommand(new GuiCommand(plugin));
@ -25,7 +25,7 @@ public class BoosterCommand extends MultiCommandBase<BoosterManager>
@Override
protected void Help(Player caller, String[] args)
{
UtilPlayer.message(caller, F.help("booster add <boostergroup>", "Add a booster to that booster group", Rank.DEVELOPER));
UtilPlayer.message(caller, F.help("booster gui", "Open Booster GUI", Rank.DEVELOPER));
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));
}
}

View File

@ -28,7 +28,7 @@ public class ReloadCommand extends CommandBase<BoosterManager>
Plugin.getBoostersAsync(data -> {
if (data != null)
{
UtilPlayer.message(caller, F.main("Booster", "Boosters reloaded!"));
UtilPlayer.message(caller, F.main("Amplifier", "Amplifiers reloaded!"));
}
});
}

View File

@ -13,6 +13,7 @@ import org.bukkit.event.inventory.ClickType;
/**
* @author Shaun Bennett
*/
@Deprecated
public class ActivateBoosterButton implements IButton
{
private BoosterShop _boosterShop;
@ -36,18 +37,18 @@ public class ActivateBoosterButton implements IButton
if (response.isSuccess())
{
long timeToStart = response.getStartTime().getTime() - System.currentTimeMillis();
if (timeToStart <= 0) player.sendMessage(F.main("Booster", "Booster Activated!"));
else player.sendMessage(F.main("Booster", "Booster Added. It will start in " + F.elem(UtilTime.convertString(timeToStart, 2, UtilTime.TimeUnit.FIT))));
if (timeToStart <= 0) player.sendMessage(F.main("Amplifier", "Amplifier Activated!"));
else player.sendMessage(F.main("Amplifier", "Game Amplifier Added. It will start in " + F.elem(UtilTime.convertString(timeToStart, 2, UtilTime.TimeUnit.FIT))));
}
else
{
player.sendMessage(C.cRed + "There was an error trying to enable your booster :(");
player.sendMessage(C.cRed + "There was an error trying to enable your Amplifier :(");
}
});
}
else
{
player.sendMessage(F.main("Booster", "There was an error charging your account. Try again later!"));
player.sendMessage(F.main("Amplifier", "There was an error charging your account. Try again later!"));
}
});
}

View File

@ -33,7 +33,7 @@ public class BoosterTipManager extends MiniDbClientPlugin<PlayerTipData>
public void addTip(Player player, Booster booster, Callback<TipAddResult> callback)
{
if (!Recharge.Instance.use(player, "Booster Tip", 1000 * 60, true, false))
if (!Recharge.Instance.use(player, "Amplifier Tip", 1000 * 60, true, false))
{
callback.run(TipAddResult.ON_COOLDOWN);
return;

View File

@ -52,17 +52,4 @@ public class CosmeticShop extends ShopBase<CosmeticManager> implements PluginMes
{
new GadgetPage(getPlugin(), this, getClientManager(), getDonationManager(), "Gadgets", event.getPlayer()).purchaseGadget(event.getPlayer(), event.getGadget());
}
@EventHandler
public void updatePages(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
for (ShopPageBase<CosmeticManager, ? extends ShopBase<CosmeticManager>> shop : getPlayerPageMap().values())
{
if (shop instanceof BoosterPage)
((BoosterPage) shop).updatePage();
}
}
}

View File

@ -1,45 +0,0 @@
package mineplex.core.cosmetic.ui.page;
import mineplex.core.account.CoreClientManager;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import java.util.ArrayList;
/**
* @author Shaun Bennett
*/
public class BoosterPage extends ShopPageBase<CosmeticManager, CosmeticShop>
{
public BoosterPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player)
{
super(plugin, shop, clientManager, donationManager, "Game Boosters", player, 9);
buildPage();
}
@Override
protected void buildPage()
{
ArrayList<String> lore = new ArrayList<>();
lore.add(" ");
lore.add("You Own: " + _plugin.getBoosterManager().getAvailableBoosterCount(getPlayer()));
ShopItem booster = new ShopItem(Material.SUGAR, "Game Booster", lore.toArray(new String[0]), 0, false, false);
setItem(4, booster);
}
public void updatePage()
{
refresh();
}
}

View File

@ -259,9 +259,4 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
{
getShop().openPageForPlayer(player, new MusicPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Music", player));
}
public void openBoosters(Player player)
{
getShop().openPageForPlayer(player, new BoosterPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), player));
}
}

View File

@ -1,30 +0,0 @@
package mineplex.core.gadget.gadgets.item;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilText;
import mineplex.core.cosmetic.event.ActivateGemBoosterEvent;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.Ammo;
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";
private static final String[] LORE = UtilText.splitLineToArray(C.cGray + "Get triple gems in any game on this server!", LineFormat.LORE);
public ItemGemBooster(GadgetManager manager)
{
super(manager, NAME, LORE, 1, Material.EMERALD, (byte) -1, 0,
new Ammo(NAME, NAME, Material.EMERALD, (byte) 0, LORE, -1, 0));
}
@Override
public void ActivateCustom(Player player)
{
player.getServer().getPluginManager().callEvent(new ActivateGemBoosterEvent(player));
}
}

View File

@ -1,87 +0,0 @@
package mineplex.core.gamebooster;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.cosmetic.ui.page.BoosterPage;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.serverdata.Region;
import mineplex.serverdata.data.DataRepository;
import mineplex.serverdata.redis.RedisDataRepository;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.Set;
import java.util.UUID;
/**
* Handles activation of GameBoosters
*
* @author Shaun Bennett
*/
public class GameBoosterManager extends MiniPlugin
{
// The item name used for InventoryManager
private static final String BOOSTER_INVENTORY_ITEM = "Global.GameBooster";
private final CoreClientManager _clientManager;
private final DonationManager _donationManager;
private final InventoryManager _inventoryManager;
private final DataRepository<BoosterData> _boosterRepository;
private BoostGame _activeBoostGame;
public GameBoosterManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager)
{
super("Game Boosters", plugin);
_clientManager = clientManager;
_donationManager = donationManager;
_inventoryManager = inventoryManager;
_boosterRepository = new RedisDataRepository(Region.currentRegion(), BoosterData.class, "gemBooster");
}
/**
* Get the number of boosters available for a player for a specific BoostGame. Currently the BoostGame has no
* affect on the output (there aren't separate types of boosters), but we may need to introduce different booster
* items for different games in the future.
*
* @param player The player that owns the boosters
* @param game The game to check for boosters
* @return The amount of unactivated boosters that player owns
*/
public int getAvailableBoosters(Player player, BoostGame game)
{
return _inventoryManager.Get(player).getItemCount(BOOSTER_INVENTORY_ITEM);
}
/**
* Attempt to activate a booster from a player for a specific game. This will do all the required checks to make sure
* the player has boosters available and removes that booster from the player's account. This will return true if
* the booster was successfully added, or false if it wasn't
*
* @param player The player that owns the booster item
* @param game The game to be boosted
* @return True if the booster has been enabled and removed from the player account, false otherwise
*/
public boolean activateBooster(Player player, BoostGame game)
{
// TODO
return false;
}
/**
* Return the BoosterData for a specific BoostGame
* @param game The BoostGame we want data for
* @return The BoosterData instance for that game
*/
public BoosterData getBoosterData(BoostGame game)
{
BoosterData data = new BoosterData(game);
data.getBoostQueue().add(new BoosterData.BoostedGame("Phinary", UUID.randomUUID()));
return data;
}
}

View File

@ -1,38 +0,0 @@
package mineplex.core.inventory;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.common.CurrencyType;
import mineplex.core.common.util.C;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.shop.item.SalesPackageBase;
public class GemBooster extends SalesPackageBase
{
public GemBooster(boolean enabled, int gemBoosters)
{
super("20 Gem Booster Pack", Material.EMERALD, (byte)0, new String[]
{
C.cYellow + "1000 Coins",
" ",
(enabled ? C.cGreen + "Left-Click To Use:" : ""),
C.cWhite + "Use these before games start to",
C.cWhite + "boost the amount of Gems earned",
C.cWhite + "for all players in the game!",
" ",
C.cGreen + "Right-Click To Purchase:",
C.cWhite + "20 Gem Boosters for " + C.cYellow + "1000 Coins",
" ",
C.cWhite + "Your Gem Boosters: " + C.cGreen + gemBoosters
}, 1000, 20);
KnownPackage = false;
OneTimePurchaseOnly = false;
}
@Override
public void Sold(Player player, CurrencyType currencyType)
{
}
}

View File

@ -23,7 +23,6 @@ import mineplex.core.common.util.Callback;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.gadgets.item.ItemGemBooster;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.server.util.TransactionResponse;
import mineplex.core.updater.UpdateType;
@ -290,7 +289,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor
_purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), "Gem Boosters", amount, response);
}
}, client.getAccountId(), ItemGemBooster.NAME, amount);
}, client.getAccountId(), "Game Booster", amount);
return true;
}

View File

@ -16,6 +16,7 @@ import mineplex.core.npc.NpcManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.database.tables.records.NpcsRecord;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
@ -213,8 +214,9 @@ public class BoosterPodium extends MiniPlugin
}
@EventHandler
public void onInteract(PlayerInteractAtEntityEvent event)
public void one(PlayerInteractAtEntityEvent event)
{
Bukkit.broadcastMessage("Interact Event. Target=" + event.getRightClicked() + ", Equals=" + event.getRightClicked().equals(_activeArmorStand));
if (event.getRightClicked().equals(_activeArmorStand))
{
_gameBoosterManager.attemptTip(event.getPlayer());
@ -225,6 +227,7 @@ public class BoosterPodium extends MiniPlugin
@EventHandler
public void onDamage(EntityDamageByEntityEvent event)
{
Bukkit.broadcastMessage("Damage Event. Target=" + event.getEntity() + ", Equals=" + event.getEntity().equals(_activeArmorStand));
if (event.getDamager() instanceof Player && event.getEntity().equals(_activeArmorStand))
{
_gameBoosterManager.attemptTip(((Player) event.getDamager()));