mirror of
https://github.com/taoneill/war.git
synced 2025-01-20 14:21:19 +01:00
Fix some deprecated stuff
This commit is contained in:
parent
69a148fc6a
commit
4e83ffada1
@ -350,7 +350,6 @@ public class Team {
|
|||||||
private void setBlock(int x, int y, int z, TeamKind kind) {
|
private void setBlock(int x, int y, int z, TeamKind kind) {
|
||||||
BlockState block = this.warzone.getWorld().getBlockAt(x, y, z).getState();
|
BlockState block = this.warzone.getWorld().getBlockAt(x, y, z).getState();
|
||||||
block.setType(kind.getMaterial());
|
block.setType(kind.getMaterial());
|
||||||
block.setData(kind.getBlockData());
|
|
||||||
block.update(true);
|
block.update(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -616,7 +615,6 @@ public class Team {
|
|||||||
// flag
|
// flag
|
||||||
BlockState flagBlock = this.warzone.getWorld().getBlockAt(x, y + 1, z).getState();
|
BlockState flagBlock = this.warzone.getWorld().getBlockAt(x, y + 1, z).getState();
|
||||||
flagBlock.setType(this.kind.getMaterial());
|
flagBlock.setType(this.kind.getMaterial());
|
||||||
flagBlock.setData(this.kind.getBlockData());
|
|
||||||
flagBlock.update(true);
|
flagBlock.update(true);
|
||||||
|
|
||||||
// Flag post using Orientation
|
// Flag post using Orientation
|
||||||
|
@ -12,10 +12,7 @@ import com.tommytony.war.mapper.WarzoneYmlMapper;
|
|||||||
import com.tommytony.war.spout.SpoutDisplayer;
|
import com.tommytony.war.spout.SpoutDisplayer;
|
||||||
import com.tommytony.war.structure.*;
|
import com.tommytony.war.structure.*;
|
||||||
import com.tommytony.war.ui.UIManager;
|
import com.tommytony.war.ui.UIManager;
|
||||||
import com.tommytony.war.utility.Loadout;
|
import com.tommytony.war.utility.*;
|
||||||
import com.tommytony.war.utility.PlayerState;
|
|
||||||
import com.tommytony.war.utility.SizeCounter;
|
|
||||||
import com.tommytony.war.utility.WarLogFormatter;
|
|
||||||
import com.tommytony.war.volume.Volume;
|
import com.tommytony.war.volume.Volume;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -224,23 +221,19 @@ public class War extends JavaPlugin {
|
|||||||
this.getDefaultInventories().clearLoadouts();
|
this.getDefaultInventories().clearLoadouts();
|
||||||
HashMap<Integer, ItemStack> defaultLoadout = new HashMap<Integer, ItemStack>();
|
HashMap<Integer, ItemStack> defaultLoadout = new HashMap<Integer, ItemStack>();
|
||||||
|
|
||||||
ItemStack stoneSword = new ItemStack(Material.STONE_SWORD, 1, (byte) 8);
|
ItemStack stoneSword = Compat.createDamagedIS(Material.STONE_SWORD, 1, (byte) 8);
|
||||||
stoneSword.setDurability((short) 8);
|
|
||||||
defaultLoadout.put(0, stoneSword);
|
defaultLoadout.put(0, stoneSword);
|
||||||
|
|
||||||
ItemStack bow = new ItemStack(Material.BOW, 1, (byte) 8);
|
ItemStack bow = Compat.createDamagedIS(Material.BOW, 1, (byte) 8);
|
||||||
bow.setDurability((short) 8);
|
|
||||||
defaultLoadout.put(1, bow);
|
defaultLoadout.put(1, bow);
|
||||||
|
|
||||||
ItemStack arrows = new ItemStack(Material.ARROW, 7);
|
ItemStack arrows = new ItemStack(Material.ARROW, 7);
|
||||||
defaultLoadout.put(2, arrows);
|
defaultLoadout.put(2, arrows);
|
||||||
|
|
||||||
ItemStack stonePick = new ItemStack(Material.IRON_PICKAXE, 1, (byte) 8);
|
ItemStack stonePick = Compat.createDamagedIS(Material.IRON_PICKAXE, 1, (byte) 8);
|
||||||
stonePick.setDurability((short) 8);
|
|
||||||
defaultLoadout.put(3, stonePick);
|
defaultLoadout.put(3, stonePick);
|
||||||
|
|
||||||
ItemStack stoneSpade = new ItemStack(Material.STONE_SHOVEL, 1, (byte) 8);
|
ItemStack stoneSpade = Compat.createDamagedIS(Material.STONE_SHOVEL, 1, (byte) 8);
|
||||||
stoneSword.setDurability((short) 8);
|
|
||||||
defaultLoadout.put(4, stoneSpade);
|
defaultLoadout.put(4, stoneSpade);
|
||||||
|
|
||||||
this.getDefaultInventories().addLoadout("default", defaultLoadout);
|
this.getDefaultInventories().addLoadout("default", defaultLoadout);
|
||||||
|
@ -1123,7 +1123,7 @@ public class Warzone {
|
|||||||
return;
|
return;
|
||||||
if (this.getScoreboard() == null)
|
if (this.getScoreboard() == null)
|
||||||
return;
|
return;
|
||||||
if (this.scoreboard.getObjective(this.getScoreboardType().getDisplayName()) == null) {
|
if (this.scoreboard.getObjective(this.getScoreboardType().name()) == null) {
|
||||||
for (String entry : this.scoreboard.getEntries()) {
|
for (String entry : this.scoreboard.getEntries()) {
|
||||||
this.scoreboard.resetScores(entry);
|
this.scoreboard.resetScores(entry);
|
||||||
}
|
}
|
||||||
@ -1131,8 +1131,8 @@ public class Warzone {
|
|||||||
for (Objective obj : this.scoreboard.getObjectives()) {
|
for (Objective obj : this.scoreboard.getObjectives()) {
|
||||||
obj.unregister();
|
obj.unregister();
|
||||||
}
|
}
|
||||||
scoreboard.registerNewObjective(this.getScoreboardType().getDisplayName(), "dummy");
|
scoreboard.registerNewObjective(this.getScoreboardType().name(), "dummy", this.getScoreboardType().getDisplayName());
|
||||||
Objective obj = scoreboard.getObjective(this.getScoreboardType().getDisplayName());
|
Objective obj = scoreboard.getObjective(this.getScoreboardType().name());
|
||||||
Validate.isTrue(obj.isModifiable(), "Cannot modify players' scores on the " + this.name + " scoreboard.");
|
Validate.isTrue(obj.isModifiable(), "Cannot modify players' scores on the " + this.name + " scoreboard.");
|
||||||
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
}
|
}
|
||||||
|
@ -12,21 +12,21 @@ import org.getspout.spoutapi.gui.Color;
|
|||||||
|
|
||||||
public enum TeamKind {
|
public enum TeamKind {
|
||||||
WHITE (DyeColor.WHITE, Material.WHITE_WOOL, ChatColor.WHITE, 450),
|
WHITE (DyeColor.WHITE, Material.WHITE_WOOL, ChatColor.WHITE, 450),
|
||||||
ORANGE (DyeColor.ORANGE, Material.WHITE_WOOL, ChatColor.GOLD, 51),
|
ORANGE (DyeColor.ORANGE, Material.ORANGE_WOOL, ChatColor.GOLD, 51),
|
||||||
MAGENTA (DyeColor.MAGENTA, Material.WHITE_WOOL, ChatColor.LIGHT_PURPLE, 353),
|
MAGENTA (DyeColor.MAGENTA, Material.MAGENTA_WOOL, ChatColor.LIGHT_PURPLE, 353),
|
||||||
BLUE (DyeColor.LIGHT_BLUE, Material.WHITE_WOOL, ChatColor.BLUE, 23),
|
BLUE (DyeColor.LIGHT_BLUE, Material.LIGHT_BLUE_WOOL, ChatColor.BLUE, 23),
|
||||||
GOLD (DyeColor.YELLOW, Material.WHITE_WOOL, ChatColor.YELLOW, 403), // yellow = gold
|
GOLD (DyeColor.YELLOW, Material.YELLOW_WOOL, ChatColor.YELLOW, 403), // yellow = gold
|
||||||
GREEN (DyeColor.LIME, Material.WHITE_WOOL, ChatColor.GREEN, 612),
|
GREEN (DyeColor.LIME, Material.LIME_WOOL, ChatColor.GREEN, 612),
|
||||||
PINK (DyeColor.PINK, Material.WHITE_WOOL, ChatColor.LIGHT_PURPLE, 929),
|
PINK (DyeColor.PINK, Material.PINK_WOOL, ChatColor.LIGHT_PURPLE, 929),
|
||||||
GRAY (DyeColor.GRAY, Material.WHITE_WOOL, ChatColor.DARK_GRAY, 600),
|
GRAY (DyeColor.GRAY, Material.GRAY_WOOL, ChatColor.DARK_GRAY, 600),
|
||||||
IRON (DyeColor.GRAY, Material.WHITE_WOOL, ChatColor.GRAY, 154), // lightgrey = iron
|
IRON (DyeColor.GRAY, Material.GRAY_WOOL, ChatColor.GRAY, 154), // lightgrey = iron
|
||||||
DIAMOND (DyeColor.CYAN, Material.WHITE_WOOL, ChatColor.DARK_AQUA, 738), // cyan = diamond
|
DIAMOND (DyeColor.CYAN, Material.CYAN_WOOL, ChatColor.DARK_AQUA, 738), // cyan = diamond
|
||||||
PURPLE (DyeColor.PURPLE, Material.WHITE_WOOL, ChatColor.DARK_PURPLE, 153),
|
PURPLE (DyeColor.PURPLE, Material.PURPLE_WOOL, ChatColor.DARK_PURPLE, 153),
|
||||||
NAVY (DyeColor.BLUE, Material.WHITE_WOOL, ChatColor.DARK_BLUE, 939),
|
NAVY (DyeColor.BLUE, Material.BLUE_WOOL, ChatColor.DARK_BLUE, 939),
|
||||||
BROWN (DyeColor.BROWN, Material.WHITE_WOOL, ChatColor.DARK_RED, 908),
|
BROWN (DyeColor.BROWN, Material.BROWN_WOOL, ChatColor.DARK_RED, 908),
|
||||||
DARKGREEN (DyeColor.GREEN, Material.WHITE_WOOL, ChatColor.DARK_GREEN, 612),
|
DARKGREEN (DyeColor.GREEN, Material.GREEN_WOOL, ChatColor.DARK_GREEN, 612),
|
||||||
RED (DyeColor.RED, Material.WHITE_WOOL, ChatColor.RED, 245),
|
RED (DyeColor.RED, Material.RED_WOOL, ChatColor.RED, 245),
|
||||||
BLACK (DyeColor.BLACK, Material.WHITE_WOOL, ChatColor.BLACK, 0);
|
BLACK (DyeColor.BLACK, Material.BLACK_WOOL, ChatColor.BLACK, 0);
|
||||||
|
|
||||||
private final DyeColor dyeColor;
|
private final DyeColor dyeColor;
|
||||||
private final ChatColor chatColor;
|
private final ChatColor chatColor;
|
||||||
@ -61,23 +61,13 @@ public enum TeamKind {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get wool block data for the dye color.
|
* Get wool block data for the dye color.
|
||||||
*
|
* @deprecated TODO remove all spout craft support
|
||||||
* @return wool color data value
|
* @return wool color data value
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public byte getData() {
|
public byte getData() {
|
||||||
return this.dyeColor.getWoolData();
|
return this.dyeColor.getWoolData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the color of the wool head block.
|
|
||||||
*
|
|
||||||
* @return head wool color.
|
|
||||||
*/
|
|
||||||
public DyeColor getDyeColor() {
|
|
||||||
return this.dyeColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the color of this team in chat messages.
|
* Get the color of this team in chat messages.
|
||||||
*
|
*
|
||||||
@ -108,7 +98,7 @@ public enum TeamKind {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get head block material. Should always be {@link Material#WOOL}.
|
* Get head block material.
|
||||||
*
|
*
|
||||||
* @return team head block material.
|
* @return team head block material.
|
||||||
*/
|
*/
|
||||||
@ -131,22 +121,12 @@ public enum TeamKind {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a single item of this team's wool head block. Creates a single block
|
* Get a single item of this team's wool head block.
|
||||||
* with data from {@link #getBlockData()}.
|
|
||||||
*
|
*
|
||||||
* @return single block head item.
|
* @return single block head item.
|
||||||
*/
|
*/
|
||||||
public ItemStack getBlockHead() {
|
public ItemStack getBlockHead() {
|
||||||
return new Wool(this.dyeColor).toItemStack(1);
|
return new ItemStack(this.material, 1);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get wool head block data (for creating blocks).
|
|
||||||
*
|
|
||||||
* @return wool head block data.
|
|
||||||
*/
|
|
||||||
public MaterialData getBlockData() {
|
|
||||||
return new Wool(this.dyeColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -156,11 +136,7 @@ public enum TeamKind {
|
|||||||
* @return true if block is this team's color.
|
* @return true if block is this team's color.
|
||||||
*/
|
*/
|
||||||
public boolean isTeamBlock(BlockState block) {
|
public boolean isTeamBlock(BlockState block) {
|
||||||
if (block.getType() != Material.WHITE_WOOL || !(block.getData() instanceof Wool)) {
|
return block.getType() == material;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Wool wool = (Wool) block.getData();
|
|
||||||
return wool.getColor() == dyeColor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -170,21 +146,7 @@ public enum TeamKind {
|
|||||||
* @return true if item is this team's color.
|
* @return true if item is this team's color.
|
||||||
*/
|
*/
|
||||||
public boolean isTeamItem(ItemStack item) {
|
public boolean isTeamItem(ItemStack item) {
|
||||||
if (item.getType() != Material.WHITE_WOOL || !(item.getData() instanceof Wool)) {
|
return item.getType() == material;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Wool wool = (Wool) item.getData();
|
|
||||||
return wool.getColor() == dyeColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a block data is this team's block data.
|
|
||||||
*
|
|
||||||
* @param data Wool block data.
|
|
||||||
* @return true if data is this team's data.
|
|
||||||
*/
|
|
||||||
public boolean isTeamBlock(MaterialData data) {
|
|
||||||
return data instanceof Wool && ((Wool)data).getColor() == this.dyeColor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFormattedName() {
|
public String getFormattedName() {
|
||||||
|
@ -1,30 +1,5 @@
|
|||||||
package com.tommytony.war.event;
|
package com.tommytony.war.event;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
|
||||||
import org.bukkit.event.block.BlockBurnEvent;
|
|
||||||
import org.bukkit.event.block.BlockDamageEvent;
|
|
||||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
|
||||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
import org.bukkit.event.world.StructureGrowEvent;
|
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.getspout.spoutapi.SpoutManager;
|
|
||||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
|
||||||
|
|
||||||
import com.tommytony.war.Team;
|
import com.tommytony.war.Team;
|
||||||
import com.tommytony.war.War;
|
import com.tommytony.war.War;
|
||||||
import com.tommytony.war.Warzone;
|
import com.tommytony.war.Warzone;
|
||||||
@ -35,6 +10,26 @@ import com.tommytony.war.spout.SpoutDisplayer;
|
|||||||
import com.tommytony.war.structure.Bomb;
|
import com.tommytony.war.structure.Bomb;
|
||||||
import com.tommytony.war.structure.Cake;
|
import com.tommytony.war.structure.Cake;
|
||||||
import com.tommytony.war.structure.Monument;
|
import com.tommytony.war.structure.Monument;
|
||||||
|
import com.tommytony.war.utility.Compat;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.*;
|
||||||
|
import org.bukkit.event.world.StructureGrowEvent;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.getspout.spoutapi.SpoutManager;
|
||||||
|
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -58,9 +53,7 @@ public class WarBlockListener implements Listener {
|
|||||||
Team team = Team.getTeamByPlayerName(player.getName());
|
Team team = Team.getTeamByPlayerName(player.getName());
|
||||||
Warzone zone = Warzone.getZoneByLocation(player);
|
Warzone zone = Warzone.getZoneByLocation(player);
|
||||||
// Monument capturing
|
// Monument capturing
|
||||||
if (team != null && block != null && zone != null
|
if (team != null && zone != null && zone.isMonumentCenterBlock(block) && team.getKind().isTeamBlock(block.getState())) {
|
||||||
&& zone.isMonumentCenterBlock(block)
|
|
||||||
&& team.getKind().isTeamBlock(block.getState())) {
|
|
||||||
Monument monument = zone.getMonumentFromCenterBlock(block);
|
Monument monument = zone.getMonumentFromCenterBlock(block);
|
||||||
if (monument != null && !monument.hasOwner()) {
|
if (monument != null && !monument.hasOwner()) {
|
||||||
monument.capture(team);
|
monument.capture(team);
|
||||||
@ -89,9 +82,7 @@ public class WarBlockListener implements Listener {
|
|||||||
|
|
||||||
boolean isZoneMaker = War.war.isZoneMaker(player);
|
boolean isZoneMaker = War.war.isZoneMaker(player);
|
||||||
// prevent build in important parts
|
// prevent build in important parts
|
||||||
if (zone != null
|
if (zone != null && (zone.isImportantBlock(block) || zone.isOpponentSpawnPeripheryBlock(team, block)) && (!isZoneMaker || team != null)) {
|
||||||
&& (zone.isImportantBlock(block) || zone.isOpponentSpawnPeripheryBlock(team, block))
|
|
||||||
&& (!isZoneMaker || (isZoneMaker && team != null))) {
|
|
||||||
War.war.badMsg(player, "build.denied.location");
|
War.war.badMsg(player, "build.denied.location");
|
||||||
cancelAndKeepItem(event);
|
cancelAndKeepItem(event);
|
||||||
return;
|
return;
|
||||||
@ -123,7 +114,7 @@ public class WarBlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// can't place a block of your team's color
|
// can't place a block of your team's color
|
||||||
if (team != null && block.getType() == team.getKind().getMaterial() && block.getState().getData() == team.getKind().getBlockData()) {
|
if (team != null && block.getType() == team.getKind().getMaterial()) {
|
||||||
War.war.badMsg(player, "build.denied.teamblock");
|
War.war.badMsg(player, "build.denied.teamblock");
|
||||||
cancelAndKeepItem(event);
|
cancelAndKeepItem(event);
|
||||||
return;
|
return;
|
||||||
@ -151,9 +142,7 @@ public class WarBlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// unbreakableZoneBlocks
|
// unbreakableZoneBlocks
|
||||||
if (zone != null && (zone.getWarzoneConfig().getBoolean(WarzoneConfig.UNBREAKABLE)
|
if (zone != null && (zone.getWarzoneConfig().getBoolean(WarzoneConfig.UNBREAKABLE) || team != null && !team.getTeamConfig().resolveBoolean(TeamConfig.PLACEBLOCK)) && (!isZoneMaker || team != null)) {
|
||||||
|| (team != null && !team.getTeamConfig().resolveBoolean(TeamConfig.PLACEBLOCK)))
|
|
||||||
&& (!isZoneMaker || (isZoneMaker && team != null))) {
|
|
||||||
// if the zone is unbreakable, no one but zone makers can break blocks (even then, zone makers in a team can't break blocks)
|
// if the zone is unbreakable, no one but zone makers can break blocks (even then, zone makers in a team can't break blocks)
|
||||||
War.war.badMsg(player, "build.denied.zone.place");
|
War.war.badMsg(player, "build.denied.zone.place");
|
||||||
cancelAndKeepItem(event);
|
cancelAndKeepItem(event);
|
||||||
@ -175,7 +164,7 @@ public class WarBlockListener implements Listener {
|
|||||||
if (inHand.getType() == Material.FIRE) {
|
if (inHand.getType() == Material.FIRE) {
|
||||||
// Weird bukkit/mc behavior where item in hand is reported as fire while using flint & steel.
|
// Weird bukkit/mc behavior where item in hand is reported as fire while using flint & steel.
|
||||||
// Just give the user his f&s back but almost broken (max durability is 8).
|
// Just give the user his f&s back but almost broken (max durability is 8).
|
||||||
newItemInHand = new ItemStack(Material.FLINT_AND_STEEL, 1, (short)1);
|
newItemInHand = Compat.createDamagedIS(Material.FLINT_AND_STEEL, 1, 1);
|
||||||
} else {
|
} else {
|
||||||
newItemInHand = inHand.clone();
|
newItemInHand = inHand.clone();
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
import org.bukkit.event.player.*;
|
import org.bukkit.event.player.*;
|
||||||
@ -170,12 +171,15 @@ public class WarPlayerListener implements Listener {
|
|||||||
|
|
||||||
private static final int MINIMUM_TEAM_BLOCKS = 1;
|
private static final int MINIMUM_TEAM_BLOCKS = 1;
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerPickupItem(final PlayerPickupItemEvent event) {
|
public void onPlayerPickupItem(final EntityPickupItemEvent event) {
|
||||||
if (War.war.isLoaded()) {
|
if (War.war.isLoaded()) {
|
||||||
Player player = event.getPlayer();
|
if (!(event.getEntity() instanceof Player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Player player = (Player) event.getEntity();
|
||||||
Team team = Team.getTeamByPlayerName(player.getName());
|
Team team = Team.getTeamByPlayerName(player.getName());
|
||||||
if (team != null) {
|
if (team != null) {
|
||||||
Warzone zone = Warzone.getZoneByPlayerName(player.getName());
|
Warzone zone = team.getZone();
|
||||||
|
|
||||||
if (zone.isFlagThief(player)) {
|
if (zone.isFlagThief(player)) {
|
||||||
// a flag thief can't pick up anything
|
// a flag thief can't pick up anything
|
||||||
|
@ -44,7 +44,7 @@ public class HelmetProtectionTask implements Runnable {
|
|||||||
int removed = 0;
|
int removed = 0;
|
||||||
for (ItemStack item : playerInv.getContents()) {
|
for (ItemStack item : playerInv.getContents()) {
|
||||||
// remove only same colored wool
|
// remove only same colored wool
|
||||||
if (item != null && item.getType() == teamBlockMaterial && item.getData() == team.getKind().getBlockData()) {
|
if (item != null && item.getType() == teamBlockMaterial) {
|
||||||
playerInv.clear(i);
|
playerInv.clear(i);
|
||||||
removed++;
|
removed++;
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ public class HelmetProtectionTask implements Runnable {
|
|||||||
player.getInventory().setItemInMainHand(null);
|
player.getInventory().setItemInMainHand(null);
|
||||||
player.getInventory().setItemInOffHand(null);
|
player.getInventory().setItemInOffHand(null);
|
||||||
player.getInventory().setHeldItemSlot(0);
|
player.getInventory().setHeldItemSlot(0);
|
||||||
player.getInventory().addItem(victim.getKind().getBlockData().toItemStack(2240));
|
player.getInventory().addItem(new ItemStack(victim.getKind().getMaterial(), 2240));
|
||||||
} else if (zone.isBombThief(player)) {
|
} else if (zone.isBombThief(player)) {
|
||||||
player.getInventory().setItemInMainHand(null);
|
player.getInventory().setItemInMainHand(null);
|
||||||
player.getInventory().setItemInOffHand(null);
|
player.getInventory().setItemInOffHand(null);
|
||||||
|
@ -538,6 +538,7 @@ public class ZoneVolumeMapper {
|
|||||||
// TODO upgrade to store owning player by UUID
|
// TODO upgrade to store owning player by UUID
|
||||||
dataStmt.setString(6, String.format("%s\n%s\n%s",
|
dataStmt.setString(6, String.format("%s\n%s\n%s",
|
||||||
((Skull) block.getState()).hasOwner() ? ((Skull) block.getState()).getOwningPlayer().getName() : "",
|
((Skull) block.getState()).hasOwner() ? ((Skull) block.getState()).getOwningPlayer().getName() : "",
|
||||||
|
// TODO remove deprecation when Spigot updates their docs about the replacement
|
||||||
((Skull) block.getState()).getSkullType().toString(),
|
((Skull) block.getState()).getSkullType().toString(),
|
||||||
((Skull) block.getState()).getRotation().toString()));
|
((Skull) block.getState()).getRotation().toString()));
|
||||||
} else if (state instanceof CommandBlock) {
|
} else if (state instanceof CommandBlock) {
|
||||||
|
@ -106,7 +106,6 @@ public class CapturePoint {
|
|||||||
1 + Math.round(Math.cos(Math.toRadians(location.getYaw()))));
|
1 + Math.round(Math.cos(Math.toRadians(location.getYaw()))));
|
||||||
BlockState state = origin.clone().add(dir).getBlock().getState();
|
BlockState state = origin.clone().add(dir).getBlock().getState();
|
||||||
state.setType(controller.getMaterial());
|
state.setType(controller.getMaterial());
|
||||||
state.setData(controller.getBlockData());
|
|
||||||
state.update(true);
|
state.update(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public class EditZoneConfigUI extends ChestUI {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
i = UIConfigHelper.addWarzoneConfigOptions(this, player, inv, zone.getWarzoneConfig(), zone, i);
|
i = UIConfigHelper.addWarzoneConfigOptions(this, player, inv, zone.getWarzoneConfig(), zone, i);
|
||||||
item = new ItemStack(Material.LEGACY_STAINED_GLASS_PANE);
|
item = new ItemStack(Material.WHITE_STAINED_GLASS_PANE);
|
||||||
meta = item.getItemMeta();
|
meta = item.getItemMeta();
|
||||||
meta.setDisplayName(">>>> Team Default Config >>>>");
|
meta.setDisplayName(">>>> Team Default Config >>>>");
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
|
@ -19,7 +19,7 @@ public class WarAdminUI extends ChestUI {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
i = UIConfigHelper.addWarConfigOptions(this, player, inv, War.war.getWarConfig(), i);
|
i = UIConfigHelper.addWarConfigOptions(this, player, inv, War.war.getWarConfig(), i);
|
||||||
item = new ItemStack(Material.LEGACY_STAINED_GLASS_PANE);
|
item = new ItemStack(Material.WHITE_STAINED_GLASS_PANE);
|
||||||
meta = item.getItemMeta();
|
meta = item.getItemMeta();
|
||||||
meta.setDisplayName(">>>> Warzone Default Config >>>>");
|
meta.setDisplayName(">>>> Warzone Default Config >>>>");
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
@ -30,7 +30,7 @@ public class WarAdminUI extends ChestUI {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
i = UIConfigHelper.addWarzoneConfigOptions(this, player, inv, War.war.getWarzoneDefaultConfig(), null, i);
|
i = UIConfigHelper.addWarzoneConfigOptions(this, player, inv, War.war.getWarzoneDefaultConfig(), null, i);
|
||||||
item = new ItemStack(Material.LEGACY_STAINED_GLASS_PANE);
|
item = new ItemStack(Material.WHITE_STAINED_GLASS_PANE);
|
||||||
meta = item.getItemMeta();
|
meta = item.getItemMeta();
|
||||||
meta.setDisplayName(">>>> Team Default Config >>>>");
|
meta.setDisplayName(">>>> Team Default Config >>>>");
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
|
19
war/src/main/java/com/tommytony/war/utility/Compat.java
Normal file
19
war/src/main/java/com/tommytony/war/utility/Compat.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package com.tommytony.war.utility;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.Damageable;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple fixes to account for removed Bukkit functionality
|
||||||
|
*/
|
||||||
|
public class Compat {
|
||||||
|
public static ItemStack createDamagedIS(Material mat, int amount, int damage) {
|
||||||
|
ItemStack is = new ItemStack(mat, amount);
|
||||||
|
ItemMeta meta = is.getItemMeta();
|
||||||
|
((Damageable) meta).setDamage(damage); // hope this works
|
||||||
|
is.setItemMeta(meta);
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user