Beispiel #1
0
  public void disconnect(String s) {
    // CraftBukkit start
    String leaveMessage = "\u00A7e" + this.player.name + " left the game.";
    PlayerKickEvent event = new PlayerKickEvent(server.getPlayer(this.player), s, leaveMessage);
    server.getPluginManager().callEvent(event);
    if (event.isCancelled()) {
      // Do not kick the player
      return;
    }
    // Send the possibly modified leave message
    s = event.getReason();
    // CraftBukkit end

    this.player.A();
    this.sendPacket(new Packet255KickDisconnect(s));
    this.networkManager.d();

    // CraftBukkit start
    leaveMessage = event.getLeaveMessage();
    if (leaveMessage != null) {
      this.minecraftServer.serverConfigurationManager.sendAll(new Packet3Chat(leaveMessage));
    }
    // CraftBukkit end

    this.minecraftServer.serverConfigurationManager.disconnect(this.player);
    this.disconnected = true;
  }
Beispiel #2
0
  /**
   * Disconnects the session with the specified reason. This causes a KickMessage to be sent. When
   * it has been delivered, the channel is closed.
   *
   * @param reason The reason for disconnection.
   * @param overrideKick Whether to skip the kick event.
   */
  public void disconnect(String reason, boolean overrideKick) {
    if (player != null && !overrideKick) {
      PlayerKickEvent event = EventFactory.onPlayerKick(player, reason);
      if (event.isCancelled()) {
        return;
      }

      reason = event.getReason();

      if (player.isOnline() && event.getLeaveMessage() != null) {
        server.broadcastMessage(event.getLeaveMessage());
      }
    }

    // log that the player was kicked
    if (player != null) {
      GlowServer.logger.info(player.getName() + " kicked: " + reason);
    } else {
      GlowServer.logger.info("[" + address + "] kicked: " + reason);
    }

    if (quitReason == null) {
      quitReason = "kicked";
    }

    // perform the kick, sending a kick message if possible
    if (isActive()
        && (getProtocol() instanceof LoginProtocol || getProtocol() instanceof PlayProtocol)) {
      // channel is both currently connected and in a protocol state allowing kicks
      sendWithFuture(new KickMessage(reason)).addListener(ChannelFutureListener.CLOSE);
    } else {
      getChannel().close();
    }
  }
 @EventHandler(priority = EventPriority.NORMAL)
 public void onPlayerKick(final PlayerKickEvent event) {
   if (event.isCancelled() || event.getLeaveMessage() == null) {
     return;
   }
   for (final IRCChannel c : Variables.channels) {
     if (!c.getBlockedEvents().contains("game_kick")) {
       IRC.sendMessageToChannel(
           c.getChannel(),
           ColorUtils.formatGametoIRC(event.getPlayer().getDisplayName() + " has been kicked."));
     }
   }
 }
 @EventHandler(order = Order.EARLIEST)
 public void onPlayerLeave(PlayerLeaveEvent event) {
   BridgePlayer player = EntityFactory.createPlayer(event.getPlayer());
   final String leaveMessage = event.getMessage().asString();
   if (event instanceof PlayerKickEvent) {
     PlayerKickEvent kickEvent = (PlayerKickEvent) event;
     final String kickMessage = kickEvent.getKickReason().asString();
     org.bukkit.event.player.PlayerKickEvent kick =
         new org.bukkit.event.player.PlayerKickEvent(player, kickMessage, leaveMessage);
     kick.setCancelled(event.isCancelled());
     Bukkit.getPluginManager().callEvent(kick);
     if (!kickMessage.equals(kick.getReason())) {
       kickEvent.setKickReason(kick.getReason());
     }
     if (!leaveMessage.equals(kick.getLeaveMessage())) {
       kickEvent.setMessage(kick.getLeaveMessage());
     }
     kickEvent.setCancelled(kick.isCancelled());
   } else {
     org.bukkit.event.player.PlayerQuitEvent quit =
         new org.bukkit.event.player.PlayerQuitEvent(player, leaveMessage);
     Bukkit.getPluginManager().callEvent(quit);
   }
 }
 @EventHandler(priority = EventPriority.MONITOR)
 public void onPlayerLeave2(PlayerKickEvent e) {
   if (!e.isCancelled()) delayTime.remove(e.getPlayer());
 }