下面列出了org.bukkit.Material#BANNER 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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);
}
}
@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);
}
}
@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);
}
}
@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);
}
}
@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);
}
}
@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);
}
}
@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);
}
}
@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);
}
}
protected Flag(Match match, FlagDefinition definition, ImmutableSet<Net> nets)
throws ModuleLoadException {
super(definition, match);
this.nets = nets;
TeamMatchModule tmm = match.getModule(TeamMatchModule.class);
if (definition.getOwner() != null) {
this.owner = tmm.getTeam(definition.getOwner());
} else {
this.owner = null;
}
ImmutableSet.Builder<Team> capturersBuilder = ImmutableSet.builder();
if (tmm != null) {
for (Team team : tmm.getTeams()) {
Query query = team.getQuery();
if (getDefinition().canPickup(query) && canCapture(query)) {
capturersBuilder.add(team);
}
}
}
this.capturers = capturersBuilder.build();
ImmutableSet.Builder<Team> controllersBuilder = ImmutableSet.builder();
ImmutableSet.Builder<Team> completersBuilder = ImmutableSet.builder();
for (Net net : nets) {
if (net.getReturnPost() != null && net.getReturnPost().getOwner() != null) {
Team controller = tmm.getTeam(net.getReturnPost().getOwner());
controllersBuilder.add(controller);
if (net.getReturnPost().isPermanent()) {
completersBuilder.add(controller);
}
}
}
this.controllers = controllersBuilder.build();
this.completers = completersBuilder.build();
Banner banner = null;
pointLoop:
for (PointProvider returnPoint : definition.getDefaultPost().getReturnPoints()) {
Region region = returnPoint.getRegion();
if (region instanceof PointRegion) {
// Do not require PointRegions to be at the exact center of the block.
// It might make sense to just override PointRegion.getBlockVectors() to
// always do this, but it does technically violate the contract of that method.
banner =
toBanner(((PointRegion) region).getPosition().toLocation(match.getWorld()).getBlock());
if (banner != null) break pointLoop;
} else {
for (BlockVector pos : returnPoint.getRegion().getBlockVectors()) {
banner = toBanner(pos.toLocation(match.getWorld()).getBlock());
if (banner != null) break pointLoop;
}
}
}
if (banner == null) {
throw new ModuleLoadException(
"Flag '" + getName() + "' must have a banner at its default post");
}
this.bannerLocation = Materials.getLocationWithYaw(banner);
this.bannerMeta = Materials.getItemMeta(banner);
this.bannerYawProvider = new StaticAngleProvider(this.bannerLocation.getYaw());
this.bannerItem = new ItemStack(Material.BANNER);
this.bannerItem.setItemMeta(this.getBannerMeta());
}
public Banner() {
super(Material.BANNER);
}
@Override
boolean applicableTo(Material type) {
return type == Material.BANNER;
}
protected Flag(Match match, FlagDefinition definition, ImmutableSet<Net> nets) throws ModuleLoadException {
super(definition, match);
this.nets = nets;
final TeamMatchModule tmm = match.getMatchModule(TeamMatchModule.class);
this.owner = definition.owner()
.map(def -> tmm.team(def)) // Do not use a method ref here, it will NPE if tmm is null
.orElse(null);
this.capturers = Lazy.from(
() -> Optionals.stream(match.module(TeamMatchModule.class))
.flatMap(TeamMatchModule::teams)
.filter(team -> getDefinition().canPickup(team) && canCapture(team))
.collect(Collectors.toSet())
);
this.controllers = Lazy.from(
() -> nets.stream()
.flatMap(net -> Optionals.stream(net.returnPost()
.flatMap(Post::owner)))
.map(def -> tmm.team(def))
.collect(Collectors.toSet())
);
this.completers = Lazy.from(
() -> nets.stream()
.flatMap(net -> Optionals.stream(net.returnPost()))
.filter(Post::isPermanent)
.flatMap(post -> Optionals.stream(post.owner()))
.map(def -> tmm.team(def))
.collect(Collectors.toSet())
);
Banner banner = null;
pointLoop: for(PointProvider returnPoint : definition.getDefaultPost().getReturnPoints()) {
Region region = returnPoint.getRegion();
if(region instanceof PointRegion) {
// Do not require PointRegions to be at the exact center of the block.
// It might make sense to just override PointRegion.getBlockVectors() to
// always do this, but it does technically violate the contract of that method.
banner = toBanner(((PointRegion) region).getPosition().toLocation(match.getWorld()).getBlock());
if(banner != null) break pointLoop;
} else {
for(BlockVector pos : returnPoint.getRegion().getBlockVectors()) {
banner = toBanner(pos.toLocation(match.getWorld()).getBlock());
if(banner != null) break pointLoop;
}
}
}
if(banner == null) {
throw new ModuleLoadException("Flag '" + getName() + "' must have a banner at its default post");
}
final Location location = Banners.getLocationWithYaw(banner);
bannerInfo = new BannerInfo(location,
Banners.getItemMeta(banner),
new ItemStack(Material.BANNER),
new StaticAngleProvider(location.getYaw()));
bannerInfo.item.setItemMeta(bannerInfo.meta);
match.registerEvents(this);
this.state = new Returned(this, this.getDefinition().getDefaultPost(), bannerInfo.location);
this.state.enterState();
}