mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-13 05:54:26 +01:00
Bump spigot api version, fix BukkitService.runTaskTimerAsynchronously() #2150
This commit is contained in:
parent
1cd0ce17a5
commit
990830c395
2
pom.xml
2
pom.xml
@ -64,7 +64,7 @@
|
||||
<maven.minimumVersion>3.3.9</maven.minimumVersion>
|
||||
|
||||
<!-- Dependencies versions -->
|
||||
<spigot.version>1.15.2-R0.1-SNAPSHOT</spigot.version>
|
||||
<spigot.version>1.16.1-R0.1-SNAPSHOT</spigot.version>
|
||||
|
||||
<!-- Versioning properties -->
|
||||
<project.outputName>AuthMe</project.outputName>
|
||||
|
@ -17,6 +17,7 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
@ -94,16 +95,19 @@ public class OnStartupTasks {
|
||||
if (!settings.getProperty(RECALL_PLAYERS)) {
|
||||
return;
|
||||
}
|
||||
bukkitService.runTaskTimerAsynchronously(() -> {
|
||||
List<String> loggedPlayersWithEmptyMail = dataSource.getLoggedPlayersWithEmptyMail();
|
||||
bukkitService.runTask(() -> {
|
||||
for (String playerWithoutMail : loggedPlayersWithEmptyMail) {
|
||||
Player player = bukkitService.getPlayerExact(playerWithoutMail);
|
||||
if (player != null) {
|
||||
messages.send(player, MessageKey.ADD_EMAIL_MESSAGE);
|
||||
bukkitService.runTaskTimerAsynchronously(new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<String> loggedPlayersWithEmptyMail = dataSource.getLoggedPlayersWithEmptyMail();
|
||||
bukkitService.runTask(() -> {
|
||||
for (String playerWithoutMail : loggedPlayersWithEmptyMail) {
|
||||
Player player = bukkitService.getPlayerExact(playerWithoutMail);
|
||||
if (player != null) {
|
||||
messages.send(player, MessageKey.ADD_EMAIL_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}, 1, TICKS_PER_MINUTE * settings.getProperty(EmailSettings.DELAY_RECALL));
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
@ -152,9 +153,10 @@ public class BukkitService implements SettingsDependent {
|
||||
* @param period the ticks to wait between runs
|
||||
* @return a BukkitTask that contains the id number
|
||||
* @throws IllegalArgumentException if task is null
|
||||
* @throws IllegalStateException if this was already scheduled
|
||||
*/
|
||||
public BukkitTask runTaskTimerAsynchronously(Runnable task, long delay, long period) {
|
||||
return Bukkit.getScheduler().runTaskTimerAsynchronously(authMe, task, delay, period);
|
||||
public BukkitTask runTaskTimerAsynchronously(BukkitRunnable task, long delay, long period) {
|
||||
return task.runTaskTimerAsynchronously(authMe, delay, period);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -167,7 +169,6 @@ public class BukkitService implements SettingsDependent {
|
||||
* @return a BukkitTask that contains the id number
|
||||
* @throws IllegalArgumentException if plugin is null
|
||||
* @throws IllegalStateException if this was already scheduled
|
||||
* @see BukkitScheduler#runTaskTimer(org.bukkit.plugin.Plugin, Runnable, long, long)
|
||||
*/
|
||||
public BukkitTask runTaskTimer(BukkitRunnable task, long delay, long period) {
|
||||
return task.runTaskTimer(authMe, delay, period);
|
||||
|
@ -226,18 +226,21 @@ public class BukkitServiceTest {
|
||||
@Test
|
||||
public void shouldRunTaskTimerAsynchronously() {
|
||||
// given
|
||||
Runnable task = () -> {/* */};
|
||||
BukkitRunnable task = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
}
|
||||
};
|
||||
long delay = 20L;
|
||||
long period = 4000L;
|
||||
BukkitTask bukkitTask = mock(BukkitTask.class);
|
||||
given(scheduler.runTaskTimerAsynchronously(authMe, task, delay, period)).willReturn(bukkitTask);
|
||||
given(task.runTaskTimerAsynchronously(authMe, delay, period)).willReturn(bukkitTask);
|
||||
|
||||
// when
|
||||
BukkitTask resultingTask = bukkitService.runTaskTimerAsynchronously(task, delay, period);
|
||||
|
||||
// then
|
||||
assertThat(resultingTask, equalTo(bukkitTask));
|
||||
verify(scheduler).runTaskTimerAsynchronously(authMe, task, delay, period);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user