Forráskód Böngészése

moved mana and cooldown handling to snuviscript, added 9 function keys, event goes to snuviscript

Kajetan Johannes Hammerle 6 éve
szülő
commit
20498393bb
100 módosított fájl, 556 hozzáadás és 784 törlés
  1. 0 31
      src/main/java/me/km/ClientEvents.java
  2. 2 0
      src/main/java/me/km/ClientProxy.java
  3. 1 1
      src/main/java/me/km/KajetansMod.java
  4. 18 47
      src/main/java/me/km/effects/ActiveEffectBase.java
  5. 12 7
      src/main/java/me/km/effects/CommandWand.java
  6. 89 103
      src/main/java/me/km/effects/Effect.java
  7. 1 16
      src/main/java/me/km/effects/EffectUtils.java
  8. 14 2
      src/main/java/me/km/effects/PlayerUsesEffectEvent.java
  9. 0 6
      src/main/java/me/km/effects/active/ArcaneShot.java
  10. 0 7
      src/main/java/me/km/effects/active/AreaDamage.java
  11. 0 6
      src/main/java/me/km/effects/active/ArmorPasser.java
  12. 0 6
      src/main/java/me/km/effects/active/BlindingShot.java
  13. 0 6
      src/main/java/me/km/effects/active/BlockExplosion.java
  14. 0 6
      src/main/java/me/km/effects/active/BoneBreaker.java
  15. 0 6
      src/main/java/me/km/effects/active/BunnyHop.java
  16. 0 6
      src/main/java/me/km/effects/active/CallBack.java
  17. 0 6
      src/main/java/me/km/effects/active/ClusterBomb.java
  18. 0 6
      src/main/java/me/km/effects/active/ConstantPower.java
  19. 0 6
      src/main/java/me/km/effects/active/Cripple.java
  20. 0 6
      src/main/java/me/km/effects/active/Day.java
  21. 0 6
      src/main/java/me/km/effects/active/Doomed.java
  22. 0 6
      src/main/java/me/km/effects/active/Earthquake.java
  23. 0 6
      src/main/java/me/km/effects/active/Elevation.java
  24. 0 6
      src/main/java/me/km/effects/active/ElvishHorn.java
  25. 0 6
      src/main/java/me/km/effects/active/Enderchest.java
  26. 0 6
      src/main/java/me/km/effects/active/Explosion.java
  27. 0 6
      src/main/java/me/km/effects/active/FallImmunity.java
  28. 0 6
      src/main/java/me/km/effects/active/Fire.java
  29. 0 6
      src/main/java/me/km/effects/active/FireProtectionRain.java
  30. 0 6
      src/main/java/me/km/effects/active/FireShot.java
  31. 0 6
      src/main/java/me/km/effects/active/Fireball.java
  32. 0 6
      src/main/java/me/km/effects/active/Flying.java
  33. 0 6
      src/main/java/me/km/effects/active/Freeze.java
  34. 0 6
      src/main/java/me/km/effects/active/GrapplingHook.java
  35. 0 6
      src/main/java/me/km/effects/active/Gravity.java
  36. 0 6
      src/main/java/me/km/effects/active/Harm.java
  37. 0 6
      src/main/java/me/km/effects/active/Harvest.java
  38. 0 6
      src/main/java/me/km/effects/active/Heal.java
  39. 0 6
      src/main/java/me/km/effects/active/HealRain.java
  40. 0 6
      src/main/java/me/km/effects/active/HeartSeeker.java
  41. 0 6
      src/main/java/me/km/effects/active/Hearts.java
  42. 0 6
      src/main/java/me/km/effects/active/HungerPunch.java
  43. 0 6
      src/main/java/me/km/effects/active/Immortality.java
  44. 0 6
      src/main/java/me/km/effects/active/ImpactPunch.java
  45. 0 6
      src/main/java/me/km/effects/active/Invisibility.java
  46. 0 6
      src/main/java/me/km/effects/active/Jump.java
  47. 0 6
      src/main/java/me/km/effects/active/JumpAttack.java
  48. 0 6
      src/main/java/me/km/effects/active/Kick.java
  49. 0 12
      src/main/java/me/km/effects/active/LeafCocoon.java
  50. 0 6
      src/main/java/me/km/effects/active/LifeBreaker.java
  51. 0 6
      src/main/java/me/km/effects/active/LifeSteal.java
  52. 0 6
      src/main/java/me/km/effects/active/LockPick.java
  53. 0 6
      src/main/java/me/km/effects/active/Lucky.java
  54. 0 6
      src/main/java/me/km/effects/active/Musket.java
  55. 0 6
      src/main/java/me/km/effects/active/NailDown.java
  56. 0 6
      src/main/java/me/km/effects/active/NailTrap.java
  57. 0 6
      src/main/java/me/km/effects/active/NetTrap.java
  58. 0 6
      src/main/java/me/km/effects/active/Night.java
  59. 0 6
      src/main/java/me/km/effects/active/Poison.java
  60. 0 6
      src/main/java/me/km/effects/active/PoisonVolley.java
  61. 0 6
      src/main/java/me/km/effects/active/PoisonedBlade.java
  62. 0 6
      src/main/java/me/km/effects/active/Power.java
  63. 0 6
      src/main/java/me/km/effects/active/PowerAttack.java
  64. 0 6
      src/main/java/me/km/effects/active/Pull.java
  65. 0 6
      src/main/java/me/km/effects/active/Push.java
  66. 0 6
      src/main/java/me/km/effects/active/PushUp.java
  67. 0 6
      src/main/java/me/km/effects/active/QuickShot.java
  68. 0 6
      src/main/java/me/km/effects/active/Rain.java
  69. 1 7
      src/main/java/me/km/effects/active/RapidFire.java
  70. 0 6
      src/main/java/me/km/effects/active/Rooting.java
  71. 0 6
      src/main/java/me/km/effects/active/Shadow.java
  72. 0 6
      src/main/java/me/km/effects/active/ShadowHit.java
  73. 0 6
      src/main/java/me/km/effects/active/ShadowStep.java
  74. 0 6
      src/main/java/me/km/effects/active/Silence.java
  75. 0 6
      src/main/java/me/km/effects/active/SlowingShot.java
  76. 0 6
      src/main/java/me/km/effects/active/Smash.java
  77. 0 6
      src/main/java/me/km/effects/active/SmokeBomb.java
  78. 0 6
      src/main/java/me/km/effects/active/Sprint.java
  79. 0 6
      src/main/java/me/km/effects/active/Stone.java
  80. 0 6
      src/main/java/me/km/effects/active/Sun.java
  81. 0 6
      src/main/java/me/km/effects/active/TeleportBlock.java
  82. 0 6
      src/main/java/me/km/effects/active/TeleportPlayer.java
  83. 0 6
      src/main/java/me/km/effects/active/Thor.java
  84. 0 6
      src/main/java/me/km/effects/active/Unlucky.java
  85. 0 7
      src/main/java/me/km/effects/active/VineTrap.java
  86. 0 6
      src/main/java/me/km/effects/active/Workbench.java
  87. 47 20
      src/main/java/me/km/items/ItemGun.java
  88. 24 5
      src/main/java/me/km/items/ItemKey.java
  89. 81 27
      src/main/java/me/km/items/ItemScroll.java
  90. 76 18
      src/main/java/me/km/items/ItemWand.java
  91. 1 1
      src/main/java/me/km/jobsystem/JobAPI.java
  92. 50 0
      src/main/java/me/km/networking/FunctionKey.java
  93. 58 0
      src/main/java/me/km/networking/KeyManager.java
  94. 6 0
      src/main/java/me/km/networking/ModPacketHandler.java
  95. 20 15
      src/main/java/me/km/scrolls/CommandScroll.java
  96. 1 2
      src/main/java/me/km/skills/ActiveSkillContainer.java
  97. 25 5
      src/main/java/me/km/skills/Skill.java
  98. 9 4
      src/main/java/me/km/skills/SkillManager.java
  99. 11 1
      src/main/java/me/km/snuviscript/MinecraftFunctions.java
  100. 9 2
      src/main/java/me/km/snuviscript/ScriptEvents.java

+ 0 - 31
src/main/java/me/km/ClientEvents.java

@@ -2,8 +2,6 @@ package me.km;
 
 import java.util.List;
 import me.km.api.GlobalText;
-import me.km.items.ItemGun;
-import me.km.items.ItemKey;
 import me.km.networking.PlayerDisplayGui;
 import net.minecraft.item.Item;
 import net.minecraft.item.ItemArmor;
@@ -73,34 +71,5 @@ public class ClientEvents
                 }
             }
         }
-        else if(item.getClass() == ItemGun.class)
-        {
-            int load = ItemGun.getLoad(stack);
-            if(load >= 0)
-            {
-                List<String> list = e.getToolTip();
-                if(load == 1)
-                {
-                    list.add(1, TextFormatting.GOLD + "" + load + " shot loaded");
-                }
-                else
-                {
-                    list.add(1, TextFormatting.GOLD + "" + load + " shots loaded");
-                }
-            }
-        }
-        else if(item.getClass() == ItemKey.class)
-        {
-            String s = ItemKey.getKey(stack);
-            List<String> list = e.getToolTip();
-            if(s.isEmpty())
-            {
-                list.set(0, TextFormatting.RED + list.get(0));
-            }
-            else
-            {
-                list.set(0, TextFormatting.GREEN + list.get(0));
-            }
-        }
     }
 }

+ 2 - 0
src/main/java/me/km/ClientProxy.java

@@ -3,6 +3,7 @@ package me.km;
 import me.km.entities.ModEntities;
 import me.km.items.ModelCylinder;
 import me.km.items.ModelHat;
+import me.km.networking.KeyManager;
 import net.minecraft.block.Block;
 import net.minecraft.block.state.IBlockState;
 import net.minecraft.client.model.ModelBiped;
@@ -63,6 +64,7 @@ public class ClientProxy extends CommonProxy
     {
         ModEntities.initClient();
         MinecraftForge.EVENT_BUS.register(new ClientEvents());
+        MinecraftForge.EVENT_BUS.register(new KeyManager());
     }
 
     @Override

+ 1 - 1
src/main/java/me/km/KajetansMod.java

@@ -69,7 +69,7 @@ public class KajetansMod
 
     public static final String MODID = "km";
     public static final String NAME = "Kajetans Mod";
-    public static final String VERSION = "0.0.12";
+    public static final String VERSION = "0.0.13";
 
     @Mod.Instance(MODID)
     public static KajetansMod instance;

+ 18 - 47
src/main/java/me/km/effects/ActiveEffectBase.java

@@ -7,14 +7,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
 
 public abstract class ActiveEffectBase 
 {
-    protected abstract int getManaCost(int manaFactor);
-    
-    public int getCoolDown()
-    {
-        return 0;
-    }
-    
-    public boolean run(EntityPlayerMP p, int power, int manaFactor, EffectCause cause)
+    public final boolean run(EntityPlayerMP p, int power, int mana, int cooldown, EffectCause cause)
     {
         if(cause != EffectCause.NOTHING)
         {
@@ -29,9 +22,9 @@ public abstract class ActiveEffectBase
                 return false;
             }
         }
-        int manaCost = getManaCost(manaFactor);
         // Effect-Event-Start
-        PlayerUsesEffectEvent e = new PlayerUsesEffectEvent(p, power, manaCost, cause, this.getClass());
+        String name = this.getClass().getSimpleName();
+        PlayerUsesEffectEvent e = new PlayerUsesEffectEvent(p, power, mana, cooldown, cause, name);
         KajetansMod.scripts.getEvent(ScriptEvents.class).useEffectEvent(e);
         if(e.isCanceled())
         {
@@ -40,42 +33,36 @@ public abstract class ActiveEffectBase
         else
         {
             power = e.getPower();
-            manaFactor = e.getMana();
+            mana = e.getMana();
+            cooldown = e.getCooldown();
         }
         // Effect-Event-End
         if(p.isCreative())
         {
             return executeEffect(p, power);
         }
-        if(!KajetansMod.playerbank.getData(p).hasData(this.getClass().getSimpleName()))
+        // cooldown check
+        if(!KajetansMod.playerbank.getData(p).hasData(name))
         {
-            if(manaFactor == 0)
+            if(mana > 0)
             {
-                if(executeEffect(p, power))
+                int currentMana = EnvironmentAPI.getMana(p);
+                if(currentMana < mana)
                 {
-                    int cooldown = getCoolDown();
-                    if(cooldown > 0)
-                    {
-                        KajetansMod.playerbank.getData(p).addTimedData(this.getClass().getSimpleName(), cooldown);
-                    }
-                    return true;
+                    KajetansMod.effects.send(p, "Du hast zu wenig Mana. (§a" + mana + "§r/§c" + mana + "§r)");
+                    return false;
                 }
-                return false;
-            }
-            int mana = EnvironmentAPI.getMana(p);
-            if(mana < manaCost)
-            {
-                KajetansMod.effects.send(p, "Du hast zu wenig Mana. (§a" + mana + "§r/§c" + manaCost + "§r)");
-                return false;
-            }
+            }  
             if(executeEffect(p, power))
             {
-                int cooldown = getCoolDown();
                 if(cooldown > 0)
                 {
-                    KajetansMod.playerbank.getData(p).addTimedData(this.getClass().getSimpleName(), cooldown);
+                    KajetansMod.playerbank.getData(p).addTimedData(name, cooldown);
+                }
+                if(mana >= 0)
+                {
+                    EnvironmentAPI.changeMana(p, -mana);
                 }
-                EnvironmentAPI.changeMana(p, -manaCost);
                 return true;
             }
             return false;
@@ -85,20 +72,4 @@ public abstract class ActiveEffectBase
     }
     
     protected abstract boolean executeEffect(EntityPlayerMP p, int power);
-    
-    public static boolean executeEffect(Class<? extends ActiveEffectBase> c, EntityPlayerMP p, int power, int manaFactor, EffectCause cause)
-    {
-        if(c == null)
-        {
-            return false;
-        }
-        try
-        {
-            return c.newInstance().run(p, power, manaFactor, cause);
-        }
-        catch(SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException ex)
-        {
-            throw new IllegalArgumentException();
-        }
-    }
 }

+ 12 - 7
src/main/java/me/km/effects/CommandWand.java

@@ -6,6 +6,7 @@ import me.km.api.GlobalText;
 import me.km.api.Module;
 import me.km.api.ModuleTabCommand;
 import me.km.items.ItemWand;
+import me.km.items.ModItems;
 import me.km.permissions.Permissions;
 import net.minecraft.command.ICommandSender;
 import net.minecraft.entity.player.EntityPlayer;
@@ -15,9 +16,12 @@ public class CommandWand extends ModuleTabCommand
 {   
     public CommandWand(Module m) 
     {
-        super("magicwand", m, Arrays.stream(Effect.values()).map(n -> n.getEffectString()).filter(o -> o != null).collect(Collectors.toList()), 0);
-        super.setDescription("Belegt deinen Zauberstab mit einem Effekt");
-        super.setUsage("/magicwand <effect>");
+        super("magicwand", m, Arrays.stream(Effect.values())
+                .filter(n -> n.isActive())
+                .map(n -> n.toString())
+                .collect(Collectors.toList()), 0);
+        super.setDescription("Belegt einen Zauberstab mit einem Effekt, Unterstriche bei <dname> werden zu Leerzeichen");
+        super.setUsage("/magicwand <effect> <dname>");
         super.setPermission(Permissions.WAND);
     }
 
@@ -38,13 +42,14 @@ public class CommandWand extends ModuleTabCommand
                 this.getModule().send(cs, "Du musst einen Zauberstab in der Hand halten.");
                 return true;
             }
-            Class<? extends ActiveEffectBase> c = EffectUtils.getEffectClass(arg[0]);
-            if(c == null)
+            
+            Effect eff = Effect.valueOf(arg[0]);
+            if(eff == null || !eff.isActive())
             { 
                 this.getModule().send(cs, "Dieser aktive Effekt existiert nicht.");
                 return true;
-            }
-            stack.setStackDisplayName("§6" + arg[0]);
+            }  
+            ModItems.woodenWand.setEffect(stack, eff.ordinal(), arg[1].replace('_', ' '));
             return true;
         } 
         return false;

+ 89 - 103
src/main/java/me/km/effects/Effect.java

@@ -62,94 +62,96 @@ public enum Effect
     NO_ARMOR_DROPPING       ,
     
     // active effects
-    POISON_VOLLEY           (PoisonVolley.class),
-    FIRE                    (Fire.class),
-    SHADOW_STEP             (ShadowStep.class),
-    BLINDING_SHOT           (BlindingShot.class),
-    KICK                    (Kick.class),
-    CRIPPLE                 (Cripple.class),
-    ELEVATION               (Elevation.class),
-    SUN                     (Sun.class),
-    IMMORTALITY             (Immortality.class),
-    LUCKY                   (Lucky.class),
-    POISONED_BLADE          (PoisonedBlade.class),
-    BUNNY_HOP               (BunnyHop.class),
-    CONSTANT_POWER          (ConstantPower.class),
-    ARMOR_PASSER            (ArmorPasser.class),
-    IMPACT_PUNCH            (ImpactPunch.class),
-    ENDERCHEST              (Enderchest.class),
-    NAIL_DOWN               (NailDown.class),
-    DOOMED                  (Doomed.class),
-    PUSH                    (Push.class),
-    PUSH_UP                 (PushUp.class),
-    HUNGER_PUNCH            (HungerPunch.class),
-    FIRE_SHOT               (FireShot.class),
-    PULL                    (Pull.class),
-    HEAL_RAIN               (HealRain.class),
-    UNLUCKY                 (Unlucky.class),
-    NAIL_TRAP               (NailTrap.class),
-    NIGHT                   (Night.class),
-    AREA_DAMAGE             (AreaDamage.class),
-    EARTHQUAKE              (Earthquake.class),
-    FIREBALL                (Fireball.class),
-    JUMP                    (Jump.class),
-    THOR                    (Thor.class),
-    GRAPPLING_HOOK          (GrapplingHook.class),
-    QUICK_SHOT              (QuickShot.class),
-    CALL_BACK               (CallBack.class),
-    SHADOW_HIT              (ShadowHit.class),
-    LOCK_PICK               (LockPick.class),
-    HEART_SEEKER            (HeartSeeker.class),
-    TELEPORT_PLAYER         (TeleportPlayer.class),
-    SPRINT                  (Sprint.class),
-    LIFE_BREAKER            (LifeBreaker.class),
-    POWER                   (Power.class),
-    MUSKET                  (Musket.class),
-    HEARTS                  (Hearts.class),
-    ROOTING                 (Rooting.class),
-    WORKBENCH               (Workbench.class),
-    NET_TRAP                (NetTrap.class),
-    LEAF_COCOON             (LeafCocoon.class),
-    POISON                  (Poison.class),
-    SMASH                   (Smash.class),
-    LIFE_STEAL              (LifeSteal.class),
-    SHADOW                  (Shadow.class),
-    SLOWING_SHOT            (SlowingShot.class),
-    VINE_TRAP               (VineTrap.class),
-    RAPID_FIRE              (RapidFire.class),
-    STONE                   (Stone.class),
-    FIRE_PROTECTION_RAIN    (FireProtectionRain.class),
-    BONE_BREAKER            (BoneBreaker.class),
-    ARCANE_SHOT             (ArcaneShot.class),
-    RAIN                    (Rain.class),
-    INVISIBILITY            (Invisibility.class),
-    DAY                     (Day.class),
-    FLYING                  (Flying.class),
-    EXPLOSION               (Explosion.class),
-    SMOKE_BOMB              (SmokeBomb.class),
-    HARVEST                 (Harvest.class),
-    FREEZE                  (Freeze.class),
-    FALL_IMMUNITY           (FallImmunity.class),
-    ELVISH_HORN             (ElvishHorn.class),
-    GRAVITY                 (Gravity.class),
-    TELEPORT_BLOCK          (TeleportBlock.class),
-    CLUSTER_BOMB            (ClusterBomb.class),
-    HARM                    (Harm.class),
-    SILENCE                 (Silence.class),
-    POWER_ATTACK            (PowerAttack.class),
-    HEAL                    (Heal.class),
-    JUMP_ATTACK             (JumpAttack.class),
-    BLOCK_EXPLOSION         (BlockExplosion.class);
+    POISON_VOLLEY           (new PoisonVolley()),
+    FIRE                    (new Fire()),
+    SHADOW_STEP             (new ShadowStep()),
+    BLINDING_SHOT           (new BlindingShot()),
+    KICK                    (new Kick()),
+    CRIPPLE                 (new Cripple()),
+    ELEVATION               (new Elevation()),
+    SUN                     (new Sun()),
+    IMMORTALITY             (new Immortality()),
+    LUCKY                   (new Lucky()),
+    POISONED_BLADE          (new PoisonedBlade()),
+    BUNNY_HOP               (new BunnyHop()),
+    CONSTANT_POWER          (new ConstantPower()),
+    ARMOR_PASSER            (new ArmorPasser()),
+    IMPACT_PUNCH            (new ImpactPunch()),
+    ENDERCHEST              (new Enderchest()),
+    NAIL_DOWN               (new NailDown()),
+    DOOMED                  (new Doomed()),
+    PUSH                    (new Push()),
+    HUNGER_PUNCH            (new HungerPunch()),
+    FIRE_SHOT               (new FireShot()),
+    PULL                    (new Pull()),
+    HEAL_RAIN               (new HealRain()),
+    UNLUCKY                 (new Unlucky()),
+    NAIL_TRAP               (new NailTrap()),
+    NIGHT                   (new Night()),
+    AREA_DAMAGE             (new AreaDamage()),
+    EARTHQUAKE              (new Earthquake()),
+    FIREBALL                (new Fireball()),
+    JUMP                    (new Jump()),
+    PUSH_UP                 (new PushUp()),
+    THOR                    (new Thor()),
+    GRAPPLING_HOOK          (new GrapplingHook()),
+    QUICK_SHOT              (new QuickShot()),
+    CALL_BACK               (new CallBack()),
+    SHADOW_HIT              (new ShadowHit()),
+    LOCK_PICK               (new LockPick()),
+    HEART_SEEKER            (new HeartSeeker()),
+    TELEPORT_PLAYER         (new TeleportPlayer()),
+    SPRINT                  (new Sprint()),
+    LIFE_BREAKER            (new LifeBreaker()),
+    POWER                   (new Power()),
+    MUSKET                  (new Musket()),
+    HEARTS                  (new Hearts()),
+    ROOTING                 (new Rooting()),
+    WORKBENCH               (new Workbench()),
+    NET_TRAP                (new NetTrap()),
+    LEAF_COCOON             (new LeafCocoon()),
+    POISON                  (new Poison()),
+    SMASH                   (new Smash()),
+    LIFE_STEAL              (new LifeSteal()),
+    SHADOW                  (new Shadow()),
+    SLOWING_SHOT            (new SlowingShot()),
+    VINE_TRAP               (new VineTrap()),
+    RAPID_FIRE              (new RapidFire()),
+    STONE                   (new Stone()),
+    FIRE_PROTECTION_RAIN    (new FireProtectionRain()),
+    BONE_BREAKER            (new BoneBreaker()),
+    ARCANE_SHOT             (new ArcaneShot()),
+    RAIN                    (new Rain()),
+    INVISIBILITY            (new Invisibility()),
+    DAY                     (new Day()),
+    FLYING                  (new Flying()),
+    EXPLOSION               (new Explosion()),
+    SMOKE_BOMB              (new SmokeBomb()),
+    HARVEST                 (new Harvest()),
+    FREEZE                  (new Freeze()),
+    FALL_IMMUNITY           (new FallImmunity()),
+    BLOCK_EXPLOSION         (new BlockExplosion()),
+    ELVISH_HORN             (new ElvishHorn()),
+    GRAVITY                 (new Gravity()),
+    TELEPORT_BLOCK          (new TeleportBlock()),
+    CLUSTER_BOMB            (new ClusterBomb()),
+    HARM                    (new Harm()),
+    SILENCE                 (new Silence()),
+    POWER_ATTACK            (new PowerAttack()),
+    HEAL                    (new Heal()),
+    JUMP_ATTACK             (new JumpAttack());
+    
+    private static Effect[] effects = Effect.values();
     
     private final ArrayList<Skill> skills;
-    private final Class<? extends ActiveEffectBase> c;
+    private final ActiveEffectBase aeb;
     private final boolean active;
     
-    Effect(Class<? extends ActiveEffectBase> c) 
+    Effect(ActiveEffectBase aeb) 
     {
         skills = new ArrayList<>();
-        this.active = c != null;
-        this.c = c;
+        this.active = aeb != null;
+        this.aeb = aeb;
     }
     
     Effect()
@@ -177,33 +179,17 @@ public enum Effect
         return active;
     }
     
-    public int getManaCost(int power)
-    {
-        if(c != null)
-        {
-            try
-            {
-                return c.newInstance().getManaCost(power);
-            }
-            catch(InstantiationException | IllegalAccessException ex)
-            {
-                return 0;
-            }
-        }
-        return 0;
-    }
-    
-    public Class<? extends ActiveEffectBase> getEffectBase()
+    public ActiveEffectBase getEffectInstance()
     {
-        return c;
+        return aeb;
     }
     
-    public String getEffectString()
+    public static Effect getEffect(int id)
     {
-        if(c == null)
+        if(id < 0 || id >= effects.length)
         {
             return null;
         }
-        return c.getSimpleName();
+        return effects[id];
     }
 }

+ 1 - 16
src/main/java/me/km/effects/EffectUtils.java

@@ -97,7 +97,7 @@ public class EffectUtils extends Module
     // Entity-Level
     // -----------------------------------------------------------------------------------
     
-    /** Returns the level of a players effect
+    /** Returns the level of a players effect, this is used for passive effects
      *
      * @param p a player
      * @param eff an effect
@@ -109,21 +109,6 @@ public class EffectUtils extends Module
         return eff.getSkills().stream().mapToInt(s -> job.getSkillLevel(p, s)).max().orElse(0);
     }
     
-    @SuppressWarnings(value = "unchecked")
-    public static Class<? extends ActiveEffectBase> getEffectClass(String s)
-    {
-        Class<? extends ActiveEffectBase> c;
-        try
-        {
-            c = (Class<? extends ActiveEffectBase>) Class.forName("me.km.effects.active." + s);
-        }
-        catch(ClassNotFoundException | ClassCastException ex)
-        {
-            return null;
-        }
-        return c;
-    }
-    
     // -----------------------------------------------------------------------------------
     // Entity-Collections
     // -----------------------------------------------------------------------------------

+ 14 - 2
src/main/java/me/km/effects/PlayerUsesEffectEvent.java

@@ -7,18 +7,20 @@ public class PlayerUsesEffectEvent
     private final EntityPlayer p;
     private int power;
     private int mana;
+    private int cooldown;
     private final EffectCause cause;
     private boolean cancel;
     private final String effect;
 
-    public PlayerUsesEffectEvent(EntityPlayer p, int power, int mana, EffectCause cause, Class<? extends ActiveEffectBase> effect) 
+    public PlayerUsesEffectEvent(EntityPlayer p, int power, int mana, int cooldown, EffectCause cause, String effect) 
     {
         this.p = p;
         this.power = power;
         this.mana = mana;
+        this.cooldown = cooldown;
         this.cause = cause;
         this.cancel = false;
-        this.effect = effect.getSimpleName();
+        this.effect = effect;
     }
     
     public EntityPlayer getPlayer()
@@ -46,6 +48,16 @@ public class PlayerUsesEffectEvent
         this.mana = mana;
     }
     
+    public int getCooldown()
+    {
+        return cooldown;
+    }
+    
+    public void setCooldown(int cooldown)
+    {
+        this.cooldown = cooldown;
+    }
+    
     public EffectCause getCause()
     {
         return cause;

+ 0 - 6
src/main/java/me/km/effects/active/ArcaneShot.java

@@ -17,10 +17,4 @@ public class ArcaneShot extends ActiveEffectBase
         KajetansMod.effects.addEntityData(p, "arcaneshot");
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 5 * manaFactor;
-    }
 }

+ 0 - 7
src/main/java/me/km/effects/active/AreaDamage.java

@@ -6,7 +6,6 @@ import me.km.effects.EffectUtils;
 import net.minecraft.entity.player.EntityPlayerMP;
 import net.minecraft.util.DamageSource;
 import net.minecraft.util.EnumParticleTypes;
-import net.minecraft.util.math.Vec3d;
 import net.minecraft.world.WorldServer;
 
 public class AreaDamage extends ActiveEffectBase
@@ -44,10 +43,4 @@ public class AreaDamage extends ActiveEffectBase
             });
         }
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 1;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/ArmorPasser.java

@@ -16,10 +16,4 @@ public class ArmorPasser extends ActiveEffectBase
         }
         return false;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 5 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/BlindingShot.java

@@ -16,10 +16,4 @@ public class BlindingShot extends ActiveEffectBase
         arrow.pickupStatus = EntityTippedArrow.PickupStatus.DISALLOWED;
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 2 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/BlockExplosion.java

@@ -50,10 +50,4 @@ public class BlockExplosion extends ActiveEffectBase
         
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 1;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/BoneBreaker.java

@@ -25,10 +25,4 @@ public class BoneBreaker extends ActiveEffectBase
         EffectUtils.addPotionTo(liv, MobEffects.NAUSEA, power * 20, 2);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 4 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/BunnyHop.java

@@ -13,10 +13,4 @@ public class BunnyHop extends ActiveEffectBase
         EffectUtils.addPotionTo(p, MobEffects.JUMP_BOOST, 300, power * 2);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 7 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/CallBack.java

@@ -24,10 +24,4 @@ public class CallBack extends ActiveEffectBase
         data.addGoodTimedData("callback", l, 100 * power, "R: §r" + ((int) p.posX) + "§7:§r" + ((int) p.posY) + "§7:§r" + ((int) p.posZ), 51);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 1;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/ClusterBomb.java

@@ -17,10 +17,4 @@ public class ClusterBomb extends ActiveEffectBase
         KajetansMod.effects.addEntityData(p, "clusterbomb", power);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 5 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/ConstantPower.java

@@ -16,10 +16,4 @@ public class ConstantPower extends ActiveEffectBase
         }
         return false;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 3 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Cripple.java

@@ -21,10 +21,4 @@ public class Cripple extends ActiveEffectBase
         liv.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, power * 20, 1));
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 1;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Day.java

@@ -11,10 +11,4 @@ public class Day extends ActiveEffectBase
         p.world.setWorldTime(0);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 20;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Doomed.java

@@ -26,10 +26,4 @@ public class Doomed extends ActiveEffectBase
         }, duration);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 1;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Earthquake.java

@@ -27,10 +27,4 @@ public class Earthquake extends ActiveEffectBase
         });
         return true;
     } 
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 8 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Elevation.java

@@ -27,10 +27,4 @@ public class Elevation extends ActiveEffectBase
         });
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 5 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/ElvishHorn.java

@@ -26,10 +26,4 @@ public class ElvishHorn extends ActiveEffectBase
         });
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 5 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Enderchest.java

@@ -11,10 +11,4 @@ public class Enderchest extends ActiveEffectBase
         p.displayGUIChest(p.getInventoryEnderChest());
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 10;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Explosion.java

@@ -16,10 +16,4 @@ public class Explosion extends ActiveEffectBase
         w.createExplosion(null, target.getX(), target.getY(), target.getZ(), power / 4f, true);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 12 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/FallImmunity.java

@@ -16,10 +16,4 @@ public class FallImmunity extends ActiveEffectBase
         }
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 1;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Fire.java

@@ -16,10 +16,4 @@ public class Fire extends ActiveEffectBase
         });
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 4 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/FireProtectionRain.java

@@ -24,10 +24,4 @@ public class FireProtectionRain extends ActiveEffectBase
         });
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 1;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/FireShot.java

@@ -15,10 +15,4 @@ public class FireShot extends ActiveEffectBase
         arrow.pickupStatus = EntityArrow.PickupStatus.DISALLOWED;
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 2 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Fireball.java

@@ -14,10 +14,4 @@ public class Fireball extends ActiveEffectBase
         fireball.explosionPower = power / 2;
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 8 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Flying.java

@@ -18,10 +18,4 @@ public class Flying extends ActiveEffectBase
         Utils.setVelocity(p, v.x, v.y, v.z);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Freeze.java

@@ -18,10 +18,4 @@ public class Freeze extends ActiveEffectBase
         });
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 6 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/GrapplingHook.java

@@ -16,10 +16,4 @@ public class GrapplingHook extends ActiveEffectBase
         }
         return false;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 1;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Gravity.java

@@ -28,10 +28,4 @@ public class Gravity extends ActiveEffectBase
         data.addGoodTimedData("gravity", cancel, power, "Schwerelos", 59);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 1;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Harm.java

@@ -14,10 +14,4 @@ public class Harm extends ActiveEffectBase
         EffectUtils.getEntsOfNotGuild(p, 5).forEach(ent -> ent.attackEntityFrom(ds, power));
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 10 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Harvest.java

@@ -37,10 +37,4 @@ public class Harvest extends ActiveEffectBase
         KajetansMod.effects.send(p, "Die Pflanzen in deiner Umgebung wurden geerntet!");
         return true;
     }
-    
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 5 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Heal.java

@@ -11,10 +11,4 @@ public class Heal extends ActiveEffectBase
         p.heal(power);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 3 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/HealRain.java

@@ -12,10 +12,4 @@ public class HealRain extends ActiveEffectBase
         EffectUtils.getPlayersOfGuild(p, 5).forEach(pl -> pl.heal(power));
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 10 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/HeartSeeker.java

@@ -24,10 +24,4 @@ public class HeartSeeker extends ActiveEffectBase
         liv.attackEntityFrom(DamageSource.causeMobDamage(p), damage);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 4 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Hearts.java

@@ -13,10 +13,4 @@ public class Hearts extends ActiveEffectBase
         EffectUtils.addPotionTo(p, MobEffects.HEALTH_BOOST, 6000, power - 1);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 10 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/HungerPunch.java

@@ -28,10 +28,4 @@ public class HungerPunch extends ActiveEffectBase
         }
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 4 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Immortality.java

@@ -13,10 +13,4 @@ public class Immortality extends ActiveEffectBase
         EffectUtils.addPotionTo(p, MobEffects.RESISTANCE, power * 100, 4);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 10 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/ImpactPunch.java

@@ -17,10 +17,4 @@ public class ImpactPunch extends ActiveEffectBase
         }
         return false;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 1;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Invisibility.java

@@ -13,10 +13,4 @@ public class Invisibility extends ActiveEffectBase
         EffectUtils.addPotionTo(p, MobEffects.INVISIBILITY, 200 + 200 * power, 0);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 5 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Jump.java

@@ -22,10 +22,4 @@ public class Jump extends ActiveEffectBase
         Utils.setVelocity(p, goal.x, goal.y, goal.z);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 2 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/JumpAttack.java

@@ -26,10 +26,4 @@ public class JumpAttack extends ActiveEffectBase
         }, 20);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 1;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Kick.java

@@ -23,10 +23,4 @@ public class Kick extends ActiveEffectBase
         liv.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, 120, 10));
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 4 * manaFactor;
-    }
 }

+ 0 - 12
src/main/java/me/km/effects/active/LeafCocoon.java

@@ -11,12 +11,6 @@ import net.minecraft.world.WorldServer;
 
 public class LeafCocoon extends ActiveEffectBase
 {
-    @Override
-    public int getCoolDown() 
-    {
-        return 100;
-    }
-    
     @Override
     protected boolean executeEffect(EntityPlayerMP p, int power) 
     {
@@ -83,10 +77,4 @@ public class LeafCocoon extends ActiveEffectBase
         list.run(160);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 15 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/LifeBreaker.java

@@ -30,10 +30,4 @@ public class LifeBreaker extends ActiveEffectBase
         EffectUtils.addPotionTo(liv, MobEffects.WEAKNESS, power * 20, 1);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 4 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/LifeSteal.java

@@ -28,10 +28,4 @@ public class LifeSteal extends ActiveEffectBase
         }
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 1;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/LockPick.java

@@ -12,10 +12,4 @@ public class LockPick extends ActiveEffectBase
         p.sendMessage(new TextComponentString("LockPick"));
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 1;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Lucky.java

@@ -13,10 +13,4 @@ public class Lucky extends ActiveEffectBase
         p.addPotionEffect(new PotionEffect(MobEffects.LUCK, 200 + 200 * power, 9));
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 3 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Musket.java

@@ -24,10 +24,4 @@ public class Musket extends ActiveEffectBase
         p.world.spawnEntity(launch);
         return true;
     }
-    
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 5 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/NailDown.java

@@ -23,10 +23,4 @@ public class NailDown extends ActiveEffectBase
         EffectUtils.playSound(p, SoundEvents.BLOCK_ANVIL_PLACE);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 4 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/NailTrap.java

@@ -17,10 +17,4 @@ public class NailTrap extends ActiveEffectBase
         KajetansMod.skills.send(p, "Du hast 9 Trittnagelfallen platziert.");
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 1;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/NetTrap.java

@@ -17,10 +17,4 @@ public class NetTrap extends ActiveEffectBase
         KajetansMod.skills.send(p, "Du hast eine Netzfalle platziert.");
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 10 + manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Night.java

@@ -11,10 +11,4 @@ public class Night extends ActiveEffectBase
         p.world.setWorldTime(14000);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 20;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Poison.java

@@ -13,10 +13,4 @@ public class Poison extends ActiveEffectBase
         EffectUtils.getEntsOfNotGuild(p, 5).forEach(ent -> EffectUtils.addPotionTo(ent, MobEffects.POISON, power * 20, 1));
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 6 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/PoisonVolley.java

@@ -20,12 +20,6 @@ public class PoisonVolley extends ActiveEffectBase
         return true;
     }
 
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 4 * manaFactor;
-    }
-    
     private void shoot(EntityPlayerMP p, int power)
     {
         EntityTippedArrow arrow = EffectUtils.launchTippedArrow(p, power / 2d, MobEffects.POISON, power * 60, 1);

+ 0 - 6
src/main/java/me/km/effects/active/PoisonedBlade.java

@@ -16,10 +16,4 @@ public class PoisonedBlade extends ActiveEffectBase
         }
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 1;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Power.java

@@ -13,10 +13,4 @@ public class Power extends ActiveEffectBase
         EffectUtils.addPotionTo(p, MobEffects.STRENGTH, 1800, power - 1);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 3 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/PowerAttack.java

@@ -17,10 +17,4 @@ public class PowerAttack extends ActiveEffectBase
         }
         return false;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 1;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Pull.java

@@ -19,10 +19,4 @@ public class Pull extends ActiveEffectBase
         });
         return true;
     }
-    
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 3 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Push.java

@@ -19,10 +19,4 @@ public class Push extends ActiveEffectBase
         });
         return true;
     }
-    
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 3 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/PushUp.java

@@ -18,10 +18,4 @@ public class PushUp extends ActiveEffectBase
         });
         return true;
     }
-    
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 3 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/QuickShot.java

@@ -14,10 +14,4 @@ public class QuickShot extends ActiveEffectBase
         arrow.pickupStatus = EntityArrow.PickupStatus.DISALLOWED;
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 4 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Rain.java

@@ -14,10 +14,4 @@ public class Rain extends ActiveEffectBase
         worldinfo.setRainTime(10000);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 15;
-    }
 }

+ 1 - 7
src/main/java/me/km/effects/active/RapidFire.java

@@ -18,13 +18,7 @@ public class RapidFire extends ActiveEffectBase
         }
         return true;
     }
-    
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 5 * manaFactor;
-    }
-    
+
     private void shoot(EntityPlayerMP p, int power)
     {
         EntityArrow arrow = EffectUtils.launchProjectile(p, EntityArrow.class, power / 4f, p);

+ 0 - 6
src/main/java/me/km/effects/active/Rooting.java

@@ -18,10 +18,4 @@ public class Rooting extends ActiveEffectBase
         arrow.pickupStatus = EntityTippedArrow.PickupStatus.DISALLOWED;
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 2 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Shadow.java

@@ -18,10 +18,4 @@ public class Shadow extends ActiveEffectBase
         }, duration);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 1;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/ShadowHit.java

@@ -16,10 +16,4 @@ public class ShadowHit extends ActiveEffectBase
         }
         return false;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 1;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/ShadowStep.java

@@ -27,10 +27,4 @@ public class ShadowStep extends ActiveEffectBase
         Utils.teleportEntity(p, liv);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 4 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Silence.java

@@ -18,10 +18,4 @@ public class Silence extends ActiveEffectBase
         KajetansMod.playerbank.getData(affectedPlayer).addBadTimedData("silence", 0, 60 * power, "Silence", 50);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 4 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/SlowingShot.java

@@ -16,10 +16,4 @@ public class SlowingShot extends ActiveEffectBase
         arrow.pickupStatus = EntityTippedArrow.PickupStatus.DISALLOWED;
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 2 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Smash.java

@@ -22,10 +22,4 @@ public class Smash extends ActiveEffectBase
         liv.attackEntityFrom(ds, power);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 1;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/SmokeBomb.java

@@ -15,10 +15,4 @@ public class SmokeBomb extends ActiveEffectBase
         KajetansMod.effects.addEntityData(ball, "smokebomb");
         return false;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 1;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Sprint.java

@@ -13,10 +13,4 @@ public class Sprint extends ActiveEffectBase
         EffectUtils.addPotionTo(p, MobEffects.SLOWNESS, 600 * power, 1);
         return true;
     }
-    
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 3 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Stone.java

@@ -24,10 +24,4 @@ public class Stone extends ActiveEffectBase
         p.world.spawnEntity(launch);
         return true;
     }
-    
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 3 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Sun.java

@@ -11,10 +11,4 @@ public class Sun extends ActiveEffectBase
         p.world.getWorldInfo().setRaining(false);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 15;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/TeleportBlock.java

@@ -33,10 +33,4 @@ public class TeleportBlock extends ActiveEffectBase
         KajetansMod.skills.send(p, "Es wurde kein freier Platz gefunden.");
         return false;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 1;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/TeleportPlayer.java

@@ -22,10 +22,4 @@ public class TeleportPlayer extends ActiveEffectBase
         inv.openForPlayer(p);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 20;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Thor.java

@@ -17,10 +17,4 @@ public class Thor extends ActiveEffectBase
         w.addWeatherEffect(new EntityLightningBolt(w, pos.getX(), pos.getY(), pos.getZ(), false));
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 20 + manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Unlucky.java

@@ -13,10 +13,4 @@ public class Unlucky extends ActiveEffectBase
         p.addPotionEffect(new PotionEffect(MobEffects.UNLUCK, 200 + 200 * power, 9));
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 3 * manaFactor;
-    }
 }

+ 0 - 7
src/main/java/me/km/effects/active/VineTrap.java

@@ -1,7 +1,6 @@
 package me.km.effects.active;
 
 import me.km.KajetansMod;
-import me.km.api.Location;
 import me.km.api.Utils;
 import me.km.effects.EffectBlockChanger;
 import me.km.effects.ActiveEffectBase;
@@ -40,10 +39,4 @@ public class VineTrap extends ActiveEffectBase
         }, 160);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 5 * manaFactor;
-    }
 }

+ 0 - 6
src/main/java/me/km/effects/active/Workbench.java

@@ -13,10 +13,4 @@ public class Workbench extends ActiveEffectBase
         KajetansMod.scheduler.scheduleTask(() -> p.displayGui(new BlockWorkbench.InterfaceCraftingTable(p.world, p.getPosition())), 0);
         return true;
     }
-
-    @Override
-    protected int getManaCost(int manaFactor) 
-    {
-        return 10;
-    }
 }

+ 47 - 20
src/main/java/me/km/items/ItemGun.java

@@ -1,6 +1,8 @@
 package me.km.items;
 
+import java.util.List;
 import me.km.api.Utils;
+import net.minecraft.client.util.ITooltipFlag;
 import net.minecraft.entity.EntityLivingBase;
 import net.minecraft.entity.player.EntityPlayer;
 import net.minecraft.item.Item;
@@ -13,8 +15,11 @@ import net.minecraft.util.EnumActionResult;
 import net.minecraft.util.EnumHand;
 import net.minecraft.util.SoundCategory;
 import net.minecraft.util.SoundEvent;
+import net.minecraft.util.text.TextFormatting;
 import net.minecraft.world.World;
 import net.minecraftforge.common.capabilities.ICapabilityProvider;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
 
 public class ItemGun extends ItemWeapon
 {
@@ -75,32 +80,50 @@ public class ItemGun extends ItemWeapon
         return null;
     }  
     
-    private static NBTTagCompound getTagCompound(ItemStack stack)
+    private NBTTagCompound getTagCompound(ItemStack stack)
     {
         NBTTagCompound com = stack.getTagCompound();
         if(com == null)
         {
             com = new NBTTagCompound();
             com.setInteger("load", 0);
+            stack.setTagCompound(com);
         }
         else if(!com.hasKey("load"))
         {
             com.setInteger("load", 0);         
         }
-        stack.setTagCompound(com);
         return com;
     }
     
-    public static int getLoad(ItemStack stack)
+    private int getLoad(ItemStack stack)
     {
         return getTagCompound(stack).getInteger("load");
     }
     
-    public static void setLoad(ItemStack stack, int load)
+    private void setLoad(ItemStack stack, int load)
     {
         getTagCompound(stack).setInteger("load", load);
     }
     
+    @SideOnly(Side.CLIENT)
+    @Override
+    public void addInformation(ItemStack stack, World w, List<String> lore, ITooltipFlag flag) 
+    {
+        int load = getLoad(stack);
+        if(load >= 0)
+        {
+            if(load == 1)
+            {
+                lore.add(1, TextFormatting.GOLD + "1 shot loaded");
+            }
+            else
+            {
+                lore.add(1, TextFormatting.GOLD + "" + load + " shots loaded");
+            }
+        }
+    }
+    
     @Override
     public void onPlayerStoppedUsing(ItemStack stack, World w, EntityLivingBase liv, int timeLeft)
     {
@@ -187,28 +210,32 @@ public class ItemGun extends ItemWeapon
         {
             setLoad(p.getHeldItem(hand), maxLoad);
             playSound(p, w, soundReload);
-            return new ActionResult(EnumActionResult.FAIL, p.getHeldItem(hand));
+            return new ActionResult(EnumActionResult.SUCCESS, p.getHeldItem(hand));
         }
-        ItemStack stack = p.getHeldItem(hand);    
-        int load = getLoad(stack);
-        if(load <= 0)
+        if(p.isSneaking())
         {
-            ItemStack ammoStack = findAmmo(p);
-            if(!ammoStack.isEmpty())
+            ItemStack stack = p.getHeldItem(hand);    
+            int load = getLoad(stack);
+            if(load <= 0)
             {
-                int newLoad = Math.min(ammoStack.getCount(), maxLoad);
-                setLoad(stack, newLoad);
-                p.getCooldownTracker().setCooldown(this, cooldown * newLoad);
-                ammoStack.shrink(newLoad);
-                if(ammoStack.isEmpty())
+                ItemStack ammoStack = findAmmo(p);
+                if(!ammoStack.isEmpty())
                 {
-                    p.inventory.deleteStack(ammoStack);
+                    int newLoad = Math.min(ammoStack.getCount(), maxLoad);
+                    setLoad(stack, newLoad);
+                    p.getCooldownTracker().setCooldown(this, cooldown * newLoad);
+                    ammoStack.shrink(newLoad);
+                    if(ammoStack.isEmpty())
+                    {
+                        p.inventory.deleteStack(ammoStack);
+                    }
+                    playSound(p, w, soundReload);
                 }
-                playSound(p, w, soundReload);
+                return new ActionResult(EnumActionResult.FAIL, stack);
             }
-            return new ActionResult(EnumActionResult.FAIL, stack);
+            p.setActiveHand(hand);
+            return new ActionResult<>(EnumActionResult.SUCCESS, p.getHeldItem(hand));
         }
-        p.setActiveHand(hand);
-        return new ActionResult<>(EnumActionResult.SUCCESS, p.getHeldItem(hand));
+        return new ActionResult<>(EnumActionResult.FAIL, p.getHeldItem(hand));
     }
 }

+ 24 - 5
src/main/java/me/km/items/ItemKey.java

@@ -1,10 +1,15 @@
 package me.km.items;
 
-import me.km.capabilities.ChestKeyProvider;
+import java.util.List;
+import net.minecraft.client.util.ITooltipFlag;
 import net.minecraft.item.Item;
 import net.minecraft.item.ItemStack;
 import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.text.TextFormatting;
+import net.minecraft.world.World;
 import net.minecraftforge.common.capabilities.ICapabilityProvider;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
 
 public class ItemKey extends ItemBase
 {
@@ -53,23 +58,37 @@ public class ItemKey extends ItemBase
         return com;
     }
     
-    public static String getKey(ItemStack stack)
+    private String getKey(ItemStack stack)
     {
         return getTagCompound(stack).getString("chestkey");
     }
     
-    public static void setKey(ItemStack stack, String key)
+    private void setKey(ItemStack stack, String key)
     {
         getTagCompound(stack).setString("chestkey", key);
     } 
     
-    public static boolean isCopy(ItemStack stack)
+   private boolean isCopy(ItemStack stack)
     {
         return getTagCompound(stack).getBoolean("iscopiedkey");
     }
     
-    public static void setCopy(ItemStack stack, boolean copy)
+    private void setCopy(ItemStack stack, boolean copy)
     {
         getTagCompound(stack).setBoolean("iscopiedkey", copy);
     } 
+    
+    @SideOnly(Side.CLIENT)
+    @Override
+    public void addInformation(ItemStack stack, World w, List<String> lore, ITooltipFlag flag) 
+    {
+        if(getKey(stack).isEmpty())
+        {
+            lore.set(0, TextFormatting.RED + lore.get(0));
+        }
+        else
+        {
+            lore.set(0, TextFormatting.GREEN + lore.get(0));
+        }
+    }
 }

+ 81 - 27
src/main/java/me/km/items/ItemScroll.java

@@ -1,19 +1,26 @@
 package me.km.items;
 
+import java.util.List;
 import me.km.KajetansMod;
 import me.km.api.GlobalText;
 import me.km.api.Utils;
 import me.km.effects.ActiveEffectBase;
+import me.km.effects.Effect;
 import me.km.effects.EffectCause;
 import me.km.effects.EffectUtils;
+import net.minecraft.client.util.ITooltipFlag;
 import net.minecraft.entity.player.EntityPlayer;
 import net.minecraft.entity.player.EntityPlayerMP;
 import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
 import net.minecraft.stats.StatList;
 import net.minecraft.util.ActionResult;
 import net.minecraft.util.EnumActionResult;
 import net.minecraft.util.EnumHand;
 import net.minecraft.world.World;
+import net.minecraftforge.common.capabilities.ICapabilityProvider;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
 
 public class ItemScroll extends ItemBase
 {
@@ -37,38 +44,85 @@ public class ItemScroll extends ItemBase
         }
         
         ItemStack stack = p.getHeldItem(hand);
-        String s = stack.getDisplayName();
-        if(s.contains(" "))
+        NBTTagCompound com = getTagCompound(stack);
+        int id = com.getInteger("effect_id");
+        if(id == -1)
         {
-            try
+            KajetansMod.scrolls.send(p, "Die Schriftrolle hat keinen Effekt.");
+            return new ActionResult(EnumActionResult.FAIL, stack);
+        }
+        Effect eff = Effect.getEffect(id);
+        if(eff == null)
+        {
+            KajetansMod.scrolls.send(p, "Die Schriftrolle ist korrupt.");
+            return new ActionResult(EnumActionResult.FAIL, stack);
+        }
+        if(eff.getEffectInstance().run((EntityPlayerMP) p, com.getInteger("effect_level"), 0, 20, EffectCause.WAND))
+        {
+            if(!p.isCreative())
             {
-                String[] parts = s.split(" ");
-                if(parts.length < 2)
-                {
-                    throw new Exception();
-                }
-                Class<? extends ActiveEffectBase> c = EffectUtils.getEffectClass(parts[0].substring(2));
-                if(c == null)
-                { 
-                    throw new Exception();
-                }
-                int power = Utils.romanToInt(parts[1]);
-                if(ActiveEffectBase.executeEffect(c, (EntityPlayerMP) p, power, 0, EffectCause.SCROLL))
-                {
-                    if(!p.isCreative())
-                    {
-                        stack.shrink(1);
-                    }
-                }
+                stack.shrink(1);
             }
-            catch(Exception ex)
+            p.addStat(StatList.getObjectUseStats(this));
+            return new ActionResult(EnumActionResult.SUCCESS, stack);
+        }
+        return new ActionResult(EnumActionResult.FAIL, stack);
+    }
+
+    @SideOnly(Side.CLIENT)
+    @Override
+    public void addInformation(ItemStack stack, World w, List<String> lore, ITooltipFlag flag) 
+    {
+        NBTTagCompound com = getTagCompound(stack);
+        String s = com.getString("effect_name");
+        if(!s.isEmpty())
+        {
+            lore.set(0, s + " " + Utils.intToRoman(com.getInteger("effect_id")));
+        }
+    }
+    
+    @Override
+    public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) 
+    {
+        getTagCompound(stack);
+        return null;
+    }  
+    
+    private NBTTagCompound getTagCompound(ItemStack stack)
+    {
+        NBTTagCompound com = stack.getTagCompound();
+        if(com == null)
+        {
+            com = new NBTTagCompound();
+            com.setInteger("effect_id", -1);
+            com.setInteger("effect_level", 1);
+            com.setString("effect_name", "");
+            stack.setTagCompound(com);
+        }
+        else 
+        {
+            if(!com.hasKey("effect_id"))
+            {
+                com.setInteger("effect_id", -1);     
+            }
+            if(!com.hasKey("effect_level"))
+            {
+                com.setInteger("effect_level", 1);     
+            }
+            if(!com.hasKey("effect_name"))
             {
-                KajetansMod.scrolls.send(p, "Die Schriftrolle ist korrupt.");
-                return new ActionResult(EnumActionResult.FAIL, stack);
+                com.setString("effect_name", "");     
             }
         }
-
-        p.addStat(StatList.getObjectUseStats(this));
-        return new ActionResult(EnumActionResult.SUCCESS, stack);
+        return com;
+    }
+    
+    public void setEffect(ItemStack stack, int id, int level, String name)
+    {
+        NBTTagCompound com = getTagCompound(stack);
+        com.setInteger("effect_id", id);
+        level = Math.max(1, Math.min(20, level));
+        com.setInteger("effect_level", level);
+        com.setString("effect_name", name);  
     }
 }

+ 76 - 18
src/main/java/me/km/items/ItemWand.java

@@ -1,28 +1,36 @@
 package me.km.items;
 
+import java.util.List;
 import me.km.KajetansMod;
 import me.km.api.GlobalText;
-import me.km.effects.ActiveEffectBase;
+import me.km.api.Utils;
 import me.km.effects.Effect;
 import me.km.effects.EffectCause;
 import me.km.effects.EffectUtils;
+import net.minecraft.client.util.ITooltipFlag;
 import net.minecraft.entity.player.EntityPlayer;
 import net.minecraft.entity.player.EntityPlayerMP;
 import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
 import net.minecraft.stats.StatList;
 import net.minecraft.util.ActionResult;
 import net.minecraft.util.EnumActionResult;
 import net.minecraft.util.EnumHand;
 import net.minecraft.world.World;
+import net.minecraftforge.common.capabilities.ICapabilityProvider;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
 
 public class ItemWand extends ItemWeapon
 {
     private final int strength;
+    private final String roman;
     
     public ItemWand(String name, String local, ToolMaterial material, int strength) 
     {
         super(name, local, material, 0, -3);
         this.strength = strength;
+        this.roman = " " + Utils.intToRoman(strength);
     }
     
     @Override
@@ -47,28 +55,78 @@ public class ItemWand extends ItemWeapon
         }
         
         ItemStack stack = p.getHeldItem(hand);
-        try
+        NBTTagCompound com = getTagCompound(stack);
+        int id = com.getInteger("effect_id");
+        if(id == -1)
         {
-            Class<? extends ActiveEffectBase> c = EffectUtils.getEffectClass(stack.getDisplayName().substring(2));
-            if(c == null)
-            { 
-                throw new Exception();
-            }
-            if(ActiveEffectBase.executeEffect(c, (EntityPlayerMP) p, strength, 0, EffectCause.WAND))
+            KajetansMod.scrolls.send(p, "Der Zauberstab hat keinen Effekt.");
+            return new ActionResult(EnumActionResult.FAIL, stack);
+        }
+        Effect eff = Effect.getEffect(id);
+        if(eff == null)
+        {
+            KajetansMod.scrolls.send(p, "Der Zauberstab ist korrupt.");
+            return new ActionResult(EnumActionResult.FAIL, stack);
+        }
+        if(eff.getEffectInstance().run((EntityPlayerMP) p, strength, 0, 20, EffectCause.WAND))
+        {
+            if(!p.isCreative())
             {
-                if(!p.isCreative())
-                {
-                    stack.damageItem(1, p);
-                }
+                stack.damageItem(1, p);
             }
+            p.addStat(StatList.getObjectUseStats(this));
+            return new ActionResult(EnumActionResult.SUCCESS, stack);
         }
-        catch(Exception ex)
+        return new ActionResult(EnumActionResult.FAIL, stack);
+    }
+    
+    @SideOnly(Side.CLIENT)
+    @Override
+    public void addInformation(ItemStack stack, World w, List<String> lore, ITooltipFlag flag) 
+    {
+        NBTTagCompound com = getTagCompound(stack);
+        String s = com.getString("effect_name");
+        if(!s.isEmpty())
         {
-            KajetansMod.effects.send(p, "Der Zauberstab ist korrupt.");
-            return new ActionResult(EnumActionResult.FAIL, stack);
+            lore.set(0, s + roman);
         }
-
-        p.addStat(StatList.getObjectUseStats(this));
-        return new ActionResult(EnumActionResult.SUCCESS, stack);
+    }
+    
+    @Override
+    public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) 
+    {
+        getTagCompound(stack);
+        return null;
+    }  
+    
+    private NBTTagCompound getTagCompound(ItemStack stack)
+    {
+        NBTTagCompound com = stack.getTagCompound();
+        if(com == null)
+        {
+            com = new NBTTagCompound();
+            com.setInteger("effect_id", -1);
+            com.setString("effect_name", "");
+            stack.setTagCompound(com);
+        }
+        else 
+        {
+            if(!com.hasKey("effect_id"))
+            {
+                com.setInteger("effect_id", -1);     
+            }
+            if(!com.hasKey("effect_name"))
+            {
+                com.setString("effect_name", "");     
+            }
+        }
+        return com;
+    }
+    
+    public void setEffect(ItemStack stack, int id, String name)
+    {
+        NBTTagCompound com = getTagCompound(stack);
+        com.setInteger("effect_id", id);
+        com.setString("effect_name", name);  
     }
 }

+ 1 - 1
src/main/java/me/km/jobsystem/JobAPI.java

@@ -117,7 +117,7 @@ public class JobAPI extends Module
                 return 0;
             }
             return j.getSkillLevel(skill, getLevel(p, b));
-        }).sum();
+        }).max().orElse(0);
     }
     
     public HashMap<Skill, Byte> getSkillMap(EntityPlayer p)

+ 50 - 0
src/main/java/me/km/networking/FunctionKey.java

@@ -0,0 +1,50 @@
+package me.km.networking;
+
+import io.netty.buffer.ByteBuf;
+import me.km.KajetansMod;
+import me.km.snuviscript.ScriptEvents;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
+import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
+import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
+
+public class FunctionKey implements IMessage
+{
+    private byte key;
+    
+    public FunctionKey() 
+    {
+        key = -1;
+    }
+    
+    public FunctionKey(int key) 
+    {
+        this.key = (byte) key;
+    }
+    
+    @Override
+    public void fromBytes(ByteBuf buf) 
+    {
+        key = buf.readByte();
+    }
+
+    @Override
+    public void toBytes(ByteBuf buf) 
+    {
+        buf.writeByte(key);
+    }
+
+    public static class Handler implements IMessageHandler<FunctionKey, IMessage>
+    {
+        @Override
+        public IMessage onMessage(FunctionKey message, MessageContext ctx) 
+        {
+            EntityPlayerMP p = ctx.getServerHandler().player;
+            p.getServerWorld().addScheduledTask(() -> 
+            {
+                KajetansMod.scripts.getEvent(ScriptEvents.class).onFunctionKey(ctx.getServerHandler().player, message.key);
+            });
+            return null;
+        }
+    }
+}

+ 58 - 0
src/main/java/me/km/networking/KeyManager.java

@@ -0,0 +1,58 @@
+package me.km.networking;
+
+import net.minecraft.client.settings.KeyBinding;
+import net.minecraftforge.fml.client.registry.ClientRegistry;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import net.minecraftforge.fml.common.gameevent.TickEvent;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
+import org.lwjgl.input.Keyboard;
+
+@SideOnly(Side.CLIENT)
+public class KeyManager 
+{
+    private KeyBinding[] functionKeys;
+    
+    public KeyManager()
+    {
+        functionKeys = new KeyBinding[9];
+        functionKeys[0] = register(1, Keyboard.KEY_G);
+        functionKeys[1] = register(2, Keyboard.KEY_H);
+        functionKeys[2] = register(3, Keyboard.KEY_J);
+        functionKeys[3] = register(4, Keyboard.KEY_K);
+        functionKeys[4] = register(5, Keyboard.KEY_V);
+        functionKeys[5] = register(6, Keyboard.KEY_B);
+        functionKeys[6] = register(7, Keyboard.KEY_N);
+        functionKeys[7] = register(8, Keyboard.KEY_M);
+        functionKeys[8] = register(9, Keyboard.KEY_COMMA);
+    }
+    
+    private KeyBinding register(int id, int key)
+    {
+        KeyBinding keyBind =  new KeyBinding("key.function." + id, key, "key.km.function");
+        ClientRegistry.registerKeyBinding(keyBind);
+        return keyBind;
+    }
+    
+    private int getFirstPressedKey()
+    {
+        for(int i = 0; i < 9; i++)
+        {
+            if(functionKeys[i].isPressed())
+            {
+                return i + 1;
+            }
+        }
+        return -1;
+    }
+    
+    @SubscribeEvent
+    public void onRenderGui(TickEvent.ClientTickEvent e)
+    {
+        int key = getFirstPressedKey();
+        if(key != -1)
+        {
+            ModPacketHandler.sendFunctionKey(key);
+        }
+    }
+}

+ 6 - 0
src/main/java/me/km/networking/ModPacketHandler.java

@@ -15,10 +15,16 @@ public class ModPacketHandler
     public static void init()
     {
         INSTANCE.registerMessage(PlayerDisplay.Handler.class, PlayerDisplay.class, id++, Side.CLIENT);
+        INSTANCE.registerMessage(FunctionKey.Handler.class, FunctionKey.class, id++, Side.SERVER);
     }
     
     public static void sendStats(EntityPlayerMP p, int action, int index, String text)
     {
         INSTANCE.sendTo(new PlayerDisplay(action, index, text), p);
     }
+    
+    public static void sendFunctionKey(int key)
+    {
+        INSTANCE.sendToServer(new FunctionKey(key));
+    }
 }

+ 20 - 15
src/main/java/me/km/scrolls/CommandScroll.java

@@ -5,23 +5,24 @@ import java.util.stream.Collectors;
 import me.km.api.GlobalText;
 import me.km.api.Module;
 import me.km.api.ModuleTabCommand;
-import me.km.api.Utils;
-import me.km.effects.ActiveEffectBase;
 import me.km.effects.Effect;
-import me.km.effects.EffectUtils;
 import me.km.items.ModItems;
 import me.km.permissions.Permissions;
-import me.km.utils.ItemStackBuilder;
+import net.minecraft.block.Block;
 import net.minecraft.command.ICommandSender;
 import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
 
 public class CommandScroll extends ModuleTabCommand
 {
     public CommandScroll(Module m) 
     {
-        super("magicscroll", m, Arrays.stream(Effect.values()).map(n -> n.getEffectString()).filter(o -> o != null).collect(Collectors.toList()), 0);
-        super.setDescription("Erstellt Schriftrollen");
-        super.setUsage("/magicscroll <name> [level] [amount]");
+        super("magicscroll", m, Arrays.stream(Effect.values())
+                .filter(n -> n.isActive())
+                .map(n -> n.toString())
+                .collect(Collectors.toList()), 0);
+        super.setDescription("Erstellt Schriftrollen, Unterstriche bei <dname> werden zu Leerzeichen");
+        super.setUsage("/magicscroll <name> <dname> [level] [amount]");
         super.setPermission(Permissions.SCROLL);
         super.addAlias("msc");
     }
@@ -29,7 +30,7 @@ public class CommandScroll extends ModuleTabCommand
     @Override
     public boolean execute(ICommandSender cs, String[] arg) 
     {
-        if(arg.length < 1)
+        if(arg.length < 2)
         {
             return false;
         }
@@ -39,16 +40,16 @@ public class CommandScroll extends ModuleTabCommand
             return true;
         }
         EntityPlayer p = (EntityPlayer) cs;
-        Class<? extends ActiveEffectBase> c = EffectUtils.getEffectClass(arg[0]);
-        if(c == null)
+        Effect eff = Effect.valueOf(arg[0]);
+        if(eff == null || !eff.isActive())
         { 
             this.getModule().send(cs, "Dieser aktive Effekt existiert nicht.");
             return true;
         }
-        int level = 1;
+        int level;
         try
         {               
-            level = Integer.parseInt(arg[1]);
+            level = Integer.parseInt(arg[2]);
             if(level <= 0)
             {
                 this.getModule().send(cs, GlobalText.noPositiveNaturalNumber());
@@ -57,11 +58,12 @@ public class CommandScroll extends ModuleTabCommand
         }
         catch(NumberFormatException | ArrayIndexOutOfBoundsException ex)
         {
+            level = 1;
         }
-        int amount = 1;
+        int amount;
         try
         {               
-            amount = Integer.parseInt(arg[2]);
+            amount = Integer.parseInt(arg[3]);
             if(amount <= 0)
             {
                 this.getModule().send(cs, GlobalText.noPositiveNaturalNumber());
@@ -70,8 +72,11 @@ public class CommandScroll extends ModuleTabCommand
         }
         catch(NumberFormatException | ArrayIndexOutOfBoundsException ex)
         {
+            amount = 1;
         }     
-        new ItemStackBuilder(ModItems.scroll, amount).setName("§6" + arg[0] + " " + Utils.intToRoman(level)).drop(p.world, p.getPosition());
+        ItemStack stack = new ItemStack(ModItems.scroll, amount);
+        ModItems.scroll.setEffect(stack, eff.ordinal(), level, arg[1].replace('_', ' '));
+        Block.spawnAsEntity(p.world, p.getPosition(), stack);
         return true;
     }
 }

+ 1 - 2
src/main/java/me/km/skills/ActiveSkillContainer.java

@@ -3,7 +3,6 @@ package me.km.skills;
 import java.util.List;
 import java.util.Map;
 import me.km.KajetansMod;
-import me.km.effects.ActiveEffectBase;
 import me.km.effects.EffectCause;
 import net.minecraft.entity.player.EntityPlayerMP;
 import net.minecraft.item.ItemStack;
@@ -24,7 +23,7 @@ public class ActiveSkillContainer extends SkillContainer
     @Override
     public void onCastSkill(EntityPlayerMP p, Skill s, byte level) 
     {
-        if(ActiveEffectBase.executeEffect(s.getEffect().getEffectBase(), p, level, level, EffectCause.SKILL))
+        if(s.getEffect().getEffectInstance().run(p, level, s.getMana(level), s.getCooldown(level), EffectCause.SKILL))
         {
             KajetansMod.skills.sendToPlayers(p.world, p.posX, p.posY, p.posZ, 20, "§3" + p.getName() + "§r hat §3" + s.getName() + "§r benutzt.");
             this.closeSafe(p);

+ 25 - 5
src/main/java/me/km/skills/Skill.java

@@ -12,7 +12,13 @@ public class Skill
     private final Effect effect;
     private final String name;
     
-    public Skill(ItemStack stack, Effect eff, String name, String explanation)
+    private final int manaConstant;
+    private final int manaFactor;
+    private final int cooldownConstant;
+    private final int cooldownFactor;
+    
+    public Skill(ItemStack stack, Effect eff, String name, String explanation, 
+            int manaConstant, int manaFactor, int cooldownConstant, int cooldownFactor)
     {
         ItemStackUtils.addItemFlag(stack, ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_UNBREAKABLE);
         stack.setStackDisplayName("§6" + name);
@@ -20,17 +26,31 @@ public class Skill
         this.stack = stack;
         this.effect = eff;
         this.name = name;
+        this.manaConstant = manaConstant;
+        this.manaFactor = manaFactor;
+        this.cooldownConstant = cooldownConstant;
+        this.cooldownFactor = cooldownFactor;
     }
 
-    public ItemStack getItemStack(int amount)
+    public ItemStack getItemStack(int power)
     {
-        int mana = effect.getManaCost(amount);
-        stack.setCount(amount);
+        int mana = getMana(power);
+        stack.setCount(power);
         if(mana == 0)
         {
             return stack.copy();
         }
-        return new ItemStackBuilder(stack, amount).addToName(" §3(" + mana +")").build();
+        return new ItemStackBuilder(stack, power).addToName(" §3(" + mana +")").build();
+    }
+    
+    public int getMana(int power)
+    {
+        return manaConstant + power * manaFactor;
+    }
+    
+    public int getCooldown(int power)
+    {
+        return cooldownConstant + power * cooldownFactor;
     }
     
     public boolean isActive()

+ 9 - 4
src/main/java/me/km/skills/SkillManager.java

@@ -16,13 +16,18 @@ public class SkillManager extends Module
         skills = new HashMap<>();
     }
     
-    public void registerSkill(int id, ItemStack icon, Effect eff, String name, String explanation)
+    public void registerSkill(int id, ItemStack icon, Effect eff, String name, String explanation,
+            int manaConstant, int manaFactor, int cooldownConstant, int cooldownFactor)
     {
-        Skill skill = new Skill(icon.copy(), eff, name, explanation);
+        Skill skill = new Skill(icon.copy(), eff, name, explanation, manaConstant, manaFactor, cooldownConstant, cooldownFactor);
         if(skills.put(id, skill) == null)
         {
             eff.addSkill(skill);
         }
+        else
+        {
+            throw new NullPointerException("ID '" + id + "' is registered twice.");
+        }
     }
     
     public Skill getSkill(int id)
@@ -30,9 +35,9 @@ public class SkillManager extends Module
         Skill skill = skills.get(id);
         if(skill == null)
         {
-            throw new NullPointerException("ID " + id + " has no skill.");
+            throw new NullPointerException("ID '" + id + "' has no skill.");
         }
-        return skills.get(id);
+        return skill;
     }
     
     public void clearSkills()

+ 11 - 1
src/main/java/me/km/snuviscript/MinecraftFunctions.java

@@ -75,6 +75,7 @@ import me.hammerle.exceptions.IllegalStringException;
 import me.hammerle.code.SnuviParser;
 import me.hammerle.exceptions.HoldCodeException;
 import me.hammerle.math.Fraction;
+import me.km.effects.Effect;
 import me.km.inventory.CustomContainer;
 import me.km.networking.ModPacketHandler;
 import me.km.pathfinder.PathfinderUtils;
@@ -366,7 +367,7 @@ public class MinecraftFunctions implements ISnuviLogger
         // Skill-Bibliothek 
         // ------------------------------------------------------------- 
         parser.registerConsumer("skill.register", (args, qd) -> 
-                KajetansMod.skills.registerSkill(ScriptUtils.getInt(args[0]), (ItemStack) args[1], me.km.effects.Effect.valueOf(args[2].toString()), args[3].toString(), args[4].toString()));
+                registerSkill(args));              
         parser.registerConsumer("skill.clear", (args, qd) -> 
                 KajetansMod.skills.clearSkills());
         
@@ -763,6 +764,15 @@ public class MinecraftFunctions implements ISnuviLogger
         ((BlockDoor) l.getWorld().getBlockState(pos).getBlock()).toggleDoor(l.getWorld(), pos, (boolean) args[1]);
     }
     
+    private static void registerSkill(Object[] args)
+    {
+        KajetansMod.skills.registerSkill(ScriptUtils.getInt(args[0]), 
+                (ItemStack) args[1], Effect.valueOf(args[2].toString()), 
+                args[3].toString(), args[4].toString(), 
+                ScriptUtils.getInt(args[5]), ScriptUtils.getInt(args[6]), 
+                ScriptUtils.getInt(args[7]), ScriptUtils.getInt(args[8]));
+    }
+    
     private static void walkTo(Object[] args)
     {
         Location l = (Location) args[1];

+ 9 - 2
src/main/java/me/km/snuviscript/ScriptEvents.java

@@ -29,6 +29,7 @@ import net.minecraft.entity.Entity;
 import net.minecraft.entity.EntityLivingBase;
 import net.minecraft.entity.passive.EntitySheep;
 import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
 import net.minecraft.init.Items;
 import net.minecraft.inventory.ClickType;
 import net.minecraft.item.ItemStack;
@@ -262,7 +263,6 @@ public class ScriptEvents extends ModuleListener
         EntityPlayer p = (EntityPlayer) e.getEntity();    
         handleEvent(p, "player_death", (qd) -> 
         {
-            //qd.setEventVar("message", e.getDeathMessage());
             qd.setEventVar("clear", false);
             EntityPlayer ent = Utils.getDamager(e.getSource());
             if(ent != null)
@@ -272,7 +272,6 @@ public class ScriptEvents extends ModuleListener
             qd.setVar("cancel", e.isCanceled()); 
         }, (qd) -> 
         {
-            //e.setDeathMessage(String.valueOf(qd.getVar("message")));
             if(qd.getBooleanVar("clear"))
             {
                 p.inventory.clear();
@@ -769,6 +768,14 @@ public class ScriptEvents extends ModuleListener
         });
     }
     
+    public void onFunctionKey(EntityPlayerMP p, int key)
+    {        
+        handleEvent(p, "function_key", (qd) -> 
+        {
+            qd.setEventVar("key", new Fraction(key));
+        });      
+    }
+    
     /*@SubscribeEvent
     public void QuestVillagerPickUpItem(ItemTossEvent e)
     {             

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott