Browse Source

Spring-cleaning round 1: remove some more deprecated API invocations

nossr50 1 month ago
parent
commit
1b49eb11b8

+ 1 - 1
pom.xml

@@ -14,7 +14,7 @@
 
 
     <properties>
     <properties>
 <!--        <spigot.version>1.19-R0.1-SNAPSHOT</spigot.version>-->
 <!--        <spigot.version>1.19-R0.1-SNAPSHOT</spigot.version>-->
-        <spigot.version>1.21.8-R0.1-SNAPSHOT</spigot.version>
+        <spigot.version>1.21.10-R0.1-SNAPSHOT</spigot.version>
         <kyori.adventure.version>4.23.0</kyori.adventure.version>
         <kyori.adventure.version>4.23.0</kyori.adventure.version>
         <kyori.adventure.platform.version>4.4.1-SNAPSHOT</kyori.adventure.platform.version>
         <kyori.adventure.platform.version>4.4.1-SNAPSHOT</kyori.adventure.platform.version>
         <kyori.option.version>1.1.0</kyori.option.version>
         <kyori.option.version>1.1.0</kyori.option.version>

+ 1 - 0
src/main/java/com/gmail/nossr50/api/AbilityAPI.java

@@ -7,6 +7,7 @@ import com.gmail.nossr50.util.player.UserManager;
 import org.bukkit.entity.LivingEntity;
 import org.bukkit.entity.LivingEntity;
 import org.bukkit.entity.Player;
 import org.bukkit.entity.Player;
 
 
+@SuppressWarnings("unused")
 public final class AbilityAPI {
 public final class AbilityAPI {
     private AbilityAPI() {
     private AbilityAPI() {
     }
     }

+ 6 - 0
src/main/java/com/gmail/nossr50/datatypes/experience/XPGainSource.java

@@ -1,10 +1,16 @@
 package com.gmail.nossr50.datatypes.experience;
 package com.gmail.nossr50.datatypes.experience;
 
 
 public enum XPGainSource {
 public enum XPGainSource {
+    /** From direct sources, either your own actions or actions done to you. */
     SELF,
     SELF,
+    /** From Vampirism Kills */
     VAMPIRISM, //From Vampirism kills
     VAMPIRISM, //From Vampirism kills
+    /** From Smelting, Brewing, etc... */
     PASSIVE, //Smelting, Brewing, etc...
     PASSIVE, //Smelting, Brewing, etc...
+    /** From shared XP from party members */
     PARTY_MEMBERS, //From other members of a party
     PARTY_MEMBERS, //From other members of a party
+    /** From commands or API */
     COMMAND,
     COMMAND,
+    /** Uncategorized, Other Plugins, etc... */
     CUSTOM, //Outside Sources
     CUSTOM, //Outside Sources
 }
 }

+ 9 - 13
src/main/java/com/gmail/nossr50/mcMMO.java

@@ -243,7 +243,7 @@ public class mcMMO extends JavaPlugin {
             checkForOutdatedAPI();
             checkForOutdatedAPI();
 
 
             if (serverAPIOutdated) {
             if (serverAPIOutdated) {
-                foliaLib.getImpl().runTimer(
+                foliaLib.getScheduler().runTimer(
                         () -> getLogger().severe(
                         () -> getLogger().severe(
                                 "You are running an outdated version of "
                                 "You are running an outdated version of "
                                         + platformManager.getServerSoftware()
                                         + platformManager.getServerSoftware()
@@ -251,7 +251,7 @@ public class mcMMO extends JavaPlugin {
                         20, 20 * 60 * 30);
                         20, 20 * 60 * 30);
 
 
                 if (platformManager.getServerSoftware() == ServerSoftwareType.CRAFT_BUKKIT) {
                 if (platformManager.getServerSoftware() == ServerSoftwareType.CRAFT_BUKKIT) {
-                    foliaLib.getImpl().runTimer(
+                    foliaLib.getScheduler().runTimer(
                             () -> getLogger().severe(
                             () -> 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."),
                                     "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);
@@ -307,11 +307,9 @@ public class mcMMO extends JavaPlugin {
         } catch (Throwable t) {
         } catch (Throwable t) {
             getLogger().log(Level.SEVERE, "There was an error while enabling mcMMO!", t);
             getLogger().log(Level.SEVERE, "There was an error while enabling mcMMO!", t);
 
 
-            if (!(t instanceof ExceptionInInitializerError)) {
-                t.printStackTrace();
-            } else {
-                getLogger().info(
-                        "Please do not replace the mcMMO jar while the server is running.");
+            if (t instanceof ExceptionInInitializerError) {
+                getLogger().info("Please do not replace the mcMMO jar while the server"
+                        + " is running.");
             }
             }
 
 
             getServer().getPluginManager().disablePlugin(this);
             getServer().getPluginManager().disablePlugin(this);
@@ -398,7 +396,7 @@ public class mcMMO extends JavaPlugin {
             formulaManager.saveFormula();
             formulaManager.saveFormula();
             chunkManager.closeAll();
             chunkManager.closeAll();
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            getLogger().log(Level.SEVERE, "An error occurred while disabling mcMMO!", e);
         }
         }
 
 
         if (generalConfig.getBackupsEnabled()) {
         if (generalConfig.getBackupsEnabled()) {
@@ -586,7 +584,6 @@ public class mcMMO extends JavaPlugin {
         TreasureConfig.getInstance();
         TreasureConfig.getInstance();
         FishingTreasureConfig.getInstance();
         FishingTreasureConfig.getInstance();
         HiddenConfig.getInstance();
         HiddenConfig.getInstance();
-        mcMMO.p.getAdvancedConfig();
 
 
         // init potion config
         // init potion config
         potionConfig = new PotionConfig();
         potionConfig = new PotionConfig();
@@ -596,16 +593,15 @@ public class mcMMO extends JavaPlugin {
         SoundConfig.getInstance();
         SoundConfig.getInstance();
         RankConfig.getInstance();
         RankConfig.getInstance();
 
 
-        List<Repairable> repairables = new ArrayList<>();
-
         // Load repair configs, make manager, and register them at this time
         // Load repair configs, make manager, and register them at this time
-        repairables.addAll(new RepairConfigManager(this).getLoadedRepairables());
+        final List<Repairable> repairables = new ArrayList<>(
+                new RepairConfigManager(this).getLoadedRepairables());
         repairableManager = new SimpleRepairableManager(repairables.size());
         repairableManager = new SimpleRepairableManager(repairables.size());
         repairableManager.registerRepairables(repairables);
         repairableManager.registerRepairables(repairables);
 
 
         // Load salvage configs, make manager and register them at this time
         // Load salvage configs, make manager and register them at this time
         SalvageConfigManager sManager = new SalvageConfigManager(this);
         SalvageConfigManager sManager = new SalvageConfigManager(this);
-        List<Salvageable> salvageables = sManager.getLoadedSalvageables();
+        final List<Salvageable> salvageables = sManager.getLoadedSalvageables();
         salvageableManager = new SimpleSalvageableManager(salvageables.size());
         salvageableManager = new SimpleSalvageableManager(salvageables.size());
         salvageableManager.registerSalvageables(salvageables);
         salvageableManager.registerSalvageables(salvageables);
     }
     }

+ 2 - 1
src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java

@@ -12,6 +12,7 @@ import com.gmail.nossr50.util.skills.PerksUtils;
 import com.gmail.nossr50.util.skills.SkillUtils;
 import com.gmail.nossr50.util.skills.SkillUtils;
 import org.bukkit.Chunk;
 import org.bukkit.Chunk;
 import org.bukkit.World;
 import org.bukkit.World;
+import org.bukkit.entity.Entity;
 import org.bukkit.entity.Player;
 import org.bukkit.entity.Player;
 
 
 public class AbilityDisableTask extends CancellableRunnable {
 public class AbilityDisableTask extends CancellableRunnable {
@@ -72,7 +73,7 @@ public class AbilityDisableTask extends CancellableRunnable {
         }
         }
     }
     }
 
 
-    private void resendChunkRadiusAt(Player player) {
+    private void resendChunkRadiusAt(Entity player) {
         Chunk chunk = player.getLocation().getChunk();
         Chunk chunk = player.getLocation().getChunk();
         World world = player.getWorld();
         World world = player.getWorld();
 
 

+ 1 - 1
src/main/java/com/gmail/nossr50/skills/SkillManager.java

@@ -32,7 +32,7 @@ public abstract class SkillManager {
      * @param xpGainReason the reason for the XP gain
      * @param xpGainReason the reason for the XP gain
      * @deprecated use applyXpGain(float, XPGainReason, XPGainSource)
      * @deprecated use applyXpGain(float, XPGainReason, XPGainSource)
      */
      */
-    @Deprecated
+    @Deprecated(forRemoval = true)
     public void applyXpGain(float xp, XPGainReason xpGainReason) {
     public void applyXpGain(float xp, XPGainReason xpGainReason) {
         mmoPlayer.beginXpGain(skill, xp, xpGainReason, XPGainSource.SELF);
         mmoPlayer.beginXpGain(skill, xp, xpGainReason, XPGainSource.SELF);
     }
     }

+ 6 - 3
src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java

@@ -3,6 +3,7 @@ package com.gmail.nossr50.skills.acrobatics;
 import com.gmail.nossr50.config.experience.ExperienceConfig;
 import com.gmail.nossr50.config.experience.ExperienceConfig;
 import com.gmail.nossr50.datatypes.BlockLocationHistory;
 import com.gmail.nossr50.datatypes.BlockLocationHistory;
 import com.gmail.nossr50.datatypes.experience.XPGainReason;
 import com.gmail.nossr50.datatypes.experience.XPGainReason;
+import com.gmail.nossr50.datatypes.experience.XPGainSource;
 import com.gmail.nossr50.datatypes.interactions.NotificationType;
 import com.gmail.nossr50.datatypes.interactions.NotificationType;
 import com.gmail.nossr50.datatypes.player.McMMOPlayer;
 import com.gmail.nossr50.datatypes.player.McMMOPlayer;
 import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
 import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
@@ -19,6 +20,8 @@ import com.gmail.nossr50.util.random.ProbabilityUtil;
 import com.gmail.nossr50.util.skills.ParticleEffectUtils;
 import com.gmail.nossr50.util.skills.ParticleEffectUtils;
 import com.gmail.nossr50.util.skills.RankUtils;
 import com.gmail.nossr50.util.skills.RankUtils;
 import com.gmail.nossr50.util.skills.SkillUtils;
 import com.gmail.nossr50.util.skills.SkillUtils;
+import com.tcoded.folialib.wrapper.task.WrappedTask;
+import java.util.function.Consumer;
 import org.bukkit.Location;
 import org.bukkit.Location;
 import org.bukkit.entity.Entity;
 import org.bukkit.entity.Entity;
 import org.bukkit.entity.LightningStrike;
 import org.bukkit.entity.LightningStrike;
@@ -118,10 +121,10 @@ public class AcrobaticsManager extends SkillManager {
 
 
                         if (count <= 5) {
                         if (count <= 5) {
                             applyXpGain((float) (damage * Acrobatics.dodgeXpModifier),
                             applyXpGain((float) (damage * Acrobatics.dodgeXpModifier),
-                                    XPGainReason.PVE);
+                                    XPGainReason.PVE, XPGainSource.SELF);
                             mob.setMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER,
                             mob.setMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER,
                                     new FixedMetadataValue(mcMMO.p, count + 1));
                                     new FixedMetadataValue(mcMMO.p, count + 1));
-                            MobDodgeMetaCleanup metaCleanupTask = new MobDodgeMetaCleanup(mob,
+                            final Consumer<WrappedTask> metaCleanupTask = new MobDodgeMetaCleanup(mob,
                                     mcMMO.p);
                                     mcMMO.p);
                             mcMMO.p.getFoliaLib().getScheduler()
                             mcMMO.p.getFoliaLib().getScheduler()
                                     .runAtEntityTimer(mob, metaCleanupTask, 20,
                                     .runAtEntityTimer(mob, metaCleanupTask, 20,
@@ -129,7 +132,7 @@ public class AcrobaticsManager extends SkillManager {
                         }
                         }
                     } else {
                     } else {
                         applyXpGain((float) (damage * Acrobatics.dodgeXpModifier),
                         applyXpGain((float) (damage * Acrobatics.dodgeXpModifier),
-                                XPGainReason.PVE);
+                                XPGainReason.PVE, XPGainSource.SELF);
                     }
                     }
                 }
                 }
             }
             }

+ 4 - 2
src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java

@@ -4,6 +4,7 @@ import com.gmail.nossr50.api.ItemSpawnReason;
 import com.gmail.nossr50.config.experience.ExperienceConfig;
 import com.gmail.nossr50.config.experience.ExperienceConfig;
 import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
 import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
 import com.gmail.nossr50.datatypes.experience.XPGainReason;
 import com.gmail.nossr50.datatypes.experience.XPGainReason;
+import com.gmail.nossr50.datatypes.experience.XPGainSource;
 import com.gmail.nossr50.datatypes.interactions.NotificationType;
 import com.gmail.nossr50.datatypes.interactions.NotificationType;
 import com.gmail.nossr50.datatypes.player.McMMOPlayer;
 import com.gmail.nossr50.datatypes.player.McMMOPlayer;
 import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
 import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
@@ -526,7 +527,7 @@ public class FishingManager extends SkillManager {
             fishingCatch.setItemStack(treasureDrop);
             fishingCatch.setItemStack(treasureDrop);
         }
         }
 
 
-        applyXpGain(fishXp + treasureXp, XPGainReason.PVE);
+        applyXpGain(fishXp + treasureXp, XPGainReason.PVE, XPGainSource.SELF);
     }
     }
 
 
     /**
     /**
@@ -631,7 +632,8 @@ public class FishingManager extends SkillManager {
             // Make it so you can shake a mob no more than 4 times.
             // Make it so you can shake a mob no more than 4 times.
             double dmg = Math.min(Math.max(target.getMaxHealth() / 4, 1), 10);
             double dmg = Math.min(Math.max(target.getMaxHealth() / 4, 1), 10);
             CombatUtils.safeDealDamage(target, dmg, getPlayer());
             CombatUtils.safeDealDamage(target, dmg, getPlayer());
-            applyXpGain(ExperienceConfig.getInstance().getFishingShakeXP(), XPGainReason.PVE);
+            applyXpGain(ExperienceConfig.getInstance().getFishingShakeXP(), XPGainReason.PVE,
+                    XPGainSource.SELF);
         }
         }
     }
     }
 
 

+ 1 - 1
src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java

@@ -121,7 +121,7 @@ public class MiningManager extends SkillManager {
         Player player = getPlayer();
         Player player = getPlayer();
 
 
         applyXpGain(ExperienceConfig.getInstance().getXp(PrimarySkillType.MINING, block),
         applyXpGain(ExperienceConfig.getInstance().getXp(PrimarySkillType.MINING, block),
-                XPGainReason.PVE);
+                XPGainReason.PVE, XPGainSource.SELF);
 
 
         if (!Permissions.isSubSkillEnabled(player, SubSkillType.MINING_DOUBLE_DROPS)) {
         if (!Permissions.isSubSkillEnabled(player, SubSkillType.MINING_DOUBLE_DROPS)) {
             return;
             return;

+ 2 - 1
src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java

@@ -2,6 +2,7 @@ package com.gmail.nossr50.skills.repair;
 
 
 import com.gmail.nossr50.config.experience.ExperienceConfig;
 import com.gmail.nossr50.config.experience.ExperienceConfig;
 import com.gmail.nossr50.datatypes.experience.XPGainReason;
 import com.gmail.nossr50.datatypes.experience.XPGainReason;
+import com.gmail.nossr50.datatypes.experience.XPGainSource;
 import com.gmail.nossr50.datatypes.interactions.NotificationType;
 import com.gmail.nossr50.datatypes.interactions.NotificationType;
 import com.gmail.nossr50.datatypes.player.McMMOPlayer;
 import com.gmail.nossr50.datatypes.player.McMMOPlayer;
 import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
 import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
@@ -212,7 +213,7 @@ public class RepairManager extends SkillManager {
                         * repairable.getXpMultiplier())
                         * repairable.getXpMultiplier())
                         * ExperienceConfig.getInstance().getRepairXPBase()
                         * ExperienceConfig.getInstance().getRepairXPBase()
                         * ExperienceConfig.getInstance().getRepairXP(repairable.getRepairMaterialType())),
                         * ExperienceConfig.getInstance().getRepairXP(repairable.getRepairMaterialType())),
-                XPGainReason.PVE);
+                XPGainReason.PVE, XPGainSource.SELF);
 
 
         // BWONG BWONG BWONG
         // BWONG BWONG BWONG
         if (mcMMO.p.getGeneralConfig().getRepairAnvilUseSoundsEnabled()) {
         if (mcMMO.p.getGeneralConfig().getRepairAnvilUseSoundsEnabled()) {

+ 1 - 1
src/main/java/com/gmail/nossr50/util/text/TextUtils.java

@@ -111,7 +111,7 @@ public class TextUtils {
     }
     }
 
 
     public static @NotNull TextComponent ofBungeeComponents(@NotNull BaseComponent[] bungeeName) {
     public static @NotNull TextComponent ofBungeeComponents(@NotNull BaseComponent[] bungeeName) {
-        return TextComponent.ofChildren(
+        return Component.textOfChildren(
                 mcMMO.getCompatibilityManager().getBungeeSerializerCompatibilityLayer()
                 mcMMO.getCompatibilityManager().getBungeeSerializerCompatibilityLayer()
                         .deserialize(bungeeName));
                         .deserialize(bungeeName));
     }
     }