-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIClient.cs
More file actions
154 lines (135 loc) · 6.54 KB
/
IClient.cs
File metadata and controls
154 lines (135 loc) · 6.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
///////////////////////////////////////////////////////////////////
// This file contains modified code from 'Bukkit'
// https://github.com/Bukkit/Bukkit
// which is released under GNU General Public License v3.0.
// https://www.gnu.org/licenses/gpl-3.0.en.html
// Copyright 2021 Bukkit Team
///////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using API.Client;
using API.Database;
using API.Inventory;
using API.Logger;
using API.Network;
using API.Network.Web;
using API.Plugins.Interfaces;
using API.Sheet;
namespace API
{
/// <summary>
/// Represents a client implementation.
/// </summary>
public interface IClient
{
/// <summary>
/// Returns the primary logger associated with this client instance.
/// </summary>
/// <returns>Logger associated with this client</returns>
ILogger GetLogger();
/// <summary>
/// Returns the network manager which controls the connection to the ryzom server.
/// </summary>
/// <returns>network manager associated with this client</returns>
INetworkManager GetApiNetworkManager();
/// <summary>
/// Returns the management for dynamically generated text from servers
/// </summary>
/// <returns>management for dynamically generated text</returns>
IStringManager GetApiStringManager();
/// <summary>
/// Returns the class that encapsulates the separate client database components
/// </summary>
/// <returns>the client database manager</returns>
IDatabaseManager GetApiDatabaseManager();
/// <summary>
/// Returns the manager for all plugins of the client
/// </summary>
/// <returns>manager for all plugins</returns>
IPluginManager GetPluginManager();
/// <summary>
/// Returns the class that manages all sheets
/// </summary>
/// <returns>Class to manage all sheets</returns>
ISheetManager GetApiSheetManager();
/// <summary>
/// Returns the class that can generate sheets from strings and numbers
/// </summary>
/// <returns>Factory for SheetIds from names and ids</returns>
ISheetIdFactory GetApiSheetIdFactory();
/// <summary>
/// Returns the class that gives direct access to inventory slots (bag, hands, and equip inventory).
/// </summary>
/// <returns>Class to manage inventory slots</returns>
IInventoryManager GetApiInventoryManager();
/// <summary>
/// Returns the class that can request websites and images from the web.
/// </summary>
/// <returns>Class to request websites and images from the web.</returns>
IWebTransfer GetWebTransfer();
/// <summary>
/// Online State
/// </summary>
/// <returns>true when the client has entered a game and is online</returns>
bool IsInGame();
/// <summary>
/// Checks if a command (including aliases) is registered.
/// </summary>
/// <param name="command">The command string (can include arguments).</param>
/// <returns>True if the command exists, false otherwise.</returns>
bool IsValidCommand(string command);
/// <summary>
/// Perform an internal RCC command (not a server command, use SendText() instead for that!)
/// </summary>
/// <param name="command">The command</param>
/// <param name="responseMsg">May contain a confirmation or error message after processing the command, or "" otherwise.</param>
/// <param name="localVars">Local variables passed along with the command</param>
/// <returns>true if the command was indeed an internal RCC command</returns>
bool PerformInternalCommand(string command, out string responseMsg, Dictionary<string, object> localVars = null);
/// <summary>
/// Register a command in command prompt. Command will be automatically unregistered when unloading the Plugin.
/// </summary>
/// <param name="cmdName">Name of the command</param>
/// <param name="cmdDesc">Description/usage of the command</param>
/// <param name="cmdUsage">Usage example</param>
/// <param name="callback">Method for handling the command</param>
/// <returns>True if successfully registered</returns>
bool RegisterCommand(string cmdName, string cmdDesc, string cmdUsage, CommandRunner callback);
/// <summary>
/// Returns a formatted string listing all available commands with their arguments and descriptions
/// </summary>
/// <returns>Formatted string with command information</returns>
string ListAllCommands();
/// <summary>
/// CommandBase runner definition.
/// Returned string will be the output of the command
/// </summary>
/// <param name="command">Full command</param>
/// <param name="args">Arguments in the command</param>
/// <returns>CommandBase result to display to the user</returns>
delegate string CommandRunner(string command, string[] args);
/// <summary>
/// Invoke a task on the main thread and wait for completion
/// </summary>
/// <param name="task">Task to run without return value</param>
/// <example>InvokeOnMainThread(methodThatReturnsNothing);</example>
/// <example>InvokeOnMainThread(() => methodThatReturnsNothing(argument));</example>
/// <example>InvokeOnMainThread(() => { yourCode(); });</example>
void InvokeOnMainThread(Action task);
/// <summary>
/// Invoke a task on the main thread, wait for completion and retrieve return value.
/// </summary>
/// <param name="task">Task to run with any type or return value</param>
/// <returns>Any result returned from task, result type is inferred from the task</returns>
/// <example>bool result = InvokeOnMainThread(methodThatReturnsAbool);</example>
/// <example>bool result = InvokeOnMainThread(() => methodThatReturnsAbool(argument));</example>
/// <example>int result = InvokeOnMainThread(() => { yourCode(); return 42; });</example>
/// <typeparam name="T">Type of the return value</typeparam>
T InvokeOnMainThread<T>(Func<T> task);
/// <summary>
/// Send a chat message or command to the server (Enqueues messages)
/// </summary>
/// <param name="text">Text to send to the server</param>
void SendText(string text);
}
}