mirror of
https://github.com/tanyaofei/minecraft-fakeplayer.git
synced 2025-09-14 11:16:46 +08:00
1. 跨世界传送添加到配置文件
2. 开放 invsee 命令
This commit is contained in:
parent
cfef7786b1
commit
455528a2fb
9
.gitignore
vendored
9
.gitignore
vendored
@ -122,10 +122,7 @@ fabric.properties
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
server/
|
||||
|
||||
server2/
|
||||
|
||||
lib/
|
||||
|
||||
*.iml
|
||||
.idea/
|
||||
/folia/
|
||||
/purpur/
|
||||
|
13
README.md
13
README.md
@ -15,13 +15,13 @@
|
||||
## 命令
|
||||
|
||||
+ /fp create - 创建一个假人
|
||||
+ /fp kick - 删除假人
|
||||
+ /fp drop - 丢弃假人手上物品
|
||||
+ /fp open - 查看假人背包
|
||||
+ /fp remove - 删除假人
|
||||
+ /fp tp - 传送到假人身边
|
||||
+ /fp tps - 与假人交换位置
|
||||
+ /fp config - 玩家个性化配置
|
||||
+ /fp tphere - 将假人传送到自己身边
|
||||
+ /fp invsee - 查看假人背包
|
||||
+ /fp config - 玩家个性化配置
|
||||
|
||||
此外,假人是一个模拟玩家,因此可以被任何指令所识别比如 `kick`, `tp`, `ban` 等等
|
||||
|
||||
@ -34,6 +34,13 @@
|
||||
+ fakeplayer.control - 查看背包、丢弃物品等指令权限
|
||||
+ fakeplayer.admin - 管理员权限
|
||||
|
||||
## 已知问题
|
||||
|
||||
1. 通过 `/fp open` 命令或者右键打开假人的背包时, 点击物品再放入玩家的背包有可能出现消失(可能塞到了假人的装备栏上),
|
||||
你可能需要将假人销毁让他背包掉落。这个 bug 的原因跟 ess 插件的 `/invsee` 存在的原因一样, 暂时没有办法处理
|
||||
2. 由于跟一些插件冲突, 跨世界 tp 假人 (包括 `/fp tp` 或者 `/tpa` 等任何方式的传送) 有可能导致假人飞走, 这可能会是一个无人区而导致区块加载,
|
||||
如果你发现了这个问题应当在配置文件里关闭跨世界传送
|
||||
|
||||
## 配置项
|
||||
|
||||
这个不定时更新内容,具体以插件的 `config.yml 为准`
|
||||
|
13
pom.xml
13
pom.xml
@ -146,12 +146,13 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.comphenix.protocol</groupId>-->
|
||||
<!-- <artifactId>ProtocolLib</artifactId>-->
|
||||
<!-- <version>5.0.0</version>-->
|
||||
<!-- <scope>provided</scope>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.comphenix.protocol</groupId>-->
|
||||
<!-- <artifactId>ProtocolLib</artifactId>-->
|
||||
<!-- <version>5.0.0</version>-->
|
||||
<!-- <scope>provided</scope>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -35,7 +35,7 @@ public final class Main extends JavaPlugin {
|
||||
pm.registerEvents(PlayerPreLoginListener.instance, this);
|
||||
pm.registerEvents(PlayerQuitListener.instance, this);
|
||||
pm.registerEvents(PlayerDeathListener.instance, this);
|
||||
// pm.registerEvents(PlayerInteractAtEntityListener.instance, this);
|
||||
pm.registerEvents(PlayerInteractAtEntityListener.instance, this);
|
||||
pm.registerEvents(PlayerTeleportListener.instance, this);
|
||||
}
|
||||
|
||||
|
@ -3,10 +3,10 @@ package io.github.hello09x.fakeplayer.command;
|
||||
import io.github.hello09x.fakeplayer.command.admin.ReloadCommand;
|
||||
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.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.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.TpSwapCommand;
|
||||
import io.github.hello09x.fakeplayer.command.player.tp.TpToCommand;
|
||||
@ -24,7 +24,7 @@ public class RootCommand extends ParentCommand {
|
||||
static {
|
||||
// spawn
|
||||
instance.register("create", CreateCommand.instance);
|
||||
instance.register("remove", RemoveCommand.instance);
|
||||
instance.register("kick", KickCommand.instance);
|
||||
instance.register("list", ListCommand.instance);
|
||||
|
||||
// tp
|
||||
@ -37,7 +37,7 @@ public class RootCommand extends ParentCommand {
|
||||
|
||||
// control
|
||||
instance.register("drop", DropCommand.instance);
|
||||
// instance.register("open", OpenCommand.instance);
|
||||
instance.register("invsee", InvseeCommand.instance);
|
||||
// instance.register("attack", AttackCommand.instance);
|
||||
|
||||
// admin
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.github.hello09x.fakeplayer.command.player.control;
|
||||
|
||||
import io.github.hello09x.fakeplayer.command.player.AbstractCommand;
|
||||
import io.github.hello09x.fakeplayer.manager.FakePlayerManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
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.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 [假人名称]",
|
||||
"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);
|
||||
}
|
||||
|
||||
@ -34,7 +37,7 @@ public class OpenCommand extends AbstractCommand {
|
||||
return false;
|
||||
}
|
||||
|
||||
p.openInventory(target.getInventory());
|
||||
manager.openInventory(p, target);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -12,17 +12,17 @@ import java.util.List;
|
||||
import static net.kyori.adventure.text.Component.text;
|
||||
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"
|
||||
);
|
||||
|
||||
private final FakePlayerManager manager = FakePlayerManager.instance;
|
||||
|
||||
public RemoveCommand(
|
||||
public KickCommand(
|
||||
@NotNull String description,
|
||||
@NotNull String usage,
|
||||
@Nullable String permission
|
@ -19,7 +19,7 @@ public class ListCommand extends ExecutableCommand {
|
||||
|
||||
public final static ListCommand instance = new ListCommand(
|
||||
"查看所有假人",
|
||||
"/list [页码] [数量]",
|
||||
"/fp list [页码] [数量]",
|
||||
"fakeplayer.spawn"
|
||||
);
|
||||
private final static FakePlayerManager manager = FakePlayerManager.instance;
|
||||
|
@ -27,7 +27,7 @@ public class PlayerInteractAtEntityListener implements Listener {
|
||||
}
|
||||
|
||||
if (player.isOp() || Objects.equals(manager.getCreator(target), player.getName())) {
|
||||
player.openInventory(target.getInventory());
|
||||
manager.openInventory(player, target);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,14 +3,12 @@ package io.github.hello09x.fakeplayer.listener;
|
||||
import io.github.hello09x.fakeplayer.Main;
|
||||
import io.github.hello09x.fakeplayer.manager.FakePlayerManager;
|
||||
import io.github.hello09x.fakeplayer.properties.FakeplayerProperties;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.CraftWorldBorder;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class PlayerTeleportListener implements Listener {
|
||||
@ -25,13 +23,18 @@ public class PlayerTeleportListener implements Listener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void handleTeleportEvent(@NotNull PlayerTeleportEvent event) {
|
||||
if (manager.isFake(event.getPlayer())
|
||||
&& !(properties.isTpAcrossWorlds()
|
||||
&& !Objects.equals(event.getFrom().getWorld().getUID(), event.getTo().getWorld().getUID()))){
|
||||
var player = event.getPlayer();
|
||||
if (!manager.isFake(player)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -8,8 +8,9 @@ import io.github.hello09x.fakeplayer.repository.UserConfigRepository;
|
||||
import io.github.hello09x.fakeplayer.repository.model.Configs;
|
||||
import io.github.hello09x.fakeplayer.util.AddressUtils;
|
||||
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.title.Title;
|
||||
import net.kyori.adventure.util.Ticks;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -218,6 +219,21 @@ public class FakePlayerManager {
|
||||
.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) {
|
||||
if (!isFake(fakePlayer)) {
|
||||
return;
|
||||
|
@ -65,7 +65,7 @@ tp-across-worlds: false
|
||||
# %u: 假人 uuid
|
||||
# %c: 创建者的名称
|
||||
preparing-commands:
|
||||
- '/give %p 1 poppy'
|
||||
- '/give %p poppy 1'
|
||||
- ''
|
||||
|
||||
# 假人销毁时执行的命令
|
||||
|
@ -21,7 +21,7 @@ permissions:
|
||||
default: op
|
||||
|
||||
fakeplayer.spawn:
|
||||
description: '拥有 create, remove, list 命令执行的权限'
|
||||
description: '拥有 create, kick, list 命令执行的权限'
|
||||
default: op
|
||||
|
||||
fakeplayer.tp:
|
||||
@ -29,7 +29,7 @@ permissions:
|
||||
default: op
|
||||
|
||||
fakeplayer.control:
|
||||
description: '拥有 open, drop 命令执行的权限'
|
||||
description: '拥有 invsee, drop 命令执行的权限'
|
||||
default: op
|
||||
|
||||
fakeplayer.admin:
|
||||
|
Loading…
Reference in New Issue
Block a user