Class Core
- All Implemented Interfaces:
AutoCloseable
- Author:
- JCM
- See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionDefault callback to use for operation returning aResult
.static final BiConsumer
<LogLevel, String> Default log hook. -
Constructor Summary
ConstructorDescriptionCore
(CreateParams params) Creates an instance of the SDK fromCreateParams
and sets the log hook toDEFAULT_LOG_HOOK
. -
Method Summary
Modifier and TypeMethodDescriptionReturns theActivityManager
associated with this core.Returns theApplicationManager
associated with this core.void
close()
Closes and destroys the instance.static final de.jcm.discordgamesdk.impl.channel.DiscordChannel
Returns theImageManager
associated with this core.boolean
boolean
isOpen()
Returns true if thisCore
instance is open, i.e.Returns theOverlayManager
associated with this core.Returns theRelationshipManager
associated with this core.void
Listens for new events and runs pending callbacks.void
setLogHook
(LogLevel minLevel, BiConsumer<LogLevel, String> logHook) Registers a log function.Returns theUserManager
associated with this core.Returns theVoiceManager
associated with this core.
-
Field Details
-
DEFAULT_CALLBACK
Default callback to use for operation returning a
Result
.Checks if the result is
Result.OK
and throws aGameSDKException
if 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 fromCreateParams
and 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
ActivityManager
associated with this core.An ActivityManager is used to set the User's activity/status.
- Returns:
- An
ActivityManager
- See Also:
-
applicationManager
Returns the
ApplicationManager
associated with this core.An ApplicationManager is used to obtain an OAuth2 token for the application.
- Returns:
- An
ApplicationManager
- See Also:
-
userManager
Returns the
UserManager
associated with this core.A UserManager is used to receive information about Discord users.
- Returns:
- A
UserManager
- See Also:
-
overlayManager
Returns the
OverlayManager
associated with this core.An OverlayManager is used to control the overlay for this game.
- Returns:
- An
OverlayManager
- See Also:
-
relationshipManager
Returns the
RelationshipManager
associated 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
ImageManager
associated 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 theVoiceManager
associated 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 thisCore
instance is open, i.e.close()
has not been called yet. Calling certain SDK methods will throwCoreClosedException
if theCore
is not open.- Returns:
- True if this
Core
is 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:
close
in interfaceAutoCloseable
- See Also:
-