parent
					
						
							
								38a0cc331d
							
						
					
				
			
			
				commit
				
					
						e564aae43d
					
				
			
		
					 1 changed files with 19 additions and 3 deletions
				
			
		| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (C) 2024  Minecon724
 | 
					 * Copyright (C) 2025  Minecon724
 | 
				
			||||||
 * Tweaks724 is licensed under the GNU General Public License. See the LICENSE.md file
 | 
					 * Tweaks724 is licensed under the GNU General Public License. See the LICENSE.md file
 | 
				
			||||||
 * in the project root for the full license text.
 | 
					 * in the project root for the full license text.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
| 
						 | 
					@ -11,6 +11,9 @@ import com.comphenix.protocol.ProtocolLibrary;
 | 
				
			||||||
import com.comphenix.protocol.events.*;
 | 
					import com.comphenix.protocol.events.*;
 | 
				
			||||||
import com.comphenix.protocol.reflect.StructureModifier;
 | 
					import com.comphenix.protocol.reflect.StructureModifier;
 | 
				
			||||||
import com.google.gson.JsonElement;
 | 
					import com.google.gson.JsonElement;
 | 
				
			||||||
 | 
					import com.google.gson.JsonParseException;
 | 
				
			||||||
 | 
					import com.google.gson.JsonParser;
 | 
				
			||||||
 | 
					import eu.m724.tweaks.DebugLogger;
 | 
				
			||||||
import eu.m724.tweaks.TweaksConfig;
 | 
					import eu.m724.tweaks.TweaksConfig;
 | 
				
			||||||
import eu.m724.tweaks.TweaksPlugin;
 | 
					import eu.m724.tweaks.TweaksPlugin;
 | 
				
			||||||
import net.md_5.bungee.api.chat.TextComponent;
 | 
					import net.md_5.bungee.api.chat.TextComponent;
 | 
				
			||||||
| 
						 | 
					@ -64,8 +67,21 @@ public class MotdManager {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // MOTDs are split with an empty line
 | 
					        // MOTDs are split with an empty line
 | 
				
			||||||
        motds = Arrays.stream(fileContent.split("\n\n"))
 | 
					        motds = Arrays.stream(fileContent.split("\n\n"))
 | 
				
			||||||
                .map(s -> {
 | 
					                .map(entry -> {
 | 
				
			||||||
                    JsonElement json = ComponentSerializer.toJson(TextComponent.fromLegacy(s.strip()));
 | 
					                    entry = entry.strip();
 | 
				
			||||||
 | 
					                    JsonElement json = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    try {
 | 
				
			||||||
 | 
					                        json = JsonParser.parseString(entry);
 | 
				
			||||||
 | 
					                        DebugLogger.fine("JSON line: " + entry);
 | 
				
			||||||
 | 
					                    } catch (JsonParseException e) {
 | 
				
			||||||
 | 
					                        DebugLogger.fine("Not a JSON line: " + entry);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (json == null) {
 | 
				
			||||||
 | 
					                        json = ComponentSerializer.toJson(TextComponent.fromLegacy(entry));
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    return Component.Serializer.fromJson(json, RegistryAccess.EMPTY);
 | 
					                    return Component.Serializer.fromJson(json, RegistryAccess.EMPTY);
 | 
				
			||||||
                })
 | 
					                })
 | 
				
			||||||
                .toArray(Component[]::new);
 | 
					                .toArray(Component[]::new);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue