mirror of
https://github.com/RoinujNosde/SimpleClans.git
synced 2026-11-04 17:00:12 -05:00
Compare commits
7
Commits
master
...
folia-support
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e46fbac90 | ||
|
|
cea3113e84 | ||
|
|
c9e5dacbeb | ||
|
|
31c5048418 | ||
|
|
6d12a3a5de | ||
|
|
211f7a16f6 | ||
|
|
7255aca06f |
No files matched your search
@@ -1,4 +1,5 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
|
||||
<artifactId>SimpleClans</artifactId>
|
||||
@@ -85,6 +86,10 @@
|
||||
<pattern>com.google.gson</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.gson</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.tcoded.folialib</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.folialib</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<artifactSet>
|
||||
<excludes>
|
||||
@@ -94,7 +99,8 @@
|
||||
|
||||
<transformers>
|
||||
<!-- Avoid overlapping MANIFEST.MF file -->
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
|
||||
<transformer
|
||||
implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
|
||||
<resource>MANIFEST.MF</resource>
|
||||
</transformer>
|
||||
</transformers>
|
||||
@@ -261,6 +267,12 @@
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.10.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tcoded</groupId>
|
||||
<artifactId>FoliaLib</artifactId>
|
||||
<version>0.5.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Test frameworks -->
|
||||
<dependency>
|
||||
@@ -311,6 +323,10 @@
|
||||
<id>eldonexus</id>
|
||||
<url>https://eldonexus.de/repository/maven-public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>tcoded-releases</id>
|
||||
<url>https://repo.tcoded.com/releases</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
|
||||
@@ -1440,10 +1440,10 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
|
||||
SimpleClans.getInstance().getRequestManager().removeRequest(getTag());
|
||||
|
||||
SimpleClans.getInstance().getServer().getScheduler().scheduleSyncDelayedTask(SimpleClans.getInstance(), () -> {
|
||||
SimpleClans.getInstance().getScheduler().runNextTick(task -> {
|
||||
SimpleClans.getInstance().getClanManager().removeClan(getTag());
|
||||
SimpleClans.getInstance().getStorageManager().deleteClan(this);
|
||||
}, 1);
|
||||
});
|
||||
}
|
||||
|
||||
public void disband() {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import com.tcoded.folialib.FoliaLib;
|
||||
import com.tcoded.folialib.impl.PlatformScheduler;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.SCCommandManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.SimpleClansExpansion;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.language.LanguageResource;
|
||||
@@ -65,6 +67,7 @@ public class SimpleClans extends JavaPlugin {
|
||||
|
||||
private BankLogger bankLogger;
|
||||
private TagValidator tagValidator;
|
||||
private FoliaLib foliaLib;
|
||||
|
||||
/**
|
||||
* @return the logger
|
||||
@@ -100,6 +103,7 @@ public class SimpleClans extends JavaPlugin {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
foliaLib = new FoliaLib(this);
|
||||
new LanguageMigration(this).migrate();
|
||||
settingsManager = new SettingsManager(this);
|
||||
new BbMigration(settingsManager);
|
||||
@@ -206,6 +210,14 @@ public class SimpleClans extends JavaPlugin {
|
||||
getSettingsManager().loadAndSave();
|
||||
}
|
||||
|
||||
// TODO Replace this with getFoliaLib#getScheduler?
|
||||
public PlatformScheduler getScheduler() {
|
||||
return foliaLib.getScheduler();
|
||||
}
|
||||
|
||||
public FoliaLib getFoliaLib() {
|
||||
return foliaLib;
|
||||
}
|
||||
/**
|
||||
* @return the clanManager
|
||||
*/
|
||||
|
||||
+20
-23
@@ -21,31 +21,28 @@ public class SpigotChatHandler implements ChatHandler {
|
||||
/*
|
||||
TODO: Make it async, change Type to Channel in 3.0
|
||||
*/
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ChatEvent event = new ChatEvent(message.getContent(), message.getSender(), message.getReceivers(),
|
||||
ChatEvent.Type.valueOf(message.getChannel().name()));
|
||||
plugin.getScheduler().runLater(() -> {
|
||||
ChatEvent event = new ChatEvent(message.getContent(), message.getSender(), message.getReceivers(),
|
||||
ChatEvent.Type.valueOf(message.getChannel().name()));
|
||||
|
||||
getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
message.setContent(stripColorsAndFormatsPerPermission(message.getSender(),event.getMessage()));
|
||||
|
||||
ConfigField configField = ConfigField.valueOf(String.format("%sCHAT_FORMAT",
|
||||
message.getSource() == DISCORD ? "DISCORD" : message.getChannel()));
|
||||
|
||||
String format = settingsManager.getString(configField);
|
||||
String formattedMessage = chatManager.parseChatFormat(format, message, event.getPlaceholders());
|
||||
|
||||
plugin.getLogger().info(ChatUtils.stripColors(formattedMessage));
|
||||
|
||||
for (ClanPlayer cp : message.getReceivers()) {
|
||||
ChatBlock.sendMessage(cp, formattedMessage);
|
||||
}
|
||||
getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
}.runTask(plugin);
|
||||
message.setContent(stripColorsAndFormatsPerPermission(message.getSender(),event.getMessage()));
|
||||
|
||||
ConfigField configField = ConfigField.valueOf(String.format("%sCHAT_FORMAT",
|
||||
message.getSource() == DISCORD ? "DISCORD" : message.getChannel()));
|
||||
|
||||
String format = settingsManager.getString(configField);
|
||||
String formattedMessage = chatManager.parseChatFormat(format, message, event.getPlaceholders());
|
||||
|
||||
plugin.getLogger().info(ChatUtils.stripColors(formattedMessage));
|
||||
|
||||
for (ClanPlayer cp : message.getReceivers()) {
|
||||
ChatBlock.sendMessage(cp, formattedMessage);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
private String stripColorsAndFormatsPerPermission(ClanPlayer sender, String message) {
|
||||
|
||||
@@ -27,19 +27,16 @@ public class Kills extends Sendable {
|
||||
|
||||
@Override
|
||||
public void send() {
|
||||
plugin.getStorageManager().getKillsPerPlayer(polled, data -> new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (data.isEmpty()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("nokillsfound", player));
|
||||
return;
|
||||
}
|
||||
configureAndSendHeader();
|
||||
addLines(data);
|
||||
|
||||
sendBlock();
|
||||
plugin.getStorageManager().getKillsPerPlayer(polled, data -> plugin.getScheduler().runAtEntity(player, task -> {
|
||||
if (data.isEmpty()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("nokillsfound", player));
|
||||
return;
|
||||
}
|
||||
}.runTask(plugin));
|
||||
configureAndSendHeader();
|
||||
addLines(data);
|
||||
|
||||
sendBlock();
|
||||
}));
|
||||
}
|
||||
|
||||
private void addLines(Map<String, Integer> data) {
|
||||
|
||||
@@ -25,25 +25,22 @@ public class MostKilled extends Sendable {
|
||||
|
||||
@Override
|
||||
public void send() {
|
||||
plugin.getStorageManager().getMostKilled(data -> new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (data.isEmpty()) {
|
||||
ChatBlock.sendMessage(player, RED + lang("nokillsfound", player));
|
||||
return;
|
||||
}
|
||||
|
||||
sendHeader();
|
||||
|
||||
Map<String, Integer> killsPerPlayer = Helper.sortByValue(data);
|
||||
|
||||
for (Map.Entry<String, Integer> attackerVictim : killsPerPlayer.entrySet()) {
|
||||
addLine(attackerVictim);
|
||||
}
|
||||
|
||||
sendBlock();
|
||||
plugin.getStorageManager().getMostKilled(data -> plugin.getScheduler().runAtEntity(player, task -> {
|
||||
if (data.isEmpty()) {
|
||||
ChatBlock.sendMessage(player, RED + lang("nokillsfound", player));
|
||||
return;
|
||||
}
|
||||
}.runTask(plugin));
|
||||
|
||||
sendHeader();
|
||||
|
||||
Map<String, Integer> killsPerPlayer = Helper.sortByValue(data);
|
||||
|
||||
for (Map.Entry<String, Integer> attackerVictim : killsPerPlayer.entrySet()) {
|
||||
addLine(attackerVictim);
|
||||
}
|
||||
|
||||
sendBlock();
|
||||
}));
|
||||
}
|
||||
|
||||
private void addLine(Map.Entry<String, Integer> attackerVictim) {
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ public class CreateClanNamePrompt extends StringPrompt {
|
||||
if (errorPrompt != null) return errorPrompt;
|
||||
|
||||
String finalClanName = clanName;
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
plugin.getScheduler().runNextTick((task) -> {
|
||||
String tag = (String) context.getSessionData(TAG_KEY);
|
||||
//noinspection ConstantConditions
|
||||
PreCreateClanEvent event = new PreCreateClanEvent(player, tag, finalClanName);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.conversation;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.conversations.Conversable;
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.conversations.ConversationCanceller;
|
||||
@@ -48,6 +49,10 @@ public class SCConversation extends Conversation {
|
||||
}
|
||||
|
||||
public void addConversationCanceller(@NotNull ConversationCanceller canceller) {
|
||||
// not supported yet by Folia, https://github.com/PaperMC/Folia/issues/216
|
||||
if (SimpleClans.getInstance().getFoliaLib().isFolia()) {
|
||||
return;
|
||||
}
|
||||
canceller.setConversation(this);
|
||||
cancellers.add(canceller);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class SCPlayerListener extends SCListener {
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(event.getPlayer());
|
||||
if (cp != null) {
|
||||
Clan clan = Objects.requireNonNull(cp.getClan());
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
plugin.getScheduler().runNextTick((task) -> {
|
||||
if (clan.getOnlineMembers().isEmpty()) {
|
||||
plugin.getProtectionManager().setWarExpirationTime(cp.getClan(),
|
||||
settingsManager.getMinutes(WAR_DISCONNECT_EXPIRATION_TIME));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.managers;
|
||||
|
||||
import com.tcoded.folialib.wrapper.task.WrappedTask;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
@@ -14,7 +15,6 @@ import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ProtectionManager {
|
||||
private final SettingsManager settingsManager;
|
||||
private final ClanManager clanManager;
|
||||
private final Logger logger;
|
||||
private final Map<War, BukkitTask> wars = new HashMap<>();
|
||||
private final Map<War, WrappedTask> wars = new HashMap<>();
|
||||
private final List<ProtectionProvider> providers = new ArrayList<>();
|
||||
private LandProtection landProtection;
|
||||
private final SimpleClans plugin;
|
||||
@@ -46,7 +46,7 @@ public class ProtectionManager {
|
||||
return;
|
||||
}
|
||||
//running on next tick, so all plugins are already loaded
|
||||
Bukkit.getScheduler().runTask(plugin, this::registerProviders);
|
||||
plugin.getScheduler().runNextTick((task) -> registerProviders()) ;
|
||||
clearWars();
|
||||
}
|
||||
|
||||
@@ -149,11 +149,10 @@ public class ProtectionManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private BukkitTask scheduleTask(@NotNull War war, int expirationTime) {
|
||||
BukkitTask timeoutTask = null;
|
||||
private WrappedTask scheduleTask(@NotNull War war, int expirationTime) {
|
||||
WrappedTask timeoutTask = null;
|
||||
if (expirationTime > 0) {
|
||||
timeoutTask = Bukkit.getScheduler().runTaskLater(plugin, new WarTimeoutTask(war), expirationTime);
|
||||
timeoutTask = plugin.getScheduler().runLater(() -> new WarTimeoutTask(war), expirationTime);
|
||||
}
|
||||
return timeoutTask;
|
||||
}
|
||||
@@ -162,12 +161,12 @@ public class ProtectionManager {
|
||||
if (expirationTime < 1) {
|
||||
return;
|
||||
}
|
||||
for (Map.Entry<War, BukkitTask> entry : wars.entrySet()) {
|
||||
for (Map.Entry<War, WrappedTask> entry : wars.entrySet()) {
|
||||
War war = entry.getKey();
|
||||
if (!war.getClans().contains(clan)) {
|
||||
continue;
|
||||
}
|
||||
BukkitTask task = entry.getValue();
|
||||
WrappedTask task = entry.getValue();
|
||||
if (task != null && !task.isCancelled()) {
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
@@ -442,26 +442,21 @@ public final class RequestManager {
|
||||
* Starts the task that asks for the votes of all requests
|
||||
*/
|
||||
public void askerTask() {
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Iterator<Map.Entry<String, Request>> iter = requests.entrySet().iterator(); iter.hasNext(); ) {
|
||||
Request req = iter.next().getValue();
|
||||
|
||||
if (req == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (req.reachedRequestLimit()) {
|
||||
iter.remove();
|
||||
}
|
||||
|
||||
ask(req);
|
||||
req.incrementAskCount();
|
||||
plugin.getScheduler().runTimerAsync(() -> {
|
||||
for (Iterator<Map.Entry<String, Request>> iter = requests.entrySet().iterator(); iter.hasNext(); ) {
|
||||
Request req = iter.next().getValue();
|
||||
if (req == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (req.reachedRequestLimit()) {
|
||||
iter.remove();
|
||||
}
|
||||
|
||||
ask(req);
|
||||
req.incrementAskCount();
|
||||
}
|
||||
}.runTaskTimerAsynchronously(plugin, 0, plugin.getSettingsManager().getSeconds(REQUEST_FREQUENCY));
|
||||
}, 0, plugin.getSettingsManager().getSeconds(REQUEST_FREQUENCY));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -488,6 +483,6 @@ public final class RequestManager {
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getPluginManager().callEvent(new RequestEvent(req)));
|
||||
plugin.getScheduler().runNextTick((task) -> Bukkit.getPluginManager().callEvent(new RequestEvent(req)));
|
||||
}
|
||||
}
|
||||
@@ -718,12 +718,7 @@ public final class StorageManager {
|
||||
*/
|
||||
@Deprecated
|
||||
public void updateClanAsync(final Clan clan) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateClan(clan);
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
plugin.getScheduler().runAsync(task -> updateClan(clan));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -732,12 +727,7 @@ public final class StorageManager {
|
||||
* @param cp to update
|
||||
*/
|
||||
public void updatePlayerNameAsync(final @NotNull ClanPlayer cp) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updatePlayerName(cp);
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
plugin.getScheduler().runAsync(task -> updatePlayerName(cp));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1032,13 +1022,7 @@ public final class StorageManager {
|
||||
* @param callback the callback
|
||||
*/
|
||||
public void getMostKilled(DataCallback<Map<String, Integer>> callback) {
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
callback.onResultReady(getMostKilled());
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
plugin.getScheduler().runAsync(task -> callback.onResultReady(getMostKilled()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1046,12 +1030,7 @@ public final class StorageManager {
|
||||
*
|
||||
*/
|
||||
public void getKillsPerPlayer(final String playerName, final DataCallback<Map<String, Integer>> callback) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
callback.onResultReady(getKillsPerPlayer(playerName));
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
plugin.getScheduler().runAsync(task -> callback.onResultReady(getKillsPerPlayer(playerName)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.managers;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.ClanPlayerTeleportEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
@@ -80,7 +79,7 @@ public final class TeleportManager {
|
||||
}
|
||||
|
||||
public void teleportToHome(@NotNull Player player, @NotNull Location destination, @NotNull String clanName) {
|
||||
PaperLib.teleportAsync(player, getSafe(destination), PlayerTeleportEvent.TeleportCause.COMMAND).thenAccept(result -> {
|
||||
plugin.getScheduler().teleportAsync(player, getSafe(destination), PlayerTeleportEvent.TeleportCause.COMMAND).thenAccept(result -> {
|
||||
if (result) {
|
||||
ChatBlock.sendMessage(player, AQUA + lang("now.at.homebase", player, clanName));
|
||||
} else {
|
||||
@@ -151,7 +150,7 @@ public final class TeleportManager {
|
||||
}
|
||||
|
||||
private void startCounter() {
|
||||
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
|
||||
plugin.getScheduler().runTimer(() -> {
|
||||
waitingPlayers.values().removeIf(ts -> ts.getPlayer() == null);
|
||||
for (Iterator<TeleportState> iter = waitingPlayers.values().iterator(); iter.hasNext(); ) {
|
||||
TeleportState state = iter.next();
|
||||
@@ -175,7 +174,7 @@ public final class TeleportManager {
|
||||
|
||||
state.setProcessing(false);
|
||||
}
|
||||
}, 0, 20L);
|
||||
}, 0, 20);
|
||||
}
|
||||
|
||||
private void teleport(TeleportState state) {
|
||||
|
||||
@@ -59,7 +59,7 @@ public final class BungeeManager implements ProxyManager, PluginMessageListener
|
||||
}
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord");
|
||||
Bukkit.getMessenger().registerIncomingPluginChannel(plugin, "BungeeCord", this);
|
||||
Bukkit.getScheduler().runTaskTimer(plugin, this::requestPlayerList, 0, 60 * 20);
|
||||
plugin.getScheduler().runTimer(this::requestPlayerList, 0, 60 * 20);
|
||||
requestServerName();
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ public final class BungeeManager implements ProxyManager, PluginMessageListener
|
||||
}
|
||||
|
||||
private void requestServerName() {
|
||||
Bukkit.getScheduler().runTaskTimer(plugin, task -> {
|
||||
plugin.getScheduler().runTimer(task -> {
|
||||
if (!serverName.isEmpty()) {
|
||||
task.cancel();
|
||||
return;
|
||||
|
||||
@@ -38,6 +38,7 @@ public interface DBCore {
|
||||
|
||||
/**
|
||||
* Execute a select statement
|
||||
*
|
||||
* @param query the query
|
||||
* @return the result set or null if the query failed
|
||||
*/
|
||||
@@ -52,6 +53,7 @@ public interface DBCore {
|
||||
|
||||
/**
|
||||
* Execute a statement
|
||||
*
|
||||
* @param query the query
|
||||
* @return true if the statement was executed
|
||||
*/
|
||||
@@ -67,6 +69,7 @@ public interface DBCore {
|
||||
|
||||
/**
|
||||
* Check whether a table exists
|
||||
*
|
||||
* @param table the table
|
||||
* @return true if the table exists
|
||||
*/
|
||||
@@ -83,7 +86,7 @@ public interface DBCore {
|
||||
/**
|
||||
* Check whether a column exists
|
||||
*
|
||||
* @param table the table
|
||||
* @param table the table
|
||||
* @param column the column
|
||||
* @return true if the column exists
|
||||
*/
|
||||
@@ -112,7 +115,7 @@ public interface DBCore {
|
||||
}
|
||||
};
|
||||
if (plugin.getSettingsManager().is(ConfigField.PERFORMANCE_USE_THREADS)) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, executeUpdate);
|
||||
plugin.getScheduler().runLaterAsync(executeUpdate, 0);
|
||||
} else {
|
||||
executeUpdate.run();
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ public class CollectFeeTask extends BukkitRunnable {
|
||||
int hour = sm.getInt(TASKS_COLLECT_FEE_HOUR);
|
||||
int minute = sm.getInt(TASKS_COLLECT_FEE_MINUTE);
|
||||
long delay = Helper.getDelayTo(hour, minute);
|
||||
|
||||
this.runTaskTimer(plugin, delay * 20, 86400 * 20);
|
||||
|
||||
plugin.getScheduler().runTimer(this, delay * 20, 86400 * 20);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,7 +35,7 @@ public class CollectUpkeepTask extends BukkitRunnable {
|
||||
int minute = settingsManager.getInt(TASKS_COLLECT_UPKEEP_MINUTE);
|
||||
long delay = Helper.getDelayTo(hour, minute);
|
||||
|
||||
this.runTaskTimer(plugin, delay * 20, 86400 * 20);
|
||||
plugin.getScheduler().runTimerAsync(this, delay * 20, 86400 * 20);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,7 +27,7 @@ public class PlayerHeadCacheTask extends BukkitRunnable {
|
||||
*/
|
||||
public void start() {
|
||||
int hour = 3600;
|
||||
this.runTaskTimerAsynchronously(plugin, 0, (hour + 60) * 20);
|
||||
plugin.getScheduler().runTimerAsync(this, 0, (hour + 60) * 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,7 +19,7 @@ public class SaveDataTask extends BukkitRunnable {
|
||||
*/
|
||||
public void start() {
|
||||
long interval = plugin.getSettingsManager().getMinutes(PERFORMANCE_SAVE_INTERVAL);
|
||||
runTaskTimerAsynchronously(plugin, interval, interval);
|
||||
plugin.getScheduler().runTimerAsync(this, interval, interval);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,8 +31,7 @@ public class UpkeepWarningTask extends BukkitRunnable {
|
||||
int hour = sm.getInt(TASKS_COLLECT_UPKEEP_WARNING_HOUR);
|
||||
int minute = sm.getInt(TASKS_COLLECT_UPKEEP_WARNING_MINUTE);
|
||||
long delay = Helper.getDelayTo(hour, minute);
|
||||
|
||||
this.runTaskTimer(plugin, delay * 20, 86400 * 20);
|
||||
plugin.getScheduler().runTimer(this, delay * 20, 86400 * 20);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.*;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.COMMANDS_CLAN;
|
||||
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -91,7 +92,7 @@ public class InventoryController implements Listener {
|
||||
}
|
||||
|
||||
Runnable finalListener = listener;
|
||||
Bukkit.getScheduler().runTask(SimpleClans.getInstance(), () -> {
|
||||
SimpleClans.getInstance().getScheduler().runAtEntity(entity, task -> {
|
||||
ItemStack currentItem = event.getCurrentItem();
|
||||
if (currentItem == null) return;
|
||||
|
||||
@@ -177,21 +178,17 @@ public class InventoryController implements Listener {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
String baseCommand = plugin.getSettingsManager().getString(COMMANDS_CLAN);
|
||||
String finalCommand = String.format("%s %s ", baseCommand, subcommand) + String.join(" ", args);
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
player.performCommand(finalCommand);
|
||||
if (!update) {
|
||||
player.closeInventory();
|
||||
} else {
|
||||
SCFrame currentFrame = frames.get(player.getUniqueId());
|
||||
if (currentFrame instanceof ConfirmationFrame) {
|
||||
currentFrame = currentFrame.getParent();
|
||||
}
|
||||
InventoryDrawer.open(currentFrame);
|
||||
plugin.getScheduler().runAtEntity(player, task -> {
|
||||
player.performCommand(finalCommand);
|
||||
if (!update) {
|
||||
player.closeInventory();
|
||||
} else {
|
||||
SCFrame currentFrame = frames.get(player.getUniqueId());
|
||||
if (currentFrame instanceof ConfirmationFrame) {
|
||||
currentFrame = currentFrame.getParent();
|
||||
}
|
||||
InventoryDrawer.open(currentFrame);
|
||||
}
|
||||
}.runTask(plugin);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -35,19 +35,19 @@ public class InventoryDrawer {
|
||||
return;
|
||||
}
|
||||
|
||||
FrameOpenEvent event = new FrameOpenEvent(frame.getViewer(), frame);
|
||||
FrameOpenEvent event = new FrameOpenEvent(frame.getViewer(), frame);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
OPENING.put(uuid, frame);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
Inventory inventory = prepareInventory(frame);
|
||||
}
|
||||
OPENING.put(uuid, frame);
|
||||
plugin.getScheduler().runAsync(task -> {
|
||||
Inventory inventory = prepareInventory(frame);
|
||||
|
||||
if (!frame.equals(OPENING.get(uuid))) {
|
||||
return;
|
||||
}
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
plugin.getScheduler().runAtEntity(frame.getViewer(), syncTask -> {
|
||||
frame.getViewer().openInventory(inventory);
|
||||
InventoryController.register(frame);
|
||||
OPENING.remove(uuid);
|
||||
@@ -70,7 +70,6 @@ public class InventoryDrawer {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated use {@link InventoryDrawer#open(SCFrame)}
|
||||
*/
|
||||
@Deprecated
|
||||
@@ -122,7 +121,7 @@ public class InventoryDrawer {
|
||||
}
|
||||
|
||||
private static void runHelpCommand(@NotNull Player player) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> plugin.getServer().getConsoleSender().sendMessage(lang("gui.not.supported")));
|
||||
plugin.getServer().getConsoleSender().sendMessage(lang("gui.not.supported"));
|
||||
SettingsManager settingsManager = plugin.getSettingsManager();
|
||||
settingsManager.set(ENABLE_GUI, false);
|
||||
String commandClan = settingsManager.getString(COMMANDS_CLAN);
|
||||
@@ -148,10 +147,10 @@ public class InventoryDrawer {
|
||||
}
|
||||
|
||||
private static boolean hasPermission(@NotNull Player viewer, @NotNull Object permission) {
|
||||
if (permission instanceof String) {
|
||||
return plugin.getPermissionsManager().has(viewer, (String) permission);
|
||||
}
|
||||
return plugin.getPermissionsManager().has(viewer, (RankPermission) permission, false);
|
||||
}
|
||||
if (permission instanceof String) {
|
||||
return plugin.getPermissionsManager().has(viewer, (String) permission);
|
||||
}
|
||||
return plugin.getPermissionsManager().has(viewer, (RankPermission) permission, false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,35 +37,31 @@ public class UpdateChecker {
|
||||
*
|
||||
*/
|
||||
public void check() {
|
||||
new BukkitRunnable() {
|
||||
plugin.getScheduler().runAsync(task -> {
|
||||
try {
|
||||
URL url = new URL(LATEST_VERSION_URL);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.addRequestProperty("User-Agent", userAgent);
|
||||
InputStreamReader reader = new InputStreamReader(connection.getInputStream());
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
URL url = new URL(LATEST_VERSION_URL);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.addRequestProperty("User-Agent", userAgent);
|
||||
InputStreamReader reader = new InputStreamReader(connection.getInputStream());
|
||||
|
||||
JsonElement parse = JsonParser.parseReader(reader);
|
||||
if (parse.isJsonObject()) {
|
||||
String latestVersion = parse.getAsJsonObject().get("name").getAsString();
|
||||
JsonElement parse = JsonParser.parseReader(reader);
|
||||
if (parse.isJsonObject()) {
|
||||
String latestVersion = parse.getAsJsonObject().get("name").getAsString();
|
||||
|
||||
if (compareVersions(version, latestVersion) < 0) {
|
||||
plugin.getLogger().info(String.format("You're running an outdated version (%s).", version));
|
||||
plugin.getLogger().info(String.format("The latest version is %s. Download it at:", latestVersion));
|
||||
plugin.getLogger().info("https://www.spigotmc.org/resources/simpleclans.71242/");
|
||||
}
|
||||
|
||||
if (compareVersions(version, latestVersion) < 0) {
|
||||
plugin.getLogger().info(String.format("You're running an outdated version (%s).", version));
|
||||
plugin.getLogger().info(String.format("The latest version is %s. Download it at:", latestVersion));
|
||||
plugin.getLogger().info("https://www.spigotmc.org/resources/simpleclans.71242/");
|
||||
}
|
||||
|
||||
reader.close();
|
||||
} catch (MalformedURLException ignored) {
|
||||
} catch (IOException | JsonParseException ex) {
|
||||
plugin.getLogger().log(Level.WARNING, "Error checking the plugin version...");
|
||||
|
||||
}
|
||||
|
||||
reader.close();
|
||||
} catch (MalformedURLException ignored) {
|
||||
} catch (IOException | JsonParseException ex) {
|
||||
plugin.getLogger().log(Level.WARNING, "Error checking the plugin version...");
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
});
|
||||
}
|
||||
|
||||
public static int compareVersions(@NotNull String a, @NotNull String b) {
|
||||
|
||||
@@ -11,6 +11,7 @@ loadbefore:
|
||||
- GriefPrevention
|
||||
- PlotSquared
|
||||
api-version: '1.13'
|
||||
folia-supported: true
|
||||
authors:
|
||||
- Phaed
|
||||
- RoinujNosde
|
||||
|
||||
Reference in new issue
Block a user