fix: shulker-teleport in a other plot (#1774)

- shulker-teleport in a other plot (Fixes #1762)
 - dropper can't drop lava_bucket and water_bucket  (Fixes #1775)
This commit is contained in:
Christian Langel 2017-12-03 17:21:15 +01:00 committed by Alexander Söderberg
parent 06208696db
commit 3779b17720
3 changed files with 36 additions and 1 deletions

View File

@ -99,8 +99,10 @@ import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Shulker;
import org.bukkit.event.Listener;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
@ -469,6 +471,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
if (!(passenger instanceof Player) && entity.getMetadata("keep").isEmpty()) {
iterator.remove();
entity.remove();
entity = null;
}
}
} else {
@ -476,6 +479,30 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
if (!(passenger instanceof Player) && entity.getMetadata("keep").isEmpty()) {
iterator.remove();
entity.remove();
entity = null;
}
}
}
}
if (entity != null && BukkitUtil.getLocation(entity.getLocation()).isPlotArea()) {
if (entity instanceof Shulker) {
LivingEntity livingEntity = (LivingEntity) entity;
if (entity.hasMetadata("ownerplot")) {
if(!livingEntity.isLeashed() || !entity.hasMetadata("keep")) {
PlotId originalPlotId = (PlotId) (!entity.getMetadata("ownerplot").isEmpty() ? entity.getMetadata("ownerplot").get(0).value() : null);
PlotId currentPlotId = BukkitUtil.getLocation(entity.getLocation()).getPlot().getId();
if(!currentPlotId.equals(originalPlotId)) {
iterator.remove();
entity.remove();
}
}
}
else {
if(!entity.hasMetadata("ownerplot")) {
//This is to apply the metadata to already spawned shulkers (see EntitySpawnListener.java)
entity.setMetadata("ownerplot", new FixedMetadataValue((Plugin) PS.get().IMP, BukkitUtil.getLocation(entity.getLocation()).getPlot().getId()));
}
}
}

View File

@ -1,5 +1,6 @@
package com.plotsquared.bukkit.listeners;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.flag.Flags;
import com.intellectualcrafters.plot.object.Location;
@ -11,6 +12,8 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.Plugin;
public class EntitySpawnListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@ -38,6 +41,10 @@ public class EntitySpawnListener implements Listener {
if (PlayerEvents.checkEntity(entity, plot)) {
event.setCancelled(true);
}
case SHULKER:
if(!entity.hasMetadata("ownerplot")) {
entity.setMetadata("ownerplot", new FixedMetadataValue((Plugin) PS.get().IMP, plot.getId()));
}
}
}
}

View File

@ -1263,7 +1263,8 @@ public class PlayerEvents extends PlotListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockDispense(BlockDispenseEvent event) {
Material type = event.getItem().getType();
if (type != Material.WATER_BUCKET && type != Material.LAVA_BUCKET) {
Material dispenserType = event.getBlock().getType();
if (dispenserType == Material.DROPPER || (type != Material.WATER_BUCKET && type != Material.LAVA_BUCKET)) {
return;
}
Location location = BukkitUtil.getLocation(event.getVelocity().toLocation(event.getBlock().getWorld()));