mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-10-31 17:23:42 +01:00 
			
		
		
		
	fixed bug where duplicate comments with leading whitespace were ignored
This commit is contained in:
		
							
								
								
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							| @@ -2,7 +2,7 @@ | ||||
|     <modelVersion>4.0.0</modelVersion> | ||||
|     <groupId>com.gmail.nossr50.mcMMO</groupId> | ||||
|     <artifactId>mcMMO</artifactId> | ||||
|     <version>2.1.208</version> | ||||
|     <version>2.1.209-SNAPSHOT</version> | ||||
|     <name>mcMMO</name> | ||||
|     <url>https://github.com/mcMMO-Dev/mcMMO</url> | ||||
|     <scm> | ||||
|   | ||||
| @@ -11,7 +11,9 @@ import java.util.List; | ||||
| import java.util.Set; | ||||
|  | ||||
| public abstract class BukkitConfig { | ||||
|     public static final String CURRENT_CONFIG_PATCH_VER = "ConfigPatchVersion: 1"; | ||||
|     public static final String CONFIG_PATCH_PREFIX = "ConfigPatchVersion:"; | ||||
|     public static final String CURRENT_CONFIG_PATCH_VER = "ConfigPatchVersion: 2"; | ||||
|     public static final char COMMENT_PREFIX = '#'; | ||||
|     protected final String fileName; | ||||
|     protected final File configFile; | ||||
|     protected YamlConfiguration config; | ||||
| @@ -149,7 +151,11 @@ public abstract class BukkitConfig { | ||||
|                     break; | ||||
|                 } | ||||
|  | ||||
|                 if (line.startsWith("#")) { | ||||
|                 //Older version, don't append this line | ||||
|                 if(line.startsWith(CONFIG_PATCH_PREFIX)) | ||||
|                     continue; | ||||
|  | ||||
|                 if (isFirstCharAsciiCharacter(line, COMMENT_PREFIX)) { | ||||
|                     if(seenBefore.contains(line)) | ||||
|                         dupedLines++; | ||||
|                     else | ||||
| @@ -189,4 +195,19 @@ public abstract class BukkitConfig { | ||||
|             ex.printStackTrace(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private boolean isFirstCharAsciiCharacter(String line, char character) { | ||||
|         if(line == null || line.isEmpty()) { | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
|         for(Character c : line.toCharArray()) { | ||||
|             if(c.equals(' ')) | ||||
|                 continue; | ||||
|  | ||||
|             return c.equals(character); | ||||
|         } | ||||
|  | ||||
|         return false; | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 nossr50
					nossr50