Jump to content

[Share]Clan community board of off servers for java


Recommended Posts

And that isnt mine I find it  in l2jserver .... I havent tested  .... as i see it is working 99% on l2jserver gameserver version 2819 ... As vago says it is working

 

On official servers, the clan community board has this feature, and my players were missing it, so i developed it Wink

It's not 100% retail-like but it works really well, and doesn't seem to have any bugs on it...

This is the patch created by  _DS_ The share was created by cybersick ...

Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java	(revision 2819)
+++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java	(working copy)
@@ -513,6 +513,15 @@
             clan.broadcastToOtherOnlineMembers(msg, activeChar);
             msg = null;
             clan.broadcastToOtherOnlineMembers(new PledgeShowMemberListUpdate(activeChar), activeChar);
+            if (clan.isNoticeEnabled())
+            {
+            	sendPacket(new NpcHtmlMessage(1, "<html><title>Clan Announcements</title><body><br><center><font color=\"CCAA00\">" +
+            			activeChar.getClan().getName() +
+            			"</font> <font color=\"6655FF\">Clan Alert Message</font></center><br>" +
+            			"<img src=\"L2UI.SquareWhite\" width=270 height=1><br>" +
+            			activeChar.getClan().getNotice().replaceAll("\r\n", "<br>") + 
+            			"</body></html>"));
+            }
         }
     }

Index: java/net/sf/l2j/gameserver/model/L2Clan.java
===================================================================
--- java/net/sf/l2j/gameserver/model/L2Clan.java	(revision 2819)
+++ java/net/sf/l2j/gameserver/model/L2Clan.java	(working copy)
@@ -156,6 +156,9 @@

     private int _reputationScore = 0;
     private int _rank = 0;
+    
+    private String _notice;
+    private boolean _noticeEnabled = false;

     /**
      * Called if a clan is referenced only by id.
@@ -870,6 +873,7 @@
             restoreSubPledges();
             restoreRankPrivs();
             restoreSkills();
+            restoreNotice();
         }
         catch (Exception e)
         {
@@ -881,6 +885,110 @@
         }
     }

+    private void restoreNotice()
+    {
+    	java.sql.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();
+    		con.close();
+    	}
+    	catch (Exception e)
+    	{
+    		_log.log(Level.SEVERE, "Error restoring clan notice.", e);
+    	}
+    	finally
+    	{
+    		try { con.close(); } catch (Exception e) {}
+    	}
+    }
+
+    private void storeNotice(String notice, boolean enabled)
+    {
+    	if (notice == null)
+    		notice = "";
+    	
+    	java.sql.Connection con = null;
+
+    	try
+    	{
+    		con = L2DatabaseFactory.getInstance().getConnection();
+
+    		if (notice.length() > 8192)
+    			notice = notice.substring(0, 8191);
+    		
+    		if (_notice != null)
+    		{
+    			PreparedStatement statement = con.prepareStatement("UPDATE clan_notices SET enabled=?,notice=? WHERE clan_id=?");
+        		if (enabled)
+            		statement.setString(1, "true");
+        		else
+            		statement.setString(1, "false");
+        		statement.setString(2, notice);
+        		statement.setInt(3, getClanId());
+                statement.execute();
+                statement.close();
+    		}
+    		else
+    		{
+        		PreparedStatement statement = con.prepareStatement("INSERT INTO clan_notices (clan_id, enabled, notice) values (?,?,?)");
+        		statement.setInt(1, getClanId());
+        		if (enabled)
+            		statement.setString(2, "true");
+        		else
+            		statement.setString(2, "false");
+        		statement.setString(3, notice);
+                statement.execute();
+                statement.close();
+    		}
+    	}
+        catch (Exception e)
+        {
+            _log.warning("Error could not store clan notice: " + e);
+        }
+        finally
+        {
+            try { con.close(); } catch (Exception e) {}
+        }
+
+    	_notice = notice;
+    	_noticeEnabled = enabled;
+    }
+
+    public void setNoticeEnabled(boolean noticeEnabled)
+    {
+    	storeNotice(_notice, noticeEnabled);
+    }
+    
+    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()
     {
         java.sql.Connection con = null;
Index: java/net/sf/l2j/gameserver/communitybbs/Manager/ClanBBSManager.java
===================================================================
--- java/net/sf/l2j/gameserver/communitybbs/Manager/ClanBBSManager.java	(revision 2819)
+++ java/net/sf/l2j/gameserver/communitybbs/Manager/ClanBBSManager.java	(working copy)
@@ -88,13 +88,127 @@
				clanhome(activeChar, index);
			}
		}
+		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);
+			separateAndSend("<html><body><br><br><center>Command : " + command + " needs core development</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
+			{
+				final StringBuilder html = StringUtil.startAppend(2000,
+						"<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> > " +
+						"<a action=\"bypass _bbsclan_clanlist\"> CLAN COMMUNITY </a>  > " +
+						"<a action=\"bypass _bbsclan_clanhome;",
+						String.valueOf(clanId),
+						"\"> &$802; </a>" +
+						"</td></tr>" +
+						"</table>"
+						);
+				if(activeChar.isClanLeader())
+				{
+					StringUtil.append(html,
+							"<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())
+						StringUtil.append(html, "<tr><td fixwidth=610> Clan Notice Function:   on   /   <a action=\"bypass _bbsclan_clannotice_disable\">off</a>");
+					else
+						StringUtil.append(html, "<tr><td fixwidth=610> Clan Notice Function:   <a action=\"bypass _bbsclan_clannotice_enable\">on</a>   /   off");
+					
+					StringUtil.append(html,
+							"</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
+				{
+					StringUtil.append(html,
+							"<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())
+					{
+						StringUtil.append(html, 
+								"<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>"
+								);
+					}
+					StringUtil.append(html,
+							"</center>" +
+							"</body>" +
+							"</html>"
+							);
+					separateAndSend(html.toString(), activeChar);
+				}
+			}
+		}
+	}
	/**
	 * @param activeChar
	 */
@@ -281,7 +395,7 @@
                                     "<a action=\"bypass _bbsclan_clanhome;",
                                     String.valueOf(clanId),
                                     ";cmail\">[CLAN MAIL]</a>  " +
-                                    "<a action=\"bypass _bbsclan_clanhome;",
+                                    "<a action=\"bypass _bbsclan_clannotice_edit;",
                                     String.valueOf(clanId),
                                     ";cnotice\">[CLAN NOTICE]</a>  " +
                                     "</td>" +
@@ -367,7 +481,11 @@
	public void parsewrite(String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar)
	{
		// TODO Auto-generated method stub
-		
+		if (ar1.equals("Set"))
+		{
+			activeChar.getClan().setNotice(ar4);
+			parsecmd("_bbsclan_clanhome;" + activeChar.getClan().getClanId(),activeChar);
+		}
	}

}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/communitybbs/CommunityBoard.java
===================================================================
--- java/net/sf/l2j/gameserver/communitybbs/CommunityBoard.java	(revision 2819)
+++ java/net/sf/l2j/gameserver/communitybbs/CommunityBoard.java	(working copy)
@@ -129,6 +129,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");

That is the patch ..

Sql file :

SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for clan_notices
-- ----------------------------
CREATE TABLE `clan_notices` (
  `clanID` int(32) NOT NULL,
  `notice` varchar(512) NOT NULL,
  `enabled` varchar(5) NOT NULL,
  PRIMARY KEY  (`clanID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Link to comment
Share on other sites

  • 2 months later...
  • 4 weeks later...
  • 5 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




  • Posts

    • From my personal experiences 🙂   Few months ago I decided to create my own Essence project. Project needs website, and I do not specialize in frontend development (t.y. i can make web work, but it won't be pretty for eye). So I search and find a guy in Discord, which claims he can make me a good looking HTML website for 30 EUR, prove some screenshots from his previous work. I agree. 1 week later, I get my HTML website, make few changes to contents, update URLs and upload it to FTP. Site looks good, I am happy that this headache is no more.   Few months passes. I randomly crawl through other Essence server websites scouting for good ideas for my own project. Suddenly one of russians project website opens and.. it's the same website as one I have 😉 perfectly absolutely same layout, colours, etc etc etc. I contact my guy to ask what the hell, to get blocked 😉  So I find a weekend worth of my time. Find HTML5 boilerplate generator and ask it to include Bootstrap 5 and some other stuff. Open Bootstrap documentation, drink two energy drinks on instant and start working my backend-inspired HTML black magic... Once I found suiting firefly effect for header, result looked oikay for me: Absolutely no magic or beauty here, but: * Unique (and probably nobody cares to rip it) * Done for free in ~10 hours by non-frontend dev * Most modern browsers friendly * Completely static content, loads instantly. No PHP at all * Sidebar statuses (online, pvp, pk) are pulled from account manager REST API endpoint and is cached for 5 minutes. Account manager runs separately from website frontend and has access to server DB. Where could/will it get better? * Code in Vue instead of HTML - time concerns only, but Vue is superior compared to HTML/PHP for supporting desktop/mobile, easing development by miles. Need to learn how to use it properly. * Way to manage content from backend - in my instance I think account manager is not really meant for that. Vue can help here too - there are components for content building. * Currently default Bootstrap components are used. Would be nice to have custom and more vibrant buttons. Guess what, Vue can help here too.   tl;dr don't buy 30EUR website, it will be ripped or shit. you better make your own website. Be curious. I am backend developer, I obviously have general idea how frontend works. But imho everyone who can make L2 server by editing NPC HTMLs, also can make their own simple website. ChatGPT and other AIs are your friends. Bootstrap. jQuery documentations are your friends. And when you feel good and comfortable with HTML, if you like, you can continue learning Vue, or going backend. Now, as for the top sites. You really need to invest money to make new project work. I mean really, really much money. For this concept to work, top website itself must get visited. But if you can sort that your top site would be popular amongst players, then it's a really very simple concept, as far as current 2004-ish sites goes. I think simple, working concept of this, maybe without proper frontend, but with implemented backend logics (add/edit/disable server, sort by votes count (top list), vote for server with verification, callback to server endpoint - all of that can be done using Symfony in mostly 5 days, with lots of breaks for coffee and a smoke 😉. Experienced mid frontend dev would make a Vue/React frontend for it in another 5 days. it's really really simple concept 🙂  
    • Need cheap aged discord accounts ? :  https://campsite.bio/utchihaamkt DISCORD USERNAME : utchiha_market TELEGRAM : https://t.me/utchiha_market Discover new products in our exclusive server today : https://discord.gg/hoodservices
    • i've copyed the files from a server that has it , like all except system folder to another that didn't had the feature and it worked but i can't find any file to resemble save acc or something
  • Topics

×
×
  • Create New...