mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
Cancel lingering potion splash
Cancelling the event still doesn't stop the animation.
This commit is contained in:
parent
1f6ad47a79
commit
1e93398fd8
3 changed files with 72 additions and 26 deletions
|
@ -42,6 +42,7 @@ import com.plotsquared.bukkit.listeners.ForceFieldListener;
|
|||
import com.plotsquared.bukkit.listeners.PlayerEvents;
|
||||
import com.plotsquared.bukkit.listeners.PlayerEvents183;
|
||||
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8;
|
||||
import com.plotsquared.bukkit.listeners.PlayerEvents_1_9;
|
||||
import com.plotsquared.bukkit.listeners.PlotPlusListener;
|
||||
import com.plotsquared.bukkit.listeners.WorldEvents;
|
||||
import com.plotsquared.bukkit.listeners.worldedit.WEListener;
|
||||
|
@ -72,6 +73,12 @@ import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
|
|||
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
|
||||
import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
|
@ -86,13 +93,6 @@ import org.bukkit.metadata.MetadataValue;
|
|||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
public static BukkitMain THIS;
|
||||
|
@ -349,13 +349,17 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||
|
||||
@Override
|
||||
public void registerPlayerEvents() {
|
||||
getServer().getPluginManager().registerEvents(new PlayerEvents(), this);
|
||||
PlayerEvents main = new PlayerEvents();
|
||||
getServer().getPluginManager().registerEvents(main, this);
|
||||
if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) {
|
||||
getServer().getPluginManager().registerEvents(new PlayerEvents_1_8(), this);
|
||||
}
|
||||
if (PS.get().checkVersion(getServerVersion(), 1, 8, 3)) {
|
||||
getServer().getPluginManager().registerEvents(new PlayerEvents183(), this);
|
||||
}
|
||||
if (PS.get().checkVersion(getServerVersion(), 1, 9, 0)) {
|
||||
getServer().getPluginManager().registerEvents(new PlayerEvents_1_9(main), this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,6 +28,16 @@ import com.plotsquared.bukkit.object.BukkitPlayer;
|
|||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.listener.PlayerBlockEventType;
|
||||
import com.plotsquared.listener.PlotListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
|
@ -108,17 +118,6 @@ import org.bukkit.projectiles.BlockProjectileSource;
|
|||
import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Player Events involving plots.
|
||||
*
|
||||
|
@ -271,15 +270,15 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||
}
|
||||
|
||||
@EventHandler
|
||||
public void onProjectileHit(ProjectileHitEvent event) {
|
||||
public boolean onProjectileHit(ProjectileHitEvent event) {
|
||||
Projectile entity = event.getEntity();
|
||||
Location loc = BukkitUtil.getLocation(entity);
|
||||
if (!PS.get().hasPlotArea(loc.getWorld())) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
PlotArea area = loc.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
Plot plot = area.getPlotAbs(loc);
|
||||
//
|
||||
|
@ -289,28 +288,32 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||
if (plot == null) {
|
||||
if (!Permissions.hasPermission(pp, C.PERMISSION_PROJECTILE_UNOWNED)) {
|
||||
entity.remove();
|
||||
return false;
|
||||
}
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_PROJECTILE_OTHER)) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
entity.remove();
|
||||
return false;
|
||||
} else if (!(shooter instanceof Entity) && shooter != null) {
|
||||
if (plot == null) {
|
||||
entity.remove();
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
Location sLoc = BukkitUtil.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
|
||||
if (!area.contains(sLoc.getX(), sLoc.getZ())) {
|
||||
entity.remove();
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
Plot sPlot = area.getOwnedPlotAbs(sLoc);
|
||||
if (sPlot == null || !PlotHandler.sameOwners(plot, sPlot)) {
|
||||
entity.remove();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
|
@ -2035,11 +2038,16 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||
if (!PS.get().hasPlotArea(l.getWorld())) {
|
||||
return;
|
||||
}
|
||||
int count = 0;
|
||||
for (LivingEntity victim : event.getAffectedEntities()) {
|
||||
if (!entityDamage(damager, victim)) {
|
||||
event.setIntensity(victim, 0);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if ((count > 0 && count == event.getAffectedEntities().size()) || !onProjectileHit(event)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package com.plotsquared.bukkit.listeners;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import org.bukkit.entity.LingeringPotion;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.LingeringPotionSplashEvent;
|
||||
|
||||
/**
|
||||
* Created by Jesse on 3/30/2016.
|
||||
*/
|
||||
public class PlayerEvents_1_9 implements Listener {
|
||||
|
||||
private final PlayerEvents parent;
|
||||
|
||||
public PlayerEvents_1_9(PlayerEvents parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPotionSplash(LingeringPotionSplashEvent event) {
|
||||
LingeringPotion entity = event.getEntity();
|
||||
Location l = BukkitUtil.getLocation(entity);
|
||||
if (!PS.get().hasPlotArea(l.getWorld())) {
|
||||
return;
|
||||
}
|
||||
if (!parent.onProjectileHit(event)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue