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 int defaultTeamCap = 7;
|
||||
private int defaultScoreCap = 10;
|
||||
private int defaultMonumentHeal = 5; //SY
|
||||
private boolean defaultBlockHeads = true;
|
||||
private boolean defaultDropLootOnDeath = false;
|
||||
private String defaultSpawnStyle = TeamSpawnStyles.BIG;
|
||||
@ -1054,6 +1055,9 @@ public class War extends JavaPlugin {
|
||||
if(namedParams.containsKey("lifepool")){
|
||||
warzone.setLifePool(Integer.parseInt(namedParams.get("lifepool")));
|
||||
}
|
||||
if(namedParams.containsKey("monumentheal")){ //SY
|
||||
warzone.setMonumentHeal(Integer.parseInt(namedParams.get("monumentheal")));
|
||||
}
|
||||
if(namedParams.containsKey("teamsize")){
|
||||
warzone.setTeamCap(Integer.parseInt(namedParams.get("teamsize")));
|
||||
}
|
||||
@ -1128,6 +1132,9 @@ public class War extends JavaPlugin {
|
||||
if(namedParams.containsKey("lifepool")){
|
||||
setDefaultLifepool(Integer.parseInt(namedParams.get("lifepool")));
|
||||
}
|
||||
if(namedParams.containsKey("monumentheal")){ //SY
|
||||
setDefaultMonumentHeal(Integer.parseInt(namedParams.get("monumentheal")));
|
||||
}
|
||||
if(namedParams.containsKey("teamsize")){
|
||||
setDefaultTeamCap(Integer.parseInt(namedParams.get("teamsize")));
|
||||
}
|
||||
@ -1317,6 +1324,14 @@ public class War extends JavaPlugin {
|
||||
return defaultLifepool;
|
||||
}
|
||||
|
||||
public void setDefaultMonumentHeal(int defaultMonumentHeal) { //SY
|
||||
this.defaultMonumentHeal = defaultMonumentHeal;
|
||||
}
|
||||
|
||||
public int getDefaultMonumentHeal() { //SY
|
||||
return defaultMonumentHeal;
|
||||
}
|
||||
|
||||
public void setDefaultFriendlyFire(boolean defaultFriendlyFire) {
|
||||
this.defaultFriendlyFire = defaultFriendlyFire;
|
||||
}
|
||||
|
@ -170,21 +170,25 @@ public class WarBlockListener extends BlockListener {
|
||||
// detect audacious thieves
|
||||
war.badMsg(player, "You can only steal one flag at a time!");
|
||||
} 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);
|
||||
ItemStack teamKindBlock = new ItemStack(lostFlagTeam.getKind().getMaterial(), 1, (short)1, new Byte(lostFlagTeam.getKind().getData()));
|
||||
player.getInventory().clear();
|
||||
player.getInventory().addItem(teamKindBlock);
|
||||
warzone.addFlagThief(lostFlagTeam, player.getName());
|
||||
block.setType(Material.AIR);
|
||||
|
||||
for(Team t : warzone.getTeams()) {
|
||||
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.");
|
||||
if (lostFlagTeam.getPlayers().size() != 0) {
|
||||
// player just broke the flag block of other team: cancel to avoid drop, give player the block, set block to air
|
||||
ItemStack teamKindBlock = new ItemStack(lostFlagTeam.getKind().getMaterial(), 1, (short)1, new Byte(lostFlagTeam.getKind().getData()));
|
||||
player.getInventory().clear();
|
||||
player.getInventory().addItem(teamKindBlock);
|
||||
warzone.addFlagThief(lostFlagTeam, player.getName());
|
||||
block.setType(Material.AIR);
|
||||
|
||||
for(Team t : warzone.getTeams()) {
|
||||
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);
|
||||
return;
|
||||
|
@ -344,17 +344,26 @@ public class WarPlayerListener extends PlayerListener {
|
||||
return;
|
||||
}
|
||||
|
||||
// Monuments
|
||||
// Monuments //SY
|
||||
if(team != null
|
||||
&& playerWarzone.nearAnyOwnedMonument(playerLoc, team)
|
||||
&& player.getHealth() < 20
|
||||
&& player.getHealth() > 0 // don't heal the dead
|
||||
&& random.nextInt(77) == 3 ) { // one chance out of many of getting healed
|
||||
int currentHp = player.getHealth();
|
||||
int newHp = currentHp + 5;
|
||||
int newHp = currentHp + locZone.getMonumentHeal();
|
||||
if(newHp > 20) newHp = 20;
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,7 @@ public class Team {
|
||||
}
|
||||
|
||||
public void addPoint() {
|
||||
points++;
|
||||
if (players.size()!=0) points++;
|
||||
}
|
||||
|
||||
public int getPoints() {
|
||||
@ -405,7 +405,7 @@ public class Team {
|
||||
}
|
||||
|
||||
public void setPoints(int score) {
|
||||
this.points = score;
|
||||
if (players.size()!=0) this.points = score;
|
||||
}
|
||||
|
||||
public void setFlagVolume(Volume flagVolume) {
|
||||
|
@ -44,6 +44,7 @@ public class Warzone {
|
||||
private boolean drawZoneOutline;
|
||||
private int teamCap = 5;
|
||||
private int scoreCap = 5;
|
||||
private int monumentHeal = 5;
|
||||
private String spawnStyle = TeamSpawnStyles.BIG;
|
||||
private HashMap<Integer, ItemStack> reward = new HashMap<Integer, ItemStack>();
|
||||
|
||||
@ -74,6 +75,7 @@ public class Warzone {
|
||||
this.setAutoAssignOnly(war.getDefaultAutoAssignOnly());
|
||||
this.teamCap = war.getDefaultTeamCap();
|
||||
this.scoreCap = war.getDefaultScoreCap();
|
||||
this.monumentHeal = war.getDefaultMonumentHeal();
|
||||
this.setBlockHeads(war.isDefaultBlockHeads());
|
||||
this.setDropLootOnDeath(war.isDefaultDropLootOnDeath());
|
||||
this.setUnbreakableZoneBlocks(war.isDefaultUnbreakableZoneBlocks());
|
||||
@ -477,6 +479,14 @@ public class Warzone {
|
||||
public int getLifePool() {
|
||||
return lifePool;
|
||||
}
|
||||
|
||||
public void setMonumentHeal(int monumentHeal) { //SY
|
||||
this.monumentHeal = monumentHeal;
|
||||
}
|
||||
|
||||
public int getMonumentHeal() { //SY
|
||||
return monumentHeal;
|
||||
}
|
||||
|
||||
public void setFriendlyFire(boolean ffOn) {
|
||||
this.friendlyFire = ffOn;
|
||||
@ -870,12 +880,14 @@ public class Warzone {
|
||||
t.teamcast("The battle is over. Team " + playerTeam.getName() + " lost: "
|
||||
+ player.getName() + " died and there were no lives left in their life pool.");
|
||||
|
||||
if(!t.getName().equals(playerTeam.getName())) {
|
||||
// all other teams get a point
|
||||
t.addPoint();
|
||||
t.resetSign();
|
||||
if (t.getPlayers().size() != 0) {
|
||||
if(!t.getName().equals(playerTeam.getName())) {
|
||||
// all other teams get a point
|
||||
t.addPoint();
|
||||
t.resetSign();
|
||||
}
|
||||
scores += t.getName() + "(" + t.getPoints() + ") " ;
|
||||
}
|
||||
scores += t.getName() + "(" + t.getPoints() + ") " ;
|
||||
}
|
||||
if(!scores.equals("")){
|
||||
for(Team t : teams) {
|
||||
@ -892,7 +904,7 @@ public class Warzone {
|
||||
if(!scoreCapTeams.isEmpty()) {
|
||||
String winnersStr = "";
|
||||
for(Team winner : scoreCapTeams) {
|
||||
winnersStr += winner.getName() + " ";
|
||||
if (winner.getPlayers().size() != 0) winnersStr += winner.getName() + " ";
|
||||
}
|
||||
|
||||
playerWarzone.handleScoreCapReached(player, winnersStr);
|
||||
|
@ -79,6 +79,9 @@ public class WarMapper {
|
||||
// defaultLifePool
|
||||
war.setDefaultLifepool(warConfig.getInt("defaultLifePool"));
|
||||
|
||||
// defaultMonumentHeal //SY
|
||||
war.setDefaultLifepool(warConfig.getInt("defaultMonumentHeal"));
|
||||
|
||||
// defaultFriendlyFire
|
||||
war.setDefaultFriendlyFire(warConfig.getBoolean("defaultFriendlyFire"));
|
||||
|
||||
@ -182,6 +185,9 @@ public class WarMapper {
|
||||
// defaultLifepool
|
||||
warConfig.setInt("defaultLifePool", war.getDefaultLifepool());
|
||||
|
||||
// defaultMonumentHeal //SY
|
||||
warConfig.setInt("defaultMonumentHeal", war.getDefaultMonumentHeal());
|
||||
|
||||
// defaultFriendlyFire
|
||||
warConfig.setBoolean("defaultFriendlyFire", war.getDefaultFriendlyFire());
|
||||
|
||||
|
@ -170,6 +170,9 @@ public class WarzoneMapper {
|
||||
// life pool
|
||||
warzone.setLifePool(warzoneConfig.getInt("lifePool"));
|
||||
|
||||
// monument heal //SY
|
||||
warzone.setMonumentHeal(warzoneConfig.getInt("monumentHeal"));
|
||||
|
||||
// drawZoneOutline
|
||||
warzone.setDrawZoneOutline(warzoneConfig.getBoolean("drawZoneOutline"));
|
||||
|
||||
@ -390,6 +393,9 @@ public class WarzoneMapper {
|
||||
// life pool
|
||||
warzoneConfig.setInt("lifePool", warzone.getLifePool());
|
||||
|
||||
// monument heal //SY
|
||||
warzoneConfig.setInt("monumentHeal", warzone.getMonumentHeal());
|
||||
|
||||
// drawZoneOutline
|
||||
warzoneConfig.setBoolean("drawZoneOutline", warzone.isDrawZoneOutline());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user