Skip to content

Commit

Permalink
!4 修复velocity中群聊数据无法读取问题
Browse files Browse the repository at this point in the history
* Fix bugs
* Fix bugs
* Fix bugs
  • Loading branch information
alazeprt authored and RegadPole committed May 26, 2024
1 parent 0965d78 commit 51899ec
Show file tree
Hide file tree
Showing 24 changed files with 29 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import com.github.Anon8281.universalScheduler.scheduling.schedulers.TaskScheduler;
import me.regadpole.plumbot.bot.Bot;
import me.regadpole.plumbot.bot.KookBot;
import me.regadpole.plumbot.bot.QQBot;
import me.regadpole.plumbot.command.Commands;
import me.regadpole.plumbot.config.DataBase;
import me.regadpole.plumbot.config.Config;
import me.regadpole.plumbot.event.server.QsChatEvent;
import me.regadpole.plumbot.event.server.QsHikariChatEvent;
import me.regadpole.plumbot.event.server.ServerEvent;
Expand All @@ -18,18 +19,12 @@
import me.regadpole.plumbot.internal.FoliaSupport;
import me.regadpole.plumbot.internal.database.Database;
import me.regadpole.plumbot.internal.database.DatabaseManager;
import me.regadpole.plumbot.internal.database.MySQL;
import me.regadpole.plumbot.internal.database.SQLite;
import me.regadpole.plumbot.internal.maven.LibraryLoader;
import me.regadpole.plumbot.metrics.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import me.regadpole.plumbot.bot.QQBot;
import me.regadpole.plumbot.config.Config;

import java.sql.SQLException;

public final class PlumBot extends JavaPlugin implements Listener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;

import static me.regadpole.plumbot.PlumBot.*;
import static me.regadpole.plumbot.PlumBot.getScheduler;

public class QQBot implements Bot {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import me.regadpole.plumbot.PlumBot;
import me.regadpole.plumbot.bot.KookBot;
import me.regadpole.plumbot.config.Config;

import me.regadpole.plumbot.config.DataBase;
import me.regadpole.plumbot.internal.database.DatabaseManager;
import org.bukkit.Bukkit;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package me.regadpole.plumbot.event.server;

import com.griefdefender.api.event.ClaimEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package me.regadpole.plumbot.hook;

import fr.xephi.authme.api.v3.AuthMeApi;
import me.regadpole.plumbot.PlumBot;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import me.regadpole.plumbot.PlumBot;

public class AuthMeHook {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package me.regadpole.plumbot.hook;

import me.regadpole.plumbot.PlumBot;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import me.regadpole.plumbot.PlumBot;

public class GriefDefenderHook {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package me.regadpole.plumbot.hook;

import me.regadpole.plumbot.PlumBot;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import me.regadpole.plumbot.PlumBot;

public class QuickShopHook {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import com.bekvon.bukkit.residence.Residence;
import com.bekvon.bukkit.residence.chat.ChatManager;
import me.regadpole.plumbot.PlumBot;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import me.regadpole.plumbot.PlumBot;

public class ResidenceHook {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
@MavenLibrary(groupId = lombok.groupId, artifactId = lombok.artifactId, version = lombok.version),
@MavenLibrary(groupId = HikariCP.groupId, artifactId = HikariCP.artifactId, version = HikariCP.version),
@MavenLibrary(groupId = MySQL.groupId, artifactId = MySQL.artifactId, version = MySQL.version),
@MavenLibrary(groupId = sqlite.groupId, artifactId = sqlite.artifactId, version = sqlite.version),
@MavenLibrary(groupId = kookbc.groupId, artifactId = kookbc.artifactId, version = kookbc.version)})
@MavenLibrary(groupId = sqlite.groupId, artifactId = sqlite.artifactId, version = sqlite.version)})
public class Dependencies {
public static class hutool{
public static final String groupId = "cn.hutool";
Expand Down Expand Up @@ -63,9 +62,4 @@ public static class sqlite{
public static final String artifactId = "sqlite-jdbc";
public static final String version = "3.42.0.0";
}
public static class kookbc{
public static final String groupId = "com.github.SNWCreations";
public static final String artifactId = "KookBC";
public static final String version = "0.27.4";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@
import snw.kookbc.SharedConstants;
import snw.kookbc.impl.CoreImpl;
import snw.kookbc.impl.KBCClient;
import snw.kookbc.impl.command.cloud.CloudCommandManagerImpl;
import snw.kookbc.impl.command.internal.CloudHelpCommand;
import snw.kookbc.impl.command.internal.HelpCommand;
import snw.kookbc.impl.command.internal.PluginsCommand;
import snw.kookbc.impl.entity.builder.EntityBuilder;
import snw.kookbc.impl.entity.builder.MessageBuilder;
import snw.kookbc.impl.event.EventFactory;
import snw.kookbc.impl.event.internal.UserClickButtonListener;
import snw.kookbc.impl.network.NetworkClient;
import snw.kookbc.impl.storage.EntityStorage;
import snw.kookbc.interfaces.network.NetworkSystem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

package me.regadpole.plumbot.internal.maven;

import me.regadpole.plumbot.config.Args;

import javax.annotation.Nonnull;
import java.lang.annotation.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.Arrays;
import java.util.Base64;

public class TextToImg {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
import me.regadpole.plumbot.internal.database.DatabaseManager;
import me.regadpole.plumbot.tool.StringTool;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.*;
import net.md_5.bungee.api.event.ChatEvent;
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.ServerConnectedEvent;
import net.md_5.bungee.api.event.ServerSwitchEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import net.md_5.bungee.event.EventPriority;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import net.md_5.bungee.api.connection.ProxiedPlayer;

import java.net.InetSocketAddress;
import java.util.*;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;

public class ServerManager {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
@MavenLibrary(groupId = HikariCP.groupId, artifactId = HikariCP.artifactId, version = HikariCP.version),
@MavenLibrary(groupId = MySQL.groupId, artifactId = MySQL.artifactId, version = MySQL.version),
@MavenLibrary(groupId = sqlite.groupId, artifactId = sqlite.artifactId, version = sqlite.version),
@MavenLibrary(groupId = kookbc.groupId, artifactId = kookbc.artifactId, version = kookbc.version),
@MavenLibrary(groupId = jsr305.groupId, artifactId = jsr305.artifactId, version = jsr305.version)})
public class Dependencies {
public static class hutool{
Expand Down Expand Up @@ -64,11 +63,6 @@ public static class sqlite{
public static final String artifactId = "sqlite-jdbc";
public static final String version = "3.42.0.0";
}
public static class kookbc{
public static final String groupId = "com.github.SNWCreations";
public static final String artifactId = "KookBC";
public static final String version = "0.27.4";
}
public static class jsr305{
public static final String groupId = "com.google.code.findbugs";
public static final String artifactId = "jsr305";
Expand Down
1 change: 0 additions & 1 deletion plumbot-bungee/src/main/java/sdk/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetSocketAddress;
import java.util.Arrays;
import java.util.concurrent.BlockingQueue;
import java.util.logging.Level;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import sdk.utils.ListenerUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
Expand Down
29 changes: 4 additions & 25 deletions plumbot-velocity/src/main/java/me/regadpole/plumbot/PlumBot.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package me.regadpole.plumbot;

import com.alibaba.fastjson.JSONArray;
import com.google.inject.Inject;
import com.velocitypowered.api.command.CommandManager;
import com.velocitypowered.api.command.CommandMeta;
Expand All @@ -19,24 +18,16 @@
import me.regadpole.plumbot.config.VelocityConfig;
import me.regadpole.plumbot.event.server.ServerEvent;
import me.regadpole.plumbot.internal.Config;
import me.regadpole.plumbot.internal.DbConfig;
import me.regadpole.plumbot.internal.Dependencies;
import me.regadpole.plumbot.internal.Environment;
import me.regadpole.plumbot.internal.database.Database;
import me.regadpole.plumbot.internal.database.DatabaseManager;
import me.regadpole.plumbot.internal.database.MySQL;
import me.regadpole.plumbot.internal.database.SQLite;
import me.regadpole.plumbot.internal.maven.LibraryLoader;
import me.regadpole.plumbot.metrics.Metrics;
import org.slf4j.Logger;
import org.yaml.snakeyaml.Yaml;

import java.io.*;
import java.io.File;
import java.nio.file.Path;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Map;
import java.util.Objects;

@Plugin(id = "plumbot", name = "PlumBot", version = "1.3.2",
url = "https://github.com/RegadPoleCN/PlumBot", description = "A bot plugin for QQ or Kook.", authors = {"Linear,RegadPole"})
Expand Down Expand Up @@ -84,21 +75,6 @@ public PlumBot(ProxyServer server, Logger logger, @DataDirectory Path dataDirect

@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {

getServer().getScheduler().buildTask(this, () -> {
try {
File botFile = new File(getDataFolder(), "bot.yml");
InputStream botIs = new FileInputStream(botFile);
Yaml yaml = new Yaml();
Map<String, Object> botObj = yaml.load(botIs);
Config.bot.Groups = !Objects.isNull(botObj.get("Groups")) ? JSONArray.parseArray(botObj.get("Groups").toString(), Long.class) : new ArrayList<>();
Config.bot.Admins = !Objects.isNull(botObj.get("Admins")) ? JSONArray.parseArray(botObj.get("Admins").toString(), Long.class) : new ArrayList<>();
botIs.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}).schedule();

DatabaseManager.start();
server.getEventManager().register(this, new ServerEvent());
logger.info("服务器事件监听器注册成功");
Expand All @@ -107,6 +83,9 @@ public void onProxyInitialization(ProxyInitializeEvent event) {
manager.register(linearbot, new Commands(this));
logger.info("插件命令监听器注册成功");

pluginContainer = server.getPluginManager().fromInstance(this).orElseThrow(
() -> new IllegalArgumentException("The provided instance is not a plugin"));

getServer().getScheduler().buildTask(this, () -> {
switch (Config.bot.Bot.Mode) {
case "go-cqhttp":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import com.velocitypowered.api.command.SimpleCommand;
import me.regadpole.plumbot.PlumBot;
import me.regadpole.plumbot.bot.KookBot;
import me.regadpole.plumbot.config.VelocityConfig;
import me.regadpole.plumbot.internal.Config;
import me.regadpole.plumbot.internal.DbConfig;
import me.regadpole.plumbot.internal.database.DatabaseManager;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import me.regadpole.plumbot.config.VelocityConfig;
import snw.jkook.command.ConsoleCommandSender;
import snw.jkook.plugin.Plugin;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package me.regadpole.plumbot.config;

import com.alibaba.fastjson.JSONArray;
import me.regadpole.plumbot.PlumBot;
import me.regadpole.plumbot.internal.Config;
import me.regadpole.plumbot.internal.DbConfig;
Expand Down Expand Up @@ -78,6 +77,8 @@ public void loadConfig() throws IOException {
Config.bot.Bot.gocqhttp.ListenPort = !Objects.isNull(cqMap.get("ListenPort")) ? Integer.parseInt(String.valueOf(cqMap.get("ListenPort"))) : 5701;
Map<String, Object> kookMap = !Objects.isNull(botMap.get("Kook")) ? (Map<String, Object>) botMap.get("Kook") : new HashMap<>();
Config.bot.Bot.kook.Token = !Objects.isNull(kookMap.get("Token")) ? String.valueOf(kookMap.get("Token")) : "";
Config.bot.Groups = !Objects.isNull(botObj.get("Groups")) ? (List<Long>) botObj.get("Groups") : new ArrayList<>();
Config.bot.Admins = !Objects.isNull(botObj.get("Admins")) ? (List<Long>) botObj.get("Admins") : new ArrayList<>();

Config.config.Ver = !Objects.isNull(configObj.get("Ver")) ? String.valueOf(configObj.get("Ver")) : "1.0";
Map<String, Object> forwardingMap = !Objects.isNull(configObj.get("Forwarding")) ? (Map<String, Object>) configObj.get("Forwarding") : new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.velocitypowered.api.proxy.Player;
import me.regadpole.plumbot.PlumBot;
import me.regadpole.plumbot.bot.KookBot;
import me.regadpole.plumbot.bot.QQBot;
import me.regadpole.plumbot.internal.Config;
import me.regadpole.plumbot.internal.DbConfig;
import me.regadpole.plumbot.internal.database.DatabaseManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
@MavenLibrary(groupId = snakeyaml.groupId, artifactId = snakeyaml.artifactId, version = snakeyaml.version),
@MavenLibrary(groupId = HikariCP.groupId, artifactId = HikariCP.artifactId, version = HikariCP.version),
@MavenLibrary(groupId = MySQL.groupId, artifactId = MySQL.artifactId, version = MySQL.version),
@MavenLibrary(groupId = sqlite.groupId, artifactId = sqlite.artifactId, version = sqlite.version),
@MavenLibrary(groupId = kookbc.groupId, artifactId = kookbc.artifactId, version = kookbc.version)})
@MavenLibrary(groupId = sqlite.groupId, artifactId = sqlite.artifactId, version = sqlite.version)})
public class Dependencies {
public static class hutool{
public static final String groupId = "cn.hutool";
Expand Down Expand Up @@ -69,9 +68,4 @@ public static class sqlite{
public static final String artifactId = "sqlite-jdbc";
public static final String version = "3.42.0.0";
}
public static class kookbc{
public static final String groupId = "com.github.SNWCreations";
public static final String artifactId = "KookBC";
public static final String version = "0.27.4";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,14 @@
import com.velocitypowered.api.plugin.PluginDescription;
import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.ProxyServer;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import org.slf4j.Logger;

import javax.net.ssl.HttpsURLConnection;
import java.io.*;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
Expand All @@ -50,8 +37,6 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.zip.GZIPOutputStream;
import javax.net.ssl.HttpsURLConnection;
import org.slf4j.Logger;

public class Metrics {

Expand Down

0 comments on commit 51899ec

Please sign in to comment.