Java Code Examples for org.bukkit.Material#BANNER

The following examples show how to use org.bukkit.Material#BANNER . 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: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 5 votes vote down vote up
@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 2
Source File: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 5 votes vote down vote up
@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 3
Source File: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 5 votes vote down vote up
@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: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 5 votes vote down vote up
@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 5
Source File: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 5 votes vote down vote up
@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 vote down vote up
@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 vote down vote up
@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 vote down vote up
@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: Flag.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
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());
}
 
Example 10
Source File: Banner.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public Banner() {
    super(Material.BANNER);
}
 
Example 11
Source File: CraftMetaBanner.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
boolean applicableTo(Material type) {
    return type == Material.BANNER;
}
 
Example 12
Source File: Flag.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
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();
}