mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-01 14:38:55 +00:00
admincommand force save
This commit is contained in:
1 parent
a59d59e962
commit
c23018bd79
7 files changed
+174
-87
No files matched your search
@@ -10,6 +10,7 @@ import com.palmergames.bukkit.towny.object.WorldCoord;
|
||||
import com.palmergames.bukkit.towny.object.metadata.LongDataField;
|
||||
import me.ShermansWorld.AlathraWar.data.RaidData;
|
||||
import me.ShermansWorld.AlathraWar.data.RaidPhase;
|
||||
import me.ShermansWorld.AlathraWar.data.SiegeData;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -907,6 +908,10 @@ public class Raid {
|
||||
};
|
||||
}
|
||||
|
||||
public void save() {
|
||||
RaidData.saveRaid(this);
|
||||
}
|
||||
|
||||
public TownBlock getHomeBlockRaided() {
|
||||
return homeBlockRaided;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.ShermansWorld.AlathraWar;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.palmergames.bukkit.towny.TownyAPI;
|
||||
@@ -7,6 +8,7 @@ import com.palmergames.bukkit.towny.object.Nation;
|
||||
import com.palmergames.bukkit.towny.object.Resident;
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
|
||||
import me.ShermansWorld.AlathraWar.data.DataManager;
|
||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||
|
||||
public class War {
|
||||
@@ -173,7 +175,9 @@ public class War {
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
DataManager.deleteFile("wars" + File.separator + this.getName() + ".yml");
|
||||
this.name = name;
|
||||
this.save();
|
||||
}
|
||||
|
||||
public void setSide1(String side1) {
|
||||
|
||||
@@ -374,7 +374,9 @@ public class AdminCommands implements CommandExecutor {
|
||||
}
|
||||
WarCommands.warJoin(p, adjusted, true);
|
||||
p.sendMessage(Helper.color("c") + "Forced " + args[3] + " to join the war " + args[4] + " on side " + args[5]);
|
||||
|
||||
Main.warLogger.log("Forced " + args[3] + " to join the war " + args[4] + " on side " + args[5]);
|
||||
finalizeWar(w);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Usage: /alathrawaradmin force join war [player] [war] [side]");
|
||||
return true;
|
||||
@@ -403,7 +405,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
RaidCommands.leaveRaid(p, fixed, true);
|
||||
p.sendMessage(Helper.Chatlabel() + "Forced player " + args[5] + " to leave raid on " + args[4] + " in war " + args[3]);
|
||||
Main.warLogger.log("Forced player " + args[5] + " to leave raid on " + args[4] + " in war " + args[3]);
|
||||
return true;
|
||||
return finalizeRaid(r);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Player not found!");
|
||||
return true;
|
||||
@@ -467,14 +469,14 @@ public class AdminCommands implements CommandExecutor {
|
||||
for (War w : WarData.getWars()) {
|
||||
if (w.getName().equals(args[2])) {
|
||||
p.sendMessage(Helper.Chatlabel() + "Info dump for war: " + w.getName());
|
||||
p.sendMessage(Helper.Chatlabel() + "oOo----------------------===----------------------oOo");
|
||||
p.sendMessage(Helper.Chatlabel() + "oOo-----------------===-----------------oOo");
|
||||
p.sendMessage(Helper.Chatlabel() + "Name: " + w.getName());
|
||||
p.sendMessage(Helper.Chatlabel() + "Side 1: " + w.getSide1());
|
||||
p.sendMessage(Helper.Chatlabel() + "Side 2: " + w.getSide2());
|
||||
// TODO I think this works!
|
||||
p.sendMessage(Helper.Chatlabel() + "Last Raid for Side 1: " + TimeMgmt.getFormattedTimeValue(w.getLastRaidTimeSide1() * 1000));
|
||||
p.sendMessage(Helper.Chatlabel() + "Last Raid for Side 2: " + TimeMgmt.getFormattedTimeValue(w.getLastRaidTimeSide2() * 1000));
|
||||
p.sendMessage(Helper.Chatlabel() + "oOo----------------------===----------------------oOo");
|
||||
p.sendMessage(Helper.Chatlabel() + "oOo-----------------===-----------------oOo");
|
||||
String side1Towns = "";
|
||||
String side1Players = "";
|
||||
for (String t : w.getSide1Towns()) {
|
||||
@@ -490,7 +492,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
side1Players = side1Players.substring(0, side1Players.length() - 3);
|
||||
p.sendMessage(Helper.Chatlabel() + w.getSide1() + " Towns: " + side1Towns);
|
||||
p.sendMessage(Helper.Chatlabel() + w.getSide1() + " Players: " + side1Players);
|
||||
p.sendMessage(Helper.Chatlabel() + "oOo----------------------===----------------------oOo");
|
||||
p.sendMessage(Helper.Chatlabel() + "oOo-----------------===-----------------oOo");
|
||||
String side2Towns = "";
|
||||
String side2Players = "";
|
||||
for (String t : w.getSide2Towns()) {
|
||||
@@ -519,7 +521,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
for (Raid r : RaidData.getRaids()) {
|
||||
if (r.getWar().getName().equals(args[2]) && r.getRaidedTown().getName().equals(args[3])) {
|
||||
p.sendMessage(Helper.Chatlabel() + "Info dump for raid: " + r.getName());
|
||||
p.sendMessage(Helper.Chatlabel() + "oOo----------------------===----------------------oOo");
|
||||
p.sendMessage(Helper.Chatlabel() + "oOo-----------------===-----------------oOo");
|
||||
p.sendMessage(Helper.Chatlabel() + "Name: " + r.getName());
|
||||
p.sendMessage(Helper.Chatlabel() + "Raiders: " + r.getRaiders());
|
||||
p.sendMessage(Helper.Chatlabel() + "Defenders: " + r.getDefenders());
|
||||
@@ -532,7 +534,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
p.sendMessage(Helper.Chatlabel() + "Owner: " + r.getOwner());
|
||||
p.sendMessage(Helper.Chatlabel() + "Gather Homeblock: " + r.getHomeBlockGather().toString());
|
||||
p.sendMessage(Helper.Chatlabel() + "Raided Homeblock: " + r.getHomeBlockRaided().toString());
|
||||
p.sendMessage(Helper.Chatlabel() + "oOo----------------------===----------------------oOo");
|
||||
p.sendMessage(Helper.Chatlabel() + "oOo-----------------===-----------------oOo");
|
||||
String activeRaiders = "";
|
||||
for (String pl : r.getActiveRaiders()) {
|
||||
activeRaiders += pl;
|
||||
@@ -555,7 +557,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
for (Siege s : SiegeData.getSieges()) {
|
||||
if (s.getWar().getName().equals(args[2]) && s.getTown().getName().equals(args[3])) {
|
||||
p.sendMessage(Helper.Chatlabel() + "Info dump for siege: " + s.getName());
|
||||
p.sendMessage(Helper.Chatlabel() + "oOo----------------------===----------------------oOo");
|
||||
p.sendMessage(Helper.Chatlabel() + "oOo-----------------===-----------------oOo");
|
||||
p.sendMessage(Helper.Chatlabel() + "Name: " + s.getName());
|
||||
p.sendMessage(Helper.Chatlabel() + "Attackers: " + s.getAttackers());
|
||||
p.sendMessage(Helper.Chatlabel() + "Defenders: " + s.getDefenders());
|
||||
@@ -567,7 +569,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
p.sendMessage(Helper.Chatlabel() + "Tick progress: " + s.getSiegeTicks());
|
||||
p.sendMessage(Helper.Chatlabel() + "Owner: " + s.getSiegeOwner());
|
||||
p.sendMessage(Helper.Chatlabel() + "Homeblock: " + s.getHomeBlock().toString());
|
||||
p.sendMessage(Helper.Chatlabel() + "oOo----------------------===----------------------oOo");
|
||||
p.sendMessage(Helper.Chatlabel() + "oOo-----------------===-----------------oOo");
|
||||
String attackers = "";
|
||||
for (String pl : s.getAttackerPlayers()) {
|
||||
attackers += pl;
|
||||
@@ -643,17 +645,17 @@ public class AdminCommands implements CommandExecutor {
|
||||
r.addPointsToRaidScore(Integer.parseInt(args[6]));
|
||||
p.sendMessage(Helper.Chatlabel() + "Added " + args[6] + " 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]);
|
||||
return true;
|
||||
return finalizeRaid(r);
|
||||
} else if (args[5].equalsIgnoreCase("subtract")) {
|
||||
r.subtractPointsFromRaidScore(Integer.parseInt(args[6]));
|
||||
p.sendMessage(Helper.Chatlabel() + "Subtracted " + args[6] + " 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]);
|
||||
return true;
|
||||
return finalizeRaid(r);
|
||||
} else if (args[5].equalsIgnoreCase("set")) {
|
||||
r.setRaidScore(Integer.parseInt(args[6]));
|
||||
p.sendMessage(Helper.Chatlabel() + "Set " + args[6] + " 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]);
|
||||
return true;
|
||||
return finalizeRaid(r);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Usage: /alathrawaradmin modify raid score [add/subtract/set] [war] [town] [value]");
|
||||
return true;
|
||||
@@ -686,7 +688,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
r.setTownSpawnRaided(t.getSpawn());
|
||||
p.sendMessage(Helper.Chatlabel() + "Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + p.getLocation().toString());
|
||||
Main.warLogger.log("Set town spawn for raided town " + args[4] + " in war " + args[3] + " to [" + args[5] + "," + args[6] + "," + args[7] + "]");
|
||||
return true;
|
||||
return finalizeRaid(r);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Town does not contain town block at [" + args[5] + "," + args[7] + "]");
|
||||
return true;
|
||||
@@ -714,7 +716,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
r.setTownSpawnRaided(t.getSpawn());
|
||||
p.sendMessage(Helper.Chatlabel() + "Set town spawn for raided town " + args[5] + " in war " + args[4] + " to " + p.getLocation().toString());
|
||||
Main.warLogger.log("Set town spawn for raided town " + args[5] + " in war " + args[4] + " to " + p.getLocation().toString());
|
||||
return true;
|
||||
return finalizeRaid(r);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Town does not contain town block at your location [" + (int) p.getLocation().getX() + "," + (int) p.getLocation().getZ() + "]");
|
||||
return true;
|
||||
@@ -754,7 +756,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
}
|
||||
p.sendMessage(Helper.Chatlabel() + "Set town new gather town " + t.getName() + " for raid against " + args[4] + " in war " + args[3]);
|
||||
Main.warLogger.log("Set town new gather town " + t.getName() + " for raid against " + args[4] + " in war " + args[3]);
|
||||
return true;
|
||||
return finalizeRaid(r);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Town does not exists!");
|
||||
return true;
|
||||
@@ -786,7 +788,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
|
||||
p.sendMessage(Helper.Chatlabel() + "Set phase for raid against " + args[4] + " in war " + args[3] + " to " + ph.name());
|
||||
Main.warLogger.log("Set phase for raid against " + args[4] + " in war " + args[3] + " to " + ph.name());
|
||||
return true;
|
||||
return finalizeRaid(r);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Phase does not exist!");
|
||||
return true;
|
||||
@@ -815,27 +817,27 @@ public class AdminCommands implements CommandExecutor {
|
||||
lb.value = Integer.parseInt(args[6]);
|
||||
p.sendMessage(Helper.Chatlabel() + "Set value for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||
Main.warLogger.log("Set value for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||
return true;
|
||||
return finalizeRaid(r);
|
||||
} else if (args[5].equalsIgnoreCase("looted")) {
|
||||
WorldCoord wc = WorldCoord.parseWorldCoord(p.getWorld().getName(), Integer.parseInt(args[7]), Integer.parseInt(args[8]));
|
||||
Raid.LootBlock lb = r.getLootedChunks().get(wc);
|
||||
lb.finished = Boolean.parseBoolean(args[6]);
|
||||
p.sendMessage(Helper.Chatlabel() + "Set finished flag for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||
Main.warLogger.log("Set finished flag for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||
return true;
|
||||
return finalizeRaid(r);
|
||||
} else if (args[5].equalsIgnoreCase("ticks")) {
|
||||
WorldCoord wc = WorldCoord.parseWorldCoord(p.getWorld().getName(), Integer.parseInt(args[7]), Integer.parseInt(args[8]));
|
||||
Raid.LootBlock lb = r.getLootedChunks().get(wc);
|
||||
lb.ticks = Integer.parseInt(args[6]);
|
||||
p.sendMessage(Helper.Chatlabel() + "Set ticks for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||
Main.warLogger.log("Set ticks for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||
return true;
|
||||
return finalizeRaid(r);
|
||||
} else if (args[5].equalsIgnoreCase("reset")) {
|
||||
WorldCoord wc = WorldCoord.parseWorldCoord(p.getWorld().getName(), Integer.parseInt(args[6]), Integer.parseInt(args[7]));
|
||||
r.getLootedChunks().remove(wc);
|
||||
p.sendMessage(Helper.Chatlabel() + "Reset loot for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3]);
|
||||
Main.warLogger.log("Reset loot for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3]);
|
||||
return true;
|
||||
return finalizeRaid(r);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Usage: /alathrawaradmin modify raid loot [war] [town] [value,looted,ticks,reset] [amt] (x) (z)");
|
||||
return true;
|
||||
@@ -850,27 +852,27 @@ public class AdminCommands implements CommandExecutor {
|
||||
lb.value = Integer.parseInt(args[6]);
|
||||
p.sendMessage(Helper.Chatlabel() + "Set value for a chunk [" + p.getLocation().getX() + "," + p.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||
Main.warLogger.log("Set value for a chunk [" + p.getLocation().getX() + "," + p.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||
return true;
|
||||
return finalizeRaid(r);
|
||||
} else if (args[5].equalsIgnoreCase("looted")) {
|
||||
WorldCoord wc = WorldCoord.parseWorldCoord(p.getLocation());
|
||||
Raid.LootBlock lb = r.getLootedChunks().get(wc);
|
||||
lb.finished = Boolean.parseBoolean(args[6]);
|
||||
p.sendMessage(Helper.Chatlabel() + "Set looted status for a chunk [" + p.getLocation().getX() + "," + p.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||
Main.warLogger.log("Set looted status for a chunk [" + p.getLocation().getX() + "," + p.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||
return true;
|
||||
return finalizeRaid(r);
|
||||
} else if (args[5].equalsIgnoreCase("ticks")) {
|
||||
WorldCoord wc = WorldCoord.parseWorldCoord(p.getLocation());
|
||||
Raid.LootBlock lb = r.getLootedChunks().get(wc);
|
||||
lb.ticks = Integer.parseInt(args[6]);
|
||||
p.sendMessage(Helper.Chatlabel() + "Set ticks for a chunk [" + p.getLocation().getX() + "," + p.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||
Main.warLogger.log("Set ticks for a chunk [" + p.getLocation().getX() + "," + p.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||
return true;
|
||||
return finalizeRaid(r);
|
||||
} else if (args[5].equalsIgnoreCase("reset")) {
|
||||
WorldCoord wc = WorldCoord.parseWorldCoord(p.getLocation());
|
||||
r.getLootedChunks().remove(wc);
|
||||
p.sendMessage(Helper.Chatlabel() + "Reset loot for a chunk [" + p.getLocation().getX() + "," + p.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3]);
|
||||
Main.warLogger.log("Reset Loot for a chunk [" + p.getLocation().getX() + "," + p.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3]);
|
||||
return true;
|
||||
return finalizeRaid(r);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Usage: /alathrawaradmin modify raid loot [war] [town] [value,looted,ticks,reset] [amt] (x) (z)");
|
||||
return true;
|
||||
@@ -893,14 +895,14 @@ public class AdminCommands implements CommandExecutor {
|
||||
r.setRaidTicks(r.getRaidTicks() + Integer.parseInt(args[6]));
|
||||
p.sendMessage(Helper.Chatlabel() + "Set time for raid against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||
Main.warLogger.log("Set time for raid against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||
return true;
|
||||
return finalizeRaid(r);
|
||||
} else if (args[5].equalsIgnoreCase("set")) {
|
||||
int t = Integer.parseInt(args[6]);
|
||||
if (t >= r.getPhase().startTick) {
|
||||
r.setRaidTicks(t);
|
||||
p.sendMessage(Helper.Chatlabel() + "Set time for raid against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||
Main.warLogger.log("Set time for raid against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||
return true;
|
||||
return finalizeRaid(r);
|
||||
} else {
|
||||
p.sendMessage(Helper.Chatlabel() + Helper.color("c") + "Time set before current phase, use \"/alathrawaradmin modify raid phase\" instead");
|
||||
return true;
|
||||
@@ -926,7 +928,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
r.setOwner(own);
|
||||
p.sendMessage(Helper.Chatlabel() + "Set owner of raid against " + args[4] + " in war " + args[3] + " to " + own.getName());
|
||||
Main.warLogger.log("Set owner of raid against " + args[4] + " in war " + args[3] + " to " + own.getName());
|
||||
return true;
|
||||
return finalizeRaid(r);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Player not found!");
|
||||
return true;
|
||||
@@ -967,24 +969,24 @@ public class AdminCommands implements CommandExecutor {
|
||||
s.addPointsToAttackers(Integer.parseInt(args[7]));
|
||||
p.sendMessage(Helper.Chatlabel() + "Added " + args[7] + " points to side " + args[6] + " in sige on " + args[4] + " in war " + args[3]);
|
||||
Main.warLogger.log("Added " + args[7] + " points to side " + args[6] + " in sige on " + args[4] + " in war " + args[3]);
|
||||
return true;
|
||||
return finalizeSiege(s);
|
||||
} else {
|
||||
s.addPointsToDefenders(Integer.parseInt(args[7]));
|
||||
p.sendMessage(Helper.Chatlabel() + "Added " + args[7] + " points to side " + args[6] + " in sige on " + args[4] + " in war " + args[3]);
|
||||
Main.warLogger.log("Added " + args[7] + " points to side " + args[6] + " in sige on " + args[4] + " in war " + args[3]);
|
||||
return true;
|
||||
return finalizeSiege(s);
|
||||
}
|
||||
} else if (s.getWar().getSide2().equals(args[6])) {
|
||||
if (s.getSide1AreAttackers()) {
|
||||
s.addPointsToDefenders(Integer.parseInt(args[7]));
|
||||
p.sendMessage(Helper.Chatlabel() + "Added " + args[7] + " points to side " + args[6] + " in sige on " + args[4] + " in war " + args[3]);
|
||||
Main.warLogger.log("Added " + args[7] + " points to side " + args[6] + " in sige on " + args[4] + " in war " + args[3]);
|
||||
return true;
|
||||
return finalizeSiege(s);
|
||||
} else {
|
||||
s.addPointsToAttackers(Integer.parseInt(args[7]));
|
||||
p.sendMessage(Helper.Chatlabel() + "Added " + args[7] + " points to side " + args[6] + " in sige on " + args[4] + " in war " + args[3]);
|
||||
Main.warLogger.log("Added " + args[7] + " points to side " + args[6] + " in sige on " + args[4] + " in war " + args[3]);
|
||||
return true;
|
||||
return finalizeSiege(s);
|
||||
}
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Side not found");
|
||||
@@ -996,24 +998,24 @@ public class AdminCommands implements CommandExecutor {
|
||||
s.setAttackerPoints(Integer.parseInt(args[7]));
|
||||
p.sendMessage(Helper.Chatlabel() + "Set " + args[7] + " points for side " + args[6] + " in sige on " + args[4] + " in war " + args[3]);
|
||||
Main.warLogger.log("Set " + args[7] + " points for side " + args[6] + " in sige on " + args[4] + " in war " + args[3]);
|
||||
return true;
|
||||
return finalizeSiege(s);
|
||||
} else {
|
||||
s.setDefenderPoints(Integer.parseInt(args[7]));
|
||||
p.sendMessage(Helper.Chatlabel() + "Set " + args[7] + " points for side " + args[6] + " in sige on " + args[4] + " in war " + args[3]);
|
||||
Main.warLogger.log("Set " + args[7] + " points for side " + args[6] + " in sige on " + args[4] + " in war " + args[3]);
|
||||
return true;
|
||||
return finalizeSiege(s);
|
||||
}
|
||||
} else if (s.getWar().getSide2().equals(args[6])) {
|
||||
if (s.getSide1AreAttackers()) {
|
||||
s.setDefenderPoints(Integer.parseInt(args[7]));
|
||||
p.sendMessage(Helper.Chatlabel() + "Set " + args[7] + " points for side " + args[6] + " in sige on " + args[4] + " in war " + args[3]);
|
||||
Main.warLogger.log("Set " + args[7] + " points for side " + args[6] + " in sige on " + args[4] + " in war " + args[3]);
|
||||
return true;
|
||||
return finalizeSiege(s);
|
||||
} else {
|
||||
s.setAttackerPoints(Integer.parseInt(args[7]));
|
||||
p.sendMessage(Helper.Chatlabel() + "Set " + args[7] + " points for side " + args[6] + " in sige on " + args[4] + " in war " + args[3]);
|
||||
Main.warLogger.log("Set " + args[7] + " points for side " + args[6] + " in sige on " + args[4] + " in war " + args[3]);
|
||||
return true;
|
||||
return finalizeSiege(s);
|
||||
}
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Side not found");
|
||||
@@ -1054,7 +1056,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
s.setTownSpawn(t.getSpawn());
|
||||
p.sendMessage(Helper.Chatlabel() + "Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + p.getLocation().toString());
|
||||
Main.warLogger.log("Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to [" + args[5] + "," + args[6] + "," + args[7] + "]");
|
||||
return true;
|
||||
return finalizeSiege(s);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Town does not contain town block at [" + args[5] + "," + args[7] + "]");
|
||||
return true;
|
||||
@@ -1082,7 +1084,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
s.setTownSpawn(t.getSpawn());
|
||||
p.sendMessage(Helper.Chatlabel() + "Set town spawn for sieged town " + args[5] + " in war " + args[4] + " to " + p.getLocation().toString());
|
||||
Main.warLogger.log("Set town spawn for sieged town " + args[5] + " in war " + args[4] + " to " + p.getLocation().toString());
|
||||
return true;
|
||||
return finalizeSiege(s);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Town does not contain town block at your location [" + (int) p.getLocation().getX() + "," + (int) p.getLocation().getZ() + "]");
|
||||
return true;
|
||||
@@ -1116,12 +1118,12 @@ public class AdminCommands implements CommandExecutor {
|
||||
s.setSiegeTicks(s.getSiegeTicks() + Integer.parseInt(args[6]));
|
||||
p.sendMessage(Helper.Chatlabel() + "Set time for siege against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||
Main.warLogger.log("Set time for siege against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||
return true;
|
||||
return finalizeSiege(s);
|
||||
} else if (args[5].equalsIgnoreCase("set")) {
|
||||
s.setSiegeTicks(Integer.parseInt(args[6]));
|
||||
p.sendMessage(Helper.Chatlabel() + "Set time for siege against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||
Main.warLogger.log("Set time for siege against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||
return true;
|
||||
return finalizeSiege(s);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Usage: /alathrawaradmin modify raid time [war] [town] [add/set] [value]");
|
||||
return true;
|
||||
@@ -1144,7 +1146,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
s.setSiegeOwner(own);
|
||||
p.sendMessage(Helper.Chatlabel() + "Set owner of siege against " + args[4] + " in war " + args[3] + " to " + own.getName());
|
||||
Main.warLogger.log("Set owner of siege against " + args[4] + " in war " + args[3] + " to " + own.getName());
|
||||
return true;
|
||||
return finalizeSiege(s);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Player not on attacking side!");
|
||||
return true;
|
||||
@@ -1195,14 +1197,16 @@ public class AdminCommands implements CommandExecutor {
|
||||
if (w.getName().equals(args[3])) {
|
||||
if (w.getSide1().equals(args[4])) {
|
||||
w.setSide1(args[5]);
|
||||
w.save();
|
||||
p.sendMessage(Helper.Chatlabel() + "Set side " + args[4] + " to " + args[5] + " in war " + args[3]);
|
||||
Main.warLogger.log(Helper.Chatlabel() + "Set side " + args[4] + " to " + args[5] + " in war " + args[3]);
|
||||
return true;
|
||||
return finalizeWar(w);
|
||||
} else if (w.getSide2().equals(args[4])) {
|
||||
w.setSide2(args[5]);
|
||||
w.save();
|
||||
p.sendMessage(Helper.Chatlabel() + "Set side " + args[4] + " to " + args[5] + " in war " + args[3]);
|
||||
Main.warLogger.log(Helper.Chatlabel() + "Set side " + args[4] + " to " + args[5] + " in war " + args[3]);
|
||||
return true;
|
||||
return finalizeWar(w);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Error: Side not found!");
|
||||
return true;
|
||||
@@ -1222,7 +1226,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
w.setName(args[4]);
|
||||
p.sendMessage(Helper.Chatlabel() + "Set name of war " + args[3] + " to " + args[4]);
|
||||
Main.warLogger.log(Helper.Chatlabel() + "Set name of war " + args[3] + " to " + args[4]);
|
||||
return true;
|
||||
return finalizeWar(w);
|
||||
}
|
||||
}
|
||||
p.sendMessage(Helper.color("c") + "Error: War not found!");
|
||||
@@ -1247,10 +1251,10 @@ public class AdminCommands implements CommandExecutor {
|
||||
w.addTown(t, args[5]);
|
||||
p.sendMessage(Helper.Chatlabel() + "Added town " + args[6] + " war " + args[3] + " on side " + args[4]);
|
||||
Main.warLogger.log(Helper.Chatlabel() + "Added town " + args[6] + " war " + args[3] + " on side " + args[4]);
|
||||
return true;
|
||||
return finalizeWar(w);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Error: Town not found!");
|
||||
return true;
|
||||
return finalizeWar(w);
|
||||
}
|
||||
} else if (args[5].equalsIgnoreCase("nation")) {
|
||||
Nation n = TownyAPI.getInstance().getNation(args[6]);
|
||||
@@ -1258,7 +1262,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
w.addNation(n, args[5]);
|
||||
p.sendMessage(Helper.Chatlabel() + "Added nation " + args[6] + " war " + args[3] + " on side " + args[4]);
|
||||
Main.warLogger.log(Helper.Chatlabel() + "Added nation " + args[6] + " war " + args[3] + " on side " + args[4]);
|
||||
return true;
|
||||
return finalizeWar(w);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Error: Nation not found!");
|
||||
return true;
|
||||
@@ -1291,7 +1295,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
w.surrenderTown(t.getName());
|
||||
p.sendMessage(Helper.Chatlabel() + "Surrendered town " + args[6] + " war " + args[3] + " on side " + args[4]);
|
||||
Main.warLogger.log(Helper.Chatlabel() + "Surrendered town " + args[6] + " war " + args[3] + " on side " + args[4]);
|
||||
return true;
|
||||
return finalizeWar(w);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Error: Town not found!");
|
||||
return true;
|
||||
@@ -1302,7 +1306,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
w.surrenderNation(n);
|
||||
p.sendMessage(Helper.Chatlabel() + "Surrendered nation " + args[6] + " war " + args[3] + " on side " + args[4]);
|
||||
Main.warLogger.log(Helper.Chatlabel() + "Surrendered nation " + args[6] + " war " + args[3] + " on side " + args[4]);
|
||||
return true;
|
||||
return finalizeWar(w);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Error: Nation not found!");
|
||||
return true;
|
||||
@@ -1329,12 +1333,12 @@ public class AdminCommands implements CommandExecutor {
|
||||
w.setLastRaidTimeSide1(w.getLastRaidTimeSide1() + Integer.parseInt(args[6]));
|
||||
p.sendMessage(Helper.Chatlabel() + "Added " + args[6] + " to last raid time in war " + args[4]);
|
||||
Main.warLogger.log(Helper.Chatlabel() + "Added " + args[6] + " to last raid time in war " + args[4]);
|
||||
return true;
|
||||
return finalizeWar(w);
|
||||
} else if (args[6].equals(w.getSide2())) {
|
||||
w.setLastRaidTimeSide2(w.getLastRaidTimeSide2() + Integer.parseInt(args[6]));
|
||||
p.sendMessage(Helper.Chatlabel() + "Added " + args[6] + " to last raid time in war " + args[4]);
|
||||
Main.warLogger.log(Helper.Chatlabel() + "Added " + args[6] + " to last raid time in war " + args[4]);
|
||||
return true;
|
||||
return finalizeWar(w);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Side not found!");
|
||||
return true;
|
||||
@@ -1349,12 +1353,12 @@ public class AdminCommands implements CommandExecutor {
|
||||
w.setLastRaidTimeSide1(Long.parseLong(args[6]));
|
||||
p.sendMessage(Helper.Chatlabel() + "Set last raid time in war " + args[4] + " to " + args[6]);
|
||||
Main.warLogger.log(Helper.Chatlabel() + "Set last raid time in war " + args[4] + " to " + args[6]);
|
||||
return true;
|
||||
return finalizeWar(w);
|
||||
} else if (args[6].equals(w.getSide2())) {
|
||||
w.setLastRaidTimeSide2(Long.parseLong(args[6]));
|
||||
p.sendMessage(Helper.Chatlabel() + "Set last raid time in war " + args[4] + " to " + args[6]);
|
||||
Main.warLogger.log(Helper.Chatlabel() + "Set last raid time in war " + args[4] + " to " + args[6]);
|
||||
return true;
|
||||
return finalizeWar(w);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Side not found!");
|
||||
return true;
|
||||
@@ -1368,12 +1372,12 @@ public class AdminCommands implements CommandExecutor {
|
||||
w.setLastRaidTimeSide1(0L);
|
||||
p.sendMessage(Helper.Chatlabel() + "Reset last raid time in war " + args[4]);
|
||||
Main.warLogger.log(Helper.Chatlabel() + "Reset last raid time in war " + args[4]);
|
||||
return true;
|
||||
return finalizeWar(w);
|
||||
} else if (args[6].equals(w.getSide2())) {
|
||||
w.setLastRaidTimeSide2(0L);
|
||||
p.sendMessage(Helper.Chatlabel() + "Reset last raid time in war " + args[4]);
|
||||
Main.warLogger.log(Helper.Chatlabel() + "Reset last raid time in war " + args[4]);
|
||||
return true;
|
||||
return finalizeWar(w);
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Side not found!");
|
||||
return true;
|
||||
@@ -1385,16 +1389,16 @@ public class AdminCommands implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
p.sendMessage(Helper.color("c") + "Error: War not found!");
|
||||
return true;
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Usage: /alathrawaradmin modify war raidTimeWar [add,set,reset] [war] [amt] [side]");
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
} else if (args[2].equalsIgnoreCase("raidTimeTown")) {
|
||||
if (args.length >= 5) {
|
||||
for (Town t : TownyAPI.getInstance().getTowns()) {
|
||||
if (t.getName().equals(args[4])) {
|
||||
if (args[3].equalsIgnoreCase("add")) {
|
||||
|
||||
if (args.length >= 6) {
|
||||
LongDataField last = (LongDataField) t.getMetadata("lastRaided");
|
||||
if (last != null) {
|
||||
@@ -1406,7 +1410,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
Main.warLogger.log(Helper.Chatlabel() + "Added " + args[6] + " to last raid time in war " + args[3]);
|
||||
return true;
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Usage: /alathrawaradmin modify war raidTimeWar [add,set,reset] [town/war] [amt] [side]");
|
||||
p.sendMessage(Helper.color("c") + "Usage: /alathrawaradmin modify war raidTimeTown [add,set,reset] [town/war] [amt] [side]");
|
||||
return true;
|
||||
}
|
||||
} else if (args[3].equalsIgnoreCase("set")) {
|
||||
@@ -1416,7 +1420,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
Main.warLogger.log(Helper.Chatlabel() + "Set last raid time in war " + args[4] + " to " + args[6]);
|
||||
return true;
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Usage: /alathrawaradmin modify war raidTimeWar [add,set,reset] [town/war] [amt] [side]");
|
||||
p.sendMessage(Helper.color("c") + "Usage: /alathrawaradmin modify war raidTimeTown [add,set,reset] [town/war] [amt] [side]");
|
||||
return true;
|
||||
}
|
||||
} else if (args[3].equalsIgnoreCase("reset")) {
|
||||
@@ -1431,10 +1435,11 @@ public class AdminCommands implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
p.sendMessage(Helper.color("c") + "Error: Town not found!");
|
||||
return true;
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Usage: /alathrawaradmin modify [raid/siege/war] [propery]");
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
p.sendMessage(Helper.color("c") + "Usage: /alathrawaradmin modify [raid/siege/war] [propery]");
|
||||
return true;
|
||||
@@ -1471,4 +1476,19 @@ public class AdminCommands implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean finalizeRaid(Raid r) {
|
||||
r.save();
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean finalizeSiege(Siege s) {
|
||||
s.save();
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean finalizeWar(War w) {
|
||||
w.save();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,8 @@ public class AdminTabCompletion implements TabCompleter {
|
||||
"name",
|
||||
"add",
|
||||
"surrender",
|
||||
"raidTime"
|
||||
"raidTimeWar",
|
||||
"raidTimeTown"
|
||||
});
|
||||
|
||||
List<String> force = List.of(new String[]{
|
||||
@@ -62,17 +63,24 @@ public class AdminTabCompletion implements TabCompleter {
|
||||
"leave"
|
||||
});
|
||||
|
||||
List<String> addSet = List.of(new String[] {
|
||||
List<String> addSet = List.of(new String[]{
|
||||
"add",
|
||||
"set"
|
||||
});
|
||||
|
||||
List<String> nationTown = List.of(new String[] {
|
||||
|
||||
List<String> addSetReset = List.of(new String[]{
|
||||
"add",
|
||||
"set",
|
||||
"reset"
|
||||
});
|
||||
|
||||
List<String> nationTown = List.of(new String[]{
|
||||
"town",
|
||||
"nation"
|
||||
});
|
||||
|
||||
List<String> lootSet = List.of(new String[] {
|
||||
List<String> lootSet = List.of(new String[]{
|
||||
"value",
|
||||
"looted",
|
||||
"ticks",
|
||||
@@ -92,13 +100,13 @@ public class AdminTabCompletion implements TabCompleter {
|
||||
* -modify raid owner [war] [town] [player]
|
||||
* -modify raid move [war] [town] [newWar] //low priority, moves raid to other war/ town
|
||||
* -modify raid clearActive [war] [town] //low priority
|
||||
*
|
||||
* <p>
|
||||
* -modify siege score [war] [town] [side] [amt]
|
||||
* -modify siege townspawn [war] [town] (x) (Z)
|
||||
* -modify siege time [war] [town] [add/set/max] [value] //max modified the max length
|
||||
* -modify siege owner [war] [town] [add/set] [value]
|
||||
* -modify siege move [war] [town] [newWar] //low priority, moves siege to other war/town
|
||||
*
|
||||
* <p>
|
||||
* -modify war score [war] [side] [amt]
|
||||
* -modify war side [war] [side] [name]
|
||||
* -modify war name [war] [name]
|
||||
@@ -515,19 +523,19 @@ public class AdminTabCompletion implements TabCompleter {
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("war")) {
|
||||
if (args.length > 3) {
|
||||
if (args.length > 4) {
|
||||
switch (args[2]) {
|
||||
/*
|
||||
* -modify war score [war] [side] [amt]
|
||||
* -modify war side [war] [side] [name]
|
||||
* -modify war name [war] [name]
|
||||
* -modify war add [war] [side] [town/nation] [town/nation]
|
||||
* -modify war add nation [war] [nation]
|
||||
* -modify war surrender town [war] [town] //adds town to surrender list
|
||||
* -modify war surrender nation [war] [town] //adds all towns to surrender list
|
||||
* -modify war raidTime [add,set,reset] [war] [town] [amt] //set when last raid was
|
||||
*/
|
||||
case "score", "raidTime" -> {
|
||||
switch (args[2]) {
|
||||
/*
|
||||
* -modify war score [war] [side] [amt]
|
||||
* -modify war side [war] [side] [name]
|
||||
* -modify war name [war] [name]
|
||||
* -modify war add [war] [side] [town/nation] [town/nation]
|
||||
* -modify war add nation [war] [nation]
|
||||
* -modify war surrender town [war] [town] //adds town to surrender list
|
||||
* -modify war surrender nation [war] [town] //adds all towns to surrender list
|
||||
* -modify war raidTimeTown [add,set,reset] [war] [town] [amt] //set when last raid was
|
||||
*/
|
||||
case "score" -> {
|
||||
if (args.length > 4) {
|
||||
if (args.length > 5) {
|
||||
if (args.length > 6) {
|
||||
if (args.length > 7) {
|
||||
@@ -540,17 +548,65 @@ public class AdminTabCompletion implements TabCompleter {
|
||||
}
|
||||
} else {
|
||||
return NameUtil.filterByStart(addSet, args[4]);
|
||||
|
||||
}
|
||||
} else {
|
||||
return NameUtil.filterByStart(CommandHelper.getWarNames(), args[3]);
|
||||
}
|
||||
case "side" -> {
|
||||
}
|
||||
//alathrawaradmin modify war raidTimeTown [add,set,reset] [town/war] [amt] [side]
|
||||
case "raidTimeTown" -> {
|
||||
if (args.length > 4) {
|
||||
if (args.length > 5) {
|
||||
return null;
|
||||
} else {
|
||||
return NameUtil.filterByStart(CommandHelper.getTownyTowns(), args[4]);
|
||||
}
|
||||
} else {
|
||||
return NameUtil.filterByStart(addSetReset, args[3]);
|
||||
}
|
||||
}
|
||||
//alathrawaradmin modify war raidTimeWar [add,set,reset] [war] [amt] [side]
|
||||
case "raidTimeWar" -> {
|
||||
if (args.length > 4) {
|
||||
if (args.length > 5) {
|
||||
if (args.length > 6) {
|
||||
if (args.length > 7) {
|
||||
return NameUtil.filterByStart(CommandHelper.getWarSides(args[4]), args[6]);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return NameUtil.filterByStart(CommandHelper.getWarNames(), args[4]);
|
||||
}
|
||||
} else {
|
||||
return NameUtil.filterByStart(addSetReset, args[3]);
|
||||
|
||||
}
|
||||
}
|
||||
case "side" -> {
|
||||
|
||||
if (args.length > 4) {
|
||||
if (args.length > 5) {
|
||||
return null;
|
||||
} else {
|
||||
return NameUtil.filterByStart(CommandHelper.getWarSides(args[3]), args[4]);
|
||||
}
|
||||
} else {
|
||||
return NameUtil.filterByStart(CommandHelper.getWarNames(), args[3]);
|
||||
}
|
||||
case "add", "surrender" -> {
|
||||
}
|
||||
case "name" -> {
|
||||
if (args.length > 4) {
|
||||
return null;
|
||||
} else {
|
||||
return NameUtil.filterByStart(CommandHelper.getWarNames(), args[3]);
|
||||
}
|
||||
}
|
||||
case "add", "surrender" -> {
|
||||
if (args.length > 4) {
|
||||
if (args.length > 5) {
|
||||
if (args.length > 6) {
|
||||
if (args.length > 7) {
|
||||
@@ -570,14 +626,15 @@ public class AdminTabCompletion implements TabCompleter {
|
||||
} else {
|
||||
return NameUtil.filterByStart(CommandHelper.getWarSides(args[3]), args[4]);
|
||||
}
|
||||
}
|
||||
default -> {
|
||||
return null;
|
||||
} else {
|
||||
return NameUtil.filterByStart(CommandHelper.getWarNames(), args[3]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return NameUtil.filterByStart(CommandHelper.getWarNames(), args[3]);
|
||||
default -> {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
return NameUtil.filterByStart(warModify, args[2]);
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ public class RaidCommands implements CommandExecutor {
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "This town was raided too recently!");
|
||||
return;
|
||||
} else if (c == -2) {
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "This town has no online players to defend it!");
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "At least on member of the raided town must be online to defend it!");
|
||||
return;
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
@@ -60,7 +60,7 @@ public class SiegeData
|
||||
|
||||
public static void removeSiege(Siege siege) {
|
||||
sieges.remove(siege);
|
||||
//deleteSiege(siege);
|
||||
//deleteSiege(siege);d
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -128,6 +128,7 @@ public class WarData
|
||||
sHashMap.put("lastRaidTimeSide2", war.getLastRaidTimeSide2());
|
||||
|
||||
|
||||
|
||||
DataManager.saveData("wars" + File.separator + war.getName() + ".yml", sHashMap);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user