mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 20:15:35 -04:00
Remove /client commands (pointless when you can just do /client), have all commands enabled in both multiplayer and singleplayer modes. (But singleplayer only commands will show 'disabled' in multiplayer)
This commit is contained in:
parent
bd04b98508
commit
83d21d1daf
@ -146,7 +146,7 @@
|
|||||||
<Compile Include="Blocks\BlockInfo.Culling.cs" />
|
<Compile Include="Blocks\BlockInfo.Culling.cs" />
|
||||||
<Compile Include="Blocks\BlockInfo.Atlas.cs" />
|
<Compile Include="Blocks\BlockInfo.Atlas.cs" />
|
||||||
<Compile Include="Blocks\DefaultSet.cs" />
|
<Compile Include="Blocks\DefaultSet.cs" />
|
||||||
<Compile Include="Commands\SinglePlayerCommands.cs" />
|
<Compile Include="Commands\Commands.cs" />
|
||||||
<Compile Include="Entities\Components\IInterpComponent.cs" />
|
<Compile Include="Entities\Components\IInterpComponent.cs" />
|
||||||
<Compile Include="Entities\Mobs\AI.cs" />
|
<Compile Include="Entities\Mobs\AI.cs" />
|
||||||
<Compile Include="Entities\Components\AnimatedComponent.cs" />
|
<Compile Include="Entities\Components\AnimatedComponent.cs" />
|
||||||
@ -222,8 +222,6 @@
|
|||||||
<Compile Include="GraphicsAPI\Direct3D9Api.cs" />
|
<Compile Include="GraphicsAPI\Direct3D9Api.cs" />
|
||||||
<Compile Include="GraphicsAPI\IGraphicsApi.cs" />
|
<Compile Include="GraphicsAPI\IGraphicsApi.cs" />
|
||||||
<Compile Include="GraphicsAPI\OpenGLApi.cs" />
|
<Compile Include="GraphicsAPI\OpenGLApi.cs" />
|
||||||
<Compile Include="Commands\Command.cs" />
|
|
||||||
<Compile Include="Commands\DefaultCommands.cs" />
|
|
||||||
<Compile Include="GraphicsAPI\VertexFormats.cs" />
|
<Compile Include="GraphicsAPI\VertexFormats.cs" />
|
||||||
<Compile Include="Hotkeys\HotkeyList.cs" />
|
<Compile Include="Hotkeys\HotkeyList.cs" />
|
||||||
<Compile Include="Hotkeys\LwjglToKey.cs" />
|
<Compile Include="Hotkeys\LwjglToKey.cs" />
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
// Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace ClassicalSharp.Commands {
|
|
||||||
|
|
||||||
/// <summary> Represents a client side action that optionally accepts arguments. </summary>
|
|
||||||
public abstract class Command {
|
|
||||||
|
|
||||||
/// <summary> Full command name, note that the user does not
|
|
||||||
/// have to fully type this into chat. </summary>
|
|
||||||
public string Name;
|
|
||||||
|
|
||||||
/// <summary> Provides help about the purpose and syntax of this
|
|
||||||
/// command. Can use colour codes. </summary>
|
|
||||||
public string[] Help;
|
|
||||||
|
|
||||||
protected internal Game game;
|
|
||||||
|
|
||||||
public abstract void Execute(string[] args);
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,6 +4,16 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace ClassicalSharp.Commands {
|
namespace ClassicalSharp.Commands {
|
||||||
|
|
||||||
|
/// <summary> Represents a client side action that optionally accepts arguments. </summary>
|
||||||
|
public abstract class Command {
|
||||||
|
public string Name;
|
||||||
|
public string[] Help;
|
||||||
|
public bool SingleplayerOnly;
|
||||||
|
protected internal Game game;
|
||||||
|
|
||||||
|
public abstract void Execute(string[] args);
|
||||||
|
}
|
||||||
|
|
||||||
public class CommandList : IGameComponent {
|
public class CommandList : IGameComponent {
|
||||||
|
|
||||||
const string prefix = "/client";
|
const string prefix = "/client";
|
||||||
@ -19,13 +29,10 @@ namespace ClassicalSharp.Commands {
|
|||||||
public List<Command> RegisteredCommands = new List<Command>();
|
public List<Command> RegisteredCommands = new List<Command>();
|
||||||
public void Init(Game game) {
|
public void Init(Game game) {
|
||||||
this.game = game;
|
this.game = game;
|
||||||
Register(new CommandsCommand());
|
|
||||||
Register(new GpuInfoCommand());
|
Register(new GpuInfoCommand());
|
||||||
Register(new HelpCommand());
|
Register(new HelpCommand());
|
||||||
Register(new RenderTypeCommand());
|
Register(new RenderTypeCommand());
|
||||||
Register(new ResolutionCommand());
|
Register(new ResolutionCommand());
|
||||||
|
|
||||||
if (!game.Server.IsSinglePlayer) return;
|
|
||||||
Register(new ModelCommand());
|
Register(new ModelCommand());
|
||||||
Register(new CuboidCommand());
|
Register(new CuboidCommand());
|
||||||
Register(new TeleportCommand());
|
Register(new TeleportCommand());
|
||||||
@ -38,11 +45,6 @@ namespace ClassicalSharp.Commands {
|
|||||||
|
|
||||||
public void Register(Command command) {
|
public void Register(Command command) {
|
||||||
command.game = game;
|
command.game = game;
|
||||||
for (int i = 0; i < RegisteredCommands.Count; i++) {
|
|
||||||
Command cmd = RegisteredCommands[i];
|
|
||||||
if (Utils.CaselessEquals(cmd.Name, command.Name))
|
|
||||||
throw new InvalidOperationException("Another command already has name : " + command.Name);
|
|
||||||
}
|
|
||||||
RegisteredCommands.Add(command);
|
RegisteredCommands.Add(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,8 +61,15 @@ namespace ClassicalSharp.Commands {
|
|||||||
match = cmd;
|
match = cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match == null)
|
if (match == null) {
|
||||||
game.Chat.Add("&e/client: Unrecognised command: \"&f" + cmdName + "&e\".");
|
game.Chat.Add("&e/client: Unrecognised command: \"&f" + cmdName + "&e\".");
|
||||||
|
game.Chat.Add("&e/client: Type &a/client &efor a list of commands.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (match.SingleplayerOnly && !game.Server.IsSinglePlayer) {
|
||||||
|
game.Chat.Add("&e/client: \"&f" + cmdName + "&e\" can only be used in singleplayer.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +84,7 @@ namespace ClassicalSharp.Commands {
|
|||||||
if (text.Length == 0) { // only / or /client
|
if (text.Length == 0) { // only / or /client
|
||||||
game.Chat.Add("&eList of client commands:");
|
game.Chat.Add("&eList of client commands:");
|
||||||
PrintDefinedCommands(game);
|
PrintDefinedCommands(game);
|
||||||
game.Chat.Add("&eTo see a particular command's help, type /client help [cmd name]");
|
game.Chat.Add("&eTo see a particular command's help, type &a/client help [cmd name]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
// Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
|
// Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using ClassicalSharp.Entities;
|
using ClassicalSharp.Entities;
|
||||||
using ClassicalSharp.Events;
|
using ClassicalSharp.Events;
|
||||||
using ClassicalSharp.Renderers;
|
using ClassicalSharp.Renderers;
|
||||||
using OpenTK.Input;
|
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
using OpenTK.Input;
|
||||||
#if USE16_BIT
|
#if USE16_BIT
|
||||||
using BlockID = System.UInt16;
|
using BlockID = System.UInt16;
|
||||||
#else
|
#else
|
||||||
@ -16,6 +16,99 @@ using BlockID = System.Byte;
|
|||||||
|
|
||||||
namespace ClassicalSharp.Commands {
|
namespace ClassicalSharp.Commands {
|
||||||
|
|
||||||
|
public sealed class HelpCommand : Command {
|
||||||
|
|
||||||
|
public HelpCommand() {
|
||||||
|
Name = "Help";
|
||||||
|
Help = new string[] {
|
||||||
|
"&a/client help [command name]",
|
||||||
|
"&eDisplays the help for the given command.",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Execute(string[] args) {
|
||||||
|
if (args.Length == 1) {
|
||||||
|
game.Chat.Add("&eList of client commands:");
|
||||||
|
game.CommandList.PrintDefinedCommands(game);
|
||||||
|
game.Chat.Add("&eTo see a particular command's help, type /client help [cmd name]");
|
||||||
|
} else {
|
||||||
|
Command cmd = game.CommandList.GetMatch(args[1]);
|
||||||
|
if (cmd == null) return;
|
||||||
|
string[] help = cmd.Help;
|
||||||
|
for (int i = 0; i < help.Length; i++)
|
||||||
|
game.Chat.Add(help[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class GpuInfoCommand : Command {
|
||||||
|
|
||||||
|
public GpuInfoCommand() {
|
||||||
|
Name = "GpuInfo";
|
||||||
|
Help = new string[] {
|
||||||
|
"&a/client gpuinfo",
|
||||||
|
"&eDisplays information about your GPU.",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Execute(string[] args) {
|
||||||
|
string[] lines = game.Graphics.ApiInfo;
|
||||||
|
for (int i = 0; i < lines.Length; i++)
|
||||||
|
game.Chat.Add("&a" + lines[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class RenderTypeCommand : Command {
|
||||||
|
|
||||||
|
public RenderTypeCommand() {
|
||||||
|
Name = "RenderType";
|
||||||
|
Help = new string[] {
|
||||||
|
"&a/client rendertype [normal/legacy/legacyfast]",
|
||||||
|
"&bnormal: &eDefault renderer, with all environmental effects enabled.",
|
||||||
|
"&blegacy: &eMay be slightly slower than normal, but produces the same environmental effects.",
|
||||||
|
"&blegacyfast: &eSacrifices clouds, fog and overhead sky for faster performance.",
|
||||||
|
"&bnormalfast: &eSacrifices clouds, fog and overhead sky for faster performance.",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Execute(string[] args) {
|
||||||
|
if (args.Length == 1) {
|
||||||
|
game.Chat.Add("&e/client: &cYou didn't specify a new render type.");
|
||||||
|
} else if (game.SetRenderType(args[1])) {
|
||||||
|
game.Chat.Add("&e/client: &fRender type is now " + args[1] + ".");
|
||||||
|
} else {
|
||||||
|
game.Chat.Add("&e/client: &cUnrecognised render type &f\"" + args[1] + "\"&c.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class ResolutionCommand : Command {
|
||||||
|
|
||||||
|
public ResolutionCommand() {
|
||||||
|
Name = "Resolution";
|
||||||
|
Help = new string[] {
|
||||||
|
"&a/client resolution [width] [height]",
|
||||||
|
"&ePrecisely sets the size of the rendered window.",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Execute(string[] args) {
|
||||||
|
int width, height;
|
||||||
|
if (args.Length < 3) {
|
||||||
|
game.Chat.Add("&e/client: &cYou didn't specify width and height");
|
||||||
|
} else if (!Int32.TryParse(args[1], out width) || !Int32.TryParse(args[2], out height)) {
|
||||||
|
game.Chat.Add("&e/client: &cWidth and height must be integers.");
|
||||||
|
} else if (width <= 0 || height <= 0) {
|
||||||
|
game.Chat.Add("&e/client: &cWidth and height must be above 0.");
|
||||||
|
} else {
|
||||||
|
game.window.ClientSize = new Size(width, height);
|
||||||
|
Options.Set(OptionsKey.WindowWidth, width);
|
||||||
|
Options.Set(OptionsKey.WindowHeight, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public sealed class ModelCommand : Command {
|
public sealed class ModelCommand : Command {
|
||||||
|
|
||||||
public ModelCommand() {
|
public ModelCommand() {
|
||||||
@ -25,6 +118,7 @@ namespace ClassicalSharp.Commands {
|
|||||||
"&bnames: &echibi, chicken, creeper, human, pig, sheep",
|
"&bnames: &echibi, chicken, creeper, human, pig, sheep",
|
||||||
"&e skeleton, spider, zombie, sitting, <numerical block id>",
|
"&e skeleton, spider, zombie, sitting, <numerical block id>",
|
||||||
};
|
};
|
||||||
|
SingleplayerOnly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Execute(string[] args) {
|
public override void Execute(string[] args) {
|
||||||
@ -47,6 +141,7 @@ namespace ClassicalSharp.Commands {
|
|||||||
"&e If persist is given and is \"yes\", then the command",
|
"&e If persist is given and is \"yes\", then the command",
|
||||||
"&e will repeatedly cuboid, without needing to be typed in again.",
|
"&e will repeatedly cuboid, without needing to be typed in again.",
|
||||||
};
|
};
|
||||||
|
SingleplayerOnly = true;
|
||||||
}
|
}
|
||||||
int block = -1;
|
int block = -1;
|
||||||
Vector3I mark1, mark2;
|
Vector3I mark1, mark2;
|
||||||
@ -126,11 +221,12 @@ namespace ClassicalSharp.Commands {
|
|||||||
public sealed class TeleportCommand : Command {
|
public sealed class TeleportCommand : Command {
|
||||||
|
|
||||||
public TeleportCommand() {
|
public TeleportCommand() {
|
||||||
Name = "Teleport";
|
Name = "TP";
|
||||||
Help = new string[] {
|
Help = new string[] {
|
||||||
"&a/client teleport [x y z]",
|
"&a/client tp [x y z]",
|
||||||
"&eMoves you to the given coordinates.",
|
"&eMoves you to the given coordinates.",
|
||||||
};
|
};
|
||||||
|
SingleplayerOnly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Execute(string[] args) {
|
public override void Execute(string[] args) {
|
@ -1,120 +0,0 @@
|
|||||||
// Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Text;
|
|
||||||
using ClassicalSharp.Renderers;
|
|
||||||
using OpenTK.Input;
|
|
||||||
|
|
||||||
namespace ClassicalSharp.Commands {
|
|
||||||
|
|
||||||
/// <summary> Command that displays the list of all currently registered client commands. </summary>
|
|
||||||
public sealed class CommandsCommand : Command {
|
|
||||||
|
|
||||||
public CommandsCommand() {
|
|
||||||
Name = "Commands";
|
|
||||||
Help = new string[] {
|
|
||||||
"&a/client commands",
|
|
||||||
"&ePrints a list of all usable commands"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Execute(string[] args) {
|
|
||||||
game.CommandList.PrintDefinedCommands(game);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Command that displays information about an input client command. </summary>
|
|
||||||
public sealed class HelpCommand : Command {
|
|
||||||
|
|
||||||
public HelpCommand() {
|
|
||||||
Name = "Help";
|
|
||||||
Help = new string[] {
|
|
||||||
"&a/client help [command name]",
|
|
||||||
"&eDisplays the help for the given command.",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Execute(string[] args) {
|
|
||||||
if (args.Length == 1) {
|
|
||||||
game.Chat.Add("&eList of client commands:");
|
|
||||||
game.CommandList.PrintDefinedCommands(game);
|
|
||||||
game.Chat.Add("&eTo see a particular command's help, type /client help [cmd name]");
|
|
||||||
} else {
|
|
||||||
Command cmd = game.CommandList.GetMatch(args[1]);
|
|
||||||
if (cmd == null) return;
|
|
||||||
string[] help = cmd.Help;
|
|
||||||
for (int i = 0; i < help.Length; i++)
|
|
||||||
game.Chat.Add(help[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Command that displays information about the user's GPU. </summary>
|
|
||||||
public sealed class GpuInfoCommand : Command {
|
|
||||||
|
|
||||||
public GpuInfoCommand() {
|
|
||||||
Name = "GpuInfo";
|
|
||||||
Help = new string[] {
|
|
||||||
"&a/client gpuinfo",
|
|
||||||
"&eDisplays information about your GPU.",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Execute(string[] args) {
|
|
||||||
string[] lines = game.Graphics.ApiInfo;
|
|
||||||
for (int i = 0; i < lines.Length; i++)
|
|
||||||
game.Chat.Add("&a" + lines[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public sealed class RenderTypeCommand : Command {
|
|
||||||
|
|
||||||
public RenderTypeCommand() {
|
|
||||||
Name = "RenderType";
|
|
||||||
Help = new string[] {
|
|
||||||
"&a/client rendertype [normal/legacy/legacyfast]",
|
|
||||||
"&bnormal: &eDefault renderer, with all environmental effects enabled.",
|
|
||||||
"&blegacy: &eMay be slightly slower than normal, but produces the same environmental effects.",
|
|
||||||
"&blegacyfast: &eSacrifices clouds, fog and overhead sky for faster performance.",
|
|
||||||
"&bnormalfast: &eSacrifices clouds, fog and overhead sky for faster performance.",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Execute(string[] args) {
|
|
||||||
if (args.Length == 1) {
|
|
||||||
game.Chat.Add("&e/client: &cYou didn't specify a new render type.");
|
|
||||||
} else if (game.SetRenderType(args[1])) {
|
|
||||||
game.Chat.Add("&e/client: &fRender type is now " + args[1] + ".");
|
|
||||||
} else {
|
|
||||||
game.Chat.Add("&e/client: &cUnrecognised render type &f\"" + args[1] + "\"&c.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public sealed class ResolutionCommand : Command {
|
|
||||||
|
|
||||||
public ResolutionCommand() {
|
|
||||||
Name = "Resolution";
|
|
||||||
Help = new string[] {
|
|
||||||
"&a/client resolution [width] [height]",
|
|
||||||
"&ePrecisely sets the size of the rendered window.",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Execute(string[] args) {
|
|
||||||
int width, height;
|
|
||||||
if (args.Length < 3) {
|
|
||||||
game.Chat.Add("&e/client: &cYou didn't specify width and height");
|
|
||||||
} else if (!Int32.TryParse(args[1], out width) || !Int32.TryParse(args[2], out height)) {
|
|
||||||
game.Chat.Add("&e/client: &cWidth and height must be integers.");
|
|
||||||
} else if (width <= 0 || height <= 0) {
|
|
||||||
game.Chat.Add("&e/client: &cWidth and height must be above 0.");
|
|
||||||
} else {
|
|
||||||
game.window.ClientSize = new Size(width, height);
|
|
||||||
Options.Set(OptionsKey.WindowWidth, width);
|
|
||||||
Options.Set(OptionsKey.WindowHeight, height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user