mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Merge branch 'master' of github.com:Hetal728/MCGalaxy
This commit is contained in:
commit
3789d2e419
@ -104,8 +104,7 @@ namespace MCGalaxy.Commands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HandleMapCommand(Player p, string message, string cmd, string value) {
|
void HandleMapCommand(Player p, string message, string cmd, string value) {
|
||||||
bool mapOnly = cmd == "PHYSICS" || cmd == "MOTD" || cmd == "GUNS" || cmd == "CHAT" || cmd == "RESTORE" ||
|
bool mapOnly = !(cmd == "ADD" || cmd == "DELETE" || cmd == "SAVE");
|
||||||
cmd == "PERVISIT" || cmd == "TEXTURE" || cmd == "BUILDABLE" || cmd == "DELETEABLE";
|
|
||||||
if (mapOnly && !OwnsMap(p, p.level)) {
|
if (mapOnly && !OwnsMap(p, p.level)) {
|
||||||
Player.Message(p, "You may only perform that action on your own map."); return;
|
Player.Message(p, "You may only perform that action on your own map."); return;
|
||||||
}
|
}
|
||||||
@ -339,8 +338,15 @@ namespace MCGalaxy.Commands {
|
|||||||
return p.name.ToLower();
|
return p.name.ToLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char[] splitChars = new [] { ',' };
|
||||||
static bool OwnsMap(Player p, Level lvl) {
|
static bool OwnsMap(Player p, Level lvl) {
|
||||||
return lvl.RealmOwner.CaselessEq(p.name) || p.level.name.CaselessStarts(p.name);
|
if (lvl.name.CaselessStarts(p.name)) return true;
|
||||||
|
string[] owners = lvl.RealmOwner.Replace(" ", "").Split(splitChars);
|
||||||
|
|
||||||
|
foreach (string owner in owners) {
|
||||||
|
if (owner.CaselessEq(p.name)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
|
@ -45,19 +45,20 @@ namespace MCGalaxy.Commands {
|
|||||||
if (!take) {
|
if (!take) {
|
||||||
if (Awards.GiveAward(plName, award)) {
|
if (Awards.GiveAward(plName, award)) {
|
||||||
Chat.MessageAll("{0} %Swas awarded: &b{1}",
|
Chat.MessageAll("{0} %Swas awarded: &b{1}",
|
||||||
PlayerInfo.GetColoredName(p, plName), award);
|
PlayerInfo.GetColoredName(p, plName), award);
|
||||||
|
Awards.SavePlayers();
|
||||||
} else {
|
} else {
|
||||||
Player.Message(p, "The player already has that award."); return;
|
Player.Message(p, "The player already has that award."); return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Awards.TakeAward(plName, award)) {
|
if (Awards.TakeAward(plName, award)) {
|
||||||
Chat.MessageAll("{0} %Shad their &b{1} %Saward removed",
|
Chat.MessageAll("{0} %Shad their &b{1} %Saward removed",
|
||||||
PlayerInfo.GetColoredName(p, plName), award);
|
PlayerInfo.GetColoredName(p, plName), award);
|
||||||
|
Awards.SavePlayers();
|
||||||
} else {
|
} else {
|
||||||
Player.Message(p, "The player didn't have the award you tried to take"); return;
|
Player.Message(p, "The player didn't have the award you tried to take"); return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Awards.Save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
|
@ -41,15 +41,16 @@ namespace MCGalaxy.Commands {
|
|||||||
Player.Message(p, "This award already exists."); return;
|
Player.Message(p, "This award already exists."); return;
|
||||||
} else {
|
} else {
|
||||||
Chat.MessageAll("Award added: &6{0} : {1}", args[0], args[1]);
|
Chat.MessageAll("Award added: &6{0} : {1}", args[0], args[1]);
|
||||||
|
Awards.SaveAwards();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!Awards.Remove(args[1])) {
|
if (!Awards.Remove(args[1])) {
|
||||||
Player.Message(p, "This award does not exist."); return;
|
Player.Message(p, "This award does not exist."); return;
|
||||||
} else {
|
} else {
|
||||||
Chat.MessageAll("Award removed: &6{0}", args[1]);
|
Chat.MessageAll("Award removed: &6{0}", args[1]);
|
||||||
|
Awards.SaveAwards();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Awards.Save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
|
@ -29,40 +29,42 @@ namespace MCGalaxy.Commands {
|
|||||||
public override CommandEnable Enabled { get { return CommandEnable.Economy; } }
|
public override CommandEnable Enabled { get { return CommandEnable.Economy; } }
|
||||||
|
|
||||||
public override void Use(Player p, string message) {
|
public override void Use(Player p, string message) {
|
||||||
Economy.EcoStats ecos;
|
|
||||||
if (CheckSuper(p, message, "player name")) return;
|
if (CheckSuper(p, message, "player name")) return;
|
||||||
|
if (!ValidName(p, message, "player")) return;
|
||||||
int matches = 1;
|
int matches = 1;
|
||||||
Player who = message == "" ? p : PlayerInfo.FindMatches(p, message, out matches);
|
Player who = message == "" ? p : PlayerInfo.FindMatches(p, message, out matches);
|
||||||
if (matches > 1) return;
|
if (matches > 1) return;
|
||||||
if (matches == 0) {
|
|
||||||
string dbName = PlayerInfo.FindOfflineNameMatches(p, message);
|
|
||||||
if (dbName == null) return;
|
|
||||||
|
|
||||||
ecos = Economy.RetrieveEcoStats(dbName);
|
|
||||||
Player.Message(p, "%3===Economy stats for: %f" + ecos.playerName + "%7(offline)%3===");
|
|
||||||
} else {
|
|
||||||
ecos = Economy.RetrieveEcoStats(who.name);
|
|
||||||
Player.Message(p, "%3===Economy stats for: " + who.color + who.name + "%3===");
|
|
||||||
}
|
|
||||||
|
|
||||||
Player.Message(p, "Current balance: %f" + ecos.money + " %3" + Server.moneys);
|
string target = null;
|
||||||
Player.Message(p, "Total spent: %f" + ecos.totalSpent + " %3" + Server.moneys);
|
int money = 0;
|
||||||
if (!(String.IsNullOrEmpty(ecos.purchase) || ecos.purchase == "%cNone"))
|
if (matches == 0) {
|
||||||
Player.Message(p, "Last purchase: " + ecos.purchase);
|
target = Economy.FindMatches(p, message, out money);
|
||||||
if (!(String.IsNullOrEmpty(ecos.payment) || ecos.payment == "%cNone"))
|
if (target == null) return;
|
||||||
Player.Message(p, "Last payment: " + ecos.payment);
|
} else {
|
||||||
if (!(String.IsNullOrEmpty(ecos.salary) || ecos.salary == "%cNone"))
|
target = who.name; money = who.money;
|
||||||
Player.Message(p, "Last receipt: " + ecos.salary);
|
}
|
||||||
if (!(String.IsNullOrEmpty(ecos.fine) || ecos.fine == "%cNone"))
|
|
||||||
Player.Message(p, "Last fine: " + ecos.fine);
|
string targetName = PlayerInfo.GetColoredName(p, target);
|
||||||
|
Player.Message(p, "Economy stats for {0}%S:", targetName);
|
||||||
|
Player.Message(p, " Current balance: &f{0} &3{1}", money, Server.moneys);
|
||||||
|
|
||||||
|
Economy.EcoStats ecos = Economy.RetrieveStats(target);
|
||||||
|
Player.Message(p, " Total spent: &f" + ecos.TotalSpent + " &3" + Server.moneys);
|
||||||
|
if (!(String.IsNullOrEmpty(ecos.Purchase) || ecos.Purchase == "%cNone"))
|
||||||
|
Player.Message(p, " Last purchase: " + ecos.Purchase);
|
||||||
|
if (!(String.IsNullOrEmpty(ecos.Payment) || ecos.Payment == "%cNone"))
|
||||||
|
Player.Message(p, " Last payment: " + ecos.Payment);
|
||||||
|
if (!(String.IsNullOrEmpty(ecos.Salary) || ecos.Salary == "%cNone"))
|
||||||
|
Player.Message(p, " Last receipt: " + ecos.Salary);
|
||||||
|
if (!(String.IsNullOrEmpty(ecos.Fine) || ecos.Fine == "%cNone"))
|
||||||
|
Player.Message(p, " Last fine: " + ecos.Fine);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
Player.Message(p, "%T/balance <player>");
|
Player.Message(p, "%T/balance [player]");
|
||||||
Player.Message(p, "%HShows how much %3" + Server.moneys + " %H<player> has, " +
|
Player.Message(p, "%HShows how much %3" + Server.moneys + " %H<player> has, " +
|
||||||
"plus their most recent transactions.");
|
"plus their most recent transactions.");
|
||||||
Player.Message(p, "%HIf <player> is not given, shows your own balance.");
|
Player.Message(p, "%HIf [player] is not given, shows your own balance.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,36 +15,24 @@
|
|||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
namespace MCGalaxy.Commands {
|
namespace MCGalaxy.Commands {
|
||||||
|
public sealed class CmdFakePay : MoneyCmd {
|
||||||
public sealed class CmdFakePay : Command {
|
|
||||||
|
|
||||||
public override string name { get { return "fakepay"; } }
|
public override string name { get { return "fakepay"; } }
|
||||||
public override string shortcut { get { return "fpay"; } }
|
public override string shortcut { get { return "fpay"; } }
|
||||||
public override string type { get { return CommandTypes.Economy; } }
|
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
||||||
public override bool museumUsable { get { return true; } }
|
|
||||||
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
|
||||||
public override CommandEnable Enabled { get { return CommandEnable.Economy; } }
|
|
||||||
|
|
||||||
public override void Use(Player p, string message) {
|
public override void Use(Player p, string message) {
|
||||||
if (message == "") { Help(p); return; }
|
MoneyCmdData data;
|
||||||
|
if (!ParseArgs(p, message, false, "fakepay", out data)) return;
|
||||||
string[] args = message.Split(' ');
|
Player who = PlayerInfo.FindMatches(p, data.Name);
|
||||||
Player who = PlayerInfo.FindMatches(p, args[0]);
|
if (who == null) return;
|
||||||
if (who == null) return;
|
if (data.Amount >= 16777215) { Player.Message(p, "You can only fakepay up to 16777215."); return; }
|
||||||
|
|
||||||
int amount = 0;
|
|
||||||
if (args.Length == 1 || !int.TryParse(args[1], out amount)) {
|
|
||||||
Player.Message(p, "You must specify an integer amount to fakepay."); return;
|
|
||||||
}
|
|
||||||
if (amount < 0) { Player.Message(p, "You can't fakepay a negative amount."); return; }
|
|
||||||
if (amount >= 16777215) { Player.Message(p, "You can only fakepay up to 16777215."); return; }
|
|
||||||
|
|
||||||
Chat.MessageAll("{0} %Swas given {1} {2}", who.ColoredName, amount, Server.moneys);
|
Chat.MessageAll("{0} %Swas given {1} {2}", who.ColoredName, data.Amount, Server.moneys);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
Player.Message(p, "%T/fakepay <name> <amount>");
|
Player.Message(p, "%T/fakepay [name] [amount]");
|
||||||
Player.Message(p, "%HSends a fake give change message.");
|
Player.Message(p, "%HSends a fake give change message.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,58 +17,45 @@
|
|||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
namespace MCGalaxy.Commands
|
namespace MCGalaxy.Commands {
|
||||||
{
|
public sealed class CmdGive : MoneyCmd {
|
||||||
public sealed class CmdGive : Command
|
|
||||||
{
|
|
||||||
public override string name { get { return "give"; } }
|
public override string name { get { return "give"; } }
|
||||||
public override string shortcut { get { return "gib"; } }
|
public override string shortcut { get { return "gib"; } }
|
||||||
public override string type { get { return CommandTypes.Economy; } }
|
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
|
||||||
public override bool museumUsable { get { return true; } }
|
|
||||||
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
|
|
||||||
public override CommandEnable Enabled { get { return CommandEnable.Economy; } }
|
|
||||||
public CmdGive() { }
|
public CmdGive() { }
|
||||||
|
|
||||||
public override void Use(Player p, string message) {
|
public override void Use(Player p, string message) {
|
||||||
string[] args = message.Split(' ');
|
MoneyCmdData data;
|
||||||
if (args.Length != 2) { Help(p); return; }
|
if (!ParseArgs(p, message, false, "give", out data)) return;
|
||||||
string giver = null, giverRaw = null;
|
|
||||||
if (p == null) { giverRaw = "(console)"; giver = "(console)"; }
|
|
||||||
else { giverRaw = p.color + p.name; giver = p.ColoredName; }
|
|
||||||
|
|
||||||
int amount;
|
|
||||||
if (!int.TryParse(args[1], out amount)) {
|
|
||||||
Player.Message(p, "Amount must be an integer."); return;
|
|
||||||
}
|
|
||||||
if (amount < 0) { Player.Message(p, "Cannot give negative %3" + Server.moneys); return; }
|
|
||||||
|
|
||||||
int matches = 1;
|
int matches = 1;
|
||||||
Player who = PlayerInfo.FindMatches(p, args[0], out matches);
|
Player who = PlayerInfo.FindMatches(p, data.Name, out matches);
|
||||||
if (matches > 1) return;
|
if (matches > 1) return;
|
||||||
if (p != null && p == who) { Player.Message(p, "You cannot give yourself %3" + Server.moneys); return; }
|
if (p != null && p == who) { Player.Message(p, "You cannot give yourself %3" + Server.moneys); return; }
|
||||||
Economy.EcoStats ecos;
|
|
||||||
|
|
||||||
|
string target = null;
|
||||||
|
int money = 0;
|
||||||
if (who == null) {
|
if (who == null) {
|
||||||
string dbName = PlayerInfo.FindOfflineNameMatches(p, args[0]);
|
target = Economy.FindMatches(p, data.Name, out money);
|
||||||
if (dbName == null) return;
|
if (target == null) return;
|
||||||
|
|
||||||
ecos = Economy.RetrieveEcoStats(dbName);
|
if (ReachedMax(p, money, data.Amount)) return;
|
||||||
if (ReachedMax(p, ecos.money, amount)) return;
|
money += data.Amount;
|
||||||
Chat.MessageAll("{0} %Sgave &f{1}%S(offline) &f{2} &3{3}",
|
Economy.UpdateMoney(target, money);
|
||||||
giver, ecos.playerName, amount, Server.moneys);
|
|
||||||
} else {
|
} else {
|
||||||
if (ReachedMax(p, who.money, amount)) return;
|
target = who.name; money = who.money;
|
||||||
ecos.money = who.money;
|
if (ReachedMax(p, money, data.Amount)) return;
|
||||||
who.SetMoney(who.money + amount);
|
who.SetMoney(who.money + data.Amount);
|
||||||
ecos = Economy.RetrieveEcoStats(who.name);
|
|
||||||
Chat.MessageAll("{0} %Sgave {1} &f{2} &3{3}",
|
|
||||||
giver, who.ColoredName, amount, Server.moneys);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string targetName = PlayerInfo.GetColoredName(p, target);
|
||||||
|
Chat.MessageAll("{0} %Sgave {1} &f{2} &3{3}",
|
||||||
|
data.Source, targetName, data.Amount, Server.moneys);
|
||||||
|
|
||||||
ecos.money += amount;
|
Economy.EcoStats stats = Economy.RetrieveStats(target);
|
||||||
ecos.salary = "%f" + amount + "%3 " + Server.moneys + " by " +
|
stats.Salary = "%f" + data.Amount + "%3 " + Server.moneys + " by "
|
||||||
giverRaw + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
+ data.SourceRaw + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
||||||
Economy.UpdateEcoStats(ecos);
|
Economy.UpdateStats(stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ReachedMax(Player p, int current, int amount) {
|
static bool ReachedMax(Player p, int current, int amount) {
|
||||||
|
@ -17,62 +17,52 @@
|
|||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
namespace MCGalaxy.Commands
|
|
||||||
{
|
namespace MCGalaxy.Commands {
|
||||||
public sealed class CmdPay : Command
|
public sealed class CmdPay : MoneyCmd {
|
||||||
{
|
|
||||||
public override string name { get { return "pay"; } }
|
public override string name { get { return "pay"; } }
|
||||||
public override string shortcut { get { return ""; } }
|
public override string shortcut { get { return ""; } }
|
||||||
public override string type { get { return CommandTypes.Economy; } }
|
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
|
||||||
public override bool museumUsable { get { return true; } }
|
|
||||||
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
|
|
||||||
public override CommandEnable Enabled { get { return CommandEnable.Economy; } }
|
|
||||||
public CmdPay() { }
|
public CmdPay() { }
|
||||||
|
|
||||||
public override void Use(Player p, string message) {
|
public override void Use(Player p, string message) {
|
||||||
string[] args = message.Split(' ');
|
MoneyCmdData data;
|
||||||
if (args.Length != 2) { Help(p); return; }
|
if (!ParseArgs(p, message, false, "pay", out data)) return;
|
||||||
int amount;
|
|
||||||
if (!int.TryParse(args[1], out amount)) { Player.Message(p, "Amount must be an integer."); return; }
|
|
||||||
if (amount < 0) { Player.Message(p, "Cannot pay negative %3" + Server.moneys); return; }
|
|
||||||
|
|
||||||
int matches = 1;
|
int matches = 1;
|
||||||
Player who = PlayerInfo.FindMatches(p, args[0], out matches);
|
Player who = PlayerInfo.FindMatches(p, data.Name, out matches);
|
||||||
if (matches > 1) return;
|
if (matches > 1) return;
|
||||||
if (p != null && p == who) { Player.Message(p, "You cannot pay yourself %3" + Server.moneys); return; }
|
if (p != null && p == who) { Player.Message(p, "You cannot pay yourself %3" + Server.moneys); return; }
|
||||||
string target = null;
|
string target = null;
|
||||||
Economy.EcoStats payer, receiver;
|
int money;
|
||||||
|
|
||||||
if (who == null) {
|
if (who == null) {
|
||||||
string dbName = PlayerInfo.FindOfflineNameMatches(p, args[0]);
|
target = Economy.FindMatches(p, data.Name, out money);
|
||||||
if (dbName == null) return;
|
if (target == null) return;
|
||||||
|
|
||||||
payer = Economy.RetrieveEcoStats(p.name);
|
if (!IsLegalPayment(p, p.money, money, data.Amount)) return;
|
||||||
receiver = Economy.RetrieveEcoStats(dbName);
|
money += data.Amount;
|
||||||
if (!IsLegalPayment(p, payer.money, receiver.money, amount)) return;
|
Economy.UpdateMoney(target, money);
|
||||||
|
|
||||||
target = receiver.playerName;
|
|
||||||
Chat.MessageAll("{0} %Spaid &f{1}%S(offline) &f{2} &3{3}",
|
|
||||||
p.ColoredName, receiver.playerName, amount, Server.moneys);
|
|
||||||
} else {
|
} else {
|
||||||
payer = Economy.RetrieveEcoStats(p.name);
|
target = who.name; money = who.money;
|
||||||
receiver = Economy.RetrieveEcoStats(who.name);
|
if (!IsLegalPayment(p, p.money, money, data.Amount)) return;
|
||||||
if (!IsLegalPayment(p, payer.money, receiver.money, amount)) return;
|
who.SetMoney(who.money + data.Amount);
|
||||||
|
|
||||||
receiver.money = who.money;
|
|
||||||
who.SetMoney(who.money + amount);
|
|
||||||
target = who.color + who.name;
|
|
||||||
Chat.MessageAll("{0} %Spaid {1} &f{2} &3{3}",
|
|
||||||
p.ColoredName, who.ColoredName, amount, Server.moneys);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.SetMoney(p.money - data.Amount);
|
||||||
|
string targetName = PlayerInfo.GetColoredName(p, target);
|
||||||
|
Chat.MessageAll("{0} %Spaid {1} &f{2} &3{3}",
|
||||||
|
data.Source, targetName, data.Amount, Server.moneys);
|
||||||
|
|
||||||
payer.payment = "%f" + amount + " %3" + Server.moneys + " to " + target + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
Economy.EcoStats stats = Economy.RetrieveStats(p.name);
|
||||||
receiver.salary = "%f" + amount + " %3" + Server.moneys + " by " + p.color + p.name + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
stats.Payment = "%f" + data.Amount + " %3" + Server.moneys + " to "
|
||||||
receiver.money += amount;
|
+ target + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
||||||
p.SetMoney(p.money - amount);
|
Economy.UpdateStats(stats);
|
||||||
payer.money = p.money;
|
|
||||||
Economy.UpdateEcoStats(payer);
|
stats = Economy.RetrieveStats(target);
|
||||||
Economy.UpdateEcoStats(receiver);
|
stats.Salary = "%f" + data.Amount + " %3" + Server.moneys + " by "
|
||||||
|
+ p.color + p.name + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
||||||
|
Economy.UpdateStats(stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsLegalPayment(Player p, int payer, int receiver, int amount) {
|
bool IsLegalPayment(Player p, int payer, int receiver, int amount) {
|
||||||
@ -83,7 +73,7 @@ namespace MCGalaxy.Commands
|
|||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
Player.Message(p, "%T/pay [player] [amount] ");
|
Player.Message(p, "%T/pay [player] [amount] ");
|
||||||
Player.Message(p, "%HPays <amount> %3" + Server.moneys + " %Hto [player]");
|
Player.Message(p, "%HPays [amount] &3" + Server.moneys + " %Hto [player]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,70 +19,58 @@ using System;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
|
||||||
namespace MCGalaxy.Commands {
|
namespace MCGalaxy.Commands {
|
||||||
public sealed class CmdTake : Command {
|
public sealed class CmdTake : MoneyCmd {
|
||||||
public override string name { get { return "take"; } }
|
public override string name { get { return "take"; } }
|
||||||
public override string shortcut { get { return ""; } }
|
public override string shortcut { get { return ""; } }
|
||||||
public override string type { get { return CommandTypes.Economy; } }
|
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
|
||||||
public override bool museumUsable { get { return true; } }
|
|
||||||
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
|
|
||||||
public override CommandEnable Enabled { get { return CommandEnable.Economy; } }
|
|
||||||
public CmdTake() { }
|
public CmdTake() { }
|
||||||
|
|
||||||
public override void Use(Player p, string message) {
|
public override void Use(Player p, string message) {
|
||||||
string[] args = message.Split(' ');
|
MoneyCmdData data;
|
||||||
if (args.Length != 2) { Help(p); return; }
|
if (!ParseArgs(p, message, true, "take", out data)) return;
|
||||||
|
|
||||||
string taker = null, takerRaw = null;
|
|
||||||
if (p == null) { takerRaw = "(console)"; taker = "(console)"; }
|
|
||||||
else { takerRaw = p.color + p.name; taker = p.ColoredName; }
|
|
||||||
|
|
||||||
int amount = 0;
|
|
||||||
bool all = args[1].CaselessEq("all");
|
|
||||||
if (!all && !int.TryParse(args[1], out amount)) {
|
|
||||||
Player.Message(p, "Amount must be an integer."); return;
|
|
||||||
}
|
|
||||||
if (amount < 0) { Player.Message(p, "%cYou can't take negative %3" + Server.moneys); return; }
|
|
||||||
|
|
||||||
int matches = 1;
|
int matches = 1;
|
||||||
Player who = PlayerInfo.FindMatches(p, args[0], out matches);
|
Player who = PlayerInfo.FindMatches(p, data.Name, out matches);
|
||||||
if (matches > 1) return;
|
if (matches > 1) return;
|
||||||
if (p != null && p == who) { Player.Message(p, "%cYou can't take %3" + Server.moneys + "%c from yourself"); return; }
|
if (p != null && p == who) { Player.Message(p, "%cYou can't take %3" + Server.moneys + "%c from yourself"); return; }
|
||||||
|
|
||||||
Economy.EcoStats ecos;
|
string target = null;
|
||||||
|
int money = 0;
|
||||||
if (who == null) {
|
if (who == null) {
|
||||||
string dbName = PlayerInfo.FindOfflineNameMatches(p, args[0]);
|
target = Economy.FindMatches(p, data.Name, out money);
|
||||||
if (dbName == null) return;
|
if (target == null) return;
|
||||||
|
Take(ref money, ref data);
|
||||||
ecos = Economy.RetrieveEcoStats(dbName);
|
Economy.UpdateMoney(target, money);
|
||||||
Take(all, ref ecos, ref amount);
|
|
||||||
Chat.MessageAll("{0} %Stook &f{2} &3{3} %Sfrom &f{1}%S(offline)",
|
|
||||||
p.ColoredName, ecos.playerName, amount, Server.moneys);
|
|
||||||
} else {
|
} else {
|
||||||
ecos = Economy.RetrieveEcoStats(who.name);
|
target = who.name; money = who.money;
|
||||||
ecos.money = who.money;
|
Take(ref money, ref data);
|
||||||
Take(all, ref ecos, ref amount);
|
who.SetMoney(money);
|
||||||
who.SetMoney(ecos.money);
|
|
||||||
Chat.MessageAll("{0} %Stook &f{2} &3{3} %Sfrom {1}",
|
|
||||||
p.ColoredName, who.ColoredName, amount, Server.moneys);
|
|
||||||
}
|
}
|
||||||
ecos.fine = "%f" + amount + " %3" + Server.moneys + " by " + takerRaw + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
|
||||||
Economy.UpdateEcoStats(ecos);
|
string targetName = PlayerInfo.GetColoredName(p, target);
|
||||||
|
Chat.MessageAll("{0} %Stook &f{2} &3{3} %Sfrom {1}",
|
||||||
|
data.Source, targetName, data.Amount, Server.moneys);
|
||||||
|
|
||||||
|
Economy.EcoStats stats = Economy.RetrieveStats(target);
|
||||||
|
stats.Fine = "%f" + data.Amount + "%3 " + Server.moneys + " by "
|
||||||
|
+ data.SourceRaw + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
||||||
|
Economy.UpdateStats(stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Take(bool all, ref Economy.EcoStats ecos, ref int amount) {
|
static void Take(ref int money, ref MoneyCmdData data) {
|
||||||
if (all || ecos.money < amount) {
|
if (data.All || money < data.Amount) {
|
||||||
amount = ecos.money;
|
data.Amount = money;
|
||||||
ecos.money = 0;
|
money = 0;
|
||||||
} else {
|
} else {
|
||||||
ecos.money -= amount;
|
money -= data.Amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Help(Player p){
|
public override void Help(Player p){
|
||||||
Player.Message(p, "%T/take [player] <amount>");
|
Player.Message(p, "%T/take [player] [amount[");
|
||||||
Player.Message(p, "%HTakes <amount> of " + Server.moneys + " from [player]");
|
Player.Message(p, "%HTakes [amount] of &3" + Server.moneys + " %Sfrom [player]");
|
||||||
Player.Message(p, "%T/take [player] all");
|
Player.Message(p, "%T/take [player] all");
|
||||||
Player.Message(p, "%HTakes all the " + Server.moneys + " from [player]");
|
Player.Message(p, "%HTakes all the &3" + Server.moneys + " %Sfrom [player]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
58
Commands/Economy/MoneyCmd.cs
Normal file
58
Commands/Economy/MoneyCmd.cs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2011 MCForge
|
||||||
|
|
||||||
|
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.Globalization;
|
||||||
|
|
||||||
|
namespace MCGalaxy.Commands {
|
||||||
|
public abstract class MoneyCmd : Command {
|
||||||
|
public override string type { get { return CommandTypes.Economy; } }
|
||||||
|
public override bool museumUsable { get { return true; } }
|
||||||
|
public override CommandEnable Enabled { get { return CommandEnable.Economy; } }
|
||||||
|
|
||||||
|
protected bool ParseArgs(Player p, string message, bool canAll,
|
||||||
|
string action, out MoneyCmdData data) {
|
||||||
|
data = default(MoneyCmdData);
|
||||||
|
string[] args = message.Split(' ');
|
||||||
|
if (args.Length != 2) { Help(p); return false; }
|
||||||
|
data.Name = args[0];
|
||||||
|
|
||||||
|
if (p == null) {
|
||||||
|
data.SourceRaw = "(console)"; data.Source = "(console)";
|
||||||
|
} else {
|
||||||
|
data.SourceRaw = p.color + p.name; data.Source = p.ColoredName;
|
||||||
|
}
|
||||||
|
|
||||||
|
int amount = 0;
|
||||||
|
data.All = canAll && args[1].CaselessEq("all");
|
||||||
|
if (!data.All && !int.TryParse(args[1], out amount)) {
|
||||||
|
Player.Message(p, "Amount to {0} must be an integer.", action); return false;
|
||||||
|
}
|
||||||
|
if (amount < 0) {
|
||||||
|
Player.Message(p, "You cannot {0} negative &3" + Server.moneys, action); return false;
|
||||||
|
}
|
||||||
|
data.Amount = amount;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected struct MoneyCmdData {
|
||||||
|
public string Source, SourceRaw, Name;
|
||||||
|
public int Amount;
|
||||||
|
public bool All;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -113,10 +113,12 @@ namespace MCGalaxy.Commands
|
|||||||
|
|
||||||
public void Append(Player pl, string name) {
|
public void Append(Player pl, string name) {
|
||||||
builder.Append(' ');
|
builder.Append(' ');
|
||||||
if (pl.voice) builder.Append("&f+%S");
|
if (pl.voice) {
|
||||||
|
builder.Append("&f+").Append(group.color);
|
||||||
|
}
|
||||||
|
|
||||||
builder.Append(name);
|
builder.Append(name);
|
||||||
builder.Append(" (" + pl.level.name + "),");
|
builder.Append(" (").Append(pl.level.name).Append("),");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ namespace MCGalaxy.Commands {
|
|||||||
if (end == 0) {
|
if (end == 0) {
|
||||||
StringBuilder list = ListMaps(p, all, files, 0, files.Length);
|
StringBuilder list = ListMaps(p, all, files, 0, files.Length);
|
||||||
if (list.Length > 0) {
|
if (list.Length > 0) {
|
||||||
Player.Message(p, "Unloaded levels [Accessible]: ");
|
Player.Message(p, "Unloaded levels (&c[no] %Sif not accessible): ");
|
||||||
Player.Message(p, list.Remove(0, 2).ToString());
|
Player.Message(p, list.Remove(0, 2).ToString());
|
||||||
if (files.Length > 50) { Player.Message(p, "For a more structured list, use /unloaded <1/2/3/..>"); }
|
if (files.Length > 50) { Player.Message(p, "For a more structured list, use /unloaded <1/2/3/..>"); }
|
||||||
} else {
|
} else {
|
||||||
@ -59,7 +59,7 @@ namespace MCGalaxy.Commands {
|
|||||||
|
|
||||||
StringBuilder list = ListMaps(p, all, files, start, end);
|
StringBuilder list = ListMaps(p, all, files, start, end);
|
||||||
if (list.Length > 0) {
|
if (list.Length > 0) {
|
||||||
Player.Message(p, "Unloaded levels [Accessible] (" + start + " to " + end + "):");
|
Player.Message(p, "Unloaded levels (&c[no] %Sif not accessible) (" + start + " to " + end + "):");
|
||||||
Player.Message(p, list.Remove(0, 2).ToString());
|
Player.Message(p, list.Remove(0, 2).ToString());
|
||||||
} else {
|
} else {
|
||||||
Player.Message(p, "No maps are unloaded");
|
Player.Message(p, "No maps are unloaded");
|
||||||
@ -78,8 +78,9 @@ namespace MCGalaxy.Commands {
|
|||||||
bool loadOnGoto;
|
bool loadOnGoto;
|
||||||
RetrieveProps(level, out visitP, out buildP, out loadOnGoto);
|
RetrieveProps(level, out visitP, out buildP, out loadOnGoto);
|
||||||
|
|
||||||
string visit = loadOnGoto && (p == null || p.Rank >= visitP) ? "%aYes" : "%cNo";
|
string color = Group.findPerm(buildP).color;
|
||||||
builder.Append(", ").Append(Group.findPerm(buildP).color + level + " &b[" + visit + "&b]");
|
string visit = loadOnGoto && (p == null || p.Rank >= visitP) ? "" : " &c[no]" + color;
|
||||||
|
builder.Append(", ").Append(color + level + visit);
|
||||||
}
|
}
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ namespace MCGalaxy.Commands {
|
|||||||
public sealed class CmdWhoNick : Command {
|
public sealed class CmdWhoNick : Command {
|
||||||
|
|
||||||
public override string name { get { return "whonick"; } }
|
public override string name { get { return "whonick"; } }
|
||||||
public override string shortcut { get { return ""; } }
|
public override string shortcut { get { return "realname"; } }
|
||||||
public override string type { get { return CommandTypes.Information; } }
|
public override string type { get { return CommandTypes.Information; } }
|
||||||
public override bool museumUsable { get { return true; } }
|
public override bool museumUsable { get { return true; } }
|
||||||
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
|
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
|
||||||
@ -38,7 +38,7 @@ namespace MCGalaxy.Commands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
Player.Message(p, "%T/whonick <nickname>");
|
Player.Message(p, "%T/whonick [nickname]");
|
||||||
Player.Message(p, "%HDisplays the player's real username");
|
Player.Message(p, "%HDisplays the player's real username");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,8 +116,7 @@ namespace MCGalaxy.Commands.World {
|
|||||||
CheckGamesJoin(p, oldLevel);
|
CheckGamesJoin(p, oldLevel);
|
||||||
p.prevMsg = "";
|
p.prevMsg = "";
|
||||||
|
|
||||||
bool showJoin = p.level.ShouldSaveChanges() || (oldLevel != null && oldLevel.ShouldSaveChanges());
|
if (!p.hidden && p.level.ShouldShowJoinMessage(oldLevel)) {
|
||||||
if (!p.hidden && showJoin) {
|
|
||||||
Player.SendChatFrom(p, p.color + "*" + p.DisplayName + " %Swent to &b" + lvl.name, false);
|
Player.SendChatFrom(p, p.color + "*" + p.DisplayName + " %Swent to &b" + lvl.name, false);
|
||||||
Player.RaisePlayerAction(p, PlayerAction.JoinWorld, lvl.name);
|
Player.RaisePlayerAction(p, PlayerAction.JoinWorld, lvl.name);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ namespace MCGalaxy.Commands.World {
|
|||||||
case "realmowner":
|
case "realmowner":
|
||||||
lvl.RealmOwner = value;
|
lvl.RealmOwner = value;
|
||||||
if (value == "") Player.Message(p, "Removed realm owner for this level.");
|
if (value == "") Player.Message(p, "Removed realm owner for this level.");
|
||||||
else Player.Message(p, "Set realm owner of this level to {0}.", value);
|
else Player.Message(p, "Set realm owner/owners of this level to {0}.", value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Player.Message(p, "Could not find option entered."); return;
|
Player.Message(p, "Could not find option entered."); return;
|
||||||
|
@ -54,7 +54,6 @@ namespace MCGalaxy {
|
|||||||
PropertiesFile.Read("text/awardsList.txt", AwardsListLineProcessor, ':');
|
PropertiesFile.Read("text/awardsList.txt", AwardsListLineProcessor, ':');
|
||||||
PlayerAwards = new List<PlayerAward>();
|
PlayerAwards = new List<PlayerAward>();
|
||||||
PropertiesFile.Read("text/playerAwards.txt", PlayerAwardsLineProcessor, ':');
|
PropertiesFile.Read("text/playerAwards.txt", PlayerAwardsLineProcessor, ':');
|
||||||
Save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AwardsListLineProcessor(string key, string value) {
|
static void AwardsListLineProcessor(string key, string value) {
|
||||||
@ -76,8 +75,11 @@ namespace MCGalaxy {
|
|||||||
PlayerAwards.Add(pl);
|
PlayerAwards.Add(pl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Save() {
|
static readonly object awardLock = new object();
|
||||||
using (CP437Writer w = new CP437Writer("text/awardsList.txt")) {
|
public static void SaveAwards() {
|
||||||
|
lock (awardLock)
|
||||||
|
using (CP437Writer w = new CP437Writer("text/awardsList.txt"))
|
||||||
|
{
|
||||||
w.WriteLine("# This is a full list of awards. The server will load these and they can be awarded as you please");
|
w.WriteLine("# This is a full list of awards. The server will load these and they can be awarded as you please");
|
||||||
w.WriteLine("# Format is:");
|
w.WriteLine("# Format is:");
|
||||||
w.WriteLine("# AwardName : Description of award goes after the colon");
|
w.WriteLine("# AwardName : Description of award goes after the colon");
|
||||||
@ -85,10 +87,15 @@ namespace MCGalaxy {
|
|||||||
foreach (Award award in AwardsList)
|
foreach (Award award in AwardsList)
|
||||||
w.WriteLine(award.Name + " : " + award.Description);
|
w.WriteLine(award.Name + " : " + award.Description);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
using (StreamWriter w = new StreamWriter("text/playerAwards.txt")) {
|
|
||||||
|
static readonly object playerLock = new object();
|
||||||
|
public static void SavePlayers() {
|
||||||
|
lock (playerLock)
|
||||||
|
using (StreamWriter w = new StreamWriter("text/playerAwards.txt"))
|
||||||
|
{
|
||||||
foreach (PlayerAward pA in PlayerAwards)
|
foreach (PlayerAward pA in PlayerAwards)
|
||||||
w.WriteLine(pA.Name.ToLower() + " : " + pA.Awards.Join(","));
|
w.WriteLine(pA.Name.ToLower() + " : " + pA.Awards.Join(","));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -107,7 +114,7 @@ namespace MCGalaxy {
|
|||||||
pl.Awards.Add(name);
|
pl.Awards.Add(name);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerAward newPl;
|
PlayerAward newPl;
|
||||||
newPl.Name = playerName;
|
newPl.Name = playerName;
|
||||||
newPl.Awards = new List<string>();
|
newPl.Awards = new List<string>();
|
||||||
|
@ -41,35 +41,38 @@ PRIMARY KEY(player)
|
|||||||
);";
|
);";
|
||||||
|
|
||||||
public struct EcoStats {
|
public struct EcoStats {
|
||||||
public string playerName, purchase, payment, salary, fine;
|
public string Player, Purchase, Payment, Salary, Fine;
|
||||||
public int money, totalSpent;
|
public int TotalSpent;
|
||||||
public EcoStats(string name, int mon, int tot, string pur, string pay, string sal, string fin) {
|
|
||||||
playerName = name;
|
public EcoStats(int tot, string player, string pur,
|
||||||
money = mon;
|
string pay, string sal, string fin) {
|
||||||
totalSpent = tot;
|
TotalSpent = tot;
|
||||||
purchase = pur;
|
Player = player;
|
||||||
payment = pay;
|
Purchase = pur;
|
||||||
salary = sal;
|
Payment = pay;
|
||||||
fine = fin;
|
Salary = sal;
|
||||||
|
Fine = fin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LoadDatabase() {
|
public static void LoadDatabase() {
|
||||||
retry:
|
Database.Execute(createTable);
|
||||||
Database.Execute(createTable); //create database
|
|
||||||
DataTable eco = Database.Fill("SELECT * FROM Economy");
|
DataTable eco = Database.Fill("SELECT * FROM Economy");
|
||||||
try {
|
foreach (DataRow row in eco.Rows) {
|
||||||
DataTable players = Database.Fill("SELECT * FROM Players");
|
int money = PlayerData.ParseInt(row["money"].ToString());
|
||||||
if (players.Rows.Count == eco.Rows.Count) { } //move along, nothing to do here
|
if (money == 0) continue;
|
||||||
else if (eco.Rows.Count == 0) { //if first time, copy content from player to economy
|
|
||||||
Database.Execute("INSERT INTO Economy (player, money) SELECT Players.Name, Players.Money FROM Players");
|
EcoStats stats;
|
||||||
} else {
|
stats.Player = row["player"].ToString();
|
||||||
//this will only be needed when the server shuts down while it was copying content (or some other error)
|
stats.Payment = row["payment"].ToString();
|
||||||
Database.Backend.DeleteTable("Economy");
|
stats.Purchase = row["purchase"].ToString();
|
||||||
goto retry;
|
stats.Salary = row["salary"].ToString();
|
||||||
}
|
stats.Fine = row["fine"].ToString();
|
||||||
players.Dispose(); eco.Dispose();
|
stats.TotalSpent = PlayerData.ParseInt(row["total"].ToString());
|
||||||
} catch { }
|
|
||||||
|
UpdateMoney(stats.Player, money);
|
||||||
|
UpdateStats(stats);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Load() {
|
public static void Load() {
|
||||||
@ -109,40 +112,50 @@ PRIMARY KEY(player)
|
|||||||
|
|
||||||
public static void Save() {
|
public static void Save() {
|
||||||
using (StreamWriter w = new StreamWriter("properties/economy.properties", false)) {
|
using (StreamWriter w = new StreamWriter("properties/economy.properties", false)) {
|
||||||
w.WriteLine("enabled:" + Enabled);
|
w.WriteLine("enabled:" + Enabled);
|
||||||
foreach (Item item in Items) {
|
foreach (Item item in Items) {
|
||||||
w.WriteLine();
|
w.WriteLine();
|
||||||
item.Serialise(w);
|
item.Serialise(w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EcoStats RetrieveEcoStats(string playername) {
|
public static void UpdateStats(EcoStats stats) {
|
||||||
EcoStats es = default(EcoStats);
|
|
||||||
es.playerName = playername;
|
|
||||||
using (DataTable eco = Database.Fill("SELECT * FROM Economy WHERE player=@0", playername)) {
|
|
||||||
if (eco.Rows.Count >= 1) {
|
|
||||||
es.money = int.Parse(eco.Rows[0]["money"].ToString());
|
|
||||||
es.totalSpent = int.Parse(eco.Rows[0]["total"].ToString());
|
|
||||||
es.purchase = eco.Rows[0]["purchase"].ToString();
|
|
||||||
es.payment = eco.Rows[0]["payment"].ToString();
|
|
||||||
es.salary = eco.Rows[0]["salary"].ToString();
|
|
||||||
es.fine = eco.Rows[0]["fine"].ToString();
|
|
||||||
} else {
|
|
||||||
es.purchase = "%cNone";
|
|
||||||
es.payment = "%cNone";
|
|
||||||
es.salary = "%cNone";
|
|
||||||
es.fine = "%cNone";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return es;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void UpdateEcoStats(EcoStats es) {
|
|
||||||
string type = Server.useMySQL ? "REPLACE INTO" : "INSERT OR REPLACE INTO";
|
string type = Server.useMySQL ? "REPLACE INTO" : "INSERT OR REPLACE INTO";
|
||||||
Database.Execute(type + " Economy (player, money, total, purchase, payment, salary, fine) " +
|
Database.Execute(type + " Economy (player, money, total, purchase, payment, salary, fine) " +
|
||||||
"VALUES (@0, @1, @2, @3, @4, @5, @6)", es.playerName, es.money, es.totalSpent,
|
"VALUES (@0, @1, @2, @3, @4, @5, @6)", stats.Player, 0, stats.TotalSpent,
|
||||||
es.purchase, es.payment, es.salary, es.fine);
|
stats.Purchase, stats.Payment, stats.Salary, stats.Fine);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EcoStats RetrieveStats(string name) {
|
||||||
|
EcoStats stats = default(EcoStats);
|
||||||
|
stats.Player = name;
|
||||||
|
|
||||||
|
using (DataTable eco = Database.Fill("SELECT * FROM Economy WHERE player=@0", name)) {
|
||||||
|
if (eco.Rows.Count > 0) {
|
||||||
|
stats.TotalSpent = int.Parse(eco.Rows[0]["total"].ToString());
|
||||||
|
stats.Purchase = eco.Rows[0]["purchase"].ToString();
|
||||||
|
stats.Payment = eco.Rows[0]["payment"].ToString();
|
||||||
|
stats.Salary = eco.Rows[0]["salary"].ToString();
|
||||||
|
stats.Fine = eco.Rows[0]["fine"].ToString();
|
||||||
|
} else {
|
||||||
|
stats.Purchase = "%cNone";
|
||||||
|
stats.Payment = "%cNone";
|
||||||
|
stats.Salary = "%cNone";
|
||||||
|
stats.Fine = "%cNone";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return stats;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string FindMatches(Player p, string name, out int money) {
|
||||||
|
DataRow row = PlayerInfo.QueryMulti(p, name, "Name, Money");
|
||||||
|
money = row == null ? 0 : PlayerData.ParseInt(row["Money"].ToString());
|
||||||
|
return row == null ? null : row["Name"].ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void UpdateMoney(string name, int money) {
|
||||||
|
Database.Execute("UPDATE Players SET Money=@0 WHERE Name=@1", money, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Item[] Items = { new ColorItem(), new TitleColorItem(),
|
public static Item[] Items = { new ColorItem(), new TitleColorItem(),
|
||||||
@ -173,15 +186,15 @@ PRIMARY KEY(player)
|
|||||||
public static RankItem Ranks { get { return (RankItem)Items[3]; } }
|
public static RankItem Ranks { get { return (RankItem)Items[3]; } }
|
||||||
public static LevelItem Levels { get { return (LevelItem)Items[4]; } }
|
public static LevelItem Levels { get { return (LevelItem)Items[4]; } }
|
||||||
|
|
||||||
public static void MakePurchase(Player p, int cost, string item) {
|
public static void MakePurchase(Player p, int cost, string item) {
|
||||||
Economy.EcoStats ecos = RetrieveEcoStats(p.name);
|
|
||||||
p.SetMoney(p.money - cost);
|
p.SetMoney(p.money - cost);
|
||||||
ecos.money = p.money;
|
Player.Message(p, "Your balance is now &f{0} &3{1}", p.money, Server.moneys);
|
||||||
ecos.totalSpent += cost;
|
|
||||||
ecos.purchase = item + "%3 - Price: %f" + cost + " %3" + Server.moneys +
|
Economy.EcoStats stats = RetrieveStats(p.name);
|
||||||
" - Date: %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
stats.TotalSpent += cost;
|
||||||
UpdateEcoStats(ecos);
|
stats.Purchase = item + "%3 for %f" + cost + " %3" + Server.moneys +
|
||||||
Player.Message(p, "%aYour balance is now %f" + p.money + " %3" + Server.moneys);
|
" on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
||||||
|
Economy.UpdateStats(stats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -68,7 +68,6 @@ namespace MCGalaxy.Eco {
|
|||||||
if (map == null) return;
|
if (map == null) return;
|
||||||
|
|
||||||
Command.all.Find("queue").Use(p, "level " + map);
|
Command.all.Find("queue").Use(p, "level " + map);
|
||||||
ZombieAwards.Give(p, ZombieAwards.buyQueue, Server.zombie);
|
|
||||||
Economy.MakePurchase(p, Price, "%3QueueLevel: " + map);
|
Economy.MakePurchase(p, Price, "%3QueueLevel: " + map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,12 +74,7 @@ namespace MCGalaxy.Gui {
|
|||||||
[Description("Whether zombie survival should start when the server starts.")]
|
[Description("Whether zombie survival should start when the server starts.")]
|
||||||
[Category("General settings")]
|
[Category("General settings")]
|
||||||
[DisplayName("Start immediately")]
|
[DisplayName("Start immediately")]
|
||||||
public bool StartImmediately { get; set; }
|
public bool StartImmediately { get; set; }
|
||||||
|
|
||||||
[Description("Whether awards should be given for various events/actions in zombie survival. ")]
|
|
||||||
[Category("General settings")]
|
|
||||||
[DisplayName("Use awards")]
|
|
||||||
public bool UseAwards { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
[Description("Max distance players are allowed to move between packets (for speedhack detection). " +
|
[Description("Max distance players are allowed to move between packets (for speedhack detection). " +
|
||||||
@ -179,7 +174,6 @@ namespace MCGalaxy.Gui {
|
|||||||
Respawning = !ZombieGame.noRespawn;
|
Respawning = !ZombieGame.noRespawn;
|
||||||
SetMainLevel = ZombieGame.SetMainLevel;
|
SetMainLevel = ZombieGame.SetMainLevel;
|
||||||
StartImmediately = ZombieGame.StartImmediately;
|
StartImmediately = ZombieGame.StartImmediately;
|
||||||
UseAwards = ZombieGame.UseAwards;
|
|
||||||
|
|
||||||
MaxMoveDistance = ZombieGame.MaxMoveDistance;
|
MaxMoveDistance = ZombieGame.MaxMoveDistance;
|
||||||
HitboxPrecision = ZombieGame.HitboxPrecision;
|
HitboxPrecision = ZombieGame.HitboxPrecision;
|
||||||
@ -217,7 +211,6 @@ namespace MCGalaxy.Gui {
|
|||||||
ZombieGame.noRespawn = !Respawning;
|
ZombieGame.noRespawn = !Respawning;
|
||||||
ZombieGame.SetMainLevel = SetMainLevel;
|
ZombieGame.SetMainLevel = SetMainLevel;
|
||||||
ZombieGame.StartImmediately = StartImmediately;
|
ZombieGame.StartImmediately = StartImmediately;
|
||||||
ZombieGame.UseAwards = UseAwards;
|
|
||||||
|
|
||||||
ZombieGame.MaxMoveDistance = MaxMoveDistance;
|
ZombieGame.MaxMoveDistance = MaxMoveDistance;
|
||||||
ZombieGame.HitboxPrecision = HitboxPrecision;
|
ZombieGame.HitboxPrecision = HitboxPrecision;
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
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;
|
|
||||||
|
|
||||||
namespace MCGalaxy.Games {
|
|
||||||
|
|
||||||
public static class ZombieAwards {
|
|
||||||
|
|
||||||
internal const string buyQueue = "Wishes";
|
|
||||||
internal const string infectedEnd = "Unlucky";
|
|
||||||
internal const string onlyHuman = "Can't touch this";
|
|
||||||
internal const string killLastHuman = "Finisher";
|
|
||||||
internal const string killInvisHuman = "The sixth sense";
|
|
||||||
internal const string killHumanTwice = "Deja Vu";
|
|
||||||
internal const string reviveSurvive = "Second Chance";
|
|
||||||
internal const string survive5Rounds = "Bear Grylls";
|
|
||||||
internal const string luckyNumber7 = "Lucky Number 7";
|
|
||||||
internal const string lowWinChance = "Impossible";
|
|
||||||
internal const string starKiller = "Dream destroyer";
|
|
||||||
internal const string afkKiller = "Assassin";
|
|
||||||
internal const string humanKiller = "Chuck Norris";
|
|
||||||
|
|
||||||
public static void AddDefaults() {
|
|
||||||
Awards.Add(buyQueue, "Buy a queue level");
|
|
||||||
Awards.Add(infectedEnd, "Get infected in last 5 seconds of a round");
|
|
||||||
Awards.Add(onlyHuman, "Be the sole human survivor");
|
|
||||||
Awards.Add(killLastHuman, "Infect the last human left");
|
|
||||||
Awards.Add(killInvisHuman, "Infect a human who is invisible");
|
|
||||||
Awards.Add(killHumanTwice, "Infect a human twice in the same round");
|
|
||||||
Awards.Add(reviveSurvive, "Survive a round after using a revive");
|
|
||||||
Awards.Add(survive5Rounds, "Survive 5 rounds in a row");
|
|
||||||
Awards.Add(luckyNumber7, "Win lottery when exactly 7 players joined it");
|
|
||||||
Awards.Add(lowWinChance, "Survive on a map with a win chance of 10% or les");
|
|
||||||
Awards.Add(starKiller, "Kill a human with a golden star.");
|
|
||||||
Awards.Add(afkKiller, "Infect an auto-afk human");
|
|
||||||
Awards.Add(humanKiller, "Infect 10 humans in a row");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Give(Player p, string award, ZombieGame game) {
|
|
||||||
Server.s.Log("AWARD: " +award + "," + p.name);
|
|
||||||
if (!ZombieGame.UseAwards) return;
|
|
||||||
bool awarded = Awards.GiveAward(p.name, award);
|
|
||||||
if (awarded && game.CurLevel != null)
|
|
||||||
game.CurLevel.ChatLevel(p.ColoredName + " %Searned the achievement &a" + award);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -186,7 +186,6 @@ namespace MCGalaxy.Games {
|
|||||||
&& pKiller.level.name.CaselessEq(CurLevelName)
|
&& pKiller.level.name.CaselessEq(CurLevelName)
|
||||||
&& pAlive.level.name.CaselessEq(CurLevelName))
|
&& pAlive.level.name.CaselessEq(CurLevelName))
|
||||||
{
|
{
|
||||||
CheckKillerAwards(pAlive, pKiller);
|
|
||||||
InfectPlayer(pAlive);
|
InfectPlayer(pAlive);
|
||||||
pAlive.Game.LastInfecter = pKiller.name;
|
pAlive.Game.LastInfecter = pKiller.name;
|
||||||
aliveChanged = true;
|
aliveChanged = true;
|
||||||
@ -199,8 +198,6 @@ namespace MCGalaxy.Games {
|
|||||||
pKiller.SetMoney(pKiller.money + (2 + infectCombo));
|
pKiller.SetMoney(pKiller.money + (2 + infectCombo));
|
||||||
CurLevel.ChatLevel(pKiller.ColoredName + " is on a rampage! " + (infectCombo + 1) + " infections in a row!");
|
CurLevel.ChatLevel(pKiller.ColoredName + " is on a rampage! " + (infectCombo + 1) + " infections in a row!");
|
||||||
}
|
}
|
||||||
if (infectCombo == 10)
|
|
||||||
ZombieAwards.Give(pKiller, ZombieAwards.humanKiller, this);
|
|
||||||
} else {
|
} else {
|
||||||
infectCombo = 0;
|
infectCombo = 0;
|
||||||
}
|
}
|
||||||
@ -209,17 +206,19 @@ namespace MCGalaxy.Games {
|
|||||||
pKiller.Game.CurrentInfected++;
|
pKiller.Game.CurrentInfected++;
|
||||||
pKiller.Game.TotalInfected++;
|
pKiller.Game.TotalInfected++;
|
||||||
pKiller.Game.MaxInfected = Math.Max(pKiller.Game.CurrentInfected, pKiller.Game.MaxInfected);
|
pKiller.Game.MaxInfected = Math.Max(pKiller.Game.CurrentInfected, pKiller.Game.MaxInfected);
|
||||||
|
|
||||||
ShowInfectMessage(random, pAlive, pKiller);
|
ShowInfectMessage(random, pAlive, pKiller);
|
||||||
CheckHumanPledge(pAlive);
|
CheckHumanPledge(pAlive);
|
||||||
CheckBounty(pAlive, pKiller);
|
CheckBounty(pAlive, pKiller);
|
||||||
UpdatePlayerColor(pAlive, InfectCol);
|
UpdatePlayerColor(pAlive, InfectCol);
|
||||||
|
Thread.Sleep(50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (aliveChanged) alive = Alive.Items;
|
if (aliveChanged) alive = Alive.Items;
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckInvisibilityTime();
|
CheckInvisibilityTime();
|
||||||
Thread.Sleep(25);
|
Thread.Sleep(200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,19 +271,6 @@ namespace MCGalaxy.Games {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckKillerAwards(Player pAlive, Player pKiller) {
|
|
||||||
if (pAlive.IsAfk)
|
|
||||||
ZombieAwards.Give(pKiller, ZombieAwards.afkKiller, this);
|
|
||||||
if (pAlive.Game.Invisible)
|
|
||||||
ZombieAwards.Give(pKiller, ZombieAwards.killInvisHuman, this);
|
|
||||||
if (pAlive.Game.CurrentRoundsSurvived >= 3)
|
|
||||||
ZombieAwards.Give(pKiller, ZombieAwards.starKiller, this);
|
|
||||||
if (Alive.Count == 1)
|
|
||||||
ZombieAwards.Give(pKiller, ZombieAwards.killLastHuman, this);
|
|
||||||
if (pAlive.Game.LastInfecter == pKiller.name)
|
|
||||||
ZombieAwards.Give(pKiller, ZombieAwards.killHumanTwice, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShowInfectMessage(Random random, Player pAlive, Player pKiller) {
|
void ShowInfectMessage(Random random, Player pAlive, Player pKiller) {
|
||||||
string text = null;
|
string text = null;
|
||||||
List<string> infectMsgs = pKiller.Game.InfectMessages;
|
List<string> infectMsgs = pKiller.Game.InfectMessages;
|
||||||
@ -330,22 +316,14 @@ namespace MCGalaxy.Games {
|
|||||||
} else {
|
} else {
|
||||||
int winChance = CurLevel.WinChance;
|
int winChance = CurLevel.WinChance;
|
||||||
CurLevel.RoundsHumanWon++;
|
CurLevel.RoundsHumanWon++;
|
||||||
if (alive.Length == 1)
|
|
||||||
ZombieAwards.Give(alive[0], ZombieAwards.onlyHuman, this);
|
|
||||||
foreach (Player pl in alive) {
|
foreach (Player pl in alive) {
|
||||||
if (pl.Game.PledgeSurvive) {
|
if (pl.Game.PledgeSurvive) {
|
||||||
pl.SendMessage("You received &a5 %3" + Server.moneys +
|
pl.SendMessage("You received &a5 %3" + Server.moneys +
|
||||||
"%S for successfully pledging that you would survive.");
|
"%S for successfully pledging that you would survive.");
|
||||||
pl.SetMoney(pl.money + 5);
|
pl.SetMoney(pl.money + 5);
|
||||||
}
|
}
|
||||||
if (winChance <= 10)
|
|
||||||
ZombieAwards.Give(pl, ZombieAwards.lowWinChance, this);
|
|
||||||
if (pl.Game.RevivesUsed > 0)
|
|
||||||
ZombieAwards.Give(pl, ZombieAwards.reviveSurvive, this);
|
|
||||||
|
|
||||||
pl.Game.CurrentRoundsSurvived++;
|
pl.Game.CurrentRoundsSurvived++;
|
||||||
if (pl.Game.CurrentRoundsSurvived == 5)
|
|
||||||
ZombieAwards.Give(pl, ZombieAwards.survive5Rounds, this);
|
|
||||||
pl.Game.TotalRoundsSurvived++;
|
pl.Game.TotalRoundsSurvived++;
|
||||||
pl.Game.MaxRoundsSurvived = Math.Max(pl.Game.CurrentRoundsSurvived, pl.Game.MaxRoundsSurvived);
|
pl.Game.MaxRoundsSurvived = Math.Max(pl.Game.CurrentRoundsSurvived, pl.Game.MaxRoundsSurvived);
|
||||||
ResetPlayer(pl, ref playersString);
|
ResetPlayer(pl, ref playersString);
|
||||||
@ -410,8 +388,6 @@ namespace MCGalaxy.Games {
|
|||||||
}
|
}
|
||||||
Lottery.Clear();
|
Lottery.Clear();
|
||||||
winner.SetMoney(winner.money + 10);
|
winner.SetMoney(winner.money + 10);
|
||||||
if (online.Count == 7)
|
|
||||||
ZombieAwards.Give(winner, ZombieAwards.luckyNumber7, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetReward(Player pl, Player[] alive, Random rand) {
|
int GetReward(Player pl, Player[] alive, Random rand) {
|
||||||
|
@ -182,7 +182,7 @@ namespace MCGalaxy.Games {
|
|||||||
public override void PlayerMoneyChanged(Player p) {
|
public override void PlayerMoneyChanged(Player p) {
|
||||||
if (!Running || !p.level.name.CaselessEq(CurLevelName)) return;
|
if (!Running || !p.level.name.CaselessEq(CurLevelName)) return;
|
||||||
string moneyMsg = "&a" + p.money + " %S" + Server.moneys;
|
string moneyMsg = "&a" + p.money + " %S" + Server.moneys;
|
||||||
string stateMsg = " and you are " + (p.Game.Infected ? "&cdead" : "&aalive");
|
string stateMsg = ", you are " + (p.Game.Infected ? "&cdead" : "&aalive");
|
||||||
p.SendCpeMessage(CpeMessageType.Status3, moneyMsg + stateMsg);
|
p.SendCpeMessage(CpeMessageType.Status3, moneyMsg + stateMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,13 +16,13 @@
|
|||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using MCGalaxy.Commands;
|
using MCGalaxy.Commands;
|
||||||
using MCGalaxy.SQL;
|
using MCGalaxy.SQL;
|
||||||
|
|
||||||
namespace MCGalaxy.Games {
|
namespace MCGalaxy.Games {
|
||||||
|
|
||||||
@ -39,7 +39,6 @@ namespace MCGalaxy.Games {
|
|||||||
RoundsDone = 0;
|
RoundsDone = 0;
|
||||||
if (!SetStartLevel(level)) return;
|
if (!SetStartLevel(level)) return;
|
||||||
|
|
||||||
if (UseAwards) ZombieAwards.AddDefaults();
|
|
||||||
Thread t = new Thread(MainLoop);
|
Thread t = new Thread(MainLoop);
|
||||||
t.Name = "MCG_ZombieGame";
|
t.Name = "MCG_ZombieGame";
|
||||||
t.Start();
|
t.Start();
|
||||||
@ -102,10 +101,6 @@ namespace MCGalaxy.Games {
|
|||||||
p.SetPrefix();
|
p.SetPrefix();
|
||||||
ResetInvisibility(p);
|
ResetInvisibility(p);
|
||||||
|
|
||||||
int delta = (int)(RoundEnd - DateTime.UtcNow).TotalSeconds;
|
|
||||||
if (delta >= 0 && delta <= 5)
|
|
||||||
ZombieAwards.Give(p, ZombieAwards.infectedEnd, this);
|
|
||||||
|
|
||||||
p.Game.Infected = true;
|
p.Game.Infected = true;
|
||||||
p.Game.TimeInfected = DateTime.UtcNow;
|
p.Game.TimeInfected = DateTime.UtcNow;
|
||||||
UpdatePlayerColor(p, Colors.red);
|
UpdatePlayerColor(p, Colors.red);
|
||||||
@ -210,20 +205,20 @@ namespace MCGalaxy.Games {
|
|||||||
|
|
||||||
string GetStatusMessage(string timespan) {
|
string GetStatusMessage(string timespan) {
|
||||||
if (timespan.Length > 0) {
|
if (timespan.Length > 0) {
|
||||||
const string format = "&a{0} %Salive, &c{1} %Sinfected ({2})";
|
const string format = "&a{0} %Salive %S({2}, map: {1})";
|
||||||
return String.Format(format, Alive.Count, Infected.Count, timespan);
|
return String.Format(format, Alive.Count, CurLevelName, timespan);
|
||||||
} else {
|
} else {
|
||||||
const string format = "&a{0} %Salive, &c{1} %Sinfected";
|
const string format = "&a{0} %Salive %S(map: {1})";
|
||||||
return String.Format(format, Alive.Count, Infected.Count);
|
return String.Format(format, Alive.Count, CurLevelName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string GetTimespan(int seconds) {
|
string GetTimespan(int seconds) {
|
||||||
if (seconds < 0) return "";
|
if (seconds < 0) return "";
|
||||||
if (seconds <= 10) return "10 secs left";
|
if (seconds <= 10) return "10s left";
|
||||||
if (seconds <= 30) return "30 secs left";
|
if (seconds <= 30) return "30s left";
|
||||||
if (seconds <= 60) return "1 min left";
|
if (seconds <= 60) return "1m left";
|
||||||
return ((seconds + 59) / 60) + " mins left";
|
return ((seconds + 59) / 60) + "m left";
|
||||||
}
|
}
|
||||||
|
|
||||||
static string[] defMessages = new string[] { "{0} WIKIWOO'D {1}", "{0} stuck their teeth into {1}",
|
static string[] defMessages = new string[] { "{0} WIKIWOO'D {1}", "{0} stuck their teeth into {1}",
|
||||||
|
@ -31,6 +31,7 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
public static byte[] MakeHackControl(Player p) {
|
public static byte[] MakeHackControl(Player p) {
|
||||||
string motd = p.level.GetMotd(p);
|
string motd = p.level.GetMotd(p);
|
||||||
|
motd = Colors.StripColors(motd);
|
||||||
bool isOp = p.Rank >= LevelPermission.Operator;
|
bool isOp = p.Rank >= LevelPermission.Operator;
|
||||||
|
|
||||||
bool fly = true, noclip = true, speed = true, respawn = true, _3rdPerson = true;
|
bool fly = true, noclip = true, speed = true, respawn = true, _3rdPerson = true;
|
||||||
|
@ -127,6 +127,13 @@ namespace MCGalaxy {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ShouldShowJoinMessage(Level prev) {
|
||||||
|
if (Server.zombie.Running && name.CaselessEq(Server.zombie.CurLevelName)
|
||||||
|
&& (prev == this || prev.name.CaselessEq(Server.zombie.LastLevelName))) return false;
|
||||||
|
if (Server.lava.active && Server.lava.HasMap(name)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary> The currently active game running on this map,
|
/// <summary> The currently active game running on this map,
|
||||||
/// or null if there is no game running. </summary>
|
/// or null if there is no game running. </summary>
|
||||||
public IGame CurrentGame() {
|
public IGame CurrentGame() {
|
||||||
|
@ -216,6 +216,7 @@
|
|||||||
<Compile Include="Commands\Economy\CmdPay.cs" />
|
<Compile Include="Commands\Economy\CmdPay.cs" />
|
||||||
<Compile Include="Commands\Economy\CmdStore.cs" />
|
<Compile Include="Commands\Economy\CmdStore.cs" />
|
||||||
<Compile Include="Commands\Economy\CmdTake.cs" />
|
<Compile Include="Commands\Economy\CmdTake.cs" />
|
||||||
|
<Compile Include="Commands\Economy\MoneyCmd.cs" />
|
||||||
<Compile Include="Commands\Fun\Cmd8Ball.cs" />
|
<Compile Include="Commands\Fun\Cmd8Ball.cs" />
|
||||||
<Compile Include="Commands\Fun\CmdAka.cs" />
|
<Compile Include="Commands\Fun\CmdAka.cs" />
|
||||||
<Compile Include="Commands\Fun\CmdCountdown.cs" />
|
<Compile Include="Commands\Fun\CmdCountdown.cs" />
|
||||||
@ -481,7 +482,6 @@
|
|||||||
<Compile Include="Games\Team.cs" />
|
<Compile Include="Games\Team.cs" />
|
||||||
<Compile Include="Games\Team.List.cs" />
|
<Compile Include="Games\Team.List.cs" />
|
||||||
<Compile Include="Games\TntWars\TntWars.cs" />
|
<Compile Include="Games\TntWars\TntWars.cs" />
|
||||||
<Compile Include="Games\ZombieSurvival\ZombieAwards.cs" />
|
|
||||||
<Compile Include="Games\ZombieSurvival\ZombieGame.Core.cs" />
|
<Compile Include="Games\ZombieSurvival\ZombieGame.Core.cs" />
|
||||||
<Compile Include="Games\ZombieSurvival\ZombieGame.cs" />
|
<Compile Include="Games\ZombieSurvival\ZombieGame.cs" />
|
||||||
<Compile Include="Games\ZombieSurvival\ZombieGame.Game.cs" />
|
<Compile Include="Games\ZombieSurvival\ZombieGame.Game.cs" />
|
||||||
|
@ -177,7 +177,7 @@ namespace MCGalaxy {
|
|||||||
void Player_PlayerDisconnect(Player p, string reason) {
|
void Player_PlayerDisconnect(Player p, string reason) {
|
||||||
if (!Server.irc ||!IsConnected() || p.hidden) return;
|
if (!Server.irc ||!IsConnected() || p.hidden) return;
|
||||||
if (!Server.guestLeaveNotify && p.Rank <= LevelPermission.Guest) return;
|
if (!Server.guestLeaveNotify && p.Rank <= LevelPermission.Guest) return;
|
||||||
Say(p.DisplayName + " %Sjoined the game (" + reason + "%S)", false);
|
Say(p.DisplayName + " %Sleft the game (" + reason + "%S)", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player_PlayerConnect(Player p) {
|
void Player_PlayerConnect(Player p) {
|
||||||
|
@ -300,8 +300,10 @@ namespace MCGalaxy {
|
|||||||
if (OnSendMOTD != null) OnSendMOTD(this, packet);
|
if (OnSendMOTD != null) OnSendMOTD(this, packet);
|
||||||
Send(packet);
|
Send(packet);
|
||||||
|
|
||||||
if (HasCpeExt(CpeExt.HackControl))
|
if (!HasCpeExt(CpeExt.HackControl)) return;
|
||||||
Send(Hacks.MakeHackControl(this));
|
Send(Hacks.MakeHackControl(this));
|
||||||
|
if (Game.Referee)
|
||||||
|
Send(Packet.MakeHackControl(true, true, true, true, true, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendMap(Level oldLevel) { SendRawMap(oldLevel, level); }
|
public void SendMap(Level oldLevel) { SendRawMap(oldLevel, level); }
|
||||||
|
@ -74,12 +74,12 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void ReadVersion2(string[] lines, List<string> cmdNames) {
|
static void ReadVersion2(string[] lines, List<string> cmdNames) {
|
||||||
string[] colon = new[] { " : " };
|
char[] colon = new char[] { ':' };
|
||||||
foreach (string line in lines) {
|
foreach (string line in lines) {
|
||||||
if (line == "" || line[0] == '#') continue;
|
if (line == "" || line[0] == '#') continue;
|
||||||
rankAllowance perms = new rankAllowance();
|
rankAllowance perms = new rankAllowance();
|
||||||
//Name : Lowest : Disallow : Allow
|
//Name : Lowest : Disallow : Allow
|
||||||
string[] args = line.Split(colon, StringSplitOptions.None);
|
string[] args = line.Replace(" ", "").Split(colon);
|
||||||
|
|
||||||
if (!cmdNames.Contains(args[0])) {
|
if (!cmdNames.Contains(args[0])) {
|
||||||
Server.s.Log("Incorrect command name: " + args[0]); continue;
|
Server.s.Log("Incorrect command name: " + args[0]); continue;
|
||||||
|
@ -118,12 +118,6 @@ namespace MCGalaxy {
|
|||||||
totalLogins, overallDeath, money, blocks,
|
totalLogins, overallDeath, money, blocks,
|
||||||
cuboided, totalKicked, time.ToDBTime(), name);
|
cuboided, totalKicked, time.ToDBTime(), name);
|
||||||
|
|
||||||
if (Economy.Enabled && loginMoney != money) {
|
|
||||||
Economy.EcoStats ecos = Economy.RetrieveEcoStats(name);
|
|
||||||
ecos.money = money;
|
|
||||||
Economy.UpdateEcoStats(ecos);
|
|
||||||
}
|
|
||||||
|
|
||||||
Server.zombie.SaveZombieStats(this);
|
Server.zombie.SaveZombieStats(this);
|
||||||
SaveUndo(this);
|
SaveUndo(this);
|
||||||
}
|
}
|
||||||
@ -581,7 +575,7 @@ namespace MCGalaxy {
|
|||||||
if (!Server.LogNotes) return;
|
if (!Server.LogNotes) return;
|
||||||
string src = who == null ? "(console)" : who.name;
|
string src = who == null ? "(console)" : who.name;
|
||||||
|
|
||||||
string time = DateTime.UtcNow.ToString("dd/mm/yyyy");
|
string time = DateTime.UtcNow.ToString("dd/MM/yyyy");
|
||||||
Server.Notes.Append(target + " " + type + " " + src + " " + time);
|
Server.Notes.Append(target + " " + type + " " + src + " " + time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -589,7 +583,7 @@ namespace MCGalaxy {
|
|||||||
if (!Server.LogNotes) return;
|
if (!Server.LogNotes) return;
|
||||||
string src = who == null ? "(console)" : who.name;
|
string src = who == null ? "(console)" : who.name;
|
||||||
|
|
||||||
string time = DateTime.UtcNow.ToString("dd/mm/yyyy");
|
string time = DateTime.UtcNow.ToString("dd/MM/yyyy");
|
||||||
reason = reason.Replace(" ", "%20");
|
reason = reason.Replace(" ", "%20");
|
||||||
Server.Notes.Append(target + " " + type + " " + src + " " + time + " " + reason);
|
Server.Notes.Append(target + " " + type + " " + src + " " + time + " " + reason);
|
||||||
}
|
}
|
||||||
|
@ -46,11 +46,6 @@ namespace MCGalaxy {
|
|||||||
", Money, totalBlocks, totalKicked, TimeSpent) VALUES (@0, @1, @2, @2, @3, @4, @5, @5, @5, @5, @6)";
|
", Money, totalBlocks, totalKicked, TimeSpent) VALUES (@0, @1, @2, @2, @3, @4, @5, @5, @5, @5, @6)";
|
||||||
Database.Execute(query,
|
Database.Execute(query,
|
||||||
p.name, p.ip, now, 1, "", 0, p.time.ToDBTime());
|
p.name, p.ip, now, 1, "", 0, p.time.ToDBTime());
|
||||||
|
|
||||||
const string ecoQuery = "INSERT INTO Economy (player, money, total, purchase, payment, salary, fine) " +
|
|
||||||
"VALUES (@0, @1, @2, @3, @3, @3, @3)";
|
|
||||||
Database.Execute(ecoQuery,
|
|
||||||
p.name, p.money, 0, "%cNone");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void Load(DataTable playerDb, Player p) {
|
internal static void Load(DataTable playerDb, Player p) {
|
||||||
@ -74,9 +69,7 @@ namespace MCGalaxy {
|
|||||||
p.TotalPlaced = data.TotalPlaced;
|
p.TotalPlaced = data.TotalPlaced;
|
||||||
p.TotalDeleted = data.TotalDeleted;
|
p.TotalDeleted = data.TotalDeleted;
|
||||||
|
|
||||||
//money = int.Parse(data.money);
|
p.money = data.Money;
|
||||||
p.money = Economy.RetrieveEcoStats(p.name).money;
|
|
||||||
p.loginMoney = p.money;
|
|
||||||
p.totalKicked = data.Kicks;
|
p.totalKicked = data.Kicks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,14 +180,14 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static DataTable Query(string name, string selector) {
|
internal static DataTable Query(string name, string selector) {
|
||||||
string syntax = Server.useMySQL ?
|
string syntax = Server.useMySQL ?
|
||||||
"SELECT " + selector + " FROM Players WHERE Name=@0 COLLATE utf8_general_ci" :
|
"SELECT " + selector + " FROM Players WHERE Name=@0 COLLATE utf8_general_ci" :
|
||||||
"SELECT " + selector + " FROM Players WHERE Name=@0 COLLATE NOCASE";
|
"SELECT " + selector + " FROM Players WHERE Name=@0 COLLATE NOCASE";
|
||||||
return Database.Fill(syntax, name);
|
return Database.Fill(syntax, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static DataRow QueryMulti(Player p, string name, string selector) {
|
internal static DataRow QueryMulti(Player p, string name, string selector) {
|
||||||
string syntax = Server.useMySQL ?
|
string syntax = Server.useMySQL ?
|
||||||
"SELECT " + selector + " FROM Players WHERE Name LIKE @0 LIMIT 21" :
|
"SELECT " + selector + " FROM Players WHERE Name LIKE @0 LIMIT 21" :
|
||||||
"SELECT " + selector + " FROM Players WHERE Name LIKE @0 LIMIT 21 COLLATE NOCASE";
|
"SELECT " + selector + " FROM Players WHERE Name LIKE @0 LIMIT 21 COLLATE NOCASE";
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
devs:Hetal+
|
devs:Hetal+
|
||||||
mods:Good+
|
mods:Good+
|
||||||
devs:UnknownShadow200+
|
|
||||||
devs:venom983+
|
devs:venom983+
|
||||||
devs:UclCommander+
|
devs:UclCommander+
|
Loading…
x
Reference in New Issue
Block a user