this isnt disabling fly when a player leaves their claim and comes back Code (Text): @EventHandler public void onOwnLandFly(PlayerMoveEvent e) { Player p = e.getPlayer(); MPlayer mplayer; mplayer = MPlayer.get(player); if (this.factionsfly.contains(p.getName())) { if ((p.hasPermission("factionsfly.use"))) { if ((!(mplayer.isInOwnTerritory()) && (p.isFlying()))) { p.setAllowFlight(false); p.setFlying(false); p.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("prefix") + getConfig().getString("FlyOff"))); } if ((mplayer.isInOwnTerritory()) && (!(p.isFlying()))) { p.setAllowFlight(true); p.setFlying(true); p.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("prefix") + getConfig().getString("FlyOn"))); } } } } }
There are a few possibilties why it doesn't work: - factionsfly doesn't contain p.getName() - isInOwnTerritory() method fails Please send isInOwnTerritory() or debug with messages within the if-clauses
Probably use getAllowFlight() instead of isFlying() in your if-clause and change Code (Text): p.setAllowFlight(false); p.setFlying(false); to Code (Text): p.setFlying(false); p.setAllowFlight(false); because it's possible that you can't change the permission of flight, while he is flying.
still doesnt work and tried changing it a little bit Code (Text): @EventHandler public void onOwnLandFly(PlayerMoveEvent e) { Player p = e.getPlayer(); MPlayer mplayer; mplayer = MPlayer.get(player); if (this.factionsfly.contains(p.getName())) { if ((p.hasPermission("factionsfly.use"))) { if ((mplayer.isInOwnTerritory() == false) && (p.getAllowFlight() == true)) { p.setFlying(false); p.setAllowFlight(false); p.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("prefix") + getConfig().getString("FlyOff"))); } if ((mplayer.isInOwnTerritory() == true) && (p.getAllowFlight() == false)) { p.setFlying(true); p.setAllowFlight(true); p.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("prefix") + getConfig().getString("FlyOn"))); } } } } }
Try that Code (Text): public static List<String> players = new ArrayList<>(); @EventHandler public void onOwnLandFly(PlayerMoveEvent e) { Player p = e.getPlayer(); if ((p.hasPermission("factionsfly.use"))) { MPlayer mplayer = MPlayer.get(player); if(players.contains(p.getName())) { if(!mplayer.isInOwnTerritory()) { p.setFlying(false); p.setAllowFlight(false); players.remove(p.getName); p.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("prefix") + getConfig().getString("FlyOff"))); } } else { if ((mplayer.isInOwnTerritory() == true) { players.add(p.getName); p.setFlying(true); p.setAllowFlight(true); p.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("prefix") + getConfig().getString("FlyOn"))); } } } }
For example cancel if player isn't moving x and z. Another possiblity are schedulers or one scheduler for all players, that loops every few seconds.