From 3ce14d208591ab7114eacd839aea27c00cdcd892 Mon Sep 17 00:00:00 2001 From: ProSavage Date: Fri, 11 May 2018 18:11:02 -0500 Subject: [PATCH] Finished up setbanner command and colored the meta and display name for the serialized banners --- .../massivecraft/factions/cmd/CmdBanner.java | 4 +- .../massivecraft/factions/cmd/FCmdRoot.java | 4 +- .../listeners/FactionsEntityListener.java | 86 +++++++++---------- 3 files changed, 48 insertions(+), 46 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdBanner.java b/src/main/java/com/massivecraft/factions/cmd/CmdBanner.java index 1d41576f..25e4a61b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdBanner.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdBanner.java @@ -46,8 +46,8 @@ public class CmdBanner extends FCommand { ItemStack warBanner = fme.getFaction().getBanner(); if (warBanner != null) { ItemMeta warmeta = warBanner.getItemMeta(); - warmeta.setDisplayName(P.p.getConfig().getString("fbanners.Item.Name")); - warmeta.setLore(P.p.getConfig().getStringList("fbanners.Item.Lore")); + warmeta.setDisplayName(P.p.color(P.p.getConfig().getString("fbanners.Item.Name"))); + warmeta.setLore(P.p.colorList(P.p.getConfig().getStringList("fbanners.Item.Lore"))); warBanner.setItemMeta(warmeta); me.getInventory().addItem(warBanner); diff --git a/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java b/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java index 047d44aa..ea0619a4 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java +++ b/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java @@ -99,7 +99,7 @@ public class FCmdRoot extends FCommand { public CmdLowPower cmdLowPower = new CmdLowPower(); public CmdTntFill cmdTntFill = new CmdTntFill(); public CmdChest cmdChest = new CmdChest(); - + public CmdSetBanner cmdSetBanner = new CmdSetBanner(); public FCmdRoot() { @@ -210,6 +210,8 @@ public class FCmdRoot extends FCommand { this.addSubCommand(this.cmdLowPower); this.addSubCommand(this.cmdTntFill); this.addSubCommand(this.cmdChest); + this.addSubCommand(this.cmdSetBanner); + if (Bukkit.getServer().getPluginManager().getPlugin("CoreProtect") != null){ P.p.log("Found CoreProtect, enabling Inspect"); diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java index 060a4dcc..3a80dc09 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java @@ -204,55 +204,55 @@ public class FactionsEntityListener implements Listener { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onEntityExplode(EntityExplodeEvent event) { - Entity boomer = event.getEntity(); + Entity boomer = event.getEntity(); - // Before we need to check the location where the block is placed - if (!this.checkExplosionForBlock(boomer, event.getLocation().getBlock())) { - event.setCancelled(true); - return; - } + // Before we need to check the location where the block is placed + if (!this.checkExplosionForBlock(boomer, event.getLocation().getBlock())) { + event.setCancelled(true); + return; + } - // Loop the blocklist to run checks on each aimed block - Iterator blockList = event.blockList().iterator(); + // Loop the blocklist to run checks on each aimed block + Iterator blockList = event.blockList().iterator(); - while (blockList.hasNext()) { - Block block = blockList.next(); + while (blockList.hasNext()) { + Block block = blockList.next(); - if (!this.checkExplosionForBlock(boomer, block)) { - // The block don't have to explode - blockList.remove(); - } - } + if (!this.checkExplosionForBlock(boomer, block)) { + // The block don't have to explode + blockList.remove(); + } + } - // Cancel the event if no block will explode - if (event.blockList().isEmpty()) { - event.setCancelled(true); + // Cancel the event if no block will explode + if (event.blockList().isEmpty()) { + event.setCancelled(true); - // Or handle the exploit of TNT in water/lava - } else if ((boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) && Conf.handleExploitTNTWaterlog) { - // TNT in water/lava doesn't normally destroy any surrounding blocks, which is usually desired behavior, but... - // this change below provides workaround for waterwalling providing perfect protection, - // and makes cheap (non-obsidian) TNT cannons require minor maintenance between shots - Block center = event.getLocation().getBlock(); + // Or handle the exploit of TNT in water/lava + } else if ((boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) && Conf.handleExploitTNTWaterlog) { + // TNT in water/lava doesn't normally destroy any surrounding blocks, which is usually desired behavior, but... + // this change below provides workaround for waterwalling providing perfect protection, + // and makes cheap (non-obsidian) TNT cannons require minor maintenance between shots + Block center = event.getLocation().getBlock(); - if (center.isLiquid()) { - // a single surrounding block in all 6 directions is broken if the material is weak enough - List targets = new ArrayList<>(); - targets.add(center.getRelative(0, 0, 1)); - targets.add(center.getRelative(0, 0, -1)); - targets.add(center.getRelative(0, 1, 0)); - targets.add(center.getRelative(0, -1, 0)); - targets.add(center.getRelative(1, 0, 0)); - targets.add(center.getRelative(-1, 0, 0)); - for (Block target : targets) { - int id = target.getTypeId(); - // ignore air, bedrock, water, lava, obsidian, enchanting table, etc.... too bad we can't get a blast resistance value through Bukkit yet - if (id != 0 && (id < 7 || id > 11) && id != 49 && id != 90 && id != 116 && id != 119 && id != 120 && id != 130) { - target.breakNaturally(); - } - } - } - } + if (center.isLiquid()) { + // a single surrounding block in all 6 directions is broken if the material is weak enough + List targets = new ArrayList<>(); + targets.add(center.getRelative(0, 0, 1)); + targets.add(center.getRelative(0, 0, -1)); + targets.add(center.getRelative(0, 1, 0)); + targets.add(center.getRelative(0, -1, 0)); + targets.add(center.getRelative(1, 0, 0)); + targets.add(center.getRelative(-1, 0, 0)); + for (Block target : targets) { + int id = target.getTypeId(); + // ignore air, bedrock, water, lava, obsidian, enchanting table, etc.... too bad we can't get a blast resistance value through Bukkit yet + if (id != 0 && (id < 7 || id > 11) && id != 49 && id != 90 && id != 116 && id != 119 && id != 120 && id != 130) { + target.breakNaturally(); + } + } + } + } } private boolean checkExplosionForBlock(Entity boomer, Block block) { @@ -710,4 +710,4 @@ public class FactionsEntityListener implements Listener { return false; } -} +} \ No newline at end of file