many UHC bug fixes

dragon escape bug fixes
barbarians bug fixes
death tag fixes
This commit is contained in:
Chiss 2013-09-13 12:24:33 +10:00
parent 60dd6c84d0
commit b1744e86d8
27 changed files with 619 additions and 172 deletions

View File

@ -1,6 +1,10 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Projectile;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
public class UtilEvent public class UtilEvent
@ -37,4 +41,32 @@ public class UtilEvent
return false; return false;
} }
public static LivingEntity GetDamagerEntity(EntityDamageEvent event, boolean ranged)
{
if (!(event instanceof EntityDamageByEntityEvent))
return null;
EntityDamageByEntityEvent eventEE = (EntityDamageByEntityEvent)event;
//Get Damager
if (eventEE.getDamager() instanceof LivingEntity)
return (LivingEntity)eventEE.getDamager();
if (!ranged)
return null;
if (!(eventEE.getDamager() instanceof Projectile))
return null;
Projectile projectile = (Projectile)eventEE.getDamager();
if (projectile.getShooter() == null)
return null;
if (!(projectile.getShooter() instanceof LivingEntity))
return null;
return (LivingEntity)projectile.getShooter();
}
} }

View File

@ -13,6 +13,8 @@ import org.bukkit.plugin.java.JavaPlugin;
public class AntiStack extends MiniPlugin public class AntiStack extends MiniPlugin
{ {
private boolean _enabled = true;
public AntiStack(JavaPlugin plugin) public AntiStack(JavaPlugin plugin)
{ {
super("AntiStack", plugin); super("AntiStack", plugin);
@ -21,6 +23,9 @@ public class AntiStack extends MiniPlugin
@EventHandler (priority=EventPriority.HIGHEST) @EventHandler (priority=EventPriority.HIGHEST)
public void ItemSpawn(ItemSpawnEvent event) public void ItemSpawn(ItemSpawnEvent event)
{ {
if (!_enabled)
return;
if (event.isCancelled()) if (event.isCancelled())
return; return;
@ -43,6 +48,9 @@ public class AntiStack extends MiniPlugin
@EventHandler (priority=EventPriority.HIGHEST) @EventHandler (priority=EventPriority.HIGHEST)
public void PlayerPickup(PlayerPickupItemEvent event) public void PlayerPickup(PlayerPickupItemEvent event)
{ {
if (!_enabled)
return;
if (event.isCancelled()) if (event.isCancelled())
return; return;
@ -62,6 +70,9 @@ public class AntiStack extends MiniPlugin
@EventHandler @EventHandler
public void HopperPickup(InventoryPickupItemEvent event) public void HopperPickup(InventoryPickupItemEvent event)
{ {
if (!_enabled)
return;
if (event.isCancelled()) if (event.isCancelled())
return; return;
@ -77,4 +88,9 @@ public class AntiStack extends MiniPlugin
//Set Name //Set Name
((CraftItemStack)item.getItemStack()).getHandle().c(name); ((CraftItemStack)item.getItemStack()).getHandle().c(name);
} }
public void SetEnabled(boolean var)
{
_enabled = var;
}
} }

View File

@ -246,7 +246,7 @@ public class Creature extends MiniPlugin
for (Player cur : players.keySet()) for (Player cur : players.keySet())
{ {
Vector vec = UtilAlg.getTrajectory(event.getEntity().getLocation(), cur.getLocation()); Vector vec = UtilAlg.getTrajectory(event.getEntity().getLocation(), cur.getLocation());
UtilAction.velocity(cur, vec, 1 + 3 * players.get(cur), false, 0, 1 + 1 * (players.get(cur)), 3, true); UtilAction.velocity(cur, vec, 1 + 2 * players.get(cur), false, 0, 0.5 + 1 * (players.get(cur)), 2, true);
} }
} }

View File

@ -393,6 +393,9 @@ public class ItemStackFactory extends MiniPlugin
public void StatsArmorRename(ItemStack item, int damage) public void StatsArmorRename(ItemStack item, int damage)
{ {
if (!_customNames)
return;
if (item == null) if (item == null)
return; return;
@ -407,8 +410,11 @@ public class ItemStackFactory extends MiniPlugin
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void StatsBowShoot(BlockBreakEvent event) public void StatsBlockMined(BlockBreakEvent event)
{ {
if (!_customNames)
return;
if (event.isCancelled()) if (event.isCancelled())
return; return;
@ -427,6 +433,9 @@ public class ItemStackFactory extends MiniPlugin
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void StatsKillMob(EntityDeathEvent event) public void StatsKillMob(EntityDeathEvent event)
{ {
if (!_customNames)
return;
if (!(event.getEntity() instanceof Monster)) if (!(event.getEntity() instanceof Monster))
return; return;
@ -454,6 +463,9 @@ public class ItemStackFactory extends MiniPlugin
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void StatsBowShoot(EntityShootBowEvent event) public void StatsBowShoot(EntityShootBowEvent event)
{ {
if (!_customNames)
return;
if (event.isCancelled()) if (event.isCancelled())
return; return;
@ -470,7 +482,7 @@ public class ItemStackFactory extends MiniPlugin
@EventHandler @EventHandler
public void RenameSpawn(ItemSpawnEvent event) public void RenameSpawn(ItemSpawnEvent event)
{ {
if (!_customNames) if (!_customNames)
return; return;
@ -720,7 +732,6 @@ public class ItemStackFactory extends MiniPlugin
return CreateStack(type.getId(), data, amount, damage, name, lore, null); return CreateStack(type.getId(), data, amount, damage, name, lore, null);
} }
//XXX
public ItemStack CreateStack(Material type, byte data, int amount, String name, List<String> lore, String owner) public ItemStack CreateStack(Material type, byte data, int amount, String name, List<String> lore, String owner)
{ {
return CreateStack(type.getId(), data, amount, (short)0, name, lore, owner); return CreateStack(type.getId(), data, amount, (short)0, name, lore, owner);
@ -951,4 +962,14 @@ public class ItemStackFactory extends MiniPlugin
stack.setItemMeta(meta); stack.setItemMeta(meta);
} }
public void SetUseCustomNames(boolean var)
{
_customNames = var;
}
public void SetCustomNameFormat(String format)
{
_nameFormat = format;
}
} }

View File

@ -67,7 +67,7 @@ public class Teleport extends MiniPlugin
LinkedList<Player> listA = new LinkedList<Player>(); LinkedList<Player> listA = new LinkedList<Player>();
//ALL //ALL
if (from.equals("%ALL%") && _clientManager.Get(caller).GetRank().Has(caller, Rank.OWNER, false)) if (from.equals("%ALL%"))
for (Player cur : UtilServer.getPlayers()) for (Player cur : UtilServer.getPlayers())
listA.add(cur); listA.add(cur);
//Normal //Normal

View File

@ -8,9 +8,11 @@ import net.minecraft.server.v1_6_R2.ItemStack;
import org.bukkit.craftbukkit.v1_6_R2.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_6_R2.inventory.CraftItemStack;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.Fireball; import org.bukkit.entity.Fireball;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -23,6 +25,7 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
@ -57,6 +60,131 @@ public class CombatManager extends MiniPlugin
return _combatClients.get(name); return _combatClients.get(name);
} }
//This is a backup, for when CustomDamageEvent is disabled (manually)
@EventHandler(priority = EventPriority.MONITOR)
public void AddAttack(EntityDamageEvent event)
{
if (event.isCancelled())
return;
if (event.getEntity() == null || !(event.getEntity() instanceof Player))
return;
Player damagee = (Player)event.getEntity();
LivingEntity damagerEnt = UtilEvent.GetDamagerEntity(event, true);
//Attacked by Entity
if (damagerEnt != null)
{
if (damagerEnt instanceof Player)
Get((Player)damagerEnt).LastCombat = System.currentTimeMillis();
Get(damagee).Attacked(
UtilEnt.getName(damagerEnt),
event.getDamage(), damagerEnt,
event.getCause() + "");
}
// Damager is WORLD
else
{
DamageCause cause = event.getCause();
String source = "?";
String reason = "-";
if (cause == DamageCause.BLOCK_EXPLOSION)
{
source = "Explosion";
reason = "-";
} else if (cause == DamageCause.CONTACT)
{
source = "Cactus";
reason = "-";
} else if (cause == DamageCause.CUSTOM)
{
source = "Custom";
reason = "-";
} else if (cause == DamageCause.DROWNING)
{
source = "Water";
reason = "-";
} else if (cause == DamageCause.ENTITY_ATTACK)
{
source = "Entity";
reason = "Attack";
} else if (cause == DamageCause.ENTITY_EXPLOSION)
{
source = "Explosion";
reason = "-";
} else if (cause == DamageCause.FALL)
{
source = "Fall";
reason = "-";
} else if (cause == DamageCause.FALLING_BLOCK)
{
source = "Falling Block";
reason = "-";
} else if (cause == DamageCause.FIRE)
{
source = "Fire";
reason = "-";
} else if (cause == DamageCause.FIRE_TICK)
{
source = "Fire";
reason = "-";
} else if (cause == DamageCause.LAVA)
{
source = "Lava";
reason = "-";
} else if (cause == DamageCause.LIGHTNING)
{
source = "Lightning";
reason = "-";
} else if (cause == DamageCause.MAGIC)
{
source = "Magic";
reason = "-";
} else if (cause == DamageCause.MELTING)
{
source = "Melting";
reason = "-";
} else if (cause == DamageCause.POISON)
{
source = "Poison";
reason = "-";
} else if (cause == DamageCause.PROJECTILE)
{
source = "Projectile";
reason = "-";
} else if (cause == DamageCause.STARVATION)
{
source = "Starvation";
reason = "-";
} else if (cause == DamageCause.SUFFOCATION)
{
source = "Suffocation";
reason = "-";
} else if (cause == DamageCause.SUICIDE)
{
source = "Suicide";
reason = "-";
} else if (cause == DamageCause.VOID)
{
source = "Void";
reason = "-";
} else if (cause == DamageCause.WITHER)
{
source = "Wither";
reason = "-";
}
Get(damagee).Attacked(source,
event.getDamage(), null, reason);
}
}
public void AddAttack(CustomDamageEvent event) public void AddAttack(CustomDamageEvent event)
{ {

View File

@ -9,6 +9,7 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
@ -48,6 +49,8 @@ public class DamageManager extends MiniPlugin
public boolean UseSimpleWeaponDamage = false; public boolean UseSimpleWeaponDamage = false;
public boolean DisableDamageChanges = false; public boolean DisableDamageChanges = false;
private boolean _enabled = true;
public DamageManager(JavaPlugin plugin, CombatManager combatManager, NpcManager npcManager, DisguiseManager disguiseManager) public DamageManager(JavaPlugin plugin, CombatManager combatManager, NpcManager npcManager, DisguiseManager disguiseManager)
{ {
super("Damage Manager", plugin); super("Damage Manager", plugin);
@ -73,6 +76,9 @@ public class DamageManager extends MiniPlugin
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void StartDamageEvent(EntityDamageEvent event) public void StartDamageEvent(EntityDamageEvent event)
{ {
if (!_enabled)
return;
boolean preCancel = false; boolean preCancel = false;
if (event.isCancelled()) if (event.isCancelled())
preCancel = true; preCancel = true;
@ -82,7 +88,7 @@ public class DamageManager extends MiniPlugin
//Get Data //Get Data
LivingEntity damagee = GetDamageeEntity(event); LivingEntity damagee = GetDamageeEntity(event);
LivingEntity damager = GetDamagerEntity(event, true); LivingEntity damager = UtilEvent.GetDamagerEntity(event, true);
Projectile projectile = GetProjectile(event); Projectile projectile = GetProjectile(event);
if (projectile instanceof Fish) if (projectile instanceof Fish)
@ -95,8 +101,6 @@ public class DamageManager extends MiniPlugin
//New Event //New Event
NewDamageEvent(damagee, damager, projectile, event.getCause(), event.getDamage(), true, false, false, null, null, preCancel); NewDamageEvent(damagee, damager, projectile, event.getCause(), event.getDamage(), true, false, false, null, null, preCancel);
//event.setDamage(0);
//if (GoldPower(damager))
event.setCancelled(true); event.setCancelled(true);
} }
@ -506,34 +510,6 @@ public class DamageManager extends MiniPlugin
event.setDamage(damage); event.setDamage(damage);
} }
private LivingEntity GetDamagerEntity(EntityDamageEvent event, boolean ranged)
{
if (!(event instanceof EntityDamageByEntityEvent))
return null;
EntityDamageByEntityEvent eventEE = (EntityDamageByEntityEvent)event;
//Get Damager
if (eventEE.getDamager() instanceof LivingEntity)
return (LivingEntity)eventEE.getDamager();
if (!ranged)
return null;
if (!(eventEE.getDamager() instanceof Projectile))
return null;
Projectile projectile = (Projectile)eventEE.getDamager();
if (projectile.getShooter() == null)
return null;
if (!(projectile.getShooter() instanceof LivingEntity))
return null;
return (LivingEntity)projectile.getShooter();
}
private LivingEntity GetDamageeEntity(EntityDamageEvent event) private LivingEntity GetDamageeEntity(EntityDamageEvent event)
{ {
if (event.getEntity() instanceof LivingEntity) if (event.getEntity() instanceof LivingEntity)
@ -554,4 +530,9 @@ public class DamageManager extends MiniPlugin
return null; return null;
} }
public void SetEnabled(boolean var)
{
_enabled = var;
}
} }

View File

@ -104,7 +104,7 @@ public class Arcade extends JavaPlugin implements INautilusPlugin, IPlugin
new MessageManager(this, _clientManager); new MessageManager(this, _clientManager);
new AntiStack(this); AntiStack antistack = new AntiStack(this);
GetCreature(); GetCreature();
GetSpawn(); GetSpawn();
@ -118,7 +118,7 @@ public class Arcade extends JavaPlugin implements INautilusPlugin, IPlugin
_damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, GetCreature()), disguiseManager); _damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, GetCreature()), disguiseManager);
//Arcade Manager //Arcade Manager
_gameManager = new ArcadeManager(this, ReadServerConfig(), _clientManager, _donationManager, conditionManager, _damageManager, disguiseManager, GetCreature(), GetBlood(), packetHandler); _gameManager = new ArcadeManager(this, ReadServerConfig(), _clientManager, _donationManager, conditionManager, _damageManager, disguiseManager, GetCreature(), GetBlood(), antistack, packetHandler);
//Unreferenced Modules //Unreferenced Modules
//new AntiStack(); //new AntiStack();

View File

@ -37,6 +37,7 @@ import mineplex.core.MiniPlugin;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.itemstack.ItemStackFactory;
import me.chiss.Core.Modules.Blood; import me.chiss.Core.Modules.Blood;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.antistack.AntiStack;
import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.chat.Chat; import mineplex.core.chat.Chat;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
@ -52,6 +53,7 @@ import mineplex.core.projectile.ProjectileManager;
public class ArcadeManager extends MiniPlugin implements IRelation public class ArcadeManager extends MiniPlugin implements IRelation
{ {
//Modules //Modules
private AntiStack _antistack;
private BlockRestore _blockRestore; private BlockRestore _blockRestore;
private Blood _blood; private Blood _blood;
private Chat _chat; private Chat _chat;
@ -83,13 +85,15 @@ public class ArcadeManager extends MiniPlugin implements IRelation
//Games //Games
private Game _game; private Game _game;
public ArcadeManager(JavaPlugin plugin, GameServerConfig serverConfig, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DamageManager damageManager, DisguiseManager disguiseManager, Creature creature, Blood blood, PacketHandler packetHandler) public ArcadeManager(JavaPlugin plugin, GameServerConfig serverConfig, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DamageManager damageManager, DisguiseManager disguiseManager, Creature creature, Blood blood, AntiStack antistack, PacketHandler packetHandler)
{ {
super("Game Manager", plugin); super("Game Manager", plugin);
_serverConfig = serverConfig; _serverConfig = serverConfig;
//Modules //Modules
_antistack = antistack;
_blockRestore = new BlockRestore(plugin); _blockRestore = new BlockRestore(plugin);
_blood = blood; _blood = blood;
@ -162,6 +166,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
return GetServerConfig().GameList; return GetServerConfig().GameList;
} }
public AntiStack GetAntiStack()
{
return _antistack;
}
public Blood GetBlood() public Blood GetBlood()
{ {
return _blood; return _blood;
@ -195,7 +204,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
public DisguiseManager GetDisguise() public DisguiseManager GetDisguise()
{ {
return _disguiseManager; return _disguiseManager;
} }
public DamageManager GetDamage() public DamageManager GetDamage()
{ {
@ -456,12 +465,19 @@ public class ArcadeManager extends MiniPlugin implements IRelation
player.setGameMode(GameMode.SURVIVAL); player.setGameMode(GameMode.SURVIVAL);
player.setAllowFlight(false); player.setAllowFlight(false);
UtilInv.Clear(player); UtilInv.Clear(player);
player.setFoodLevel(20); player.setFoodLevel(20);
player.setSaturation(3f);
player.setExhaustion(0f);
player.setHealth(20); player.setHealth(20);
player.setFireTicks(0); player.setFireTicks(0);
player.setFallDistance(0); player.setFallDistance(0);
player.setLevel(0); player.setLevel(0);
player.setExp(0f); player.setExp(0f);
((CraftPlayer)player).getHandle().spectating = false; ((CraftPlayer)player).getHandle().spectating = false;
((CraftPlayer)player).getHandle().m = true; ((CraftPlayer)player).getHandle().m = true;

View File

@ -58,6 +58,8 @@ public class GameTeam
private HashSet<Kit> _kitRestrict = new HashSet<Kit>(); private HashSet<Kit> _kitRestrict = new HashSet<Kit>();
private int _spawnDistance = 0; private int _spawnDistance = 0;
private boolean _visible = true;
public GameTeam(String name, ChatColor color, ArrayList<Location> spawns) public GameTeam(String name, ChatColor color, ArrayList<Location> spawns)
{ {
@ -295,4 +297,14 @@ public class GameTeam
_players.put(player, state); _players.put(player, state);
} }
} }
public void SetVisible(boolean b)
{
_visible = b;
}
public boolean GetVisible()
{
return _visible;
}
} }

View File

@ -1,13 +1,28 @@
package nautilus.game.arcade.game.games.barbarians; package nautilus.game.arcade.game.games.barbarians;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.barbarians.kits.*; import nautilus.game.arcade.game.games.barbarians.kits.*;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
public class Barbarians extends SoloGame public class Barbarians extends SoloGame
{ {
private GameTeam _barbs;
private GameTeam _pigs;
public Barbarians(ArcadeManager manager) public Barbarians(ArcadeManager manager)
{ {
super(manager, GameType.Barbarians, super(manager, GameType.Barbarians,
@ -16,7 +31,8 @@ public class Barbarians extends SoloGame
{ {
new KitBrute(manager), new KitBrute(manager),
new KitArcher(manager), new KitArcher(manager),
new KitBomber(manager) new KitBomber(manager),
new KitPig(manager)
}, },
new String[] new String[]
@ -25,8 +41,11 @@ public class Barbarians extends SoloGame
"Wooden blocks are breakable.", "Wooden blocks are breakable.",
"Last player alive wins!" "Last player alive wins!"
}); });
this.DeathOut = false;
this.HungerSet = 20; this.HungerSet = 20;
this.DamageTeamSelf = true; this.DamageTeamSelf = true;
this.CompassEnabled = true;
this.BlockBreakAllow.add(5); this.BlockBreakAllow.add(5);
this.BlockBreakAllow.add(17); this.BlockBreakAllow.add(17);
@ -47,4 +66,111 @@ public class Barbarians extends SoloGame
this.BlockBreakAllow.add(135); this.BlockBreakAllow.add(135);
this.BlockBreakAllow.add(136); this.BlockBreakAllow.add(136);
} }
@Override
@EventHandler
public void CustomTeamGeneration(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Recruit)
return;
_barbs = this.GetTeamList().get(0);
_barbs.SetName("Barbarians");
//Undead Team
_pigs = new GameTeam("Dead", ChatColor.RED, _barbs.GetSpawns());
GetTeamList().add(_pigs);
_pigs.SetVisible(false);
RestrictKits();
}
@Override
public GameTeam ChooseTeam(Player player)
{
return _barbs;
}
@EventHandler
public void PlayerDeath(PlayerDeathEvent event)
{
if (_barbs.HasPlayer(event.getEntity()))
SetChaser(event.getEntity());
}
public void SetChaser(Player player)
{
if (!GetPlaces().contains(player))
GetPlaces().add(0, player);
SetPlayerTeam(player, _pigs);
//Kit
Kit newKit = GetKits()[3];
SetKit(player, newKit, false);
newKit.ApplyKit(player);
//Refresh
for (Player other : UtilServer.getPlayers())
{
other.hidePlayer(player);
other.showPlayer(player);
}
}
@Override
public void EndCheck()
{
if (!IsLive())
return;
if (_barbs.GetPlayers(true).size() <= 1)
{
if (_barbs.GetPlayers(true).size() == 1)
GetPlaces().add(0, GetPlayers(true).get(0));
if (GetPlaces().size() >= 1)
AddGems(GetPlaces().get(0), 15, "1st Place", false);
if (GetPlaces().size() >= 2)
AddGems(GetPlaces().get(1), 10, "2nd Place", false);
if (GetPlaces().size() >= 3)
AddGems(GetPlaces().get(2), 5, "3rd Place", false);
for (Player player : GetPlayers(false))
if (player.isOnline())
AddGems(player, 10, "Participation", false);
SetState(GameState.End);
AnnounceEnd(GetPlaces());
}
}
@Override
@EventHandler
public void ScoreboardUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
if (_barbs == null || _pigs == null)
return;
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(_barbs.GetColor() + _barbs.GetName())).setScore(_barbs.GetPlayers(true).size());
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(_pigs.GetColor() + _pigs.GetName())).setScore(_pigs.GetPlayers(true).size());
}
@Override
public boolean CanJoinTeam(GameTeam team)
{
return (team.GetColor() != ChatColor.RED);
}
@EventHandler
public void BlockBreak(BlockDamageEvent event)
{
event.setInstaBreak(true);
}
} }

View File

@ -58,6 +58,8 @@ public class DeathTag extends SoloGame
this.HungerSet = 20; this.HungerSet = 20;
this.CompassEnabled = true; this.CompassEnabled = true;
this.PrepareFreeze = false;
} }
@Override @Override
@ -165,7 +167,7 @@ public class DeathTag extends SoloGame
if (event.getType() != UpdateType.FAST) if (event.getType() != UpdateType.FAST)
return; return;
int req = 1 + _runners.GetPlayers(true).size()/20; int req = 1 + (int) ((System.currentTimeMillis() - GetStateTime()) / 30000);
while (_chasers.GetPlayers(true).size() < req && _runners.GetPlayers(true).size() > 0) while (_chasers.GetPlayers(true).size() < req && _runners.GetPlayers(true).size() > 0)
{ {
@ -216,6 +218,7 @@ public class DeathTag extends SoloGame
} }
UtilPlayer.message(player, C.cRed + C.Bold + "You are now a Chaser!"); UtilPlayer.message(player, C.cRed + C.Bold + "You are now a Chaser!");
UtilPlayer.message(player, C.cRed + C.Bold + "KILL THEM ALL!!!!!!");
} }
@Override @Override

View File

@ -20,10 +20,12 @@ import org.bukkit.util.Vector;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
@ -37,6 +39,8 @@ public class DragonEscape extends SoloGame
{ {
private ArrayList<DragonScore> _ranks = new ArrayList<DragonScore>(); private ArrayList<DragonScore> _ranks = new ArrayList<DragonScore>();
private ArrayList<String> _lastScoreboard = new ArrayList<String>(); private ArrayList<String> _lastScoreboard = new ArrayList<String>();
private NautHashMap<Player, Long> _warpTime = new NautHashMap<Player, Long>();
private Location _dragon; private Location _dragon;
private ArrayList<Location> _waypoints; private ArrayList<Location> _waypoints;
@ -175,9 +179,12 @@ public class DragonEscape extends SoloGame
//Shortcut //Shortcut
if (postNode - preNode >= 2) if (postNode - preNode >= 2)
{ {
score.Player.damage(500); if (!_warpTime.containsKey(score.Player) || UtilTime.elapsed(_warpTime.get(score.Player), 1000))
UtilPlayer.message(player, F.main("Game", "You were killed for trying to cheat!")); {
return false; score.Player.damage(500);
UtilPlayer.message(player, F.main("Game", "You were killed for trying to cheat!"));
return false;
}
} }
//Finish //Finish
@ -210,8 +217,6 @@ public class DragonEscape extends SoloGame
return score; return score;
} }
public int GetWaypointIndex(Location loc) public int GetWaypointIndex(Location loc)
{ {
int best = -1; int best = -1;
@ -281,7 +286,7 @@ public class DragonEscape extends SoloGame
_lastScoreboard.add(out); _lastScoreboard.add(out);
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore((int)score.Score); //16-i GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore(16-i);
} }
} }
@ -413,6 +418,9 @@ public class DragonEscape extends SoloGame
player.setVelocity(new Vector(0,0,0)); player.setVelocity(new Vector(0,0,0));
player.setFallDistance(0); player.setFallDistance(0);
//Record
_warpTime.put(player, System.currentTimeMillis());
//Inform //Inform
UtilPlayer.message(player, F.main("Game", "You warped to " + F.name(target.getName()) + "!")); UtilPlayer.message(player, F.main("Game", "You warped to " + F.name(target.getName()) + "!"));

View File

@ -20,7 +20,7 @@ public class KitWarper extends Kit
new String[] new String[]
{ {
"Use your Enderpearl to instantlyy warp", "Use your Enderpearl to instantly warp",
"to the player in front of you!" "to the player in front of you!"
}, },

View File

@ -26,6 +26,7 @@ import org.bukkit.scoreboard.Objective;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
@ -317,7 +318,7 @@ public class MilkCow extends SoloGame
SetScore(event.getPlayer(), GetScore(event.getPlayer())+1); SetScore(event.getPlayer(), GetScore(event.getPlayer())+1);
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.BURP, 2f, 1f); event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.BURP, 2f, 1f);
Manager.GetCondition().Factory().Regen("Drink Milk", event.getPlayer(), event.getPlayer(), 6, 1, false, false, false); UtilPlayer.health(event.getPlayer(), 8);
} }
public void SetScore(Player player, double level) public void SetScore(Player player, double level)
@ -331,7 +332,7 @@ public class MilkCow extends SoloGame
{ {
score.Score = level; score.Score = level;
if (level == 6) if (level == 15)
End(); End();
return; return;

View File

@ -20,7 +20,7 @@ public class KitCow extends SmashKit
{ {
public KitCow(ArcadeManager manager) public KitCow(ArcadeManager manager)
{ {
super(manager, "The Disgusting Cow", KitAvailability.Blue, super(manager, "The Angry Cow", KitAvailability.Free,
new String[] new String[]
{ {
@ -28,7 +28,7 @@ public class KitCow extends SmashKit
new Perk[] new Perk[]
{ {
new PerkDamageSet(4), new PerkDamageSet(5),
new PerkKnockbackMultiplier(4), new PerkKnockbackMultiplier(4),
new PerkCharge(), new PerkCharge(),
new PerkCowBomb(), new PerkCowBomb(),

View File

@ -30,7 +30,7 @@ public class KitFarmerJump extends Kit
new PerkDoubleJump("Double Jump", 1, 0.8, false) new PerkDoubleJump("Double Jump", 1, 0.8, false)
}, },
EntityType.VILLAGER, EntityType.ZOMBIE,
new ItemStack(Material.IRON_HOE)); new ItemStack(Material.IRON_HOE));
} }

View File

@ -122,7 +122,8 @@ public class KitKnight extends SmashKit
_horses.add(horse); _horses.add(horse);
_mounts.put(player, horse); _mounts.put(player, horse);
/*
final Player fPlayer = player; final Player fPlayer = player;
Manager.GetPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable() Manager.GetPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
@ -132,6 +133,7 @@ public class KitKnight extends SmashKit
horse.setPassenger(fPlayer); horse.setPassenger(fPlayer);
} }
}, 1); }, 1);
*/
} }
@EventHandler @EventHandler

View File

@ -18,10 +18,10 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.scoreboard.Score; import org.bukkit.scoreboard.Score;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
@ -66,7 +66,7 @@ public class TurfForts extends TeamGame
private long _fightTime = 90000; private long _fightTime = 90000;
private boolean _fight = false; private boolean _fight = false;
private int _lines = 0; private int _lines = 0;
private HashMap<Player, Long> _enemyTurf = new HashMap<Player, Long>(); private HashMap<Player, Long> _enemyTurf = new HashMap<Player, Long>();
public TurfForts(ArcadeManager manager) public TurfForts(ArcadeManager manager)
@ -134,7 +134,7 @@ public class TurfForts extends TeamGame
if (event.GetLog().GetKiller() == null) if (event.GetLog().GetKiller() == null)
return; return;
Player killed = (Player)event.GetEvent().getEntity(); Player killed = (Player)event.GetEvent().getEntity();
Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
@ -143,10 +143,10 @@ public class TurfForts extends TeamGame
if (GetTeam(killer) == null) if (GetTeam(killer) == null)
return; return;
if (GetTeam(killed) == null) if (GetTeam(killed) == null)
return; return;
if (GetTeam(killer).equals(GetTeam(killed))) if (GetTeam(killer).equals(GetTeam(killed)))
return; return;
@ -221,16 +221,12 @@ public class TurfForts extends TeamGame
} }
@EventHandler @EventHandler
public void BowCancel(PlayerInteractEvent event) public void BowCancel(EntityShootBowEvent event)
{ {
if (!_fight) if (!_fight)
{ {
if (UtilGear.isMat(event.getPlayer().getItemInHand(), Material.BOW)) event.setCancelled(true);
{ UtilPlayer.message(event.getEntity(), F.main("Game", "You cannot attack during Build Time!"));
event.setCancelled(true);
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot attack during Build Time!"));
}
} }
} }
@ -320,7 +316,7 @@ public class TurfForts extends TeamGame
block.breakNaturally(); block.breakNaturally();
} }
arrow.remove(); arrow.remove();
} }
catch (Exception e) catch (Exception e)
@ -338,22 +334,22 @@ public class TurfForts extends TeamGame
{ {
event.SetCancelled("Build Time"); event.SetCancelled("Build Time");
} }
Player damager = event.GetDamagerPlayer(true); Player damager = event.GetDamagerPlayer(true);
if (damager == null) return; if (damager == null) return;
if (event.GetCause() == DamageCause.PROJECTILE) if (event.GetCause() == DamageCause.PROJECTILE)
{ {
event.AddMod("Turf Forts", "Nullify", -event.GetDamageInitial(), false); event.AddMod("Turf Forts", "Nullify", -event.GetDamageInitial(), false);
if (GetKit(damager).GetName().contains("Shredder")) if (GetKit(damager).GetName().contains("Shredder"))
{ {
event.SetCancelled("Shredder"); event.SetCancelled("Shredder");
Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), damager, null, Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), damager, null,
DamageCause.CUSTOM, 6, true, true, false, DamageCause.CUSTOM, 6, true, true, false,
damager.getName(), "Barrage"); damager.getName(), "Barrage");
return; return;
} }
else else
@ -364,7 +360,7 @@ public class TurfForts extends TeamGame
else if (event.GetCause() == DamageCause.ENTITY_ATTACK) else if (event.GetCause() == DamageCause.ENTITY_ATTACK)
{ {
event.AddMod("Turf Forts", "Nullify", -event.GetDamageInitial(), false); event.AddMod("Turf Forts", "Nullify", -event.GetDamageInitial(), false);
if (UtilGear.isMat(damager.getItemInHand(), Material.IRON_SWORD)) if (UtilGear.isMat(damager.getItemInHand(), Material.IRON_SWORD))
{ {
event.AddMod("Turf Forts", "One Hit Kill", 12, false); event.AddMod("Turf Forts", "One Hit Kill", 12, false);
@ -381,7 +377,7 @@ public class TurfForts extends TeamGame
{ {
if (GetState() != GameState.Live) if (GetState() != GameState.Live)
return; return;
//2x Initial Build //2x Initial Build
if (_phaseTime == 0) if (_phaseTime == 0)
_phaseTime = System.currentTimeMillis() + _buildTime; _phaseTime = System.currentTimeMillis() + _buildTime;
@ -393,41 +389,41 @@ public class TurfForts extends TeamGame
if (!_fight) if (!_fight)
{ {
time = _buildTime - (System.currentTimeMillis() - _phaseTime); time = _buildTime - (System.currentTimeMillis() - _phaseTime);
long displayTime = Math.max(0, time); long displayTime = Math.max(0, time);
GetObjectiveSide().setDisplayName(ChatColor.WHITE + C.Bold + "Build Time " + C.cGreen + C.Bold+ UtilTime.MakeStr(displayTime)); GetObjectiveSide().setDisplayName(ChatColor.WHITE + C.Bold + "Build Time " + C.cGreen + C.Bold+ UtilTime.MakeStr(displayTime));
if (time <= 0) if (time <= 0)
{ {
_fight = true; _fight = true;
_lines++; _lines++;
Announce(" "); Announce(" ");
Announce(C.cWhite + C.Bold + "1 Kill" + C.cWhite + C.Bold + " = " + C.cWhite + C.Bold + GetLinesPerKill() + " Turf Lines"); Announce(C.cWhite + C.Bold + "1 Kill" + C.cWhite + C.Bold + " = " + C.cWhite + C.Bold + GetLinesPerKill() + " Turf Lines");
Announce(C.cWhite + C.Bold + "90 Seconds of " + C.cYellow + C.Bold + "Combat Time" + C.cWhite + C.Bold + " has begun!"); Announce(C.cWhite + C.Bold + "90 Seconds of " + C.cYellow + C.Bold + "Combat Time" + C.cWhite + C.Bold + " has begun!");
Announce(" "); Announce(" ");
_phaseTime = System.currentTimeMillis(); _phaseTime = System.currentTimeMillis();
} }
} }
else else
{ {
time = _fightTime - (System.currentTimeMillis() - _phaseTime); time = _fightTime - (System.currentTimeMillis() - _phaseTime);
long displayTime = Math.max(0, time); long displayTime = Math.max(0, time);
GetObjectiveSide().setDisplayName(ChatColor.WHITE + C.Bold + "Combat Time " + C.cGreen + C.Bold+ UtilTime.MakeStr(displayTime)); GetObjectiveSide().setDisplayName(ChatColor.WHITE + C.Bold + "Combat Time " + C.cGreen + C.Bold+ UtilTime.MakeStr(displayTime));
if (time <= 0) if (time <= 0)
{ {
_fight = false; _fight = false;
Announce(" "); Announce(" ");
Announce(C.cWhite + C.Bold + "20 Seconds of " + C.cGreen + C.Bold + "Build Time" + C.cWhite + C.Bold + " has begun!"); Announce(C.cWhite + C.Bold + "20 Seconds of " + C.cGreen + C.Bold + "Build Time" + C.cWhite + C.Bold + " has begun!");
Announce(" "); Announce(" ");
_phaseTime = System.currentTimeMillis(); _phaseTime = System.currentTimeMillis();
for (GameTeam team : GetTeamList()) for (GameTeam team : GetTeamList())
{ {
for (Player player : team.GetPlayers(true)) for (Player player : team.GetPlayers(true))
@ -498,7 +494,7 @@ public class TurfForts extends TeamGame
{ {
_enemyTurf.remove(event.getEntity()); _enemyTurf.remove(event.getEntity());
} }
@EventHandler @EventHandler
public void Territory(UpdateEvent event) public void Territory(UpdateEvent event)
{ {
@ -513,8 +509,11 @@ public class TurfForts extends TeamGame
for (Player player : team.GetPlayers(true)) for (Player player : team.GetPlayers(true))
{ {
Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN); Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
while (block.getTypeId() == 0) while (block.getTypeId() == 0 && block.getY() > 0)
block = block.getRelative(BlockFace.DOWN); block = block.getRelative(BlockFace.DOWN);
if (block.getTypeId() == 0)
continue;
byte data = block.getData(); byte data = block.getData();
@ -522,25 +521,25 @@ public class TurfForts extends TeamGame
if (_enemyTurf.containsKey(player)) if (_enemyTurf.containsKey(player))
{ {
int time = (int) ((System.currentTimeMillis() - _enemyTurf.get(player))/2500); int time = (int) ((System.currentTimeMillis() - _enemyTurf.get(player))/2500);
if (time > 0) if (time > 0)
Manager.GetCondition().Factory().Slow("Infiltrator Slow", player, player, 0.9, time-1, false, false, false, false); Manager.GetCondition().Factory().Slow("Infiltrator Slow", player, player, 0.9, time-1, false, false, false, false);
} }
//On Enemy Turf //On Enemy Turf
if ((team.GetColor() == ChatColor.RED && data == 3) || (team.GetColor() == ChatColor.AQUA && data == 14)) if ((team.GetColor() == ChatColor.RED && data == 3) || (team.GetColor() == ChatColor.AQUA && data == 14))
{ {
//Infiltrate //Infiltrate
if (_fight && GetKit(player) != null && GetKit(player).GetName().contains("Infil")) if (_fight && GetKit(player) != null && GetKit(player).GetName().contains("Infil"))
{ {
if (!_enemyTurf.containsKey(player)) if (!_enemyTurf.containsKey(player))
_enemyTurf.put(player, System.currentTimeMillis()); _enemyTurf.put(player, System.currentTimeMillis());
continue; continue;
} }
if (Recharge.Instance.use(player, "Territory Knockback", 2000, false)) if (Recharge.Instance.use(player, "Territory Knockback", 2000, false))
{ {
UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), team.GetSpawn()), 2, false, 0, 0.8, 1, true); UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), team.GetSpawn()), 2, false, 0, 0.8, 1, true);

View File

@ -26,7 +26,7 @@ public class KitInfiltrator extends Kit
new Perk[] new Perk[]
{ {
new PerkConstructor("Constructor", 4, 4, Material.WOOL, "Wool", false), new PerkConstructor("Constructor", 4, 4, Material.WOOL, "Wool", false),
new PerkFletcher(12, 1, false), new PerkFletcher(8, 1, false),
}, },
EntityType.ZOMBIE, EntityType.ZOMBIE,
new ItemStack(Material.IRON_SWORD)); new ItemStack(Material.IRON_SWORD));

View File

@ -25,7 +25,7 @@ public class KitMarksman extends Kit
new Perk[] new Perk[]
{ {
new PerkConstructor("Constructor", 4, 8, Material.WOOL, "Wool", false), new PerkConstructor("Constructor", 4, 8, Material.WOOL, "Wool", false),
new PerkFletcher(4, 2, false), new PerkFletcher(2, 2, false),
}, },
EntityType.ZOMBIE, EntityType.ZOMBIE,

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.game.games.uhc; package nautilus.game.arcade.game.games.uhc;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -10,6 +11,7 @@ import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_6_R2.entity.CraftPlayer;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -21,6 +23,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
@ -28,7 +31,6 @@ import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
@ -45,6 +47,8 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
@ -62,7 +66,6 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.CombatLog; import mineplex.minecraft.game.core.combat.CombatLog;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeFormat; import nautilus.game.arcade.ArcadeFormat;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
@ -103,11 +106,6 @@ public class UHC extends TeamGame
"Last team alive wins!" "Last team alive wins!"
}); });
// Flags
this.DamagePvP = false;
this.DamageSelf = true;
this.DamageTeamSelf = true;
this.DeathDropItems = true; this.DeathDropItems = true;
this.ItemDrop = true; this.ItemDrop = true;
@ -146,8 +144,8 @@ public class UHC extends TeamGame
//Disable Custom Mob Drops (and EXP Disable) //Disable Custom Mob Drops (and EXP Disable)
Manager.GetCreature().SetDisableCustomDrops(true); Manager.GetCreature().SetDisableCustomDrops(true);
//Disable Weapon Damage Mods //Disable Anti-Stack
Manager.GetDamage().DisableDamageChanges = true; Manager.GetAntiStack().SetEnabled(false);
} }
@ -189,11 +187,11 @@ public class UHC extends TeamGame
else if (_gameMinutes == 18) else if (_gameMinutes == 18)
{ {
Announce(ChatColor.WHITE + C.Bold + "PvP enabled in 2 minutes."); Announce(ChatColor.WHITE + C.Bold + "PvP enabled in 2 minutes.");
} }
else if (_gameMinutes == 19) else if (_gameMinutes == 19)
{ {
Announce(ChatColor.WHITE + C.Bold + "PvP enabled in 1 minutes."); Announce(ChatColor.WHITE + C.Bold + "PvP enabled in 1 minutes.");
} }
else if (_gameMinutes == 20) else if (_gameMinutes == 20)
{ {
Announce(ChatColor.WHITE + C.Bold + "PvP enabled! 20 minutes have passed."); Announce(ChatColor.WHITE + C.Bold + "PvP enabled! 20 minutes have passed.");
@ -214,6 +212,9 @@ public class UHC extends TeamGame
if (event.GetState() != GameState.Prepare) if (event.GetState() != GameState.Prepare)
return; return;
//Disable Damage Manager
Manager.GetDamage().SetEnabled(false);
WorldData.World.setTime(2000); WorldData.World.setTime(2000);
//Kill Mobs //Kill Mobs
@ -233,19 +234,12 @@ public class UHC extends TeamGame
{ {
Manager.GetCondition().Factory().Blind("Start Blind", player, player, 8, 1, false, false, false); Manager.GetCondition().Factory().Blind("Start Blind", player, player, 8, 1, false, false, false);
Manager.GetCondition().Factory().Slow("Start Slow", player, player, 8, 4, false, false, false, false); Manager.GetCondition().Factory().Slow("Start Slow", player, player, 8, 4, false, false, false, false);
player.setSaturation(0f); player.setSaturation(3f);
player.setExhaustion(0f); player.setExhaustion(0f);
} }
} }
@EventHandler
public void PlayerJoinMap(PlayerJoinEvent event)
{
//event.getPlayer().getInventory().remove(Material.MAP);
//event.getPlayer().getInventory().addItem(_map.GetMap());
}
@EventHandler @EventHandler
public void WorldBoundaryCheck(PlayerMoveEvent event) public void WorldBoundaryCheck(PlayerMoveEvent event)
{ {
@ -363,7 +357,7 @@ public class UHC extends TeamGame
for (GameTeam team : GetTeamList()) for (GameTeam team : GetTeamList())
{ {
Location loc = WorldData.World.getHighestBlockAt(-1000 + UtilMath.r(2000), -1000 + UtilMath.r(2000)).getLocation(); Location loc = GetRandomSpawn(null);
//Ensure 250 Blocks between Teams //Ensure 250 Blocks between Teams
while (true) while (true)
@ -385,20 +379,58 @@ public class UHC extends TeamGame
if (!clash) if (!clash)
break; break;
loc = WorldData.World.getHighestBlockAt(-1000 + UtilMath.r(2000), -1000 + UtilMath.r(2000)).getLocation(); loc = GetRandomSpawn(null);
} }
team.GetSpawns().add(loc); team.GetSpawns().add(loc);
while (team.GetSpawns().size() < 5) while (team.GetSpawns().size() < 5)
{ {
Location other = WorldData.World.getHighestBlockAt(loc.getBlockX() - 5 + UtilMath.r(10), loc.getBlockZ() - 5 + UtilMath.r(10)).getLocation(); Location other = GetRandomSpawn(loc);
team.GetSpawns().add(other); team.GetSpawns().add(other);
} }
} }
} }
public Location GetRandomSpawn(Location around)
{
HashSet<Material> ignore = new HashSet<Material>();
ignore.add(Material.LEAVES);
Location loc = null;
while (loc == null)
{
Block block = null;
//Get Team Location
if (around == null)
{
block = UtilBlock.getHighest(WorldData.World, -900 + UtilMath.r(1800), -900 + UtilMath.r(1800), ignore);
}
//Get Radius Location
else
{
block = UtilBlock.getHighest(WorldData.World, around.getBlockX() - 5 + UtilMath.r(10), around.getBlockZ() - 5 + UtilMath.r(10), ignore);
}
//Check Validity
//Liquid
if (block.getRelative(BlockFace.DOWN).isLiquid())
continue;
//Suffocated
if (block.getTypeId() != 0 || block.getRelative(BlockFace.UP).getTypeId() != 0)
continue;
loc = block.getLocation().add(0.5, 0, 0.5);
}
return loc;
}
@EventHandler @EventHandler
public void GhastDrops(EntityDeathEvent event) public void GhastDrops(EntityDeathEvent event)
{ {
@ -421,7 +453,9 @@ public class UHC extends TeamGame
event.getDrops().add(ItemStackFactory.Instance.CreateStack(Material.SKULL, (byte)3, 1, team.GetColor() + player.getName() + "'s Head")); event.getDrops().add(ItemStackFactory.Instance.CreateStack(Material.SKULL, (byte)3, 1, team.GetColor() + player.getName() + "'s Head"));
//Lightning //Lightning
player.getWorld().strikeLightningEffect(player.getLocation()); Location loc = player.getLocation();
loc.setY(-150);
player.getWorld().strikeLightningEffect(loc);
//Time //Time
_deathTime.put(player.getName(), System.currentTimeMillis()); _deathTime.put(player.getName(), System.currentTimeMillis());
@ -529,25 +563,61 @@ public class UHC extends TeamGame
} }
@EventHandler @EventHandler
public void DamageRecord(CustomDamageEvent event) public void DamageRecord(EntityDamageEvent event)
{ {
if (event.IsCancelled()) if (event.isCancelled())
return; return;
Player damagee = event.GetDamageePlayer(); LivingEntity damagerEnt = UtilEvent.GetDamagerEntity(event, true);
if (damagee == null) return;
//No PvP
if (_gameMinutes < 20)
{
if (damagerEnt != null && damagerEnt instanceof Player && event.getEntity() instanceof Player)
{
event.setCancelled(true);
return;
}
}
//Damager
if (damagerEnt != null)
{
if (damagerEnt instanceof Player)
{
Player damager = (Player)damagerEnt;
Player damager = event.GetDamagerPlayer(true); //Damager Not Alive
if (damager == null) return; if (!IsAlive(damager))
{
event.setCancelled(true);
return;
}
//Damager Alive
else
{
_combatTime.put(damager, System.currentTimeMillis());
}
}
}
_combatTime.put(damagee, System.currentTimeMillis()); //Damagee
_combatTime.put(damager, System.currentTimeMillis()); if (event.getEntity() instanceof Player)
} {
Player damagee = (Player)event.getEntity();
@EventHandler(priority = EventPriority.LOWEST) //Damagee Not Alive
public void DamageToLevelDisable(CustomDamageEvent event) if (!IsAlive(damagee))
{ {
event.SetDamageToLevel(false); event.setCancelled(true);
return;
}
//Damagee Alive
else if (damagerEnt != null && damagerEnt instanceof Player)
{
_combatTime.put(damagee, System.currentTimeMillis());
}
}
} }
@EventHandler @EventHandler
@ -878,7 +948,7 @@ public class UHC extends TeamGame
Manager.GetDisguise().disguise(disguise); Manager.GetDisguise().disguise(disguise);
player.sendMessage("You are a Wither Skeleton!"); player.sendMessage("You are a Wither Skeleton!");
} }
UtilInv.Clear(player); UtilInv.Clear(player);
UtilInv.insert(player, new ItemStack(Material.IRON_SWORD)); UtilInv.insert(player, new ItemStack(Material.IRON_SWORD));
@ -888,34 +958,40 @@ public class UHC extends TeamGame
} }
@EventHandler @EventHandler
public void SpecialDamage(CustomDamageEvent event) public void SpecialDamage(EntityDamageEvent event)
{ {
if (event.IsCancelled()) if (event.isCancelled())
return; return;
Player player = event.GetDamageePlayer(); //Damager
if (player != null) LivingEntity damagerEnt = UtilEvent.GetDamagerEntity(event, true);
if (damagerEnt != null)
{ {
GameTeam team = GetTeam(player); if (damagerEnt instanceof Player)
if (team != null)
{ {
if (team.GetColor() == ChatColor.DARK_GRAY) Player damager = (Player)damagerEnt;
GameTeam team = GetTeam(damager);
if (team != null && team.GetColor() == ChatColor.DARK_GRAY)
{ {
event.SetCancelled("Special Cancel"); event.setCancelled(true);
return;
} }
} }
} }
player = event.GetDamagerPlayer(true); //Damagee
if (player != null) if (event.getEntity() instanceof Player)
{ {
GameTeam team = GetTeam(player); Player damagee = (Player)event.getEntity();
if (team != null)
GameTeam team = GetTeam(damagee);
if (team != null && team.GetColor() == ChatColor.DARK_GRAY)
{ {
if (team.GetColor() == ChatColor.DARK_GRAY) event.setCancelled(true);
{ return;
event.SetCancelled("Special Cancel");
}
} }
} }
} }
@ -980,7 +1056,7 @@ public class UHC extends TeamGame
player.setPlayerListName(" "); player.setPlayerListName(" ");
else else
player.setPlayerListName(" "); player.setPlayerListName(" ");
continue; continue;
} }
@ -993,17 +1069,22 @@ public class UHC extends TeamGame
if (((int)player.getHealth()) % 2 == 0) if (((int)player.getHealth()) % 2 == 0)
health += (int)(player.getHealth()/2); health += (int)(player.getHealth()/2);
else else
health += player.getHealth()/2d; health += UtilMath.trim(1, player.getHealth()/2d);
String name = team.GetColor() + player.getName(); String name = team.GetColor() + player.getName();
int length = 16 - (name.length() + health.length()); try
if (length < 0)
{ {
name = name.substring(0, name.length() + length); while (name.length() + health.length() > 16)
name = name.substring(0, name.length()-1);
player.setPlayerListName(name + health);
}
catch (Exception e)
{
System.out.println("TAB NAME: " + name + health);
e.printStackTrace();
} }
player.setPlayerListName(name + health);
} }
} }
@ -1071,7 +1152,7 @@ public class UHC extends TeamGame
UtilPlayer.message(player, ArcadeFormat.Line); UtilPlayer.message(player, ArcadeFormat.Line);
} }
} }
@Override @Override
public void AnnounceEnd(GameTeam team) public void AnnounceEnd(GameTeam team)
{ {
@ -1140,6 +1221,18 @@ public class UHC extends TeamGame
if (team.GetColor() != ChatColor.DARK_GRAY) if (team.GetColor() != ChatColor.DARK_GRAY)
if (team.GetPlayers(true).size() > 0) if (team.GetPlayers(true).size() > 0)
teamsAlive.add(team); teamsAlive.add(team);
/*
{
for (Player player : team.GetPlayers(true))
{
if (player.isOnline())
{
teamsAlive.add(team);
break;
}
}
}
*/
if (teamsAlive.size() <= 1) if (teamsAlive.size() <= 1)
{ {

View File

@ -43,7 +43,7 @@ public class PerkCharge extends Perk
if (!Kit.HasKit(player)) if (!Kit.HasKit(player))
continue; continue;
player.getWorld().playSound(player.getLocation(), Sound.COW_WALK, 2f, 1f); player.getWorld().playSound(player.getLocation(), Sound.COW_WALK, 0.8f, 1f);
Manager.GetCondition().Factory().Speed(GetName(), player, player, 0.9, 2, false, false, false); Manager.GetCondition().Factory().Speed(GetName(), player, player, 0.9, 2, false, false, false);
@ -63,7 +63,7 @@ public class PerkCharge extends Perk
//Damage Event //Damage Event
Manager.GetDamage().NewDamageEvent(cur, player, null, Manager.GetDamage().NewDamageEvent(cur, player, null,
DamageCause.CUSTOM, 2, false, false, false, DamageCause.CUSTOM, 3, false, false, false,
player.getName(), GetName()); player.getName(), GetName());
//Velocity //Velocity

View File

@ -9,6 +9,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -191,4 +192,15 @@ public class PerkCreeperExplode extends Perk
event.AddKnockback(GetName(), 2.5); event.AddKnockback(GetName(), 2.5);
} }
@EventHandler
public void Death(PlayerDeathEvent event)
{
if (!Kit.HasKit(event.getEntity()))
return;
_active.remove(event.getEntity());
DecreaseSize(event.getEntity());
}
} }

View File

@ -139,9 +139,10 @@ public class GameCreationManager implements Listener
private void CreateGame(GameType gameType) private void CreateGame(GameType gameType)
{ {
//Reset Damage Changes //Reset Changes
Manager.GetDamage().DisableDamageChanges = false; Manager.GetDamage().DisableDamageChanges = false;
Manager.GetCreature().SetDisableCustomDrops(false); Manager.GetCreature().SetDisableCustomDrops(false);
Manager.GetDamage().SetEnabled(true);
HashMap<String, ChatColor> pastTeams = null; HashMap<String, ChatColor> pastTeams = null;

View File

@ -166,12 +166,8 @@ public class GameFlagManager implements Listener
if (game == null || !game.IsAlive(player) || game.GetState() != GameState.Live) if (game == null || !game.IsAlive(player) || game.GetState() != GameState.Live)
{ {
if (player.isOp() && player.getGameMode() == GameMode.CREATIVE)
{
return;
}
event.setCancelled(true); event.setCancelled(true);
return;
} }
@ -658,7 +654,7 @@ public class GameFlagManager implements Listener
player.getLocation().getZ() < game.WorldData.MinZ || player.getLocation().getZ() < game.WorldData.MinZ ||
((player.getLocation().getY() > game.WorldData.MaxY || ((player.getLocation().getY() > game.WorldData.MaxY ||
player.getLocation().getY() < game.WorldData.MinY) && game.IsAlive(player))) player.getLocation().getY() < game.WorldData.MinY) && game.IsAlive(player)))
{ {
if (!Manager.IsAlive(player)) if (!Manager.IsAlive(player))
{ {
player.teleport(game.GetSpectatorLocation()); player.teleport(game.GetSpectatorLocation());

View File

@ -304,8 +304,12 @@ public class GameLobbyManager implements IPacketRunnable, Listener
if (game.GetKits().length > 1 || game.GetType() != GameType.UHC) if (game.GetKits().length > 1 || game.GetType() != GameType.UHC)
{ {
//Display //Display
ArrayList<GameTeam> teams = game.GetTeamList(); ArrayList<GameTeam> teams = new ArrayList<GameTeam>();
for (GameTeam team : game.GetTeamList())
if (team.GetVisible())
teams.add(team);
//Positions //Positions
double space = 6; double space = 6;
double offset = (teams.size()-1)*space/2d; double offset = (teams.size()-1)*space/2d;
@ -410,12 +414,8 @@ public class GameLobbyManager implements IPacketRunnable, Listener
_teams.put(ent, new LobbyEnt(ent, entLoc, teamsB.get(i))); _teams.put(ent, new LobbyEnt(ent, entLoc, teamsB.get(i)));
} }
} }
} }
CreateScoreboards(); CreateScoreboards();
} }