Fancy icons for 1.8!

This commit is contained in:
Shaun Bennett 2014-12-17 19:15:31 -06:00
parent a63c48e338
commit 2677d2e557
3 changed files with 30 additions and 3 deletions

View File

@ -3,6 +3,7 @@ package mineplex.core.shop.page;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftInventoryCustom;
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
@ -17,6 +18,7 @@ import mineplex.core.common.util.UtilInv;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType extends ShopBase<PluginType>> extends CraftInventoryCustom implements Listener
{
@ -85,6 +87,21 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
setItem(slot, item);
}
}
protected void AddItemFakeCount(int slot, ItemStack item, int fakeCount)
{
net.minecraft.server.v1_7_R4.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
nmsStack.count = fakeCount;
if (slot > inventory.getSize() - 1)
{
((CraftPlayer) Player).getHandle().inventory.setItem(getPlayerSlot(slot), nmsStack);
}
else
{
getInventory().setItem(slot, nmsStack);
}
}
protected int getPlayerSlot(int slot)
{
@ -98,6 +115,13 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
ButtonMap.put(slot, button);
}
protected void AddButtonFakeCount(int slot, ItemStack item, IButton button, int fakeItemCount)
{
AddItemFakeCount(slot, item, fakeItemCount);
ButtonMap.put(slot, button);
}
protected void addGlow(int slot)
{
UtilInv.addDullEnchantment(getItem(slot));

View File

@ -5,6 +5,7 @@ import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.shop.item.IButton;
@ -40,7 +41,9 @@ public class EditRotationPage extends BasePage
String titleString = ChatColor.RESET + (enabled ? C.cGreen : C.cRed) + ChatColor.BOLD + type.GetLobbyName();
String infoString = ChatColor.RESET + C.cGray + (enabled ? "Click to Disable" : "Click to Enable");
ShopItem shopItem = new ShopItem(type.GetMaterial(), type.GetMaterialData(), titleString, new String[]{infoString}, 1, false, false);
AddButton(slot, shopItem, new IButton()
int itemCount = enabled ? 1 : 0;
AddButtonFakeCount(slot, shopItem, new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
@ -51,7 +54,7 @@ public class EditRotationPage extends BasePage
Plugin.GetServerConfig().GameList.add(type);
Refresh();
}
});
}, itemCount);
if (enabled)
addGlow(slot);

View File

@ -42,7 +42,7 @@ public class SetGamePage extends BasePage
public void onClick(Player player, ClickType clickType)
{
Plugin.GetGame().setGame(type, player, true);
org.bukkit.entity.Player.closeInventory();
player.closeInventory();
}
});
}