mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-04 17:59:31 +01:00
Idiot-proof some player listeners against Citizens; resolves #772
This commit is contained in:
parent
e46fb89349
commit
8658f49730
@ -22,6 +22,7 @@ import de.erethon.dungeonsxl.DungeonsXL;
|
|||||||
import de.erethon.dungeonsxl.config.DMessage;
|
import de.erethon.dungeonsxl.config.DMessage;
|
||||||
import de.erethon.dungeonsxl.player.DGlobalPlayer;
|
import de.erethon.dungeonsxl.player.DGlobalPlayer;
|
||||||
import de.erethon.dungeonsxl.player.DPermission;
|
import de.erethon.dungeonsxl.player.DPermission;
|
||||||
|
import de.erethon.dungeonsxl.player.DPlayerListener;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@ -105,6 +106,10 @@ public class GlobalProtectionListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerBucketFill(PlayerBucketFillEvent event) {
|
public void onPlayerBucketFill(PlayerBucketFillEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (DPlayerListener.isCitizensNPC(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Block block = event.getBlockClicked();
|
Block block = event.getBlockClicked();
|
||||||
if (DPortal.getByBlock(plugin, block) != null) {
|
if (DPortal.getByBlock(plugin, block) != null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -140,6 +145,9 @@ public class GlobalProtectionListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
if (DPlayerListener.isCitizensNPC(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
DPortal dPortal = DPortal.getByLocation(plugin, player.getEyeLocation());
|
DPortal dPortal = DPortal.getByLocation(plugin, player.getEyeLocation());
|
||||||
if (dPortal == null) {
|
if (dPortal == null) {
|
||||||
return;
|
return;
|
||||||
@ -181,7 +189,11 @@ public class GlobalProtectionListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||||
public void onPortalCreation(PlayerInteractEvent event) {
|
public void onPortalCreation(PlayerInteractEvent event) {
|
||||||
DGlobalPlayer dPlayer = (DGlobalPlayer) plugin.getPlayerCache().get(event.getPlayer());
|
Player player = event.getPlayer();
|
||||||
|
if (DPlayerListener.isCitizensNPC(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DGlobalPlayer dPlayer = (DGlobalPlayer) plugin.getPlayerCache().get(player);
|
||||||
if (!dPlayer.isCreatingPortal()) {
|
if (!dPlayer.isCreatingPortal()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -213,7 +225,7 @@ public class GlobalProtectionListener implements Listener {
|
|||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||||
public void onInteract(PlayerInteractEvent event) {
|
public void onInteract(PlayerInteractEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (plugin.getPlayerCache().get(player).isInBreakMode()) {
|
if (DPlayerListener.isCitizensNPC(player) || plugin.getPlayerCache().get(player).isInBreakMode()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Block clickedBlock = event.getClickedBlock();
|
Block clickedBlock = event.getClickedBlock();
|
||||||
|
@ -21,6 +21,7 @@ import de.erethon.dungeonsxl.DungeonsXL;
|
|||||||
import de.erethon.dungeonsxl.api.player.GlobalPlayer;
|
import de.erethon.dungeonsxl.api.player.GlobalPlayer;
|
||||||
import de.erethon.dungeonsxl.config.DMessage;
|
import de.erethon.dungeonsxl.config.DMessage;
|
||||||
import de.erethon.dungeonsxl.player.DPermission;
|
import de.erethon.dungeonsxl.player.DPermission;
|
||||||
|
import de.erethon.dungeonsxl.player.DPlayerListener;
|
||||||
import de.erethon.dungeonsxl.util.ContainerAdapter;
|
import de.erethon.dungeonsxl.util.ContainerAdapter;
|
||||||
import de.erethon.dungeonsxl.world.DGameWorld;
|
import de.erethon.dungeonsxl.world.DGameWorld;
|
||||||
import de.erethon.dungeonsxl.world.block.RewardChest;
|
import de.erethon.dungeonsxl.world.block.RewardChest;
|
||||||
@ -114,6 +115,9 @@ public class RewardListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
if (DPlayerListener.isCitizensNPC(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
GlobalPlayer dPlayer = plugin.getPlayerCache().get(player);
|
GlobalPlayer dPlayer = plugin.getPlayerCache().get(player);
|
||||||
if (plugin.getInstanceWorld(player.getWorld()) != null) {
|
if (plugin.getInstanceWorld(player.getWorld()) != null) {
|
||||||
return;
|
return;
|
||||||
|
@ -25,6 +25,7 @@ import de.erethon.dungeonsxl.api.sign.DungeonSign;
|
|||||||
import de.erethon.dungeonsxl.api.world.EditWorld;
|
import de.erethon.dungeonsxl.api.world.EditWorld;
|
||||||
import de.erethon.dungeonsxl.config.DMessage;
|
import de.erethon.dungeonsxl.config.DMessage;
|
||||||
import de.erethon.dungeonsxl.player.DPermission;
|
import de.erethon.dungeonsxl.player.DPermission;
|
||||||
|
import de.erethon.dungeonsxl.player.DPlayerListener;
|
||||||
import de.erethon.dungeonsxl.trigger.InteractTrigger;
|
import de.erethon.dungeonsxl.trigger.InteractTrigger;
|
||||||
import de.erethon.dungeonsxl.world.DGameWorld;
|
import de.erethon.dungeonsxl.world.DGameWorld;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -52,6 +53,9 @@ public class DSignListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
if (DPlayerListener.isCitizensNPC(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Block clickedBlock = event.getClickedBlock();
|
Block clickedBlock = event.getClickedBlock();
|
||||||
if (clickedBlock == null) {
|
if (clickedBlock == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -19,6 +19,7 @@ package de.erethon.dungeonsxl.trigger;
|
|||||||
import de.erethon.caliburn.item.VanillaItem;
|
import de.erethon.caliburn.item.VanillaItem;
|
||||||
import de.erethon.dungeonsxl.DungeonsXL;
|
import de.erethon.dungeonsxl.DungeonsXL;
|
||||||
import de.erethon.dungeonsxl.api.world.GameWorld;
|
import de.erethon.dungeonsxl.api.world.GameWorld;
|
||||||
|
import de.erethon.dungeonsxl.player.DPlayerListener;
|
||||||
import de.erethon.dungeonsxl.world.DGameWorld;
|
import de.erethon.dungeonsxl.world.DGameWorld;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -57,6 +58,9 @@ public class TriggerListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
if (DPlayerListener.isCitizensNPC(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
DGameWorld gameWorld = (DGameWorld) plugin.getGameWorld(player.getWorld());
|
DGameWorld gameWorld = (DGameWorld) plugin.getGameWorld(player.getWorld());
|
||||||
if (gameWorld == null) {
|
if (gameWorld == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -28,6 +28,7 @@ import de.erethon.dungeonsxl.api.dungeon.GameRuleContainer;
|
|||||||
import de.erethon.dungeonsxl.api.world.EditWorld;
|
import de.erethon.dungeonsxl.api.world.EditWorld;
|
||||||
import de.erethon.dungeonsxl.api.world.GameWorld;
|
import de.erethon.dungeonsxl.api.world.GameWorld;
|
||||||
import de.erethon.dungeonsxl.api.world.InstanceWorld;
|
import de.erethon.dungeonsxl.api.world.InstanceWorld;
|
||||||
|
import de.erethon.dungeonsxl.player.DPlayerListener;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -35,6 +36,7 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -99,6 +101,10 @@ public class DWorldListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||||
public void onBlockInteract(PlayerInteractEvent event) {
|
public void onBlockInteract(PlayerInteractEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (DPlayerListener.isCitizensNPC(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
GameWorld gameWorld = plugin.getGameWorld(block.getWorld());
|
GameWorld gameWorld = plugin.getGameWorld(block.getWorld());
|
||||||
if (gameWorld == null || gameWorld.isPlaying()) {
|
if (gameWorld == null || gameWorld.isPlaying()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user