mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-26 20:26:34 +01:00
Reworked Projectile permissions
This commit is contained in:
parent
37759f598c
commit
57994742a2
@ -1,7 +1,6 @@
|
|||||||
package com.songoda.skyblock.listeners;
|
package com.songoda.skyblock.listeners;
|
||||||
|
|
||||||
import com.songoda.skyblock.SkyBlock;
|
import com.songoda.skyblock.SkyBlock;
|
||||||
import com.songoda.skyblock.permission.event.events.ProjectileLaunchByPlayerEvent;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -20,16 +19,13 @@ public class Projectile implements Listener {
|
|||||||
public void onProjectileLaunch(ProjectileLaunchEvent event) {
|
public void onProjectileLaunch(ProjectileLaunchEvent event) {
|
||||||
org.bukkit.entity.Projectile projectile = event.getEntity();
|
org.bukkit.entity.Projectile projectile = event.getEntity();
|
||||||
ProjectileSource shooter = projectile.getShooter();
|
ProjectileSource shooter = projectile.getShooter();
|
||||||
if (!(shooter instanceof Player))
|
if (shooter instanceof Player) {
|
||||||
return;
|
Player player = (Player) shooter;
|
||||||
|
|
||||||
Player player = (Player) shooter;
|
if (plugin.getWorldManager().isIslandWorld(player.getWorld())) {
|
||||||
|
plugin.getPermissionManager().processPermission(event, player, player.getLocation());
|
||||||
if (!plugin.getWorldManager().isIslandWorld(player.getWorld()))
|
}
|
||||||
return;
|
}
|
||||||
|
|
||||||
// Check permissions.
|
|
||||||
plugin.getPermissionManager().processPermission(new ProjectileLaunchByPlayerEvent(event.getEntity()), player, player.getLocation());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import com.songoda.core.compatibility.CompatibleSound;
|
|||||||
import com.songoda.skyblock.SkyBlock;
|
import com.songoda.skyblock.SkyBlock;
|
||||||
import com.songoda.skyblock.message.MessageManager;
|
import com.songoda.skyblock.message.MessageManager;
|
||||||
import com.songoda.skyblock.permission.event.events.PlayerEnterPortalEvent;
|
import com.songoda.skyblock.permission.event.events.PlayerEnterPortalEvent;
|
||||||
import com.songoda.skyblock.permission.event.events.ProjectileLaunchByPlayerEvent;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
@ -79,7 +78,7 @@ public abstract class ListeningPermission extends BasicPermission {
|
|||||||
|
|
||||||
public void onTeleport(PlayerTeleportEvent event) {}
|
public void onTeleport(PlayerTeleportEvent event) {}
|
||||||
|
|
||||||
public void onProjectileLaunch(ProjectileLaunchByPlayerEvent event) {}
|
public void onProjectileLaunch(ProjectileLaunchEvent event) {}
|
||||||
|
|
||||||
public void onBlockIgnite(BlockIgniteEvent event) {}
|
public void onBlockIgnite(BlockIgniteEvent event) {}
|
||||||
|
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
package com.songoda.skyblock.permission.event.events;
|
|
||||||
|
|
||||||
import com.songoda.skyblock.permission.event.Stoppable;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
|
||||||
|
|
||||||
public class ProjectileLaunchByPlayerEvent extends ProjectileLaunchEvent implements Cancellable, Stoppable {
|
|
||||||
|
|
||||||
private boolean isCancelled = false;
|
|
||||||
private boolean isStopped = false;
|
|
||||||
|
|
||||||
public ProjectileLaunchByPlayerEvent(Entity what) {
|
|
||||||
super(what);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return isCancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancelled) {
|
|
||||||
isCancelled = cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isStopped() {
|
|
||||||
return isStopped;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setStopped(boolean stopped) {
|
|
||||||
isStopped = stopped;
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,9 +7,9 @@ import com.songoda.skyblock.permission.ListeningPermission;
|
|||||||
import com.songoda.skyblock.permission.PermissionHandler;
|
import com.songoda.skyblock.permission.PermissionHandler;
|
||||||
import com.songoda.skyblock.permission.PermissionPriority;
|
import com.songoda.skyblock.permission.PermissionPriority;
|
||||||
import com.songoda.skyblock.permission.PermissionType;
|
import com.songoda.skyblock.permission.PermissionType;
|
||||||
import com.songoda.skyblock.permission.event.events.ProjectileLaunchByPlayerEvent;
|
|
||||||
import org.bukkit.entity.FishHook;
|
import org.bukkit.entity.FishHook;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||||
|
|
||||||
public class FishingPermission extends ListeningPermission {
|
public class FishingPermission extends ListeningPermission {
|
||||||
|
|
||||||
@ -23,12 +23,11 @@ public class FishingPermission extends ListeningPermission {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PermissionHandler(priority = PermissionPriority.LAST)
|
@PermissionHandler(priority = PermissionPriority.LAST)
|
||||||
public void onProjectileLaunch(ProjectileLaunchByPlayerEvent event) {
|
public void onProjectileLaunch(ProjectileLaunchEvent event) {
|
||||||
org.bukkit.entity.Projectile projectile = event.getEntity();
|
org.bukkit.entity.Projectile projectile = event.getEntity();
|
||||||
if (projectile instanceof FishHook && projectile.getShooter() instanceof Player) {
|
if (projectile instanceof FishHook && projectile.getShooter() instanceof Player) {
|
||||||
Player shooter = (Player) projectile.getShooter();
|
Player shooter = (Player) projectile.getShooter();
|
||||||
cancelAndMessage(event, shooter, plugin, messageManager);
|
cancelAndMessage(event, shooter, plugin, messageManager);
|
||||||
event.setStopped(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,9 @@ import com.songoda.skyblock.permission.ListeningPermission;
|
|||||||
import com.songoda.skyblock.permission.PermissionHandler;
|
import com.songoda.skyblock.permission.PermissionHandler;
|
||||||
import com.songoda.skyblock.permission.PermissionPriority;
|
import com.songoda.skyblock.permission.PermissionPriority;
|
||||||
import com.songoda.skyblock.permission.PermissionType;
|
import com.songoda.skyblock.permission.PermissionType;
|
||||||
import com.songoda.skyblock.permission.event.events.ProjectileLaunchByPlayerEvent;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
public class ProjectilePermission extends ListeningPermission {
|
public class ProjectilePermission extends ListeningPermission {
|
||||||
@ -34,7 +34,9 @@ public class ProjectilePermission extends ListeningPermission {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PermissionHandler(priority = PermissionPriority.LAST)
|
@PermissionHandler(priority = PermissionPriority.LAST)
|
||||||
public void onProjectileLaunch(ProjectileLaunchByPlayerEvent event) {
|
public void onProjectileLaunch(ProjectileLaunchEvent event) {
|
||||||
event.setCancelled(true);
|
if(event.getEntity().getShooter() instanceof Player) {
|
||||||
|
cancelAndMessage(event, (Player) event.getEntity().getShooter(), plugin, messageManager);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user