Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Anubis-class Cruiser (12/20/24)

Pages: 1 ... 235 236 [237] 238 239 ... 751

Author Topic: Misc modding questions that are too minor to warrant their own thread  (Read 2028200 times)

TJJ

  • Admiral
  • *****
  • Posts: 1906
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3540 on: August 30, 2017, 09:08:11 AM »

Without seeing some screenshots, it's hard to say whether you've encountered a Janino bug (of which there are many, especially relating to the resolving of imports), or have made a mistake yourself.

General problem solving process should work though; reduce the number of contributing factors until it starts working, and build up from there.

Start with a class whose name & package precisely matches the source file's location & name, and which contains the absolute minimum of imports & zero functional code.

Changing  
"modPlugin":"data.scripts.SCModPlugin"     <---- this seems to only work if it's in a .jar
into  
"modPlugin":"data\scripts\SCModPlugin.java"

stops the crash, but it does so because the game doesn't see my mod anymore. Cant select it.

WTF is going on?

Don't guess; read the spec.

The modPlugin attribute in mod_info.json should be the fully qualified name of a class implementing the com.fs.starfarer.api.ModPlugin interface.
« Last Edit: August 30, 2017, 09:10:27 AM by TJJ »
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3541 on: August 30, 2017, 09:16:19 AM »

Also, if you haven't set up NetBeans / Eclipse, do that immediately; it would have told you that your current code has a bunch of un-necessary dependencies it's loading, any of which might be the cause of the issue.  I know that learning how to build a JAR seems rather confusing / intimidating at first, but it's basically a one-time setup hassle and after that, it's easy :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

TrashMan

  • Admiral
  • *****
  • Posts: 1329
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3542 on: August 30, 2017, 12:11:20 PM »

Bloody hell. Got the SDF kit, compiled, still the same s***

Here's the contents of the .jar (attached image)

And here's the code for the SCModPlugin

Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.impl.campaign.shared.SharedData;

public class SCModPlugin extends BaseModPlugin {

    @Override
    public void onNewGame() {
        updateConditionSpecs();
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("ISA");
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("RSF");
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("UIN");
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("XLE");
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("FFS");
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("VNS");
    }

}


[attachment deleted by admin]
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3543 on: August 30, 2017, 12:22:05 PM »

Post a link to a copy of your mod as it is now via PM and I'll take a look.  It's probably something small that's tripping you up somewhere :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

TrashMan

  • Admiral
  • *****
  • Posts: 1329
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3544 on: August 30, 2017, 02:08:24 PM »

https://www.mediafire.com/folder/r40qicb1txupx/StarSector

Steelclad_v06_TEST is the main mod (data, jar and mod_info)
You'll need the sounds.rar and graphics.rar too

Also, EZFaction or NExirilien
« Last Edit: August 31, 2017, 12:23:41 AM by TrashMan »
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1329
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3545 on: August 31, 2017, 11:41:47 AM »

Anything?
Logged

Tufted Titmouse

  • Lieutenant
  • **
  • Posts: 70
  • Fire the missiles. All of them.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3546 on: September 01, 2017, 08:23:31 AM »

Working on making a private mod Nexerelin compatible, keeps giving me this
Code
Caused by: java.lang.ClassNotFoundException: File 'data/scripts/AleuramPlugin.java', Line 10, Column 39: Unknown variable or type "Global"
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
at org.codehaus.janino.CachingJavaSourceClassLoader.generateBytecodes(CachingJavaSourceClassLoader.java:163)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
plugin file looks like
Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import exerelin.campaign.SectorManager;

public class AleuramPlugin extends BaseModPlugin {

    @Override
    public void onNewGame() {
        boolean haveNexerelin = Global.getSettings().getModManager().isModEnabled("nexerelin");
        if (!haveNexerelin || SectorManager.getCorvusMode()){
            new ADFSectorgen().generate(Global.getSector());
        }
}
}

Any way to fix it?

Edit: Good god am i stupid
I forgot to add
Code
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.PluginPick;
import com.fs.starfarer.api.campaign.CampaignPlugin;
import com.fs.starfarer.api.combat.MissileAIPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.combat.ShipAPI;


Edit: Another error.
Code
Caused by: java.lang.ClassNotFoundException: File 'data/scripts/AleuramPlugin.java', Line 18, Column 29: Cannot determine simple type name "AdfSysGen"
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
at org.codehaus.janino.CachingJavaSourceClassLoader.generateBytecodes(CachingJavaSourceClassLoader.java:163)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more

plugin looks like
Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.PluginPick;
import com.fs.starfarer.api.campaign.CampaignPlugin;
import com.fs.starfarer.api.combat.MissileAIPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import exerelin.campaign.SectorManager;

public class AleuramPlugin extends BaseModPlugin {

    @Override
    public void onNewGame() {
        boolean haveNexerelin = Global.getSettings().getModManager().isModEnabled("nexerelin");
        if (!haveNexerelin || SectorManager.getCorvusMode()){
            new AdfSysGen().generate(Global.getSector());
        }
}
}
Edit: Fixed it again
« Last Edit: September 01, 2017, 10:39:06 AM by Tufted Titmouse »
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4938
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3547 on: September 01, 2017, 11:30:21 PM »

TrashMan: Remove the updateConditionSpecs(); line. It's not defined in the plugin and I have no idea where it comes from.

Also your .jar doesn't work because it put stuff in a package named Modding.java.scripts instead of data.scripts.
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1329
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3548 on: September 02, 2017, 03:17:46 AM »

TrashMan: Remove the updateConditionSpecs(); line. It's not defined in the plugin and I have no idea where it comes from.

Also your .jar doesn't work because it put stuff in a package named Modding.java.scripts instead of data.scripts.

Fixed both. Still the same.

Could it be a manifest file problem?


EDIT: Re-complied again, making sure the manifest file is updated with "Main-Class: scripts.SCModPlugin"

No change. Still the same error. The .jar is below in zip format

[attachment deleted by admin]
« Last Edit: September 02, 2017, 03:30:31 AM by TrashMan »
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1329
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3549 on: September 02, 2017, 07:45:20 AM »

What's he difference between ModPlugin and BaseModPlugin?


Also, when compiling, do I need to somehow link to the sarfarer.api?
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4938
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3550 on: September 02, 2017, 08:28:20 AM »

Your packages are still wrong (should be data.scripts not just scripts). It works fine on my side just from changing data/scripts/SCModPlugin.java without touching the .jar, which still isn't being used.

Also don't duplicate Java files between the mod's data/scripts folder and what goes into the jar, at best it's confusing.

Also: why are you using command line instead an IDE? You're not even actually compiling the Java files as far as I can tell, just archiving them in a jar (as if it were a zip file).

What's he difference between ModPlugin and BaseModPlugin?
ModPlugin is an interface, BaseModPlugin is a class implementing that interface.
But the only thing you need to know: you should extend BaseModPlugin (that's what it's there for) instead of going to the trouble of implementing ModPlugin directly.

Also, when compiling, do I need to somehow link to the sarfarer.api?
Yes. (The fact that it hasn't already thrown a compile error is further evidence that it's not actually being compiled. Seriously, get an IDE, it'll save heaps of effort in the medium and long term.)
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1329
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3551 on: September 02, 2017, 10:08:48 AM »

I did get it.
I made a new project. Added starfarer.api.jar to the libraries/jars.
Made a data.scripts package and put the code in there.
Compiled.
Re-named the .jar to SC.jar
Tried to start SS


Code
53249 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.fs.starfarer.loading.scripts.ScriptStore.?00000(Unknown Source)
at com.fs.starfarer.settings.StarfarerSettings.o00000(Unknown Source)
at com.fs.starfarer.launcher.ModManager.getEnabledModPlugins(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

All I wanted is to add one line that will allow my factions to generate bounties.
WHHYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY?????

Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1329
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3552 on: September 02, 2017, 12:07:09 PM »

A week of failures.

A this point, instead of trying to help me with advice, it would be faster to simply compile that .jar for me. Would take less time.... :-\
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4938
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3553 on: September 02, 2017, 10:42:21 PM »

Project Properties (right-click on the project in Projects window, or use the File menu) -> Sources -> Set Source/Binary Format to JDK 7
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1329
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3554 on: September 03, 2017, 12:44:30 AM »

Project Properties (right-click on the project in Projects window, or use the File menu) -> Sources -> Set Source/Binary Format to JDK 7

Nope. Still getting the same error.
Logged
Pages: 1 ... 235 236 [237] 238 239 ... 751