mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 21:51:19 -04:00
Fix rank item in economy vanishing after server restart. (Thanks electronus1)
This commit is contained in:
parent
d69a050941
commit
fc9d5f26c9
@ -49,7 +49,7 @@ namespace MCGalaxy.Commands {
|
||||
{
|
||||
if (message.CaselessEq(alias)) {
|
||||
if (!item.Enabled) {
|
||||
Player.Message(p, "%cThe " + item.Name + " item is not currently buyable."); return;
|
||||
Player.Message(p, "%cThe " + item.ShopName + " item is not currently buyable."); return;
|
||||
}
|
||||
item.OnStoreCommand(p);
|
||||
return;
|
||||
|
@ -70,7 +70,6 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
|
||||
void SetPassword(Player p, string message) {
|
||||
Server.s.Log("_" + message + "_");
|
||||
if (p.adminpen && File.Exists("extra/passwords/" + p.name + ".dat")) {
|
||||
Player.Message(p, "&cYou already have a password set. %SYou &ccannot change %Sit unless &cyou verify it with &a/pass [Password]. " +
|
||||
"%SIf you have &cforgotten %Syour password, contact &c" + Server.server_owner + " %Sand they can &creset it!");
|
||||
|
@ -167,7 +167,7 @@ namespace MCGalaxy {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < Items.Length; i++) {
|
||||
if (!Items[i].Enabled) continue;
|
||||
builder.Append(Items[i].Name);
|
||||
builder.Append(Items[i].ShopName);
|
||||
if (i < Items.Length - 1)
|
||||
builder.Append(separator);
|
||||
}
|
||||
|
@ -27,6 +27,9 @@ namespace MCGalaxy.Eco {
|
||||
/// <summary> Simple name for this item. </summary>
|
||||
public abstract string Name { get; }
|
||||
|
||||
/// <summary> Simple name displayed in /shop, defaults to item name. </summary>
|
||||
public virtual string ShopName { get { return Name; } }
|
||||
|
||||
/// <summary> Other common names for this item. </summary>
|
||||
public string[] Aliases;
|
||||
|
||||
|
@ -28,7 +28,9 @@ namespace MCGalaxy.Eco {
|
||||
Aliases = new [] { "rank", "ranks", "rankup" };
|
||||
}
|
||||
|
||||
public override string Name { get { return "Rankup"; } }
|
||||
public override string Name { get { return "Rank"; } }
|
||||
|
||||
public override string ShopName { get { return "Rankup"; } }
|
||||
|
||||
public string MaxRank = Group.findPerm(LevelPermission.AdvBuilder).name;
|
||||
|
||||
@ -120,17 +122,17 @@ namespace MCGalaxy.Eco {
|
||||
}
|
||||
|
||||
protected internal override void OnStoreOverview(Player p) {
|
||||
Group maxrank = Group.Find(MaxRank);
|
||||
if (p.group.Permission >= maxrank.Permission) {
|
||||
Group maxrank = Group.Find(MaxRank);
|
||||
if (p == null || p.group.Permission >= maxrank.Permission) {
|
||||
Player.Message(p, "Rankup - &calready at max rank."); return;
|
||||
}
|
||||
Rank rnk = NextRank(p);
|
||||
Rank rnk = NextRank(p);
|
||||
Player.Message(p, "Rankup to " + rnk.group.color + rnk.group.name + " %S- costs &f" + rnk.price + " &3" + Server.moneys);
|
||||
}
|
||||
|
||||
protected internal override void OnStoreCommand(Player p) {
|
||||
Group maxrank = Group.Find(MaxRank);
|
||||
Player.Message(p, "Syntax: %T/buy rankup");
|
||||
Player.Message(p, "Syntax: %T/buy rankup");
|
||||
Player.Message(p, "%fThe max buyable rank is: " + maxrank.ColoredName);
|
||||
Player.Message(p, "%cYou can only buy ranks one at a time, in sequential order.");
|
||||
|
||||
@ -149,19 +151,10 @@ namespace MCGalaxy.Eco {
|
||||
}
|
||||
|
||||
public Rank NextRank(Player p) {
|
||||
Group foundGroup = p.group;
|
||||
Group nextGroup = null; bool nextOne = false;
|
||||
for (int i = 0; i < Group.GroupList.Count; i++) {
|
||||
Group grp = Group.GroupList[i];
|
||||
if (nextOne) {
|
||||
if (grp.Permission >= LevelPermission.Nobody) break;
|
||||
nextGroup = grp;
|
||||
break;
|
||||
}
|
||||
if (grp == foundGroup)
|
||||
nextOne = true;
|
||||
}
|
||||
return FindRank(nextGroup.name);
|
||||
int index = Group.GroupList.IndexOf(p.group);
|
||||
if (index < Group.GroupList.Count - 1)
|
||||
return FindRank(Group.GroupList[index + 1].name);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void UpdatePrices() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user