mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 08:29:05 +00:00
Linked Packets
This commit is contained in:
1 parent
35da0f92f6
commit
b15d64bd09
9 files changed
+53
-51
No files matched your search
@@ -68,13 +68,7 @@ public class PacketHandlerServer{
|
||||
ItemStack item = player.inventory.getCurrentItem();
|
||||
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(type.needsNpc && npc == null){
|
||||
|
||||
}
|
||||
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.ScriptGlobalNPCGet || type == EnumPacketServer.ScriptGlobalNPCSave || type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave))
|
||||
if(item == null && (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave || type == EnumPacketServer.ScriptGlobalNPCGet || type == EnumPacketServer.ScriptGlobalNPCSave || type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave))
|
||||
warn(player, "tried to use custom npcs without a tool in hand, probably a hacker");
|
||||
else {
|
||||
if (item != null) {
|
||||
@@ -455,27 +449,7 @@ public class PacketHandlerServer{
|
||||
}
|
||||
|
||||
private void wandPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws IOException{
|
||||
if(type == EnumPacketServer.LinkedRemove){
|
||||
LinkedNpcController.Instance.removeData(ByteBufUtils.readString(buffer));
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
for(LinkedData data : LinkedNpcController.Instance.list)
|
||||
list.add(data.name);
|
||||
ScrollListPacket.sendList((EntityPlayerMP)player, list);
|
||||
}
|
||||
else if(type == EnumPacketServer.LinkedGetAll){
|
||||
List<String> list = new ArrayList<String>();
|
||||
for(LinkedData data : LinkedNpcController.Instance.list)
|
||||
list.add(data.name);
|
||||
ScrollListPacket.sendList((EntityPlayerMP)player, list);
|
||||
if(npc != null)
|
||||
ScrollSelectedPacket.setSelectedList(player, npc.linkedName);
|
||||
}
|
||||
else if(type == EnumPacketServer.LinkedSet){
|
||||
npc.linkedName = ByteBufUtils.readString(buffer);
|
||||
LinkedNpcController.Instance.loadNpcData(npc);
|
||||
}
|
||||
else if(type == EnumPacketServer.BanksGet){
|
||||
if(type == EnumPacketServer.BanksGet){
|
||||
NoppesUtilServer.sendBankDataAll(player);
|
||||
}
|
||||
else if(type == EnumPacketServer.BankGet){
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package noppes.npcs.client.gui.advanced;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.linked.LinkedGetAllPacket;
|
||||
import kamkeel.npcs.network.packets.request.linked.LinkedSetPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import noppes.npcs.client.Client;
|
||||
@@ -15,21 +18,21 @@ import java.util.Vector;
|
||||
public class GuiNPCAdvancedLinkedNpc extends GuiNPCInterface2 implements IScrollData, ICustomScrollListener{
|
||||
private GuiCustomScroll scroll;
|
||||
private List<String> data = new ArrayList<String>();
|
||||
|
||||
|
||||
public static GuiScreen Instance;
|
||||
|
||||
|
||||
public GuiNPCAdvancedLinkedNpc(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
Instance = this;
|
||||
Client.sendData(EnumPacketServer.LinkedGetAll);
|
||||
PacketClient.sendClient(new LinkedGetAllPacket());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
|
||||
|
||||
this.addButton(new GuiNpcButton(1,guiLeft + 358, guiTop + 38, 58, 20, "gui.clear"));
|
||||
|
||||
|
||||
if(scroll == null){
|
||||
scroll = new GuiCustomScroll(this,0);
|
||||
scroll.setSize(143, 208);
|
||||
@@ -44,9 +47,9 @@ public class GuiNPCAdvancedLinkedNpc extends GuiNPCInterface2 implements IScroll
|
||||
@Override
|
||||
public void buttonEvent(GuiButton button){
|
||||
if(button.id == 1){
|
||||
Client.sendData(EnumPacketServer.LinkedSet, "");
|
||||
PacketClient.sendClient(new LinkedSetPacket(""));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,13 +65,13 @@ public class GuiNPCAdvancedLinkedNpc extends GuiNPCInterface2 implements IScroll
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customScrollClicked(int i, int j, int k,
|
||||
GuiCustomScroll guiCustomScroll) {
|
||||
Client.sendData(EnumPacketServer.LinkedSet, guiCustomScroll.getSelected());
|
||||
PacketClient.sendClient(new LinkedSetPacket(guiCustomScroll.getSelected()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
package noppes.npcs.client.gui.global;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.linked.LinkedAddPacket;
|
||||
import kamkeel.npcs.network.packets.request.linked.LinkedGetAllPacket;
|
||||
import kamkeel.npcs.network.packets.request.linked.LinkedRemovePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import noppes.npcs.client.Client;
|
||||
@@ -23,7 +27,7 @@ public class GuiNPCManageLinkedNpc extends GuiNPCInterface2 implements IScrollDa
|
||||
public GuiNPCManageLinkedNpc(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
Instance = this;
|
||||
Client.sendData(EnumPacketServer.LinkedGetAll);
|
||||
PacketClient.sendClient(new LinkedGetAllPacket());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,7 +83,7 @@ public class GuiNPCManageLinkedNpc extends GuiNPCInterface2 implements IScrollDa
|
||||
}
|
||||
if(button.id == 2){
|
||||
if(scroll.hasSelected())
|
||||
Client.sendData(EnumPacketServer.LinkedRemove, scroll.getSelected());
|
||||
PacketClient.sendClient(new LinkedRemovePacket(scroll.getSelected()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -87,7 +91,7 @@ public class GuiNPCManageLinkedNpc extends GuiNPCInterface2 implements IScrollDa
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subgui) {
|
||||
if(!((SubGuiEditText)subgui).cancelled){
|
||||
Client.sendData(EnumPacketServer.LinkedAdd, ((SubGuiEditText)subgui).text);
|
||||
PacketClient.sendClient(new LinkedAddPacket(((SubGuiEditText)subgui).text));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package noppes.npcs.constants;
|
||||
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.client.gui.custom.components.CustomGuiButton;
|
||||
|
||||
public enum EnumPacketServer {
|
||||
NPCDelete(CustomNpcsPermissions.NPC_DELETE, true),
|
||||
@@ -33,7 +35,6 @@ public enum EnumPacketServer {
|
||||
RoleSave(CustomNpcsPermissions.NPC_ADVANCED, true), RoleGet(true),
|
||||
JobSpawnerAdd(CustomNpcsPermissions.NPC_ADVANCED, true), JobSpawnerRemove(CustomNpcsPermissions.NPC_ADVANCED, true),
|
||||
RoleCompanionUpdate(CustomNpcsPermissions.NPC_ADVANCED, true),
|
||||
LinkedSet(CustomNpcsPermissions.NPC_ADVANCED, true),
|
||||
|
||||
ClonePreSave(CustomNpcsPermissions.NPC_CLONE), CloneSave(CustomNpcsPermissions.NPC_CLONE), CloneRemove(CustomNpcsPermissions.NPC_CLONE), CloneList, CloneTagList, CloneAllTags, CloneAllTagsShort,
|
||||
|
||||
@@ -55,9 +56,6 @@ public enum EnumPacketServer {
|
||||
ScriptBlockDataSave(CustomNpcsPermissions.SCRIPT_BLOCK, false),
|
||||
ScriptBlockDataGet(false),
|
||||
|
||||
LinkedGetAll,
|
||||
LinkedRemove(CustomNpcsPermissions.GLOBAL_LINKED), LinkedAdd(CustomNpcsPermissions.GLOBAL_LINKED),
|
||||
|
||||
ScriptDataSave(CustomNpcsPermissions.SCRIPT_NPC, true), ScriptDataGet(true),
|
||||
EventScriptDataSave(CustomNpcsPermissions.SCRIPT_NPC, true), EventScriptDataGet(true),
|
||||
|
||||
|
||||
Reference in new issue
Block a user