Updated WatcherTriggers to use eco PlayerJumpEvent
This commit is contained in:
@@ -3,6 +3,7 @@ package com.willfp.talismans.talismans.util;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.PluginDependent;
|
||||
import com.willfp.eco.core.events.PlayerJumpEvent;
|
||||
import com.willfp.eco.core.integrations.antigrief.AntigriefManager;
|
||||
import com.willfp.eco.core.integrations.mcmmo.McmmoManager;
|
||||
import org.bukkit.Material;
|
||||
@@ -31,16 +32,6 @@ import java.util.UUID;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class WatcherTriggers extends PluginDependent<EcoPlugin> implements Listener {
|
||||
/**
|
||||
* For jump listeners.
|
||||
*/
|
||||
private static final Set<UUID> PREVIOUS_PLAYERS_ON_GROUND = Sets.newHashSet();
|
||||
|
||||
/**
|
||||
* For jump listeners.
|
||||
*/
|
||||
private static final DecimalFormat FORMAT = new DecimalFormat("0.00");
|
||||
|
||||
/**
|
||||
* Create new listener for watcher events.
|
||||
*
|
||||
@@ -172,44 +163,28 @@ public class WatcherTriggers extends PluginDependent<EcoPlugin> implements Liste
|
||||
* @param event The event to listen for.
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onJump(@NotNull final PlayerMoveEvent event) {
|
||||
public void onJump(@NotNull final PlayerJumpEvent event) {
|
||||
if (McmmoManager.isFake(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (player.getVelocity().getY() > 0) {
|
||||
float jumpVelocity = 0.42f;
|
||||
if (player.hasPotionEffect(PotionEffectType.JUMP)) {
|
||||
jumpVelocity += ((float) player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() + 1) * 0.1F;
|
||||
|
||||
TalismanChecks.getTalismansOnPlayer(player).forEach(talismanLevel -> {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
jumpVelocity = Float.parseFloat(FORMAT.format(jumpVelocity).replace(',', '.'));
|
||||
if (event.getPlayer().getLocation().getBlock().getType() != Material.LADDER
|
||||
&& PREVIOUS_PLAYERS_ON_GROUND.contains(player.getUniqueId())
|
||||
&& !player.isOnGround()
|
||||
&& Float.compare((float) player.getVelocity().getY(), jumpVelocity) == 0) {
|
||||
TalismanChecks.getTalismansOnPlayer(player).forEach(talismanLevel -> {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!talismanLevel.getTalisman().isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (talismanLevel.getTalisman().getDisabledWorlds().contains(player.getWorld())) {
|
||||
return;
|
||||
}
|
||||
|
||||
talismanLevel.getTalisman().onJump(talismanLevel, player, event);
|
||||
});
|
||||
if (!talismanLevel.getTalisman().isEnabled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (player.isOnGround()) {
|
||||
PREVIOUS_PLAYERS_ON_GROUND.add(player.getUniqueId());
|
||||
} else {
|
||||
PREVIOUS_PLAYERS_ON_GROUND.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
if (talismanLevel.getTalisman().getDisabledWorlds().contains(player.getWorld())) {
|
||||
return;
|
||||
}
|
||||
|
||||
talismanLevel.getTalisman().onJump(talismanLevel, player, event);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user