mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-04 14:38:57 +00:00
Shift Admin and raid commands to use console as well.
This commit is contained in:
1 parent
bacf39583e
commit
6c6828f7fa
3 files changed
+130
-72
No files matched your search
@@ -106,26 +106,25 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
final Player p = (Player) sender;
|
if (!sender.hasPermission("AlathraWar.admin")) {
|
||||||
if (!p.hasPermission("AlathraWar.admin")) {
|
return fail(sender, args, "permissions");
|
||||||
return fail(p, args, "permissions");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
return fail(p, args, "syntax");
|
return fail(sender, args, "syntax");
|
||||||
} else if (args.length >= 1) {
|
} else if (args.length >= 1) {
|
||||||
if (args[0].equalsIgnoreCase("create")) {
|
if (args[0].equalsIgnoreCase("create")) {
|
||||||
return create(p, args);
|
return create(sender, args);
|
||||||
} else if (args[0].equalsIgnoreCase("force")) {
|
} else if (args[0].equalsIgnoreCase("force")) {
|
||||||
return force(p, args);
|
return force(sender, args);
|
||||||
} else if (args[0].equalsIgnoreCase("help")) {
|
} else if (args[0].equalsIgnoreCase("help")) {
|
||||||
return help(p, args);
|
return help(sender, args);
|
||||||
} else if (args[0].equalsIgnoreCase("info")) {
|
} else if (args[0].equalsIgnoreCase("info")) {
|
||||||
return info(p, args);
|
return info(sender, args);
|
||||||
} else if (args[0].equalsIgnoreCase("modify")) {
|
} else if (args[0].equalsIgnoreCase("modify")) {
|
||||||
return modify(p, args);
|
return modify(sender, args);
|
||||||
} else if (args[0].equalsIgnoreCase("awa")) {
|
} else if (args[0].equalsIgnoreCase("awa")) {
|
||||||
return awa(p, args);
|
return awa(sender, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -138,18 +137,19 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
* -create raid [war] [raidTown] [gatherTown] (owner)
|
* -create raid [war] [raidTown] [gatherTown] (owner)
|
||||||
* -create war [name] [side1] [side2]
|
* -create war [name] [side1] [side2]
|
||||||
*/
|
*/
|
||||||
private static boolean create(Player p, String[] args) {
|
private static boolean create(CommandSender p, String[] args) {
|
||||||
if (args.length >= 2) {
|
if (args.length >= 2) {
|
||||||
if (args[1].equalsIgnoreCase("raid")) {
|
if (args[1].equalsIgnoreCase("raid")) {
|
||||||
if (args.length >= 4) {
|
if (args.length >= 4) {
|
||||||
//specific behavior exists if an admin ran this
|
//specific behavior exists if an admin ran this
|
||||||
//using same method so that this doesnt get fucked up if we go back and change original implementation
|
//using same method so that this doesnt get fucked up if we go back and change original implementation
|
||||||
RaidCommands.startRaid(p, args, true);
|
RaidCommands.startRaid(p, args, true);
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
//defaultCode will bypass the custom gather town to force set owner
|
//defaultCode will bypass the custom gather town to force set owner
|
||||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create raid [war] [raidTown] (gatherTown/\"defaultCode\") (owner)"));
|
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create raid [war] [raidTown] (gatherTown/\"defaultCode\") (owner)"));
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
} else if (args[1].equalsIgnoreCase("siege")) {
|
} else if (args[1].equalsIgnoreCase("siege")) {
|
||||||
//this exists to force a seige with a new owner
|
//this exists to force a seige with a new owner
|
||||||
if (args.length >= 4) {
|
if (args.length >= 4) {
|
||||||
@@ -161,6 +161,7 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
};
|
};
|
||||||
SiegeCommands.siegeStart(p, adjusted, true);
|
SiegeCommands.siegeStart(p, adjusted, true);
|
||||||
p.sendMessage(Helper.Chatlabel() + "Try again later!");
|
p.sendMessage(Helper.Chatlabel() + "Try again later!");
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create siege [war] [town] (owner)"));
|
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create siege [war] [town] (owner)"));
|
||||||
return true;
|
return true;
|
||||||
@@ -176,6 +177,7 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
args[4]
|
args[4]
|
||||||
};
|
};
|
||||||
WarCommands.warCreate(p, adjusted);
|
WarCommands.warCreate(p, adjusted);
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create war [name] [side1] [side2]"));
|
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create war [name] [side1] [side2]"));
|
||||||
return true;
|
return true;
|
||||||
@@ -203,7 +205,7 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
* @param args args
|
* @param args args
|
||||||
* @return result
|
* @return result
|
||||||
*/
|
*/
|
||||||
private static boolean force(Player p, String[] args) {
|
private static boolean force(CommandSender p, String[] args) {
|
||||||
if (args.length >= 2) {
|
if (args.length >= 2) {
|
||||||
if (args[1].equalsIgnoreCase("end")) {
|
if (args[1].equalsIgnoreCase("end")) {
|
||||||
if (args.length >= 3) {
|
if (args.length >= 3) {
|
||||||
@@ -429,7 +431,7 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
return fail(p, args, "syntax");
|
return fail(p, args, "syntax");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean help(Player p, String[] args) {
|
private static boolean help(CommandSender p, String[] args) {
|
||||||
p.sendMessage(Helper.Chatlabel() + "/alathrawaradmin create");
|
p.sendMessage(Helper.Chatlabel() + "/alathrawaradmin create");
|
||||||
p.sendMessage(Helper.Chatlabel() + "/alathrawaradmin force");
|
p.sendMessage(Helper.Chatlabel() + "/alathrawaradmin force");
|
||||||
p.sendMessage(Helper.Chatlabel() + "/alathrawaradmin help");
|
p.sendMessage(Helper.Chatlabel() + "/alathrawaradmin help");
|
||||||
@@ -450,7 +452,7 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
* @param args args
|
* @param args args
|
||||||
* @return result
|
* @return result
|
||||||
*/
|
*/
|
||||||
private static boolean info(Player p, String[] args) {
|
private static boolean info(CommandSender p, String[] args) {
|
||||||
if (args.length >= 2) {
|
if (args.length >= 2) {
|
||||||
if (args[1].equalsIgnoreCase("war")) {
|
if (args[1].equalsIgnoreCase("war")) {
|
||||||
if (args.length >= 3) {
|
if (args.length >= 3) {
|
||||||
@@ -643,7 +645,7 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
* @param args args
|
* @param args args
|
||||||
* @return result
|
* @return result
|
||||||
*/
|
*/
|
||||||
private static boolean modify(Player p, String[] args) {
|
private static boolean modify(CommandSender p, String[] args) {
|
||||||
if (args.length >= 2) {
|
if (args.length >= 2) {
|
||||||
if (args[1].equalsIgnoreCase("raid")) {
|
if (args[1].equalsIgnoreCase("raid")) {
|
||||||
if (args.length >= 3) {
|
if (args.length >= 3) {
|
||||||
@@ -756,15 +758,19 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
Town t = r.getRaidedTown();
|
Town t = r.getRaidedTown();
|
||||||
if (args.length >= 8) {
|
if (args.length >= 8) {
|
||||||
if (p.getWorld() == t.getWorld()) {
|
if(!(p instanceof Player runner)) {
|
||||||
|
p.sendMessage(Helper.Chatlabel() + "This command cannot be run through console!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (runner.getWorld() == t.getWorld()) {
|
||||||
try {
|
try {
|
||||||
WorldCoord tb = WorldCoord.parseWorldCoord(p.getWorld().getName(), (int) Double.parseDouble(args[5]), (int) Double.parseDouble(args[7]));
|
WorldCoord tb = WorldCoord.parseWorldCoord(runner.getWorld().getName(), (int) Double.parseDouble(args[5]), (int) Double.parseDouble(args[7]));
|
||||||
if (t.hasTownBlock(tb)) {
|
if (t.hasTownBlock(tb)) {
|
||||||
t.setHomeBlock(tb.getTownBlock());
|
t.setHomeBlock(tb.getTownBlock());
|
||||||
t.setSpawn(new Location(p.getWorld(), Double.parseDouble(args[5]), Double.parseDouble(args[6]), Double.parseDouble(args[7])));
|
t.setSpawn(new Location(runner.getWorld(), Double.parseDouble(args[5]), Double.parseDouble(args[6]), Double.parseDouble(args[7])));
|
||||||
r.setHomeBlockRaided(tb.getTownBlock());
|
r.setHomeBlockRaided(tb.getTownBlock());
|
||||||
r.setTownSpawnRaided(t.getSpawn());
|
r.setTownSpawnRaided(t.getSpawn());
|
||||||
p.sendMessage(Helper.Chatlabel() + "Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + p.getLocation().toString());
|
p.sendMessage(Helper.Chatlabel() + "Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString());
|
||||||
Main.warLogger.log("Set town spawn for raided town " + args[4] + " in war " + args[3] + " to [" + args[5] + "," + args[6] + "," + args[7] + "]");
|
Main.warLogger.log("Set town spawn for raided town " + args[4] + " in war " + args[3] + " to [" + args[5] + "," + args[6] + "," + args[7] + "]");
|
||||||
return finalizeRaid(r);
|
return finalizeRaid(r);
|
||||||
} else {
|
} else {
|
||||||
@@ -783,19 +789,23 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (p.getWorld() == t.getWorld()) {
|
if(!(p instanceof Player runner)) {
|
||||||
|
p.sendMessage(Helper.Chatlabel() + "This command cannot be run through console!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (runner.getWorld() == t.getWorld()) {
|
||||||
try {
|
try {
|
||||||
WorldCoord tb = WorldCoord.parseWorldCoord(p.getWorld().getName(), (int) p.getLocation().getX(), (int) p.getLocation().getZ());
|
WorldCoord tb = WorldCoord.parseWorldCoord(runner.getWorld().getName(), (int) runner.getLocation().getX(), (int) runner.getLocation().getZ());
|
||||||
if (t.hasTownBlock(tb)) {
|
if (t.hasTownBlock(tb)) {
|
||||||
t.setHomeBlock(tb.getTownBlock());
|
t.setHomeBlock(tb.getTownBlock());
|
||||||
t.setSpawn(p.getLocation());
|
t.setSpawn(runner.getLocation());
|
||||||
r.setHomeBlockRaided(tb.getTownBlock());
|
r.setHomeBlockRaided(tb.getTownBlock());
|
||||||
r.setTownSpawnRaided(t.getSpawn());
|
r.setTownSpawnRaided(t.getSpawn());
|
||||||
p.sendMessage(Helper.Chatlabel() + "Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + p.getLocation().toString());
|
p.sendMessage(Helper.Chatlabel() + "Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString());
|
||||||
Main.warLogger.log("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 " + runner.getLocation().toString());
|
||||||
return finalizeRaid(r);
|
return finalizeRaid(r);
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Helper.color("&cTown does not contain town block at your location [" + (int) p.getLocation().getX() + "," + (int) p.getLocation().getZ() + "]"));
|
p.sendMessage(Helper.color("&cTown does not contain town block at your location [" + (int) runner.getLocation().getX() + "," + (int) runner.getLocation().getZ() + "]"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (NotRegisteredException e) {
|
} catch (NotRegisteredException e) {
|
||||||
@@ -880,13 +890,18 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
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])) {
|
||||||
//parse phase
|
//parse phase
|
||||||
if (!p.getWorld().equals(r.getRaidedTown().getWorld())) {
|
if(!(p instanceof Player runner)) {
|
||||||
|
p.sendMessage(Helper.Chatlabel() + "This command cannot be run through console!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!runner.getWorld().equals(r.getRaidedTown().getWorld())) {
|
||||||
p.sendMessage(Helper.Chatlabel() + "Error wrong world");
|
p.sendMessage(Helper.Chatlabel() + "Error wrong world");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args.length >= 9) {
|
if (args.length >= 9) {
|
||||||
if (args[5].equalsIgnoreCase("value")) {
|
if (args[5].equalsIgnoreCase("value")) {
|
||||||
WorldCoord wc = WorldCoord.parseWorldCoord(p.getWorld().getName(), (int) Double.parseDouble(args[7]), (int) Double.parseDouble(args[8]));
|
WorldCoord wc = WorldCoord.parseWorldCoord(runner.getWorld().getName(), (int) Double.parseDouble(args[7]), (int) Double.parseDouble(args[8]));
|
||||||
Raid.LootBlock lb = r.getLootedChunks().get(wc);
|
Raid.LootBlock lb = r.getLootedChunks().get(wc);
|
||||||
if(lb == null) {
|
if(lb == null) {
|
||||||
r.addLootedChunk(wc);
|
r.addLootedChunk(wc);
|
||||||
@@ -898,7 +913,7 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
Main.warLogger.log("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 finalizeRaid(r);
|
return finalizeRaid(r);
|
||||||
} else if (args[5].equalsIgnoreCase("looted")) {
|
} else if (args[5].equalsIgnoreCase("looted")) {
|
||||||
WorldCoord wc = WorldCoord.parseWorldCoord(p.getWorld().getName(), (int) Double.parseDouble(args[7]), (int) Double.parseDouble(args[8]));
|
WorldCoord wc = WorldCoord.parseWorldCoord(runner.getWorld().getName(), (int) Double.parseDouble(args[7]), (int) Double.parseDouble(args[8]));
|
||||||
Raid.LootBlock lb = r.getLootedChunks().get(wc);
|
Raid.LootBlock lb = r.getLootedChunks().get(wc);
|
||||||
//The base value can be abjusted
|
//The base value can be abjusted
|
||||||
if(!lb.finished && Boolean.parseBoolean(args[6])) {
|
if(!lb.finished && Boolean.parseBoolean(args[6])) {
|
||||||
@@ -914,14 +929,14 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
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]);
|
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 finalizeRaid(r);
|
return finalizeRaid(r);
|
||||||
} else if (args[5].equalsIgnoreCase("ticks")) {
|
} else if (args[5].equalsIgnoreCase("ticks")) {
|
||||||
WorldCoord wc = WorldCoord.parseWorldCoord(p.getWorld().getName(), (int) Double.parseDouble(args[7]), (int) Double.parseDouble(args[8]));
|
WorldCoord wc = WorldCoord.parseWorldCoord(runner.getWorld().getName(), (int) Double.parseDouble(args[7]), (int) Double.parseDouble(args[8]));
|
||||||
Raid.LootBlock lb = r.getLootedChunks().get(wc);
|
Raid.LootBlock lb = r.getLootedChunks().get(wc);
|
||||||
lb.ticks = Integer.parseInt(args[6]);
|
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]);
|
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]);
|
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 finalizeRaid(r);
|
return finalizeRaid(r);
|
||||||
} else if (args[5].equalsIgnoreCase("reset")) {
|
} else if (args[5].equalsIgnoreCase("reset")) {
|
||||||
WorldCoord wc = WorldCoord.parseWorldCoord(p.getWorld().getName(), (int) Double.parseDouble(args[6]), (int) Double.parseDouble(args[7]));
|
WorldCoord wc = WorldCoord.parseWorldCoord(runner.getWorld().getName(), (int) Double.parseDouble(args[6]), (int) Double.parseDouble(args[7]));
|
||||||
r.getLootedChunks().remove(wc);
|
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]);
|
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]);
|
Main.warLogger.log("Reset loot for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3]);
|
||||||
@@ -935,31 +950,31 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (args[5].equalsIgnoreCase("value")) {
|
if (args[5].equalsIgnoreCase("value")) {
|
||||||
WorldCoord wc = WorldCoord.parseWorldCoord(p.getLocation());
|
WorldCoord wc = WorldCoord.parseWorldCoord(runner.getLocation());
|
||||||
Raid.LootBlock lb = r.getLootedChunks().get(wc);
|
Raid.LootBlock lb = r.getLootedChunks().get(wc);
|
||||||
lb.value = Integer.parseInt(args[6]);
|
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]);
|
p.sendMessage(Helper.Chatlabel() + "Set value for a chunk [" + runner.getLocation().getX() + "," + runner.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]);
|
Main.warLogger.log("Set value for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||||
return finalizeRaid(r);
|
return finalizeRaid(r);
|
||||||
} else if (args[5].equalsIgnoreCase("looted")) {
|
} else if (args[5].equalsIgnoreCase("looted")) {
|
||||||
WorldCoord wc = WorldCoord.parseWorldCoord(p.getLocation());
|
WorldCoord wc = WorldCoord.parseWorldCoord(runner.getLocation());
|
||||||
Raid.LootBlock lb = r.getLootedChunks().get(wc);
|
Raid.LootBlock lb = r.getLootedChunks().get(wc);
|
||||||
lb.finished = Boolean.parseBoolean(args[6]);
|
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]);
|
p.sendMessage(Helper.Chatlabel() + "Set looted status for a chunk [" + runner.getLocation().getX() + "," + runner.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]);
|
Main.warLogger.log("Set looted status for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||||
return finalizeRaid(r);
|
return finalizeRaid(r);
|
||||||
} else if (args[5].equalsIgnoreCase("ticks")) {
|
} else if (args[5].equalsIgnoreCase("ticks")) {
|
||||||
WorldCoord wc = WorldCoord.parseWorldCoord(p.getLocation());
|
WorldCoord wc = WorldCoord.parseWorldCoord(runner.getLocation());
|
||||||
Raid.LootBlock lb = r.getLootedChunks().get(wc);
|
Raid.LootBlock lb = r.getLootedChunks().get(wc);
|
||||||
lb.ticks = Integer.parseInt(args[6]);
|
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]);
|
p.sendMessage(Helper.Chatlabel() + "Set ticks for a chunk [" + runner.getLocation().getX() + "," + runner.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]);
|
Main.warLogger.log("Set ticks for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]);
|
||||||
return finalizeRaid(r);
|
return finalizeRaid(r);
|
||||||
} else if (args[5].equalsIgnoreCase("reset")) {
|
} else if (args[5].equalsIgnoreCase("reset")) {
|
||||||
WorldCoord wc = WorldCoord.parseWorldCoord(p.getLocation());
|
WorldCoord wc = WorldCoord.parseWorldCoord(runner.getLocation());
|
||||||
r.getLootedChunks().remove(wc);
|
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]);
|
p.sendMessage(Helper.Chatlabel() + "Reset loot for a chunk [" + runner.getLocation().getX() + "," + runner.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]);
|
Main.warLogger.log("Reset Loot for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3]);
|
||||||
return finalizeRaid(r);
|
return finalizeRaid(r);
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify raid loot [war] [town] [value,looted,ticks,reset] [amt] (x) (z)"));
|
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify raid loot [war] [town] [value,looted,ticks,reset] [amt] (x) (z)"));
|
||||||
@@ -1123,15 +1138,19 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
Town t = s.getTown();
|
Town t = s.getTown();
|
||||||
if (args.length >= 8) {
|
if (args.length >= 8) {
|
||||||
if (p.getWorld() == t.getWorld()) {
|
if(!(p instanceof Player runner)) {
|
||||||
|
p.sendMessage(Helper.Chatlabel() + "This command cannot be run through console!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (runner.getWorld() == t.getWorld()) {
|
||||||
try {
|
try {
|
||||||
WorldCoord tb = WorldCoord.parseWorldCoord(p.getWorld().getName(), (int) Double.parseDouble(args[5]), (int) Double.parseDouble(args[7]));
|
WorldCoord tb = WorldCoord.parseWorldCoord(runner.getWorld().getName(), (int) Double.parseDouble(args[5]), (int) Double.parseDouble(args[7]));
|
||||||
if (t.hasTownBlock(tb)) {
|
if (t.hasTownBlock(tb)) {
|
||||||
t.setHomeBlock(tb.getTownBlock());
|
t.setHomeBlock(tb.getTownBlock());
|
||||||
t.setSpawn(new Location(p.getWorld(), (int) Double.parseDouble(args[5]), (int) Double.parseDouble(args[6]), (int) Double.parseDouble(args[7])));
|
t.setSpawn(new Location(runner.getWorld(), (int) Double.parseDouble(args[5]), (int) Double.parseDouble(args[6]), (int) Double.parseDouble(args[7])));
|
||||||
s.setHomeBlock(tb.getTownBlock());
|
s.setHomeBlock(tb.getTownBlock());
|
||||||
s.setTownSpawn(t.getSpawn());
|
s.setTownSpawn(t.getSpawn());
|
||||||
p.sendMessage(Helper.Chatlabel() + "Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + p.getLocation().toString());
|
p.sendMessage(Helper.Chatlabel() + "Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString());
|
||||||
Main.warLogger.log("Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to [" + args[5] + "," + args[6] + "," + args[7] + "]");
|
Main.warLogger.log("Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to [" + args[5] + "," + args[6] + "," + args[7] + "]");
|
||||||
return finalizeSiege(s);
|
return finalizeSiege(s);
|
||||||
} else {
|
} else {
|
||||||
@@ -1150,19 +1169,24 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (p.getWorld() == t.getWorld()) {
|
|
||||||
|
if(!(p instanceof Player runner)) {
|
||||||
|
p.sendMessage(Helper.Chatlabel() + "This command cannot be run through console!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (runner.getWorld() == t.getWorld()) {
|
||||||
try {
|
try {
|
||||||
WorldCoord tb = WorldCoord.parseWorldCoord(p.getWorld().getName(), (int) p.getLocation().getX(), (int) p.getLocation().getZ());
|
WorldCoord tb = WorldCoord.parseWorldCoord(runner.getWorld().getName(), (int) runner.getLocation().getX(), (int) runner.getLocation().getZ());
|
||||||
if (t.hasTownBlock(tb)) {
|
if (t.hasTownBlock(tb)) {
|
||||||
t.setHomeBlock(tb.getTownBlock());
|
t.setHomeBlock(tb.getTownBlock());
|
||||||
t.setSpawn(p.getLocation());
|
t.setSpawn(runner.getLocation());
|
||||||
s.setHomeBlock(tb.getTownBlock());
|
s.setHomeBlock(tb.getTownBlock());
|
||||||
s.setTownSpawn(t.getSpawn());
|
s.setTownSpawn(t.getSpawn());
|
||||||
p.sendMessage(Helper.Chatlabel() + "Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + p.getLocation().toString());
|
p.sendMessage(Helper.Chatlabel() + "Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString());
|
||||||
Main.warLogger.log("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 " + runner.getLocation().toString());
|
||||||
return finalizeSiege(s);
|
return finalizeSiege(s);
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Helper.color("&cTown does not contain town block at your location [" + (int) p.getLocation().getX() + "," + (int) p.getLocation().getZ() + "]"));
|
p.sendMessage(Helper.color("&cTown does not contain town block at your location [" + (int) runner.getLocation().getX() + "," + (int) runner.getLocation().getZ() + "]"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (NotRegisteredException e) {
|
} catch (NotRegisteredException e) {
|
||||||
@@ -1726,7 +1750,8 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean awa(Player sender, String[] args) {
|
private static boolean awa(CommandSender sender, String[] args) {
|
||||||
|
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
Player p = Bukkit.getPlayer(args[1]);
|
Player p = Bukkit.getPlayer(args[1]);
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
@@ -1736,11 +1761,12 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
p.chat("awa awa! ^.^ UwU");
|
p.chat("awa awa! ^.^ UwU");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
sender.chat("awa awa! ^.^ UwU");
|
if(sender instanceof Player)
|
||||||
|
((Player) sender).chat("awa awa! ^.^ UwU");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean fail(Player p, String[] args, String type) {
|
private static boolean fail(CommandSender p, String[] args, String type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "permissions" -> {
|
case "permissions" -> {
|
||||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&cYou do not have permission to do this."));
|
p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&cYou do not have permission to do this."));
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
* @param p
|
* @param p
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
protected static void startRaid(Player p, String[] args, boolean admin) {
|
protected static void startRaid(CommandSender p, String[] args, boolean admin) {
|
||||||
boolean warFound = false;
|
boolean warFound = false;
|
||||||
boolean townExists = false;
|
boolean townExists = false;
|
||||||
for (final War war : WarData.getWars()) {
|
for (final War war : WarData.getWars()) {
|
||||||
@@ -71,13 +71,20 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
if (war.getName().equalsIgnoreCase(args[1 + (admin ? 1 : 0)])) {
|
if (war.getName().equalsIgnoreCase(args[1 + (admin ? 1 : 0)])) {
|
||||||
warFound = true;
|
warFound = true;
|
||||||
|
|
||||||
Player raidOwner = p;
|
Player raidOwner = null;
|
||||||
|
if(p instanceof Player) {
|
||||||
|
raidOwner = (Player) p;
|
||||||
|
} else {
|
||||||
|
p.sendMessage("Running this from the console requires a Player Argument!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
TownyWorld townyWorld;
|
TownyWorld townyWorld;
|
||||||
townyWorld = WorldCoord.parseWorldCoord(raidOwner.getLocation()).getTownyWorld();
|
townyWorld = WorldCoord.parseWorldCoord(raidOwner.getLocation()).getTownyWorld();
|
||||||
if(admin && args.length >= 6) {
|
if(admin && args.length >= 6) {
|
||||||
raidOwner = Bukkit.getPlayer(args[5]);
|
raidOwner = Bukkit.getPlayer(args[5]);
|
||||||
if(raidOwner == null) {
|
if(raidOwner == null) {
|
||||||
raidOwner = p;
|
p.sendMessage("Player Does not exist");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,7 +256,7 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//check player balance
|
//check player balance
|
||||||
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(p.getUniqueId());
|
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(raidOwner.getUniqueId());
|
||||||
if (Main.econ.getBalance(offlinePlayer) <= 1000.0) {
|
if (Main.econ.getBalance(offlinePlayer) <= 1000.0) {
|
||||||
if (admin) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You must have at least $1000 to put up to start a raid.");
|
if (admin) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You must have at least $1000 to put up to start a raid.");
|
||||||
raidOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "You must have at least $1000 to put up to start a raid.");
|
raidOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "You must have at least $1000 to put up to start a raid.");
|
||||||
@@ -294,7 +301,7 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
* @param p
|
* @param p
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
private static void stopRaid(Player p, String[] args) {
|
private static void stopRaid(CommandSender p, String[] args) {
|
||||||
//admin check
|
//admin check
|
||||||
if (!p.hasPermission("AlathraWar.admin")) {
|
if (!p.hasPermission("AlathraWar.admin")) {
|
||||||
fail(p, args, "permission");
|
fail(p, args, "permission");
|
||||||
@@ -319,12 +326,16 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void joinRaid(Player p, String[] args, boolean admin) {
|
protected static void joinRaid(CommandSender p, String[] args, boolean admin) {
|
||||||
//Grab raid!
|
//Grab raid!
|
||||||
Raid raid = RaidData.getRaidOrNull(args[1] + "-" + args[2]);
|
Raid raid = RaidData.getRaidOrNull(args[1] + "-" + args[2]);
|
||||||
if (raid != null) {
|
if (raid != null) {
|
||||||
if (raid.getWar().getName().equalsIgnoreCase(args[1])) {
|
if (raid.getWar().getName().equalsIgnoreCase(args[1])) {
|
||||||
Player joiner = p;
|
Player joiner = null;
|
||||||
|
if(p instanceof Player) {
|
||||||
|
joiner = (Player) p;
|
||||||
|
}
|
||||||
|
|
||||||
if (admin) {
|
if (admin) {
|
||||||
joiner = Bukkit.getPlayer(args[3]);
|
joiner = Bukkit.getPlayer(args[3]);
|
||||||
|
|
||||||
@@ -351,6 +362,11 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(joiner == null) {
|
||||||
|
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Player not found! Is something broken?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!raid.getWar().getSide1Players().contains(joiner.getName()) && !raid.getWar().getSide2Players().contains(joiner.getName())) {
|
if (!raid.getWar().getSide1Players().contains(joiner.getName()) && !raid.getWar().getSide2Players().contains(joiner.getName())) {
|
||||||
joiner.sendMessage(String.valueOf(Helper.Chatlabel()) + "You are not in this war! Type /war join [war] [side]");
|
joiner.sendMessage(String.valueOf(Helper.Chatlabel()) + "You are not in this war! Type /war join [war] [side]");
|
||||||
}
|
}
|
||||||
@@ -425,9 +441,9 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void leaveRaid(Player player, String[] args, boolean admin) {
|
protected static void leaveRaid(CommandSender player, String[] args, boolean admin) {
|
||||||
//Get raid!
|
//Get raid!
|
||||||
Player p = player;
|
Player p = null;
|
||||||
if (admin) {
|
if (admin) {
|
||||||
p = Bukkit.getPlayer(args[3]);
|
p = Bukkit.getPlayer(args[3]);
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
@@ -435,6 +451,9 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(p == null) {
|
||||||
|
p = (Player) player;
|
||||||
|
}
|
||||||
|
|
||||||
Raid raid = RaidData.getRaidOrNull(args[1] + "-" + args[2]);
|
Raid raid = RaidData.getRaidOrNull(args[1] + "-" + args[2]);
|
||||||
if (raid != null) {
|
if (raid != null) {
|
||||||
@@ -477,7 +496,7 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
* @param p
|
* @param p
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
private static void abandonRaid(Player p, String[] args) {
|
private static void abandonRaid(CommandSender p, String[] args) {
|
||||||
//Get raid
|
//Get raid
|
||||||
Raid raid = RaidData.getRaidOrNull(args[1] + "-" + args[2]);
|
Raid raid = RaidData.getRaidOrNull(args[1] + "-" + args[2]);
|
||||||
if (raid != null) {
|
if (raid != null) {
|
||||||
@@ -506,7 +525,7 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "This raid does not exist!");
|
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "This raid does not exist!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void listRaids(Player p, String[] args) {
|
private static void listRaids(CommandSender p, String[] args) {
|
||||||
if (RaidData.getRaids().isEmpty()) {
|
if (RaidData.getRaids().isEmpty()) {
|
||||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "There are currently no Raids in progress");
|
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "There are currently no Raids in progress");
|
||||||
return;
|
return;
|
||||||
@@ -528,7 +547,7 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void raidHelp(Player p, String[] args) {
|
private static void raidHelp(CommandSender p, String[] args) {
|
||||||
if (p.hasPermission("!AlathraWar.admin")) {
|
if (p.hasPermission("!AlathraWar.admin")) {
|
||||||
p.sendMessage(Helper.Chatlabel() + "/raid stop [name]");
|
p.sendMessage(Helper.Chatlabel() + "/raid stop [name]");
|
||||||
}
|
}
|
||||||
@@ -539,7 +558,7 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
p.sendMessage(Helper.Chatlabel() + "/raid list");
|
p.sendMessage(Helper.Chatlabel() + "/raid list");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void fail(Player p, String[] args, String type) {
|
private static void fail(CommandSender p, String[] args, String type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "permissions" -> p.sendMessage(String.valueOf(Helper.Chatlabel()) + "&cYou do not have permission to do this");
|
case "permissions" -> p.sendMessage(String.valueOf(Helper.Chatlabel()) + "&cYou do not have permission to do this");
|
||||||
case "syntax" -> p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Invalid Syntax. /raid help");
|
case "syntax" -> p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Invalid Syntax. /raid help");
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class WarCommands implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void warCreate(Player p, String[] args) {
|
protected static void warCreate(CommandSender p, String[] args) {
|
||||||
if (!p.hasPermission("AlathraWar.admin")) {
|
if (!p.hasPermission("AlathraWar.admin")) {
|
||||||
p.sendMessage("You do not have permission to run this command.");
|
p.sendMessage("You do not have permission to run this command.");
|
||||||
return;
|
return;
|
||||||
@@ -122,7 +122,7 @@ public class WarCommands implements CommandExecutor {
|
|||||||
* @param args
|
* @param args
|
||||||
* @param admin - admin behavior
|
* @param admin - admin behavior
|
||||||
*/
|
*/
|
||||||
protected static void warJoin(Player p, String[] args, boolean admin) {
|
protected static void warJoin(CommandSender p, String[] args, boolean admin) {
|
||||||
// Sufficient args check
|
// Sufficient args check
|
||||||
if (args.length < 3) {
|
if (args.length < 3) {
|
||||||
p.sendMessage(Helper.Chatlabel()
|
p.sendMessage(Helper.Chatlabel()
|
||||||
@@ -138,8 +138,21 @@ public class WarCommands implements CommandExecutor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Player player = null;
|
||||||
|
if (admin){
|
||||||
|
player = Bukkit.getPlayer(args[3]);
|
||||||
|
if(player == null) {
|
||||||
|
p.sendMessage(Helper.Chatlabel() + "Player " + args[3] + " not found!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(player == null) {
|
||||||
|
player = (Player) p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Towny Resident Object, if admin then dont use command runner, use declared player
|
// Towny Resident Object, if admin then dont use command runner, use declared player
|
||||||
Resident res = TownyAPI.getInstance().getResident(admin ? Bukkit.getPlayer(args[3]) : p);
|
Resident res = TownyAPI.getInstance().getResident(player);
|
||||||
|
|
||||||
// Town check
|
// Town check
|
||||||
Town town = res.getTownOrNull();
|
Town town = res.getTownOrNull();
|
||||||
|
|||||||
Reference in new issue
Block a user