config.yml add invsee-implement

This commit is contained in:
tanyaofei 2024-08-12 14:21:29 +08:00
parent a1d4315486
commit b665b12cd2
6 changed files with 50 additions and 15 deletions

View File

@ -4,11 +4,12 @@ import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import io.github.hello09x.fakeplayer.api.spi.NMSBridge;
import io.github.hello09x.fakeplayer.core.config.FakeplayerConfig;
import io.github.hello09x.fakeplayer.core.manager.FakeplayerList;
import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
import io.github.hello09x.fakeplayer.core.manager.invsee.DefaultInvseeManagerImpl;
import io.github.hello09x.fakeplayer.core.manager.invsee.InvseeManager;
import io.github.hello09x.fakeplayer.core.manager.invsee.OpenInvInvseeManagerImpl;
import io.github.hello09x.fakeplayer.core.manager.invsee.SimpleInvseeManagerImpl;
import io.github.hello09x.fakeplayer.core.util.ClassUtils;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
@ -27,14 +28,18 @@ public class FakeplayerModule extends AbstractModule {
@Provides
@Singleton
public InvseeManager invseeManager(FakeplayerManager fakeplayerManager, FakeplayerList fakeplayerList) {
public InvseeManager invseeManager(FakeplayerConfig config, FakeplayerManager fakeplayerManager, FakeplayerList fakeplayerList) {
return switch (config.getInvseeImplement()) {
case SIMPLE -> new SimpleInvseeManagerImpl(fakeplayerManager, fakeplayerList);
case AUTO -> {
if (Bukkit.getPluginManager().isPluginEnabled("OpenInv") && ClassUtils.isClassExists("com.lishid.openinv.IOpenInv")) {
log.info("Using OpenInv as invsee implementation");
return new OpenInvInvseeManagerImpl(fakeplayerManager, fakeplayerList);
log.info("Using OpenInv as invsee implement");
yield new OpenInvInvseeManagerImpl(fakeplayerManager, fakeplayerList);
}
log.info("Using default invsee implementation");
return new DefaultInvseeManagerImpl(fakeplayerManager, fakeplayerList);
log.info("Using simple invsee implement");
yield new SimpleInvseeManagerImpl(fakeplayerManager, fakeplayerList);
}
};
}
@Provides

View File

@ -4,6 +4,7 @@ package io.github.hello09x.fakeplayer.core.config;
import com.google.common.annotations.Beta;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import io.github.hello09x.devtools.core.config.ConfigUtils;
import io.github.hello09x.devtools.core.config.PluginConfig;
import io.github.hello09x.fakeplayer.core.Main;
import lombok.Getter;
@ -139,6 +140,11 @@ public class FakeplayerConfig extends PluginConfig {
*/
private PreventKicking preventKicking;
/**
* invsee 实现方式
*/
private InvseeImplement invseeImplement;
/**
* 真实皮肤
*/
@ -164,7 +170,6 @@ public class FakeplayerConfig extends PluginConfig {
this.selfCommands = file.getStringList("self-commands");
this.preSpawnCommands = file.getStringList("pre-spawn-commands");
this.postSpawnCommands = file.getStringList("post-spawn-commands");
deprecated:
this.afterSpawnCommands = file.getStringList("after-spawn-commands");
this.postQuitCommands = file.getStringList("post-quit-commands");
this.afterQuitCommands = file.getStringList("after-quit-commands");
@ -184,6 +189,7 @@ public class FakeplayerConfig extends PluginConfig {
.collect(Collectors.toSet());
this.defaultOnlineSkin = file.getBoolean("default-online-skin", false);
this.invseeImplement = ConfigUtils.getEnum(file, "invsee-implement", InvseeImplement.class, InvseeImplement.AUTO);
this.debug = file.getBoolean("debug", false);
if (this.isFileConfigurationOutOfDate()) {
@ -245,7 +251,7 @@ public class FakeplayerConfig extends PluginConfig {
return PreventKicking.ON_SPAWNING;
}
return PreventKicking.valueOf(file.getString("prevent-kicking", PreventKicking.NEVER.toString()));
return ConfigUtils.getEnum(file, "prevent-kicking", PreventKicking.class, PreventKicking.ON_SPAWNING);
}
}

View File

@ -0,0 +1,13 @@
package io.github.hello09x.fakeplayer.core.config;
/**
* @author tanyaofei
* @since 2024/8/12
**/
public enum InvseeImplement {
AUTO,
SIMPLE
}

View File

@ -16,10 +16,10 @@ import org.jetbrains.annotations.Nullable;
* @since 2024/8/12
**/
@Singleton
public class DefaultInvseeManagerImpl extends AbstractInvseeManager {
public class SimpleInvseeManagerImpl extends AbstractInvseeManager {
@Inject
public DefaultInvseeManagerImpl(FakeplayerManager manager, FakeplayerList fakeplayerList) {
public SimpleInvseeManagerImpl(FakeplayerManager manager, FakeplayerList fakeplayerList) {
super(manager, fakeplayerList);
}

View File

@ -4,7 +4,7 @@
# 不要直接修改 config.tmpl.yml 文件,将这份文件复制并重命名为 config.yml 来作为配置文件
# 【Important】【非常重要】
# =========================================================================================================
version: 16
version: 17
# 多国语言配置
# 可选项: en, zh, zh_cn, zh_tw, zh_hk
@ -124,6 +124,17 @@ kick-on-dead: true
kale-tps: 0
# Invsee implement:
# Options:
# AUTO: Auto choose a implement depends on server plugins. Supports: OpenInv
# SIMPLE: A simple implement, with it, you can NOT visit or modify equipments
# Invsee 实现:
# 可选项:
# AUTO: 自动,自动根据服务器安装的插件来选择, 当前支持的插件: OpenInv
# SIMPLE: 一个简单的内嵌实现, 使用这个不能看到或者编辑假人的装备栏
invsee-implement: AUTO
# Pre-Spawn-Commands
# Server will execute the following commands BEFORE trying to spawn a fake player.
# This is helpful for adding fake player into whitelist

View File

@ -26,7 +26,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>0.3.9-b.4</revision>
<detools.version>0.1.3-SNAPSHOT</detools.version>
<detools.version>0.1.4-SNAPSHOT</detools.version>
</properties>
<repositories>