Noticias:

No tienes permiso para ver los enlaces. Para poder verlos Registrate o Conectate.

Menú Principal

Clan Notice Message

Iniciado por Swarlog, Jul 25, 2025, 11:34 PM

Tema anterior - Siguiente tema

Swarlog

No puedes ver este adjunto. No puedes ver este adjunto.

CitarCORE:

Index: head-src/com/l2jfrozen/gameserver/communitybbs/Manager/ClanBBSManager.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/communitybbs/Manager/ClanBBSManager.java	(revision 758)
+++ head-src/com/l2jfrozen/gameserver/communitybbs/Manager/ClanBBSManager.java	(working copy)
@@ -95,13 +96,96 @@
 				st = null;
 			}
 		}
+		else if (command.startsWith("_bbsclan_clannotice_edit;"))
+		{
+			clanNotice(activeChar, activeChar.getClan().getClanId());
+		}
+		else if (command.startsWith("_bbsclan_clannotice_enable"))
+		{
+			activeChar.getClan().setNoticeEnabled(true);
+			clanNotice(activeChar, activeChar.getClan().getClanId());
+		}
+		else if (command.startsWith("_bbsclan_clannotice_disable"))
+		{
+			activeChar.getClan().setNoticeEnabled(false);
+			clanNotice(activeChar, activeChar.getClan().getClanId());
+		}
 		else
 		{
 			separateAndSend("<html><body><br><br><center>Commande : " + command + " pas encore implante</center><br><br></body></html>", activeChar);
 
 		}
 	}
-
+	private void clanNotice(L2PcInstance activeChar, int clanId)
+	{
+		L2Clan cl = ClanTable.getInstance().getClan(clanId);
+		if (cl != null)
+		{
+			if (cl.getLevel() < 2)
+			{
+				activeChar.sendPacket(new SystemMessage(SystemMessageId.NO_CB_IN_MY_CLAN));
+				parsecmd("_bbsclan_clanlist", activeChar);
+			}
+			else
+			{
+				
+				TextBuilder html = new TextBuilder("<html><body><br><br>"
+						+ "<table border=0 width=610><tr><td width=10></td><td width=600 align=left>"
+						+ "<a action=\"bypass _bbshome\">HOME</a> &gt; "
+						+ "<a action=\"bypass _bbsclan_clanlist\"> CLAN COMMUNITY </a>  &gt; " + "<a action=\"bypass _bbsclan_clanhome;"+String.valueOf(clanId)+"\"> &amp;$802; </a>"
+						+ "</td></tr>" + "</table>");
+				if (activeChar.isClanLeader())
+				{
+					html.append("<br><br><center>"
+							+ "<table width=610 border=0 cellspacing=0 cellpadding=0>"
+							+ "<tr><td fixwidth=610><font color=\"AAAAAA\">The Clan Notice function allows the clan leader to send messages through a pop-up window to clan members at login.</font> </td></tr>"
+							+ "<tr><td height=20></td></tr>");
+					
+					if (activeChar.getClan().isNoticeEnabled())
+						html.append( "<tr><td fixwidth=610> Clan Notice Function:&nbsp;&nbsp;&nbsp;on&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;<a action=\"bypass _bbsclan_clannotice_disable\">off</a>");
+					else
+						html.append( "<tr><td fixwidth=610> Clan Notice Function:&nbsp;&nbsp;&nbsp;<a action=\"bypass _bbsclan_clannotice_enable\">on</a>&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;off");
+					
+					html.append( "</td></tr>"
+							+ "</table>"
+							+ "<img src=\"L2UI.Squaregray\" width=\"610\" height=\"1\">"
+							+ "<br> <br>"
+							+ "<table width=610 border=0 cellspacing=2 cellpadding=0>"
+							+ "<tr><td>Edit Notice: </td></tr>"
+							+ "<tr><td height=5></td></tr>"
+							+ "<tr><td>"
+							+ "<MultiEdit var =\"Content\" width=610 height=100>"
+							+ "</td></tr>"
+							+ "</table>"
+							+ "<br>"
+							+ "<table width=610 border=0 cellspacing=0 cellpadding=0>"
+							+ "<tr><td height=5></td></tr>"
+							+ "<tr>"
+							+ "<td align=center FIXWIDTH=65><button value=\"&$140;\" action=\"Write Notice Set _ Content Content Content\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\" ></td>"
+							+ "<td align=center FIXWIDTH=45></td>" + "<td align=center FIXWIDTH=500></td>" + "</tr>" + "</table>"
+							+ "</center>" + "</body>" + "</html>");
+					send1001(html.toString(), activeChar);
+					send1002(activeChar, activeChar.getClan().getNotice(), " ", "0");
+				}
+				else
+				{
+					html.append( "<img src=\"L2UI.squareblank\" width=\"1\" height=\"10\">" + "<center>"
+							+ "<table border=0 cellspacing=0 cellpadding=0><tr>"
+							+ "<td>You are not your clan's leader, and therefore cannot change the clan notice</td>" + "</tr></table>");
+					if (activeChar.getClan().isNoticeEnabled())
+					{
+						html.append( "<table border=0 cellspacing=0 cellpadding=0>" + "<tr>"
+								+ "<td>The current clan notice:</td>" + "</tr>" + "<tr><td fixwidth=5></td>"
+								+ "<td FIXWIDTH=600 align=left>" + activeChar.getClan().getNotice() + "</td>" + "<td fixqqwidth=5></td>"
+								+ "</tr>" + "</table>");
+					}
+					html.append( "</center>" + "</body>" + "</html>");
+					separateAndSend(html.toString(), activeChar);
+				}
+			}
+		}
+	}
+	
 	/**
 	 * @param activeChar
 	 */
@@ -266,7 +350,7 @@
 				html.append("<td fixwidth=600>");
 				html.append("<a action=\"bypass _bbsclan_clanhome;" + clanId + ";announce\">[CLAN ANNOUNCEMENT]</a> <a action=\"bypass _bbsclan_clanhome;" + clanId + ";cbb\">[CLAN BULLETIN BOARD]</a>");
 				html.append("<a action=\"bypass _bbsclan_clanhome;" + clanId + ";cmail\">[CLAN MAIL]</a>&nbsp;&nbsp;");
-				html.append("<a action=\"bypass _bbsclan_clanhome;" + clanId + ";cnotice\">[CLAN NOTICE]</a>&nbsp;&nbsp;");
+				html.append("<a action=\"bypass _bbsclan_clannotice_edit;" + clanId + ";cnotice\">[CLAN NOTICE]</a>&nbsp;&nbsp;");
 				html.append("</td>");
 				html.append("<td fixWIDTH=5></td>");
 				html.append("</tr>");
@@ -341,7 +425,11 @@
 	@Override
 	public void parsewrite(String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar)
 	{
-	//null;
+		if (ar1.equals("Set"))
+		{
+			activeChar.getClan().setNotice(ar4);
+			parsecmd("_bbsclan_clanhome;" + activeChar.getClan().getClanId(), activeChar);
+		}
 	}
 
 }
Index: head-src/com/l2jfrozen/gameserver/communitybbs/CommunityBoard.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/communitybbs/CommunityBoard.java	(revision 758)
+++ head-src/com/l2jfrozen/gameserver/communitybbs/CommunityBoard.java	(working copy)
@@ -208,6 +224,10 @@
 			{
 				RegionBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
 			}
+			else if (url.equals("Notice"))
+			{
+				ClanBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
+			}
 			else
 			{
 				ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + url + " is not implemented yet</center><br><br></body></html>", "101");


Index: head-src/com/l2jfrozen/gameserver/model/L2Clan.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/model/L2Clan.java	(revision 758)
+++ head-src/com/l2jfrozen/gameserver/model/L2Clan.java	(working copy)
@@ -24,6 +24,7 @@
 import java.sql.SQLException;
 import java.util.List;
 import java.util.Map;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javolution.util.FastList;
@@ -164,6 +165,9 @@
 	private int _reputationScore = 0;
 	private int _rank = 0;
 
+	private String _notice;
+	private boolean _noticeEnabled = false;
+	private static final int MAX_NOTICE_LENGTH = 8192;
 	/**
 	 * Called if a clan is referenced only by id. In this case all other data needs to be fetched from db
 	 * 
@@ -963,6 +967,7 @@
 			restoreSubPledges();
 			restoreRankPrivs();
 			restoreSkills();
+			restoreNotice();
 
 			member = null;
 		}
@@ -976,7 +981,97 @@
 			con = null;
 		}
 	}
-
+	private void restoreNotice()
+	{
+		Connection con = null;
+		try
+		{
+			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement statement = con.prepareStatement("SELECT enabled,notice FROM clan_notices WHERE clan_id=?");
+			statement.setInt(1, getClanId());
+			ResultSet noticeData = statement.executeQuery();
+			
+			while (noticeData.next())
+			{
+				_noticeEnabled = noticeData.getBoolean("enabled");
+				_notice = noticeData.getString("notice");
+			}
+			
+			noticeData.close();
+			statement.close();
+		}
+		catch (Exception e)
+		{
+			_log.log(Level.SEVERE, "Error restoring clan notice: " + e.getMessage(), e);
+		}
+		finally
+		{
+			L2DatabaseFactory.close(con);
+		}
+		
+	}
+	
+	private void storeNotice(String notice, boolean enabled)
+	{
+		if (notice == null)
+			notice = "";
+		
+		if (notice.length() > MAX_NOTICE_LENGTH)
+			notice = notice.substring(0, MAX_NOTICE_LENGTH - 1);
+		
+		Connection con = null;
+		try
+		{
+			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement statement = con.prepareStatement("INSERT INTO clan_notices (clan_id,notice,enabled) values (?,?,?) ON DUPLICATE KEY UPDATE notice=?,enabled=?");
+			statement.setInt(1, getClanId());
+			statement.setString(2, notice);
+			if (enabled)
+				statement.setString(3, "true");
+			else
+				statement.setString(3, "false");
+			statement.setString(4, notice);
+			if (enabled)
+				statement.setString(5, "true");
+			else
+				statement.setString(5, "false");
+			statement.execute();
+			statement.close();
+		}
+		catch (Exception e)
+		{
+			_log.log(Level.WARNING, "Error could not store clan notice: " + e.getMessage(), e);
+		}
+		finally
+		{
+			L2DatabaseFactory.close(con);
+		}
+		
+		_notice = notice;
+		_noticeEnabled = enabled;
+	}
+	
+	public void setNoticeEnabled(boolean enabled)
+	{
+		storeNotice(_notice, enabled);
+	}
+	
+	public void setNotice(String notice)
+	{
+		storeNotice(notice, _noticeEnabled);
+	}
+	
+	public boolean isNoticeEnabled()
+	{
+		return _noticeEnabled;
+	}
+	
+	public String getNotice()
+	{
+		if (_notice == null)
+			return "";
+		return _notice;
+	}
 	private void restoreSkills()
 	{
 		Connection con = null;
Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java	(revision 769)
+++ head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java	(working copy)

@@ -553,9 +553,21 @@
 			activeChar.setFirstLog(false);
 			activeChar.updateFirstLog();
 		}
-
-		if(Config.WELCOME_HTM)
+		if (activeChar.getClan().isNoticeEnabled())
 		{
+			String clanNotice = "data/html/clanNotice.htm";
+			File mainText = new File(Config.DATAPACK_ROOT, clanNotice);
+			if(mainText.exists())
+			{
+				NpcHtmlMessage html = new NpcHtmlMessage(1);
+				html.setFile(clanNotice);
+				html.replace("%clan_name%", activeChar.getClan().getName());
+				html.replace("%notice_text%", activeChar.getClan().getNotice().replaceAll("\r\n", "<br>"));
+				sendPacket(html);
+			}
+		}
+		if(Config.WELCOME_HTM && !activeChar.getClan().isNoticeEnabled())
+		{
 			String Welcome_Path = "data/html/welcome.htm";
 			File mainText = new File(Config.DATAPACK_ROOT, Welcome_Path);
 			if(mainText.exists())

CitarDATA:

<html><title>Clan Announcements</title>
<body><br>
<center><font color="CCAA00">%clan_name%</font>
<font color="6655FF"> Clan Alert Message</font></center><br>
<img src="L2UI.SquareWhite" width=270 height=1><br>
%notice_text%
</body></html>

CitarSQL:

ALTER TABLE `clan_notices`
CHANGE `clanID` `clan_id` int(32) NOT NULL FIRST,
COMMENT=''