Fixed saving custom builds.

Fixed items staying from previous class in game.
This commit is contained in:
Jonathan Williams 2014-03-18 23:40:54 -07:00
parent 9715f5454a
commit 24f1c6c722
9 changed files with 18 additions and 93 deletions

Binary file not shown.

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS" value="Dominate,CaptureThePig,PvP,"/>
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="Dominate,CaptureThePig,PvP,"/>
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="CaptureThePig,PvP,Dominate,"/>
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS" value="Dominate,"/>
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="Dominate,"/>
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="Dominate,"/>
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>

View File

@ -132,10 +132,6 @@ public class ClientClass
public void SaveActiveCustomBuild()
{
if (GetGameClass() == null)
return;
_savingCustomBuild.PvpClassId = GetGameClass().GetSalesPackageId();
_savingCustomBuild.PlayerName = _client.GetPlayerName();
ISkill swordSkill = GetSkillByType(SkillType.Sword);
@ -190,6 +186,8 @@ public class ClientClass
public void SetSavingCustomBuild(IPvpClass pvpClass, CustomBuildToken customBuild)
{
_savingCustomBuild = customBuild;
_savingCustomBuild.PvpClassId = pvpClass.GetSalesPackageId();
_customBuilds.get(pvpClass).put(_savingCustomBuild.CustomBuildNumber, _savingCustomBuild);
}

View File

@ -14,9 +14,6 @@ import mineplex.minecraft.game.classcombat.shop.page.CustomBuildPage;
public abstract class ClassCombatShop extends ShopBase<ClassShopManager>
{
private NautHashMap<String, ItemStack[]> _inventoryStorage = new NautHashMap<String, ItemStack[]>();
private NautHashMap<String, ItemStack[]> _armorStorage = new NautHashMap<String, ItemStack[]>();
public ClassCombatShop(ClassShopManager plugin, CoreClientManager clientManager, DonationManager donationManager, String name)
{
super(plugin, clientManager, donationManager, name, CurrencyType.Gems);
@ -51,9 +48,6 @@ public abstract class ClassCombatShop extends ShopBase<ClassShopManager>
@Override
protected void OpenShopForPlayer(Player player)
{
_inventoryStorage.put(player.getName(), player.getInventory().getContents());
_armorStorage.put(player.getName(), player.getInventory().getArmorContents());
player.getInventory().clear();
player.getInventory().setArmorContents(new ItemStack[4]);
@ -67,18 +61,7 @@ public abstract class ClassCombatShop extends ShopBase<ClassShopManager>
if (clientClass != null && clientClass.IsSavingCustomBuild())
{
clientClass.SaveActiveCustomBuild();
clientClass.SaveActiveCustomBuild();
}
if (player.isOnline())
{
player.getInventory().setContents(_inventoryStorage.get(player.getName()));
player.getInventory().setArmorContents(_armorStorage.get(player.getName()));
((CraftPlayer)player).getHandle().updateInventory(((CraftPlayer)player).getHandle().defaultContainer);
}
_inventoryStorage.remove(player.getName());
_armorStorage.remove(player.getName());
}
}

View File

@ -1,25 +0,0 @@
package mineplex.minecraft.game.classcombat.shop.button;
import org.bukkit.entity.Player;
import mineplex.core.shop.item.IButton;
import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken;
import mineplex.minecraft.game.classcombat.shop.page.CustomBuildPage;
public class EditAndDontSaveCustomBuildButton implements IButton
{
private CustomBuildPage _page;
private CustomBuildToken _customBuild;
public EditAndDontSaveCustomBuildButton(CustomBuildPage page, CustomBuildToken customBuild)
{
_page = page;
_customBuild = customBuild;
}
@Override
public void Clicked(Player player)
{
_page.EditAndDontSaveCustomBuild(_customBuild);
}
}

View File

@ -36,7 +36,7 @@ public class ArmorPage extends ShopPageBase<ClassShopManager, ClassCombatShop>
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1f, .6f);
if (_purchasing)
Shop.OpenPageForPlayer(Player, new SkillPage(Plugin, Shop, ClientManager, DonationManager, Player, pvpClass, true));
Shop.OpenPageForPlayer(Player, new SkillPage(Plugin, Shop, ClientManager, DonationManager, Player, pvpClass));
else
{
ClientClass clientClass = Plugin.GetClassManager().Get(player);

View File

@ -11,7 +11,6 @@ import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildTok
import mineplex.minecraft.game.classcombat.shop.ClassCombatShop;
import mineplex.minecraft.game.classcombat.shop.ClassShopManager;
import mineplex.minecraft.game.classcombat.shop.button.DeleteCustomBuildButton;
import mineplex.minecraft.game.classcombat.shop.button.EditAndDontSaveCustomBuildButton;
import mineplex.minecraft.game.classcombat.shop.button.EditAndSaveCustomBuildButton;
import mineplex.minecraft.game.classcombat.shop.button.SelectCustomBuildButton;
@ -138,23 +137,7 @@ public class CustomBuildPage extends ShopPageBase<ClassShopManager, ClassCombatS
clientClass.EquipCustomBuild(customBuild, false);
clientClass.SetSavingCustomBuild(_pvpClass, customBuild);
Shop.OpenPageForPlayer(Player, new SkillPage(Plugin, Shop, ClientManager, DonationManager, Player, _pvpClass, false));
}
public void EditAndDontSaveCustomBuild(CustomBuildToken customBuild)
{
ClientClass clientClass = Plugin.GetClassManager().Get(Player);
clientClass.SetActiveCustomBuild(_pvpClass, customBuild);
ClassSetupEvent event = new ClassSetupEvent(Player, SetupType.EditCustomBuild, _pvpClass.GetType(), customBuild.CustomBuildNumber + 1, customBuild);
Plugin.GetPlugin().getServer().getPluginManager().callEvent(event);
if (event.IsCancelled())
return;
clientClass.EquipCustomBuild(customBuild, false);
Shop.OpenPageForPlayer(Player, new SkillPage(Plugin, Shop, ClientManager, DonationManager, Player, _pvpClass, false));
Shop.OpenPageForPlayer(Player, new SkillPage(Plugin, Shop, ClientManager, DonationManager, Player, _pvpClass));
}
public void SelectCustomBuild(CustomBuildToken customBuild)
@ -170,9 +153,6 @@ public class CustomBuildPage extends ShopPageBase<ClassShopManager, ClassCombatS
clientClass.EquipCustomBuild(customBuild);
if (saveActiveCustomBuild)
clientClass.SetSavingCustomBuild(_pvpClass, customBuild);
Player.closeInventory();
}

View File

@ -28,14 +28,12 @@ import org.bukkit.entity.Player;
public class SkillPage extends ShopPageBase<ClassShopManager, ClassCombatShop>
{
private IPvpClass _pvpClass;
private boolean _purchasing;
public SkillPage(ClassShopManager plugin, ClassCombatShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, IPvpClass pvpClass, boolean purchasing)
public SkillPage(ClassShopManager plugin, ClassCombatShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, IPvpClass pvpClass)
{
super(plugin, shop, clientManager, donationManager, " Select Skills", player);
_pvpClass = pvpClass;
_purchasing = purchasing;
BuildPage();
}
@ -129,7 +127,9 @@ public class SkillPage extends ShopPageBase<ClassShopManager, ClassCombatShop>
{
List<String> skillLore = new ArrayList<String>();
if (_purchasing)
boolean locked = isSkillLocked(skill.GetSalesPackageId(), skill);
if (locked)
{
skillLore.add(C.cYellow + skill.GetCost() + " Gems");
skillLore.add(C.cBlack);
@ -142,23 +142,12 @@ public class SkillPage extends ShopPageBase<ClassShopManager, ClassCombatShop>
skillLore.set(i, C.cGray + skillLore.get(i));
}
boolean locked = isSkillLocked(skill.GetSalesPackageId(), skill);
ShopItem skillItem = new ShopItem(locked ? Material.BOOK_AND_QUILL : ((skill.GetUsers().contains(Player) || _purchasing) ? Material.WRITTEN_BOOK : Material.BOOK), (locked ? ChatColor.RED + skill.GetName() + " (Locked)" : skill.GetName()), skillLore.toArray(new String[skillLore.size()]), 1, locked, true);
if (_purchasing)
{
if (locked)
AddButton(slotNumber, skillItem, new PurchaseSkillButton(this, skill));
else
AddItem(slotNumber, skillItem);
}
else
{
if (locked)
AddItem(slotNumber, skillItem);
else
AddButton(slotNumber, skillItem, new SelectSkillButton(this, skill));
}
ShopItem skillItem = new ShopItem(locked ? Material.BOOK_AND_QUILL : (skill.GetUsers().contains(Player) ? Material.WRITTEN_BOOK : Material.BOOK), (locked ? ChatColor.RED + skill.GetName() + " (Locked)" : skill.GetName()), skillLore.toArray(new String[skillLore.size()]), 1, locked, true);
if (locked)
AddButton(slotNumber, skillItem, new PurchaseSkillButton(this, skill));
else
AddButton(slotNumber, skillItem, new SelectSkillButton(this, skill));
}
/*

Binary file not shown.