Exemple #1
0
 public static void Exit()
 {
     Self.SendChat(ChatColors.Blue + "C# Interactive Mode disabled");
     Server.SettingsProvider.Set(Self.Username + ".repl.enabled", false);
     Evaluators.Remove(Self.Username);
     Self = null;
 }
Exemple #2
0
 public override void Execute(Server server, RemoteClient user, string text, params string[] parameters)
 {
     Server = server;
     if (parameters.Length != 0)
     {
         user.SendChat(ChatColors.Red + "Invalid parameters. Use /help repl for more information.");
         return;
     }
     if (ReplContext.Self != null)
     {
         user.SendChat(ChatColors.Red + ReplContext.Self.Username + " is currently in REPL mode. Only one user may be in REPL mode at a time.");
         // TODO: Upgrade Mono.CSharp to Mono 3.0 and support several REPLs at once
         return;
     }
     server.ChatMessage -= HandleChatMessage;
     server.ChatMessage += HandleChatMessage;
     server.MinecraftServer.PlayerLoggedOut += (s, e) =>
     {
         if (Evaluators.ContainsKey(e.Username))
         {
             Evaluators.Remove(e.Username);
         }
         ReplContext.Self = null;
     };
     Evaluators[user.Username] = new Evaluator(new CompilerContext(new CompilerSettings(), new MinecraftReportPrinter(user)));
     Evaluators[user.Username].ReferenceAssembly(typeof(Server).Assembly);
     Evaluators[user.Username].ReferenceAssembly(typeof(MinecraftServer).Assembly);
     Evaluators[user.Username].ReferenceAssembly(typeof(Craft.Net.Networking.IPacket).Assembly);
     Evaluators[user.Username].ReferenceAssembly(typeof(World).Assembly);
     Evaluators[user.Username].ReferenceAssembly(typeof(IServer).Assembly);
     Evaluators[user.Username].InteractiveBaseClass = typeof(ReplContext);
     Evaluators[user.Username].Run("using Craft.Net");
     Evaluators[user.Username].Run("using Craft.Net.Data");
     Evaluators[user.Username].Run("using Craft.Net.Data.Blocks");
     Evaluators[user.Username].Run("using Craft.Net.Data.Items");
     Evaluators[user.Username].Run("using Craft.Net.Server");
     Evaluators[user.Username].Run("using PartyCraft");
     ReplContext.Self   = user;
     ReplContext.Server = server;
     user.SendChat(ChatColors.Blue + "Entering C# Interactive Mode");
     user.SendChat(ChatColors.Blue + "Use `Exit()` to exit REPL mode.");
 }