Config Overhaul

This commit is contained in:
KAMKEEL committed 2023-01-07 00:21:08 -05:00
1 parent b4cb69000e
commit 6e92f08851
51 files changed
+764 -395

No files matched your search

@@ -31,6 +31,9 @@ import net.minecraft.village.MerchantRecipeList;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager;
import noppes.npcs.config.ConfigDebug;
import noppes.npcs.config.ConfigMain;
import noppes.npcs.config.ConfigScript;
import noppes.npcs.constants.EnumCompanionStage;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumJobType;
@@ -61,7 +64,7 @@ public class PacketHandlerServer{
@SubscribeEvent
public void onServerPacket(ServerCustomPacketEvent event) {
EntityPlayerMP player = ((NetHandlerPlayServer)event.handler).playerEntity;
if(CustomNpcs.OpsOnly && !NoppesUtilServer.isOp(player)){
if(ConfigMain.OpsOnly && !NoppesUtilServer.isOp(player)){
warn(player, "tried to use custom npcs without being an op");
return;
}
@@ -123,7 +126,7 @@ public class PacketHandlerServer{
featherPackets(type, buffer, player);
else if (item.getItem() == Item.getItemFromBlock(CustomItems.waypoint) || item.getItem() == Item.getItemFromBlock(CustomItems.border) || item.getItem() == Item.getItemFromBlock(CustomItems.redstoneBlock))
blockPackets(type, buffer, player);
else if (CustomNpcs.isScriptDev(player)) {
else if (ConfigScript.isScriptDev(player)) {
if (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave)
playerScriptPackets(type, buffer, player);
else if (type == EnumPacketServer.ScriptNPCGet || type == EnumPacketServer.ScriptNPCSave)
@@ -178,18 +181,18 @@ public class PacketHandlerServer{
private void getScriptsEnabled(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException {
if (type == EnumPacketServer.ScriptGlobalGuiDataGet) {
NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("ScriptsEnabled", CustomNpcs.ScriptingEnabled);
compound.setBoolean("PlayerScriptsEnabled", CustomNpcs.GlobalPlayerScripts);
compound.setBoolean("GlobalNPCScriptsEnabled", CustomNpcs.GlobalNPCScripts);
compound.setBoolean("ForgeScriptsEnabled", CustomNpcs.GlobalForgeScripts);
compound.setBoolean("ScriptsEnabled", ConfigScript.ScriptingEnabled);
compound.setBoolean("PlayerScriptsEnabled", ConfigScript.GlobalPlayerScripts);
compound.setBoolean("GlobalNPCScriptsEnabled", ConfigScript.GlobalNPCScripts);
compound.setBoolean("ForgeScriptsEnabled", ConfigScript.GlobalForgeScripts);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
}
else if (type == EnumPacketServer.ScriptGlobalGuiDataSave) {
NBTTagCompound compound = Server.readNBT(buffer);
CustomNpcs.ScriptingEnabled = compound.getBoolean("ScriptsEnabled");
CustomNpcs.GlobalPlayerScripts = compound.getBoolean("PlayerScriptsEnabled");
CustomNpcs.GlobalNPCScripts = compound.getBoolean("GlobalNPCScriptsEnabled");
CustomNpcs.GlobalForgeScripts = compound.getBoolean("ForgeScriptsEnabled");
ConfigScript.ScriptingEnabled = compound.getBoolean("ScriptsEnabled");
ConfigScript.GlobalPlayerScripts = compound.getBoolean("PlayerScriptsEnabled");
ConfigScript.GlobalNPCScripts = compound.getBoolean("GlobalNPCScriptsEnabled");
ConfigScript.GlobalForgeScripts = compound.getBoolean("ForgeScriptsEnabled");
}
}
@@ -198,7 +201,7 @@ public class PacketHandlerServer{
npc.script.readFromNBT(Server.readNBT(buffer));
npc.updateAI = true;
npc.script.hasInited = false;
if(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] (Player) %s SAVED NPC %s (%s, %s, %s) [%s]", "SCRIPTER", player.getCommandSenderName(), npc.display.getName(), (int)npc.posX, (int)(npc).posY, (int)npc.posZ, npc.worldObj.getWorldInfo().getWorldName()));
}
}
@@ -373,7 +376,7 @@ public class PacketHandlerServer{
private void wandPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws IOException{
if(type == EnumPacketServer.Delete){
if(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] (Player) %s DELETE NPC %s (%s, %s, %s) [%s]", "WAND", player.getCommandSenderName(), npc.display.getName(), (int)npc.posX, (int)npc.posY, (int)npc.posZ, npc.worldObj.getWorldInfo().getWorldName()));
}
npc.delete();
@@ -411,7 +414,7 @@ public class PacketHandlerServer{
npc.reset();
if(npc.linkedData != null)
LinkedNpcController.Instance.saveNpcData(npc);
if(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] (Player) %s CLOSE NPC %s (%s, %s, %s) [%s]", "WAND", player.getCommandSenderName(), npc.display.getName(), (int)npc.posX, (int)npc.posY, (int)npc.posZ, npc.worldObj.getWorldInfo().getWorldName()));
}
NoppesUtilServer.setEditingNpc(player, null);
@@ -440,7 +443,7 @@ public class PacketHandlerServer{
if(entity == null || !(entity instanceof EntityNPCInterface))
return;
NoppesUtilServer.sendOpenGui(player, EnumGuiType.MainMenuDisplay, (EntityNPCInterface) entity);
if(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "WAND", player.getCommandSenderName(), ((EntityNPCInterface)entity).display.getName(), entity.posX, entity.posY, entity.posZ, entity.worldObj.getWorldInfo().getWorldName()));
}
}
@@ -449,7 +452,7 @@ public class PacketHandlerServer{
if(entity == null || !(entity instanceof EntityNPCInterface))
return;
npc = (EntityNPCInterface) entity;
if(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] (Player) %s DELETE NPC %s (%s, %s, %s) [%s]", "WAND", player.getCommandSenderName(), npc.display.getName(), (int)npc.posX, (int)npc.posY, (int)npc.posZ, npc.worldObj.getWorldInfo().getWorldName()));
}
npc.delete();
@@ -879,7 +882,7 @@ public class PacketHandlerServer{
player.addChatMessage(new ChatComponentText("Failed to create an entity out of your clone"));
return;
}
if(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] (Player) %s SPAWNED ENTITY %s", "CLONER", player.getCommandSenderName(), entity));
}
}