public static Inventory mainMenu() {
Inventory i = Bukkit.createInventory(null, 54, Messager.color("&bMain Menu"));
ItemStack pending = new ItemStack(Material.BARRIER);
ItemMeta pendingMeta = pending.getItemMeta();
pendingMeta.setDisplayName(Messager.color("&cCurrent Ban Requests"));
pendingMeta.setLore(Arrays.asList(Messager.color("&7Pending: " + Main.getPendingRequests())));
pending.setItemMeta(pendingMeta);
i.setItem(20, pending);
// Remove the archived ones for now.
/**
ItemStack archive = new ItemStack(Material.CHEST);
ItemMeta archiveMeta = archive.getItemMeta();
archiveMeta.setDisplayName(Messager.color("&7Archived Requests"));
archive.setItemMeta(archiveMeta);
i.setItem(24, archive);
**/
return i;
}
java类org.bukkit.inventory.ItemStack的实例源码
GUIManager.java 文件源码
项目:EpicBanRequests
阅读 23
收藏 0
点赞 0
评论 0
BackpackManager.java 文件源码
项目:RPGInventory
阅读 21
收藏 0
点赞 0
评论 0
public static boolean playerCanTakeBackpack(Player player) {
if (BACKPACK_LIMIT == 0) {
return true;
}
// Check vanilla inventory
Inventory inventory = player.getInventory();
int count = 0;
for (ItemStack item : inventory.getContents()) {
if (isBackpack(item)) {
count++;
}
}
// Check RPGInventory slots
inventory = InventoryManager.get(player).getInventory();
Slot backpackSlot = SlotManager.instance().getBackpackSlot();
if (BackpackManager.isBackpack(inventory.getItem(backpackSlot.getSlotId())) && !backpackSlot.isQuick()) {
count++;
}
return count < BACKPACK_LIMIT;
}
BardClass.java 文件源码
项目:HCFCore
阅读 24
收藏 0
点赞 0
评论 0
@Override
public boolean isApplicableFor(Player player) {
ItemStack helmet = player.getInventory().getHelmet();
if (helmet == null || helmet.getType() != Material.GOLD_HELMET)
return false;
ItemStack chestplate = player.getInventory().getChestplate();
if (chestplate == null || chestplate.getType() != Material.GOLD_CHESTPLATE)
return false;
ItemStack leggings = player.getInventory().getLeggings();
if (leggings == null || leggings.getType() != Material.GOLD_LEGGINGS)
return false;
ItemStack boots = player.getInventory().getBoots();
return !(boots == null || boots.getType() != Material.GOLD_BOOTS);
}
XPItemShop.java 文件源码
项目:BedwarsXP
阅读 23
收藏 0
点赞 0
评论 0
private boolean hasEnoughRessource(Player player, VillagerTrade trade) {
if (trade instanceof XPVillagerTrade) {
return XPManager.hasEnoughXP(bedwars.getName(), player,
((XPVillagerTrade) trade).getXP());
} else {
ItemStack item1 = trade.getItem1();
ItemStack item2 = trade.getItem2();
PlayerInventory inventory = player.getInventory();
if (item2 != null) {
if ((!inventory.contains(item1.getType(), item1.getAmount()))
|| (!inventory.contains(item2.getType(),
item2.getAmount()))) {
return false;
}
} else if (!inventory.contains(item1.getType(), item1.getAmount())) {
return false;
}
return true;
}
}
KillRewardModule.java 文件源码
项目:ProjectAres
阅读 21
收藏 0
点赞 0
评论 0
public static KillRewardModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
ImmutableList.Builder<KillReward> rewards = ImmutableList.builder();
final ItemParser itemParser = context.needModule(ItemParser.class);
final Optional<ItemModifyModule> itemModifier = context.module(ItemModifyModule.class);
// Must allow top-level children for legacy support
for(Element elKillReward : XMLUtils.flattenElements(doc.getRootElement(), ImmutableSet.of("kill-rewards"), ImmutableSet.of("kill-reward", "killreward"), 0)) {
ImmutableList.Builder<ItemStack> items = ImmutableList.builder();
for(Element itemEl : elKillReward.getChildren("item")) {
final ItemStack item = itemParser.parseItem(itemEl, false);
itemModifier.ifPresent(imm -> imm.applyRules(item));
items.add(item.immutableCopy());
}
Filter filter = context.needModule(FilterParser.class).property(elKillReward, "filter").optional(StaticFilter.ALLOW);
Kit kit = context.needModule(KitParser.class).property(elKillReward, "kit").optional(KitNode.EMPTY);
rewards.add(new KillReward(items.build(), filter, kit));
}
ImmutableList<KillReward> list = rewards.build();
if(list.isEmpty()) {
return null;
} else {
return new KillRewardModule(list);
}
}
PuppyPowerModule.java 文件源码
项目:SurvivalAPI
阅读 17
收藏 0
点赞 0
评论 0
/**
* Give 64 bones, 64 rotten flesh and 64 wolf eggs to all the players
*
* @param game Game
*/
@Override
public void onGameStart(SurvivalGame game)
{
ItemStack eggs = MojangShitUtils.getMonsterEgg(EntityType.WOLF);
eggs.setAmount((int) this.moduleConfiguration.get("eggs"));
for (GamePlayer player : (Collection<GamePlayer>) game.getInGamePlayers().values())
{
Player p = player.getPlayerIfOnline();
if (p == null)
continue;
p.getInventory().addItem(new ItemStack(Material.BONE, (int) this.moduleConfiguration.get("bones")));
p.getInventory().addItem(new ItemStack(Material.ROTTEN_FLESH, (int) this.moduleConfiguration.get("rotten-flesh")));
p.getInventory().addItem(eggs);
}
}
StandardGun.java 文件源码
项目:AddGun
阅读 18
收藏 0
点赞 0
评论 0
/**
* Checks if the proferred item is a gun.
*
* @param toCheck the item to check if this gun
* @return true if gun, false otherwise
*/
@Override
public boolean isGun(ItemStack toCheck) {
if (!enabled || toCheck == null)
return false;
if (!gunExample.getType().equals(toCheck.getType()))
return false;
if (!toCheck.hasItemMeta())
return false;
ItemMeta meta = toCheck.getItemMeta();
if (meta.hasLore() && meta.getLore().contains(tag))
return true;
return false;
}
MatchListener.java 文件源码
项目:ZorahPractice
阅读 23
收藏 0
点赞 0
评论 0
@EventHandler
public void onDeath(PlayerDeathEvent event) {
Player player = event.getEntity();
PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(player);
if (profile.getStatus() != PlayerStatus.PLAYING) {
return;
}
player.spigot().respawn();
IMatch match = profile.getCurrentMatch();
match.handleDeath(player, player.getLocation(), ChatColor.RED + player.getName() + ChatColor.GRAY + " has been slain.");
event.setDeathMessage(null);
player.setHealth(20.0);
for (ItemStack i : event.getDrops()) {
i.setType(Material.AIR);
}
}
SExprItemEffectTypeAmplifier.java 文件源码
项目:QuarSK
阅读 23
收藏 0
点赞 0
评论 0
@Nullable
@Override
protected Number[] get(Event e) {
ItemStack i = item.getSingle(e);
if (i == null) {
return null;
}
if (PotionUtils.isPotionItem(i)) {
PotionMeta meta = (PotionMeta) i.getItemMeta();
PotionEffect eff = PotionUtils.getEffectByEffectType(meta, effectType.getSingle(e));
if (eff == null) {
return null;
}
return new Number[]{eff.getAmplifier()};
}
return null;
}
Tribe.java 文件源码
项目:AsgardAscension
阅读 18
收藏 0
点赞 0
评论 0
public ItemStack[] loadContent() {
TribeFile.createConfig(getName());
if(TribeFile.getChest() != null) {
List<?> list = TribeFile.getChest();
ItemStack[] turinys = new ItemStack[list.size()];
for (int i = 0; i < list.size(); i++) {
Object o = list.get(i);
if (o instanceof ItemStack) {
turinys[i] = (ItemStack) o;
} else {
turinys[i] = new ItemStack(Material.AIR);
}
}
return turinys;
}
return new ItemStack[0];
}
InventoryManager.java 文件源码
项目:RPGInventory
阅读 20
收藏 0
点赞 0
评论 0
public static void syncInfoSlots(PlayerWrapper playerWrapper) {
final Player player = (Player) playerWrapper.getPlayer();
for (Slot infoSlot : SlotManager.instance().getInfoSlots()) {
ItemStack cup = infoSlot.getCup();
ItemMeta meta = cup.getItemMeta();
List<String> lore = meta.getLore();
for (int i = 0; i < lore.size(); i++) {
String line = lore.get(i);
lore.set(i, StringUtils.setPlaceholders(player, line));
}
meta.setLore(lore);
cup.setItemMeta(meta);
playerWrapper.getInventory().setItem(infoSlot.getSlotId(), cup);
}
player.updateInventory();
}
PageGUI.java 文件源码
项目:MCLibrary
阅读 20
收藏 0
点赞 0
评论 0
private void setLayout(Inventory inv) {
String title = getData().title();
int size = getData().size();
int lastLineFirstIndex = size - 9;
ItemStack wall = new ItemBuilder(Material.STAINED_GLASS)
.display("")
.build();
for (int i = 0; i < 9; i++) {
inv.setItem(i, wall);
}
for (int i = lastLineFirstIndex; i < size; i++) {
inv.setItem(i, wall);
}
inv.setItem(4, new ItemBuilder(Material.NETHER_STAR).display(title).build());
inv.setItem(prevPageBtnIndex, new ItemBuilder(Material.WOOD_BUTTON).build());
inv.setItem(nextPageBtnIndex, new ItemBuilder(Material.WOOD_BUTTON).build());
}
StaticCrate.java 文件源码
项目:WC
阅读 17
收藏 0
点赞 0
评论 0
@Override
public ArrayList<ItemStack> contains(){
ArrayList<ItemStack> items = new ArrayList<>();
switch (getCrateType()){
case NORMAL:
items.add(new ItemMaker(Material.APPLE).setDisplayName("An apple a day keeps the doctor away").setAmount(7).build());
items.add(new ItemMaker(Material.BOAT).build());
items.add(new ItemMaker(Material.IRON_BLOCK).build());
break;
case EPICA:
break;
case LEGENDARIA:
break;
}
return items;
}
LobbySelector.java 文件源码
项目:WC
阅读 99
收藏 0
点赞 0
评论 0
public LobbySelector(WCLobby instance){
gameSelector = iu.createInventory(9, "&cServidores");
ItemStack glass = ItemUtils.coloredBlock(DyeColor.ORANGE, "&cWorld&8Crafteros", ItemUtils.ColoredBlock.FLAT_GLASS);
//Glass
for (int x = 1; x < 8; x++){
gameSelector = iu.setItem(gameSelector, x + 9, glass);
gameSelector = iu.setItem(gameSelector, x + (9 * 4), glass);
}
gameSelector = iu.setItem(gameSelector, 18, glass);
gameSelector = iu.setItem(gameSelector, 27, glass);
gameSelector = iu.setItem(gameSelector, 26, glass);
gameSelector = iu.setItem(gameSelector, 35, glass);
//
}
ClickListener.java 文件源码
项目:NineSlots
阅读 24
收藏 0
点赞 0
评论 0
@EventHandler
public void on(PlayerDropItemEvent event) {
ItemStack item = event.getItemDrop().getItemStack();
if (item == null) {
return;
}
if (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) {
return;
}
String name = item.getItemMeta().getDisplayName();
if (name.equals("§4§lBlocked Slot")) {
event.setCancelled(true);
}
}
ArmorStands.java 文件源码
项目:Kineticraft
阅读 25
收藏 0
点赞 0
评论 0
public ArmorPose(ArmorStand a) {
this(a.getHeadPose(), a.getBodyPose(), a.getLeftArmPose(), a.getRightArmPose(), a.getLeftLegPose(), a.getRightLegPose(), new JsonMap<>());
for (EquipmentSlot slot : EquipmentSlot.values()) { // Save gear.
ItemStack i = Utils.getItem(a, slot);
if (!Utils.isAir(i))
getGear().put(slot.name(), i);
}
}
SExprItemLayers.java 文件源码
项目:QuarSK
阅读 34
收藏 0
点赞 0
评论 0
@Nullable
@Override
protected Pattern[] get(Event e) {
ItemStack i = item.getSingle(e);
if (i == null) {
return null;
}
if (i.getType() == Material.BANNER || i.getType() == Material.SHIELD) {
return ((BannerMeta) i.getItemMeta()).getPatterns().stream().toArray(Pattern[]::new);
}
return null;
}
RuneManager.java 文件源码
项目:AsgardAscension
阅读 29
收藏 0
点赞 0
评论 0
public void start(Player player, Rune rune) {
startEffect(player, rune);
setActiveRune(player, rune);
switch(rune.getName()) {
case "Freeze":
handleFreeze(player, rune);
return;
case "Fire Storm":
handleFireStorm(player, rune);
break;
case "Slowdown":
handleSlowdown(player, rune);
break;
case "Invisibility":
handleInvisibility(player, rune);
break;
case "Lightning":
handleLightning(player, rune);
break;
case "Detonate":
handleDetonate(player, rune);
break;
default:
return;
}
player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
player.sendMessage(Lang.HEADERS_TOKENS.toString() + Lang.TOKENS_RUNE_APPLY.toString()
.replaceAll("%s", rune.getName()));
}
FireCraftTableRecipe.java 文件源码
项目:RealSurvival
阅读 23
收藏 0
点赞 0
评论 0
public FireCraftTableRecipe(int time, double temperature, int maxTime, String name, List<String> shape,
HashMap<Character, ItemStack> materials, ItemStack[] product) {
super();
this.time = time;
this.temperature = temperature;
this.maxTime = maxTime;
this.name = name;
this.shape = shape;
this.materials = materials;
this.product = product;
}
InventorySerializer.java 文件源码
项目:RPGInventory
阅读 23
收藏 0
点赞 0
评论 0
static void savePlayer(PlayerWrapper playerWrapper, Path file) throws IOException {
List<NbtCompound> slotList = new ArrayList<>();
try (DataOutputStream dataOutput = new DataOutputStream(new GZIPOutputStream(Files.newOutputStream(file)))) {
for (Slot slot : SlotManager.instance().getSlots()) {
if (slot.getSlotType() == Slot.SlotType.ARMOR) {
continue;
}
List<NbtCompound> itemList = new ArrayList<>();
List<Integer> slotIds = slot.getSlotIds();
Inventory inventory = playerWrapper.getInventory();
for (int i = 0; i < slotIds.size(); i++) {
int slotId = slotIds.get(i);
ItemStack itemStack = inventory.getItem(slotId);
if (!ItemUtils.isEmpty(itemStack) && !slot.isCup(itemStack)) {
itemList.add(ItemUtils.itemStackToNBT(itemStack, i + ""));
}
}
if (itemList.size() > 0 || playerWrapper.isBuyedSlot(slot.getName())) {
NbtCompound slotNbt = NbtFactory.ofCompound(slot.getName());
slotNbt.put("type", slot.getSlotType().name());
if (playerWrapper.isBuyedSlot(slot.getName())) {
slotNbt.put("buyed", "true");
}
slotNbt.put(NbtFactory.ofCompound("items", itemList));
slotList.add(slotNbt);
}
}
NbtCompound playerNbt = NbtFactory.ofCompound("Inventory");
playerNbt.put(NbtFactory.ofCompound("slots", slotList));
playerNbt.put("buyed-slots", playerWrapper.getBuyedGenericSlots());
NbtBinarySerializer.DEFAULT.serialize(playerNbt, dataOutput);
}
}
Punishments.java 文件源码
项目:Kineticraft
阅读 20
收藏 0
点赞 0
评论 0
/**
* Create an item to represent this punishment
* @return item
*/
public ItemStack getItem() {
return ItemManager.createItem(isValid() ? getType().getIcon() : Material.BARRIER, getType().getDisplay(),
"Source: " + ChatColor.WHITE + getSource(),
"Date: " + ChatColor.WHITE + new Date(timestamp).toString(),
"Click here to " + (isValid() ? "in" : "") + "validate this punishment.");
}
ItemRequest.java 文件源码
项目:Slimefun4-Chinese-Version
阅读 18
收藏 0
点赞 0
评论 0
public ItemRequest(Location terminal, int slot, ItemStack item, ItemTransportFlow flow)
{
this.terminal = terminal;
this.item = item;
this.slot = slot;
this.flow = flow;
}
ModeratorMode.java 文件源码
项目:HCFCore
阅读 19
收藏 0
点赞 0
评论 0
public static void loadInventory(Player p)
{
p.getInventory().clear();
p.getInventory().setContents((ItemStack[])inventoryContents.get(p.getName()));
p.getInventory().setArmorContents((ItemStack[])armorContents.get(p.getName()));
p.setLevel(((Integer)xplevel.get(p.getName())).intValue());
inventoryContents.remove(p.getName());
armorContents.remove(p.getName());
xplevel.remove(p.getName());
}
GameVotingRunnable.java 文件源码
项目:Arcadia-Spigot
阅读 22
收藏 0
点赞 0
评论 0
public GameVotingRunnable() {
this.api = Arcadia.getPlugin(Arcadia.class).getAPI();
api.getGameManager().getMainBossBar().setColor(BarColor.YELLOW);
List<Class<? extends BaseGame>> temp = api.getGameRegistry().getRegisteredGames();
List<String> allowedGames = api.getPlugin().mainConfiguration.fetch().getStringList("games-in-voting");
Iterator<Class<? extends BaseGame>> iterator = temp.iterator();
while(iterator.hasNext()) {
Class<? extends BaseGame> next = iterator.next();
if(!allowedGames.contains(next.getName())) iterator.remove();
}
Collections.shuffle(temp);
int slot = 2;
for(int i=0; i<5; i++) {
if(i < temp.size()) {
slots.put(slot, temp.get(i));
slot++;
}
}
Bukkit.getOnlinePlayers().forEach(player -> {
for(int i=0; i<9; i++) {
Utils.setSpacer(player, i);
}
int s = 2;
for(Class<? extends BaseGame> key : slots.values()) {
final VotingData votingData = api.getGameRegistry().getVotingData(key);
ItemStack itemStack = new ItemStack(votingData.getMaterialData().getItemType(), 1,
votingData.getMaterialData().getData());
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&b&l" + votingData.getGameName()));
itemStack.setItemMeta(itemMeta);
player.getInventory().setItem(s, itemStack);
s++;
}
});
api.getPlugin().getServer().getPluginManager().registerEvents(this, api.getPlugin());
this.runTaskTimer(Arcadia.getPlugin(Arcadia.class), 0, 20L);
}
Lore.java 文件源码
项目:HNRPG
阅读 19
收藏 0
点赞 0
评论 0
public void addLore(int ID, int DATA, int STACK, List<String> Lore, CommandSender sender) {
try {
Integer.parseInt(String.valueOf(tempStr));
ItemStack itemStack = new MaterialData(ID, (byte) DATA).toItemStack(STACK);
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setLore(Lore);
} catch (NumberFormatException e) {
sender.sendMessage("§c[ §4§l! §c] §3§l줄 수§7를 입력해주세요.");
return;
}
}
PopeyeModule.java 文件源码
项目:SurvivalAPI
阅读 20
收藏 0
点赞 0
评论 0
/**
* Give strength on spinash use
* @param event Event
*/
@EventHandler
public void onInteract(PlayerInteractEvent event)
{
if (event.getItem() != null && event.getItem().isSimilar(this.spinash))
{
event.getPlayer().addPotionEffect(PotionEffectType.INCREASE_DAMAGE.createEffect(this.bonusTime * 20, 1));
event.getPlayer().setItemInHand(new ItemStack(Material.AIR));
event.setCancelled(true);
}
}
BackpackListener.java 文件源码
项目:Slimefun4-Chinese-Version
阅读 21
收藏 0
点赞 0
评论 0
public void onItemDrop(PlayerDropItemEvent e)
{
if(Variables.backpack.containsKey(e.getPlayer().getUniqueId()))
{
ItemStack item = e.getItemDrop().getItemStack();
SlimefunItem sfItem = SlimefunItem.getByItem(item);
if(sfItem instanceof SlimefunBackpack)
e.setCancelled(true);
}
}
MyPetManager.java 文件源码
项目:RPGInventory
阅读 25
收藏 0
点赞 0
评论 0
@EventHandler
public void onMyPetItemUse(PlayerInteractEvent event) {
if (event.getItem() != null) {
Player player = event.getPlayer();
if (!InventoryManager.playerIsLoaded(player)) {
return;
}
Inventory inventory = InventoryManager.get(player).getInventory();
if (isMyPetItem(event.getItem())
&& (event.getAction() == Action.RIGHT_CLICK_BLOCK
|| event.getAction() == Action.RIGHT_CLICK_AIR)) {
Slot petSlot = getMyPetSlot();
ItemStack currentPet = inventory.getItem(petSlot.getSlotId());
boolean hasPet = !petSlot.isCup(currentPet);
ItemStack newPet = event.getItem();
if (!hasPet) {
currentPet = null;
}
player.getEquipment().setItemInMainHand(currentPet);
inventory.setItem(petSlot.getSlotId(), newPet);
swapMyPets(player, hasPet, newPet);
}
}
}
CraftItemGUI.java 文件源码
项目:RealSurvival
阅读 19
收藏 0
点赞 0
评论 0
public static Inventory resetSF(ItemStack itemKey){
WorkbenchRecipe sf=rs.getSF(itemKey.getItemMeta().getDisplayName().split(":")[0]);
Inventory inv=createDefaultGUI(rs.getWorkbenchItems()[7]+"*");
inv.setItem(0, itemKey);
inv.setItem(49, Items.createPItem((short) 14, "��b��l==>��c��l�����b��l<=="));
return sf.setInv(inv);
}
PlayerListener.java 文件源码
项目:AsgardAscension
阅读 29
收藏 0
点赞 0
评论 0
public PlayerListener(Main plugin) {
diamondMiner = new HashMap<String, Boolean>();
speedMiner = new HashMap<String, ItemStack>();
rainbowMiner = new HashMap<String, ItemStack>();
randomGen = new Random();
this.plugin = plugin;
}