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
4 changes: 2 additions & 2 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.14.0'
version = '8.14.1'
description = 'CommandTimer'

repositories {
Expand Down Expand Up @@ -74,7 +74,7 @@ publishing {
maven(MavenPublication) {
groupId = 'me.playbosswar.com'
artifactId = 'commandtimer'
version = '8.14.0'
version = '8.14.1'

from components.java
}
Expand Down
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.14.0'
version = '8.14.1'
description = 'CommandTimer'

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

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.14.0'
version = '8.14.1'
description = 'CommandTimer'

repositories {
Expand Down Expand Up @@ -67,7 +67,7 @@ publishing {
maven(MavenPublication) {
groupId = 'me.playbosswar.com'
artifactId = 'commandtimer-java21'
version = '8.14.0'
version = '8.14.1'
from components.java
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/me/playbosswar/com/CommandTimerPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,15 @@ public void onEnable() {
plugin = this;
instance = this;

this.loadConfig();
languageManager = new LanguageManager(this, getConfig().getString("language"));

if(FoliaSchedulerAdapter.isSupported()) {
schedulerAdapter = new FoliaSchedulerAdapter(this);
Messages.sendConsole("&eUsing Folia scheduler adapter");
} else {
schedulerAdapter = new BukkitSchedulerAdapter(this);
schedulerAdapter = new BukkitSchedulerAdapter(this);
Messages.sendConsole("&eUsing Bukkit scheduler adapter");
}

Sentry.init(options -> {
Expand All @@ -76,8 +81,6 @@ public void onEnable() {

ITransaction transaction = Sentry.startTransaction("server_startup", "initiation");

this.loadConfig();
languageManager = new LanguageManager(this, getConfig().getString("language"));
this.registerCommands();

Bukkit.getPluginManager().registerEvents(new JoinEvents(), this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ public BukkitTask runTask(Runnable runnable) {
public BukkitTask runTaskLater(Runnable runnable, long delay) {
return Bukkit.getScheduler().runTaskLater(plugin, runnable, delay);
}

@Override
public BukkitTask runTaskAsynchronously(Runnable runnable) {
return Bukkit.getScheduler().runTaskAsynchronously(plugin, runnable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ public BukkitTask runTaskLater(Runnable runnable, long delay) {
return new ScheduledTask(null);
}

@Override
public BukkitTask runTaskAsynchronously(Runnable runnable) {
return runTask(runnable);
}

private class ScheduledTask implements BukkitTask {
private final Object task;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ public interface SchedulerAdapter {
BukkitTask runTask(Runnable runnable);

BukkitTask runTaskLater(Runnable runnable, long delay);

BukkitTask runTaskAsynchronously(Runnable runnable);
}
16 changes: 7 additions & 9 deletions src/main/java/me/playbosswar/com/tasks/TasksManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@


public class TasksManager {
private final Plugin plugin;
private static final String CONDITION_NO_MATCH = "Conditions did not match";
private static final Random RANDOM = new Random();
private static final String ALPHA_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
Expand All @@ -45,7 +44,6 @@ public class TasksManager {
public int executionsSinceLastSync = 0;

public TasksManager(Plugin plugin) {
this.plugin = plugin;
if (plugin.getConfig().getBoolean("database.enabled")) {
try {
Messages.sendConsole("Loading all tasks from database");
Expand Down Expand Up @@ -160,7 +158,7 @@ private boolean runConsolePerUserCommand(Task task, TaskCommand taskCommand, Lis
executionsSinceLastSync++;
}, (20L * i * taskCommand.getInterval().toSeconds()) + 1);
} else {
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), PAPIHook.parsePAPI(command, p)));
CommandTimerPlugin.getScheduler().runTask(() -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), PAPIHook.parsePAPI(command, p)));
executionsSinceLastSync++;
}
i++;
Expand All @@ -185,11 +183,11 @@ private boolean runConsolePerUserOfflineCommand(Task task, TaskCommand taskComma
}
if (delayedExecutions) {
CommandTimerPlugin.getScheduler().runTaskLater(() -> {
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), PAPIHook.parsePAPI(command, p)));
CommandTimerPlugin.getScheduler().runTask(() -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), PAPIHook.parsePAPI(command, p)));
executionsSinceLastSync++;
}, (20L * i * taskCommand.getInterval().toSeconds()) + 1);
} else {
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), PAPIHook.parsePAPI(command, p)));
CommandTimerPlugin.getScheduler().runTask(() -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), PAPIHook.parsePAPI(command, p)));
executionsSinceLastSync++;
}
i++;
Expand All @@ -212,7 +210,7 @@ private boolean runConsoleCommand(Task task, TaskCommand taskCommand) throws Com
}

String command = taskCommand.getCommand();
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), PAPIHook.parsePAPI(command, null)));
CommandTimerPlugin.getScheduler().runTask(() -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), PAPIHook.parsePAPI(command, null)));
executionsSinceLastSync++;
return true;
}
Expand Down Expand Up @@ -253,7 +251,7 @@ private boolean runPlayerCommand(Task task, TaskCommand taskCommand, List<UUID>

private void runForPlayer(Player p, String command) {
String parsedCommand = PAPIHook.parsePAPI(command, p);
Bukkit.getScheduler().runTask(plugin, () -> {
CommandTimerPlugin.getScheduler().runTask(() -> {
boolean executed = p.performCommand(parsedCommand);

if (!executed) {
Expand Down Expand Up @@ -305,7 +303,7 @@ private boolean runOperatorCommand(Task task, TaskCommand taskCommand, List<UUID
executionsSinceLastSync++;
}, (20L * i * taskCommand.getInterval().toSeconds()) + 1);
} else {
Bukkit.getScheduler().runTask(plugin, () -> p.performCommand(PAPIHook.parsePAPI(command, p)));
CommandTimerPlugin.getScheduler().runTask(() -> p.performCommand(PAPIHook.parsePAPI(command, p)));
executionsSinceLastSync++;
}

Expand Down Expand Up @@ -353,7 +351,7 @@ public void processCommandExecution(Task task, TaskCommand taskCommand) {
return;
}

Bukkit.getScheduler().runTaskAsynchronously(CommandTimerPlugin.getPlugin(), () -> {
CommandTimerPlugin.getScheduler().runTaskAsynchronously(() -> {
Gender gender = taskCommand.getGender();

boolean executed = false;
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/me/playbosswar/com/updater/Updater.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

import me.playbosswar.com.CommandTimerPlugin;

import org.bukkit.plugin.Plugin;

import java.io.*;
Expand Down Expand Up @@ -161,7 +164,7 @@ private boolean shouldUpdate(String newVersion, String oldVersion) {
*/
private void waitThread() {
if (thread != null && thread.isAlive()) {
this.plugin.getServer().getScheduler().runTaskAsynchronously(this.plugin, () -> {
CommandTimerPlugin.getScheduler().runTaskAsynchronously(() -> {
try {
this.plugin.getLogger().log(Level.INFO, "Waiting for updater thread to finish.");
thread.join();
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
main: me.playbosswar.com.CommandTimerPlugin
name: "CommandTimer"
version: "8.14.0"
version: "8.14.1"
description: "Schedule commands like you want"
author: PlayBossWar
api-version: 1.13
Expand Down
Loading