diff --git a/war/.classpath b/war/.classpath index cb8a30d..af0eeff 100644 --- a/war/.classpath +++ b/war/.classpath @@ -1,7 +1,6 @@ - diff --git a/war/src/main/java/bukkit/tommytony/war/WarPlayerListener.java b/war/src/main/java/bukkit/tommytony/war/WarPlayerListener.java index a831b5f..f5ffed1 100644 --- a/war/src/main/java/bukkit/tommytony/war/WarPlayerListener.java +++ b/war/src/main/java/bukkit/tommytony/war/WarPlayerListener.java @@ -594,14 +594,14 @@ public class WarPlayerListener extends PlayerListener { if(oldTeam == null) { // trying to counter spammy player move if(zone.getLobby().isAutoAssignGate(to)) { dropFromOldTeamIfAny(player); - zone.autoAssign(player); - } else if (zone.getLobby().isInTeamGate(TeamMaterials.TEAMDIAMOND, to)){ + zone.autoAssign(event, player); + } else if (zone.getLobby().isInTeamGate(TeamMaterials.TEAMDIAMOND, from)){ dropFromOldTeamIfAny(player); Team diamondTeam = zone.getTeamByMaterial(TeamMaterials.TEAMDIAMOND); diamondTeam.addPlayer(player); zone.keepPlayerInventory(player); player.sendMessage(war.str("Your inventory is is storage until you /leave.")); - zone.respawnPlayer(diamondTeam, player); + zone.respawnPlayer(event, diamondTeam, player); for(Team team : zone.getTeams()){ team.teamcast(war.str("" + player.getName() + " joined team diamond.")); } @@ -611,7 +611,7 @@ public class WarPlayerListener extends PlayerListener { ironTeam.addPlayer(player); zone.keepPlayerInventory(player); player.sendMessage(war.str("Your inventory is is storage until you /leave.")); - zone.respawnPlayer(ironTeam, player); + zone.respawnPlayer(event, ironTeam, player); for(Team team : zone.getTeams()){ team.teamcast(war.str("" + player.getName() + " joined team iron.")); } @@ -621,12 +621,13 @@ public class WarPlayerListener extends PlayerListener { goldTeam.addPlayer(player); zone.keepPlayerInventory(player); player.sendMessage(war.str("Your inventory is is storage until you /leave.")); - zone.respawnPlayer(goldTeam, player); + zone.respawnPlayer(event, goldTeam, player); for(Team team : zone.getTeams()){ team.teamcast(war.str("" + player.getName() + " joined team gold.")); } } else if (zone.getLobby().isInWarHubLinkGate(to)){ dropFromOldTeamIfAny(player); + event.setTo(to); player.teleportTo(war.getWarHub().getLocation()); } } @@ -639,11 +640,13 @@ public class WarPlayerListener extends PlayerListener { if(hub != null) { Warzone zone = hub.getDestinationWarzoneForLocation(player.getLocation()); synchronized(player) { + if(zone != null && (zone.getTeleport().getBlockX() - player.getLocation().getBlockX() > 10 || zone.getTeleport().getBlockZ() - player.getLocation().getBlockZ() > 10) // trying to prevent effects of spammy player move ) { - player.teleportTo(zone.getTeleport()); + event.setTo(zone.getTeleport()); + //player.teleportTo(zone.getTeleport()); player.sendMessage(war.str("Welcome to warzone " + zone.getName() + ".")); } } diff --git a/war/src/main/java/com/tommytony/war/Warzone.java b/war/src/main/java/com/tommytony/war/Warzone.java index da0b995..1186b78 100644 --- a/war/src/main/java/com/tommytony/war/Warzone.java +++ b/war/src/main/java/com/tommytony/war/Warzone.java @@ -11,6 +11,7 @@ import org.bukkit.Material; import org.bukkit.Player; import org.bukkit.PlayerInventory; import org.bukkit.World; +import org.bukkit.event.player.PlayerMoveEvent; import bukkit.tommytony.war.War; @@ -280,7 +281,15 @@ public class Warzone { public void respawnPlayer(Team team, Player player) { player.teleportTo(team.getTeamSpawn()); - + handleRespawn(team, player); + } + + public void respawnPlayer(PlayerMoveEvent event, Team team, Player player) { + event.setTo(team.getTeamSpawn()); + handleRespawn(team, player); + } + + private void handleRespawn(Team team, Player player){ // Reset inventory to loadout PlayerInventory playerInv = player.getInventory(); // BUKKIT @@ -389,12 +398,13 @@ public class Warzone { public void restorePlayerInventory(Player player) { List originalContents = inventories.remove(player.getName()); PlayerInventory playerInv = player.getInventory(); - for(int i = 0; i < playerInv.getSize(); i++) { - playerInv.setItem(i, new ItemStack(Material.AIR)); - } - for(int i = 0; i < playerInv.getSize(); i++) { - playerInv.setItem(i, originalContents.get(i)); - } + // BUKKIT +// for(int i = 0; i < playerInv.getSize(); i++) { +// playerInv.setItem(i, new ItemStack(Material.AIR)); +// } +// for(int i = 0; i < playerInv.getSize(); i++) { +// playerInv.setItem(i, originalContents.get(i)); +// } } public boolean hasMonument(String monumentName) { @@ -632,7 +642,7 @@ public class Warzone { return lobby; } - public void autoAssign(Player player) { + public void autoAssign(PlayerMoveEvent event, Player player) { Team lowestNoOfPlayers = null; for(Team t : teams) { if(lowestNoOfPlayers == null @@ -646,7 +656,7 @@ public class Warzone { keepPlayerInventory(player); } player.sendMessage(war.str("Your inventory is is storage until you /leave.")); - respawnPlayer(lowestNoOfPlayers, player); + respawnPlayer(event, lowestNoOfPlayers, player); for(Team team : teams){ team.teamcast(war.str("" + player.getName() + " joined team " + team.getName() + ".")); } diff --git a/war/src/main/java/com/tommytony/war/ZoneLobby.java b/war/src/main/java/com/tommytony/war/ZoneLobby.java index dea92e3..e2be3d6 100644 --- a/war/src/main/java/com/tommytony/war/ZoneLobby.java +++ b/war/src/main/java/com/tommytony/war/ZoneLobby.java @@ -156,7 +156,7 @@ public class ZoneLobby { if(warzone.getTeamByMaterial(TeamMaterials.TEAMDIAMOND) != null && warzone.getTeamByMaterial(TeamMaterials.TEAMIRON) != null) { diamondGate = lobbyMiddleWallBlock.getFace(leftSide, 2); - ironGate = lobbyMiddleWallBlock.getFace(BlockFace.West, 2); + ironGate = lobbyMiddleWallBlock.getFace(rightSide, 2); } else if (warzone.getTeamByMaterial(TeamMaterials.TEAMIRON) != null && warzone.getTeamByMaterial(TeamMaterials.TEAMGOLD) != null) { ironGate = lobbyMiddleWallBlock.getFace(leftSide, 2); diff --git a/war/src/main/resources/plugin.yml b/war/src/main/resources/plugin.yml deleted file mode 100644 index 4b28239..0000000 --- a/war/src/main/resources/plugin.yml +++ /dev/null @@ -1,3 +0,0 @@ -name: War -main: bukkit.tommytony.war.War -version: 0.3 \ No newline at end of file