diff options
| author | 2020-05-03 21:06:38 +0100 | |
|---|---|---|
| committer | 2020-05-03 21:06:38 +0100 | |
| commit | 854f4d49407e45d67dd5754afd21a7e59970ca5b (patch) | |
| tree | 582e3245786f9723b5895b0c8d41087b0e6bb416 /src/main/java/cuchaz/enigma/EnigmaProfile.java | |
| parent | Rewrite search dialog (#233) (diff) | |
| download | enigma-fork-854f4d49407e45d67dd5754afd21a7e59970ca5b.tar.gz enigma-fork-854f4d49407e45d67dd5754afd21a7e59970ca5b.tar.xz enigma-fork-854f4d49407e45d67dd5754afd21a7e59970ca5b.zip | |
Multiplayer support (#221)
* First pass on multiplayer
* Apply review suggestions
* Dedicated Enigma server
* Don't jump to references when other users do stuff
* Better UI + translations
* french translation
* Apply review suggestions
* Document the protocol
* Fix most issues with scrolling.
* Apply review suggestions
* Fix zip hash issues + add a bit more logging
* Optimize zip hash
* Fix a couple of login bugs
* Add message log and user list
* Make Message an abstract class
* Make status bar work, add chat box
* Hide message log/users list when not connected
* Fix status bar not resetting entirely
* Run stop server task on server thread to prevent multithreading race conditions
* Add c2s message to packet id list
* Fix message scroll bar not scrolling to the end
* Formatting
* User list size -> ushort
* Combine contains and remove check
* Check removal before sending packet
* Add password to login packet
* Fix the GUI closing the rename text field when someone else renames something
* Update fr_fr.json
* oups
* Make connection/server create dialogs not useless if it fails once
* Refactor UI state updating
* Fix imports
* Fix Collab menu
* Fix NPE when rename not allowed
* Make the log file a configurable option
* Don't use modified UTF
* Update fr_fr.json
* Bump version to 0.15.4
* Apparently I can't spell neither words nor semantic versions
Co-authored-by: Yanis48 <doublecraft.official@gmail.com>
Co-authored-by: 2xsaiko <git@dblsaiko.net>
Diffstat (limited to 'src/main/java/cuchaz/enigma/EnigmaProfile.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/EnigmaProfile.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main/java/cuchaz/enigma/EnigmaProfile.java b/src/main/java/cuchaz/enigma/EnigmaProfile.java index 5a68be1..09b90f5 100644 --- a/src/main/java/cuchaz/enigma/EnigmaProfile.java +++ b/src/main/java/cuchaz/enigma/EnigmaProfile.java | |||
| @@ -14,8 +14,15 @@ import cuchaz.enigma.api.service.EnigmaServiceType; | |||
| 14 | import cuchaz.enigma.translation.mapping.MappingFileNameFormat; | 14 | import cuchaz.enigma.translation.mapping.MappingFileNameFormat; |
| 15 | import cuchaz.enigma.translation.mapping.MappingSaveParameters; | 15 | import cuchaz.enigma.translation.mapping.MappingSaveParameters; |
| 16 | 16 | ||
| 17 | import javax.annotation.Nullable; | ||
| 18 | import java.io.BufferedReader; | ||
| 19 | import java.io.IOException; | ||
| 20 | import java.io.InputStreamReader; | ||
| 17 | import java.io.Reader; | 21 | import java.io.Reader; |
| 18 | import java.lang.reflect.Type; | 22 | import java.lang.reflect.Type; |
| 23 | import java.nio.charset.StandardCharsets; | ||
| 24 | import java.nio.file.Files; | ||
| 25 | import java.nio.file.Path; | ||
| 19 | import java.util.Collections; | 26 | import java.util.Collections; |
| 20 | import java.util.List; | 27 | import java.util.List; |
| 21 | import java.util.Map; | 28 | import java.util.Map; |
| @@ -41,6 +48,21 @@ public final class EnigmaProfile { | |||
| 41 | this.serviceProfiles = serviceProfiles; | 48 | this.serviceProfiles = serviceProfiles; |
| 42 | } | 49 | } |
| 43 | 50 | ||
| 51 | public static EnigmaProfile read(@Nullable Path file) throws IOException { | ||
| 52 | if (file != null) { | ||
| 53 | try (BufferedReader reader = Files.newBufferedReader(file)) { | ||
| 54 | return EnigmaProfile.parse(reader); | ||
| 55 | } | ||
| 56 | } else { | ||
| 57 | try (BufferedReader reader = new BufferedReader(new InputStreamReader(Main.class.getResourceAsStream("/profile.json"), StandardCharsets.UTF_8))) { | ||
| 58 | return EnigmaProfile.parse(reader); | ||
| 59 | } catch (IOException ex) { | ||
| 60 | System.err.println("Failed to load default profile, will use empty profile: " + ex.getMessage()); | ||
| 61 | return EnigmaProfile.EMPTY; | ||
| 62 | } | ||
| 63 | } | ||
| 64 | } | ||
| 65 | |||
| 44 | public static EnigmaProfile parse(Reader reader) { | 66 | public static EnigmaProfile parse(Reader reader) { |
| 45 | return GSON.fromJson(reader, EnigmaProfile.class); | 67 | return GSON.fromJson(reader, EnigmaProfile.class); |
| 46 | } | 68 | } |