Class Core
- All Implemented Interfaces:
AutoCloseable
- Author:
- JCM
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionDefault callback to use for operation returning aResult.static final BiConsumer<LogLevel, String> Default log hook. -
Constructor Summary
ConstructorsConstructorDescriptionCore(CreateParams params) Creates an instance of the SDK fromCreateParamsand sets the log hook toDEFAULT_LOG_HOOK. -
Method Summary
Modifier and TypeMethodDescriptionReturns theActivityManagerassociated with this core.Returns theApplicationManagerassociated with this core.voidclose()Closes and destroys the instance.static final de.jcm.discordgamesdk.impl.channel.DiscordChannelReturns theImageManagerassociated with this core.booleanbooleanisOpen()Returns true if thisCoreinstance is open, i.e.Returns theOverlayManagerassociated with this core.Returns theRelationshipManagerassociated with this core.voidListens for new events and runs pending callbacks.voidsetLogHook(LogLevel minLevel, BiConsumer<LogLevel, String> logHook) Registers a log function.Returns theUserManagerassociated with this core.Returns theVoiceManagerassociated with this core.
-
Field Details
-
DEFAULT_CALLBACK
Default callback to use for operation returning a
Result.Checks if the result is
Result.OKand throws aGameSDKExceptionif it is not. -
DEFAULT_LOG_HOOK
Default log hook. Simply prints the log message in pattern "
[level] message" toSystem.out.
-
-
Constructor Details
-
Core
Creates an instance of the SDK fromCreateParamsand sets the log hook toDEFAULT_LOG_HOOK.Example:
try(CreateParams params = new CreateParams()) { params.setClientID(<client ID of your application>); params.setFlags(CreateParams.getDefaultFlags()); try(Core core = new Core(params)) { // do something with your Core } }- Parameters:
params- Parameters to create Core from.- See Also:
-
-
Method Details
-
getDiscordChannel
public static final de.jcm.discordgamesdk.impl.channel.DiscordChannel getDiscordChannel() throws IOException- Throws:
IOException
-
activityManager
Returns the
ActivityManagerassociated with this core.An ActivityManager is used to set the User's activity/status.
- Returns:
- An
ActivityManager - See Also:
-
applicationManager
Returns the
ApplicationManagerassociated with this core.An ApplicationManager is used to obtain an OAuth2 token for the application.
- Returns:
- An
ApplicationManager - See Also:
-
userManager
Returns the
UserManagerassociated with this core.A UserManager is used to receive information about Discord users.
- Returns:
- A
UserManager - See Also:
-
overlayManager
Returns the
OverlayManagerassociated with this core.An OverlayManager is used to control the overlay for this game.
- Returns:
- An
OverlayManager - See Also:
-
relationshipManager
Returns the
RelationshipManagerassociated with this core.A RelationshipManager is used to receive information about the user's relationships with other Discord users (e.g. friends).
- Returns:
- A
RelationshipManager - See Also:
-
imageManager
Returns the
ImageManagerassociated with this core.An ImageManager is used to fetch images and information about images (dimensions) from Discord (mainly avatars).
- Returns:
- An
ImageManager - See Also:
-
voiceManager
Returns theVoiceManagerassociated with this core.A VoiceManager is used to control Discord Lobby voice channels. It can be used to configure input modes, to mute and deaf the current user, to locally mute other users and to locally adjust their volume.
- Returns:
- A
VoiceManager - See Also:
-
runCallbacks
public void runCallbacks()Listens for new events and runs pending callbacks.
This method should be called in a main loop every few millis.
- See Also:
-
isDiscordRunning
public boolean isDiscordRunning() -
setLogHook
Registers a log function.- Parameters:
minLevel- Minimal level of message to receive.logHook- Hook to send log messages to.- See Also:
-
isOpen
public boolean isOpen()Returns true if thisCoreinstance is open, i.e.close()has not been called yet. Calling certain SDK methods will throwCoreClosedExceptionif theCoreis not open.- Returns:
- True if this
Coreis still open, false otherwise
-
close
public void close()Closes and destroys the instance.
This should be called at the end of the program.
- Specified by:
closein interfaceAutoCloseable- See Also:
-