22
33import me .tinyoverflow .privatestatus .events .AddAddressEvent ;
44import org .bukkit .OfflinePlayer ;
5- import org .jetbrains .annotations .NotNull ;
65
7- import javax .sound .sampled .Line ;
86import java .net .InetAddress ;
97import java .net .UnknownHostException ;
108import java .time .LocalDateTime ;
@@ -28,35 +26,6 @@ public AddressRepository(Logger logger)
2826 this .zoneOffset = OffsetDateTime .now ().getOffset ();
2927 }
3028
31- /**
32- * Loads data from a map consisting of the UUID string as the key and the base64 encoded address as the value.
33- *
34- * @param configMap Map of key => value pairs from the configuration file.
35- */
36- public void fromMap (@ NotNull Map <String , Object > configMap )
37- {
38- // Make sure we work with a fresh map.
39- storage .clear ();
40-
41- // Process each and every item inside the section.
42- for (Map .Entry <String , Object > entry : configMap .entrySet ()) {
43- String address = entry .getKey ();
44- LocalDateTime expiration = LocalDateTime .ofEpochSecond ((Long ) entry .getValue (), 0 , zoneOffset );
45-
46- // Decode the stored address and add it to the repository.
47- try {
48- InetAddress inetAddress = InetAddress .getByName (address );
49- storage .put (inetAddress , expiration );
50- }
51- catch (UnknownHostException e ) {
52- logger .warning ("Unknown host found in config. Skipping: " + address );
53- }
54- }
55-
56- // Notify the user about the loading state.
57- logger .info ("Loaded " + storage .size () + " addresses from configuration." );
58- }
59-
6029 /**
6130 * Loads known addresses from a {@code List<Map<String, Object>>}.
6231 *
@@ -87,25 +56,6 @@ public void fromList(List<Map<String, Object>> data)
8756 logger .info ("Loaded " + storage .size () + " addresses from configuration." );
8857 }
8958
90- /**
91- * Returns the data as a string map.
92- *
93- * @return The map with the UUID string as the key and the base64 encoded address as the value.
94- */
95- public Map <String , Long > toMap ()
96- {
97- Map <String , Long > addressList = new HashMap <>();
98-
99- for (Map .Entry <InetAddress , LocalDateTime > entry : storage .entrySet ()) {
100- InetAddress inetAddress = entry .getKey ();
101- LocalDateTime localDateTime = entry .getValue ();
102-
103- addressList .put (inetAddress .getHostAddress (), localDateTime .toEpochSecond (zoneOffset ));
104- }
105-
106- return addressList ;
107- }
108-
10959 public List <Map <String , Object >> toList ()
11060 {
11161 List <Map <String , Object >> addressList = new ArrayList <>();
@@ -148,6 +98,7 @@ public void add(OfflinePlayer player, InetAddress inetAddress, LocalDateTime exp
14898 }
14999 }
150100
101+ @ SuppressWarnings ("unchecked" )
151102 public Map <InetAddress , LocalDateTime > getAll ()
152103 {
153104 return (Map <InetAddress , LocalDateTime >) storage .clone ();
0 commit comments