mirror of
https://github.com/Crazy-Crew/CrazyAuctions.git
synced 2025-01-07 19:28:10 +01:00
add folia support
This commit is contained in:
parent
190932aef5
commit
8b3caa4c3b
@ -10,6 +10,7 @@ import com.badbones69.crazyauctions.controllers.GuiListener;
|
||||
import com.badbones69.crazyauctions.controllers.MarcoListener;
|
||||
import com.badbones69.crazyauctions.currency.VaultSupport;
|
||||
import com.ryderbelserion.vital.paper.files.config.FileManager;
|
||||
import com.ryderbelserion.vital.paper.util.scheduler.FoliaRunnable;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
@ -19,8 +20,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Base64;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class CrazyAuctions extends JavaPlugin {
|
||||
|
||||
@ -29,15 +28,11 @@ public class CrazyAuctions extends JavaPlugin {
|
||||
return JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
}
|
||||
|
||||
private Timer timer;
|
||||
|
||||
private FileManager fileManager;
|
||||
private CrazyManager crazyManager;
|
||||
|
||||
private VaultSupport support;
|
||||
|
||||
private MetricsWrapper metrics;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (!getServer().getPluginManager().isPluginEnabled("Vault")) {
|
||||
@ -48,8 +43,6 @@ public class CrazyAuctions extends JavaPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
this.timer = new Timer();
|
||||
|
||||
this.fileManager = new FileManager();
|
||||
this.crazyManager = new CrazyManager();
|
||||
|
||||
@ -126,25 +119,19 @@ public class CrazyAuctions extends JavaPlugin {
|
||||
|
||||
registerCommand(getCommand("crazyauctions"), new AuctionTab(), new AuctionCommand());
|
||||
|
||||
// Run a task every 5 seconds to update auctions.
|
||||
TimerTask task = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
getServer().getScheduler().runTask(get(), Methods::updateAuction);
|
||||
}
|
||||
};
|
||||
|
||||
this.timer.scheduleAtFixedRate(task, 20L, 5000L);
|
||||
|
||||
// Add new messages.
|
||||
Messages.addMissingMessages();
|
||||
|
||||
// Enable vault support if enabled.
|
||||
this.support = new VaultSupport();
|
||||
this.support.loadVault();
|
||||
|
||||
// Create bstats instance.
|
||||
this.metrics = new MetricsWrapper(this, 4624);
|
||||
new FoliaRunnable(getServer().getGlobalRegionScheduler()) {
|
||||
@Override
|
||||
public void run() {
|
||||
Methods.updateAuction();
|
||||
}
|
||||
}.runAtFixedRate(this, 0L, 5000L);
|
||||
|
||||
Messages.addMissingMessages();
|
||||
|
||||
new MetricsWrapper(this, 4624);
|
||||
}
|
||||
|
||||
private void registerCommand(PluginCommand pluginCommand, TabCompleter tabCompleter, CommandExecutor commandExecutor) {
|
||||
@ -157,8 +144,6 @@ public class CrazyAuctions extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (this.timer != null) this.timer.cancel();
|
||||
|
||||
if (this.crazyManager != null) this.crazyManager.unload();
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ import com.badbones69.crazyauctions.api.enums.ShopType;
|
||||
import com.badbones69.crazyauctions.api.events.AuctionBuyEvent;
|
||||
import com.badbones69.crazyauctions.api.events.AuctionCancelledEvent;
|
||||
import com.badbones69.crazyauctions.api.events.AuctionNewBidEvent;
|
||||
import com.ryderbelserion.vital.paper.util.scheduler.FoliaRunnable;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Sound;
|
||||
@ -1038,8 +1039,6 @@ public class GuiListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
final Runnable runnable = () -> inv.setItem(slot, item);
|
||||
|
||||
if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getUniqueId().toString())) {
|
||||
String itemName = config.getString("Settings.GUISettings.OtherSettings.Your-Item.Item");
|
||||
String name = config.getString("Settings.GUISettings.OtherSettings.Your-Item.Name");
|
||||
@ -1054,7 +1053,12 @@ public class GuiListener implements Listener {
|
||||
|
||||
playClick(player);
|
||||
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, runnable, 3 * 20);
|
||||
new FoliaRunnable(plugin.getServer().getGlobalRegionScheduler()) {
|
||||
@Override
|
||||
public void run() {
|
||||
inv.setItem(slot, item);
|
||||
}
|
||||
}.runDelayed(plugin, 3 * 20);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1074,7 +1078,12 @@ public class GuiListener implements Listener {
|
||||
inv.setItem(slot, itemBuilder.build());
|
||||
playClick(player);
|
||||
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, runnable, 3 * 20);
|
||||
new FoliaRunnable(plugin.getServer().getGlobalRegionScheduler()) {
|
||||
@Override
|
||||
public void run() {
|
||||
inv.setItem(slot, item);
|
||||
}
|
||||
}.runDelayed(plugin, 3 * 20);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1094,7 +1103,13 @@ public class GuiListener implements Listener {
|
||||
|
||||
playClick(player);
|
||||
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, runnable, 3 * 20);
|
||||
new FoliaRunnable(plugin.getServer().getGlobalRegionScheduler()) {
|
||||
@Override
|
||||
public void run() {
|
||||
inv.setItem(slot, item);
|
||||
}
|
||||
}.runDelayed(plugin, 3 * 20);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,8 @@ website: '${website}'
|
||||
|
||||
softdepend: [Vault]
|
||||
|
||||
folia-supported: true
|
||||
|
||||
commands:
|
||||
crazyauctions:
|
||||
description: Opens the Crazy Auctions GUI.
|
||||
|
Loading…
Reference in New Issue
Block a user