Merge 81abca0b60
into 3522d5099b
This commit is contained in:
commit
aa4306bbb8
|
@ -40,8 +40,8 @@
|
|||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigotmc-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
<id>papermc</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>codemc-repo</id>
|
||||
|
@ -50,8 +50,8 @@
|
|||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<groupId>dev.folia</groupId>
|
||||
<artifactId>folia-api</artifactId>
|
||||
<version>1.19.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
|
@ -63,10 +63,6 @@
|
|||
<artifactId>gson</artifactId>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>joml</artifactId>
|
||||
<groupId>org.joml</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>bungeecord-chat</artifactId>
|
||||
<groupId>net.md-5</groupId>
|
||||
|
@ -75,17 +71,65 @@
|
|||
<artifactId>snakeyaml</artifactId>
|
||||
<groupId>org.yaml</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.30</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>joml</artifactId>
|
||||
<groupId>org.joml</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>fastutil</artifactId>
|
||||
<groupId>it.unimi.dsi</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>maven-resolver-provider</artifactId>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>adventure-api</artifactId>
|
||||
<groupId>net.kyori</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>adventure-text-minimessage</artifactId>
|
||||
<groupId>net.kyori</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>adventure-text-serializer-gson</artifactId>
|
||||
<groupId>net.kyori</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>adventure-text-serializer-legacy</artifactId>
|
||||
<groupId>net.kyori</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>adventure-text-serializer-plain</artifactId>
|
||||
<groupId>net.kyori</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>adventure-text-logger-slf4j</artifactId>
|
||||
<groupId>net.kyori</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>checker-qual</artifactId>
|
||||
<groupId>org.checkerframework</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>asm</artifactId>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>asm-commons</artifactId>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
|
16
pom.xml
16
pom.xml
|
@ -48,8 +48,8 @@
|
|||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigotmc-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
<id>papermc</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>codemc-repo</id>
|
||||
|
@ -60,15 +60,15 @@
|
|||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<groupId>dev.folia</groupId>
|
||||
<artifactId>folia-api</artifactId>
|
||||
<version>1.19.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.tr7zw</groupId>
|
||||
<artifactId>item-nbt-api</artifactId>
|
||||
<version>2.11.2</version>
|
||||
<version>2.11.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.tr7zw</groupId>
|
||||
|
@ -76,12 +76,6 @@
|
|||
<version>0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.30</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
|
|
|
@ -6,13 +6,15 @@ import com.pretzel.dev.villagertradelimiter.data.PlayerData;
|
|||
import com.pretzel.dev.villagertradelimiter.database.DatabaseManager;
|
||||
import com.pretzel.dev.villagertradelimiter.listeners.InventoryListener;
|
||||
import com.pretzel.dev.villagertradelimiter.listeners.VillagerListener;
|
||||
import com.pretzel.dev.villagertradelimiter.scheduler.BukkitSchedulerAdapter;
|
||||
import com.pretzel.dev.villagertradelimiter.scheduler.FoliaSchedulerAdapter;
|
||||
import com.pretzel.dev.villagertradelimiter.scheduler.SchedulerAdapter;
|
||||
import com.pretzel.dev.villagertradelimiter.settings.ConfigUpdater;
|
||||
import com.pretzel.dev.villagertradelimiter.lib.Metrics;
|
||||
import com.pretzel.dev.villagertradelimiter.lib.Util;
|
||||
import com.pretzel.dev.villagertradelimiter.listeners.PlayerListener;
|
||||
import com.pretzel.dev.villagertradelimiter.settings.Lang;
|
||||
import com.pretzel.dev.villagertradelimiter.settings.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
@ -28,6 +30,9 @@ public class VillagerTradeLimiter extends JavaPlugin {
|
|||
public static final String PREFIX = ChatColor.GOLD+"["+PLUGIN_NAME+"] ";
|
||||
private static final int BSTATS_ID = 9829;
|
||||
|
||||
private final SchedulerAdapter scheduler = FoliaSchedulerAdapter.isSupported()
|
||||
? new FoliaSchedulerAdapter(this) : new BukkitSchedulerAdapter(this);
|
||||
|
||||
//Settings
|
||||
private FileConfiguration cfg;
|
||||
private Lang lang;
|
||||
|
@ -123,4 +128,8 @@ public class VillagerTradeLimiter extends JavaPlugin {
|
|||
|
||||
/** @return the invsee inventory's barrier block */
|
||||
public ItemStack getBarrier() { return this.commandManager.getBarrier(); }
|
||||
|
||||
public SchedulerAdapter getScheduler() {
|
||||
return this.scheduler;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,18 +3,20 @@ package com.pretzel.dev.villagertradelimiter.data;
|
|||
import com.pretzel.dev.villagertradelimiter.wrappers.VillagerWrapper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class PlayerData {
|
||||
private final HashMap<String, String> tradingCooldowns;
|
||||
private final Map<String, String> tradingCooldowns;
|
||||
private VillagerWrapper tradingVillager;
|
||||
|
||||
public PlayerData() {
|
||||
this.tradingCooldowns = new HashMap<>();
|
||||
this.tradingCooldowns = new ConcurrentHashMap<>();
|
||||
this.tradingVillager = null;
|
||||
}
|
||||
|
||||
/** @return The map of items to timestamps for the player's trading history */
|
||||
public HashMap<String, String> getTradingCooldowns() { return this.tradingCooldowns; }
|
||||
public Map<String, String> getTradingCooldowns() { return this.tradingCooldowns; }
|
||||
|
||||
/** @param tradingVillager The villager that this player is currently trading with */
|
||||
public void setTradingVillager(final VillagerWrapper tradingVillager) { this.tradingVillager = tradingVillager; }
|
||||
|
|
|
@ -1,29 +1,26 @@
|
|||
package com.pretzel.dev.villagertradelimiter.database;
|
||||
|
||||
import com.pretzel.dev.villagertradelimiter.VillagerTradeLimiter;
|
||||
import com.pretzel.dev.villagertradelimiter.lib.Callback;
|
||||
import com.pretzel.dev.villagertradelimiter.lib.Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public abstract class Database {
|
||||
protected final JavaPlugin instance;
|
||||
protected final VillagerTradeLimiter instance;
|
||||
|
||||
public Database(final JavaPlugin instance) {
|
||||
public Database(final VillagerTradeLimiter instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
//Tests a DataSource
|
||||
public void test() {
|
||||
try {
|
||||
try (Connection conn = this.getSource().getConnection()) {
|
||||
try (Connection conn = this.getConnection()) {
|
||||
if (!conn.isValid(1000)) throw new SQLException("Could not connect to database!");
|
||||
else Util.consoleMsg("Connected to database!");
|
||||
}
|
||||
|
@ -34,7 +31,7 @@ public abstract class Database {
|
|||
|
||||
//Executes a statement or query in the database
|
||||
public ArrayList<String> execute(final String sql, boolean query) {
|
||||
try(Connection conn = this.getSource().getConnection(); PreparedStatement statement = conn.prepareStatement(sql)) {
|
||||
try(Connection conn = this.getConnection(); PreparedStatement statement = conn.prepareStatement(sql)) {
|
||||
if(query) {
|
||||
final ResultSet result = statement.executeQuery();
|
||||
int columns = result.getMetaData().getColumnCount();
|
||||
|
@ -53,13 +50,13 @@ public abstract class Database {
|
|||
return null;
|
||||
}
|
||||
public void execute(final String sql, boolean query, final Callback<ArrayList<String>> callback) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.instance, () -> {
|
||||
instance.getScheduler().runAsync(() -> {
|
||||
final ArrayList<String> result = execute(sql, query);
|
||||
if(callback != null) Bukkit.getScheduler().runTask(this.instance, () -> callback.call(result));
|
||||
if(callback != null) instance.getScheduler().runAsync(() -> callback.call(result));
|
||||
});
|
||||
}
|
||||
|
||||
public abstract void load(final ConfigurationSection cfg);
|
||||
public abstract boolean isMySQL();
|
||||
protected abstract DataSource getSource();
|
||||
protected abstract Connection getConnection() throws SQLException;
|
||||
}
|
|
@ -1,35 +1,45 @@
|
|||
package com.pretzel.dev.villagertradelimiter.database;
|
||||
|
||||
import com.mysql.cj.jdbc.MysqlConnectionPoolDataSource;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import com.pretzel.dev.villagertradelimiter.VillagerTradeLimiter;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class MySQL extends Database {
|
||||
private final MysqlConnectionPoolDataSource source;
|
||||
private String hostname;
|
||||
private int port;
|
||||
private String database;
|
||||
private String username;
|
||||
private String password;
|
||||
private String encoding;
|
||||
private boolean useSsl;
|
||||
|
||||
public MySQL(final JavaPlugin instance, final ConfigurationSection cfg) {
|
||||
public MySQL(final VillagerTradeLimiter instance, final ConfigurationSection cfg) {
|
||||
super(instance);
|
||||
this.source = new MysqlConnectionPoolDataSource();
|
||||
this.load(cfg);
|
||||
}
|
||||
|
||||
public void load(final ConfigurationSection cfg) {
|
||||
this.source.setServerName(cfg.getString("host", "localhost"));
|
||||
this.source.setPort(cfg.getInt("port", 3306));
|
||||
this.source.setDatabaseName(cfg.getString("database", "sagas_holo"));
|
||||
this.source.setUser(cfg.getString("username", "root"));
|
||||
this.source.setPassword(cfg.getString("password", "root"));
|
||||
try {
|
||||
this.source.setCharacterEncoding(cfg.getString("encoding", "utf8"));
|
||||
this.source.setUseSSL(cfg.getBoolean("useSSL", false));
|
||||
} catch (SQLException ignored) {}
|
||||
|
||||
this.hostname = cfg.getString("host", "localhost");
|
||||
this.port = cfg.getInt("port", 3306);
|
||||
this.database = cfg.getString("database", "sagas_holo");
|
||||
this.username = cfg.getString("username", "root");
|
||||
this.password = cfg.getString("password", "root");
|
||||
this.encoding = cfg.getString("encoding", "utf8");
|
||||
this.useSsl = cfg.getBoolean("useSSL", false);
|
||||
this.test();
|
||||
}
|
||||
|
||||
public boolean isMySQL() { return true; }
|
||||
public DataSource getSource() { return this.source; }
|
||||
|
||||
@Override
|
||||
public Connection getConnection() throws SQLException {
|
||||
return DriverManager.getConnection(
|
||||
"jdbc:mysql://" + hostname + ":" + port + "/" + database
|
||||
+ "?autoReconnect=true&useSSL=" + useSsl + "&characterEncoding=" + encoding,
|
||||
username,
|
||||
password
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,31 @@
|
|||
package com.pretzel.dev.villagertradelimiter.database;
|
||||
|
||||
import com.pretzel.dev.villagertradelimiter.VillagerTradeLimiter;
|
||||
import java.nio.file.Path;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.sqlite.javax.SQLiteConnectionPoolDataSource;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
public class SQLite extends Database {
|
||||
private final SQLiteConnectionPoolDataSource source;
|
||||
|
||||
public SQLite(final JavaPlugin instance) {
|
||||
private Path path;
|
||||
|
||||
public SQLite(final VillagerTradeLimiter instance) {
|
||||
super(instance);
|
||||
this.source = new SQLiteConnectionPoolDataSource();
|
||||
this.load(null);
|
||||
}
|
||||
|
||||
public void load(final ConfigurationSection cfg) {
|
||||
this.source.setUrl("jdbc:sqlite:"+instance.getDataFolder().getPath()+"/database.db");
|
||||
path = instance.getDataFolder().toPath().resolve("database.db");
|
||||
this.test();
|
||||
}
|
||||
|
||||
public boolean isMySQL() { return false; }
|
||||
public DataSource getSource() { return this.source; }
|
||||
|
||||
@Override
|
||||
protected Connection getConnection() throws SQLException {
|
||||
return DriverManager.getConnection("jdbc:sqlite:" + path);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.pretzel.dev.villagertradelimiter.lib;
|
||||
|
||||
import com.pretzel.dev.villagertradelimiter.VillagerTradeLimiter;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
@ -30,12 +31,10 @@ import javax.net.ssl.HttpsURLConnection;
|
|||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Metrics {
|
||||
|
||||
private final Plugin plugin;
|
||||
private final VillagerTradeLimiter plugin;
|
||||
|
||||
private final MetricsBase metricsBase;
|
||||
|
||||
|
@ -46,7 +45,7 @@ public class Metrics {
|
|||
* @param serviceId The id of the service. It can be found at <a
|
||||
* href="https://bstats.org/what-is-my-plugin-id">What is my plugin id?</a>
|
||||
*/
|
||||
public Metrics(JavaPlugin plugin, int serviceId) {
|
||||
public Metrics(VillagerTradeLimiter plugin, int serviceId) {
|
||||
this.plugin = plugin;
|
||||
// Get the config file
|
||||
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
|
||||
|
@ -87,7 +86,7 @@ public class Metrics {
|
|||
enabled,
|
||||
this::appendPlatformData,
|
||||
this::appendServiceData,
|
||||
submitDataTask -> Bukkit.getScheduler().runTask(plugin, submitDataTask),
|
||||
submitDataTask -> plugin.getScheduler().runAsync(submitDataTask),
|
||||
plugin::isEnabled,
|
||||
(message, error) -> this.plugin.getLogger().log(Level.WARNING, message, error),
|
||||
(message) -> this.plugin.getLogger().log(Level.INFO, message),
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.pretzel.dev.villagertradelimiter.wrappers.VillagerWrapper;
|
|||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -48,7 +49,7 @@ public class InventoryListener implements Listener {
|
|||
//If the inventory matches the invsee inventory, cancel click events
|
||||
event.setCancelled(true);
|
||||
if(event.getCurrentItem() != null && event.getCurrentItem().isSimilar(instance.getBarrier())) {
|
||||
Bukkit.getScheduler().runTaskLater(instance, () -> event.getWhoClicked().closeInventory(), 0L);
|
||||
instance.getScheduler().runEntity(event.getWhoClicked(), HumanEntity::closeInventory);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,7 +116,7 @@ public class InventoryListener implements Listener {
|
|||
final PlayerData playerData = instance.getPlayerData().get(player.getUniqueId());
|
||||
final PlayerData villagerData = instance.getPlayerData().get(villager.getUniqueId());
|
||||
if(playerData == null || playerData.getTradingVillager() == null) return;
|
||||
Bukkit.getScheduler().runTaskLater(instance, () -> {
|
||||
instance.getScheduler().runAsync(() -> {
|
||||
int uses = selectedRecipe.getUses();
|
||||
final String time = Cooldown.formatTime(Date.from(Instant.now()));
|
||||
if(uses >= selectedRecipe.getMaxUses()) {
|
||||
|
@ -126,7 +127,7 @@ public class InventoryListener implements Listener {
|
|||
villagerData.getTradingCooldowns().put(type, time);
|
||||
}
|
||||
}
|
||||
}, 1);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package com.pretzel.dev.villagertradelimiter.scheduler;
|
||||
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BukkitSchedulerAdapter implements SchedulerAdapter {
|
||||
|
||||
private final Plugin plugin;
|
||||
private final BukkitScheduler scheduler;
|
||||
|
||||
public BukkitSchedulerAdapter(final Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.scheduler = plugin.getServer().getScheduler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runAsync(final Runnable submitDataTask) {
|
||||
scheduler.runTaskAsynchronously(plugin, submitDataTask);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Entity> void runEntity(final T entity, final Consumer<T> consumer) {
|
||||
scheduler.runTask(plugin, () -> consumer.accept(entity));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.pretzel.dev.villagertradelimiter.scheduler;
|
||||
|
||||
|
||||
import io.papermc.paper.threadedregions.scheduler.AsyncScheduler;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class FoliaSchedulerAdapter implements SchedulerAdapter {
|
||||
|
||||
private final static boolean SUPPORTED = checkSupport();
|
||||
private final Plugin plugin;
|
||||
private final AsyncScheduler asyncScheduler;
|
||||
|
||||
public FoliaSchedulerAdapter(final Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.asyncScheduler = plugin.getServer().getAsyncScheduler();
|
||||
}
|
||||
|
||||
public static boolean isSupported() {
|
||||
return SUPPORTED;
|
||||
}
|
||||
|
||||
private static boolean checkSupport() {
|
||||
try {
|
||||
Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runAsync(Runnable submitDataTask) {
|
||||
asyncScheduler.runNow(plugin, task -> submitDataTask.run());
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Entity> void runEntity(T entity, Consumer<T> consumer) {
|
||||
entity.getScheduler().run(plugin, task -> consumer.accept(entity), () -> {
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.pretzel.dev.villagertradelimiter.scheduler;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public interface SchedulerAdapter {
|
||||
|
||||
void runAsync(Runnable submitDataTask);
|
||||
|
||||
<T extends Entity> void runEntity(T entity, Consumer<T> consumer);
|
||||
}
|
|
@ -3,6 +3,7 @@ author: PretzelJohn
|
|||
main: com.pretzel.dev.villagertradelimiter.VillagerTradeLimiter
|
||||
version: 1.6.3
|
||||
api-version: 1.14
|
||||
folia-supported: true
|
||||
|
||||
commands:
|
||||
villagertradelimiter:
|
||||
|
|
Loading…
Reference in New Issue