Split raid score in half, added boss bar display

This commit is contained in:
Aubri Seebauer committed 2023-04-27 14:07:38 -04:00
1 parent 7c483a9c39
commit 14b962424d
3 files changed
+203 -75

No files matched your search

@@ -10,6 +10,10 @@ import me.ShermansWorld.AlathraWar.data.RaidPhase;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@@ -72,7 +76,8 @@ public class Raid {
private String raiders; private String raiders;
private String defenders; private String defenders;
private boolean side1AreRaiders; private boolean side1AreRaiders;
private int raidScore; private int raiderScore;
private int defenderScore;
private OfflinePlayer owner; private OfflinePlayer owner;
private int raidTicks; private int raidTicks;
private TownBlock homeBlockRaided; private TownBlock homeBlockRaided;
@@ -106,7 +111,8 @@ public class Raid {
this.owner = owner; this.owner = owner;
this.raiders = side1AreRaiders ? war.getSide1() : war.getSide2(); this.raiders = side1AreRaiders ? war.getSide1() : war.getSide2();
this.defenders = !side1AreRaiders ? war.getSide1() : war.getSide2(); this.defenders = !side1AreRaiders ? war.getSide1() : war.getSide2();
this.raidScore = 500; this.raiderScore = 0;
this.defenderScore = 0;
//AttackSide-Town //AttackSide-Town
this.name = war.getName() + "-" + raidedTown.getName().toLowerCase(); this.name = war.getName() + "-" + raidedTown.getName().toLowerCase();
@@ -151,7 +157,8 @@ public class Raid {
this.owner = owner; this.owner = owner;
this.raiders = side1AreRaiders ? war.getSide1() : war.getSide2(); this.raiders = side1AreRaiders ? war.getSide1() : war.getSide2();
this.defenders = !side1AreRaiders ? war.getSide1() : war.getSide2(); this.defenders = !side1AreRaiders ? war.getSide1() : war.getSide2();
this.raidScore = 500; this.raiderScore = 0;
this.defenderScore = 0;
//AttackSide-Town //AttackSide-Town
this.name = war.getName() + "-" + raidedTown.getName().toLowerCase(); this.name = war.getName() + "-" + raidedTown.getName().toLowerCase();
@@ -264,7 +271,7 @@ public class Raid {
lb.value = r.nextDouble() * 30; lb.value = r.nextDouble() * 30;
//score for looting //score for looting
this.addPointsToRaidScore(10); this.addPointsToRaiderScore(10);
Main.warLogger.log(String.format("A townblock has been looted for $%.2f", lb.value)); Main.warLogger.log(String.format("A townblock has been looted for $%.2f", lb.value));
//Broadcast to the whole raid //Broadcast to the whole raid
@@ -333,7 +340,7 @@ public class Raid {
public void raiderKilledInCombat(PlayerDeathEvent event) { public void raiderKilledInCombat(PlayerDeathEvent event) {
//award negative score //award negative score
this.subtractPointsFromRaidScore(40); this.addPointsToDefenderScore(40);
for (final String playerName : this.getActiveRaiders()) { for (final String playerName : this.getActiveRaiders()) {
Player pl = Bukkit.getPlayer(playerName); Player pl = Bukkit.getPlayer(playerName);
if(pl != null) pl.sendMessage(String.valueOf(Helper.Chatlabel()) + "Raider killed! -40 Raid Score"); if(pl != null) pl.sendMessage(String.valueOf(Helper.Chatlabel()) + "Raider killed! -40 Raid Score");
@@ -348,7 +355,7 @@ public class Raid {
* Defender killed in combat * Defender killed in combat
*/ */
public void defenderKilledInCombat(PlayerDeathEvent event) { public void defenderKilledInCombat(PlayerDeathEvent event) {
this.addPointsToRaidScore(20); this.addPointsToRaiderScore(20);
for (final String playerName : this.getActiveRaiders()) { for (final String playerName : this.getActiveRaiders()) {
Player pl = Bukkit.getPlayer(playerName); Player pl = Bukkit.getPlayer(playerName);
if(pl != null) pl.sendMessage(String.valueOf(Helper.Chatlabel()) + "Defender killed! +20 Raid Score"); if(pl != null) pl.sendMessage(String.valueOf(Helper.Chatlabel()) + "Defender killed! +20 Raid Score");
@@ -439,17 +446,15 @@ public class Raid {
/** /**
* Raiders win, give payout and finalize raid * Raiders win, give payout and finalize raid
* *
* @param owner
* @param raidScore
*/ */
public void raidersWin(final OfflinePlayer owner, int raidScore) { public void raidersWin(final OfflinePlayer owner, int raiderScore, int defenderScore) {
//TODO finalize payout //TODO finalize payout
//Calc win factor //Calc win factor
//difference of score minus 800, then divided by 100 //difference of score minus 800, then divided by 100
//raid needs 10+ kills over defenders to win //raid needs 10+ kills over defenders to win
//factor is 0.5 -> 3 //factor is 0.5 -> 3
double factor = ((raidScore - 800.0) / 100) + 0.5; double factor = ((raiderScore - defenderScore) / 200.0D);
if (factor > 3.0) factor = 3.0; if (factor > 3.0) factor = 3.0;
if (factor < 0) factor = 0.0; if (factor < 0) factor = 0.0;
@@ -466,22 +471,37 @@ public class Raid {
//TODO cap based on the town balance //TODO cap based on the town balance
//raid chest TODO REMOVE THIS
Main.econ.depositPlayer(offlinePlayer, 1000);
double amt = 0.0; double amt = 0.0;
//calc looted chunks
double looted = 0.0;
//calc looted chunks
for (WorldCoord wc : this.getLootedChunks().keySet()) {
if (this.getLootedChunks().get(wc).finished) looted += this.getLootedChunks().get(wc).value;
}
//multiply by victory factor
amt += looted * factor;
//cap based on town bank
if (this.raidedTown.getAccount().getHoldingBalance() > 10000) { if (this.raidedTown.getAccount().getHoldingBalance() > 10000) {
amt = Math.floor(this.raidedTown.getAccount().getHoldingBalance()) / 10.0; //large towns get raided for alot more, cap at 1/10th the town holdings
amt *= factor; double maxVal = Math.floor(this.raidedTown.getAccount().getHoldingBalance()) / 10.0;
if (amt > 10000.0) amt = 10000.0; if (amt > maxVal) amt = maxVal;
this.raidedTown.getAccount().withdraw(amt, "war loot"); this.raidedTown.getAccount().withdraw(amt, "war loot");
} else if (this.raidedTown.getAccount().getHoldingBalance() < 1000) { } else if (this.raidedTown.getAccount().getHoldingBalance() < 1000) {
amt = 1000; //generate $1000 if the town doesnt have it
double maxVal = 1000;
if (amt > maxVal) amt = maxVal;
this.raidedTown.getAccount().withdraw(this.raidedTown.getAccount().getHoldingBalance(), "war loot"); this.raidedTown.getAccount().withdraw(this.raidedTown.getAccount().getHoldingBalance(), "war loot");
} else { } else {
amt = 1000; //give $1000 for the raid win
double maxVal = 1000;
if (amt > maxVal) amt = maxVal;
this.raidedTown.getAccount().withdraw(amt, "war loot"); this.raidedTown.getAccount().withdraw(amt, "war loot");
} }
//broadcast victory
String statement = "raided"; String statement = "raided";
if (factor <= 1.0) { if (factor <= 1.0) {
statement = "looted"; statement = "looted";
@@ -491,18 +511,10 @@ public class Raid {
statement = "emptied"; statement = "emptied";
} }
double looted = 0.0;
//calc looted chunks
for (WorldCoord wc : this.getLootedChunks().keySet()) {
if (this.getLootedChunks().get(wc).finished) looted += this.getLootedChunks().get(wc).value;
}
amt += looted;
Bukkit.broadcastMessage("The town of " + this.raidedTown.getName() + " has been " + statement + " by " + this.getRaiders() Bukkit.broadcastMessage("The town of " + this.raidedTown.getName() + " has been " + statement + " by " + this.getRaiders()
+ " in a raid for $" + String.valueOf(amt)); + " in a raid for $" + amt);
Main.warLogger.log("The town of " + this.raidedTown.getName() + " has been " + statement + " by " + this.getRaiders() Main.warLogger.log("The town of " + this.raidedTown.getName() + " has been " + statement + " by " + this.getRaiders()
+ " in a raid for $" + String.valueOf(amt)); + " in a raid for $" + amt);
Main.econ.depositPlayer(offlinePlayer, amt); Main.econ.depositPlayer(offlinePlayer, amt);
@@ -512,9 +524,8 @@ public class Raid {
/** /**
* Defenders win, payout, and finalize raid * Defenders win, payout, and finalize raid
* *
* @param raidScore
*/ */
public void defendersWin(int raidScore) { public void defendersWin(int raiderScore, int defenderScore) {
//TODO finalize payout //TODO finalize payout
/* /*
If defenders win, they get the 1000 deposit. If defenders win, they get the 1000 deposit.
@@ -525,30 +536,30 @@ public class Raid {
//at 500 this results in 1.0 //at 500 this results in 1.0
//at 0 this results in 3.5, which is capped to 3 //at 0 this results in 3.5, which is capped to 3
double factor = (3 - ((raidScore) / 200.0) - 0.5); double factor = ((defenderScore - raiderScore) / 200.0D);
if (factor > 3.0) factor = 3.0; if (factor > 3.0) factor = 3.0;
if (factor < 0) factor = 0.0; if (factor < 0) factor = 0.0;
if (factor <= 0.5) { if (factor <= 0.5) {
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The defenders from " + this.defenders Bukkit.broadcastMessage(Helper.Chatlabel() + "The defenders from " + this.defenders
+ " have barely pushed back the raiders of " + this.raiders + ". More has been lost than gained."); + " have barely pushed back the raiders of " + this.raiders + ". More has been lost than gained.");
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + this.raidedTown.getName() Bukkit.broadcastMessage(Helper.Chatlabel() + this.raidedTown.getName()
+ " has recovered part of the attackers' raid chest, valued at $500"); + " has recovered part of the attackers' raid chest, valued at $500");
Main.warLogger Main.warLogger
.log("The defenders from " + this.defenders + " have won the raid of " + this.raidedTown.getName() + "!"); .log("The defenders from " + this.defenders + " have won the raid of " + this.raidedTown.getName() + "!");
this.raidedTown.getAccount().deposit(500, "Raid chest"); this.raidedTown.getAccount().deposit(500, "Raid chest");
} else if (factor <= 1.5) { } else if (factor <= 1.5) {
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The defenders from " + this.defenders Bukkit.broadcastMessage(Helper.Chatlabel() + "The defenders from " + this.defenders
+ " have fended off the raiders of " + this.raiders + "!"); + " have fended off the raiders of " + this.raiders + "!");
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + this.raidedTown.getName() Bukkit.broadcastMessage(Helper.Chatlabel() + this.raidedTown.getName()
+ " has recovered the attackers' raid chest, valued at $1000"); + " has recovered the attackers' raid chest, valued at $1000");
Main.warLogger Main.warLogger
.log("The defenders from " + this.defenders + " have won the raid of " + this.raidedTown.getName() + "!"); .log("The defenders from " + this.defenders + " have won the raid of " + this.raidedTown.getName() + "!");
this.raidedTown.getAccount().deposit(1000, "Raid chest"); this.raidedTown.getAccount().deposit(1000, "Raid chest");
} else if (factor <= 3.0) { } else if (factor <= 3.0) {
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The defenders from " + this.defenders Bukkit.broadcastMessage(Helper.Chatlabel() + "The defenders from " + this.defenders
+ " have wholly defeated the raiders of " + this.raiders + "! They barely broke the walls."); + " have wholly defeated the raiders of " + this.raiders + "! They barely broke the walls.");
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + this.raidedTown.getName() Bukkit.broadcastMessage(Helper.Chatlabel() + this.raidedTown.getName()
+ " has recovered the attackers' raid chest, valued at $1000."); + " has recovered the attackers' raid chest, valued at $1000.");
Main.warLogger Main.warLogger
.log("The defenders from " + this.defenders + " have won the raid of " + this.raidedTown.getName() + "!"); .log("The defenders from " + this.defenders + " have won the raid of " + this.raidedTown.getName() + "!");
@@ -577,11 +588,9 @@ public class Raid {
* *
* @param points * @param points
*/ */
public void addPointsToRaidScore(final int points) { public void addPointsToRaiderScore(final int points) {
this.raidScore += points; this.raiderScore += points;
//cap if (raiderScore < 0) this.raiderScore = 0;
if (raidScore > 1200) this.raidScore = 1200;
if (raidScore < 0) this.raidScore = 0;
} }
/** /**
@@ -589,11 +598,24 @@ public class Raid {
* *
* @param points * @param points
*/ */
public void subtractPointsFromRaidScore(final int points) { public void addPointsToDefenderScore(final int points) {
this.raidScore -= points; this.defenderScore += points;
//cap if (defenderScore < 0) this.defenderScore = 0;
if (raidScore > 1200) this.raidScore = 1200; }
if (raidScore < 0) this.raidScore = 0;
public void subtractPointsFromRaiderScore(final int points) {
this.raiderScore -= points;
if (raiderScore < 0) this.raiderScore = 0;
}
/**
* Negatively impact the raid score
*
* @param points
*/
public void subtractPointsFromDefenderScore(final int points) {
this.defenderScore -= points;
if (defenderScore < 0) this.defenderScore = 0;
} }
public String getName() { public String getName() {
@@ -649,12 +671,20 @@ public class Raid {
this.raiders = defenders; this.raiders = defenders;
} }
public int getRaidScore() { public int getRaiderScore() {
return this.raidScore; return this.raiderScore;
} }
public void setRaidScore(final int raidScore) { public void setRaiderScore(final int raiderScore) {
this.raidScore = raidScore; this.raiderScore = raiderScore;
}
public int getDefenderScore() {
return this.defenderScore;
}
public void setDefenderScore(final int defenderScore) {
this.defenderScore = defenderScore;
} }
public boolean getSide1AreRaiders() { public boolean getSide1AreRaiders() {
@@ -776,11 +806,11 @@ public class Raid {
if (Raid.this.phase == RaidPhase.END) { if (Raid.this.phase == RaidPhase.END) {
//TODO: fix raid scoring //TODO: fix raid scoring
//for raiders to win, they need a significant up from the defenders //for raiders to win enough money, they need a significant up from the defenders, tie given to defender
if (Raid.this.raidScore > 800) { if (Raid.this.raiderScore > Raid.this.defenderScore) {
Raid.this.raidersWin(Raid.this.owner, Raid.this.raidScore); Raid.this.raidersWin(Raid.this.owner, Raid.this.raiderScore, Raid.this.defenderScore);
} else { } else {
Raid.this.defendersWin(Raid.this.raidScore); Raid.this.defendersWin(Raid.this.raiderScore, Raid.this.defenderScore);
} }
} }
@@ -862,7 +892,9 @@ public class Raid {
Bukkit.broadcastMessage(Helper.Chatlabel() + "Report on the raid of " Bukkit.broadcastMessage(Helper.Chatlabel() + "Report on the raid of "
+ Raid.this.getRaidedTown().getName() + ":"); + Raid.this.getRaidedTown().getName() + ":");
Bukkit.broadcastMessage( Bukkit.broadcastMessage(
"Raid Score - " + Raid.this.raidScore); "Raider Score - " + Raid.this.raiderScore);
Bukkit.broadcastMessage(
"Defender Score - " + Raid.this.defenderScore);
Bukkit.broadcastMessage( Bukkit.broadcastMessage(
"Chunks Looted - " + Raid.this.lootedChunks.size() + "/" + raidedTown.getTownBlocks().size()); "Chunks Looted - " + Raid.this.lootedChunks.size() + "/" + raidedTown.getTownBlocks().size());
} }
@@ -891,6 +923,16 @@ public class Raid {
} }
} }
} }
BossBar bossBar = Bukkit.createBossBar(String.format("%d -- Raiders -- Raid Score -- Defenders -- %d", Raid.this.raiderScore, Raid.this.defenderScore), BarColor.RED, BarStyle.SOLID, BarFlag.CREATE_FOG);
for (String s : Raid.this.getActiveRaiders()) {
Player p = Bukkit.getPlayer(s);
if (p != null) bossBar.addPlayer(p);
}
for (String s : Raid.this.getDefenderPlayers()) {
Player p = Bukkit.getPlayer(s);
if (p != null) bossBar.addPlayer(p);
}
} }
} }
}; };
@@ -213,12 +213,12 @@ public class AdminCommands implements CommandExecutor {
if (r.getWar().getName().equals(args[3]) && r.getRaidedTown().getName().equals(args[4])) { if (r.getWar().getName().equals(args[3]) && r.getRaidedTown().getName().equals(args[4])) {
if (r.getSide1AreRaiders()) { if (r.getSide1AreRaiders()) {
if (args[5].equals(r.getWar().getSide1())) { if (args[5].equals(r.getWar().getSide1())) {
r.raidersWin(r.getOwner(), r.getRaidScore()); r.raidersWin(r.getOwner(), r.getRaiderScore(), r.getDefenderScore());
p.sendMessage(Helper.Chatlabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (raiders) declared as victor."); p.sendMessage(Helper.Chatlabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (raiders) declared as victor.");
Main.warLogger.log("Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (raiders) declared as victor."); Main.warLogger.log("Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (raiders) declared as victor.");
return true; return true;
} else if (args[5].equals(r.getWar().getSide2())) { } else if (args[5].equals(r.getWar().getSide2())) {
r.defendersWin(r.getRaidScore()); r.defendersWin(r.getRaiderScore(), r.getDefenderScore());
p.sendMessage(Helper.Chatlabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (defenders) declared as victor."); p.sendMessage(Helper.Chatlabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (defenders) declared as victor.");
Main.warLogger.log("Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (defenders) declared as victor."); Main.warLogger.log("Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (defenders) declared as victor.");
return true; return true;
@@ -228,12 +228,12 @@ public class AdminCommands implements CommandExecutor {
} }
} else { } else {
if (args[5].equals(r.getWar().getSide1())) { if (args[5].equals(r.getWar().getSide1())) {
r.defendersWin(r.getRaidScore()); r.defendersWin(r.getRaiderScore(), r.getDefenderScore());
p.sendMessage(Helper.Chatlabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (defenders) declared as victor."); p.sendMessage(Helper.Chatlabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (defenders) declared as victor.");
Main.warLogger.log("Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (defenders) declared as victor."); Main.warLogger.log("Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (defenders) declared as victor.");
return true; return true;
} else if (args[5].equals(r.getWar().getSide2())) { } else if (args[5].equals(r.getWar().getSide2())) {
r.raidersWin(r.getOwner(), r.getRaidScore()); r.raidersWin(r.getOwner(), r.getRaiderScore(), r.getDefenderScore());
p.sendMessage(Helper.Chatlabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (raiders) declared as victor."); p.sendMessage(Helper.Chatlabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (raiders) declared as victor.");
Main.warLogger.log("Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (raiders) declared as victor."); Main.warLogger.log("Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (raiders) declared as victor.");
return true; return true;
@@ -524,7 +524,8 @@ public class AdminCommands implements CommandExecutor {
p.sendMessage(Helper.Chatlabel() + "Name: " + r.getName()); p.sendMessage(Helper.Chatlabel() + "Name: " + r.getName());
p.sendMessage(Helper.Chatlabel() + "Raiders: " + r.getRaiders()); p.sendMessage(Helper.Chatlabel() + "Raiders: " + r.getRaiders());
p.sendMessage(Helper.Chatlabel() + "Defenders: " + r.getDefenders()); p.sendMessage(Helper.Chatlabel() + "Defenders: " + r.getDefenders());
p.sendMessage(Helper.Chatlabel() + "Raid Score: " + r.getRaidScore()); p.sendMessage(Helper.Chatlabel() + "Raider Score: " + r.getRaiderScore());
p.sendMessage(Helper.Chatlabel() + "Defender Score: " + r.getDefenderScore());
p.sendMessage(Helper.Chatlabel() + "War: " + r.getWar().getName()); p.sendMessage(Helper.Chatlabel() + "War: " + r.getWar().getName());
p.sendMessage(Helper.Chatlabel() + "Raided Town: " + r.getRaidedTown().getName()); p.sendMessage(Helper.Chatlabel() + "Raided Town: " + r.getRaidedTown().getName());
p.sendMessage(Helper.Chatlabel() + "Gather Town: " + r.getGatherTown().getName()); p.sendMessage(Helper.Chatlabel() + "Gather Town: " + r.getGatherTown().getName());
@@ -635,33 +636,102 @@ public class AdminCommands implements CommandExecutor {
if (args[1].equalsIgnoreCase("raid")) { if (args[1].equalsIgnoreCase("raid")) {
if (args.length >= 3) { if (args.length >= 3) {
if (args[2].equalsIgnoreCase("score")) { if (args[2].equalsIgnoreCase("score")) {
if (args.length >= 7) { if (args.length >= 8) {
for (Raid r : RaidData.getRaids()) { for (Raid r : RaidData.getRaids()) {
if (r.getWar().getName().equals(args[3]) && r.getRaidedTown().getName().equals(args[4])) { if (r.getWar().getName().equals(args[3]) && r.getRaidedTown().getName().equals(args[4])) {
if(args[6].equals(r.getWar().getSide1())) {
if(r.getSide1AreRaiders()) {
if (args[5].equalsIgnoreCase("add")) { if (args[5].equalsIgnoreCase("add")) {
r.addPointsToRaidScore(Integer.parseInt(args[6])); r.addPointsToRaiderScore(Integer.parseInt(args[7]));
p.sendMessage(Helper.Chatlabel() + "Added " + args[6] + " points to the raid score in the war " + args[3] + " on town " + args[4]); p.sendMessage(Helper.Chatlabel() + "Added " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]);
Main.warLogger.log("Added " + args[6] + " points to the raid score in the war " + args[3] + " on town " + args[4]); Main.warLogger.log("Added " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]);
return finalizeRaid(r); return finalizeRaid(r);
} else if (args[5].equalsIgnoreCase("subtract")) { } else if (args[5].equalsIgnoreCase("subtract")) {
r.subtractPointsFromRaidScore(Integer.parseInt(args[6])); r.subtractPointsFromRaiderScore(Integer.parseInt(args[7]));
p.sendMessage(Helper.Chatlabel() + "Subtracted " + args[6] + " points to the raid score in the war " + args[3] + " on town " + args[4]); p.sendMessage(Helper.Chatlabel() + "Subtracted " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]);
Main.warLogger.log("Subtracted " + args[6] + " points to the raid score in the war " + args[3] + " on town " + args[4]); Main.warLogger.log("Subtracted " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]);
return finalizeRaid(r); return finalizeRaid(r);
} else if (args[5].equalsIgnoreCase("set")) { } else if (args[5].equalsIgnoreCase("set")) {
r.setRaidScore(Integer.parseInt(args[6])); r.setRaiderScore(Integer.parseInt(args[7]));
p.sendMessage(Helper.Chatlabel() + "Set " + args[6] + " points as the raid score in the war " + args[3] + " on town " + args[4]); p.sendMessage(Helper.Chatlabel() + "Set " + args[7] + " points as the raid score in the war " + args[3] + " on town " + args[4]);
Main.warLogger.log("Set " + args[6] + " points as the raid score in the war " + args[3] + " on town " + args[4]); Main.warLogger.log("Set " + args[7] + " points as the raid score in the war " + args[3] + " on town " + args[4]);
return finalizeRaid(r); return finalizeRaid(r);
} else { } else {
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify raid score [add/subtract/set] [war] [town] [value]")); p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify raid score [add/subtract/set] [war] [town] [side] [value]"));
return true;
}
} else {
if (args[5].equalsIgnoreCase("add")) {
r.addPointsToDefenderScore(Integer.parseInt(args[7]));
p.sendMessage(Helper.Chatlabel() + "Added " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]);
Main.warLogger.log("Added " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]);
return finalizeRaid(r);
} else if (args[5].equalsIgnoreCase("subtract")) {
r.subtractPointsFromDefenderScore(Integer.parseInt(args[7]));
p.sendMessage(Helper.Chatlabel() + "Subtracted " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]);
Main.warLogger.log("Subtracted " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]);
return finalizeRaid(r);
} else if (args[5].equalsIgnoreCase("set")) {
r.setDefenderScore(Integer.parseInt(args[7]));
p.sendMessage(Helper.Chatlabel() + "Set " + args[7] + " points as the raid score in the war " + args[3] + " on town " + args[4]);
Main.warLogger.log("Set " + args[7] + " points as the raid score in the war " + args[3] + " on town " + args[4]);
return finalizeRaid(r);
} else {
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify raid score [add/subtract/set] [war] [town] [side] [value]"));
return true;
}
}
} else if(args[6].equals(r.getWar().getSide2())) {
if(!r.getSide1AreRaiders()) {
if (args[5].equalsIgnoreCase("add")) {
r.addPointsToRaiderScore(Integer.parseInt(args[7]));
p.sendMessage(Helper.Chatlabel() + "Added " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]);
Main.warLogger.log("Added " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]);
return finalizeRaid(r);
} else if (args[5].equalsIgnoreCase("subtract")) {
r.subtractPointsFromRaiderScore(Integer.parseInt(args[7]));
p.sendMessage(Helper.Chatlabel() + "Subtracted " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]);
Main.warLogger.log("Subtracted " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]);
return finalizeRaid(r);
} else if (args[5].equalsIgnoreCase("set")) {
r.setRaiderScore(Integer.parseInt(args[7]));
p.sendMessage(Helper.Chatlabel() + "Set " + args[7] + " points as the raid score in the war " + args[3] + " on town " + args[4]);
Main.warLogger.log("Set " + args[7] + " points as the raid score in the war " + args[3] + " on town " + args[4]);
return finalizeRaid(r);
} else {
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify raid score [add/subtract/set] [war] [town] [side] [value]"));
return true;
}
} else {
if (args[5].equalsIgnoreCase("add")) {
r.addPointsToDefenderScore(Integer.parseInt(args[7]));
p.sendMessage(Helper.Chatlabel() + "Added " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]);
Main.warLogger.log("Added " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]);
return finalizeRaid(r);
} else if (args[5].equalsIgnoreCase("subtract")) {
r.subtractPointsFromDefenderScore(Integer.parseInt(args[7]));
p.sendMessage(Helper.Chatlabel() + "Subtracted " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]);
Main.warLogger.log("Subtracted " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]);
return finalizeRaid(r);
} else if (args[5].equalsIgnoreCase("set")) {
r.setDefenderScore(Integer.parseInt(args[7]));
p.sendMessage(Helper.Chatlabel() + "Set " + args[7] + " points as the raid score in the war " + args[3] + " on town " + args[4]);
Main.warLogger.log("Set " + args[7] + " points as the raid score in the war " + args[3] + " on town " + args[4]);
return finalizeRaid(r);
} else {
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify raid score [war] [town] [add/subtract/set] [side] [value]"));
return true;
}
}
} else {
p.sendMessage(Helper.color("&cSide not found!"));
return true; return true;
} }
} }
} }
p.sendMessage(Helper.Chatlabel() + Helper.color("&cRaid cannot be found.")); p.sendMessage(Helper.Chatlabel() + Helper.color("&cRaid cannot be found."));
} else { } else {
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify raid score [add/subtract/set] [war] [town] [value]")); p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify raid score [war] [town] [add/subtract/set] [side] [value]"));
} }
return true; return true;
} else if (args[2].equalsIgnoreCase("townspawn")) { } else if (args[2].equalsIgnoreCase("townspawn")) {
@@ -822,7 +892,7 @@ public class AdminCommands implements CommandExecutor {
if(!lb.finished && Boolean.parseBoolean(args[6])) { if(!lb.finished && Boolean.parseBoolean(args[6])) {
lb.value = new Random().nextDouble() * 100; lb.value = new Random().nextDouble() * 100;
//score for looting //score for looting
r.addPointsToRaidScore(10); r.addPointsToRaiderScore(10);
p.sendMessage(Helper.Chatlabel() + "Gave value and score because flag was false before."); p.sendMessage(Helper.Chatlabel() + "Gave value and score because flag was false before.");
Main.warLogger.log("Gave value and score because flag was false before."); Main.warLogger.log("Gave value and score because flag was false before.");
} }
@@ -69,6 +69,11 @@ public class AdminTabCompletion implements TabCompleter {
"set" "set"
}); });
List<String> addSubSet = List.of(new String[]{
"add",
"subtract",
"set"
});
List<String> boolSet = List.of(new String[]{ List<String> boolSet = List.of(new String[]{
"true", "true",
@@ -417,7 +422,7 @@ public class AdminTabCompletion implements TabCompleter {
if (args.length > 5) { if (args.length > 5) {
switch (args[2]) { switch (args[2]) {
/* /*
* -modify raid score [war] [town] [add/set] [value] * -modify raid score [war] [town] [add/subtract/set] [side] [value]
* -modify raid townspawn [war] [town] (x) (y) (Z) * -modify raid townspawn [war] [town] (x) (y) (Z)
* -modify raid gather [war] [town] [town] * -modify raid gather [war] [town] [town]
* -modify raid phase [war] [town] [phase] //"next" to move to next phase * -modify raid phase [war] [town] [phase] //"next" to move to next phase
@@ -427,7 +432,18 @@ public class AdminTabCompletion implements TabCompleter {
* -modify raid move [war] [town] [newWar] //low priority, moves raid to other war/ town * -modify raid move [war] [town] [newWar] //low priority, moves raid to other war/ town
* -modify raid clearActive [war] [town] //low priority * -modify raid clearActive [war] [town] //low priority
*/ */
case "score", "time" -> { case "score" -> {
if (args.length > 6) {
if (args.length > 7) {
return empty;
} else {
return NameUtil.filterByStart(CommandHelper.getWarSides(args[3]), args[5]);
}
} else {
return NameUtil.filterByStart(addSubSet, args[5]);
}
}
case "time" -> {
if (args.length > 6) { if (args.length > 6) {
return empty; return empty;
} else { } else {