Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

The subject basically says my problem. Basically I have an ArrayList that stores all of my commands for my mod and HashMaps that store the details for each command. Then there's a registry class that loops through each command and registers it with Forge. However, instead of processing the command in the processCommand() method with Forge I use a command listener which has a few checks before it passes the arguments to the command method. This is where my problem comes in. The whole beginning part works perfectly, however once I get to actually using the command for some reason the ArrayList and HashMaps have no data stored in them anymore. I can't for the life of my figure out why and I'm hoping it's something stupid that I'm just not seeing.

 

Here's my CommandManager class:

http://pastebin.com/mYTrdfmq

And then my CommandHandler class:

http://pastebin.com/9ADGSr5Z

And the class I use to loop through and register each command:

http://pastebin.com/jHMWkBLV

 

The method getLengths() is only for debug as well as most of the logging you'll see.

CommandHandler extends CommandManager

* Handler is supposed to act on data held in Manager

* You are using e.g:

if(!commands.contains(command))

The "commands" is an ArrayList that is currently in THIS CommandHandler (more precisely in Manager which you are extending).

 

CommandRegistry extends CommandManager

* Is yet another instance of Manager

* This one actually holds your registered classes/data.

 

You messed up this/other.

 

UNLESS - Note: There is possibility that I am not seeing code that is responsible for actually being exact opposite of what I am saying above (meaning: I am wrong and you just provided too few classes, you should ALWAYS post @Mod class and proxies if they are used).

 

EDIT

 

PLEASE USE 'static" keyword! This will save you from instances and is much more prefered in this case.

1.7.10 is no longer supported by forge, you are on your own.

  • Author

Here's my @Mod main class. You can see I register my commands in during FMLServerStartingEvent

http://pastebin.com/uNiNQys1

And here's my CommandWrapper class:

http://pastebin.com/LKLWw4ZS

 

I think I see what you're saying.. CommandRegistry and CommandHandler are running on different instances of CommandManager and the data was only stored during the CommandRegistry instance?

 

Also are you saying I should be making all of the Maps and Lists static?

  • Author

Ahh never mind I think I get what you are saying. Haha I kind of feel stupid that I didn't think of just making them static, but I guess that's how it often is. Thank you very much!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.