Jump to content

Katherine1

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by Katherine1

  1. I need to be able to detect when a player right clicks on another character and be able to tell who they clicked on, and who is doing the clicking. Unfortunately, Forge's lack of documentation and lack of mentioning anything on this topic in close to a decade has left me guessing and failing to come up with an event that would work. On the server side, the PlayerInteractEvent sounds promising on paper, but it doesn't seem to contain any members that would get me information on both players in question. On the client side, I could detect keypresses, but then I have no way of really getting information on who they clicked. So is there a way to do this?
  2. I'm aware that Forge already uses Log4J for logging and exposes a preconfigured logger for each mod though FMLPreInitializationEvent::getModLog() however, for my purposes, this is insufficient. I need to be able to actually set the configuration of the logger as I need to have two separate loggers, one as a debug logger that can be configured to only log error level or above on the actually server while being able to be set to trace level on a developer machine. The other would simply be for maintaining a chat log with some custom information. This would be fairly trivial if I could configure the loggers myself, however, there doesn't seem to be an exposed log4j configuration in a Forge setup, and if I try to define my own and pass it to Log4J programmatically, FML overrides. For instance, here is a log4j configuration: <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="debug-file" class="org.apache.log4j.RollingFileAppender"> <param name="File" value="C:\path\to\debug.log"/> <param name="append" value="true"/> <param name="encoding" value="UTF-8"/> <param name="MaxFileSize" value="500MB"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d{ISO8601} %p | %m%n"/> </layout> </appender> <logger name="logger.name" additivity="false"> <level value="all"/> <appender-ref ref="debug-file"/> </logger> </log4j:configuration> This is a perfectly fine Log4J configuration for a logger. The problem comes below: ConfigurationSource source = new ConfigurationSource(new FileInputStream(new File("C:\path\to\config.xml"))); LoggerContext logSource = Configurator.initialize(null, source); Logger logger = logSource.getLogger("logger.name"); To pass a configuration file into Log4J programmatically you'd do those first two lines, and then you should be able to just get the logger from the resulting LoggerContext. Unfortunately, what I end up getting is the preconfigured pile of loggers from Forge. So, is there any way that I can define my loggers with a custom config, or do I just need to give up and configure them entirely programmatically?
  3. I think I got it. I tossed out using Forge's resource loader for Java's. I can get the folder as a File object, and then I can get an array of files contained by the folder, which gives me a count of the schema revisions in the app. Then it's simply a matter of iterating through the files in that folder in numeric order and running the SQL scripts against the database.
  4. In my mod, I have scripts for initializing and updating the database it will be using as separate resources. They are all in the same folder and named with <number>.sql Now, I can access any of them with new ResourceLocation("modid", "sql/1.sql"); The issue is that this list of files may grow and it'd be preferable to iterate over these files. Is there a way to get how many files are in that sql folder?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.