/** * Keeps track of player glide part 2; if they are gliding we track when they glided, or, clear if no longer gliding. * * @param event * the glide toggle event */ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void toggleGlideEvent(EntityToggleGlideEvent event) { if (!(event.getEntity() instanceof Player)) return; Player eventPlayer = (Player) event.getEntity(); if (event.isGliding()) { glidingSince.computeIfAbsent(eventPlayer.getUniqueId(), u -> { //if (eventPlayer.hasPermission("addgun.data")) { eventPlayer.sendMessage(ChatColor.GOLD + "glide started"); } return System.currentTimeMillis(); }); glidingEnd.remove(eventPlayer.getUniqueId()); } else { /*if (glidingSince.containsKey(eventPlayer.getUniqueId()) && eventPlayer.hasPermission("addgun.data")) { eventPlayer.sendMessage(ChatColor.GOLD + " glide cleared"); }*/ glidingSince.remove(eventPlayer.getUniqueId()); glidingEnd.computeIfAbsent(eventPlayer.getUniqueId(), u -> { return System.currentTimeMillis(); }); } }
@EventHandler public void onPlayerGlide(EntityToggleGlideEvent event) { if (!(event.getEntity() instanceof Player)) return; if (!SamaGamesAPI.get().getPermissionsManager().hasPermission(event.getEntity(), "network.vipplus")) if (((Player) event.getEntity()).isFlying() && ((Player) event.getEntity()).getInventory().getChestplate().getType() == Material.ELYTRA) ((Player) event.getEntity()).getInventory().setChestplate(null); if (event.isGliding() && RestrictedVersion.isLoggedInPost19((Player) event.getEntity())) { ItemStack stack = new ItemStack(Material.FEATHER); ItemMeta meta = stack.getItemMeta(); meta.setDisplayName(ChatColor.GOLD + "" + ChatColor.BOLD + "Ventilateur" + ChatColor.RESET + "" + ChatColor.GRAY + " (Clic-droit)"); stack.setItemMeta(meta); stack.addUnsafeEnchantment(Enchantment.DURABILITY, 1); ((Player) event.getEntity()).getInventory().setItem(3, stack); } else { ((Player) event.getEntity()).getInventory().setItem(3, new ItemStack(Material.AIR)); } }
@EventHandler(ignoreCancelled = true) public void onEntityToggleGlide(EntityToggleGlideEvent event) { if (event.getEntityType() != EntityType.PLAYER) { return; } Player player = (Player) event.getEntity(); if (!InventoryManager.playerIsLoaded(player)) { return; } if (event.isGliding()) { PlayerWrapper playerWrapper = InventoryManager.get(player); playerWrapper.onStartGliding(); } }
@EventHandler public void onEntityToggleGlideEvent(EntityToggleGlideEvent event){ if(event.getEntity() instanceof Player){ Player p = (Player) event.getEntity(); if(playerCanFall(p) && p.getLocation().subtract(0, 1, 0).getBlock().getType()!=Material.STATIONARY_WATER){ //****************************** Changes by DrkMatr1984 START ****************************** PlayerStartFallingEvent e = new PlayerStartFallingEvent(p); Bukkit.getServer().getPluginManager().callEvent(e); if(!e.isCancelled()){ p.setVelocity(new Vector(p.getLocation().getDirection().getX()* Config.fallGlideSpeed, Config.fallDownwardSpeed*-1, p.getLocation().getDirection().getZ()*Config.fallGlideSpeed)); event.setCancelled(true); }else{ p.setGliding(false); } //****************************** Changes by DrkMatr1984 END ****************************** } } }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEntityToggleGlideEvent(EntityToggleGlideEvent event) { if (event.getEntity() instanceof Player) { Player player = (Player)event.getEntity(); if (!WorldGuardUtils.hasBypass(player)) { ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionContainer().createQuery().getApplicableRegions(player.getLocation()); State state = regions.queryValue(WorldGuardUtils.wrapPlayer(player), FlagUtils.GLIDE); if (state != null) { event.setCancelled(true); player.setGliding(state == State.ALLOW); } } } }
@EventHandler public void onPlayerFly(EntityToggleGlideEvent event) { if (event.getEntity() instanceof Player) { Player player = (Player) event.getEntity(); if (event.isGliding()) { manager.addHUD(player); } else { manager.removeHUD(player); } } }
@EventHandler public void onEntityToggleGlideEvent(EntityToggleGlideEvent event){ if(event.getEntity() instanceof Player){ Player p = (Player) event.getEntity(); if(playerCanSwim(p) && !p.hasMetadata("swimmingDisabled")){ event.setCancelled(true); } } }
@EventHandler public void onEntityToggleGlideEvent(EntityToggleGlideEvent event){ if(event.getEntity() instanceof Player){ Player p = (Player) event.getEntity(); if(p.isSneaking() && Config.enableSneak){ event.setCancelled(true); } } }
@EventHandler public void onEntityToggleGlideEvent(EntityToggleGlideEvent event) { if (event.getEntity().getLocation().add(0, -1, 0).getBlock().getType() == Material.AIR) event.setCancelled(true); }
@EventHandler public void onToggleGlide(EntityToggleGlideEvent event) { event.setCancelled(true); }
@Override public void play(Player player) { if (this.flyingPlayers.contains(player.getUniqueId())) return; if (this.hub.getPlayerManager().isBusy(player) || player.getGameMode() == GameMode.SPECTATOR) return; if (!RestrictedVersion.isLoggedInPost19(player)) { if (!this.disclaimerCooldowns.containsKey(player.getUniqueId())) { player.sendMessage(ChatColor.RED + "Veuillez vous connecter avec une version supérieure ou égale à Minecraft 1.9 pour utiliser les Bumpers."); this.disclaimerCooldowns.put(player.getUniqueId(), 20); } else { int cooldown = this.disclaimerCooldowns.get(player.getUniqueId()); cooldown--; this.disclaimerCooldowns.remove(player.getUniqueId()); if (cooldown > 0) { this.disclaimerCooldowns.put(player.getUniqueId(), cooldown); } } return; } this.hub.getServer().getScheduler().runTask(this.hub, () -> SamaGamesAPI.get().getAchievementManager().getAchievementByID(6).unlock(player.getUniqueId())); this.flyingPlayers.add(player.getUniqueId()); Vector vec = this.bumperLocation.getDirection().multiply(this.power); long flyTime = (long) (((vec.getY()) / g) * 20.0); BukkitTask run = new BukkitRunnable() { double x = vec.getX() / 2; double y = vec.getY() / 2; double z = vec.getZ() / 2; @Override public void run() { ((CraftPlayer)player).getHandle().motX = x; ((CraftPlayer)player).getHandle().motY = y; ((CraftPlayer)player).getHandle().motZ = z; ((CraftPlayer)player).getHandle().velocityChanged = true; } }.runTaskTimer(this.hub, 0L, flyTime/2L); this.flyTasks.put(player.getUniqueId(), this.hub.getServer().getScheduler().runTaskLater(this.hub, () -> { ItemStack stack = new ItemStack(Material.ELYTRA); ItemMeta meta = stack.getItemMeta(); meta.spigot().setUnbreakable(true); stack.setItemMeta(meta); player.getInventory().setChestplate(stack); ((CraftPlayer)player).getHandle().setFlag(7, true); this.hub.getPlayerManager().getStaticInventory().setInventoryToPlayer(player); this.hub.getServer().getPluginManager().callEvent(new EntityToggleGlideEvent(player, true)); Titles.sendTitle(player, 10, 40, 10, "", ChatColor.GOLD + "Bon vol !"); this.stop(player); run.cancel(); }, flyTime)); }
@EventHandler public void onPlayerToggleFlight(PlayerToggleFlightEvent event) { this.onPlayerGlide(new EntityToggleGlideEvent(event.getPlayer(), false)); }
@EventHandler(ignoreCancelled = true) public void onElytraToggle(EntityToggleGlideEvent evt) { // Disables elytra in party world. evt.setCancelled(evt.isGliding() && isParty(evt.getEntity())); }
@Override public void onEnable() { WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(TeleportOnEntryFlag.FACTORY, null); WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(TeleportOnExitFlag.FACTORY, null); WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(CommandOnEntryFlag.FACTORY, null); WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(CommandOnExitFlag.FACTORY, null); WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(ConsoleCommandOnEntryFlag.FACTORY, null); WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(ConsoleCommandOnExitFlag.FACTORY, null); WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(WalkSpeedFlag.FACTORY, null); WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(BlockedEffectsFlag.FACTORY, null); WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(GodmodeFlag.FACTORY, null); WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(GiveEffectsFlag.FACTORY, null); WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(FlyFlag.FACTORY, null); WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(PlaySoundsFlag.FACTORY, null); WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(GlideFlag.FACTORY, null); this.getServer().getPluginManager().registerEvents(new PlayerListener(), this); this.getServer().getPluginManager().registerEvents(new BlockListener(), this); this.getServer().getPluginManager().registerEvents(new EntityListener(), this); this.getServer().getPluginManager().registerEvents(new WorldListener(), this); try { if (EntityToggleGlideEvent.class != null) //LOL, Just making it look nice xD { this.getServer().getPluginManager().registerEvents(new EntityListenerOnePointNine(), this); } } catch(NoClassDefFoundError ignored) { } Plugin essentialsPlugin = this.getServer().getPluginManager().getPlugin("Essentials"); if (essentialsPlugin != null) { WorldGuardExtraFlagsPlugin.essentialsPlugin = (Essentials)essentialsPlugin; } WorldGuardExtraFlagsPlugin.mythicMobsEnabled = this.getServer().getPluginManager().isPluginEnabled("MythicMobs"); WorldGuardExtraFlagsPlugin.fastAsyncWorldEditEnabled = this.getServer().getPluginManager().isPluginEnabled("FastAsyncWorldEdit"); if (WorldGuardExtraFlagsPlugin.fastAsyncWorldEditEnabled) { PluginUtils.registerFAWE(); } else { WorldGuardExtraFlagsPlugin.worldEditPlugin.getWorldEdit().getEventBus().register(new WorldEditListener()); } if (WorldGuardExtraFlagsPlugin.isEssentialsEnable()) { this.getServer().getPluginManager().registerEvents(new EssentialsListener(), this); } for(World world : this.getServer().getWorlds()) { WorldGuardExtraFlagsPlugin.doUnloadChunkFlagWorldCheck(world); } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onMove(final EntityToggleGlideEvent event) { if (!(event.getEntity() instanceof Player)) return; // Get player final Player player = (Player) event.getEntity(); StatzUtil.isGliding.put(player.getUniqueId(), event.isGliding()); }