Added Banner patterns support in Blueprints

Implements https://github.com/BentoBoxWorld/BentoBox/issues/961
This commit is contained in:
Florian CUNY 2019-09-29 10:26:39 +02:00
parent a415a65e7e
commit 477f60ae03
4 changed files with 39 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Banner;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.CreatureSpawner;
@ -288,6 +289,12 @@ public class BlueprintClipboard {
cs.setSpawnRange(spawner.getSpawnRange());
b.setCreatureSpawner(cs);
}
// Banners
if (blockState instanceof Banner) {
b.setBannerPatterns(((Banner) blockState).getPatterns());
}
this.bpBlocks.put(pos, b);
return true;
}

View File

@ -11,6 +11,7 @@ import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Banner;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
@ -246,6 +247,12 @@ public class BlueprintPaster {
spawner.setSpawnRange(s.getSpawnRange());
bs.update(true, false);
}
// Banners
if (bs instanceof Banner) {
Banner banner = (Banner) bs;
banner.setPatterns(bpBlock.getBannerPatterns());
banner.update(true, false);
}
}
/**

View File

@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.block.banner.Pattern;
import org.bukkit.inventory.ItemStack;
import com.google.gson.annotations.Expose;
@ -22,6 +23,11 @@ public class BlueprintBlock {
private Map<Integer, ItemStack> inventory;
@Expose
private BlueprintCreatureSpawner creatureSpawner;
/**
* @since 1.8.0
*/
@Expose
private List<Pattern> bannerPatterns;
public BlueprintBlock(String blockData) {
this.blockData = blockData;
@ -82,4 +88,20 @@ public class BlueprintBlock {
public void setCreatureSpawner(BlueprintCreatureSpawner creatureSpawner) {
this.creatureSpawner = creatureSpawner;
}
/**
* @return list of the banner patterns
* @since 1.8.0
*/
public List<Pattern> getBannerPatterns() {
return bannerPatterns;
}
/**
* @param bannerPatterns the banner Patterns to set
* @since 1.8.0
*/
public void setBannerPatterns(List<Pattern> bannerPatterns) {
this.bannerPatterns = bannerPatterns;
}
}

View File

@ -41,6 +41,9 @@ public class BlueprintEntity {
@Expose
private Style style;
/**
* @since 1.8.0
*/
public void configureEntity(Entity e) {
if (e instanceof Colorable) {
((Colorable) e).setColor(color);