@@ -18,18 +18,18 @@ public class CmdHelp : ClientCommand, ServerCommand

public void Use(Client client, string[] tokens)
{
if (tokens.Length == 1)
if (tokens.Length == 0)
{
client.SendMessage("Use " + ChatColor.Teal + "/help build" + ChatColor.White + " for a list of building commands.");
client.SendMessage("Use " + ChatColor.Teal + "/help mod" + ChatColor.White + " for a list of moderation commands.");
client.SendMessage("Use " + ChatColor.Teal + "/help information" + ChatColor.White + " for a list of information commands.");
client.SendMessage("Use " + ChatColor.Teal + "/help other" + ChatColor.White + " for a list of other commands.");
client.SendMessage("Use " + ChatColor.Teal + "/help short" + ChatColor.White + " for a list of shortcuts.");
}
else if (tokens.Length > 1)
else if (tokens.Length > 0)
{
string message;
switch (tokens[1].ToLower())
switch (tokens[0].ToLower())
{
case "build":
message = (from ClientCommand c in ClientCommandHandler.GetCommands() where c.Type == CommandType.Build && client.Owner.CanUseCommand(c) select c).Aggregate("", (current, c) => current + (", " + c.Name));
@@ -86,7 +86,7 @@ public void Use(Client client, string[] tokens)
ClientCommand cmd;
try
{
cmd = ClientCommandHandler.Find(tokens[1]) as ClientCommand;
cmd = ClientCommandHandler.Find(tokens[0]) as ClientCommand;
}
catch (CommandNotFoundException e) { client.SendMessage(e.Message); return; }
try
@@ -114,12 +114,12 @@ public void Use(Client client, string[] tokens)

public void Help(Client client)
{
client.SendMessage("WOW, really? Wow... just wow.");
client.SendMessage("helps");
}

public void Use(Server server, string[] tokens)
{
if (tokens.Length == 1)
if (tokens.Length == 0)
{

server.Logger.Log(Logger.LogLevel.Info, "Use /help build for a list of building commands.");
@@ -128,20 +128,13 @@ public void Use(Server server, string[] tokens)
server.Logger.Log(Logger.LogLevel.Info, "Use /help other for a list of other commands.");
server.Logger.Log(Logger.LogLevel.Info, "Use /help short for a list of shortcuts.");
}
else if (tokens.Length > 1)
else if (tokens.Length > 0)
{
string message;
switch (tokens[1].ToLower())
switch (tokens[0].ToLower())
{
case "build":
message = "";
foreach (ServerCommand c in ServerCommandHandler.GetCommands())
{
if (c.Type == CommandType.Build)
{
message += ", " + c.Name;
}
}
message = (from ServerCommand c in ServerCommandHandler.GetCommands() where c.Type == CommandType.Build select c).Aggregate("", (current, c) => current + (", " + c.Name));
if (message == "")
{
server.Logger.Log(Logger.LogLevel.Info, "There are no commands of this type that you can use.");
@@ -151,14 +144,7 @@ public void Use(Server server, string[] tokens)
server.Logger.Log(Logger.LogLevel.Info, message);
break;
case "mod":
message = "";
foreach (ServerCommand c in ServerCommandHandler.GetCommands())
{
if (c.Type == CommandType.Build)
{
message += ", " + c.Name;
}
}
message = (from ServerCommand c in ServerCommandHandler.GetCommands() where c.Type == CommandType.Build select c).Aggregate("", (current, c) => current + (", " + c.Name));
if (message == "")
{
server.Logger.Log(Logger.LogLevel.Info, "There are no commands of this type that you can use.");
@@ -169,14 +155,7 @@ public void Use(Server server, string[] tokens)
break;
case "information":
case "info":
message = "";
foreach (ServerCommand c in ServerCommandHandler.GetCommands())
{
if (c.Type == CommandType.Build)
{
message += ", " + c.Name;
}
}
message = (from ServerCommand c in ServerCommandHandler.GetCommands() where c.Type == CommandType.Build select c).Aggregate("", (current, c) => current + (", " + c.Name));
if (message == "")
{
server.Logger.Log(Logger.LogLevel.Info, "There are no commands of this type that you can use.");
@@ -186,14 +165,7 @@ public void Use(Server server, string[] tokens)
server.Logger.Log(Logger.LogLevel.Info, message);
break;
case "other":
message = "";
foreach (ServerCommand c in ServerCommandHandler.GetCommands())
{
if (c.Type == CommandType.Build)
{
message += ", " + c.Name;
}
}
message = (from ServerCommand c in ServerCommandHandler.GetCommands() where c.Type == CommandType.Build select c).Aggregate("", (current, c) => current + (", " + c.Name));
if (message == "")
{
server.Logger.Log(Logger.LogLevel.Info, "There are no commands of this type that you can use.");
@@ -203,14 +175,7 @@ public void Use(Server server, string[] tokens)
server.Logger.Log(Logger.LogLevel.Info, message);
break;
case "short":
message = "";
foreach (ServerCommand c in ServerCommandHandler.GetCommands())
{
if (!string.IsNullOrEmpty(c.Shortcut))
{
message += ", " + c.Shortcut;
}
}
message = (from ServerCommand c in ServerCommandHandler.GetCommands() where !string.IsNullOrEmpty(c.Shortcut) select c).Aggregate("", (current, c) => current + (", " + c.Shortcut));
if (message == "")
{
server.Logger.Log(Logger.LogLevel.Info, "There are no commands of this type that you can use.");
@@ -243,7 +208,7 @@ public void Use(Server server, string[] tokens)

public void Help(Server server)
{
server.Logger.Log(Logger.LogLevel.Info, "WOW, really? Wow... just wow.");
server.Logger.Log(Logger.LogLevel.Info, "helps");
}
}
}
@@ -94,12 +94,12 @@ internal virtual void OnClicked(WindowClickPacket packet)
}
else if (e.RightClick)
{ // Right-click in void: drop item
Owner.Server.DropItem(Owner.Client, new ItemStack(Cursor.Type, 1, Cursor.Durability));
Owner.Server.DropItem(Owner, new ItemStack(Cursor.Type, 1, Cursor.Durability));
Cursor.Count--;
}
else
{ // Left-click in void: drop stack
Owner.Server.DropItem(Owner.Client, Cursor);
Owner.Server.DropItem(Owner, Cursor);
Cursor = ItemStack.Void;
}
return;
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using Chraft.Entity;
using Chraft.Plugins.Events;
using Chraft.World;
@@ -134,10 +135,11 @@ public void ExecuteCommand(string command)

private void CommandProc(string raw, string[] tokens)
{
var cleanedTokens = tokens.Skip(1).ToArray();
ClientCommand cmd;
try
{
cmd = _Player.Server.ClientCommandHandler.Find(tokens[0]) as ClientCommand;
cmd = _Player.Server.ClientCommandHandler.Find(raw) as ClientCommand;
}
catch (CommandNotFoundException e)
{
@@ -147,29 +149,19 @@ private void CommandProc(string raw, string[] tokens)
try
{
//Event
ClientCommandEventArgs e = new ClientCommandEventArgs(this, cmd, tokens);
ClientCommandEventArgs e = new ClientCommandEventArgs(this, cmd, cleanedTokens);
_Player.Server.PluginManager.CallEvent(Event.PLAYER_COMMAND, e);
if (e.EventCanceled) return;
tokens = e.Tokens;
cleanedTokens = e.Tokens;
//End Event

cmd.Use(this, tokens);
cmd.Use(this, cleanedTokens);
}
catch (Exception e)
{
SendMessage("There was an error while executing the command.");
_Player.Server.Logger.Log(e);
}
}

public void SetHealth(string[] tokens)
{
if (tokens.Length < 1)
{
_Player.SetHealth(20);
return;
}
_Player.SetHealth(short.Parse(tokens[1]));
}
}
}
@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using Chraft.Net;
using Chraft.Net.Packets;
@@ -237,7 +237,12 @@ public static void HandlePacketCreativeInventoryAction(Client client, CreativeIn
}
else
{
client.Owner.Inventory[packet.Slot] = new ItemStack(packet.ItemID, (sbyte)packet.Quantity, packet.Damage);
if (packet.Slot != -1)// mouse cursor mode
{
client.Owner.Inventory[packet.Slot] = new ItemStack(packet.ItemID, (sbyte)packet.Quantity, packet.Damage);
}


}
else
client.Kick("Invalid action: CreativeInventoryAction");
@@ -168,6 +168,7 @@ public void Kick(string reason)
if (e.EventCanceled) return;
reason = e.Message;
//End Event
Save();
SendPacket(new DisconnectPacket
{
Reason = reason
@@ -176,6 +177,7 @@ public void Kick(string reason)

public void Disconnected(object sender, SocketAsyncEventArgs e)
{
Save();
// Just wait a bit since it's possible that we close the socket before the packet reached the client
Thread.Sleep(200);
Stop();