Skip to content

Commit debb7fe

Browse files
committed
Update 1.7.4
1 parent 16f05b4 commit debb7fe

20 files changed

Lines changed: 181 additions & 120 deletions

File tree

api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<artifactId>lastloginapi</artifactId>
99
<groupId>com.alessiodp.lastloginapi</groupId>
10-
<version>1.7.3</version>
10+
<version>1.7.4</version>
1111
</parent>
1212

1313
<artifactId>lastloginapi-api</artifactId>

bukkit/dependency-reduced-pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<artifactId>lastloginapi</artifactId>
55
<groupId>com.alessiodp.lastloginapi</groupId>
6-
<version>1.7.3</version>
6+
<version>1.7.4</version>
77
</parent>
88
<modelVersion>4.0.0</modelVersion>
99
<artifactId>lastloginapi-bukkit</artifactId>
@@ -72,7 +72,7 @@
7272
<dependency>
7373
<groupId>com.alessiodp.lastloginapi</groupId>
7474
<artifactId>lastloginapi-common</artifactId>
75-
<version>1.7.3</version>
75+
<version>1.7.4</version>
7676
<scope>compile</scope>
7777
</dependency>
7878
<dependency>
@@ -114,7 +114,7 @@
114114
<dependency>
115115
<groupId>me.clip</groupId>
116116
<artifactId>placeholderapi</artifactId>
117-
<version>2.11.1</version>
117+
<version>2.11.2</version>
118118
<scope>provided</scope>
119119
<exclusions>
120120
<exclusion>
@@ -140,7 +140,7 @@
140140
<dependency>
141141
<groupId>org.mockito</groupId>
142142
<artifactId>mockito-inline</artifactId>
143-
<version>4.5.1</version>
143+
<version>4.11.0</version>
144144
<scope>test</scope>
145145
<exclusions>
146146
<exclusion>
@@ -152,7 +152,7 @@
152152
<dependency>
153153
<groupId>org.junit.jupiter</groupId>
154154
<artifactId>junit-jupiter</artifactId>
155-
<version>5.8.2</version>
155+
<version>5.9.1</version>
156156
<scope>test</scope>
157157
<exclusions>
158158
<exclusion>

bukkit/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<artifactId>lastloginapi</artifactId>
99
<groupId>com.alessiodp.lastloginapi</groupId>
10-
<version>1.7.3</version>
10+
<version>1.7.4</version>
1111
</parent>
1212

1313
<artifactId>lastloginapi-bukkit</artifactId>

bukkit/src/main/java/com/alessiodp/lastloginapi/bukkit/BukkitLastLoginPlugin.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.alessiodp.lastloginapi.bukkit;
22

3-
import com.alessiodp.core.bukkit.addons.internal.json.BukkitJsonHandler;
4-
import com.alessiodp.core.bukkit.addons.internal.json.SpigotJsonHandler;
5-
import com.alessiodp.core.bukkit.addons.internal.title.BukkitTitleHandler;
3+
import com.alessiodp.core.bukkit.addons.internal.BukkitJsonHandler;
4+
import com.alessiodp.core.bukkit.addons.internal.SpigotJsonHandler;
65
import com.alessiodp.core.bukkit.scheduling.ADPBukkitScheduler;
76
import com.alessiodp.core.common.bootstrap.ADPBootstrap;
87
import com.alessiodp.core.common.configuration.Constants;
@@ -62,11 +61,6 @@ protected void initializeJsonHandler() {
6261
jsonHandler = new BukkitJsonHandler(this);
6362
}
6463

65-
@Override
66-
protected void initializeTitleHandler() {
67-
titleHandler = new BukkitTitleHandler(this);
68-
}
69-
7064
@Override
7165
protected void registerListeners() {
7266
getLoggerManager().logDebug(Constants.DEBUG_PLUGIN_REGISTERING, true);

bukkit/src/test/java/com/alessiodp/lastloginapi/bukkit/BukkitConfigurationTest.java

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,71 @@
33
import com.alessiodp.core.common.addons.external.simpleyaml.configuration.file.YamlFile;
44
import com.alessiodp.core.common.configuration.ConfigOption;
55
import com.alessiodp.core.common.configuration.ConfigurationFile;
6+
import com.alessiodp.core.common.logging.logger.ADPLogger;
67
import com.alessiodp.lastloginapi.bukkit.configuration.data.BukkitConfigMain;
78
import com.alessiodp.lastloginapi.bukkit.configuration.data.BukkitMessages;
89
import com.alessiodp.lastloginapi.common.LastLoginPlugin;
10+
import org.junit.jupiter.api.BeforeAll;
911
import org.junit.jupiter.api.Test;
12+
import org.junit.jupiter.api.io.TempDir;
1013

11-
import java.io.InputStreamReader;
14+
import java.io.IOException;
1215
import java.lang.reflect.Field;
16+
import java.nio.file.Path;
1317
import java.util.Collections;
1418
import java.util.List;
1519

1620
import static org.junit.jupiter.api.Assertions.assertNotNull;
21+
import static org.mockito.ArgumentMatchers.anyString;
22+
import static org.mockito.Mockito.doAnswer;
1723
import static org.mockito.Mockito.mock;
24+
import static org.mockito.Mockito.when;
1825

1926
public class BukkitConfigurationTest {
2027
private static final LastLoginPlugin mockPlugin = mock(LastLoginPlugin.class);
2128

29+
@BeforeAll
30+
public static void setUp() {
31+
ADPLogger testLogger = mock(ADPLogger.class);
32+
doAnswer((params) -> {
33+
//System.out.println((String) params.getArgument(0));
34+
return null;
35+
}).when(testLogger).info(anyString());
36+
doAnswer((params) -> {
37+
System.out.println((String) params.getArgument(0));
38+
return null;
39+
}).when(testLogger).error(anyString());
40+
when(mockPlugin.getLogger()).thenReturn(testLogger);
41+
42+
when(mockPlugin.getResource(anyString())).thenAnswer((a) -> ClassLoader.getSystemResourceAsStream(a.getArgument(0)));
43+
}
44+
2245
@Test
23-
public void testConfigMain() throws IllegalAccessException {
46+
public void testConfigMain(@TempDir Path tempDir) throws IllegalAccessException, IOException {
2447
BukkitConfigMain configMain = new BukkitConfigMain(mockPlugin);
2548

2649
List<String> skipPaths = Collections.emptyList();
2750

28-
testConfiguration(configMain, skipPaths);
51+
testConfiguration(configMain, skipPaths, tempDir);
52+
testAutomaticUpgrade(configMain);
2953
}
3054

3155
@Test
32-
public void testMessages() throws IllegalAccessException {
56+
public void testMessages(@TempDir Path tempDir) throws IllegalAccessException, IOException {
3357
BukkitMessages messages = new BukkitMessages(mockPlugin);
3458

3559
List<String> skipPaths = Collections.emptyList();
3660

37-
testConfiguration(messages, skipPaths);
61+
testConfiguration(messages, skipPaths, tempDir);
62+
testAutomaticUpgrade(messages);
3863
}
3964

40-
private void testConfiguration(ConfigurationFile configurationFile, List<String> skipPaths) throws IllegalAccessException {
65+
private void testConfiguration(ConfigurationFile configurationFile, List<String> skipPaths, Path tempDir) throws IllegalAccessException {
4166
Field[] fields = configurationFile.getClass().getFields();
4267

4368
// Initialize YAML
44-
YamlFile yf = YamlFile.loadConfiguration(new InputStreamReader(getClass().getResourceAsStream("/" + configurationFile.getResourceName())));
69+
configurationFile.initializeConfiguration(tempDir);
70+
YamlFile yf = configurationFile.getConfiguration();
4571

4672
// Check fields
4773
for (Field f : fields) {
@@ -54,6 +80,13 @@ private void testConfiguration(ConfigurationFile configurationFile, List<String>
5480
}
5581
}
5682

83+
private void testAutomaticUpgrade(ConfigurationFile configurationFile) throws IOException {
84+
configurationFile.getConfiguration().set("dont-edit-this.version", -1);
85+
configurationFile.getConfiguration().save();
86+
87+
configurationFile.checkVersion(true);
88+
}
89+
5790
private boolean skippablePath(String path, List<String> skipPaths) {
5891
for (String sp : skipPaths) {
5992
if (path.startsWith(sp))

bungeecord/dependency-reduced-pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<artifactId>lastloginapi</artifactId>
55
<groupId>com.alessiodp.lastloginapi</groupId>
6-
<version>1.7.3</version>
6+
<version>1.7.4</version>
77
</parent>
88
<modelVersion>4.0.0</modelVersion>
99
<artifactId>lastloginapi-bungeecord</artifactId>
@@ -58,7 +58,7 @@
5858
<dependency>
5959
<groupId>com.alessiodp.lastloginapi</groupId>
6060
<artifactId>lastloginapi-common</artifactId>
61-
<version>1.7.3</version>
61+
<version>1.7.4</version>
6262
<scope>compile</scope>
6363
</dependency>
6464
<dependency>
@@ -70,7 +70,7 @@
7070
<dependency>
7171
<groupId>org.mockito</groupId>
7272
<artifactId>mockito-inline</artifactId>
73-
<version>4.5.1</version>
73+
<version>4.11.0</version>
7474
<scope>test</scope>
7575
<exclusions>
7676
<exclusion>
@@ -82,7 +82,7 @@
8282
<dependency>
8383
<groupId>org.junit.jupiter</groupId>
8484
<artifactId>junit-jupiter</artifactId>
85-
<version>5.8.2</version>
85+
<version>5.9.1</version>
8686
<scope>test</scope>
8787
<exclusions>
8888
<exclusion>

bungeecord/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<artifactId>lastloginapi</artifactId>
99
<groupId>com.alessiodp.lastloginapi</groupId>
10-
<version>1.7.3</version>
10+
<version>1.7.4</version>
1111
</parent>
1212

1313
<artifactId>lastloginapi-bungeecord</artifactId>

bungeecord/src/main/java/com/alessiodp/lastloginapi/bungeecord/BungeeLastLoginPlugin.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.alessiodp.lastloginapi.bungeecord;
22

3-
import com.alessiodp.core.bungeecord.addons.internal.json.BungeeJsonHandler;
4-
import com.alessiodp.core.bungeecord.addons.internal.title.BungeeTitleHandler;
3+
import com.alessiodp.core.bungeecord.addons.internal.BungeeJsonHandler;
54
import com.alessiodp.core.bungeecord.scheduling.ADPBungeeScheduler;
65
import com.alessiodp.core.common.bootstrap.ADPBootstrap;
76
import com.alessiodp.core.common.configuration.Constants;
@@ -56,11 +55,6 @@ protected void initializeJsonHandler() {
5655
jsonHandler = new BungeeJsonHandler(this);
5756
}
5857

59-
@Override
60-
protected void initializeTitleHandler() {
61-
titleHandler = new BungeeTitleHandler(this);
62-
}
63-
6458
@Override
6559
protected void registerListeners() {
6660
getLoggerManager().logDebug(Constants.DEBUG_PLUGIN_REGISTERING, true);

bungeecord/src/test/java/com/alessiodp/lastloginapi/bungeecord/BungeeConfigurationTest.java

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,71 @@
33
import com.alessiodp.core.common.addons.external.simpleyaml.configuration.file.YamlFile;
44
import com.alessiodp.core.common.configuration.ConfigOption;
55
import com.alessiodp.core.common.configuration.ConfigurationFile;
6+
import com.alessiodp.core.common.logging.logger.ADPLogger;
67
import com.alessiodp.lastloginapi.bungeecord.configuration.data.BungeeConfigMain;
78
import com.alessiodp.lastloginapi.bungeecord.configuration.data.BungeeMessages;
89
import com.alessiodp.lastloginapi.common.LastLoginPlugin;
10+
import org.junit.jupiter.api.BeforeAll;
911
import org.junit.jupiter.api.Test;
12+
import org.junit.jupiter.api.io.TempDir;
1013

11-
import java.io.InputStreamReader;
14+
import java.io.IOException;
1215
import java.lang.reflect.Field;
16+
import java.nio.file.Path;
1317
import java.util.Collections;
1418
import java.util.List;
1519

1620
import static org.junit.jupiter.api.Assertions.assertNotNull;
21+
import static org.mockito.ArgumentMatchers.anyString;
22+
import static org.mockito.Mockito.doAnswer;
1723
import static org.mockito.Mockito.mock;
24+
import static org.mockito.Mockito.when;
1825

1926
public class BungeeConfigurationTest {
2027
private static final LastLoginPlugin mockPlugin = mock(LastLoginPlugin.class);
2128

29+
@BeforeAll
30+
public static void setUp() {
31+
ADPLogger testLogger = mock(ADPLogger.class);
32+
doAnswer((params) -> {
33+
//System.out.println((String) params.getArgument(0));
34+
return null;
35+
}).when(testLogger).info(anyString());
36+
doAnswer((params) -> {
37+
System.out.println((String) params.getArgument(0));
38+
return null;
39+
}).when(testLogger).error(anyString());
40+
when(mockPlugin.getLogger()).thenReturn(testLogger);
41+
42+
when(mockPlugin.getResource(anyString())).thenAnswer((a) -> ClassLoader.getSystemResourceAsStream(a.getArgument(0)));
43+
}
44+
2245
@Test
23-
public void testConfigMain() throws IllegalAccessException {
46+
public void testConfigMain(@TempDir Path tempDir) throws IllegalAccessException, IOException {
2447
BungeeConfigMain configMain = new BungeeConfigMain(mockPlugin);
2548

2649
List<String> skipPaths = Collections.emptyList();
2750

28-
testConfiguration(configMain, skipPaths);
51+
testConfiguration(configMain, skipPaths, tempDir);
52+
testAutomaticUpgrade(configMain);
2953
}
3054

3155
@Test
32-
public void testMessages() throws IllegalAccessException {
56+
public void testMessages(@TempDir Path tempDir) throws IllegalAccessException, IOException {
3357
BungeeMessages messages = new BungeeMessages(mockPlugin);
3458

3559
List<String> skipPaths = Collections.emptyList();
3660

37-
testConfiguration(messages, skipPaths);
61+
testConfiguration(messages, skipPaths, tempDir);
62+
testAutomaticUpgrade(messages);
3863
}
3964

40-
private void testConfiguration(ConfigurationFile configurationFile, List<String> skipPaths) throws IllegalAccessException {
65+
private void testConfiguration(ConfigurationFile configurationFile, List<String> skipPaths, Path tempDir) throws IllegalAccessException {
4166
Field[] fields = configurationFile.getClass().getFields();
4267

4368
// Initialize YAML
44-
YamlFile yf = YamlFile.loadConfiguration(new InputStreamReader(getClass().getResourceAsStream("/" + configurationFile.getResourceName())));
69+
configurationFile.initializeConfiguration(tempDir);
70+
YamlFile yf = configurationFile.getConfiguration();
4571

4672
// Check fields
4773
for (Field f : fields) {
@@ -54,6 +80,13 @@ private void testConfiguration(ConfigurationFile configurationFile, List<String>
5480
}
5581
}
5682

83+
private void testAutomaticUpgrade(ConfigurationFile configurationFile) throws IOException {
84+
configurationFile.getConfiguration().set("dont-edit-this.version", -1);
85+
configurationFile.getConfiguration().save();
86+
87+
configurationFile.checkVersion(true);
88+
}
89+
5790
private boolean skippablePath(String path, List<String> skipPaths) {
5891
for (String sp : skipPaths) {
5992
if (path.startsWith(sp))

0 commit comments

Comments
 (0)