Merge pull request #153 from jascotty2/dev

Improve event checking
This commit is contained in:
sekwah41 2019-06-03 03:07:59 +01:00 committed by GitHub
commit 4392d60b26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 15 deletions

View File

@ -6,7 +6,11 @@ import com.sekwah.advancedportals.PluginMessages;
import com.sekwah.advancedportals.api.events.WarpEvent;
import com.sekwah.advancedportals.portals.AdvancedPortal;
import com.sekwah.advancedportals.portals.Portal;
import org.bukkit.*;
import org.bukkit.Axis;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Orientable;
import org.bukkit.entity.Player;
@ -71,19 +75,19 @@ public class Listeners implements Listener {
Portal.cooldown.put(event.getPlayer().getName(), System.currentTimeMillis());
}
@EventHandler
@EventHandler(ignoreCancelled = true)
public void onTeleportEvent(PlayerTeleportEvent event) {
Portal.cooldown.put(event.getPlayer().getName(), System.currentTimeMillis());
}
@EventHandler
@EventHandler(ignoreCancelled = true)
public void spawnMobEvent(CreatureSpawnEvent event) {
if(event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.NETHER_PORTAL && Portal.inPortalRegion(event.getLocation(), Portal.getPortalProtectionRadius())) {
event.setCancelled(true);
}
}
@EventHandler
@EventHandler(ignoreCancelled = true)
public void onLeaveEvent(PlayerQuitEvent event) {
Portal.cooldown.remove(event.getPlayer().getName());
@ -93,7 +97,7 @@ public class Listeners implements Listener {
}
}
@EventHandler(priority = EventPriority.HIGHEST)
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onMoveEvent(PlayerMoveEvent event) {
// will check if the player is in the portal or not.
if (!Portal.portalsActive || event.isCancelled()) {
@ -172,22 +176,22 @@ public class Listeners implements Listener {
}
}
@EventHandler
@EventHandler(ignoreCancelled = true)
public void onCombustEntityEvent(EntityCombustEvent event) {
if (Portal.inPortalTriggerRegion(event.getEntity().getLocation()))
if (event.getEntity() instanceof Player && Portal.inPortalTriggerRegion(event.getEntity().getLocation()))
event.setCancelled(true);
}
@EventHandler
@EventHandler(ignoreCancelled = true)
public void onDamEvent(EntityDamageEvent event) {
if (event.getCause() == EntityDamageEvent.DamageCause.LAVA || event.getCause() == EntityDamageEvent.DamageCause.FIRE || event.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK) {
if (event.getEntity() instanceof Player && (event.getCause() == EntityDamageEvent.DamageCause.LAVA || event.getCause() == EntityDamageEvent.DamageCause.FIRE || event.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK)) {
if (event.getEntity().hasMetadata("lavaWarped") | Portal.inPortalTriggerRegion(event.getEntity().getLocation()))
event.setCancelled(true);
}
}
@EventHandler
@EventHandler(ignoreCancelled = true)
public void onPortalEvent(PlayerPortalEvent event) {
if (event.isCancelled()) {
return;
@ -205,7 +209,7 @@ public class Listeners implements Listener {
event.setCancelled(true);
}
@EventHandler
@EventHandler(ignoreCancelled = true)
public void onItemInteract(PlayerInteractEvent event) {
// will detect if the player is using an axe so the points of a portal can be set

View File

@ -3,10 +3,8 @@ package com.sekwah.advancedportals.listeners;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.portals.Portal;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;

View File

@ -4,7 +4,6 @@ import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.PluginMessages;
import com.sekwah.advancedportals.portals.Portal;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;

View File

@ -8,7 +8,13 @@ import com.sekwah.advancedportals.PluginMessages;
import com.sekwah.advancedportals.api.portaldata.PortalArg;
import com.sekwah.advancedportals.destinations.Destination;
import com.sekwah.advancedportals.effects.WarpEffects;
import org.bukkit.*;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionAttachment;