Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
Version 2.2.050
Minimum supported Minecraft version raised to 1.20.4 (see notes)
Minimum supported Minecraft version raised to 1.20.5 (see notes)
Improved Spears damage detection (see notes)
Spear abilities can now trigger from off-hand attacks with the Spear
Further improved compatibility with Excellent Enchants (fixed more errors)
Fixed Spears command showing too many decimal places in some circumstances (Thanks Momshroom)
(Codebase) Updated Recipe API to use alternative methods (Thanks Warriorrrr)
(Codebase) Removed a bunch of unused code
(Codebase) Refactored code around evaluating Minecraft server version


NOTES:
From 2.2.050 onwards, mcMMO will require Minecraft versions 1.20.4 or newer.
From 2.2.050 onwards, mcMMO will require Minecraft versions 1.20.5 or newer.
Every now and then I raise the minimum supported Minecraft version to reduce maintenance burden of supporting older versions.
mcMMO no longer monitors PlayerAnimationEvent, it turns out Spigot has a DamageType just for Spear damage, avoiding the need to track player arm swings.
I changed how mcMMO detects the game version slightly, now if it fails to determine the game version it will make the assumption you are on the minimum supported version and print an error, this is just a failsafe in case the version detection mechanism ever fails.

Version 2.2.049
Combat abilities work with spear in off-hand again (see notes)
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
</scm>

<properties>
<!-- <spigot.version>1.20.4-R0.1-SNAPSHOT</spigot.version>-->
<spigot.version>1.21.11-R0.1-SNAPSHOT</spigot.version>
<spigot.version>1.20.5-R0.1-SNAPSHOT</spigot.version>
<!-- <spigot.version>1.21.11-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>
Expand Down Expand Up @@ -301,7 +301,7 @@
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.25.3</version>
<version>3.27.7</version>
<scope>test</scope>
<exclusions>
<!-- Exclude bytebuddy, messes with tests on java 25+ -->
Expand Down

This file was deleted.

14 changes: 0 additions & 14 deletions src/main/java/com/gmail/nossr50/commands/player/McTopCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
return true;
}

// Check if the command is for Maces but the MC version is not correct
if (skill == PrimarySkillType.MACES
&& !mcMMO.getCompatibilityManager().getMinecraftGameVersion()
.isAtLeast(1, 21, 0)) {
return true;
}

display(1, skill, sender, command);
return true;

Expand All @@ -65,13 +58,6 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
return true;
}

// Check if the command is for Maces but the MC version is not correct
if (skill == PrimarySkillType.MACES
&& !mcMMO.getCompatibilityManager().getMinecraftGameVersion()
.isAtLeast(1, 21, 0)) {
return true;
}

display(Math.abs(Integer.parseInt(args[1])), skill, sender, command);
return true;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.gmail.nossr50.commands.skills;

import static com.gmail.nossr50.util.Permissions.canUseSubSkill;

import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.treasure.Rarity;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.random.Probability;
import com.gmail.nossr50.util.random.ProbabilityUtil;
import com.gmail.nossr50.util.skills.RankUtils;
Expand Down Expand Up @@ -118,16 +118,14 @@ protected void dataCalculations(Player player, float skillValue) {

@Override
protected void permissionsCheck(Player player) {
canTreasureHunt = Permissions.canUseSubSkill(player, SubSkillType.FISHING_TREASURE_HUNTER);
canMagicHunt = Permissions.canUseSubSkill(player, SubSkillType.FISHING_MAGIC_HUNTER)
&& Permissions.canUseSubSkill(player, SubSkillType.FISHING_TREASURE_HUNTER);
canShake = Permissions.canUseSubSkill(player, SubSkillType.FISHING_SHAKE);
canFishermansDiet = Permissions.canUseSubSkill(player,
canTreasureHunt = canUseSubSkill(player, SubSkillType.FISHING_TREASURE_HUNTER);
canMagicHunt = canUseSubSkill(player, SubSkillType.FISHING_MAGIC_HUNTER)
&& canUseSubSkill(player, SubSkillType.FISHING_TREASURE_HUNTER);
canShake = canUseSubSkill(player, SubSkillType.FISHING_SHAKE);
canFishermansDiet = canUseSubSkill(player,
SubSkillType.FISHING_FISHERMANS_DIET);
canMasterAngler =
mcMMO.getCompatibilityManager().getMasterAnglerCompatibilityLayer() != null
&& Permissions.canUseSubSkill(player, SubSkillType.FISHING_MASTER_ANGLER);
canIceFish = Permissions.canUseSubSkill(player, SubSkillType.FISHING_ICE_FISHING);
canMasterAngler = canUseSubSkill(player, SubSkillType.FISHING_MASTER_ANGLER);
canIceFish = canUseSubSkill(player, SubSkillType.FISHING_ICE_FISHING);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected List<String> statsDisplay(Player player, float skillValue, boolean has

if (canUseSubskill(player, SPEARS_SPEAR_MASTERY)) {
messages.add(getStatMessage(SPEARS_SPEAR_MASTERY,
String.valueOf(spearMasteryBonusDmg)));
String.format("%.2f", spearMasteryBonusDmg)));
}

if (SkillUtils.canUseSubskill(player, SPEARS_MOMENTUM)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
import static com.gmail.nossr50.util.ItemUtils.customName;
import static com.gmail.nossr50.util.PotionUtil.matchPotionType;
import static com.gmail.nossr50.util.PotionUtil.setBasePotionType;
import static com.gmail.nossr50.util.PotionUtil.setUpgradedAndExtendedProperties;

import com.gmail.nossr50.config.LegacyConfigLoader;
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.LogUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -49,9 +47,6 @@ public class PotionConfig extends LegacyConfigLoader {
private final List<ItemStack> concoctionsIngredientsTierSix = new ArrayList<>();
private final List<ItemStack> concoctionsIngredientsTierSeven = new ArrayList<>();
private final List<ItemStack> concoctionsIngredientsTierEight = new ArrayList<>();
private final AlchemyPotionConfigResult INCOMPATIBLE_POTION_RESULT = new AlchemyPotionConfigResult(
null,
AlchemyPotionConfigResultType.INCOMPATIBLE);
private final AlchemyPotionConfigResult ERROR_POTION_RESULT = new AlchemyPotionConfigResult(
null,
AlchemyPotionConfigResultType.ERROR);
Expand Down Expand Up @@ -258,15 +253,15 @@ int loadPotionMap() {
if (potion_section.contains("Effects")) {
for (String effect : potion_section.getStringList("Effects")) {
String[] parts = effect.split(" ");
if (isTrickyTrialsPotionEffect(parts[0]) && !mcMMO.getCompatibilityManager()
.getMinecraftGameVersion()
.isAtLeast(1, 21, 0)) {
LogUtils.debug(
mcMMO.p.getLogger(),
"Skipping potion effect " + effect + " because it is not"
+ " compatible with the current Minecraft game version.");
return INCOMPATIBLE_POTION_RESULT;
}
// if (isTrickyTrialsPotionEffect(parts[0]) && !mcMMO.getCompatibilityManager()
// .minecraftGameVersion()
// .isAtLeast(1, 21, 0)) {
// LogUtils.debug(
// mcMMO.p.getLogger(),
// "Skipping potion effect " + effect + " because it is not"
// + " compatible with the current Minecraft game version.");
// return INCOMPATIBLE_POTION_RESULT;
// }

PotionEffectType type =
parts.length > 0 ? PotionEffectType.getByName(parts[0]) : null;
Expand Down Expand Up @@ -298,9 +293,7 @@ int loadPotionMap() {
.getKeys(false)) {
// Breeze Rod was only for potions after 1.21.0
if (isTrickyTrialsIngredient(childIngredient)
&& !mcMMO.getCompatibilityManager()
.getMinecraftGameVersion()
.isAtLeast(1, 21, 0)) {
&& !mcMMO.getMinecraftGameVersion().isAtLeast(1, 21, 0)) {
continue;
}
ItemStack ingredient = loadIngredient(childIngredient);
Expand Down Expand Up @@ -359,8 +352,6 @@ private boolean setPotionType(PotionMeta potionMeta, String potionTypeStr, boole
// set base
setBasePotionType(potionMeta, potionType, extended, upgraded);

// Legacy only
setUpgradedAndExtendedProperties(potionType, potionMeta, upgraded, extended);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private static String getConnectionString() {
+ general.getMySQLDatabaseName();

// Temporary hack for 1.17 + SSL support (legacy path kept intact)
if (!mcMMO.getCompatibilityManager().getMinecraftGameVersion().isAtLeast(1, 17, 0)
if (!mcMMO.getMinecraftGameVersion().isAtLeast(1, 17, 0)
&& general.getMySQLSSL()) {
connectionString += "?verifyServerCertificate=false&useSSL=true&requireSSL=true";
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ private void initSkillManagers() {
}

private void initManager(PrimarySkillType primarySkillType) throws InvalidSkillException {
final var version = mcMMO.getCompatibilityManager().getMinecraftGameVersion();

final SkillManager manager = switch (primarySkillType) {
case ACROBATICS -> new AcrobaticsManager(this);
case ALCHEMY -> new AlchemyManager(this);
Expand All @@ -202,8 +200,10 @@ private void initManager(PrimarySkillType primarySkillType) throws InvalidSkillE
case TRIDENTS -> new TridentsManager(this);
case UNARMED -> new UnarmedManager(this);
case WOODCUTTING -> new WoodcuttingManager(this);
case MACES -> version.isAtLeast(1, 21, 0) ? new MacesManager(this) : null;
case SPEARS -> version.isAtLeast(1, 21, 11) ? new SpearsManager(this) : null;
case MACES -> new MacesManager(this);
case SPEARS -> mcMMO.getMinecraftGameVersion().isAtLeast(1, 21, 11)
? new SpearsManager(this)
: null;
};

if (manager != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.gmail.nossr50.datatypes.skills.alchemy;

import static com.gmail.nossr50.util.PotionUtil.samePotionType;
import static java.util.Objects.requireNonNull;

import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.PotionUtil;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
Expand Down Expand Up @@ -80,12 +78,14 @@ public boolean isSimilarPotion(@NotNull ItemStack otherPotion, @Nullable ItemMet
return false;
}

if (!samePotionType(getAlchemyPotionMeta(), otherPotionMeta)) {
@NotNull PotionMeta potionMeta = getAlchemyPotionMeta();
if (!(potionMeta.getBasePotionType() == otherPotionMeta.getBasePotionType())) {
return false;
}

// Legacy only comparison, compare PotionData
if (!PotionUtil.isPotionDataEqual(getAlchemyPotionMeta(), otherPotionMeta)) {
@NotNull PotionMeta potionMeta1 = getAlchemyPotionMeta();
if (!(potionMeta1.getBasePotionType() == otherPotionMeta.getBasePotionType())) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,7 @@ public void onPlayerFishMonitor(PlayerFishEvent event) {

fishingManager.processExploiting(event.getHook().getLocation().toVector());

if (fishingManager.isExploitingFishing(
event.getHook().getLocation().toVector())) {
if (fishingManager.isExploitingFishing()) {
player.sendMessage(LocaleLoader.getString("Fishing.ScarcityTip",
ExperienceConfig.getInstance()
.getFishingExploitingOptionMoveRange()));
Expand Down
41 changes: 26 additions & 15 deletions src/main/java/com/gmail/nossr50/mcMMO.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TransientEntityTracker;
import com.gmail.nossr50.util.TransientMetadataTools;
import com.gmail.nossr50.util.MinecraftGameVersionFactory;
import com.gmail.nossr50.util.blockmeta.ChunkManager;
import com.gmail.nossr50.util.blockmeta.ChunkManagerFactory;
import com.gmail.nossr50.util.blockmeta.UserBlockTracker;
import com.gmail.nossr50.util.commands.CommandRegistrationManager;
import com.gmail.nossr50.util.compat.CompatibilityManager;
import com.gmail.nossr50.util.experience.FormulaManager;
import com.gmail.nossr50.util.platform.PlatformManager;
import com.gmail.nossr50.util.platform.ServerSoftwareType;
import com.gmail.nossr50.util.platform.MinecraftGameVersion;
import com.gmail.nossr50.util.player.PlayerLevelUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
Expand Down Expand Up @@ -94,7 +93,6 @@

public class mcMMO extends JavaPlugin {
/* Managers & Services */
private static PlatformManager platformManager;
private static ChunkManager chunkManager;
private static RepairableManager repairableManager;
private static SalvageableManager salvageableManager;
Expand All @@ -107,6 +105,7 @@ public class mcMMO extends JavaPlugin {
private static ChatManager chatManager;
private static CommandManager commandManager; //ACF
private static TransientEntityTracker transientEntityTracker;
private static MinecraftGameVersion minecraftGameVersion;

private SkillTools skillTools;

Expand Down Expand Up @@ -170,8 +169,19 @@ public void onEnable() {
//Filter out any debug messages (if debug/verbose logging is not enabled)
getLogger().setFilter(new LogFilter(this));

//Platform Manager
platformManager = new PlatformManager();
// Determine game version before moving forward
final String versionStr = Bukkit.getVersion();
try {
minecraftGameVersion = MinecraftGameVersionFactory.calculateGameVersion(versionStr);
} catch (Exception e) {
// if anything goes wrong with our calculations, assume they are running the minimum
// supported version and log the error
getLogger().warning("Could not determine Minecraft version from"
+ " server software version string: " + versionStr +
", Please report this bug to the devs!");
e.printStackTrace();
minecraftGameVersion = new MinecraftGameVersion(1, 20, 5);
}

//Folia lib plugin instance
foliaLib = new FoliaLib(this);
Expand Down Expand Up @@ -248,7 +258,7 @@ public void onEnable() {
"You are potentially running an outdated version of your server software"
+ ", mcMMO will not work unless you update to a newer version!"),
20, 20 * 60 * 30);
if (!getCompatibilityManager().getMinecraftGameVersion().isAtLeast(1, 20, 4)) {
if (!minecraftGameVersion.isAtLeast(1, 20, 4)) {
foliaLib.getScheduler().runTimer(
() -> getLogger().severe(
"This version of mcMMO requires at least Minecraft 1.20.4 to"
Expand Down Expand Up @@ -501,10 +511,6 @@ public static UpgradeManager getUpgradeManager() {
return upgradeManager;
}

public static @Nullable CompatibilityManager getCompatibilityManager() {
return platformManager.getCompatibilityManager();
}

@Deprecated
public static void setDatabaseManager(DatabaseManager databaseManager) {
mcMMO.databaseManager = databaseManager;
Expand Down Expand Up @@ -750,10 +756,6 @@ public static WorldBlacklist getWorldBlacklist() {
return worldBlacklist;
}

public static PlatformManager getPlatformManager() {
return platformManager;
}

public static BukkitAudiences getAudiences() {
return audiences;
}
Expand Down Expand Up @@ -834,4 +836,13 @@ public EnchantmentMapper getEnchantmentMapper() {
public @NotNull FoliaLib getFoliaLib() {
return foliaLib;
}

/**
* Get the {@link MinecraftGameVersion}
*
* @return the {@link MinecraftGameVersion}
*/
public static MinecraftGameVersion getMinecraftGameVersion() {
return minecraftGameVersion;
}
}
Loading