diff --git a/runelite-client/src/main/java/net/runelite/client/account/AccountSession.java b/runelite-client/src/main/java/net/runelite/client/account/AccountSession.java index 24d9d29356..dc1534ab94 100644 --- a/runelite-client/src/main/java/net/runelite/client/account/AccountSession.java +++ b/runelite-client/src/main/java/net/runelite/client/account/AccountSession.java @@ -25,73 +25,15 @@ package net.runelite.client.account; import java.time.Instant; -import java.util.Objects; import java.util.UUID; +import lombok.Data; +import lombok.EqualsAndHashCode; +@Data +@EqualsAndHashCode(of = "uuid") public class AccountSession { - private UUID uuid; + private final UUID uuid; + private final Instant created; private String username; - private Instant created; - - @Override - public int hashCode() - { - int hash = 3; - hash = 29 * hash + Objects.hashCode(this.uuid); - return hash; - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - if (obj == null) - { - return false; - } - if (getClass() != obj.getClass()) - { - return false; - } - final AccountSession other = (AccountSession) obj; - if (!Objects.equals(this.uuid, other.uuid)) - { - return false; - } - return true; - } - - public UUID getUuid() - { - return uuid; - } - - public void setUuid(UUID uuid) - { - this.uuid = uuid; - } - - public String getUsername() - { - return username; - } - - public void setUsername(String username) - { - this.username = username; - } - - public Instant getCreated() - { - return created; - } - - public void setCreated(Instant created) - { - this.created = created; - } -} +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/account/AccountPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/account/AccountPlugin.java index ca0c5c7fff..29fdaea89a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/account/AccountPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/account/AccountPlugin.java @@ -132,11 +132,7 @@ public class AccountPlugin extends Plugin } // Create new session - AccountSession session = new AccountSession(); - session.setUuid(login.getUid()); - session.setCreated(Instant.now()); - - sessionManager.openSession(session); + sessionManager.openSession(new AccountSession(login.getUid(), Instant.now())); if (!Desktop.isDesktopSupported()) { diff --git a/runelite-client/src/test/java/net/runelite/client/config/ConfigManagerTest.java b/runelite-client/src/test/java/net/runelite/client/config/ConfigManagerTest.java index 6b7f289bca..b5f520ee2a 100644 --- a/runelite-client/src/test/java/net/runelite/client/config/ConfigManagerTest.java +++ b/runelite-client/src/test/java/net/runelite/client/config/ConfigManagerTest.java @@ -68,10 +68,8 @@ public class ConfigManagerTest @Test public void testGetConfig() throws IOException { - AccountSession accountSession = new AccountSession(); - accountSession.setUuid(UUID.randomUUID()); + AccountSession accountSession = new AccountSession(UUID.randomUUID(), Instant.now()); accountSession.setUsername("test"); - accountSession.setCreated(Instant.now()); manager.setConfiguration("test", "key", "moo"); @@ -82,10 +80,8 @@ public class ConfigManagerTest @Test public void testGetConfigDefault() throws IOException { - AccountSession accountSession = new AccountSession(); - accountSession.setUuid(UUID.randomUUID()); + AccountSession accountSession = new AccountSession(UUID.randomUUID(), Instant.now()); accountSession.setUsername("test"); - accountSession.setCreated(Instant.now()); TestConfig conf = manager.getConfig(TestConfig.class); Assert.assertEquals("default", conf.key()); @@ -94,10 +90,8 @@ public class ConfigManagerTest @Test public void testSetConfig() throws IOException { - AccountSession accountSession = new AccountSession(); - accountSession.setUuid(UUID.randomUUID()); + AccountSession accountSession = new AccountSession(UUID.randomUUID(), Instant.now()); accountSession.setUsername("test"); - accountSession.setCreated(Instant.now()); TestConfig conf = manager.getConfig(TestConfig.class); conf.key("new value"); @@ -108,10 +102,8 @@ public class ConfigManagerTest @Test public void testGetConfigDescriptor() throws IOException { - AccountSession accountSession = new AccountSession(); - accountSession.setUuid(UUID.randomUUID()); + AccountSession accountSession = new AccountSession(UUID.randomUUID(), Instant.now()); accountSession.setUsername("test"); - accountSession.setCreated(Instant.now()); TestConfig conf = manager.getConfig(TestConfig.class); ConfigDescriptor descriptor = manager.getConfigDescriptor(conf);