-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add the option to clear the message counters when joining a world
- Loading branch information
1 parent
17586d5
commit d529a5a
Showing
5 changed files
with
18 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,28 @@ | ||
package dev.cbyrne.compactchat; | ||
|
||
import com.mojang.logging.LogUtils; | ||
import dev.cbyrne.compactchat.config.Configuration; | ||
import dev.cbyrne.compactchat.event.ClientJoinWorldCallback; | ||
import me.shedaniel.autoconfig.AutoConfig; | ||
import me.shedaniel.autoconfig.serializer.GsonConfigSerializer; | ||
import net.fabricmc.api.ModInitializer; | ||
import org.slf4j.Logger; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class CompactChat implements ModInitializer { | ||
public static final Map<String, Integer> messageCounters = new HashMap<>(); | ||
public static final Logger LOGGER = LogUtils.getLogger(); | ||
public static final Map<String, Integer> MESSAGE_COUNTERS = new HashMap<>(); | ||
|
||
@Override | ||
public void onInitialize() { | ||
AutoConfig.register(Configuration.class, GsonConfigSerializer::new); | ||
ClientJoinWorldCallback.EVENT.register(() -> { | ||
if (!Configuration.getInstance().resetCounterOnWorldJoin) return; | ||
|
||
LOGGER.info("Clearing message counters of length " + MESSAGE_COUNTERS.size() + " because the client is joining a new world!"); | ||
MESSAGE_COUNTERS.clear(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"text.autoconfig.compactchat.title": "CompactChat Settings", | ||
"text.autoconfig.compactchat.option.infiniteChatHistory": "Infinite Chat History" | ||
"text.autoconfig.compactchat.option.infiniteChatHistory": "Infinite chat history", | ||
"text.autoconfig.compactchat.option.resetCounterOnWorldJoin": "Reset message counter on world join" | ||
} |