mirror of
https://github.com/taoneill/war.git
synced 2024-11-24 03:05:54 +01:00
Working lobby portals - dont use player.teleportTo but event.setTo instead instead a PlayerMoveEvent. Fixed lobby door bug.
This commit is contained in:
parent
78eafe7ba8
commit
5cd2d90173
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
|
||||
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/bukkit"/>
|
||||
|
@ -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() + "."));
|
||||
}
|
||||
}
|
||||
|
@ -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<ItemStack> 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() + "."));
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -1,3 +0,0 @@
|
||||
name: War
|
||||
main: bukkit.tommytony.war.War
|
||||
version: 0.3
|
Loading…
Reference in New Issue
Block a user