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

This commit is contained in:
nossr50
2025-11-09 10:34:41 -08:00
parent 3533c50489
commit 1b49eb11b8
11 changed files with 34 additions and 24 deletions

View File

@@ -14,7 +14,7 @@
<properties>
<!-- <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.platform.version>4.4.1-SNAPSHOT</kyori.adventure.platform.version>
<kyori.option.version>1.1.0</kyori.option.version>

View File

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

View File

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

View File

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

View File

@@ -12,6 +12,7 @@ import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
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();
World world = player.getWorld();

View File

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

View File

@@ -3,6 +3,7 @@ package com.gmail.nossr50.skills.acrobatics;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.BlockLocationHistory;
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.player.McMMOPlayer;
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.RankUtils;
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.entity.Entity;
import org.bukkit.entity.LightningStrike;
@@ -118,10 +121,10 @@ public class AcrobaticsManager extends SkillManager {
if (count <= 5) {
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier),
XPGainReason.PVE);
XPGainReason.PVE, XPGainSource.SELF);
mob.setMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER,
new FixedMetadataValue(mcMMO.p, count + 1));
MobDodgeMetaCleanup metaCleanupTask = new MobDodgeMetaCleanup(mob,
final Consumer<WrappedTask> metaCleanupTask = new MobDodgeMetaCleanup(mob,
mcMMO.p);
mcMMO.p.getFoliaLib().getScheduler()
.runAtEntityTimer(mob, metaCleanupTask, 20,
@@ -129,7 +132,7 @@ public class AcrobaticsManager extends SkillManager {
}
} else {
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier),
XPGainReason.PVE);
XPGainReason.PVE, XPGainSource.SELF);
}
}
}

View File

@@ -4,6 +4,7 @@ import com.gmail.nossr50.api.ItemSpawnReason;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
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.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
@@ -526,7 +527,7 @@ public class FishingManager extends SkillManager {
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.
double dmg = Math.min(Math.max(target.getMaxHealth() / 4, 1), 10);
CombatUtils.safeDealDamage(target, dmg, getPlayer());
applyXpGain(ExperienceConfig.getInstance().getFishingShakeXP(), XPGainReason.PVE);
applyXpGain(ExperienceConfig.getInstance().getFishingShakeXP(), XPGainReason.PVE,
XPGainSource.SELF);
}
}

View File

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

View File

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

View File

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