mirror of
https://github.com/taoneill/war.git
synced 2024-11-23 18:55:28 +01:00
Added teamCap and scoreCap. Also mapped autoAssign and drawOutiline in warzone file.
This commit is contained in:
parent
efa3b63ea9
commit
72afd7068d
@ -52,10 +52,13 @@ public class War extends JavaPlugin {
|
||||
private final List<Warzone> warzones = new ArrayList<Warzone>();
|
||||
private final List<String> zoneMakerNames = new ArrayList<String>();
|
||||
private final HashMap<Integer, ItemStack> defaultLoadout = new HashMap<Integer, ItemStack>();
|
||||
private int defaultLifepool = 7;
|
||||
private int defaultLifepool = 15;
|
||||
private boolean defaultFriendlyFire = false;
|
||||
private boolean defaultDrawZoneOutline = true;
|
||||
private boolean defaultAutoAssignOnly = false;
|
||||
private int defaultTeamCap = 5;
|
||||
private int defaultScoreCap = 5;
|
||||
private boolean pvpInZonesOnly = false;
|
||||
private WarHub warHub;
|
||||
|
||||
public void onDisable() {
|
||||
@ -199,10 +202,15 @@ public class War extends JavaPlugin {
|
||||
warzone.keepPlayerInventory(player);
|
||||
player.sendMessage(this.str("Your inventory is is storage until you /leave."));
|
||||
}
|
||||
team.addPlayer(player);
|
||||
Warzone zone = this.warzone(player.getLocation());
|
||||
zone.respawnPlayer(team, player);
|
||||
foundTeam = true;
|
||||
if(team.getPlayers().size() < warzone.getTeamCap()) {
|
||||
team.addPlayer(player);
|
||||
Warzone zone = this.warzone(player.getLocation());
|
||||
zone.respawnPlayer(team, player);
|
||||
foundTeam = true;
|
||||
} else {
|
||||
player.sendMessage(this.str("Team " + name + " is full."));
|
||||
foundTeam = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(foundTeam) {
|
||||
@ -835,5 +843,29 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setDefaultTeamCap(int defaultTeamCap) {
|
||||
this.defaultTeamCap = defaultTeamCap;
|
||||
}
|
||||
|
||||
public int getDefaultTeamCap() {
|
||||
return defaultTeamCap;
|
||||
}
|
||||
|
||||
public void setPvpInZonesOnly(boolean pvpInZonesOnly) {
|
||||
this.pvpInZonesOnly = pvpInZonesOnly;
|
||||
}
|
||||
|
||||
public boolean isPvpInZonesOnly() {
|
||||
return pvpInZonesOnly;
|
||||
}
|
||||
|
||||
public void setDefaultScoreCap(int defaultScoreCap) {
|
||||
this.defaultScoreCap = defaultScoreCap;
|
||||
}
|
||||
|
||||
public int getDefaultScoreCap() {
|
||||
return defaultScoreCap;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -154,8 +154,8 @@ public class WarEntityListener extends EntityListener {
|
||||
a.sendMessage(war.str("Your target is on your team."));
|
||||
event.setCancelled(true); // ff is off
|
||||
}
|
||||
} else if (attackerTeam == null && defenderTeam == null){
|
||||
// normal PVP
|
||||
} else if (attackerTeam == null && defenderTeam == null && !war.isPvpInZonesOnly()){
|
||||
// let normal PVP through is its not turned off
|
||||
} else {
|
||||
a.sendMessage(war.str("Your attack missed!"));
|
||||
if(attackerTeam == null) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
package bukkit.tommytony.war;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Level;
|
||||
@ -76,7 +77,8 @@ public class WarPlayerListener extends PlayerListener {
|
||||
if(from != null && war.warzone(player.getLocation()) == null && team != null) {
|
||||
// teleport to team spawn upon death
|
||||
|
||||
boolean roundOver = false;
|
||||
boolean newBattle = false;
|
||||
boolean scoreCapReached = false;
|
||||
synchronized(playerWarzone) {
|
||||
int remaining = team.getRemainingTickets();
|
||||
if(remaining == 0) { // your death caused your team to lose
|
||||
@ -84,26 +86,55 @@ public class WarPlayerListener extends PlayerListener {
|
||||
for(Team t : teams) {
|
||||
t.teamcast(war.str("The battle is over. Team " + team.getName() + " lost: "
|
||||
+ player.getName() + " hit the bottom of their life pool." ));
|
||||
t.teamcast(war.str("A new battle begins. The warzone is being reset..."));
|
||||
|
||||
if(!t.getName().equals(team.getName())) {
|
||||
// all other teams get a point
|
||||
t.addPoint();
|
||||
t.resetSign();
|
||||
}
|
||||
}
|
||||
playerWarzone.getVolume().resetBlocks();
|
||||
playerWarzone.initializeZone();
|
||||
roundOver = true;
|
||||
// detect score cap
|
||||
List<Team> scoreCapTeams = new ArrayList<Team>();
|
||||
for(Team t : teams) {
|
||||
if(t.getPoints() == playerWarzone.getScoreCap()) {
|
||||
scoreCapTeams.add(t);
|
||||
}
|
||||
}
|
||||
if(!scoreCapTeams.isEmpty()) {
|
||||
String winnersStr = "Score cap reached! Winning team(s): ";
|
||||
for(Team winner : scoreCapTeams) {
|
||||
winnersStr += winner.getName() + " ";
|
||||
}
|
||||
winnersStr += ". The warzone is being reset... Please choose a new team.";
|
||||
// Score cap reached. Reset everything.
|
||||
for(Team t : teams) {
|
||||
t.teamcast(war.str(winnersStr));
|
||||
t.getPlayers().clear(); // empty the team
|
||||
}
|
||||
scoreCapReached = true;
|
||||
} else {
|
||||
// We can keep going
|
||||
for(Team t : teams) {
|
||||
t.teamcast(war.str("A new battle begins. The warzone is being reset..."));
|
||||
}
|
||||
playerWarzone.getVolume().resetBlocks();
|
||||
playerWarzone.initializeZone();
|
||||
newBattle = true;
|
||||
}
|
||||
} else {
|
||||
team.setRemainingTickets(remaining - 1);
|
||||
}
|
||||
}
|
||||
synchronized(player) {
|
||||
if(!roundOver && !war.inAnyWarzone(player.getLocation())) { // only respawn him if he isnt back at zone yet
|
||||
if(!newBattle && !scoreCapReached && !war.inAnyWarzone(player.getLocation())) { // only respawn him if he isnt back at zone yet
|
||||
playerWarzone.respawnPlayer(event, team, player);
|
||||
team.resetSign();
|
||||
war.getLogger().log(Level.INFO, player.getName() + " died and was tp'd back to team " + team.getName() + "'s spawn");
|
||||
} else {
|
||||
} else if (scoreCapReached) {
|
||||
player.teleportTo(playerWarzone.getTeleport());
|
||||
team.resetSign();
|
||||
war.getLogger().log(Level.INFO, player.getName() + " died and enemy team reached score cap");
|
||||
} else if (newBattle){
|
||||
war.getLogger().log(Level.INFO, player.getName() + " died and battle ended in team " + team.getName() + "'s disfavor");
|
||||
}
|
||||
}
|
||||
@ -132,36 +163,60 @@ public class WarPlayerListener extends PlayerListener {
|
||||
if(oldTeam == null) { // trying to counter spammy player move
|
||||
if(zone.getLobby().isAutoAssignGate(to)) {
|
||||
dropFromOldTeamIfAny(player);
|
||||
zone.autoAssign(event, player);
|
||||
int noOfPlayers = 0;
|
||||
for(Team t : zone.getTeams()) {
|
||||
noOfPlayers += t.getPlayers().size();
|
||||
}
|
||||
if(noOfPlayers < zone.getTeams().size() * zone.getTeamCap()) {
|
||||
zone.autoAssign(event, player);
|
||||
} else {
|
||||
event.setTo(zone.getTeleport());
|
||||
player.sendMessage("All teams are full.");
|
||||
}
|
||||
} else if (zone.getLobby().isInTeamGate(TeamMaterials.TEAMDIAMOND, to)){
|
||||
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(event, diamondTeam, player);
|
||||
for(Team team : zone.getTeams()){
|
||||
team.teamcast(war.str("" + player.getName() + " joined team diamond."));
|
||||
if(diamondTeam.getPlayers().size() < zone.getTeamCap()) {
|
||||
diamondTeam.addPlayer(player);
|
||||
zone.keepPlayerInventory(player);
|
||||
player.sendMessage(war.str("Your inventory is is storage until you /leave."));
|
||||
zone.respawnPlayer(event, diamondTeam, player);
|
||||
for(Team team : zone.getTeams()){
|
||||
team.teamcast(war.str("" + player.getName() + " joined team diamond."));
|
||||
}
|
||||
} else {
|
||||
event.setTo(zone.getTeleport());
|
||||
player.sendMessage("Team diamond is full.");
|
||||
}
|
||||
} else if (zone.getLobby().isInTeamGate(TeamMaterials.TEAMIRON, to)){
|
||||
dropFromOldTeamIfAny(player);
|
||||
Team ironTeam = zone.getTeamByMaterial(TeamMaterials.TEAMIRON);
|
||||
ironTeam.addPlayer(player);
|
||||
zone.keepPlayerInventory(player);
|
||||
player.sendMessage(war.str("Your inventory is is storage until you /leave."));
|
||||
zone.respawnPlayer(event, ironTeam, player);
|
||||
for(Team team : zone.getTeams()){
|
||||
team.teamcast(war.str("" + player.getName() + " joined team iron."));
|
||||
if(ironTeam.getPlayers().size() < zone.getTeamCap()) {
|
||||
ironTeam.addPlayer(player);
|
||||
zone.keepPlayerInventory(player);
|
||||
player.sendMessage(war.str("Your inventory is is storage until you /leave."));
|
||||
zone.respawnPlayer(event, ironTeam, player);
|
||||
for(Team team : zone.getTeams()){
|
||||
team.teamcast(war.str("" + player.getName() + " joined team iron."));
|
||||
}
|
||||
} else {
|
||||
event.setTo(zone.getTeleport());
|
||||
player.sendMessage("Team iron is full.");
|
||||
}
|
||||
} else if (zone.getLobby().isInTeamGate(TeamMaterials.TEAMGOLD, to)){
|
||||
dropFromOldTeamIfAny(player);
|
||||
Team goldTeam = zone.getTeamByMaterial(TeamMaterials.TEAMGOLD);
|
||||
goldTeam.addPlayer(player);
|
||||
zone.keepPlayerInventory(player);
|
||||
player.sendMessage(war.str("Your inventory is is storage until you /leave."));
|
||||
zone.respawnPlayer(event, goldTeam, player);
|
||||
for(Team team : zone.getTeams()){
|
||||
team.teamcast(war.str("" + player.getName() + " joined team gold."));
|
||||
if(goldTeam.getPlayers().size() < zone.getTeamCap()) {
|
||||
goldTeam.addPlayer(player);
|
||||
zone.keepPlayerInventory(player);
|
||||
player.sendMessage(war.str("Your inventory is is storage until you /leave."));
|
||||
zone.respawnPlayer(event, goldTeam, player);
|
||||
for(Team team : zone.getTeams()){
|
||||
team.teamcast(war.str("" + player.getName() + " joined team gold."));
|
||||
}
|
||||
} else {
|
||||
event.setTo(zone.getTeleport());
|
||||
player.sendMessage("Team gold is full.");
|
||||
}
|
||||
} else if (zone.getLobby().isInWarHubLinkGate(to)){
|
||||
dropFromOldTeamIfAny(player);
|
||||
|
@ -35,6 +35,8 @@ public class Warzone {
|
||||
private int lifePool;
|
||||
private HashMap<Integer, ItemStack> loadout;
|
||||
private boolean drawZoneOutline;
|
||||
private int teamCap = 5;
|
||||
private int scoreCap = 5;
|
||||
|
||||
private HashMap<String, ItemStack[]> inventories = new HashMap<String, ItemStack[]>();
|
||||
private World world;
|
||||
@ -54,8 +56,10 @@ public class Warzone {
|
||||
this.friendlyFire = war.getDefaultFriendlyFire();
|
||||
this.setLifePool(war.getDefaultLifepool());
|
||||
this.setLoadout(war.getDefaultLoadout());
|
||||
this.drawZoneOutline = war.getDefaultDrawZoneOutline();
|
||||
this.autoAssignOnly = war.getDefaultAutoAssignOnly();
|
||||
this.setDrawZoneOutline(war.getDefaultDrawZoneOutline());
|
||||
this.setAutoAssignOnly(war.getDefaultAutoAssignOnly());
|
||||
this.teamCap = war.getDefaultTeamCap();
|
||||
this.scoreCap = war.getDefaultScoreCap();
|
||||
this.volume = new VerticalVolume(name, war, this.getWorld());
|
||||
}
|
||||
|
||||
@ -237,7 +241,7 @@ public class Warzone {
|
||||
|
||||
private void initZone() {
|
||||
// add wall outlines
|
||||
if(drawZoneOutline) {
|
||||
if(isDrawZoneOutline()) {
|
||||
addZoneOutline(BlockFace.NORTH);
|
||||
addZoneOutline(BlockFace.EAST);
|
||||
addZoneOutline(BlockFace.SOUTH);
|
||||
@ -657,7 +661,7 @@ public class Warzone {
|
||||
if(guard.getPlayer().getName().equals(player.getName())){
|
||||
playerGuards.add(guard);
|
||||
int reset = volume.resetWallBlocks(guard.getWall()); // this should restore old blocks
|
||||
if(drawZoneOutline) {
|
||||
if(isDrawZoneOutline()) {
|
||||
addZoneOutline(guard.getWall());
|
||||
}
|
||||
if(lobby != null) {
|
||||
@ -677,7 +681,7 @@ public class Warzone {
|
||||
|
||||
public boolean getAutoAssignOnly() {
|
||||
|
||||
return autoAssignOnly;
|
||||
return isAutoAssignOnly();
|
||||
}
|
||||
|
||||
public void setLobby(ZoneLobby lobby) {
|
||||
@ -709,6 +713,38 @@ public class Warzone {
|
||||
}
|
||||
}
|
||||
|
||||
public void setTeamCap(int teamCap) {
|
||||
this.teamCap = teamCap;
|
||||
}
|
||||
|
||||
public int getTeamCap() {
|
||||
return teamCap;
|
||||
}
|
||||
|
||||
public void setScoreCap(int scoreCap) {
|
||||
this.scoreCap = scoreCap;
|
||||
}
|
||||
|
||||
public int getScoreCap() {
|
||||
return scoreCap;
|
||||
}
|
||||
|
||||
public void setAutoAssignOnly(boolean autoAssignOnly) {
|
||||
this.autoAssignOnly = autoAssignOnly;
|
||||
}
|
||||
|
||||
public boolean isAutoAssignOnly() {
|
||||
return autoAssignOnly;
|
||||
}
|
||||
|
||||
public void setDrawZoneOutline(boolean drawZoneOutline) {
|
||||
this.drawZoneOutline = drawZoneOutline;
|
||||
}
|
||||
|
||||
public boolean isDrawZoneOutline() {
|
||||
return drawZoneOutline;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -96,6 +96,15 @@ public class WarMapper {
|
||||
// defaultAutoAssignOnly
|
||||
war.setDefaultAutoAssignOnly(warConfig.getBoolean("defaultAutoAssignOnly"));
|
||||
|
||||
// defaultTeamCap
|
||||
war.setDefaultTeamCap(warConfig.getInt("defaultTeamCap"));
|
||||
|
||||
// defaultScoreCap
|
||||
war.setDefaultScoreCap(warConfig.getInt("defaultScoreCap"));
|
||||
|
||||
// defaultScoreCap
|
||||
war.setPvpInZonesOnly(warConfig.getBoolean("pvpInZonesOnly"));
|
||||
|
||||
// warhub
|
||||
String hubStr = warConfig.getString("warhub");
|
||||
if(hubStr != null && !hubStr.equals("")) {
|
||||
@ -163,6 +172,16 @@ public class WarMapper {
|
||||
// defaultAutoAssignOnly
|
||||
warConfig.setBoolean("defaultAutoAssignOnly", war.getDefaultAutoAssignOnly());
|
||||
|
||||
// defaultTeamCap
|
||||
warConfig.setInt("defaultTeamCap", war.getDefaultTeamCap());
|
||||
|
||||
// defaultScoreCap
|
||||
warConfig.getInt("defaultScoreCap", war.getDefaultScoreCap());
|
||||
|
||||
// defaultScoreCap
|
||||
warConfig.setBoolean("pvpInZonesOnly", war.isPvpInZonesOnly());
|
||||
war.setPvpInZonesOnly(warConfig.getBoolean("pvpInZonesOnly"));
|
||||
|
||||
// warhub
|
||||
String hubStr = "";
|
||||
WarHub hub = war.getWarHub();
|
||||
|
@ -131,6 +131,19 @@ public class WarzoneMapper {
|
||||
|
||||
// life pool
|
||||
warzone.setLifePool(warzoneConfig.getInt("lifePool"));
|
||||
|
||||
// drawZoneOutline
|
||||
warzone.setFriendlyFire(warzoneConfig.getBoolean("drawZoneOutline"));
|
||||
|
||||
// autoAssignOnly
|
||||
warzone.setAutoAssignOnly(warzoneConfig.getBoolean("autoAssignOnly"));
|
||||
|
||||
// team cap
|
||||
warzone.setTeamCap(warzoneConfig.getInt("teamCap"));
|
||||
|
||||
// score cap
|
||||
warzone.setScoreCap(warzoneConfig.getInt("scoreCap"));
|
||||
|
||||
|
||||
// monuments
|
||||
String monumentsStr = warzoneConfig.getString("monuments");
|
||||
@ -252,6 +265,18 @@ public class WarzoneMapper {
|
||||
// life pool
|
||||
warzoneConfig.setInt("lifePool", warzone.getLifePool());
|
||||
|
||||
// drawZoneOutline
|
||||
warzoneConfig.setBoolean("drawZoneOutline", warzone.isDrawZoneOutline());
|
||||
|
||||
// autoAssignOnly
|
||||
warzoneConfig.setBoolean("autoAssignOnly", warzone.isAutoAssignOnly());
|
||||
|
||||
// team cap
|
||||
warzoneConfig.setInt("teamCap", warzone.getTeamCap());
|
||||
|
||||
// score cap
|
||||
warzoneConfig.setInt("scoreCap", warzone.getScoreCap());
|
||||
|
||||
// monuments
|
||||
String monumentsStr = "";
|
||||
List<Monument> monuments = warzone.getMonuments();
|
||||
|
Loading…
Reference in New Issue
Block a user