mirror of
https://github.com/taoneill/war.git
synced 2025-01-05 07:17:34 +01:00
Magic wool block appears when hat clicked
This commit is contained in:
parent
c6c93ba44f
commit
a92b2ea4ae
@ -33,7 +33,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
@ -503,11 +502,7 @@ public class Warzone {
|
||||
}
|
||||
}
|
||||
if (this.getWarzoneConfig().getBoolean(WarzoneConfig.BLOCKHEADS)) {
|
||||
ItemStack helmet = new ItemStack(Material.LEATHER_HELMET);
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) helmet.getItemMeta();
|
||||
meta.setColor(team.getKind().getBukkitColor());
|
||||
helmet.setItemMeta(meta);
|
||||
playerInv.setHelmet(helmet);
|
||||
playerInv.setHelmet(team.getKind().getHat());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.material.Wool;
|
||||
import org.getspout.spoutapi.gui.Color;
|
||||
@ -189,4 +190,16 @@ public enum TeamKind {
|
||||
public String getFormattedName() {
|
||||
return this.getColor() + this.name().toLowerCase() + ChatColor.WHITE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a colored hat item for the team.
|
||||
* @return Hat item with the team's color.
|
||||
*/
|
||||
public ItemStack getHat() {
|
||||
ItemStack helmet = new ItemStack(Material.LEATHER_HELMET);
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) helmet.getItemMeta();
|
||||
meta.setColor(this.getBukkitColor());
|
||||
helmet.setItemMeta(meta);
|
||||
return helmet;
|
||||
}
|
||||
}
|
||||
|
@ -905,12 +905,16 @@ public class WarPlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
// Prevent thieves from taking their bomb/wool/cake into a chest, etc.
|
||||
if (zone.isThief(player.getName())
|
||||
// Prevent player from grabbing their block helmet
|
||||
|| event.getSlotType() == InventoryType.SlotType.ARMOR && event.getSlot() == 39
|
||||
&& zone.getWarzoneConfig().getBoolean(WarzoneConfig.BLOCKHEADS)) {
|
||||
if (zone.isThief(player.getName())) {
|
||||
event.setCancelled(true);
|
||||
player.playSound(player.getLocation(), Sound.FIZZ, 10, 10);
|
||||
} else // Magically give player a wool block when they click their helmet
|
||||
if (event.getSlotType() == InventoryType.SlotType.ARMOR && event.getSlot() == 39
|
||||
&& zone.getWarzoneConfig().getBoolean(WarzoneConfig.BLOCKHEADS)) {
|
||||
ItemStack teamBlock = zone.getPlayerTeam(player.getName()).getKind().getBlockHead();
|
||||
player.getInventory().remove(teamBlock.getType());
|
||||
event.setCursor(teamBlock);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,11 +37,7 @@ public class HelmetProtectionTask implements Runnable {
|
||||
teamBlockMaterial = team.getKind().getMaterial();
|
||||
// 1) Replace missing block head
|
||||
if (playerInv.getHelmet() == null || playerInv.getHelmet().getType() != Material.LEATHER_HELMET) {
|
||||
ItemStack helmet = new ItemStack(Material.LEATHER_HELMET);
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) helmet.getItemMeta();
|
||||
meta.setColor(team.getKind().getBukkitColor());
|
||||
helmet.setItemMeta(meta);
|
||||
playerInv.setHelmet(helmet);
|
||||
playerInv.setHelmet(team.getKind().getHat());
|
||||
}
|
||||
|
||||
// 2) Get rid of extra blocks in inventory: only keep one
|
||||
|
Loading…
Reference in New Issue
Block a user