Clan energy warnings implemented. (not tested yet)
This commit is contained in:
parent
c23b2f54f5
commit
f79c282225
@ -5,9 +5,13 @@ import mineplex.core.common.util.UtilTime;
|
|||||||
public enum UpdateType
|
public enum UpdateType
|
||||||
{
|
{
|
||||||
MIN_64(3840000),
|
MIN_64(3840000),
|
||||||
|
HOUR_01(3600000),
|
||||||
MIN_32(1920000),
|
MIN_32(1920000),
|
||||||
|
MIN_30(1800000),
|
||||||
MIN_16(960000),
|
MIN_16(960000),
|
||||||
|
MIN_10(600000),
|
||||||
MIN_08(480000),
|
MIN_08(480000),
|
||||||
|
MIN_05(300000),
|
||||||
MIN_04(240000),
|
MIN_04(240000),
|
||||||
MIN_02(120000),
|
MIN_02(120000),
|
||||||
MIN_01(60000),
|
MIN_01(60000),
|
||||||
|
@ -0,0 +1,142 @@
|
|||||||
|
package mineplex.game.clans.clans;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import mineplex.core.MiniPlugin;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilTextMiddle;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
|
public class ClanEnergyTracker extends MiniPlugin
|
||||||
|
{
|
||||||
|
private ClansManager _clans;
|
||||||
|
|
||||||
|
public ClanEnergyTracker(JavaPlugin plugin, ClansManager clans)
|
||||||
|
{
|
||||||
|
super("Clan Energy Tracker", plugin);
|
||||||
|
_clans = clans;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onUpdate(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() == UpdateType.MIN_05)
|
||||||
|
{
|
||||||
|
for (String clanName : _clans.getClanNameSet())
|
||||||
|
{
|
||||||
|
ClanInfo clan = _clans.getClan(clanName);
|
||||||
|
|
||||||
|
if (clan.isOnlineNow())
|
||||||
|
{
|
||||||
|
if (displayFor(clan, event.getType()))
|
||||||
|
{
|
||||||
|
for (Player player : clan.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
UtilTextMiddle.display(C.cRed + "Urgent", "Clan Energy is almost depleted");
|
||||||
|
UtilPlayer.message(player, F.main("Energy", "To top up your Clan's Energy, head to the shop and go to the Energy Shop!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (event.getType() == UpdateType.MIN_10)
|
||||||
|
{
|
||||||
|
for (String clanName : _clans.getClanNameSet())
|
||||||
|
{
|
||||||
|
ClanInfo clan = _clans.getClan(clanName);
|
||||||
|
|
||||||
|
if (clan.isOnlineNow())
|
||||||
|
{
|
||||||
|
if (displayFor(clan, event.getType()))
|
||||||
|
{
|
||||||
|
for (Player player : clan.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
UtilTextMiddle.display(C.cGold + "Warning", "Clan Energy is almost depleted");
|
||||||
|
UtilPlayer.message(player, F.main("Energy", "To top up your Clan's Energy, head to the shop and go to the Energy Shop!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (event.getType() == UpdateType.MIN_30)
|
||||||
|
{
|
||||||
|
for (String clanName : _clans.getClanNameSet())
|
||||||
|
{
|
||||||
|
ClanInfo clan = _clans.getClan(clanName);
|
||||||
|
|
||||||
|
if (clan.isOnlineNow())
|
||||||
|
{
|
||||||
|
if (displayFor(clan, event.getType()))
|
||||||
|
{
|
||||||
|
for (Player player : clan.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
UtilTextMiddle.display(C.cYellow + "Energy", "Clan Energy is running low");
|
||||||
|
UtilPlayer.message(player, F.main("Energy", "To top up your Clan's Energy, head to the shop and go to the Energy Shop!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (event.getType() == UpdateType.HOUR_01)
|
||||||
|
{
|
||||||
|
for (String clanName : _clans.getClanNameSet())
|
||||||
|
{
|
||||||
|
ClanInfo clan = _clans.getClan(clanName);
|
||||||
|
|
||||||
|
if (clan.isOnlineNow())
|
||||||
|
{
|
||||||
|
if (displayFor(clan, event.getType()))
|
||||||
|
{
|
||||||
|
for (Player player : clan.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
UtilTextMiddle.display(C.cYellow + "Energy", "Clan Energy is running low");
|
||||||
|
UtilPlayer.message(player, F.main("Energy", "To top up your Clan's Energy, head to the shop and go to the Energy Shop!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean displayFor(ClanInfo clan, UpdateType type)
|
||||||
|
{
|
||||||
|
double energyRemainingSeconds = ((60000L * clan.getEnergy()) / (clan.getEnergyCostPerMinute())) / 1000.0D;
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case MIN_05:
|
||||||
|
if (energyRemainingSeconds <= (1000 * 60 * 60))
|
||||||
|
{
|
||||||
|
return clan.isOnlineNow();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MIN_10:
|
||||||
|
if (energyRemainingSeconds <= (1000 * 60 * 60 * 4))
|
||||||
|
{
|
||||||
|
return clan.isOnlineNow();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MIN_30:
|
||||||
|
if (energyRemainingSeconds <= (1000 * 60 * 60 * 24))
|
||||||
|
{
|
||||||
|
return clan.isOnlineNow();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case HOUR_01:
|
||||||
|
if (energyRemainingSeconds <= (1000 * 60 * 60 * 48))
|
||||||
|
{
|
||||||
|
return clan.isOnlineNow();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -235,6 +235,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
|||||||
new SafeLog(plugin, this);
|
new SafeLog(plugin, this);
|
||||||
new ObserverManager(plugin, _condition, this);
|
new ObserverManager(plugin, _condition, this);
|
||||||
|
|
||||||
|
new ClanEnergyTracker(plugin, this);
|
||||||
|
|
||||||
new ClansAlphaManager(this, taskManager);
|
new ClansAlphaManager(this, taskManager);
|
||||||
|
|
||||||
new Weapon(plugin, energy);
|
new Weapon(plugin, energy);
|
||||||
|
Loading…
Reference in New Issue
Block a user