Skip to content

Commit

Permalink
fix(load): 修复插件加载时出现的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
CarmJos committed Dec 17, 2022
1 parent 708d3f8 commit fa30bda
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 39 deletions.
6 changes: 0 additions & 6 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,6 @@
<scope>compile</scope>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>compile</scope>
</dependency>

</dependencies>

<build>
Expand Down
10 changes: 3 additions & 7 deletions core/src/main/java/cc/carm/plugin/minesql/MineSQLCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,10 @@
import co.aikar.commands.CommandManager;
import co.aikar.commands.InvalidCommandArgument;
import co.aikar.commands.Locales;
import com.google.common.collect.ImmutableList;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
import java.util.*;
import java.util.logging.Logger;

public class MineSQLCore implements IMineSQL {
Expand Down Expand Up @@ -126,8 +122,8 @@ protected void initializeCommands(CommandManager<?, ?, ?, ?, ?, ?> commandManage
}
});
commandManager.getCommandCompletions().registerCompletion("sql-managers", c -> {
if (c.getIssuer().isPlayer()) return ImmutableList.of();
else return ImmutableList.copyOf(getRegistry().list().keySet());
if (c.getIssuer().isPlayer()) return Collections.emptyList();
else return getRegistry().list().keySet();
});
commandManager.registerCommand(new MineSQLCommand(this));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import cc.carm.plugin.minesql.api.source.SQLSourceConfig;
import cn.beecp.BeeDataSource;
import cn.beecp.BeeDataSourceConfig;
import com.google.common.collect.ImmutableMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Unmodifiable;
Expand Down Expand Up @@ -115,7 +114,7 @@ public MineSQLCore getCore() {
@Override
@Unmodifiable
public @NotNull Map<String, SQLManagerImpl> list() {
return ImmutableMap.copyOf(this.managers);
return Collections.unmodifiableMap(this.managers);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package cc.carm.plugin.minesql;

import cc.carm.lib.easyplugin.utils.ColorParser;
import cc.carm.lib.easyplugin.utils.JarResourceUtils;
import cc.carm.plugin.minesql.conf.PluginConfiguration;
import co.aikar.commands.BungeeCommandManager;
import co.aikar.commands.CommandManager;
Expand All @@ -10,6 +12,8 @@
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.util.Arrays;
import java.util.Optional;
import java.util.logging.Logger;

public class MineSQLBungee extends Plugin implements MineSQLPlatform {
Expand All @@ -29,6 +33,7 @@ public void onLoad() {

@Override
public void onEnable() {
outputInfo();
getLogger().info("初始化指令管理器...");
this.commandManager = new BungeeCommandManager(this);

Expand Down Expand Up @@ -59,6 +64,7 @@ public void onEnable() {

@Override
public void onDisable() {
outputInfo();
getLogger().info("终止全部数据库连接...");
this.core.getRegistry().shutdownAll();
}
Expand Down Expand Up @@ -86,5 +92,11 @@ public static MineSQLBungee getInstance() {
return this.commandManager;
}

@SuppressWarnings("deprecation")
public void outputInfo() {
Optional.ofNullable(JarResourceUtils.readResource(this.getResourceAsStream("PLUGIN_INFO")))
.map(v -> ColorParser.parse(Arrays.asList(v)))
.ifPresent(list -> list.forEach(s -> ProxyServer.getInstance().getConsole().sendMessage(s)));
}

}
18 changes: 8 additions & 10 deletions platforms/velocity/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,32 +68,30 @@

<!--suppress VulnerableLibrariesLocal -->
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>minesql-core</artifactId>
<version>${project.parent.version}</version>
<scope>compile</scope>
<groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId>
<version>3.1.1</version>
<scope>provided</scope>
</dependency>

<!--suppress VulnerableLibrariesLocal -->
<dependency>
<groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
<groupId>${project.parent.groupId}</groupId>
<artifactId>minesql-core</artifactId>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-velocity</artifactId>
<version>3.0.0</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-velocity</artifactId>
<version>0.5.1-SNAPSHOT</version>
<optional>true</optional>
</dependency>

</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
)
public class MineSQLVelocity implements MineSQLPlatform {

private static MineSQLVelocity instance;

private final ProxyServer server;
private final Logger logger;
private final File dataFolder;
Expand All @@ -45,7 +43,6 @@ public class MineSQLVelocity implements MineSQLPlatform {
public MineSQLVelocity(ProxyServer server, Logger logger,
@DataDirectory Path dataDirectory,
Metrics.Factory metricsFactory) {
instance = this;
this.server = server;
this.logger = logger;
this.dataFolder = dataDirectory.toFile();
Expand All @@ -57,7 +54,7 @@ public MineSQLVelocity(ProxyServer server, Logger logger,

@Subscribe(order = PostOrder.FIRST)
public void onInitialize(ProxyInitializeEvent event) {

outputInfo();
getLogger().info("初始化指令管理器...");
this.commandManager = new VelocityCommandManager(server, this);

Expand Down Expand Up @@ -87,18 +84,19 @@ public void onInitialize(ProxyInitializeEvent event) {

@Subscribe(order = PostOrder.LAST)
public void onShutdown(ProxyShutdownEvent event) {
outputInfo();
getLogger().info("终止全部数据库连接...");
this.core.getRegistry().shutdownAll();
}

public static MineSQLVelocity getInstance() {
return instance;
}

public ProxyServer getServer() {
return server;
}

public @NotNull Logger getLogger() {
return logger;
}

public String getVersion() {
return this.server.getPluginManager().getPlugin("minesql")
.map(PluginContainer::getDescription)
Expand All @@ -110,9 +108,6 @@ public String getVersion() {
return this.dataFolder;
}

public @NotNull Logger getLogger() {
return logger;
}

@Override
public @NotNull CommandManager<?, ?, ?, ?, ?, ?> getCommandManager() {
Expand All @@ -123,5 +118,7 @@ public String getVersion() {
return this.core.getConfig();
}


public void outputInfo() {
//TODO
}
}
8 changes: 6 additions & 2 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,12 @@
<shadedPattern>cc.carm.plugin.minesql.lib.jna</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>com.google</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.google</shadedPattern> <!-- Replace this -->
<pattern>com.google.protobuf</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.google.protobuf</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>com.google.errorprone</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.google.errorprone</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>com.github</pattern>
Expand Down

0 comments on commit fa30bda

Please sign in to comment.