Fix for SpellEffectsEnum class freeze

This commit is contained in:
Sindusk
2018-06-24 08:04:29 -04:00
parent d8897f5add
commit b657797f1b
4 changed files with 19 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
apply plugin: 'java'
group "mod.sin"
version "2.3"
version "2.4"
repositories {
mavenCentral()

View File

@@ -1,4 +1,4 @@
classname=ArmouryMod
classname=mod.sin.armoury.ArmouryMod
classpath=Armoury.jar
depend.import=SinduskLibrary
depend.suggests=ServerTweaks

View File

@@ -502,6 +502,7 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene
@Override
public void onServerStarted(){
WeaponTweaks.onServerStarted();
CombatTweaks.onServerStarted();
for(CreatureTemplate template : CreatureTemplateFactory.getInstance().getTemplates()){
if(ArmourAssist.armourTypeToName.containsKey((int) template.getArmourType())) {
logger.info(template.getName() + " - " + ArmourAssist.armourTypeToName.get((int) template.getArmourType()));

View File

@@ -39,6 +39,20 @@ public class CombatTweaks {
}
}
public static void onServerStarted(){
// - Make spell effects hud show your armour limit properly - //
if(ArmouryMod.fixArmourLimitSpellEffect){
try {
ReflectionUtil.setPrivateField(SpellEffectsEnum.ARMOUR_LIMIT_HEAVY, ReflectionUtil.getField(SpellEffectsEnum.ARMOUR_LIMIT_HEAVY.getClass(), "name"), "Armour Penalty");
ReflectionUtil.setPrivateField(SpellEffectsEnum.ARMOUR_LIMIT_MEDIUM, ReflectionUtil.getField(SpellEffectsEnum.ARMOUR_LIMIT_MEDIUM.getClass(), "name"), "Armour Penalty");
ReflectionUtil.setPrivateField(SpellEffectsEnum.ARMOUR_LIMIT_LIGHT, ReflectionUtil.getField(SpellEffectsEnum.ARMOUR_LIMIT_LIGHT.getClass(), "name"), "Armour Bonus");
ReflectionUtil.setPrivateField(SpellEffectsEnum.ARMOUR_LIMIT_NONE, ReflectionUtil.getField(SpellEffectsEnum.ARMOUR_LIMIT_NONE.getClass(), "name"), "Armour Bonus");
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
}
}
}
public static void preInit(){
try {
ClassPool classPool = HookManager.getInstance().getClassPool();
@@ -122,14 +136,6 @@ public class CombatTweaks {
});
}
// - Make spell effects hud show your armour limit properly - //
if(ArmouryMod.fixArmourLimitSpellEffect){
ReflectionUtil.setPrivateField(SpellEffectsEnum.ARMOUR_LIMIT_HEAVY, ReflectionUtil.getField(SpellEffectsEnum.ARMOUR_LIMIT_HEAVY.getClass(), "name"), "Armour Penalty");
ReflectionUtil.setPrivateField(SpellEffectsEnum.ARMOUR_LIMIT_MEDIUM, ReflectionUtil.getField(SpellEffectsEnum.ARMOUR_LIMIT_MEDIUM.getClass(), "name"), "Armour Penalty");
ReflectionUtil.setPrivateField(SpellEffectsEnum.ARMOUR_LIMIT_LIGHT, ReflectionUtil.getField(SpellEffectsEnum.ARMOUR_LIMIT_LIGHT.getClass(), "name"), "Armour Bonus");
ReflectionUtil.setPrivateField(SpellEffectsEnum.ARMOUR_LIMIT_NONE, ReflectionUtil.getField(SpellEffectsEnum.ARMOUR_LIMIT_NONE.getClass(), "name"), "Armour Bonus");
}
// - Change the minimum swing timer - //
if(ArmouryMod.minimumSwingTime != 3.0f){
CtClass ctCombatHandler = classPool.get("com.wurmonline.server.creatures.CombatHandler");
@@ -293,7 +299,7 @@ public class CombatTweaks {
desc = Descriptor.ofMethod(CtClass.booleanType, params3);
ctCombatHandler.getMethod("attack", desc).insertBefore("logger.info(\"Calling attack(Creature, Item, boolean)\");");*/
} catch (CannotCompileException | NotFoundException | IllegalArgumentException | IllegalAccessException | ClassCastException | NoSuchFieldException e) {
} catch (CannotCompileException | NotFoundException | IllegalArgumentException | ClassCastException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}