Browse Source

Minor optimization if/elseif goes to switch for community type selector.
Don't forget to update your config (General.properties)

DrHouse 16 years ago
parent
commit
8dfb0c603a

+ 4 - 4
L2_GameServer/java/config/General.properties

@@ -338,10 +338,10 @@ AllowPetWalkers = False
 ShowServerNews = False
 
 # Type of the Community board
-#  - Full = new Community Board ( /!\ Experimental)
-#  - Old = old Community Board
-#  - off =  no community Board
-CommunityType = old
+# 0 = community is disabled
+# 1 = old community [default]
+# 2 = full community (not fully implemented, experimental)
+CommunityType = 1
 BBSShowPlayerList = False
 BBSDefault = _bbshome
 # show level of character to others in Community Board

+ 3 - 3
L2_GameServer/java/net/sf/l2j/Config.java

@@ -403,7 +403,7 @@ public final class Config
     public static boolean	ALLOW_NPC_WALKERS;
     public static boolean	ALLOW_PET_WALKERS;
     public static boolean	SERVER_NEWS;
-    public static String	COMMUNITY_TYPE;
+    public static int		COMMUNITY_TYPE;
     public static boolean	BBS_SHOW_PLAYERLIST;
     public static String	BBS_DEFAULT;
     public static boolean	SHOW_LEVEL_COMMUNITYBOARD;
@@ -1475,7 +1475,7 @@ public final class Config
 	                ALLOW_NPC_WALKERS							= Boolean.parseBoolean(General.getProperty("AllowNpcWalkers", "true"));
 	                ALLOW_PET_WALKERS							= Boolean.parseBoolean(General.getProperty("AllowPetWalkers", "False"));
 	                SERVER_NEWS									= Boolean.parseBoolean(General.getProperty("ShowServerNews", "False"));
-	                COMMUNITY_TYPE								= General.getProperty("CommunityType", "old").toLowerCase();
+	                COMMUNITY_TYPE								= Integer.parseInt(General.getProperty("CommunityType", "1"));
 	                BBS_SHOW_PLAYERLIST							= Boolean.parseBoolean(General.getProperty("BBSShowPlayerList", "false"));
 	                BBS_DEFAULT									= General.getProperty("BBSDefault", "_bbshome");
 	                SHOW_LEVEL_COMMUNITYBOARD					= Boolean.parseBoolean(General.getProperty("ShowLevelOnCommunityBoard", "False"));
@@ -2047,7 +2047,7 @@ public final class Config
         else if (pName.equalsIgnoreCase("AllowPetWalkers")) ALLOW_PET_WALKERS = Boolean.parseBoolean(pValue);
         else if (pName.equalsIgnoreCase("BypassValidation")) BYPASS_VALIDATION = Boolean.parseBoolean(pValue);
 
-        else if (pName.equalsIgnoreCase("CommunityType")) COMMUNITY_TYPE = pValue.toLowerCase();
+        else if (pName.equalsIgnoreCase("CommunityType")) COMMUNITY_TYPE = Integer.parseInt(pValue);
         else if (pName.equalsIgnoreCase("BBSShowPlayerList")) BBS_SHOW_PLAYERLIST = Boolean.parseBoolean(pValue);
         else if (pName.equalsIgnoreCase("BBSDefault")) BBS_DEFAULT = pValue;
         else if (pName.equalsIgnoreCase("ShowLevelOnCommunityBoard")) SHOW_LEVEL_COMMUNITYBOARD = Boolean.parseBoolean(pValue);

+ 72 - 70
L2_GameServer/java/net/sf/l2j/gameserver/communitybbs/CommunityBoard.java

@@ -50,51 +50,52 @@ public class CommunityBoard
 		if (activeChar == null)
 			return;
 		
-		if (Config.COMMUNITY_TYPE.equals("full"))
+		switch (Config.COMMUNITY_TYPE)
 		{
-			if (command.startsWith("_bbsclan"))
-			{
-				ClanBBSManager.getInstance().parsecmd(command, activeChar);
-			}
-			else if (command.startsWith("_bbsmemo"))
-			{
-				TopicBBSManager.getInstance().parsecmd(command, activeChar);
-			}
-			else if (command.startsWith("_bbstopics"))
-			{
-				TopicBBSManager.getInstance().parsecmd(command, activeChar);
-			}
-			else if (command.startsWith("_bbsposts"))
-			{
-				PostBBSManager.getInstance().parsecmd(command, activeChar);
-			}
-			else if (command.startsWith("_bbstop"))
-			{
-				TopBBSManager.getInstance().parsecmd(command, activeChar);
-			}
-			else if (command.startsWith("_bbshome"))
-			{
-				TopBBSManager.getInstance().parsecmd(command, activeChar);
-			}
-			else if (command.startsWith("_bbsloc"))
-			{
+			default:
+			case 0: //disabled
+				activeChar.sendPacket(new SystemMessage(SystemMessageId.CB_OFFLINE));
+				break;
+			case 1: // old
 				RegionBBSManager.getInstance().parsecmd(command, activeChar);
-			}
-			else
-			{
-				ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + command + " is not implemented yet</center><br><br></body></html>", "101");
-				activeChar.sendPacket(sb);
-				activeChar.sendPacket(new ShowBoard(null, "102"));
-				activeChar.sendPacket(new ShowBoard(null, "103"));
-			}
-		}
-		else if (Config.COMMUNITY_TYPE.equals("old"))
-		{
-			RegionBBSManager.getInstance().parsecmd(command, activeChar);
-		}
-		else
-		{
-			activeChar.sendPacket(new SystemMessage(SystemMessageId.CB_OFFLINE));
+				break;
+			case 2: // new
+				if (command.startsWith("_bbsclan"))
+				{
+					ClanBBSManager.getInstance().parsecmd(command, activeChar);
+				}
+				else if (command.startsWith("_bbsmemo"))
+				{
+					TopicBBSManager.getInstance().parsecmd(command, activeChar);
+				}
+				else if (command.startsWith("_bbstopics"))
+				{
+					TopicBBSManager.getInstance().parsecmd(command, activeChar);
+				}
+				else if (command.startsWith("_bbsposts"))
+				{
+					PostBBSManager.getInstance().parsecmd(command, activeChar);
+				}
+				else if (command.startsWith("_bbstop"))
+				{
+					TopBBSManager.getInstance().parsecmd(command, activeChar);
+				}
+				else if (command.startsWith("_bbshome"))
+				{
+					TopBBSManager.getInstance().parsecmd(command, activeChar);
+				}
+				else if (command.startsWith("_bbsloc"))
+				{
+					RegionBBSManager.getInstance().parsecmd(command, activeChar);
+				}
+				else
+				{
+					ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + command + " is not implemented yet</center><br><br></body></html>", "101");
+					activeChar.sendPacket(sb);
+					activeChar.sendPacket(new ShowBoard(null, "102"));
+					activeChar.sendPacket(new ShowBoard(null, "103"));
+				}
+				break;
 		}
 	}
 	
@@ -113,38 +114,39 @@ public class CommunityBoard
 		if (activeChar == null)
 			return;
 		
-		if (Config.COMMUNITY_TYPE.equals("full"))
+		switch (Config.COMMUNITY_TYPE)
 		{
-			if (url.equals("Topic"))
-			{
-				TopicBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
-			}
-			else if (url.equals("Post"))
-			{
-				PostBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
-			}
-			else if (url.equals("Region"))
-			{
+			case 2:
+				if (url.equals("Topic"))
+				{
+					TopicBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
+				}
+				else if (url.equals("Post"))
+				{
+					PostBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
+				}
+				else if (url.equals("Region"))
+				{
+					RegionBBSManager.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");
+					activeChar.sendPacket(sb);
+					activeChar.sendPacket(new ShowBoard(null, "102"));
+					activeChar.sendPacket(new ShowBoard(null, "103"));
+				}
+				break;
+			case 1:
 				RegionBBSManager.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");
+				break;
+			default:
+			case 0:
+				ShowBoard sb = new ShowBoard("<html><body><br><br><center>The Community board is currently disable</center><br><br></body></html>", "101");
 				activeChar.sendPacket(sb);
 				activeChar.sendPacket(new ShowBoard(null, "102"));
 				activeChar.sendPacket(new ShowBoard(null, "103"));
-			}
-		}
-		else if (Config.COMMUNITY_TYPE.equals("old"))
-		{
-			RegionBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
-		}
-		else
-		{
-			ShowBoard sb = new ShowBoard("<html><body><br><br><center>The Community board is currently disable</center><br><br></body></html>", "101");
-			activeChar.sendPacket(sb);
-			activeChar.sendPacket(new ShowBoard(null, "102"));
-			activeChar.sendPacket(new ShowBoard(null, "103"));
+				break;
 		}
 	}
 }

+ 1 - 1
L2_GameServer/java/net/sf/l2j/gameserver/communitybbs/Manager/RegionBBSManager.java

@@ -78,7 +78,7 @@ public class RegionBBSManager extends BaseBBSManager
 		}
 		else
 		{
-			if (Config.COMMUNITY_TYPE.equals("old"))
+			if (Config.COMMUNITY_TYPE == 1)
 			{
 				showOldCommunity(activeChar, 1);
 			}