Prettify /mapinfo, allow disabling BlockDB for specific worlds with /blockdb disable.

This commit is contained in:
UnknownShadow200 2016-05-17 14:49:20 +10:00
parent a9af01b69e
commit 183d092ce7
9 changed files with 113 additions and 77 deletions

View File

@ -55,6 +55,7 @@ namespace MCGalaxy.Commands {
new CommandKeywords((new CmdBanip()), "ip ban kick mod punish");
new CommandKeywords((new CmdBanlist()), "list ban info mod");
new CommandKeywords((new CmdBind()), "block replace");
new CommandKeywords((new CmdBlockDB()), "about block change remove del");
new CommandKeywords((new CmdBlocks()), "block info list");
new CommandKeywords((new CmdBlockSet()), "rank mod block");
new CommandKeywords((new CmdBlockSpeed()), "block speed mod setting");
@ -67,7 +68,6 @@ namespace MCGalaxy.Commands {
new CommandKeywords((new CmdC4()), "tnt c4 explosion");
new CommandKeywords((new CmdChain()), "grab block mushroom brown");
new CommandKeywords((new CmdChangeLog()), "MCGalaxy change log");
new CommandKeywords((new CmdClearBlockChanges()), "about block change remove del");
new CommandKeywords((new CmdClick()), "block use");
new CommandKeywords((new CmdClones()), "clone ip player info");
new CommandKeywords((new CmdCmdBind()), "bind cmd command shortcut");

View File

@ -57,23 +57,25 @@ namespace MCGalaxy.Commands {
}
void ShowNormal(Player p, MapInfoData data) {
Player.Message(p, "&b" + data.Name + "%S: Width=" + data.Width + " Height=" + data.Height + " Depth=" + data.Length);
Player.Message(p, "&bAbout {0}%S: Width={1} Height={2} Length={3}", data.Name, data.Width, data.Height, data.Length);
string physicsState = CmdPhysics.states[data.Physics];
Player.Message(p, "Physics are " + physicsState + " %Son &b" + data.Name);
string gunStatus = data.Guns ? "&aonline" : "&coffline";
if (p == null || p.group.CanExecute("gun"))
Player.Message(p, "&cGuns &eare " + gunStatus + " &eon " + data.Name + ".");
if (p == null || p.group.CanExecute("gun")) {
Player.Message(p, " Physics are {0}%S, gun usage %Sis {1}",
physicsState, data.Guns ? "&aenabled" : "&cdisabled");
} else {
Player.Message(p, " Physics are {0}", physicsState);
}
if (Directory.Exists(Server.backupLocation + "/" + data.Name)) {
int latestBackup = Directory.GetDirectories(Server.backupLocation + "/" + data.Name).Length;
DateTime time = Directory.GetCreationTime(LevelInfo.BackupPath(data.Name, latestBackup.ToString()));
Player.Message(p, "Latest backup: &a" + latestBackup + " %Sat &a" + time.ToString("yyyy-MM-dd HH:mm:ss"));
Player.Message(p, " Latest backup: &a{0} %Sat &a" + time.ToString("yyyy-MM-dd HH:mm:ss"), latestBackup);
} else {
Player.Message(p, "No backups for this map exist yet.");
Player.Message(p, " No backups for this map exist yet.");
}
Player.Message(p, "Use %T/mi env " + data.Name + " %Sto see environment settings.");
Player.Message(p, "Use %T/mi perms " + data.Name + " %Sto see permission settings.");
Player.Message(p, " BlockDB (Used for /b) is {0}", data.BlockDB ? "&aEnabled" : "&cDisabled");
Player.Message(p, "Use %T/mi env {0} %Sto see environment settings.", data.Name);
Player.Message(p, "Use %T/mi perms {0} %Sto see permission settings.", data.Name);
if (!Server.zombie.IsZombieMap(data.Name)) return;
Player.Message(p, "Map authors: " + data.Authors);
@ -137,7 +139,7 @@ namespace MCGalaxy.Commands {
public ushort Width, Height, Length;
public int Physics;
public bool Guns;
public bool Guns, BlockDB;
public string Name, TerrainUrl, TextureUrl;
public string Fog, Sky, Clouds, Light, Shadow;
public int EdgeLevel, CloudsHeight, MaxFog;
@ -154,7 +156,7 @@ namespace MCGalaxy.Commands {
public void FromOnlineLevel(Level lvl) {
Name = lvl.name;
Width = lvl.Width; Height = lvl.Height; Length = lvl.Length;
Physics = lvl.physics; Guns = lvl.guns;
Physics = lvl.physics; Guns = lvl.guns; BlockDB = lvl.UseBlockDB;
visit = lvl.permissionvisit; build = lvl.permissionbuild;
visitmax = lvl.pervisitmax; buildmax = lvl.perbuildmax;
VisitWhitelist = new List<string>(lvl.VisitWhitelist);
@ -201,6 +203,7 @@ namespace MCGalaxy.Commands {
case "clouds-speed": CloudsSpeed = int.Parse(value); break;
case "weather-speed": WeatherSpeed = int.Parse(value); break;
case "weather-fade": WeatherFade = int.Parse(value); break;
case "useblockdb": BlockDB = bool.Parse(value); break;
case "perbuild": build = GetPerm(value); break;
case "pervisit": visit = GetPerm(value); break;

View File

@ -0,0 +1,77 @@
/*
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 MCGalaxy.SQL;
namespace MCGalaxy.Commands {
public sealed class CmdBlockDB : Command {
public override string name { get { return "blockdb"; } }
public override string shortcut { get { return ""; } }
public override string type { get { return CommandTypes.World; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
public override CommandAlias[] Aliases {
get { return new [] { new CommandAlias("clearblockchanges", "clear"),
new CommandAlias("cbc", "clear") }; }
}
public override void Use(Player p, string message) {
string[] args = message.Split(' ');
if (args.Length == 1 && p == null) {
Player.Message(p, "You must provide a map name when running the command from console."); return;
}
args[0] = args[0].ToLower();
Level lvl = p == null ? null : p.level;
if (args.Length > 1) {
lvl = LevelInfo.FindOrShowMatches(p, args[1]);
if (lvl == null) return;
}
if (args[0] == "clear") {
Player.Message(p, "Clearing &cALL %Sblock changes for &d{0}...", lvl.name);
if (Server.useMySQL)
Database.executeQuery("TRUNCATE TABLE `Block" + lvl.name + "`");
else
Database.executeQuery("DELETE FROM `Block" + lvl.name + "`");
Player.Message(p, "Cleared &cALL %Sblock changes for &d" + lvl.name);
} else if (args[0] == "disable") {
lvl.UseBlockDB = false;
Player.Message(p, "&cDisabled %Srecording further block changesfor &d" + lvl.name);
Level.SaveSettings(lvl);
} else if (args[0] == "enable") {
lvl.UseBlockDB = true;
Player.Message(p, "&aEnabled %Srecording further block changes for &d" + lvl.name);
Level.SaveSettings(lvl);
} else {
Help(p);
}
}
public override void Help(Player p) {
Player.Message(p, "%T/blockdb clear [map]");
Player.Message(p, "%HClears the BlockDB (block changes stored in /about) for [map]");
Player.Message(p, "%T/blockdb disable [map]");
Player.Message(p, "%HDisables recording block changes to the BlockDB for [map]");
Player.Message(p, "%T/blockdb enable [map]");
Player.Message(p, "%HEnables %Hrecording block changes to the BlockDB for [map]");
Player.Message(p, "%HIf no map name is given, uses your current map.");
Player.Message(p, "%CUse these commands with great caution!");
}
}
}

View File

@ -1,53 +0,0 @@
/*
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 MCGalaxy.SQL;
namespace MCGalaxy.Commands {
public sealed class CmdClearBlockChanges : Command {
public override string name { get { return "clearblockchanges"; } }
public override string shortcut { get { return "cbc"; } }
public override string type { get { return CommandTypes.World; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
public override void Use(Player p, string message) {
if (p == null && message == "") {
Player.Message(p, "You must provide a map name when running the command from console."); return;
}
Level lvl = p == null ? null : p.level;
if (message != "") {
lvl = LevelInfo.FindOrShowMatches(p, message);
if (lvl == null) return;
}
if ( Server.useMySQL )
Database.executeQuery("TRUNCATE TABLE `Block" + lvl.name + "`");
else
Database.executeQuery("DELETE FROM `Block" + lvl.name + "`");
Player.Message(p, "Cleared &cALL %Srecorded block changes for: &d" + lvl.name);
}
public override void Help(Player p) {
Player.Message(p, "%T/clearblockchanges [map]");
Player.Message(p, "%HClears the block changes stored in /about for [map]");
Player.Message(p, "%H If no map name is given, clears block changes for the current map.");
Player.Message(p, "%CUse with great caution!");
}
}
}

View File

@ -109,7 +109,8 @@ namespace MCGalaxy.Drawing.Ops {
bP.index = lvl.PosToInt(x, y, z);
bP.SetData(type, extType, type == 0);
lvl.blockCache.Add(bP);
if (lvl.UseBlockDB)
lvl.blockCache.Add(bP);
BlockQueue.Addblock(p, bP.index, type, extType);
TotalModified++;
break;
@ -119,7 +120,8 @@ namespace MCGalaxy.Drawing.Ops {
bP.index = lvl.PosToInt(x, y, z);
bP.SetData(type, extType, type == 0);
lvl.blockCache.Add(bP);
if (lvl.UseBlockDB)
lvl.blockCache.Add(bP);
Player.GlobalBlockchange(lvl, x, y, z, type, extType);
TotalModified++;
break;
@ -131,7 +133,7 @@ namespace MCGalaxy.Drawing.Ops {
p.loginBlocks++;
p.overallBlocks++;
TotalModified++;
break;
break;
case M_BlockChange:
lvl.Blockchange(x, y, z, type, extType);
TotalModified++;

View File

@ -149,8 +149,9 @@ namespace MCGalaxy {
Level.BlockPos bP = default(Level.BlockPos);
bP.name = p.name;
bP.index = b;
bP.SetData(type, extType, type == 0);
blockCache.Add(bP);
bP.SetData(type, extType, type == 0);
if (UseBlockDB)
blockCache.Add(bP);
Player.UndoPos Pos;
Pos.x = x; Pos.y = y; Pos.z = z;
@ -472,7 +473,8 @@ namespace MCGalaxy {
bP.name = p.name;
bP.index = PosToInt(x, y, z);
bP.SetData(type, extType, type == 0);
blockCache.Add(bP);
if (UseBlockDB)
blockCache.Add(bP);
if (bufferblocks)
BlockQueue.Addblock(p, bP.index, type, extType);

View File

@ -94,6 +94,9 @@ namespace MCGalaxy
public bool Buildable = true;
[ConfigBool("Deletable", "Permissions", null, true)]
public bool Deletable = true;
[ConfigBool("UseBlockDB", "Other", null, true)]
public bool UseBlockDB = true;
[ConfigInt("Weather", "Env", null, 0, 0, 2)]
public int Weather;
@ -454,6 +457,7 @@ namespace MCGalaxy
public unsafe void saveChanges() {
if (blockCache.Count == 0) return;
if (!UseBlockDB) { blockCache.Clear(); return; }
List<BlockPos> tempCache = blockCache;
string date = new String('-', 19); //yyyy-mm-dd hh:mm:ss

View File

@ -385,7 +385,7 @@
<Compile Include="Commands\other\CmdWarp.cs" />
<Compile Include="Commands\other\CmdWaypoint.cs" />
<Compile Include="Commands\other\CmdXJail.cs" />
<Compile Include="Commands\World\CmdClearBlockChanges.cs" />
<Compile Include="Commands\World\CmdBlockDB.cs" />
<Compile Include="Commands\World\CmdCopyLVL.cs" />
<Compile Include="Commands\World\CmdDeleteLvl.cs" />
<Compile Include="Commands\World\CmdEnvironment.cs" />

View File

@ -78,7 +78,8 @@ namespace MCGalaxy {
if ( Blockchange != null ) {
if ( Blockchange.Method.ToString().IndexOf("AboutBlockchange") == -1 && !level.IsMuseum ) {
bP.flags |= 1;
level.blockCache.Add(bP);
if (level.UseBlockDB)
level.blockCache.Add(bP);
}
Blockchange(this, x, y, z, type, extType);
@ -128,12 +129,12 @@ namespace MCGalaxy {
}
}
//else
if ( !painting && action == 0 ) {
if (!painting && action == 0) {
bP.flags |= 1;
if (DeleteBlock(b, x, y, z, type, extType))
if (DeleteBlock(b, x, y, z, type, extType) && level.UseBlockDB)
level.blockCache.Add(bP);
} else {
if (PlaceBlock(b, x, y, z, type, extType))
if (PlaceBlock(b, x, y, z, type, extType) && level.UseBlockDB)
level.blockCache.Add(bP);
}
}