Item Custom Build Fixes.

This commit is contained in:
Jonathan Williams 2014-04-19 22:54:52 -07:00
parent 458f5741d7
commit dc625726c4
11 changed files with 224 additions and 52 deletions

View File

@ -7,6 +7,7 @@ import java.util.Map.Entry;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -275,7 +276,7 @@ public class ClientClass
if (_gameClass.GetType() == ClassType.Assassin || _gameClass.GetType() == ClassType.Ranger)
{
PutDefaultItem(ItemStackFactory.Instance.CreateStack(Material.BOW), 2);
PutDefaultItem(ItemStackFactory.Instance.CreateStack(Material.ARROW, _gameClass.GetType() == ClassType.Assassin ? 16 : 32), 3);
PutDefaultItem(ItemStackFactory.Instance.CreateStack(Material.ARROW, _gameClass.GetType() == ClassType.Assassin ? 12 : 24), 3);
}
else
{
@ -297,7 +298,13 @@ public class ClientClass
continue;
customItems = true;
_lastItems.put(customBuild.Slots.indexOf(token), ItemStackFactory.Instance.CreateStack(Enum.valueOf(Material.class, token.Material), (byte)0, token.Amount, token.Name));
ItemStack itemStack = ItemStackFactory.Instance.CreateStack(Enum.valueOf(Material.class, token.Material), (byte)0, token.Amount, token.Name);
if (token.Name.contains("Booster"))
itemStack.addUnsafeEnchantment(Enchantment.DURABILITY, 5);
_lastItems.put(customBuild.Slots.indexOf(token), itemStack);
}
if (!customItems)

View File

@ -46,6 +46,14 @@ public class CustomBuildToken
public int SkillTokens = MAX_SKILL_TOKENS;
public int ItemTokens = MAX_ITEM_TOKENS;
public CustomBuildToken()
{
for (int i = 0; i < 9; i++)
{
Slots.add(new SlotToken());
}
}
public void printInfo()
{
System.out.println("CustomBuildId : " + CustomBuildId);
@ -214,27 +222,8 @@ public class CustomBuildToken
return false;
}
public int addItem(Item item)
{
for (SlotToken token : Slots)
{
if (token == null || token.Material == null || token.Material.isEmpty())
{
token.Material = item.GetType().name();
token.Amount = item.GetAmount();
token.Name = item.GetName();
ItemTokens -= item.getTokenCost();
return Slots.indexOf(token);
}
}
return -1;
}
public int removeItem(Item item)
public boolean hasItemType(Material material)
{
for (SlotToken token : Slots)
{
@ -245,10 +234,81 @@ public class CustomBuildToken
if (token.Material == null)
continue;
if (token.Material.equalsIgnoreCase(material.name()))
return true;
}
return false;
}
public boolean hasItemWithNameLike(String name)
{
for (SlotToken token : Slots)
{
// Stupid json crap giving me null values.
if (token == null)
continue;
token.printInfo();
if (token.Name == null)
continue;
if (token.Material.equalsIgnoreCase(item.GetName()) && token.Amount == item.GetAmount())
if (token.Name.contains(name))
{
return true;
}
}
return false;
}
public int getItemIndexWithNameLike(String name)
{
for (SlotToken token : Slots)
{
// Stupid json crap giving me null values.
if (token == null)
continue;
if (token.Name == null)
continue;
if (token.Name.contains(name))
return Slots.indexOf(token);
}
return -1;
}
public void addItem(Item item, int index)
{
SlotToken token = Slots.get(index);
token.Material = item.GetType().name();
token.Amount = item.GetAmount();
token.Name = item.GetName();
ItemTokens -= item.getTokenCost();
}
public int removeItem(Item item)
{
for (SlotToken token : Slots)
{
// Stupid json crap giving me null values.
if (token == null)
continue;
token.printInfo();
if (token.Material == null)
continue;
if (token.Name == null)
continue;
if (token.Material.equalsIgnoreCase(item.GetType().name()) && token.Name.equalsIgnoreCase(item.GetName()) && token.Amount == item.GetAmount())
{
token.Material = "";
token.Amount = 0;

View File

@ -104,9 +104,9 @@ public class ItemFactory extends MiniPlugin implements IItemFactory
AddItem(new BoosterAxe(this, 0, 2));
AddItem(new BoosterBow(this, 0, 2));
AddItem(new GoldenSword(this, 0, 2));
AddItem(new GoldenAxe(this, 0, 2));
AddItem(new GoldenBow(this, 0, 2));
AddItem(new PowerSword(this, 0, 2));
AddItem(new PowerAxe(this, 0, 2));
AddItem(new PowerBow(this, 0, 2));
}
private void AddPassive()
@ -155,8 +155,8 @@ public class ItemFactory extends MiniPlugin implements IItemFactory
private void AddOther()
{
AddItem(new Item(this, "Assassin Arrows", new String[] { "Arrows for your bow." }, Material.ARROW, 16, true, 0, 1));
AddItem(new Item(this, "Ranger Arrows", new String[] { "Arrows for your bow." }, Material.ARROW, 32, true, 0, 1));
AddItem(new Item(this, "Assassin Arrows", new String[] { "Arrows for your bow." }, Material.ARROW, 12, true, 0, 1));
AddItem(new Item(this, "Ranger Arrows", new String[] { "Arrows for your bow." }, Material.ARROW, 24, true, 0, 1));
}
public IItem GetItem(String weaponName)

View File

@ -30,6 +30,7 @@ import mineplex.minecraft.game.classcombat.shop.salespackage.SkillSalesPackage;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -135,8 +136,14 @@ public class SkillPage extends ShopPageBase<ClassShopManager, ClassCombatShop>
if (itemStack != null && itemStack.getType() == item.GetType() && itemStack.getAmount() == item.GetAmount())
{
System.out.println("Put button at index " + (81 + i) + " for " + item.GetType() + " " + item.GetAmount() + " count");
ButtonMap.put(81 + i, new DeselectItemButton(this, item, i));
if (clientClass.GetSavingCustomBuild().hasItem(item.GetType(), item.GetName()))
{
ButtonMap.put(81 + i, new DeselectItemButton(this, item));
}
else
{
ButtonMap.put(81 + i, new DeselectItemButton(this, item, i));
}
}
}
}
@ -413,14 +420,65 @@ public class SkillPage extends ShopPageBase<ClassShopManager, ClassCombatShop>
public void SelectItem(Player player, Item item)
{
int index = -1;
ClientClass clientClass = Plugin.GetClassManager().Get(player);
int index = clientClass.GetSavingCustomBuild().addItem(item);
if (item.GetName().contains("Sword") || item.GetName().contains("Axe") || item.GetName().contains("Bow"))
{
if (clientClass.GetSavingCustomBuild().hasItem(item.GetType(), item.GetName()))
{
PlayDenySound(player);
System.out.println("Denying because of matching material and name.");
return;
}
if (item.GetName().contains("Sword"))
{
System.out.println("Sword");
if (player.getInventory().getItem(0) != null && player.getInventory().getItem(0).getType() == Material.IRON_SWORD)
DeselectItem(player, null, 0, false);
else if (clientClass.GetSavingCustomBuild().hasItemWithNameLike("Sword"))
index = clientClass.GetSavingCustomBuild().getItemIndexWithNameLike("Sword");
}
else if (item.GetName().contains("Axe"))
{
System.out.println("Axe");
if (player.getInventory().getItem(1) != null && player.getInventory().getItem(1).getType() == Material.IRON_AXE)
DeselectItem(player, null, 1, false);
else if (clientClass.GetSavingCustomBuild().hasItemWithNameLike("Axe"))
index = clientClass.GetSavingCustomBuild().getItemIndexWithNameLike("Axe");
}
else if (item.GetName().contains("Bow"))
{
System.out.println("Bow");
if (player.getInventory().getItem(2) != null && player.getInventory().getItem(2).getType() == Material.BOW)
DeselectItem(player, null, 2, false);
else if (clientClass.GetSavingCustomBuild().hasItemWithNameLike("Bow"))
index = clientClass.GetSavingCustomBuild().getItemIndexWithNameLike("Bow");
}
if (index != -1)
{
System.out.println("Triggering ClickedRight on slot " + (81 + index));
ButtonMap.get(81 + index).ClickedRight(player);
}
}
if (index == -1 && player.getInventory().firstEmpty() < 9)
index = player.getInventory().firstEmpty();
if (index != -1)
{
PlayAcceptSound(player);
player.getInventory().setItem(index, ItemStackFactory.Instance.CreateStack(item.GetType(), (byte)0, item.GetAmount(), item.GetName()));
clientClass.GetSavingCustomBuild().addItem(item, index);
ItemStack itemStack = ItemStackFactory.Instance.CreateStack(item.GetType(), (byte)0, item.GetAmount(), item.GetName());
if (item.GetName().contains("Booster"))
itemStack.addUnsafeEnchantment(Enchantment.DURABILITY, 5);
player.getInventory().setItem(index, itemStack);
}
else
{
@ -440,7 +498,7 @@ public class SkillPage extends ShopPageBase<ClassShopManager, ClassCombatShop>
if (index != -1 || override)
{
PlayAcceptSound(player);
player.getInventory().setItem(index, null);
if (override)

View File

@ -100,6 +100,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
private SkillFactory _skillFactory;
private ClassShopManager _classShopManager;
private ClassCombatShop _classShop;
private MiscManager _miscManager;
//Server Games
private GameServerConfig _serverConfig;
@ -180,7 +182,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
new GamePlayerManager(this);
_gameStatsManager = new GameStatsManager(this);
_gameWorldManager = new GameWorldManager(this);
new MiscManager(this);
_miscManager = new MiscManager(this);
new IdleManager(this);
//Game Addons

View File

@ -1,5 +1,8 @@
package nautilus.game.arcade.managers;
import java.util.ArrayList;
import java.util.List;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
@ -8,18 +11,22 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
public class MiscManager implements Listener
{
ArcadeManager Manager;
private List<String> _dontGiveClockList = new ArrayList<String>();
private ArcadeManager Manager;
public MiscManager(ArcadeManager manager)
{
@ -69,6 +76,24 @@ public class MiscManager implements Listener
}
}
@EventHandler
public void addClockPrevent(InventoryOpenEvent event)
{
if (event.getPlayer() instanceof Player)
{
_dontGiveClockList.add(event.getPlayer().getName());
}
}
@EventHandler
public void removeClockPrevent(InventoryCloseEvent event)
{
if (event.getPlayer() instanceof Player)
{
_dontGiveClockList.remove(event.getPlayer().getName());
}
}
@EventHandler
public void HubClockUpdate(UpdateEvent event)
{
@ -85,7 +110,7 @@ public class MiscManager implements Listener
{
if (!Manager.GetGame().IsAlive(player))
{
if (!player.getInventory().contains(Material.WATCH))
if (!_dontGiveClockList.contains(player.getName()) && !player.getInventory().contains(Material.WATCH))
{
Manager.HubClock(player);
}

View File

@ -36,30 +36,39 @@
public int ItemTokens { get; set; }
public string Slot1Name { get; set; }
public string Slot1Material { get; set; }
public int Slot1Amount { get; set; }
public string Slot2Name { get; set; }
public string Slot2Material { get; set; }
public int Slot2Amount { get; set; }
public string Slot3Name { get; set; }
public string Slot3Material { get; set; }
public int Slot3Amount { get; set; }
public string Slot4Name { get; set; }
public string Slot4Material { get; set; }
public int Slot4Amount { get; set; }
public string Slot5Name { get; set; }
public string Slot5Material { get; set; }
public int Slot5Amount { get; set; }
public string Slot6Name { get; set; }
public string Slot6Material { get; set; }
public int Slot6Amount { get; set; }
public string Slot7Name { get; set; }
public string Slot7Material { get; set; }
public int Slot7Amount { get; set; }
public string Slot8Name { get; set; }
public string Slot8Material { get; set; }
public int Slot8Amount { get; set; }
public string Slot9Name { get; set; }
public string Slot9Material { get; set; }
public int Slot9Amount { get; set; }
}

View File

@ -38,15 +38,15 @@
Slots = new List<SlotToken>();
Slots.Add(new SlotToken { Material = customBuild.Slot1Material, Amount = customBuild.Slot1Amount});
Slots.Add(new SlotToken { Material = customBuild.Slot2Material, Amount = customBuild.Slot2Amount });
Slots.Add(new SlotToken { Material = customBuild.Slot3Material, Amount = customBuild.Slot3Amount });
Slots.Add(new SlotToken { Material = customBuild.Slot4Material, Amount = customBuild.Slot4Amount });
Slots.Add(new SlotToken { Material = customBuild.Slot5Material, Amount = customBuild.Slot5Amount });
Slots.Add(new SlotToken { Material = customBuild.Slot6Material, Amount = customBuild.Slot6Amount });
Slots.Add(new SlotToken { Material = customBuild.Slot7Material, Amount = customBuild.Slot7Amount });
Slots.Add(new SlotToken { Material = customBuild.Slot8Material, Amount = customBuild.Slot8Amount });
Slots.Add(new SlotToken { Material = customBuild.Slot9Material, Amount = customBuild.Slot9Amount });
Slots.Add(new SlotToken { Material = customBuild.Slot1Material, Name = customBuild.Slot1Name, Amount = customBuild.Slot1Amount });
Slots.Add(new SlotToken { Material = customBuild.Slot2Material, Name = customBuild.Slot2Name, Amount = customBuild.Slot2Amount });
Slots.Add(new SlotToken { Material = customBuild.Slot3Material, Name = customBuild.Slot3Name, Amount = customBuild.Slot3Amount });
Slots.Add(new SlotToken { Material = customBuild.Slot4Material, Name = customBuild.Slot4Name, Amount = customBuild.Slot4Amount });
Slots.Add(new SlotToken { Material = customBuild.Slot5Material, Name = customBuild.Slot5Name, Amount = customBuild.Slot5Amount });
Slots.Add(new SlotToken { Material = customBuild.Slot6Material, Name = customBuild.Slot6Name, Amount = customBuild.Slot6Amount });
Slots.Add(new SlotToken { Material = customBuild.Slot7Material, Name = customBuild.Slot7Name, Amount = customBuild.Slot7Amount });
Slots.Add(new SlotToken { Material = customBuild.Slot8Material, Name = customBuild.Slot8Name, Amount = customBuild.Slot8Amount });
Slots.Add(new SlotToken { Material = customBuild.Slot9Material, Name = customBuild.Slot9Name, Amount = customBuild.Slot9Amount });
}
public int CustomBuildId { get; set; }
@ -123,30 +123,40 @@
if (Slots != null && Slots.Count > 0)
{
var slots = Slots.ToArray();
customBuild.Slot1Material = slots[0].Material;
customBuild.Slot1Name = slots[0].Name;
customBuild.Slot1Material = slots[0].Material;
customBuild.Slot1Amount = slots[0].Amount;
customBuild.Slot2Name = slots[1].Name;
customBuild.Slot2Material = slots[1].Material;
customBuild.Slot2Amount = slots[1].Amount;
customBuild.Slot3Name = slots[2].Name;
customBuild.Slot3Material = slots[2].Material;
customBuild.Slot3Amount = slots[2].Amount;
customBuild.Slot4Name = slots[3].Name;
customBuild.Slot4Material = slots[3].Material;
customBuild.Slot4Amount = slots[3].Amount;
customBuild.Slot5Name = slots[4].Name;
customBuild.Slot5Material = slots[4].Material;
customBuild.Slot5Amount = slots[4].Amount;
customBuild.Slot6Name = slots[5].Name;
customBuild.Slot6Material = slots[5].Material;
customBuild.Slot6Amount = slots[5].Amount;
customBuild.Slot7Name = slots[6].Name;
customBuild.Slot7Material = slots[6].Material;
customBuild.Slot7Amount = slots[6].Amount;
customBuild.Slot8Name = slots[7].Name;
customBuild.Slot8Material = slots[7].Material;
customBuild.Slot8Amount = slots[7].Amount;
customBuild.Slot9Name = slots[8].Name;
customBuild.Slot9Material = slots[8].Material;
customBuild.Slot9Amount = slots[8].Amount;
}

View File

@ -2,6 +2,7 @@
{
public class SlotToken
{
public string Name { get; set; }
public string Material { get; set; }
public int Amount { get; set; }
}

View File

@ -623,8 +623,8 @@
<file relUrl="Content/themes/techno/images/templatemo_image_02.png" publishTime="11/02/2013 13:30:01" />
<file relUrl="Content/Images/Wiki/Ranger.png" publishTime="11/02/2013 13:30:01" />
<file relUrl="Scripts/jquery-1.8.2.js" publishTime="11/02/2013 13:30:01" />
<file relUrl="bin/LOC.Website.Common.pdb" publishTime="04/18/2014 21:31:52" />
<file relUrl="bin/LOC.Core.pdb" publishTime="04/18/2014 21:31:52" />
<file relUrl="bin/LOC.Website.Common.pdb" publishTime="04/19/2014 22:01:45" />
<file relUrl="bin/LOC.Core.pdb" publishTime="04/19/2014 22:01:45" />
<file relUrl="Content/Images/Wiki/red_dye.jpg" publishTime="11/02/2013 13:30:01" />
<file relUrl="Scripts/MicrosoftMvcValidation.js" publishTime="11/02/2013 13:30:01" />
<file relUrl="Views/_ViewStart.cshtml" publishTime="11/02/2013 13:30:01" />
@ -696,9 +696,9 @@
<file relUrl="Views/Store/_WritePackage.cshtml" publishTime="11/02/2013 13:30:01" />
<file relUrl="Content/css/bootstrap-responsive.min.css" publishTime="11/02/2013 13:30:01" />
<file relUrl="Views/Servers/Index.cshtml" publishTime="11/02/2013 13:30:01" />
<file relUrl="bin/LOC.Website.Web.dll" publishTime="04/18/2014 21:31:53" />
<file relUrl="bin/LOC.Website.Web.dll" publishTime="04/19/2014 22:01:46" />
<file relUrl="Views/Shared/_FrontLayout.cshtml" publishTime="11/02/2013 13:30:01" />
<file relUrl="bin/LOC.Website.Web.pdb" publishTime="04/18/2014 21:31:53" />
<file relUrl="bin/LOC.Website.Web.pdb" publishTime="04/19/2014 22:01:46" />
<file relUrl="Content/themes/base/images/ui-bg_glass_65_ffffff_1x400.png" publishTime="11/02/2013 13:30:01" />
<file relUrl="Views/Profile/Index.cshtml" publishTime="11/02/2013 13:30:01" />
<file relUrl="bin/WebMatrix.WebData.xml" publishTime="11/02/2013 13:30:01" />
@ -746,10 +746,10 @@
<file relUrl="Content/themes/techno/images/templatemo_home_header.jpg" publishTime="11/02/2013 13:30:01" />
<file relUrl="Content/themes/techno/images/blog/03.jpg" publishTime="11/02/2013 13:30:01" />
<file relUrl="Content/themes/techno/images/slider/ss.png" publishTime="11/02/2013 13:30:01" />
<file relUrl="bin/LOC.Website.Common.dll" publishTime="04/18/2014 21:31:52" />
<file relUrl="bin/LOC.Website.Common.dll" publishTime="04/19/2014 22:01:45" />
<file relUrl="Content/themes/techno/images/prevlabel.gif" publishTime="11/02/2013 13:30:01" />
<file relUrl="Content/themes/techno/images/templatemo_subpage_bg.jpg" publishTime="11/02/2013 13:30:01" />
<file relUrl="bin/LOC.Core.dll" publishTime="04/18/2014 21:31:52" />
<file relUrl="bin/LOC.Core.dll" publishTime="04/19/2014 22:01:45" />
<file relUrl="Content/themes/techno/images/facebook.png" publishTime="11/02/2013 13:30:01" />
<file relUrl="Content/themes/base/images/ui-icons_888888_256x240.png" publishTime="11/02/2013 13:30:01" />
<file relUrl="Content/themes/techno/css/templatemo_style.css" publishTime="11/02/2013 13:30:01" />

Binary file not shown.