Exemplo n.º 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;
  }
Exemplo n.º 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();
    }
  }
Exemplo n.º 3
0
 @Override
 public void onPlayerKick(PlayerKickEvent event) {
   Player triggerMessage = event.getPlayer();
   String[] replaceThese = {"<<kick-reason>>", "<<kickedplayer>>"};
   String[] withThese = {event.getReason(), triggerMessage.getName()};
   plugin.triggerMessages(triggerMessage, "onkick", replaceThese, withThese);
 }
Exemplo n.º 4
0
 @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
 public void onKick(PlayerKickEvent event) {
   try {
     if (running) {
       if (as != null && as.isValid() && event.getReason().contains("Fly")) {
         if (as.getLocation().distance(event.getPlayer().getLocation()) < 8) {
           event.setCancelled(true);
           System.out.println("UltraCosmetics >> Cancelling invalid Flight KicK.");
           return;
         }
       }
       event.setCancelled(true);
       System.out.println("UltraCosmetics >> Cancelling invalid Flight KicK.");
       return;
     }
   } catch (Exception exc) {
   }
 }