From 78c068ad188f6297859596c35ffd7e5dc7cc6c62 Mon Sep 17 00:00:00 2001
From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com>
Date: Tue, 22 May 2018 14:19:44 +0000
Subject: [PATCH] Support for deleting items when LongTimeEvent ends.
---
.../dist/game/data/xsd/eventConfig.xsd | 15 ++++
.../gameserver/model/quest/LongTimeEvent.java | 71 ++++++++++++++++
.../dist/game/data/xsd/eventConfig.xsd | 15 ++++
.../gameserver/model/quest/LongTimeEvent.java | 71 ++++++++++++++++
.../dist/game/data/xsd/eventConfig.xsd | 15 ++++
.../gameserver/model/quest/LongTimeEvent.java | 71 ++++++++++++++++
.../dist/game/data/xsd/eventConfig.xsd | 15 ++++
.../gameserver/model/quest/LongTimeEvent.java | 71 ++++++++++++++++
.../dist/game/data/xsd/eventConfig.xsd | 15 ++++
.../gameserver/model/quest/LongTimeEvent.java | 82 +++++++++++++++++--
.../dist/game/data/xsd/eventConfig.xsd | 15 ++++
.../gameserver/model/quest/LongTimeEvent.java | 71 ++++++++++++++++
.../dist/game/data/xsd/eventConfig.xsd | 15 ++++
.../gameserver/model/quest/LongTimeEvent.java | 71 ++++++++++++++++
.../dist/game/data/xsd/eventConfig.xsd | 15 ++++
.../gameserver/model/quest/LongTimeEvent.java | 71 ++++++++++++++++
16 files changed, 693 insertions(+), 6 deletions(-)
diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/data/xsd/eventConfig.xsd b/L2J_Mobius_1.0_Ertheia/dist/game/data/xsd/eventConfig.xsd
index 7e58ebd06c..c9b013b446 100644
--- a/L2J_Mobius_1.0_Ertheia/dist/game/data/xsd/eventConfig.xsd
+++ b/L2J_Mobius_1.0_Ertheia/dist/game/data/xsd/eventConfig.xsd
@@ -32,6 +32,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
index 0a5994e0d5..248d5997e4 100644
--- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
+++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
@@ -17,6 +17,9 @@
package com.l2jmobius.gameserver.model.quest;
import java.io.File;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -28,13 +31,16 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.concurrent.ThreadPool;
+import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.data.sql.impl.AnnouncementsTable;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.datatables.EventDroplist;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.instancemanager.EventShrineManager;
+import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
+import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.announce.EventAnnouncement;
import com.l2jmobius.gameserver.model.holders.DropHolder;
import com.l2jmobius.gameserver.script.DateRange;
@@ -64,6 +70,9 @@ public class LongTimeEvent extends Quest
// Drop data for event
protected final List _dropList = new ArrayList<>();
+ // Items to destroy when event ends.
+ protected final List _destoyItemsOnEnd = new ArrayList<>();
+
protected class NpcSpawn
{
protected final Location loc;
@@ -96,6 +105,8 @@ public class LongTimeEvent extends Quest
}
else
{
+ // Destroy items that must exist only on event period.
+ destoyItemsOnEnd();
LOGGER.info("Event " + _eventName + " has passed... Ignored ");
}
}
@@ -259,6 +270,35 @@ public class LongTimeEvent extends Quest
}
}
}
+
+ // Load destroy item list at all times.
+ final Node first = doc.getDocumentElement().getFirstChild();
+ for (Node n = first; n != null; n = n.getNextSibling())
+ {
+ if (n.getNodeName().equalsIgnoreCase("destoyItemsOnEnd"))
+ {
+ for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
+ {
+ if (d.getNodeName().equalsIgnoreCase("item"))
+ {
+ try
+ {
+ final int itemId = Integer.parseInt(d.getAttributes().getNamedItem("id").getNodeValue());
+ if (ItemTable.getInstance().getTemplate(itemId) == null)
+ {
+ LOGGER.warning(getScriptName() + " event: Item " + itemId + " does not exist.");
+ continue;
+ }
+ _destoyItemsOnEnd.add(itemId);
+ }
+ catch (NumberFormatException nfe)
+ {
+ LOGGER.warning("Wrong number format in config.xml destoyItemsOnEnd block for " + getScriptName() + " event");
+ }
+ }
+ }
+ }
+ }
}
}.load();
@@ -347,8 +387,39 @@ public class LongTimeEvent extends Quest
{
EventShrineManager.getInstance().setEnabled(false);
}
+ // Destroy items that must exist only on event period.
+ destoyItemsOnEnd();
// Send message on end
Broadcast.toAllOnlinePlayers(_endMsg);
}
}
+
+ void destoyItemsOnEnd()
+ {
+ if (!_destoyItemsOnEnd.isEmpty())
+ {
+ for (int itemId : _destoyItemsOnEnd)
+ {
+ // Remove item from online players.
+ for (L2PcInstance player : L2World.getInstance().getPlayers())
+ {
+ if (player != null)
+ {
+ player.destroyItemByItemId(_eventName, itemId, -1, player, true);
+ }
+ }
+ // Update database
+ try (Connection con = DatabaseFactory.getInstance().getConnection();
+ PreparedStatement statement = con.prepareStatement("DELETE FROM items WHERE item_id=?"))
+ {
+ statement.setInt(1, itemId);
+ statement.execute();
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
}
diff --git a/L2J_Mobius_2.5_Underground/dist/game/data/xsd/eventConfig.xsd b/L2J_Mobius_2.5_Underground/dist/game/data/xsd/eventConfig.xsd
index 7e58ebd06c..c9b013b446 100644
--- a/L2J_Mobius_2.5_Underground/dist/game/data/xsd/eventConfig.xsd
+++ b/L2J_Mobius_2.5_Underground/dist/game/data/xsd/eventConfig.xsd
@@ -32,6 +32,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
index 0a5994e0d5..248d5997e4 100644
--- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
+++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
@@ -17,6 +17,9 @@
package com.l2jmobius.gameserver.model.quest;
import java.io.File;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -28,13 +31,16 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.concurrent.ThreadPool;
+import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.data.sql.impl.AnnouncementsTable;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.datatables.EventDroplist;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.instancemanager.EventShrineManager;
+import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
+import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.announce.EventAnnouncement;
import com.l2jmobius.gameserver.model.holders.DropHolder;
import com.l2jmobius.gameserver.script.DateRange;
@@ -64,6 +70,9 @@ public class LongTimeEvent extends Quest
// Drop data for event
protected final List _dropList = new ArrayList<>();
+ // Items to destroy when event ends.
+ protected final List _destoyItemsOnEnd = new ArrayList<>();
+
protected class NpcSpawn
{
protected final Location loc;
@@ -96,6 +105,8 @@ public class LongTimeEvent extends Quest
}
else
{
+ // Destroy items that must exist only on event period.
+ destoyItemsOnEnd();
LOGGER.info("Event " + _eventName + " has passed... Ignored ");
}
}
@@ -259,6 +270,35 @@ public class LongTimeEvent extends Quest
}
}
}
+
+ // Load destroy item list at all times.
+ final Node first = doc.getDocumentElement().getFirstChild();
+ for (Node n = first; n != null; n = n.getNextSibling())
+ {
+ if (n.getNodeName().equalsIgnoreCase("destoyItemsOnEnd"))
+ {
+ for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
+ {
+ if (d.getNodeName().equalsIgnoreCase("item"))
+ {
+ try
+ {
+ final int itemId = Integer.parseInt(d.getAttributes().getNamedItem("id").getNodeValue());
+ if (ItemTable.getInstance().getTemplate(itemId) == null)
+ {
+ LOGGER.warning(getScriptName() + " event: Item " + itemId + " does not exist.");
+ continue;
+ }
+ _destoyItemsOnEnd.add(itemId);
+ }
+ catch (NumberFormatException nfe)
+ {
+ LOGGER.warning("Wrong number format in config.xml destoyItemsOnEnd block for " + getScriptName() + " event");
+ }
+ }
+ }
+ }
+ }
}
}.load();
@@ -347,8 +387,39 @@ public class LongTimeEvent extends Quest
{
EventShrineManager.getInstance().setEnabled(false);
}
+ // Destroy items that must exist only on event period.
+ destoyItemsOnEnd();
// Send message on end
Broadcast.toAllOnlinePlayers(_endMsg);
}
}
+
+ void destoyItemsOnEnd()
+ {
+ if (!_destoyItemsOnEnd.isEmpty())
+ {
+ for (int itemId : _destoyItemsOnEnd)
+ {
+ // Remove item from online players.
+ for (L2PcInstance player : L2World.getInstance().getPlayers())
+ {
+ if (player != null)
+ {
+ player.destroyItemByItemId(_eventName, itemId, -1, player, true);
+ }
+ }
+ // Update database
+ try (Connection con = DatabaseFactory.getInstance().getConnection();
+ PreparedStatement statement = con.prepareStatement("DELETE FROM items WHERE item_id=?"))
+ {
+ statement.setInt(1, itemId);
+ statement.execute();
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
}
diff --git a/L2J_Mobius_3.0_Helios/dist/game/data/xsd/eventConfig.xsd b/L2J_Mobius_3.0_Helios/dist/game/data/xsd/eventConfig.xsd
index 7e58ebd06c..c9b013b446 100644
--- a/L2J_Mobius_3.0_Helios/dist/game/data/xsd/eventConfig.xsd
+++ b/L2J_Mobius_3.0_Helios/dist/game/data/xsd/eventConfig.xsd
@@ -32,6 +32,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
index 0a5994e0d5..248d5997e4 100644
--- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
+++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
@@ -17,6 +17,9 @@
package com.l2jmobius.gameserver.model.quest;
import java.io.File;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -28,13 +31,16 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.concurrent.ThreadPool;
+import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.data.sql.impl.AnnouncementsTable;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.datatables.EventDroplist;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.instancemanager.EventShrineManager;
+import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
+import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.announce.EventAnnouncement;
import com.l2jmobius.gameserver.model.holders.DropHolder;
import com.l2jmobius.gameserver.script.DateRange;
@@ -64,6 +70,9 @@ public class LongTimeEvent extends Quest
// Drop data for event
protected final List _dropList = new ArrayList<>();
+ // Items to destroy when event ends.
+ protected final List _destoyItemsOnEnd = new ArrayList<>();
+
protected class NpcSpawn
{
protected final Location loc;
@@ -96,6 +105,8 @@ public class LongTimeEvent extends Quest
}
else
{
+ // Destroy items that must exist only on event period.
+ destoyItemsOnEnd();
LOGGER.info("Event " + _eventName + " has passed... Ignored ");
}
}
@@ -259,6 +270,35 @@ public class LongTimeEvent extends Quest
}
}
}
+
+ // Load destroy item list at all times.
+ final Node first = doc.getDocumentElement().getFirstChild();
+ for (Node n = first; n != null; n = n.getNextSibling())
+ {
+ if (n.getNodeName().equalsIgnoreCase("destoyItemsOnEnd"))
+ {
+ for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
+ {
+ if (d.getNodeName().equalsIgnoreCase("item"))
+ {
+ try
+ {
+ final int itemId = Integer.parseInt(d.getAttributes().getNamedItem("id").getNodeValue());
+ if (ItemTable.getInstance().getTemplate(itemId) == null)
+ {
+ LOGGER.warning(getScriptName() + " event: Item " + itemId + " does not exist.");
+ continue;
+ }
+ _destoyItemsOnEnd.add(itemId);
+ }
+ catch (NumberFormatException nfe)
+ {
+ LOGGER.warning("Wrong number format in config.xml destoyItemsOnEnd block for " + getScriptName() + " event");
+ }
+ }
+ }
+ }
+ }
}
}.load();
@@ -347,8 +387,39 @@ public class LongTimeEvent extends Quest
{
EventShrineManager.getInstance().setEnabled(false);
}
+ // Destroy items that must exist only on event period.
+ destoyItemsOnEnd();
// Send message on end
Broadcast.toAllOnlinePlayers(_endMsg);
}
}
+
+ void destoyItemsOnEnd()
+ {
+ if (!_destoyItemsOnEnd.isEmpty())
+ {
+ for (int itemId : _destoyItemsOnEnd)
+ {
+ // Remove item from online players.
+ for (L2PcInstance player : L2World.getInstance().getPlayers())
+ {
+ if (player != null)
+ {
+ player.destroyItemByItemId(_eventName, itemId, -1, player, true);
+ }
+ }
+ // Update database
+ try (Connection con = DatabaseFactory.getInstance().getConnection();
+ PreparedStatement statement = con.prepareStatement("DELETE FROM items WHERE item_id=?"))
+ {
+ statement.setInt(1, itemId);
+ statement.execute();
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
}
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/xsd/eventConfig.xsd b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/xsd/eventConfig.xsd
index 7e58ebd06c..c9b013b446 100644
--- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/xsd/eventConfig.xsd
+++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/xsd/eventConfig.xsd
@@ -32,6 +32,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
index 0a5994e0d5..248d5997e4 100644
--- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
+++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
@@ -17,6 +17,9 @@
package com.l2jmobius.gameserver.model.quest;
import java.io.File;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -28,13 +31,16 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.concurrent.ThreadPool;
+import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.data.sql.impl.AnnouncementsTable;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.datatables.EventDroplist;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.instancemanager.EventShrineManager;
+import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
+import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.announce.EventAnnouncement;
import com.l2jmobius.gameserver.model.holders.DropHolder;
import com.l2jmobius.gameserver.script.DateRange;
@@ -64,6 +70,9 @@ public class LongTimeEvent extends Quest
// Drop data for event
protected final List _dropList = new ArrayList<>();
+ // Items to destroy when event ends.
+ protected final List _destoyItemsOnEnd = new ArrayList<>();
+
protected class NpcSpawn
{
protected final Location loc;
@@ -96,6 +105,8 @@ public class LongTimeEvent extends Quest
}
else
{
+ // Destroy items that must exist only on event period.
+ destoyItemsOnEnd();
LOGGER.info("Event " + _eventName + " has passed... Ignored ");
}
}
@@ -259,6 +270,35 @@ public class LongTimeEvent extends Quest
}
}
}
+
+ // Load destroy item list at all times.
+ final Node first = doc.getDocumentElement().getFirstChild();
+ for (Node n = first; n != null; n = n.getNextSibling())
+ {
+ if (n.getNodeName().equalsIgnoreCase("destoyItemsOnEnd"))
+ {
+ for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
+ {
+ if (d.getNodeName().equalsIgnoreCase("item"))
+ {
+ try
+ {
+ final int itemId = Integer.parseInt(d.getAttributes().getNamedItem("id").getNodeValue());
+ if (ItemTable.getInstance().getTemplate(itemId) == null)
+ {
+ LOGGER.warning(getScriptName() + " event: Item " + itemId + " does not exist.");
+ continue;
+ }
+ _destoyItemsOnEnd.add(itemId);
+ }
+ catch (NumberFormatException nfe)
+ {
+ LOGGER.warning("Wrong number format in config.xml destoyItemsOnEnd block for " + getScriptName() + " event");
+ }
+ }
+ }
+ }
+ }
}
}.load();
@@ -347,8 +387,39 @@ public class LongTimeEvent extends Quest
{
EventShrineManager.getInstance().setEnabled(false);
}
+ // Destroy items that must exist only on event period.
+ destoyItemsOnEnd();
// Send message on end
Broadcast.toAllOnlinePlayers(_endMsg);
}
}
+
+ void destoyItemsOnEnd()
+ {
+ if (!_destoyItemsOnEnd.isEmpty())
+ {
+ for (int itemId : _destoyItemsOnEnd)
+ {
+ // Remove item from online players.
+ for (L2PcInstance player : L2World.getInstance().getPlayers())
+ {
+ if (player != null)
+ {
+ player.destroyItemByItemId(_eventName, itemId, -1, player, true);
+ }
+ }
+ // Update database
+ try (Connection con = DatabaseFactory.getInstance().getConnection();
+ PreparedStatement statement = con.prepareStatement("DELETE FROM items WHERE item_id=?"))
+ {
+ statement.setInt(1, itemId);
+ statement.execute();
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
}
diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/xsd/eventConfig.xsd b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/xsd/eventConfig.xsd
index 01812477c8..10a65330d5 100644
--- a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/xsd/eventConfig.xsd
+++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/xsd/eventConfig.xsd
@@ -32,6 +32,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
index f64fe7e3a6..3d499c7da0 100644
--- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
+++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
@@ -17,6 +17,9 @@
package com.l2jmobius.gameserver.model.quest;
import java.io.File;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -31,11 +34,14 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.concurrent.ThreadPool;
+import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.data.sql.impl.AnnouncementsTable;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.datatables.EventDroplist;
import com.l2jmobius.gameserver.datatables.ItemTable;
+import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
+import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.announce.EventAnnouncement;
import com.l2jmobius.gameserver.model.holders.DropHolder;
import com.l2jmobius.gameserver.script.DateRange;
@@ -51,19 +57,22 @@ public class LongTimeEvent extends Quest
private String _eventName;
// Messages
- private String _onEnterMsg = "Event is in process";
+ protected String _onEnterMsg = "Event is in process";
protected String _endMsg = "Event ends!";
- private DateRange _eventPeriod = null;
- private DateRange _dropPeriod;
+ protected DateRange _eventPeriod = null;
+ protected DateRange _dropPeriod;
// NPCs to spawm and their spawn points
- private final List _spawnList = new ArrayList<>();
+ protected final List _spawnList = new ArrayList<>();
// Drop data for event
- private final List _dropList = new ArrayList<>();
+ protected final List _dropList = new ArrayList<>();
- private class NpcSpawn
+ // Items to destroy when event ends.
+ protected final List _destoyItemsOnEnd = new ArrayList<>();
+
+ protected class NpcSpawn
{
protected final Location loc;
protected final int npcId;
@@ -95,6 +104,8 @@ public class LongTimeEvent extends Quest
}
else
{
+ // Destroy items that must exist only on event period.
+ destoyItemsOnEnd();
LOGGER.info("Event " + _eventName + " has passed... Ignored ");
}
}
@@ -242,6 +253,34 @@ public class LongTimeEvent extends Quest
}
}
}
+
+ // Load destroy item list at all times.
+ for (Node n = doc.getDocumentElement().getFirstChild(); n != null; n = n.getNextSibling())
+ {
+ if (n.getNodeName().equalsIgnoreCase("destoyItemsOnEnd"))
+ {
+ for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
+ {
+ if (d.getNodeName().equalsIgnoreCase("item"))
+ {
+ try
+ {
+ final int itemId = Integer.parseInt(d.getAttributes().getNamedItem("id").getNodeValue());
+ if (ItemTable.getInstance().getTemplate(itemId) == null)
+ {
+ LOGGER.warning(getScriptName() + " event: Item " + itemId + " does not exist.");
+ continue;
+ }
+ _destoyItemsOnEnd.add(itemId);
+ }
+ catch (NumberFormatException nfe)
+ {
+ LOGGER.warning("Wrong number format in config.xml destoyItemsOnEnd block for " + getScriptName() + " event");
+ }
+ }
+ }
+ }
+ }
}
catch (Exception e)
{
@@ -322,8 +361,39 @@ public class LongTimeEvent extends Quest
@Override
public void run()
{
+ // Destroy items that must exist only on event period.
+ destoyItemsOnEnd();
// Send message on end
Broadcast.toAllOnlinePlayers(_endMsg);
}
}
+
+ void destoyItemsOnEnd()
+ {
+ if (!_destoyItemsOnEnd.isEmpty())
+ {
+ for (int itemId : _destoyItemsOnEnd)
+ {
+ // Remove item from online players.
+ for (L2PcInstance player : L2World.getInstance().getPlayers())
+ {
+ if (player != null)
+ {
+ player.destroyItemByItemId(_eventName, itemId, -1, player, true);
+ }
+ }
+ // Update database
+ try (Connection con = DatabaseFactory.getInstance().getConnection();
+ PreparedStatement statement = con.prepareStatement("DELETE FROM items WHERE item_id=?"))
+ {
+ statement.setInt(1, itemId);
+ statement.execute();
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/xsd/eventConfig.xsd b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/xsd/eventConfig.xsd
index 7e58ebd06c..c9b013b446 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/xsd/eventConfig.xsd
+++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/xsd/eventConfig.xsd
@@ -32,6 +32,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
index 0a5994e0d5..248d5997e4 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
+++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
@@ -17,6 +17,9 @@
package com.l2jmobius.gameserver.model.quest;
import java.io.File;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -28,13 +31,16 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.concurrent.ThreadPool;
+import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.data.sql.impl.AnnouncementsTable;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.datatables.EventDroplist;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.instancemanager.EventShrineManager;
+import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
+import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.announce.EventAnnouncement;
import com.l2jmobius.gameserver.model.holders.DropHolder;
import com.l2jmobius.gameserver.script.DateRange;
@@ -64,6 +70,9 @@ public class LongTimeEvent extends Quest
// Drop data for event
protected final List _dropList = new ArrayList<>();
+ // Items to destroy when event ends.
+ protected final List _destoyItemsOnEnd = new ArrayList<>();
+
protected class NpcSpawn
{
protected final Location loc;
@@ -96,6 +105,8 @@ public class LongTimeEvent extends Quest
}
else
{
+ // Destroy items that must exist only on event period.
+ destoyItemsOnEnd();
LOGGER.info("Event " + _eventName + " has passed... Ignored ");
}
}
@@ -259,6 +270,35 @@ public class LongTimeEvent extends Quest
}
}
}
+
+ // Load destroy item list at all times.
+ final Node first = doc.getDocumentElement().getFirstChild();
+ for (Node n = first; n != null; n = n.getNextSibling())
+ {
+ if (n.getNodeName().equalsIgnoreCase("destoyItemsOnEnd"))
+ {
+ for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
+ {
+ if (d.getNodeName().equalsIgnoreCase("item"))
+ {
+ try
+ {
+ final int itemId = Integer.parseInt(d.getAttributes().getNamedItem("id").getNodeValue());
+ if (ItemTable.getInstance().getTemplate(itemId) == null)
+ {
+ LOGGER.warning(getScriptName() + " event: Item " + itemId + " does not exist.");
+ continue;
+ }
+ _destoyItemsOnEnd.add(itemId);
+ }
+ catch (NumberFormatException nfe)
+ {
+ LOGGER.warning("Wrong number format in config.xml destoyItemsOnEnd block for " + getScriptName() + " event");
+ }
+ }
+ }
+ }
+ }
}
}.load();
@@ -347,8 +387,39 @@ public class LongTimeEvent extends Quest
{
EventShrineManager.getInstance().setEnabled(false);
}
+ // Destroy items that must exist only on event period.
+ destoyItemsOnEnd();
// Send message on end
Broadcast.toAllOnlinePlayers(_endMsg);
}
}
+
+ void destoyItemsOnEnd()
+ {
+ if (!_destoyItemsOnEnd.isEmpty())
+ {
+ for (int itemId : _destoyItemsOnEnd)
+ {
+ // Remove item from online players.
+ for (L2PcInstance player : L2World.getInstance().getPlayers())
+ {
+ if (player != null)
+ {
+ player.destroyItemByItemId(_eventName, itemId, -1, player, true);
+ }
+ }
+ // Update database
+ try (Connection con = DatabaseFactory.getInstance().getConnection();
+ PreparedStatement statement = con.prepareStatement("DELETE FROM items WHERE item_id=?"))
+ {
+ statement.setInt(1, itemId);
+ statement.execute();
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/xsd/eventConfig.xsd b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/xsd/eventConfig.xsd
index 7e58ebd06c..c9b013b446 100644
--- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/xsd/eventConfig.xsd
+++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/xsd/eventConfig.xsd
@@ -32,6 +32,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
index 0a5994e0d5..248d5997e4 100644
--- a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
+++ b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
@@ -17,6 +17,9 @@
package com.l2jmobius.gameserver.model.quest;
import java.io.File;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -28,13 +31,16 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.concurrent.ThreadPool;
+import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.data.sql.impl.AnnouncementsTable;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.datatables.EventDroplist;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.instancemanager.EventShrineManager;
+import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
+import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.announce.EventAnnouncement;
import com.l2jmobius.gameserver.model.holders.DropHolder;
import com.l2jmobius.gameserver.script.DateRange;
@@ -64,6 +70,9 @@ public class LongTimeEvent extends Quest
// Drop data for event
protected final List _dropList = new ArrayList<>();
+ // Items to destroy when event ends.
+ protected final List _destoyItemsOnEnd = new ArrayList<>();
+
protected class NpcSpawn
{
protected final Location loc;
@@ -96,6 +105,8 @@ public class LongTimeEvent extends Quest
}
else
{
+ // Destroy items that must exist only on event period.
+ destoyItemsOnEnd();
LOGGER.info("Event " + _eventName + " has passed... Ignored ");
}
}
@@ -259,6 +270,35 @@ public class LongTimeEvent extends Quest
}
}
}
+
+ // Load destroy item list at all times.
+ final Node first = doc.getDocumentElement().getFirstChild();
+ for (Node n = first; n != null; n = n.getNextSibling())
+ {
+ if (n.getNodeName().equalsIgnoreCase("destoyItemsOnEnd"))
+ {
+ for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
+ {
+ if (d.getNodeName().equalsIgnoreCase("item"))
+ {
+ try
+ {
+ final int itemId = Integer.parseInt(d.getAttributes().getNamedItem("id").getNodeValue());
+ if (ItemTable.getInstance().getTemplate(itemId) == null)
+ {
+ LOGGER.warning(getScriptName() + " event: Item " + itemId + " does not exist.");
+ continue;
+ }
+ _destoyItemsOnEnd.add(itemId);
+ }
+ catch (NumberFormatException nfe)
+ {
+ LOGGER.warning("Wrong number format in config.xml destoyItemsOnEnd block for " + getScriptName() + " event");
+ }
+ }
+ }
+ }
+ }
}
}.load();
@@ -347,8 +387,39 @@ public class LongTimeEvent extends Quest
{
EventShrineManager.getInstance().setEnabled(false);
}
+ // Destroy items that must exist only on event period.
+ destoyItemsOnEnd();
// Send message on end
Broadcast.toAllOnlinePlayers(_endMsg);
}
}
+
+ void destoyItemsOnEnd()
+ {
+ if (!_destoyItemsOnEnd.isEmpty())
+ {
+ for (int itemId : _destoyItemsOnEnd)
+ {
+ // Remove item from online players.
+ for (L2PcInstance player : L2World.getInstance().getPlayers())
+ {
+ if (player != null)
+ {
+ player.destroyItemByItemId(_eventName, itemId, -1, player, true);
+ }
+ }
+ // Update database
+ try (Connection con = DatabaseFactory.getInstance().getConnection();
+ PreparedStatement statement = con.prepareStatement("DELETE FROM items WHERE item_id=?"))
+ {
+ statement.setInt(1, itemId);
+ statement.execute();
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/xsd/eventConfig.xsd b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/xsd/eventConfig.xsd
index 7e58ebd06c..c9b013b446 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/xsd/eventConfig.xsd
+++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/xsd/eventConfig.xsd
@@ -32,6 +32,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
index 0a5994e0d5..248d5997e4 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/quest/LongTimeEvent.java
@@ -17,6 +17,9 @@
package com.l2jmobius.gameserver.model.quest;
import java.io.File;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -28,13 +31,16 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.concurrent.ThreadPool;
+import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.data.sql.impl.AnnouncementsTable;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.datatables.EventDroplist;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.instancemanager.EventShrineManager;
+import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
+import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.announce.EventAnnouncement;
import com.l2jmobius.gameserver.model.holders.DropHolder;
import com.l2jmobius.gameserver.script.DateRange;
@@ -64,6 +70,9 @@ public class LongTimeEvent extends Quest
// Drop data for event
protected final List _dropList = new ArrayList<>();
+ // Items to destroy when event ends.
+ protected final List _destoyItemsOnEnd = new ArrayList<>();
+
protected class NpcSpawn
{
protected final Location loc;
@@ -96,6 +105,8 @@ public class LongTimeEvent extends Quest
}
else
{
+ // Destroy items that must exist only on event period.
+ destoyItemsOnEnd();
LOGGER.info("Event " + _eventName + " has passed... Ignored ");
}
}
@@ -259,6 +270,35 @@ public class LongTimeEvent extends Quest
}
}
}
+
+ // Load destroy item list at all times.
+ final Node first = doc.getDocumentElement().getFirstChild();
+ for (Node n = first; n != null; n = n.getNextSibling())
+ {
+ if (n.getNodeName().equalsIgnoreCase("destoyItemsOnEnd"))
+ {
+ for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
+ {
+ if (d.getNodeName().equalsIgnoreCase("item"))
+ {
+ try
+ {
+ final int itemId = Integer.parseInt(d.getAttributes().getNamedItem("id").getNodeValue());
+ if (ItemTable.getInstance().getTemplate(itemId) == null)
+ {
+ LOGGER.warning(getScriptName() + " event: Item " + itemId + " does not exist.");
+ continue;
+ }
+ _destoyItemsOnEnd.add(itemId);
+ }
+ catch (NumberFormatException nfe)
+ {
+ LOGGER.warning("Wrong number format in config.xml destoyItemsOnEnd block for " + getScriptName() + " event");
+ }
+ }
+ }
+ }
+ }
}
}.load();
@@ -347,8 +387,39 @@ public class LongTimeEvent extends Quest
{
EventShrineManager.getInstance().setEnabled(false);
}
+ // Destroy items that must exist only on event period.
+ destoyItemsOnEnd();
// Send message on end
Broadcast.toAllOnlinePlayers(_endMsg);
}
}
+
+ void destoyItemsOnEnd()
+ {
+ if (!_destoyItemsOnEnd.isEmpty())
+ {
+ for (int itemId : _destoyItemsOnEnd)
+ {
+ // Remove item from online players.
+ for (L2PcInstance player : L2World.getInstance().getPlayers())
+ {
+ if (player != null)
+ {
+ player.destroyItemByItemId(_eventName, itemId, -1, player, true);
+ }
+ }
+ // Update database
+ try (Connection con = DatabaseFactory.getInstance().getConnection();
+ PreparedStatement statement = con.prepareStatement("DELETE FROM items WHERE item_id=?"))
+ {
+ statement.setInt(1, itemId);
+ statement.execute();
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
}