diff --git a/anvil-api/build.gradle b/anvil-api/build.gradle
index e29e992c8..707c855a7 100644
--- a/anvil-api/build.gradle
+++ b/anvil-api/build.gradle
@@ -4,6 +4,7 @@ plugins {
repositories {
mavenCentral()
+ maven { url 'https://repo.spongepowered.org/maven' }
}
dependencies {
@@ -11,4 +12,6 @@ dependencies {
implementation reflections
implementation javasisst
implementation guice
+ implementation configurate_core
+ implementation configurate_hocon
}
diff --git a/anvil-api/src/main/java/org/anvilpowered/anvil/api/data/config/Channel.java b/anvil-api/src/main/java/org/anvilpowered/anvil/api/data/config/Channel.java
new file mode 100644
index 000000000..07f502e91
--- /dev/null
+++ b/anvil-api/src/main/java/org/anvilpowered/anvil/api/data/config/Channel.java
@@ -0,0 +1,32 @@
+/*
+ * Anvil - AnvilPowered
+ * Copyright (C) 2020 Cableguy20
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package org.anvilpowered.anvil.api.data.config;
+
+import java.util.List;
+
+public class Channel {
+
+ public String id;
+
+ public List aliases;
+
+ public String prefix;
+
+ public boolean alwaysVisible;
+}
diff --git a/anvil-api/src/main/java/org/anvilpowered/anvil/api/util/ChatService.java b/anvil-api/src/main/java/org/anvilpowered/anvil/api/util/ChatService.java
new file mode 100644
index 000000000..27482a0fc
--- /dev/null
+++ b/anvil-api/src/main/java/org/anvilpowered/anvil/api/util/ChatService.java
@@ -0,0 +1,58 @@
+/*
+ * Anvil - AnvilPowered
+ * Copyright (C) 2020 Cableguy20
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package org.anvilpowered.anvil.api.util;
+
+import org.anvilpowered.anvil.api.data.config.Channel;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+
+public interface ChatService {
+
+ TString createChannel(String channelId, String prefix, List aliases, Boolean alwaysVisible);
+
+ //Return the prefix for a specified channel
+ Optional getPrefixForChannel(String channelId);
+
+ //Return a channel for the specified channelId
+ Optional getChannelFromId(String channelId);
+
+ //Change channels for a user
+ TString switchChannel(UUID userUUID, String channelId);
+
+ //return the current channel for a user
+ String getChannelIdForUser(UUID userUUID);
+
+ //Return a total count of users in a specified channel
+ int getUserCountFromChannel(String channelId);
+
+ //Return a list of users in a specified channel
+ TString getUsersInChannel(String channelId);
+
+ //Return a list of online players
+ String getPlayerList();
+
+ //Send a message to a specified channel
+ CompletableFuture sendMessageToChannel(String channelId, TString message);
+
+ //Send a message globally
+ CompletableFuture sendGlobalMessage(TString message);
+}
diff --git a/anvil-common/src/main/java/org/anvilpowered/anvil/common/util/CommonChatService.java b/anvil-common/src/main/java/org/anvilpowered/anvil/common/util/CommonChatService.java
new file mode 100644
index 000000000..2bb687e40
--- /dev/null
+++ b/anvil-common/src/main/java/org/anvilpowered/anvil/common/util/CommonChatService.java
@@ -0,0 +1,131 @@
+/*
+ * Anvil - AnvilPowered
+ * Copyright (C) 2020 Cableguy20
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package org.anvilpowered.anvil.common.util;
+
+import org.anvilpowered.anvil.api.data.config.Channel;
+import org.anvilpowered.anvil.api.data.key.Keys;
+import org.anvilpowered.anvil.api.data.registry.Registry;
+import org.anvilpowered.anvil.api.util.ChatService;
+import org.anvilpowered.anvil.api.util.StringResult;
+import org.anvilpowered.anvil.api.util.UserService;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
+
+@Singleton
+public class CommonChatService implements ChatService {
+
+ @Inject
+ protected StringResult stringResult;
+
+ @Inject
+ protected Registry registry;
+
+ @Inject
+ protected UserService userService;
+
+ Map channelMap = new HashMap<>();
+
+ @Override
+ public TString createChannel(String channelId, String prefix, List aliases, Boolean alwaysVisible) {
+ Channel channel = new Channel();
+ channel.id = channelId;
+ channel.prefix = prefix;
+ channel.aliases = aliases;
+ channel.alwaysVisible = alwaysVisible;
+
+ return stringResult.success("Successfully created channel " + channelId);
+ }
+
+ @Override
+ public Optional getPrefixForChannel(String channelId) {
+ return getChannelFromId(channelId).map(c -> c.prefix);
+ }
+
+ @Override
+ public Optional getChannelFromId(String channelId) {
+ return registry.get(Keys.>resolveUnsafe("CHANNEL_ID")).flatMap((List channel) ->
+ channel.stream()
+ .filter(c -> c.id.equals(channelId))
+ .findAny());
+ }
+
+ @Override
+ public TString switchChannel(UUID userUUID, String channelId) {
+ if (getChannelFromId(channelId).isPresent()) {
+ channelMap.put(userUUID, channelId);
+ return stringResult.success("Connected to channel " + channelId);
+ }
+ return stringResult.fail("Failed to connect to channel " + channelId);
+ }
+
+ @Override
+ public String getChannelIdForUser(UUID userUUID) {
+ return channelMap.get(userUUID) == null ? registry.getOrDefault(Keys.resolveUnsafe("CHANNEL_DEFAULT")) : channelMap.get(userUUID);
+ }
+
+ @Override
+ public int getUserCountFromChannel(String channelId) {
+ return (int) userService.getOnlinePlayers()
+ .stream()
+ .filter(p -> getChannelIdForUser(userService.getUUID(p))
+ .equals(channelId)).count();
+ }
+
+ @Override
+ public TString getUsersInChannel(String channelId) {
+ List channelUsersList = userService.getOnlinePlayers()
+ .stream()
+ .filter(p -> getChannelIdForUser(userService.getUUID(p)).equals(channelId))
+ .map(p -> userService.getUserName(p))
+ .collect(Collectors.toList());
+
+ return stringResult.builder()
+ .green().append("------------------- ")
+ .gold().append(channelId)
+ .green().append(" --------------------\n")
+ .append(String.join(", ", channelUsersList))
+ .build();
+ }
+
+ @Override
+ public String getPlayerList() {
+ return userService.getOnlinePlayers().stream().map(userService::getUserName).collect(Collectors.joining(", \n"));
+ }
+
+ @Override
+ public CompletableFuture sendMessageToChannel(String channelId, TString message) {
+ return CompletableFuture.runAsync(() -> userService.getOnlinePlayers().forEach(p -> {
+ if (getChannelIdForUser(userService.getUUID(p)).equals(channelId))
+ stringResult.send(message, p);
+ }));
+ }
+
+ @Override
+ public CompletableFuture sendGlobalMessage(TString message) {
+ return CompletableFuture.runAsync(() -> userService.getOnlinePlayers().forEach(p -> stringResult.send(message, p)));
+ }
+}
diff --git a/anvil-core/anvil-core-common/src/main/java/org/anvilpowered/anvil/core/common/plugin/AnvilCorePluginInfo.java b/anvil-core/anvil-core-common/src/main/java/org/anvilpowered/anvil/core/common/plugin/AnvilCorePluginInfo.java
index cc1fb5e2e..182d26b12 100644
--- a/anvil-core/anvil-core-common/src/main/java/org/anvilpowered/anvil/core/common/plugin/AnvilCorePluginInfo.java
+++ b/anvil-core/anvil-core-common/src/main/java/org/anvilpowered/anvil/core/common/plugin/AnvilCorePluginInfo.java
@@ -28,7 +28,7 @@ public class AnvilCorePluginInfo implements PluginInfo<
public static final String version = "$modVersion";
public static final String description = "A cross platform Minecraft plugin framework";
public static final String url = "https://github.com/AnvilPowered/Anvil";
- public static final String[] authors = {"Cableguy20"};
+ public static final String[] authors = {"Cableguy20, STG_Allen"};
public static final String organizationName = "AnvilPowered";
public static final String buildDate = "$buildDate";
public TString pluginPrefix;
diff --git a/gradle.properties b/gradle.properties
index f578475fe..a88c9d741 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -2,6 +2,7 @@
beanutils=commons-beanutils:commons-beanutils:1.9.2
bson=org.mongodb:bson:3.10.1
configurate_core=org.spongepowered:configurate-core:3.6
+configurate_hocon=org.spongepowered:configurate-hocon:3.6
guava=com.google.guava:guava:28.1-jre
guice=com.google.inject:guice:4.1.0
h2=com.h2database:h2-mvstore:1.4.200
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 1b16c34a7..8164aa2c3 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,6 @@
+#Sat Feb 08 13:34:47 EST 2020
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip
-zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME