Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MapScreen.java Broken #11

Open
cameronbowe opened this issue Apr 23, 2024 · 5 comments
Open

MapScreen.java Broken #11

cameronbowe opened this issue Apr 23, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@cameronbowe
Copy link

Issue description

I can never get my MapScreens to create due to issues in the console, and under some investigation, it seems out of my control.

To reproduce

		session.updateScreen(); //Update the screen.
		session.screen.spawnFrames(player); //Spawn the frames.
		session.screen.sendMaps(true, player); //Send the maps to the player.

This is my code, the session.updateScreen() handles the screen update and spawnFrames(player) SHOULD spawn the frames- but it doesn't, instead it throws a null pointer saying this.frames is not set. I looked into your Map Screen class and it attempts to get this.frames[x][y] but the this.frames variable was never setup within the class whatsoever, so therefore it just keeps throwing errors upon attempting to create it.

Expected behaviour

For map screens to actually show and not throw a null pointer.

Screenshots / videos

Look into MapScreen.java to see what I mean, it's pretty self-explanatory, but here's the log as well I keep getting.
java.lang.NullPointerException: Cannot load from object array because "this.frames" is null at com.legacymc.legacyrp.libraries.maps.api.MapScreen.spawnFrames(MapScreen.java:191) ~[LegacyRP-0.0.1.jar:?]

Additional information

No response

@cameronbowe cameronbowe added the bug Something isn't working label Apr 23, 2024
@cerus
Copy link
Owner

cerus commented Apr 23, 2024

How do you create MapScreens? The frames are set when using the "official" storage implementation - here and here.

@cameronbowe
Copy link
Author

new MapScreen(CURRENT_ID.getAndUpdate(i -> (i < Integer.MAX_VALUE ? i : 0)), new VersionAdapter20R3(), NationsConfiguration.MAP_VIEWER_SIZE_WIDTH, NationsConfiguration.MAP_VIEWER_SIZE_HEIGHT); //Create the map screen.

Using this line. I don't need anything storage-wise since map screens are only shown via a command and removed after logout or exit- so I didn't think I needed the plugin to store them. So does the plugin automatically create the frames if they don't exist?

@cerus
Copy link
Owner

cerus commented Apr 24, 2024

The plugin does not automatically create frames, they are usually created when the screen is first created. Take a look here

@cameronbowe
Copy link
Author

cameronbowe commented Apr 24, 2024

Oh I see, it was non-apparent in the docs how much the plugin really handles... It really isn't just storage, it's even creating the item frames, the location & setting all that- which none of the docs showcase since I guess you assumed everyone would use the plugin. So in a nutshell, the common shouldn't be touched on it's own without the plugin lol

@cerus
Copy link
Owner

cerus commented Apr 24, 2024

Yeah, the scope of the plugin has kinda grown exponentially which wasn't planned at the start. It's probably getting time for another rewrite. But in the meantime you should be able to copy and adjust the plugins code to your needs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants