mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 06:06:45 +01:00
update & rollback some "big changes"
This commit is contained in:
parent
5ed0c47e84
commit
c11223b174
@ -1356,7 +1356,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "users` ADD `uuid` varchar(36) NULL DEFAULT NULL");
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "users` ADD UNIQUE INDEX `uuid` (`uuid`) USING BTREE");
|
||||
|
||||
mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new GetUUIDUpdatesRequired(), 100 * Misc.TICK_MS_CONVERSION_FACTOR, TimeUnit.MILLISECONDS); // wait until after first purge
|
||||
mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new GetUUIDUpdatesRequired(), 100); // wait until after first purge
|
||||
}
|
||||
|
||||
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS);
|
||||
|
@ -149,10 +149,7 @@ public class PlayerListener implements Listener {
|
||||
new MobHealthDisplayUpdaterTask(attacker).run();
|
||||
|
||||
// set the name back
|
||||
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(attacker,
|
||||
() -> MobHealthbarUtils.handleMobHealthbars(attacker, 0, mcMMO.p),
|
||||
Misc.TICK_MS_CONVERSION_FACTOR, TimeUnit.MILLISECONDS
|
||||
);
|
||||
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(attacker, () -> MobHealthbarUtils.handleMobHealthbars(attacker, 0, mcMMO.p), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@ public class WorldListener implements Listener {
|
||||
for (BlockState blockState : event.getBlocks()) {
|
||||
mcMMO.getPlaceStore().setFalse(blockState);
|
||||
}
|
||||
}, 50, TimeUnit.MILLISECONDS);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -242,7 +242,8 @@ public class mcMMO extends JavaPlugin {
|
||||
.getImpl()
|
||||
.runTimer(
|
||||
() -> getLogger().severe("You are running an outdated version of "+platformManager.getServerSoftware()+", mcMMO will not work unless you update to a newer version!"),
|
||||
20 * 50L, 1000 * 60 * 30, TimeUnit.MILLISECONDS);
|
||||
20, 20*60*30
|
||||
);
|
||||
|
||||
if(platformManager.getServerSoftware() == ServerSoftwareType.CRAFT_BUKKIT)
|
||||
{
|
||||
@ -250,7 +251,8 @@ public class mcMMO extends JavaPlugin {
|
||||
.getImpl()
|
||||
.runTimer(
|
||||
() -> getLogger().severe("We have detected you are using incompatible server software, our best guess is that you are using CraftBukkit. mcMMO requires Spigot or Paper, if you are not using CraftBukkit, you will still need to update your custom server software before mcMMO will work."),
|
||||
20 * 50L, 1000 * 60 * 30, TimeUnit.MILLISECONDS);
|
||||
20, 20*60*30
|
||||
);
|
||||
}
|
||||
} else {
|
||||
registerEvents();
|
||||
@ -635,7 +637,7 @@ public class mcMMO extends JavaPlugin {
|
||||
if (generalConfig.getChimaeraEnabled()) {
|
||||
getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe());
|
||||
}
|
||||
}, 40 * 50, TimeUnit.MILLISECONDS);
|
||||
}, 40);
|
||||
}
|
||||
|
||||
private void scheduleTasks() {
|
||||
|
@ -5,26 +5,22 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.tcoded.folialib.wrapper.task.WrappedTask;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
public class SaveTimerTask extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "[User Data] Saving...");
|
||||
// All player data will be saved periodically through this
|
||||
int count = 1;
|
||||
|
||||
public class SaveTimerTask {
|
||||
public WrappedTask runTaskTimer(long delay, long period) {
|
||||
return mcMMO.p.getFoliaLib().getImpl().runTimer(() -> {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "[User Data] Saving...");
|
||||
// All player data will be saved periodically through this
|
||||
int count = 1;
|
||||
|
||||
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
|
||||
new PlayerProfileSaveTask(mcMMOPlayer.getProfile(), false).runTaskLaterAsynchronously(mcMMO.p, count);
|
||||
count++;
|
||||
}
|
||||
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
|
||||
new PlayerProfileSaveTask(mcMMOPlayer.getProfile(), false).runTaskLaterAsynchronously(mcMMO.p, count);
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
PartyManager.saveParties();
|
||||
}, delay * Misc.TICK_CONVERSION_FACTOR, period * Misc.TICK_CONVERSION_FACTOR, TimeUnit.MILLISECONDS);
|
||||
PartyManager.saveParties();
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ public class UUIDUpdateAsyncTask implements Runnable {
|
||||
|
||||
// Bukkit runnables don't let themselves reschedule themselves, so we are a pseudo bukkit runnable.
|
||||
private void runTaskLaterAsynchronously(mcMMO plugin, int delay) {
|
||||
plugin.getFoliaLib().getImpl().runLaterAsync(this, delay, TimeUnit.MILLISECONDS);
|
||||
plugin.getFoliaLib().getImpl().runLaterAsync(this, delay);
|
||||
}
|
||||
|
||||
public void start() {
|
||||
|
@ -26,7 +26,6 @@ public final class Misc {
|
||||
|
||||
public static final int TIME_CONVERSION_FACTOR = 1000;
|
||||
public static final int TICK_CONVERSION_FACTOR = 20;
|
||||
public static final int TICK_MS_CONVERSION_FACTOR = 50;
|
||||
|
||||
public static final int PLAYER_RESPAWN_COOLDOWN_SECONDS = 5;
|
||||
public static final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0;
|
||||
|
@ -18,10 +18,12 @@ import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager.SidebarType;
|
||||
import com.gmail.nossr50.util.skills.SkillTools;
|
||||
import com.tcoded.folialib.wrapper.task.WrappedTask;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Score;
|
||||
@ -30,7 +32,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ScoreboardWrapper {
|
||||
public static final String SIDE_OBJECTIVE = "mcMMO_sideObjective";
|
||||
@ -85,40 +86,38 @@ public class ScoreboardWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
public WrappedTask updateTask = null;
|
||||
public BukkitTask updateTask = null;
|
||||
|
||||
private class ScoreboardQuickUpdate {
|
||||
public WrappedTask runTaskLater(long delay) {
|
||||
return mcMMO.p.getFoliaLib().getImpl().runLater(() -> {
|
||||
updateSidebar();
|
||||
updateTask = null;
|
||||
}, delay * Misc.TICK_CONVERSION_FACTOR, TimeUnit.MILLISECONDS);
|
||||
private class ScoreboardQuickUpdate extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
updateSidebar();
|
||||
updateTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
public WrappedTask revertTask = null;
|
||||
public BukkitTask revertTask = null;
|
||||
|
||||
private class ScoreboardChangeTask {
|
||||
public WrappedTask runTaskLater(long delay) {
|
||||
return mcMMO.p.getFoliaLib().getImpl().runLater(() -> {
|
||||
tryRevertBoard();
|
||||
revertTask = null;
|
||||
}, delay * Misc.TICK_CONVERSION_FACTOR, TimeUnit.MILLISECONDS);
|
||||
private class ScoreboardChangeTask extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
tryRevertBoard();
|
||||
revertTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
public WrappedTask cooldownTask = null;
|
||||
public BukkitTask cooldownTask = null;
|
||||
|
||||
private class ScoreboardCooldownTask {
|
||||
public WrappedTask runTaskTimer(long delay, long period) {
|
||||
return mcMMO.p.getFoliaLib().getImpl().runTimer(() -> {
|
||||
// Stop updating if it's no longer something displaying cooldowns
|
||||
if (isBoardShown() && (isSkillScoreboard() || isCooldownScoreboard())) {
|
||||
doSidebarUpdateSoon();
|
||||
} else {
|
||||
stopCooldownUpdating();
|
||||
}
|
||||
}, delay, period, TimeUnit.MILLISECONDS);
|
||||
private class ScoreboardCooldownTask extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
// Stop updating if it's no longer something displaying cooldowns
|
||||
if (isBoardShown() && (isSkillScoreboard() || isCooldownScoreboard())) {
|
||||
doSidebarUpdateSoon();
|
||||
}
|
||||
else {
|
||||
stopCooldownUpdating();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,7 +125,7 @@ public class ScoreboardWrapper {
|
||||
public void doSidebarUpdateSoon() {
|
||||
if (updateTask == null) {
|
||||
// To avoid spamming the scheduler, store the instance and run 2 ticks later
|
||||
updateTask = new ScoreboardQuickUpdate().runTaskLater(2L);
|
||||
updateTask = new ScoreboardQuickUpdate().runTaskLater(mcMMO.p, 2L);
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,7 +133,7 @@ public class ScoreboardWrapper {
|
||||
if (cooldownTask == null) {
|
||||
// Repeat every 5 seconds.
|
||||
// Cancels once all cooldowns are done, using stopCooldownUpdating().
|
||||
cooldownTask = new ScoreboardCooldownTask().runTaskTimer(5 * Misc.TICK_CONVERSION_FACTOR, 5 * Misc.TICK_CONVERSION_FACTOR);
|
||||
cooldownTask = new ScoreboardCooldownTask().runTaskTimer(mcMMO.p, 5 * Misc.TICK_CONVERSION_FACTOR, 5 * Misc.TICK_CONVERSION_FACTOR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,7 +216,7 @@ public class ScoreboardWrapper {
|
||||
}
|
||||
|
||||
player.setScoreboard(scoreboard);
|
||||
revertTask = new ScoreboardChangeTask().runTaskLater(ticks);
|
||||
revertTask = new ScoreboardChangeTask().runTaskLater(mcMMO.p, ticks);
|
||||
|
||||
// TODO is there any way to do the time that looks acceptable?
|
||||
// player.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Timer", StringUtils.capitalize(sidebarType.toString().toLowerCase(Locale.ENGLISH)), ticks / 20F));
|
||||
@ -427,7 +426,7 @@ public class ScoreboardWrapper {
|
||||
NotificationManager.sendPlayerInformationChatOnlyPrefixed(player, "Scoreboard.Recovery");
|
||||
|
||||
initBoard(); //Start over
|
||||
mcMMO.p.getFoliaLib().getImpl().runLater(() -> ScoreboardManager.retryLastSkillBoard(player), 0, TimeUnit.MILLISECONDS);
|
||||
Bukkit.getScheduler().runTaskLater(mcMMO.p, () -> ScoreboardManager.retryLastSkillBoard(player), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -983,6 +983,6 @@ public final class CombatUtils {
|
||||
* @param entity the projectile
|
||||
*/
|
||||
public static void delayArrowMetaCleanup(@NotNull Projectile entity) {
|
||||
mcMMO.p.getFoliaLib().getImpl().runLater(() -> cleanupArrowMetadata(entity), 1000 * 60, TimeUnit.MILLISECONDS);
|
||||
mcMMO.p.getFoliaLib().getImpl().runLater(() -> cleanupArrowMetadata(entity), 20*60);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user