Remove Gem Fountain and open brawl on weekends

This commit is contained in:
cnr 2017-06-09 00:14:49 -05:00
parent 3c3cffb001
commit d226a4e710
15 changed files with 79 additions and 800 deletions

View File

@ -1,57 +0,0 @@
package mineplex.core.brawl.fountain;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
/**
* This class handled filling a vertical area with a specific block based off a percent
*
* @author Shaun Bennett
*/
public class BlockProgressBar
{
// Starting block for the block fill
private final Block _startBlock;
// Direction the blockfill takes place in
private final BlockFace _direction;
// Blocks in order from lowest to highes
private final Block[] _blocks;
// Material used to fill the blocks
private final Material _material;
public BlockProgressBar(Block startBlock, Material material, BlockFace direction)
{
_startBlock = startBlock;
_material = material;
_direction = direction;
// Add blocks to array
int i;
Block curr;
Block[] blocks = new Block[100]; // max of 100 to prevent blocking
for (i = 0, curr = startBlock; (curr.getType() == Material.AIR || curr.getType() == material) && i < blocks.length; i++)
{
blocks[i] = curr;
curr = curr.getRelative(direction);
}
_blocks = new Block[i];
System.arraycopy(blocks, 0, _blocks, 0, i);
}
// Update the blockfill based on fill percent
public void update(double percent)
{
double percentPerBlock = 1D / _blocks.length;
double check = 0;
for (int i = 0; i < _blocks.length; i++)
{
_blocks[i].setType(percent > check ? _material : Material.AIR);
check += percentPerBlock;
}
}
}

View File

@ -1,11 +0,0 @@
package mineplex.core.brawl.fountain;
import mineplex.core.shop.ShopBase;
/**
* @author Shaun Bennett
*/
public interface BrawlShopProvider
{
public ShopBase getBrawlShop();
}

View File

@ -1,258 +0,0 @@
package mineplex.core.brawl.fountain;
import mineplex.core.account.CoreClientManager;
import mineplex.core.brawl.fountain.gui.FountainShop;
import mineplex.core.common.SortedSchematicLoader;
import mineplex.core.common.block.schematic.UtilSchematic;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilText;
import mineplex.core.donation.DonationManager;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramManager;
import mineplex.core.stats.StatsManager;
import mineplex.serverdata.Region;
import mineplex.serverdata.redis.counter.GoalCounter;
import mineplex.serverdata.redis.counter.GoalCounterListener;
import mineplex.serverdata.servers.ConnectionData;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.TimeZone;
/**
* Represents a fountain that players can add gems to, with a reward for reaching specific goals
* @author Shaun Bennett
*/
public class Fountain implements GoalCounterListener
{
// Manager Injections
private final HologramManager _hologramManager;
private final StatsManager _statsManager;
private boolean _brawlActive;
private final String _name;
private final String _dataKey;
private final Location _location;
private final Hologram _hologram;
private final GoalCounter _counter;
// private final BlockProgressBar _blockProgressBar;
private final SortedSchematicLoader<Double> _schematicLoader;
private final FountainShop _shop;
public Fountain(ConnectionData writeConnection, ConnectionData readConnection, Region region, Location location, Location pasteLocation, String name, String dataKey, long goal, FountainManager fountainManager,
CoreClientManager clientManager, DonationManager donationManager, HologramManager hologramManager,
StatsManager statsManager)
{
_hologramManager = hologramManager;
_statsManager = statsManager;
_name = name;
_dataKey = dataKey;
_location = location;
_hologram = new Hologram(hologramManager, new Location(location.getWorld(), -23, 75, 3), name).start();
_counter = new GoalCounter(writeConnection, readConnection, region, dataKey, goal);
_counter.addListener(this);
_brawlActive = false;
// _blockProgressBar = new BlockProgressBar(_lavaLocation.getBlock(), Material.LAVA, BlockFace.UP);
_schematicLoader = new SortedSchematicLoader<>(pasteLocation);
loadSchematics();
_shop = new FountainShop(this, fountainManager, clientManager, donationManager);
updateVisuals();
}
private void loadSchematics()
{
try
{
_schematicLoader.addSchematic(0.0, UtilSchematic.loadSchematic(new File("../../update/schematic/fountain0.schematic")));
_schematicLoader.addSchematic(0.2, UtilSchematic.loadSchematic(new File("../../update/schematic/fountain20.schematic")));
_schematicLoader.addSchematic(0.4, UtilSchematic.loadSchematic(new File("../../update/schematic/fountain40.schematic")));
_schematicLoader.addSchematic(0.6, UtilSchematic.loadSchematic(new File("../../update/schematic/fountain60.schematic")));
_schematicLoader.addSchematic(0.8, UtilSchematic.loadSchematic(new File("../../update/schematic/fountain80.schematic")));
_schematicLoader.addSchematic(1.0, UtilSchematic.loadSchematic(new File("../../update/schematic/fountain100.schematic")));
_schematicLoader.addSchematic(2.0, UtilSchematic.loadSchematic(new File("../../update/schematic/fountain200.schematic")));
_schematicLoader.addSchematic(3.0, UtilSchematic.loadSchematic(new File("../../update/schematic/fountain300.schematic")));
}
catch (IOException e)
{
System.err.println("Failed to load Gem Fountain Schematics");
e.printStackTrace();
}
}
protected void updateVisuals()
{
double fillPercent = getFillPercent();
if (isBrawlActive())
{
ArrayList<String> text = new ArrayList<>();
if (fillPercent >= 1)
{
text.add(C.cRed + C.Bold + "Weekend Brawl is Active!");
if (fillPercent >= 2)
{
text.add("Bonus Reward Unlocked:");
if (fillPercent >= 3)
{
text.add(C.cGreen + "3X Experience in Brawl");
}
else
{
text.add(C.cGreen + "2X Experience in Brawl");
}
}
text.add(" ");
text.add("Speak to the Fountain Keeper to Join!");
}
else
{
text.add(C.cRed + "Brawl goal was not met");
text.add("Come back next week");
}
_hologram.setText(text.toArray(new String[text.size()]));
//_schematicLoader.update(fillPercent);
}
else
{
double flatPercent = fillPercent - (int) fillPercent;
String fillColor;
String emptyColor;
String goalMessage;
if (fillPercent < 1)
{
fillColor = C.cGreen;
emptyColor = C.cRed;
goalMessage = "100% to Unlock Weekend Brawl";
} else if (fillPercent < 2)
{
fillColor = C.cYellow;
emptyColor = C.cGreen;
goalMessage = "200% to Unlock 2x XP for Weekend Brawl";
} else if (fillPercent < 3)
{
fillColor = C.cAqua;
emptyColor = C.cYellow;
goalMessage = "300% to Unlock 3x XP for Weekend Brawl";
} else
{
fillColor = C.cAqua;
emptyColor = C.cYellow;
goalMessage = "All Rewards Unlocked!";
flatPercent = 1;
}
int intPercent = (int) (fillPercent * 100);
String progressBar = UtilText.getProgress(null, flatPercent, null, false, 30, emptyColor, fillColor);
_hologram.setText(_name + C.Reset + " " + intPercent + "%", goalMessage, progressBar);
_schematicLoader.update(fillPercent);
}
}
public void increment(Player player, long amount, Callback<Long> callback)
{
_statsManager.incrementStat(player, getStatName(), amount);
_statsManager.runAsync(() -> {
long count = _counter.addAndGet(amount);
_statsManager.runSync(() -> {
updateVisuals();
if (callback != null) callback.run(count);
});
});
}
public long getAmountAdded(Player player)
{
return _statsManager.Get(player).getStat(getStatName());
}
private final String getStatName()
{
return "Global.Fountain." + getDataKey();
}
public String getName()
{
return _name;
}
public String getDataKey()
{
return _dataKey;
}
public void openShop(Player player)
{
_shop.attemptShopOpen(player);
}
public double getFillPercent()
{
return Math.min(3, _counter.getFillPercent());
}
public long getCount()
{
return _counter.getCount();
}
public void reset()
{
_counter.reset();
updateVisuals();
}
@Override
public void onMilestone(GoalCounter counter, int milestone)
{
switch (milestone)
{
case 1:
Bukkit.broadcastMessage(F.main("Fountain", "The Gem Fountain has reached 100%! Brawl Game unlocked this week"));
break;
case 2:
Bukkit.broadcastMessage(F.main("Fountain", "The Gem Fountain has reached 200%! 2x XP enabled for Brawl!"));
break;
case 3:
Bukkit.broadcastMessage(F.main("Fountain", "The Gem Fountain has reached 300%! 3x XP enabled for Brawl!"));
break;
}
}
public void updateBrawlActive()
{
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("PST"));
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
if (dayOfWeek == Calendar.FRIDAY || dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY)
{
_brawlActive = true;
}
else
{
_brawlActive = false;
}
}
public void updateCounter()
{
_counter.updateCount();
}
public boolean isBrawlActive()
{
return _brawlActive;
}
}

View File

@ -1,123 +0,0 @@
package mineplex.core.brawl.fountain;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.brawl.fountain.command.FountainCommand;
import mineplex.core.common.util.C;
import mineplex.core.donation.DonationManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.locations.LocationConstants;
import mineplex.core.stats.StatsManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.serverdata.Region;
import mineplex.serverdata.servers.ConnectionData;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.plugin.java.JavaPlugin;
/**
* @author Shaun Bennett
*/
public class FountainManager extends MiniPlugin
{
private HologramManager _hologramManager;
private StatsManager _statsManager;
private DonationManager _donationManager;
// used so we can inject the brawl shop (only on hub) into fountain code
private BrawlShopProvider _brawlShopProvider;
private Fountain _gemFountain;
public FountainManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, HologramManager hologramManager, StatsManager statsManager, BrawlShopProvider shopProvider)
{
super("Counter", plugin);
_hologramManager = hologramManager;
_statsManager = statsManager;
_donationManager = donationManager;
_brawlShopProvider = shopProvider;
World world = Bukkit.getWorlds().get(0);//-43.5, 66, -38.5
int goal = 35000000;//!new File("eu.dat").exists() ? 200000000 : 20000000;
_gemFountain = new Fountain(new ConnectionData("10.3.203.80", 6379, ConnectionData.ConnectionType.MASTER, "USRedis"),
new ConnectionData("10.3.203.80", 6377, ConnectionData.ConnectionType.SLAVE, "USRedis"), Region.ALL,
LocationConstants.FOUNTAIN_LOCATION, LocationConstants.FOUNTAIN_SCHEMATIC,
C.cGreen + "Gem Fountain", "GemFountain_01", goal, this, clientManager, donationManager, _hologramManager, _statsManager);
}
@Override
public void addCommands()
{
addCommand(new FountainCommand(this));
}
@EventHandler
public void updateFountainCount(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
_gemFountain.updateBrawlActive();
_gemFountain.updateVisuals();
}
@EventHandler
public void updateCounter(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC_05)
return;
runAsync(_gemFountain::updateCounter);
}
@EventHandler
public void onInteractAtEntity(PlayerInteractAtEntityEvent event)
{
Entity entity = event.getRightClicked();
if (entity.getCustomName() != null && entity.isCustomNameVisible())
{
if (entity.getCustomName().contains("Weekend Brawl") && getBrawlShopProvider() != null)
{
getBrawlShopProvider().getBrawlShop().attemptShopOpen(event.getPlayer());
}
}
}
@EventHandler
public void onDamage(EntityDamageByEntityEvent event)
{
if (!(event.getDamager() instanceof Player))
return;
Entity entity = event.getEntity();
if (entity.getCustomName() != null && entity.isCustomNameVisible())
{
if (entity.getCustomName().contains("Weekend Brawl") && getBrawlShopProvider() != null)
{
getBrawlShopProvider().getBrawlShop().attemptShopOpen(((Player) event.getDamager()));
}
}
}
public Fountain getGemFountain()
{
return _gemFountain;
}
public DonationManager getDonationManager()
{
return _donationManager;
}
public BrawlShopProvider getBrawlShopProvider()
{
return _brawlShopProvider;
}
}

View File

@ -1,20 +0,0 @@
package mineplex.core.brawl.fountain;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.shop.item.SalesPackageBase;
import org.bukkit.Material;
/**
* @author Shaun Bennett
*/
public class GemFountainSalesPackage extends SalesPackageBase
{
public GemFountainSalesPackage(int gems)
{
super("Add " + gems + " Gems", Material.EMERALD, (byte) 0, new String[] {}, gems, 1);
CurrencyCostMap.put(GlobalCurrency.GEM, gems);
KnownPackage = false;
OneTimePurchaseOnly = false;
}
}

View File

@ -1,69 +0,0 @@
package mineplex.core.brawl.fountain.command;
import java.util.function.Consumer;
import mineplex.core.brawl.fountain.FountainManager;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.server.util.TransactionResponse;
import org.bukkit.entity.Player;
/**
* Command to add gems to the fountain
*
* @author Shaun Bennett
*/
public class AddCommand extends CommandBase<FountainManager>
{
public AddCommand(FountainManager plugin)
{
super(plugin, Rank.DEVELOPER, "add");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args == null || args.length != 1)
{
help(caller);
return;
}
try
{
int amount = Integer.parseInt(args[0]);
Plugin.getDonationManager().purchaseUnknownSalesPackage(caller, "GemFountain.Add", GlobalCurrency.GEM, amount, false,
result ->
{
if (result == TransactionResponse.Success)
{
Plugin.getGemFountain().increment(caller, amount, null);
UtilPlayer.message(caller, F.main("Fountain", "Added " + F.elem(amount) + " to the fountain!"));
}
else if (result == TransactionResponse.InsufficientFunds)
{
UtilPlayer.message(caller, F.main("Fountain", "You do not have enough gems!"));
}
else
{
UtilPlayer.message(caller, F.main("Fountain", "There was an error processing your request!"));
}
});
}
catch (NumberFormatException ex)
{
help(caller);
}
}
private void help(Player player)
{
UtilPlayer.message(player, F.help("/fountain add", "<amount>", Rank.DEVELOPER));
}
}

View File

@ -1,27 +0,0 @@
package mineplex.core.brawl.fountain.command;
import mineplex.core.brawl.fountain.FountainManager;
import mineplex.core.command.MultiCommandBase;
import mineplex.core.common.Rank;
import org.bukkit.entity.Player;
/**
* @author Shaun Bennett
*/
public class FountainCommand extends MultiCommandBase<FountainManager>
{
public FountainCommand(FountainManager plugin)
{
super(plugin, Rank.DEVELOPER, "fountain");
AddCommand(new AddCommand(plugin));
AddCommand(new GuiCommand(plugin));
AddCommand(new ResetCommand(plugin));
}
@Override
protected void Help(Player caller, String[] args)
{
}
}

View File

@ -1,26 +0,0 @@
package mineplex.core.brawl.fountain.command;
import mineplex.core.brawl.fountain.FountainManager;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import org.bukkit.entity.Player;
/**
* Command to open the fountain gui without speaking to the fountain keeper
* @author Shaun Bennett
*/
public class GuiCommand extends CommandBase<FountainManager>
{
public GuiCommand(FountainManager plugin)
{
super(plugin, Rank.DEVELOPER, "gui");
}
@Override
public void Execute(Player caller, String[] args)
{
Plugin.getGemFountain().openShop(caller);
}
}

View File

@ -1,26 +0,0 @@
package mineplex.core.brawl.fountain.command;
import mineplex.core.brawl.fountain.FountainManager;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import org.bukkit.entity.Player;
/**
* Command to reset the fountain
* @author Shaun Bennett
*/
public class ResetCommand extends CommandBase<FountainManager>
{
public ResetCommand(FountainManager plugin)
{
super(plugin, Rank.DEVELOPER, "reset");
}
@Override
public void Execute(Player caller, String[] args)
{
Plugin.getGemFountain().reset();
}
}

View File

@ -1,92 +0,0 @@
package mineplex.core.brawl.fountain.gui;
import mineplex.core.account.CoreClientManager;
import mineplex.core.brawl.fountain.Fountain;
import mineplex.core.brawl.fountain.FountainManager;
import mineplex.core.brawl.fountain.gui.button.FountainAddButton;
import mineplex.core.common.MaterialData;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
import org.bukkit.Material;
import org.bukkit.entity.Player;
/**
* @author Shaun Bennett
*/
public class FountainPage extends ShopPageBase<FountainManager, FountainShop>
{
private final MaterialData EMPTY_XP = MaterialData.of(Material.STAINED_GLASS_PANE, (byte) 7);
private final MaterialData XP = MaterialData.of(Material.STAINED_GLASS_PANE, (byte) 5);
private final MaterialData EMPTY_XP100 = MaterialData.of(Material.STAINED_GLASS_PANE, (byte) 5);
private final MaterialData XP100 = MaterialData.of(Material.STAINED_GLASS_PANE, (byte) 4);
private final MaterialData EMPTY_XP200 = MaterialData.of(Material.STAINED_GLASS_PANE, (byte) 4);
private final MaterialData XP200 = MaterialData.of(Material.STAINED_GLASS_PANE, (byte) 3);
private final int[] XP_SLOTS = { 2, 3, 4, 5, 6 };
private Fountain _fountain;
public FountainPage(FountainManager plugin, FountainShop shop, CoreClientManager clientManager, DonationManager donationManager, Fountain fountain, Player player)
{
super(plugin, shop, clientManager, donationManager, "Fountain Keeper", player, 27);
_fountain = fountain;
buildPage();
}
@Override
protected void buildPage()
{
// Experience Bar
long added = _fountain.getAmountAdded(getPlayer());
final double fillPercent = _fountain.getFillPercent();
String title = ((int)(fillPercent * 100)) + "% Complete";
boolean canAdd = fillPercent < 3;
String unlockMessage;
if (fillPercent < 1) unlockMessage = "Reach 100% to unlock Weekend Brawl Game";
else if (fillPercent < 2) unlockMessage = "Reach 200% to unlock 2x XP in Brawl";
else if (fillPercent < 3) unlockMessage = "Reach 300% to unlock 3x XP in Brawl";
else unlockMessage = "All rewards unlocked!";
String[] lore = new String[] {
" ",
C.cWhite + unlockMessage,
" ",
C.cWhite + "You have added " + C.cGreen + added + " Gems"};
final double percentForEach = 1D / XP_SLOTS.length;
double check = percentForEach;
double flatPercent = fillPercent == 3 ? 1 : fillPercent - ((int) fillPercent);
for (int i = 0; i < XP_SLOTS.length; i++)
{
MaterialData data;
if (fillPercent < 1) data = flatPercent >= check ? XP : EMPTY_XP;
else if (fillPercent < 2) data = flatPercent >= check ? XP100 : EMPTY_XP100;
else data = flatPercent >= check ? XP200 : EMPTY_XP200;
ShopItem shopItem = new ShopItem(data.getMaterial(), data.getData(), title,
lore, 1, false, false);
setItem(XP_SLOTS[i], shopItem);
check += percentForEach;
}
if (canAdd)
{
int playerGems = getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.GEM);
ShopItem add1 = new ShopItem(Material.EMERALD, "Add 100 Gems", new String[]{}, 1, playerGems < 100, false);
ShopItem add2 = new ShopItem(Material.EMERALD, "Add 1,000 Gems", new String[]{}, 64, playerGems < 1000, false);
ShopItem add3 = new ShopItem(Material.EMERALD_BLOCK, "Add 10,000 Gems", new String[]{}, 1, playerGems < 10000, false);
ShopItem add4 = new ShopItem(Material.EMERALD_BLOCK, "Add 100,000 Gems", new String[]{}, 64, playerGems < 100000, false);
// Buttons
addButton(19, add1, new FountainAddButton(this, 100));
addButton(21, add2, new FountainAddButton(this, 1000));
addButton(23, add3, new FountainAddButton(this, 10000));
addButton(25, add4, new FountainAddButton(this, 100000));
}
}
}

View File

@ -1,48 +0,0 @@
package mineplex.core.brawl.fountain.gui;
import mineplex.core.account.CoreClientManager;
import mineplex.core.brawl.fountain.Fountain;
import mineplex.core.brawl.fountain.FountainManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import org.bukkit.entity.Player;
/**
* @author Shaun Bennett
*/
public class FountainShop extends ShopBase<FountainManager>
{
private final Fountain _fountain;
public FountainShop(Fountain fountain, FountainManager plugin, CoreClientManager clientManager, DonationManager donationManager)
{
super(plugin, clientManager, donationManager, "Fountain Keeper");
_fountain = fountain;
}
@Override
protected ShopPageBase<FountainManager, ? extends ShopBase<FountainManager>> buildPagesFor(Player player)
{
return new FountainPage(getPlugin(), this, getClientManager(), getDonationManager(), _fountain, player);
}
public Fountain getFountain()
{
return _fountain;
}
@Override
public boolean attemptShopOpen(Player player)
{
if (_fountain.isBrawlActive() && getPlugin().getBrawlShopProvider() != null)
{
return getPlugin().getBrawlShopProvider().getBrawlShop().attemptShopOpen(player);
}
else
{
return super.attemptShopOpen(player);
}
}
}

View File

@ -1,38 +0,0 @@
package mineplex.core.brawl.fountain.gui.button;
import mineplex.core.brawl.fountain.GemFountainSalesPackage;
import mineplex.core.brawl.fountain.gui.FountainPage;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.shop.confirmation.ConfirmationPage;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.SalesPackageBase;
import mineplex.core.shop.item.SalesPackageProcessor;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
/**
* @author Shaun Bennett
*/
public class FountainAddButton implements IButton
{
private final FountainPage _page;
private final int _gems;
private final SalesPackageBase _salesPackage;
public FountainAddButton(FountainPage page, int gems)
{
_page = page;
_gems = gems;
_salesPackage = new GemFountainSalesPackage(gems);
}
@Override
public void onClick(Player player, ClickType clickType)
{
_page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.GEM, _salesPackage, _page.getDonationManager(), () ->
{
_page.getPlugin().getGemFountain().increment(player, _gems, null);
_page.refresh();
}), _salesPackage.buildIcon()));
}
}

View File

@ -16,7 +16,7 @@ import mineplex.core.antihack.guardians.GuardianManager;
import mineplex.core.aprilfools.AprilFoolsManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.boosters.BoosterManager;
import mineplex.core.brawl.fountain.FountainManager;
import mineplex.hub.brawl.fountain.FountainManager;
import mineplex.core.chat.Chat;
import mineplex.core.chatsnap.SnapshotManager;
import mineplex.core.chatsnap.SnapshotPlugin;
@ -188,7 +188,7 @@ public class Hub extends JavaPlugin implements IRelation
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, eloManager, partyManager);
ServerManager serverManager = new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, queueManager, boosterManager);
new FountainManager(this, clientManager, donationManager, hologramManager, statsManager, serverManager);
new FountainManager(this, serverManager);
Chat chat = new Chat(this, incognito, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
new MessageManager(this, incognito, clientManager, preferenceManager, ignoreManager, punish, friendManager, chat);

View File

@ -0,0 +1,75 @@
package mineplex.hub.brawl.fountain;
import java.util.Calendar;
import java.util.TimeZone;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.server.ServerManager;
public class FountainManager extends MiniPlugin
{
private final ServerManager _serverManager;
private boolean _brawlActive = false;
public FountainManager(JavaPlugin plugin, ServerManager serverManager)
{
super("Counter", plugin);
_serverManager = serverManager;
}
@EventHandler
public void updateFountainCount(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
updateBrawlActive();
}
public void updateBrawlActive()
{
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("PST"));
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
_brawlActive = dayOfWeek == Calendar.FRIDAY || dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY;
}
@EventHandler
public void onInteractAtEntity(PlayerInteractAtEntityEvent event)
{
tryBrawl(event.getPlayer(), event.getRightClicked());
}
@EventHandler
public void onDamage(EntityDamageByEntityEvent event)
{
tryBrawl((Player)event.getDamager(), event.getEntity());
}
private void tryBrawl(Player player, Entity entity)
{
if (entity.getCustomName() != null && entity.isCustomNameVisible())
{
if (entity.getCustomName().contains("Weekend Brawl"))
{
if (_brawlActive)
{
_serverManager.getBrawlShop().attemptShopOpen(player);
}
else
{
player.sendMessage(F.main("BRAWL", "Come back this weekend to play Weekend Brawl!"));
}
}
}
}
}

View File

@ -29,7 +29,6 @@ import mineplex.core.Managers;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.boosters.BoosterManager;
import mineplex.core.brawl.fountain.BrawlShopProvider;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
@ -62,7 +61,7 @@ import mineplex.serverdata.Region;
import mineplex.serverdata.data.MinecraftServer;
import mineplex.serverdata.data.ServerGroup;
public class ServerManager extends MiniPlugin implements BrawlShopProvider
public class ServerManager extends MiniPlugin
{
private static final Long FREE_PORTAL_TIMER = -1L;
private static final Long BETA_PORTAL_TIMER = 120000L;
@ -858,7 +857,7 @@ public class ServerManager extends MiniPlugin implements BrawlShopProvider
public ShopBase<ServerManager> getBrawlShop()
{
return _serverNpcShopMap.get("Weekend Brawl");
return _serverNpcShopMap.get("BRAWL");
}
public ShopBase<ServerManager> getBawkShop()