mirror of
https://github.com/taoneill/war.git
synced 2025-01-07 00:08:25 +01:00
Working signs on lobbies and the warhub. They spam-destroy a lot though.
This commit is contained in:
parent
72afd7068d
commit
fbf4dc26fc
@ -204,6 +204,7 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
if(team.getPlayers().size() < warzone.getTeamCap()) {
|
||||
team.addPlayer(player);
|
||||
team.resetSign();
|
||||
Warzone zone = this.warzone(player.getLocation());
|
||||
zone.respawnPlayer(team, player);
|
||||
foundTeam = true;
|
||||
@ -231,6 +232,7 @@ public class War extends JavaPlugin {
|
||||
} else {
|
||||
Team playerTeam = this.getPlayerTeam(player.getName());
|
||||
playerTeam.removePlayer(player.getName());
|
||||
playerTeam.resetSign();
|
||||
|
||||
Warzone zone = this.warzone(player.getLocation());
|
||||
player.teleportTo(zone.getTeleport());
|
||||
|
@ -47,6 +47,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
Team team = war.getPlayerTeam(player.getName());
|
||||
if(team != null) {
|
||||
team.removePlayer(player.getName());
|
||||
team.resetSign();
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,6 +179,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
Team diamondTeam = zone.getTeamByMaterial(TeamMaterials.TEAMDIAMOND);
|
||||
if(diamondTeam.getPlayers().size() < zone.getTeamCap()) {
|
||||
diamondTeam.addPlayer(player);
|
||||
diamondTeam.resetSign();
|
||||
zone.keepPlayerInventory(player);
|
||||
player.sendMessage(war.str("Your inventory is is storage until you /leave."));
|
||||
zone.respawnPlayer(event, diamondTeam, player);
|
||||
@ -193,6 +195,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
Team ironTeam = zone.getTeamByMaterial(TeamMaterials.TEAMIRON);
|
||||
if(ironTeam.getPlayers().size() < zone.getTeamCap()) {
|
||||
ironTeam.addPlayer(player);
|
||||
ironTeam.resetSign();
|
||||
zone.keepPlayerInventory(player);
|
||||
player.sendMessage(war.str("Your inventory is is storage until you /leave."));
|
||||
zone.respawnPlayer(event, ironTeam, player);
|
||||
@ -208,6 +211,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
Team goldTeam = zone.getTeamByMaterial(TeamMaterials.TEAMGOLD);
|
||||
if(goldTeam.getPlayers().size() < zone.getTeamCap()) {
|
||||
goldTeam.addPlayer(player);
|
||||
goldTeam.resetSign();
|
||||
zone.keepPlayerInventory(player);
|
||||
player.sendMessage(war.str("Your inventory is is storage until you /leave."));
|
||||
zone.respawnPlayer(event, goldTeam, player);
|
||||
@ -231,6 +235,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
// same as leave, except event.setTo
|
||||
Team playerTeam = war.getPlayerTeam(player.getName());
|
||||
playerTeam.removePlayer(player.getName());
|
||||
playerTeam.resetSign();
|
||||
event.setTo(playerWarzone.getTeleport());
|
||||
player.sendMessage(war.str("Left the zone."));
|
||||
playerWarzone.restorePlayerInventory(player);
|
||||
|
@ -6,9 +6,11 @@ import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import bukkit.tommytony.war.War;
|
||||
|
||||
@ -196,22 +198,26 @@ public class Team {
|
||||
return volume;
|
||||
}
|
||||
|
||||
|
||||
public void resetSign(){
|
||||
int x = teamSpawn.getBlockX();
|
||||
int y = teamSpawn.getBlockY();
|
||||
int z = teamSpawn.getBlockZ();
|
||||
|
||||
Block block = warzone.getWorld().getBlockAt(x, y, z);
|
||||
block.setType(Material.SIGN_POST);
|
||||
Block block = warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.SOUTH, 2).getFace(BlockFace.WEST, 2);
|
||||
if(block.getType() != Material.SIGN_POST) block.setType(Material.SIGN_POST);
|
||||
block.setData((byte)6);
|
||||
|
||||
BlockState state = block.getState();
|
||||
Sign sign = (Sign) state;
|
||||
sign.setLine(0, "Team");
|
||||
sign.setLine(1, name);
|
||||
sign.setLine(2, points + " pts");
|
||||
sign.setLine(3, remainingTickets + "/" + warzone.getLifePool() + " lives left");
|
||||
state.update(true);
|
||||
Sign sign = (Sign) state;
|
||||
sign.setLine(0, "Team " + name);
|
||||
sign.setLine(1, remainingTickets + "/" + warzone.getLifePool() + " lives left");
|
||||
sign.setLine(2, points + "/" + warzone.getScoreCap() + " pts");
|
||||
sign.setLine(3, players.size() + "/" + warzone.getTeamCap() + " players");
|
||||
state.update(true);
|
||||
|
||||
if(warzone.getLobby() != null) {
|
||||
warzone.getLobby().resetTeamGateSign(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void setVolume(Volume volume) {
|
||||
|
@ -7,6 +7,8 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
|
||||
import bukkit.tommytony.war.War;
|
||||
|
||||
@ -93,8 +95,32 @@ public class WarHub {
|
||||
}
|
||||
}
|
||||
|
||||
public void resetSigns() {
|
||||
public void resetZoneSign(Warzone zone) {
|
||||
// TODO Signs
|
||||
int i = 0;
|
||||
for(i = 0; i < war.getWarzones().size(); i++) {
|
||||
if(zone.getName() == war.getWarzones().get(i).getName()) break;
|
||||
}
|
||||
|
||||
Block zoneGate = zoneGateBlocks.get(i);
|
||||
Block block = zoneGate.getFace(BlockFace.SOUTH).getFace(BlockFace.EAST, 1);
|
||||
if(block.getType() != Material.SIGN_POST) block.setType(Material.SIGN_POST);
|
||||
block.setData((byte)8);
|
||||
|
||||
int zoneCap = 0;
|
||||
int zonePlayers = 0;
|
||||
for(Team t : zone.getTeams()) {
|
||||
zonePlayers += t.getPlayers().size();
|
||||
zoneCap += zone.getTeamCap();
|
||||
}
|
||||
|
||||
BlockState state = block.getState();
|
||||
Sign sign = (Sign) state;
|
||||
sign.setLine(0, "Warzone");
|
||||
sign.setLine(1, zone.getName());
|
||||
sign.setLine(2, zonePlayers + "/" + zoneCap + " players");
|
||||
sign.setLine(3, zone.getTeams().size() + " teams");
|
||||
state.update(true);
|
||||
}
|
||||
|
||||
public void setVolume(Volume vol) {
|
||||
|
@ -702,6 +702,7 @@ public class Warzone {
|
||||
}
|
||||
if(lowestNoOfPlayers != null) {
|
||||
lowestNoOfPlayers.addPlayer(player);
|
||||
lowestNoOfPlayers.resetSign();
|
||||
if(!hasPlayerInventory(player.getName())) {
|
||||
keepPlayerInventory(player);
|
||||
}
|
||||
@ -745,6 +746,5 @@ public class Warzone {
|
||||
return drawZoneOutline;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
|
||||
import bukkit.tommytony.war.War;
|
||||
|
||||
@ -149,6 +151,13 @@ public class ZoneLobby {
|
||||
// add war hub link gate
|
||||
if(war.getWarHub() != null) {
|
||||
placeGate(warHubLinkGate, Material.OBSIDIAN);
|
||||
// add warhub sign
|
||||
String[] lines = new String[4];
|
||||
lines[0] = "";
|
||||
lines[1] = "War hub";
|
||||
lines[2] = "";
|
||||
lines[3] = "";
|
||||
resetGateSign(warHubLinkGate, lines, false);
|
||||
}
|
||||
|
||||
// add team gates or single auto assign gate
|
||||
@ -156,6 +165,9 @@ public class ZoneLobby {
|
||||
placeGate(diamondGate, TeamMaterials.TEAMDIAMOND);
|
||||
placeGate(ironGate, TeamMaterials.TEAMIRON);
|
||||
placeGate(goldGate, TeamMaterials.TEAMGOLD);
|
||||
for(Team t : warzone.getTeams()) {
|
||||
resetTeamGateSign(t);
|
||||
}
|
||||
|
||||
// set zone tp
|
||||
zoneTeleportBlock = lobbyMiddleWallBlock.getFace(wall, 6);
|
||||
@ -447,4 +459,73 @@ public class ZoneLobby {
|
||||
public Warzone getZone() {
|
||||
return this.warzone;
|
||||
}
|
||||
|
||||
public void resetTeamGateSign(Team team) {
|
||||
if(team.getMaterial() == TeamMaterials.TEAMDIAMOND) {
|
||||
resetTeamGateSign(team, diamondGate);
|
||||
} else if(team.getMaterial() == TeamMaterials.TEAMIRON) {
|
||||
resetTeamGateSign(team, ironGate);
|
||||
} else if(team.getMaterial() == TeamMaterials.TEAMGOLD) {
|
||||
resetTeamGateSign(team, goldGate);
|
||||
}
|
||||
|
||||
if(war.getWarHub() != null) {
|
||||
war.getWarHub().resetZoneSign(warzone);
|
||||
}
|
||||
}
|
||||
|
||||
private void resetTeamGateSign(Team team, Block gate) {
|
||||
if(gate != null) {
|
||||
String[] lines = new String[4];
|
||||
lines[0] = "Team " + team.getName();
|
||||
lines[1] = team.getPlayers().size() + "/" + warzone.getTeamCap() + " players";
|
||||
lines[2] = team.getPoints() + "/" + warzone.getScoreCap() + " pts";
|
||||
lines[3] = team.getRemainingTickets() + "/" + warzone.getLifePool() + " lives left";
|
||||
resetGateSign(gate, lines, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void resetGateSign(Block gate, String[] lines, boolean awayFromWall) {
|
||||
Block block = null;
|
||||
BlockFace direction = null;
|
||||
if(awayFromWall) {
|
||||
direction = wall;
|
||||
} else if (wall == BlockFace.NORTH) {
|
||||
direction = BlockFace.SOUTH;
|
||||
} else if (wall == BlockFace.EAST) {
|
||||
direction = BlockFace.WEST;
|
||||
} else if (wall == BlockFace.SOUTH) {
|
||||
direction = BlockFace.NORTH;
|
||||
} else if (wall == BlockFace.WEST) {
|
||||
direction = BlockFace.EAST;
|
||||
}
|
||||
if(wall == BlockFace.NORTH) {
|
||||
block = gate.getFace(direction).getFace(BlockFace.EAST);
|
||||
if(block.getType() != Material.SIGN_POST) block.setType(Material.SIGN_POST);
|
||||
if(awayFromWall) block.setData((byte)4);
|
||||
else block.setData((byte)12);
|
||||
} else if(wall == BlockFace.EAST) {
|
||||
block = gate.getFace(direction).getFace(BlockFace.SOUTH);
|
||||
if(block.getType() != Material.SIGN_POST) block.setType(Material.SIGN_POST);
|
||||
if(awayFromWall) block.setData((byte)8);
|
||||
else block.setData((byte)0);
|
||||
} else if(wall == BlockFace.SOUTH) {
|
||||
block = gate.getFace(direction).getFace(BlockFace.WEST);
|
||||
if(block.getType() != Material.SIGN_POST) block.setType(Material.SIGN_POST);
|
||||
if(awayFromWall) block.setData((byte)12);
|
||||
else block.setData((byte)4);
|
||||
} else if(wall == BlockFace.WEST) {
|
||||
block = gate.getFace(direction).getFace(BlockFace.NORTH);
|
||||
if(block.getType() != Material.SIGN_POST) block.setType(Material.SIGN_POST);
|
||||
if(awayFromWall) block.setData((byte)0);
|
||||
else block.setData((byte)8);
|
||||
}
|
||||
BlockState state = block.getState();
|
||||
Sign sign = (Sign) state;
|
||||
sign.setLine(0, lines[0]);
|
||||
sign.setLine(1, lines[1]);
|
||||
sign.setLine(2, lines[2]);
|
||||
sign.setLine(3, lines[3]);
|
||||
state.update(true);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user