Skip to content
Open
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
13 changes: 6 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@
<systemPath>${project.basedir}/lib/spigot-1.19.3.jar</systemPath>
<optional>true</optional>
</dependency>-->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.20.5-R0.1-SNAPSHOT</version>
<optional>true</optional>
<scope>provided</scope>
</dependency>
<!-- bStats API -->
<dependency>
<groupId>org.bstats</groupId>
Expand All @@ -85,6 +78,12 @@
<version>1.0.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>dev.folia</groupId>
<artifactId>folia-api</artifactId>
<version>1.21.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.nuclyon.technicallycoded.inventoryrollback.UpdateChecker.UpdateResult;
import com.nuclyon.technicallycoded.inventoryrollback.commands.Commands;
import com.nuclyon.technicallycoded.inventoryrollback.folia.SchedulerUtils;
import com.nuclyon.technicallycoded.inventoryrollback.util.TimeZoneUtil;
import com.nuclyon.technicallycoded.inventoryrollback.util.test.SelfTestSerialization;
import com.tcoded.lightlibs.bukkitversion.BukkitVersion;
Expand Down Expand Up @@ -30,6 +31,7 @@
public class InventoryRollbackPlus extends InventoryRollback {

private static InventoryRollbackPlus instancePlus;
public static boolean usingFolia = false;

private TimeZoneUtil timeZoneUtil = null;

Expand All @@ -42,6 +44,16 @@ public static InventoryRollbackPlus getInstance() {
return instancePlus;
}

@Override
public void onLoad() {
try {
Class.forName("io.papermc.paper.threadedregions.scheduler.RegionScheduler");
usingFolia = true;
} catch (ClassNotFoundException e) {
usingFolia = false;
}
}

@Override
public void onEnable() {
instancePlus = this;
Expand Down Expand Up @@ -89,7 +101,7 @@ public void onEnable() {
getServer().getPluginManager().registerEvents(new ClickGUI(), this);
getServer().getPluginManager().registerEvents(new EventLogs(), this);
// Run after all plugin enable
getServer().getScheduler().runTask(this, EventLogs::patchLowestHandlers);
SchedulerUtils.runTask(null, EventLogs::patchLowestHandlers);

// PaperLib
if (!PaperLib.isPaper()) {
Expand Down Expand Up @@ -124,7 +136,7 @@ public void onDisable() {
HandlerList.unregisterAll(this);

// Cancel tasks
this.getServer().getScheduler().cancelTasks(this);
if(!usingFolia) this.getServer().getScheduler().cancelTasks(this);

// Clear instance references
instancePlus = null;
Expand All @@ -149,7 +161,7 @@ public boolean isCompatibleCb(String cbVersion) {
}

public void checkUpdate() {
Bukkit.getScheduler().runTaskAsynchronously(InventoryRollback.getInstance(), () -> {
SchedulerUtils.runTaskAsynchronously(() -> {
InventoryRollbackPlus.getInstance().getConsoleSender().sendMessage(MessageData.getPluginPrefix() + "Checking for updates...");

final UpdateResult result = new UpdateChecker(getInstance(), 85811).getResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import com.nuclyon.technicallycoded.inventoryrollback.commands.inventoryrollback.*;
import me.danjono.inventoryrollback.config.MessageData;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
Expand All @@ -20,7 +20,7 @@ public class Commands implements CommandExecutor, TabCompleter {
private String[] backupOptions = new String[] {"all", "player"};
private String[] importOptions = new String[] {"confirm"};

private HashMap<String, IRPCommand> subCommands = new HashMap<>();
private ConcurrentHashMap<String, IRPCommand> subCommands = new ConcurrentHashMap<>();

public Commands(InventoryRollbackPlus mainIn) {
this.main = mainIn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.nuclyon.technicallycoded.inventoryrollback.InventoryRollbackPlus;
import com.nuclyon.technicallycoded.inventoryrollback.commands.IRPCommand;
import com.nuclyon.technicallycoded.inventoryrollback.folia.SchedulerUtils;
import com.nuclyon.technicallycoded.inventoryrollback.util.LegacyBackupConversionUtil;
import me.danjono.inventoryrollback.config.MessageData;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -32,15 +33,15 @@ public void onCommand(CommandSender sender, Command cmd, String label, String[]
suggestConfirm.set(true);

// Reset suggestion availability after 10 seconds
this.main.getServer().getScheduler().runTaskLaterAsynchronously(this.main, () -> {
SchedulerUtils.runTaskLaterAsynchronously(null, () -> {
suggestConfirm.set(false);
}, 10 * 20);

return;
}

// Execute import
Bukkit.getScheduler().runTaskAsynchronously(main, LegacyBackupConversionUtil::convertOldBackupData);
SchedulerUtils.runTaskAsynchronously(LegacyBackupConversionUtil::convertOldBackupData);

// Reset suggestion to not visible
suggestConfirm.set(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.nuclyon.technicallycoded.inventoryrollback.InventoryRollbackPlus;
import com.nuclyon.technicallycoded.inventoryrollback.commands.IRPCommand;
import com.nuclyon.technicallycoded.inventoryrollback.folia.SchedulerUtils;
import me.danjono.inventoryrollback.InventoryRollback;
import me.danjono.inventoryrollback.config.ConfigData;
import me.danjono.inventoryrollback.config.MessageData;
Expand Down Expand Up @@ -90,14 +91,14 @@ private void openMainMenu(Player staff) {
MainMenu menu = new MainMenu(staff, 1);

staff.openInventory(menu.getInventory());
Bukkit.getScheduler().runTaskAsynchronously(InventoryRollback.getInstance(), menu::getMainMenu);
SchedulerUtils.runTaskAsynchronously(menu::getMainMenu);
}

private void openPlayerMenu(Player staff, OfflinePlayer offlinePlayer) {
PlayerMenu menu = new PlayerMenu(staff, offlinePlayer);

staff.openInventory(menu.getInventory());
Bukkit.getScheduler().runTaskAsynchronously(InventoryRollback.getInstance(), menu::getPlayerMenu);
SchedulerUtils.runTaskAsynchronously(menu::getPlayerMenu);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.nuclyon.technicallycoded.inventoryrollback.folia;

import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
import org.bukkit.scheduler.BukkitRunnable;

public class FoliaRunnable extends BukkitRunnable {

private ScheduledTask foliaTask;

@Override
public synchronized void cancel() throws IllegalStateException {
if(foliaTask != null) foliaTask.cancel();
}

@Override
public void run() {
}

public void setScheduledTask(ScheduledTask task) {
this.foliaTask = task;
}
}
Loading