RocketMod / Rocket.Unturned

Unturned 3 implementation of the RocketMod — .NET Game Server Plugin Framework
MIT License
84 stars 109 forks source link

Item Command #93

Open rube200 opened 5 years ago

rube200 commented 5 years ago

*Console* Rube200 has executed command: "i "revolver speed"" Chat Screen1 (2)

*Console* Rube200 has executed command: "i revolver speed" Chat Screen1 (3)

Error:

FormatException: Input string was not in a correct format. - System.Number.StringToNumber (System.String str, System.Globalization.NumberStyles options, System.Number+NumberBuffer& number, System.Globalization.NumberFormatInfo info, System.Boolean parseDecimal) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Number.ParseInt32 (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Byte.Parse (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Byte.Parse (System.String s, System.Globalization.NumberStyles style, System.IFormatProvider provider) (at <cfc149f8218b496788d8493c87de777a>:0)
System.ComponentModel.ByteConverter.FromString (System.String value, System.Globalization.NumberFormatInfo formatInfo) (at <a3bc56cd038446b2ba8027b187001bf8>:0)
System.ComponentModel.BaseNumberConverter.ConvertFrom (System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, System.Object value) (at <a3bc56cd038446b2ba8027b187001bf8>:0)
Rethrow as Exception: speed is not a valid value for Byte.
System.ComponentModel.BaseNumberConverter.ConvertFrom (System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, System.Object value) (at <a3bc56cd038446b2ba8027b187001bf8>:0)
Rocket.Core.Extensions.TypeConverterExtensions.ConvertFromWithContext (System.ComponentModel.TypeConverter converter, Rocket.API.DependencyInjection.IDependencyContainer container, System.Object value) (at <95672b3f871f49e49212672667f157c7>:0)
Rocket.Core.Commands.CommandParameters+<GetAsync>d__10.MoveNext () (at <95672b3f871f49e49212672667f157c7>:0)
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () (at <cfc149f8218b496788d8493c87de777a>:0)
Rocket.Core.Commands.CommandParameters+<GetAsync>d__9`1[T].MoveNext () (at <95672b3f871f49e49212672667f157c7>:0)
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () (at <cfc149f8218b496788d8493c87de777a>:0)
Rocket.Unturned.Commands.CommandItem+<ExecuteAsync>d__1.MoveNext () (at <e3161f39f5714336b872cca8807ff2e0>:0)
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.GetResult () (at <cfc149f8218b496788d8493c87de777a>:0)
Rocket.Core.Commands.ProxyCommand+<ExecuteAsync>d__18.MoveNext () (at <95672b3f871f49e49212672667f157c7>:0)
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.GetResult () (at <cfc149f8218b496788d8493c87de777a>:0)
Rocket.Core.Commands.DefaultCommandHandler+<HandleCommandAsync>d__2.MoveNext () (at <95672b3f871f49e49212672667f157c7>:0)
Rethrow as Exception: Command "i revolver speed" of user "Ôò¡Ôê®Ôò«(Ôÿ¡ ═£╩û Ôÿ¡)Ôò»Ôö╗Ôö╗" caused an exception:
Rocket.Core.Commands.DefaultCommandHandler+<HandleCommandAsync>d__2.MoveNext () (at <95672b3f871f49e49212672667f157c7>:0)
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () (at <cfc149f8218b496788d8493c87de777a>:0)
Rocket.Core.Commands.CommandHandlerProxy+<HandleCommandAsync>d__1.MoveNext () (at <95672b3f871f49e49212672667f157c7>:0)
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () (at <cfc149f8218b496788d8493c87de777a>:0)
Rocket.Unturned.RocketUnturnedHost+<>c__DisplayClass30_2+<<OnServerHosted>b__3>d.MoveNext () (at <e3161f39f5714336b872cca8807ff2e0>:0)
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Runtime.CompilerServices.TaskAwaiter.GetResult () (at <cfc149f8218b496788d8493c87de777a>:0)
Rocket.Unturned.RocketUnturnedHost+<>c__DisplayClass30_0.<OnServerHosted>b__0 (SDG.Unturned.SteamPlayer player, System.String commandLine, System.Boolean& shouldExecuteCommand, System.Boolean& shouldList) (at <e3161f39f5714336b872cca8807ff2e0>:0)
SDG.Unturned.ChatManager.process (SDG.Unturned.SteamPlayer player, System.String cmd) (at <1c60162165a4477d9588d3bbeccaf506>:0)
SDG.Unturned.ChatManager.askChat (Steamworks.CSteamID steamID, System.Byte mode, System.String text) (at <1c60162165a4477d9588d3bbeccaf506>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <cfc149f8218b496788d8493c87de777a>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <cfc149f8218b496788d8493c87de777a>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <cfc149f8218b496788d8493c87de777a>:0)
SDG.Unturned.SteamChannel.receive (Steamworks.CSteamID steamID, System.Byte[] packet, System.Int32 offset, System.Int32 size) (at <1c60162165a4477d9588d3bbeccaf506>:0)
UnityEngine.Debug:LogException(Exception)
SDG.Unturned.SteamChannel:receive(CSteamID, Byte[], Int32, Int32)
SDG.Unturned.Provider:receiveServer(CSteamID, Byte[], Int32, Int32, Int32)
SDG.Unturned.Provider:listenServer(Int32)
SDG.Unturned.Provider:listen()
SDG.Unturned.Provider:Update()
cartman-2000 commented 5 years ago

Without quotes it would "try" to parse speed as the second variable while only an amount is supported for it.

The line here gets the amount: https://github.com/RocketMod/Rocket.Unturned/blob/fa73a1c7a361a9039f81f7bb76652a1a429b185d/Rocket.Unturned/Commands/CommandItem.cs#L50

There could be a couple ways of fixing the trace, one could be to do a TryGet, the other would be probably the most simple one is to make a temp amount var as string, switch the type from the get line from byte to a string to put into the temp var then run an if statement on it checking for proper format(one file modified and only around 6-7 lines of code needing to be added/changed.).

Trojaner commented 5 years ago

cartman is right, beside that currently " " (strings with spaces) arguments are not implemented in RM5