mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Separate up /zone command a bit.
This commit is contained in:
parent
f3b0915e33
commit
7e098ad8f8
@ -25,72 +25,37 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
public override string type { get { return CommandTypes.Moderation; } }
|
||||
public override bool museumUsable { get { return false; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
||||
public override CommandPerm[] ExtraPerms {
|
||||
get { return new[] {
|
||||
new CommandPerm(LevelPermission.Operator, "+ can delete zones"),
|
||||
new CommandPerm(LevelPermission.Operator, "+ can delete all zones"),
|
||||
new CommandPerm(LevelPermission.Operator, "+ can create zones"),
|
||||
}; }
|
||||
}
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
string[] args = message.SplitSpaces();
|
||||
if (message.Length == 0) {
|
||||
Player.Message(p, "Place a block where you would like to check for zones.");
|
||||
p.MakeSelection(1, null, CheckZone);
|
||||
} else if (args[0].CaselessEq("add")) {
|
||||
if (message.Length == 0) { Help(p); return; }
|
||||
|
||||
if (args[0].CaselessEq("add")) {
|
||||
if (args.Length == 1) { Help(p); return; }
|
||||
if (!CheckAdd(p, args, "Zone add")) return;
|
||||
|
||||
Player.Message(p, "Place or break two blocks to determine the edges.");
|
||||
Player.Message(p, "Zone for: &b" + args[1] + ".");
|
||||
p.MakeSelection(2, args[1], AddZone);
|
||||
} else if (args[0].CaselessEq("del")) {
|
||||
if (!CheckExtraPerm(p, 1)) return;
|
||||
|
||||
Player.Message(p, "Place a block where you would like to delete a zone.");
|
||||
p.MakeSelection(1, null, DeleteZone);
|
||||
} else if (args[0].CaselessEq("list")) {
|
||||
string modifier = args.Length > 1 ? args[1] : "";
|
||||
MultiPageOutput.Output(p, p.level.Zones, FormatZone, "Zone list", "zones", modifier, true);
|
||||
} else {
|
||||
Help(p);
|
||||
if (!CheckAdd(p, args, "Zone add")) return; // TODO: broken
|
||||
|
||||
Player.Message(p, "Place or break two blocks to determine the edges.");
|
||||
Player.Message(p, "Zone for: &b" + args[0] + ".");
|
||||
p.MakeSelection(2, args[0], AddZone);
|
||||
}
|
||||
}
|
||||
|
||||
static string FormatZone(Zone zone) {
|
||||
return zone.ColoredName
|
||||
+ " &b- (" + zone.MinX + ", " + zone.MinY + ", " + zone.MinZ
|
||||
+ ") to (" + zone.MaxX + ", " + zone.MaxY + ", " + zone.MaxZ + ")";
|
||||
}
|
||||
|
||||
bool CheckAdd(Player p, string[] args, string cmd) {
|
||||
if (!CheckExtraPerm(p, 3)) return false;
|
||||
if (args.Length == 1) { Help(p); return false; }
|
||||
if (!Formatter.ValidName(p, args[1], "player or rank")) return false;
|
||||
|
||||
string reason = args.Length > 2 ? args[2] : "";
|
||||
args[1] = FindZoneOwner(p, cmd, args[1], ref reason);
|
||||
return args[1] != null;
|
||||
}
|
||||
|
||||
bool CheckZone(Player p, Vec3S32[] marks, object state, ExtBlock block) {
|
||||
Vec3S32 P = marks[0];
|
||||
Level lvl = p.level;
|
||||
bool found = false;
|
||||
|
||||
for (int i = 0; i < lvl.Zones.Count; i++) {
|
||||
Zone z = lvl.Zones[i];
|
||||
if (!z.Contains(P.X, P.Y, P.Z)) continue;
|
||||
found = true;
|
||||
|
||||
AccessResult status = z.Acess.Check(p);
|
||||
bool allowed = status == AccessResult.Allowed || status == AccessResult.Whitelisted;
|
||||
Player.Message(p, " Zone {0} %S- {1}{2}", z.ColoredName, allowed ? "&a" : "&c", status );
|
||||
}
|
||||
|
||||
if (!found) { Player.Message(p, "No zones affect this block."); }
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeleteZone(Player p, Vec3S32[] marks, object state, ExtBlock block) {
|
||||
Level lvl = p.level;
|
||||
@ -101,7 +66,7 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
Zone zn = lvl.Zones[i];
|
||||
if (P.X < zn.MinX || P.X > zn.MaxX || P.Y < zn.MinY || P.Y > zn.MaxY || P.Z < zn.MinZ || P.Z > zn.MaxZ) continue;
|
||||
|
||||
if (!zn.Acess.CheckDetailed(p)) {
|
||||
if (!zn.Acess.CheckDetailed(p)) {
|
||||
Player.Message(p, "Hence, you cannot delete this zone.");
|
||||
continue;
|
||||
}
|
||||
@ -141,9 +106,63 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/Zone add [name] %H- Creates a zone only [name] can build in");
|
||||
Player.Message(p, "%T/Zone add [rank] %H- Creates a zone only [rank]+ can build in");
|
||||
Player.Message(p, "%T/Zone map [name/rank] %H- /zone add across the entire map");
|
||||
Player.Message(p, "%T/Zone del %H- Deletes the zone clicked");
|
||||
Player.Message(p, "%T/Zone list %H- Lists zones in the map");
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CmdZoneTest : Command {
|
||||
public override string name { get { return "ZoneTest"; } }
|
||||
public override string shortcut { get { return "ZTest"; } }
|
||||
public override string type { get { return CommandTypes.Moderation; } }
|
||||
public override bool museumUsable { get { return false; } }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
Player.Message(p, "Place or delete a block where you would like to check for zones.");
|
||||
p.MakeSelection(1, null, TestZone);
|
||||
}
|
||||
|
||||
bool TestZone(Player p, Vec3S32[] marks, object state, ExtBlock block) {
|
||||
Vec3S32 P = marks[0];
|
||||
Level lvl = p.level;
|
||||
bool found = false;
|
||||
|
||||
for (int i = 0; i < lvl.Zones.Count; i++) {
|
||||
Zone z = lvl.Zones[i];
|
||||
if (!z.Contains(P.X, P.Y, P.Z)) continue;
|
||||
found = true;
|
||||
|
||||
AccessResult status = z.Acess.Check(p);
|
||||
bool allowed = status == AccessResult.Allowed || status == AccessResult.Whitelisted;
|
||||
Player.Message(p, " Zone {0} %S- {1}{2}", z.ColoredName, allowed ? "&a" : "&c", status );
|
||||
}
|
||||
|
||||
if (!found) { Player.Message(p, "No zones affect this block."); }
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/ZoneTest %H- Lists all zones affecting a block");
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CmdZoneList : Command {
|
||||
public override string name { get { return "ZoneList"; } }
|
||||
public override string shortcut { get { return "Zones"; } }
|
||||
public override string type { get { return CommandTypes.Moderation; } }
|
||||
public override bool museumUsable { get { return false; } }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
MultiPageOutput.Output(p, p.level.Zones, FormatZone, "ZoneList", "zones", message, true);
|
||||
}
|
||||
|
||||
static string FormatZone(Zone zone) {
|
||||
return zone.ColoredName
|
||||
+ " &b- (" + zone.MinX + ", " + zone.MinY + ", " + zone.MinZ
|
||||
+ ") to (" + zone.MaxX + ", " + zone.MaxY + ", " + zone.MaxZ + ")";
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/ZoneList %H- Lists all zones in current level");
|
||||
}
|
||||
}
|
||||
}
|
@ -329,7 +329,7 @@
|
||||
<Compile Include="Commands\Moderation\CmdWhitelist.cs" />
|
||||
<Compile Include="Commands\Moderation\CmdXban.cs" />
|
||||
<Compile Include="Commands\Moderation\CmdXJail.cs" />
|
||||
<Compile Include="Commands\Moderation\CmdZone.cs" />
|
||||
<Compile Include="Commands\Moderation\ZoneCmds.cs" />
|
||||
<Compile Include="Commands\Moderation\ModActionCmd.cs" />
|
||||
<Compile Include="Commands\other\CmdAscend.cs" />
|
||||
<Compile Include="Commands\other\CmdBack.cs" />
|
||||
@ -381,7 +381,7 @@
|
||||
<Compile Include="Commands\World\CmdSpawn.cs" />
|
||||
<Compile Include="Commands\World\CmdUnflood.cs" />
|
||||
<Compile Include="Commands\World\CmdUnload.cs" />
|
||||
<Compile Include="Commands\World\PermissionCmd.cs" />
|
||||
<Compile Include="Commands\World\PermissionCmds.cs" />
|
||||
<Compile Include="Config\ConfigAttribute.cs" />
|
||||
<Compile Include="Config\NumberAttributes.cs" />
|
||||
<Compile Include="Config\OtherAttributes.cs" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user