Java 类org.bukkit.material.Colorable 实例源码
项目:buildinggame
文件:ColorSelectionMenu.java
/**
* Constructs a new Gui
*
* @param entity the entity to change the color of
*/
public ColorSelectionMenu(Creature entity) {
super(null, 18, ChatColor.GREEN + "Select a color", 1);
for (DyeColor dyeColor : DyeColor.values())
addItem(new Wool(dyeColor).toItemStack(1), event -> {
if (entity instanceof Colorable)
((Colorable) entity).setColor(dyeColor);
else if (entity instanceof Wolf) {
Wolf wolf = (Wolf) entity;
wolf.setTamed(true);
wolf.setCollarColor(dyeColor);
}
event.setCancelled(true);
});
}
项目:BukkitLib
文件:Utilities.java
/**
* Sets the color of the specified block.
* The block that is passed will be modified by reference after the operation.
* @param block The block to modify the data of.
* @param color The new color of the item.
*/
@SuppressWarnings("deprecation")
public static void setColor(Block block, DyeColor color) {
Validate.isTrue(block != null && ((block.getState() != null && block.getState().getData() instanceof Colorable)
|| (block.getType() == Material.STAINED_CLAY
|| block.getType() == Material.STAINED_GLASS || block.getType() == Material.STAINED_GLASS_PANE || block.getType() == Material.CARPET)), "The specified block is not colorable.");
Validate.notNull(color, "The specified color is null.");
if(block.getState().getData() instanceof Colorable){
MaterialData data = block.getState().getData();
((Colorable)data).setColor(color);
block.getState().setData(data);
}else{
block.setData(color.getWoolData()); // Needed until Bukkit adds proper support
}
}
项目:Essentials
文件:MaterialDotStarPermission.java
public boolean isAuthorized(final CommandSender sender, final Material material, final MaterialData data)
{
final String materialName = material.name();
final String materialId = String.valueOf(material.getId());
if (data != null)
{
final String durName = materialName + ":" + data.getData();
final String durId = materialId + ":" + data.getData();
if (data instanceof Colorable)
{
return super.isAuthorized(sender, materialName + ":" + ((Colorable)data).getColor().name(), durName, durId, materialName, materialId);
}
if (data instanceof TexturedMaterial)
{
return super.isAuthorized(sender, materialName + ":" + ((TexturedMaterial)data).getMaterial().name(), durName, durId, materialName, materialId);
}
return super.isAuthorized(sender, durName, durId, materialName, materialId);
}
return super.isAuthorized(sender, materialName, materialId);
}
项目:GameBoxx
文件:EEntity.java
public DyeColor getColor() {
if (entity instanceof Colorable) {
return ((Colorable)entity).getColor();
} else if (entity instanceof Wolf) {
return ((Wolf)entity).getCollarColor();
}
return DyeColor.WHITE;
}
项目:GameBoxx
文件:EEntity.java
public EEntity setColor(DyeColor color) {
if (entity instanceof Colorable) {
((Colorable)entity).setColor(color);
} else if (entity instanceof Wolf) {
((Wolf)entity).setCollarColor(color);
}
return this;
}
项目:Skript
文件:ExprColorOf.java
@SuppressWarnings("null")
@Override
@Nullable
public Color convert(final Object o) {
if (o instanceof ItemStack || o instanceof Item) {
final ItemStack is = o instanceof ItemStack ? (ItemStack) o : ((Item) o).getItemStack();
final MaterialData d = is.getData();
if (d instanceof Colorable)
return Color.byWoolColor(((Colorable) d).getColor());
} else if (o instanceof Colorable) { // Sheep
return Color.byWoolColor(((Colorable) o).getColor());
}
return null;
}
项目:sensibletoolbox
文件:PaintBrush.java
private boolean okToColor(Block b, BaseSTBBlock stb) {
if (stb != null && !(stb instanceof Colorable)) {
// we don't want blocks which happen to use a Colorable material to be paintable
return false;
}
if (getBlockColour(b) == getColour() || getPaintLevel() <= 0) {
return false;
}
return STBUtil.isColorable(b.getType())
|| b.getType() == Material.GLASS
|| b.getType() == Material.THIN_GLASS
|| allowWoodStaining() && isStainableWood(b.getType()) && okWoodStain(getColour());
}
项目:sensibletoolbox
文件:PaintBrush.java
@Override
public void onInteractEntity(PlayerInteractEntityEvent event) {
event.setCancelled(true);
if (getPaintLevel() <= 0) {
return;
}
Entity e = event.getRightClicked();
int paintUsed = 0;
if (e instanceof Colorable) {
((Colorable) e).setColor(getColour());
paintUsed = 1;
} else if (e instanceof Painting) {
Art a = ((Painting) e).getArt();
if (getPaintLevel() >= a.getBlockHeight() * a.getBlockWidth()) {
IconMenu menu = buildMenu((Painting) e);
menu.open(event.getPlayer());
} else {
Location loc = e.getLocation().add(0, -a.getBlockHeight() / 2.0, 0);
PopupMessage.quickMessage(event.getPlayer(), loc, ChatColor.RED + "Not enough paint!");
}
} else if (e instanceof Wolf) {
Wolf wolf = (Wolf) e;
wolf.setCollarColor(getColour());
paintUsed = 1;
}
if (paintUsed > 0) {
setPaintLevel(getPaintLevel() - paintUsed);
event.getPlayer().setItemInHand(toItemStack());
event.getPlayer().playSound(e.getLocation(), Sound.WATER, 1.0f, 1.5f);
}
}
项目:sensibletoolbox
文件:PaintBrush.java
private int paintBlocks(Player player, Block... blocks) {
int painted = 0;
for (Block b : blocks) {
if (!SensibleToolbox.getBlockProtection().playerCanBuild(player, b, BlockProtection.Operation.PLACE)) {
continue;
}
Debugger.getInstance().debug(2, "painting! " + b + " " + getPaintLevel() + " " + getColour());
BaseSTBBlock stb = SensibleToolbox.getBlockAt(b.getLocation());
if (stb != null && stb instanceof Colorable) {
((Colorable) stb).setColor(getColour());
} else if (isStainableWood(b.getType())) {
int data = b.getData() & 0xf8;
data |= getWoodType(getColour()).getData();
b.setData((byte) data);
} else {
if (b.getType() == Material.GLASS) {
b.setType(Material.STAINED_GLASS);
} else if (b.getType() == Material.THIN_GLASS) {
b.setType(Material.STAINED_GLASS_PANE);
}
b.setData(getColour().getWoolData());
}
painted++;
setPaintLevel(getPaintLevel() - 1);
if (getPaintLevel() <= 0) {
break;
}
}
return painted;
}
项目:NucleusFramework
文件:ColorableAnimal.java
public ColorableAnimal(Entity entity) {
PreCon.notNull(entity);
PreCon.isValid(entity instanceof Colorable, "org.bukkit.material.Colorable expected.");
Colorable colorable = (Colorable)entity;
_color = colorable.getColor();
}
项目:NucleusFramework
文件:ColorableAnimal.java
@Override
public boolean apply(Entity entity) {
PreCon.notNull(entity);
PreCon.isValid(entity instanceof Colorable, "org.bukkit.material.Colorable expected.");
Colorable colorable = (Colorable)entity;
colorable.setColor(_color);
return true;
}
项目:Thermos-Bukkit
文件:DyeColorTest.java
private void testColorable(final Colorable colorable) {
assertThat(colorable.getColor(), is(this.dye));
}
项目:CauldronGit
文件:DyeColorTest.java
private void testColorable(final Colorable colorable) {
assertThat(colorable.getColor(), is(this.dye));
}
项目:BukkitLib
文件:Utilities.java
private static boolean isColorable(ItemStack stack){
return stack.getData() instanceof Colorable || stack.getType() == Material.STAINED_CLAY
|| stack.getType() == Material.STAINED_GLASS || stack.getType() == Material.STAINED_GLASS_PANE || stack.getType() == Material.CARPET
|| stack.getType() == Material.FIREWORK;
}
项目:Cauldron
文件:DyeColorTest.java
private void testColorable(final Colorable colorable) {
assertThat(colorable.getColor(), is(this.dye));
}
项目:Almura-API
文件:DyeColorTest.java
private void testColorable(final Colorable colorable) {
assertThat(colorable.getColor(), is(this.dye));
}
项目:Spigot-API
文件:DyeColorTest.java
private void testColorable(final Colorable colorable) {
assertThat(colorable.getColor(), is(this.dye));
}
项目:Bukkit-JavaDoc
文件:DyeColorTest.java
private void testColorable(final Colorable colorable) {
assertThat(colorable.getColor(), is(this.dye));
}