Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

是否考虑游戏结束自动刷新世界 #3

Open
konglai55 opened this issue Oct 7, 2022 · 6 comments
Open

是否考虑游戏结束自动刷新世界 #3

konglai55 opened this issue Oct 7, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@konglai55
Copy link

今天常识了大佬的插件 但是对于这种一局一重启的游戏是否加上一个游戏结束自动刷新世界的功能比较合理呢

@MossCG
Copy link
Contributor

MossCG commented Oct 7, 2022

合理,但是懒得写(
我用的是命令行去删除目前233333

@MossCG MossCG added the enhancement New feature or request label Oct 7, 2022
@konglai55
Copy link
Author

能说一下大佬是怎么删除的吗 如果有能游戏结束自动刷新的办法自然也没必要去写了 (doge)

@JerryZRF
Copy link

我写的分支里加了这个功能(虽然很傻的样子
欢迎看看https://github.com/JerryZRF/MineHunt3
(几百年没更新过了
https://github.com/JerryZRF/MineHunt3/blob/master/src/main/java/net/mcbbs/jerryzrf/minehunt/MineHunt.java#L60

	@Override
	public void onDisable() {
		// Plugin shutdown logic
		if (getConfig().getBoolean("changeMap")) {
			Runtime.getRuntime().addShutdownHook(new Thread(() -> {
				File world = new File(getDataFolder(), "..\\..\\world");
				DeleteFile(world);
				world = new File(getDataFolder(), "..\\..\\world_nether");
				DeleteFile(world);
				world = new File(getDataFolder(), "..\\..\\world_the_end");
				DeleteFile(world);
				System.out.println("地图清理完成");
			}));
		}
	}

@MossCG
Copy link
Contributor

MossCG commented Oct 26, 2022

我写的分支里加了这个功能(虽然很傻的样子 欢迎看看https://github.com/JerryZRF/MineHunt3 (几百年没更新过了 https://github.com/JerryZRF/MineHunt3/blob/master/src/main/java/net/mcbbs/jerryzrf/minehunt/MineHunt.java#L60

	@Override
	public void onDisable() {
		// Plugin shutdown logic
		if (getConfig().getBoolean("changeMap")) {
			Runtime.getRuntime().addShutdownHook(new Thread(() -> {
				File world = new File(getDataFolder(), "..\\..\\world");
				DeleteFile(world);
				world = new File(getDataFolder(), "..\\..\\world_nether");
				DeleteFile(world);
				world = new File(getDataFolder(), "..\\..\\world_the_end");
				DeleteFile(world);
				System.out.println("地图清理完成");
			}));
		}
	}

看起来可行,但是我记得插件onDisable的执行应该是再保存世界前面?如果我没记错的话

@JerryZRF
Copy link

JerryZRF commented Nov 4, 2022

所以注册了一个ShutdownHook

@MossCG
Copy link
Contributor

MossCG commented Nov 4, 2022

所以注册了一个ShutdownHook

噢看到了 瞎了 合理
这个思路确实可以,但是最近有点懒得敲代码,等下一次想更新的时间再加上吧(((

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants