Add plugin
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package com.alttd.chat;
|
||||
package com.alttd.velocitychat;
|
||||
|
||||
import com.alttd.chat.database.DatabaseConnection;
|
||||
import com.alttd.velocitychat.database.DatabaseConnection;
|
||||
import net.luckperms.api.LuckPerms;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface ChatAPI {
|
||||
|
||||
ChatAPI get();
|
||||
@@ -10,4 +12,11 @@ public interface ChatAPI {
|
||||
LuckPerms getLuckPerms();
|
||||
|
||||
DatabaseConnection getDataBase();
|
||||
|
||||
String getPrefix(UUID uuid);
|
||||
|
||||
String getPrefix(UUID uuid, boolean all);
|
||||
|
||||
String getStaffPrefix(UUID uuid);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package com.alttd.chat;
|
||||
package com.alttd.velocitychat;
|
||||
|
||||
import com.alttd.chat.config.Config;
|
||||
import com.alttd.chat.database.DatabaseConnection;
|
||||
import com.alttd.velocitychat.config.Config;
|
||||
import com.alttd.velocitychat.database.DatabaseConnection;
|
||||
import net.luckperms.api.LuckPerms;
|
||||
import net.luckperms.api.LuckPermsProvider;
|
||||
import net.luckperms.api.model.group.Group;
|
||||
import net.luckperms.api.model.user.User;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ChatImplementation implements ChatAPI{
|
||||
|
||||
@@ -14,9 +18,9 @@ public class ChatImplementation implements ChatAPI{
|
||||
private LuckPerms luckPerms;
|
||||
private DatabaseConnection databaseConnection;
|
||||
|
||||
ChatImplementation() {
|
||||
public ChatImplementation() {
|
||||
instance = this;
|
||||
Config.init(new File(System.getProperty("user.home")));
|
||||
Config.init();
|
||||
// init database
|
||||
// init depends//or set them the first time they are called?
|
||||
}
|
||||
@@ -42,5 +46,36 @@ public class ChatImplementation implements ChatAPI{
|
||||
return databaseConnection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix(UUID uuid) {
|
||||
return getPrefix(uuid, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix(UUID uuid, boolean all) {
|
||||
// TODO cache these components on load, and return them here?
|
||||
StringBuilder prefix = new StringBuilder();
|
||||
LuckPerms luckPerms = getLuckPerms();
|
||||
User user = luckPerms.getUserManager().getUser(uuid);
|
||||
if(user == null) return "";
|
||||
if(all) {
|
||||
Collection<Group> inheritedGroups = user.getInheritedGroups(user.getQueryOptions());
|
||||
inheritedGroups.stream()
|
||||
.sorted(Comparator.comparingInt(o -> o.getWeight().orElse(0)))
|
||||
.forEach(group -> {
|
||||
if (Config.PREFIXGROUPS.contains(group.getName())) {
|
||||
prefix.append("<white>[").append(group.getCachedData().getMetaData().getPrefix()).append("]</white>");
|
||||
}
|
||||
});
|
||||
}
|
||||
prefix.append("<white>[").append(user.getCachedData().getMetaData().getPrefix()).append("]</white>");
|
||||
return prefix.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStaffPrefix(UUID uuid) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alttd.chat.config;
|
||||
package com.alttd.velocitychat.config;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -28,8 +28,8 @@ public final class Config {
|
||||
static int version;
|
||||
static boolean verbose;
|
||||
|
||||
public static void init(File path) {
|
||||
CONFIG_FILE = new File(path, "config.yml");;
|
||||
public static void init() {
|
||||
CONFIG_FILE = new File(new File(System.getProperty("user.home")), "config.yml");;
|
||||
configLoader = YAMLConfigurationLoader.builder()
|
||||
.setFile(CONFIG_FILE)
|
||||
.setFlowStyle(DumperOptions.FlowStyle.BLOCK)
|
||||
@@ -150,9 +150,11 @@ public final class Config {
|
||||
|
||||
/** ONLY EDIT ANYTHING BELOW THIS LINE **/
|
||||
public static List<String> PREFIXGROUPS = new ArrayList<>();
|
||||
public static String CONSOLENAME = "Console";
|
||||
private static void settings() {
|
||||
PREFIXGROUPS = getList("settings.prefix-groups",
|
||||
Lists.newArrayList("discord", "socialmedia", "eventteam", "eventleader", "youtube", "twitch", "developer"));
|
||||
CONSOLENAME = getString("settings.console-name", CONSOLENAME);
|
||||
}
|
||||
|
||||
public static List<String> MESSAGECOMMANDALIASES = new ArrayList<>();
|
||||
@@ -168,13 +170,11 @@ public final class Config {
|
||||
MESSAGERECIEVER = getString("commands.message.reciever-message", MESSAGERECIEVER);
|
||||
}
|
||||
|
||||
public static List<String> GCCOMMANDALIASES = new ArrayList<>();
|
||||
public static String GCFORMAT = "<white><light_purple><prefix></light_purple> <gray><sender></gray> <hover:show_text:on <server>><yellow>to Global</yellow></hover><gray>: <message></gray></white>";
|
||||
public static String GCPERMISSION = "proxy.globalchat";
|
||||
private static void globalChat() {
|
||||
MESSAGERECIEVER = getString("commands.globalchat.format", MESSAGERECIEVER);
|
||||
GCPERMISSION = getString("commands.globalchat.view-chat-permission", GCPERMISSION);
|
||||
GCCOMMANDALIASES = getList("commands.globalchat.aliases", Lists.newArrayList("gc"));
|
||||
}
|
||||
|
||||
public static List<String> GACECOMMANDALIASES = new ArrayList<>();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alttd.chat.database;
|
||||
package com.alttd.velocitychat.database;
|
||||
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.alttd.chat.database;
|
||||
package com.alttd.velocitychat.database;
|
||||
|
||||
import com.alttd.chat.objects.Party;
|
||||
import com.alttd.chat.objects.PartyUser;
|
||||
import com.alttd.velocitychat.objects.Party;
|
||||
import com.alttd.velocitychat.objects.PartyUser;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
@@ -64,8 +64,8 @@ public class Queries {
|
||||
|
||||
//Ignore
|
||||
|
||||
public static void getIgnoredUsers() { //TODO store this in a user object or something?
|
||||
HashMap<UUID, ArrayList<UUID>> ignoredUsers = new HashMap<>(); //TODO Replace with a proper way/location to store this in
|
||||
public static void getIgnoredUsers() { //TODO store this in a user object or something? -> ChatPlayer
|
||||
HashMap<UUID, ArrayList<UUID>> ignoredUsers = new HashMap<>(); //TODO Replace with a proper way/location to store this in -> a list<UUID> in ChatPlayer?
|
||||
String query = "SELECT * FROM ignored_users";
|
||||
|
||||
try {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alttd.chat.objects;
|
||||
package com.alttd.velocitychat.objects;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.alttd.chat.objects;
|
||||
package com.alttd.velocitychat.objects;
|
||||
|
||||
import com.alttd.chat.database.Queries;
|
||||
import com.alttd.velocitychat.database.Queries;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.alttd.chat.objects;
|
||||
package com.alttd.velocitychat.objects;
|
||||
|
||||
import com.alttd.chat.database.Queries;
|
||||
import com.alttd.velocitychat.database.Queries;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alttd.chat.objects;
|
||||
package com.alttd.velocitychat.objects;
|
||||
|
||||
public class Regex {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alttd.chat.objects;
|
||||
package com.alttd.velocitychat.objects;
|
||||
|
||||
public enum RegexType {
|
||||
REPLACE("replace"),
|
||||
|
||||
Reference in New Issue
Block a user