Maintain game type boost queue across network.
This commit is contained in:
parent
4899d56c09
commit
0f83e302dd
@ -66,6 +66,9 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.classcombat.event.ClassCombatCreatureAllowSpawnEvent;
|
||||
import mineplex.minecraft.game.core.combat.DeathMessageType;
|
||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.data.DataRepository;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
import nautilus.game.arcade.ArcadeFormat;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
@ -1360,6 +1363,22 @@ public abstract class Game implements Listener
|
||||
SetState(GameState.End);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void GameStateChange(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Dead)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BoosterData data = _boosterRepository.getElement(Manager.GetServerConfig().ServerType);
|
||||
if (data != null)
|
||||
{
|
||||
data.getBoostQueue().remove(0);
|
||||
_boosterRepository.addElement(data, 60 * 30); // 30 minutes
|
||||
}
|
||||
}
|
||||
private final DataRepository<BoosterData> _boosterRepository = new RedisDataRepository(Region.currentRegion(), BoosterData.class, "gemBooster");
|
||||
public void AddGemBooster(Player player)
|
||||
{
|
||||
if (!GemBoosterEnabled)
|
||||
@ -1374,6 +1393,23 @@ public abstract class Game implements Listener
|
||||
return;
|
||||
}
|
||||
|
||||
BoosterData data = _boosterRepository.getElement(Manager.GetServerConfig().ServerType);
|
||||
if (data == null)
|
||||
{
|
||||
data = new BoosterData(Manager.GetServerConfig().ServerType);
|
||||
}
|
||||
if (!data.getBoostQueue().isEmpty())
|
||||
{
|
||||
BoosterData.BoostedGame first = data.getBoostQueue().get(0);
|
||||
if (!first.getPlayer().equals(player.getName()))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Game", "This game type is already being boosted by " + F.elem(first.getPlayer()) + " on " + F.elem(first.getPlayer())) + " please try again later.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
data.getBoostQueue().add(new BoosterData.BoostedGame(Manager.GetServerConfig().HostName, player.getName()));
|
||||
_boosterRepository.addElement(data, 60 * 30); // 30 minutes
|
||||
|
||||
Manager.getInventoryManager().addItemToInventory(player, ItemGemBooster.NAME, -1);
|
||||
|
||||
new GiveawayMessage("GemBooster", player.getName(), "%p has used a gem booster on " + Manager.getPlugin().getConfig().getString("serverstatus.name")
|
||||
|
Loading…
Reference in New Issue
Block a user