mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-19 04:07:10 -04:00
Allow /give on yourself, since it's a mod command, and you could just give money to an alt anyways
This commit is contained in:
parent
732c5e476e
commit
b79cfa2dad
@ -33,7 +33,6 @@ namespace MCGalaxy.Commands.Eco {
|
|||||||
int matches = 1;
|
int matches = 1;
|
||||||
Player who = PlayerInfo.FindMatches(p, trans.TargetName, out matches);
|
Player who = PlayerInfo.FindMatches(p, trans.TargetName, out matches);
|
||||||
if (matches > 1) return;
|
if (matches > 1) return;
|
||||||
if (p == who) { p.Message("You cannot give yourself &3" + ServerConfig.Currency); return; }
|
|
||||||
int money = 0;
|
int money = 0;
|
||||||
|
|
||||||
if (who == null) {
|
if (who == null) {
|
||||||
|
@ -32,7 +32,7 @@ namespace MCGalaxy.Commands.Eco {
|
|||||||
int matches = 1;
|
int matches = 1;
|
||||||
Player who = PlayerInfo.FindMatches(p, trans.TargetName, out matches);
|
Player who = PlayerInfo.FindMatches(p, trans.TargetName, out matches);
|
||||||
if (matches > 1) return;
|
if (matches > 1) return;
|
||||||
if (p == who) { p.Message("You cannot pay yourself &3" + ServerConfig.Currency); return; }
|
if (p == who) { p.Message("%WYou cannot pay yourself &3" + ServerConfig.Currency); return; }
|
||||||
int money, srcMoney = p.IsSuper ? int.MaxValue : p.money;
|
int money, srcMoney = p.IsSuper ? int.MaxValue : p.money;
|
||||||
|
|
||||||
if (who == null) {
|
if (who == null) {
|
||||||
|
@ -32,7 +32,7 @@ namespace MCGalaxy.Commands.Eco {
|
|||||||
int matches = 1;
|
int matches = 1;
|
||||||
Player who = PlayerInfo.FindMatches(p, trans.TargetName, out matches);
|
Player who = PlayerInfo.FindMatches(p, trans.TargetName, out matches);
|
||||||
if (matches > 1) return;
|
if (matches > 1) return;
|
||||||
if (p == who) { p.Message("%WYou can't take &3" + ServerConfig.Currency + "%W from yourself"); return; }
|
if (p == who) { p.Message("%WYou cannot take &3" + ServerConfig.Currency + " %Wfrom yourself"); return; }
|
||||||
|
|
||||||
int money = 0;
|
int money = 0;
|
||||||
if (who == null) {
|
if (who == null) {
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using MCGalaxy.Commands.World;
|
using MCGalaxy.Commands.World;
|
||||||
@ -41,32 +40,26 @@ namespace MCGalaxy.Commands.Info {
|
|||||||
string map = env ? (args.Length > 1 ? args[1] : "") : args[0];
|
string map = env ? (args.Length > 1 ? args[1] : "") : args[0];
|
||||||
|
|
||||||
Level lvl = map.Length == 0 ? p.level : null;
|
Level lvl = map.Length == 0 ? p.level : null;
|
||||||
MapInfoData mapData = new MapInfoData();
|
MapInfo info = new MapInfo();
|
||||||
|
|
||||||
|
// User provided specific map name
|
||||||
if (lvl == null) {
|
if (lvl == null) {
|
||||||
if (!GetFromMap(p, mapData, map)) return;
|
map = Matcher.FindMaps(p, map);
|
||||||
} else {
|
if (map == null) return;
|
||||||
mapData.FromOnlineLevel(lvl);
|
lvl = LevelInfo.FindExact(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (env) ShowEnv(p, mapData, mapData.Config);
|
|
||||||
else ShowNormal(p, mapData, mapData.Config);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GetFromMap(Player p, MapInfoData data, string map) {
|
|
||||||
map = Matcher.FindMaps(p, map);
|
|
||||||
if (map == null) return false;
|
|
||||||
|
|
||||||
Level lvl = LevelInfo.FindExact(map);
|
|
||||||
if (lvl != null) {
|
if (lvl != null) {
|
||||||
data.FromOnlineLevel(lvl);
|
info.FromLevel(lvl);
|
||||||
} else {
|
} else {
|
||||||
data.FromOfflineLevel(map);
|
info.FromMap(map);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
|
if (env) ShowEnv(p, info, info.Config);
|
||||||
|
else ShowNormal(p, info, info.Config);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowNormal(Player p, MapInfoData data, LevelConfig cfg) {
|
void ShowNormal(Player p, MapInfo data, LevelConfig cfg) {
|
||||||
p.Message("&bAbout {0}%S: Width={1} Height={2} Length={3}",
|
p.Message("&bAbout {0}%S: Width={1} Height={2} Length={3}",
|
||||||
cfg.Color + data.Name, data.Width, data.Height, data.Length);
|
cfg.Color + data.Name, data.Width, data.Height, data.Length);
|
||||||
|
|
||||||
@ -101,7 +94,7 @@ namespace MCGalaxy.Commands.Info {
|
|||||||
ShowZombieSurvival(p, data, cfg);
|
ShowZombieSurvival(p, data, cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowPermissions(Player p, MapInfoData data, LevelConfig cfg) {
|
void ShowPermissions(Player p, MapInfo data, LevelConfig cfg) {
|
||||||
PrintRanks(p, data.Visit, " Visitable by ");
|
PrintRanks(p, data.Visit, " Visitable by ");
|
||||||
PrintRanks(p, data.Build, " Modifiable by ");
|
PrintRanks(p, data.Build, " Modifiable by ");
|
||||||
|
|
||||||
@ -122,7 +115,7 @@ namespace MCGalaxy.Commands.Info {
|
|||||||
p.Message(perms.ToString());
|
p.Message(perms.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowZombieSurvival(Player p, MapInfoData data, LevelConfig cfg) {
|
void ShowZombieSurvival(Player p, MapInfo data, LevelConfig cfg) {
|
||||||
if (!ZSGame.Instance.HasMap(data.MapName)) return;
|
if (!ZSGame.Instance.HasMap(data.MapName)) return;
|
||||||
|
|
||||||
string[] authors = cfg.Authors.SplitComma();
|
string[] authors = cfg.Authors.SplitComma();
|
||||||
@ -154,7 +147,7 @@ namespace MCGalaxy.Commands.Info {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowEnv(Player p, MapInfoData data, LevelConfig cfg) {
|
void ShowEnv(Player p, MapInfo data, LevelConfig cfg) {
|
||||||
string url = cfg.Terrain.Length > 0 ? cfg.Terrain : ServerConfig.DefaultTerrain;
|
string url = cfg.Terrain.Length > 0 ? cfg.Terrain : ServerConfig.DefaultTerrain;
|
||||||
if (url.Length > 0) {
|
if (url.Length > 0) {
|
||||||
p.Message("Terrain: &b" + url);
|
p.Message("Terrain: &b" + url);
|
||||||
@ -191,14 +184,14 @@ namespace MCGalaxy.Commands.Info {
|
|||||||
return angle == 0 ? "none" : (angle / 1024.0).ToString("F3") + "/s";
|
return angle == 0 ? "none" : (angle / 1024.0).ToString("F3") + "/s";
|
||||||
}
|
}
|
||||||
|
|
||||||
class MapInfoData {
|
class MapInfo {
|
||||||
public ushort Width, Height, Length;
|
public ushort Width, Height, Length;
|
||||||
public string Name, MapName;
|
public string Name, MapName;
|
||||||
public long BlockDBEntries = -1;
|
public long BlockDBEntries = -1;
|
||||||
public LevelAccessController Visit, Build;
|
public LevelAccessController Visit, Build;
|
||||||
public LevelConfig Config;
|
public LevelConfig Config;
|
||||||
|
|
||||||
public void FromOnlineLevel(Level lvl) {
|
public void FromLevel(Level lvl) {
|
||||||
Name = lvl.name; MapName = lvl.MapName;
|
Name = lvl.name; MapName = lvl.MapName;
|
||||||
Width = lvl.Width; Height = lvl.Height; Length = lvl.Length;
|
Width = lvl.Width; Height = lvl.Height; Length = lvl.Length;
|
||||||
BlockDBEntries = lvl.BlockDB.TotalEntries();
|
BlockDBEntries = lvl.BlockDB.TotalEntries();
|
||||||
@ -208,21 +201,21 @@ namespace MCGalaxy.Commands.Info {
|
|||||||
Build = lvl.BuildAccess;
|
Build = lvl.BuildAccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FromOfflineLevel(string name) {
|
public void FromMap(string map) {
|
||||||
this.Name = name; MapName = name;
|
this.Name = map; MapName = map;
|
||||||
string path = LevelInfo.MapPath(name);
|
string path = LevelInfo.MapPath(map);
|
||||||
Vec3U16 dims = IMapImporter.Formats[0].ReadDimensions(path);
|
Vec3U16 dims = IMapImporter.Formats[0].ReadDimensions(path);
|
||||||
Width = dims.X; Height = dims.Y; Length = dims.Z;
|
Width = dims.X; Height = dims.Y; Length = dims.Z;
|
||||||
BlockDBEntries = BlockDBFile.CountEntries(name);
|
BlockDBEntries = BlockDBFile.CountEntries(map);
|
||||||
|
|
||||||
path = LevelInfo.PropsPath(name);
|
path = LevelInfo.PropsPath(map);
|
||||||
LevelConfig cfg = new LevelConfig();
|
LevelConfig cfg = new LevelConfig();
|
||||||
cfg.SetDefaults(Height);
|
cfg.SetDefaults(Height);
|
||||||
cfg.Load(path);
|
cfg.Load(path);
|
||||||
|
|
||||||
Config = cfg;
|
Config = cfg;
|
||||||
Visit = new LevelAccessController(cfg, name, true);
|
Visit = new LevelAccessController(cfg, map, true);
|
||||||
Build = new LevelAccessController(cfg, name, false);
|
Build = new LevelAccessController(cfg, map, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user