Skip to content

Commit

Permalink
将GameCore下载整合到GameCoreDownload工具类
Browse files Browse the repository at this point in the history
  • Loading branch information
lt-name committed Dec 25, 2022
1 parent 50fd2e7 commit 30d0a18
Show file tree
Hide file tree
Showing 5 changed files with 269 additions and 263 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
<includes>
<include>${project.basedir}/src/main/resources/plugin.yml</include>
<include>${project.basedir}/src/main/java/com/smallaswater/npc/RsNPC.java</include>
<include>${project.basedir}/src/main/java/com/smallaswater/npc/utils/GameCoreDownload.java</include>
</includes>
<replacements>
<replacement>
Expand Down
38 changes: 6 additions & 32 deletions src/main/java/com/smallaswater/npc/RsNPC.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.smallaswater.npc.dialog.DialogManager;
import com.smallaswater.npc.entitys.EntityRsNPC;
import com.smallaswater.npc.tasks.CheckNpcEntityTask;
import com.smallaswater.npc.utils.GameCoreDownload;
import com.smallaswater.npc.utils.MetricsLite;
import com.smallaswater.npc.utils.Utils;
import com.smallaswater.npc.utils.update.ConfigUpdateUtils;
Expand Down Expand Up @@ -59,13 +60,6 @@ public class RsNPC extends PluginBase {

private static final Skin DEFAULT_SKIN;

public static final String MINIMUM_GAME_CORE_VERSION = "1.6.8";

private static final String MAVEN_URL_CENTRAL = "https://repo1.maven.org/maven2/";
private static final String MAVEN_URL_LANINK = "https://repo.lanink.cn/";

private static final String GAME_CORE_URL = "cn/lanink/MemoriesOfTime-GameCore/" + MINIMUM_GAME_CORE_VERSION + "/MemoriesOfTime-GameCore-" + MINIMUM_GAME_CORE_VERSION + ".jar";

static {
Skin skin = new Skin();
skin.setTrusted(true);
Expand All @@ -82,8 +76,6 @@ public static RsNPC getInstance() {
public void onLoad() {
rsNPC = this;

this.loadLanguage();

VariableManage.addVariable("%npcName%", (player, rsNpcConfig) -> rsNpcConfig.getName());
VariableManage.addVariable("@p", (player, rsNpcConfig) -> player.getName());

Expand All @@ -101,9 +93,7 @@ public void onLoad() {

@Override
public void onEnable() {
this.getLogger().info(this.getLanguage().translateString("plugin.load.startLoad"));

switch (Utils.checkAndDownloadDepend()) {
switch (GameCoreDownload.checkAndDownload()) {
case 1:
Server.getInstance().getPluginManager().disablePlugin(this);
return;
Expand All @@ -114,6 +104,10 @@ public void onEnable() {
break;
}

this.loadLanguage();

this.getLogger().info(this.getLanguage().translateString("plugin.load.startLoad"));

NukkitTypeUtils.NukkitType nukkitType = NukkitTypeUtils.getNukkitType();
if (nukkitType != NukkitTypeUtils.NukkitType.NUKKITX && nukkitType != NukkitTypeUtils.NukkitType.POWER_NUKKIT) {
this.getLogger().error("警告!您所使用的插件版本不支持此Nukkit分支!");
Expand Down Expand Up @@ -357,26 +351,6 @@ public Config getNpcConfigDescription() {
return this.npcConfigDescription;
}

/**
* @return 最低GameCore版本
*/
public String getMinimumGameCoreVersion() {
return MINIMUM_GAME_CORE_VERSION;
}

/**
* @return GameCore下载链接
*/
public String getGameCoreUrl(int i) {
String maven;
if (i > 0) {
maven = MAVEN_URL_LANINK;
}else {
maven = MAVEN_URL_CENTRAL;
}
return maven + GAME_CORE_URL;
}

public String getVersion() {
Config config = new Config(Config.PROPERTIES);
config.load(this.getResource("git.properties"));
Expand Down
146 changes: 0 additions & 146 deletions src/main/java/com/smallaswater/npc/utils/Download.java

This file was deleted.

Loading

0 comments on commit 30d0a18

Please sign in to comment.