Another dupe fix + 1.16 support part 4

This commit is contained in:
nossr50
2020-03-03 16:37:13 -08:00
parent d585b1c2f7
commit 89a990f0cb
7 changed files with 75 additions and 53 deletions

View File

@ -153,6 +153,9 @@ public class mcMMO extends JavaPlugin {
modManager = new ModManager();
//Init Material Maps
materialMapStore = new MaterialMapStore();
loadConfigFiles();
if (!noErrorsInConfigFiles) {
@ -250,9 +253,6 @@ public class mcMMO extends JavaPlugin {
getServer().getPluginManager().disablePlugin(this);
}
//Init Material Maps
materialMapStore = new MaterialMapStore();
//Init player level values
playerLevelUtils = new PlayerLevelUtils();

View File

@ -136,11 +136,11 @@ public class MiningManager extends SkillManager {
List<BlockState> ores = new ArrayList<BlockState>();
List<Block> newYieldList = new ArrayList<>();
List<Block> notOres = new ArrayList<>();
for (Block targetBlock : event.blockList()) {
//Containers usually have 0 XP unless someone edited their config in a very strange way
if (ExperienceConfig.getInstance().getXp(PrimarySkillType.MINING, targetBlock) == 0 || targetBlock instanceof Container || mcMMO.getPlaceStore().isTrue(targetBlock)) {
newYieldList.add(targetBlock);
notOres.add(targetBlock);
} else {
ores.add(targetBlock.getState());
}
@ -156,7 +156,7 @@ public class MiningManager extends SkillManager {
// float debrisYield = yield - debrisReduction;
for (BlockState blockState : ores) {
if (Misc.getRandom().nextFloat() < (newYieldList.size() + oreBonus)) {
if (Misc.getRandom().nextFloat() < (notOres.size() + oreBonus)) {
xp += Mining.getBlockXp(blockState);
Misc.dropItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType())); // Initial block that would have been dropped
@ -168,8 +168,9 @@ public class MiningManager extends SkillManager {
}
//Replace the event blocklist with the newYield list
event.blockList().clear();
event.blockList().addAll(newYieldList);
event.setYield(0F);
// event.blockList().clear();
// event.blockList().addAll(notOres);
applyXpGain(xp, XPGainReason.PVE);
}

View File

@ -98,6 +98,8 @@ public class SwordsManager extends SkillManager {
public int getToolTier(ItemStack itemStack)
{
if(ItemUtils.isNetherriteTool(itemStack))
return 5;
if(ItemUtils.isDiamondTool(itemStack))
return 4;
else if(ItemUtils.isIronTool(itemStack) || ItemUtils.isGoldTool(itemStack))

View File

@ -2,6 +2,7 @@ package com.gmail.nossr50.util;
import org.bukkit.Material;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
@ -53,6 +54,8 @@ public class MaterialMapStore {
private HashSet<String> ores;
private HashMap<String, Integer> tierValue;
public MaterialMapStore()
{
@ -96,7 +99,9 @@ public class MaterialMapStore {
ores = new HashSet<>();
fillHardcodedHashSets();
tierValue = new HashMap<>();
fillVanillaMaterialRegisters();
}
public boolean isMultiBlockPlant(Material material)
@ -139,7 +144,7 @@ public class MaterialMapStore {
return canMakeShroomyWhiteList.contains(material.getKey().getKey());
}
private void fillHardcodedHashSets()
private void fillVanillaMaterialRegisters()
{
fillAbilityBlackList();
fillToolBlackList();
@ -155,6 +160,34 @@ public class MaterialMapStore {
fillTools();
fillEnchantables();
fillOres();
fillTierMap();
}
private void fillTierMap() {
for(String id : leatherArmor) {
tierValue.put(id, 1);
}
for(String id : ironArmor) {
tierValue.put(id, 2);
}
for(String id : goldArmor) {
tierValue.put(id, 3);
}
for(String id : chainmailArmor) {
tierValue.put(id, 3);
}
for(String id : diamondArmor) {
tierValue.put(id, 6);
}
for(String id : netherriteArmor) {
tierValue.put(id, 12);
}
}
private void fillOres() {
@ -1040,6 +1073,14 @@ public class MaterialMapStore {
toolBlackList.add("stonecutter");
}
public int getTier(Material material) {
return getTier(material.getKey().getKey());
}
public int getTier(String id) {
return tierValue.getOrDefault(id, 1); //1 for unknown items
}
private void addToHashSet(String string, HashSet<String> stringHashSet)
{
stringHashSet.add(string.toLowerCase(Locale.ENGLISH));

View File

@ -411,12 +411,9 @@ public final class CombatUtils {
if(metadataValue.size() <= 0)
return;
if(metadataValue != null)
{
OldName oldName = (OldName) metadataValue.get(0);
entity.setCustomName(oldName.asString());
entity.setCustomNameVisible(false);
}
OldName oldName = (OldName) metadataValue.get(0);
entity.setCustomName(oldName.asString());
entity.setCustomNameVisible(false);
}
/**
@ -480,33 +477,7 @@ public final class CombatUtils {
* @return the armor quality of a specific Item Stack
*/
private static int getArmorQuality(ItemStack itemStack) {
int quality = 0;
switch(itemStack.getType()) {
case LEATHER_HELMET:
case LEATHER_BOOTS:
case LEATHER_CHESTPLATE:
case LEATHER_LEGGINGS:
return 1;
case IRON_HELMET:
case IRON_BOOTS:
case IRON_CHESTPLATE:
case IRON_LEGGINGS:
return 2;
case GOLDEN_HELMET:
case GOLDEN_BOOTS:
case GOLDEN_CHESTPLATE:
case GOLDEN_LEGGINGS:
return 3;
case DIAMOND_HELMET:
case DIAMOND_BOOTS:
case DIAMOND_CHESTPLATE:
case DIAMOND_LEGGINGS:
return 6;
default:
return 1;
}
return mcMMO.getMaterialMapStore().getTier(itemStack.getType().getKey().getKey());
}
/**