Add /kick
This commit is contained in:
parent
2f17ab4a5f
commit
52795a349f
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -1307,6 +1307,7 @@ commands.banlist.players=There are %d total banned players:
|
|||
commands.banlist.usage=/banlist [ips|players]
|
||||
commands.kick.success=Kicked %s from the game
|
||||
commands.kick.success.reason=Kicked %s from the game: '%s'
|
||||
commands.kick.owner=You cannot kick the world owner!
|
||||
commands.kick.usage=/kick <player> [reason ...]
|
||||
commands.op.success=Opped %s
|
||||
commands.op.usage=/op <player>
|
||||
|
|
35
sp-server/src/main/java/net/minecraft/src/CommandKick.java
Normal file
35
sp-server/src/main/java/net/minecraft/src/CommandKick.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
package net.minecraft.src;
|
||||
|
||||
public class CommandKick extends CommandBase {
|
||||
public String getCommandName() {
|
||||
return "kick";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the required permission level for this command.
|
||||
*/
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) {
|
||||
if (par2ArrayOfStr.length == 0) {
|
||||
throw new WrongUsageException("commands.kick.usage", new Object[0]);
|
||||
}
|
||||
EntityPlayerMP target = func_82359_c(par1ICommandSender, par2ArrayOfStr[0]);
|
||||
if (target.mcServer.getServerOwner().equals(target.username)) {
|
||||
throw new SyntaxErrorException("commands.kick.owner", new Object[0]);
|
||||
}
|
||||
if (par2ArrayOfStr.length == 1) {
|
||||
target.playerNetServerHandler.kickPlayer("Kicked.");
|
||||
notifyAdmins(par1ICommandSender, "commands.kick.success",
|
||||
new Object[] { target.getEntityName() });
|
||||
} else {
|
||||
String message = String.join(" ", par2ArrayOfStr);
|
||||
message = message.substring(message.indexOf(' ') + 1).trim();
|
||||
target.playerNetServerHandler.kickPlayer(message);
|
||||
notifyAdmins(par1ICommandSender, "commands.kick.success.reason",
|
||||
new Object[] { target.getEntityName(), message });
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ import net.minecraft.server.MinecraftServer;
|
|||
|
||||
public class ServerCommandManager extends CommandHandler implements IAdminCommand {
|
||||
public ServerCommandManager() {
|
||||
this.registerCommand(new CommandKick());
|
||||
this.registerCommand(new CommandTime());
|
||||
this.registerCommand(new CommandGameMode());
|
||||
this.registerCommand(new CommandDifficulty());
|
||||
|
|
Loading…
Reference in New Issue
Block a user