-
Notifications
You must be signed in to change notification settings - Fork 19
Fix major issues and perms #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
efc50a9
455e54c
690602e
93b216d
d12d152
aa00180
ca97025
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -568,3 +568,5 @@ fabric.properties | |
# End of https://www.gitignore.io/api/rider,csharp,visualstudio | ||
|
||
.DS_Store | ||
|
||
*.bat |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
using Uchu.Core; | ||
using Uchu.World.Scripting.Managed; | ||
using Uchu.World.Social; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace Uchu.World.Handlers.Commands | ||
{ | ||
|
@@ -236,5 +237,57 @@ public string Target(string[] arguments, Player player) | |
|
||
return $"Target: {baseCombatAiComponent.Target}"; | ||
} | ||
|
||
|
||
[CommandHandler(Signature = "execute", Help = "Execute a command as another player", GameMasterLevel = GameMasterLevel.Admin)] | ||
public async Task<string> Execute(string[] arguments, Player executor) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd appreciate a doc string here with maybe some example usage |
||
{ | ||
List<Player> players = new List<Player>(); | ||
if (arguments[0] == "*") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code in this block doesn't adhere to the overall Uchu / C# style, we generally do:
and
|
||
foreach (var player in executor.Zone.Players) { | ||
players.Add(player); | ||
} | ||
} else { | ||
var player = executor.Zone.Players.FirstOrDefault(p => p.Name == arguments[0]); // This throws an error if no character is found :shrug: | ||
if (player == default) return $"No player named {arguments[0]}"; | ||
players.Add(player); | ||
} | ||
|
||
await using var ctx = new UchuContext(); | ||
var character = await ctx.Characters.Include(c => c.User).FirstAsync( | ||
c => c.Id == executor.Id | ||
); | ||
|
||
var _com = new List<string>(arguments); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bit of a odd variable name, if you meant command I would just use |
||
_com.RemoveAt(0); | ||
|
||
var message = string.Join(" ", _com); | ||
|
||
if (!message.StartsWith('/')) { | ||
message = "/" + message; | ||
} | ||
|
||
if (!SocialHandler.ClientCommands.Contains(message.Split(" ").ElementAt(0)) && message.Split(" ").ElementAt(0) != "/execute" && message.Length > 1) { | ||
foreach (Player player in players) { | ||
player.SendChatMessage("You feel a magical power...", PlayerChatChannel.Normal); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lol I like this little extra |
||
var response = await UchuServer.HandleCommandAsync( | ||
message, player, (GameMasterLevel)character.User.GameMasterLevel | ||
); | ||
|
||
if (!string.IsNullOrWhiteSpace(response)) { | ||
//executor.SendChatMessage($"{player.Name}: {response}", PlayerChatChannel.Normal); | ||
player.SendChatMessage(response, PlayerChatChannel.Normal); | ||
} | ||
} | ||
|
||
return $"Executed \"{message}\" as {players.Count} {(players.Count == 1 ? "person" : "people")}"; | ||
} | ||
else | ||
{ | ||
return $"Unable to execute \"{message}\""; | ||
} | ||
|
||
return "Failed to execute command"; | ||
} | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nitpicky but we generally only use double slash comments inline and use triple slash comments for doc strings