1. 跨世界传送添加到配置文件

2. 开放 invsee 命令
This commit is contained in:
tanyaofei 2023-07-21 14:39:55 +08:00
parent cfef7786b1
commit 455528a2fb
13 changed files with 69 additions and 42 deletions

11
.gitignore vendored
View File

@ -122,10 +122,7 @@ fabric.properties
# Android studio 3.1+ serialized cache file # Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser .idea/caches/build_file_checksums.ser
server/ *.iml
.idea/
server2/ /folia/
/purpur/
lib/
.idea/

View File

@ -15,13 +15,13 @@
## 命令 ## 命令
+ /fp create - 创建一个假人 + /fp create - 创建一个假人
+ /fp kick - 删除假人
+ /fp drop - 丢弃假人手上物品 + /fp drop - 丢弃假人手上物品
+ /fp open - 查看假人背包
+ /fp remove - 删除假人
+ /fp tp - 传送到假人身边 + /fp tp - 传送到假人身边
+ /fp tps - 与假人交换位置 + /fp tps - 与假人交换位置
+ /fp config - 玩家个性化配置
+ /fp tphere - 将假人传送到自己身边 + /fp tphere - 将假人传送到自己身边
+ /fp invsee - 查看假人背包
+ /fp config - 玩家个性化配置
此外,假人是一个模拟玩家,因此可以被任何指令所识别比如 `kick`, `tp`, `ban` 等等 此外,假人是一个模拟玩家,因此可以被任何指令所识别比如 `kick`, `tp`, `ban` 等等
@ -34,6 +34,13 @@
+ fakeplayer.control - 查看背包、丢弃物品等指令权限 + fakeplayer.control - 查看背包、丢弃物品等指令权限
+ fakeplayer.admin - 管理员权限 + fakeplayer.admin - 管理员权限
## 已知问题
1. 通过 `/fp open` 命令或者右键打开假人的背包时, 点击物品再放入玩家的背包有可能出现消失(可能塞到了假人的装备栏上),
你可能需要将假人销毁让他背包掉落。这个 bug 的原因跟 ess 插件的 `/invsee` 存在的原因一样, 暂时没有办法处理
2. 由于跟一些插件冲突, 跨世界 tp 假人 (包括 `/fp tp` 或者 `/tpa` 等任何方式的传送) 有可能导致假人飞走, 这可能会是一个无人区而导致区块加载,
如果你发现了这个问题应当在配置文件里关闭跨世界传送
## 配置项 ## 配置项
这个不定时更新内容,具体以插件的 `config.yml 为准` 这个不定时更新内容,具体以插件的 `config.yml 为准`

13
pom.xml
View File

@ -146,12 +146,13 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>com.comphenix.protocol</groupId>--> <!-- <dependency>-->
<!-- <artifactId>ProtocolLib</artifactId>--> <!-- <groupId>com.comphenix.protocol</groupId>-->
<!-- <version>5.0.0</version>--> <!-- <artifactId>ProtocolLib</artifactId>-->
<!-- <scope>provided</scope>--> <!-- <version>5.0.0</version>-->
<!-- </dependency>--> <!-- <scope>provided</scope>-->
<!-- </dependency>-->
</dependencies> </dependencies>
</project> </project>

View File

@ -35,7 +35,7 @@ public final class Main extends JavaPlugin {
pm.registerEvents(PlayerPreLoginListener.instance, this); pm.registerEvents(PlayerPreLoginListener.instance, this);
pm.registerEvents(PlayerQuitListener.instance, this); pm.registerEvents(PlayerQuitListener.instance, this);
pm.registerEvents(PlayerDeathListener.instance, this); pm.registerEvents(PlayerDeathListener.instance, this);
// pm.registerEvents(PlayerInteractAtEntityListener.instance, this); pm.registerEvents(PlayerInteractAtEntityListener.instance, this);
pm.registerEvents(PlayerTeleportListener.instance, this); pm.registerEvents(PlayerTeleportListener.instance, this);
} }

View File

@ -3,10 +3,10 @@ package io.github.hello09x.fakeplayer.command;
import io.github.hello09x.fakeplayer.command.admin.ReloadCommand; import io.github.hello09x.fakeplayer.command.admin.ReloadCommand;
import io.github.hello09x.fakeplayer.command.player.config.ConfigCommand; import io.github.hello09x.fakeplayer.command.player.config.ConfigCommand;
import io.github.hello09x.fakeplayer.command.player.control.DropCommand; import io.github.hello09x.fakeplayer.command.player.control.DropCommand;
import io.github.hello09x.fakeplayer.command.player.control.OpenCommand; import io.github.hello09x.fakeplayer.command.player.control.InvseeCommand;
import io.github.hello09x.fakeplayer.command.player.spawn.CreateCommand; import io.github.hello09x.fakeplayer.command.player.spawn.CreateCommand;
import io.github.hello09x.fakeplayer.command.player.spawn.ListCommand; import io.github.hello09x.fakeplayer.command.player.spawn.ListCommand;
import io.github.hello09x.fakeplayer.command.player.spawn.RemoveCommand; import io.github.hello09x.fakeplayer.command.player.spawn.KickCommand;
import io.github.hello09x.fakeplayer.command.player.tp.TpHereCommand; import io.github.hello09x.fakeplayer.command.player.tp.TpHereCommand;
import io.github.hello09x.fakeplayer.command.player.tp.TpSwapCommand; import io.github.hello09x.fakeplayer.command.player.tp.TpSwapCommand;
import io.github.hello09x.fakeplayer.command.player.tp.TpToCommand; import io.github.hello09x.fakeplayer.command.player.tp.TpToCommand;
@ -24,7 +24,7 @@ public class RootCommand extends ParentCommand {
static { static {
// spawn // spawn
instance.register("create", CreateCommand.instance); instance.register("create", CreateCommand.instance);
instance.register("remove", RemoveCommand.instance); instance.register("kick", KickCommand.instance);
instance.register("list", ListCommand.instance); instance.register("list", ListCommand.instance);
// tp // tp
@ -37,7 +37,7 @@ public class RootCommand extends ParentCommand {
// control // control
instance.register("drop", DropCommand.instance); instance.register("drop", DropCommand.instance);
// instance.register("open", OpenCommand.instance); instance.register("invsee", InvseeCommand.instance);
// instance.register("attack", AttackCommand.instance); // instance.register("attack", AttackCommand.instance);
// admin // admin

View File

@ -1,6 +1,7 @@
package io.github.hello09x.fakeplayer.command.player.control; package io.github.hello09x.fakeplayer.command.player.control;
import io.github.hello09x.fakeplayer.command.player.AbstractCommand; import io.github.hello09x.fakeplayer.command.player.AbstractCommand;
import io.github.hello09x.fakeplayer.manager.FakePlayerManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -10,15 +11,17 @@ import org.jetbrains.annotations.Nullable;
import static net.kyori.adventure.text.Component.text; import static net.kyori.adventure.text.Component.text;
import static net.kyori.adventure.text.format.NamedTextColor.RED; import static net.kyori.adventure.text.format.NamedTextColor.RED;
public class OpenCommand extends AbstractCommand { public class InvseeCommand extends AbstractCommand {
public final static OpenCommand instance = new OpenCommand( private final FakePlayerManager manager = FakePlayerManager.instance;
public final static InvseeCommand instance = new InvseeCommand(
"打开假人背包", "打开假人背包",
"/fp open [假人名称]", "/fp open [假人名称]",
"fakeplayer.control" "fakeplayer.control"
); );
public OpenCommand(@NotNull String description, @NotNull String usage, @Nullable String permission) { public InvseeCommand(@NotNull String description, @NotNull String usage, @Nullable String permission) {
super(description, usage, permission); super(description, usage, permission);
} }
@ -34,7 +37,7 @@ public class OpenCommand extends AbstractCommand {
return false; return false;
} }
p.openInventory(target.getInventory()); manager.openInventory(p, target);
return true; return true;
} }
} }

View File

@ -12,17 +12,17 @@ import java.util.List;
import static net.kyori.adventure.text.Component.text; import static net.kyori.adventure.text.Component.text;
import static net.kyori.adventure.text.format.NamedTextColor.GRAY; import static net.kyori.adventure.text.format.NamedTextColor.GRAY;
public class RemoveCommand extends AbstractCommand { public class KickCommand extends AbstractCommand {
public final static RemoveCommand instance = new RemoveCommand( public final static KickCommand instance = new KickCommand(
"移除假人", "移除假人",
"/fp remove [假人名称]", "/fp kick [假人名称]",
"fakeplayer.spawn" "fakeplayer.spawn"
); );
private final FakePlayerManager manager = FakePlayerManager.instance; private final FakePlayerManager manager = FakePlayerManager.instance;
public RemoveCommand( public KickCommand(
@NotNull String description, @NotNull String description,
@NotNull String usage, @NotNull String usage,
@Nullable String permission @Nullable String permission

View File

@ -19,7 +19,7 @@ public class ListCommand extends ExecutableCommand {
public final static ListCommand instance = new ListCommand( public final static ListCommand instance = new ListCommand(
"查看所有假人", "查看所有假人",
"/list [页码] [数量]", "/fp list [页码] [数量]",
"fakeplayer.spawn" "fakeplayer.spawn"
); );
private final static FakePlayerManager manager = FakePlayerManager.instance; private final static FakePlayerManager manager = FakePlayerManager.instance;

View File

@ -27,7 +27,7 @@ public class PlayerInteractAtEntityListener implements Listener {
} }
if (player.isOp() || Objects.equals(manager.getCreator(target), player.getName())) { if (player.isOp() || Objects.equals(manager.getCreator(target), player.getName())) {
player.openInventory(target.getInventory()); manager.openInventory(player, target);
} }
} }

View File

@ -3,14 +3,12 @@ package io.github.hello09x.fakeplayer.listener;
import io.github.hello09x.fakeplayer.Main; import io.github.hello09x.fakeplayer.Main;
import io.github.hello09x.fakeplayer.manager.FakePlayerManager; import io.github.hello09x.fakeplayer.manager.FakePlayerManager;
import io.github.hello09x.fakeplayer.properties.FakeplayerProperties; import io.github.hello09x.fakeplayer.properties.FakeplayerProperties;
import org.bukkit.craftbukkit.v1_20_R1.CraftWorldBorder;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Objects;
import java.util.logging.Logger; import java.util.logging.Logger;
public class PlayerTeleportListener implements Listener { public class PlayerTeleportListener implements Listener {
@ -25,13 +23,18 @@ public class PlayerTeleportListener implements Listener {
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void handleTeleportEvent(@NotNull PlayerTeleportEvent event) { public void handleTeleportEvent(@NotNull PlayerTeleportEvent event) {
if (manager.isFake(event.getPlayer()) var player = event.getPlayer();
&& !(properties.isTpAcrossWorlds() if (!manager.isFake(player)) {
&& !Objects.equals(event.getFrom().getWorld().getUID(), event.getTo().getWorld().getUID()))){ return;
}
var fromWorld = event.getFrom().getWorld().getUID();
var toWorld = event.getTo().getWorld().getUID();
if (!properties.isTpAcrossWorlds() && fromWorld != toWorld) {
log.info(String.format("已取消假人 %s 跨世界传送的操作", event.getPlayer().getName()));
event.setCancelled(true); event.setCancelled(true);
} }
} }
} }

View File

@ -8,8 +8,9 @@ import io.github.hello09x.fakeplayer.repository.UserConfigRepository;
import io.github.hello09x.fakeplayer.repository.model.Configs; import io.github.hello09x.fakeplayer.repository.model.Configs;
import io.github.hello09x.fakeplayer.util.AddressUtils; import io.github.hello09x.fakeplayer.util.AddressUtils;
import io.github.hello09x.fakeplayer.util.MetadataUtils; import io.github.hello09x.fakeplayer.util.MetadataUtils;
import io.github.hello09x.fakeplayer.util.SeedUUID;
import net.kyori.adventure.text.format.Style; import net.kyori.adventure.text.format.Style;
import net.kyori.adventure.title.Title;
import net.kyori.adventure.util.Ticks;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -218,6 +219,21 @@ public class FakePlayerManager {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
public void openInventory(@NotNull Player player, @NotNull Player fakePlayer) {
if (!isFake(fakePlayer)) {
return;
}
player.showTitle(Title.title(
text("取物品有概率消失", RED),
text("尽量使用 Shift + 左键取物品"),
Title.Times.times(Ticks.duration(10), Ticks.duration(20), Ticks.duration(20))
));
var inv = fakePlayer.getInventory();
player.openInventory(inv);
}
public void cleanup(@NotNull Player fakePlayer) { public void cleanup(@NotNull Player fakePlayer) {
if (!isFake(fakePlayer)) { if (!isFake(fakePlayer)) {
return; return;

View File

@ -65,7 +65,7 @@ tp-across-worlds: false
# %u: 假人 uuid # %u: 假人 uuid
# %c: 创建者的名称 # %c: 创建者的名称
preparing-commands: preparing-commands:
- '/give %p 1 poppy' - '/give %p poppy 1'
- '' - ''
# 假人销毁时执行的命令 # 假人销毁时执行的命令

View File

@ -21,7 +21,7 @@ permissions:
default: op default: op
fakeplayer.spawn: fakeplayer.spawn:
description: '拥有 create, remove, list 命令执行的权限' description: '拥有 create, kick, list 命令执行的权限'
default: op default: op
fakeplayer.tp: fakeplayer.tp:
@ -29,7 +29,7 @@ permissions:
default: op default: op
fakeplayer.control: fakeplayer.control:
description: '拥有 open, drop 命令执行的权限' description: '拥有 invsee, drop 命令执行的权限'
default: op default: op
fakeplayer.admin: fakeplayer.admin: