Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
CreatureChat
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Public
CreatureChat
Commits
e1c3ea8d
Commit
e1c3ea8d
authored
Nov 07, 2023
by
Jonathan Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separating client & server instances of ChatDataManager, in preparation for data sync
parent
bfe50738
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
8 deletions
+14
-8
ClickHandler.java
src/client/java/com/owlmaddie/ClickHandler.java
+1
-1
ClientInit.java
src/client/java/com/owlmaddie/ClientInit.java
+1
-1
ChatDataManager.java
src/main/java/com/owlmaddie/ChatDataManager.java
+10
-4
ModInit.java
src/main/java/com/owlmaddie/ModInit.java
+2
-2
No files found.
src/client/java/com/owlmaddie/ClickHandler.java
View file @
e1c3ea8d
...
@@ -106,7 +106,7 @@ public class ClickHandler {
...
@@ -106,7 +106,7 @@ public class ClickHandler {
// Handle the click for the closest entity after the loop
// Handle the click for the closest entity after the loop
if
(
closestEntity
!=
null
)
{
if
(
closestEntity
!=
null
)
{
// Look-up conversation
// Look-up conversation
ChatDataManager
.
EntityChatData
chatData
=
ChatDataManager
.
getInstance
().
getOrCreateChatData
(
closestEntity
.
getId
());
ChatDataManager
.
EntityChatData
chatData
=
ChatDataManager
.
get
Client
Instance
().
getOrCreateChatData
(
closestEntity
.
getId
());
if
(
chatData
.
currentMessage
.
isEmpty
())
{
if
(
chatData
.
currentMessage
.
isEmpty
())
{
// Start conversation
// Start conversation
...
...
src/client/java/com/owlmaddie/ClientInit.java
View file @
e1c3ea8d
...
@@ -167,7 +167,7 @@ public class ClientInit implements ClientModInitializer {
...
@@ -167,7 +167,7 @@ public class ClientInit implements ClientModInitializer {
}
}
// Look-up greeting (if any)
// Look-up greeting (if any)
ChatDataManager
.
EntityChatData
chatData
=
ChatDataManager
.
getInstance
().
getOrCreateChatData
(
entity
.
getId
());
ChatDataManager
.
EntityChatData
chatData
=
ChatDataManager
.
get
Client
Instance
().
getOrCreateChatData
(
entity
.
getId
());
List
<
String
>
lines
=
chatData
.
getWrappedLines
();
List
<
String
>
lines
=
chatData
.
getWrappedLines
();
// Set the range of lines to display
// Set the range of lines to display
...
...
src/main/java/com/owlmaddie/ChatDataManager.java
View file @
e1c3ea8d
...
@@ -7,7 +7,8 @@ import java.util.ArrayList;
...
@@ -7,7 +7,8 @@ import java.util.ArrayList;
public
class
ChatDataManager
{
public
class
ChatDataManager
{
// Use a static instance to manage our data globally
// Use a static instance to manage our data globally
private
static
final
ChatDataManager
INSTANCE
=
new
ChatDataManager
();
private
static
final
ChatDataManager
SERVER_INSTANCE
=
new
ChatDataManager
();
private
static
final
ChatDataManager
CLIENT_INSTANCE
=
new
ChatDataManager
();
public
static
int
MAX_CHAR_PER_LINE
=
22
;
public
static
int
MAX_CHAR_PER_LINE
=
22
;
public
enum
ChatStatus
{
public
enum
ChatStatus
{
...
@@ -77,9 +78,14 @@ public class ChatDataManager {
...
@@ -77,9 +78,14 @@ public class ChatDataManager {
entityChatDataMap
=
new
HashMap
<>();
entityChatDataMap
=
new
HashMap
<>();
}
}
// Method to get the global instance of the data manager
// Method to get the global instance of the server data manager
public
static
ChatDataManager
getInstance
()
{
public
static
ChatDataManager
getServerInstance
()
{
return
INSTANCE
;
return
SERVER_INSTANCE
;
}
// Method to get the global instance of the client data manager (synced from server)
public
static
ChatDataManager
getClientInstance
()
{
return
CLIENT_INSTANCE
;
}
}
// Retrieve chat data for a specific entity, or create it if it doesn't exist
// Retrieve chat data for a specific entity, or create it if it doesn't exist
...
...
src/main/java/com/owlmaddie/ModInit.java
View file @
e1c3ea8d
...
@@ -36,7 +36,7 @@ public class ModInit implements ModInitializer {
...
@@ -36,7 +36,7 @@ public class ModInit implements ModInitializer {
// Slow entity
// Slow entity
SlowEntity
((
LivingEntity
)
entity
,
3.5
F
);
SlowEntity
((
LivingEntity
)
entity
,
3.5
F
);
ChatDataManager
.
EntityChatData
chatData
=
ChatDataManager
.
getInstance
().
getOrCreateChatData
(
entityId
);
ChatDataManager
.
EntityChatData
chatData
=
ChatDataManager
.
get
Server
Instance
().
getOrCreateChatData
(
entityId
);
if
(
chatData
.
status
==
ChatDataManager
.
ChatStatus
.
NONE
||
if
(
chatData
.
status
==
ChatDataManager
.
ChatStatus
.
NONE
||
chatData
.
status
==
ChatDataManager
.
ChatStatus
.
END
)
{
chatData
.
status
==
ChatDataManager
.
ChatStatus
.
END
)
{
// Only generate a new greeting if not already doing so
// Only generate a new greeting if not already doing so
...
@@ -61,7 +61,7 @@ public class ModInit implements ModInitializer {
...
@@ -61,7 +61,7 @@ public class ModInit implements ModInitializer {
// Slow entity
// Slow entity
SlowEntity
((
LivingEntity
)
entity
,
3.5
F
);
SlowEntity
((
LivingEntity
)
entity
,
3.5
F
);
ChatDataManager
.
EntityChatData
chatData
=
ChatDataManager
.
getInstance
().
getOrCreateChatData
(
entityId
);
ChatDataManager
.
EntityChatData
chatData
=
ChatDataManager
.
get
Server
Instance
().
getOrCreateChatData
(
entityId
);
if
(
chatData
.
status
==
ChatDataManager
.
ChatStatus
.
DISPLAY
)
{
if
(
chatData
.
status
==
ChatDataManager
.
ChatStatus
.
DISPLAY
)
{
// Only set line number if status allows
// Only set line number if status allows
LOGGER
.
info
(
"Increment read lines to "
+
lineNumber
+
" for: "
+
entity
.
getType
().
toString
());
LOGGER
.
info
(
"Increment read lines to "
+
lineNumber
+
" for: "
+
entity
.
getType
().
toString
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment