From d3a3cc278f3cd8b8018780115085de872bc846d7 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sun, 13 Apr 2014 04:24:22 -0700 Subject: [PATCH] Fixed ultra custom builds not saving. Fixed default builds. Fixed armor bug. --- .../game/classcombat/Class/ClassManager.java | 253 ++++++++++-------- .../game/classcombat/Class/ClientClass.java | 15 +- .../game/classcombat/Class/IPvpClass.java | 1 - .../game/classcombat/Class/PvpClass.java | 10 - .../game/classcombat/Skill/ISkill.java | 2 +- .../game/classcombat/Skill/Skill.java | 9 +- 6 files changed, 156 insertions(+), 134 deletions(-) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClassManager.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClassManager.java index ba46da64e..67b9c29fb 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClassManager.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClassManager.java @@ -7,7 +7,9 @@ import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Class.repository.ClassRepository; import mineplex.minecraft.game.classcombat.Class.repository.token.ClientClassTokenWrapper; import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken; +import mineplex.minecraft.game.classcombat.Skill.ISkill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; +import mineplex.minecraft.game.classcombat.Skill.ISkill.SkillType; import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.event.ClientWebResponseEvent; @@ -29,24 +31,25 @@ public class ClassManager extends MiniClientPlugin implements IClas private ClassRepository _repository; private HashMap _classes; private HashMap _classSalesPackageIdMap; - + private Object _clientLock = new Object(); - - public ClassManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, SkillFactory skillFactory, String webAddress) + + public ClassManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, + SkillFactory skillFactory, String webAddress) { super("Class Manager", plugin); - + _plugin = plugin; _clientManager = clientManager; _donationManager = donationManager; _skillFactory = skillFactory; - _repository = new ClassRepository(webAddress); - _classes = new HashMap(); - _classSalesPackageIdMap = new HashMap(); - - PopulateClasses(); + _repository = new ClassRepository(webAddress); + _classes = new HashMap(); + _classSalesPackageIdMap = new HashMap(); + + PopulateClasses(); } - + @EventHandler public void OnClientWebResponse(ClientWebResponseEvent event) { @@ -58,7 +61,9 @@ public class ClassManager extends MiniClientPlugin implements IClas { synchronized (_clientLock) { - Set(token.Name, new ClientClass(this, _skillFactory, _clientManager.Get(token.Name), _donationManager.Get(token.Name), token.DonorToken)); + Set(token.Name, + new ClientClass(this, _skillFactory, _clientManager.Get(token.Name), _donationManager + .Get(token.Name), token.DonorToken)); } } @@ -69,137 +74,173 @@ public class ClassManager extends MiniClientPlugin implements IClas return super.Get(name); } } - + private void PopulateClasses() { _classes.clear(); - + AddKnight(); AddRanger(); AddBrute(); AddMage(); AddAssassin(); - + /* - AddClass(new PvpClass(this, 6, ClassType.Shapeshifter, - new String[] { "Able to transform into various creatures." }, - Material.LEATHER_HELMET, Material.LEATHER_CHESTPLATE, Material.LEATHER_LEGGINGS, Material.LEATHER_BOOTS, - Color.fromRGB(20, 100, 0))); - */ + * AddClass(new PvpClass(this, 6, ClassType.Shapeshifter, new String[] { + * "Able to transform into various creatures." }, + * Material.LEATHER_HELMET, Material.LEATHER_CHESTPLATE, + * Material.LEATHER_LEGGINGS, Material.LEATHER_BOOTS, Color.fromRGB(20, + * 100, 0))); + */ + + for (IPvpClass pvpClass : GetAllClasses()) + { + CustomBuildToken customBuild = pvpClass.getDefaultBuild(); + ISkill swordSkill = _skillFactory.GetSkill(customBuild.SwordSkill); + ISkill axeSkill = _skillFactory.GetSkill(customBuild.AxeSkill); + ISkill bowSkill = _skillFactory.GetSkill(customBuild.BowSkill); + ISkill classPassiveASkill = _skillFactory.GetSkill(customBuild.ClassPassiveASkill); + ISkill classPassiveBSkill = _skillFactory.GetSkill(customBuild.ClassPassiveBSkill); + ISkill globalPassive = _skillFactory.GetSkill(customBuild.GlobalPassiveSkill); + + if (swordSkill != null) + swordSkill.setFree(true); + + if (axeSkill != null) + axeSkill.setFree(true); + + if (bowSkill != null) + bowSkill.setFree(true); + + if (classPassiveASkill != null) + classPassiveASkill.setFree(true); + + if (classPassiveBSkill != null) + classPassiveBSkill.setFree(true); + + if (globalPassive != null) + globalPassive.setFree(true); + } } private void AddAssassin() { CustomBuildToken customBuild = new CustomBuildToken(); customBuild.Name = "Default Build"; - - customBuild.SwordSkill = "Evade"; - customBuild.AxeSkill = "Blink"; - customBuild.BowSkill = "Marked for Death"; - customBuild.ClassPassiveASkill = "Stealth"; - customBuild.ClassPassiveBSkill = "Repeated Strikes"; - customBuild.GlobalPassiveSkill = "Break Fall"; - - AddClass(new PvpClass( - this, - 5, - ClassType.Assassin, - customBuild, - new String[] { "Extremely nimble and smart.", "Excels at ambushing and takedowns.", "", "Permanent Speed II" }, - Material.LEATHER_HELMET, Material.LEATHER_CHESTPLATE, Material.LEATHER_LEGGINGS, Material.LEATHER_BOOTS, - null)); + + customBuild.SwordSkill = "Evade"; + customBuild.SwordSkillLevel = 2; + customBuild.AxeSkill = "Leap"; + customBuild.AxeSkillLevel = 3; + customBuild.BowSkill = "Smoke Arrow"; + customBuild.BowSkillLevel = 2; + customBuild.ClassPassiveASkill = "Smoke Bomb"; + customBuild.ClassPassiveASkillLevel = 2; + customBuild.ClassPassiveBSkill = "Combo Attack"; + customBuild.ClassPassiveBSkillLevel = 2; + customBuild.GlobalPassiveSkill = "Break Fall"; + customBuild.GlobalPassiveSkillLevel = 1; + + AddClass(new PvpClass(this, 5, ClassType.Assassin, customBuild, new String[] { "Extremely nimble and smart.", + "Excels at ambushing and takedowns.", "", "Permanent Speed II" }, Material.LEATHER_HELMET, + Material.LEATHER_CHESTPLATE, Material.LEATHER_LEGGINGS, Material.LEATHER_BOOTS, null)); } private void AddMage() { CustomBuildToken customBuild = new CustomBuildToken(); customBuild.Name = "Default Build"; - - customBuild.SwordSkill = "Blizzard"; - customBuild.AxeSkill = "Freezing Blast"; - customBuild.BowSkill = ""; - customBuild.ClassPassiveASkill = "Arctic Armor"; - customBuild.ClassPassiveBSkill = "Glacial Blade"; - customBuild.GlobalPassiveSkill = "Fitness"; - - AddClass(new PvpClass(this, - 4, - ClassType.Mage, - customBuild, - new String[] { "Trained in the ancient arts.", "Able to adapt to many roles in combat."}, - Material.GOLD_HELMET, Material.GOLD_CHESTPLATE, Material.GOLD_LEGGINGS, Material.GOLD_BOOTS, - null)); + + customBuild.SwordSkill = "Blizzard"; + customBuild.SwordSkillLevel = 3; + customBuild.AxeSkill = "Ice Prison"; + customBuild.AxeSkillLevel = 3; + customBuild.BowSkill = ""; + customBuild.ClassPassiveASkill = "Arctic Armor"; + customBuild.ClassPassiveASkillLevel = 2; + customBuild.ClassPassiveBSkill = "Glacial Blade"; + customBuild.ClassPassiveBSkillLevel = 2; + customBuild.GlobalPassiveSkill = "Mana Pool"; + customBuild.GlobalPassiveSkillLevel = 2; + + AddClass(new PvpClass(this, 4, ClassType.Mage, customBuild, new String[] { "Trained in the ancient arts.", + "Able to adapt to many roles in combat." }, Material.GOLD_HELMET, Material.GOLD_CHESTPLATE, + Material.GOLD_LEGGINGS, Material.GOLD_BOOTS, null)); } private void AddBrute() { CustomBuildToken customBuild = new CustomBuildToken(); customBuild.Name = "Default Build"; - - customBuild.SwordSkill = "Dwarf Toss"; - customBuild.AxeSkill = "Seismic Slam"; - customBuild.BowSkill = ""; - customBuild.ClassPassiveASkill = "Stampede"; - customBuild.ClassPassiveBSkill = "Crippling Blow"; - customBuild.GlobalPassiveSkill = "Recharge"; - - AddClass(new PvpClass(this, - 3, - ClassType.Brute, - customBuild, - new String[] { "Uses pure strength to dominate.", "Great at crowd control."}, - Material.DIAMOND_HELMET, Material.DIAMOND_CHESTPLATE, Material.DIAMOND_LEGGINGS, Material.DIAMOND_BOOTS, - null)); + + customBuild.SwordSkill = "Block Toss"; + customBuild.SwordSkillLevel = 4; + customBuild.AxeSkill = "Seismic Slam"; + customBuild.AxeSkillLevel = 3; + customBuild.BowSkill = ""; + customBuild.BowSkillLevel = 0; + customBuild.ClassPassiveASkill = "Stampede"; + customBuild.ClassPassiveASkillLevel = 2; + customBuild.ClassPassiveBSkill = "Crippling Blow"; + customBuild.ClassPassiveBSkillLevel = 2; + customBuild.GlobalPassiveSkill = "Recharge"; + customBuild.GlobalPassiveSkillLevel = 1; + + AddClass(new PvpClass(this, 3, ClassType.Brute, customBuild, new String[] { "Uses pure strength to dominate.", + "Great at crowd control." }, Material.DIAMOND_HELMET, Material.DIAMOND_CHESTPLATE, + Material.DIAMOND_LEGGINGS, Material.DIAMOND_BOOTS, null)); } private void AddRanger() { CustomBuildToken customBuild = new CustomBuildToken(); customBuild.Name = "Default Build"; - - customBuild.SwordSkill = "Disengage"; - customBuild.AxeSkill = "Agility"; - customBuild.BowSkill = "Napalm Shot"; - customBuild.ClassPassiveASkill = "Barrage"; - customBuild.ClassPassiveBSkill = "Barbed Arrows"; - customBuild.GlobalPassiveSkill = "Quick Recovery"; - - AddClass(new PvpClass(this, - -1, - ClassType.Ranger, - customBuild, - new String[] { "Mastery with a Bow and Arrow.", "Adept in Wilderness Survival" }, - Material.CHAINMAIL_HELMET, Material.CHAINMAIL_CHESTPLATE, Material.CHAINMAIL_LEGGINGS, Material.CHAINMAIL_BOOTS, - null)); + + customBuild.SwordSkill = "Disengage"; + customBuild.SwordSkillLevel = 3; + customBuild.AxeSkill = "Agility"; + customBuild.AxeSkillLevel = 2; + customBuild.BowSkill = "Napalm Shot"; + customBuild.BowSkillLevel = 3; + customBuild.ClassPassiveASkill = "Barrage"; + customBuild.ClassPassiveASkillLevel = 2; + customBuild.ClassPassiveBSkill = "Barbed Arrows"; + customBuild.ClassPassiveBSkillLevel = 1; + customBuild.GlobalPassiveSkill = "Resistance"; + customBuild.GlobalPassiveSkillLevel = 1; + + AddClass(new PvpClass(this, -1, ClassType.Ranger, customBuild, new String[] { "Mastery with a Bow and Arrow.", + "Adept in Wilderness Survival" }, Material.CHAINMAIL_HELMET, Material.CHAINMAIL_CHESTPLATE, + Material.CHAINMAIL_LEGGINGS, Material.CHAINMAIL_BOOTS, null)); } private void AddKnight() { CustomBuildToken customBuild = new CustomBuildToken(); customBuild.Name = "Default Build"; - - customBuild.SwordSkill = "Hilt Smash"; - customBuild.AxeSkill = "Bulls Charge"; - customBuild.BowSkill = ""; - customBuild.ClassPassiveASkill = "Swordsmanship"; - customBuild.ClassPassiveBSkill = "Fortitude"; - customBuild.GlobalPassiveSkill = "Resistance"; - - AddClass(new PvpClass( - this, - -1, - ClassType.Knight, - customBuild, - new String[] { "Trained in the arts of melee combat.", "Able to stand his ground against foes."}, - Material.IRON_HELMET, Material.IRON_CHESTPLATE, Material.IRON_LEGGINGS, Material.IRON_BOOTS, - null)); + + customBuild.SwordSkill = "Hilt Smash"; + customBuild.SwordSkillLevel = 3; + customBuild.AxeSkill = "Bulls Charge"; + customBuild.AxeSkillLevel = 3; + customBuild.BowSkill = ""; + customBuild.ClassPassiveASkill = "Swordsmanship"; + customBuild.ClassPassiveASkillLevel = 2; + customBuild.ClassPassiveBSkill = "Vengeance"; + customBuild.ClassPassiveBSkillLevel = 2; + customBuild.GlobalPassiveSkill = "Resistance"; + customBuild.GlobalPassiveSkillLevel = 2; + + AddClass(new PvpClass(this, -1, ClassType.Knight, customBuild, new String[] { + "Trained in the arts of melee combat.", "Able to stand his ground against foes." }, + Material.IRON_HELMET, Material.IRON_CHESTPLATE, Material.IRON_LEGGINGS, Material.IRON_BOOTS, null)); } public IPvpClass GetClass(String className) { return _classes.get(className); } - + public IPvpClass GetClass(int id) { return _classSalesPackageIdMap.get(id); @@ -216,26 +257,26 @@ public class ClassManager extends MiniClientPlugin implements IClas } @Override - public Collection GetGameClasses() + public Collection GetGameClasses() { return _classes.values(); } - + @EventHandler public void update(UpdateEvent event) { if (event.getType() != UpdateType.FAST) - return; - + return; + for (IPvpClass cur : _classes.values()) cur.checkEquip(); } - public SkillFactory GetSkillFactory() + public SkillFactory GetSkillFactory() { return _skillFactory; } - + @Override protected ClientClass AddPlayer(String player) { @@ -246,21 +287,21 @@ public class ClassManager extends MiniClientPlugin implements IClas { return _repository; } - + @EventHandler public void SkillDisplay(PlayerCommandPreprocessEvent event) { if (event.getMessage().equals("/skill")) { ClientClass client = Get(event.getPlayer().getName()); - + if (client == null) event.getPlayer().sendMessage("You do not have a ClientClass."); else { client.DisplaySkills(event.getPlayer()); } - + event.setCancelled(true); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java index 6d2638bac..c5fea6631 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java @@ -27,7 +27,7 @@ import mineplex.minecraft.game.classcombat.Skill.SkillFactory; public class ClientClass { - public static int MAX_TOKENS = 60; + public static int MAX_TOKENS = 12; private ClassManager _classFactory; private SkillFactory _skillFactory; @@ -268,11 +268,7 @@ public class ClientClass _lastArmor[1] = ItemStackFactory.Instance.CreateStack(_lastClass.GetLeggings()); _lastArmor[0] = ItemStackFactory.Instance.CreateStack(_lastClass.GetBoots()); - for (ISkill skill : _lastClass.GetDefaultSkills().keySet()) - { - if (skill.GetSkillType() != SkillType.Class) - _lastSkillMap.put(skill.GetSkillType(), new AbstractMap.SimpleEntry(skill, _lastClass.GetDefaultSkills().get(skill))); - } + EquipCustomBuild(_customBuilds.get(_lastClass).get(0)); } SetGameClass(_lastClass); @@ -329,12 +325,6 @@ public class ClientClass ClearSkills(); - for (ISkill cur : _gameClass.GetDefaultSkills().keySet()) - { - if (cur.GetSkillType() == SkillType.Class) - AddSkill(cur, _gameClass.GetDefaultSkills().get(cur)); - } - for (Entry skill : _lastSkillMap.values()) { AddSkill(skill.getKey(), skill.getValue()); @@ -508,7 +498,6 @@ public class ClientClass if (ValidSkill(customBuild.GlobalPassiveSkill, globalPassive, SkillType.GlobalPassive)) SkillTokens -= globalPassive.GetTokenCost() * customBuild.GlobalPassiveSkillLevel; - } public void DisplaySkills(Player player) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/IPvpClass.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/IPvpClass.java index 72b3694fc..4786b3433 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/IPvpClass.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/IPvpClass.java @@ -30,7 +30,6 @@ public interface IPvpClass Material GetLeggings(); Material GetBoots(); HashSet GetSkills(); - HashMap GetDefaultSkills(); void checkEquip(); Integer GetCost(); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/PvpClass.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/PvpClass.java index 2d8b08a77..02018536f 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/PvpClass.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/PvpClass.java @@ -1,6 +1,5 @@ package mineplex.minecraft.game.classcombat.Class; -import java.util.HashMap; import java.util.HashSet; import mineplex.core.common.util.UtilGear; @@ -33,7 +32,6 @@ public class PvpClass implements IPvpClass private Color _leatherColor = null; private HashSet _skillSet; - private HashMap _skillDefault; private ClassManager _classes; @@ -58,8 +56,6 @@ public class PvpClass implements IPvpClass _skillSet.addAll(_classes.GetSkillFactory().GetSkillsFor(this)); _skillSet.addAll(_classes.GetSkillFactory().GetGlobalSkillsFor(this)); - _skillDefault = _classes.GetSkillFactory().GetDefaultSkillsFor(this); - _leatherColor = leatherColor; } @@ -105,12 +101,6 @@ public class PvpClass implements IPvpClass return _skillSet; } - @Override - public HashMap GetDefaultSkills() - { - return _skillDefault; - } - public void checkEquip() { for (Player cur : Bukkit.getOnlinePlayers()) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/ISkill.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/ISkill.java index e0ad949a1..0a7499f7a 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/ISkill.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/ISkill.java @@ -1,6 +1,5 @@ package mineplex.minecraft.game.classcombat.Skill; -import java.util.ArrayList; import java.util.Set; import org.bukkit.entity.Entity; @@ -28,6 +27,7 @@ public interface ISkill int GetGemCost(); int GetTokenCost(); boolean IsFree(); + void setFree(boolean free); String[] GetDesc(int level); void Reset(Player player); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Skill.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Skill.java index 37a28a931..012cfd646 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Skill.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Skill.java @@ -8,7 +8,6 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilDisplay; import mineplex.core.common.util.UtilGear; -import mineplex.core.recharge.Recharge; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Skill.repository.token.SkillToken; @@ -303,12 +302,16 @@ public abstract class Skill implements ISkill, Listener { return _free; } + + @Override + public void setFree(boolean free) + { + _free = free; + } public void Update(SkillToken skillToken) { _salesPackageId = skillToken.SalesPackage.GameSalesPackageId; - _free = skillToken.SalesPackage.Free; - _gemCost = skillToken.SalesPackage.Gems; } public void DisplayProgress(Player player, String ability, float amount)