Fix small gameplay issues and update kit selection data points for TDM

This commit is contained in:
AlexTheCoder 2017-05-12 00:47:11 -04:00 committed by cnr
parent b18d36b361
commit 7b7b91ed3f
2 changed files with 45 additions and 14 deletions

View File

@ -820,7 +820,7 @@ public class CastleAssault extends TeamGame
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@EventHandler(ignoreCancelled=true) @EventHandler(ignoreCancelled=true)
public void onPlayerEmptyBucket(PlayerBucketFillEvent event) public void onPlayerFillBucket(PlayerBucketFillEvent event)
{ {
if (!IsLive()) if (!IsLive())
{ {
@ -828,10 +828,10 @@ public class CastleAssault extends TeamGame
} }
Player player = event.getPlayer(); Player player = event.getPlayer();
if (player.getItemInHand().getType() == Material.LAVA_BUCKET) Block block = event.getBlockClicked().getRelative(event.getBlockFace());
if (block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA)
{ {
event.setCancelled(true); event.setCancelled(true);
Block block = event.getBlockClicked().getRelative(event.getBlockFace());
player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); player.sendBlockChange(block.getLocation(), block.getType(), block.getData());
} }
} }
@ -1117,6 +1117,11 @@ public class CastleAssault extends TeamGame
{ {
return; return;
} }
if (Manager.GetLobby().getKits().containsKey(event.getEntity()))
{
event.setCancelled(true);
return;
}
if (event.getEntity() instanceof EnderCrystal) if (event.getEntity() instanceof EnderCrystal)
{ {
event.setCancelled(true); event.setCancelled(true);
@ -1127,6 +1132,10 @@ public class CastleAssault extends TeamGame
event.setCancelled(true); event.setCancelled(true);
if (event instanceof EntityDamageByEntityEvent) if (event instanceof EntityDamageByEntityEvent)
{ {
if (!event.getEntity().getCustomName().contains("Ryan") && !event.getEntity().getCustomName().contains("Jon"))
{
return;
}
GameTeam owner = event.getEntity().getCustomName().contains("Ryan") ? GetTeam(ChatColor.AQUA) : GetTeam(ChatColor.RED); GameTeam owner = event.getEntity().getCustomName().contains("Ryan") ? GetTeam(ChatColor.AQUA) : GetTeam(ChatColor.RED);
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event; EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
if (e.getDamager() instanceof Player) if (e.getDamager() instanceof Player)
@ -1354,6 +1363,11 @@ public class CastleAssault extends TeamGame
return; return;
} }
Bukkit.getOnlinePlayers().forEach(player ->
{
player.getInventory().remove(_wearableTnt.build());
});
Iterator<Player> tntIterator = _tntCarry.iterator(); Iterator<Player> tntIterator = _tntCarry.iterator();
while (tntIterator.hasNext()) while (tntIterator.hasNext())
@ -1406,6 +1420,10 @@ public class CastleAssault extends TeamGame
UtilTextBottom.display(GetTeam(player).GetColor() + player.getName() + " has the TNT!", UtilServer.getPlayers()); UtilTextBottom.display(GetTeam(player).GetColor() + player.getName() + " has the TNT!", UtilServer.getPlayers());
UtilFirework.playFirework(player.getEyeLocation(), Type.BURST, Color.RED, false, false); UtilFirework.playFirework(player.getEyeLocation(), Type.BURST, Color.RED, false, false);
if (player.getInventory().getHelmet() == null || player.getInventory().getHelmet().getType() != Material.TNT)
{
player.getInventory().setHelmet(_wearableTnt.build());
}
} }
} }

View File

@ -29,6 +29,7 @@ import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockFormEvent; import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.LeavesDecayEvent; import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileHitEvent;
@ -307,16 +308,14 @@ public class CastleAssaultTDM extends TeamGame
GameTeam blue = GetTeam(ChatColor.AQUA); GameTeam blue = GetTeam(ChatColor.AQUA);
_teamKills.put(blue, 0); _teamKills.put(blue, 0);
this.CreatureAllowOverride = true; this.CreatureAllowOverride = true;
int kitIndex = 0; for (Kit kit : GetKits())
for (int i = 0; i < WorldData.GetDataLocs("WHITE").size(); i++)
{ {
if (kitIndex >= GetKits().length) List<Location> spawns = WorldData.GetCustomLocs(kit.GetName().toUpperCase());
for (Location spawn : spawns)
{ {
kitIndex = 0; Entity ent = kit.SpawnEntity(spawn);
Manager.GetLobby().addKitLocation(ent, kit, spawn);
} }
Entity ent = GetKits()[kitIndex].SpawnEntity(WorldData.GetDataLocs("WHITE").get(i));
Manager.GetLobby().addKitLocation(ent, GetKits()[kitIndex], WorldData.GetDataLocs("WHITE").get(i));
kitIndex++;
} }
this.CreatureAllowOverride = false; this.CreatureAllowOverride = false;
} }
@ -711,7 +710,7 @@ public class CastleAssaultTDM extends TeamGame
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@EventHandler(ignoreCancelled=true) @EventHandler(ignoreCancelled=true)
public void onPlayerEmptyBucket(PlayerBucketFillEvent event) public void onPlayerFillBucket(PlayerBucketFillEvent event)
{ {
if (!IsLive()) if (!IsLive())
{ {
@ -719,10 +718,10 @@ public class CastleAssaultTDM extends TeamGame
} }
Player player = event.getPlayer(); Player player = event.getPlayer();
if (player.getItemInHand().getType() == Material.LAVA_BUCKET) Block block = event.getBlockClicked().getRelative(event.getBlockFace());
if (block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA)
{ {
event.setCancelled(true); event.setCancelled(true);
Block block = event.getBlockClicked().getRelative(event.getBlockFace());
player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); player.sendBlockChange(block.getLocation(), block.getType(), block.getData());
} }
} }
@ -1068,4 +1067,18 @@ public class CastleAssaultTDM extends TeamGame
_streakData.getOrDefault(player, new KillStreakData()).reset(); _streakData.getOrDefault(player, new KillStreakData()).reset();
} }
@EventHandler(ignoreCancelled = true)
public void onDamage(EntityDamageEvent event)
{
if (!IsLive())
{
return;
}
if (Manager.GetLobby().getKits().containsKey(event.getEntity()))
{
event.setCancelled(true);
return;
}
}
} }