Disabling shrines when event is not active.

This commit is contained in:
MobiusDev
2016-02-25 20:44:33 +00:00
parent 94ed7933c5
commit 8c3acc5454
3 changed files with 27 additions and 5 deletions

View File

@@ -59,7 +59,7 @@ final class EventShrines extends Quest
@Override @Override
public String onEnterZone(L2Character character, L2ZoneType zone) public String onEnterZone(L2Character character, L2ZoneType zone)
{ {
if (character.isPlayer() && EventShrineManager.areShrinesEnabled()) if (character.isPlayer() && EventShrineManager.getInstance().areShrinesEnabled())
{ {
character.sendPacket(new OnEventTrigger(ZONE_TRIGGERS.get(zone.getId()), true)); character.sendPacket(new OnEventTrigger(ZONE_TRIGGERS.get(zone.getId()), true));
} }

View File

@@ -23,13 +23,23 @@ public final class EventShrineManager
{ {
private static boolean ENABLE_SHRINES = false; private static boolean ENABLE_SHRINES = false;
public static boolean areShrinesEnabled() public boolean areShrinesEnabled()
{ {
return ENABLE_SHRINES; return ENABLE_SHRINES;
} }
public static void setEnabled(boolean enabled) public void setEnabled(boolean enabled)
{ {
ENABLE_SHRINES = enabled; ENABLE_SHRINES = enabled;
} }
public static final EventShrineManager getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final EventShrineManager _instance = new EventShrineManager();
}
} }

View File

@@ -53,6 +53,7 @@ import com.l2jmobius.gameserver.util.Broadcast;
public class LongTimeEvent extends Quest public class LongTimeEvent extends Quest
{ {
private String _eventName; private String _eventName;
boolean _enableShrines = false;
// Messages // Messages
private String _onEnterMsg = "Event is in process"; private String _onEnterMsg = "Event is in process";
@@ -61,7 +62,7 @@ public class LongTimeEvent extends Quest
private DateRange _eventPeriod = null; private DateRange _eventPeriod = null;
private DateRange _dropPeriod; private DateRange _dropPeriod;
// NPC's to spawm and their spawn points // NPCs to spawm and their spawn points
private final List<NpcSpawn> _spawnList = new ArrayList<>(); private final List<NpcSpawn> _spawnList = new ArrayList<>();
// Drop data for event // Drop data for event
@@ -129,7 +130,7 @@ public class LongTimeEvent extends Quest
final String enableShrines = doc.getDocumentElement().getAttributes().getNamedItem("enableShrines").getNodeValue(); final String enableShrines = doc.getDocumentElement().getAttributes().getNamedItem("enableShrines").getNodeValue();
if (enableShrines.equalsIgnoreCase("true")) if (enableShrines.equalsIgnoreCase("true"))
{ {
EventShrineManager.setEnabled(true); _enableShrines = true;
} }
} }
@@ -297,6 +298,12 @@ public class LongTimeEvent extends Quest
} }
} }
// Enable town shrines
if (_enableShrines)
{
EventShrineManager.getInstance().setEnabled(true);
}
// Send message on begin // Send message on begin
Broadcast.toAllOnlinePlayers(_onEnterMsg); Broadcast.toAllOnlinePlayers(_onEnterMsg);
@@ -345,6 +352,11 @@ public class LongTimeEvent extends Quest
@Override @Override
public void run() public void run()
{ {
// Disable town shrines
if (_enableShrines)
{
EventShrineManager.getInstance().setEnabled(false);
}
// Send message on end // Send message on end
Broadcast.toAllOnlinePlayers(_endMsg); Broadcast.toAllOnlinePlayers(_endMsg);
} }