Java Code Examples for org.bukkit.Material#WOOL
The following examples show how to use
org.bukkit.Material#WOOL .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WoolMatchModule.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
@EventHandler public void handleWoolCrafting(PrepareItemCraftEvent event) { ItemStack result = event.getRecipe().getResult(); InventoryHolder holder = event.getInventory().getHolder(); if (holder instanceof Player) { MatchPlayer playerHolder = this.match.getPlayer((Player) holder); if (playerHolder != null && result != null && result.getType() == Material.WOOL) { for (MonumentWool wool : this.wools.values()) { if (wool.getDefinition().isObjectiveWool(result)) { if (!wool.getDefinition().isCraftable()) { playerHolder.sendWarning( TranslatableComponent.of("wool.craftingDisabled", wool.getComponentName())); event.getInventory().setResult(null); } } } } } }
Example 2
Source File: GameObjectiveProximityHandler.java From CardinalPGM with MIT License | 6 votes |
private void tryUpdate(Player player, Block block) { if (!teamAllowsUpdate(Teams.getTeamByPlayer(player))) return; boolean update = true; if (objective instanceof WoolObjective) { update = !info.needsTouch; if (info.needsTouch) { if (info.metric.equals(ProximityMetric.CLOSEST_BLOCK)) { if (block.getType().equals(Material.WOOL) && ((Wool) block.getState().getData()).getColor().equals(((WoolObjective) objective).getColor())) update = true; } else { ItemStack item = new ItemStack(Material.WOOL, 1, ((WoolObjective) objective).getColor().getWoolData()); if (player.getInventory().containsAtLeast(item, 1)) update = true; } } } else if (objective instanceof FlagObjective) { if (info.needsTouch) { update = Flags.getFlag(player) == objective; } } if (update) setProximity(player.getLocation(), player); }
Example 3
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public ItemStack getColorItem(String mat, byte color) { if (mat.equalsIgnoreCase("wool")) { return new ItemStack(Material.WOOL, 1, (short) color); } else if (mat.equalsIgnoreCase("glass")) { return new ItemStack(Material.STAINED_GLASS, 1, (short) color); } else if (mat.equalsIgnoreCase("banner")) { return new ItemStack(Material.BANNER, 1, (short) color); } else { return new ItemStack(Material.STAINED_GLASS, 1, (short) color); } }
Example 4
Source File: WoolMatchModule.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
private boolean isObjectiveWool(ItemStack stack) { if (stack.getType() == Material.WOOL) { for (MonumentWool wool : this.wools.values()) { if (wool.getDefinition().isObjectiveWool(stack)) return true; } } return false; }
Example 5
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public ItemStack getColorItem(String mat, byte color) { if (mat.equalsIgnoreCase("wool")) { return new ItemStack(Material.WOOL, 1, (short) color); } else if (mat.equalsIgnoreCase("glass")) { return new ItemStack(Material.STAINED_GLASS, 1, (short) color); } else if (mat.equalsIgnoreCase("banner")) { return new ItemStack(Material.BANNER, 1, (short) color); } else { return new ItemStack(Material.STAINED_GLASS, 1, (short) color); } }
Example 6
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public ItemStack getColorItem(String mat, byte color) { if (mat.equalsIgnoreCase("wool")) { return new ItemStack(Material.WOOL, 1, (short) color); } else if (mat.equalsIgnoreCase("glass")) { return new ItemStack(Material.STAINED_GLASS, 1, (short) color); } else if (mat.equalsIgnoreCase("banner")) { return new ItemStack(Material.BANNER, 1, (short) color); } else { return new ItemStack(Material.STAINED_GLASS, 1, (short) color); } }
Example 7
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public ItemStack getColorItem(String mat, byte color) { if (mat.equalsIgnoreCase("wool")) { return new ItemStack(Material.WOOL, 1, (short) color); } else if (mat.equalsIgnoreCase("glass")) { return new ItemStack(Material.STAINED_GLASS, 1, (short) color); } else if (mat.equalsIgnoreCase("banner")) { return new ItemStack(Material.BANNER, 1, (short) color); } else { return new ItemStack(Material.STAINED_GLASS, 1, (short) color); } }
Example 8
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public ItemStack getColorItem(String mat, byte color) { if (mat.equalsIgnoreCase("wool")) { return new ItemStack(Material.WOOL, 1, (short) color); } else if (mat.equalsIgnoreCase("glass")) { return new ItemStack(Material.STAINED_GLASS, 1, (short) color); } else if (mat.equalsIgnoreCase("banner")) { return new ItemStack(Material.BANNER, 1, (short) color); } else { return new ItemStack(Material.STAINED_GLASS, 1, (short) color); } }
Example 9
Source File: WoolObjective.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onWoolPickup(PlayerPickupItemEvent event) { Player player = event.getPlayer(); if (!this.complete && GameHandler.getGameHandler().getMatch().isRunning()) { try { if (event.getItem().getItemStack().getType() == Material.WOOL && ((Wool) event.getItem().getItemStack().getData()).getColor().equals(color)) { if (Teams.getTeamByPlayer(player).orNull() == team) { boolean touchMessage = false; if (!this.playersTouched.contains(player.getUniqueId())) { this.playersTouched.add(player.getUniqueId()); if (this.show && !this.complete) { Teams.getTeamChannel(Optional.of(team)).sendLocalizedMessage(new UnlocalizedChatMessage(ChatColor.WHITE + "{0}", new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_PICKED, team.getColor() + player.getName() + ChatColor.WHITE, MiscUtil.convertDyeColorToChatColor(color) + name.toUpperCase().replaceAll("_", " ") + ChatColor.WHITE, team.getCompleteName() + ChatColor.WHITE))); for (Player player1 : Bukkit.getOnlinePlayers()) { if (Teams.getTeamByPlayer(player1).isPresent() && Teams.getTeamByPlayer(player1).get().isObserver()) { player1.sendMessage(new UnlocalizedChatMessage(ChatColor.GRAY + "{0}", new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_PICKED_FOR, team.getColor() + player.getName() + ChatColor.GRAY, MiscUtil.convertDyeColorToChatColor(color) + name.toUpperCase().replaceAll("_", " ") + ChatColor.GRAY, team.getCompleteName() + ChatColor.GRAY)).getMessage(player1.getLocale())); } } touchMessage = true; } } if (!touched) touched = true; ObjectiveTouchEvent touchEvent = new ObjectiveTouchEvent(this, player, touchMessage); Bukkit.getServer().getPluginManager().callEvent(touchEvent); } } } catch (NullPointerException e) { } } }
Example 10
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public ItemStack getColorItem(String mat, byte color) { if (mat.equalsIgnoreCase("wool")) { return new ItemStack(Material.WOOL, 1, (short) color); } else if (mat.equalsIgnoreCase("glass")) { return new ItemStack(Material.STAINED_GLASS, 1, (short) color); } else if (mat.equalsIgnoreCase("banner")) { return new ItemStack(Material.BANNER, 1, (short) color); } else { return new ItemStack(Material.STAINED_GLASS, 1, (short) color); } }
Example 11
Source File: TeamBlock.java From AnnihilationPro with MIT License | 5 votes |
public void giveToPlayer(final Player player) { ItemStack[] inv = player.getInventory().getContents(); for(int x = 0; x < inv.length; x++) { if(inv[x] != null && inv[x].getType() == Material.WOOL) { if(KitUtils.itemHasName(inv[x], this.getName())) player.getInventory().clear(x); } } player.getInventory().addItem(this.toItemStack()); }
Example 12
Source File: TeamBlock.java From AnnihilationPro with MIT License | 5 votes |
private ItemStack toItemStack() { @SuppressWarnings("deprecation") ItemStack stack = new ItemStack(Material.WOOL,1,(short)0,datavalue); ItemMeta meta = stack.getItemMeta(); meta.setDisplayName(getName()); if (lore != null) meta.setLore(lore); stack.setItemMeta(meta); return KitUtils.addSoulbound(stack); }
Example 13
Source File: MapRatingsMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler public void onButtonClick(final InventoryClickEvent event) { ItemStack stack = event.getCurrentItem(); final MatchPlayer player = this.getMatch().getPlayer(event.getWhoClicked()); if(stack == null || player == null) return; if(stack.getType() != Material.WOOL && stack.getType() != Material.CARPET) return; ItemMeta meta = stack.getItemMeta(); if(!meta.hasDisplayName()) return; String name = meta.getDisplayName(); if(!name.startsWith(BUTTON_PREFIX)) return; event.setCancelled(true); final int score = stack.getAmount(); if(!isScoreValid(score)) return; this.getMatch().getScheduler(MatchScope.LOADED).createTask(() -> { Integer oldScore = playerRatings.get(player); if(oldScore == null || oldScore != score) { player.playSound(Sound.UI_BUTTON_CLICK, 1, 2); rate(player, score); } else { player.getBukkit().closeInventory(); } }); }
Example 14
Source File: WoolMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
private boolean isObjectiveWool(ItemStack stack) { if(stack.getType() == Material.WOOL) { for(MonumentWool wool : this.wools) { if(wool.getDefinition().isObjectiveWool(stack)) return true; } } return false; }
Example 15
Source File: CreeperShop.java From Shopkeepers with GNU General Public License v3.0 | 4 votes |
@Override public ItemStack getSubTypeItem() { return new ItemStack(Material.WOOL, 1, powered ? (short) 3 : (short) 5); }
Example 16
Source File: DisableableModule.java From UHC with MIT License | 4 votes |
@Override public void initialize() throws InvalidConfigurationException { if (!config.contains(ENABLED_KEY)) { config.set(ENABLED_KEY, isEnabledByDefault()); } if (!config.isBoolean(ENABLED_KEY)) { throw new InvalidConfigurationException( "Invalid value at key " + config.getCurrentPath() + ".enabled (" + config.get(ENABLED_KEY) + ")" ); } // store inverted version to trigger change this.enabled = !config.getBoolean(ENABLED_KEY); toggle(); // register a click handler on our icon to show the confirmation inventory icon.registerClickHandler(new ClickHandler() { @Override public void onClick(Player player) { if (player.hasPermission(ADMIN_PERMISSION)) { confirmation.showTo(player); } } }); // setup confirmation inventory confirmation = new IconInventory(CONFIRMATION_TITLE + id); for (int i = 0; i < INVENTORY_WIDTH; i++) { final IconStack stack; if (i == CONFIRM_ITEM_SLOT) { stack = new IconStack(Material.WOOL, 1, CONFIRM_WOOL_COLOUR_ID); stack.setDisplayName(ChatColor.GREEN + "Confirm Toggle"); stack.setLore("Clicking this will toggle the module " + id); stack.registerClickHandler(this); } else { stack = new IconStack(Material.AIR); stack.registerClickHandler(CANCELLED_TOGGLE); } stack.setWeight(i); stack.registerClickHandler(CLOSE_INVENTORY); confirmation.registerNewIcon(stack); } // register confirmation inventory for events Bukkit.getServer().getPluginManager().registerEvents(confirmation, plugin); }
Example 17
Source File: WoolMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@SuppressWarnings("deprecation") private static boolean isValidWool(DyeColor expectedColor, BlockState state) { return state.getType() == Material.WOOL && expectedColor.getWoolData() == state.getRawData(); }
Example 18
Source File: SheepShop.java From Shopkeepers with GNU General Public License v3.0 | 4 votes |
@Override public ItemStack getSubTypeItem() { return new ItemStack(Material.WOOL, 1, color.getWoolData()); }
Example 19
Source File: Wool.java From Kettle with GNU General Public License v3.0 | 4 votes |
public Wool() { super(Material.WOOL); }
Example 20
Source File: CatShop.java From Shopkeepers with GNU General Public License v3.0 | 4 votes |
@Override public ItemStack getSubTypeItem() { return new ItemStack(Material.WOOL, 1, this.getSubItemData(catType)); }