use of org.bukkit.block.banner.Pattern in project Denizen-For-Bukkit by DenizenScript.
the class ItemPatterns method adjust.
@Override
public void adjust(Mechanism mechanism) {
if (mechanism.matches("patterns")) {
List<Pattern> patterns = new ArrayList<Pattern>();
dList list = mechanism.getValue().asType(dList.class);
List<String> split;
for (String string : list) {
try {
split = CoreUtilities.split(string, '/', 2);
patterns.add(new Pattern(DyeColor.valueOf(split.get(0).toUpperCase()), PatternType.valueOf(split.get(1).toUpperCase())));
} catch (Exception e) {
dB.echoError("Could not apply pattern to banner: " + string);
}
}
setPatterns(patterns);
}
}
use of org.bukkit.block.banner.Pattern in project Denizen-For-Bukkit by DenizenScript.
the class PacketHelper_v1_10_R1 method showBannerUpdate.
@Override
public void showBannerUpdate(Player player, Location location, DyeColor base, List<Pattern> patterns) {
List<CompoundTag> nbtPatterns = new ArrayList<CompoundTag>();
for (Pattern pattern : patterns) {
nbtPatterns.add(NMSHandler.getInstance().createCompoundTag(new HashMap<String, Tag>()).createBuilder().putInt("Color", pattern.getColor().getDyeData()).putString("Pattern", pattern.getPattern().getIdentifier()).build());
}
CompoundTag compoundTag = NMSHandler.getInstance().getBlockHelper().getNbtData(location.getBlock()).createBuilder().putInt("Base", base.getDyeData()).put("Patterns", new ListTag(CompoundTag.class, nbtPatterns)).build();
showTileEntityData(player, location, 3, compoundTag);
}
use of org.bukkit.block.banner.Pattern in project CitizensAPI by CitizensDev.
the class ItemStorage method deserialiseBanner.
private static void deserialiseBanner(DataKey root, Banner meta) {
if (root.keyExists("banner.basecolor")) {
meta.setBaseColor(DyeColor.valueOf(root.getString("banner.basecolor")));
}
if (root.keyExists("banner.patterns")) {
for (DataKey sub : root.getRelative("banner.patterns").getIntegerSubKeys()) {
Pattern pattern = new Pattern(DyeColor.valueOf(sub.getString("color")), PatternType.getByIdentifier(sub.getString("type")));
meta.addPattern(pattern);
}
}
}
use of org.bukkit.block.banner.Pattern in project askyblock by tastybento.
the class BannerBlock method prep.
@SuppressWarnings("deprecation")
public boolean prep(Map<String, Tag> tileData) {
// x = Int
try {
// Do the base color
int baseColor = 15 - ((IntTag) tileData.get("Base")).getValue();
// //ASkyBlock.getPlugin().getLogger().info("Base value = " +
// baseColor);
// baseColor green = 10
bannerBaseColor = DyeColor.getByDyeData((byte) baseColor);
// Do the patterns (no idea if this will work or not)
bannerPattern = new ArrayList<Pattern>();
ListTag patterns = (ListTag) tileData.get("Patterns");
if (patterns != null) {
for (Tag pattern : patterns.getValue()) {
// Translate pattern to PatternType
if (pattern instanceof CompoundTag) {
CompoundTag patternColor = (CompoundTag) pattern;
// The tag is made up of pattern (String) and color
// (int)
Map<String, Tag> patternValue = patternColor.getValue();
StringTag mark = (StringTag) patternValue.get("Pattern");
Integer markColor = 15 - ((IntTag) patternValue.get("Color")).getValue();
// ASkyBlock.getPlugin().getLogger().info("mark = " +
// mark.getValue());
// ASkyBlock.getPlugin().getLogger().info("color = " +
// markColor);
DyeColor dColor = DyeColor.getByDyeData(markColor.byteValue());
// + dColor.toString());
if (patternKey.containsKey(mark.getValue())) {
Pattern newPattern = new Pattern(dColor, patternKey.get(mark.getValue()));
bannerPattern.add(newPattern);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
use of org.bukkit.block.banner.Pattern in project Prism-Bukkit by prism.
the class BlockAction method handleBanners.
private ChangeResultImpl handleBanners(Block block, BlockActionData blockActionData, BlockState originalBlock) {
block.setType(getMaterial());
BlockState state = block.getState();
final BannerActionData actionData = (BannerActionData) blockActionData;
setBlockRotatable(state, actionData);
state = block.getState();
if (!actionData.patterns.isEmpty()) {
final Banner banner = (Banner) state;
List<Pattern> patternsList = new ArrayList<>();
actionData.patterns.forEach((s, s2) -> {
PatternType type = PatternType.valueOf(s);
DyeColor color = DyeColor.valueOf(s2.toUpperCase());
Pattern p = new Pattern(color, type);
patternsList.add(p);
});
banner.setPatterns(patternsList);
banner.update();
}
BlockStateChangeImpl stateChange = new BlockStateChangeImpl(originalBlock, state);
return new ChangeResultImpl(ChangeResultType.APPLIED, stateChange);
}
Aggregations