hub Update

fixed bad gameid
This commit is contained in:
Mini-Chiss 2015-08-08 13:47:09 +02:00
parent eab7aa59f2
commit 328c31de88
12 changed files with 745 additions and 63 deletions

View File

@ -44,6 +44,9 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.Item))
{
if (gadget.GetCost(CurrencyType.Coins) == -3)
continue;
addGadget(gadget, slot);
if (getPlugin().getInventoryManager().Get(getPlayer()).getItemCount(gadget.GetDisplayName()) > 0)
@ -88,6 +91,11 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
{
itemLore.add(C.cGold + "Found in Treasure Chests.");
}
else if (gadget.GetCost(CurrencyType.Coins) == -3)
{
}
itemLore.add(C.cBlack);
itemLore.addAll(Arrays.asList(gadget.GetDescription()));

View File

@ -96,6 +96,7 @@ public class GadgetManager extends MiniPlugin
addGadget(new ItemBatGun(this));
addGadget(new ItemCoinBomb(this));
addGadget(new ItemPaintbrush(this));
addGadget(new ItemDuelingSword(this));
// Costume
addGadget(new OutfitRaveSuit(this, "Rave Hat", -2, ArmorSlot.Helmet, Material.LEATHER_HELMET, (byte)0));

View File

@ -1,66 +1,48 @@
package mineplex.core.gadget.gadgets;
import java.util.HashSet;
import org.bukkit.Material;
import org.bukkit.entity.Bat;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.itemstack.ItemStackFactory;
public class ItemDuelingSword extends ItemGadget
{
public ItemDuelingSword(GadgetManager manager)
{
super(manager, "Dueling Sword", new String[]
super(manager, "PvP Sword", new String[]
{
C.cWhite + "While active, you are able to fight",
C.cWhite + "against other people who are also",
C.cWhite + "wielding a dueling sword.",
C.cGreen + "Activated in King of the Hill",
},
-1,
Material.WOOD_SWORD, (byte)3,
-3,
Material.GOLD_SWORD, (byte)0,
1000, new Ammo("Dueling Sword", "10 Swords", Material.WOOD_SWORD, (byte)0, new String[] { C.cWhite + "10 Swords to duel with" }, 1000, 10));
}
@Override
public void ApplyItem(Player player, boolean inform)
{
Manager.RemoveItem(player);
_active.add(player);
player.getInventory().setItem(Manager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte)0, 1, "PvP Sword"));
}
@Override
@EventHandler
public void Activate(PlayerInteractEvent event)
{
}
@Override
public void ActivateCustom(Player player)
{
ItemStack stack = new ItemStack(Material.GOLD_SWORD);
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName("Dueling Sword");
stack.setItemMeta(meta);
{
player.getInventory().setItem(Manager.getActiveItemSlot(), stack);
//Inform
UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + "."));
}
@EventHandler(priority = EventPriority.HIGHEST)
public void damage(EntityDamageByEntityEvent event)
{
if (!(event.getEntity() instanceof Player) || !(event.getDamager() instanceof Player))
return;
Player damager = (Player)event.getDamager();
Player damagee = (Player)event.getEntity();
if (!UtilGear.isMat(damager.getItemInHand(), Material.GOLD_SWORD) || !UtilGear.isMat(damagee.getItemInHand(), Material.GOLD_SWORD))
return;
event.setCancelled(false);
event.setDamage(4);
}
}

View File

@ -0,0 +1,5 @@
package mineplex.core.gadget.gadgets;
public class ItemKothSword {
}

View File

@ -41,9 +41,9 @@ public class ItemPaintbrush extends ItemGadget
{
C.cWhite + "Unleash your inner creativity!",
C.cWhite + "",
C.cWhite + "Click a Painter NPC to equip this.",
C.cGreen + "Activated at a Painter NPC",
},
-2,
-3,
Material.WOOD_SWORD, (byte)0,
200, new Ammo("Paint", "100 Pixels", Material.INK_SACK, (byte)0, new String[] { C.cWhite + "100 Pixels worth of Paint!" }, 500, 100));
}
@ -100,11 +100,11 @@ public class ItemPaintbrush extends ItemGadget
{
if (!IsActive(event.getPlayer()))
return;
if (!UtilEvent.isAction(event, ActionType.L))
return;
Player player = event.getPlayer();
if (!UtilGear.isMat(player.getItemInHand(), Material.WOOD_SWORD))
return;
Block block = player.getTargetBlock(null, 100);
if (block == null || block.getType() != Material.STAINED_CLAY)

View File

@ -146,7 +146,7 @@ public class MorphWither extends MorphGadget
{
WitherSkull skull = skullIterator.next();
if (!skull.isValid())
if (!skull.isValid() || skull.getTicksLived() > 60)
{
skullIterator.remove();
skull.remove();

View File

@ -71,6 +71,18 @@ public class OutfitTeam extends OutfitGadget
else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots(
ItemStackFactory.Instance.CreateStack(GetDisplayMaterial().getId(), GetDisplayData(), 1, GetName()));
}
@Override
public void RemoveArmor(Player player)
{
if (!_active.remove(player))
return;
if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet(null);
else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate(null);
else if (_slot == ArmorSlot.Legs) player.getInventory().setLeggings(null);
else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots(null);
}
@Override
public void EnableCustom(Player player)
@ -90,7 +102,7 @@ public class OutfitTeam extends OutfitGadget
{
Player player = event.getPlayer();
if (!event.getMessage().toLowerCase().startsWith("/team "))
if (!event.getMessage().toLowerCase().startsWith("/team"))
return;
event.setCancelled(true);
@ -98,11 +110,24 @@ public class OutfitTeam extends OutfitGadget
String[] args = event.getMessage().toLowerCase().split(" ");
if (args.length < 2)
{
Disable(player);
return;
}
//Will only display the message once
if (GetSlot() == ArmorSlot.Legs)
{
if (!Recharge.Instance.use(player, "Set Team Color", 20000, true, false))
return;
}
else
{
if (!Recharge.Instance.use(player, "Set Team Color " + GetSlot(), 20000, false, false))
return;
}
if (!Recharge.Instance.use(player, "Set Team Color", 20000, true, false))
return;
//Color
if (args[1].equals("red"))
{
@ -132,6 +157,8 @@ public class OutfitTeam extends OutfitGadget
if (GetSlot() == ArmorSlot.Legs) //Only Display Once
UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(C.cAqua + "Blue Team Outfit") + "!"));
}
else
return;
colorArmor(player);

View File

@ -27,7 +27,7 @@ public enum GameDisplay
HideSeek("Block Hunt", Material.GRASS, (byte)0, GameCategory.CLASSICS, 20),
HoleInTheWall("Hole in the Wall", Material.STAINED_GLASS, (byte) 2, GameCategory.ARCADE, 52),
Horse("Horseback", Material.IRON_BARDING, (byte)0, GameCategory.ARCADE, 21),
Lobbers("Bomb Lobbers", Material.FIREBALL, (byte) 0, GameCategory.ARCADE, 53),
Micro("Micro Battle", Material.LAVA_BUCKET, (byte)0, GameCategory.ARCADE, 24),
MilkCow("Milk the Cow", Material.MILK_BUCKET, (byte)0, GameCategory.ARCADE, 27),
MineStrike("MineStrike", Material.TNT, (byte)0, GameCategory.CHAMPIONS, 25),// Temp set to CHAMPIONS to fix UI bug
@ -63,6 +63,8 @@ public enum GameDisplay
Cards("Craft Against Humanity", Material.MAP, (byte)0, GameCategory.CLASSICS, 51),
Skywars("Skywars", Material.FEATHER, (byte) 0, GameCategory.SURVIVAL, 52),
SkywarsTeams("Skywars Teams", "Skywars", Material.FEATHER, (byte)0, GameCategory.TEAM_VARIANT, 53),
Lobbers("Bomb Lobbers", Material.FIREBALL, (byte) 0, GameCategory.ARCADE, 54),
Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999);

View File

@ -55,6 +55,7 @@ import mineplex.hub.commands.NewsCommand;
import mineplex.hub.modules.ForcefieldManager;
import mineplex.hub.modules.HubVisibilityManager;
import mineplex.hub.modules.JumpManager;
import mineplex.hub.modules.KothManager;
import mineplex.hub.modules.NewsManager;
import mineplex.hub.modules.ParkourManager;
import mineplex.hub.modules.SoccerManager;
@ -184,6 +185,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager);
new SoccerManager(this, _gadgetManager);
new KothManager(this, _gadgetManager);
_petManager = petManager;
_partyManager = partyManager;
@ -600,14 +602,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
}
}
@EventHandler
public void PlayerDeath(PlayerDeathEvent event)
{
//XXX make this work > event.setKeepInventory(true);
event.getDrops().clear();
}
@EventHandler
public void PlayerQuit(PlayerQuitEvent event)
{
@ -734,6 +728,14 @@ public class HubManager extends MiniClientPlugin<HubClient>
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOWEST)
public void handleDeath(PlayerDeathEvent event)
{
event.setKeepInventory(true);
event.getDrops().clear();
event.getEntity().setHealth(20);
event.getEntity().teleport(GetSpawn());
}
@EventHandler
public void FoodHealthUpdate(UpdateEvent event)

View File

@ -0,0 +1,266 @@
package mineplex.hub.modules;
import java.util.ArrayList;
import java.util.HashSet;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetActivateEvent;
import mineplex.core.gadget.gadgets.ItemDuelingSword;
import mineplex.core.gadget.gadgets.OutfitTeam;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.mount.event.MountActivateEvent;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.HubManager;
import mineplex.hub.modules.koth.CapturePoint;
public class KothManager extends MiniPlugin
{
public HubManager Manager;
private HashSet<Player> _active = new HashSet<Player>();
private ArrayList<OutfitTeam> _teamArmor = new ArrayList<OutfitTeam>();
private ItemDuelingSword _kothSword;
private Location _cornerPlayerA;
private Location _cornerPlayerB;
private Location _cornerHillA;
private Location _cornerHillB;
private CapturePoint _cp;
Color _hillOwner = null;
long _hillOwnTime = 0;
public KothManager(HubManager manager, GadgetManager gadgets)
{
super("KOTH Manager", manager.getPlugin());
Manager = manager;
_cornerPlayerA = new Location(Manager.GetSpawn().getWorld(), -52.5,0,-23.5);
_cornerPlayerB = new Location(Manager.GetSpawn().getWorld(), -133.5,200,80.5);
_cornerHillA = new Location(Manager.GetSpawn().getWorld(), -88.5,60,47.5);
_cornerHillB = new Location(Manager.GetSpawn().getWorld(), -102.5,80,61.5);
_cp = new CapturePoint(this, "Desert Pyramid", new Location(Manager.GetSpawn().getWorld(), -95.5,72,54.5));
//Store Gadgets
for (Gadget gadget : gadgets.getGadgets(GadgetType.Costume))
{
if (gadget instanceof OutfitTeam)
{
_teamArmor.add((OutfitTeam)gadget);
}
}
for (Gadget gadget : gadgets.getGadgets(GadgetType.Item))
{
if (gadget instanceof ItemDuelingSword)
{
_kothSword = (ItemDuelingSword)gadget;
}
}
}
@EventHandler
public void cpUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
_cp.captureUpdate();
}
public Color getTeamColor(Player player)
{
//All peices are always same color!
for (OutfitTeam outfit : _teamArmor)
{
return outfit.getTeamColor(player);
}
return null;
}
public boolean inPlayerArena(Entity entity)
{
return UtilAlg.inBoundingBox(entity.getLocation(), _cornerPlayerA, _cornerPlayerB);
}
@EventHandler
public void joinLeaveGame(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player player : UtilServer.getPlayers())
{
if (_active.contains(player))
{
if (!inPlayerArena(player))
{
setKOTHMode(player, false, null);
continue;
}
//Took armor off
Color color = getTeamColor(player);
if (color == null)
{
setKOTHMode(player, false, null);
}
}
else
{
if (inPlayerArena(player))
{
Color color = getTeamColor(player);
//Join
if (color != null)
{
setKOTHMode(player, true, color);
continue;
}
//Eject
else if (UtilAlg.inBoundingBox(player.getLocation(), _cornerHillA, _cornerHillB))
{
Location bounce = UtilAlg.getMidpoint(_cornerHillA, _cornerHillB);
bounce.setY(Math.min(_cornerHillA.getY(), _cornerHillB.getY()));
Entity bottom = player;
if (bottom.getVehicle() != null)
bottom = bottom.getVehicle();
UtilAction.velocity(bottom, UtilAlg.getTrajectory(bounce, player.getLocation()), 1, false, 0, 0.4, 1, true);
if (Recharge.Instance.use(player, "KOTH Eject", 5000, false, false))
{
UtilPlayer.message(player, F.main("Football", "You must be wearing a Team Outfit."));
UtilPlayer.message(player, F.main("Football", "Type " + F.elem("/team red|yellow|green|blue") + "!"));
}
}
}
}
}
}
public void setKOTHMode(Player player, boolean enabled, Color color)
{
if (enabled)
{
_kothSword.Enable(player);
_active.add(player);
if (color == null)
UtilPlayer.message(player, F.main("Parkour", "You have entered " + F.elem("KOTH Mode") + "."));
else if (color == Color.RED)
UtilPlayer.message(player, F.main("Parkour", "You have joined " + F.elem(C.cRed + "Red KOTH Team") + "."));
else if (color == Color.AQUA)
UtilPlayer.message(player, F.main("Parkour", "You have joined " + F.elem(C.cAqua + "Blue KOTH Team") + "."));
else if (color == Color.LIME)
UtilPlayer.message(player, F.main("Parkour", "You have joined " + F.elem(C.cGreen + "Green KOTH Team") + "."));
else if (color == Color.YELLOW)
UtilPlayer.message(player, F.main("Parkour", "You have joined " + F.elem(C.cYellow + "Yellow KOTH Team") + "."));
ArrayList<String> outfit = new ArrayList<String>();
outfit.add("Team Helmet");
outfit.add("Team Shirt");
outfit.add("Team Pants");
outfit.add("Team Boots");
outfit.add("PvP Sword");
Manager.GetGadget().DisableAll(player, outfit);
}
else
{
_kothSword.Disable(player);
_active.remove(player);
UtilPlayer.message(player, F.main("Parkour", "You have exited " + F.elem("KOTH Mode") + "."));
}
}
public boolean isKothMode(Player player)
{
return _active.contains(player);
}
@EventHandler
public void disableGadgets(GadgetActivateEvent event)
{
if (isKothMode(event.getPlayer()))
event.setCancelled(true);
}
@EventHandler
public void disableMounts(MountActivateEvent event)
{
if (isKothMode(event.getPlayer()))
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOWEST)
public void disableStacker(PlayerInteractEntityEvent event)
{
if (_active.contains(event.getPlayer()))
event.setCancelled(true);
}
@EventHandler
public void playerQuit(PlayerQuitEvent event)
{
_active.remove(event.getPlayer());
}
@EventHandler(priority = EventPriority.HIGHEST)
public void allowDamage(EntityDamageByEntityEvent event)
{
if (!(event.getEntity() instanceof Player) || !(event.getDamager() instanceof Player))
return;
Player damager = (Player)event.getDamager();
Player damagee = (Player)event.getEntity();
if (!_active.contains(damager) || !_active.contains(damagee))
return;
if (getTeamColor(damager) == null || getTeamColor(damagee) == null)
return;
if (getTeamColor(damager) == getTeamColor(damagee))
return;
event.setCancelled(false);
event.setDamage(3.5);
}
public HashSet<Player> getActive()
{
return _active;
}
}

View File

@ -195,7 +195,7 @@ public class SoccerManager extends MiniPlugin
if (UtilEnt.isGrounded(_ball) && _ballVel.getY() <= 0)
_ballVel.setY(0);
_ballVel.setY(Math.min(_ballVel.getY(), 0.8));
_ballVel.setY(Math.min(_ballVel.getY(), 1));
_ball.getWorld().playSound(_ball.getLocation(), Sound.ZOMBIE_WOOD, 0.5f, 1.5f);

View File

@ -0,0 +1,389 @@
package mineplex.hub.modules.koth;
import java.util.ArrayList;
import java.util.Collection;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.hub.modules.KothManager;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
public class CapturePoint
{
private KothManager Host;
private String _name;
//Locations
private ArrayList<Block> _floor = new ArrayList<Block>();
private ArrayList<Block> _indicators = new ArrayList<Block>();
private Location _loc;
//Capture
private double _captureMax = 24;
private double _captureRate = 1;
private double _captureAmount = 0;
private Color _owner = null;
private boolean _captured = false;
private ArrayList<Block> _captureFloor = new ArrayList<Block>();
private long _decayDelay = 0;
private int _indicatorTick = 0;
public CapturePoint(KothManager host, String name, Location loc)
{
Host = host;
_name = name;
for (int x=-3 ; x<= 3 ; x++)
{
for (int z=-3 ; z<= 3 ; z++)
{
//Indicators
if (Math.abs(x) == 3 && Math.abs(z) == 3)
{
Block ind = loc.getBlock().getRelative(x, 3, z);
ind.setType(Material.WOOL);
ind.setData((byte) 0);
_indicators.add(ind);
}
//Floors
if (Math.abs(x) <= 2 && Math.abs(z) <= 2)
{
if (x != 0 || z != 0)
{
Block floor = loc.getBlock().getRelative(x, -2, z);
floor.setType(Material.WOOL);
_floor.add(floor);
}
else
{
Block block = loc.getBlock().getRelative(x, -2, z);
block.setType(Material.BEACON);
}
}
//Glass
if (Math.abs(x) <= 2 && Math.abs(z) <= 2)
{
Block block = loc.getBlock().getRelative(x, -1, z);
block.setType(Material.STAINED_GLASS);
}
//Iron
if (Math.abs(x) <= 1 && Math.abs(z) <= 1)
{
Block block = loc.getBlock().getRelative(x, -3, z);
block.setType(Material.IRON_BLOCK);
}
}
}
//Firework
_loc = loc;
}
public void captureUpdate()
{
//Who's on the CP?
ArrayList<Player> red = new ArrayList<Player>();
ArrayList<Player> yellow = new ArrayList<Player>();
ArrayList<Player> green = new ArrayList<Player>();
ArrayList<Player> blue = new ArrayList<Player>();
ArrayList<Player> players = new ArrayList<Player>();
for (Player player : Host.getActive())
{
Color team = Host.getTeamColor(player);
if (team == null)
continue;
if (Math.abs(_loc.getX() - player.getLocation().getX()) > 2.5)
continue;
if (Math.abs(_loc.getY() - player.getLocation().getY()) > 2.5)
continue;
if (Math.abs(_loc.getZ() - player.getLocation().getZ()) > 2.5)
continue;
if (team == Color.RED)
{
red.add(player);
}
else if (team == Color.YELLOW)
{
yellow.add(player);
}
else if (team == Color.LIME)
{
green.add(player);
}
else if (team == Color.AQUA)
{
blue.add(player);
}
players.add(player);
}
//No one around (DEGENERATE CAPTURE)
if (players.isEmpty())
{
if (_captureAmount > 0)
regenDegen();
return;
}
//Capture
if (red.size() > players.size() - red.size())
capture(Color.RED, red.size() - (players.size() - red.size()), red);
else if (yellow.size() > players.size() - yellow.size())
capture(Color.YELLOW, yellow.size() - (players.size() - yellow.size()), yellow);
else if (green.size() > players.size() - green.size())
capture(Color.LIME, green.size() - (players.size() - green.size()), green);
else if (blue.size() > players.size() - blue.size())
capture(Color.AQUA, blue.size() - (players.size() - blue.size()), blue);
}
private void regenDegen()
{
if (!UtilTime.elapsed(_decayDelay, 1000))
return;
//Degen
if (!_captured || Host.getActive().isEmpty())
{
_captureAmount = Math.max(0, (_captureAmount - (_captureRate*1)));
//Floor Color
while ((double)_captureFloor.size()/((double)_captureFloor.size() + (double)_floor.size()) > _captureAmount/_captureMax)
{
Block block = _captureFloor.remove(UtilMath.r(_captureFloor.size()));
_floor.add(block);
setWoolColor(block, null, false);
}
//Set Uncaptured
if (_captureAmount == 0)
{
_owner = null;
_loc.getBlock().getRelative(BlockFace.DOWN).setData((byte)0);
//Indicators
for (Block block : _indicators)
{
block.setData((byte)0);
}
}
//Effect
for (Block block : _indicators)
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, 35);
}
//Regen
else if (_captureAmount < _captureMax)
{
_captureAmount = Math.min(_captureMax, (_captureAmount + (_captureRate*1)));
//Floor Color
while ((double)_captureFloor.size()/((double)_captureFloor.size() + (double)_floor.size()) < _captureAmount/_captureMax)
{
Block block = _floor.remove(UtilMath.r(_floor.size()));
_captureFloor.add(block);
setWoolColor(block, _owner, false);
}
//Effect
indicate(_owner);
}
}
private void capture(Color team, int count, Collection<Player> capturers)
{
//Decay Delay
_decayDelay = System.currentTimeMillis();
//Count Up
if (_owner != null && _owner.equals(team))
{
//Given if the other team hadnt actually captured it fully
int bonus = 0;
if (_captured)
bonus = 1;
_captureAmount = Math.min(_captureMax, (_captureAmount + ((_captureRate*count)+bonus)));
//Floor Color
while ((double)_captureFloor.size()/((double)_captureFloor.size() + (double)_floor.size()) < _captureAmount/_captureMax)
{
Block block = _floor.remove(UtilMath.r(_floor.size()));
_captureFloor.add(block);
setWoolColor(block, team, false);
}
//Set Fully Captured
if (_captureAmount == _captureMax && !_captured)
{
_captured = true;
//Firework
UtilFirework.playFirework(_loc, FireworkEffect.builder().flicker(true).withColor(team).with(Type.BALL_LARGE).trail(true).build());
//Indicators
indicate(team);
for (Block block : _indicators)
{
if (team == Color.RED)
block.setData((byte) 14);
else if (team == Color.YELLOW)
block.setData((byte) 4);
else if (team == Color.LIME)
block.setData((byte) 5);
else if (team == Color.AQUA)
block.setData((byte) 3);
}
//Center
setWoolColor(_loc.getBlock().getRelative(0, -2, 0), _owner, true);
String teamName = C.cRed + "Red";
if (team == Color.YELLOW) teamName = C.cYellow + "Yellow";
if (team == Color.LIME) teamName = C.cGreen + "Green";
if (team == Color.AQUA) teamName = C.cAqua + "Blue";
for (Player player : Host.getActive())
UtilTextMiddle.display("KOTH", teamName + " Team captured the Hill!", 0, 60, 10, player);
}
}
//Count Down
else
{
//Given if the other team hadnt actually captured it fully
int bonus = 0;
if (!_captured)
bonus = 1;
_captureAmount = Math.max(0, (_captureAmount - ((_captureRate*count)+bonus)));
//Floor Color
while ((double)_captureFloor.size()/((double)_captureFloor.size() + (double)_floor.size()) > _captureAmount/_captureMax)
{
Block block = _captureFloor.remove(UtilMath.r(_captureFloor.size()));
_floor.add(block);
setWoolColor(block, null, false);
}
//Set Uncaptured
if (_captureAmount == 0)
{
_captured = false;
_owner = team;
//Center
setWoolColor(_loc.getBlock().getRelative(0, -2, 0), null, true);
//Indicators
for (Block block : _indicators)
{
block.setData((byte)0);
}
}
}
if (_captureAmount != _captureMax)
{
indicate(team);
}
}
private void setWoolColor(Block block, Color color, boolean glassOnly)
{
System.out.println(color == null ? "null" : color.toString());
if (color == null)
{
if (!glassOnly)
block.setData((byte)0);
block.getRelative(BlockFace.UP).setTypeIdAndData(95, (byte)0, true);
}
else if (color == Color.RED)
{
if (!glassOnly)
block.setData((byte)14);
block.getRelative(BlockFace.UP).setTypeIdAndData(95, (byte)14, true);
}
else if (color == Color.YELLOW)
{
if (!glassOnly)
block.setData((byte)4);
block.getRelative(BlockFace.UP).setTypeIdAndData(95, (byte)4, true);
}
else if (color == Color.LIME)
{
if (!glassOnly)
block.setData((byte)5);
block.getRelative(BlockFace.UP).setTypeIdAndData(95, (byte)5, true);
}
else if (color == Color.AQUA)
{
if (!glassOnly)
block.setData((byte)3);
block.getRelative(BlockFace.UP).setTypeIdAndData(95, (byte)3, true);
}
}
private void indicate(Color color)
{
//Effect
for (Block block : _indicators)
{
if (color == Color.RED)
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK);
else if (color == Color.YELLOW)
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.GOLD_BLOCK);
else if (color == Color.LIME)
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.EMERALD_BLOCK);
else if (color == Color.AQUA)
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.DIAMOND_BLOCK);
}
}
}