mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-13 03:07:34 +00:00
commit
This commit is contained in:
1 parent
c2bc9c6c11
commit
e77a1032d3
2 files changed
+32
-3
No files matched your search
@@ -4,6 +4,8 @@ import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
@@ -11,6 +13,8 @@ import java.util.List;
|
||||
|
||||
public abstract class AbstractPacket {
|
||||
|
||||
public EntityNPCInterface npc;
|
||||
|
||||
public FMLProxyPacket generatePacket() {
|
||||
PacketChannel packetChannel = getChannel();
|
||||
ByteBuf buf = Unpooled.buffer();
|
||||
@@ -36,6 +40,19 @@ public abstract class AbstractPacket {
|
||||
|
||||
public abstract Enum getType();
|
||||
public abstract PacketChannel getChannel();
|
||||
|
||||
public CustomNpcsPermissions.Permission getPermission(){
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean needsNPC(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setNPC(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
}
|
||||
|
||||
public abstract void sendData(ByteBuf out) throws IOException;
|
||||
|
||||
//"player" on the server side is the client who sent this packet
|
||||
|
||||
@@ -18,7 +18,10 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -154,9 +157,18 @@ public final class PacketHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if(packetType == EnumChannelType.REQUEST){
|
||||
EnumRequestPacket requestPacket = EnumRequestPacket.values()[packetId];
|
||||
if()
|
||||
// Check if permission is allowed
|
||||
if(abstractPacket.getPermission() != null && !CustomNpcsPermissions.hasPermission(player, abstractPacket.getPermission())){
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for required NPC
|
||||
if(abstractPacket.needsNPC()){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null)
|
||||
return;
|
||||
|
||||
abstractPacket.setNPC(npc);
|
||||
}
|
||||
|
||||
// Let the packet parse the rest
|
||||
|
||||
Reference in new issue
Block a user