ScriptLogIgnoreType & PlayerLogging

This commit is contained in:
KAMKEEL committed 2022-11-05 23:32:54 -04:00
1 parent 7692c1b628
commit ac39e0a6d0
6 files changed
+141 -14

No files matched your search

+63 -2
View File
@@ -23,6 +23,7 @@ import net.minecraftforge.common.MinecraftForge;
import nikedemos.markovnames.generators.*;
import noppes.npcs.config.ConfigLoader;
import noppes.npcs.config.ConfigProp;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.*;
import noppes.npcs.enchants.EnchantInterface;
import noppes.npcs.entity.*;
@@ -32,6 +33,7 @@ import noppes.npcs.scripted.NpcAPI;
import java.io.File;
import java.util.ArrayList;
import java.util.Set;
import java.util.Timer;
import java.util.UUID;
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.6.4")
@@ -59,7 +61,12 @@ public class CustomNpcs {
"Every additional compound tag adds 65535 more characters to your script length limit. Use incrementally, with caution.")
public static int ExpandedScriptLimit = 2;
@ConfigProp(info = "Enables if Scripting Information should be printed to CustomNPCs Logs")
@ConfigProp(info = "Enables if Player Information (WAND-USE) should be printed to CustomNPCs Logs. IF on Server \n" +
"Logs will only be present SERVER-SIDE only in CustomNPCs-latest, -1, -2, and -3")
public static boolean PlayerLogging = false;
@ConfigProp(info = "Enables if Scripting Information should be printed to CustomNPCs Logs. IF on Server \n" +
"Logs will only be present SERVER-SIDE only in CustomNPCs-latest, -1, -2, and -3")
public static boolean ScriptLogging = false;
@ConfigProp(info = "Amount of Messages marked as SPAM [5, 3000]. Lower Number means MORE accurate messages \n" +
@@ -69,6 +76,10 @@ public class CustomNpcs {
@ConfigProp(info = "IN Milliseconds 1s = 1000s. If a recent LOG of the same event is SENT within this threshold it will be ignored.")
public static int ScriptIgnoreTime = 2000;
@ConfigProp(info = "Comma separated list of NPC Script Types that will omit these from the logs,\n" +
"INIT,TICK,INTERACT,DIALOG,DAMAGED,KILLED,ATTACK,TARGET,COLLIDE,KILLS,DIALOG_CLOSE,TIMER")
public static String ScriptLogIgnoreType = "TICK";
@ConfigProp(info = "Navigation search range for NPCs. Not recommended to increase if you have a slow pc or on a server. Minimum of 16, maximum of 96.")
public static int NpcNavRange = 32;
@@ -181,6 +192,19 @@ public class CustomNpcs {
public static final MarkovGenerator[] MARKOV_GENERATOR = new MarkovGenerator[10];
public static boolean InitIgnore = false;
public static boolean TickIgnore = false;
public static boolean InteractIgnore = false;
public static boolean DialogIgnore = false;
public static boolean DamagedIgnore = false;
public static boolean KilledIgnore = false;
public static boolean AttackIgnore = false;
public static boolean TargetIgnore = false;
public static boolean CollideIgnore = false;
public static boolean KillsIgnore = false;
public static boolean DialogCloseIgnore = false;
public static boolean TimerIgnore = false;
public CustomNpcs() {
instance = this;
}
@@ -205,7 +229,7 @@ public class CustomNpcs {
try {
ScriptDevs.clear();
String[] uuidStrings = ScriptDevIDs.split(";");
String[] uuidStrings = ScriptDevIDs.split(",");
for (String s : uuidStrings) {
ScriptDevs.add(UUID.fromString(s));
}
@@ -245,6 +269,43 @@ public class CustomNpcs {
if (ScriptIgnoreTime < 0)
ScriptIgnoreTime = 0;
try {
String[] ignoreTypes = ScriptLogIgnoreType.split(",");
for (String s : ignoreTypes) {
EnumScriptType type = EnumScriptType.valueOfIgnoreCase(s);
if(type != null){
switch (type){
case INIT:
InitIgnore = true;
case TICK:
TickIgnore = true;
case INTERACT:
InteractIgnore = true;
case DIALOG:
DialogIgnore = true;
case DAMAGED:
DamagedIgnore = true;
case KILLED:
KilledIgnore = true;
case ATTACK:
AttackIgnore = true;
case TARGET:
TargetIgnore = true;
case COLLIDE:
CollideIgnore = true;
case KILLS:
KillsIgnore = true;
case DIALOG_CLOSE:
DialogCloseIgnore = true;
case TIMER:
TimerIgnore = true;
default:
break;
}
}
}
} catch (Exception ignored) {}
EnchantInterface.load();
CustomItems.load();
+36 -12
View File
@@ -102,39 +102,63 @@ public class LogWriter {
public static void postScriptLog(UUID npcUUID, EnumScriptType type, String message) {
switch (type){
case INIT:
scriptLogCalculator(InitCacheMap, npcUUID, message);
if(!CustomNpcs.InitIgnore){
scriptLogCalculator(InitCacheMap, npcUUID, message);
}
break;
case TICK:
scriptLogCalculator(TickCacheMap, npcUUID, message);
if(!CustomNpcs.TickIgnore){
scriptLogCalculator(TickCacheMap, npcUUID, message);
}
break;
case INTERACT:
scriptLogCalculator(InteractCacheMap, npcUUID, message);
if(!CustomNpcs.InteractIgnore){
scriptLogCalculator(InteractCacheMap, npcUUID, message);
}
break;
case DIALOG:
scriptLogCalculator(DialogCacheMap, npcUUID, message);
if(!CustomNpcs.DialogIgnore){
scriptLogCalculator(DialogCacheMap, npcUUID, message);
}
break;
case DAMAGED:
scriptLogCalculator(DamagedCacheMap, npcUUID, message);
if(!CustomNpcs.DamagedIgnore){
scriptLogCalculator(DamagedCacheMap, npcUUID, message);
}
break;
case KILLED:
scriptLogCalculator(KilledCacheMap, npcUUID, message);
if(!CustomNpcs.KilledIgnore){
scriptLogCalculator(KilledCacheMap, npcUUID, message);
}
break;
case ATTACK:
scriptLogCalculator(AttackCacheMap, npcUUID, message);
if(!CustomNpcs.AttackIgnore){
scriptLogCalculator(AttackCacheMap, npcUUID, message);
}
break;
case TARGET:
scriptLogCalculator(TargetCacheMap, npcUUID, message);
if(!CustomNpcs.TargetIgnore){
scriptLogCalculator(TargetCacheMap, npcUUID, message);
}
break;
case COLLIDE:
scriptLogCalculator(CollideCacheMap, npcUUID, message);
if(!CustomNpcs.CollideIgnore){
scriptLogCalculator(CollideCacheMap, npcUUID, message);
}
break;
case KILLS:
scriptLogCalculator(KillsCacheMap, npcUUID, message);
if(!CustomNpcs.KillsIgnore){
scriptLogCalculator(KillsCacheMap, npcUUID, message);
}
case DIALOG_CLOSE:
scriptLogCalculator(DialogCloseCacheMap, npcUUID, message);
if(!CustomNpcs.DialogCloseIgnore){
scriptLogCalculator(DialogCloseCacheMap, npcUUID, message);
}
break;
case TIMER:
scriptLogCalculator(TimerCacheMap, npcUUID, message);
if(!CustomNpcs.TimerIgnore){
scriptLogCalculator(TimerCacheMap, npcUUID, message);
}
break;
default:
break;
@@ -1,5 +1,7 @@
package noppes.npcs;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import foxz.utils.Market;
import io.netty.buffer.ByteBuf;
@@ -196,6 +198,9 @@ public class PacketHandlerServer{
npc.script.readFromNBT(Server.readNBT(buffer));
npc.updateAI = true;
npc.script.hasInited = false;
if(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] %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()));
}
}
else if(type == EnumPacketServer.ScriptDataGet){
NBTTagCompound compound = npc.script.writeToNBT(new NBTTagCompound());
@@ -368,6 +373,9 @@ 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){
LogWriter.script(String.format("[%s] %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();
NoppesUtilServer.deleteNpc(npc,player);
}
@@ -403,6 +411,9 @@ public class PacketHandlerServer{
npc.reset();
if(npc.linkedData != null)
LinkedNpcController.Instance.saveNpcData(npc);
if(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] %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);
}
else if(type == EnumPacketServer.BanksGet){
@@ -429,12 +440,18 @@ 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){
LogWriter.script(String.format("[%s] %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()));
}
}
else if(type == EnumPacketServer.RemoteDelete){
Entity entity = player.worldObj.getEntityByID(buffer.readInt());
if(entity == null || !(entity instanceof EntityNPCInterface))
return;
npc = (EntityNPCInterface) entity;
if(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] %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();
NoppesUtilServer.deleteNpc(npc,player);
NoppesUtilServer.sendNearbyNpcs(player);
@@ -862,6 +879,9 @@ 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){
LogWriter.script(String.format("[%s] %s SPAWNED ENTITY %s", "CLONER", player.getCommandSenderName(), entity));
}
}
else if(type == EnumPacketServer.MobSpawner){
boolean server = buffer.readBoolean();
@@ -4,7 +4,9 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
@@ -83,6 +85,9 @@ public class ServerEventsHandler {
if(!isRemote && item.getItem() == CustomItems.soulstoneEmpty && event.target instanceof EntityLivingBase) {
((ItemSoulstoneEmpty)item.getItem()).store((EntityLivingBase)event.target, item, event.entityPlayer);
if(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] %s PICKED ENTITY %s", "SOULSTONE", event.entityPlayer.getCommandSenderName(), event.target));
}
}
if(item.getItem() == CustomItems.wand && npcInteracted && !isRemote){
@@ -91,6 +96,9 @@ public class ServerEventsHandler {
}
event.setCanceled(true);
NoppesUtilServer.sendOpenGui(event.entityPlayer, EnumGuiType.MainMenuDisplay, (EntityNPCInterface) event.target);
if(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] %s OPEN NPC %s (%s, %s, %s) [%s]", "WAND", event.entityPlayer.getCommandSenderName(), ((EntityNPCInterface)(event.target)).display.getName(), (int)(event.target).posX, (int)(event.target).posY, (int)(event.target).posZ, (event.target).worldObj.getWorldInfo().getWorldName()));
}
}
else if(item.getItem() == CustomItems.cloner && !isRemote && !(event.target instanceof EntityPlayer)){
NBTTagCompound compound = new NBTTagCompound();
@@ -109,6 +117,9 @@ public class ServerEventsHandler {
NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface)event.target);
event.setCanceled(true);
Server.sendData((EntityPlayerMP)event.entityPlayer, EnumPacketClient.GUI, EnumGuiType.Script.ordinal());
if(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] %s OPEN NPC %s (%s, %s, %s) [%s]", "SCRIPTER", event.entityPlayer.getCommandSenderName(), ((EntityNPCInterface)(event.target)).display.getName(), (int)(event.target).posX, (int)(event.target).posY, (int)(event.target).posZ, (event.target).worldObj.getWorldInfo().getWorldName()));
}
}
else if(item.getItem() == CustomItems.mount){
if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_MOUNTER))
@@ -85,6 +85,11 @@ public enum EnumScriptType {
public String function;
public static EnumScriptType valueOfIgnoreCase(String channelName) {
channelName = channelName.toUpperCase();
return valueOf(channelName);
}
private EnumScriptType(String function) {
this.function = function;
}
@@ -2,6 +2,7 @@ package noppes.npcs.items;
import java.util.List;
import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.player.EntityPlayer;
@@ -11,6 +12,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter;
import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.PlayerDataController;
@@ -73,6 +76,9 @@ public class ItemSoulstoneFilled extends Item {
if(entity == null)
return false;
entity.setPosition(x + 0.5, y + 1 + 0.2F, z + 0.5);
if(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] %s PLACED ENTITY %s", "SOULSTONE", player.getCommandSenderName(), entity));
}
if(entity instanceof EntityNPCInterface){
EntityNPCInterface npc = (EntityNPCInterface) entity;
npc.ai.startPos = new int[]{x, y, z};