less reliant on core ranks existing

This commit is contained in:
UnknownShadow200 2017-01-06 07:49:57 +11:00
parent 21c0ffb722
commit abe20df16a
10 changed files with 60 additions and 22 deletions

View File

@ -88,9 +88,7 @@ namespace MCGalaxy.Commands
internal static string FormatBlockName(string block, int i) {
Block.Blocks perms = Block.BlockList[Block.Byte(block)];
Group grp = Group.findPerm(perms.lowestRank);
string col = grp == null ? "&f" : grp.color;
return col + block;
return Group.GetColor(perms.lowestRank) + block;
}
static void OutputBlockData(Player p, string block) {

View File

@ -182,8 +182,7 @@ namespace MCGalaxy.Commands {
internal static string GetColor(Command cmd) {
LevelPermission perm = GrpCommands.MinPerm(cmd);
Group grp = Group.findPerm(perm);
return grp == null ? "&f" : grp.color;
return Group.GetColor(perm);
}
public override void Help(Player p) {

View File

@ -54,13 +54,11 @@ namespace MCGalaxy.Commands {
bool loadOnGoto;
RetrieveProps(map, out visitP, out buildP, out loadOnGoto);
LevelPermission perm = visitP;
if (perm < buildP) perm = buildP;
Group grp = Group.findPerm(perm);
LevelPermission maxPerm = visitP;
if (maxPerm < buildP) maxPerm = buildP;
string color = grp == null ? "&f" : grp.color;
string visit = loadOnGoto && (p == null || p.Rank >= visitP) ? "" : " &c[no]";
return color + map + visit;
return Group.GetColor(maxPerm) + map + visit;
}
static bool IsLoaded(Level[] loaded, string level) {

View File

@ -56,7 +56,7 @@ namespace MCGalaxy.Commands {
}
public override void Help(Player p) {
string name = Group.findPerm(LevelPermission.Operator).ColoredName;
string name = Group.GetColoredName(LevelPermission.Operator);
Player.Message(p, "%T/ascend");
Player.Message(p, "%HTeleports you to the first free space above you.");
Player.Message(p, "%H Does not work on maps which have -hax in their motd. " +

View File

@ -56,7 +56,7 @@ namespace MCGalaxy.Commands {
}
public override void Help(Player p) {
string name = Group.findPerm(LevelPermission.Operator).ColoredName;
string name = Group.GetColoredName(LevelPermission.Operator);
Player.Message(p, "%T/descend");
Player.Message(p, "%HTeleports you to the first free space below you.");
Player.Message(p, "%H Does not work on maps which have -hax in their motd. " +

View File

@ -93,7 +93,7 @@ namespace MCGalaxy.Commands {
}
public override void Help(Player p) {
string name = Group.findPerm(LevelPermission.Operator).ColoredName;
string name = Group.GetColoredName(LevelPermission.Operator);
Player.Message(p, "%T/fly");
Player.Message(p, "%HThe old method of flight before custom clients.");
Player.Message(p, "%HMay not work at all depending on your connection.");

View File

@ -0,0 +1,41 @@
/*
Copyright 2015 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.Data;
using MCGalaxy.SQL;
namespace MCGalaxy.DB {
/// <summary> Optimised in-memory BlockDB cache. </summary>
public sealed class BlockDBCache {
public BlockDBCacheNode Head, Tail;
int nextSize = 10000;
}
// TODO: track start time so we can use int16 instead of int32 time delta
public sealed class BlockDBCacheNode {
public BlockDBCacheNode Prev, Next;
public int Count;
public BlockDBEntry[] Entries;
}
}

View File

@ -147,8 +147,7 @@ namespace MCGalaxy.Eco {
if (p == null || p.Rank >= PurchaseRank) {
Player.Message(p, "&6{0} %S- &a{1} %S{2}", Name, Price, Server.moneys);
} else {
Group grp = Group.findPerm(PurchaseRank);
string grpName = grp == null ? ((int)PurchaseRank).ToString() : grp.ColoredName;
string grpName = Group.GetColoredName(PurchaseRank);
Player.Message(p, "&6{0} %S({3}%S+) - &a{1} %S{2}", Name, Price, Server.moneys, grpName);
}
}

View File

@ -34,12 +34,9 @@ namespace MCGalaxy {
public string ColoredName {
get {
LevelPermission perm = permissionvisit;
if (perm < permissionbuild) perm = permissionbuild;
Group grp = Group.findPerm(perm);
string col = grp == null ? "&f" : grp.color;
return col + name;
LevelPermission maxPerm = permissionvisit;
if (maxPerm < permissionbuild) maxPerm = permissionbuild;
return Group.GetColoredName(maxPerm) + name;
}
}

View File

@ -247,7 +247,13 @@ namespace MCGalaxy {
public static string GetColoredName(LevelPermission perm) {
Group grp = findPerm(perm);
if (grp != null) return grp.ColoredName;
return "&f" + ((int)perm);
return Colors.white + ((int)perm);
}
public static string GetColor(LevelPermission perm) {
Group grp = findPerm(perm);
if (grp != null) return grp.color;
return Colors.white;
}
}
}