@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerCommandPreprocessEvent(PlayerToggleFlightEvent event) {
if (plugin.isDisabled() || event.getPlayer().hasPermission("antiworldfly.fly")) {
return;
}
if (!this.plugin.isAntiFlyCreative() && event.getPlayer().getGameMode() == GameMode.CREATIVE
|| "SPECTATOR".equals(event.getPlayer().getGameMode().toString())) {
return;
}
Player player = event.getPlayer();
for (String world : plugin.getAntiFlyWorlds()) {
if (event.getPlayer().getWorld().getName().equalsIgnoreCase(world)) {
// Disable flying.
player.setAllowFlight(false);
player.getPlayer().setFlying(false);
event.setCancelled(true);
if (plugin.isChatMessage()) {
player.sendMessage(plugin.getChatHeader() + plugin.getPluginLang().getString("fly-disabled-chat",
"Flying is disabled in this world."));
}
if (plugin.isTitleMessage()) {
try {
PacketSender.sendTitlePacket(player, "{\"text\":\""
+ plugin.getPluginLang().getString("fly-disabled-title", "&9AntiWorldFly") + "\"}",
"{\"text\":\"" + plugin.getPluginLang().getString("fly-disabled-subtitle",
"Flying is disabled in this world.") + "\"}");
} catch (Exception e) {
plugin.getLogger().log(Level.SEVERE, "Errors while trying to display flying disabled title: ",
e);
}
}
break;
}
}
}
AntiWorldFlyToggleFly.java 文件源码
java
阅读 32
收藏 0
点赞 0
评论 0
项目:AntiWorldFly
作者:
评论列表
文章目录