diff --git a/src/main/java/noppes/npcs/PacketHandlerServer.java b/src/main/java/noppes/npcs/PacketHandlerServer.java index 9e6cd4443..80a98d1f5 100644 --- a/src/main/java/noppes/npcs/PacketHandlerServer.java +++ b/src/main/java/noppes/npcs/PacketHandlerServer.java @@ -102,7 +102,7 @@ public class PacketHandlerServer{ if(type.needsNpc && npc == null){ } - else if(type.hasPermission() && !CustomNpcsPermissions.Instance.hasPermission(player, type.permission)){ + else if(type.hasPermission() && !CustomNpcsPermissions.hasPermission(player, type.permission)){ //player doesnt have permission to do this } else if(item == null && (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave || type == EnumPacketServer.ScriptNPCGet || type == EnumPacketServer.ScriptNPCSave || type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave)) diff --git a/src/main/java/noppes/npcs/scripted/ScriptWorld.java b/src/main/java/noppes/npcs/scripted/ScriptWorld.java index e377e486a..2b8ea1ba9 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptWorld.java +++ b/src/main/java/noppes/npcs/scripted/ScriptWorld.java @@ -2,6 +2,7 @@ package noppes.npcs.scripted; import java.util.*; +import com.mojang.authlib.GameProfile; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.effect.EntityLightningBolt; @@ -18,9 +19,12 @@ import net.minecraft.tileentity.TileEntitySign; import net.minecraft.util.Vec3; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; +import net.minecraftforge.common.util.FakePlayer; import noppes.npcs.CustomNpcs; +import noppes.npcs.CustomNpcsPermissions; import noppes.npcs.NoppesUtilServer; import noppes.npcs.blocks.tiles.TileBigSign; +import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.controllers.ScriptController; import noppes.npcs.controllers.ServerCloneController; import noppes.npcs.scripted.interfaces.IBlock; @@ -585,9 +589,20 @@ public class ScriptWorld implements IWorld { * @return Returns the entity which was spawned */ public IEntity spawnClone(int x, int y, int z, int tab, String name){ + return spawnClone(x,y,z,tab,name,true); + } + + 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; + + if (!ignoreProtection) { + FakePlayer fakePlayer = new FakePlayer(world, new GameProfile(null, "NpcAPI")); + if (!CustomNpcsPermissions.hasPermission(fakePlayer, EnumPacketServer.SpawnMob.permission)) + return null; + } + Entity entity = NoppesUtilServer.spawnClone(compound, x, y, z, world); if(entity == null) return null; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java b/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java index 275d51e0f..c7d1e6297 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java @@ -350,6 +350,8 @@ public interface IWorld { */ IEntity spawnClone(int x, int y, int z, int tab, String name); + IEntity spawnClone(int x, int y, int z, int tab, String name, boolean ignoreProtection); + ScriptScoreboard getScoreboard(); /**