Re-added my TurfForts patch, as well as fixed the "Game Changes to build time while spectating so you don't get your blocks" glitch.
This commit is contained in:
parent
8dd80094b4
commit
acc915c34e
@ -3,6 +3,10 @@ package nautilus.game.arcade.game.games.turfforts;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -16,15 +20,19 @@ import org.bukkit.craftbukkit.v1_7_R4.entity.CraftArrow;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.EntityArrow;
|
||||
import net.minecraft.server.v1_7_R4.Item;
|
||||
@ -45,6 +53,8 @@ import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
|
||||
import nautilus.game.arcade.events.PlayerKitGiveEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
import nautilus.game.arcade.game.games.turfforts.kits.KitInfiltrator;
|
||||
@ -106,6 +116,8 @@ public class TurfForts extends TeamGame
|
||||
|
||||
private HashMap<Player, Long> _enemyTurf = new HashMap<Player, Long>();
|
||||
|
||||
private Set<UUID> playersThatNeedBlocks = new HashSet<UUID>();
|
||||
|
||||
public TurfForts(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.TurfWars,
|
||||
@ -285,6 +297,8 @@ public class TurfForts extends TeamGame
|
||||
if (event.isCancelled()) // this statement might save just a small amount of time
|
||||
return;
|
||||
|
||||
|
||||
|
||||
if (!IsAlive(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
@ -296,6 +310,18 @@ public class TurfForts extends TeamGame
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getBlock();
|
||||
|
||||
GameTeam team = GetTeam(event.getPlayer());
|
||||
GameTeam otherTeam = GetOtherTeam(team);
|
||||
|
||||
if (block.getType().equals(Material.WOOL) && (block.getData() == 14 && team.GetColor() != ChatColor.RED) || (block.getData() == 3 && team.GetColor() != ChatColor.AQUA))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot break the " + F.elem(otherTeam.GetColor() + otherTeam.GetName()) + " team's blocks!"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
@ -524,13 +550,44 @@ public class TurfForts extends TeamGame
|
||||
for (GameTeam team : GetTeamList())
|
||||
{
|
||||
for (Player player : team.GetPlayers(true))
|
||||
{
|
||||
if (UtilPlayer.isSpectator(player))
|
||||
{
|
||||
this.playersThatNeedBlocks.add(player.getUniqueId());
|
||||
}
|
||||
else
|
||||
{
|
||||
addBlocks(team, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addBlocks(GameTeam team, Player player)
|
||||
{
|
||||
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOL, team.GetColorData(), 24));
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onQuit(PlayerQuitEvent event)
|
||||
{
|
||||
this.playersThatNeedBlocks.remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onSpawn(PlayerKitGiveEvent event)
|
||||
{
|
||||
Player player = event.GetPlayer();
|
||||
if (this.playersThatNeedBlocks.contains(player.getUniqueId()))
|
||||
{
|
||||
this.playersThatNeedBlocks.remove(player.getUniqueId());
|
||||
this.addBlocks(GetTeam(player), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@EventHandler
|
||||
@ -707,23 +764,6 @@ public class TurfForts extends TeamGame
|
||||
}
|
||||
*/
|
||||
|
||||
//Added by TheMineBench.
|
||||
@EventHandler
|
||||
public void blockBreak(BlockBreakEvent event) {
|
||||
|
||||
Block block = event.getBlock();
|
||||
|
||||
GameTeam team = GetTeam(event.getPlayer());
|
||||
GameTeam otherTeam = GetOtherTeam(team);
|
||||
|
||||
if (block.getType().equals(Material.WOOL) && (block.getData() == 14 && team.GetColor() != ChatColor.RED) || (block.getData() == 3 && team.GetColor() != ChatColor.AQUA))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot break the " + F.elem(otherTeam.GetColor() + otherTeam.GetName()) + " team's blocks!"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public GameTeam GetOtherTeam(GameTeam team) {
|
||||
return team.GetColor() == ChatColor.RED ? GetTeam(ChatColor.AQUA) : GetTeam(ChatColor.RED);
|
||||
|
Loading…
Reference in New Issue
Block a user