1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package me.km.commands;
- import com.mojang.authlib.GameProfile;
- import me.km.api.Utils;
- import me.km.api.GlobalText;
- import me.km.api.Module;
- import me.km.api.ModuleCommand;
- import me.km.KajetansMod;
- import me.km.permissions.Permissions;
- import net.minecraft.command.ICommandSender;
- import net.minecraft.entity.player.EntityPlayerMP;
- import net.minecraft.server.management.UserListBansEntry;
- import net.minecraft.util.text.TextComponentString;
- public class CommandBan extends ModuleCommand
- {
- public CommandBan(Module m)
- {
- super("ban", m);
- super.setDescription("Bannt einen Spiele dauerhaft");
- super.setUsage("/ban <name> <reason>");
- super.setPermission(Permissions.BAN);
- }
- @Override
- public boolean execute(ICommandSender cs, String[] arg)
- {
- if(arg.length <= 1)
- {
- return false;
- }
- GameProfile affectedPlayer = KajetansMod.playerbank.getDataBank().getOfflinePlayer(arg[0]);
- if(affectedPlayer == null)
- {
- this.getModule().send(cs, GlobalText.cantFindPlayer(arg[0]));
- return true;
- }
- String message = Utils.connectSpaces(arg, 1);
- this.getModule().sendBroadcast("§4" + affectedPlayer.getName() + " §cwurde von §4" + cs.getName() + "§c gebannt, weil: §4" + message);
-
- UserListBansEntry bans = new UserListBansEntry(affectedPlayer, null, cs.getName(), null, message);
- KajetansMod.server.getPlayerList().getBannedPlayers().addEntry(bans);
- EntityPlayerMP p = KajetansMod.server.getPlayerList().getPlayerByUUID(affectedPlayer.getId());
- if(p != null)
- {
- p.connection.disconnect(new TextComponentString("§4Du §cwurdest von §4" + cs.getName() + "§c gebannt, weil: §4" + message));
- }
- return true;
- }
- }
|