-Implemented spawnClone() with a boolean parameter to check entity protection from mods & plugins correctly (for real this time).

ICloneHandler:
-Implemented ignoreProtection boolean value for the spawn() function.
This commit is contained in:
c0508383 committed 2022-07-06 01:29:43 -07:00
1 parent a4585fdf4d
commit a3b5f5993e
5 files changed
+51 -8

No files matched your search

@@ -588,14 +588,21 @@ public class ScriptWorld implements IWorld {
* @param name Name of the cloned entity
* @return Returns the entity which was spawned
*/
public IEntity spawnClone(int x, int y, int z, int tab, String name){
public IEntity spawnClone(int x, int y, int z, int tab, String name, boolean ignoreProtection){
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(null, name, tab);
if(compound == null)
return null;
Entity entity = NoppesUtilServer.spawnClone(compound, x, y, z, world);
if(entity == null)
return null;
return NpcAPI.Instance().getIEntity(entity);
Entity entity;
if (!ignoreProtection) {
entity = NoppesUtilServer.spawnCloneWithProtection(compound, x, y, z, world);
} else {
entity = NoppesUtilServer.spawnClone(compound, x, y, z, world);
}
return entity == null ? null : NpcAPI.Instance().getIEntity(entity);
}
public IEntity spawnClone(int x, int y, int z, int tab, String name) {
return this.spawnClone(x,y,z,tab,name,true);
}
public ScriptScoreboard getScoreboard(){
@@ -346,8 +346,11 @@ public interface IWorld {
* @param z The z position the clone will be spawned at
* @param tab The tab in which the clone is
* @param name Name of the cloned entity
* @param ignoreProtection Whether the spawning of this clone skips protection checks.
* @return Returns the entity which was spawned
*/
IEntity spawnClone(int x, int y, int z, int tab, String name, boolean ignoreProtection);
IEntity spawnClone(int x, int y, int z, int tab, String name);
ScriptScoreboard getScoreboard();
@@ -9,6 +9,9 @@ import noppes.npcs.scripted.interfaces.IWorld;
import noppes.npcs.scripted.interfaces.entity.IEntity;
public interface ICloneHandler {
IEntity spawn(double x, double y, double z, int tab, String name, IWorld world, boolean ignoreProtection);
IEntity spawn(double x, double y, double z, int tab, String name, IWorld world);
IEntity[] getTab(int tab, IWorld world);