mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
Reduce code duplication so all /env commands can be used in /os env. (Thanks MrRockman888)
This commit is contained in:
parent
024cd71945
commit
0513fc6f8f
@ -45,11 +45,16 @@ namespace MCGalaxy.Commands {
|
||||
args[0] = args[1];
|
||||
args[1] = args[2];
|
||||
}
|
||||
Handle(p, args[0], args[1]);
|
||||
|
||||
if (args[0] == "preset") {
|
||||
SetPreset(p, args[1]);
|
||||
} else if (!Handle(p, args[0], args[1])) {
|
||||
Help(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Handle(Player p, string variable, string value) {
|
||||
internal static bool Handle(Player p, string variable, string value) {
|
||||
Level lvl = p.level;
|
||||
switch (variable) {
|
||||
case "fog":
|
||||
@ -103,13 +108,11 @@ namespace MCGalaxy.Commands {
|
||||
case "bedrock":
|
||||
LevelEnv.SetBlock(p, value, EnvProp.SidesBlock,
|
||||
"sides block", Block.blackrock, ref lvl.EdgeBlock); break;
|
||||
case "preset":
|
||||
if (!SetPreset(p, value)) return;
|
||||
break;
|
||||
default:
|
||||
Help(p); return;
|
||||
return false;
|
||||
}
|
||||
p.level.Save(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void ResetEnv(Player p) {
|
||||
|
@ -101,27 +101,18 @@ namespace MCGalaxy.Commands
|
||||
}
|
||||
|
||||
void HandleEnvCommand(Player p, string type, string value) {
|
||||
if (type == "FOG" || type == "CLOUD" || type == "SKY" || type == "SHADOW" || type == "SUN" ||
|
||||
type == "LEVEL" || type == "CLOUDHEIGHT" || type == "HORIZON" || type == "BORDER" || type == "MAXFOG") {
|
||||
string col = value == "" ? "normal" : value;
|
||||
Command.all.Find("env").Use(p, type.ToLower() + " " + col);
|
||||
} else if (type == "WEATHER") {
|
||||
if (value == "") {
|
||||
Player.Message(p, "/os env weather [sun/rain/snow/normal] -- Changes the weather of your map.");
|
||||
} else {
|
||||
LevelEnv.SetWeather(p, p.level, value);
|
||||
}
|
||||
} else {
|
||||
Player.Message(p, "/os env [fog/cloud/sky/shadow/sun] [hex color code] -- Changes env colors of your map");
|
||||
Player.Message(p, "/os env level -- Sets the water height of your map");
|
||||
Player.Message(p, "/os env cloudheight -- Sets the cloud height of your map");
|
||||
Player.Message(p, "/os env maxfog -- Sets the max fog distance in your map");
|
||||
Player.Message(p, "/os env horizon -- Sets what block the \"ocean\" shows outside your map");
|
||||
Player.Message(p, "/os env border -- Sets what block replaces the \"bedrock\" below sea level in your map");
|
||||
Player.Message(p, "/os env weather [sun/rain/snow/normal] -- Changes the weather of your map.");
|
||||
Player.Message(p, " Warning: Shrub,Flowers,Mushroom,Rope,Fire cannot be used for horizon/bedrock.");
|
||||
Player.Message(p, " Note: If no hex or block is given, the default will be used.");
|
||||
}
|
||||
string arg = value == "" ? "normal" : value;
|
||||
if (CmdEnvironment.Handle(p, type.ToLower(), arg)) return;
|
||||
|
||||
Player.Message(p, "/os env [fog/cloud/sky/shadow/sun] [hex color code] -- Changes env colors of your map");
|
||||
Player.Message(p, "/os env level -- Sets the water height of your map");
|
||||
Player.Message(p, "/os env cloudheight -- Sets the cloud height of your map");
|
||||
Player.Message(p, "/os env maxfog -- Sets the max fog distance in your map");
|
||||
Player.Message(p, "/os env horizon -- Sets what block the \"ocean\" shows outside your map");
|
||||
Player.Message(p, "/os env border -- Sets what block replaces the \"bedrock\" below sea level in your map");
|
||||
Player.Message(p, "/os env weather [sun/rain/snow/normal] -- Changes the weather of your map.");
|
||||
Player.Message(p, " Warning: Shrub,Flowers,Mushroom,Rope,Fire cannot be used for horizon/bedrock.");
|
||||
Player.Message(p, " Note: If no hex or block is given, the default will be used.");
|
||||
}
|
||||
|
||||
void HandleMapCommand(Player p, string message, string cmd, string value) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user