mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Fixes #1970
This commit is contained in:
parent
40635255e3
commit
442513b592
@ -87,12 +87,7 @@ import com.sk89q.worldedit.WorldEdit;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -527,28 +522,44 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
case SHULKER: {
|
case SHULKER: {
|
||||||
if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
|
if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
|
||||||
LivingEntity livingEntity = (LivingEntity) entity;
|
LivingEntity livingEntity = (LivingEntity) entity;
|
||||||
if (entity.hasMetadata("plot")) {
|
List<MetadataValue> meta = entity.getMetadata("plot");
|
||||||
if (!livingEntity.isLeashed() || !entity.hasMetadata("keep")) {
|
if (meta != null && !meta.isEmpty()) {
|
||||||
PlotId originalPlotId = (PlotId) (!entity.getMetadata("plot").isEmpty() ? entity.getMetadata("plot").get(0).value() : null);
|
if (livingEntity.isLeashed()) continue;
|
||||||
PlotId currentPlotId = BukkitUtil.getLocation(entity.getLocation()).getPlot().getId();
|
|
||||||
if (!currentPlotId.equals(originalPlotId)) {
|
List<MetadataValue> keep = entity.getMetadata("keep");
|
||||||
|
if (keep != null && !keep.isEmpty()) continue;
|
||||||
|
|
||||||
|
PlotId originalPlotId = (PlotId) meta.get(0).value();
|
||||||
|
if (originalPlotId != null) {
|
||||||
|
com.intellectualcrafters.plot.object.Location pLoc = BukkitUtil.getLocation(entity.getLocation());
|
||||||
|
PlotArea area = pLoc.getPlotArea();
|
||||||
|
if (area != null) {
|
||||||
|
PlotId currentPlotId = PlotId.of(area.getPlotAbs(pLoc));
|
||||||
|
if (!originalPlotId.equals(currentPlotId) && (currentPlotId == null || !area.getPlot(originalPlotId).equals(area.getPlot(currentPlotId)))) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
entity.remove();
|
entity.remove();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!entity.hasMetadata("plot")) {
|
|
||||||
//This is to apply the metadata to already spawned shulkers (see EntitySpawnListener.java)
|
//This is to apply the metadata to already spawned shulkers (see EntitySpawnListener.java)
|
||||||
entity.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, BukkitUtil.getLocation(entity.getLocation()).getPlot().getId()));
|
com.intellectualcrafters.plot.object.Location pLoc = BukkitUtil.getLocation(entity.getLocation());
|
||||||
|
PlotArea area = pLoc.getPlotArea();
|
||||||
|
if (area != null) {
|
||||||
|
PlotId currentPlotId = PlotId.of(area.getPlotAbs(pLoc));
|
||||||
|
if (currentPlotId != null) {
|
||||||
|
entity.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, currentPlotId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.intellectualcrafters.plot.object;
|
package com.intellectualcrafters.plot.object;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class PlotId {
|
public class PlotId {
|
||||||
/**
|
/**
|
||||||
* x value
|
* x value
|
||||||
@ -77,6 +79,10 @@ public class PlotId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PlotId of(@Nullable Plot plot) {
|
||||||
|
return plot != null ? plot.getId() : null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the PlotId from the HashCode<br>
|
* Get the PlotId from the HashCode<br>
|
||||||
* Note: Only accurate for small x,z values (short)
|
* Note: Only accurate for small x,z values (short)
|
||||||
|
Loading…
Reference in New Issue
Block a user