Fixed treasures only requiring level 0

This commit is contained in:
nossr50 2021-04-05 13:41:37 -07:00
parent c5f4666525
commit 2d11b7befc
3 changed files with 126 additions and 62 deletions

View File

@ -1,13 +1,18 @@
Version 2.1.187
Fixed a ClassCastException error involving Rupture
Version 2.1.188
Updated default entries in treasures.yml to use "Level_Requirement" instead of "Drop_Level"
Fixed a bug where excavation treasures only required level 0 instead of loading the value from the config
Fixed a bug where /fishing was showing the wrong shake chance
Default Shake chance increased from 15% to 30% (update advanced.yml manually or delete the file to regenerate it and receive these changes)
Removed entries for ranks 2-8 of Shake from advanced.yml (Shake only has one rank, these entries were a mistake)
Modified the warning about UltraPermissions
NOTES:
This update makes changes to treasures.yml automatically to apply the fix, you don't need to do anything
The latest versions of UltraPermissions should play nicely with mcMMO, but older versions do not. Make sure to update UltraPermissions.
Version 2.1.187
Fixed a ClassCastException error involving Rupture
Version 2.1.186
Rupture has been reworked to solve a few outstanding issues (see notes)
Fixed an exploit involving enchantments (thanks TheBusyBiscuit)

View File

@ -25,8 +25,10 @@ public class TreasureConfig extends ConfigLoader {
public static final String FILENAME = "treasures.yml";
public static final String LEVEL_REQUIREMENT_RETRO_MODE = ".Level_Requirement.Retro_Mode";
public static final String LEVEL_REQUIREMENT_STANDARD_MODE = ".Level_Requirement.Standard_Mode";
public static final String LEVEL_REQUIREMENT_INVALID = ".Level_Requirement.Standard";
public static final String WRONG_KEY_VALUE_STANDARD = ".Drop_Level.Standard_Mode";
public static final String WRONG_KEY_VALUE_RETRO = ".Drop_Level.Retro_Mode";
public static final String LEGACY_DROP_LEVEL = ".Drop_Level";
public static final String WRONG_KEY_ROOT = ".Drop_Level";
private static TreasureConfig instance;
public HashMap<String, List<ExcavationTreasure>> excavationMap = new HashMap<>();
@ -66,7 +68,7 @@ public class TreasureConfig extends ConfigLoader {
}
private void loadTreasures(String type) {
boolean updatedFile = false;
boolean shouldWeUpdateFile = false;
boolean isExcavation = type.equals("Excavation");
boolean isHylian = type.equals("Hylian_Luck");
@ -110,38 +112,38 @@ public class TreasureConfig extends ConfigLoader {
int xp = config.getInt(type + "." + treasureName + ".XP");
double dropChance = config.getDouble(type + "." + treasureName + ".Drop_Chance");
int legacyDropLevel = config.getInt(type + "." + treasureName + LEGACY_DROP_LEVEL, -1);
DropLevelKeyConversionType conversionType;
//Check for legacy drop level values and convert
if(getWrongKeyValue(type, treasureName, DropLevelKeyConversionType.LEGACY) != -1) {
//Legacy Drop level, needs to be converted
shouldWeUpdateFile = processAutomaticKeyConversion(type, shouldWeUpdateFile, treasureName, DropLevelKeyConversionType.LEGACY);
}
//Check for a bad key that was accidentally shipped out to some users
if(getWrongKeyValue(type, treasureName, DropLevelKeyConversionType.WRONG_KEY_STANDARD) != -1) {
//Partially converted to the new system, I had a dyslexic moment so some configs have this
shouldWeUpdateFile = processAutomaticKeyConversion(type, shouldWeUpdateFile, treasureName, DropLevelKeyConversionType.WRONG_KEY_STANDARD);
}
//Check for a bad key that was accidentally shipped out to some users
if(getWrongKeyValue(type, treasureName, DropLevelKeyConversionType.WRONG_KEY_RETRO) != -1) {
//Partially converted to the new system, I had a dyslexic moment so some configs have this
shouldWeUpdateFile = processAutomaticKeyConversion(type, shouldWeUpdateFile, treasureName, DropLevelKeyConversionType.WRONG_KEY_RETRO);
}
int dropLevel = -1;
int badDefaults = config.getInt(type + "." + treasureName + LEVEL_REQUIREMENT_INVALID, -1);
//Hacky fix for bad keys in treasures.yml defaults
if(badDefaults != -1) {
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_INVALID, null);
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_STANDARD_MODE, badDefaults);
updatedFile = true;
}
if(legacyDropLevel >= 0) {
//Config needs to be updated to be more specific
mcMMO.p.getLogger().info("(" + treasureName + ") Updating Drop_Level in treasures.yml for treasure to match new expected format");
config.set(type + "." + treasureName + LEGACY_DROP_LEVEL, null);
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_RETRO_MODE, legacyDropLevel * 10);
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_STANDARD_MODE, legacyDropLevel);
updatedFile = true;
}
if(mcMMO.isRetroModeEnabled()) {
dropLevel = config.getInt(type + "." + treasureName + LEVEL_REQUIREMENT_RETRO_MODE, 0);
dropLevel = config.getInt(type + "." + treasureName + LEVEL_REQUIREMENT_RETRO_MODE, -1);
} else {
dropLevel = config.getInt(type + "." + treasureName + LEVEL_REQUIREMENT_STANDARD_MODE, 0);
dropLevel = config.getInt(type + "." + treasureName + LEVEL_REQUIREMENT_STANDARD_MODE, -1);
}
if(dropLevel < 0) {
mcMMO.p.getLogger().info("Treasure drop level wasn't valid, using a default value.");
//Set it to the "max" if we don't have a drop level
dropLevel = 0;
if(dropLevel == -1) {
mcMMO.p.getLogger().severe("Could not find a Level_Requirement entry for treasure " + treasureName);
mcMMO.p.getLogger().severe("Skipping treasure");
continue;
}
if (xp < 0) {
@ -256,7 +258,7 @@ public class TreasureConfig extends ConfigLoader {
}
//Apply our fix
if(updatedFile) {
if(shouldWeUpdateFile) {
try {
config.save(getFile());
} catch (IOException e) {
@ -265,6 +267,63 @@ public class TreasureConfig extends ConfigLoader {
}
}
private boolean processAutomaticKeyConversion(String type, boolean shouldWeUpdateTheFile, String treasureName, DropLevelKeyConversionType conversionType) {
switch (conversionType) {
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");
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");
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
if(wrongKeyValueStandard != -1) {
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_STANDARD_MODE, wrongKeyValueStandard);
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_RETRO_MODE, wrongKeyValueStandard * 10); //Multiply by 10 for Retro
}
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");
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
if(wrongKeyValueRetro != -1) {
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_RETRO_MODE, wrongKeyValueRetro);
}
shouldWeUpdateTheFile = true;
break;
}
return shouldWeUpdateTheFile;
}
private int getWrongKeyValue(String type, String treasureName, DropLevelKeyConversionType dropLevelKeyConversionType) {
switch (dropLevelKeyConversionType) {
case LEGACY:
return config.getInt(type + "." + treasureName + LEGACY_DROP_LEVEL, -1);
case WRONG_KEY_STANDARD:
return config.getInt(type + "." + treasureName + WRONG_KEY_VALUE_STANDARD, -1);
case WRONG_KEY_RETRO:
return config.getInt(type + "." + treasureName + WRONG_KEY_VALUE_RETRO, -1);
}
return -1;
}
private enum DropLevelKeyConversionType {
LEGACY,
WRONG_KEY_STANDARD,
WRONG_KEY_RETRO
}
private void AddHylianTreasure(String dropper, HylianTreasure treasure) {
if (!hylianMap.containsKey(dropper))
hylianMap.put(dropper, new ArrayList<>());

View File

@ -6,7 +6,7 @@ Excavation:
Amount: 1
XP: 3000
Drop_Chance: 0.05
Drop_Level:
Level_Requirement:
Standard_Mode: 75
Retro_Mode: 750
Drops_From: [Dirt, Coarse_Dirt, Podzol, Grass_Block, Sand, Red_Sand, Gravel, Clay, Mycelium, Soul_Sand, Soul_Soil]
@ -14,7 +14,7 @@ Excavation:
Amount: 1
XP: 30
Drop_Chance: 10.0
Drop_Level:
Level_Requirement:
Standard_Mode: 10
Retro_Mode: 1000
Drops_From: [Gravel]
@ -22,7 +22,7 @@ Excavation:
Amount: 1
XP: 30
Drop_Chance: 10.0
Drop_Level:
Level_Requirement:
Standard_Mode: 20
Retro_Mode: 200
Drops_From: [Gravel]
@ -30,7 +30,7 @@ Excavation:
Amount: 1
XP: 100
Drop_Chance: 0.1
Drop_Level:
Level_Requirement:
Standard_Mode: 25
Retro_Mode: 250
Drops_From: [Grass_Block, Mycelium]
@ -38,7 +38,7 @@ Excavation:
Amount: 1
XP: 100
Drop_Chance: 5.0
Drop_Level:
Level_Requirement:
Standard_Mode: 15
Retro_Mode: 150
Drops_From: [Clay]
@ -46,7 +46,7 @@ Excavation:
Amount: 1
XP: 100
Drop_Chance: 0.1
Drop_Level:
Level_Requirement:
Standard_Mode: 50
Retro_Mode: 500
Drops_From: [Clay]
@ -54,7 +54,7 @@ Excavation:
Amount: 1
XP: 30
Drop_Chance: 0.5
Drop_Level:
Level_Requirement:
Standard_Mode: 85
Retro_Mode: 850
Drops_From: [Gravel]
@ -62,7 +62,7 @@ Excavation:
Amount: 1
XP: 80
Drop_Chance: 0.5
Drop_Level:
Level_Requirement:
Standard_Mode: 50
Retro_Mode: 500
Drops_From: [Dirt, Coarse_Dirt, Podzol, Grass_Block, Mycelium]
@ -70,7 +70,7 @@ Excavation:
Amount: 1
XP: 80
Drop_Chance: 0.5
Drop_Level:
Level_Requirement:
Standard_Mode: 50
Retro_Mode: 500
Drops_From: [Dirt, Coarse_Dirt, Podzol, Grass_Block, Mycelium]
@ -78,7 +78,7 @@ Excavation:
Amount: 1
XP: 100
Drop_Chance: 1.0
Drop_Level:
Level_Requirement:
Standard_Mode: 25
Retro_Mode: 250
Drops_From: [Grass_Block]
@ -86,7 +86,7 @@ Excavation:
Amount: 1
XP: 80
Drop_Chance: 0.5
Drop_Level:
Level_Requirement:
Standard_Mode: 65
Retro_Mode: 650
Drops_From: [Sand, Red_Sand]
@ -94,7 +94,7 @@ Excavation:
Amount: 1
XP: 100
Drop_Chance: 0.1
Drop_Level:
Level_Requirement:
Standard_Mode: 50
Retro_Mode: 500
Drops_From: [Clay]
@ -102,7 +102,7 @@ Excavation:
Amount: 1
XP: 150
Drop_Chance: 5.0
Drop_Level:
Level_Requirement:
Standard_Mode: 75
Retro_Mode: 750
Drops_From: [Clay]
@ -110,7 +110,7 @@ Excavation:
Amount: 1
XP: 200
Drop_Chance: 5.0
Drop_Level:
Level_Requirement:
Standard_Mode: 25
Retro_Mode: 250
Drops_From: [Clay]
@ -118,7 +118,7 @@ Excavation:
Amount: 1
XP: 80
Drop_Chance: 5.0
Drop_Level:
Level_Requirement:
Standard_Mode: 5
Retro_Mode: 50
Drops_From: [Dirt, Coarse_Dirt, Podzol, Grass_Block, Sand, Red_Sand, Mycelium]
@ -126,7 +126,7 @@ Excavation:
Amount: 1
XP: 3000
Drop_Chance: 0.05
Drop_Level:
Level_Requirement:
Standard_Mode: 25
Retro_Mode: 250
Drops_From: [Dirt, Coarse_Dirt, Podzol, Grass_Block, Sand, Red_Sand, Gravel, Clay, Mycelium, Soul_Sand, Soul_Soil]
@ -134,7 +134,7 @@ Excavation:
Amount: 1
XP: 3000
Drop_Chance: 0.05
Drop_Level:
Level_Requirement:
Standard_Mode: 25
Retro_Mode: 250
Drops_From: [Dirt, Coarse_Dirt, Podzol, Grass_Block, Sand, Red_Sand, Gravel, Clay, Mycelium, Soul_Sand, Soul_Soil]
@ -142,7 +142,7 @@ Excavation:
Amount: 1
XP: 1000
Drop_Chance: 0.13
Drop_Level:
Level_Requirement:
Standard_Mode: 35
Retro_Mode: 350
Drops_From: [Dirt, Coarse_Dirt, Podzol, Grass_Block, Sand, Red_Sand, Gravel, Clay, Mycelium, Soul_Sand, Soul_Soil]
@ -150,7 +150,7 @@ Excavation:
Amount: 1
XP: 100
Drop_Chance: 1.33
Drop_Level:
Level_Requirement:
Standard_Mode: 35
Retro_Mode: 350
Drops_From: [Dirt, Coarse_Dirt, Podzol, Grass_Block, Mycelium]
@ -158,7 +158,7 @@ Excavation:
Amount: 1
XP: 100
Drop_Chance: 0.5
Drop_Level:
Level_Requirement:
Standard_Mode: 85
Retro_Mode: 850
Drops_From: [Dirt, Coarse_Dirt, Podzol, Grass_Block, Sand, Red_Sand, Gravel, Mycelium, Soul_Sand, Soul_Soil]
@ -166,20 +166,20 @@ Excavation:
Amount: 1
XP: 3000
Drop_Chance: 0.05
Drop_Level:
Level_Requirement:
Standard_Mode: 25
Retro_Mode: 250
Drops_From: [Dirt, Coarse_Dirt, Podzol, Grass_Block, Sand, Red_Sand, Gravel, Clay, Mycelium, Soul_Sand, Soul_Soil]
#
# Settings for Hylian Luck
# If you are in retro mode, Drop_Level is multiplied by 10.
# If you are in retro mode, Level_Requirement is multiplied by 10.
###
Hylian_Luck:
MELON_SEEDS:
Amount: 1
XP: 0
Drop_Chance: 100.0
Drop_Level:
Level_Requirement:
Standard_Mode: 0
Retro_Mode: 0
Drops_From: [Bushes]
@ -187,7 +187,7 @@ Hylian_Luck:
Amount: 1
XP: 0
Drop_Chance: 100.0
Drop_Level:
Level_Requirement:
Standard_Mode: 0
Retro_Mode: 0
Drops_From: [Bushes]
@ -195,7 +195,7 @@ Hylian_Luck:
Amount: 1
XP: 0
Drop_Chance: 100.0
Drop_Level:
Level_Requirement:
Standard_Mode: 0
Retro_Mode: 0
Drops_From: [Bushes]
@ -203,7 +203,7 @@ Hylian_Luck:
Amount: 1
XP: 0
Drop_Chance: 100.0
Drop_Level:
Level_Requirement:
Standard_Mode: 0
Retro_Mode: 0
Drops_From: [Flowers]
@ -211,7 +211,7 @@ Hylian_Luck:
Amount: 1
XP: 0
Drop_Chance: 100.0
Drop_Level:
Level_Requirement:
Standard_Mode: 0
Retro_Mode: 0
Drops_From: [Flowers]
@ -219,7 +219,7 @@ Hylian_Luck:
Amount: 1
XP: 0
Drop_Chance: 100.0
Drop_Level:
Level_Requirement:
Standard_Mode: 0
Retro_Mode: 0
Drops_From: [Flowers]
@ -227,7 +227,7 @@ Hylian_Luck:
Amount: 1
XP: 0
Drop_Chance: 100.0
Drop_Level:
Level_Requirement:
Standard_Mode: 0
Retro_Mode: 0
Drops_From: [Pots]
@ -235,7 +235,7 @@ Hylian_Luck:
Amount: 1
XP: 0
Drop_Chance: 100.0
Drop_Level:
Level_Requirement:
Standard_Mode: 0
Retro_Mode: 0
Drops_From: [Pots]
@ -243,7 +243,7 @@ Hylian_Luck:
Amount: 1
XP: 0
Drop_Chance: 100.0
Drop_Level:
Level_Requirement:
Standard_Mode: 0
Retro_Mode: 0
Drops_From: [Pots]