TownyAdvanced / TownyFlight

Flight plugin for Towny servers.
https://townyadvanced.github.io/
Other
23 stars 17 forks source link

BUG:Players can fly in areas that are not legal #83

Closed 2534905003 closed 2 weeks ago

2534905003 commented 2 weeks ago

What is the issue that you see?

What steps can be done to repeat the issue on a test server?

!#My English is not very good, I try to describe it clearly. 1.The player can use the /tfly command to start flying around the town, and then use the teleport command of the ender pearl or other plugins to bypass detection at the edge of the town, thus flying in illegal areas. He's a very fatal bug, please fix it

Versions/Files

Towny Version (use '/towny v' in game) : towny-0.100.2.13 TownyFlight Version : TownyFlight-1.10.2 Link to pastebin.com with full server startup from the latest.log :latest.log Link to pastebin.com with TownyFlight config.yml :config.txt !#It doesn't seem to be able to upload files in .yml format

LlmDl commented 2 weeks ago

TownyFlight already checks if flight should be allowed when a player teleports.

Please explain exactly how you reproduce this. If other plugins are needed to accomplish this then I need to know which ones.

2534905003 commented 2 weeks ago

TownyFlight 已经检查了玩家传送时是否应该允许飞行。

请准确解释您是如何重现此内容的。如果需要其他插件来完成此操作,那么我需要知道哪些插件。

方法1:使用原版的末影珍珠,在城镇内往城镇外仍 方法2:使用插件的传送指令,如:HuskHomes的/tpa /home等

LlmDl commented 2 weeks ago

Maybe in English would work better for me.

2534905003 commented 2 weeks ago

Method 1: Use the original ender pearl,Targets use inside and outside towns Method 2: Use plugins to send commands, e.g. HuskHomes, /tpa /home

LlmDl commented 2 weeks ago
public class PlayerTeleportListener implements Listener {

    @EventHandler(priority = EventPriority.MONITOR)
    private void playerTeleports(PlayerTeleportEvent event) {
        if (!aTeleportCauseThatMatters(event.getCause()))
            return;

        Player player = event.getPlayer();
        if (player.hasPermission("townyflight.bypass") 
                || !player.getAllowFlight()
                || flightAllowedDestination(player, event.getTo())) {
            return;
        }

        TownyFlightAPI.getInstance().removeFlight(player, false, true, "");
    }

    private boolean aTeleportCauseThatMatters(TeleportCause teleportCause) {
        return teleportCause == TeleportCause.PLUGIN || teleportCause == TeleportCause.COMMAND ||
                teleportCause == TeleportCause.ENDER_PEARL || teleportCause == TeleportCause.CHORUS_FRUIT;
    }

    private boolean flightAllowedDestination(Player player, Location loc) {
        Resident resident = TownyUniverse.getInstance().getResident(player.getUniqueId());
        return resident != null && TownyFlightAPI.allowedLocation(player, loc, resident);
    }

}

TownyFlight retests their ability to fly if its a TeleportCause of plugin, command, ender pearl or chorus fruit.

The HuskHomes might not be using the correct TeleportCause. You might have another plugin altering ender pearls.

You might also have the townyflight.bypass permission node.

2534905003 commented 2 weeks ago
public class PlayerTeleportListener implements Listener {

  @EventHandler(priority = EventPriority.MONITOR)
  private void playerTeleports(PlayerTeleportEvent event) {
      if (!aTeleportCauseThatMatters(event.getCause()))
          return;

      Player player = event.getPlayer();
      if (player.hasPermission("townyflight.bypass") 
              || !player.getAllowFlight()
              || flightAllowedDestination(player, event.getTo())) {
          return;
      }

      TownyFlightAPI.getInstance().removeFlight(player, false, true, "");
  }

  private boolean aTeleportCauseThatMatters(TeleportCause teleportCause) {
      return teleportCause == TeleportCause.PLUGIN || teleportCause == TeleportCause.COMMAND ||
              teleportCause == TeleportCause.ENDER_PEARL || teleportCause == TeleportCause.CHORUS_FRUIT;
  }

  private boolean flightAllowedDestination(Player player, Location loc) {
      Resident resident = TownyUniverse.getInstance().getResident(player.getUniqueId());
      return resident != null && TownyFlightAPI.allowedLocation(player, loc, resident);
  }

}

TownyFlight 重新测试他们的飞行能力,如果它是插件、命令、末影珍珠或合唱果实的 TeleportCause。

HuskHomes可能没有使用正确的TeleportCause。您可能有另一个插件更改末影珍珠。

您可能还具有权限节点。townyflight.bypass

: )