Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ java {
}

group = 'me.playbosswar.com'
version = '8.11.6'
version = '8.12.0'
description = 'CommandTimer'

repositories {
Expand All @@ -30,11 +30,14 @@ repositories {
maven {
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}

maven { url 'https://jitpack.io' }
}

shadowJar {
dependencies {
include(dependency('fr.minuskube.inv:smart-invs:1.2.7'))
// include(dependency('fr.minuskube.inv:smart-invs:1.2.7'))
include(dependency('com.github.titivermeesch:SmartInvs:feat~folia-support-SNAPSHOT'))
include(dependency('com.github.cryptomorin:XSeries:8.6.2'))
include(dependency('joda-time:joda-time:2.10.13'))
include(dependency('org.jeasy:easy-rules-core:4.1.0'))
Expand All @@ -53,7 +56,8 @@ compileJava {

dependencies {
implementation 'com.github.cryptomorin:XSeries:8.6.2'
implementation 'fr.minuskube.inv:smart-invs:1.2.7'
// implementation 'fr.minuskube.inv:smart-invs:1.2.7'
implementation 'com.github.titivermeesch:SmartInvs:feat~folia-support-SNAPSHOT'
implementation 'joda-time:joda-time:2.10.13'
implementation 'org.jeasy:easy-rules-core:4.1.0'
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
Expand All @@ -70,7 +74,7 @@ publishing {
maven(MavenPublication) {
groupId = 'me.playbosswar.com'
artifactId = 'commandtimer'
version = '8.11.6'
version = '8.12.0'

from components.java
}
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 5 additions & 2 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions java17-build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ java {


group = 'me.playbosswar.com'
version = '8.11.6'
version = '8.12.0'
description = 'CommandTimer'

repositories {
Expand Down Expand Up @@ -63,7 +63,7 @@ publishing {
maven(MavenPublication) {
groupId = 'me.playbosswar.com'
artifactId = 'commandtimer-java17'
version = '8.11.6'
version = '8.12.0'

from components.java
}
Expand Down
4 changes: 2 additions & 2 deletions java21-build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ java {


group = 'me.playbosswar.com'
version = '8.11.6'
version = '8.12.0'
description = 'CommandTimer'

repositories {
Expand Down Expand Up @@ -68,7 +68,7 @@ publishing {
maven(MavenPublication) {
groupId = 'me.playbosswar.com'
artifactId = 'commandtimer-java21'
version = '8.11.6'
version = '8.12.0'
from components.java
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/me/playbosswar/com/CommandTimerPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import me.playbosswar.com.hooks.HooksManager;
import me.playbosswar.com.hooks.Metrics;
import me.playbosswar.com.language.LanguageManager;
import me.playbosswar.com.scheduler.BukkitSchedulerAdapter;
import me.playbosswar.com.scheduler.FoliaSchedulerAdapter;
import me.playbosswar.com.scheduler.SchedulerAdapter;
import me.playbosswar.com.tasks.Task;
import me.playbosswar.com.tasks.TasksManager;
import me.playbosswar.com.tasks.persistors.*;
Expand Down Expand Up @@ -48,12 +51,19 @@ public class CommandTimerPlugin extends JavaPlugin implements Listener {
public static Updater updater;
public static LanguageManager languageManager;
public static Dao<Task, Integer> taskDao;
public static SchedulerAdapter schedulerAdapter;

@Override
public void onEnable() {
plugin = this;
instance = this;

if(FoliaSchedulerAdapter.isSupported()) {
schedulerAdapter = new FoliaSchedulerAdapter(this);
} else {
schedulerAdapter = new BukkitSchedulerAdapter(this);
}

Sentry.init(options -> {
options.setDsn("https://45383fac83f64e65a45d83c3059eb934@o1414814.ingest.sentry.io/6755132");
options.setTracesSampleRate(0.3);
Expand Down Expand Up @@ -210,4 +220,8 @@ public static LanguageManager getLanguageManager() {
public static Dao<Task, Integer> getTaskDao() {
return taskDao;
}

public static SchedulerAdapter getScheduler() {
return schedulerAdapter;
}
}
14 changes: 6 additions & 8 deletions src/main/java/me/playbosswar/com/commands/MainCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import me.playbosswar.com.utils.Files;
import me.playbosswar.com.utils.Messages;
import me.playbosswar.com.utils.Tools;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
Expand Down Expand Up @@ -150,10 +149,9 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N
}

if(task.getCommandExecutionMode().equals(CommandExecutionMode.INTERVAL)) {
Bukkit.getScheduler().runTaskTimer(
CommandTimerPlugin.getPlugin(),
CommandTimerPlugin.getScheduler().runTaskTimer(
new CommandIntervalExecutorRunnable(task),
0,
1,
task.getCommandExecutionInterval().toSeconds() * 20L);

Messages.sendMessage(sender, languageManager.get(LanguageKey.TASK_EXECUTION_ONGOING));
Expand All @@ -163,9 +161,9 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N
if(task.getCommandExecutionMode().equals(CommandExecutionMode.ORDERED)) {
final int[] accumulatedDelaySeconds = {0};
task.getCommands().forEach(command -> {
Bukkit.getScheduler().scheduleSyncDelayedTask(CommandTimerPlugin.getPlugin(),
CommandTimerPlugin.getScheduler().runTaskLater(
() -> tasksManager.processCommandExecution(task, command),
20L * accumulatedDelaySeconds[0]);
(20L * accumulatedDelaySeconds[0]) + 1);
accumulatedDelaySeconds[0] += command.getDelay().toSeconds();
});
Messages.sendMessage(sender, languageManager.get(LanguageKey.TASK_EXECUTION_ONGOING));
Expand All @@ -174,10 +172,10 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N

int selectedCommandIndex = tasksManager.getNextTaskCommandIndex(task);
if(selectedCommandIndex == -1) {
Bukkit.getScheduler().runTask(CommandTimerPlugin.getPlugin(), () ->
CommandTimerPlugin.getScheduler().runTask(() ->
task.getCommands().forEach(command -> tasksManager.processCommandExecution(task, command)));
} else {
Bukkit.getScheduler().runTask(CommandTimerPlugin.getPlugin(), () ->
CommandTimerPlugin.getScheduler().runTask(() ->
tasksManager.processCommandExecution(task, task.getCommands().get(selectedCommandIndex)));
}

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/me/playbosswar/com/hooks/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;

import me.playbosswar.com.CommandTimerPlugin;

import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -179,7 +182,7 @@ public void run() {
}
// Nevertheless we want our code to run in the Bukkit main thread, so we have to use the Bukkit scheduler
// Don't be afraid! The connection to the bStats server is still async, only the stats collection is sync ;)
Bukkit.getScheduler().runTask(plugin, () -> submitData());
CommandTimerPlugin.getScheduler().runTask(() -> submitData());
}
}, 1000 * 60 * 5, 1000 * 60 * 30);
// Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package me.playbosswar.com.scheduler;

import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitTask;

public class BukkitSchedulerAdapter implements SchedulerAdapter {
private Plugin plugin;

public BukkitSchedulerAdapter(Plugin plugin) {
this.plugin = plugin;
}

@Override
public BukkitTask runTaskTimer(Runnable runnable, long delay, long period) {
return Bukkit.getScheduler().runTaskTimer(plugin, runnable, delay, period);
}

@Override
public BukkitTask runTask(Runnable runnable) {
return Bukkit.getScheduler().runTask(plugin, runnable);
}

@Override
public BukkitTask runTaskLater(Runnable runnable, long delay) {
return Bukkit.getScheduler().runTaskLater(plugin, runnable, delay);
}
}
Loading