mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-26 14:54:12 -04:00
Cleanup /bs command.
This commit is contained in:
parent
9b63b0bd69
commit
b665b02121
@ -16,109 +16,76 @@
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System;
|
||||
namespace MCGalaxy.Commands
|
||||
{
|
||||
public sealed class CmdBlockSpeed : Command
|
||||
{
|
||||
|
||||
namespace MCGalaxy.Commands {
|
||||
|
||||
public sealed class CmdBlockSpeed : Command {
|
||||
|
||||
public override string name { get { return "blockspeed"; } }
|
||||
public override string shortcut { get { return "bs"; } }
|
||||
public override string type { get { return CommandTypes.Moderation; } }
|
||||
public override string type { get { return CommandTypes.Moderation; } }
|
||||
public override bool museumUsable { get { return true; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
||||
public CmdBlockSpeed() { }
|
||||
|
||||
public override void Use(Player p, string text)
|
||||
{
|
||||
if (text == "")
|
||||
{
|
||||
SendEstimation(p);
|
||||
return;
|
||||
public override void Use(Player p, string text) {
|
||||
if (text == "") { SendEstimation(p); return; }
|
||||
string[] args = text.Split(' ');
|
||||
string cmd = args[0].ToLower();
|
||||
if (cmd == "clear") {
|
||||
Server.levels.ForEach(lvl => lvl.blockqueue.Clear()); return;
|
||||
}
|
||||
if (text == "clear")
|
||||
{
|
||||
Server.levels.ForEach((l) => { l.blockqueue.Clear(); });
|
||||
return;
|
||||
}
|
||||
if (text.StartsWith("bs"))
|
||||
{
|
||||
try { BlockQueue.blockupdates = int.Parse(text.Split(' ')[1]); }
|
||||
catch { Player.SendMessage(p, "Invalid number specified."); return; }
|
||||
if (args.Length == 1) { Help(p); return; }
|
||||
int value = 0;
|
||||
|
||||
if (cmd == "bs") {
|
||||
if (!int.TryParse(args[1], out value)) {
|
||||
Player.SendMessage(p, "Invalid number specified."); return;
|
||||
}
|
||||
BlockQueue.blockupdates = value;
|
||||
Player.SendMessage(p, String.Format("Blocks per interval is now {0}.", BlockQueue.blockupdates));
|
||||
return;
|
||||
}
|
||||
if (text.StartsWith("ts"))
|
||||
{
|
||||
try { BlockQueue.time = int.Parse(text.Split(' ')[1]); }
|
||||
catch { Player.SendMessage(p, "Invalid number specified."); return; }
|
||||
} else if (cmd == "ts") {
|
||||
if (!int.TryParse(args[1], out value)) {
|
||||
Player.SendMessage(p, "Invalid number specified."); return;
|
||||
}
|
||||
BlockQueue.time = value;
|
||||
Player.SendMessage(p, String.Format("Block interval is now {0}.", BlockQueue.time));
|
||||
return;
|
||||
}
|
||||
if (text.StartsWith("buf"))
|
||||
{
|
||||
} else if (cmd == "buf") {
|
||||
if (p.level.bufferblocks)
|
||||
{
|
||||
p.level.bufferblocks = false;
|
||||
Player.SendMessage(p, String.Format("Block buffering on {0} disabled.", p.level.name));
|
||||
}
|
||||
else
|
||||
{
|
||||
p.level.bufferblocks = true;
|
||||
Player.SendMessage(p, String.Format("Block buffering on {0} enabled.", p.level.name));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (text.StartsWith("net"))
|
||||
{
|
||||
switch (int.Parse(text.Split(' ')[1]))
|
||||
{
|
||||
case 2:
|
||||
BlockQueue.blockupdates = 25;
|
||||
BlockQueue.time = 100;
|
||||
break;
|
||||
case 4:
|
||||
BlockQueue.blockupdates = 50;
|
||||
BlockQueue.time = 100;
|
||||
break;
|
||||
case 8:
|
||||
BlockQueue.blockupdates = 100;
|
||||
BlockQueue.time = 100;
|
||||
break;
|
||||
case 12:
|
||||
BlockQueue.blockupdates = 200;
|
||||
BlockQueue.time = 100;
|
||||
break;
|
||||
case 16:
|
||||
BlockQueue.blockupdates = 200;
|
||||
BlockQueue.time = 100;
|
||||
break;
|
||||
case 161:
|
||||
BlockQueue.blockupdates = 100;
|
||||
BlockQueue.time = 50;
|
||||
break;
|
||||
case 20:
|
||||
BlockQueue.blockupdates = 125;
|
||||
BlockQueue.time = 50;
|
||||
break;
|
||||
case 24:
|
||||
BlockQueue.blockupdates = 150;
|
||||
BlockQueue.time = 50;
|
||||
break;
|
||||
default:
|
||||
BlockQueue.blockupdates = 200;
|
||||
BlockQueue.time = 100;
|
||||
break;
|
||||
p.level.bufferblocks = !p.level.bufferblocks;
|
||||
} else if (cmd == "net") {
|
||||
if (!int.TryParse(args[1], out value)) {
|
||||
Player.SendMessage(p, "Invalid number specified."); return;
|
||||
}
|
||||
|
||||
switch (value) {
|
||||
case 2: Set(25, 100); break;
|
||||
case 4: Set(50, 100); break;
|
||||
case 8: Set(100, 100); break;
|
||||
case 12: Set(200, 100); break;
|
||||
case 16: Set(200, 100); break;
|
||||
case 161: Set(100, 50); break;
|
||||
case 20: Set(125, 50); break;
|
||||
case 24: Set(150, 50); break;
|
||||
default: Set(200, 100); break;
|
||||
}
|
||||
SendEstimation(p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
private static void SendEstimation(Player p)
|
||||
{
|
||||
|
||||
static void Set(int updates, int time) {
|
||||
BlockQueue.blockupdates = updates;
|
||||
BlockQueue.time = time;
|
||||
}
|
||||
|
||||
static void SendEstimation(Player p) {
|
||||
Player.SendMessage(p, String.Format("{0} blocks every {1} milliseconds = {2} blocks per second.", BlockQueue.blockupdates, BlockQueue.time, BlockQueue.blockupdates * (1000 / BlockQueue.time)));
|
||||
Player.SendMessage(p, String.Format("Using ~{0}KB/s times {1} player(s) = ~{2}KB/s", (BlockQueue.blockupdates * (1000 / BlockQueue.time) * 8) / 1000, PlayerInfo.players.Count, PlayerInfo.players.Count * ((BlockQueue.blockupdates * (1000 / BlockQueue.time) * 8) / 1000)));
|
||||
}
|
||||
public override void Help(Player p)
|
||||
{
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.SendMessage(p, "/bs [option] [option value] - Options for block speeds.");
|
||||
Player.SendMessage(p, "Options are: bs (blocks per interval), ts (interval in milliseconds), buf (toggles buffering), clear, net.");
|
||||
Player.SendMessage(p, "/bs net [2,4,8,12,16,20,24] - Presets, divide by 8 and times by 1000 to get blocks per second.");
|
||||
|
@ -36,10 +36,10 @@ namespace MCGalaxy.Commands
|
||||
if (who == null) { Player.SendMessage(p, "Could not find player"); return; }
|
||||
if (p != null && who.group.Permission >= p.group.Permission) { Player.SendMessage(p, "Cannot ban someone of the same rank"); return; }
|
||||
int minutes;
|
||||
try
|
||||
{
|
||||
minutes = int.Parse(message.Split(' ')[1]);
|
||||
} catch { Player.SendMessage(p, "Invalid minutes"); return; }
|
||||
if (!int.TryParse(message.Split(' ')[1], out minutes)) {
|
||||
Player.SendMessage(p, "Invalid minutes"); return;
|
||||
}
|
||||
|
||||
if (minutes > 1440) { Player.SendMessage(p, "Cannot ban for more than a day"); return; }
|
||||
if (minutes < 1) { Player.SendMessage(p, "Cannot ban someone for less than a minute"); return; }
|
||||
|
||||
|
@ -29,32 +29,23 @@ namespace MCGalaxy.Commands
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
|
||||
public static int randomizer = 0;
|
||||
public static bool[,] wall;
|
||||
public override void Use(Player p, string message)
|
||||
{
|
||||
String[] split = message.Split(' ');
|
||||
if (split.Length >= 1&&message.Length>0)
|
||||
{
|
||||
try
|
||||
{
|
||||
randomizer = int.Parse(split[0]);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
this.Help(p); return;
|
||||
}
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (message.Length > 0 && !int.TryParse(message, out randomizer)) {
|
||||
Help(p); return;
|
||||
}
|
||||
Player.SendMessage(p, "Place two blocks to determine the edges");
|
||||
|
||||
|
||||
Player.SendMessage(p, "Place two blocks to determine the edges");
|
||||
p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
|
||||
}
|
||||
public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type, byte extType)
|
||||
{
|
||||
|
||||
void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
|
||||
RevertAndClearState(p, x, y, z);
|
||||
p.blockchangeObject = new CatchPos(x, y, z);
|
||||
p.Blockchange += new Player.BlockchangeEventHandler(Blockchange2);
|
||||
}
|
||||
public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType)
|
||||
{
|
||||
|
||||
void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
|
||||
RevertAndClearState(p, x, y, z);
|
||||
|
||||
CatchPos first = (CatchPos)p.blockchangeObject;
|
||||
@ -178,11 +169,7 @@ namespace MCGalaxy.Commands
|
||||
rand.GetBytes(r);
|
||||
r[0] /= (255 / 4);
|
||||
break;
|
||||
case 1:
|
||||
r[0] = (byte)rand2.Next(4);
|
||||
break;
|
||||
default:
|
||||
Random rand3 = new Random(Environment.TickCount);
|
||||
r[0] = (byte)rand2.Next(4);
|
||||
break;
|
||||
}
|
||||
|
@ -197,9 +197,9 @@ namespace MCGalaxy.Commands
|
||||
|
||||
if (b == undo.newType || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava) {
|
||||
ushort x, y, z;
|
||||
int undoIndex = p.level.currentUndo;
|
||||
p.level.currentUndo = i;
|
||||
p.level.IntToPos(undo.location, out x, out y, out z);
|
||||
int undoIndex = p.level.currentUndo;
|
||||
p.level.currentUndo = i;
|
||||
p.level.currentUndo = undoIndex;
|
||||
p.level.Blockchange(x, y, z, undo.oldType, true, "", undo.oldExtType, false);
|
||||
}
|
||||
|
@ -75,11 +75,9 @@ namespace MCGalaxy.Commands
|
||||
else
|
||||
{
|
||||
int zoneID;
|
||||
try
|
||||
{
|
||||
zoneID = int.Parse(message);
|
||||
if (!int.TryParse(message, out zoneID)) {
|
||||
Help(p); return;
|
||||
}
|
||||
catch { Help(p); return; }
|
||||
|
||||
if (zoneID < 0 || zoneID > p.level.ZoneList.Count)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user