mirror of
https://github.com/taoneill/war.git
synced 2024-11-23 18:55:28 +01:00
Merged pull request #141 from Superyoshi/master.
Configurable Monument Heal Rate + ignoring 0 player teams Thanks Superyoshi Sorry for taking forever to merge this. I'm finally back.
This commit is contained in:
commit
50872d6802
@ -67,6 +67,7 @@ public class War extends JavaPlugin {
|
|||||||
private boolean defaultAutoAssignOnly = false;
|
private boolean defaultAutoAssignOnly = false;
|
||||||
private int defaultTeamCap = 7;
|
private int defaultTeamCap = 7;
|
||||||
private int defaultScoreCap = 10;
|
private int defaultScoreCap = 10;
|
||||||
|
private int defaultMonumentHeal = 5; //SY
|
||||||
private boolean defaultBlockHeads = true;
|
private boolean defaultBlockHeads = true;
|
||||||
private boolean defaultDropLootOnDeath = false;
|
private boolean defaultDropLootOnDeath = false;
|
||||||
private String defaultSpawnStyle = TeamSpawnStyles.BIG;
|
private String defaultSpawnStyle = TeamSpawnStyles.BIG;
|
||||||
@ -1054,6 +1055,9 @@ public class War extends JavaPlugin {
|
|||||||
if(namedParams.containsKey("lifepool")){
|
if(namedParams.containsKey("lifepool")){
|
||||||
warzone.setLifePool(Integer.parseInt(namedParams.get("lifepool")));
|
warzone.setLifePool(Integer.parseInt(namedParams.get("lifepool")));
|
||||||
}
|
}
|
||||||
|
if(namedParams.containsKey("monumentheal")){ //SY
|
||||||
|
warzone.setMonumentHeal(Integer.parseInt(namedParams.get("monumentheal")));
|
||||||
|
}
|
||||||
if(namedParams.containsKey("teamsize")){
|
if(namedParams.containsKey("teamsize")){
|
||||||
warzone.setTeamCap(Integer.parseInt(namedParams.get("teamsize")));
|
warzone.setTeamCap(Integer.parseInt(namedParams.get("teamsize")));
|
||||||
}
|
}
|
||||||
@ -1128,6 +1132,9 @@ public class War extends JavaPlugin {
|
|||||||
if(namedParams.containsKey("lifepool")){
|
if(namedParams.containsKey("lifepool")){
|
||||||
setDefaultLifepool(Integer.parseInt(namedParams.get("lifepool")));
|
setDefaultLifepool(Integer.parseInt(namedParams.get("lifepool")));
|
||||||
}
|
}
|
||||||
|
if(namedParams.containsKey("monumentheal")){ //SY
|
||||||
|
setDefaultMonumentHeal(Integer.parseInt(namedParams.get("monumentheal")));
|
||||||
|
}
|
||||||
if(namedParams.containsKey("teamsize")){
|
if(namedParams.containsKey("teamsize")){
|
||||||
setDefaultTeamCap(Integer.parseInt(namedParams.get("teamsize")));
|
setDefaultTeamCap(Integer.parseInt(namedParams.get("teamsize")));
|
||||||
}
|
}
|
||||||
@ -1317,6 +1324,14 @@ public class War extends JavaPlugin {
|
|||||||
return defaultLifepool;
|
return defaultLifepool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDefaultMonumentHeal(int defaultMonumentHeal) { //SY
|
||||||
|
this.defaultMonumentHeal = defaultMonumentHeal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDefaultMonumentHeal() { //SY
|
||||||
|
return defaultMonumentHeal;
|
||||||
|
}
|
||||||
|
|
||||||
public void setDefaultFriendlyFire(boolean defaultFriendlyFire) {
|
public void setDefaultFriendlyFire(boolean defaultFriendlyFire) {
|
||||||
this.defaultFriendlyFire = defaultFriendlyFire;
|
this.defaultFriendlyFire = defaultFriendlyFire;
|
||||||
}
|
}
|
||||||
|
@ -170,21 +170,25 @@ public class WarBlockListener extends BlockListener {
|
|||||||
// detect audacious thieves
|
// detect audacious thieves
|
||||||
war.badMsg(player, "You can only steal one flag at a time!");
|
war.badMsg(player, "You can only steal one flag at a time!");
|
||||||
} else {
|
} else {
|
||||||
// player just broke the flag block of other team: cancel to avoid drop, give player the block, set block to air
|
|
||||||
Team lostFlagTeam = warzone.getTeamForFlagBlock(block);
|
Team lostFlagTeam = warzone.getTeamForFlagBlock(block);
|
||||||
ItemStack teamKindBlock = new ItemStack(lostFlagTeam.getKind().getMaterial(), 1, (short)1, new Byte(lostFlagTeam.getKind().getData()));
|
if (lostFlagTeam.getPlayers().size() != 0) {
|
||||||
player.getInventory().clear();
|
// player just broke the flag block of other team: cancel to avoid drop, give player the block, set block to air
|
||||||
player.getInventory().addItem(teamKindBlock);
|
ItemStack teamKindBlock = new ItemStack(lostFlagTeam.getKind().getMaterial(), 1, (short)1, new Byte(lostFlagTeam.getKind().getData()));
|
||||||
warzone.addFlagThief(lostFlagTeam, player.getName());
|
player.getInventory().clear();
|
||||||
block.setType(Material.AIR);
|
player.getInventory().addItem(teamKindBlock);
|
||||||
|
warzone.addFlagThief(lostFlagTeam, player.getName());
|
||||||
for(Team t : warzone.getTeams()) {
|
block.setType(Material.AIR);
|
||||||
t.teamcast(player.getName() + " stole team " + lostFlagTeam.getName() + "'s flag.");
|
|
||||||
if(t.getName().equals(lostFlagTeam.getName())){
|
for(Team t : warzone.getTeams()) {
|
||||||
t.teamcast("Prevent " + player.getName() + " from reaching team " + team.getName() + "'s spawn or flag.");
|
t.teamcast(player.getName() + " stole team " + lostFlagTeam.getName() + "'s flag.");
|
||||||
|
if(t.getName().equals(lostFlagTeam.getName())){
|
||||||
|
t.teamcast("Prevent " + player.getName() + " from reaching team " + team.getName() + "'s spawn or flag.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
war.msg(player, "You have team " + lostFlagTeam.getName() + "'s flag. Reach your team spawn or flag to capture it!");
|
||||||
war.msg(player, "You have team " + lostFlagTeam.getName() + "'s flag. Reach your team spawn or flag to capture it!");
|
} else {
|
||||||
|
war.msg(player, "You can't steal team " + lostFlagTeam.getName() + "'s flag since there are no players there.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
@ -344,17 +344,26 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Monuments
|
// Monuments //SY
|
||||||
if(team != null
|
if(team != null
|
||||||
&& playerWarzone.nearAnyOwnedMonument(playerLoc, team)
|
&& playerWarzone.nearAnyOwnedMonument(playerLoc, team)
|
||||||
&& player.getHealth() < 20
|
&& player.getHealth() < 20
|
||||||
&& player.getHealth() > 0 // don't heal the dead
|
&& player.getHealth() > 0 // don't heal the dead
|
||||||
&& random.nextInt(77) == 3 ) { // one chance out of many of getting healed
|
&& random.nextInt(77) == 3 ) { // one chance out of many of getting healed
|
||||||
int currentHp = player.getHealth();
|
int currentHp = player.getHealth();
|
||||||
int newHp = currentHp + 5;
|
int newHp = currentHp + locZone.getMonumentHeal();
|
||||||
if(newHp > 20) newHp = 20;
|
if(newHp > 20) newHp = 20;
|
||||||
player.setHealth(newHp);
|
player.setHealth(newHp);
|
||||||
war.msg(player, "Your dance pleases the monument's voodoo. You gain health!");
|
String isS = "s"; // no 's' in 'hearts' when it's just one heart
|
||||||
|
if (newHp-currentHp==2) isS="";
|
||||||
|
String heartNum = ""; // since (newHp-currentHp)/2 won't give the right amount
|
||||||
|
if (newHp-currentHp==2)
|
||||||
|
heartNum="1 ";
|
||||||
|
else if (newHp-currentHp%2==0) // for some reason
|
||||||
|
heartNum=((newHp-currentHp)/2)+" ";
|
||||||
|
else
|
||||||
|
heartNum=((newHp-currentHp-1)/2)+".5 ";
|
||||||
|
war.msg(player, "Your dance pleases the monument's voodoo. You gain "+heartNum+"heart"+isS+"!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ public class Team {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addPoint() {
|
public void addPoint() {
|
||||||
points++;
|
if (players.size()!=0) points++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPoints() {
|
public int getPoints() {
|
||||||
@ -405,7 +405,7 @@ public class Team {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setPoints(int score) {
|
public void setPoints(int score) {
|
||||||
this.points = score;
|
if (players.size()!=0) this.points = score;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlagVolume(Volume flagVolume) {
|
public void setFlagVolume(Volume flagVolume) {
|
||||||
|
@ -44,6 +44,7 @@ public class Warzone {
|
|||||||
private boolean drawZoneOutline;
|
private boolean drawZoneOutline;
|
||||||
private int teamCap = 5;
|
private int teamCap = 5;
|
||||||
private int scoreCap = 5;
|
private int scoreCap = 5;
|
||||||
|
private int monumentHeal = 5;
|
||||||
private String spawnStyle = TeamSpawnStyles.BIG;
|
private String spawnStyle = TeamSpawnStyles.BIG;
|
||||||
private HashMap<Integer, ItemStack> reward = new HashMap<Integer, ItemStack>();
|
private HashMap<Integer, ItemStack> reward = new HashMap<Integer, ItemStack>();
|
||||||
|
|
||||||
@ -74,6 +75,7 @@ public class Warzone {
|
|||||||
this.setAutoAssignOnly(war.getDefaultAutoAssignOnly());
|
this.setAutoAssignOnly(war.getDefaultAutoAssignOnly());
|
||||||
this.teamCap = war.getDefaultTeamCap();
|
this.teamCap = war.getDefaultTeamCap();
|
||||||
this.scoreCap = war.getDefaultScoreCap();
|
this.scoreCap = war.getDefaultScoreCap();
|
||||||
|
this.monumentHeal = war.getDefaultMonumentHeal();
|
||||||
this.setBlockHeads(war.isDefaultBlockHeads());
|
this.setBlockHeads(war.isDefaultBlockHeads());
|
||||||
this.setDropLootOnDeath(war.isDefaultDropLootOnDeath());
|
this.setDropLootOnDeath(war.isDefaultDropLootOnDeath());
|
||||||
this.setUnbreakableZoneBlocks(war.isDefaultUnbreakableZoneBlocks());
|
this.setUnbreakableZoneBlocks(war.isDefaultUnbreakableZoneBlocks());
|
||||||
@ -477,6 +479,14 @@ public class Warzone {
|
|||||||
public int getLifePool() {
|
public int getLifePool() {
|
||||||
return lifePool;
|
return lifePool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMonumentHeal(int monumentHeal) { //SY
|
||||||
|
this.monumentHeal = monumentHeal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMonumentHeal() { //SY
|
||||||
|
return monumentHeal;
|
||||||
|
}
|
||||||
|
|
||||||
public void setFriendlyFire(boolean ffOn) {
|
public void setFriendlyFire(boolean ffOn) {
|
||||||
this.friendlyFire = ffOn;
|
this.friendlyFire = ffOn;
|
||||||
@ -870,12 +880,14 @@ public class Warzone {
|
|||||||
t.teamcast("The battle is over. Team " + playerTeam.getName() + " lost: "
|
t.teamcast("The battle is over. Team " + playerTeam.getName() + " lost: "
|
||||||
+ player.getName() + " died and there were no lives left in their life pool.");
|
+ player.getName() + " died and there were no lives left in their life pool.");
|
||||||
|
|
||||||
if(!t.getName().equals(playerTeam.getName())) {
|
if (t.getPlayers().size() != 0) {
|
||||||
// all other teams get a point
|
if(!t.getName().equals(playerTeam.getName())) {
|
||||||
t.addPoint();
|
// all other teams get a point
|
||||||
t.resetSign();
|
t.addPoint();
|
||||||
|
t.resetSign();
|
||||||
|
}
|
||||||
|
scores += t.getName() + "(" + t.getPoints() + ") " ;
|
||||||
}
|
}
|
||||||
scores += t.getName() + "(" + t.getPoints() + ") " ;
|
|
||||||
}
|
}
|
||||||
if(!scores.equals("")){
|
if(!scores.equals("")){
|
||||||
for(Team t : teams) {
|
for(Team t : teams) {
|
||||||
@ -892,7 +904,7 @@ public class Warzone {
|
|||||||
if(!scoreCapTeams.isEmpty()) {
|
if(!scoreCapTeams.isEmpty()) {
|
||||||
String winnersStr = "";
|
String winnersStr = "";
|
||||||
for(Team winner : scoreCapTeams) {
|
for(Team winner : scoreCapTeams) {
|
||||||
winnersStr += winner.getName() + " ";
|
if (winner.getPlayers().size() != 0) winnersStr += winner.getName() + " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
playerWarzone.handleScoreCapReached(player, winnersStr);
|
playerWarzone.handleScoreCapReached(player, winnersStr);
|
||||||
|
@ -79,6 +79,9 @@ public class WarMapper {
|
|||||||
// defaultLifePool
|
// defaultLifePool
|
||||||
war.setDefaultLifepool(warConfig.getInt("defaultLifePool"));
|
war.setDefaultLifepool(warConfig.getInt("defaultLifePool"));
|
||||||
|
|
||||||
|
// defaultMonumentHeal //SY
|
||||||
|
war.setDefaultLifepool(warConfig.getInt("defaultMonumentHeal"));
|
||||||
|
|
||||||
// defaultFriendlyFire
|
// defaultFriendlyFire
|
||||||
war.setDefaultFriendlyFire(warConfig.getBoolean("defaultFriendlyFire"));
|
war.setDefaultFriendlyFire(warConfig.getBoolean("defaultFriendlyFire"));
|
||||||
|
|
||||||
@ -182,6 +185,9 @@ public class WarMapper {
|
|||||||
// defaultLifepool
|
// defaultLifepool
|
||||||
warConfig.setInt("defaultLifePool", war.getDefaultLifepool());
|
warConfig.setInt("defaultLifePool", war.getDefaultLifepool());
|
||||||
|
|
||||||
|
// defaultMonumentHeal //SY
|
||||||
|
warConfig.setInt("defaultMonumentHeal", war.getDefaultMonumentHeal());
|
||||||
|
|
||||||
// defaultFriendlyFire
|
// defaultFriendlyFire
|
||||||
warConfig.setBoolean("defaultFriendlyFire", war.getDefaultFriendlyFire());
|
warConfig.setBoolean("defaultFriendlyFire", war.getDefaultFriendlyFire());
|
||||||
|
|
||||||
|
@ -170,6 +170,9 @@ public class WarzoneMapper {
|
|||||||
// life pool
|
// life pool
|
||||||
warzone.setLifePool(warzoneConfig.getInt("lifePool"));
|
warzone.setLifePool(warzoneConfig.getInt("lifePool"));
|
||||||
|
|
||||||
|
// monument heal //SY
|
||||||
|
warzone.setMonumentHeal(warzoneConfig.getInt("monumentHeal"));
|
||||||
|
|
||||||
// drawZoneOutline
|
// drawZoneOutline
|
||||||
warzone.setDrawZoneOutline(warzoneConfig.getBoolean("drawZoneOutline"));
|
warzone.setDrawZoneOutline(warzoneConfig.getBoolean("drawZoneOutline"));
|
||||||
|
|
||||||
@ -390,6 +393,9 @@ public class WarzoneMapper {
|
|||||||
// life pool
|
// life pool
|
||||||
warzoneConfig.setInt("lifePool", warzone.getLifePool());
|
warzoneConfig.setInt("lifePool", warzone.getLifePool());
|
||||||
|
|
||||||
|
// monument heal //SY
|
||||||
|
warzoneConfig.setInt("monumentHeal", warzone.getMonumentHeal());
|
||||||
|
|
||||||
// drawZoneOutline
|
// drawZoneOutline
|
||||||
warzoneConfig.setBoolean("drawZoneOutline", warzone.isDrawZoneOutline());
|
warzoneConfig.setBoolean("drawZoneOutline", warzone.isDrawZoneOutline());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user