mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
When /copy ing, it also states origin of copy.
This commit is contained in:
parent
8e4156974c
commit
eb97813b01
@ -99,13 +99,13 @@ namespace MCGalaxy.Commands.Building {
|
||||
copy.Offset.Z = copy.OriginZ - m[i].Z;
|
||||
Player.Message(p, "Set offset of where to paste from.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (i != 1) return;
|
||||
|
||||
CopyArgs cArgs = (CopyArgs)state;
|
||||
ushort minX = (ushort)Math.Min(m[0].X, m[1].X), maxX = (ushort)Math.Max(m[0].X, m[1].X);
|
||||
ushort minY = (ushort)Math.Min(m[0].Y, m[1].Y), maxY = (ushort)Math.Max(m[0].Y, m[1].Y);
|
||||
ushort minZ = (ushort)Math.Min(m[0].Z, m[1].Z), maxZ = (ushort)Math.Max(m[0].Z, m[1].Z);
|
||||
Vec3S32 min = Vec3S32.Min(m[0], m[1]), max = Vec3S32.Max(m[0], m[1]);
|
||||
ushort minX = (ushort)min.X, minY = (ushort)min.Y, minZ = (ushort)min.Z;
|
||||
ushort maxX = (ushort)max.X, maxY = (ushort)max.X, maxZ = (ushort)max.Z;
|
||||
|
||||
CopyState cState = new CopyState(minX, minY, minZ, maxX - minX + 1,
|
||||
maxY - minY + 1, maxZ - minZ + 1);
|
||||
@ -140,24 +140,23 @@ namespace MCGalaxy.Commands.Building {
|
||||
DrawOp op = new CuboidDrawOp();
|
||||
op.Flags = BlockDBFlags.Cut;
|
||||
Brush brush = new SolidBrush(ExtBlock.Air);
|
||||
|
||||
Vec3S32[] marks = new Vec3S32[] {
|
||||
new Vec3S32(minX, minY, minZ),
|
||||
new Vec3S32(maxX, maxY, maxZ)
|
||||
};
|
||||
DrawOpPerformer.Do(op, brush, p, marks, false);
|
||||
DrawOpPerformer.Do(op, brush, p, new Vec3S32[] { min, max }, false);
|
||||
}
|
||||
|
||||
string format = "Copied &a{0} %Sblocks." +
|
||||
(cState.PasteAir ? "" : " To also copy air blocks, use %T/Copy Air");
|
||||
Player.Message(p, format, cState.UsedBlocks);
|
||||
Player.Message(p, "Copied &a{0} %Sblocks, origin at ({1}, {2}, {3}) corner", cState.UsedBlocks,
|
||||
cState.OriginX == cState.X ? "Min" : "Max",
|
||||
cState.OriginY == cState.Y ? "Min" : "Max",
|
||||
cState.OriginY == cState.Y ? "Min" : "Max");
|
||||
if (!cState.PasteAir) {
|
||||
Player.Message(p, "To also copy air blocks, use %T/Copy Air");
|
||||
}
|
||||
if (cArgs.offsetIndex != -1) {
|
||||
Player.Message(p, "Place a block to determine where to paste from");
|
||||
}
|
||||
}
|
||||
|
||||
bool DoCopy(Player p, Vec3S32[] m, object state, ExtBlock block) { return false; }
|
||||
class CopyArgs { public int type, offsetIndex; }
|
||||
class CopyArgs { public int type, offsetIndex; }
|
||||
|
||||
void SaveCopy(Player p, string file) {
|
||||
if (!Directory.Exists("extra/savecopy"))
|
||||
|
@ -23,14 +23,11 @@ namespace MCGalaxy.Commands.Building {
|
||||
public override string shortcut { get { return "dnm"; } }
|
||||
public override string type { get { return CommandTypes.Building; } }
|
||||
public override bool SuperUseable { get { return false; } }
|
||||
public override CommandAlias[] Aliases {
|
||||
get { return new[] { new CommandAlias("dm") }; }
|
||||
}
|
||||
public override CommandAlias[] Aliases { get { return new[] { new CommandAlias("dm") }; } }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
p.ClickToMark = !p.ClickToMark;
|
||||
Player.Message(p, "Click blocks to %T/mark%S: {0}",
|
||||
p.ClickToMark ? "&2ON" : "&4OFF");
|
||||
Player.Message(p, "Click blocks to %T/mark%S: {0}", p.ClickToMark ? "&2ON" : "&4OFF");
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -591,7 +591,6 @@
|
||||
<Compile Include="Network\Utils\NetUtils.cs" />
|
||||
<Compile Include="Network\Utils\PingList.cs" />
|
||||
<Compile Include="Player\Group\Group.cs" />
|
||||
<Compile Include="Player\Group\Group.List.cs" />
|
||||
<Compile Include="Player\Group\GroupProperties.cs" />
|
||||
<Compile Include="Player\List\PlayerExtList.cs" />
|
||||
<Compile Include="Player\List\PlayerList.cs" />
|
||||
|
@ -1,139 +0,0 @@
|
||||
/*
|
||||
Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy)
|
||||
|
||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||
not use this file except in compliance with the Licenses. You may
|
||||
obtain a copy of the Licenses at
|
||||
|
||||
http://www.opensource.org/licenses/ecl2.php
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the Licenses are distributed on an "AS IS"
|
||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
or implied. See the Licenses for the specific language governing
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using MCGalaxy.Events.GroupEvents;
|
||||
|
||||
namespace MCGalaxy {
|
||||
/// <summary> This is the group object, where ranks and their data are stored </summary>
|
||||
public sealed partial class Group {
|
||||
|
||||
public static Group BannedRank { get { return Find(LevelPermission.Banned); } }
|
||||
public static Group GuestRank { get { return Find(LevelPermission.Guest); } }
|
||||
public static Group NobodyRank { get { return Find(LevelPermission.Nobody); } }
|
||||
public static Group standard;
|
||||
static bool reloading;
|
||||
|
||||
public static void Register(Group grp) {
|
||||
GroupList.Add(grp);
|
||||
grp.LoadPlayers();
|
||||
|
||||
if (reloading) {
|
||||
grp.SetUsableBlocks();
|
||||
grp.SetUsableCommands();
|
||||
}
|
||||
OnGroupLoadedEvent.Call(grp);
|
||||
}
|
||||
|
||||
public static List<Group> GroupList = new List<Group>();
|
||||
static readonly object saveLock = new object();
|
||||
|
||||
/// <summary> Load all server groups </summary>
|
||||
public static void InitAll() {
|
||||
GroupList = new List<Group>();
|
||||
if (File.Exists(Paths.RankPropsFile)) {
|
||||
GroupProperties.InitAll();
|
||||
} else {
|
||||
// Add some default ranks
|
||||
Register(new Group(LevelPermission.Builder, 400, 300, "Builder", '2'));
|
||||
Register(new Group(LevelPermission.AdvBuilder, 1200, 900, "AdvBuilder", '3'));
|
||||
Register(new Group(LevelPermission.Operator, 2500, 5400, "Operator", 'c'));
|
||||
Register(new Group(LevelPermission.Admin, 65536, int.MaxValue, "SuperOP", 'e'));
|
||||
}
|
||||
|
||||
if (BannedRank == null)
|
||||
Register(new Group(LevelPermission.Banned, 1, 1, "Banned", '8'));
|
||||
if (GuestRank == null)
|
||||
Register(new Group(LevelPermission.Guest, 1, 120, "Guest", '7'));
|
||||
if (NobodyRank == null)
|
||||
Register(new Group(LevelPermission.Nobody, 65536, -1, "Nobody", '0'));
|
||||
|
||||
GroupList.Sort((a, b) => a.Permission.CompareTo(b.Permission));
|
||||
standard = Find(ServerConfig.DefaultRankName);
|
||||
if (standard == null) standard = GuestRank;
|
||||
|
||||
OnGroupLoadEvent.Call();
|
||||
reloading = true;
|
||||
SaveList(GroupList);
|
||||
}
|
||||
|
||||
/// <summary> Save givenList group </summary>
|
||||
/// <param name="givenList">The list of groups to save</param>
|
||||
public static void SaveList(List<Group> givenList) {
|
||||
lock (saveLock)
|
||||
GroupProperties.SaveGroups(givenList);
|
||||
|
||||
OnGroupSaveEvent.Call();
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Find the group which has the given name. </summary>
|
||||
public static Group Find(string name) {
|
||||
MapName(ref name);
|
||||
|
||||
const StringComparison comp = StringComparison.OrdinalIgnoreCase;
|
||||
foreach (Group grp in GroupList) {
|
||||
if (grp.Name.Equals(name, comp)) return grp;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
internal static void MapName(ref string name) {
|
||||
if (name.CaselessEq("op")) name = "operator";
|
||||
}
|
||||
|
||||
/// <summary> Finds the group which has the given permission level. </summary>
|
||||
public static Group Find(LevelPermission perm) {
|
||||
return GroupList.Find(grp => grp.Permission == perm);
|
||||
}
|
||||
|
||||
/// <summary> Find the group which has the given permission level. </summary>
|
||||
public static Group Find(int perm) {
|
||||
return GroupList.Find(grp => (int)grp.Permission == perm);
|
||||
}
|
||||
|
||||
/// <summary> Find the group that the given player is a member of. </summary>
|
||||
/// <param name="playerName"> The player name. </param>
|
||||
public static Group GroupIn(string playerName) {
|
||||
foreach (Group grp in GroupList) {
|
||||
if (grp.Players.Contains(playerName)) return grp;
|
||||
}
|
||||
return standard;
|
||||
}
|
||||
|
||||
|
||||
public static string GetColoredName(LevelPermission perm) {
|
||||
Group grp = Find(perm);
|
||||
if (grp != null) return grp.ColoredName;
|
||||
return Colors.white + ((int)perm);
|
||||
}
|
||||
|
||||
public static string GetColoredName(string rankName) {
|
||||
Group grp = Find(rankName);
|
||||
if (grp != null) return grp.ColoredName;
|
||||
return Colors.white + rankName;
|
||||
}
|
||||
|
||||
public static string GetColor(LevelPermission perm) {
|
||||
Group grp = Find(perm);
|
||||
if (grp != null) return grp.Color;
|
||||
return Colors.white;
|
||||
}
|
||||
}
|
||||
}
|
@ -20,63 +20,41 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using MCGalaxy.Blocks;
|
||||
using MCGalaxy.Commands;
|
||||
using MCGalaxy.Events;
|
||||
using MCGalaxy.Events.GroupEvents;
|
||||
|
||||
namespace MCGalaxy {
|
||||
/// <summary> This is the group object, where ranks and their data are stored </summary>
|
||||
public sealed partial class Group {
|
||||
|
||||
public static Group BannedRank { get { return Find(LevelPermission.Banned); } }
|
||||
public static Group GuestRank { get { return Find(LevelPermission.Guest); } }
|
||||
public static Group NobodyRank { get { return Find(LevelPermission.Nobody); } }
|
||||
public static Group standard;
|
||||
public static List<Group> GroupList = new List<Group>();
|
||||
static bool reloading;
|
||||
|
||||
const int mapGenLimitAdmin = 225 * 1000 * 1000;
|
||||
const int mapGenLimit = 30 * 1000 * 1000;
|
||||
public static bool cancelrank = false;
|
||||
|
||||
/// <summary> Name of this rank. </summary>
|
||||
public string Name;
|
||||
|
||||
/// <summary> Default color code applied to members of this rank. </summary>
|
||||
public string Color;
|
||||
|
||||
/// <summary> Name of this rank, prefixed by its color code. </summary>
|
||||
public string ColoredName { get { return Color + Name; } }
|
||||
|
||||
/// <summary> Permission level of this rank. </summary>
|
||||
public LevelPermission Permission = LevelPermission.Null;
|
||||
|
||||
/// <summary> Maximum number of blocks members of this group can use in draw commands. </summary>
|
||||
public int DrawLimit;
|
||||
|
||||
/// <summary> Maximum number of seconds members of this group can /undo up to. </summary>
|
||||
public int MaxUndo;
|
||||
|
||||
/// <summary> Maximum volume of a map that members of this group can generate. </summary>
|
||||
public int GenVolume = mapGenLimit;
|
||||
|
||||
/// <summary> Whether members of this rank are auto kicked for being AFK. </summary>
|
||||
public bool AfkKicked = true;
|
||||
|
||||
/// <summary> Number of minutes members of this rank can be AFK for, before they are auto kicked. </summary>
|
||||
public int AfkKickMinutes = 45;
|
||||
|
||||
/// <summary> Optional MOTD shown to members of this group, instead of server's default MOTD. </summary>
|
||||
/// <remarks> If a level has a custom MOTD, it overrides this. </remarks>
|
||||
public string MOTD = "";
|
||||
|
||||
/// <summary> Maxmimum number of personal/realm worlds allowed for members of this rank. </summary>
|
||||
public int GenVolume = mapGenLimit;
|
||||
public byte OverseerMaps = 3;
|
||||
|
||||
/// <summary> Optional prefix shown in chat before titles and player name. </summary>
|
||||
public string Prefix = "";
|
||||
|
||||
/// <summary> List of players who are members of this group. </summary>
|
||||
public PlayerList Players;
|
||||
|
||||
/// <summary> List of commands members of this group can use. </summary>
|
||||
public List<Command> Commands;
|
||||
|
||||
/// <summary> List of blocks members of this group can use. </summary>
|
||||
public bool[] Blocks = new bool[256];
|
||||
|
||||
public bool AfkKicked = true;
|
||||
public int AfkKickMinutes = 45;
|
||||
public string Prefix = "";
|
||||
public int CopySlots = 1;
|
||||
internal string filename;
|
||||
|
||||
public PlayerList Players;
|
||||
public List<Command> Commands;
|
||||
public bool[] Blocks = new bool[256];
|
||||
public Group() { }
|
||||
|
||||
private Group(LevelPermission perm, int maxB, int maxUn, string name, char colCode) {
|
||||
@ -90,27 +68,21 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Sets all the commands that members of this group can use. </summary>
|
||||
public void SetUsableCommands() {
|
||||
Commands = CommandPerms.AllCommandsUsableBy(Permission);
|
||||
}
|
||||
|
||||
/// <summary> Sets all the blocks that this group can use. </summary>
|
||||
public void SetUsableBlocks() {
|
||||
for (int i = 0; i < Blocks.Length; i++)
|
||||
Blocks[i] = BlockPerms.UsableBy(Permission, (byte)i);
|
||||
}
|
||||
|
||||
/// <summary> Returns true if members of this group can use the given command. </summary>
|
||||
public bool CanExecute(Command cmd) { return Commands.Contains(cmd); }
|
||||
public bool CanExecute(string cmdName) {
|
||||
Command cmd = Command.all.Find(cmdName);
|
||||
return cmd != null && Commands.Contains(cmd);
|
||||
}
|
||||
|
||||
/// <summary> Returns true if members of this group can use the given command. </summary>
|
||||
public bool CanExecute(Command cmd) { return Commands.Contains(cmd); }
|
||||
|
||||
|
||||
|
||||
/// <summary> Creates a copy of this group, except for members list and usable commands and blocks. </summary>
|
||||
public Group CopyConfig() {
|
||||
Group copy = new Group();
|
||||
@ -118,8 +90,50 @@ namespace MCGalaxy {
|
||||
copy.DrawLimit = DrawLimit; copy.MaxUndo = MaxUndo; copy.MOTD = MOTD;
|
||||
copy.GenVolume = GenVolume; copy.OverseerMaps = OverseerMaps;
|
||||
copy.AfkKicked = AfkKicked; copy.AfkKickMinutes = AfkKickMinutes;
|
||||
copy.Prefix = Prefix; copy.filename = filename;
|
||||
copy.Prefix = Prefix; copy.CopySlots = CopySlots; copy.filename = filename;
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
public static Group Find(string name) {
|
||||
MapName(ref name);
|
||||
foreach (Group grp in GroupList) {
|
||||
if (grp.Name.CaselessEq(name)) return grp;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
internal static void MapName(ref string name) {
|
||||
if (name.CaselessEq("op")) name = "operator";
|
||||
}
|
||||
|
||||
public static Group Find(LevelPermission perm) {
|
||||
return GroupList.Find(grp => grp.Permission == perm);
|
||||
}
|
||||
|
||||
public static Group GroupIn(string playerName) {
|
||||
foreach (Group grp in GroupList) {
|
||||
if (grp.Players.Contains(playerName)) return grp;
|
||||
}
|
||||
return standard;
|
||||
}
|
||||
|
||||
public static string GetColoredName(LevelPermission perm) {
|
||||
Group grp = Find(perm);
|
||||
if (grp != null) return grp.ColoredName;
|
||||
return Colors.white + ((int)perm);
|
||||
}
|
||||
|
||||
public static string GetColoredName(string rankName) {
|
||||
Group grp = Find(rankName);
|
||||
if (grp != null) return grp.ColoredName;
|
||||
return Colors.white + rankName;
|
||||
}
|
||||
|
||||
public static string GetColor(LevelPermission perm) {
|
||||
Group grp = Find(perm);
|
||||
if (grp != null) return grp.Color;
|
||||
return Colors.white;
|
||||
}
|
||||
|
||||
public static LevelPermission ParsePermOrName(string value, LevelPermission defPerm) {
|
||||
@ -134,6 +148,54 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
|
||||
public static void Register(Group grp) {
|
||||
GroupList.Add(grp);
|
||||
grp.LoadPlayers();
|
||||
|
||||
if (reloading) {
|
||||
grp.SetUsableBlocks();
|
||||
grp.SetUsableCommands();
|
||||
}
|
||||
OnGroupLoadedEvent.Call(grp);
|
||||
}
|
||||
|
||||
public static void InitAll() {
|
||||
GroupList = new List<Group>();
|
||||
if (File.Exists(Paths.RankPropsFile)) {
|
||||
GroupProperties.InitAll();
|
||||
} else {
|
||||
// Add some default ranks
|
||||
Register(new Group(LevelPermission.Builder, 400, 300, "Builder", '2'));
|
||||
Register(new Group(LevelPermission.AdvBuilder, 1200, 900, "AdvBuilder", '3'));
|
||||
Register(new Group(LevelPermission.Operator, 2500, 5400, "Operator", 'c'));
|
||||
Register(new Group(LevelPermission.Admin, 65536, int.MaxValue, "SuperOP", 'e'));
|
||||
}
|
||||
|
||||
if (BannedRank == null)
|
||||
Register(new Group(LevelPermission.Banned, 1, 1, "Banned", '8'));
|
||||
if (GuestRank == null)
|
||||
Register(new Group(LevelPermission.Guest, 1, 120, "Guest", '7'));
|
||||
if (NobodyRank == null)
|
||||
Register(new Group(LevelPermission.Nobody, 65536, -1, "Nobody", '0'));
|
||||
|
||||
GroupList.Sort((a, b) => a.Permission.CompareTo(b.Permission));
|
||||
standard = Find(ServerConfig.DefaultRankName);
|
||||
if (standard == null) standard = GuestRank;
|
||||
|
||||
OnGroupLoadEvent.Call();
|
||||
reloading = true;
|
||||
SaveList(GroupList);
|
||||
}
|
||||
|
||||
static readonly object saveLock = new object();
|
||||
public static void SaveList(List<Group> givenList) {
|
||||
lock (saveLock) {
|
||||
GroupProperties.SaveGroups(givenList);
|
||||
}
|
||||
OnGroupSaveEvent.Call();
|
||||
}
|
||||
|
||||
|
||||
void LoadPlayers() {
|
||||
string desired = (int)Permission + "_rank";
|
||||
// Try to use the auto filename format
|
||||
@ -170,6 +232,5 @@ namespace MCGalaxy {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ namespace MCGalaxy {
|
||||
} if (perm > 120 || perm < -50) {
|
||||
Logger.Log(LogType.Warning, "Permission must be between -50 and 120 for ranks");
|
||||
temp = null;
|
||||
} else if (Group.Find(perm) == null) {
|
||||
} else if (Group.Find((LevelPermission)perm) == null) {
|
||||
temp.Permission = (LevelPermission)perm;
|
||||
} else {
|
||||
Logger.Log(LogType.Warning, "Cannot have 2 ranks set at permission level " + value);
|
||||
@ -102,10 +102,7 @@ namespace MCGalaxy {
|
||||
temp.MOTD = value;
|
||||
break;
|
||||
case "osmaps":
|
||||
byte osmaps;
|
||||
if (!byte.TryParse(value, out osmaps))
|
||||
osmaps = 3;
|
||||
temp.OverseerMaps = osmaps;
|
||||
temp.OverseerMaps = byte.Parse(value);
|
||||
break;
|
||||
case "prefix":
|
||||
if (!String.IsNullOrEmpty(value))
|
||||
@ -116,6 +113,9 @@ namespace MCGalaxy {
|
||||
temp.Prefix = temp.Prefix.Substring(0, 3);
|
||||
}
|
||||
break;
|
||||
case "copyslots":
|
||||
temp.CopySlots = byte.Parse(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,6 +181,7 @@ namespace MCGalaxy {
|
||||
w.WriteLine("GenVolume = " + grp.GenVolume);
|
||||
w.WriteLine("AfkKicked = " + grp.AfkKicked);
|
||||
w.WriteLine("AfkKickMinutes = " + grp.AfkKickMinutes);
|
||||
w.WriteLine("CopySlots = " + grp.CopySlots);
|
||||
w.WriteLine();
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ namespace MCGalaxy {
|
||||
|
||||
/// <summary> Find partial matches of 'name' against the list of ranks. </summary>
|
||||
public static Group FindRanks(Player p, string name) {
|
||||
Group.MapName(ref name);
|
||||
Group.MapName(ref name);
|
||||
int matches = 0;
|
||||
return Find<Group>(p, name, out matches, Group.GroupList,
|
||||
null, g => Colors.Strip(g.Name), "ranks");
|
||||
|
Loading…
x
Reference in New Issue
Block a user