Skip to content

Commit

Permalink
2.2.009
Browse files Browse the repository at this point in the history
  • Loading branch information
nossr50 committed May 12, 2024
1 parent cae2132 commit 1705286
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 17 deletions.
14 changes: 14 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
Version 2.2.009
Fixed a bug that prevented mcMMO from loading on MC versions older than 1.20.6
Dramatically increased the base XP for Alchemy again (see notes)

NOTES:
Alchemy leveling still felt too slow, so I've increased it again. You can either delete experience.yml to get the new values or adjust them manually.
If you haven't updated mcMMO since 2.2.006 or older you don't need to do anything to get these new values.
The new default values are...
Potion_Brewing:
Stage_1: 666
Stage_2: 1111
Stage_3: 1750
Stage_4: 2250

Version 2.2.008
Fixed alchemy potions not upgrading correctly (This will only affect new potions made, see notes)
Fixed a bug where alchemy potions had italicized names
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>2.2.008</version>
<version>2.2.009</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.gmail.nossr50.config.LegacyConfigLoader;
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.PotionUtil;
Expand All @@ -21,6 +20,7 @@
import java.io.File;
import java.util.*;

import static com.gmail.nossr50.util.ItemUtils.setItemName;
import static com.gmail.nossr50.util.PotionUtil.*;
import static com.gmail.nossr50.util.text.StringUtils.convertKeyToName;

Expand Down Expand Up @@ -257,19 +257,15 @@ private AlchemyPotion loadPotion(ConfigurationSection potion_section) {
}

private void setPotionDisplayName(ConfigurationSection section, PotionMeta potionMeta) {
String configuredName = section.getString("Name", null);
// If a potion doesn't have any custom effects, there is no reason to override the vanilla name
if (potionMeta.getCustomEffects().isEmpty()) {
return;
}

final String configuredName = section.getString("Name", null);
if (configuredName != null) {
potionMeta.setItemName(configuredName);
setItemName(potionMeta, configuredName);
}
//
// // Potion is water, but has effects
// if (isPotionTypeWater(potionMeta)
// && (PotionUtil.hasBasePotionEffects(potionMeta) || !potionMeta.getCustomEffects().isEmpty())) {
// // If we don't set a name for these potions, they will simply be called "Water Potion"
// final String name = section.getName().toUpperCase().replace("_", " ");
// potionMeta.setDisplayName(name);
// System.out.println("DEBUG: Renaming potion to " + name);
// }
}

/**
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/com/gmail/nossr50/util/ItemUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.List;

Expand All @@ -32,6 +34,43 @@ public final class ItemUtils {
*/
private ItemUtils() {}

private static final Method setItemName;

static {
setItemName = getSetItemName();
}

private static Method getSetItemName() {
try {
return ItemMeta.class.getMethod("setItemName", String.class);
} catch (NoSuchMethodException e) {
return null;
}
}

/**
* Sets the item name using the new API if available
* or falls back to the old API.
* @param itemMeta The item meta to set the name on
* @param name The name to set
*/
public static void setItemName(ItemMeta itemMeta, String name) {
if (setItemName != null) {
setItemNameModern(itemMeta, name);
} else {
itemMeta.setDisplayName(ChatColor.RESET + name);
}
}

private static void setItemNameModern(ItemMeta itemMeta, String name) {
try {
setItemName.invoke(itemMeta, name);
} catch (IllegalAccessException | InvocationTargetException e) {
mcMMO.p.getLogger().severe("Failed to set item name: " + e.getMessage());
throw new RuntimeException(e);
}
}

/**
* Checks if the item is a bow.
*
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/experience.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ Experience_Values:
# Stage_3 represents a base potion with one ingredient and one amplifier
# Stage_4 represents a base potion with one ingredient and two amplifiers
# Stage_5 represents a base potion with one ingredient where the amplifiers are swapped
Stage_1: 120
Stage_2: 240
Stage_3: 480
Stage_4: 960
Stage_1: 666
Stage_2: 1111
Stage_3: 1750
Stage_4: 2250
Stage_5: 0
Archery:
Distance_Multiplier: 0.025
Expand Down

0 comments on commit 1705286

Please sign in to comment.