diff --git a/Changelog.txt b/Changelog.txt
index a7b1d1a09..4726153ff 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -56,10 +56,41 @@ Version 2.2.000
New Power Level Command
This power level command gives you a view of all your current masteries, it also provides a summary of your power level.
+Version 2.1.226
+ Added Short_Grass to experience.yml for Herbalism
+ Updated Hylian Treasures "Bushes" alias to use short_grass when playing on new Minecraft versions
+ Fixed dirt_path and grass_block not being correctly whitelisted for herbalism abilities
+Version 2.1.225
+ Fixed text from mcMMO not being sent or displayed to the player
+ Updated Adventure dependencies
+ Added new API McMMOPlayerNotificationEvent.getPlayer
+
+Version 2.1.224
+ Updated to a new build of ACF to fix NoSuchFieldException locale
+ Improved Folia Support (Thanks HSGamer)
+ Fishing Shake has 8 ranks again
+
+ NOTES:
+ At some point Shake got reduced to 1 rank, this didn't really make sense as it was meant to be a skill that ranked up and got better over time.
+ It now has 8 ranks again, you may need to update advanced.yml and skillranks.yml to get the new ranks.
+Version 2.1.223
+ Folia Support added (Thanks to HSGamer, TechnicallyCoded, Rockyers, and Yomamaeatstoes)
+
+ NOTES: This update brings mcMMO to Folia, not all features are guaranteed to work but from limited testing it appears to be working well.
+Version 2.1.222
+ Fixed dupe exploit
+ Glow Lichen default XP changed from 200 to 5
+ A lot of mcMMO logging was moved from INFO to DEBUG, this should reduce the amount of noise in your logs and console
+
+ NOTES: If you want to see all logging messages, modify config.yml and set General.Verbose_Logging to true
+ You will have to adjust experience.yml to get the balance changes, or delete it to generate a new one
Version 2.1.221
+ PAPI Support is now built into mcMMO and loads when mcMMO loads (as long as you have PAPI running)
Fixed blast mining bonus drops not working (Thanks warriiorrrr)
Added fail safes to prevent bonus drops metadata from lingering on blocks
+ NOTES: Placeholders were brought in from electroniccat's original work on a PAPI expansion for mcMMO, the placeholders are the same as a result
+ I will be adding a leaderboard placeholder in the next patch (most likely). Feel free to share details of what functionality you'd want from additional placeholders on discord.
Version 2.1.220
(API) Added TreeFellerBlockBreakEvent class which extends FakeBlockBreakEvent (see notes), this is sent out during Tree Feller processing to allow other plugins to differentiate between Tree Feller and other fake block break events
Config files update automatically again
diff --git a/README.md b/README.md
index 64ac62516..9b1d9e046 100644
--- a/README.md
+++ b/README.md
@@ -29,6 +29,12 @@ In December 2018, the original author and creator of mcMMO (nossr50) returned an
#### Classic Maintainer
[![t00thpick1](http://www.gravatar.com/avatar/ee23c7794a0c40120c3474287c7bce06.png)](https://github.com/t00thpick1)
+#### Folia Inquisitors
+[](https://github.com/HSGamer)
+[](https://github.com/TechnicallyCoded)
+[](https://github.com/Yomamaeatstoes)
+[](https://github.com/Rockyers)
+
## Former Team Members
### Former Lead & Awesome guy
diff --git a/pom.xml b/pom.xml
old mode 100755
new mode 100644
index ca4dcd638..c092e7494
--- a/pom.xml
+++ b/pom.xml
@@ -150,20 +150,20 @@
net.kyori:examination-api
net.kyori:examination-string
net.kyori:adventure-text-serializer-legacy
+ net.kyori:adventure-text-serializer-gson
+ net.kyori:adventure-text-serializer-json
net.kyori:adventure-text-serializer-bungeecord
net.kyori:adventure-text-serializer-craftbukkit
net.kyori:adventure-text-serializer-gson-legacy-impl
+ net.kyori:adventure-text-serializer-json-legacy-impl
co.aikar:acf-bukkit
+ com.tcoded:FoliaLib
- net.kyori.examination
- com.gmail.nossr50.mcmmo.kyori.examination
-
-
- net.kyori.adventure
- com.gmail.nossr50.mcmmo.kyori.adventure
+ net.kyori
+ com.gmail.nossr50.mcmmo.kyori
co.aikar.commands
@@ -189,6 +189,10 @@
org.bstats
com.gmail.nossr50.mcmmo.metrics.bstats
+
+ com.tcoded.folialib
+ com.gmail.nossr50.mcmmo.folialib
+
@@ -241,50 +245,88 @@
sonatype-oss-snapshots1
https://s01.oss.sonatype.org/content/repositories/snapshots/
+
+ placeholderapi
+ https://repo.extendedclip.com/content/repositories/placeholderapi/
+
+
+ devmart-other
+ https://nexuslite.gcnt.net/repos/other/
+
+
+ me.clip
+ placeholderapi
+ 2.11.3
+ provided
+
co.aikar
acf-bukkit
0.5.1-SNAPSHOT
-
+
+ net.kyori
+ adventure-text-serializer-bungeecord
+ 4.3.1
+
net.kyori
adventure-text-serializer-gson
- 4.13.0
-
-
- net.kyori
- adventure-api
- 4.13.0
-
-
- net.kyori
- adventure-nbt
- 4.13.0
-
-
- net.kyori
- adventure-key
- 4.13.0
+ 4.14.0
net.kyori
adventure-text-serializer-gson-legacy-impl
- 4.13.0
+ 4.14.0
net.kyori
- adventure-platform-bukkit
- 4.3.0
+ adventure-text-serializer-json
+ 4.14.0
+
+
+ net.kyori
+ adventure-text-serializer-json-legacy-impl
+ 4.14.0
+
+
+ net.kyori
+ adventure-api
+ 4.14.0
+
+
+ net.kyori
+ adventure-nbt
+ 4.14.0
+
+
+ net.kyori
+ adventure-key
+ 4.14.0
net.kyori
adventure-platform-api
- 4.3.0
+ 4.3.1
+
+
+ net.kyori
+ adventure-platform-bukkit
+ 4.3.1
+
+
+ net.kyori
+ adventure-platform-facet
+ 4.3.1
+
+
+ net.kyori
+ adventure-platform-viaversion
+ 4.3.1
org.apache.maven.scm
@@ -300,7 +342,13 @@
org.spigotmc
spigot-api
- 1.19.2-R0.1-SNAPSHOT
+ 1.20.4-R0.1-SNAPSHOT
+ provided
+
+
+ com.sk89q.worldedit
+ worldedit-bukkit
+ 7.2.0-SNAPSHOT
provided
@@ -359,7 +407,13 @@
com.google.guava
guava
- 31.1-jre
+ 32.1.1-jre
+ compile
+
+
+ com.tcoded
+ FoliaLib
+ 0.3.1
compile
diff --git a/src/main/java/com/gmail/nossr50/api/TreeFellerBlockBreakEvent.java b/src/main/java/com/gmail/nossr50/api/TreeFellerBlockBreakEvent.java
index 7f7db7bcf..de084578b 100644
--- a/src/main/java/com/gmail/nossr50/api/TreeFellerBlockBreakEvent.java
+++ b/src/main/java/com/gmail/nossr50/api/TreeFellerBlockBreakEvent.java
@@ -1,10 +1,8 @@
package com.gmail.nossr50.api;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
-import com.gmail.nossr50.events.fake.FakeEvent;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
-import org.bukkit.event.block.BlockBreakEvent;
import org.jetbrains.annotations.NotNull;
public class TreeFellerBlockBreakEvent extends FakeBlockBreakEvent {
diff --git a/src/main/java/com/gmail/nossr50/commands/McImportCommand.java b/src/main/java/com/gmail/nossr50/commands/McImportCommand.java
index ce43f9675..3c913ea47 100644
--- a/src/main/java/com/gmail/nossr50/commands/McImportCommand.java
+++ b/src/main/java/com/gmail/nossr50/commands/McImportCommand.java
@@ -204,7 +204,7 @@ public class McImportCommand implements CommandExecutor {
else if (materialName.contains("LOG") || materialName.contains("LEAVES")) {
skillName = "Woodcutting";
}
- else if (materialName.contains("GRASS") || materialName.contains("FLOWER") || materialName.contains("CROP")) {
+ else if (materialName.contains("GRASS") || materialName.contains("SHORT_GRASS") || materialName.contains("FLOWER") || materialName.contains("CROP")) {
skillName = "Herbalism";
}
else if (materialName.contains("DIRT") || materialName.contains("SAND")) {
diff --git a/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java b/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java
index 8642bc922..571f1ae35 100644
--- a/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java
+++ b/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java
@@ -64,10 +64,10 @@ public class ConvertDatabaseCommand implements CommandExecutor {
mcMMO.getDatabaseManager().saveUser(profile);
}
- new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
+ mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileLoadingTask(player), 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
- new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(mcMMO.p);
+ mcMMO.p.getFoliaLib().getImpl().runAsync(new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()));
return true;
}
return false;
diff --git a/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java
index e15063ebf..3b0ea7ea3 100644
--- a/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java
+++ b/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java
@@ -36,10 +36,10 @@ public class ConvertExperienceCommand implements CommandExecutor {
UserManager.saveAll();
UserManager.clearAll();
- new FormulaConversionTask(sender, newType).runTaskLater(mcMMO.p, 1);
+ mcMMO.p.getFoliaLib().getImpl().runLater(new FormulaConversionTask(sender, newType), 1);
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
- new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
+ mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileLoadingTask(player), 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
return true;
diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java
index c892fa7e0..48276c723 100644
--- a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java
+++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java
@@ -250,7 +250,7 @@ public class PtpCommand implements TabExecutor {
if (warmup > 0) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Teleport.Commencing", warmup));
- new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(teleportingPlayer, new TeleportationWarmup(mcMMOPlayer, mcMMOTarget), 20 * warmup);
}
else {
EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
diff --git a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java
index 080be4e08..dcfcdcdbe 100644
--- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java
+++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java
@@ -111,7 +111,7 @@ public class McrankCommand implements TabExecutor {
boolean useBoard = mcMMO.p.getGeneralConfig().getScoreboardsEnabled() && (sender instanceof Player) && (mcMMO.p.getGeneralConfig().getRankUseBoard());
boolean useChat = !useBoard || mcMMO.p.getGeneralConfig().getRankUseChat();
- new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
+ mcMMO.p.getFoliaLib().getImpl().runAsync(new McrankCommandAsyncTask(playerName, sender, useBoard, useChat));
}
private long getCDSeconds(McMMOPlayer mcMMOPlayer, long cooldownMillis) {
diff --git a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java
index aaf660bc1..86b1757e9 100644
--- a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java
+++ b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java
@@ -115,7 +115,7 @@ public class MctopCommand implements TabExecutor {
boolean useBoard = (sender instanceof Player) && (mcMMO.p.getGeneralConfig().getTopUseBoard());
boolean useChat = !useBoard || mcMMO.p.getGeneralConfig().getTopUseChat();
- new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
+ mcMMO.p.getFoliaLib().getImpl().runAsync(new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat));
}
private PrimarySkillType extractSkill(CommandSender sender, String skillName) {
diff --git a/src/main/java/com/gmail/nossr50/config/AutoUpdateLegacyConfigLoader.java b/src/main/java/com/gmail/nossr50/config/AutoUpdateLegacyConfigLoader.java
index b021a7bac..600e7f984 100644
--- a/src/main/java/com/gmail/nossr50/config/AutoUpdateLegacyConfigLoader.java
+++ b/src/main/java/com/gmail/nossr50/config/AutoUpdateLegacyConfigLoader.java
@@ -1,6 +1,7 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
@@ -31,7 +32,7 @@ public abstract class AutoUpdateLegacyConfigLoader extends LegacyConfigLoader {
protected void saveConfig() {
try {
- mcMMO.p.getLogger().info("Saving changes to config file - " + fileName);
+ LogUtils.debug(mcMMO.p.getLogger(), "Saving changes to config file - " + fileName);
config.options().indent(2);
config.save(configFile);
} catch (IOException e) {
@@ -58,9 +59,9 @@ public abstract class AutoUpdateLegacyConfigLoader extends LegacyConfigLoader {
oldKeys.removeAll(internalConfigKeys);
if (!oldKeys.isEmpty()) {
- mcMMO.p.debug("old key(s) in \"" + fileName + "\"");
+ LogUtils.debug(mcMMO.p.getLogger(), "old key(s) in \"" + fileName + "\"");
for (String key : oldKeys) {
- mcMMO.p.debug(" old-key:" + key);
+ LogUtils.debug(mcMMO.p.getLogger(), " old-key:" + key);
}
}
@@ -73,7 +74,7 @@ public abstract class AutoUpdateLegacyConfigLoader extends LegacyConfigLoader {
}
for (String key : newKeys) {
- mcMMO.p.debug("Adding new key: " + key + " = " + internalConfig.get(key));
+ LogUtils.debug(mcMMO.p.getLogger(), "Adding new key: " + key + " = " + internalConfig.get(key));
config.set(key, internalConfig.get(key));
}
diff --git a/src/main/java/com/gmail/nossr50/config/BukkitConfig.java b/src/main/java/com/gmail/nossr50/config/BukkitConfig.java
index 35c598e36..23d50b6b2 100644
--- a/src/main/java/com/gmail/nossr50/config/BukkitConfig.java
+++ b/src/main/java/com/gmail/nossr50/config/BukkitConfig.java
@@ -1,6 +1,7 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
@@ -22,7 +23,7 @@ public abstract class BukkitConfig {
private boolean savedDefaults = false;
public BukkitConfig(@NotNull String fileName, @NotNull File dataFolder, boolean copyDefaults) {
- mcMMO.p.getLogger().info("[config] Initializing config: " + fileName);
+ LogUtils.debug(mcMMO.p.getLogger(), "Initializing config: " + fileName);
this.copyDefaults = copyDefaults;
this.fileName = fileName;
this.dataFolder = dataFolder;
@@ -30,7 +31,7 @@ public abstract class BukkitConfig {
this.defaultYamlConfig = saveDefaultConfigToDisk();
this.config = initConfig();
updateFile();
- mcMMO.p.getLogger().info("[config] Config initialized: " + fileName);
+ LogUtils.debug(mcMMO.p.getLogger(), "Config initialized: " + fileName);
}
public BukkitConfig(@NotNull String fileName, @NotNull File dataFolder) {
@@ -81,10 +82,10 @@ public abstract class BukkitConfig {
* Copies the config from the JAR to defaults/
*/
YamlConfiguration saveDefaultConfigToDisk() {
- mcMMO.p.getLogger().info("[config] Copying default config to disk: " + fileName + " to defaults/" + fileName);
+ LogUtils.debug(mcMMO.p.getLogger(), "Copying default config to disk: " + fileName + " to defaults/" + fileName);
try(InputStream inputStream = mcMMO.p.getResource(fileName)) {
if(inputStream == null) {
- mcMMO.p.getLogger().severe("[config] Unable to copy default config: " + fileName);
+ mcMMO.p.getLogger().severe("Unable to copy default config: " + fileName);
return null;
}
@@ -109,11 +110,11 @@ public abstract class BukkitConfig {
YamlConfiguration initConfig() {
if (!configFile.exists()) {
- mcMMO.p.getLogger().info("[config] User config file not found, copying a default config to disk: " + fileName);
+ LogUtils.debug(mcMMO.p.getLogger(), "User config file not found, copying a default config to disk: " + fileName);
mcMMO.p.saveResource(fileName, false);
}
- mcMMO.p.getLogger().info("[config] Loading config from disk: " + fileName);
+ LogUtils.debug(mcMMO.p.getLogger(), "Loading config from disk: " + fileName);
YamlConfiguration config = new YamlConfiguration();
config.options().indent(4);
@@ -151,7 +152,7 @@ public abstract class BukkitConfig {
protected void validate() {
if (validateKeys()) {
- mcMMO.p.debug("No errors found in " + fileName + "!");
+ LogUtils.debug(mcMMO.p.getLogger(), "No errors found in " + fileName + "!");
} else {
mcMMO.p.getLogger().warning("Errors were found in " + fileName + "! mcMMO was disabled!");
mcMMO.p.getServer().getPluginManager().disablePlugin(mcMMO.p);
@@ -160,8 +161,8 @@ public abstract class BukkitConfig {
}
public void backup() {
- mcMMO.p.getLogger().info("You are using an old version of the " + fileName + " file.");
- mcMMO.p.getLogger().info("Your old file has been renamed to " + fileName + ".old and has been replaced by an updated version.");
+ LogUtils.debug(mcMMO.p.getLogger(), "You are using an old version of the " + fileName + " file.");
+ LogUtils.debug(mcMMO.p.getLogger(), "Your old file has been renamed to " + fileName + ".old and has been replaced by an updated version.");
configFile.renameTo(new File(configFile.getPath() + ".old"));
diff --git a/src/main/java/com/gmail/nossr50/config/GeneralConfig.java b/src/main/java/com/gmail/nossr50/config/GeneralConfig.java
index f0ae3cd1c..801cae25c 100644
--- a/src/main/java/com/gmail/nossr50/config/GeneralConfig.java
+++ b/src/main/java/com/gmail/nossr50/config/GeneralConfig.java
@@ -1006,5 +1006,9 @@ public class GeneralConfig extends BukkitConfig {
return config.getBoolean("Green_Thumb_Replanting_Crops." + StringUtils.getCapitalized(material.toString()), true);
}
+ public boolean useVerboseLogging() {
+ return config.getBoolean("General.Verbose_Logging", false);
+ }
+
public boolean isMasterySystemEnabled() { return config.getBoolean( "General.PowerLevel.Skill_Mastery.Enabled"); }
}
diff --git a/src/main/java/com/gmail/nossr50/config/LegacyConfigLoader.java b/src/main/java/com/gmail/nossr50/config/LegacyConfigLoader.java
index ebd82c237..6a917b3fd 100644
--- a/src/main/java/com/gmail/nossr50/config/LegacyConfigLoader.java
+++ b/src/main/java/com/gmail/nossr50/config/LegacyConfigLoader.java
@@ -1,6 +1,7 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
@@ -46,7 +47,7 @@ public abstract class LegacyConfigLoader {
protected void loadFile() {
if (!configFile.exists()) {
- mcMMO.p.getLogger().info("Creating mcMMO " + fileName + " File...");
+ LogUtils.debug(mcMMO.p.getLogger(), "Creating mcMMO " + fileName + " File...");
try {
mcMMO.p.saveResource(fileName, false); // Normal files
@@ -54,7 +55,7 @@ public abstract class LegacyConfigLoader {
mcMMO.p.saveResource(configFile.getParentFile().getName() + File.separator + fileName, false); // Mod files
}
} else {
- mcMMO.p.getLogger().info("Loading mcMMO " + fileName + " File...");
+ LogUtils.debug(mcMMO.p.getLogger(), "Loading mcMMO " + fileName + " File...");
}
config = YamlConfiguration.loadConfiguration(configFile);
@@ -76,7 +77,7 @@ public abstract class LegacyConfigLoader {
protected void validate() {
if (validateKeys()) {
- mcMMO.p.debug("No errors found in " + fileName + "!");
+ LogUtils.debug(mcMMO.p.getLogger(), "No errors found in " + fileName + "!");
} else {
mcMMO.p.getLogger().warning("Errors were found in " + fileName + "! mcMMO was disabled!");
mcMMO.p.getServer().getPluginManager().disablePlugin(mcMMO.p);
diff --git a/src/main/java/com/gmail/nossr50/config/RankConfig.java b/src/main/java/com/gmail/nossr50/config/RankConfig.java
index 01f291b7b..d892ecda4 100644
--- a/src/main/java/com/gmail/nossr50/config/RankConfig.java
+++ b/src/main/java/com/gmail/nossr50/config/RankConfig.java
@@ -3,6 +3,7 @@ package com.gmail.nossr50.config;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
@@ -130,7 +131,7 @@ public class RankConfig extends BukkitConfig {
String key = getRankAddressKey(subSkillType, rank, retroMode);
int defaultValue = defaultYamlConfig.getInt(key);
config.set(key, defaultValue);
- mcMMO.p.getLogger().info(key + " SET -> " + defaultValue);
+ LogUtils.debug(mcMMO.p.getLogger(), key + " SET -> " + defaultValue);
}
/**
@@ -147,10 +148,10 @@ public class RankConfig extends BukkitConfig {
if (badSkillSetup.isEmpty())
return;
- mcMMO.p.getLogger().info("(FIXING CONFIG) mcMMO is correcting a few mistakes found in your skill rank config setup");
+ LogUtils.debug(mcMMO.p.getLogger(), "(FIXING CONFIG) mcMMO is correcting a few mistakes found in your skill rank config setup");
for (SubSkillType subSkillType : badSkillSetup) {
- mcMMO.p.getLogger().info("(FIXING CONFIG) Resetting rank config settings for skill named - " + subSkillType.toString());
+ LogUtils.debug(mcMMO.p.getLogger(), "(FIXING CONFIG) Resetting rank config settings for skill named - " + subSkillType.toString());
fixBadEntries(subSkillType);
}
}
@@ -178,7 +179,7 @@ public class RankConfig extends BukkitConfig {
if (prevRank > curRank) {
//We're going to allow this but we're going to warn them
- mcMMO.p.getLogger().info("(CONFIG ISSUE) You have the ranks for the subskill " + subSkillType + " set up poorly, sequential ranks should have ascending requirements");
+ LogUtils.debug(mcMMO.p.getLogger(), "(CONFIG ISSUE) You have the ranks for the subskill " + subSkillType + " set up poorly, sequential ranks should have ascending requirements");
badSkillSetup.add(subSkillType);
}
}
diff --git a/src/main/java/com/gmail/nossr50/config/SoundConfig.java b/src/main/java/com/gmail/nossr50/config/SoundConfig.java
index e19ad7f44..407b8ef1a 100644
--- a/src/main/java/com/gmail/nossr50/config/SoundConfig.java
+++ b/src/main/java/com/gmail/nossr50/config/SoundConfig.java
@@ -1,6 +1,7 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.sounds.SoundType;
public class SoundConfig extends BukkitConfig {
@@ -28,14 +29,14 @@ public class SoundConfig extends BukkitConfig {
protected boolean validateKeys() {
for (SoundType soundType : SoundType.values()) {
if (config.getDouble("Sounds." + soundType.toString() + ".Volume") < 0) {
- mcMMO.p.getLogger().info("[mcMMO] Sound volume cannot be below 0 for " + soundType);
+ LogUtils.debug(mcMMO.p.getLogger(), "[mcMMO] Sound volume cannot be below 0 for " + soundType);
return false;
}
//Sounds with custom pitching don't use pitch values
if (!soundType.usesCustomPitch()) {
if (config.getDouble("Sounds." + soundType + ".Pitch") < 0) {
- mcMMO.p.getLogger().info("[mcMMO] Sound pitch cannot be below 0 for " + soundType);
+ LogUtils.debug(mcMMO.p.getLogger(), "[mcMMO] Sound pitch cannot be below 0 for " + soundType);
return false;
}
}
diff --git a/src/main/java/com/gmail/nossr50/config/WorldBlacklist.java b/src/main/java/com/gmail/nossr50/config/WorldBlacklist.java
index 44ec42530..7b93ebd89 100644
--- a/src/main/java/com/gmail/nossr50/config/WorldBlacklist.java
+++ b/src/main/java/com/gmail/nossr50/config/WorldBlacklist.java
@@ -73,7 +73,8 @@ public class WorldBlacklist {
closeRead(fileReader);
}
- plugin.getLogger().info(blacklist.size() + " entries in mcMMO World Blacklist");
+ if(blacklist.size() > 0)
+ plugin.getLogger().info(blacklist.size() + " entries in mcMMO World Blacklist");
}
private void closeRead(Reader reader) {
diff --git a/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java b/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java
index e8dd1a41c..3b21589c6 100644
--- a/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java
+++ b/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java
@@ -3,6 +3,7 @@ package com.gmail.nossr50.config.skills.alchemy;
import com.gmail.nossr50.config.LegacyConfigLoader;
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Material;
@@ -100,7 +101,7 @@ public class PotionConfig extends LegacyConfigLoader {
}
}
- mcMMO.p.debug("Loaded " + pass + " Alchemy potions, skipped " + fail + ".");
+ LogUtils.debug(mcMMO.p.getLogger(), "Loaded " + pass + " Alchemy potions, skipped " + fail + ".");
}
/**
diff --git a/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java b/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java
index 85e8c9431..1df5de82c 100644
--- a/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java
+++ b/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java
@@ -7,6 +7,7 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
import com.gmail.nossr50.util.ItemUtils;
+import com.gmail.nossr50.util.LogUtils;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
@@ -48,7 +49,7 @@ public class RepairConfig extends BukkitConfig {
Material itemMaterial = Material.matchMaterial(key);
if (itemMaterial == null) {
- //mcMMO.p.getLogger().info("No support for repair item "+key+ " in this version of Minecraft, skipping.");
+ //LogUtils.debug(mcMMO.p.getLogger(), "No support for repair item "+key+ " in this version of Minecraft, skipping.");
notSupported.add(key); //Collect names of unsupported items
continue;
}
@@ -160,8 +161,8 @@ public class RepairConfig extends BukkitConfig {
}
}
- mcMMO.p.getLogger().info(stringBuilder.toString());
- mcMMO.p.getLogger().info("Items using materials that are not supported will simply be skipped.");
+ LogUtils.debug(mcMMO.p.getLogger(), stringBuilder.toString());
+ LogUtils.debug(mcMMO.p.getLogger(), "Items using materials that are not supported will simply be skipped.");
}
}
diff --git a/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java b/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java
index 0900cebcc..fdcdee3f7 100644
--- a/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java
+++ b/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java
@@ -8,6 +8,7 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
import com.gmail.nossr50.skills.salvage.salvageables.SalvageableFactory;
import com.gmail.nossr50.util.ItemUtils;
+import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
@@ -15,6 +16,7 @@ import org.bukkit.inventory.ItemStack;
import java.io.IOException;
import java.util.*;
+import java.util.logging.Level;
public class SalvageConfig extends BukkitConfig {
private final HashSet notSupported;
@@ -41,7 +43,7 @@ public class SalvageConfig extends BukkitConfig {
//Original version of 1.16 support had maximum quantities that were bad, this fixes it
if (mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.FIX_NETHERITE_SALVAGE_QUANTITIES)) {
- mcMMO.p.getLogger().info("Fixing incorrect Salvage quantities on Netherite gear, this will only run once...");
+ mcMMO.p.getLogger().log(Level.INFO, "Fixing incorrect Salvage quantities on Netherite gear, this will only run once...");
for (String namespacedkey : mcMMO.getMaterialMapStore().getNetheriteArmor()) {
config.set("Salvageables." + namespacedkey.toUpperCase() + ".MaximumQuantity", 4); //TODO: Doesn't make sense to default to 4 for everything
}
@@ -49,9 +51,9 @@ public class SalvageConfig extends BukkitConfig {
try {
config.save(getFile());
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.FIX_NETHERITE_SALVAGE_QUANTITIES);
- mcMMO.p.getLogger().info("Fixed incorrect Salvage quantities for Netherite gear!");
+ LogUtils.debug(mcMMO.p.getLogger(), "Fixed incorrect Salvage quantities for Netherite gear!");
} catch (IOException e) {
- mcMMO.p.getLogger().info("Unable to fix Salvage config, please delete the salvage yml file to generate a new one.");
+ LogUtils.debug(mcMMO.p.getLogger(), "Unable to fix Salvage config, please delete the salvage yml file to generate a new one.");
e.printStackTrace();
}
}
@@ -178,8 +180,8 @@ public class SalvageConfig extends BukkitConfig {
}
}
- mcMMO.p.getLogger().info(stringBuilder.toString());
- mcMMO.p.getLogger().info("Items using materials that are not supported will simply be skipped.");
+ LogUtils.debug(mcMMO.p.getLogger(), stringBuilder.toString());
+ LogUtils.debug(mcMMO.p.getLogger(), "Items using materials that are not supported will simply be skipped.");
}
}
diff --git a/src/main/java/com/gmail/nossr50/config/treasure/FishingTreasureConfig.java b/src/main/java/com/gmail/nossr50/config/treasure/FishingTreasureConfig.java
index 4239d8803..a02e0bd3f 100755
--- a/src/main/java/com/gmail/nossr50/config/treasure/FishingTreasureConfig.java
+++ b/src/main/java/com/gmail/nossr50/config/treasure/FishingTreasureConfig.java
@@ -4,6 +4,7 @@ import com.gmail.nossr50.config.BukkitConfig;
import com.gmail.nossr50.datatypes.treasure.*;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.EnchantmentUtils;
+import com.gmail.nossr50.util.LogUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
@@ -332,7 +333,7 @@ public class FishingTreasureConfig extends BukkitConfig {
}
if (!foundMatch) {
- mcMMO.p.getLogger().info("[Fishing Treasure Init] Could not find any enchantments which matched the user defined enchantment named: " + str);
+ LogUtils.debug(mcMMO.p.getLogger(), "[Fishing Treasure Init] Could not find any enchantments which matched the user defined enchantment named: " + str);
}
}
}
diff --git a/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java b/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java
index 7ebf53ae7..97967a131 100755
--- a/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java
+++ b/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java
@@ -4,6 +4,8 @@ import com.gmail.nossr50.config.BukkitConfig;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.BlockUtils;
+import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.text.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@@ -227,7 +229,7 @@ public class TreasureConfig extends BukkitConfig {
for (String dropper : dropList) {
if (dropper.equals("Bushes")) {
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.FERN), hylianTreasure);
- AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.TALL_GRASS), hylianTreasure);
+ AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(BlockUtils.getShortGrass()), hylianTreasure);
for (Material species : Tag.SAPLINGS.getValues())
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(species), hylianTreasure);
@@ -272,14 +274,14 @@ public class TreasureConfig extends BukkitConfig {
case LEGACY:
int legacyDropLevel = getWrongKeyValue(type, treasureName, conversionType); //Legacy only had one value, Retro Mode didn't have a setting
//Config needs to be updated to be more specific
- mcMMO.p.getLogger().info("(" + treasureName + ") [Fixing bad address: Legacy] Converting Drop_Level to Level_Requirement in treasures.yml for treasure to match new expected format");
+ LogUtils.debug(mcMMO.p.getLogger(), "(" + treasureName + ") [Fixing bad address: Legacy] Converting Drop_Level to Level_Requirement in treasures.yml for treasure to match new expected format");
config.set(type + "." + treasureName + LEGACY_DROP_LEVEL, null); //Remove legacy entry
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_RETRO_MODE, legacyDropLevel * 10); //Multiply by 10 for Retro
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_STANDARD_MODE, legacyDropLevel);
shouldWeUpdateTheFile = true;
break;
case WRONG_KEY_STANDARD:
- mcMMO.p.getLogger().info("(" + treasureName + ") [Fixing bad address: STANDARD] Converting Drop_Level to Level_Requirement in treasures.yml for treasure to match new expected format");
+ LogUtils.debug(mcMMO.p.getLogger(), "(" + treasureName + ") [Fixing bad address: STANDARD] Converting Drop_Level to Level_Requirement in treasures.yml for treasure to match new expected format");
int wrongKeyValueStandard = getWrongKeyValue(type, treasureName, conversionType);
config.set(type + "." + treasureName + WRONG_KEY_ROOT, null); //We also kill the Retro key here as we have enough information for setting in values if needed
@@ -291,7 +293,7 @@ public class TreasureConfig extends BukkitConfig {
shouldWeUpdateTheFile = true;
break;
case WRONG_KEY_RETRO:
- mcMMO.p.getLogger().info("(" + treasureName + ") [Fixing bad address: RETRO] Converting Drop_Level to Level_Requirement in treasures.yml for treasure to match new expected format");
+ LogUtils.debug(mcMMO.p.getLogger(), "(" + treasureName + ") [Fixing bad address: RETRO] Converting Drop_Level to Level_Requirement in treasures.yml for treasure to match new expected format");
int wrongKeyValueRetro = getWrongKeyValue(type, treasureName, conversionType);
config.set(type + "." + treasureName + WRONG_KEY_ROOT, null); //We also kill the Retro key here as we have enough information for setting in values if needed
diff --git a/src/main/java/com/gmail/nossr50/database/DatabaseManagerFactory.java b/src/main/java/com/gmail/nossr50/database/DatabaseManagerFactory.java
index 1e30c6819..cb5025f6f 100644
--- a/src/main/java/com/gmail/nossr50/database/DatabaseManagerFactory.java
+++ b/src/main/java/com/gmail/nossr50/database/DatabaseManagerFactory.java
@@ -2,6 +2,7 @@ package com.gmail.nossr50.database;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -16,14 +17,14 @@ public class DatabaseManagerFactory {
return createDefaultCustomDatabaseManager();
}
catch (Exception e) {
- mcMMO.p.debug("Could not create custom database manager");
+ LogUtils.debug(mcMMO.p.getLogger(), "Could not create custom database manager");
e.printStackTrace();
}
catch (Throwable e) {
- mcMMO.p.debug("Failed to create custom database manager");
+ LogUtils.debug(mcMMO.p.getLogger(), "Failed to create custom database manager");
e.printStackTrace();
}
- mcMMO.p.debug("Falling back on " + (mcMMO.p.getGeneralConfig().getUseMySQL() ? "SQL" : "Flatfile") + " database");
+ LogUtils.debug(mcMMO.p.getLogger(), "Falling back on " + (mcMMO.p.getGeneralConfig().getUseMySQL() ? "SQL" : "Flatfile") + " database");
}
return mcMMO.p.getGeneralConfig().getUseMySQL() ? new SQLDatabaseManager() : new FlatFileDatabaseManager(userFilePath, logger, purgeTime, startingLevel);
@@ -62,16 +63,16 @@ public class DatabaseManagerFactory {
public static @Nullable DatabaseManager createDatabaseManager(@NotNull DatabaseType type, @NotNull String userFilePath, @NotNull Logger logger, long purgeTime, int startingLevel) {
switch (type) {
case FLATFILE:
- mcMMO.p.getLogger().info("Using FlatFile Database");
+ LogUtils.debug(mcMMO.p.getLogger(), "Using FlatFile Database");
return new FlatFileDatabaseManager(userFilePath, logger, purgeTime, startingLevel);
case SQL:
- mcMMO.p.getLogger().info("Using SQL Database");
+ LogUtils.debug(mcMMO.p.getLogger(), "Using SQL Database");
return new SQLDatabaseManager();
case CUSTOM:
try {
- mcMMO.p.getLogger().info("Attempting to use Custom Database");
+ LogUtils.debug(mcMMO.p.getLogger(), "Attempting to use Custom Database");
return createDefaultCustomDatabaseManager();
}
catch (Throwable e) {
diff --git a/src/main/java/com/gmail/nossr50/database/FlatFileDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/FlatFileDatabaseManager.java
index cc473e13d..e547ab964 100644
--- a/src/main/java/com/gmail/nossr50/database/FlatFileDatabaseManager.java
+++ b/src/main/java/com/gmail/nossr50/database/FlatFileDatabaseManager.java
@@ -9,6 +9,7 @@ import com.gmail.nossr50.datatypes.player.UniqueDataType;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.SkillTools;
import org.bukkit.OfflinePlayer;
@@ -121,7 +122,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
public int purgePowerlessUsers() {
int purgedUsers = 0;
- logger.info("Purging powerless users...");
+ LogUtils.debug(logger, "Purging powerless users...");
BufferedReader in = null;
FileWriter out = null;
@@ -189,7 +190,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
int removedPlayers = 0;
long currentTime = System.currentTimeMillis();
- logger.info("Purging old users...");
+ LogUtils.debug(logger, "Purging old users...");
BufferedReader in = null;
FileWriter out = null;
@@ -203,7 +204,8 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
while ((line = in.readLine()) != null) {
String[] character = line.split(":");
- String name = character[USERNAME_INDEX];
+ String uuidString = character[UUID_INDEX];
+ UUID uuid = UUID.fromString(uuidString);
long lastPlayed = 0;
boolean rewrite = false;
@@ -214,7 +216,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
}
if (lastPlayed == -1) {
- OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(name);
+ OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(uuid);
if(player.getLastPlayed() != 0) {
lastPlayed = player.getLastPlayed();
@@ -222,7 +224,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
}
}
- if (lastPlayed != -1 && lastPlayed != 0 && currentTime - lastPlayed > purgeTime) {
+ if (lastPlayed < 1 && (currentTime - lastPlayed > purgeTime)) {
removedPlayers++;
} else {
if (rewrite) {
@@ -723,7 +725,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
boolean matchingName = dbPlayerName.equalsIgnoreCase(playerName);
if (!matchingName) {
- logger.info("When loading user: "+playerName +" with UUID of (" + uuid.toString()
+ logger.warning("When loading user: "+playerName +" with UUID of (" + uuid.toString()
+") we found a mismatched name, the name in the DB will be replaced (DB name: "+dbPlayerName+")");
//logger.info("Name updated for player: " + rawSplitData[USERNAME_INDEX] + " => " + playerName);
rawSplitData[USERNAME_INDEX] = playerName;
@@ -848,7 +850,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
logger.severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e);
}
finally {
- logger.info(i + " entries written while saving UUID for " + userName);
+ LogUtils.debug(logger, i + " entries written while saving UUID for " + userName);
if (in != null) {
try {
in.close();
@@ -906,7 +908,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
logger.severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e);
}
finally {
- logger.info(i + " entries written while saving UUID batch");
+ LogUtils.debug(logger, i + " entries written while saving UUID batch");
if (in != null) {
try {
in.close();
@@ -1108,7 +1110,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
public @Nullable List checkFileHealthAndStructure() {
ArrayList flagsFound = null;
- logger.info("(" + usersFile.getPath() + ") Validating database file..");
+ LogUtils.debug(logger, "(" + usersFile.getPath() + ") Validating database file..");
FlatFileDataProcessor dataProcessor = null;
if (usersFile.exists()) {
@@ -1143,7 +1145,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
//Only update the file if needed
if(dataProcessor.getFlatFileDataFlags().size() > 0) {
flagsFound = new ArrayList<>(dataProcessor.getFlatFileDataFlags());
- logger.info("Saving the updated and or repaired FlatFile Database...");
+ logger.info("Updating FlatFile Database...");
fileWriter = new FileWriter(usersFilePath);
//Write data to file
if(dbCommentDate != null)
diff --git a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java
index 9d32407d8..0be013e7e 100644
--- a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java
+++ b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java
@@ -11,13 +11,13 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.database.UUIDUpdateAsyncTask;
+import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.SkillTools;
import org.apache.tomcat.jdbc.pool.DataSource;
import org.apache.tomcat.jdbc.pool.PoolProperties;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -1013,7 +1013,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
*/
private void checkDatabaseStructure(Connection connection, UpgradeType upgrade) {
if (!mcMMO.getUpgradeManager().shouldUpgrade(upgrade)) {
- mcMMO.p.debug("Skipping " + upgrade.name() + " upgrade (unneeded)");
+ LogUtils.debug(mcMMO.p.getLogger(), "Skipping " + upgrade.name() + " upgrade (unneeded)");
return;
}
@@ -1355,7 +1355,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");
- new GetUUIDUpdatesRequired().runTaskLaterAsynchronously(mcMMO.p, 100); // wait until after first purge
+ mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new GetUUIDUpdatesRequired(), 100); // wait until after first purge
}
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS);
@@ -1368,7 +1368,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
}
- private class GetUUIDUpdatesRequired extends BukkitRunnable {
+ private class GetUUIDUpdatesRequired implements Runnable {
public void run() {
massUpdateLock.lock();
List names = new ArrayList<>();
@@ -1577,7 +1577,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
@Override
public void onDisable() {
- mcMMO.p.debug("Releasing connection pool resource...");
+ LogUtils.debug(mcMMO.p.getLogger(), "Releasing connection pool resource...");
miscPool.close();
loadPool.close();
savePool.close();
diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java
index 71bdbccb5..5d6aa9e5b 100644
--- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java
+++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java
@@ -957,7 +957,7 @@ public class McMMOPlayer implements Identified {
}
setToolPreparationMode(tool, false);
- new AbilityDisableTask(this, superAbilityType).runTaskLater(mcMMO.p, (long) ticks * Misc.TICK_CONVERSION_FACTOR);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new AbilityDisableTask(this, superAbilityType), (long) ticks * Misc.TICK_CONVERSION_FACTOR);
}
public void processAbilityActivation(@NotNull PrimarySkillType primarySkillType) {
@@ -1019,7 +1019,7 @@ public class McMMOPlayer implements Identified {
}
setToolPreparationMode(tool, true);
- new ToolLowerTask(this, tool).runTaskLater(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new ToolLowerTask(this, tool), 4 * Misc.TICK_CONVERSION_FACTOR);
}
}
diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java
index 976ee3434..65ebf4c85 100644
--- a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java
+++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java
@@ -102,16 +102,16 @@ public class PlayerProfile {
}
public void scheduleAsyncSave() {
- new PlayerProfileSaveTask(this, false).runTaskAsynchronously(mcMMO.p);
+ mcMMO.p.getFoliaLib().getImpl().runAsync(new PlayerProfileSaveTask(this, false));
}
public void scheduleAsyncSaveDelay() {
- new PlayerProfileSaveTask(this, false).runTaskLaterAsynchronously(mcMMO.p, 20);
+ mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileSaveTask(this, false), 20);
}
@Deprecated
public void scheduleSyncSaveDelay() {
- new PlayerProfileSaveTask(this, true).runTaskLater(mcMMO.p, 20);
+ mcMMO.p.getFoliaLib().getImpl().runLater(new PlayerProfileSaveTask(this, true), 20);
}
public void save(boolean useSync) {
@@ -138,7 +138,7 @@ public class PlayerProfile {
//Back out of async saving if we detect a server shutdown, this is not always going to be caught
if(mcMMO.isServerShutdownExecuted() || useSync)
- new PlayerProfileSaveTask(this, true).runTask(mcMMO.p);
+ mcMMO.p.getFoliaLib().getImpl().runNextTick(new PlayerProfileSaveTask(this, true));
else
scheduleAsyncSave();
diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java
index 433d9f2b9..945277c67 100644
--- a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java
+++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java
@@ -45,7 +45,7 @@ public enum SubSkillType {
FISHING_MAGIC_HUNTER(1),
FISHING_MASTER_ANGLER(8),
FISHING_TREASURE_HUNTER(8),
- FISHING_SHAKE(1),
+ FISHING_SHAKE(8),
/* Herbalism */
HERBALISM_DOUBLE_DROPS(1),
diff --git a/src/main/java/com/gmail/nossr50/datatypes/treasure/FishingTreasureBook.java b/src/main/java/com/gmail/nossr50/datatypes/treasure/FishingTreasureBook.java
index 8f89f7484..69feb7b9b 100644
--- a/src/main/java/com/gmail/nossr50/datatypes/treasure/FishingTreasureBook.java
+++ b/src/main/java/com/gmail/nossr50/datatypes/treasure/FishingTreasureBook.java
@@ -1,6 +1,7 @@
package com.gmail.nossr50.datatypes.treasure;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
@@ -26,7 +27,7 @@ public class FishingTreasureBook extends FishingTreasure {
}
private void initLegalEnchantments() {
- mcMMO.p.getLogger().info("Registering enchantments for Fishing Book...");
+ LogUtils.debug(mcMMO.p.getLogger(), "Registering enchantments for Fishing Book...");
for(Enchantment enchantment : Enchantment.values()) {
if(isEnchantAllowed(enchantment)) {
diff --git a/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerNotificationEvent.java b/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerNotificationEvent.java
index 1b0c17949..75d8eae83 100644
--- a/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerNotificationEvent.java
+++ b/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerNotificationEvent.java
@@ -27,8 +27,13 @@ public class McMMOPlayerNotificationEvent extends Event implements Cancellable {
protected Component notificationTextComponent;
protected final NotificationType notificationType;
- public McMMOPlayerNotificationEvent(Player who, NotificationType notificationType, Component notificationTextComponent, McMMOMessageType chatMessageType, boolean isMessageAlsoBeingSentToChat) {
+ protected final Player player;
+
+ public McMMOPlayerNotificationEvent(Player player, NotificationType notificationType,
+ Component notificationTextComponent, McMMOMessageType chatMessageType,
+ boolean isMessageAlsoBeingSentToChat) {
super(false);
+ this.player = player;
this.notificationType = notificationType;
this.notificationTextComponent = notificationTextComponent;
this.chatMessageType = chatMessageType;
@@ -48,6 +53,10 @@ public class McMMOPlayerNotificationEvent extends Event implements Cancellable {
isMessageAlsoBeingSentToChat = messageAlsoBeingSentToChat;
}
+ public Player getPlayer() {
+ return player;
+ }
+
public Component getNotificationTextComponent() {
return notificationTextComponent;
}
diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java
index af7201460..63585b917 100644
--- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java
+++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java
@@ -134,14 +134,16 @@ public class BlockListener implements Listener {
return;
}
- BlockFace direction = event.getDirection();
- Block movedBlock;
- for (Block block : event.getBlocks()) {
- movedBlock = block.getRelative(direction);
+ final BlockFace direction = event.getDirection();
- if(BlockUtils.isWithinWorldBounds(movedBlock)) {
- BlockUtils.setUnnaturalBlock(block);
- }
+ for (final Block block : event.getBlocks()) {
+ mcMMO.p.getFoliaLib().getImpl().runAtLocation(block.getLocation(), t -> {
+ final Block movedBlock = block.getRelative(direction);
+
+ if (BlockUtils.isWithinWorldBounds(movedBlock)) {
+ BlockUtils.setUnnaturalBlock(movedBlock);
+ }
+ });
}
}
diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java
index b66728c83..7da526414 100644
--- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java
+++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java
@@ -217,7 +217,7 @@ public class EntityListener implements Listener {
entity.setMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK, MetadataConstants.MCMMO_METADATA_VALUE);
TravelingBlockMetaCleanup metaCleanupTask = new TravelingBlockMetaCleanup(entity, pluginRef);
- metaCleanupTask.runTaskTimer(pluginRef, 20, 20*60); //6000 ticks is 5 minutes
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityTimer(entity, metaCleanupTask, 20, 20*60); //6000 ticks is 5 minutes
}
else if (isTracked) {
BlockUtils.setUnnaturalBlock(block);
diff --git a/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java b/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java
index 48a8faff2..348ba2af0 100644
--- a/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java
+++ b/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java
@@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.InteractType;
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.Interaction;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import org.bukkit.event.Event;
import java.util.ArrayList;
@@ -52,7 +53,7 @@ public class InteractionManager {
//Register in name map
subSkillNameMap.putIfAbsent(lowerCaseName, abstractSubSkill);
- mcMMO.p.getLogger().info("Registered subskill: "+ abstractSubSkill.getConfigKeyName());
+ LogUtils.debug(mcMMO.p.getLogger(), "Registered subskill: "+ abstractSubSkill.getConfigKeyName());
}
/**
diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java
index 6be0eb357..4467ff723 100644
--- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java
+++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java
@@ -439,7 +439,7 @@ public class InventoryListener implements Listener {
return;
}
- new PlayerUpdateInventoryTask((Player) whoClicked).runTaskLater(plugin, 0);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntity(whoClicked, new PlayerUpdateInventoryTask((Player) whoClicked));
}
}
diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java
index 8246ffd4f..a63b7650e 100644
--- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java
+++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java
@@ -49,7 +49,6 @@ import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.*;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.scheduler.BukkitRunnable;
import java.util.Locale;
@@ -149,12 +148,7 @@ public class PlayerListener implements Listener {
new MobHealthDisplayUpdaterTask(attacker).run();
// set the name back
- new BukkitRunnable() {
- @Override
- public void run() {
- MobHealthbarUtils.handleMobHealthbars(attacker, 0, mcMMO.p);
- }
- }.runTaskLater(mcMMO.p, 1);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(attacker, () -> MobHealthbarUtils.handleMobHealthbars(attacker, 0, mcMMO.p), 1);
}
/**
@@ -595,7 +589,7 @@ public class PlayerListener implements Listener {
Player player = event.getPlayer();
//Delay loading for 3 seconds in case the player has a save task running, its hacky but it should do the trick
- new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 60);
+ mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileLoadingTask(player), 60);
if (mcMMO.p.getGeneralConfig().getMOTDEnabled() && Permissions.motd(player)) {
Motd.displayAll(player);
@@ -958,8 +952,8 @@ public class PlayerListener implements Listener {
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(player);
if (mcMMOPlayer == null) {
- mcMMO.p.debug(player.getName() + "is chatting, but is currently not logged in to the server.");
- mcMMO.p.debug("Party & Admin chat will not work properly for this player.");
+ LogUtils.debug(mcMMO.p.getLogger(), player.getName() + "is chatting, but is currently not logged in to the server.");
+ LogUtils.debug(mcMMO.p.getLogger(), "Party & Admin chat will not work properly for this player.");
return;
}
diff --git a/src/main/java/com/gmail/nossr50/listeners/WorldListener.java b/src/main/java/com/gmail/nossr50/listeners/WorldListener.java
index d8553f80e..4c24930c6 100644
--- a/src/main/java/com/gmail/nossr50/listeners/WorldListener.java
+++ b/src/main/java/com/gmail/nossr50/listeners/WorldListener.java
@@ -2,7 +2,6 @@ package com.gmail.nossr50.listeners;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.mcMMO;
-import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.block.BlockState;
import org.bukkit.event.EventHandler;
@@ -30,7 +29,8 @@ public class WorldListener implements Listener {
if(WorldBlacklist.isWorldBlacklisted(event.getWorld()))
return;
- Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, () -> {
+ // Using 50 ms later as I do not know of a way to run one tick later (safely)
+ plugin.getFoliaLib().getImpl().runLater(() -> {
for (BlockState blockState : event.getBlocks()) {
mcMMO.getPlaceStore().setFalse(blockState);
}
diff --git a/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java b/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java
index 38944f720..20b5e2631 100644
--- a/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java
+++ b/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java
@@ -1,6 +1,7 @@
package com.gmail.nossr50.locale;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.text.TextUtils;
import net.kyori.adventure.text.TextComponent;
import org.bukkit.ChatColor;
@@ -192,7 +193,7 @@ public final class LocaleLoader {
//Use the new locale file
if (Files.exists(overridePath) && Files.isRegularFile(overridePath)) {
try (Reader localeReader = Files.newBufferedReader(overridePath)) {
- mcMMO.p.getLogger().log(Level.INFO, "Loading locale from {0}", overridePath);
+ LogUtils.debug(mcMMO.p.getLogger(), "Loading locale from " + overridePath.toString());
filesystemBundle = new PropertyResourceBundle(localeReader);
} catch (IOException e) {
mcMMO.p.getLogger().log(Level.WARNING, "Failed to load locale from " + overridePath, e);
diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java
index 78b5b937b..f6e96c3fb 100644
--- a/src/main/java/com/gmail/nossr50/mcMMO.java
+++ b/src/main/java/com/gmail/nossr50/mcMMO.java
@@ -20,6 +20,7 @@ import com.gmail.nossr50.datatypes.skills.subskills.acrobatics.Roll;
import com.gmail.nossr50.listeners.*;
import com.gmail.nossr50.metadata.MetadataService;
import com.gmail.nossr50.party.PartyManager;
+import com.gmail.nossr50.placeholders.PapiExpansion;
import com.gmail.nossr50.runnables.SaveTimerTask;
import com.gmail.nossr50.runnables.backups.CleanBackupsTask;
import com.gmail.nossr50.runnables.commands.NotifySquelchReminderTask;
@@ -52,6 +53,8 @@ import com.gmail.nossr50.util.skills.SkillTools;
import com.gmail.nossr50.util.skills.SmeltingTracker;
import com.gmail.nossr50.util.upgrade.UpgradeManager;
import com.gmail.nossr50.worldguard.WorldGuardManager;
+import com.tcoded.folialib.FoliaLib;
+import com.tcoded.folialib.util.InvalidTickDelayNotifier;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.shatteredlands.shatt.backup.ZipLibrary;
import org.bstats.bukkit.Metrics;
@@ -136,6 +139,9 @@ public class mcMMO extends JavaPlugin {
private GeneralConfig generalConfig;
private AdvancedConfig advancedConfig;
+
+ private FoliaLib foliaLib;
+
// private RepairConfig repairConfig;
// private SalvageConfig salvageConfig;
// private PersistentDataConfig persistentDataConfig;
@@ -163,6 +169,13 @@ public class mcMMO extends JavaPlugin {
@Override
public void onEnable() {
try {
+ //Filter out any debug messages (if debug/verbose logging is not enabled)
+ getLogger().setFilter(new LogFilter(this));
+
+ //Folia lib plugin instance
+ foliaLib = new FoliaLib(this);
+ InvalidTickDelayNotifier.disableNotifications = true;
+
setupFilePaths();
generalConfig = new GeneralConfig(getDataFolder()); //Load before skillTools
skillTools = new SkillTools(this); //Load after general config
@@ -179,9 +192,6 @@ public class mcMMO extends JavaPlugin {
//metadata service
metadataService = new MetadataService(this);
- //Filter out any debug messages (if debug/verbose logging is not enabled)
- getLogger().setFilter(new LogFilter(this));
-
MetadataConstants.MCMMO_METADATA_VALUE = new FixedMetadataValue(this, true);
PluginManager pluginManager = getServer().getPluginManager();
@@ -190,7 +200,6 @@ public class mcMMO extends JavaPlugin {
upgradeManager = new UpgradeManager();
-
modManager = new ModManager();
//Init Material Maps
@@ -229,18 +238,21 @@ public class mcMMO extends JavaPlugin {
if(serverAPIOutdated)
{
- Bukkit
- .getScheduler()
- .scheduleSyncRepeatingTask(this,
+ foliaLib
+ .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, 20*60*30);
+ 20, 20*60*30
+ );
if(platformManager.getServerSoftware() == ServerSoftwareType.CRAFT_BUKKIT)
{
- Bukkit.getScheduler()
- .scheduleSyncRepeatingTask(this,
+ foliaLib
+ .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, 20*60*30);
+ 20, 20*60*30
+ );
}
} else {
registerEvents();
@@ -252,10 +264,10 @@ public class mcMMO extends JavaPlugin {
formulaManager = new FormulaManager();
for (Player player : getServer().getOnlinePlayers()) {
- new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
+ getFoliaLib().getImpl().runLaterAsync(new PlayerProfileLoadingTask(player), 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
- debug("Version " + getDescription().getVersion() + " is enabled!");
+ LogUtils.debug(mcMMO.p.getLogger(), "Version " + getDescription().getVersion() + " is enabled!");
scheduleTasks();
CommandRegistrationManager.registerCommands();
@@ -282,9 +294,7 @@ public class mcMMO extends JavaPlugin {
else
metrics.addCustomChart(new SimplePie("leveling_system", () -> "Standard"));
}
- }
-
- catch (Throwable t) {
+ } catch (Throwable t) {
getLogger().severe("There was an error while enabling mcMMO!");
if (!(t instanceof ExceptionInInitializerError)) {
@@ -320,6 +330,10 @@ public class mcMMO extends JavaPlugin {
transientEntityTracker = new TransientEntityTracker();
setServerShutdown(false); //Reset flag, used to make decisions about async saves
+
+ if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
+ new PapiExpansion().register();
+ }
}
public static PlayerLevelUtils getPlayerLevelUtils() {
@@ -388,13 +402,13 @@ public class mcMMO extends JavaPlugin {
}
}
- debug("Canceling all tasks...");
- getServer().getScheduler().cancelTasks(this); // This removes our tasks
- debug("Unregister all events...");
+ LogUtils.debug(mcMMO.p.getLogger(), "Canceling all tasks...");
+ getFoliaLib().getImpl().cancelAllTasks(); // This removes our tasks
+ LogUtils.debug(mcMMO.p.getLogger(), "Unregister all events...");
HandlerList.unregisterAll(this); // Cancel event registrations
databaseManager.onDisable();
- debug("Was disabled."); // How informative!
+ LogUtils.debug(mcMMO.p.getLogger(), "Was disabled."); // How informative!
}
public static String getMainDirectory() {
@@ -429,10 +443,6 @@ public class mcMMO extends JavaPlugin {
xpEventEnabled = !xpEventEnabled;
}
- public void debug(String message) {
- getLogger().info("[Debug] " + message);
- }
-
public static FormulaManager getFormulaManager() {
return formulaManager;
}
@@ -613,7 +623,7 @@ public class mcMMO extends JavaPlugin {
if(CoreSkillsConfig.getInstance().isPrimarySkillEnabled(PrimarySkillType.ACROBATICS))
{
- getLogger().info("Enabling Acrobatics Skills");
+ LogUtils.debug(mcMMO.p.getLogger(), "Enabling Acrobatics Skills");
//TODO: Should do this differently
Roll roll = new Roll();
@@ -623,7 +633,7 @@ public class mcMMO extends JavaPlugin {
}
private void registerCustomRecipes() {
- getServer().getScheduler().scheduleSyncDelayedTask(this, () -> {
+ getFoliaLib().getImpl().runLater(() -> {
if (generalConfig.getChimaeraEnabled()) {
getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe());
}
@@ -637,42 +647,42 @@ public class mcMMO extends JavaPlugin {
long saveIntervalTicks = Math.max(minute, generalConfig.getSaveInterval() * minute);
- new SaveTimerTask().runTaskTimer(this, saveIntervalTicks, saveIntervalTicks);
+ getFoliaLib().getImpl().runTimer(new SaveTimerTask(), saveIntervalTicks, saveIntervalTicks);
// Cleanup the backups folder
- new CleanBackupsTask().runTaskAsynchronously(mcMMO.p);
+ getFoliaLib().getImpl().runAsync(new CleanBackupsTask());
// Old & Powerless User remover
long purgeIntervalTicks = generalConfig.getPurgeInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR;
if (purgeIntervalTicks == 0) {
- new UserPurgeTask().runTaskLaterAsynchronously(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.
+ getFoliaLib().getImpl().runLaterAsync(new UserPurgeTask(), 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.
}
else if (purgeIntervalTicks > 0) {
- new UserPurgeTask().runTaskTimerAsynchronously(this, purgeIntervalTicks, purgeIntervalTicks);
+ getFoliaLib().getImpl().runTimerAsync(new UserPurgeTask(), purgeIntervalTicks, purgeIntervalTicks);
}
// Automatically remove old members from parties
long kickIntervalTicks = generalConfig.getAutoPartyKickInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR;
if (kickIntervalTicks == 0) {
- new PartyAutoKickTask().runTaskLater(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.
+ getFoliaLib().getImpl().runLater(new PartyAutoKickTask(), 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.
}
else if (kickIntervalTicks > 0) {
- new PartyAutoKickTask().runTaskTimer(this, kickIntervalTicks, kickIntervalTicks);
+ getFoliaLib().getImpl().runTimer(new PartyAutoKickTask(), kickIntervalTicks, kickIntervalTicks);
}
// Update power level tag scoreboards
- new PowerLevelUpdatingTask().runTaskTimer(this, 2 * Misc.TICK_CONVERSION_FACTOR, 2 * Misc.TICK_CONVERSION_FACTOR);
+ getFoliaLib().getImpl().runTimer(new PowerLevelUpdatingTask(), 2 * Misc.TICK_CONVERSION_FACTOR, 2 * Misc.TICK_CONVERSION_FACTOR);
// Clear the registered XP data so players can earn XP again
if (ExperienceConfig.getInstance().getDiminishedReturnsEnabled()) {
- new ClearRegisteredXPGainTask().runTaskTimer(this, 60, 60);
+ getFoliaLib().getImpl().runTimer(new ClearRegisteredXPGainTask(), 60, 60);
}
if(mcMMO.p.getAdvancedConfig().allowPlayerTips())
{
- new NotifySquelchReminderTask().runTaskTimer(this, 60, ((20 * 60) * 60));
+ getFoliaLib().getImpl().runTimer(new NotifySquelchReminderTask(), 60, ((20 * 60) * 60));
}
}
@@ -772,4 +782,8 @@ public class mcMMO extends JavaPlugin {
public @NotNull AdvancedConfig getAdvancedConfig() {
return advancedConfig;
}
+
+ public @NotNull FoliaLib getFoliaLib() {
+ return foliaLib;
+ }
}
diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java
index c723dbd50..7bc3afe9b 100644
--- a/src/main/java/com/gmail/nossr50/party/PartyManager.java
+++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java
@@ -12,6 +12,7 @@ import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.NotificationManager;
@@ -644,7 +645,7 @@ public final class PartyManager {
}
}
- mcMMO.p.debug("Loaded (" + parties.size() + ") Parties...");
+ LogUtils.debug(mcMMO.p.getLogger(), "Loaded (" + parties.size() + ") Parties...");
for (Party party : hasAlly) {
party.setAlly(PartyManager.getParty(partiesFile.getString(party.getName() + ".Ally")));
@@ -660,7 +661,7 @@ public final class PartyManager {
* Save party file.
*/
public static void saveParties() {
- mcMMO.p.debug("[Party Data] Saving...");
+ LogUtils.debug(mcMMO.p.getLogger(), "[Party Data] Saving...");
if (partyFile.exists()) {
if (!partyFile.delete()) {
@@ -768,7 +769,7 @@ public final class PartyManager {
// parties.add(party);
// }
//
-// mcMMO.p.debug("Loaded (" + parties.size() + ") Parties...");
+// LogUtils.debug(mcMMO.p.getLogger(), "Loaded (" + parties.size() + ") Parties...");
//
// for (Party party : hasAlly) {
// party.setAlly(PartyManager.getParty(partiesFile.getString(party.getName() + ".Ally")));
diff --git a/src/main/java/com/gmail/nossr50/placeholders/PapiExpansion.java b/src/main/java/com/gmail/nossr50/placeholders/PapiExpansion.java
new file mode 100644
index 000000000..ff7a90cea
--- /dev/null
+++ b/src/main/java/com/gmail/nossr50/placeholders/PapiExpansion.java
@@ -0,0 +1,230 @@
+package com.gmail.nossr50.placeholders;
+
+import com.gmail.nossr50.api.ExperienceAPI;
+import com.gmail.nossr50.config.experience.ExperienceConfig;
+import com.gmail.nossr50.datatypes.party.Party;
+import com.gmail.nossr50.datatypes.player.McMMOPlayer;
+import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
+import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.Permissions;
+import com.gmail.nossr50.util.player.UserManager;
+import com.gmail.nossr50.util.text.StringUtils;
+import me.clip.placeholderapi.PlaceholderAPIPlugin;
+import me.clip.placeholderapi.expansion.PlaceholderExpansion;
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+public class PapiExpansion extends PlaceholderExpansion {
+ private final Map placeholders = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+
+ public PapiExpansion() {
+ init();
+ }
+
+ @Override
+ public String getIdentifier() {
+ return "mcmmo";
+ }
+
+ @Override
+ public String getAuthor() {
+ return "mcMMO Dev Team";
+ }
+
+ @Override
+ public String getVersion() {
+ //grab version from pom.xml
+ return "1.0,0";
+ }
+
+ @Override
+ public String getRequiredPlugin() {
+ return "mcMMO";
+ }
+
+ @Override
+ @Nullable
+ public String onPlaceholderRequest(final Player player, @NotNull final String params) {
+ String token;
+ String data = null;
+ int dataPosition = params.indexOf(":");
+
+ if (dataPosition != -1) {
+ token = params.substring(0, dataPosition);
+ data = params.substring(dataPosition + 1);
+ } else {
+ token = params;
+ }
+
+ Placeholder placeholder = placeholders.get(token);
+
+ if (placeholder != null) {
+ return placeholder.process(player, data);
+ } else {
+ return null;
+ }
+ }
+
+ public Integer getSkillLevel(PrimarySkillType skill, Player player) {
+ final McMMOPlayer user = UserManager.getPlayer(player);
+ if (user == null) return null;
+ return user.getSkillLevel(skill);
+ }
+
+ public Integer getExpNeeded(PrimarySkillType skill, Player player) {
+ final McMMOPlayer user = UserManager.getPlayer(player);
+ if (user == null) return null;
+ return user.getXpToLevel(skill);
+ }
+
+ public Integer getExp(PrimarySkillType skill, Player player) {
+ final McMMOPlayer user = UserManager.getPlayer(player);
+ if (user == null) return null;
+
+ return user.getSkillXpLevel(skill);
+ }
+
+
+ public Integer getExpRemaining(PrimarySkillType skill, Player player) {
+ final McMMOPlayer user = UserManager.getPlayer(player);
+ if (user == null) return null;
+ int current = user.getSkillXpLevel(skill);
+ int needed = user.getXpToLevel(skill);
+
+ return needed - current;
+ }
+
+ public Integer getRank(PrimarySkillType skill, Player player) {
+ try {
+ return ExperienceAPI.getPlayerRankSkill(player.getUniqueId(), StringUtils.getCapitalized(skill.toString()));
+ } catch (Exception ex) {
+ return null;
+ }
+ }
+
+ public Integer getPowerLevel(Player player) {
+ final McMMOPlayer user = UserManager.getPlayer(player);
+ if (user == null) return null;
+ return user.getPowerLevel();
+ }
+
+ public Integer getPowerCap(Player player) {
+ return mcMMO.p.getGeneralConfig().getPowerLevelCap();
+ }
+
+ public String getPartyName(Player player) {
+ final McMMOPlayer user = UserManager.getPlayer(player);
+ if (user == null) return null;
+ final Party party = user.getParty();
+
+ return (party == null) ? null : party.getName();
+ }
+
+ public String getPartyLeader(Player player) {
+ final McMMOPlayer user = UserManager.getPlayer(player);
+ if (user == null) return null;
+ final Party party = user.getParty();
+ return (party == null) ? null : party.getLeader().getPlayerName();
+ }
+
+ public Integer getPartySize(Player player) {
+ final McMMOPlayer user = UserManager.getPlayer(player);
+ if (user == null) return null;
+ final Party party = user.getParty();
+ return (party == null) ? null : party.getMembers().size();
+ }
+
+ public String getXpRate(Player player) {
+ return String.valueOf(ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier());
+ }
+
+ public String getSkillXpRate(PrimarySkillType skill, Player player) {
+ final McMMOPlayer user = UserManager.getPlayer(player);
+ if (user == null) return null;
+
+ double modifier = 1.0F;
+
+ if (Permissions.customXpBoost(player, skill))
+ modifier = ExperienceConfig.getInstance().getCustomXpPerkBoost();
+ else if (Permissions.quadrupleXp(player, skill))
+ modifier = 4;
+ else if (Permissions.tripleXp(player, skill))
+ modifier = 3;
+ else if (Permissions.doubleAndOneHalfXp(player, skill))
+ modifier = 2.5;
+ else if (Permissions.doubleXp(player, skill))
+ modifier = 2;
+ else if (Permissions.oneAndOneHalfXp(player, skill))
+ modifier = 1.5;
+ else if (Permissions.oneAndOneTenthXp(player, skill))
+ modifier = 1.1;
+
+ return String.valueOf(modifier);
+ }
+
+ public String isExpEventActive(Player player) {
+ return mcMMO.p.isXPEventEnabled() ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
+ }
+
+ public void registerPlaceholder(Placeholder placeholder) {
+ final Placeholder registered = placeholders.get(placeholder.getName());
+ if (registered != null)
+ throw new IllegalStateException("Placeholder " + placeholder.getName() + " is already registered!");
+
+ placeholders.put(placeholder.getName(), placeholder);
+ }
+
+ protected void init() {
+
+ for (PrimarySkillType skill : PrimarySkillType.values()) {
+ // %mcmmo_level_%
+ registerPlaceholder(new SkillLevelPlaceholder(this, skill));
+
+ //%mcmmo_xp_needed_%
+ registerPlaceholder(new SkillExpNeededPlaceholder(this, skill));
+
+ //%mcmmo_xp_%
+ registerPlaceholder(new SkillExpPlaceholder(this, skill));
+
+ //%mcmmo_xp_remaining_%
+ registerPlaceholder(new SkillExpRemainingPlaceholder(this, skill));
+
+ //%mcmmo_rank_%
+ registerPlaceholder(new SkillRankPlaceholder(this, skill));
+
+ //%mcmmo_xprate_%
+ registerPlaceholder(new SkillXpRatePlaceholder(this, skill));
+ }
+
+
+ //%mcmmo_power_level%
+ registerPlaceholder(new PowerLevelPlaceholder(this));
+
+ // %mcmmo_power_level_cap%
+ registerPlaceholder(new PowerLevelCapPlaceholder(this));
+
+ // %mcmmo_in_party%
+ registerPlaceholder(new PartyIsMemberPlaceholder(this));
+
+ /// %mcmmo_party_name%
+ registerPlaceholder(new PartyNamePlaceholder(this));
+
+ // %mcmmo_is_party_leader%
+ registerPlaceholder(new PartyIsLeaderPlaceholder(this));
+
+ // %mcmmo_party_leader%
+ registerPlaceholder(new PartyLeaderPlaceholder(this));
+
+ // %mcmmo_party_size%
+ registerPlaceholder(new PartySizePlaceholder(this));
+
+ // %mcmmo_is_xp_event_active%
+ registerPlaceholder(new XpEventActivePlaceholder(this));
+ // %mcmmo_xprate%
+ registerPlaceholder(new XpRatePlaceholder(this));
+ };
+}
diff --git a/src/main/java/com/gmail/nossr50/placeholders/PartyIsLeaderPlaceholder.java b/src/main/java/com/gmail/nossr50/placeholders/PartyIsLeaderPlaceholder.java
new file mode 100644
index 000000000..f10248f20
--- /dev/null
+++ b/src/main/java/com/gmail/nossr50/placeholders/PartyIsLeaderPlaceholder.java
@@ -0,0 +1,29 @@
+package com.gmail.nossr50.placeholders;
+
+import org.bukkit.entity.Player;
+
+public class PartyIsLeaderPlaceholder implements Placeholder {
+
+ private final PapiExpansion papiExpansion;
+
+ public PartyIsLeaderPlaceholder(PapiExpansion papiExpansion) {
+ this.papiExpansion = papiExpansion;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String process(Player player, String params) {
+ String leader = papiExpansion.getPartyLeader(player);
+ return (leader.equals(player.getName())) ? "true" : "false";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getName() {
+ return "is_party_leader";
+ }
+}
diff --git a/src/main/java/com/gmail/nossr50/placeholders/PartyIsMemberPlaceholder.java b/src/main/java/com/gmail/nossr50/placeholders/PartyIsMemberPlaceholder.java
new file mode 100644
index 000000000..ac385a4ba
--- /dev/null
+++ b/src/main/java/com/gmail/nossr50/placeholders/PartyIsMemberPlaceholder.java
@@ -0,0 +1,21 @@
+package com.gmail.nossr50.placeholders;
+
+import org.bukkit.entity.Player;
+
+public class PartyIsMemberPlaceholder implements Placeholder {
+
+ private final PapiExpansion papiExpansion;
+ public PartyIsMemberPlaceholder(PapiExpansion papiExpansion) {
+ this.papiExpansion = papiExpansion;
+ }
+
+ @Override
+ public String process(Player player, String params) {
+ return (papiExpansion.getPartyName(player) == null) ? "false" : "true";
+ }
+
+ @Override
+ public String getName() {
+ return "in_party";
+ }
+}
diff --git a/src/main/java/com/gmail/nossr50/placeholders/PartyLeaderPlaceholder.java b/src/main/java/com/gmail/nossr50/placeholders/PartyLeaderPlaceholder.java
new file mode 100644
index 000000000..3f753bed9
--- /dev/null
+++ b/src/main/java/com/gmail/nossr50/placeholders/PartyLeaderPlaceholder.java
@@ -0,0 +1,22 @@
+package com.gmail.nossr50.placeholders;
+
+import org.apache.commons.lang.StringUtils;
+import org.bukkit.entity.Player;
+
+public class PartyLeaderPlaceholder implements Placeholder {
+ private final PapiExpansion papiExpansion;
+
+ public PartyLeaderPlaceholder(PapiExpansion papiExpansion) {
+ this.papiExpansion = papiExpansion;
+ }
+
+ @Override
+ public String process(Player player, String params) {
+ return StringUtils.stripToEmpty(papiExpansion.getPartyLeader(player));
+ }
+
+ @Override
+ public String getName() {
+ return "party_leader";
+ }
+}
diff --git a/src/main/java/com/gmail/nossr50/placeholders/PartyNamePlaceholder.java b/src/main/java/com/gmail/nossr50/placeholders/PartyNamePlaceholder.java
new file mode 100644
index 000000000..2cec030d6
--- /dev/null
+++ b/src/main/java/com/gmail/nossr50/placeholders/PartyNamePlaceholder.java
@@ -0,0 +1,22 @@
+package com.gmail.nossr50.placeholders;
+
+import org.apache.commons.lang.StringUtils;
+import org.bukkit.entity.Player;
+
+public class PartyNamePlaceholder implements Placeholder {
+ private final PapiExpansion papiExpansion;
+
+ public PartyNamePlaceholder(PapiExpansion papiExpansion) {
+ this.papiExpansion = papiExpansion;
+ }
+
+ @Override
+ public String process(Player player, String params) {
+ return StringUtils.stripToEmpty(papiExpansion.getPartyName(player));
+ }
+
+ @Override
+ public String getName() {
+ return "party_name";
+ }
+}
diff --git a/src/main/java/com/gmail/nossr50/placeholders/PartySizePlaceholder.java b/src/main/java/com/gmail/nossr50/placeholders/PartySizePlaceholder.java
new file mode 100644
index 000000000..0d60d2786
--- /dev/null
+++ b/src/main/java/com/gmail/nossr50/placeholders/PartySizePlaceholder.java
@@ -0,0 +1,22 @@
+package com.gmail.nossr50.placeholders;
+
+import org.bukkit.entity.Player;
+
+public class PartySizePlaceholder implements Placeholder {
+ private final PapiExpansion papiExpansion;
+
+ public PartySizePlaceholder(PapiExpansion papiExpansion) {
+ this.papiExpansion = papiExpansion;
+ }
+
+ @Override
+ public String process(Player player, String params) {
+ Integer partySize = papiExpansion.getPartySize(player);
+ return (partySize == null) ? "" : partySize.toString();
+ }
+
+ @Override
+ public String getName() {
+ return "party_size";
+ }
+}
diff --git a/src/main/java/com/gmail/nossr50/placeholders/Placeholder.java b/src/main/java/com/gmail/nossr50/placeholders/Placeholder.java
new file mode 100644
index 000000000..0df697325
--- /dev/null
+++ b/src/main/java/com/gmail/nossr50/placeholders/Placeholder.java
@@ -0,0 +1,18 @@
+package com.gmail.nossr50.placeholders;
+
+import org.bukkit.entity.Player;
+
+public interface Placeholder {
+
+ /**
+ * @param player the player to process the placeholder for
+ * @param params the paramaters to be passed to the placeholder
+ * @return the value of the placeholder
+ */
+ String process(Player player, String params);
+
+ /**
+ * @return the name of the placeholder
+ */
+ String getName();
+}
diff --git a/src/main/java/com/gmail/nossr50/placeholders/PowerLevelCapPlaceholder.java b/src/main/java/com/gmail/nossr50/placeholders/PowerLevelCapPlaceholder.java
new file mode 100644
index 000000000..ac4192a00
--- /dev/null
+++ b/src/main/java/com/gmail/nossr50/placeholders/PowerLevelCapPlaceholder.java
@@ -0,0 +1,22 @@
+package com.gmail.nossr50.placeholders;
+
+import org.bukkit.entity.Player;
+
+public class PowerLevelCapPlaceholder implements Placeholder {
+ private final PapiExpansion papiExpansion;
+
+ public PowerLevelCapPlaceholder(PapiExpansion papiExpansion) {
+ this.papiExpansion = papiExpansion;
+ }
+
+ @Override
+ public String process(Player player, String params) {
+ Integer cap = papiExpansion.getPowerCap(player);
+ return (cap == null) ? "" : cap.toString();
+ }
+
+ @Override
+ public String getName() {
+ return "power_level_cap";
+ }
+}
diff --git a/src/main/java/com/gmail/nossr50/placeholders/PowerLevelPlaceholder.java b/src/main/java/com/gmail/nossr50/placeholders/PowerLevelPlaceholder.java
new file mode 100644
index 000000000..1b2916c23
--- /dev/null
+++ b/src/main/java/com/gmail/nossr50/placeholders/PowerLevelPlaceholder.java
@@ -0,0 +1,22 @@
+package com.gmail.nossr50.placeholders;
+
+import org.bukkit.entity.Player;
+
+public class PowerLevelPlaceholder implements Placeholder {
+ private final PapiExpansion papiExpansion;
+
+ public PowerLevelPlaceholder(PapiExpansion papiExpansion) {
+ this.papiExpansion = papiExpansion;
+ }
+
+ @Override
+ public String process(Player player, String params) {
+ Integer powerLevel = papiExpansion.getPowerLevel(player);
+ return (powerLevel == null) ? "" : powerLevel.toString();
+ }
+
+ @Override
+ public String getName() {
+ return "power_level";
+ }
+}
diff --git a/src/main/java/com/gmail/nossr50/placeholders/SkillExpNeededPlaceholder.java b/src/main/java/com/gmail/nossr50/placeholders/SkillExpNeededPlaceholder.java
new file mode 100644
index 000000000..93cc967e9
--- /dev/null
+++ b/src/main/java/com/gmail/nossr50/placeholders/SkillExpNeededPlaceholder.java
@@ -0,0 +1,26 @@
+package com.gmail.nossr50.placeholders;
+
+import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
+import org.bukkit.entity.Player;
+
+public class SkillExpNeededPlaceholder implements Placeholder {
+
+ private final PapiExpansion papiExpansion;
+ private final PrimarySkillType skillType;
+
+ public SkillExpNeededPlaceholder(PapiExpansion papiExpansion, PrimarySkillType skillType) {
+ this.papiExpansion = papiExpansion;
+ this.skillType = skillType;
+ }
+
+ @Override
+ public String process(Player player, String params) {
+ final Integer expNeeded = papiExpansion.getExpNeeded(skillType, player);
+ return (expNeeded == null) ? "" : expNeeded.toString();
+ }
+
+ @Override
+ public String getName() {
+ return "xp_needed_" + skillType.toString().toLowerCase();
+ }
+}
diff --git a/src/main/java/com/gmail/nossr50/placeholders/SkillExpPlaceholder.java b/src/main/java/com/gmail/nossr50/placeholders/SkillExpPlaceholder.java
new file mode 100644
index 000000000..a6f9fd2bd
--- /dev/null
+++ b/src/main/java/com/gmail/nossr50/placeholders/SkillExpPlaceholder.java
@@ -0,0 +1,26 @@
+package com.gmail.nossr50.placeholders;
+
+import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
+import org.bukkit.entity.Player;
+
+public class SkillExpPlaceholder implements Placeholder {
+ private final PapiExpansion papiExpansion;
+ private final PrimarySkillType skill;
+
+ public SkillExpPlaceholder(PapiExpansion papiExpansion, PrimarySkillType skill) {
+ this.papiExpansion = papiExpansion;
+ this.skill = skill;
+ }
+
+
+ @Override
+ public String process(Player player, String params) {
+ Integer exp = papiExpansion.getExp(skill, player);
+ return (exp == null) ? "" : exp.toString();
+ }
+
+ @Override
+ public String getName() {
+ return "xp_" + skill.toString().toLowerCase();
+ }
+}
diff --git a/src/main/java/com/gmail/nossr50/placeholders/SkillExpRemainingPlaceholder.java b/src/main/java/com/gmail/nossr50/placeholders/SkillExpRemainingPlaceholder.java
new file mode 100644
index 000000000..6f8c61715
--- /dev/null
+++ b/src/main/java/com/gmail/nossr50/placeholders/SkillExpRemainingPlaceholder.java
@@ -0,0 +1,25 @@
+package com.gmail.nossr50.placeholders;
+
+import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
+import org.bukkit.entity.Player;
+
+public class SkillExpRemainingPlaceholder implements Placeholder {
+ private final PapiExpansion papiExpansion;
+ private final PrimarySkillType skill;
+
+ public SkillExpRemainingPlaceholder(PapiExpansion papiExpansion, PrimarySkillType skill) {
+ this.papiExpansion = papiExpansion;
+ this.skill = skill;
+ }
+
+ @Override
+ public String process(Player player, String params) {
+ final Integer expRemaining = papiExpansion.getExpRemaining(skill, player);
+ return (expRemaining == null) ? "" : expRemaining.toString();
+ }
+
+ @Override
+ public String getName() {
+ return "xp_remaining_" + skill.toString().toLowerCase();
+ }
+}
diff --git a/src/main/java/com/gmail/nossr50/placeholders/SkillLevelPlaceholder.java b/src/main/java/com/gmail/nossr50/placeholders/SkillLevelPlaceholder.java
new file mode 100644
index 000000000..3521a5969
--- /dev/null
+++ b/src/main/java/com/gmail/nossr50/placeholders/SkillLevelPlaceholder.java
@@ -0,0 +1,25 @@
+package com.gmail.nossr50.placeholders;
+
+import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
+import org.bukkit.entity.Player;
+
+public class SkillLevelPlaceholder implements Placeholder {
+ private final PapiExpansion papiExpansion;
+ private final PrimarySkillType skillType;
+
+ public SkillLevelPlaceholder(PapiExpansion papiExpansion, PrimarySkillType skillType) {
+ this.papiExpansion = papiExpansion;
+ this.skillType = skillType;
+ }
+
+ @Override
+ public String process(Player p, String params) {
+ final Integer skillLevel = papiExpansion.getSkillLevel(skillType, p);
+ return (skillLevel == null) ? "" : skillLevel.toString();
+ }
+
+ @Override
+ public String getName() {
+ return "level_" + skillType.toString().toLowerCase();
+ }
+}
diff --git a/src/main/java/com/gmail/nossr50/placeholders/SkillRankPlaceholder.java b/src/main/java/com/gmail/nossr50/placeholders/SkillRankPlaceholder.java
new file mode 100644
index 000000000..1deca8e8a
--- /dev/null
+++ b/src/main/java/com/gmail/nossr50/placeholders/SkillRankPlaceholder.java
@@ -0,0 +1,25 @@
+package com.gmail.nossr50.placeholders;
+
+import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
+import org.bukkit.entity.Player;
+
+public class SkillRankPlaceholder implements Placeholder {
+ private final PapiExpansion papiExpansion;
+ private final PrimarySkillType skill;
+
+ public SkillRankPlaceholder(PapiExpansion papiExpansion, PrimarySkillType skill) {
+ this.papiExpansion = papiExpansion;
+ this.skill = skill;
+ }
+
+ @Override
+ public String process(Player player, String params) {
+ Integer rank = papiExpansion.getRank(skill, player);
+ return (rank == null) ? "" : rank.toString();
+ }
+
+ @Override
+ public String getName() {
+ return "rank_" + skill.toString().toLowerCase();
+ }
+}
diff --git a/src/main/java/com/gmail/nossr50/placeholders/SkillXpRatePlaceholder.java b/src/main/java/com/gmail/nossr50/placeholders/SkillXpRatePlaceholder.java
new file mode 100644
index 000000000..85fe7f461
--- /dev/null
+++ b/src/main/java/com/gmail/nossr50/placeholders/SkillXpRatePlaceholder.java
@@ -0,0 +1,25 @@
+package com.gmail.nossr50.placeholders;
+
+import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
+import org.bukkit.entity.Player;
+
+public class SkillXpRatePlaceholder implements Placeholder {
+ private final PapiExpansion papiExpansion;
+ private final PrimarySkillType skillType;
+
+ public SkillXpRatePlaceholder(PapiExpansion papiExpansion, PrimarySkillType skillType) {
+ this.papiExpansion = papiExpansion;
+ this.skillType = skillType;
+ }
+
+ @Override
+ public String process(Player p, String params) {
+ final String skillLevel = papiExpansion.getSkillXpRate(skillType, p);
+ return (skillLevel == null) ? "" : skillLevel;
+ }
+
+ @Override
+ public String getName() {
+ return "xprate_" + skillType.toString().toLowerCase();
+ }
+}
diff --git a/src/main/java/com/gmail/nossr50/placeholders/XpEventActivePlaceholder.java b/src/main/java/com/gmail/nossr50/placeholders/XpEventActivePlaceholder.java
new file mode 100644
index 000000000..e55c47ed6
--- /dev/null
+++ b/src/main/java/com/gmail/nossr50/placeholders/XpEventActivePlaceholder.java
@@ -0,0 +1,22 @@
+package com.gmail.nossr50.placeholders;
+
+import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
+import org.bukkit.entity.Player;
+
+public class XpEventActivePlaceholder implements Placeholder {
+ private final PapiExpansion papiExpansion;
+
+ public XpEventActivePlaceholder(PapiExpansion papiExpansion) {
+ this.papiExpansion = papiExpansion;
+ }
+
+ @Override
+ public String process(Player player, String params) {
+ return papiExpansion.isExpEventActive(player);
+ }
+
+ @Override
+ public String getName() {
+ return "is_xp_event_active";
+ }
+}
diff --git a/src/main/java/com/gmail/nossr50/placeholders/XpRatePlaceholder.java b/src/main/java/com/gmail/nossr50/placeholders/XpRatePlaceholder.java
new file mode 100644
index 000000000..907c3865e
--- /dev/null
+++ b/src/main/java/com/gmail/nossr50/placeholders/XpRatePlaceholder.java
@@ -0,0 +1,22 @@
+package com.gmail.nossr50.placeholders;
+
+import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
+import org.bukkit.entity.Player;
+
+public class XpRatePlaceholder implements Placeholder {
+ private final PapiExpansion papiExpansion;
+
+ public XpRatePlaceholder(PapiExpansion papiExpansion) {
+ this.papiExpansion = papiExpansion;
+ }
+
+ @Override
+ public String process(Player player, String params) {
+ return papiExpansion.getXpRate(player);
+ }
+
+ @Override
+ public String getName() {
+ return "xprate";
+ }
+}
diff --git a/src/main/java/com/gmail/nossr50/runnables/CheckDateTask.java b/src/main/java/com/gmail/nossr50/runnables/CheckDateTask.java
index 9f52ed5bf..e52cb2c25 100644
--- a/src/main/java/com/gmail/nossr50/runnables/CheckDateTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/CheckDateTask.java
@@ -3,9 +3,9 @@
//import com.gmail.nossr50.mcMMO;
//import com.gmail.nossr50.runnables.skills.AprilTask;
//import com.gmail.nossr50.util.Misc;
-//import org.bukkit.scheduler.BukkitRunnable;
+//import com.gmail.nossr50.util.CancellableRunnable;
//
-//public class CheckDateTask extends BukkitRunnable {
+//public class CheckDateTask extends CancellableRunnable {
//
// @Override
// public void run() {
diff --git a/src/main/java/com/gmail/nossr50/runnables/MobDodgeMetaCleanup.java b/src/main/java/com/gmail/nossr50/runnables/MobDodgeMetaCleanup.java
index 43e2a2e4b..8087d3c65 100644
--- a/src/main/java/com/gmail/nossr50/runnables/MobDodgeMetaCleanup.java
+++ b/src/main/java/com/gmail/nossr50/runnables/MobDodgeMetaCleanup.java
@@ -1,12 +1,12 @@
package com.gmail.nossr50.runnables;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.MetadataConstants;
import org.bukkit.entity.Mob;
-import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
-public class MobDodgeMetaCleanup extends BukkitRunnable {
+public class MobDodgeMetaCleanup extends CancellableRunnable {
private final @NotNull Mob mob;
private final @NotNull mcMMO pluginRef;
diff --git a/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java b/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java
index a48375727..8e59fcb5b 100644
--- a/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java
@@ -1,11 +1,11 @@
package com.gmail.nossr50.runnables;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.MetadataConstants;
import org.bukkit.entity.LivingEntity;
-import org.bukkit.scheduler.BukkitRunnable;
-public class MobHealthDisplayUpdaterTask extends BukkitRunnable {
+public class MobHealthDisplayUpdaterTask extends CancellableRunnable {
private final LivingEntity target;
public MobHealthDisplayUpdaterTask(LivingEntity target) {
diff --git a/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java b/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java
index 1dc0d4ea6..d4e69c5bc 100644
--- a/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java
@@ -2,14 +2,14 @@ package com.gmail.nossr50.runnables;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.BlockUtils;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.MetadataConstants;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
-import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
-public class PistonTrackerTask extends BukkitRunnable {
+public class PistonTrackerTask extends CancellableRunnable {
private final List blocks;
private final BlockFace direction;
private final Block futureEmptyBlock;
diff --git a/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java
index 2eba9ec1f..e109cce98 100644
--- a/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java
@@ -4,18 +4,19 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask;
+import com.gmail.nossr50.util.CancellableRunnable;
+import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.player.UserManager;
-import org.bukkit.scheduler.BukkitRunnable;
-public class SaveTimerTask extends BukkitRunnable {
+public class SaveTimerTask extends CancellableRunnable {
@Override
public void run() {
- mcMMO.p.debug("[User Data] Saving...");
+ 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);
+ mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileSaveTask(mcMMOPlayer.getProfile(), false), count);
count++;
}
diff --git a/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java b/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java
index 40e21b71b..d8f52ae30 100644
--- a/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java
@@ -2,11 +2,11 @@ package com.gmail.nossr50.runnables;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.BlockUtils;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
-import org.bukkit.scheduler.BukkitRunnable;
-public class StickyPistonTrackerTask extends BukkitRunnable {
+public class StickyPistonTrackerTask extends CancellableRunnable {
private final BlockFace direction;
private final Block block;
private final Block movedBlock;
diff --git a/src/main/java/com/gmail/nossr50/runnables/TravelingBlockMetaCleanup.java b/src/main/java/com/gmail/nossr50/runnables/TravelingBlockMetaCleanup.java
index 2b4dc57ae..366fb2967 100644
--- a/src/main/java/com/gmail/nossr50/runnables/TravelingBlockMetaCleanup.java
+++ b/src/main/java/com/gmail/nossr50/runnables/TravelingBlockMetaCleanup.java
@@ -1,12 +1,12 @@
package com.gmail.nossr50.runnables;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.MetadataConstants;
import org.bukkit.entity.Entity;
-import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
-public class TravelingBlockMetaCleanup extends BukkitRunnable {
+public class TravelingBlockMetaCleanup extends CancellableRunnable {
private final @NotNull Entity entity;
private final @NotNull mcMMO pluginRef;
diff --git a/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java b/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java
index 1a8162843..c4de1183d 100644
--- a/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java
@@ -1,7 +1,8 @@
package com.gmail.nossr50.runnables.backups;
import com.gmail.nossr50.mcMMO;
-import org.bukkit.scheduler.BukkitRunnable;
+import com.gmail.nossr50.util.CancellableRunnable;
+import com.gmail.nossr50.util.LogUtils;
import java.io.File;
import java.text.ParseException;
@@ -9,7 +10,7 @@ import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
-public class CleanBackupsTask extends BukkitRunnable {
+public class CleanBackupsTask extends CancellableRunnable {
private static final String BACKUP_DIRECTORY = mcMMO.getMainDirectory() + "backup" + File.separator;
private static final File BACKUP_DIR = new File(BACKUP_DIRECTORY);
@@ -37,7 +38,7 @@ public class CleanBackupsTask extends BukkitRunnable {
Date date = getDate(fileName.split("[.]")[0]);
if (!fileName.contains(".zip") || date == null) {
- mcMMO.p.debug("Could not determine date for file: " + fileName);
+ LogUtils.debug(mcMMO.p.getLogger(), "Could not determine date for file: " + fileName);
continue;
}
@@ -74,11 +75,11 @@ public class CleanBackupsTask extends BukkitRunnable {
return;
}
- mcMMO.p.getLogger().info("Cleaned backup files. Deleted " + amountDeleted + " of " + amountTotal + " files.");
+ LogUtils.debug(mcMMO.p.getLogger(), "Cleaned backup files. Deleted " + amountDeleted + " of " + amountTotal + " files.");
for (File file : toDelete) {
if (file.delete()) {
- mcMMO.p.debug("Deleted: " + file.getName());
+ LogUtils.debug(mcMMO.p.getLogger(), "Deleted: " + file.getName());
}
}
}
diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/McScoreboardKeepTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/McScoreboardKeepTask.java
index a5d02c1dc..2a9243b0c 100644
--- a/src/main/java/com/gmail/nossr50/runnables/commands/McScoreboardKeepTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/commands/McScoreboardKeepTask.java
@@ -1,10 +1,10 @@
package com.gmail.nossr50.runnables.commands;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
-public class McScoreboardKeepTask extends BukkitRunnable {
+public class McScoreboardKeepTask extends CancellableRunnable {
private final Player player;
public McScoreboardKeepTask(Player player) {
diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java
index 7311b50bf..2897b4388 100644
--- a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java
@@ -2,14 +2,14 @@ package com.gmail.nossr50.runnables.commands;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.apache.commons.lang.Validate;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
import java.util.Map;
-public class McrankCommandAsyncTask extends BukkitRunnable {
+public class McrankCommandAsyncTask extends CancellableRunnable {
private final String playerName;
private final CommandSender sender;
private final boolean useBoard, useChat;
@@ -32,7 +32,7 @@ public class McrankCommandAsyncTask extends BukkitRunnable {
public void run() {
Map skills = mcMMO.getDatabaseManager().readRank(playerName);
- new McrankCommandDisplayTask(skills, sender, playerName, useBoard, useChat).runTaskLater(mcMMO.p, 1);
+ mcMMO.p.getFoliaLib().getImpl().runNextTick(new McrankCommandDisplayTask(skills, sender, playerName, useBoard, useChat));
}
}
diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java
index 76a68345d..c1067ecf1 100644
--- a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java
@@ -3,19 +3,19 @@ package com.gmail.nossr50.runnables.commands;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.MetadataConstants;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.SkillTools;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
import java.util.Map;
/**
* Display the results of McrankCommandAsyncTask to the sender.
*/
-public class McrankCommandDisplayTask extends BukkitRunnable {
+public class McrankCommandDisplayTask extends CancellableRunnable {
private final Map skills;
private final CommandSender sender;
private final String playerName;
diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java
index 387175cf7..a343bc810 100644
--- a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java
@@ -3,14 +3,14 @@ package com.gmail.nossr50.runnables.commands;
import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.apache.commons.lang.Validate;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
-public class MctopCommandAsyncTask extends BukkitRunnable {
+public class MctopCommandAsyncTask extends CancellableRunnable {
private final CommandSender sender;
private final PrimarySkillType skill;
private final int page;
@@ -35,6 +35,6 @@ public class MctopCommandAsyncTask extends BukkitRunnable {
public void run() {
final List userStats = mcMMO.getDatabaseManager().readLeaderboard(skill, page, 10);
- new MctopCommandDisplayTask(userStats, page, skill, sender, useBoard, useChat).runTaskLater(mcMMO.p, 1);
+ mcMMO.p.getFoliaLib().getImpl().runNextTick(new MctopCommandDisplayTask(userStats, page, skill, sender, useBoard, useChat));
}
}
diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandDisplayTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandDisplayTask.java
index f105faa42..ed1a2f73c 100644
--- a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandDisplayTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandDisplayTask.java
@@ -4,19 +4,19 @@ import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.MetadataConstants;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
/**
* Display the results of {@link MctopCommandAsyncTask} to the sender.
*/
-public class MctopCommandDisplayTask extends BukkitRunnable {
+public class MctopCommandDisplayTask extends CancellableRunnable {
private final List userStats;
private final CommandSender sender;
private final PrimarySkillType skill;
diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/NotifySquelchReminderTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/NotifySquelchReminderTask.java
index 4d7b11fc6..9b9fcd6fe 100644
--- a/src/main/java/com/gmail/nossr50/runnables/commands/NotifySquelchReminderTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/commands/NotifySquelchReminderTask.java
@@ -1,12 +1,12 @@
package com.gmail.nossr50.runnables.commands;
import com.gmail.nossr50.locale.LocaleLoader;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
-public class NotifySquelchReminderTask extends BukkitRunnable {
+public class NotifySquelchReminderTask extends CancellableRunnable {
@Override
public void run() {
diff --git a/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java b/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java
index 0089ee677..4e59a01fb 100644
--- a/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java
@@ -3,10 +3,10 @@ package com.gmail.nossr50.runnables.database;
import com.gmail.nossr50.database.DatabaseManager;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.command.CommandSender;
-import org.bukkit.scheduler.BukkitRunnable;
-public class DatabaseConversionTask extends BukkitRunnable {
+public class DatabaseConversionTask extends CancellableRunnable {
private final DatabaseManager sourceDatabase;
private final CommandSender sender;
private final String message;
@@ -21,6 +21,6 @@ public class DatabaseConversionTask extends BukkitRunnable {
public void run() {
sourceDatabase.convertUsers(mcMMO.getDatabaseManager());
- mcMMO.p.getServer().getScheduler().runTask(mcMMO.p, () -> sender.sendMessage(message));
+ mcMMO.p.getFoliaLib().getImpl().runNextTick(t -> sender.sendMessage(message));
}
}
diff --git a/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java b/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java
index dd061d8b6..214d4e58b 100644
--- a/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java
@@ -8,13 +8,14 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
+import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillTools;
import org.bukkit.command.CommandSender;
-import org.bukkit.scheduler.BukkitRunnable;
-public class FormulaConversionTask extends BukkitRunnable {
+public class FormulaConversionTask extends CancellableRunnable {
private final CommandSender sender;
private final FormulaType formulaType;
@@ -36,7 +37,7 @@ public class FormulaConversionTask extends BukkitRunnable {
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName);
if (!profile.isLoaded()) {
- mcMMO.p.debug("Profile not loaded.");
+ LogUtils.debug(mcMMO.p.getLogger(), "Profile not loaded.");
continue;
}
@@ -57,8 +58,8 @@ public class FormulaConversionTask extends BukkitRunnable {
}
private void editValues(PlayerProfile profile) {
- mcMMO.p.debug("========================================================================");
- mcMMO.p.debug("Conversion report for " + profile.getPlayerName() + ":");
+ LogUtils.debug(mcMMO.p.getLogger(), "========================================================================");
+ LogUtils.debug(mcMMO.p.getLogger(), "Conversion report for " + profile.getPlayerName() + ":");
for (PrimarySkillType primarySkillType : SkillTools.NON_CHILD_SKILLS) {
int oldLevel = profile.getSkillLevel(primarySkillType);
int oldXPLevel = profile.getSkillXpLevel(primarySkillType);
@@ -72,17 +73,17 @@ public class FormulaConversionTask extends BukkitRunnable {
int newLevel = newExperienceValues[0];
int newXPlevel = newExperienceValues[1];
- mcMMO.p.debug(" Skill: " + primarySkillType.toString());
+ LogUtils.debug(mcMMO.p.getLogger(), " Skill: " + primarySkillType.toString());
- mcMMO.p.debug(" OLD:");
- mcMMO.p.debug(" Level: " + oldLevel);
- mcMMO.p.debug(" XP " + oldXPLevel);
- mcMMO.p.debug(" Total XP " + totalOldXP);
+ LogUtils.debug(mcMMO.p.getLogger(), " OLD:");
+ LogUtils.debug(mcMMO.p.getLogger(), " Level: " + oldLevel);
+ LogUtils.debug(mcMMO.p.getLogger(), " XP " + oldXPLevel);
+ LogUtils.debug(mcMMO.p.getLogger(), " Total XP " + totalOldXP);
- mcMMO.p.debug(" NEW:");
- mcMMO.p.debug(" Level " + newLevel);
- mcMMO.p.debug(" XP " + newXPlevel);
- mcMMO.p.debug("------------------------------------------------------------------------");
+ LogUtils.debug(mcMMO.p.getLogger(), " NEW:");
+ LogUtils.debug(mcMMO.p.getLogger(), " Level " + newLevel);
+ LogUtils.debug(mcMMO.p.getLogger(), " XP " + newXPlevel);
+ LogUtils.debug(mcMMO.p.getLogger(), "------------------------------------------------------------------------");
profile.modifySkill(primarySkillType, newLevel);
profile.setSkillXpLevel(primarySkillType, newXPlevel);
diff --git a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java
index fe7a029a7..44b7cf36f 100644
--- a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java
@@ -2,6 +2,7 @@ package com.gmail.nossr50.runnables.database;
import com.gmail.nossr50.datatypes.database.UpgradeType;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.Misc;
import com.google.common.collect.ImmutableList;
import com.google.gson.Gson;
@@ -20,7 +21,7 @@ import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.logging.Level;
-public class UUIDUpdateAsyncTask implements Runnable {
+public class UUIDUpdateAsyncTask extends CancellableRunnable {
private static final Gson GSON = new Gson();
private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft";
@@ -109,11 +110,11 @@ 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.getServer().getScheduler().runTaskLaterAsynchronously(plugin, this, delay);
+ plugin.getFoliaLib().getImpl().runLaterAsync(this, delay);
}
public void start() {
- plugin.getServer().getScheduler().runTaskAsynchronously(plugin, this);
+ plugin.getFoliaLib().getImpl().runAsync(this);
}
private static UUID toUUID(String id) {
diff --git a/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java b/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java
index cf570e3f2..ab2b4cbea 100644
--- a/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java
@@ -1,11 +1,11 @@
package com.gmail.nossr50.runnables.database;
import com.gmail.nossr50.mcMMO;
-import org.bukkit.scheduler.BukkitRunnable;
+import com.gmail.nossr50.util.CancellableRunnable;
import java.util.concurrent.locks.ReentrantLock;
-public class UserPurgeTask extends BukkitRunnable {
+public class UserPurgeTask extends CancellableRunnable {
private final ReentrantLock lock = new ReentrantLock();
@Override
public void run() {
diff --git a/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java b/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java
index c7409b3ce..bb0996b50 100644
--- a/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java
+++ b/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java
@@ -3,6 +3,7 @@ package com.gmail.nossr50.runnables.items;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.ChimaeraWing;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
@@ -10,9 +11,8 @@ import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.scheduler.BukkitRunnable;
-public class ChimaeraWingWarmup extends BukkitRunnable {
+public class ChimaeraWingWarmup extends CancellableRunnable {
private final McMMOPlayer mcMMOPlayer;
public ChimaeraWingWarmup(McMMOPlayer mcMMOPlayer) {
diff --git a/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java b/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java
index 49ce24aad..52d245227 100644
--- a/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java
+++ b/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java
@@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
@@ -11,9 +12,8 @@ import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
-public class TeleportationWarmup extends BukkitRunnable {
+public class TeleportationWarmup extends CancellableRunnable {
private final McMMOPlayer mcMMOPlayer;
private final McMMOPlayer mcMMOTarget;
diff --git a/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java b/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java
index f66b003b6..18891155c 100644
--- a/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java
@@ -3,8 +3,8 @@ package com.gmail.nossr50.runnables.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.OfflinePlayer;
-import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.HashMap;
@@ -12,7 +12,7 @@ import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;
-public class PartyAutoKickTask extends BukkitRunnable {
+public class PartyAutoKickTask extends CancellableRunnable {
private final static long KICK_TIME = 24L * 60L * 60L * 1000L * mcMMO.p.getGeneralConfig().getAutoPartyKickTime();
@Override
diff --git a/src/main/java/com/gmail/nossr50/runnables/player/ClearRegisteredXPGainTask.java b/src/main/java/com/gmail/nossr50/runnables/player/ClearRegisteredXPGainTask.java
index 2c281ee88..47923c7a4 100644
--- a/src/main/java/com/gmail/nossr50/runnables/player/ClearRegisteredXPGainTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/player/ClearRegisteredXPGainTask.java
@@ -1,10 +1,10 @@
package com.gmail.nossr50.runnables.player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.player.UserManager;
-import org.bukkit.scheduler.BukkitRunnable;
-public class ClearRegisteredXPGainTask extends BukkitRunnable {
+public class ClearRegisteredXPGainTask extends CancellableRunnable {
@Override
public void run() {
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
diff --git a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java
index 572f36e0f..6cd865055 100644
--- a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java
@@ -5,15 +5,16 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.McScoreboardKeepTask;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.EventUtils;
+import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import org.bukkit.Server;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
-public class PlayerProfileLoadingTask extends BukkitRunnable {
+public class PlayerProfileLoadingTask extends CancellableRunnable {
private final Player player;
private int attempt = 0;
@@ -37,21 +38,21 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
// Quit if they logged out
if (!player.isOnline()) {
- mcMMO.p.getLogger().info("Aborting profile loading recovery for " + player.getName() + " - player logged out");
+ LogUtils.debug(mcMMO.p.getLogger(), "Aborting profile loading recovery for " + player.getName() + " - player logged out");
return;
}
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(player);
if(!profile.isLoaded()) {
- mcMMO.p.getLogger().info("Creating new data for player: "+player.getName());
+ LogUtils.debug(mcMMO.p.getLogger(), "Creating new data for player: "+player.getName());
//Profile isn't loaded so add as new user
profile = mcMMO.getDatabaseManager().newUser(player);
}
// If successful, schedule the apply
if (profile.isLoaded()) {
- new ApplySuccessfulProfile(new McMMOPlayer(player, profile)).runTask(mcMMO.p);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntity(player, new ApplySuccessfulProfile(new McMMOPlayer(player, profile)));
EventUtils.callPlayerProfileLoadEvent(player, profile);
return;
}
@@ -73,10 +74,10 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
// Increment attempt counter and try
attempt++;
- new PlayerProfileLoadingTask(player, attempt).runTaskLaterAsynchronously(mcMMO.p, (100 + (attempt * 100L)));
+ mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileLoadingTask(player, attempt), (100 + (attempt * 100L)));
}
- private class ApplySuccessfulProfile extends BukkitRunnable {
+ private class ApplySuccessfulProfile extends CancellableRunnable {
private final McMMOPlayer mcMMOPlayer;
private ApplySuccessfulProfile(McMMOPlayer mcMMOPlayer) {
@@ -103,7 +104,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
if (mcMMO.p.getGeneralConfig().getShowStatsAfterLogin()) {
ScoreboardManager.enablePlayerStatsScoreboard(player);
- new McScoreboardKeepTask(player).runTaskLater(mcMMO.p, Misc.TICK_CONVERSION_FACTOR);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new McScoreboardKeepTask(player), Misc.TICK_CONVERSION_FACTOR);
}
}
diff --git a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileSaveTask.java b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileSaveTask.java
index 2a6d30c69..9868c3898 100644
--- a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileSaveTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileSaveTask.java
@@ -1,9 +1,9 @@
package com.gmail.nossr50.runnables.player;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
-import org.bukkit.scheduler.BukkitRunnable;
+import com.gmail.nossr50.util.CancellableRunnable;
-public class PlayerProfileSaveTask extends BukkitRunnable {
+public class PlayerProfileSaveTask extends CancellableRunnable {
private final PlayerProfile playerProfile;
private final boolean isSync;
diff --git a/src/main/java/com/gmail/nossr50/runnables/player/PlayerUpdateInventoryTask.java b/src/main/java/com/gmail/nossr50/runnables/player/PlayerUpdateInventoryTask.java
index cdfb17d88..d5361e7ce 100644
--- a/src/main/java/com/gmail/nossr50/runnables/player/PlayerUpdateInventoryTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/player/PlayerUpdateInventoryTask.java
@@ -1,10 +1,10 @@
package com.gmail.nossr50.runnables.player;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
@SuppressWarnings("deprecation")
-public class PlayerUpdateInventoryTask extends BukkitRunnable {
+public class PlayerUpdateInventoryTask extends CancellableRunnable {
private final Player player;
public PlayerUpdateInventoryTask(Player player) {
diff --git a/src/main/java/com/gmail/nossr50/runnables/player/PowerLevelUpdatingTask.java b/src/main/java/com/gmail/nossr50/runnables/player/PowerLevelUpdatingTask.java
index 3f50bce89..da7217261 100644
--- a/src/main/java/com/gmail/nossr50/runnables/player/PowerLevelUpdatingTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/player/PowerLevelUpdatingTask.java
@@ -1,9 +1,9 @@
package com.gmail.nossr50.runnables.player;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
-import org.bukkit.scheduler.BukkitRunnable;
-public class PowerLevelUpdatingTask extends BukkitRunnable {
+public class PowerLevelUpdatingTask extends CancellableRunnable {
@Override
public void run() {
if (!ScoreboardManager.powerLevelHeartbeat()) {
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java
index 56c772a84..69e080972 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java
@@ -3,10 +3,10 @@ package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.player.NotificationManager;
-import org.bukkit.scheduler.BukkitRunnable;
-public class AbilityCooldownTask extends BukkitRunnable {
+public class AbilityCooldownTask extends CancellableRunnable {
private final McMMOPlayer mcMMOPlayer;
private final SuperAbilityType ability;
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java
index 7265b386b..a789171e0 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java
@@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.NotificationManager;
@@ -12,9 +13,8 @@ import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
-public class AbilityDisableTask extends BukkitRunnable {
+public class AbilityDisableTask extends CancellableRunnable {
private final McMMOPlayer mcMMOPlayer;
private final SuperAbilityType ability;
@@ -63,7 +63,7 @@ public class AbilityDisableTask extends BukkitRunnable {
SkillUtils.sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, ability.getAbilityPlayerOff());
}
if(!mcMMO.isServerShutdownExecuted()) {
- new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLater(mcMMO.p, (long) PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new AbilityCooldownTask(mcMMOPlayer, ability), (long) PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR);
}
}
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewCheckTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewCheckTask.java
index e81804ac8..68de298f5 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewCheckTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewCheckTask.java
@@ -2,15 +2,15 @@ package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.skills.alchemy.Alchemy;
import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.Location;
import org.bukkit.block.BrewingStand;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.scheduler.BukkitRunnable;
import java.util.Arrays;
-public class AlchemyBrewCheckTask extends BukkitRunnable {
+public class AlchemyBrewCheckTask extends CancellableRunnable {
private final Player player;
private final BrewingStand brewingStand;
private final ItemStack[] oldInventory;
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java
index 7a615bd96..de5ea2adb 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java
@@ -7,6 +7,7 @@ import com.gmail.nossr50.events.skills.alchemy.McMMOPlayerCatalysisEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.alchemy.Alchemy;
import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
@@ -15,9 +16,8 @@ import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.block.BrewingStand;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
-public class AlchemyBrewTask extends BukkitRunnable {
+public class AlchemyBrewTask extends CancellableRunnable {
private static final double DEFAULT_BREW_SPEED = 1.0;
private static final int DEFAULT_BREW_TICKS = 400;
@@ -62,7 +62,7 @@ public class AlchemyBrewTask extends BukkitRunnable {
fuel--;
Alchemy.brewingStandMap.put(location, this);
- this.runTaskTimer(mcMMO.p, 1, 1);
+ mcMMO.p.getFoliaLib().getImpl().runAtLocationTimer(location, this, 1, 1);
}
@Override
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AprilTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AprilTask.java
index 86fd6b819..9b4aa61a4 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/AprilTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/AprilTask.java
@@ -8,9 +8,9 @@
//import org.bukkit.ChatColor;
//import org.bukkit.Statistic;
//import org.bukkit.entity.Player;
-//import org.bukkit.scheduler.BukkitRunnable;
+//import com.gmail.nossr50.util.CancellableRunnable;
//
-//public class AprilTask extends BukkitRunnable {
+//public class AprilTask extends CancellableRunnable {
//
// @Override
// public void run() {
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java
index 02e01ed1e..6ced4c66a 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java
@@ -5,10 +5,10 @@ import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.experience.XPGainSource;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.entity.LivingEntity;
-import org.bukkit.scheduler.BukkitRunnable;
-public class AwardCombatXpTask extends BukkitRunnable {
+public class AwardCombatXpTask extends CancellableRunnable {
private final McMMOPlayer mcMMOPlayer;
private final double baseXp;
private final PrimarySkillType primarySkillType;
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java
index 839358afd..0cb4d3d13 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java
@@ -15,7 +15,7 @@
//import org.bukkit.entity.Player;
//import org.bukkit.event.entity.EntityDamageEvent;
//import org.bukkit.inventory.ItemStack;
-//import org.bukkit.scheduler.BukkitRunnable;
+//import com.gmail.nossr50.util.CancellableRunnable;
//import org.jetbrains.annotations.NotNull;
//
//import java.util.HashMap;
@@ -23,7 +23,7 @@
//import java.util.Map;
//import java.util.Map.Entry;
//
-//public class BleedTimerTask extends BukkitRunnable {
+//public class BleedTimerTask extends CancellableRunnable {
// private static final @NotNull Map bleedList = new HashMap<>();
// private static boolean isIterating = false;
//
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/DelayedCropReplant.java b/src/main/java/com/gmail/nossr50/runnables/skills/DelayedCropReplant.java
index 31f19fada..927e9a3f8 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/DelayedCropReplant.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/DelayedCropReplant.java
@@ -2,6 +2,7 @@ package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.datatypes.meta.RecentlyReplantedCropMeta;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.MetadataConstants;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import org.bukkit.Location;
@@ -14,11 +15,10 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.type.Cocoa;
import org.bukkit.event.block.BlockBreakEvent;
-import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-public class DelayedCropReplant extends BukkitRunnable {
+public class DelayedCropReplant extends CancellableRunnable {
private final int desiredCropAge;
private final Location cropLocation;
@@ -54,7 +54,7 @@ public class DelayedCropReplant extends BukkitRunnable {
PlantAnchorType plantAnchorType = PlantAnchorType.NORMAL;
//Remove the metadata marking the block as recently replanted
- new markPlantAsOld(blockBreakEvent.getBlock().getLocation()).runTaskLater(mcMMO.p, 10);
+ mcMMO.p.getFoliaLib().getImpl().runAtLocationLater(blockBreakEvent.getBlock().getLocation(), new markPlantAsOld(blockBreakEvent.getBlock().getLocation()), 10);
if(blockBreakEvent.isCancelled()) {
wasImmaturePlant = true;
@@ -101,7 +101,7 @@ public class DelayedCropReplant extends BukkitRunnable {
//Play an effect
ParticleEffectUtils.playGreenThumbEffect(cropLocation);
- new PhysicsBlockUpdate(newState.getBlock(), cropFace, plantAnchorType).runTaskLater(mcMMO.p, 1);
+ mcMMO.p.getFoliaLib().getImpl().runAtLocationLater(newState.getLocation(), new PhysicsBlockUpdate(newState.getBlock(), cropFace, plantAnchorType), 1);
}
}
@@ -110,7 +110,7 @@ public class DelayedCropReplant extends BukkitRunnable {
COCOA
}
- private static class PhysicsBlockUpdate extends BukkitRunnable {
+ private static class PhysicsBlockUpdate extends CancellableRunnable {
private final Block plantBlock;
private final PlantAnchorType plantAnchorType;
private BlockFace plantFace;
@@ -160,7 +160,7 @@ public class DelayedCropReplant extends BukkitRunnable {
- private static class markPlantAsOld extends BukkitRunnable {
+ private static class markPlantAsOld extends CancellableRunnable {
private final Location cropLoc;
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/DelayedHerbalismXPCheckTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/DelayedHerbalismXPCheckTask.java
index 3ecc03747..dcc583f02 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/DelayedHerbalismXPCheckTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/DelayedHerbalismXPCheckTask.java
@@ -2,11 +2,11 @@ package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.datatypes.BlockSnapshot;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
-import org.bukkit.scheduler.BukkitRunnable;
+import com.gmail.nossr50.util.CancellableRunnable;
import java.util.ArrayList;
-public class DelayedHerbalismXPCheckTask extends BukkitRunnable {
+public class DelayedHerbalismXPCheckTask extends CancellableRunnable {
private final McMMOPlayer mcMMOPlayer;
private final ArrayList chorusBlocks;
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/ExperienceBarHideTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/ExperienceBarHideTask.java
index 23e78909c..34c87b0d4 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/ExperienceBarHideTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/ExperienceBarHideTask.java
@@ -2,10 +2,10 @@ package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.experience.ExperienceBarManager;
-import org.bukkit.scheduler.BukkitRunnable;
-public class ExperienceBarHideTask extends BukkitRunnable {
+public class ExperienceBarHideTask extends CancellableRunnable {
public final McMMOPlayer mcMMOPlayer;
public final PrimarySkillType primarySkillType;
public final ExperienceBarManager experienceBarManagerRef;
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java
index 102c9b0b7..e753957e3 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java
@@ -1,9 +1,9 @@
package com.gmail.nossr50.runnables.skills;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.block.BlockState;
-import org.bukkit.scheduler.BukkitRunnable;
-public class HerbalismBlockUpdaterTask extends BukkitRunnable {
+public class HerbalismBlockUpdaterTask extends CancellableRunnable {
private final BlockState blockState;
public HerbalismBlockUpdaterTask(BlockState blockState) {
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/MasterAnglerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/MasterAnglerTask.java
index 0f652e02c..39a6c01b4 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/MasterAnglerTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/MasterAnglerTask.java
@@ -1,11 +1,11 @@
package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.skills.fishing.FishingManager;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.entity.FishHook;
-import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
-public class MasterAnglerTask extends BukkitRunnable {
+public class MasterAnglerTask extends CancellableRunnable {
private final @NotNull FishHook fishHook;
private final @NotNull FishingManager fishingManager;
private final int lureLevel;
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/RuptureTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/RuptureTask.java
index 4a93893cb..32ecf72b2 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/RuptureTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/RuptureTask.java
@@ -3,15 +3,15 @@ package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.skills.rupture.McMMOEntityDamageByRuptureEvent;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.MetadataConstants;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.google.common.base.Objects;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
-public class RuptureTask extends BukkitRunnable {
+public class RuptureTask extends CancellableRunnable {
public static final int DAMAGE_TICK_INTERVAL = 10;
public static final int ANIMATION_TICK_INTERVAL = 1;
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/SkillUnlockNotificationTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/SkillUnlockNotificationTask.java
index 342f77162..c9b6d87a5 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/SkillUnlockNotificationTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/SkillUnlockNotificationTask.java
@@ -2,11 +2,11 @@ package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.player.NotificationManager;
-import org.bukkit.scheduler.BukkitRunnable;
-public class SkillUnlockNotificationTask extends BukkitRunnable {
+public class SkillUnlockNotificationTask extends CancellableRunnable {
private final McMMOPlayer mcMMOPlayer;
private final SubSkillType subSkillType;
private final int rank;
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java
index ef3cd0561..98f336e84 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java
@@ -4,10 +4,10 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.player.NotificationManager;
-import org.bukkit.scheduler.BukkitRunnable;
-public class ToolLowerTask extends BukkitRunnable {
+public class ToolLowerTask extends CancellableRunnable {
private final McMMOPlayer mcMMOPlayer;
private final ToolType tool;
diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java
index 6322e52c5..08fd39ab4 100644
--- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java
+++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java
@@ -113,7 +113,7 @@ public class AcrobaticsManager extends SkillManager {
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier), XPGainReason.PVE);
mob.setMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER, new FixedMetadataValue(mcMMO.p, count + 1));
MobDodgeMetaCleanup metaCleanupTask = new MobDodgeMetaCleanup(mob, mcMMO.p);
- metaCleanupTask.runTaskTimer(mcMMO.p, 20, 20*60); //one minute
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityTimer(mob, metaCleanupTask, 20, 20*60); //one minute
}
} else {
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier), XPGainReason.PVE);
diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/Alchemy.java b/src/main/java/com/gmail/nossr50/skills/alchemy/Alchemy.java
index 387a35550..c6c5470a3 100644
--- a/src/main/java/com/gmail/nossr50/skills/alchemy/Alchemy.java
+++ b/src/main/java/com/gmail/nossr50/skills/alchemy/Alchemy.java
@@ -2,6 +2,7 @@ package com.gmail.nossr50.skills.alchemy;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.AlchemyBrewTask;
+import com.gmail.nossr50.util.LogUtils;
import org.bukkit.Location;
import java.util.ArrayList;
@@ -58,7 +59,7 @@ public final class Alchemy {
* Finish all active brews. Used upon Disable to prevent vanilla potions from being brewed upon next Enable.
*/
public static void finishAllBrews() {
- mcMMO.p.debug("Completing " + brewingStandMap.size() + " unfinished Alchemy brews.");
+ LogUtils.debug(mcMMO.p.getLogger(), "Completing " + brewingStandMap.size() + " unfinished Alchemy brews.");
List toFinish = new ArrayList<>(brewingStandMap.values());
diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java
index 116fe64e6..2a11b0159 100644
--- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java
+++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java
@@ -259,13 +259,13 @@ public final class AlchemyPotionBrewer {
}
public static void scheduleCheck(Player player, BrewingStand brewingStand) {
- new AlchemyBrewCheckTask(player, brewingStand).runTask(mcMMO.p);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntity(player, new AlchemyBrewCheckTask(player, brewingStand));
}
public static void scheduleUpdate(Inventory inventory) {
for (HumanEntity humanEntity : inventory.getViewers()) {
if (humanEntity instanceof Player) {
- new PlayerUpdateInventoryTask((Player) humanEntity).runTask(mcMMO.p);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntity(humanEntity, new PlayerUpdateInventoryTask((Player) humanEntity));
}
}
}
diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java
index b46317067..7cc028e8f 100644
--- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java
+++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java
@@ -95,7 +95,8 @@ public class ArcheryManager extends SkillManager {
Location dazedLocation = defender.getLocation();
dazedLocation.setPitch(90 - Misc.getRandom().nextInt(181));
- defender.teleport(dazedLocation);
+// defender.teleport(dazedLocation);
+ mcMMO.p.getFoliaLib().getImpl().teleportAsync(defender, dazedLocation);
defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10));
diff --git a/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java b/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java
index 8cc97cc29..613ddaf70 100644
--- a/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java
+++ b/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java
@@ -1,12 +1,12 @@
package com.gmail.nossr50.skills.archery;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.entity.LivingEntity;
-import org.bukkit.scheduler.BukkitRunnable;
import java.util.UUID;
-public class TrackedEntity extends BukkitRunnable {
+public class TrackedEntity extends CancellableRunnable {
private final LivingEntity livingEntity;
private final UUID id;
private int arrowCount;
@@ -15,7 +15,7 @@ public class TrackedEntity extends BukkitRunnable {
this.livingEntity = livingEntity;
this.id = livingEntity.getUniqueId();
- this.runTaskTimer(mcMMO.p, 12000, 12000);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityTimer(livingEntity, this, 12000, 12000);
}
@Override
diff --git a/src/main/java/com/gmail/nossr50/skills/child/ChildConfig.java b/src/main/java/com/gmail/nossr50/skills/child/ChildConfig.java
index ae4360de7..0e200bafa 100644
--- a/src/main/java/com/gmail/nossr50/skills/child/ChildConfig.java
+++ b/src/main/java/com/gmail/nossr50/skills/child/ChildConfig.java
@@ -3,6 +3,7 @@ package com.gmail.nossr50.skills.child;
import com.gmail.nossr50.config.BukkitConfig;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.text.StringUtils;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -22,7 +23,7 @@ public class ChildConfig extends BukkitConfig {
FamilyTree.clearRegistrations(); // when reloading, need to clear statics
for (PrimarySkillType skill : mcMMO.p.getSkillTools().CHILD_SKILLS) {
- mcMMO.p.debug("Finding parents of " + skill.name());
+ LogUtils.debug(mcMMO.p.getLogger(), "Finding parents of " + skill.name());
EnumSet parentSkills = EnumSet.noneOf(PrimarySkillType.class);
boolean useDefaults = false; // If we had an error we back out and use defaults
@@ -53,7 +54,7 @@ public class ChildConfig extends BukkitConfig {
// Register them
for (PrimarySkillType parentSkill : parentSkills) {
- mcMMO.p.debug("Registering " + parentSkill.name() + " as parent of " + skill.name());
+ LogUtils.debug(mcMMO.p.getLogger(), "Registering " + parentSkill.name() + " as parent of " + skill.name());
FamilyTree.registerParent(skill, parentSkill);
}
}
diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java
index d7295a31a..6063add73 100644
--- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java
+++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java
@@ -246,7 +246,7 @@ public class FishingManager extends SkillManager {
}
public void masterAngler(@NotNull FishHook hook, int lureLevel) {
- new MasterAnglerTask(hook, this, lureLevel).runTaskLater(mcMMO.p, 0); //We run later to get the lure bonus applied
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(hook, new MasterAnglerTask(hook, this, lureLevel), 1); //We run later to get the lure bonus applied
}
/**
diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java
index 7755a1fef..a2eb57ae1 100644
--- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java
+++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java
@@ -37,7 +37,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
-import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -105,12 +104,12 @@ public class HerbalismManager extends SkillManager {
}
CheckBushAge checkBushAge = new CheckBushAge(blockState.getBlock(), mmoPlayer, xpReward);
- checkBushAge.runTaskLater(mcMMO.p, 1);
+ mcMMO.p.getFoliaLib().getImpl().runAtLocationLater(blockState.getLocation(), checkBushAge, 1);
}
}
}
- private class CheckBushAge extends BukkitRunnable {
+ private class CheckBushAge extends CancellableRunnable {
@NotNull Block block;
@NotNull McMMOPlayer mmoPlayer;
@@ -309,7 +308,7 @@ public class HerbalismManager extends SkillManager {
DelayedHerbalismXPCheckTask delayedHerbalismXPCheckTask = new DelayedHerbalismXPCheckTask(mmoPlayer, delayedChorusBlocks);
//Large delay because the tree takes a while to break
- delayedHerbalismXPCheckTask.runTaskLater(mcMMO.p, 0); //Calculate Chorus XP + Bonus Drops 1 tick later
+ mcMMO.p.getFoliaLib().getImpl().runAtEntity(mmoPlayer.getPlayer(), delayedHerbalismXPCheckTask); //Calculate Chorus XP + Bonus Drops 1 tick later
}
}
@@ -362,7 +361,7 @@ public class HerbalismManager extends SkillManager {
*
*/
- //If its a Crop we need to reward XP when its fully grown
+ //If it's a Crop we need to reward XP when its fully grown
if(isAgeableAndFullyMature(plantData) && !isBizarreAgeable(plantData)) {
//Add metadata to mark this block for double or triple drops
markForBonusDrops(brokenPlantState);
@@ -372,21 +371,17 @@ public class HerbalismManager extends SkillManager {
}
/**
- * Checks if BlockData is ageable and we can trust that age for Herbalism rewards/XP reasons
+ * Checks if BlockData is bizarre ageable, and we cannot trust that age for Herbalism rewards/XP reasons
* @param blockData target BlockData
- * @return returns true if the ageable is trustworthy for Herbalism XP / Rewards
+ * @return returns true if the BlockData is a bizarre ageable for Herbalism XP / Rewards
*/
public boolean isBizarreAgeable(BlockData blockData) {
if(blockData instanceof Ageable) {
//Catcus and Sugar Canes cannot be trusted
- switch(blockData.getMaterial()) {
- case CACTUS:
- case KELP:
- case SUGAR_CANE:
- return true;
- default:
- return false;
- }
+ return switch (blockData.getMaterial()) {
+ case CACTUS, KELP, SUGAR_CANE, BAMBOO -> true;
+ default -> false;
+ };
}
return false;
@@ -740,7 +735,7 @@ public class HerbalismManager extends SkillManager {
*/
private void startReplantTask(int desiredCropAge, BlockBreakEvent blockBreakEvent, BlockState cropState, boolean isImmature) {
//Mark the plant as recently replanted to avoid accidental breakage
- new DelayedCropReplant(blockBreakEvent, cropState, desiredCropAge, isImmature).runTaskLater(mcMMO.p, 20 * 2);
+ mcMMO.p.getFoliaLib().getImpl().runAtLocationLater(blockBreakEvent.getBlock().getLocation(), new DelayedCropReplant(blockBreakEvent, cropState, desiredCropAge, isImmature), 2 * Misc.TICK_CONVERSION_FACTOR);
blockBreakEvent.getBlock().setMetadata(MetadataConstants.METADATA_KEY_REPLANT, new RecentlyReplantedCropMeta(mcMMO.p, true));
}
diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java
index 8400bdab7..b91274ce4 100644
--- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java
+++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java
@@ -158,7 +158,7 @@ public class MiningManager extends SkillManager {
mmoPlayer.setAbilityDATS(SuperAbilityType.BLAST_MINING, System.currentTimeMillis());
mmoPlayer.setAbilityInformed(SuperAbilityType.BLAST_MINING, false);
- new AbilityCooldownTask(mmoPlayer, SuperAbilityType.BLAST_MINING).runTaskLater(mcMMO.p, (long) SuperAbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(mmoPlayer.getPlayer(), new AbilityCooldownTask(mmoPlayer, SuperAbilityType.BLAST_MINING), (long) SuperAbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR);
}
/**
diff --git a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java
index 7ab2536d1..d68d98e8d 100644
--- a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java
+++ b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java
@@ -95,7 +95,7 @@ public class SwordsManager extends SkillManager {
RuptureTaskMeta ruptureTaskMeta = new RuptureTaskMeta(mcMMO.p, ruptureTask);
- ruptureTask.runTaskTimer(mcMMO.p, 0, 1);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityTimer(mmoPlayer.getPlayer(), ruptureTask, 1, 1);
target.setMetadata(MetadataConstants.METADATA_KEY_RUPTURE, ruptureTaskMeta);
// if (mmoPlayer.useChatNotifications()) {
diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java
index 8a2673fe7..dcee2e0bd 100644
--- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java
+++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java
@@ -237,7 +237,7 @@ public class TamingManager extends SkillManager {
if(jumpAttribute != null) {
double jumpStrength = jumpAttribute.getValue();
- // Taken from https://minecraft.gamepedia.com/Horse#Jump_strength
+ // Taken from https://minecraft.wiki/w/Horse#Jump_strength
jumpStrength = -0.1817584952 * Math.pow(jumpStrength, 3) + 3.689713992 * Math.pow(jumpStrength, 2) + 2.128599134 * jumpStrength - 0.343930367;
message = message.concat("\n" + LocaleLoader.getString("Combat.BeastLoreHorseSpeed", horseLikeCreature.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getValue() * 43))
.concat("\n" + LocaleLoader.getString("Combat.BeastLoreHorseJumpStrength", jumpStrength));
diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java b/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java
index 79cd4802b..8af370b9e 100644
--- a/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java
+++ b/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java
@@ -2,13 +2,13 @@ package com.gmail.nossr50.skills.taming;
import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.Misc;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
-public class TrackedTamingEntity extends BukkitRunnable {
+public class TrackedTamingEntity extends CancellableRunnable {
private final @NotNull LivingEntity livingEntity;
private final @NotNull CallOfTheWildType callOfTheWildType;
private final @NotNull Player player;
@@ -22,7 +22,7 @@ public class TrackedTamingEntity extends BukkitRunnable {
if (tamingCOTWLength > 0) {
int length = tamingCOTWLength * Misc.TICK_CONVERSION_FACTOR;
- this.runTaskLater(mcMMO.p, length);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(livingEntity, this, length);
}
}
diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java
index d0213ef93..6edb342a5 100644
--- a/src/main/java/com/gmail/nossr50/util/BlockUtils.java
+++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java
@@ -21,6 +21,9 @@ import java.util.HashSet;
public final class BlockUtils {
+ public static final String SHORT_GRASS = "SHORT_GRASS";
+ public static final String GRASS = "GRASS";
+
private BlockUtils() {
}
@@ -37,6 +40,21 @@ public final class BlockUtils {
blockState.setMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, new BonusDropMeta(1, mcMMO.p));
}
+ /**
+ * Util method for compatibility across Minecraft versions, grabs the {@link Material} enum for short_grass
+ *
+ * @return the {@link Material} enum for short_grass
+ */
+ public static Material getShortGrass() {
+ if (Material.getMaterial(SHORT_GRASS) != null) {
+ return Material.getMaterial(SHORT_GRASS);
+ } else if (Material.getMaterial(GRASS) != null) {
+ return Material.getMaterial(GRASS);
+ } else {
+ throw new UnsupportedOperationException("Unable to find short grass material");
+ }
+ }
+
/**
* Set up the state for a block to be seen as unnatural and cleanup any unwanted metadata from the block
* @param block target block
diff --git a/src/main/java/com/gmail/nossr50/util/CancellableRunnable.java b/src/main/java/com/gmail/nossr50/util/CancellableRunnable.java
new file mode 100644
index 000000000..a47cdcda3
--- /dev/null
+++ b/src/main/java/com/gmail/nossr50/util/CancellableRunnable.java
@@ -0,0 +1,28 @@
+package com.gmail.nossr50.util;
+
+import com.tcoded.folialib.wrapper.task.WrappedTask;
+
+import java.util.function.Consumer;
+
+public abstract class CancellableRunnable implements Consumer {
+ private boolean cancelled = false;
+
+ public void cancel() {
+ cancelled = true;
+ }
+
+ public abstract void run();
+
+ @Override
+ public void accept(WrappedTask wrappedTask) {
+ // Run the task if it hasn't been cancelled
+ if (!cancelled) {
+ run();
+ }
+
+ // Cancel the task if it has been cancelled after running
+ if (cancelled) {
+ wrappedTask.cancel();
+ }
+ }
+}
diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java
index 07bace1a5..e6ea0582c 100644
--- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java
+++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java
@@ -112,7 +112,7 @@ public final class ChimaeraWing {
if (warmup > 0) {
NotificationManager.sendPlayerInformation(player, NotificationType.ITEM_MESSAGE, "Teleport.Commencing", String.valueOf(warmup));
- new ChimaeraWingWarmup(mcMMOPlayer).runTaskLater(mcMMO.p, 20 * warmup);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new ChimaeraWingWarmup(mcMMOPlayer), 20 * warmup);
}
else {
chimaeraExecuteTeleport();
@@ -123,15 +123,18 @@ public final class ChimaeraWing {
Player player = mcMMOPlayer.getPlayer();
if (mcMMO.p.getGeneralConfig().getChimaeraUseBedSpawn() && player.getBedSpawnLocation() != null) {
- player.teleport(player.getBedSpawnLocation());
+// player.teleport(player.getBedSpawnLocation());
+ mcMMO.p.getFoliaLib().getImpl().teleportAsync(player, player.getBedSpawnLocation());
}
else {
Location spawnLocation = player.getWorld().getSpawnLocation();
if (spawnLocation.getBlock().getType() == Material.AIR) {
- player.teleport(spawnLocation);
+// player.teleport(spawnLocation);
+ mcMMO.p.getFoliaLib().getImpl().teleportAsync(player, spawnLocation);
}
else {
- player.teleport(player.getWorld().getHighestBlockAt(spawnLocation).getLocation());
+// player.teleport(player.getWorld().getHighestBlockAt(spawnLocation).getLocation());
+ mcMMO.p.getFoliaLib().getImpl().teleportAsync(player, player.getWorld().getHighestBlockAt(spawnLocation).getLocation());
}
}
diff --git a/src/main/java/com/gmail/nossr50/util/EventUtils.java b/src/main/java/com/gmail/nossr50/util/EventUtils.java
index 49d9b4d76..624340f3b 100644
--- a/src/main/java/com/gmail/nossr50/util/EventUtils.java
+++ b/src/main/java/com/gmail/nossr50/util/EventUtils.java
@@ -366,7 +366,8 @@ public final class EventUtils {
return;
}
- teleportingPlayer.teleport(targetPlayer);
+// teleportingPlayer.teleport(targetPlayer);
+ mcMMO.p.getFoliaLib().getImpl().teleportAsync(teleportingPlayer, targetPlayer.getLocation());
teleportingPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Player", targetPlayer.getName()));
targetPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Target", teleportingPlayer.getName()));
diff --git a/src/main/java/com/gmail/nossr50/util/FixSpellingNetheriteUtil.java b/src/main/java/com/gmail/nossr50/util/FixSpellingNetheriteUtil.java
index 3db284a9f..a9e6b4bea 100644
--- a/src/main/java/com/gmail/nossr50/util/FixSpellingNetheriteUtil.java
+++ b/src/main/java/com/gmail/nossr50/util/FixSpellingNetheriteUtil.java
@@ -8,7 +8,7 @@ import java.io.*;
public class FixSpellingNetheriteUtil {
public static void processFileCheck(mcMMO pluginRef, String fileName, UpgradeType upgradeType) {
- pluginRef.getLogger().info("Checking " + fileName + " config material names...");
+ LogUtils.debug(mcMMO.p.getLogger(), "Checking " + fileName + " config material names...");
File configFile = new File(pluginRef.getDataFolder(), fileName);
if(configFile.exists()) {
diff --git a/src/main/java/com/gmail/nossr50/util/HolidayManager.java b/src/main/java/com/gmail/nossr50/util/HolidayManager.java
index f89937844..6ea18317b 100644
--- a/src/main/java/com/gmail/nossr50/util/HolidayManager.java
+++ b/src/main/java/com/gmail/nossr50/util/HolidayManager.java
@@ -186,14 +186,14 @@
//
// for (File file : toDelete) {
// if (file.delete()) {
-// mcMMO.p.debug("Deleted: " + file.getName());
+// LogUtils.debug(mcMMO.p.getLogger(), "Deleted: " + file.getName());
// }
// }
// }
//
// // This gets called onDisable
// public void saveAnniversaryFiles() {
-// mcMMO.p.debug("Saving anniversary files...");
+// LogUtils.debug(mcMMO.p.getLogger(), "Saving anniversary files...");
// String anniversaryFilePath = mcMMO.getFlatFileDirectory() + "anniversary." + currentYear + ".yml";
//
// try {
diff --git a/src/main/java/com/gmail/nossr50/util/LogFilter.java b/src/main/java/com/gmail/nossr50/util/LogFilter.java
index 355c070e7..4a1ee3898 100644
--- a/src/main/java/com/gmail/nossr50/util/LogFilter.java
+++ b/src/main/java/com/gmail/nossr50/util/LogFilter.java
@@ -5,6 +5,8 @@ import com.gmail.nossr50.mcMMO;
import java.util.logging.Filter;
import java.util.logging.LogRecord;
+import static com.gmail.nossr50.util.LogUtils.DEBUG_STR;
+
public class LogFilter implements Filter {
private final boolean debug;
@@ -15,6 +17,6 @@ public class LogFilter implements Filter {
@Override
public boolean isLoggable(LogRecord record) {
- return !(record.getMessage().contains("[Debug]") && !debug);
+ return !(record.getMessage().contains(DEBUG_STR) && !debug);
}
}
diff --git a/src/main/java/com/gmail/nossr50/util/LogUtils.java b/src/main/java/com/gmail/nossr50/util/LogUtils.java
new file mode 100644
index 000000000..b0c114d00
--- /dev/null
+++ b/src/main/java/com/gmail/nossr50/util/LogUtils.java
@@ -0,0 +1,14 @@
+package com.gmail.nossr50.util;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.logging.Logger;
+
+public class LogUtils {
+
+ public static final String DEBUG_STR = "[D] ";
+
+ public static void debug(@NotNull Logger logger, @NotNull String message) {
+ logger.info(DEBUG_STR + message);
+ }
+}
diff --git a/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java b/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java
index 471f9af48..b0f623602 100644
--- a/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java
+++ b/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java
@@ -490,6 +490,7 @@ public class MaterialMapStore {
tools.addAll(tridents);
tools.addAll(stringTools);
tools.addAll(bows);
+ tools.addAll(crossbows);
}
private void fillBows() {
@@ -999,8 +1000,8 @@ public class MaterialMapStore {
private void fillShroomyWhiteList()
{
canMakeShroomyWhiteList.add("dirt");
- canMakeShroomyWhiteList.add("grass");
- canMakeShroomyWhiteList.add("grass_path");
+ canMakeShroomyWhiteList.add("grass_block");
+ canMakeShroomyWhiteList.add("dirt_path");
}
private void fillBlockCrackerWhiteList()
@@ -1013,8 +1014,8 @@ public class MaterialMapStore {
private void fillHerbalismAbilityBlackList()
{
herbalismAbilityBlackList.add("dirt");
- herbalismAbilityBlackList.add("grass");
- herbalismAbilityBlackList.add("grass_path");
+ herbalismAbilityBlackList.add("grass_block");
+ herbalismAbilityBlackList.add("dirt_path");
herbalismAbilityBlackList.add("farmland");
}
diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java
index 19d1a5dbb..2467a5540 100644
--- a/src/main/java/com/gmail/nossr50/util/Misc.java
+++ b/src/main/java/com/gmail/nossr50/util/Misc.java
@@ -12,7 +12,6 @@ import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.entity.*;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -255,7 +254,7 @@ public final class Misc {
if (player != null) {
UserManager.remove(player);
- new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
+ mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileLoadingTask(player), 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
}
@@ -326,7 +325,7 @@ public final class Misc {
experienceOrb.setExperience(experienceValue);
}
- private static class SpawnOrbTask extends BukkitRunnable {
+ private static class SpawnOrbTask implements Runnable {
private final Location location;
private int orbExpValue;
diff --git a/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java b/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java
index 2e952e625..a1d8023f8 100644
--- a/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java
+++ b/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java
@@ -81,7 +81,7 @@ public final class MobHealthbarUtils {
target.setMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY, new FixedMetadataValue(mcMMO.p, false));
}
- new MobHealthDisplayUpdaterTask(target).runTaskLater(mcMMO.p, (long) displayTime * Misc.TICK_CONVERSION_FACTOR); // Clear health display after 3 seconds
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(target, new MobHealthDisplayUpdaterTask(target), (long) displayTime * Misc.TICK_CONVERSION_FACTOR); // Clear health display after 3 seconds
}
}
diff --git a/src/main/java/com/gmail/nossr50/util/ModManager.java b/src/main/java/com/gmail/nossr50/util/ModManager.java
index 4ec27d192..19e1202ed 100644
--- a/src/main/java/com/gmail/nossr50/util/ModManager.java
+++ b/src/main/java/com/gmail/nossr50/util/ModManager.java
@@ -268,7 +268,7 @@ public class ModManager {
try {
entitiesFile.save(entityFile);
- mcMMO.p.debug(entity.getType().toString() + " was added to the custom entities file!");
+ LogUtils.debug(mcMMO.p.getLogger(), entity.getType().toString() + " was added to the custom entities file!");
}
catch (Exception e) {
e.printStackTrace();
diff --git a/src/main/java/com/gmail/nossr50/util/compat/CompatibilityManager.java b/src/main/java/com/gmail/nossr50/util/compat/CompatibilityManager.java
index 063c858c5..11d4a6d68 100644
--- a/src/main/java/com/gmail/nossr50/util/compat/CompatibilityManager.java
+++ b/src/main/java/com/gmail/nossr50/util/compat/CompatibilityManager.java
@@ -2,6 +2,7 @@ package com.gmail.nossr50.util.compat;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.compat.layers.bungee.AbstractBungeeSerializerCompatibilityLayer;
import com.gmail.nossr50.util.compat.layers.bungee.BungeeLegacySerializerCompatibilityLayer;
import com.gmail.nossr50.util.compat.layers.bungee.BungeeModernSerializerCompatibilityLayer;
@@ -34,11 +35,11 @@ public class CompatibilityManager {
private AbstractMasterAnglerCompatibility masterAnglerCompatibility;
public CompatibilityManager(@NotNull MinecraftGameVersion minecraftGameVersion) {
- mcMMO.p.getLogger().info("Loading compatibility layers...");
+ LogUtils.debug(mcMMO.p.getLogger(), "Loading compatibility layers...");
this.minecraftGameVersion = minecraftGameVersion;
this.nmsVersion = determineNMSVersion();
init();
- mcMMO.p.getLogger().info("Finished loading compatibility layers.");
+ LogUtils.debug(mcMMO.p.getLogger(), "Finished loading compatibility layers.");
}
private void init() {
diff --git a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java
index e77641d32..c4617bd69 100644
--- a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java
+++ b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java
@@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.ExperienceBarHideTask;
+import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.NotificationManager;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
@@ -77,7 +78,7 @@ public class ExperienceBarManager {
return;
ExperienceBarHideTask experienceBarHideTask = new ExperienceBarHideTask(this, mcMMOPlayer, primarySkillType);
- experienceBarHideTask.runTaskLater(plugin, 20L * delaySeconds);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(mcMMOPlayer.getPlayer(), experienceBarHideTask, (long) delaySeconds * Misc.TICK_CONVERSION_FACTOR);
experienceBarHideTaskHashMap.put(primarySkillType, experienceBarHideTask);
}
diff --git a/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java b/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java
index f7478e24c..6685e816b 100644
--- a/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java
+++ b/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java
@@ -4,6 +4,7 @@ import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
@@ -224,7 +225,7 @@ public class FormulaManager {
* Save formula file.
*/
public void saveFormula() {
- mcMMO.p.debug("Saving previous XP formula type...");
+ LogUtils.debug(mcMMO.p.getLogger(), "Saving previous XP formula type...");
YamlConfiguration formulasFile = new YamlConfiguration();
formulasFile.set("Previous_Formula", previousFormula.toString());
diff --git a/src/main/java/com/gmail/nossr50/util/platform/PlatformManager.java b/src/main/java/com/gmail/nossr50/util/platform/PlatformManager.java
index 989eb3da6..e68ff1912 100644
--- a/src/main/java/com/gmail/nossr50/util/platform/PlatformManager.java
+++ b/src/main/java/com/gmail/nossr50/util/platform/PlatformManager.java
@@ -1,6 +1,7 @@
package com.gmail.nossr50.util.platform;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.compat.CompatibilityManager;
import org.bukkit.Bukkit;
import org.jetbrains.annotations.NotNull;
@@ -47,7 +48,7 @@ public class PlatformManager {
private @NotNull MinecraftGameVersion determineGameVersion(String platformVersionString) {
int major = 0, minor = 0, patch = 0;
- mcMMO.p.getLogger().info("Platform String: " + platformVersionString);
+ LogUtils.debug(mcMMO.p.getLogger(), "Platform String: " + platformVersionString);
// Gets two numbers separated by . and optional third number after next dot. Must end with - or _
Matcher versionMatch = Pattern.compile("(\\d+)\\.(\\d+)(?:\\.(\\d+))?[-_].*").matcher(platformVersionString);
@@ -61,7 +62,7 @@ public class PlatformManager {
}
}
- mcMMO.p.getLogger().info("Minecraft version determined to be - "
+ LogUtils.debug(mcMMO.p.getLogger(), "Minecraft version determined to be - "
+ major + "."
+ minor + "."
+ patch);
diff --git a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java
index 5ae709683..615ae3fbb 100644
--- a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java
+++ b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java
@@ -16,7 +16,6 @@ import com.gmail.nossr50.util.sounds.SoundType;
import com.gmail.nossr50.util.text.McMMOMessageType;
import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.audience.Audience;
-import net.kyori.adventure.audience.MessageType;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.HoverEvent;
@@ -49,7 +48,9 @@ public class NotificationManager {
if(UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications())
return;
- McMMOMessageType destination = mcMMO.p.getAdvancedConfig().doesNotificationUseActionBar(notificationType) ? McMMOMessageType.ACTION_BAR : McMMOMessageType.SYSTEM;
+ McMMOMessageType destination
+ = mcMMO.p.getAdvancedConfig().doesNotificationUseActionBar(notificationType)
+ ? McMMOMessageType.ACTION_BAR : McMMOMessageType.SYSTEM;
Component message = TextComponentFactory.getNotificationTextComponentFromLocale(key);
McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(player, notificationType, destination, message);
@@ -75,7 +76,8 @@ public class NotificationManager {
* @param key Locale Key for the string to use with this event
* @param values values to be injected into the locale string
*/
- public static void sendNearbyPlayersInformation(Player targetPlayer, NotificationType notificationType, String key, String... values)
+ public static void sendNearbyPlayersInformation(Player targetPlayer, NotificationType notificationType, String key,
+ String... values)
{
sendPlayerInformation(targetPlayer, notificationType, key, values);
}
@@ -99,7 +101,8 @@ public class NotificationManager {
player.sendMessage(prefixFormattedMessage);
}
- public static void sendPlayerInformation(Player player, NotificationType notificationType, String key, String... values)
+ public static void sendPlayerInformation(Player player, NotificationType notificationType, String key,
+ String... values)
{
if(UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications())
return;
@@ -119,24 +122,28 @@ public class NotificationManager {
final Audience audience = mcMMO.getAudiences().player(player);
//If the message is being sent to the action bar we need to check if the copy if a copy is sent to the chat system
+ Component notificationTextComponent = customEvent.getNotificationTextComponent();
if(customEvent.getChatMessageType() == McMMOMessageType.ACTION_BAR)
{
- audience.sendActionBar(customEvent.getNotificationTextComponent());
+ audience.sendActionBar(notificationTextComponent);
if(customEvent.isMessageAlsoBeingSentToChat())
{
//Send copy to chat system
- audience.sendMessage(Identity.nil(), customEvent.getNotificationTextComponent(), MessageType.SYSTEM);
+ audience.sendMessage(notificationTextComponent);
}
} else {
- audience.sendMessage(Identity.nil(), customEvent.getNotificationTextComponent(), MessageType.SYSTEM);
+ audience.sendMessage(notificationTextComponent);
}
}
- private static McMMOPlayerNotificationEvent checkNotificationEvent(Player player, NotificationType notificationType, McMMOMessageType destination, Component message) {
+ private static McMMOPlayerNotificationEvent checkNotificationEvent(Player player, NotificationType notificationType,
+ McMMOMessageType destination,
+ Component message) {
//Init event
McMMOPlayerNotificationEvent customEvent = new McMMOPlayerNotificationEvent(player,
- notificationType, message, destination, mcMMO.p.getAdvancedConfig().doesNotificationSendCopyToChat(notificationType));
+ notificationType, message, destination,
+ mcMMO.p.getAdvancedConfig().doesNotificationSendCopyToChat(notificationType));
//Call event
Bukkit.getServer().getPluginManager().callEvent(customEvent);
@@ -149,15 +156,23 @@ public class NotificationManager {
* @param skillName skill that leveled up
* @param newLevel new level of that skill
*/
- public static void sendPlayerLevelUpNotification(McMMOPlayer mcMMOPlayer, PrimarySkillType skillName, int levelsGained, int newLevel)
+ public static void sendPlayerLevelUpNotification(McMMOPlayer mcMMOPlayer, PrimarySkillType skillName,
+ int levelsGained, int newLevel)
{
if(!mcMMOPlayer.useChatNotifications())
return;
- McMMOMessageType destination = mcMMO.p.getAdvancedConfig().doesNotificationUseActionBar(NotificationType.LEVEL_UP_MESSAGE) ? McMMOMessageType.ACTION_BAR : McMMOMessageType.SYSTEM;
+ McMMOMessageType destination
+ = mcMMO.p.getAdvancedConfig().doesNotificationUseActionBar(NotificationType.LEVEL_UP_MESSAGE)
+ ? McMMOMessageType.ACTION_BAR : McMMOMessageType.SYSTEM;
- Component levelUpTextComponent = TextComponentFactory.getNotificationLevelUpTextComponent(skillName, levelsGained, newLevel);
- McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(mcMMOPlayer.getPlayer(), NotificationType.LEVEL_UP_MESSAGE, destination, levelUpTextComponent);
+ Component levelUpTextComponent = TextComponentFactory.getNotificationLevelUpTextComponent(
+ skillName, levelsGained, newLevel);
+ McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(
+ mcMMOPlayer.getPlayer(),
+ NotificationType.LEVEL_UP_MESSAGE,
+ destination,
+ levelUpTextComponent);
sendNotification(mcMMOPlayer.getPlayer(), customEvent);
}
@@ -176,17 +191,12 @@ public class NotificationManager {
return;
//CHAT MESSAGE
- mcMMO.getAudiences().player(mcMMOPlayer.getPlayer()).sendMessage(Identity.nil(), TextComponentFactory.getSubSkillUnlockedNotificationComponents(mcMMOPlayer.getPlayer(), subSkillType));
+ mcMMO.getAudiences().player(mcMMOPlayer.getPlayer()).sendMessage(Identity.nil(),
+ TextComponentFactory.getSubSkillUnlockedNotificationComponents(mcMMOPlayer.getPlayer(), subSkillType));
//Unlock Sound Effect
- SoundManager.sendCategorizedSound(mcMMOPlayer.getPlayer(), mcMMOPlayer.getPlayer().getLocation(), SoundType.SKILL_UNLOCKED, SoundCategory.MASTER);
-
- //ACTION BAR MESSAGE
- /*if(mcMMO.p.getAdvancedConfig().doesNotificationUseActionBar(NotificationType.SUBSKILL_UNLOCKED))
- mcMMOPlayer.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(LocaleLoader.getString("JSON.SkillUnlockMessage",
- subSkillType.getLocaleName(),
- String.valueOf(RankUtils.getRank(mcMMOPlayer.getPlayer(),
- subSkillType)))));*/
+ SoundManager.sendCategorizedSound(mcMMOPlayer.getPlayer(), mcMMOPlayer.getPlayer().getLocation(),
+ SoundType.SKILL_UNLOCKED, SoundCategory.MASTER);
}
/**
@@ -225,7 +235,8 @@ public class NotificationManager {
* @param commandSender the command user
* @param sensitiveCommandType type of command issued
*/
- public static void processSensitiveCommandNotification(CommandSender commandSender, SensitiveCommandType sensitiveCommandType, String... args) {
+ public static void processSensitiveCommandNotification(CommandSender commandSender,
+ SensitiveCommandType sensitiveCommandType, String... args) {
/*
* Determine the 'identity' of the one who executed the command to pass as a parameters
*/
@@ -233,19 +244,26 @@ public class NotificationManager {
if(commandSender instanceof Player)
{
- senderName = ((Player) commandSender).getDisplayName() + ChatColor.RESET + "-" + ((Player) commandSender).getUniqueId();
+ senderName = ((Player) commandSender).getDisplayName()
+ + ChatColor.RESET + "-" + ((Player) commandSender).getUniqueId();
}
//Send the notification
switch(sensitiveCommandType)
{
case XPRATE_MODIFY:
- sendAdminNotification(LocaleLoader.getString("Notifications.Admin.XPRate.Start.Others", addItemToFirstPositionOfArray(senderName, args)));
- sendAdminCommandConfirmation(commandSender, LocaleLoader.getString("Notifications.Admin.XPRate.Start.Self", args));
+ sendAdminNotification(LocaleLoader.getString("Notifications.Admin.XPRate.Start.Others",
+ addItemToFirstPositionOfArray(senderName, args)));
+ sendAdminCommandConfirmation(
+ commandSender, LocaleLoader.getString("Notifications.Admin.XPRate.Start.Self", args));
break;
case XPRATE_END:
- sendAdminNotification(LocaleLoader.getString("Notifications.Admin.XPRate.End.Others", addItemToFirstPositionOfArray(senderName, args)));
- sendAdminCommandConfirmation(commandSender, LocaleLoader.getString("Notifications.Admin.XPRate.End.Self", args));
+ sendAdminNotification(
+ LocaleLoader.getString(
+ "Notifications.Admin.XPRate.End.Others",
+ addItemToFirstPositionOfArray(senderName, args)));
+ sendAdminCommandConfirmation(commandSender,
+ LocaleLoader.getString("Notifications.Admin.XPRate.End.Self", args));
break;
}
}
@@ -266,8 +284,6 @@ public class NotificationManager {
return newArray;
}
- //TODO: Remove the code duplication, am lazy atm
- //TODO: Fix broadcasts being skipped for situations where a player skips over the milestone like with the addlevels command
public static void processLevelUpBroadcasting(@NotNull McMMOPlayer mmoPlayer, @NotNull PrimarySkillType primarySkillType, int level) {
if(level <= 0)
return;
@@ -290,13 +306,22 @@ public class NotificationManager {
.append(Component.newline())
.append(Component.text(LocalDate.now().toString()))
.append(Component.newline())
- .append(Component.text(mcMMO.p.getSkillTools().getLocalizedSkillName(primarySkillType)+" reached level "+level)).color(TextColor.fromHexString(HEX_BEIGE_COLOR))
+ .append(Component.text(
+ mcMMO.p.getSkillTools().getLocalizedSkillName(primarySkillType)
+ + " reached level "+level)).color(TextColor.fromHexString(HEX_BEIGE_COLOR))
.asHoverEvent();
- String localeMessage = LocaleLoader.getString("Broadcasts.LevelUpMilestone", mmoPlayer.getPlayer().getDisplayName(), level, mcMMO.p.getSkillTools().getLocalizedSkillName(primarySkillType));
- Component message = LegacyComponentSerializer.legacySection().deserialize(localeMessage).hoverEvent(levelMilestoneHover);
+ String localeMessage = LocaleLoader.getString(
+ "Broadcasts.LevelUpMilestone", mmoPlayer.getPlayer().getDisplayName(), level,
+ mcMMO.p.getSkillTools().getLocalizedSkillName(primarySkillType));
+ Component component = LegacyComponentSerializer
+ .legacySection()
+ .deserialize(localeMessage)
+ .hoverEvent(levelMilestoneHover);
- Bukkit.getScheduler().runTaskLater(mcMMO.p, () -> audience.sendMessage(Identity.nil(), message), 0);
+ // TODO: Update system msg API
+ mcMMO.p.getFoliaLib().getImpl().runNextTick(
+ t -> audience.sendMessage(component));
}
}
}
@@ -331,7 +356,7 @@ public class NotificationManager {
String localeMessage = LocaleLoader.getString("Broadcasts.PowerLevelUpMilestone", mmoPlayer.getPlayer().getDisplayName(), powerLevel);
Component message = LegacyComponentSerializer.legacySection().deserialize(localeMessage).hoverEvent(levelMilestoneHover);
- Bukkit.getScheduler().runTaskLater(mcMMO.p, () -> audience.sendMessage(Identity.nil(), message), 0);
+ mcMMO.p.getFoliaLib().getImpl().runNextTick(t -> audience.sendMessage(message));
}
}
}
diff --git a/src/main/java/com/gmail/nossr50/util/player/UserManager.java b/src/main/java/com/gmail/nossr50/util/player/UserManager.java
index ef0b63e43..a7f4a840b 100644
--- a/src/main/java/com/gmail/nossr50/util/player/UserManager.java
+++ b/src/main/java/com/gmail/nossr50/util/player/UserManager.java
@@ -2,6 +2,7 @@ package com.gmail.nossr50.util.player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.MetadataConstants;
import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer;
@@ -85,7 +86,7 @@ public final class UserManager {
for (McMMOPlayer playerData : trackedSyncData) {
try
{
- mcMMO.p.getLogger().info("Saving data for player: "+playerData.getPlayerName());
+ LogUtils.debug(mcMMO.p.getLogger(), "Saving data for player: "+playerData.getPlayerName());
playerData.getProfile().save(true);
}
catch (Exception e)
diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java
index 1851f5479..331d3f5b3 100644
--- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java
+++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java
@@ -9,6 +9,7 @@ import com.gmail.nossr50.events.scoreboard.McMMOScoreboardMakeboardEvent;
import com.gmail.nossr50.events.scoreboard.ScoreboardEventReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
@@ -204,7 +205,7 @@ public class ScoreboardManager {
// Called in onDisable()
public static void teardownAll() {
ImmutableList onlinePlayers = ImmutableList.copyOf(mcMMO.p.getServer().getOnlinePlayers());
- mcMMO.p.debug("Tearing down scoreboards... (" + onlinePlayers.size() + ")");
+ LogUtils.debug(mcMMO.p.getLogger(), "Tearing down scoreboards... (" + onlinePlayers.size() + ")");
for (Player player : onlinePlayers) {
teardownPlayer(player);
}
@@ -524,7 +525,7 @@ public class ScoreboardManager {
if (objective != null) {
objective.unregister();
- mcMMO.p.debug("Removed leftover targetBoard objects from Power Level Tags.");
+ LogUtils.debug(mcMMO.p.getLogger(), "Removed leftover targetBoard objects from Power Level Tags.");
}
return null;
diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java
index 24634bad2..1237ce086 100644
--- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java
+++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java
@@ -12,17 +12,16 @@ import com.gmail.nossr50.events.scoreboard.ScoreboardObjectiveEventReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.child.FamilyTree;
+import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.Misc;
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;
@@ -85,9 +84,9 @@ public class ScoreboardWrapper {
}
}
- public BukkitTask updateTask = null;
+ public WrappedTask updateTask = null;
- private class ScoreboardQuickUpdate extends BukkitRunnable {
+ private class ScoreboardQuickUpdate implements Runnable {
@Override
public void run() {
updateSidebar();
@@ -95,9 +94,9 @@ public class ScoreboardWrapper {
}
}
- public BukkitTask revertTask = null;
+ public WrappedTask revertTask = null;
- private class ScoreboardChangeTask extends BukkitRunnable {
+ private class ScoreboardChangeTask implements Runnable {
@Override
public void run() {
tryRevertBoard();
@@ -105,9 +104,9 @@ public class ScoreboardWrapper {
}
}
- public BukkitTask cooldownTask = null;
+ public WrappedTask cooldownTask = null;
- private class ScoreboardCooldownTask extends BukkitRunnable {
+ private class ScoreboardCooldownTask implements Runnable {
@Override
public void run() {
// Stop updating if it's no longer something displaying cooldowns
@@ -124,7 +123,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(mcMMO.p, 2L);
+ updateTask = mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new ScoreboardQuickUpdate(), 2L);
}
}
@@ -132,7 +131,7 @@ public class ScoreboardWrapper {
if (cooldownTask == null) {
// Repeat every 5 seconds.
// Cancels once all cooldowns are done, using stopCooldownUpdating().
- cooldownTask = new ScoreboardCooldownTask().runTaskTimer(mcMMO.p, 5 * Misc.TICK_CONVERSION_FACTOR, 5 * Misc.TICK_CONVERSION_FACTOR);
+ cooldownTask = mcMMO.p.getFoliaLib().getImpl().runAtEntityTimer(player, new ScoreboardCooldownTask(), 5 * Misc.TICK_CONVERSION_FACTOR, 5 * Misc.TICK_CONVERSION_FACTOR);
}
}
@@ -215,7 +214,7 @@ public class ScoreboardWrapper {
}
player.setScoreboard(scoreboard);
- revertTask = new ScoreboardChangeTask().runTaskLater(mcMMO.p, ticks);
+ revertTask = mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new ScoreboardChangeTask(), 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));
@@ -260,7 +259,7 @@ public class ScoreboardWrapper {
oldBoard = null;
}
else {
- mcMMO.p.debug("Not reverting targetBoard for " + playerName + " - targetBoard was changed by another plugin (Consider disabling the mcMMO scoreboards if you don't want them!)");
+ LogUtils.debug(mcMMO.p.getLogger(), "Not reverting targetBoard for " + playerName + " - targetBoard was changed by another plugin (Consider disabling the mcMMO scoreboards if you don't want them!)");
}
}
@@ -419,13 +418,13 @@ public class ScoreboardWrapper {
} catch (IllegalStateException e) {
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
- mcMMO.p.debug("Recovering scoreboard for player: " + player.getName());
+ LogUtils.debug(mcMMO.p.getLogger(), "Recovering scoreboard for player: " + player.getName());
if(mmoPlayer.isDebugMode())
NotificationManager.sendPlayerInformationChatOnlyPrefixed(player, "Scoreboard.Recovery");
initBoard(); //Start over
- Bukkit.getScheduler().runTaskLater(mcMMO.p, () -> ScoreboardManager.retryLastSkillBoard(player), 0);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntity(player, t -> ScoreboardManager.retryLastSkillBoard(player));
}
}
diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java
index 45f30203b..7654d4ac9 100644
--- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java
+++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java
@@ -24,7 +24,6 @@ import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.UserManager;
-import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
@@ -840,7 +839,8 @@ public final class CombatUtils {
EntityType type = target.getType();
baseXP = ExperienceConfig.getInstance().getAnimalsXP(type);
}
- else if (target instanceof Monster) {
+ else if (target instanceof Monster)
+ {
EntityType type = target.getType();
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
}
@@ -887,7 +887,7 @@ public final class CombatUtils {
baseXP *= multiplier;
if (baseXP > 0) {
- new AwardCombatXpTask(mcMMOPlayer, primarySkillType, baseXP, target, xpGainReason).runTaskLater(mcMMO.p, 0);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntity(mcMMOPlayer.getPlayer(), new AwardCombatXpTask(mcMMOPlayer, primarySkillType, baseXP, target, xpGainReason));
}
}
@@ -1062,6 +1062,6 @@ public final class CombatUtils {
* @param entity the projectile
*/
public static void delayArrowMetaCleanup(@NotNull Projectile entity) {
- Bukkit.getServer().getScheduler().runTaskLater(mcMMO.p, () -> cleanupArrowMetadata(entity), 20*60);
+ mcMMO.p.getFoliaLib().getImpl().runLater(() -> cleanupArrowMetadata(entity), 20*60);
}
}
diff --git a/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java b/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java
index 4af318e9d..e06497128 100644
--- a/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java
+++ b/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java
@@ -48,7 +48,7 @@ public class RankUtils {
{
SkillUnlockNotificationTask skillUnlockNotificationTask = new SkillUnlockNotificationTask(mcMMOPlayer, subSkillType, newLevel);
- skillUnlockNotificationTask.runTaskLater(plugin, (count * 100L));
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(mcMMOPlayer.getPlayer(), skillUnlockNotificationTask, (count * 100L));
count++;
}
@@ -294,23 +294,6 @@ public class RankUtils {
subSkillRanks.computeIfAbsent(s, k -> new HashMap<>());
}
-/* public static int getSubSkillUnlockRequirement(SubSkillType subSkillType)
- {
- String skillName = subSkillType.toString();
- int numRanks = subSkillType.getNumRanks();
-
- if(subSkillRanks == null)
- subSkillRanks = new HashMap<>();
-
- if(numRanks == 0)
- return -1; //-1 Means the skill doesn't have ranks
-
- if(subSkillRanks.get(skillName) == null && numRanks > 0)
- addRanks(subSkillType);
-
- return subSkillRanks.get(subSkillType.toString()).get(1);
- }*/
-
/**
* Gets the unlock level for a specific rank in a subskill
* @param subSkillType The target subskill
diff --git a/src/main/java/com/gmail/nossr50/util/text/TextComponentFactory.java b/src/main/java/com/gmail/nossr50/util/text/TextComponentFactory.java
index 7554f78d2..65edc3d9e 100644
--- a/src/main/java/com/gmail/nossr50/util/text/TextComponentFactory.java
+++ b/src/main/java/com/gmail/nossr50/util/text/TextComponentFactory.java
@@ -12,8 +12,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.RankUtils;
import net.kyori.adventure.audience.Audience;
-import net.kyori.adventure.audience.MessageType;
-import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.ClickEvent;
@@ -35,41 +33,37 @@ public class TextComponentFactory {
/**
* Makes a text component using strings from a locale and supports passing an undefined number of variables to the LocaleLoader
+ *
* @param localeKey target locale string address
- * @param values vars to be passed to the locale loader
+ * @param values vars to be passed to the locale loader
* @return
*/
- public static TextComponent getNotificationMultipleValues(String localeKey, String... values)
- {
+ public static TextComponent getNotificationMultipleValues(String localeKey, String... values) {
String preColoredString = LocaleLoader.getString(localeKey, (Object[]) values);
return Component.text(preColoredString);
}
- public static Component getNotificationTextComponentFromLocale(String localeKey)
- {
+ public static Component getNotificationTextComponentFromLocale(String localeKey) {
return getNotificationTextComponent(LocaleLoader.getString(localeKey));
}
- public static Component getNotificationLevelUpTextComponent(PrimarySkillType skill, int levelsGained, int currentLevel)
- {
- return Component.text(LocaleLoader.getString("Overhaul.Levelup", LocaleLoader.getString("Overhaul.Name."+ StringUtils.getCapitalized(skill.toString())), levelsGained, currentLevel));
+ public static Component getNotificationLevelUpTextComponent(PrimarySkillType skill, int levelsGained, int currentLevel) {
+ return Component.text(LocaleLoader.getString("Overhaul.Levelup", LocaleLoader.getString("Overhaul.Name." + StringUtils.getCapitalized(skill.toString())), levelsGained, currentLevel));
}
- private static TextComponent getNotificationTextComponent(String text)
- {
+ private static TextComponent getNotificationTextComponent(String text) {
//textComponent.setColor(getNotificationColor(notificationType));
return Component.text(text);
}
- public static void sendPlayerSubSkillWikiLink(Player player, String subskillformatted)
- {
- if(!mcMMO.p.getGeneralConfig().getUrlLinksEnabled())
+ public static void sendPlayerSubSkillWikiLink(Player player, String subskillformatted) {
+ if (!mcMMO.p.getGeneralConfig().getUrlLinksEnabled())
return;
TextComponent.Builder wikiLinkComponent = Component.text().content(LocaleLoader.getString("Overhaul.mcMMO.MmoInfo.Wiki"));
wikiLinkComponent.decoration(TextDecoration.UNDERLINED, true);
- String wikiUrl = "https://wiki.mcmmo.org/"+subskillformatted;
+ String wikiUrl = "https://wiki.mcmmo.org/" + subskillformatted;
wikiLinkComponent.clickEvent(ClickEvent.openUrl(wikiUrl));
@@ -77,39 +71,40 @@ public class TextComponentFactory {
wikiLinkComponent.hoverEvent(HoverEvent.showText(componentBuilder.build()));
- mcMMO.getAudiences().player(player).sendMessage(Identity.nil(), wikiLinkComponent, MessageType.SYSTEM);
+ mcMMO.getAudiences().player(player).sendMessage(wikiLinkComponent);
}
public static void sendPlayerUrlHeader(Player player) {
TextComponent prefix = Component.text(LocaleLoader.getString("Overhaul.mcMMO.Url.Wrap.Prefix") + " ");
/*prefix.setColor(ChatColor.DARK_AQUA);*/
- TextComponent suffix = Component.text(" "+LocaleLoader.getString("Overhaul.mcMMO.Url.Wrap.Suffix"));
+ TextComponent suffix = Component.text(" " + LocaleLoader.getString("Overhaul.mcMMO.Url.Wrap.Suffix"));
/*suffix.setColor(ChatColor.DARK_AQUA);*/
TextComponent emptySpace = Component.space();
- mcMMO.getAudiences().player(player).sendMessage(Identity.nil(),Component.textOfChildren(
- prefix,
- getWebLinkTextComponent(McMMOWebLinks.WEBSITE),
- emptySpace,
- getWebLinkTextComponent(McMMOWebLinks.DISCORD),
- emptySpace,
- getWebLinkTextComponent(McMMOWebLinks.PATREON),
- emptySpace,
- getWebLinkTextComponent(McMMOWebLinks.WIKI),
- emptySpace,
- getWebLinkTextComponent(McMMOWebLinks.SPIGOT),
- emptySpace,
- getWebLinkTextComponent(McMMOWebLinks.HELP_TRANSLATE),
- suffix
- ), MessageType.SYSTEM);
+ // TODO: Update system msg API
+ mcMMO.getAudiences().player(player).sendMessage(Component.textOfChildren(
+ prefix,
+ getWebLinkTextComponent(McMMOWebLinks.WEBSITE),
+ emptySpace,
+ getWebLinkTextComponent(McMMOWebLinks.DISCORD),
+ emptySpace,
+ getWebLinkTextComponent(McMMOWebLinks.PATREON),
+ emptySpace,
+ getWebLinkTextComponent(McMMOWebLinks.WIKI),
+ emptySpace,
+ getWebLinkTextComponent(McMMOWebLinks.SPIGOT),
+ emptySpace,
+ getWebLinkTextComponent(McMMOWebLinks.HELP_TRANSLATE),
+ suffix
+ ));
}
/**
* Sends a player a bunch of text components that represent a list of sub-skills
* Styling and formatting is applied before sending the messages
*
- * @param player target player
+ * @param player target player
* @param subSkillComponents the text components representing the sub-skills by name
*/
public static void sendPlayerSubSkillList(@NotNull Player player, @NotNull List subSkillComponents) {
@@ -129,13 +124,12 @@ public class TextComponentFactory {
}
//Send each group
- for(Component curLine : individualLinesToSend) {
- audience.sendMessage(Identity.nil(), curLine);
+ for (Component curLine : individualLinesToSend) {
+ audience.sendMessage(curLine);
}
}
- private static Component getWebLinkTextComponent(McMMOWebLinks webLinks)
- {
+ private static Component getWebLinkTextComponent(McMMOWebLinks webLinks) {
TextComponent.Builder webTextComponent;
switch (webLinks) {
@@ -178,8 +172,7 @@ public class TextComponentFactory {
return webTextComponent.build();
}
- private static Component getUrlHoverEvent(McMMOWebLinks webLinks)
- {
+ private static Component getUrlHoverEvent(McMMOWebLinks webLinks) {
TextComponent.Builder componentBuilder = Component.text().content(webLinks.getNiceTitle());
switch (webLinks) {
@@ -232,13 +225,11 @@ public class TextComponentFactory {
componentBuilder.append(Component.text(webLinks.getUrl(), NamedTextColor.GRAY, TextDecoration.ITALIC));
}
- private static ClickEvent getUrlClickEvent(String url)
- {
+ private static ClickEvent getUrlClickEvent(String url) {
return ClickEvent.openUrl(url);
}
- private static Component getSubSkillTextComponent(Player player, SubSkillType subSkillType)
- {
+ private static Component getSubSkillTextComponent(Player player, SubSkillType subSkillType) {
//Get skill name
String skillName = subSkillType.getLocaleName();
@@ -255,8 +246,7 @@ public class TextComponentFactory {
return textComponent.build();
}
- private static TextComponent getSubSkillTextComponent(Player player, AbstractSubSkill abstractSubSkill)
- {
+ private static TextComponent getSubSkillTextComponent(Player player, AbstractSubSkill abstractSubSkill) {
//String key = abstractSubSkill.getConfigKeyName();
String skillName = abstractSubSkill.getNiceName();
@@ -295,46 +285,37 @@ public class TextComponentFactory {
return textComponent;
}
- private static Component getSubSkillHoverComponent(Player player, AbstractSubSkill abstractSubSkill)
- {
+ private static Component getSubSkillHoverComponent(Player player, AbstractSubSkill abstractSubSkill) {
return getSubSkillHoverEventJSON(abstractSubSkill, player);
}
- private static Component getSubSkillHoverComponent(Player player, SubSkillType subSkillType)
- {
+ private static Component getSubSkillHoverComponent(Player player, SubSkillType subSkillType) {
return getSubSkillHoverEventJSON(subSkillType, player);
}
/**
* Used for the skill in the new skill system (Deriving from AbstractSubSkill)
+ *
* @param abstractSubSkill this subskill
- * @param player the player who owns this subskill
+ * @param player the player who owns this subskill
* @return the hover basecomponent object for this subskill
*/
- private static Component getSubSkillHoverEventJSON(AbstractSubSkill abstractSubSkill, Player player)
- {
+ private static Component getSubSkillHoverEventJSON(AbstractSubSkill abstractSubSkill, Player player) {
String skillName = abstractSubSkill.getNiceName();
/*
* Hover Event BaseComponent color table
*/
- TextColor ccSubSkillHeader = NamedTextColor.GOLD;
- TextColor ccRank = NamedTextColor.BLUE;
- TextColor ccCurRank = NamedTextColor.GREEN;
- TextColor ccPossessive = NamedTextColor.WHITE;
- //ChatColor ccDescriptionHeader = ChatColor.DARK_PURPLE;
- //ChatColor ccDescription = ChatColor.WHITE;
- TextColor ccLocked = NamedTextColor.DARK_GRAY;
- TextColor ccLevelRequirement = NamedTextColor.BLUE;
- TextColor ccLevelRequired = NamedTextColor.RED;
+ TextColor ccLocked = NamedTextColor.DARK_GRAY;
+ TextColor ccLevelRequirement = NamedTextColor.BLUE;
+ TextColor ccLevelRequired = NamedTextColor.RED;
SubSkillType subSkillType = abstractSubSkill.getSubSkillType();
//SubSkillType Name
TextComponent.Builder componentBuilder = setupSkillComponentNameStyle(player, skillName, subSkillType, RankUtils.hasUnlockedSubskill(player, abstractSubSkill));
- if(!RankUtils.hasUnlockedSubskill(player, abstractSubSkill))
- {
+ if (!RankUtils.hasUnlockedSubskill(player, abstractSubSkill)) {
//Skill is not unlocked yet
addLocked(abstractSubSkill, ccLocked, ccLevelRequirement, ccLevelRequired, componentBuilder);
} else {
@@ -344,12 +325,11 @@ public class TextComponentFactory {
int curRank = RankUtils.getRank(player, abstractSubSkill);
int nextRank = 0;
- if(curRank < abstractSubSkill.getNumRanks() && abstractSubSkill.getNumRanks() > 0)
- {
- nextRank = RankUtils.getRankUnlockLevel(abstractSubSkill, curRank+1);
+ if (curRank < abstractSubSkill.getNumRanks() && abstractSubSkill.getNumRanks() > 0) {
+ nextRank = RankUtils.getRankUnlockLevel(abstractSubSkill, curRank + 1);
}
- addRanked(ccRank, ccCurRank, ccPossessive, ccCurRank, componentBuilder, abstractSubSkill.getNumRanks(), RankUtils.getRank(player, abstractSubSkill), nextRank);
+ addRanked(componentBuilder, abstractSubSkill.getNumRanks(), RankUtils.getRank(player, abstractSubSkill), nextRank);
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.DescriptionHeader")));
componentBuilder.append(Component.newline()).append(Component.text(abstractSubSkill.getDescription())).append(Component.newline());
@@ -384,17 +364,14 @@ public class TextComponentFactory {
return componentBuilder;
}
- private static void addRanked(TextColor ccRank, TextColor ccCurRank, TextColor ccPossessive, TextColor ccNumRanks, TextComponent.Builder componentBuilder, int numRanks, int rank, int nextRank) {
+ private static void addRanked(TextComponent.Builder componentBuilder, int numRanks, int rank, int nextRank) {
if (numRanks > 0) {
//Rank: x
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Hover.Rank", String.valueOf(rank)))).append(Component.newline());
//Next Rank: x
- if(nextRank > rank)
+ if (nextRank > rank)
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Hover.NextRank", String.valueOf(nextRank)))).append(Component.newline());
-
- /*componentBuilder.append(" " + LocaleLoader.getString("JSON.RankPossesive") + " ").color(ccPossessive);
- componentBuilder.append(String.valueOf(numRanks)).color(ccNumRanks);*/
}
}
@@ -416,47 +393,38 @@ public class TextComponentFactory {
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.LevelRequirement") + ": ", ccLevelRequirement));
}
- @Deprecated
- private static Component getSubSkillHoverEventJSON(SubSkillType subSkillType, Player player)
- {
+ private static Component getSubSkillHoverEventJSON(SubSkillType subSkillType, Player player) {
String skillName = subSkillType.getLocaleName();
/*
* Hover Event BaseComponent color table
*/
- TextColor ccSubSkillHeader = NamedTextColor.GOLD;
- TextColor ccRank = NamedTextColor.BLUE;
- TextColor ccCurRank = NamedTextColor.GREEN;
- TextColor ccPossessive = NamedTextColor.WHITE;
- TextColor ccDescriptionHeader = NamedTextColor.DARK_PURPLE;
- TextColor ccDescription = NamedTextColor.DARK_GRAY;
- TextColor ccLocked = NamedTextColor.DARK_GRAY;
- TextColor ccLevelRequirement = NamedTextColor.BLUE;
- TextColor ccLevelRequired = NamedTextColor.RED;
+ TextColor ccDescriptionHeader = NamedTextColor.DARK_PURPLE;
+ TextColor ccDescription = NamedTextColor.DARK_GRAY;
+ TextColor ccLocked = NamedTextColor.DARK_GRAY;
+ TextColor ccLevelRequirement = NamedTextColor.BLUE;
+ TextColor ccLevelRequired = NamedTextColor.RED;
//SubSkillType Name
TextComponent.Builder componentBuilder = setupSkillComponentNameStyle(player, skillName, subSkillType, RankUtils.hasUnlockedSubskill(player, subSkillType));
- if(!RankUtils.hasUnlockedSubskill(player, subSkillType))
- {
+ if (!RankUtils.hasUnlockedSubskill(player, subSkillType)) {
//Skill is not unlocked yet
addLocked(subSkillType, ccLocked, ccLevelRequirement, ccLevelRequired, componentBuilder);
} else {
//addSubSkillTypeToHoverEventJSON(subSkillType, componentBuilder);
//RANK
- if(subSkillType.getNumRanks() > 0)
- {
+ if (subSkillType.getNumRanks() > 0) {
int curRank = RankUtils.getRank(player, subSkillType);
int nextRank = 0;
- if(curRank < subSkillType.getNumRanks())
- {
- nextRank = RankUtils.getRankUnlockLevel(subSkillType, curRank+1);
+ if (curRank < subSkillType.getNumRanks()) {
+ nextRank = RankUtils.getRankUnlockLevel(subSkillType, curRank + 1);
}
- addRanked(ccRank, ccCurRank, ccPossessive, ccCurRank, componentBuilder, subSkillType.getNumRanks(), RankUtils.getRank(player, subSkillType), nextRank);
-
+ addRanked(componentBuilder, subSkillType.getNumRanks(),
+ RankUtils.getRank(player, subSkillType), nextRank);
}
componentBuilder.append(Component.newline());
@@ -470,55 +438,52 @@ public class TextComponentFactory {
return componentBuilder.build();
}
- private static void addSubSkillTypeToHoverEventJSON(AbstractSubSkill abstractSubSkill, TextComponent.Builder componentBuilder)
- {
- if(abstractSubSkill.isSuperAbility())
- {
- componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Type.SuperAbility"), NamedTextColor.LIGHT_PURPLE, TextDecoration.BOLD));
- } else if(abstractSubSkill.isActiveUse())
- {
- componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Type.Active"), NamedTextColor.DARK_RED, TextDecoration.BOLD));
+ private static void addSubSkillTypeToHoverEventJSON(AbstractSubSkill abstractSubSkill,
+ TextComponent.Builder componentBuilder) {
+ if (abstractSubSkill.isSuperAbility()) {
+ componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Type.SuperAbility"),
+ NamedTextColor.LIGHT_PURPLE, TextDecoration.BOLD));
+ } else if (abstractSubSkill.isActiveUse()) {
+ componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Type.Active"),
+ NamedTextColor.DARK_RED, TextDecoration.BOLD));
} else {
- componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Type.Passive"), NamedTextColor.GREEN, TextDecoration.BOLD));
+ componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Type.Passive"),
+ NamedTextColor.GREEN, TextDecoration.BOLD));
}
componentBuilder.append(Component.newline());
}
- public static void getSubSkillTextComponents(Player player, List textComponents, PrimarySkillType parentSkill) {
- for(SubSkillType subSkillType : SubSkillType.values())
- {
- if(subSkillType.getParentSkill() == parentSkill)
- {
+ public static void getSubSkillTextComponents(Player player, List textComponents,
+ PrimarySkillType parentSkill) {
+ for (SubSkillType subSkillType : SubSkillType.values()) {
+ if (subSkillType.getParentSkill() == parentSkill) {
//TODO: Hacky rewrite later
//Only some versions of MC have this skill
- if(subSkillType == SubSkillType.FISHING_MASTER_ANGLER && mcMMO.getCompatibilityManager().getMasterAnglerCompatibilityLayer() == null)
+ if (subSkillType == SubSkillType.FISHING_MASTER_ANGLER
+ && mcMMO.getCompatibilityManager().getMasterAnglerCompatibilityLayer() == null)
continue;
- if(Permissions.isSubSkillEnabled(player, subSkillType))
- {
- if(!InteractionManager.hasSubSkill(subSkillType))
+ if (Permissions.isSubSkillEnabled(player, subSkillType)) {
+ if (!InteractionManager.hasSubSkill(subSkillType))
textComponents.add(TextComponentFactory.getSubSkillTextComponent(player, subSkillType));
}
}
}
/* NEW SKILL SYSTEM */
- for(AbstractSubSkill abstractSubSkill : InteractionManager.getSubSkillList())
- {
- if(abstractSubSkill.getPrimarySkill() == parentSkill)
- {
- if(Permissions.isSubSkillEnabled(player, abstractSubSkill.getSubSkillType()))
+ for (AbstractSubSkill abstractSubSkill : InteractionManager.getSubSkillList()) {
+ if (abstractSubSkill.getPrimarySkill() == parentSkill) {
+ if (Permissions.isSubSkillEnabled(player, abstractSubSkill.getSubSkillType()))
textComponents.add(TextComponentFactory.getSubSkillTextComponent(player, abstractSubSkill));
}
}
}
- public static TextComponent getSubSkillUnlockedNotificationComponents(Player player, SubSkillType subSkillType)
- {
+ public static TextComponent getSubSkillUnlockedNotificationComponents(Player player, SubSkillType subSkillType) {
TextComponent.Builder unlockMessage = Component.text().content(LocaleLoader.getString("JSON.SkillUnlockMessage", subSkillType.getLocaleName(), RankUtils.getRank(player, subSkillType)));
unlockMessage.hoverEvent(HoverEvent.showText(getSubSkillHoverComponent(player, subSkillType)));
- unlockMessage.clickEvent(ClickEvent.runCommand("/"+subSkillType.getParentSkill().toString().toLowerCase(Locale.ENGLISH)));
+ unlockMessage.clickEvent(ClickEvent.runCommand("/" + subSkillType.getParentSkill().toString().toLowerCase(Locale.ENGLISH)));
return unlockMessage.build();
}
}
diff --git a/src/main/java/com/gmail/nossr50/util/upgrade/UpgradeManager.java b/src/main/java/com/gmail/nossr50/util/upgrade/UpgradeManager.java
index 2325b2800..4bb13f6eb 100644
--- a/src/main/java/com/gmail/nossr50/util/upgrade/UpgradeManager.java
+++ b/src/main/java/com/gmail/nossr50/util/upgrade/UpgradeManager.java
@@ -3,6 +3,7 @@ package com.gmail.nossr50.util.upgrade;
import com.gmail.nossr50.config.BukkitConfig;
import com.gmail.nossr50.datatypes.database.UpgradeType;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import java.util.Arrays;
import java.util.EnumSet;
@@ -41,7 +42,7 @@ public class UpgradeManager extends BukkitConfig {
return;
}
- mcMMO.p.debug("Saving upgrade status for type " + type.toString() + "...");
+ LogUtils.debug(mcMMO.p.getLogger(), "Saving upgrade status for type " + type.toString() + "...");
config.set("Upgrades_Finished." + type.toString(), true);
@@ -61,6 +62,6 @@ public class UpgradeManager extends BukkitConfig {
}
}
- mcMMO.p.debug("Needed upgrades: " + Arrays.toString(setNeededUpgrades.toArray(new UpgradeType[setNeededUpgrades.size()])));
+ LogUtils.debug(mcMMO.p.getLogger(), "Needed upgrades: " + Arrays.toString(setNeededUpgrades.toArray(new UpgradeType[setNeededUpgrades.size()])));
}
}
diff --git a/src/main/java/com/gmail/nossr50/worldguard/WorldGuardManager.java b/src/main/java/com/gmail/nossr50/worldguard/WorldGuardManager.java
index 3e4ea3386..29b4e89c2 100644
--- a/src/main/java/com/gmail/nossr50/worldguard/WorldGuardManager.java
+++ b/src/main/java/com/gmail/nossr50/worldguard/WorldGuardManager.java
@@ -1,6 +1,7 @@
package com.gmail.nossr50.worldguard;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldguard.WorldGuard;
@@ -94,7 +95,7 @@ public class WorldGuardManager {
registry.register(WorldGuardFlags.MCMMO_ENABLE_WG_FLAG);
registry.register(WorldGuardFlags.MCMMO_XP_WG_FLAG);
registry.register(WorldGuardFlags.MCMMO_HARDCORE_WG_FLAG);
- mcMMO.p.getLogger().info("Registered WG flags successfully!");
+ LogUtils.debug(mcMMO.p.getLogger(), "Registered WG flags successfully!");
} catch (FlagConflictException e) {
e.printStackTrace();
mcMMO.p.getLogger().warning("Failed to register WG flags!");
diff --git a/src/main/java/com/gmail/nossr50/worldguard/WorldGuardUtils.java b/src/main/java/com/gmail/nossr50/worldguard/WorldGuardUtils.java
index 479b9dbfe..d37f0a50c 100644
--- a/src/main/java/com/gmail/nossr50/worldguard/WorldGuardUtils.java
+++ b/src/main/java/com/gmail/nossr50/worldguard/WorldGuardUtils.java
@@ -1,6 +1,7 @@
package com.gmail.nossr50.worldguard;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.registry.SimpleFlagRegistry;
@@ -67,7 +68,7 @@ public class WorldGuardUtils {
if(plugin == null) {
//WG is not present
detectedIncompatibleWG = true;
- mcMMO.p.getLogger().info("WorldGuard was not detected.");
+ LogUtils.debug(mcMMO.p.getLogger(), "WorldGuard was not detected.");
} else {
//Check that its actually of class WorldGuardPlugin
if(plugin instanceof WorldGuardPlugin)
diff --git a/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java b/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java
index f6f0d829c..4ce8fee08 100644
--- a/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java
+++ b/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java
@@ -1,6 +1,7 @@
package net.shatteredlands.shatt.backup;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.LogUtils;
import java.io.File;
import java.io.FileInputStream;
@@ -27,13 +28,13 @@ public class ZipLibrary {
public static void mcMMOBackup() throws IOException {
if (mcMMO.p.getGeneralConfig().getUseMySQL()) {
- mcMMO.p.debug("This server is running in SQL Mode.");
- mcMMO.p.debug("Only config files will be backed up.");
+ LogUtils.debug(mcMMO.p.getLogger(), "This server is running in SQL Mode.");
+ LogUtils.debug(mcMMO.p.getLogger(), "Only config files will be backed up.");
}
try {
if (BACKUP_DIR.mkdir()) {
- mcMMO.p.debug("Created Backup Directory.");
+ LogUtils.debug(mcMMO.p.getLogger(), "Created Backup Directory.");
}
}
catch (Exception e) {
@@ -60,7 +61,7 @@ public class ZipLibrary {
}
// Actually do something
- mcMMO.p.debug("Backing up your mcMMO Configuration... ");
+ LogUtils.debug(mcMMO.p.getLogger(), "Backing up your mcMMO Configuration... ");
packZip(fileZip, sources);
}
@@ -80,7 +81,7 @@ public class ZipLibrary {
zipOut.flush();
zipOut.close();
- mcMMO.p.debug("Backup Completed.");
+ LogUtils.debug(mcMMO.p.getLogger(), "Backup Completed.");
}
private static String buildPath(String path, String file) {
diff --git a/src/main/resources/advanced.yml b/src/main/resources/advanced.yml
index ce788d396..b5662f261 100644
--- a/src/main/resources/advanced.yml
+++ b/src/main/resources/advanced.yml
@@ -209,7 +209,14 @@ Skills:
Fishing:
ShakeChance:
- Rank_1: 30
+ Rank_1: 15.0
+ Rank_2: 20.0
+ Rank_3: 25.0
+ Rank_4: 35.0
+ Rank_5: 45.0
+ Rank_6: 55.0
+ Rank_7: 65.0
+ Rank_8: 75.0
# VanillaXPMultiplier: Vanilla XP gained from fishing is multiplied by these values.
VanillaXPMultiplier:
diff --git a/src/main/resources/experience.yml b/src/main/resources/experience.yml
index fffceb4a3..e83fd3770 100644
--- a/src/main/resources/experience.yml
+++ b/src/main/resources/experience.yml
@@ -330,7 +330,7 @@ Experience_Values:
Big_Dripleaf: 140
Cave_Vines: 90
Cave_Vines_Plant: 90
- Glow_Lichen: 200
+ Glow_Lichen: 5
Moss_Block: 150
Crimson_Roots: 6
Warped_Roots: 6
@@ -403,6 +403,7 @@ Experience_Values:
Rose_Bush: 50
Fern: 10
Grass: 10
+ Short_Grass: 10
Sugar_Cane: 30
Sunflower: 50
Tall_Grass: 50
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index f8893ea1a..697d218fd 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -14,8 +14,9 @@ author: nossr50
authors: [GJ, NuclearW, bm01, Glitchfinder, TfT_02, t00thpick1, Riking, electronicboy, kashike]
website: https://www.mcmmo.org
main: com.gmail.nossr50.mcMMO
-softdepend: [WorldGuard, CombatTag, HealthBar]
+softdepend: [WorldGuard, CombatTag, HealthBar, PlaceholderAPI]
load: POSTWORLD
+folia-supported: true
api-version: 1.13
commands:
diff --git a/src/main/resources/skillranks.yml b/src/main/resources/skillranks.yml
index ae71e5074..b2f26be30 100644
--- a/src/main/resources/skillranks.yml
+++ b/src/main/resources/skillranks.yml
@@ -479,8 +479,22 @@ Fishing:
Shake:
Standard:
Rank_1: 15
+ Rank_2: 20
+ Rank_3: 25
+ Rank_4: 30
+ Rank_5: 40
+ Rank_6: 50
+ Rank_7: 60
+ Rank_8: 70
RetroMode:
Rank_1: 150
+ Rank_2: 200
+ Rank_3: 250
+ Rank_4: 300
+ Rank_5: 400
+ Rank_6: 500
+ Rank_7: 600
+ Rank_8: 700
MasterAngler:
Standard:
Rank_1: 1