Empeld
Empeld plugin documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
essentials.Subsystems.Chat.UserManagerChatPlugin Class Reference
Inheritance diagram for essentials.Subsystems.Chat.UserManagerChatPlugin:
essentials.Subsystems.Chat.IChatCommandHandler

Public Member Functions

 UserManagerChatPlugin (IChatServer chat)
 
bool Handle (IUser fromUser, string command, string[] args)
 

Properties

IUserManager UserManager [get]
 
IEntityManager EntityManager [get]
 

Constructor & Destructor Documentation

essentials.Subsystems.Chat.UserManagerChatPlugin.UserManagerChatPlugin ( IChatServer  chat)
20  {
21  this.InjectDependencies();
22  _chat = chat;
23  }

Member Function Documentation

bool essentials.Subsystems.Chat.UserManagerChatPlugin.Handle ( IUser  fromUser,
string  command,
string[]  args 
)

Attribute: 0

);

Attribute: 0

);

Attribute: 0

);

Attribute: 0

, UserAuthLevel.Moderator);

Attribute: 0

);

Attribute: 0

, "You are now a moderator. It will take affect after rejoining");

Attribute: 0

, UserAuthLevel.Moderator);

Attribute: 0

);

Attribute: 0

, "You have been op'd. It will take affect after rejoining.");

Attribute: 0

, UserAuthLevel.Normal);

Attribute: 0

);

Attribute: 0

);

Attribute: 0

);

Attribute: 0

);

Attribute: 0

);

Attribute: 0

);

Attribute: 1

);

Attribute: 2

);

Attribute: 0

);

Implements essentials.Subsystems.Chat.IChatCommandHandler.

26  {
27  if (fromUser.UserAuthenticationLevel >= UserAuthLevel.Moderator && args.Length >= 1)
28  {
29  var user = this.UserManager.GetUser(args[0]);
30 
31  switch(command)
32  {
33  case "kick":
34  // Kick, but only if the target user exists, and our auth level is >= theirs (So a mod can't kick an admin)
35  if(user != null)
36  {
37  if (fromUser.UserAuthenticationLevel >= user.UserAuthenticationLevel)
38  {
39  UserManager.Kick(user);
40  _chat.BroadcastSystemMessage("Kicked {0}", user.Username);
41  }
42  else
43  {
44  _chat.SendDirectedMessage(fromUser, "You aren't allowed to kick a superior");
45  _chat.SendDirectedMessage(user, "{0} tried to kick you", fromUser.Username);
46  }
47  }
48  return true;
49 
50  case "ban":
51  if (user != null)
52  {
53  if (fromUser.UserAuthenticationLevel >= user.UserAuthenticationLevel)
54  {
55  UserManager.Ban(user);
56  _chat.BroadcastSystemMessage("Banned {0}", user.Username);
57  }
58  else
59  {
60  _chat.SendDirectedMessage(fromUser, "You aren't allowed to ban a superior");
61  _chat.SendDirectedMessage(user, "{0} tried to ban you", fromUser.Username);
62  }
63  }
64  return true;
65 
66  case "unban":
67  UserManager.Unban(args[0]);
68  _chat.SendDirectedMessage(fromUser, "Unbanned {0}", args[0]);
69  return true;
70 
71  case "mod":
72  UserManager.SetUserLevel(args[0], UserAuthLevel.Moderator);
73  _chat.BroadcastSystemMessage("{0} is now a moderator", args[0]);
74  _chat.SendDirectedMessage(args[0], "You are now a moderator. It will take affect after rejoining");
75  return true;
76 
77  case "op":
78  UserManager.SetUserLevel(args[0], UserAuthLevel.Moderator);
79  _chat.BroadcastSystemMessage("Op gifted to {0}", args[0]);
80  _chat.SendDirectedMessage(args[0], "You have been op'd. It will take affect after rejoining.");
81  return true;
82 
83  case "deop":
84  UserManager.SetUserLevel(args[0], UserAuthLevel.Normal);
85  _chat.BroadcastSystemMessage("Deop {0}", args[0]);
86  return true;
87 
88  case "whitelist":
89  UserManager.Whitelist(args[0]);
90  _chat.BroadcastSystemMessage("Whitelisted {0}", args[0]);
91  return true;
92 
93  case "unwhitelist":
94  UserManager.UnWhitelist(args[0]);
95  _chat.BroadcastSystemMessage("Un-whitelisted {0}", args[0]);
96  return true;
97 
98  case "tp":
99  try
100  {
101  double x = double.Parse(args[0]);
102  double y = double.Parse(args[1]);
103  double z = double.Parse(args[2]);
104 
105  var entity = this.EntityManager.GetClientPrimaryEntity(fromUser);
106  if (entity != null)
107  {
108  entity.SetPosition(x,y,z);
109  }
110  }
111  catch
112  {
113  _chat.SendDirectedMessage(fromUser, "Error teleporting");
114  }
115  return true;
116 
117  case "tpto":
118  try
119  {
120  var entity = this.EntityManager.GetClientPrimaryEntity(fromUser);
121  var toEntity = this.EntityManager.GetClientPrimaryEntity(user);
122  if (toEntity != null)
123  {
124  var coord = toEntity.Position;
125  entity.SetPosition(coord.X, coord.Y, coord.Z);
126  }
127  else
128  {
129  _chat.SendDirectedMessage(fromUser, "Unable to teleport to {0}", args[0]);
130  }
131  }
132  catch
133  {
134  _chat.SendDirectedMessage(fromUser, "Error teleporting to someone");
135  }
136  return true;
137  }
138  }
139  return false;
140  }
void SetPosition(double x, double y, double z)
Sets the position.
IUserManager UserManager
Definition: UserManagerChatPlugin.cs:12
void Whitelist(string username)
void SendDirectedMessage(string username, string msg, params object[] args)
IPlayableEntity GetClientPrimaryEntity(ushort ident)
Get the playable entity for a client Id
void BroadcastSystemMessage(string msg, params object[] args)
void UnWhitelist(string username)
UserAuthLevel UserAuthenticationLevel
The authentication level of a user
Definition: IUser.cs:44
void SetUserLevel(string username, UserAuthLevel level)
UserAuthLevel
User authentication level
Definition: UserAuthLevel.cs:8
string Username
The username of the user
Definition: IUser.cs:14
IEntityManager EntityManager
Definition: UserManagerChatPlugin.cs:15
Vector3d Position
Gets the position.
Definition: IPositionableEntity.cs:17

Property Documentation

IEntityManager essentials.Subsystems.Chat.UserManagerChatPlugin.EntityManager
getprotected

Attribute: Dependency

IUserManager essentials.Subsystems.Chat.UserManagerChatPlugin.UserManager
getprotected

Attribute: Dependency


The documentation for this class was generated from the following file: