Browse Source

BETA: Added Dirs for Custom MultiSells/Items/Skills
Added New Configs for e-mail System

mrTJO 14 years ago
parent
commit
7c5fa1d573

+ 5 - 4
L2J_Server_BETA/java/com/l2jserver/Config.java

@@ -1042,10 +1042,9 @@ public final class Config
 	public static long SECOND_AUTH_BAN_TIME;
 	public static String SECOND_AUTH_REC_LINK;
 	
+	// Email
 	public static String EMAIL_SERVERINFO_NAME;
 	public static String EMAIL_SERVERINFO_ADDRESS;
-	
-	// Email
 	public static boolean EMAIL_SYS_ENABLED;
 	public static String EMAIL_SYS_HOST;
 	public static int EMAIL_SYS_PORT;
@@ -1055,8 +1054,8 @@ public final class Config
 	public static String EMAIL_SYS_USERNAME;
 	public static String EMAIL_SYS_PASSWORD;
 	public static String EMAIL_SYS_ADDRESS;
-	
-	
+	public static String EMAIL_SYS_SELECTQUERY;
+	public static String EMAIL_SYS_DBFIELD;
 	
 	/**
 	 * This class initializes all global variables for configuration.<br>
@@ -2945,6 +2944,8 @@ public final class Config
 					EMAIL_SYS_USERNAME = emailSettings.getProperty("SmtpUsername", "user@gmail.com");
 					EMAIL_SYS_PASSWORD = emailSettings.getProperty("SmtpPassword", "password");
 					EMAIL_SYS_ADDRESS = emailSettings.getProperty("EmailSystemAddress", "noreply@myl2jserver.com");
+					EMAIL_SYS_SELECTQUERY = emailSettings.getProperty("EmailDBSelectQuery", "SELECT value FROM account_data WHERE account_name=? AND var='email_addr'");
+					EMAIL_SYS_DBFIELD = emailSettings.getProperty("EmailDBField", "value");
 				}
 				catch (Exception e)
 				{

+ 6 - 7
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/MultiSell.java

@@ -41,6 +41,7 @@ import com.l2jserver.gameserver.network.serverpackets.ExBrExtraUserInfo;
 import com.l2jserver.gameserver.network.serverpackets.MultiSellList;
 import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
 import com.l2jserver.gameserver.network.serverpackets.UserInfo;
+import com.l2jserver.util.file.filter.XMLFilter;
 
 public class MultiSell
 {
@@ -185,7 +186,8 @@ public class MultiSell
 		Document doc = null;
 		int id = 0;
 		List<File> files = new FastList<File>();
-		hashFiles("multisell", files);
+		hashFiles("data/multisell", files);
+		hashFiles("data/multisell/custom", files);
 		
 		for (File f : files)
 		{
@@ -301,19 +303,16 @@ public class MultiSell
 	
 	private final void hashFiles(String dirname, List<File> hash)
 	{
-		File dir = new File(Config.DATAPACK_ROOT, "data/" + dirname);
+		File dir = new File(Config.DATAPACK_ROOT, dirname);
 		if (!dir.exists())
 		{
 			_log.log(Level.WARNING, "Dir " + dir.getAbsolutePath() + " not exists");
 			return;
 		}
 		
-		File[] files = dir.listFiles();
+		File[] files = dir.listFiles(new XMLFilter());
 		for (File f : files)
-		{
-			if (f.getName().endsWith(".xml"))
-				hash.add(f);
-		}
+			hash.add(f);
 	}
 	
 	private final void verify()

+ 5 - 48
L2J_Server_BETA/java/com/l2jserver/gameserver/skills/SkillsEngine.java

@@ -26,6 +26,7 @@ import com.l2jserver.Config;
 import com.l2jserver.gameserver.datatables.SkillTable;
 import com.l2jserver.gameserver.model.L2Skill;
 import com.l2jserver.gameserver.templates.item.L2Item;
+import com.l2jserver.util.file.filter.XMLFilter;
 
 /**
  * @author mkizub
@@ -46,7 +47,9 @@ public class SkillsEngine
 	private SkillsEngine()
 	{
 		hashFiles("data/stats/items", _itemFiles);
+		hashFiles("data/stats/items/custom", _itemFiles);
 		hashFiles("data/stats/skills", _skillFiles);
+		hashFiles("data/stats/skills/custom", _skillFiles);
 	}
 	
 	private void hashFiles(String dirname, List<File> hash)
@@ -57,15 +60,9 @@ public class SkillsEngine
 			_log.warning("Dir " + dir.getAbsolutePath() + " not exists");
 			return;
 		}
-		File[] files = dir.listFiles();
+		File[] files = dir.listFiles(new XMLFilter());
 		for (File f : files)
-		{
-			if (f.getName().endsWith(".xml") && !f.getName().startsWith("custom"))
-				hash.add(f);
-		}
-		File customfile = new File(Config.DATAPACK_ROOT, dirname + "/custom.xml");
-		if (customfile.exists())
-			hash.add(customfile);
+			hash.add(f);
 	}
 	
 	public List<L2Skill> loadSkills(File file)
@@ -113,46 +110,6 @@ public class SkillsEngine
 		return list;
 	}
 	
-	/*public List<L2Weapon> loadWeapons(Map<Integer, Item> weaponData)
-	{
-		List<L2Weapon> list = new FastList<L2Weapon>();
-		for (L2Item item : loadData(weaponData, _weaponFiles))
-		{
-			list.add((L2Weapon) item);
-		}
-		return list;
-	}
-	
-	public List<L2EtcItem> loadItems(Map<Integer, Item> itemData)
-	{
-		List<L2EtcItem> list = new FastList<L2EtcItem>();
-		List<Integer> xmlItem = new FastList<Integer>();
-		
-		for (L2Item item : loadData(itemData, _etcitemFiles))
-		{
-			list.add((L2EtcItem) item);
-			xmlItem.add(item.getItemId());
-		}
-		for (Item item : itemData.values())
-		{
-			if (!xmlItem.contains(item.id))
-				list.add(new L2EtcItem((L2EtcItemType) item.type, item.set));
-		}
-		return list;
-	}
-	
-	public List<L2Item> loadData(Map<Integer, ? extends Item> itemData, List<File> files)
-	{
-		List<L2Item> list = new FastList<L2Item>();
-		for (File f : files)
-		{
-			DocumentItem document = new DocumentItem(itemData, f);
-			document.parse();
-			list.addAll(document.getItemList());
-		}
-		return list;
-	}*/
-	
 	@SuppressWarnings("synthetic-access")
 	private static class SingletonHolder
 	{

+ 3 - 6
L2J_Server_BETA/java/com/l2jserver/loginserver/mail/BaseMail.java

@@ -41,10 +41,7 @@ import com.l2jserver.loginserver.mail.MailSystem.MailContent;
 public class BaseMail implements Runnable
 {
 	private final static Logger _log = Logger.getLogger(BaseMail.class.getName());
-	
-	private static final String QUERY_SEL_MAIL = "SELECT value FROM account_data " +
-	"WHERE account_name=? AND var='email_addr'";
-	
+		
 	private final Properties _mailProp = new Properties();
 	private final SmtpAuthenticator _authenticator;
 	private MimeMessage _messageMime = null;
@@ -131,12 +128,12 @@ public class BaseMail implements Runnable
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(QUERY_SEL_MAIL);
+			PreparedStatement statement = con.prepareStatement(Config.EMAIL_SYS_SELECTQUERY);
 			statement.setString(1, username);
 			ResultSet rset = statement.executeQuery();
 			if (rset.next())
 			{
-				String mail = rset.getString("value");
+				String mail = rset.getString(Config.EMAIL_SYS_DBFIELD);
 				return mail;
 			}
 			rset.close();

+ 38 - 0
L2J_Server_BETA/java/com/l2jserver/util/file/filter/XMLFilter.java

@@ -0,0 +1,38 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.l2jserver.util.file.filter;
+
+import java.io.File;
+import java.io.FileFilter;
+
+/**
+ * 
+ * @author mrTJO
+ */
+public class XMLFilter implements FileFilter
+{
+
+	/* (non-Javadoc)
+	 * @see java.io.FileFilter#accept(java.io.File)
+	 */
+	@Override
+	public boolean accept(File pathname)
+	{
+		if (pathname.getName().endsWith(".xml"))
+			return true;
+		return false;
+	}
+	
+}

+ 9 - 1
L2J_Server_BETA/java/config/email.properties

@@ -24,6 +24,14 @@ ServerInfoAddress = info@myl2jserver.com
 # Default: False
 EmailSystemEnabled = False
 
+# Select Query for Email Addresses
+# Default: SELECT value FROM account_data WHERE account_name=? AND var='email_addr'
+EmailDBSelectQuery = SELECT value FROM account_data WHERE account_name=? AND var='email_addr'
+
+# Email Address Field
+# Default: value
+EmailDBField = value
+
 # Mail Server Host
 # Default: smtp.gmail.com
 SmtpServerHost = smtp.gmail.com
@@ -36,7 +44,7 @@ SmtpServerPort = 465
 # Default: True
 SmtpAuthRequired = True
 
-# Mail Factory
+# Mail Socket Factory
 # Default: javax.net.ssl.SSLSocketFactory
 SmtpFactory = javax.net.ssl.SSLSocketFactory