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
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));
}

View File

@ -23,13 +23,23 @@ public final class EventShrineManager
{
private static boolean ENABLE_SHRINES = false;
public static boolean areShrinesEnabled()
public boolean areShrinesEnabled()
{
return ENABLE_SHRINES;
}
public static void setEnabled(boolean enabled)
public void setEnabled(boolean 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
{
private String _eventName;
boolean _enableShrines = false;
// Messages
private String _onEnterMsg = "Event is in process";
@ -61,7 +62,7 @@ public class LongTimeEvent extends Quest
private DateRange _eventPeriod = null;
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<>();
// Drop data for event
@ -129,7 +130,7 @@ public class LongTimeEvent extends Quest
final String enableShrines = doc.getDocumentElement().getAttributes().getNamedItem("enableShrines").getNodeValue();
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
Broadcast.toAllOnlinePlayers(_onEnterMsg);
@ -345,6 +352,11 @@ public class LongTimeEvent extends Quest
@Override
public void run()
{
// Disable town shrines
if (_enableShrines)
{
EventShrineManager.getInstance().setEnabled(false);
}
// Send message on end
Broadcast.toAllOnlinePlayers(_endMsg);
}