Apply Configs to Packets

This commit is contained in:
Kam committed 2025-02-22 22:29:27 -05:00
1 parent aeee864bf7
commit 294abe4d25
6 files changed
+32 -6

No files matched your search

@@ -9,9 +9,11 @@ import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.enums.EnumRequestPacket;
import kamkeel.npcs.network.packets.data.ChatAlertPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.CustomNpcsPermissions;
import noppes.npcs.config.ConfigMain;
import java.io.IOException;
@@ -52,11 +54,13 @@ public final class ProfileChangePacket extends AbstractPacket {
if (!(player instanceof EntityPlayerMP))
return;
if(!ConfigMain.ProfilesEnabled)
return;
int slot = in.readInt();
ProfileOperation operation = ProfileController.Instance.changeSlot(player, slot);
// TODO: Check Operation and Send Message
ProfileGetPacket.sendProfileNBT(player);
ProfileGetInfoPacket.sendProfileInfo(player);
ChatAlertPacket.sendChatAlert((EntityPlayerMP) player, operation.getMessage());
}
}
@@ -10,9 +10,11 @@ import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.enums.EnumRequestPacket;
import kamkeel.npcs.network.packets.data.ChatAlertPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.CustomNpcsPermissions;
import noppes.npcs.config.ConfigMain;
import java.io.IOException;
@@ -45,9 +47,13 @@ public final class ProfileCreatePacket extends AbstractPacket {
if (!(player instanceof EntityPlayerMP))
return;
if(!ConfigMain.ProfilesEnabled)
return;
Profile profile = ProfileController.Instance.getProfile(player);
ProfileOperation operation = ProfileController.Instance.createSlotInternal(profile);
ProfileGetPacket.sendProfileNBT(player);
ProfileGetInfoPacket.sendProfileInfo(player);
ChatAlertPacket.sendChatAlert((EntityPlayerMP) player, operation.getMessage());
}
}
@@ -17,6 +17,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.util.Constants;
import noppes.npcs.config.ConfigMain;
import java.io.IOException;
import java.util.ArrayList;
@@ -47,6 +48,9 @@ public final class ProfileGetInfoPacket extends AbstractPacket {
if (!(player instanceof EntityPlayerMP))
return;
if(!ConfigMain.ProfilesEnabled)
return;
sendProfileInfo(player);
}
@@ -13,6 +13,7 @@ import kamkeel.npcs.network.packets.data.large.GuiDataPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.config.ConfigMain;
import java.io.IOException;
@@ -40,6 +41,9 @@ public final class ProfileGetPacket extends AbstractPacket {
if (!(player instanceof EntityPlayerMP))
return;
if(!ConfigMain.ProfilesEnabled)
return;
sendProfileNBT(player);
}
@@ -9,9 +9,11 @@ import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.enums.EnumRequestPacket;
import kamkeel.npcs.network.packets.data.ChatAlertPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.CustomNpcsPermissions;
import noppes.npcs.config.ConfigMain;
import java.io.IOException;
@@ -52,12 +54,13 @@ public final class ProfileRemovePacket extends AbstractPacket {
if (!(player instanceof EntityPlayerMP))
return;
if(!ConfigMain.ProfilesEnabled)
return;
int slot = in.readInt();
ProfileOperation operation = ProfileController.Instance.removeSlot(player, slot);
// TODO: Check Operation and Send Message
ProfileGetPacket.sendProfileNBT(player);
ProfileGetInfoPacket.sendProfileInfo(player);
ChatAlertPacket.sendChatAlert((EntityPlayerMP) player, operation.getMessage());
}
}
@@ -9,10 +9,12 @@ import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.enums.EnumRequestPacket;
import kamkeel.npcs.network.packets.data.ChatAlertPacket;
import kamkeel.npcs.util.ByteBufUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.CustomNpcsPermissions;
import noppes.npcs.config.ConfigMain;
import java.io.IOException;
@@ -56,12 +58,15 @@ public final class ProfileRenamePacket extends AbstractPacket {
if (!(player instanceof EntityPlayerMP))
return;
if(!ConfigMain.ProfilesEnabled)
return;
int slot = in.readInt();
String newName = ByteBufUtils.readString(in);
Profile profile = ProfileController.Instance.getProfile(player);
if(!profile.getSlots().containsKey(slot)) {
// TODO: Check Operation and Send Message
ChatAlertPacket.sendChatAlert((EntityPlayerMP) player, "No slot found");
return;
}