Update to fix ArmourTypes freeze.

This commit is contained in:
Sindusk
2018-06-24 07:43:04 -04:00
parent 89600d06b5
commit d8897f5add
3 changed files with 24 additions and 34 deletions

View File

@@ -7,6 +7,7 @@ import com.wurmonline.server.items.*;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.NotFoundException;
import mod.sin.lib.ArmourAssist;
import mod.sin.lib.Util;
import mod.sin.lib.WoundAssist;
import org.gotti.wurmunlimited.modloader.ReflectionUtil;
@@ -19,10 +20,8 @@ import java.util.logging.Logger;
public class ArmourTweaks {
public static Logger logger = Logger.getLogger(ArmourTweaks.class.getName());
public static String[] armourTypes = {"cloth", "leather", "studded", "chain", "plate", "drake", "dragonscale", // Worn armour pieces
"scale", "ring", "splint"}; // Used by the system but not worn by players
public static HashMap<String, Integer> armourNameToType = new HashMap<>();
public static HashMap<Integer, String> armourTypeToName = new HashMap<>();
//public static String[] armourTypes = {"cloth", "leather", "studded", "chain", "plate", "drake", "dragonscale", // Worn armour pieces
// "scale", "ring", "splint"}; // Used by the system but not worn by players
public static HashMap<Integer, Float> armourDamageReduction = new HashMap<>();
public static HashMap<Integer, HashMap<Byte, Float>> armourEffectiveness = new HashMap<>();
@@ -107,14 +106,8 @@ public class ArmourTweaks {
toReturn *= materialGlanceRate.get(armourMaterial).get(damageType);
//logger.info(String.format("Found material %s, adjusting glance rate by %.2f%%.", armourMaterial, materialGlanceRate.get(armourMaterial).get(damageType)));
}
String name = String.valueOf(armourType);
if(ArmourTweaks.armourTypeToName.containsKey(armourType)){
name = ArmourTweaks.armourTypeToName.get(armourType);
}
String wound = String.valueOf(damageType);
if(WoundAssist.woundTypeToName.containsKey(damageType)){
wound = WoundAssist.woundTypeToName.get(damageType);
}
String name = ArmourAssist.getArmourName(armourType);
String wound = WoundAssist.getWoundName(damageType);
//logger.info(String.format("Glance rate for %s against %s: %.2f", name, wound, toReturn));
return toReturn;
}
@@ -265,7 +258,7 @@ public class ArmourTweaks {
public static void initializeArmourMaps(){
// Armour name mapping:
armourNameToType.put("cloth", ArmourTypes.ARMOUR_CLOTH);
/*armourNameToType.put("cloth", ArmourTypes.ARMOUR_CLOTH);
armourNameToType.put("leather", ArmourTypes.ARMOUR_LEATHER);
armourNameToType.put("studded", ArmourTypes.ARMOUR_STUDDED);
armourNameToType.put("chain", ArmourTypes.ARMOUR_CHAIN);
@@ -277,7 +270,7 @@ public class ArmourTweaks {
armourNameToType.put("splint", ArmourTypes.ARMOUR_SPLINT);
for(String name : armourNameToType.keySet()){
armourTypeToName.put(armourNameToType.get(name), name);
}
}*/
// Default material movement speed modifiers:
materialMovementModifier.put(Materials.MATERIAL_ADAMANTINE, 0.95f);

View File

@@ -3,6 +3,7 @@ package mod.sin.armoury;
import com.wurmonline.server.creatures.CreatureTemplate;
import com.wurmonline.server.creatures.CreatureTemplateFactory;
import com.wurmonline.server.items.Materials;
import mod.sin.lib.ArmourAssist;
import mod.sin.lib.Prop;
import mod.sin.lib.WoundAssist;
import org.gotti.wurmunlimited.modloader.interfaces.*;
@@ -62,13 +63,6 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene
public static HashMap<Integer, Float> weaponParryPercent = new HashMap<>();
public static HashMap<Integer, Double> weaponSkillPenalty = new HashMap<>();
public static int parseArmourType(String str){
if(ArmourTweaks.armourNameToType.containsKey(str.toLowerCase())){
return ArmourTweaks.armourNameToType.get(str.toLowerCase());
}
return Integer.parseInt(str);
}
public static byte parseMaterialType(String str){
byte mat = Materials.convertMaterialStringIntoByte(str);
if(mat > 0){
@@ -148,17 +142,17 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene
armourReductionOverride.put(armourId, reductionValue);
} else if (name.startsWith("armourDamageReduction")) {
String[] split = value.split(",");
int armourId = parseArmourType(split[0]);
int armourId = ArmourAssist.getArmourType(split[0]);
float reductionValue = Float.parseFloat(split[1]);
ArmourTweaks.addArmourDamageReduction(armourId, reductionValue);
} else if (name.startsWith("armourEffectiveness")) {
String[] split = value.split(";");
int armourType = parseArmourType(split[0]);
int armourType = ArmourAssist.getArmourType(split[0]);
String[] split2 = split[1].split(",");
ArmourTweaks.addArmourEffectiveness(armourType, split2);
} else if (name.startsWith("armourGlanceRate")) {
String[] split = value.split(";");
int armourType = parseArmourType(split[0]);
int armourType = ArmourAssist.getArmourType(split[0]);
String[] split2 = split[1].split(",");
ArmourTweaks.addArmourGlanceRate(armourType, split2);
} else if (name.startsWith("materialDamageReduction")) {
@@ -326,19 +320,21 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene
logger.log(Level.INFO, "unarmouredReduction: " + ArmourTweaks.unarmouredReduction);
logger.info("> Armour Base DR Settings <");
for(int armourType : ArmourTweaks.armourDamageReduction.keySet()){
String name = String.valueOf(armourType);
String name = ArmourAssist.getArmourName(armourType);
/*String name = String.valueOf(armourType);
if(ArmourTweaks.armourTypeToName.containsKey(armourType)){
name = ArmourTweaks.armourTypeToName.get(armourType);
}
}*/
//logger.info("Base DR for "+name+": "+(ArmourTweaks.armourDamageReduction.get(armourType)*100f) +"%");
logger.info(String.format("Base DR for %s: %.2f%%", name, ArmourTweaks.armourDamageReduction.get(armourType)*100f));
}
logger.info("> Armour Effectiveness Settings <");
for(int armourType : ArmourTweaks.armourEffectiveness.keySet()){
String name = String.valueOf(armourType);
String name = ArmourAssist.getArmourName(armourType);
/*String name = String.valueOf(armourType);
if(ArmourTweaks.armourTypeToName.containsKey(armourType)){
name = ArmourTweaks.armourTypeToName.get(armourType);
}
}*/
HashMap<Byte, Float> woundMap = ArmourTweaks.armourEffectiveness.get(armourType);
for(byte woundType : woundMap.keySet()){
String wound = WoundAssist.getWoundName(woundType);
@@ -348,10 +344,11 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene
}
logger.info("> Armour Glance Rate Settings <");
for(int armourType : ArmourTweaks.armourGlanceRates.keySet()){
String name = String.valueOf(armourType);
String name = ArmourAssist.getArmourName(armourType);
/*String name = String.valueOf(armourType);
if(ArmourTweaks.armourTypeToName.containsKey(armourType)){
name = ArmourTweaks.armourTypeToName.get(armourType);
}
}*/
HashMap<Byte, Float> woundMap = ArmourTweaks.armourGlanceRates.get(armourType);
for(byte woundType : woundMap.keySet()){
String wound = WoundAssist.getWoundName(woundType);
@@ -506,8 +503,8 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene
public void onServerStarted(){
WeaponTweaks.onServerStarted();
for(CreatureTemplate template : CreatureTemplateFactory.getInstance().getTemplates()){
if(ArmourTweaks.armourTypeToName.containsKey((int) template.getArmourType())) {
logger.info(template.getName() + " - " + ArmourTweaks.armourTypeToName.get((int) template.getArmourType()));
if(ArmourAssist.armourTypeToName.containsKey((int) template.getArmourType())) {
logger.info(template.getName() + " - " + ArmourAssist.armourTypeToName.get((int) template.getArmourType()));
}
}
}