├── .gitattributes
├── .github
├── README
│ └── BANNER.png
└── ISSUE_TEMPLATE
│ ├── feature_request.md
│ ├── bug-report_zh.md
│ └── bug-report_en.md
├── fakeplayer-api
├── src
│ └── main
│ │ └── java
│ │ └── io
│ │ └── github
│ │ └── hello09x
│ │ └── fakeplayer
│ │ └── api
│ │ └── spi
│ │ ├── NMSEntity.java
│ │ ├── NMSServerLevel.java
│ │ ├── Action.java
│ │ ├── NMSServerGamePacketListener.java
│ │ ├── NMSServer.java
│ │ ├── ActionTicker.java
│ │ ├── NMSNetwork.java
│ │ ├── NMSBridge.java
│ │ ├── ActionType.java
│ │ └── ActionSetting.java
└── pom.xml
├── fakeplayer-core
└── src
│ └── main
│ └── java
│ └── io
│ └── github
│ └── hello09x
│ └── fakeplayer
│ └── core
│ ├── config
│ ├── InvseeImplement.java
│ └── PreventKicking.java
│ ├── placeholder
│ └── FakeplayerPlaceholderExpansion.java
│ ├── constant
│ ├── ConstantPool.java
│ ├── InteractionHand.java
│ ├── Direction.java
│ └── MetadataKeys.java
│ ├── manager
│ ├── invsee
│ │ ├── InvseeManager.java
│ │ ├── SimpleInvseeManagerImpl.java
│ │ └── OpenInvInvseeManagerImpl.java
│ ├── naming
│ │ ├── exception
│ │ │ └── IllegalCustomNameException.java
│ │ ├── SequenceName.java
│ │ └── NameSource.java
│ └── feature
│ │ └── FeatureInstance.java
│ ├── repository
│ └── model
│ │ ├── UserConfig.java
│ │ ├── FakePlayerSkin.java
│ │ ├── UserConfigRowMapper.java
│ │ ├── FakePlayerSkinRowMapper.java
│ │ ├── Singletons.java
│ │ └── FakePlayerProfile.java
│ ├── util
│ ├── ClassUtils.java
│ ├── update
│ │ ├── Release.java
│ │ └── UpdateChecker.java
│ ├── AddressUtils.java
│ ├── Mth.java
│ ├── Attributes.java
│ ├── InternalAddressGenerator.java
│ ├── Commands.java
│ ├── Reflections.java
│ └── Skins.java
│ ├── command
│ ├── impl
│ │ ├── KillallCommand.java
│ │ ├── SwapCommand.java
│ │ ├── HoldCommand.java
│ │ ├── SneakCommand.java
│ │ ├── RespawnCommand.java
│ │ ├── StopCommand.java
│ │ ├── KillCommand.java
│ │ ├── SleepCommand.java
│ │ ├── DebugCommand.java
│ │ ├── ExpmeCommand.java
│ │ ├── SprintCommand.java
│ │ ├── ReloadCommand.java
│ │ ├── SetCommand.java
│ │ ├── InvseeCommand.java
│ │ ├── SelectCommand.java
│ │ ├── TeleportCommand.java
│ │ └── MoveCommand.java
│ └── Permission.java
│ ├── entity
│ ├── SpawnOption.java
│ └── action
│ │ └── impl
│ │ ├── DropItemAction.java
│ │ ├── DropStackAction.java
│ │ ├── DropInventoryAction.java
│ │ ├── JumpAction.java
│ │ └── LookAtEntityAction.java
│ └── listener
│ └── PlayerListener.java
├── BUILD.md
├── fakeplayer-v1_21
└── src
│ └── main
│ └── java
│ └── io
│ └── github
│ └── hello09x
│ └── fakeplayer
│ └── v1_21
│ ├── spi
│ ├── NMSEntityImpl.java
│ ├── NMSServerLevelImpl.java
│ ├── NMSServerImpl.java
│ ├── ActionTickerImpl.java
│ └── NMSBridgeImpl.java
│ ├── action
│ ├── TraceAction.java
│ └── AttackAction.java
│ └── network
│ ├── FakeConnection.java
│ └── FakePlayerAdvancements.java
├── fakeplayer-v1_20_1
└── src
│ └── main
│ └── java
│ └── io
│ └── github
│ └── hello09x
│ └── fakeplayer
│ └── v1_20_1
│ ├── spi
│ ├── NMSEntityImpl.java
│ ├── NMSServerLevelImpl.java
│ ├── NMSServerImpl.java
│ ├── ActionTickerImpl.java
│ ├── NMSBridgeImpl.java
│ └── NMSNetworkImpl.java
│ ├── action
│ ├── TraceAction.java
│ └── AttackAction.java
│ └── network
│ ├── FakeConnection.java
│ └── FakePlayerAdvancements.java
├── fakeplayer-v1_20_2
└── src
│ └── main
│ └── java
│ └── io
│ └── github
│ └── hello09x
│ └── fakeplayer
│ └── v1_20_2
│ ├── spi
│ ├── NMSEntityImpl.java
│ ├── NMSServerLevelImpl.java
│ ├── NMSServerImpl.java
│ ├── ActionTickerImpl.java
│ └── NMSBridgeImpl.java
│ ├── action
│ ├── TraceAction.java
│ └── AttackAction.java
│ └── network
│ ├── FakeConnection.java
│ └── FakePlayerAdvancements.java
├── fakeplayer-v1_20_4
└── src
│ └── main
│ └── java
│ └── io
│ └── github
│ └── hello09x
│ └── fakeplayer
│ └── v1_20_4
│ ├── spi
│ ├── NMSEntityImpl.java
│ ├── NMSServerLevelImpl.java
│ ├── NMSServerImpl.java
│ ├── ActionTickerImpl.java
│ └── NMSBridgeImpl.java
│ ├── action
│ ├── TraceAction.java
│ └── AttackAction.java
│ └── network
│ ├── FakeConnection.java
│ └── FakePlayerAdvancements.java
├── fakeplayer-v1_20_6
└── src
│ └── main
│ └── java
│ └── io
│ └── github
│ └── hello09x
│ └── fakeplayer
│ └── v1_20_6
│ ├── spi
│ ├── NMSEntityImpl.java
│ ├── NMSServerLevelImpl.java
│ ├── NMSServerImpl.java
│ ├── ActionTickerImpl.java
│ └── NMSBridgeImpl.java
│ ├── action
│ ├── TraceAction.java
│ └── AttackAction.java
│ └── network
│ ├── FakeConnection.java
│ └── FakePlayerAdvancements.java
├── fakeplayer-v1_21_3
└── src
│ └── main
│ └── java
│ └── io
│ └── github
│ └── hello09x
│ └── fakeplayer
│ └── v1_21_3
│ ├── spi
│ ├── NMSEntityImpl.java
│ ├── NMSServerLevelImpl.java
│ ├── NMSServerImpl.java
│ ├── ActionTickerImpl.java
│ └── NMSBridgeImpl.java
│ ├── action
│ ├── TraceAction.java
│ └── AttackAction.java
│ └── network
│ ├── FakeConnection.java
│ └── FakePlayerAdvancements.java
├── fakeplayer-v1_21_4
└── src
│ └── main
│ └── java
│ └── io
│ └── github
│ └── hello09x
│ └── fakeplayer
│ └── v1_21_4
│ ├── spi
│ ├── NMSEntityImpl.java
│ ├── NMSServerLevelImpl.java
│ ├── NMSServerImpl.java
│ ├── ActionTickerImpl.java
│ └── NMSBridgeImpl.java
│ ├── action
│ ├── TraceAction.java
│ └── AttackAction.java
│ └── network
│ ├── FakeConnection.java
│ └── FakePlayerAdvancements.java
├── fakeplayer-v1_21_5
└── src
│ └── main
│ └── java
│ └── io
│ └── github
│ └── hello09x
│ └── fakeplayer
│ └── v1_21_5
│ ├── spi
│ ├── NMSEntityImpl.java
│ ├── NMSServerLevelImpl.java
│ ├── NMSServerImpl.java
│ ├── ActionTickerImpl.java
│ └── NMSBridgeImpl.java
│ ├── action
│ ├── TraceAction.java
│ └── AttackAction.java
│ └── network
│ ├── FakeConnection.java
│ └── FakePlayerAdvancements.java
├── fakeplayer-v1_21_6
└── src
│ └── main
│ └── java
│ └── io
│ └── github
│ └── hello09x
│ └── fakeplayer
│ └── v1_21_6
│ ├── spi
│ ├── NMSEntityImpl.java
│ ├── NMSServerLevelImpl.java
│ ├── NMSServerImpl.java
│ ├── ActionTickerImpl.java
│ └── NMSBridgeImpl.java
│ ├── action
│ ├── TraceAction.java
│ └── AttackAction.java
│ └── network
│ ├── FakeConnection.java
│ └── FakePlayerAdvancements.java
├── fakeplayer-v1_21_9
└── src
│ └── main
│ └── java
│ └── io
│ └── github
│ └── hello09x
│ └── fakeplayer
│ └── v1_21_9
│ ├── spi
│ ├── NMSEntityImpl.java
│ ├── NMSServerLevelImpl.java
│ ├── NMSServerImpl.java
│ ├── ActionTickerImpl.java
│ └── NMSBridgeImpl.java
│ ├── action
│ ├── TraceAction.java
│ └── AttackAction.java
│ └── network
│ ├── FakeConnection.java
│ └── FakePlayerAdvancements.java
├── fakeplayer-dist
└── src
│ └── main
│ └── resources
│ └── META-INF
│ └── services
│ └── io.github.hello09x.fakeplayer.api.spi.NMSBridge
├── fakeplayer-v1_20_3
└── src
│ └── main
│ └── java
│ └── io
│ └── github
│ └── hello09x
│ └── fakeplayer
│ └── v1_20_3
│ └── spi
│ └── NMSBridgeImpl.java
├── fakeplayer-v1_20_5
└── src
│ └── main
│ └── java
│ └── io
│ └── github
│ └── hello09x
│ └── fakeplayer
│ └── v1_20_5
│ └── spi
│ └── NMSBridgeImpl.java
├── fakeplayer-v1_21_1
└── src
│ └── main
│ └── java
│ └── io
│ └── github
│ └── hello09x
│ └── fakeplayer
│ └── v1_21_1
│ └── spi
│ └── NMSBridgeImpl.java
├── fakeplayer-v1_21_7
└── src
│ └── main
│ └── java
│ └── io
│ └── github
│ └── hello09x
│ └── fakeplayer
│ └── v1_21_7
│ └── spi
│ └── NMSBridgeImpl.java
├── fakeplayer-v1_21_8
└── src
│ └── main
│ └── java
│ └── io
│ └── github
│ └── hello09x
│ └── fakeplayer
│ └── v1_21_8
│ └── spi
│ └── NMSBridgeImpl.java
└── fakeplayer-v1_21_10
└── src
└── main
└── java
└── io
└── github
└── hello09x
└── fakeplayer
└── v1_21_10
└── spi
└── NMSBridgeImpl.java
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.png binary
2 |
--------------------------------------------------------------------------------
/.github/README/BANNER.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tanyaofei/minecraft-fakeplayer/HEAD/.github/README/BANNER.png
--------------------------------------------------------------------------------
/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/NMSEntity.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.api.spi;
2 |
3 | public interface NMSEntity {
4 |
5 |
6 | }
7 |
--------------------------------------------------------------------------------
/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/NMSServerLevel.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.api.spi;
2 |
3 | public interface NMSServerLevel {
4 |
5 |
6 | }
7 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the feature you'd like / 描述你想要的新特性**
11 | ...
12 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/config/InvseeImplement.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.config;
2 |
3 | /**
4 | * @author tanyaofei
5 | * @since 2024/8/12
6 | **/
7 | public enum InvseeImplement {
8 |
9 | AUTO,
10 |
11 | SIMPLE
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/placeholder/FakeplayerPlaceholderExpansion.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.placeholder;
2 |
3 | import org.bukkit.event.Listener;
4 |
5 | /**
6 | * @author tanyaofei
7 | * @since 2024/8/15
8 | **/
9 | public interface FakeplayerPlaceholderExpansion extends Listener {
10 |
11 | boolean register();
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/constant/ConstantPool.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.constant;
2 |
3 | public interface ConstantPool {
4 |
5 | /**
6 | * 玩家皮肤设置
7 | *
Serverbound Client Information (configuration)
8 | */
9 | byte MODEL_CUSTOMISATION = 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40;
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/Action.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.api.spi;
2 |
3 | public interface Action {
4 |
5 | /**
6 | * 活跃 tick 时执行
7 | *
8 | * @return 是否有做出行动
9 | */
10 | boolean tick();
11 |
12 | /**
13 | * 非活跃 tick 时执行
14 | */
15 | void inactiveTick();
16 |
17 | /**
18 | * 结束动作时执行
19 | */
20 | void stop();
21 |
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/NMSServerGamePacketListener.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.api.spi;
2 |
3 | import org.bukkit.plugin.messaging.StandardMessenger;
4 |
5 | public interface NMSServerGamePacketListener {
6 |
7 |
8 | String BUNGEE_CORD_CHANNEL = "BungeeCord";
9 |
10 | String BUNGEE_CORD_CORRECTED_CHANNEL = StandardMessenger.validateAndCorrectChannel(BUNGEE_CORD_CHANNEL);
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/config/PreventKicking.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.config;
2 |
3 | /**
4 | * @author tanyaofei
5 | * @since 2024/7/26
6 | **/
7 | public enum PreventKicking {
8 |
9 | /**
10 | * 不进行任何处理
11 | */
12 | NEVER,
13 |
14 | /**
15 | * 创建时
16 | */
17 | ON_SPAWNING,
18 |
19 | /**
20 | * 永远, 除了假人插件自身
21 | */
22 | ALWAYS
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug-report_zh.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug 修复
3 | about: 告诉我们程序存在的问题以协助完善 Fakeplayer
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **描述**
11 |
12 | 简单描述这是一个怎么样的 Bug, 导致了什么问题
13 |
14 |
15 |
16 | **触发步骤**
17 | 1. ...
18 | 2. ...
19 | 3. ...
20 | 4. ...
21 |
22 | **服务器信息**
23 | - 核心: [e.g. Purpur 1.20.1]
24 | - Java: [e.g. 21]
25 | - Fakeplayer 版本: [e.g. 0.3.1]
26 |
27 | **其他有帮助的信息**
28 |
29 | 提供一些有帮助的信息以协助我们定位问题,如插件清单、报错日志、或者插件的一些配置 **(请隐藏敏感信息)**
30 |
31 |
--------------------------------------------------------------------------------
/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/NMSServer.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.api.spi;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 |
5 | import java.util.UUID;
6 |
7 | public interface NMSServer {
8 |
9 | /**
10 | * 创建一名新的玩家加入游戏
11 | *
12 | * @param uuid UUID
13 | * @param name 名称
14 | * @return 假人
15 | */
16 | @NotNull NMSServerPlayer newPlayer(@NotNull UUID uuid, @NotNull String name);
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/manager/invsee/InvseeManager.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.manager.invsee;
2 |
3 | import org.bukkit.entity.Player;
4 | import org.bukkit.event.Listener;
5 | import org.jetbrains.annotations.NotNull;
6 |
7 | /**
8 | * @author tanyaofei
9 | * @since 2024/8/12
10 | **/
11 | public interface InvseeManager extends Listener {
12 |
13 | boolean invsee(@NotNull Player viewer, @NotNull Player whom);
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/repository/model/UserConfig.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.repository.model;
2 |
3 |
4 | import org.jetbrains.annotations.NotNull;
5 |
6 | import java.util.UUID;
7 |
8 | public record UserConfig(
9 |
10 | Integer id,
11 |
12 | @NotNull
13 | UUID playerId,
14 |
15 | @NotNull
16 | Feature key,
17 |
18 | @NotNull
19 | String value
20 |
21 | ) {
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/util/ClassUtils.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.util;
2 |
3 | /**
4 | * @author tanyaofei
5 | * @since 2024/8/12
6 | **/
7 | public class ClassUtils {
8 |
9 | public static boolean isClassExists(String className) {
10 | try {
11 | Class.forName(className);
12 | return true;
13 | } catch (ClassNotFoundException e) {
14 | return false;
15 | }
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/BUILD.md:
--------------------------------------------------------------------------------
1 | # Build introduction
2 |
3 | Here is a simple introduction lead you to build this project
4 |
5 | ## Build NMS Dependencies
6 |
7 | Mojang does not allow anyone to publish the remapped NMS jar to any public repository,
8 | so you need to build it yourself
9 |
10 | 1. Download [BuildTools](https://www.spigotmc.org/wiki/buildtools/)
11 | 2. execute `java -jar BuildTools.jar --rev 1.21 --remapped` to install remapped NMS 1.21 to your local repository. _You might need to install other version depending on projects' requirements._
12 |
13 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/repository/model/FakePlayerSkin.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.repository.model;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 |
5 | import java.util.UUID;
6 |
7 | /**
8 | * @author tanyaofei
9 | * @since 2024/8/8
10 | **/
11 | public record FakePlayerSkin(
12 |
13 | @NotNull
14 | UUID playerId,
15 |
16 | @NotNull
17 | UUID creatorId,
18 |
19 | @NotNull
20 | UUID targetId
21 |
22 | ) {
23 |
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/ActionTicker.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.api.spi;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 |
5 | public interface ActionTicker {
6 |
7 | @NotNull
8 | ActionSetting getSetting();
9 |
10 | /**
11 | * 时刻计算
12 | *
13 | * @return 是否已经完成, 不再需要继续执行
14 | */
15 | boolean tick();
16 |
17 | /**
18 | * 非活跃时刻计算
19 | */
20 | void inactiveTick();
21 |
22 | /**
23 | * 停止行为
24 | */
25 | void stop();
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/manager/naming/exception/IllegalCustomNameException.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.manager.naming.exception;
2 |
3 | import io.github.hello09x.devtools.command.exception.CommandException;
4 | import net.kyori.adventure.text.Component;
5 | import org.jetbrains.annotations.NotNull;
6 |
7 | public class IllegalCustomNameException extends CommandException {
8 |
9 | public IllegalCustomNameException(@NotNull Component message) {
10 | super(message);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/constant/InteractionHand.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.constant;
2 |
3 | import lombok.AllArgsConstructor;
4 | import org.bukkit.inventory.EquipmentSlot;
5 | import org.jetbrains.annotations.NotNull;
6 |
7 | @AllArgsConstructor
8 | public enum InteractionHand {
9 |
10 | MAIN_HAND(EquipmentSlot.HAND),
11 |
12 | OFF_HAND(EquipmentSlot.OFF_HAND);
13 |
14 | final EquipmentSlot slot;
15 |
16 | public @NotNull EquipmentSlot asSlot() {
17 | return slot;
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/manager/naming/SequenceName.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.manager.naming;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 |
5 | import java.util.UUID;
6 |
7 | /**
8 | * 序列名
9 | *
10 | * @param group 分组
11 | * @param sequence 序列
12 | * @param uuid UUID
13 | * @param name 名称
14 | */
15 | public record SequenceName(
16 |
17 | @NotNull
18 | String group,
19 |
20 | int sequence,
21 |
22 | @NotNull
23 | UUID uuid,
24 |
25 | @NotNull
26 | String name
27 |
28 | ) {
29 | }
30 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/util/update/Release.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.util.update;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | @Data
9 | @AllArgsConstructor
10 | @NoArgsConstructor
11 | public class Release {
12 |
13 | /**
14 | * GitHub tag name
15 | */
16 | @SerializedName("tag_name")
17 | private String tagName;
18 |
19 | /**
20 | * GitHub release content
21 | */
22 | private String body;
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/KillallCommand.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.command.impl;
2 |
3 | import com.google.inject.Singleton;
4 | import dev.jorel.commandapi.executors.CommandArguments;
5 | import org.bukkit.command.CommandSender;
6 | import org.jetbrains.annotations.NotNull;
7 |
8 | @Singleton
9 | public class KillallCommand extends AbstractCommand {
10 |
11 | /**
12 | * 移除服务器所有假人
13 | */
14 | public void killall(@NotNull CommandSender sender, @NotNull CommandArguments args) {
15 | manager.removeAll("Command killall");
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug-report_en.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. ...
16 | 2. ...
17 | 3. ...
18 | 4. ...
19 |
20 | **Server information**
21 | - Software: [e.g. Purpur 1.20.1]
22 | - Java: [e.g. 21]
23 | - Fakeplayer Version: [e.g. 0.3.1]
24 |
25 | **Additional context**
26 |
27 | Add any other context about the problem here. Such as log, plugin list or config files of other plugins **(hide sensitive content)**.
28 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21/src/main/java/io/github/hello09x/fakeplayer/v1_21/spi/NMSEntityImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.NMSEntity;
4 | import lombok.Getter;
5 | import net.minecraft.world.entity.Entity;
6 | import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | public class NMSEntityImpl implements NMSEntity {
10 |
11 | @Getter
12 | private final Entity handle;
13 |
14 | public NMSEntityImpl(@NotNull org.bukkit.entity.@NotNull Entity entity) {
15 | this.handle = ((CraftEntity) entity).getHandle();
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_1/src/main/java/io/github/hello09x/fakeplayer/v1_20_1/spi/NMSEntityImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_1.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.NMSEntity;
4 | import lombok.Getter;
5 | import net.minecraft.world.entity.Entity;
6 | import org.bukkit.craftbukkit.v1_20_R1.entity.CraftEntity;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | public class NMSEntityImpl implements NMSEntity {
10 |
11 | @Getter
12 | private final Entity handle;
13 |
14 | public NMSEntityImpl(@NotNull org.bukkit.entity.@NotNull Entity entity) {
15 | this.handle = ((CraftEntity) entity).getHandle();
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_2/src/main/java/io/github/hello09x/fakeplayer/v1_20_2/spi/NMSEntityImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_2.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.NMSEntity;
4 | import lombok.Getter;
5 | import net.minecraft.world.entity.Entity;
6 | import org.bukkit.craftbukkit.v1_20_R2.entity.CraftEntity;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | public class NMSEntityImpl implements NMSEntity {
10 |
11 | @Getter
12 | private final Entity handle;
13 |
14 | public NMSEntityImpl(@NotNull org.bukkit.entity.@NotNull Entity entity) {
15 | this.handle = ((CraftEntity) entity).getHandle();
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_4/src/main/java/io/github/hello09x/fakeplayer/v1_20_4/spi/NMSEntityImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_4.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.NMSEntity;
4 | import lombok.Getter;
5 | import net.minecraft.world.entity.Entity;
6 | import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | public class NMSEntityImpl implements NMSEntity {
10 |
11 | @Getter
12 | private final Entity handle;
13 |
14 | public NMSEntityImpl(@NotNull org.bukkit.entity.@NotNull Entity entity) {
15 | this.handle = ((CraftEntity) entity).getHandle();
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_6/src/main/java/io/github/hello09x/fakeplayer/v1_20_6/spi/NMSEntityImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_6.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.NMSEntity;
4 | import lombok.Getter;
5 | import net.minecraft.world.entity.Entity;
6 | import org.bukkit.craftbukkit.v1_20_R4.entity.CraftEntity;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | public class NMSEntityImpl implements NMSEntity {
10 |
11 | @Getter
12 | private final Entity handle;
13 |
14 | public NMSEntityImpl(@NotNull org.bukkit.entity.@NotNull Entity entity) {
15 | this.handle = ((CraftEntity) entity).getHandle();
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_3/src/main/java/io/github/hello09x/fakeplayer/v1_21_3/spi/NMSEntityImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_3.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.NMSEntity;
4 | import lombok.Getter;
5 | import net.minecraft.world.entity.Entity;
6 | import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | public class NMSEntityImpl implements NMSEntity {
10 |
11 | @Getter
12 | private final Entity handle;
13 |
14 | public NMSEntityImpl(@NotNull org.bukkit.entity.@NotNull Entity entity) {
15 | this.handle = ((CraftEntity) entity).getHandle();
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_4/src/main/java/io/github/hello09x/fakeplayer/v1_21_4/spi/NMSEntityImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_4.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.NMSEntity;
4 | import lombok.Getter;
5 | import net.minecraft.world.entity.Entity;
6 | import org.bukkit.craftbukkit.v1_21_R3.entity.CraftEntity;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | public class NMSEntityImpl implements NMSEntity {
10 |
11 | @Getter
12 | private final Entity handle;
13 |
14 | public NMSEntityImpl(@NotNull org.bukkit.entity.@NotNull Entity entity) {
15 | this.handle = ((CraftEntity) entity).getHandle();
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_5/src/main/java/io/github/hello09x/fakeplayer/v1_21_5/spi/NMSEntityImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_5.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.NMSEntity;
4 | import lombok.Getter;
5 | import net.minecraft.world.entity.Entity;
6 | import org.bukkit.craftbukkit.v1_21_R4.entity.CraftEntity;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | public class NMSEntityImpl implements NMSEntity {
10 |
11 | @Getter
12 | private final Entity handle;
13 |
14 | public NMSEntityImpl(@NotNull org.bukkit.entity.@NotNull Entity entity) {
15 | this.handle = ((CraftEntity) entity).getHandle();
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_6/src/main/java/io/github/hello09x/fakeplayer/v1_21_6/spi/NMSEntityImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_6.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.NMSEntity;
4 | import lombok.Getter;
5 | import net.minecraft.world.entity.Entity;
6 | import org.bukkit.craftbukkit.v1_21_R5.entity.CraftEntity;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | public class NMSEntityImpl implements NMSEntity {
10 |
11 | @Getter
12 | private final Entity handle;
13 |
14 | public NMSEntityImpl(@NotNull org.bukkit.entity.@NotNull Entity entity) {
15 | this.handle = ((CraftEntity) entity).getHandle();
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_9/src/main/java/io/github/hello09x/fakeplayer/v1_21_9/spi/NMSEntityImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_9.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.NMSEntity;
4 | import lombok.Getter;
5 | import net.minecraft.world.entity.Entity;
6 | import org.bukkit.craftbukkit.v1_21_R6.entity.CraftEntity;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | public class NMSEntityImpl implements NMSEntity {
10 |
11 | @Getter
12 | private final Entity handle;
13 |
14 | public NMSEntityImpl(@NotNull org.bukkit.entity.@NotNull Entity entity) {
15 | this.handle = ((CraftEntity) entity).getHandle();
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21/src/main/java/io/github/hello09x/fakeplayer/v1_21/spi/NMSServerLevelImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.NMSServerLevel;
4 | import lombok.Getter;
5 | import net.minecraft.server.level.ServerLevel;
6 | import org.bukkit.World;
7 | import org.bukkit.craftbukkit.v1_21_R1.CraftWorld;
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | public class NMSServerLevelImpl implements NMSServerLevel {
11 |
12 | @Getter
13 | private final ServerLevel handle;
14 |
15 | public NMSServerLevelImpl(@NotNull World world) {
16 | this.handle = ((CraftWorld) world).getHandle();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_1/src/main/java/io/github/hello09x/fakeplayer/v1_20_1/spi/NMSServerLevelImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_1.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.NMSServerLevel;
4 | import lombok.Getter;
5 | import net.minecraft.server.level.ServerLevel;
6 | import org.bukkit.World;
7 | import org.bukkit.craftbukkit.v1_20_R1.CraftWorld;
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | public class NMSServerLevelImpl implements NMSServerLevel {
11 |
12 | @Getter
13 | private final ServerLevel handle;
14 |
15 | public NMSServerLevelImpl(@NotNull World world) {
16 | this.handle = ((CraftWorld) world).getHandle();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_2/src/main/java/io/github/hello09x/fakeplayer/v1_20_2/spi/NMSServerLevelImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_2.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.NMSServerLevel;
4 | import lombok.Getter;
5 | import net.minecraft.server.level.ServerLevel;
6 | import org.bukkit.World;
7 | import org.bukkit.craftbukkit.v1_20_R2.CraftWorld;
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | public class NMSServerLevelImpl implements NMSServerLevel {
11 |
12 | @Getter
13 | private final ServerLevel handle;
14 |
15 | public NMSServerLevelImpl(@NotNull World world) {
16 | this.handle = ((CraftWorld) world).getHandle();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_4/src/main/java/io/github/hello09x/fakeplayer/v1_20_4/spi/NMSServerLevelImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_4.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.NMSServerLevel;
4 | import lombok.Getter;
5 | import net.minecraft.server.level.ServerLevel;
6 | import org.bukkit.World;
7 | import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | public class NMSServerLevelImpl implements NMSServerLevel {
11 |
12 | @Getter
13 | private final ServerLevel handle;
14 |
15 | public NMSServerLevelImpl(@NotNull World world) {
16 | this.handle = ((CraftWorld) world).getHandle();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_6/src/main/java/io/github/hello09x/fakeplayer/v1_20_6/spi/NMSServerLevelImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_6.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.NMSServerLevel;
4 | import lombok.Getter;
5 | import net.minecraft.server.level.ServerLevel;
6 | import org.bukkit.World;
7 | import org.bukkit.craftbukkit.v1_20_R4.CraftWorld;
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | public class NMSServerLevelImpl implements NMSServerLevel {
11 |
12 | @Getter
13 | private final ServerLevel handle;
14 |
15 | public NMSServerLevelImpl(@NotNull World world) {
16 | this.handle = ((CraftWorld) world).getHandle();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_3/src/main/java/io/github/hello09x/fakeplayer/v1_21_3/spi/NMSServerLevelImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_3.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.NMSServerLevel;
4 | import lombok.Getter;
5 | import net.minecraft.server.level.ServerLevel;
6 | import org.bukkit.World;
7 | import org.bukkit.craftbukkit.v1_21_R2.CraftWorld;
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | public class NMSServerLevelImpl implements NMSServerLevel {
11 |
12 | @Getter
13 | private final ServerLevel handle;
14 |
15 | public NMSServerLevelImpl(@NotNull World world) {
16 | this.handle = ((CraftWorld) world).getHandle();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_4/src/main/java/io/github/hello09x/fakeplayer/v1_21_4/spi/NMSServerLevelImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_4.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.NMSServerLevel;
4 | import lombok.Getter;
5 | import net.minecraft.server.level.ServerLevel;
6 | import org.bukkit.World;
7 | import org.bukkit.craftbukkit.v1_21_R3.CraftWorld;
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | public class NMSServerLevelImpl implements NMSServerLevel {
11 |
12 | @Getter
13 | private final ServerLevel handle;
14 |
15 | public NMSServerLevelImpl(@NotNull World world) {
16 | this.handle = ((CraftWorld) world).getHandle();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_5/src/main/java/io/github/hello09x/fakeplayer/v1_21_5/spi/NMSServerLevelImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_5.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.NMSServerLevel;
4 | import lombok.Getter;
5 | import net.minecraft.server.level.ServerLevel;
6 | import org.bukkit.World;
7 | import org.bukkit.craftbukkit.v1_21_R4.CraftWorld;
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | public class NMSServerLevelImpl implements NMSServerLevel {
11 |
12 | @Getter
13 | private final ServerLevel handle;
14 |
15 | public NMSServerLevelImpl(@NotNull World world) {
16 | this.handle = ((CraftWorld) world).getHandle();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_6/src/main/java/io/github/hello09x/fakeplayer/v1_21_6/spi/NMSServerLevelImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_6.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.NMSServerLevel;
4 | import lombok.Getter;
5 | import net.minecraft.server.level.ServerLevel;
6 | import org.bukkit.World;
7 | import org.bukkit.craftbukkit.v1_21_R5.CraftWorld;
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | public class NMSServerLevelImpl implements NMSServerLevel {
11 |
12 | @Getter
13 | private final ServerLevel handle;
14 |
15 | public NMSServerLevelImpl(@NotNull World world) {
16 | this.handle = ((CraftWorld) world).getHandle();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_9/src/main/java/io/github/hello09x/fakeplayer/v1_21_9/spi/NMSServerLevelImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_9.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.NMSServerLevel;
4 | import lombok.Getter;
5 | import net.minecraft.server.level.ServerLevel;
6 | import org.bukkit.World;
7 | import org.bukkit.craftbukkit.v1_21_R6.CraftWorld;
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | public class NMSServerLevelImpl implements NMSServerLevel {
11 |
12 | @Getter
13 | private final ServerLevel handle;
14 |
15 | public NMSServerLevelImpl(@NotNull World world) {
16 | this.handle = ((CraftWorld) world).getHandle();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/manager/feature/FeatureInstance.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.manager.feature;
2 |
3 | import io.github.hello09x.fakeplayer.core.repository.model.Feature;
4 | import org.jetbrains.annotations.NotNull;
5 |
6 | /**
7 | * @author tanyaofei
8 | * @since 2024/8/13
9 | **/
10 | public record FeatureInstance(
11 |
12 | @NotNull
13 | Feature key,
14 |
15 | @NotNull
16 | String value
17 |
18 | ) {
19 |
20 | public @NotNull String asString() {
21 | return value;
22 | }
23 |
24 | public boolean asBoolean() {
25 | return Boolean.parseBoolean(value);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/NMSNetwork.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.api.spi;
2 |
3 | import org.bukkit.Server;
4 | import org.bukkit.entity.Player;
5 | import org.jetbrains.annotations.NotNull;
6 |
7 | public interface NMSNetwork {
8 |
9 | /**
10 | * 绑定一个虚拟的游戏连接
11 | *
12 | * @param server 服务器
13 | * @param player 假人玩家
14 | */
15 | @NotNull NMSServerGamePacketListener placeNewPlayer(@NotNull Server server, @NotNull Player player);
16 |
17 | /**
18 | * 获取服务侧游戏数据包监听器
19 | * 在获取之前需要先执行了 {@link #placeNewPlayer(Server, Player)} 才会初始化值
20 | */
21 | @NotNull
22 | NMSServerGamePacketListener getServerGamePacketListener() throws IllegalStateException;
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/SwapCommand.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.command.impl;
2 |
3 | import com.google.inject.Singleton;
4 | import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
5 | import dev.jorel.commandapi.executors.CommandArguments;
6 | import org.bukkit.command.CommandSender;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | @Singleton
10 | public class SwapCommand extends AbstractCommand {
11 |
12 | /**
13 | * 交换主副手物品
14 | */
15 | public void swap(@NotNull CommandSender sender, @NotNull CommandArguments args) throws WrapperCommandSyntaxException {
16 | var fake = super.getFakeplayer(sender, args);
17 | bridge.fromPlayer(fake).swapItemWithOffhand();
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/constant/Direction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.constant;
2 |
3 | import lombok.AllArgsConstructor;
4 | import net.kyori.adventure.translation.Translatable;
5 | import org.jetbrains.annotations.NotNull;
6 |
7 | @AllArgsConstructor
8 | public enum Direction implements Translatable {
9 |
10 | DOWN("fakeplayer.direction.down"),
11 |
12 | UP("fakeplayer.direction.up"),
13 |
14 | NORTH("fakeplayer.direction.north"),
15 |
16 | SOUTH("fakeplayer.direction.south"),
17 |
18 | WEST("fakeplayer.direction.west"),
19 |
20 | EAST("fakeplayer.direction.east");
21 |
22 | final String translationKey;
23 |
24 | @Override
25 | public @NotNull String translationKey() {
26 | return this.translationKey;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/entity/SpawnOption.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.entity;
2 |
3 | import org.bukkit.Location;
4 | import org.jetbrains.annotations.NotNull;
5 |
6 | /**
7 | * @param spawnAt 出生点
8 | * @param invulnerable 是否无敌
9 | * @param collidable 是否开启碰撞
10 | * @param lookAtEntity 是否看向附近实体
11 | * @param pickupItems 是否拾取物品
12 | * @param replenish 自动补货
13 | */
14 | public record SpawnOption(
15 |
16 | @NotNull
17 | Location spawnAt,
18 |
19 | boolean invulnerable,
20 |
21 | boolean collidable,
22 |
23 | boolean lookAtEntity,
24 |
25 | boolean pickupItems,
26 |
27 | boolean skin,
28 |
29 | boolean replenish,
30 |
31 | boolean autofish,
32 |
33 | boolean wolverine
34 |
35 | ) {
36 | }
37 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/HoldCommand.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.command.impl;
2 |
3 | import com.google.inject.Singleton;
4 | import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
5 | import dev.jorel.commandapi.executors.CommandArguments;
6 | import org.bukkit.command.CommandSender;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | import java.util.Objects;
10 |
11 | @Singleton
12 | public class HoldCommand extends AbstractCommand {
13 |
14 | public void hold(@NotNull CommandSender sender, @NotNull CommandArguments args) throws WrapperCommandSyntaxException {
15 | var fake = super.getFakeplayer(sender, args);
16 | var slot = (int) Objects.requireNonNull(args.get("slot"));
17 | fake.getInventory().setHeldItemSlot(slot - 1);
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/constant/MetadataKeys.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.constant;
2 |
3 | import com.google.common.collect.Iterables;
4 | import org.bukkit.entity.Player;
5 | import org.jetbrains.annotations.NotNull;
6 | import org.jetbrains.annotations.Nullable;
7 |
8 | public interface MetadataKeys {
9 |
10 |
11 | String SELECTION = "fakeplayer:selection";
12 |
13 | String REPLENISH = "fakeplayer:replenish";
14 |
15 | String SPAWNED_AT = "fakeplayer:spawned_at";
16 |
17 | String AUTOFISH = "fakeplayer:autofish";
18 |
19 | static @Nullable Integer getSpawnedAt(@NotNull Player player) {
20 | var value = Iterables.getFirst(player.getMetadata(SPAWNED_AT), null);
21 | if (value == null) {
22 | return null;
23 | }
24 | return value.asInt();
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/entity/action/impl/DropItemAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.entity.action.impl;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.Action;
4 | import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer;
5 | import org.jetbrains.annotations.NotNull;
6 |
7 | public class DropItemAction implements Action {
8 |
9 | @NotNull
10 | private final NMSServerPlayer player;
11 |
12 | public DropItemAction(@NotNull NMSServerPlayer player) {
13 | this.player = player;
14 | }
15 |
16 | @Override
17 | public boolean tick() {
18 | player.drop(false);
19 | player.resetLastActionTime();
20 | return true;
21 | }
22 |
23 | @Override
24 | public void inactiveTick() {
25 |
26 | }
27 |
28 | @Override
29 | public void stop() {
30 |
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21/src/main/java/io/github/hello09x/fakeplayer/v1_21/action/TraceAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21.action;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.Action;
4 | import io.github.hello09x.fakeplayer.v1_21.action.util.Tracer;
5 | import net.minecraft.server.level.ServerPlayer;
6 | import net.minecraft.world.phys.HitResult;
7 | import org.jetbrains.annotations.NotNull;
8 | import org.jetbrains.annotations.Nullable;
9 |
10 | public abstract class TraceAction implements Action {
11 |
12 | protected final ServerPlayer player;
13 |
14 | protected TraceAction(@NotNull ServerPlayer player) {
15 | this.player = player;
16 | }
17 |
18 | protected @Nullable HitResult getTarget() {
19 | double reach = player.gameMode.isCreative() ? 5 : 4.5f;
20 | return Tracer.rayTrace(player, 1, reach, false);
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_1/src/main/java/io/github/hello09x/fakeplayer/v1_20_1/action/TraceAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_1.action;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.Action;
4 | import io.github.hello09x.fakeplayer.v1_20_1.action.util.Tracer;
5 | import net.minecraft.server.level.ServerPlayer;
6 | import net.minecraft.world.phys.HitResult;
7 | import org.jetbrains.annotations.NotNull;
8 | import org.jetbrains.annotations.Nullable;
9 |
10 | public abstract class TraceAction implements Action {
11 |
12 | protected final ServerPlayer player;
13 |
14 | protected TraceAction(@NotNull ServerPlayer player) {
15 | this.player = player;
16 | }
17 |
18 | protected @Nullable HitResult getTarget() {
19 | double reach = player.gameMode.isCreative() ? 5 : 4.5f;
20 | return Tracer.rayTrace(player, 1, reach, false);
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_2/src/main/java/io/github/hello09x/fakeplayer/v1_20_2/action/TraceAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_2.action;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.Action;
4 | import io.github.hello09x.fakeplayer.v1_20_2.action.util.Tracer;
5 | import net.minecraft.server.level.ServerPlayer;
6 | import net.minecraft.world.phys.HitResult;
7 | import org.jetbrains.annotations.NotNull;
8 | import org.jetbrains.annotations.Nullable;
9 |
10 | public abstract class TraceAction implements Action {
11 |
12 | protected final ServerPlayer player;
13 |
14 | protected TraceAction(@NotNull ServerPlayer player) {
15 | this.player = player;
16 | }
17 |
18 | protected @Nullable HitResult getTarget() {
19 | double reach = player.gameMode.isCreative() ? 5 : 4.5f;
20 | return Tracer.rayTrace(player, 1, reach, false);
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_4/src/main/java/io/github/hello09x/fakeplayer/v1_20_4/action/TraceAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_4.action;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.Action;
4 | import io.github.hello09x.fakeplayer.v1_20_4.action.util.Tracer;
5 | import net.minecraft.server.level.ServerPlayer;
6 | import net.minecraft.world.phys.HitResult;
7 | import org.jetbrains.annotations.NotNull;
8 | import org.jetbrains.annotations.Nullable;
9 |
10 | public abstract class TraceAction implements Action {
11 |
12 | protected final ServerPlayer player;
13 |
14 | protected TraceAction(@NotNull ServerPlayer player) {
15 | this.player = player;
16 | }
17 |
18 | protected @Nullable HitResult getTarget() {
19 | double reach = player.gameMode.isCreative() ? 5 : 4.5f;
20 | return Tracer.rayTrace(player, 1, reach, false);
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_6/src/main/java/io/github/hello09x/fakeplayer/v1_20_6/action/TraceAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_6.action;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.Action;
4 | import io.github.hello09x.fakeplayer.v1_20_6.action.util.Tracer;
5 | import net.minecraft.server.level.ServerPlayer;
6 | import net.minecraft.world.phys.HitResult;
7 | import org.jetbrains.annotations.NotNull;
8 | import org.jetbrains.annotations.Nullable;
9 |
10 | public abstract class TraceAction implements Action {
11 |
12 | protected final ServerPlayer player;
13 |
14 | protected TraceAction(@NotNull ServerPlayer player) {
15 | this.player = player;
16 | }
17 |
18 | protected @Nullable HitResult getTarget() {
19 | double reach = player.gameMode.isCreative() ? 5 : 4.5f;
20 | return Tracer.rayTrace(player, 1, reach, false);
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_3/src/main/java/io/github/hello09x/fakeplayer/v1_21_3/action/TraceAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_3.action;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.Action;
4 | import io.github.hello09x.fakeplayer.v1_21_3.action.util.Tracer;
5 | import net.minecraft.server.level.ServerPlayer;
6 | import net.minecraft.world.phys.HitResult;
7 | import org.jetbrains.annotations.NotNull;
8 | import org.jetbrains.annotations.Nullable;
9 |
10 | public abstract class TraceAction implements Action {
11 |
12 | protected final ServerPlayer player;
13 |
14 | protected TraceAction(@NotNull ServerPlayer player) {
15 | this.player = player;
16 | }
17 |
18 | protected @Nullable HitResult getTarget() {
19 | double reach = player.gameMode.isCreative() ? 5 : 4.5f;
20 | return Tracer.rayTrace(player, 1, reach, false);
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_4/src/main/java/io/github/hello09x/fakeplayer/v1_21_4/action/TraceAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_4.action;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.Action;
4 | import io.github.hello09x.fakeplayer.v1_21_4.action.util.Tracer;
5 | import net.minecraft.server.level.ServerPlayer;
6 | import net.minecraft.world.phys.HitResult;
7 | import org.jetbrains.annotations.NotNull;
8 | import org.jetbrains.annotations.Nullable;
9 |
10 | public abstract class TraceAction implements Action {
11 |
12 | protected final ServerPlayer player;
13 |
14 | protected TraceAction(@NotNull ServerPlayer player) {
15 | this.player = player;
16 | }
17 |
18 | protected @Nullable HitResult getTarget() {
19 | double reach = player.gameMode.isCreative() ? 5 : 4.5f;
20 | return Tracer.rayTrace(player, 1, reach, false);
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_5/src/main/java/io/github/hello09x/fakeplayer/v1_21_5/action/TraceAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_5.action;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.Action;
4 | import io.github.hello09x.fakeplayer.v1_21_5.action.util.Tracer;
5 | import net.minecraft.server.level.ServerPlayer;
6 | import net.minecraft.world.phys.HitResult;
7 | import org.jetbrains.annotations.NotNull;
8 | import org.jetbrains.annotations.Nullable;
9 |
10 | public abstract class TraceAction implements Action {
11 |
12 | protected final ServerPlayer player;
13 |
14 | protected TraceAction(@NotNull ServerPlayer player) {
15 | this.player = player;
16 | }
17 |
18 | protected @Nullable HitResult getTarget() {
19 | double reach = player.gameMode.isCreative() ? 5 : 4.5f;
20 | return Tracer.rayTrace(player, 1, reach, false);
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_6/src/main/java/io/github/hello09x/fakeplayer/v1_21_6/action/TraceAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_6.action;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.Action;
4 | import io.github.hello09x.fakeplayer.v1_21_6.action.util.Tracer;
5 | import net.minecraft.server.level.ServerPlayer;
6 | import net.minecraft.world.phys.HitResult;
7 | import org.jetbrains.annotations.NotNull;
8 | import org.jetbrains.annotations.Nullable;
9 |
10 | public abstract class TraceAction implements Action {
11 |
12 | protected final ServerPlayer player;
13 |
14 | protected TraceAction(@NotNull ServerPlayer player) {
15 | this.player = player;
16 | }
17 |
18 | protected @Nullable HitResult getTarget() {
19 | double reach = player.gameMode.isCreative() ? 5 : 4.5f;
20 | return Tracer.rayTrace(player, 1, reach, false);
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_9/src/main/java/io/github/hello09x/fakeplayer/v1_21_9/action/TraceAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_9.action;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.Action;
4 | import io.github.hello09x.fakeplayer.v1_21_9.action.util.Tracer;
5 | import net.minecraft.server.level.ServerPlayer;
6 | import net.minecraft.world.phys.HitResult;
7 | import org.jetbrains.annotations.NotNull;
8 | import org.jetbrains.annotations.Nullable;
9 |
10 | public abstract class TraceAction implements Action {
11 |
12 | protected final ServerPlayer player;
13 |
14 | protected TraceAction(@NotNull ServerPlayer player) {
15 | this.player = player;
16 | }
17 |
18 | protected @Nullable HitResult getTarget() {
19 | double reach = player.gameMode.isCreative() ? 5 : 4.5f;
20 | return Tracer.rayTrace(player, 1, reach, false);
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/entity/action/impl/DropStackAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.entity.action.impl;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.Action;
4 | import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer;
5 | import org.jetbrains.annotations.NotNull;
6 |
7 | public class DropStackAction implements Action {
8 |
9 | @NotNull
10 | private final NMSServerPlayer player;
11 |
12 | public DropStackAction(@NotNull NMSServerPlayer player) {
13 | this.player = player;
14 | }
15 |
16 |
17 | @Override
18 | public boolean tick() {
19 | player.drop(true);
20 | player.resetLastActionTime();
21 | return true;
22 | }
23 |
24 | @Override
25 | public void inactiveTick() {
26 |
27 | }
28 |
29 | @Override
30 | public void stop() {
31 |
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/NMSBridge.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.api.spi;
2 |
3 | import org.bukkit.Server;
4 | import org.bukkit.World;
5 | import org.bukkit.entity.Entity;
6 | import org.bukkit.entity.Player;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | import java.net.InetAddress;
10 |
11 | public interface NMSBridge {
12 |
13 | @NotNull NMSEntity fromEntity(@NotNull Entity entity);
14 |
15 | @NotNull NMSServer fromServer(@NotNull Server server);
16 |
17 | @NotNull NMSServerLevel fromWorld(@NotNull World world);
18 |
19 | @NotNull NMSServerPlayer fromPlayer(@NotNull Player player);
20 |
21 | @NotNull NMSNetwork createNetwork(@NotNull InetAddress address);
22 |
23 | boolean isSupported();
24 |
25 | @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting);
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/util/AddressUtils.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.util;
2 |
3 | import org.bukkit.command.CommandSender;
4 | import org.bukkit.entity.Player;
5 | import org.jetbrains.annotations.NotNull;
6 |
7 | import java.net.InetSocketAddress;
8 | import java.util.Optional;
9 |
10 | /**
11 | * @author tanyaofei
12 | * @since 2024/7/29
13 | **/
14 | public class AddressUtils {
15 |
16 | /**
17 | * 获取 IP 地址
18 | * 如果不是玩家则返回 127.0.0.1, 如果该玩家已离线则返回 0.0.0.0
19 | *
20 | * @param sender 玩家
21 | * @return IP 地址
22 | */
23 | public static @NotNull String getAddress(@NotNull CommandSender sender) {
24 | if (sender instanceof Player p) {
25 | return Optional.ofNullable(p.getAddress()).map(InetSocketAddress::getHostString).orElse("0.0.0.0");
26 | } else {
27 | return "127.0.0.1";
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/util/Mth.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.util;
2 |
3 | public class Mth {
4 |
5 | /**
6 | * 将 num 以 base 向下取整
7 | *
8 | * - 3.0, 0.5 -> 3.0
9 | * - 3.1, 0.5 -> 3.0
10 | * - 3.6, 0.5 -> 3.5
11 | *
12 | *
13 | * @param num 数
14 | * @param base 基数
15 | * @return 取整后的数
16 | */
17 | public static double floor(double num, double base) {
18 | if (num % base == 0) {
19 | return num;
20 | }
21 | return Math.floor(num / base) * base;
22 | }
23 |
24 | /**
25 | * 将一个数约束在范围以内
26 | *
27 | * @param value 数
28 | * @param min 最小值
29 | * @param max 最大值
30 | * @return 约束后的数
31 | */
32 | public static float clamp(float value, float min, float max) {
33 | return value < min ? min : Math.min(value, max);
34 | }
35 |
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/SneakCommand.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.command.impl;
2 |
3 | import com.google.inject.Singleton;
4 | import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
5 | import dev.jorel.commandapi.executors.CommandArguments;
6 | import org.bukkit.command.CommandSender;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | @Singleton
10 | public class SneakCommand extends AbstractCommand {
11 |
12 | /**
13 | * 设置潜行
14 | */
15 | public void sneak(@NotNull CommandSender sender, @NotNull CommandArguments args) throws WrapperCommandSyntaxException {
16 | var fake = getFakeplayer(sender, args);
17 | var sneaking = args
18 | .getOptional("sneaking")
19 | .map(String.class::cast)
20 | .map(Boolean::valueOf)
21 | .orElse(!fake.isSneaking());
22 |
23 | fake.setSneaking(sneaking);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/RespawnCommand.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.command.impl;
2 |
3 | import com.google.inject.Singleton;
4 | import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
5 | import dev.jorel.commandapi.executors.CommandArguments;
6 | import org.bukkit.command.CommandSender;
7 | import org.bukkit.entity.Entity;
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | import static net.kyori.adventure.text.Component.translatable;
11 |
12 | @Singleton
13 | public class RespawnCommand extends AbstractCommand {
14 |
15 | /**
16 | * 重生
17 | */
18 | public void respawn(@NotNull CommandSender sender, @NotNull CommandArguments args) throws WrapperCommandSyntaxException {
19 | var fake = super.getFakeplayer(sender, args, Entity::isDead);
20 | bridge.fromPlayer(fake).respawn();
21 | sender.sendMessage(translatable("fakeplayer.command.generic.success"));
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/repository/model/UserConfigRowMapper.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.repository.model;
2 |
3 | import io.github.hello09x.devtools.database.jdbc.RowMapper;
4 | import org.jetbrains.annotations.NotNull;
5 | import org.jetbrains.annotations.Nullable;
6 |
7 | import java.sql.ResultSet;
8 | import java.sql.SQLException;
9 | import java.util.UUID;
10 |
11 | /**
12 | * @author tanyaofei
13 | * @since 2024/7/27
14 | **/
15 | public class UserConfigRowMapper implements RowMapper {
16 |
17 | public final static UserConfigRowMapper instance = new UserConfigRowMapper();
18 |
19 | @Override
20 | public @Nullable UserConfig mapRow(@NotNull ResultSet rs, int rowNum) throws SQLException {
21 | return new UserConfig(
22 | rs.getInt("id"),
23 | UUID.fromString(rs.getString("player_id")),
24 | Feature.valueOf(rs.getString("key")),
25 | rs.getString("value")
26 | );
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/fakeplayer-dist/src/main/resources/META-INF/services/io.github.hello09x.fakeplayer.api.spi.NMSBridge:
--------------------------------------------------------------------------------
1 | io.github.hello09x.fakeplayer.v1_20_1.spi.NMSBridgeImpl
2 | io.github.hello09x.fakeplayer.v1_20_2.spi.NMSBridgeImpl
3 | io.github.hello09x.fakeplayer.v1_20_3.spi.NMSBridgeImpl
4 | io.github.hello09x.fakeplayer.v1_20_4.spi.NMSBridgeImpl
5 | io.github.hello09x.fakeplayer.v1_20_5.spi.NMSBridgeImpl
6 | io.github.hello09x.fakeplayer.v1_20_6.spi.NMSBridgeImpl
7 | io.github.hello09x.fakeplayer.v1_21.spi.NMSBridgeImpl
8 | io.github.hello09x.fakeplayer.v1_21_1.spi.NMSBridgeImpl
9 | io.github.hello09x.fakeplayer.v1_21_3.spi.NMSBridgeImpl
10 | io.github.hello09x.fakeplayer.v1_21_4.spi.NMSBridgeImpl
11 | io.github.hello09x.fakeplayer.v1_21_5.spi.NMSBridgeImpl
12 | io.github.hello09x.fakeplayer.v1_21_6.spi.NMSBridgeImpl
13 | io.github.hello09x.fakeplayer.v1_21_7.spi.NMSBridgeImpl
14 | io.github.hello09x.fakeplayer.v1_21_8.spi.NMSBridgeImpl
15 | io.github.hello09x.fakeplayer.v1_21_9.spi.NMSBridgeImpl
16 | io.github.hello09x.fakeplayer.v1_21_10.spi.NMSBridgeImpl
17 |
18 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/repository/model/FakePlayerSkinRowMapper.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.repository.model;
2 |
3 | import io.github.hello09x.devtools.database.jdbc.RowMapper;
4 | import org.jetbrains.annotations.NotNull;
5 | import org.jetbrains.annotations.Nullable;
6 |
7 | import java.sql.ResultSet;
8 | import java.sql.SQLException;
9 | import java.util.UUID;
10 |
11 | /**
12 | * @author tanyaofei
13 | * @since 2024/8/8
14 | **/
15 | public class FakePlayerSkinRowMapper implements RowMapper {
16 |
17 | public final static FakePlayerSkinRowMapper instance = new FakePlayerSkinRowMapper();
18 |
19 | @Override
20 | public @Nullable FakePlayerSkin mapRow(@NotNull ResultSet rs, int i) throws SQLException {
21 | return new FakePlayerSkin(
22 | UUID.fromString(rs.getString("player_id")),
23 | UUID.fromString(rs.getString("creator_id")),
24 | UUID.fromString(rs.getString("target_id"))
25 | );
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/entity/action/impl/DropInventoryAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.entity.action.impl;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.Action;
4 | import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer;
5 | import org.jetbrains.annotations.NotNull;
6 |
7 | public class DropInventoryAction implements Action {
8 |
9 |
10 | @NotNull
11 | private final NMSServerPlayer player;
12 |
13 | public DropInventoryAction(@NotNull NMSServerPlayer player) {
14 | this.player = player;
15 | }
16 |
17 | @Override
18 | public boolean tick() {
19 | var inventory = player.getPlayer().getInventory();
20 | for (int i = inventory.getSize(); i >= 0; i--) {
21 | player.drop(i, false, true);
22 | }
23 | player.resetLastActionTime();
24 | return true;
25 | }
26 |
27 | @Override
28 | public void inactiveTick() {
29 |
30 | }
31 |
32 | @Override
33 | public void stop() {
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/entity/action/impl/JumpAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.entity.action.impl;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.Action;
4 | import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer;
5 | import org.jetbrains.annotations.NotNull;
6 |
7 | public class JumpAction implements Action {
8 |
9 | @NotNull
10 | private final NMSServerPlayer player;
11 |
12 | public JumpAction(@NotNull NMSServerPlayer player) {
13 | this.player = player;
14 | }
15 |
16 |
17 | @Override
18 | public boolean tick() {
19 | if (player.onGround()) {
20 | player.jumpFromGround();
21 | } else {
22 | player.setJumping(true);
23 | }
24 | player.resetLastActionTime();
25 | return true;
26 | }
27 |
28 | @Override
29 | public void inactiveTick() {
30 | player.setJumping(false);
31 | }
32 |
33 | @Override
34 | public void stop() {
35 | player.setJumping(false);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/StopCommand.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.command.impl;
2 |
3 | import com.google.inject.Inject;
4 | import com.google.inject.Singleton;
5 | import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
6 | import dev.jorel.commandapi.executors.CommandArguments;
7 | import io.github.hello09x.fakeplayer.core.manager.action.ActionManager;
8 | import org.bukkit.command.CommandSender;
9 | import org.jetbrains.annotations.NotNull;
10 |
11 | /**
12 | * @author tanyaofei
13 | * @since 2024/7/28
14 | **/
15 | @Singleton
16 | public class StopCommand extends AbstractCommand {
17 |
18 | private final ActionManager actionManager;
19 |
20 | @Inject
21 | public StopCommand(ActionManager actionManager) {
22 | this.actionManager = actionManager;
23 | }
24 |
25 | public void stop(@NotNull CommandSender sender, @NotNull CommandArguments args) throws WrapperCommandSyntaxException {
26 | var fake = super.getFakeplayer(sender, args);
27 | actionManager.stop(fake);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/repository/model/Singletons.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.repository.model;
2 |
3 | import io.github.hello09x.devtools.core.utils.SingletonSupplier;
4 | import io.github.hello09x.fakeplayer.core.Main;
5 | import io.github.hello09x.fakeplayer.core.manager.FakeplayerAutofishManager;
6 | import io.github.hello09x.fakeplayer.core.manager.FakeplayerReplenishManager;
7 | import io.github.hello09x.fakeplayer.core.manager.action.ActionManager;
8 |
9 | import java.util.function.Supplier;
10 |
11 | /**
12 | * @author tanyaofei
13 | * @since 2024/8/13
14 | **/
15 | public interface Singletons {
16 |
17 | Supplier actionManager = new SingletonSupplier<>(() -> Main.getInjector().getInstance(ActionManager.class));
18 | Supplier replenishManager = new SingletonSupplier<>(() -> Main.getInjector().getInstance(FakeplayerReplenishManager.class));
19 | Supplier autofishManager = new SingletonSupplier<>(() -> Main.getInjector().getInstance(FakeplayerAutofishManager.class));
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/manager/invsee/SimpleInvseeManagerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.manager.invsee;
2 |
3 | import com.google.inject.Inject;
4 | import com.google.inject.Singleton;
5 | import io.github.hello09x.fakeplayer.core.manager.FakeplayerList;
6 | import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
7 | import org.bukkit.entity.Player;
8 | import org.bukkit.inventory.InventoryView;
9 | import org.jetbrains.annotations.NotNull;
10 | import org.jetbrains.annotations.Nullable;
11 |
12 | /**
13 | * 默认实现, 无法看到装备栏
14 | *
15 | * @author tanyaofei
16 | * @since 2024/8/12
17 | **/
18 | @Singleton
19 | public class SimpleInvseeManagerImpl extends AbstractInvseeManager {
20 |
21 | @Inject
22 | public SimpleInvseeManagerImpl(FakeplayerManager manager, FakeplayerList fakeplayerList) {
23 | super(manager, fakeplayerList);
24 | }
25 |
26 | @Override
27 | protected @Nullable InventoryView openInventory(@NotNull Player viewer, @NotNull Player whom) {
28 | return viewer.openInventory(whom.getInventory());
29 | }
30 |
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/util/Attributes.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.util;
2 |
3 | import org.bukkit.attribute.Attribute;
4 | import org.jetbrains.annotations.NotNull;
5 |
6 | import java.util.NoSuchElementException;
7 |
8 | /**
9 | * @author tanyaofei
10 | * @since 2025/7/16
11 | **/
12 | public abstract class Attributes {
13 |
14 | /**
15 | *
16 | * - <= 1.12.5 GENERIC_MAX_HEALTH
17 | * - >= 1.21.6 MAX_HEALTH
18 | *
19 | *
20 | * @return
21 | */
22 | public static @NotNull Attribute maxHealth() {
23 | try {
24 | return (Attribute) Attribute.class.getField("GENERIC_MAX_HEALTH").get(Attribute.class);
25 | } catch (NoSuchFieldException | IllegalAccessException e) {
26 | try {
27 | return (Attribute) Attribute.class.getField("MAX_HEALTH").get(Attribute.class);
28 | } catch (Exception e1) {
29 | throw new NoSuchElementException("No attribute found for MAX_HEALTH or GENERIC_MAX_HEALTH");
30 | }
31 | }
32 | }
33 |
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_1/src/main/java/io/github/hello09x/fakeplayer/v1_20_1/network/FakeConnection.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_1.network;
2 |
3 | import io.github.hello09x.fakeplayer.core.network.FakeChannel;
4 | import net.minecraft.network.Connection;
5 | import net.minecraft.network.PacketSendListener;
6 | import net.minecraft.network.protocol.Packet;
7 | import net.minecraft.network.protocol.PacketFlow;
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | import java.net.InetAddress;
11 |
12 | public class FakeConnection extends Connection {
13 | public FakeConnection(@NotNull InetAddress address) {
14 | super(PacketFlow.SERVERBOUND);
15 | this.channel = new FakeChannel(null, address);
16 | this.address = this.channel.remoteAddress();
17 | }
18 |
19 | @Override
20 | public boolean isConnected() {
21 | return true;
22 | }
23 |
24 | @Override
25 | public void send(Packet> packet, PacketSendListener listener) {
26 | }
27 |
28 | @Override
29 | public void send(Packet> packet) {
30 | }
31 |
32 | @Override
33 | public void handleDisconnection() {
34 | }
35 | }
--------------------------------------------------------------------------------
/fakeplayer-v1_20_6/src/main/java/io/github/hello09x/fakeplayer/v1_20_6/network/FakeConnection.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_6.network;
2 |
3 | import io.github.hello09x.fakeplayer.core.network.FakeChannel;
4 | import net.minecraft.network.Connection;
5 | import net.minecraft.network.PacketSendListener;
6 | import net.minecraft.network.protocol.Packet;
7 | import net.minecraft.network.protocol.PacketFlow;
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | import java.net.InetAddress;
11 |
12 | public class FakeConnection extends Connection {
13 |
14 | public FakeConnection(@NotNull InetAddress address) {
15 | super(PacketFlow.SERVERBOUND);
16 | this.channel = new FakeChannel(null, address);
17 | this.address = this.channel.remoteAddress();
18 | Connection.configureSerialization(this.channel.pipeline(), PacketFlow.SERVERBOUND, false, null);
19 | }
20 |
21 | @Override
22 | public boolean isConnected() {
23 | return true;
24 | }
25 |
26 | @Override
27 | public void send(Packet> packet, PacketSendListener listener) {
28 | }
29 |
30 | @Override
31 | public void send(Packet> packet) {
32 | }
33 |
34 | }
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/repository/model/FakePlayerProfile.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.repository.model;
2 |
3 | import io.github.hello09x.devtools.database.jdbc.RowMapper;
4 | import org.jetbrains.annotations.NotNull;
5 | import org.jetbrains.annotations.Nullable;
6 |
7 | import java.sql.ResultSet;
8 | import java.sql.SQLException;
9 |
10 | /**
11 | * @author tanyaofei
12 | * @since 2024/8/3
13 | **/
14 | public record FakePlayerProfile(
15 |
16 | Integer id,
17 |
18 | @NotNull
19 | String name,
20 |
21 | @NotNull
22 | String uuid
23 |
24 | ) {
25 |
26 | public static class FakePlayerProfileRowMapper implements RowMapper {
27 |
28 | public final static FakePlayerProfileRowMapper instance = new FakePlayerProfileRowMapper();
29 |
30 | @Override
31 | public @Nullable FakePlayerProfile mapRow(@NotNull ResultSet rs, int rowNum) throws SQLException {
32 | return new FakePlayerProfile(
33 | rs.getInt("id"),
34 | rs.getString("name"),
35 | rs.getString("uuid")
36 | );
37 | }
38 |
39 | }
40 |
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/util/InternalAddressGenerator.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.util;
2 |
3 | import lombok.SneakyThrows;
4 | import org.jetbrains.annotations.NotNull;
5 |
6 | import java.net.InetAddress;
7 | import java.util.concurrent.atomic.AtomicInteger;
8 |
9 | public class InternalAddressGenerator {
10 |
11 | private final AtomicInteger next = new AtomicInteger(1);
12 |
13 | /**
14 | * 判断 IP 地址能否由本工具类生成
15 | *
16 | * @param address 地址
17 | * @return 能否生成
18 | */
19 | public static boolean canBeGenerated(@NotNull InetAddress address) {
20 | return address.getAddress()[0] == 127;
21 | }
22 |
23 | /**
24 | * 获取下一个 IP 地址
25 | *
26 | * @return IP 地址
27 | */
28 | @SneakyThrows
29 | public @NotNull InetAddress next() {
30 | var ip = next.getAndIncrement();
31 | // max 127.255.255.254
32 | if (ip == 0xfffffe) {
33 | next.set(0);
34 | }
35 |
36 | var p2 = (ip >> 16) & 0xff;
37 | var p3 = (ip >> 8) & 0xff;
38 | var p4 = ip & 0xff;
39 |
40 | return InetAddress.getByAddress(new byte[]{127, (byte) p2, (byte) p3, (byte) p4});
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/fakeplayer-api/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | io.github.hello09x.fakeplayer
8 | fakeplayer-parent
9 | ${revision}
10 |
11 |
12 | fakeplayer-api
13 |
14 |
15 | 17
16 | 17
17 | UTF-8
18 |
19 |
20 |
21 |
22 | io.papermc.paper
23 | paper-api
24 | provided
25 |
26 |
27 |
28 | org.projectlombok
29 | lombok
30 | provided
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21/src/main/java/io/github/hello09x/fakeplayer/v1_21/action/AttackAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21.action;
2 |
3 | import net.minecraft.server.level.ServerPlayer;
4 | import net.minecraft.world.InteractionHand;
5 | import net.minecraft.world.phys.EntityHitResult;
6 | import net.minecraft.world.phys.HitResult;
7 |
8 |
9 | public class AttackAction extends TraceAction {
10 |
11 | private final ServerPlayer player;
12 |
13 | public AttackAction(ServerPlayer player) {
14 | super(player);
15 | this.player = player;
16 | }
17 |
18 |
19 | @Override
20 | public boolean tick() {
21 | var hit = this.getTarget();
22 | if (hit == null) {
23 | return false;
24 | }
25 |
26 | if (hit.getType() != HitResult.Type.ENTITY) {
27 | return false;
28 | }
29 |
30 | var entityHit = (EntityHitResult) hit;
31 | player.attack(entityHit.getEntity());
32 | player.swing(InteractionHand.MAIN_HAND);
33 | player.resetAttackStrengthTicker();
34 | player.resetLastActionTime();
35 | return true;
36 | }
37 |
38 | @Override
39 | public void inactiveTick() {
40 |
41 | }
42 |
43 | @Override
44 | public void stop() {
45 |
46 | }
47 |
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_1/src/main/java/io/github/hello09x/fakeplayer/v1_20_1/action/AttackAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_1.action;
2 |
3 | import net.minecraft.server.level.ServerPlayer;
4 | import net.minecraft.world.InteractionHand;
5 | import net.minecraft.world.phys.EntityHitResult;
6 | import net.minecraft.world.phys.HitResult;
7 |
8 |
9 | public class AttackAction extends TraceAction {
10 |
11 | private final ServerPlayer player;
12 |
13 | public AttackAction(ServerPlayer player) {
14 | super(player);
15 | this.player = player;
16 | }
17 |
18 |
19 | @Override
20 | public boolean tick() {
21 | var hit = this.getTarget();
22 | if (hit == null) {
23 | return false;
24 | }
25 |
26 | if (hit.getType() != HitResult.Type.ENTITY) {
27 | return false;
28 | }
29 |
30 | var entityHit = (EntityHitResult) hit;
31 | player.attack(entityHit.getEntity());
32 | player.swing(InteractionHand.MAIN_HAND);
33 | player.resetAttackStrengthTicker();
34 | player.resetLastActionTime();
35 | return true;
36 | }
37 |
38 | @Override
39 | public void inactiveTick() {
40 |
41 | }
42 |
43 | @Override
44 | public void stop() {
45 |
46 | }
47 |
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_2/src/main/java/io/github/hello09x/fakeplayer/v1_20_2/action/AttackAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_2.action;
2 |
3 | import net.minecraft.server.level.ServerPlayer;
4 | import net.minecraft.world.InteractionHand;
5 | import net.minecraft.world.phys.EntityHitResult;
6 | import net.minecraft.world.phys.HitResult;
7 |
8 |
9 | public class AttackAction extends TraceAction {
10 |
11 | private final ServerPlayer player;
12 |
13 | public AttackAction(ServerPlayer player) {
14 | super(player);
15 | this.player = player;
16 | }
17 |
18 |
19 | @Override
20 | public boolean tick() {
21 | var hit = this.getTarget();
22 | if (hit == null) {
23 | return false;
24 | }
25 |
26 | if (hit.getType() != HitResult.Type.ENTITY) {
27 | return false;
28 | }
29 |
30 | var entityHit = (EntityHitResult) hit;
31 | player.attack(entityHit.getEntity());
32 | player.swing(InteractionHand.MAIN_HAND);
33 | player.resetAttackStrengthTicker();
34 | player.resetLastActionTime();
35 | return true;
36 | }
37 |
38 | @Override
39 | public void inactiveTick() {
40 |
41 | }
42 |
43 | @Override
44 | public void stop() {
45 |
46 | }
47 |
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_4/src/main/java/io/github/hello09x/fakeplayer/v1_20_4/action/AttackAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_4.action;
2 |
3 | import net.minecraft.server.level.ServerPlayer;
4 | import net.minecraft.world.InteractionHand;
5 | import net.minecraft.world.phys.EntityHitResult;
6 | import net.minecraft.world.phys.HitResult;
7 |
8 |
9 | public class AttackAction extends TraceAction {
10 |
11 | private final ServerPlayer player;
12 |
13 | public AttackAction(ServerPlayer player) {
14 | super(player);
15 | this.player = player;
16 | }
17 |
18 |
19 | @Override
20 | public boolean tick() {
21 | var hit = this.getTarget();
22 | if (hit == null) {
23 | return false;
24 | }
25 |
26 | if (hit.getType() != HitResult.Type.ENTITY) {
27 | return false;
28 | }
29 |
30 | var entityHit = (EntityHitResult) hit;
31 | player.attack(entityHit.getEntity());
32 | player.swing(InteractionHand.MAIN_HAND);
33 | player.resetAttackStrengthTicker();
34 | player.resetLastActionTime();
35 | return true;
36 | }
37 |
38 | @Override
39 | public void inactiveTick() {
40 |
41 | }
42 |
43 | @Override
44 | public void stop() {
45 |
46 | }
47 |
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_6/src/main/java/io/github/hello09x/fakeplayer/v1_20_6/action/AttackAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_6.action;
2 |
3 | import net.minecraft.server.level.ServerPlayer;
4 | import net.minecraft.world.InteractionHand;
5 | import net.minecraft.world.phys.EntityHitResult;
6 | import net.minecraft.world.phys.HitResult;
7 |
8 |
9 | public class AttackAction extends TraceAction {
10 |
11 | private final ServerPlayer player;
12 |
13 | public AttackAction(ServerPlayer player) {
14 | super(player);
15 | this.player = player;
16 | }
17 |
18 |
19 | @Override
20 | public boolean tick() {
21 | var hit = this.getTarget();
22 | if (hit == null) {
23 | return false;
24 | }
25 |
26 | if (hit.getType() != HitResult.Type.ENTITY) {
27 | return false;
28 | }
29 |
30 | var entityHit = (EntityHitResult) hit;
31 | player.attack(entityHit.getEntity());
32 | player.swing(InteractionHand.MAIN_HAND);
33 | player.resetAttackStrengthTicker();
34 | player.resetLastActionTime();
35 | return true;
36 | }
37 |
38 | @Override
39 | public void inactiveTick() {
40 |
41 | }
42 |
43 | @Override
44 | public void stop() {
45 |
46 | }
47 |
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_3/src/main/java/io/github/hello09x/fakeplayer/v1_21_3/action/AttackAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_3.action;
2 |
3 | import net.minecraft.server.level.ServerPlayer;
4 | import net.minecraft.world.InteractionHand;
5 | import net.minecraft.world.phys.EntityHitResult;
6 | import net.minecraft.world.phys.HitResult;
7 |
8 |
9 | public class AttackAction extends TraceAction {
10 |
11 | private final ServerPlayer player;
12 |
13 | public AttackAction(ServerPlayer player) {
14 | super(player);
15 | this.player = player;
16 | }
17 |
18 |
19 | @Override
20 | public boolean tick() {
21 | var hit = this.getTarget();
22 | if (hit == null) {
23 | return false;
24 | }
25 |
26 | if (hit.getType() != HitResult.Type.ENTITY) {
27 | return false;
28 | }
29 |
30 | var entityHit = (EntityHitResult) hit;
31 | player.attack(entityHit.getEntity());
32 | player.swing(InteractionHand.MAIN_HAND);
33 | player.resetAttackStrengthTicker();
34 | player.resetLastActionTime();
35 | return true;
36 | }
37 |
38 | @Override
39 | public void inactiveTick() {
40 |
41 | }
42 |
43 | @Override
44 | public void stop() {
45 |
46 | }
47 |
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_4/src/main/java/io/github/hello09x/fakeplayer/v1_21_4/action/AttackAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_4.action;
2 |
3 | import net.minecraft.server.level.ServerPlayer;
4 | import net.minecraft.world.InteractionHand;
5 | import net.minecraft.world.phys.EntityHitResult;
6 | import net.minecraft.world.phys.HitResult;
7 |
8 |
9 | public class AttackAction extends TraceAction {
10 |
11 | private final ServerPlayer player;
12 |
13 | public AttackAction(ServerPlayer player) {
14 | super(player);
15 | this.player = player;
16 | }
17 |
18 |
19 | @Override
20 | public boolean tick() {
21 | var hit = this.getTarget();
22 | if (hit == null) {
23 | return false;
24 | }
25 |
26 | if (hit.getType() != HitResult.Type.ENTITY) {
27 | return false;
28 | }
29 |
30 | var entityHit = (EntityHitResult) hit;
31 | player.attack(entityHit.getEntity());
32 | player.swing(InteractionHand.MAIN_HAND);
33 | player.resetAttackStrengthTicker();
34 | player.resetLastActionTime();
35 | return true;
36 | }
37 |
38 | @Override
39 | public void inactiveTick() {
40 |
41 | }
42 |
43 | @Override
44 | public void stop() {
45 |
46 | }
47 |
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_5/src/main/java/io/github/hello09x/fakeplayer/v1_21_5/action/AttackAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_5.action;
2 |
3 | import net.minecraft.server.level.ServerPlayer;
4 | import net.minecraft.world.InteractionHand;
5 | import net.minecraft.world.phys.EntityHitResult;
6 | import net.minecraft.world.phys.HitResult;
7 |
8 |
9 | public class AttackAction extends TraceAction {
10 |
11 | private final ServerPlayer player;
12 |
13 | public AttackAction(ServerPlayer player) {
14 | super(player);
15 | this.player = player;
16 | }
17 |
18 |
19 | @Override
20 | public boolean tick() {
21 | var hit = this.getTarget();
22 | if (hit == null) {
23 | return false;
24 | }
25 |
26 | if (hit.getType() != HitResult.Type.ENTITY) {
27 | return false;
28 | }
29 |
30 | var entityHit = (EntityHitResult) hit;
31 | player.attack(entityHit.getEntity());
32 | player.swing(InteractionHand.MAIN_HAND);
33 | player.resetAttackStrengthTicker();
34 | player.resetLastActionTime();
35 | return true;
36 | }
37 |
38 | @Override
39 | public void inactiveTick() {
40 |
41 | }
42 |
43 | @Override
44 | public void stop() {
45 |
46 | }
47 |
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_6/src/main/java/io/github/hello09x/fakeplayer/v1_21_6/action/AttackAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_6.action;
2 |
3 | import net.minecraft.server.level.ServerPlayer;
4 | import net.minecraft.world.InteractionHand;
5 | import net.minecraft.world.phys.EntityHitResult;
6 | import net.minecraft.world.phys.HitResult;
7 |
8 |
9 | public class AttackAction extends TraceAction {
10 |
11 | private final ServerPlayer player;
12 |
13 | public AttackAction(ServerPlayer player) {
14 | super(player);
15 | this.player = player;
16 | }
17 |
18 |
19 | @Override
20 | public boolean tick() {
21 | var hit = this.getTarget();
22 | if (hit == null) {
23 | return false;
24 | }
25 |
26 | if (hit.getType() != HitResult.Type.ENTITY) {
27 | return false;
28 | }
29 |
30 | var entityHit = (EntityHitResult) hit;
31 | player.attack(entityHit.getEntity());
32 | player.swing(InteractionHand.MAIN_HAND);
33 | player.resetAttackStrengthTicker();
34 | player.resetLastActionTime();
35 | return true;
36 | }
37 |
38 | @Override
39 | public void inactiveTick() {
40 |
41 | }
42 |
43 | @Override
44 | public void stop() {
45 |
46 | }
47 |
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_9/src/main/java/io/github/hello09x/fakeplayer/v1_21_9/action/AttackAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_9.action;
2 |
3 | import net.minecraft.server.level.ServerPlayer;
4 | import net.minecraft.world.InteractionHand;
5 | import net.minecraft.world.phys.EntityHitResult;
6 | import net.minecraft.world.phys.HitResult;
7 |
8 |
9 | public class AttackAction extends TraceAction {
10 |
11 | private final ServerPlayer player;
12 |
13 | public AttackAction(ServerPlayer player) {
14 | super(player);
15 | this.player = player;
16 | }
17 |
18 |
19 | @Override
20 | public boolean tick() {
21 | var hit = this.getTarget();
22 | if (hit == null) {
23 | return false;
24 | }
25 |
26 | if (hit.getType() != HitResult.Type.ENTITY) {
27 | return false;
28 | }
29 |
30 | var entityHit = (EntityHitResult) hit;
31 | player.attack(entityHit.getEntity());
32 | player.swing(InteractionHand.MAIN_HAND);
33 | player.resetAttackStrengthTicker();
34 | player.resetLastActionTime();
35 | return true;
36 | }
37 |
38 | @Override
39 | public void inactiveTick() {
40 |
41 | }
42 |
43 | @Override
44 | public void stop() {
45 |
46 | }
47 |
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/ActionType.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.api.spi;
2 |
3 | import lombok.AllArgsConstructor;
4 | import net.kyori.adventure.translation.Translatable;
5 | import org.jetbrains.annotations.NotNull;
6 |
7 | /**
8 | * @author tanyaofei
9 | * @since 2024/8/9
10 | **/
11 | @AllArgsConstructor
12 | public
13 | enum ActionType implements Translatable {
14 |
15 | /**
16 | * 攻击实体
17 | */
18 | ATTACK("fakeplayer.action.attack"),
19 |
20 | /**
21 | * 挖掘
22 | */
23 | MINE("fakeplayer.action.mine"),
24 |
25 | /**
26 | * 右键
27 | */
28 | USE("fakeplayer.action.use"),
29 |
30 | /**
31 | * 跳跃
32 | */
33 | JUMP("fakeplayer.action.jump"),
34 |
35 | /**
36 | * 看向附近实体
37 | */
38 | LOOK_AT_NEAREST_ENTITY("fakeplayer.action.look-at-entity"),
39 |
40 | /**
41 | * 丢弃手上 1 个物品
42 | */
43 | DROP_ITEM("fakeplayer.action.drop-item"),
44 |
45 | /**
46 | * 丢弃手上整组物品
47 | */
48 | DROP_STACK("fakeplayer.action.drop-stack"),
49 |
50 | /**
51 | * 丢弃背包
52 | */
53 | DROP_INVENTORY("fakeplayer.action.drop-inventory");
54 |
55 | final String translationKey;
56 |
57 |
58 | @Override
59 | public @NotNull String translationKey() {
60 | return this.translationKey;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_1/src/main/java/io/github/hello09x/fakeplayer/v1_20_1/spi/NMSServerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_1.spi;
2 |
3 | import com.mojang.authlib.GameProfile;
4 | import io.github.hello09x.devtools.core.utils.WorldUtils;
5 | import io.github.hello09x.fakeplayer.api.spi.NMSServer;
6 | import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer;
7 | import lombok.Getter;
8 | import net.minecraft.server.MinecraftServer;
9 | import net.minecraft.server.level.ServerPlayer;
10 | import org.bukkit.Bukkit;
11 | import org.bukkit.Server;
12 | import org.bukkit.craftbukkit.v1_20_R1.CraftServer;
13 | import org.jetbrains.annotations.NotNull;
14 |
15 | import java.util.UUID;
16 |
17 | public class NMSServerImpl implements NMSServer {
18 |
19 |
20 | @Getter
21 | private final MinecraftServer handle;
22 |
23 | public NMSServerImpl(@NotNull Server server) {
24 | this.handle = ((CraftServer) server).getServer();
25 | }
26 |
27 | @Override
28 | public @NotNull NMSServerPlayer newPlayer(@NotNull UUID uuid, @NotNull String name) {
29 | var handle = new ServerPlayer(
30 | new NMSServerImpl(Bukkit.getServer()).getHandle(),
31 | new NMSServerLevelImpl(WorldUtils.getMainWorld()).getHandle(),
32 | new GameProfile(uuid, name)
33 | );
34 | return new NMSServerPlayerImpl(handle.getBukkitEntity());
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/util/Commands.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.util;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 |
5 | import java.util.ArrayList;
6 | import java.util.HashMap;
7 | import java.util.List;
8 |
9 | public class Commands {
10 |
11 | public static List formatCommands(@NotNull List commands, @NotNull String @NotNull ... pa) {
12 | if ((pa.length & 1) != 0) {
13 | throw new IllegalArgumentException("parameter 'pa' should be paired");
14 | }
15 |
16 | var args = new HashMap(pa.length / 2, 1.0F);
17 | for (int i = 0; i < pa.length; i += 2) {
18 | args.put(pa[i], pa[i + 1]);
19 | }
20 |
21 | var ret = new ArrayList(commands.size());
22 | for (var cmd : commands) {
23 | cmd = cmd.trim();
24 | if (cmd.startsWith("/")) {
25 | if (cmd.length() < 2) {
26 | continue;
27 | }
28 | cmd = cmd.substring(1);
29 | }
30 |
31 | if (!args.isEmpty()) {
32 | for (var entry : args.entrySet()) {
33 | cmd = cmd.replace(entry.getKey(), entry.getValue());
34 | }
35 | }
36 |
37 | if (cmd.isBlank()) {
38 | continue;
39 | }
40 | ret.add(cmd);
41 | }
42 | return ret;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/listener/PlayerListener.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.listener;
2 |
3 | import com.google.inject.Inject;
4 | import com.google.inject.Singleton;
5 | import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.event.EventHandler;
8 | import org.bukkit.event.EventPriority;
9 | import org.bukkit.event.Listener;
10 | import org.bukkit.event.player.PlayerToggleSneakEvent;
11 | import org.jetbrains.annotations.NotNull;
12 |
13 | @Singleton
14 | public class PlayerListener implements Listener {
15 |
16 | private final FakeplayerManager manager;
17 |
18 | @Inject
19 | public PlayerListener(FakeplayerManager manager) {
20 | this.manager = manager;
21 | }
22 |
23 | /**
24 | * 玩家蹲伏时取消假人骑乘
25 | */
26 | @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
27 | public void onSneak(@NotNull PlayerToggleSneakEvent event) {
28 | var player = event.getPlayer();
29 | var passengers = player.getPassengers();
30 | if (passengers.isEmpty()) {
31 | return;
32 | }
33 |
34 | for (var passenger : passengers) {
35 | if (!(passenger instanceof Player target)) {
36 | continue;
37 | }
38 | if (manager.isFake(target)) {
39 | player.removePassenger(target);
40 | }
41 | }
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21/src/main/java/io/github/hello09x/fakeplayer/v1_21/spi/NMSServerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21.spi;
2 |
3 | import com.mojang.authlib.GameProfile;
4 | import io.github.hello09x.devtools.core.utils.WorldUtils;
5 | import io.github.hello09x.fakeplayer.api.spi.NMSServer;
6 | import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer;
7 | import lombok.Getter;
8 | import net.minecraft.server.MinecraftServer;
9 | import net.minecraft.server.level.ClientInformation;
10 | import net.minecraft.server.level.ServerPlayer;
11 | import org.bukkit.Bukkit;
12 | import org.bukkit.Server;
13 | import org.bukkit.craftbukkit.v1_21_R1.CraftServer;
14 | import org.jetbrains.annotations.NotNull;
15 |
16 | import java.util.UUID;
17 |
18 | public class NMSServerImpl implements NMSServer {
19 |
20 |
21 | @Getter
22 | private final MinecraftServer handle;
23 |
24 | public NMSServerImpl(@NotNull Server server) {
25 | this.handle = ((CraftServer) server).getServer();
26 | }
27 |
28 | @Override
29 | public @NotNull NMSServerPlayer newPlayer(@NotNull UUID uuid, @NotNull String name) {
30 | var handle = new ServerPlayer(
31 | new NMSServerImpl(Bukkit.getServer()).getHandle(),
32 | new NMSServerLevelImpl(WorldUtils.getMainWorld()).getHandle(),
33 | new GameProfile(uuid, name),
34 | ClientInformation.createDefault()
35 | );
36 | return new NMSServerPlayerImpl(handle.getBukkitEntity());
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_2/src/main/java/io/github/hello09x/fakeplayer/v1_20_2/spi/NMSServerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_2.spi;
2 |
3 | import com.mojang.authlib.GameProfile;
4 | import io.github.hello09x.devtools.core.utils.WorldUtils;
5 | import io.github.hello09x.fakeplayer.api.spi.NMSServer;
6 | import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer;
7 | import lombok.Getter;
8 | import net.minecraft.server.MinecraftServer;
9 | import net.minecraft.server.level.ClientInformation;
10 | import net.minecraft.server.level.ServerPlayer;
11 | import org.bukkit.Bukkit;
12 | import org.bukkit.Server;
13 | import org.bukkit.craftbukkit.v1_20_R2.CraftServer;
14 | import org.jetbrains.annotations.NotNull;
15 |
16 | import java.util.UUID;
17 |
18 | public class NMSServerImpl implements NMSServer {
19 |
20 |
21 | @Getter
22 | private final MinecraftServer handle;
23 |
24 | public NMSServerImpl(@NotNull Server server) {
25 | this.handle = ((CraftServer) server).getServer();
26 | }
27 |
28 | @Override
29 | public @NotNull NMSServerPlayer newPlayer(@NotNull UUID uuid, @NotNull String name) {
30 | var handle = new ServerPlayer(
31 | new NMSServerImpl(Bukkit.getServer()).getHandle(),
32 | new NMSServerLevelImpl(WorldUtils.getMainWorld()).getHandle(),
33 | new GameProfile(uuid, name),
34 | ClientInformation.createDefault()
35 | );
36 | return new NMSServerPlayerImpl(handle.getBukkitEntity());
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_4/src/main/java/io/github/hello09x/fakeplayer/v1_20_4/spi/NMSServerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_4.spi;
2 |
3 | import com.mojang.authlib.GameProfile;
4 | import io.github.hello09x.devtools.core.utils.WorldUtils;
5 | import io.github.hello09x.fakeplayer.api.spi.NMSServer;
6 | import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer;
7 | import lombok.Getter;
8 | import net.minecraft.server.MinecraftServer;
9 | import net.minecraft.server.level.ClientInformation;
10 | import net.minecraft.server.level.ServerPlayer;
11 | import org.bukkit.Bukkit;
12 | import org.bukkit.Server;
13 | import org.bukkit.craftbukkit.v1_20_R3.CraftServer;
14 | import org.jetbrains.annotations.NotNull;
15 |
16 | import java.util.UUID;
17 |
18 | public class NMSServerImpl implements NMSServer {
19 |
20 |
21 | @Getter
22 | private final MinecraftServer handle;
23 |
24 | public NMSServerImpl(@NotNull Server server) {
25 | this.handle = ((CraftServer) server).getServer();
26 | }
27 |
28 | @Override
29 | public @NotNull NMSServerPlayer newPlayer(@NotNull UUID uuid, @NotNull String name) {
30 | var handle = new ServerPlayer(
31 | new NMSServerImpl(Bukkit.getServer()).getHandle(),
32 | new NMSServerLevelImpl(WorldUtils.getMainWorld()).getHandle(),
33 | new GameProfile(uuid, name),
34 | ClientInformation.createDefault()
35 | );
36 | return new NMSServerPlayerImpl(handle.getBukkitEntity());
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_6/src/main/java/io/github/hello09x/fakeplayer/v1_20_6/spi/NMSServerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_6.spi;
2 |
3 | import com.mojang.authlib.GameProfile;
4 | import io.github.hello09x.devtools.core.utils.WorldUtils;
5 | import io.github.hello09x.fakeplayer.api.spi.NMSServer;
6 | import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer;
7 | import lombok.Getter;
8 | import net.minecraft.server.MinecraftServer;
9 | import net.minecraft.server.level.ClientInformation;
10 | import net.minecraft.server.level.ServerPlayer;
11 | import org.bukkit.Bukkit;
12 | import org.bukkit.Server;
13 | import org.bukkit.craftbukkit.v1_20_R4.CraftServer;
14 | import org.jetbrains.annotations.NotNull;
15 |
16 | import java.util.UUID;
17 |
18 | public class NMSServerImpl implements NMSServer {
19 |
20 |
21 | @Getter
22 | private final MinecraftServer handle;
23 |
24 | public NMSServerImpl(@NotNull Server server) {
25 | this.handle = ((CraftServer) server).getServer();
26 | }
27 |
28 | @Override
29 | public @NotNull NMSServerPlayer newPlayer(@NotNull UUID uuid, @NotNull String name) {
30 | var handle = new ServerPlayer(
31 | new NMSServerImpl(Bukkit.getServer()).getHandle(),
32 | new NMSServerLevelImpl(WorldUtils.getMainWorld()).getHandle(),
33 | new GameProfile(uuid, name),
34 | ClientInformation.createDefault()
35 | );
36 | return new NMSServerPlayerImpl(handle.getBukkitEntity());
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_3/src/main/java/io/github/hello09x/fakeplayer/v1_21_3/spi/NMSServerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_3.spi;
2 |
3 | import com.mojang.authlib.GameProfile;
4 | import io.github.hello09x.devtools.core.utils.WorldUtils;
5 | import io.github.hello09x.fakeplayer.api.spi.NMSServer;
6 | import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer;
7 | import lombok.Getter;
8 | import net.minecraft.server.MinecraftServer;
9 | import net.minecraft.server.level.ClientInformation;
10 | import net.minecraft.server.level.ServerPlayer;
11 | import org.bukkit.Bukkit;
12 | import org.bukkit.Server;
13 | import org.bukkit.craftbukkit.v1_21_R2.CraftServer;
14 | import org.jetbrains.annotations.NotNull;
15 |
16 | import java.util.UUID;
17 |
18 | public class NMSServerImpl implements NMSServer {
19 |
20 |
21 | @Getter
22 | private final MinecraftServer handle;
23 |
24 | public NMSServerImpl(@NotNull Server server) {
25 | this.handle = ((CraftServer) server).getServer();
26 | }
27 |
28 | @Override
29 | public @NotNull NMSServerPlayer newPlayer(@NotNull UUID uuid, @NotNull String name) {
30 | var handle = new ServerPlayer(
31 | new NMSServerImpl(Bukkit.getServer()).getHandle(),
32 | new NMSServerLevelImpl(WorldUtils.getMainWorld()).getHandle(),
33 | new GameProfile(uuid, name),
34 | ClientInformation.createDefault()
35 | );
36 | return new NMSServerPlayerImpl(handle.getBukkitEntity());
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_4/src/main/java/io/github/hello09x/fakeplayer/v1_21_4/spi/NMSServerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_4.spi;
2 |
3 | import com.mojang.authlib.GameProfile;
4 | import io.github.hello09x.devtools.core.utils.WorldUtils;
5 | import io.github.hello09x.fakeplayer.api.spi.NMSServer;
6 | import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer;
7 | import lombok.Getter;
8 | import net.minecraft.server.MinecraftServer;
9 | import net.minecraft.server.level.ClientInformation;
10 | import net.minecraft.server.level.ServerPlayer;
11 | import org.bukkit.Bukkit;
12 | import org.bukkit.Server;
13 | import org.bukkit.craftbukkit.v1_21_R3.CraftServer;
14 | import org.jetbrains.annotations.NotNull;
15 |
16 | import java.util.UUID;
17 |
18 | public class NMSServerImpl implements NMSServer {
19 |
20 |
21 | @Getter
22 | private final MinecraftServer handle;
23 |
24 | public NMSServerImpl(@NotNull Server server) {
25 | this.handle = ((CraftServer) server).getServer();
26 | }
27 |
28 | @Override
29 | public @NotNull NMSServerPlayer newPlayer(@NotNull UUID uuid, @NotNull String name) {
30 | var handle = new ServerPlayer(
31 | new NMSServerImpl(Bukkit.getServer()).getHandle(),
32 | new NMSServerLevelImpl(WorldUtils.getMainWorld()).getHandle(),
33 | new GameProfile(uuid, name),
34 | ClientInformation.createDefault()
35 | );
36 | return new NMSServerPlayerImpl(handle.getBukkitEntity());
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_5/src/main/java/io/github/hello09x/fakeplayer/v1_21_5/spi/NMSServerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_5.spi;
2 |
3 | import com.mojang.authlib.GameProfile;
4 | import io.github.hello09x.devtools.core.utils.WorldUtils;
5 | import io.github.hello09x.fakeplayer.api.spi.NMSServer;
6 | import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer;
7 | import lombok.Getter;
8 | import net.minecraft.server.MinecraftServer;
9 | import net.minecraft.server.level.ClientInformation;
10 | import net.minecraft.server.level.ServerPlayer;
11 | import org.bukkit.Bukkit;
12 | import org.bukkit.Server;
13 | import org.bukkit.craftbukkit.v1_21_R4.CraftServer;
14 | import org.jetbrains.annotations.NotNull;
15 |
16 | import java.util.UUID;
17 |
18 | public class NMSServerImpl implements NMSServer {
19 |
20 |
21 | @Getter
22 | private final MinecraftServer handle;
23 |
24 | public NMSServerImpl(@NotNull Server server) {
25 | this.handle = ((CraftServer) server).getServer();
26 | }
27 |
28 | @Override
29 | public @NotNull NMSServerPlayer newPlayer(@NotNull UUID uuid, @NotNull String name) {
30 | var handle = new ServerPlayer(
31 | new NMSServerImpl(Bukkit.getServer()).getHandle(),
32 | new NMSServerLevelImpl(WorldUtils.getMainWorld()).getHandle(),
33 | new GameProfile(uuid, name),
34 | ClientInformation.createDefault()
35 | );
36 | return new NMSServerPlayerImpl(handle.getBukkitEntity());
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_6/src/main/java/io/github/hello09x/fakeplayer/v1_21_6/spi/NMSServerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_6.spi;
2 |
3 | import com.mojang.authlib.GameProfile;
4 | import io.github.hello09x.devtools.core.utils.WorldUtils;
5 | import io.github.hello09x.fakeplayer.api.spi.NMSServer;
6 | import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer;
7 | import lombok.Getter;
8 | import net.minecraft.server.MinecraftServer;
9 | import net.minecraft.server.level.ClientInformation;
10 | import net.minecraft.server.level.ServerPlayer;
11 | import org.bukkit.Bukkit;
12 | import org.bukkit.Server;
13 | import org.bukkit.craftbukkit.v1_21_R5.CraftServer;
14 | import org.jetbrains.annotations.NotNull;
15 |
16 | import java.util.UUID;
17 |
18 | public class NMSServerImpl implements NMSServer {
19 |
20 |
21 | @Getter
22 | private final MinecraftServer handle;
23 |
24 | public NMSServerImpl(@NotNull Server server) {
25 | this.handle = ((CraftServer) server).getServer();
26 | }
27 |
28 | @Override
29 | public @NotNull NMSServerPlayer newPlayer(@NotNull UUID uuid, @NotNull String name) {
30 | var handle = new ServerPlayer(
31 | new NMSServerImpl(Bukkit.getServer()).getHandle(),
32 | new NMSServerLevelImpl(WorldUtils.getMainWorld()).getHandle(),
33 | new GameProfile(uuid, name),
34 | ClientInformation.createDefault()
35 | );
36 | return new NMSServerPlayerImpl(handle.getBukkitEntity());
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_9/src/main/java/io/github/hello09x/fakeplayer/v1_21_9/spi/NMSServerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_9.spi;
2 |
3 | import com.mojang.authlib.GameProfile;
4 | import io.github.hello09x.devtools.core.utils.WorldUtils;
5 | import io.github.hello09x.fakeplayer.api.spi.NMSServer;
6 | import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer;
7 | import lombok.Getter;
8 | import net.minecraft.server.MinecraftServer;
9 | import net.minecraft.server.level.ClientInformation;
10 | import net.minecraft.server.level.ServerPlayer;
11 | import org.bukkit.Bukkit;
12 | import org.bukkit.Server;
13 | import org.bukkit.craftbukkit.v1_21_R6.CraftServer;
14 | import org.jetbrains.annotations.NotNull;
15 |
16 | import java.util.UUID;
17 |
18 | public class NMSServerImpl implements NMSServer {
19 |
20 |
21 | @Getter
22 | private final MinecraftServer handle;
23 |
24 | public NMSServerImpl(@NotNull Server server) {
25 | this.handle = ((CraftServer) server).getServer();
26 | }
27 |
28 | @Override
29 | public @NotNull NMSServerPlayer newPlayer(@NotNull UUID uuid, @NotNull String name) {
30 | var handle = new ServerPlayer(
31 | new NMSServerImpl(Bukkit.getServer()).getHandle(),
32 | new NMSServerLevelImpl(WorldUtils.getMainWorld()).getHandle(),
33 | new GameProfile(uuid, name),
34 | ClientInformation.createDefault()
35 | );
36 | return new NMSServerPlayerImpl(handle.getBukkitEntity());
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/KillCommand.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.command.impl;
2 |
3 | import com.google.inject.Singleton;
4 | import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
5 | import dev.jorel.commandapi.executors.CommandArguments;
6 | import org.bukkit.command.CommandSender;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | import java.util.StringJoiner;
10 |
11 | import static net.kyori.adventure.text.Component.*;
12 | import static net.kyori.adventure.text.format.NamedTextColor.GRAY;
13 |
14 | @Singleton
15 | public class KillCommand extends AbstractCommand {
16 |
17 | /**
18 | * 移除假人
19 | */
20 | public void kill(@NotNull CommandSender sender, @NotNull CommandArguments args) throws WrapperCommandSyntaxException {
21 | var fakes = super.getFakeplayers(sender, args);
22 |
23 | if (fakes.isEmpty()) {
24 | sender.sendMessage(translatable("fakeplayer.command.kill.error.non-removed", GRAY));
25 | return;
26 | }
27 |
28 | var names = new StringJoiner(", ");
29 | for (var fake : fakes) {
30 | if (manager.remove(fake.getName(), "command kill")) {
31 | names.add(fake.getName());
32 | }
33 | }
34 | sender.sendMessage(textOfChildren(
35 | translatable("fakeplayer.command.kill.success.removed", GRAY),
36 | space(),
37 | text(names.toString())
38 | ));
39 | }
40 |
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_2/src/main/java/io/github/hello09x/fakeplayer/v1_20_2/network/FakeConnection.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_2.network;
2 |
3 | import io.github.hello09x.fakeplayer.core.network.FakeChannel;
4 | import net.minecraft.network.Connection;
5 | import net.minecraft.network.ConnectionProtocol;
6 | import net.minecraft.network.PacketSendListener;
7 | import net.minecraft.network.protocol.Packet;
8 | import net.minecraft.network.protocol.PacketFlow;
9 | import org.jetbrains.annotations.NotNull;
10 |
11 | import java.net.InetAddress;
12 |
13 | public class FakeConnection extends Connection {
14 |
15 | public FakeConnection(@NotNull InetAddress address) {
16 | super(PacketFlow.SERVERBOUND);
17 | this.channel = new FakeChannel(null, address);
18 | this.address = this.channel.remoteAddress();
19 | Connection.configureSerialization(this.channel.pipeline(), PacketFlow.SERVERBOUND, null);
20 | }
21 |
22 | @Override
23 | public boolean isConnected() {
24 | return true;
25 | }
26 |
27 | @Override
28 | public void send(Packet> packet, PacketSendListener listener) {
29 | }
30 |
31 | @Override
32 | public void send(Packet> packet) {
33 | }
34 |
35 | public void setProtocolAttr(@NotNull ConnectionProtocol protocol) {
36 | this.channel.attr(Connection.ATTRIBUTE_SERVERBOUND_PROTOCOL).set(protocol.codec(PacketFlow.SERVERBOUND));
37 | this.channel.attr(Connection.ATTRIBUTE_CLIENTBOUND_PROTOCOL).set(protocol.codec(PacketFlow.CLIENTBOUND));
38 | }
39 |
40 | }
--------------------------------------------------------------------------------
/fakeplayer-v1_20_4/src/main/java/io/github/hello09x/fakeplayer/v1_20_4/network/FakeConnection.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_4.network;
2 |
3 | import io.github.hello09x.fakeplayer.core.network.FakeChannel;
4 | import net.minecraft.network.Connection;
5 | import net.minecraft.network.ConnectionProtocol;
6 | import net.minecraft.network.PacketSendListener;
7 | import net.minecraft.network.protocol.Packet;
8 | import net.minecraft.network.protocol.PacketFlow;
9 | import org.jetbrains.annotations.NotNull;
10 |
11 | import java.net.InetAddress;
12 |
13 | public class FakeConnection extends Connection {
14 |
15 | public FakeConnection(@NotNull InetAddress address) {
16 | super(PacketFlow.SERVERBOUND);
17 | this.channel = new FakeChannel(null, address);
18 | this.address = this.channel.remoteAddress();
19 | Connection.configureSerialization(this.channel.pipeline(), PacketFlow.SERVERBOUND, null);
20 | }
21 |
22 | @Override
23 | public boolean isConnected() {
24 | return true;
25 | }
26 |
27 | @Override
28 | public void send(Packet> packet, PacketSendListener listener) {
29 | }
30 |
31 | @Override
32 | public void send(Packet> packet) {
33 | }
34 |
35 | public void setProtocolAttr(@NotNull ConnectionProtocol protocol) {
36 | this.channel.attr(Connection.ATTRIBUTE_SERVERBOUND_PROTOCOL).set(protocol.codec(PacketFlow.SERVERBOUND));
37 | this.channel.attr(Connection.ATTRIBUTE_CLIENTBOUND_PROTOCOL).set(protocol.codec(PacketFlow.CLIENTBOUND));
38 | }
39 |
40 | }
--------------------------------------------------------------------------------
/fakeplayer-v1_21/src/main/java/io/github/hello09x/fakeplayer/v1_21/network/FakeConnection.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21.network;
2 |
3 | import io.github.hello09x.fakeplayer.core.Main;
4 | import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
5 | import io.github.hello09x.fakeplayer.core.network.FakeChannel;
6 | import net.minecraft.network.Connection;
7 | import net.minecraft.network.PacketSendListener;
8 | import net.minecraft.network.protocol.Packet;
9 | import net.minecraft.network.protocol.PacketFlow;
10 | import org.jetbrains.annotations.NotNull;
11 | import org.jetbrains.annotations.Nullable;
12 |
13 | import java.net.InetAddress;
14 | import java.util.logging.Logger;
15 |
16 | public class FakeConnection extends Connection {
17 |
18 | private final static Logger log = Main.getInstance().getLogger();
19 | private final FakeplayerManager manager = Main.getInjector().getInstance(FakeplayerManager.class);
20 |
21 | public FakeConnection(@NotNull InetAddress address) {
22 | super(PacketFlow.SERVERBOUND);
23 | this.channel = new FakeChannel(null, address);
24 | this.address = this.channel.remoteAddress();
25 | Connection.configureSerialization(this.channel.pipeline(), PacketFlow.SERVERBOUND, false, null);
26 | }
27 |
28 | @Override
29 | public boolean isConnected() {
30 | return true;
31 | }
32 |
33 | @Override
34 | public void send(Packet> packet, @Nullable PacketSendListener listener) {
35 |
36 | }
37 |
38 | @Override
39 | public void send(Packet> packet) {
40 |
41 | }
42 |
43 | }
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/SleepCommand.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.command.impl;
2 |
3 | import com.google.inject.Singleton;
4 | import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
5 | import dev.jorel.commandapi.executors.CommandArguments;
6 | import io.github.hello09x.devtools.core.utils.BlockUtils;
7 | import org.bukkit.block.data.type.Bed;
8 | import org.bukkit.command.CommandSender;
9 | import org.jetbrains.annotations.NotNull;
10 |
11 | @Singleton
12 | public class SleepCommand extends AbstractCommand {
13 |
14 | /**
15 | * 睡觉
16 | */
17 | public void sleep(@NotNull CommandSender sender, @NotNull CommandArguments args) throws WrapperCommandSyntaxException {
18 | var fake = getFakeplayer(sender, args);
19 | var bed = BlockUtils.getNearbyBlock(fake.getLocation(), 4, block -> {
20 | if (!(block.getBlockData() instanceof Bed data)) {
21 | return false;
22 | }
23 |
24 | return !data.isOccupied() && data.getPart() == Bed.Part.HEAD;
25 | });
26 | if (bed == null) {
27 | return;
28 | }
29 |
30 | fake.sleep(bed.getLocation(), false);
31 | }
32 |
33 | /**
34 | * 起床
35 | */
36 | public void wakeup(@NotNull CommandSender sender, @NotNull CommandArguments args) throws WrapperCommandSyntaxException {
37 | var target = getFakeplayer(sender, args);
38 | if (!target.isSleeping()) {
39 | return;
40 | }
41 |
42 | target.wakeup(true);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_3/src/main/java/io/github/hello09x/fakeplayer/v1_21_3/network/FakeConnection.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_3.network;
2 |
3 | import io.github.hello09x.fakeplayer.core.Main;
4 | import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
5 | import io.github.hello09x.fakeplayer.core.network.FakeChannel;
6 | import net.minecraft.network.Connection;
7 | import net.minecraft.network.PacketSendListener;
8 | import net.minecraft.network.protocol.Packet;
9 | import net.minecraft.network.protocol.PacketFlow;
10 | import org.jetbrains.annotations.NotNull;
11 | import org.jetbrains.annotations.Nullable;
12 |
13 | import java.net.InetAddress;
14 | import java.util.logging.Logger;
15 |
16 | public class FakeConnection extends Connection {
17 |
18 | private final static Logger log = Main.getInstance().getLogger();
19 | private final FakeplayerManager manager = Main.getInjector().getInstance(FakeplayerManager.class);
20 |
21 | public FakeConnection(@NotNull InetAddress address) {
22 | super(PacketFlow.SERVERBOUND);
23 | this.channel = new FakeChannel(null, address);
24 | this.address = this.channel.remoteAddress();
25 | Connection.configureSerialization(this.channel.pipeline(), PacketFlow.SERVERBOUND, false, null);
26 | }
27 |
28 | @Override
29 | public boolean isConnected() {
30 | return true;
31 | }
32 |
33 | @Override
34 | public void send(Packet> packet, @Nullable PacketSendListener listener) {
35 |
36 | }
37 |
38 | @Override
39 | public void send(Packet> packet) {
40 |
41 | }
42 |
43 | }
--------------------------------------------------------------------------------
/fakeplayer-v1_21_4/src/main/java/io/github/hello09x/fakeplayer/v1_21_4/network/FakeConnection.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_4.network;
2 |
3 | import io.github.hello09x.fakeplayer.core.Main;
4 | import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
5 | import io.github.hello09x.fakeplayer.core.network.FakeChannel;
6 | import net.minecraft.network.Connection;
7 | import net.minecraft.network.PacketSendListener;
8 | import net.minecraft.network.protocol.Packet;
9 | import net.minecraft.network.protocol.PacketFlow;
10 | import org.jetbrains.annotations.NotNull;
11 | import org.jetbrains.annotations.Nullable;
12 |
13 | import java.net.InetAddress;
14 | import java.util.logging.Logger;
15 |
16 | public class FakeConnection extends Connection {
17 |
18 | private final static Logger log = Main.getInstance().getLogger();
19 | private final FakeplayerManager manager = Main.getInjector().getInstance(FakeplayerManager.class);
20 |
21 | public FakeConnection(@NotNull InetAddress address) {
22 | super(PacketFlow.SERVERBOUND);
23 | this.channel = new FakeChannel(null, address);
24 | this.address = this.channel.remoteAddress();
25 | Connection.configureSerialization(this.channel.pipeline(), PacketFlow.SERVERBOUND, false, null);
26 | }
27 |
28 | @Override
29 | public boolean isConnected() {
30 | return true;
31 | }
32 |
33 | @Override
34 | public void send(Packet> packet, @Nullable PacketSendListener listener) {
35 |
36 | }
37 |
38 | @Override
39 | public void send(Packet> packet) {
40 |
41 | }
42 |
43 | }
--------------------------------------------------------------------------------
/fakeplayer-v1_21_5/src/main/java/io/github/hello09x/fakeplayer/v1_21_5/network/FakeConnection.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_5.network;
2 |
3 | import io.github.hello09x.fakeplayer.core.Main;
4 | import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
5 | import io.github.hello09x.fakeplayer.core.network.FakeChannel;
6 | import net.minecraft.network.Connection;
7 | import net.minecraft.network.PacketSendListener;
8 | import net.minecraft.network.protocol.Packet;
9 | import net.minecraft.network.protocol.PacketFlow;
10 | import org.jetbrains.annotations.NotNull;
11 | import org.jetbrains.annotations.Nullable;
12 |
13 | import java.net.InetAddress;
14 | import java.util.logging.Logger;
15 |
16 | public class FakeConnection extends Connection {
17 |
18 | private final static Logger log = Main.getInstance().getLogger();
19 | private final FakeplayerManager manager = Main.getInjector().getInstance(FakeplayerManager.class);
20 |
21 | public FakeConnection(@NotNull InetAddress address) {
22 | super(PacketFlow.SERVERBOUND);
23 | this.channel = new FakeChannel(null, address);
24 | this.address = this.channel.remoteAddress();
25 | Connection.configureSerialization(this.channel.pipeline(), PacketFlow.SERVERBOUND, false, null);
26 | }
27 |
28 | @Override
29 | public boolean isConnected() {
30 | return true;
31 | }
32 |
33 | @Override
34 | public void send(Packet> packet, @Nullable PacketSendListener listener) {
35 |
36 | }
37 |
38 | @Override
39 | public void send(Packet> packet) {
40 |
41 | }
42 |
43 | }
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/manager/naming/NameSource.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.manager.naming;
2 |
3 | import java.util.Collections;
4 | import java.util.LinkedList;
5 |
6 | public class NameSource {
7 |
8 | /**
9 | * 接下来可以使用的名称序号
10 | */
11 | private final LinkedList names;
12 |
13 | /**
14 | * 容量
15 | */
16 | private int capacity;
17 |
18 | public NameSource(int initializeCapacity) {
19 | this.capacity = initializeCapacity;
20 | this.names = new LinkedList<>();
21 | for (int i = 0; i < initializeCapacity; i++) {
22 | names.add(i);
23 | }
24 | }
25 |
26 | public NameSource() {
27 | this(0);
28 | }
29 |
30 | /**
31 | * 获取一个可使用的名称序号
32 | *
33 | * @return 名称序号
34 | */
35 | public int pop() {
36 | if (names.isEmpty()) {
37 | var newCapacity = capacity * 2;
38 | for (int i = capacity; i < newCapacity; i++) {
39 | names.add(i);
40 | }
41 | this.capacity = newCapacity;
42 | }
43 | return names.pop();
44 | }
45 |
46 | /**
47 | * 归还一个名称序号
48 | *
49 | * @param i 名称序号
50 | */
51 | public void push(int i) {
52 | if (i >= capacity) {
53 | return;
54 | }
55 |
56 | if (names.contains(i)) {
57 | return;
58 | }
59 |
60 | names.push(i);
61 | this.sort();
62 | }
63 |
64 | public void sort() {
65 | Collections.sort(this.names);
66 | }
67 |
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/DebugCommand.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.command.impl;
2 |
3 | import com.google.common.io.ByteStreams;
4 | import com.google.inject.Inject;
5 | import com.google.inject.Singleton;
6 | import dev.jorel.commandapi.executors.CommandArguments;
7 | import io.github.hello09x.fakeplayer.api.spi.NMSBridge;
8 | import io.github.hello09x.fakeplayer.core.Main;
9 | import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
10 | import org.bukkit.Bukkit;
11 | import org.bukkit.command.CommandSender;
12 | import org.bukkit.entity.Player;
13 | import org.jetbrains.annotations.NotNull;
14 |
15 |
16 | /**
17 | * @author tanyaofei
18 | * @since 2024/7/26
19 | **/
20 | @Singleton
21 | public class DebugCommand {
22 |
23 | private final FakeplayerManager manager;
24 | private final NMSBridge bridge;
25 |
26 | @Inject
27 | public DebugCommand(FakeplayerManager manager, NMSBridge bridge) {
28 | this.manager = manager;
29 | this.bridge = bridge;
30 | }
31 |
32 | public void sendPluginMessage(@NotNull CommandSender sender, @NotNull CommandArguments args) {
33 | var player = (Player) args.get("player");
34 | var channel = (String) args.get("channel");
35 | var message = (String) args.get("message");
36 | Bukkit.getServer().getMessenger().registerOutgoingPluginChannel(Main.getInstance(), channel);
37 |
38 | var msg = ByteStreams.newDataOutput();
39 | msg.writeUTF(message);
40 | player.sendPluginMessage(Main.getInstance(), channel, msg.toByteArray());
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/manager/invsee/OpenInvInvseeManagerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.manager.invsee;
2 |
3 | import com.google.common.base.Throwables;
4 | import com.lishid.openinv.IOpenInv;
5 | import io.github.hello09x.fakeplayer.core.Main;
6 | import io.github.hello09x.fakeplayer.core.manager.FakeplayerList;
7 | import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
8 | import org.bukkit.Bukkit;
9 | import org.bukkit.entity.Player;
10 | import org.bukkit.inventory.InventoryView;
11 | import org.jetbrains.annotations.NotNull;
12 |
13 | import java.util.logging.Logger;
14 |
15 | /**
16 | * @author tanyaofei
17 | * @since 2024/8/12
18 | **/
19 | public class OpenInvInvseeManagerImpl extends AbstractInvseeManager {
20 |
21 | private final static Logger log = Main.getInstance().getLogger();
22 | private final IOpenInv openInv;
23 |
24 | public OpenInvInvseeManagerImpl(FakeplayerManager manager, FakeplayerList fakeplayerList) {
25 | super(manager, fakeplayerList);
26 | this.openInv = (IOpenInv) Bukkit.getPluginManager().getPlugin("OpenInv");
27 | }
28 |
29 | @Override
30 | protected InventoryView openInventory(@NotNull Player viewer, @NotNull Player whom) {
31 | try {
32 | return openInv.openInventory(viewer, openInv.getSpecialInventory(whom, true));
33 | } catch (InstantiationException e) {
34 | log.warning("Failed to %s's open inventory for %s\n%s".formatted(whom.getName(), viewer.getName(), Throwables.getStackTraceAsString(e)));
35 | return null;
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/ExpmeCommand.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.command.impl;
2 |
3 |
4 | import com.google.inject.Singleton;
5 | import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
6 | import dev.jorel.commandapi.executors.CommandArguments;
7 | import io.github.hello09x.devtools.core.utils.ExperienceUtils;
8 | import org.bukkit.entity.Player;
9 | import org.jetbrains.annotations.NotNull;
10 |
11 | import static net.kyori.adventure.text.Component.text;
12 | import static net.kyori.adventure.text.Component.translatable;
13 | import static net.kyori.adventure.text.format.NamedTextColor.*;
14 |
15 | @Singleton
16 | public class ExpmeCommand extends AbstractCommand {
17 |
18 | public void expme(@NotNull Player sender, @NotNull CommandArguments args) throws WrapperCommandSyntaxException {
19 | var fake = getFakeplayer(sender, args);
20 | var exp = ExperienceUtils.getExp(fake);
21 |
22 | if (exp == 0) {
23 | sender.sendMessage(
24 | translatable(
25 | "fakeplayer.command.expme.error.non-experience",
26 | text(fake.getName(), WHITE)
27 | ).color(GRAY)
28 | );
29 | return;
30 | }
31 |
32 | ExperienceUtils.clean(fake);
33 | sender.giveExp(exp, false);
34 | sender.sendMessage(translatable(
35 | "fakeplayer.command.expme.success",
36 | text(fake.getName(), WHITE),
37 | text(exp, DARK_GREEN)
38 | ).color(GRAY));
39 | }
40 |
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21/src/main/java/io/github/hello09x/fakeplayer/v1_21/spi/ActionTickerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21.spi;
2 |
3 |
4 | import io.github.hello09x.fakeplayer.api.spi.ActionSetting;
5 | import io.github.hello09x.fakeplayer.api.spi.ActionTicker;
6 | import io.github.hello09x.fakeplayer.api.spi.ActionType;
7 | import io.github.hello09x.fakeplayer.api.spi.NMSBridge;
8 | import io.github.hello09x.fakeplayer.core.entity.action.BaseActionTicker;
9 | import io.github.hello09x.fakeplayer.v1_21.action.AttackAction;
10 | import io.github.hello09x.fakeplayer.v1_21.action.MineAction;
11 | import io.github.hello09x.fakeplayer.v1_21.action.UseAction;
12 | import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer;
13 | import org.bukkit.entity.Player;
14 | import org.jetbrains.annotations.NotNull;
15 |
16 | public class ActionTickerImpl extends BaseActionTicker implements ActionTicker {
17 |
18 | public ActionTickerImpl(@NotNull NMSBridge nms, @NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
19 | super(nms, player, action, setting);
20 | if (this.action == null) {
21 | this.action = switch (action) {
22 | case ATTACK -> new AttackAction(((CraftPlayer) player).getHandle());
23 | case MINE -> new MineAction(((CraftPlayer) player).getHandle());
24 | case USE -> new UseAction(((CraftPlayer) player).getHandle());
25 | case JUMP, LOOK_AT_NEAREST_ENTITY, DROP_INVENTORY, DROP_STACK, DROP_ITEM ->
26 | throw new UnsupportedOperationException();
27 | };
28 | }
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_2/src/main/java/io/github/hello09x/fakeplayer/v1_20_2/spi/ActionTickerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_2.spi;
2 |
3 |
4 | import io.github.hello09x.fakeplayer.api.spi.ActionSetting;
5 | import io.github.hello09x.fakeplayer.api.spi.ActionTicker;
6 | import io.github.hello09x.fakeplayer.api.spi.ActionType;
7 | import io.github.hello09x.fakeplayer.api.spi.NMSBridge;
8 | import io.github.hello09x.fakeplayer.core.entity.action.BaseActionTicker;
9 | import io.github.hello09x.fakeplayer.v1_20_2.action.AttackAction;
10 | import io.github.hello09x.fakeplayer.v1_20_2.action.MineAction;
11 | import io.github.hello09x.fakeplayer.v1_20_2.action.UseAction;
12 | import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer;
13 | import org.bukkit.entity.Player;
14 | import org.jetbrains.annotations.NotNull;
15 |
16 | public class ActionTickerImpl extends BaseActionTicker implements ActionTicker {
17 |
18 | public ActionTickerImpl(@NotNull NMSBridge nms, @NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
19 | super(nms, player, action, setting);
20 | if (this.action == null) {
21 | this.action = switch (action) {
22 | case ATTACK -> new AttackAction(((CraftPlayer) player).getHandle());
23 | case MINE -> new MineAction(((CraftPlayer) player).getHandle());
24 | case USE -> new UseAction(((CraftPlayer) player).getHandle());
25 | case JUMP, LOOK_AT_NEAREST_ENTITY, DROP_INVENTORY, DROP_STACK, DROP_ITEM ->
26 | throw new UnsupportedOperationException();
27 | };
28 | }
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_4/src/main/java/io/github/hello09x/fakeplayer/v1_20_4/spi/ActionTickerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_4.spi;
2 |
3 |
4 | import io.github.hello09x.fakeplayer.api.spi.ActionSetting;
5 | import io.github.hello09x.fakeplayer.api.spi.ActionTicker;
6 | import io.github.hello09x.fakeplayer.api.spi.ActionType;
7 | import io.github.hello09x.fakeplayer.api.spi.NMSBridge;
8 | import io.github.hello09x.fakeplayer.core.entity.action.BaseActionTicker;
9 | import io.github.hello09x.fakeplayer.v1_20_4.action.AttackAction;
10 | import io.github.hello09x.fakeplayer.v1_20_4.action.MineAction;
11 | import io.github.hello09x.fakeplayer.v1_20_4.action.UseAction;
12 | import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
13 | import org.bukkit.entity.Player;
14 | import org.jetbrains.annotations.NotNull;
15 |
16 | public class ActionTickerImpl extends BaseActionTicker implements ActionTicker {
17 |
18 | public ActionTickerImpl(@NotNull NMSBridge nms, @NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
19 | super(nms, player, action, setting);
20 | if (this.action == null) {
21 | this.action = switch (action) {
22 | case ATTACK -> new AttackAction(((CraftPlayer) player).getHandle());
23 | case MINE -> new MineAction(((CraftPlayer) player).getHandle());
24 | case USE -> new UseAction(((CraftPlayer) player).getHandle());
25 | case JUMP, LOOK_AT_NEAREST_ENTITY, DROP_INVENTORY, DROP_STACK, DROP_ITEM ->
26 | throw new UnsupportedOperationException();
27 | };
28 | }
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_6/src/main/java/io/github/hello09x/fakeplayer/v1_20_6/spi/ActionTickerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_6.spi;
2 |
3 |
4 | import io.github.hello09x.fakeplayer.api.spi.ActionSetting;
5 | import io.github.hello09x.fakeplayer.api.spi.ActionTicker;
6 | import io.github.hello09x.fakeplayer.api.spi.ActionType;
7 | import io.github.hello09x.fakeplayer.api.spi.NMSBridge;
8 | import io.github.hello09x.fakeplayer.core.entity.action.BaseActionTicker;
9 | import io.github.hello09x.fakeplayer.v1_20_6.action.AttackAction;
10 | import io.github.hello09x.fakeplayer.v1_20_6.action.MineAction;
11 | import io.github.hello09x.fakeplayer.v1_20_6.action.UseAction;
12 | import org.bukkit.craftbukkit.v1_20_R4.entity.CraftPlayer;
13 | import org.bukkit.entity.Player;
14 | import org.jetbrains.annotations.NotNull;
15 |
16 | public class ActionTickerImpl extends BaseActionTicker implements ActionTicker {
17 |
18 | public ActionTickerImpl(@NotNull NMSBridge nms, @NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
19 | super(nms, player, action, setting);
20 | if (this.action == null) {
21 | this.action = switch (action) {
22 | case ATTACK -> new AttackAction(((CraftPlayer) player).getHandle());
23 | case MINE -> new MineAction(((CraftPlayer) player).getHandle());
24 | case USE -> new UseAction(((CraftPlayer) player).getHandle());
25 | case JUMP, LOOK_AT_NEAREST_ENTITY, DROP_INVENTORY, DROP_STACK, DROP_ITEM ->
26 | throw new UnsupportedOperationException();
27 | };
28 | }
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_3/src/main/java/io/github/hello09x/fakeplayer/v1_21_3/spi/ActionTickerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_3.spi;
2 |
3 |
4 | import io.github.hello09x.fakeplayer.api.spi.ActionSetting;
5 | import io.github.hello09x.fakeplayer.api.spi.ActionTicker;
6 | import io.github.hello09x.fakeplayer.api.spi.ActionType;
7 | import io.github.hello09x.fakeplayer.api.spi.NMSBridge;
8 | import io.github.hello09x.fakeplayer.core.entity.action.BaseActionTicker;
9 | import io.github.hello09x.fakeplayer.v1_21_3.action.AttackAction;
10 | import io.github.hello09x.fakeplayer.v1_21_3.action.MineAction;
11 | import io.github.hello09x.fakeplayer.v1_21_3.action.UseAction;
12 | import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer;
13 | import org.bukkit.entity.Player;
14 | import org.jetbrains.annotations.NotNull;
15 |
16 | public class ActionTickerImpl extends BaseActionTicker implements ActionTicker {
17 |
18 | public ActionTickerImpl(@NotNull NMSBridge nms, @NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
19 | super(nms, player, action, setting);
20 | if (this.action == null) {
21 | this.action = switch (action) {
22 | case ATTACK -> new AttackAction(((CraftPlayer) player).getHandle());
23 | case MINE -> new MineAction(((CraftPlayer) player).getHandle());
24 | case USE -> new UseAction(((CraftPlayer) player).getHandle());
25 | case JUMP, LOOK_AT_NEAREST_ENTITY, DROP_INVENTORY, DROP_STACK, DROP_ITEM ->
26 | throw new UnsupportedOperationException();
27 | };
28 | }
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_4/src/main/java/io/github/hello09x/fakeplayer/v1_21_4/spi/ActionTickerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_4.spi;
2 |
3 |
4 | import io.github.hello09x.fakeplayer.api.spi.ActionSetting;
5 | import io.github.hello09x.fakeplayer.api.spi.ActionTicker;
6 | import io.github.hello09x.fakeplayer.api.spi.ActionType;
7 | import io.github.hello09x.fakeplayer.api.spi.NMSBridge;
8 | import io.github.hello09x.fakeplayer.core.entity.action.BaseActionTicker;
9 | import io.github.hello09x.fakeplayer.v1_21_4.action.AttackAction;
10 | import io.github.hello09x.fakeplayer.v1_21_4.action.MineAction;
11 | import io.github.hello09x.fakeplayer.v1_21_4.action.UseAction;
12 | import org.bukkit.craftbukkit.v1_21_R3.entity.CraftPlayer;
13 | import org.bukkit.entity.Player;
14 | import org.jetbrains.annotations.NotNull;
15 |
16 | public class ActionTickerImpl extends BaseActionTicker implements ActionTicker {
17 |
18 | public ActionTickerImpl(@NotNull NMSBridge nms, @NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
19 | super(nms, player, action, setting);
20 | if (this.action == null) {
21 | this.action = switch (action) {
22 | case ATTACK -> new AttackAction(((CraftPlayer) player).getHandle());
23 | case MINE -> new MineAction(((CraftPlayer) player).getHandle());
24 | case USE -> new UseAction(((CraftPlayer) player).getHandle());
25 | case JUMP, LOOK_AT_NEAREST_ENTITY, DROP_INVENTORY, DROP_STACK, DROP_ITEM ->
26 | throw new UnsupportedOperationException();
27 | };
28 | }
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_5/src/main/java/io/github/hello09x/fakeplayer/v1_21_5/spi/ActionTickerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_5.spi;
2 |
3 |
4 | import io.github.hello09x.fakeplayer.api.spi.ActionSetting;
5 | import io.github.hello09x.fakeplayer.api.spi.ActionTicker;
6 | import io.github.hello09x.fakeplayer.api.spi.ActionType;
7 | import io.github.hello09x.fakeplayer.api.spi.NMSBridge;
8 | import io.github.hello09x.fakeplayer.core.entity.action.BaseActionTicker;
9 | import io.github.hello09x.fakeplayer.v1_21_5.action.AttackAction;
10 | import io.github.hello09x.fakeplayer.v1_21_5.action.MineAction;
11 | import io.github.hello09x.fakeplayer.v1_21_5.action.UseAction;
12 | import org.bukkit.craftbukkit.v1_21_R4.entity.CraftPlayer;
13 | import org.bukkit.entity.Player;
14 | import org.jetbrains.annotations.NotNull;
15 |
16 | public class ActionTickerImpl extends BaseActionTicker implements ActionTicker {
17 |
18 | public ActionTickerImpl(@NotNull NMSBridge nms, @NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
19 | super(nms, player, action, setting);
20 | if (this.action == null) {
21 | this.action = switch (action) {
22 | case ATTACK -> new AttackAction(((CraftPlayer) player).getHandle());
23 | case MINE -> new MineAction(((CraftPlayer) player).getHandle());
24 | case USE -> new UseAction(((CraftPlayer) player).getHandle());
25 | case JUMP, LOOK_AT_NEAREST_ENTITY, DROP_INVENTORY, DROP_STACK, DROP_ITEM ->
26 | throw new UnsupportedOperationException();
27 | };
28 | }
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_6/src/main/java/io/github/hello09x/fakeplayer/v1_21_6/spi/ActionTickerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_6.spi;
2 |
3 |
4 | import io.github.hello09x.fakeplayer.api.spi.ActionSetting;
5 | import io.github.hello09x.fakeplayer.api.spi.ActionTicker;
6 | import io.github.hello09x.fakeplayer.api.spi.ActionType;
7 | import io.github.hello09x.fakeplayer.api.spi.NMSBridge;
8 | import io.github.hello09x.fakeplayer.core.entity.action.BaseActionTicker;
9 | import io.github.hello09x.fakeplayer.v1_21_6.action.AttackAction;
10 | import io.github.hello09x.fakeplayer.v1_21_6.action.MineAction;
11 | import io.github.hello09x.fakeplayer.v1_21_6.action.UseAction;
12 | import org.bukkit.craftbukkit.v1_21_R5.entity.CraftPlayer;
13 | import org.bukkit.entity.Player;
14 | import org.jetbrains.annotations.NotNull;
15 |
16 | public class ActionTickerImpl extends BaseActionTicker implements ActionTicker {
17 |
18 | public ActionTickerImpl(@NotNull NMSBridge nms, @NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
19 | super(nms, player, action, setting);
20 | if (this.action == null) {
21 | this.action = switch (action) {
22 | case ATTACK -> new AttackAction(((CraftPlayer) player).getHandle());
23 | case MINE -> new MineAction(((CraftPlayer) player).getHandle());
24 | case USE -> new UseAction(((CraftPlayer) player).getHandle());
25 | case JUMP, LOOK_AT_NEAREST_ENTITY, DROP_INVENTORY, DROP_STACK, DROP_ITEM ->
26 | throw new UnsupportedOperationException();
27 | };
28 | }
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_9/src/main/java/io/github/hello09x/fakeplayer/v1_21_9/spi/ActionTickerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_9.spi;
2 |
3 |
4 | import io.github.hello09x.fakeplayer.api.spi.ActionSetting;
5 | import io.github.hello09x.fakeplayer.api.spi.ActionTicker;
6 | import io.github.hello09x.fakeplayer.api.spi.ActionType;
7 | import io.github.hello09x.fakeplayer.api.spi.NMSBridge;
8 | import io.github.hello09x.fakeplayer.core.entity.action.BaseActionTicker;
9 | import io.github.hello09x.fakeplayer.v1_21_9.action.AttackAction;
10 | import io.github.hello09x.fakeplayer.v1_21_9.action.MineAction;
11 | import io.github.hello09x.fakeplayer.v1_21_9.action.UseAction;
12 | import org.bukkit.craftbukkit.v1_21_R6.entity.CraftPlayer;
13 | import org.bukkit.entity.Player;
14 | import org.jetbrains.annotations.NotNull;
15 |
16 | public class ActionTickerImpl extends BaseActionTicker implements ActionTicker {
17 |
18 | public ActionTickerImpl(@NotNull NMSBridge nms, @NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
19 | super(nms, player, action, setting);
20 | if (this.action == null) {
21 | this.action = switch (action) {
22 | case ATTACK -> new AttackAction(((CraftPlayer) player).getHandle());
23 | case MINE -> new MineAction(((CraftPlayer) player).getHandle());
24 | case USE -> new UseAction(((CraftPlayer) player).getHandle());
25 | case JUMP, LOOK_AT_NEAREST_ENTITY, DROP_INVENTORY, DROP_STACK, DROP_ITEM ->
26 | throw new UnsupportedOperationException();
27 | };
28 | }
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_1/src/main/java/io/github/hello09x/fakeplayer/v1_20_1/spi/ActionTickerImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_1.spi;
2 |
3 |
4 | import io.github.hello09x.fakeplayer.api.spi.ActionSetting;
5 | import io.github.hello09x.fakeplayer.api.spi.ActionTicker;
6 | import io.github.hello09x.fakeplayer.api.spi.ActionType;
7 | import io.github.hello09x.fakeplayer.api.spi.NMSBridge;
8 | import io.github.hello09x.fakeplayer.core.entity.action.BaseActionTicker;
9 | import io.github.hello09x.fakeplayer.v1_20_1.action.AttackAction;
10 | import io.github.hello09x.fakeplayer.v1_20_1.action.MineAction;
11 | import io.github.hello09x.fakeplayer.v1_20_1.action.UseAction;
12 | import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
13 | import org.bukkit.entity.Player;
14 | import org.jetbrains.annotations.NotNull;
15 |
16 | public class ActionTickerImpl extends BaseActionTicker implements ActionTicker {
17 |
18 |
19 | public ActionTickerImpl(@NotNull NMSBridge nms, @NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
20 | super(nms, player, action, setting);
21 | if (this.action == null) {
22 | this.action = switch (action) {
23 | case ATTACK -> new AttackAction(((CraftPlayer) player).getHandle());
24 | case MINE -> new MineAction(((CraftPlayer) player).getHandle());
25 | case USE -> new UseAction(((CraftPlayer) player).getHandle());
26 | case JUMP, LOOK_AT_NEAREST_ENTITY, DROP_INVENTORY, DROP_STACK, DROP_ITEM ->
27 | throw new UnsupportedOperationException();
28 | };
29 | }
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/ActionSetting.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.api.spi;
2 |
3 | import lombok.EqualsAndHashCode;
4 |
5 | /**
6 | * @author tanyaofei
7 | * @since 2024/8/9
8 | **/
9 | @EqualsAndHashCode
10 | public
11 | class ActionSetting implements Cloneable {
12 |
13 | /**
14 | * 总次数
15 | */
16 | public final int maximum;
17 |
18 | /**
19 | * 剩余次数
20 | */
21 | public int remains;
22 |
23 | /**
24 | * 间隔
25 | */
26 | public int interval;
27 |
28 | /**
29 | * 等待 ticks
30 | */
31 | public int wait;
32 |
33 | public ActionSetting(int maximum, int interval) {
34 | this(maximum, interval, 0);
35 | }
36 |
37 | public ActionSetting(int maximum, int interval, int wait) {
38 | this.maximum = maximum;
39 | this.remains = maximum;
40 | this.interval = interval;
41 | this.wait = wait;
42 | }
43 |
44 | public static ActionSetting once() {
45 | return new ActionSetting(1, 0);
46 | }
47 |
48 | public static ActionSetting stop() {
49 | return new ActionSetting(0, 0);
50 | }
51 |
52 | public static ActionSetting interval(int interval) {
53 | return new ActionSetting(-1, interval);
54 | }
55 |
56 | public static ActionSetting continuous() {
57 | return new ActionSetting(-1, 0);
58 | }
59 |
60 | @Override
61 | public ActionSetting clone() {
62 | try {
63 | return (ActionSetting) super.clone();
64 | } catch (CloneNotSupportedException e) {
65 | throw new Error(e);
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/SprintCommand.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.command.impl;
2 |
3 | import com.google.inject.Singleton;
4 | import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
5 | import dev.jorel.commandapi.executors.CommandArguments;
6 | import org.bukkit.command.CommandSender;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | import static net.kyori.adventure.text.Component.text;
10 | import static net.kyori.adventure.text.Component.translatable;
11 | import static net.kyori.adventure.text.format.NamedTextColor.GRAY;
12 | import static net.kyori.adventure.text.format.NamedTextColor.WHITE;
13 |
14 | /**
15 | * @author tanyaofei
16 | * @since 2024/8/9
17 | **/
18 | @Singleton
19 | public class SprintCommand extends AbstractCommand {
20 |
21 | public void sprint(@NotNull CommandSender sender, @NotNull CommandArguments args) throws WrapperCommandSyntaxException {
22 | var fake = super.getFakeplayer(sender, args);
23 | var sprinting = (Boolean) args.getOptional("sprinting")
24 | .map(String.class::cast)
25 | .map(Boolean::valueOf)
26 | .orElse(!fake.isSprinting());
27 |
28 | var message = sprinting
29 | ? translatable("fakeplayer.command.sprint.success.enabled", text(fake.getName(), WHITE)).color(GRAY)
30 | : translatable("fakeplayer.command.sprint.success.disabled", text(fake.getName(), WHITE)).color(GRAY);
31 | fake.setSprinting(sprinting);
32 | sender.sendMessage(message);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/ReloadCommand.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.command.impl;
2 |
3 | import com.google.inject.Inject;
4 | import com.google.inject.Singleton;
5 | import dev.jorel.commandapi.executors.CommandArguments;
6 | import io.github.hello09x.devtools.core.translation.PluginTranslator;
7 | import io.github.hello09x.fakeplayer.core.config.FakeplayerConfig;
8 | import org.bukkit.command.CommandSender;
9 | import org.jetbrains.annotations.NotNull;
10 |
11 | import static net.kyori.adventure.text.Component.translatable;
12 | import static net.kyori.adventure.text.format.NamedTextColor.GRAY;
13 |
14 | @Singleton
15 | public class ReloadCommand extends AbstractCommand {
16 |
17 | private final FakeplayerConfig config;
18 |
19 | private final PluginTranslator translator;
20 |
21 | @Inject
22 | public ReloadCommand(FakeplayerConfig config, PluginTranslator translator) {
23 | this.config = config;
24 | this.translator = translator;
25 | }
26 |
27 | public void reload(@NotNull CommandSender sender, @NotNull CommandArguments args) {
28 | config.reload();
29 | sender.sendMessage(translatable("fakeplayer.command.generic.success", GRAY));
30 | if (config.isConfigFileOutOfDate()) {
31 | sender.sendMessage(translatable("fakeplayer.configuration.out-of-date", GRAY));
32 | }
33 | }
34 |
35 | public void reloadTranslation(@NotNull CommandSender sender, @NotNull CommandArguments args) {
36 | translator.reload();
37 | sender.sendMessage(translatable(
38 | "fakeplayer.command.generic.success"
39 | ));
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/SetCommand.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.command.impl;
2 |
3 | import com.google.inject.Singleton;
4 | import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
5 | import dev.jorel.commandapi.executors.CommandArguments;
6 | import io.github.hello09x.fakeplayer.core.repository.model.Feature;
7 | import org.bukkit.command.CommandSender;
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | import java.util.Objects;
11 |
12 | import static net.kyori.adventure.text.Component.text;
13 | import static net.kyori.adventure.text.Component.translatable;
14 | import static net.kyori.adventure.text.format.NamedTextColor.*;
15 |
16 | @Singleton
17 | public class SetCommand extends AbstractCommand {
18 |
19 | public void set(@NotNull CommandSender sender, @NotNull CommandArguments args) throws WrapperCommandSyntaxException {
20 | var target = super.getFakeplayer(sender, args);
21 | var feature = (Feature) Objects.requireNonNull(args.get("feature"));
22 | var value = (String) Objects.requireNonNull(args.get("option"));
23 |
24 | var modifier = feature.getModifier();
25 | if (modifier == null) {
26 | sender.sendMessage(translatable("fakeplayer.command.config.set.error.invalid-key", RED));
27 | return;
28 | }
29 |
30 | modifier.accept(target, value);
31 | sender.sendMessage(translatable(
32 | "fakeplayer.command.set.success",
33 | text(target.getName(), WHITE),
34 | translatable(feature, GOLD),
35 | text(value, WHITE)
36 | ).color(GRAY));
37 |
38 |
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/InvseeCommand.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.command.impl;
2 |
3 | import com.google.inject.Inject;
4 | import com.google.inject.Singleton;
5 | import dev.jorel.commandapi.CommandAPI;
6 | import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
7 | import dev.jorel.commandapi.executors.CommandArguments;
8 | import io.github.hello09x.devtools.core.translation.TranslatorUtils;
9 | import io.github.hello09x.devtools.core.utils.ComponentUtils;
10 | import io.github.hello09x.fakeplayer.core.manager.invsee.InvseeManager;
11 | import org.bukkit.entity.Player;
12 | import org.jetbrains.annotations.NotNull;
13 |
14 | import java.util.Objects;
15 |
16 | import static net.kyori.adventure.text.Component.translatable;
17 |
18 | @Singleton
19 | public class InvseeCommand extends AbstractCommand {
20 |
21 | private final InvseeManager invseeManager;
22 |
23 | @Inject
24 | public InvseeCommand(InvseeManager invseeManager) {
25 | this.invseeManager = invseeManager;
26 | }
27 |
28 | /**
29 | * 查看背包
30 | */
31 | public void invsee(@NotNull Player sender, @NotNull CommandArguments args) throws WrapperCommandSyntaxException {
32 | var fake = super.getFakeplayer(sender, args);
33 | if (!Objects.equals(sender.getLocation().getWorld(), fake.getLocation().getWorld())) {
34 | throw CommandAPI.failWithString(ComponentUtils.toString(
35 | translatable("fakeplayer.command.invsee.error.not-the-same-world"),
36 | TranslatorUtils.getLocale(sender)
37 | ));
38 | }
39 | invseeManager.invsee(sender, fake);
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_6/src/main/java/io/github/hello09x/fakeplayer/v1_21_6/network/FakeConnection.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_6.network;
2 |
3 | import io.github.hello09x.fakeplayer.core.Main;
4 | import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
5 | import io.github.hello09x.fakeplayer.core.network.FakeChannel;
6 | import io.netty.channel.ChannelFutureListener;
7 | import net.minecraft.network.Connection;
8 | import net.minecraft.network.protocol.Packet;
9 | import net.minecraft.network.protocol.PacketFlow;
10 | import org.jetbrains.annotations.NotNull;
11 | import org.jetbrains.annotations.Nullable;
12 |
13 | import java.net.InetAddress;
14 | import java.util.logging.Logger;
15 |
16 | public class FakeConnection extends Connection {
17 |
18 | private final static Logger log = Main.getInstance().getLogger();
19 | private final FakeplayerManager manager = Main.getInjector().getInstance(FakeplayerManager.class);
20 |
21 | public FakeConnection(@NotNull InetAddress address) {
22 | super(PacketFlow.SERVERBOUND);
23 | this.channel = new FakeChannel(null, address);
24 | this.address = this.channel.remoteAddress();
25 | Connection.configureSerialization(this.channel.pipeline(), PacketFlow.SERVERBOUND, false, null);
26 | }
27 |
28 | @Override
29 | public boolean isConnected() {
30 | return true;
31 | }
32 |
33 | @Override
34 | public void send(Packet> packet, @Nullable ChannelFutureListener channelfuturelistener) {
35 | }
36 |
37 | @Override
38 | public void send(Packet> packet, @Nullable ChannelFutureListener channelfuturelistener, boolean flag) {
39 | }
40 |
41 |
42 |
43 | @Override
44 | public void send(Packet> packet) {
45 |
46 | }
47 |
48 | }
--------------------------------------------------------------------------------
/fakeplayer-v1_21_9/src/main/java/io/github/hello09x/fakeplayer/v1_21_9/network/FakeConnection.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_9.network;
2 |
3 | import io.github.hello09x.fakeplayer.core.Main;
4 | import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
5 | import io.github.hello09x.fakeplayer.core.network.FakeChannel;
6 | import io.netty.channel.ChannelFutureListener;
7 | import net.minecraft.network.Connection;
8 | import net.minecraft.network.protocol.Packet;
9 | import net.minecraft.network.protocol.PacketFlow;
10 | import org.jetbrains.annotations.NotNull;
11 | import org.jetbrains.annotations.Nullable;
12 |
13 | import java.net.InetAddress;
14 | import java.util.logging.Logger;
15 |
16 | public class FakeConnection extends Connection {
17 |
18 | private final static Logger log = Main.getInstance().getLogger();
19 | private final FakeplayerManager manager = Main.getInjector().getInstance(FakeplayerManager.class);
20 |
21 | public FakeConnection(@NotNull InetAddress address) {
22 | super(PacketFlow.SERVERBOUND);
23 | this.channel = new FakeChannel(null, address);
24 | this.address = this.channel.remoteAddress();
25 | Connection.configureSerialization(this.channel.pipeline(), PacketFlow.SERVERBOUND, false, null);
26 | }
27 |
28 | @Override
29 | public boolean isConnected() {
30 | return true;
31 | }
32 |
33 | @Override
34 | public void send(Packet> packet, @Nullable ChannelFutureListener channelfuturelistener) {
35 | }
36 |
37 | @Override
38 | public void send(Packet> packet, @Nullable ChannelFutureListener channelfuturelistener, boolean flag) {
39 | }
40 |
41 |
42 |
43 | @Override
44 | public void send(Packet> packet) {
45 |
46 | }
47 |
48 | }
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/SelectCommand.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.command.impl;
2 |
3 | import com.google.inject.Singleton;
4 | import dev.jorel.commandapi.executors.CommandArguments;
5 | import org.bukkit.entity.Player;
6 | import org.jetbrains.annotations.NotNull;
7 |
8 | import static net.kyori.adventure.text.Component.text;
9 | import static net.kyori.adventure.text.Component.translatable;
10 | import static net.kyori.adventure.text.format.NamedTextColor.GRAY;
11 | import static net.kyori.adventure.text.format.NamedTextColor.WHITE;
12 |
13 | @Singleton
14 | public class SelectCommand extends AbstractCommand {
15 |
16 | public void select(@NotNull Player sender, @NotNull CommandArguments args) {
17 | var target = this.getTargetNullable(sender, args);
18 | manager.setSelection(sender, target);
19 | if (target == null) {
20 | sender.sendMessage(translatable("fakeplayer.command.select.success.clear", GRAY));
21 | } else {
22 | sender.sendMessage(translatable(
23 | "fakeplayer.command.select.success.selected",
24 | text(target.getName(), WHITE)
25 | ).color(GRAY));
26 | }
27 | }
28 |
29 | public void selection(@NotNull Player sender, @NotNull CommandArguments args) {
30 | var selection = manager.getSelection(sender);
31 | if (selection == null) {
32 | sender.sendMessage(translatable("fakeplayer.command.selection.error.none", GRAY));
33 | } else {
34 | sender.sendMessage(translatable(
35 | "fakeplayer.command.selection.success",
36 | text(selection.getName(), WHITE)
37 | ).color(GRAY));
38 | }
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_1/src/main/java/io/github/hello09x/fakeplayer/v1_20_1/network/FakePlayerAdvancements.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_1.network;
2 |
3 | import com.mojang.datafixers.DataFixer;
4 | import net.minecraft.advancements.Advancement;
5 | import net.minecraft.advancements.AdvancementProgress;
6 | import net.minecraft.server.PlayerAdvancements;
7 | import net.minecraft.server.ServerAdvancementManager;
8 | import net.minecraft.server.level.ServerPlayer;
9 | import net.minecraft.server.players.PlayerList;
10 |
11 | import java.nio.file.Path;
12 |
13 | public class FakePlayerAdvancements extends PlayerAdvancements {
14 |
15 | public FakePlayerAdvancements(
16 | DataFixer datafixer,
17 | PlayerList playerlist,
18 | ServerAdvancementManager manager,
19 | Path path,
20 | ServerPlayer player
21 | ) {
22 | super(datafixer, playerlist, manager, path, player);
23 | this.save();
24 | }
25 |
26 | @Override
27 | public boolean award(Advancement advancement, String s) {
28 | return false;
29 | }
30 |
31 | @Override
32 | public void flushDirty(ServerPlayer player) {
33 | }
34 |
35 | @Override
36 | public AdvancementProgress getOrStartProgress(Advancement advancement) {
37 | return new AdvancementProgress();
38 | }
39 |
40 | @Override
41 | public boolean revoke(Advancement advancement, String s) {
42 | return false;
43 | }
44 |
45 | @Override
46 | public void save() {
47 | }
48 |
49 | @Override
50 | public void setPlayer(ServerPlayer player) {
51 | }
52 |
53 | @Override
54 | public void setSelectedTab(Advancement advancement) {
55 | }
56 |
57 | @Override
58 | public void stopListening() {
59 | }
60 |
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21/src/main/java/io/github/hello09x/fakeplayer/v1_21/network/FakePlayerAdvancements.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21.network;
2 |
3 | import com.mojang.datafixers.DataFixer;
4 | import net.minecraft.advancements.AdvancementHolder;
5 | import net.minecraft.advancements.AdvancementProgress;
6 | import net.minecraft.server.PlayerAdvancements;
7 | import net.minecraft.server.ServerAdvancementManager;
8 | import net.minecraft.server.level.ServerPlayer;
9 | import net.minecraft.server.players.PlayerList;
10 |
11 | import java.nio.file.Path;
12 |
13 | public class FakePlayerAdvancements extends PlayerAdvancements {
14 |
15 | public FakePlayerAdvancements(
16 | DataFixer datafixer,
17 | PlayerList playerlist,
18 | ServerAdvancementManager manager,
19 | Path path,
20 | ServerPlayer player
21 | ) {
22 | super(datafixer, playerlist, manager, path, player);
23 | this.save();
24 | }
25 |
26 | @Override
27 | public boolean award(AdvancementHolder advancementholder, String s) {
28 | return false;
29 | }
30 |
31 | @Override
32 | public void flushDirty(ServerPlayer player) {
33 | }
34 |
35 | @Override
36 | public AdvancementProgress getOrStartProgress(AdvancementHolder advancement) {
37 | return new AdvancementProgress();
38 | }
39 |
40 | @Override
41 | public boolean revoke(AdvancementHolder advancement, String s) {
42 | return false;
43 | }
44 |
45 | @Override
46 | public void save() {
47 | }
48 |
49 | @Override
50 | public void setPlayer(ServerPlayer player) {
51 | }
52 |
53 | @Override
54 | public void setSelectedTab(AdvancementHolder advancement) {
55 | }
56 |
57 | @Override
58 | public void stopListening() {
59 |
60 | }
61 |
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_2/src/main/java/io/github/hello09x/fakeplayer/v1_20_2/network/FakePlayerAdvancements.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_2.network;
2 |
3 | import com.mojang.datafixers.DataFixer;
4 | import net.minecraft.advancements.AdvancementHolder;
5 | import net.minecraft.advancements.AdvancementProgress;
6 | import net.minecraft.server.PlayerAdvancements;
7 | import net.minecraft.server.ServerAdvancementManager;
8 | import net.minecraft.server.level.ServerPlayer;
9 | import net.minecraft.server.players.PlayerList;
10 |
11 | import java.nio.file.Path;
12 |
13 | public class FakePlayerAdvancements extends PlayerAdvancements {
14 |
15 | public FakePlayerAdvancements(
16 | DataFixer datafixer,
17 | PlayerList playerlist,
18 | ServerAdvancementManager manager,
19 | Path path,
20 | ServerPlayer player
21 | ) {
22 | super(datafixer, playerlist, manager, path, player);
23 | this.save();
24 | }
25 |
26 | @Override
27 | public boolean award(AdvancementHolder advancementholder, String s) {
28 | return false;
29 | }
30 |
31 | @Override
32 | public void flushDirty(ServerPlayer player) {
33 | }
34 |
35 | @Override
36 | public AdvancementProgress getOrStartProgress(AdvancementHolder advancement) {
37 | return new AdvancementProgress();
38 | }
39 |
40 | @Override
41 | public boolean revoke(AdvancementHolder advancement, String s) {
42 | return false;
43 | }
44 |
45 | @Override
46 | public void save() {
47 | }
48 |
49 | @Override
50 | public void setPlayer(ServerPlayer player) {
51 | }
52 |
53 | @Override
54 | public void setSelectedTab(AdvancementHolder advancement) {
55 | }
56 |
57 | @Override
58 | public void stopListening() {
59 |
60 | }
61 |
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_4/src/main/java/io/github/hello09x/fakeplayer/v1_20_4/network/FakePlayerAdvancements.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_4.network;
2 |
3 | import com.mojang.datafixers.DataFixer;
4 | import net.minecraft.advancements.AdvancementHolder;
5 | import net.minecraft.advancements.AdvancementProgress;
6 | import net.minecraft.server.PlayerAdvancements;
7 | import net.minecraft.server.ServerAdvancementManager;
8 | import net.minecraft.server.level.ServerPlayer;
9 | import net.minecraft.server.players.PlayerList;
10 |
11 | import java.nio.file.Path;
12 |
13 | public class FakePlayerAdvancements extends PlayerAdvancements {
14 |
15 | public FakePlayerAdvancements(
16 | DataFixer datafixer,
17 | PlayerList playerlist,
18 | ServerAdvancementManager manager,
19 | Path path,
20 | ServerPlayer player
21 | ) {
22 | super(datafixer, playerlist, manager, path, player);
23 | this.save();
24 | }
25 |
26 | @Override
27 | public boolean award(AdvancementHolder advancementholder, String s) {
28 | return false;
29 | }
30 |
31 | @Override
32 | public void flushDirty(ServerPlayer player) {
33 | }
34 |
35 | @Override
36 | public AdvancementProgress getOrStartProgress(AdvancementHolder advancement) {
37 | return new AdvancementProgress();
38 | }
39 |
40 | @Override
41 | public boolean revoke(AdvancementHolder advancement, String s) {
42 | return false;
43 | }
44 |
45 | @Override
46 | public void save() {
47 | }
48 |
49 | @Override
50 | public void setPlayer(ServerPlayer player) {
51 | }
52 |
53 | @Override
54 | public void setSelectedTab(AdvancementHolder advancement) {
55 | }
56 |
57 | @Override
58 | public void stopListening() {
59 |
60 | }
61 |
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_6/src/main/java/io/github/hello09x/fakeplayer/v1_20_6/network/FakePlayerAdvancements.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_6.network;
2 |
3 | import com.mojang.datafixers.DataFixer;
4 | import net.minecraft.advancements.AdvancementHolder;
5 | import net.minecraft.advancements.AdvancementProgress;
6 | import net.minecraft.server.PlayerAdvancements;
7 | import net.minecraft.server.ServerAdvancementManager;
8 | import net.minecraft.server.level.ServerPlayer;
9 | import net.minecraft.server.players.PlayerList;
10 |
11 | import java.nio.file.Path;
12 |
13 | public class FakePlayerAdvancements extends PlayerAdvancements {
14 |
15 | public FakePlayerAdvancements(
16 | DataFixer datafixer,
17 | PlayerList playerlist,
18 | ServerAdvancementManager manager,
19 | Path path,
20 | ServerPlayer player
21 | ) {
22 | super(datafixer, playerlist, manager, path, player);
23 | this.save();
24 | }
25 |
26 | @Override
27 | public boolean award(AdvancementHolder advancementholder, String s) {
28 | return false;
29 | }
30 |
31 | @Override
32 | public void flushDirty(ServerPlayer player) {
33 | }
34 |
35 | @Override
36 | public AdvancementProgress getOrStartProgress(AdvancementHolder advancement) {
37 | return new AdvancementProgress();
38 | }
39 |
40 | @Override
41 | public boolean revoke(AdvancementHolder advancement, String s) {
42 | return false;
43 | }
44 |
45 | @Override
46 | public void save() {
47 | }
48 |
49 | @Override
50 | public void setPlayer(ServerPlayer player) {
51 | }
52 |
53 | @Override
54 | public void setSelectedTab(AdvancementHolder advancement) {
55 | }
56 |
57 | @Override
58 | public void stopListening() {
59 |
60 | }
61 |
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_3/src/main/java/io/github/hello09x/fakeplayer/v1_21_3/network/FakePlayerAdvancements.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_3.network;
2 |
3 | import com.mojang.datafixers.DataFixer;
4 | import net.minecraft.advancements.AdvancementHolder;
5 | import net.minecraft.advancements.AdvancementProgress;
6 | import net.minecraft.server.PlayerAdvancements;
7 | import net.minecraft.server.ServerAdvancementManager;
8 | import net.minecraft.server.level.ServerPlayer;
9 | import net.minecraft.server.players.PlayerList;
10 |
11 | import java.nio.file.Path;
12 |
13 | public class FakePlayerAdvancements extends PlayerAdvancements {
14 |
15 | public FakePlayerAdvancements(
16 | DataFixer datafixer,
17 | PlayerList playerlist,
18 | ServerAdvancementManager manager,
19 | Path path,
20 | ServerPlayer player
21 | ) {
22 | super(datafixer, playerlist, manager, path, player);
23 | this.save();
24 | }
25 |
26 | @Override
27 | public boolean award(AdvancementHolder advancementholder, String s) {
28 | return false;
29 | }
30 |
31 | @Override
32 | public void flushDirty(ServerPlayer player) {
33 | }
34 |
35 | @Override
36 | public AdvancementProgress getOrStartProgress(AdvancementHolder advancement) {
37 | return new AdvancementProgress();
38 | }
39 |
40 | @Override
41 | public boolean revoke(AdvancementHolder advancement, String s) {
42 | return false;
43 | }
44 |
45 | @Override
46 | public void save() {
47 | }
48 |
49 | @Override
50 | public void setPlayer(ServerPlayer player) {
51 | }
52 |
53 | @Override
54 | public void setSelectedTab(AdvancementHolder advancement) {
55 | }
56 |
57 | @Override
58 | public void stopListening() {
59 |
60 | }
61 |
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_4/src/main/java/io/github/hello09x/fakeplayer/v1_21_4/network/FakePlayerAdvancements.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_4.network;
2 |
3 | import com.mojang.datafixers.DataFixer;
4 | import net.minecraft.advancements.AdvancementHolder;
5 | import net.minecraft.advancements.AdvancementProgress;
6 | import net.minecraft.server.PlayerAdvancements;
7 | import net.minecraft.server.ServerAdvancementManager;
8 | import net.minecraft.server.level.ServerPlayer;
9 | import net.minecraft.server.players.PlayerList;
10 |
11 | import java.nio.file.Path;
12 |
13 | public class FakePlayerAdvancements extends PlayerAdvancements {
14 |
15 | public FakePlayerAdvancements(
16 | DataFixer datafixer,
17 | PlayerList playerlist,
18 | ServerAdvancementManager manager,
19 | Path path,
20 | ServerPlayer player
21 | ) {
22 | super(datafixer, playerlist, manager, path, player);
23 | this.save();
24 | }
25 |
26 | @Override
27 | public boolean award(AdvancementHolder advancementholder, String s) {
28 | return false;
29 | }
30 |
31 | @Override
32 | public void flushDirty(ServerPlayer player) {
33 | }
34 |
35 | @Override
36 | public AdvancementProgress getOrStartProgress(AdvancementHolder advancement) {
37 | return new AdvancementProgress();
38 | }
39 |
40 | @Override
41 | public boolean revoke(AdvancementHolder advancement, String s) {
42 | return false;
43 | }
44 |
45 | @Override
46 | public void save() {
47 | }
48 |
49 | @Override
50 | public void setPlayer(ServerPlayer player) {
51 | }
52 |
53 | @Override
54 | public void setSelectedTab(AdvancementHolder advancement) {
55 | }
56 |
57 | @Override
58 | public void stopListening() {
59 |
60 | }
61 |
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_2/src/main/java/io/github/hello09x/fakeplayer/v1_20_2/spi/NMSBridgeImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_2.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.*;
4 | import io.github.hello09x.fakeplayer.core.Main;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.Server;
7 | import org.bukkit.World;
8 | import org.bukkit.entity.Entity;
9 | import org.bukkit.entity.Player;
10 | import org.jetbrains.annotations.NotNull;
11 |
12 | import java.net.InetAddress;
13 | import java.util.Set;
14 |
15 | public class NMSBridgeImpl implements NMSBridge {
16 |
17 | private final static Set SUPPORTS = Set.of("1.20.2");
18 |
19 | @Override
20 | public @NotNull NMSEntity fromEntity(@NotNull Entity entity) {
21 | return new NMSEntityImpl(entity);
22 | }
23 |
24 | @Override
25 | public @NotNull NMSServer fromServer(@NotNull Server server) {
26 | return new NMSServerImpl(server);
27 | }
28 |
29 | @Override
30 | public @NotNull NMSServerLevel fromWorld(@NotNull World world) {
31 | return new NMSServerLevelImpl(world);
32 | }
33 |
34 | @Override
35 | public @NotNull NMSServerPlayer fromPlayer(@NotNull Player player) {
36 | return new NMSServerPlayerImpl(player);
37 | }
38 |
39 | @Override
40 | public @NotNull NMSNetwork createNetwork(@NotNull InetAddress address) {
41 | return new NMSNetworkImpl(address);
42 | }
43 |
44 | @Override
45 | public boolean isSupported() {
46 | return SUPPORTS.contains(Bukkit.getMinecraftVersion());
47 | }
48 |
49 | @Override
50 | public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
51 | return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting);
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_4/src/main/java/io/github/hello09x/fakeplayer/v1_20_4/spi/NMSBridgeImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_4.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.*;
4 | import io.github.hello09x.fakeplayer.core.Main;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.Server;
7 | import org.bukkit.World;
8 | import org.bukkit.entity.Entity;
9 | import org.bukkit.entity.Player;
10 | import org.jetbrains.annotations.NotNull;
11 |
12 | import java.net.InetAddress;
13 | import java.util.Set;
14 |
15 | public class NMSBridgeImpl implements NMSBridge {
16 |
17 | private final static Set SUPPORTS = Set.of("1.20.4");
18 |
19 | @Override
20 | public @NotNull NMSEntity fromEntity(@NotNull Entity entity) {
21 | return new NMSEntityImpl(entity);
22 | }
23 |
24 | @Override
25 | public @NotNull NMSServer fromServer(@NotNull Server server) {
26 | return new NMSServerImpl(server);
27 | }
28 |
29 | @Override
30 | public @NotNull NMSServerLevel fromWorld(@NotNull World world) {
31 | return new NMSServerLevelImpl(world);
32 | }
33 |
34 | @Override
35 | public @NotNull NMSServerPlayer fromPlayer(@NotNull Player player) {
36 | return new NMSServerPlayerImpl(player);
37 | }
38 |
39 | @Override
40 | public @NotNull NMSNetwork createNetwork(@NotNull InetAddress address) {
41 | return new NMSNetworkImpl(address);
42 | }
43 |
44 | @Override
45 | public boolean isSupported() {
46 | return SUPPORTS.contains(Bukkit.getMinecraftVersion());
47 | }
48 |
49 | @Override
50 | public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
51 | return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting);
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_6/src/main/java/io/github/hello09x/fakeplayer/v1_20_6/spi/NMSBridgeImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_6.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.*;
4 | import io.github.hello09x.fakeplayer.core.Main;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.Server;
7 | import org.bukkit.World;
8 | import org.bukkit.entity.Entity;
9 | import org.bukkit.entity.Player;
10 | import org.jetbrains.annotations.NotNull;
11 |
12 | import java.net.InetAddress;
13 | import java.util.Set;
14 |
15 | public class NMSBridgeImpl implements NMSBridge {
16 |
17 | private final static Set SUPPORTS = Set.of("1.20.6");
18 |
19 | @Override
20 | public @NotNull NMSEntity fromEntity(@NotNull Entity entity) {
21 | return new NMSEntityImpl(entity);
22 | }
23 |
24 | @Override
25 | public @NotNull NMSServer fromServer(@NotNull Server server) {
26 | return new NMSServerImpl(server);
27 | }
28 |
29 | @Override
30 | public @NotNull NMSServerLevel fromWorld(@NotNull World world) {
31 | return new NMSServerLevelImpl(world);
32 | }
33 |
34 | @Override
35 | public @NotNull NMSServerPlayer fromPlayer(@NotNull Player player) {
36 | return new NMSServerPlayerImpl(player);
37 | }
38 |
39 | @Override
40 | public @NotNull NMSNetwork createNetwork(@NotNull InetAddress address) {
41 | return new NMSNetworkImpl(address);
42 | }
43 |
44 | @Override
45 | public boolean isSupported() {
46 | return SUPPORTS.contains(Bukkit.getMinecraftVersion());
47 | }
48 |
49 | @Override
50 | public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
51 | return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting);
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21/src/main/java/io/github/hello09x/fakeplayer/v1_21/spi/NMSBridgeImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.*;
4 | import io.github.hello09x.fakeplayer.core.Main;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.Server;
7 | import org.bukkit.World;
8 | import org.bukkit.entity.Entity;
9 | import org.bukkit.entity.Player;
10 | import org.jetbrains.annotations.NotNull;
11 |
12 | import java.net.InetAddress;
13 | import java.util.Set;
14 |
15 | public class NMSBridgeImpl implements NMSBridge {
16 |
17 | private final static Set SUPPORTS = Set.of("1.21", "1.21.0");
18 |
19 | @Override
20 | public @NotNull NMSEntity fromEntity(@NotNull Entity entity) {
21 | return new NMSEntityImpl(entity);
22 | }
23 |
24 | @Override
25 | public @NotNull NMSServer fromServer(@NotNull Server server) {
26 | return new NMSServerImpl(server);
27 | }
28 |
29 | @Override
30 | public @NotNull NMSServerLevel fromWorld(@NotNull World world) {
31 | return new NMSServerLevelImpl(world);
32 | }
33 |
34 | @Override
35 | public @NotNull NMSServerPlayer fromPlayer(@NotNull Player player) {
36 | return new NMSServerPlayerImpl(player);
37 | }
38 |
39 | @Override
40 | public @NotNull NMSNetwork createNetwork(@NotNull InetAddress address) {
41 | return new NMSNetworkImpl(address);
42 | }
43 |
44 | @Override
45 | public boolean isSupported() {
46 | return SUPPORTS.contains(Bukkit.getMinecraftVersion());
47 | }
48 |
49 | @Override
50 | public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
51 | return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting);
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_4/src/main/java/io/github/hello09x/fakeplayer/v1_21_4/spi/NMSBridgeImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_4.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.*;
4 | import io.github.hello09x.fakeplayer.core.Main;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.Server;
7 | import org.bukkit.World;
8 | import org.bukkit.entity.Entity;
9 | import org.bukkit.entity.Player;
10 | import org.jetbrains.annotations.NotNull;
11 |
12 | import java.net.InetAddress;
13 | import java.util.Set;
14 |
15 | public class NMSBridgeImpl implements NMSBridge {
16 |
17 | private final static Set SUPPORTS = Set.of("1.21.4");
18 |
19 | @Override
20 | public @NotNull NMSEntity fromEntity(@NotNull Entity entity) {
21 | return new NMSEntityImpl(entity);
22 | }
23 |
24 | @Override
25 | public @NotNull NMSServer fromServer(@NotNull Server server) {
26 | return new NMSServerImpl(server);
27 | }
28 |
29 | @Override
30 | public @NotNull NMSServerLevel fromWorld(@NotNull World world) {
31 | return new NMSServerLevelImpl(world);
32 | }
33 |
34 | @Override
35 | public @NotNull NMSServerPlayer fromPlayer(@NotNull Player player) {
36 | return new NMSServerPlayerImpl(player);
37 | }
38 |
39 | @Override
40 | public @NotNull NMSNetwork createNetwork(@NotNull InetAddress address) {
41 | return new NMSNetworkImpl(address);
42 | }
43 |
44 | @Override
45 | public boolean isSupported() {
46 | return SUPPORTS.contains(Bukkit.getMinecraftVersion());
47 | }
48 |
49 | @Override
50 | public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
51 | return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting);
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_5/src/main/java/io/github/hello09x/fakeplayer/v1_21_5/spi/NMSBridgeImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_5.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.*;
4 | import io.github.hello09x.fakeplayer.core.Main;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.Server;
7 | import org.bukkit.World;
8 | import org.bukkit.entity.Entity;
9 | import org.bukkit.entity.Player;
10 | import org.jetbrains.annotations.NotNull;
11 |
12 | import java.net.InetAddress;
13 | import java.util.Set;
14 |
15 | public class NMSBridgeImpl implements NMSBridge {
16 |
17 | private final static Set SUPPORTS = Set.of("1.21.5");
18 |
19 | @Override
20 | public @NotNull NMSEntity fromEntity(@NotNull Entity entity) {
21 | return new NMSEntityImpl(entity);
22 | }
23 |
24 | @Override
25 | public @NotNull NMSServer fromServer(@NotNull Server server) {
26 | return new NMSServerImpl(server);
27 | }
28 |
29 | @Override
30 | public @NotNull NMSServerLevel fromWorld(@NotNull World world) {
31 | return new NMSServerLevelImpl(world);
32 | }
33 |
34 | @Override
35 | public @NotNull NMSServerPlayer fromPlayer(@NotNull Player player) {
36 | return new NMSServerPlayerImpl(player);
37 | }
38 |
39 | @Override
40 | public @NotNull NMSNetwork createNetwork(@NotNull InetAddress address) {
41 | return new NMSNetworkImpl(address);
42 | }
43 |
44 | @Override
45 | public boolean isSupported() {
46 | return SUPPORTS.contains(Bukkit.getMinecraftVersion());
47 | }
48 |
49 | @Override
50 | public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
51 | return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting);
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_6/src/main/java/io/github/hello09x/fakeplayer/v1_21_6/spi/NMSBridgeImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_6.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.*;
4 | import io.github.hello09x.fakeplayer.core.Main;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.Server;
7 | import org.bukkit.World;
8 | import org.bukkit.entity.Entity;
9 | import org.bukkit.entity.Player;
10 | import org.jetbrains.annotations.NotNull;
11 |
12 | import java.net.InetAddress;
13 | import java.util.Set;
14 |
15 | public class NMSBridgeImpl implements NMSBridge {
16 |
17 | private final static Set SUPPORTS = Set.of("1.21.6");
18 |
19 | @Override
20 | public @NotNull NMSEntity fromEntity(@NotNull Entity entity) {
21 | return new NMSEntityImpl(entity);
22 | }
23 |
24 | @Override
25 | public @NotNull NMSServer fromServer(@NotNull Server server) {
26 | return new NMSServerImpl(server);
27 | }
28 |
29 | @Override
30 | public @NotNull NMSServerLevel fromWorld(@NotNull World world) {
31 | return new NMSServerLevelImpl(world);
32 | }
33 |
34 | @Override
35 | public @NotNull NMSServerPlayer fromPlayer(@NotNull Player player) {
36 | return new NMSServerPlayerImpl(player);
37 | }
38 |
39 | @Override
40 | public @NotNull NMSNetwork createNetwork(@NotNull InetAddress address) {
41 | return new NMSNetworkImpl(address);
42 | }
43 |
44 | @Override
45 | public boolean isSupported() {
46 | return SUPPORTS.contains(Bukkit.getMinecraftVersion());
47 | }
48 |
49 | @Override
50 | public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
51 | return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting);
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_9/src/main/java/io/github/hello09x/fakeplayer/v1_21_9/spi/NMSBridgeImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_9.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.*;
4 | import io.github.hello09x.fakeplayer.core.Main;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.Server;
7 | import org.bukkit.World;
8 | import org.bukkit.entity.Entity;
9 | import org.bukkit.entity.Player;
10 | import org.jetbrains.annotations.NotNull;
11 |
12 | import java.net.InetAddress;
13 | import java.util.Set;
14 |
15 | public class NMSBridgeImpl implements NMSBridge {
16 |
17 | private final static Set SUPPORTS = Set.of("1.21.9");
18 |
19 | @Override
20 | public @NotNull NMSEntity fromEntity(@NotNull Entity entity) {
21 | return new NMSEntityImpl(entity);
22 | }
23 |
24 | @Override
25 | public @NotNull NMSServer fromServer(@NotNull Server server) {
26 | return new NMSServerImpl(server);
27 | }
28 |
29 | @Override
30 | public @NotNull NMSServerLevel fromWorld(@NotNull World world) {
31 | return new NMSServerLevelImpl(world);
32 | }
33 |
34 | @Override
35 | public @NotNull NMSServerPlayer fromPlayer(@NotNull Player player) {
36 | return new NMSServerPlayerImpl(player);
37 | }
38 |
39 | @Override
40 | public @NotNull NMSNetwork createNetwork(@NotNull InetAddress address) {
41 | return new NMSNetworkImpl(address);
42 | }
43 |
44 | @Override
45 | public boolean isSupported() {
46 | return SUPPORTS.contains(Bukkit.getMinecraftVersion());
47 | }
48 |
49 | @Override
50 | public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
51 | return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting);
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_1/src/main/java/io/github/hello09x/fakeplayer/v1_20_1/spi/NMSBridgeImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_1.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.*;
4 | import io.github.hello09x.fakeplayer.core.Main;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.Server;
7 | import org.bukkit.World;
8 | import org.bukkit.entity.Entity;
9 | import org.bukkit.entity.Player;
10 | import org.jetbrains.annotations.NotNull;
11 |
12 | import java.net.InetAddress;
13 | import java.util.Set;
14 |
15 | public class NMSBridgeImpl implements NMSBridge {
16 |
17 | private final static Set SUPPORTS = Set.of("1.20", "1.20.1");
18 |
19 | @Override
20 | public @NotNull NMSEntity fromEntity(@NotNull Entity entity) {
21 | return new NMSEntityImpl(entity);
22 | }
23 |
24 | @Override
25 | public @NotNull NMSServer fromServer(@NotNull Server server) {
26 | return new NMSServerImpl(server);
27 | }
28 |
29 | @Override
30 | public @NotNull NMSServerLevel fromWorld(@NotNull World world) {
31 | return new NMSServerLevelImpl(world);
32 | }
33 |
34 | @Override
35 | public @NotNull NMSServerPlayer fromPlayer(@NotNull Player player) {
36 | return new NMSServerPlayerImpl(player);
37 | }
38 |
39 | @Override
40 | public @NotNull NMSNetwork createNetwork(@NotNull InetAddress address) {
41 | return new NMSNetworkImpl(address);
42 | }
43 |
44 | @Override
45 | public boolean isSupported() {
46 | return SUPPORTS.contains(Bukkit.getMinecraftVersion());
47 | }
48 |
49 | @Override
50 | public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
51 | return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting);
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_3/src/main/java/io/github/hello09x/fakeplayer/v1_21_3/spi/NMSBridgeImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_3.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.*;
4 | import io.github.hello09x.fakeplayer.core.Main;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.Server;
7 | import org.bukkit.World;
8 | import org.bukkit.entity.Entity;
9 | import org.bukkit.entity.Player;
10 | import org.jetbrains.annotations.NotNull;
11 |
12 | import java.net.InetAddress;
13 | import java.util.Set;
14 |
15 | public class NMSBridgeImpl implements NMSBridge {
16 |
17 | private final static Set SUPPORTS = Set.of("1.21.2", "1.21.3");
18 |
19 | @Override
20 | public @NotNull NMSEntity fromEntity(@NotNull Entity entity) {
21 | return new NMSEntityImpl(entity);
22 | }
23 |
24 | @Override
25 | public @NotNull NMSServer fromServer(@NotNull Server server) {
26 | return new NMSServerImpl(server);
27 | }
28 |
29 | @Override
30 | public @NotNull NMSServerLevel fromWorld(@NotNull World world) {
31 | return new NMSServerLevelImpl(world);
32 | }
33 |
34 | @Override
35 | public @NotNull NMSServerPlayer fromPlayer(@NotNull Player player) {
36 | return new NMSServerPlayerImpl(player);
37 | }
38 |
39 | @Override
40 | public @NotNull NMSNetwork createNetwork(@NotNull InetAddress address) {
41 | return new NMSNetworkImpl(address);
42 | }
43 |
44 | @Override
45 | public boolean isSupported() {
46 | return SUPPORTS.contains(Bukkit.getMinecraftVersion());
47 | }
48 |
49 | @Override
50 | public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
51 | return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting);
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_5/src/main/java/io/github/hello09x/fakeplayer/v1_21_5/network/FakePlayerAdvancements.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_5.network;
2 |
3 | import com.mojang.datafixers.DataFixer;
4 | import net.minecraft.advancements.AdvancementHolder;
5 | import net.minecraft.advancements.AdvancementProgress;
6 | import net.minecraft.server.PlayerAdvancements;
7 | import net.minecraft.server.ServerAdvancementManager;
8 | import net.minecraft.server.level.ServerPlayer;
9 | import net.minecraft.server.players.PlayerList;
10 |
11 | import java.nio.file.Path;
12 |
13 | public class FakePlayerAdvancements extends PlayerAdvancements {
14 |
15 | public FakePlayerAdvancements(
16 | DataFixer datafixer,
17 | PlayerList playerlist,
18 | ServerAdvancementManager manager,
19 | Path path,
20 | ServerPlayer player
21 | ) {
22 | super(datafixer, playerlist, manager, path, player);
23 | this.save();
24 | }
25 |
26 | @Override
27 | public boolean award(AdvancementHolder advancementholder, String s) {
28 | return false;
29 | }
30 |
31 | @Override
32 | public void flushDirty(ServerPlayer entityplayer, boolean flag) {
33 |
34 | }
35 |
36 | @Override
37 | public AdvancementProgress getOrStartProgress(AdvancementHolder advancement) {
38 | return new AdvancementProgress();
39 | }
40 |
41 | @Override
42 | public boolean revoke(AdvancementHolder advancement, String s) {
43 | return false;
44 | }
45 |
46 | @Override
47 | public void save() {
48 | }
49 |
50 | @Override
51 | public void setPlayer(ServerPlayer player) {
52 | }
53 |
54 | @Override
55 | public void setSelectedTab(AdvancementHolder advancement) {
56 | }
57 |
58 | @Override
59 | public void stopListening() {
60 |
61 | }
62 |
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_6/src/main/java/io/github/hello09x/fakeplayer/v1_21_6/network/FakePlayerAdvancements.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_6.network;
2 |
3 | import com.mojang.datafixers.DataFixer;
4 | import net.minecraft.advancements.AdvancementHolder;
5 | import net.minecraft.advancements.AdvancementProgress;
6 | import net.minecraft.server.PlayerAdvancements;
7 | import net.minecraft.server.ServerAdvancementManager;
8 | import net.minecraft.server.level.ServerPlayer;
9 | import net.minecraft.server.players.PlayerList;
10 |
11 | import java.nio.file.Path;
12 |
13 | public class FakePlayerAdvancements extends PlayerAdvancements {
14 |
15 | public FakePlayerAdvancements(
16 | DataFixer datafixer,
17 | PlayerList playerlist,
18 | ServerAdvancementManager manager,
19 | Path path,
20 | ServerPlayer player
21 | ) {
22 | super(datafixer, playerlist, manager, path, player);
23 | this.save();
24 | }
25 |
26 | @Override
27 | public boolean award(AdvancementHolder advancementholder, String s) {
28 | return false;
29 | }
30 |
31 | @Override
32 | public void flushDirty(ServerPlayer entityplayer, boolean flag) {
33 |
34 | }
35 |
36 | @Override
37 | public AdvancementProgress getOrStartProgress(AdvancementHolder advancement) {
38 | return new AdvancementProgress();
39 | }
40 |
41 | @Override
42 | public boolean revoke(AdvancementHolder advancement, String s) {
43 | return false;
44 | }
45 |
46 | @Override
47 | public void save() {
48 | }
49 |
50 | @Override
51 | public void setPlayer(ServerPlayer player) {
52 | }
53 |
54 | @Override
55 | public void setSelectedTab(AdvancementHolder advancement) {
56 | }
57 |
58 | @Override
59 | public void stopListening() {
60 |
61 | }
62 |
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_9/src/main/java/io/github/hello09x/fakeplayer/v1_21_9/network/FakePlayerAdvancements.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_9.network;
2 |
3 | import com.mojang.datafixers.DataFixer;
4 | import net.minecraft.advancements.AdvancementHolder;
5 | import net.minecraft.advancements.AdvancementProgress;
6 | import net.minecraft.server.PlayerAdvancements;
7 | import net.minecraft.server.ServerAdvancementManager;
8 | import net.minecraft.server.level.ServerPlayer;
9 | import net.minecraft.server.players.PlayerList;
10 |
11 | import java.nio.file.Path;
12 |
13 | public class FakePlayerAdvancements extends PlayerAdvancements {
14 |
15 | public FakePlayerAdvancements(
16 | DataFixer datafixer,
17 | PlayerList playerlist,
18 | ServerAdvancementManager manager,
19 | Path path,
20 | ServerPlayer player
21 | ) {
22 | super(datafixer, playerlist, manager, path, player);
23 | this.save();
24 | }
25 |
26 | @Override
27 | public boolean award(AdvancementHolder advancementholder, String s) {
28 | return false;
29 | }
30 |
31 | @Override
32 | public void flushDirty(ServerPlayer entityplayer, boolean flag) {
33 |
34 | }
35 |
36 | @Override
37 | public AdvancementProgress getOrStartProgress(AdvancementHolder advancement) {
38 | return new AdvancementProgress();
39 | }
40 |
41 | @Override
42 | public boolean revoke(AdvancementHolder advancement, String s) {
43 | return false;
44 | }
45 |
46 | @Override
47 | public void save() {
48 | }
49 |
50 | @Override
51 | public void setPlayer(ServerPlayer player) {
52 | }
53 |
54 | @Override
55 | public void setSelectedTab(AdvancementHolder advancement) {
56 | }
57 |
58 | @Override
59 | public void stopListening() {
60 |
61 | }
62 |
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_3/src/main/java/io/github/hello09x/fakeplayer/v1_20_3/spi/NMSBridgeImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_3.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.*;
4 | import io.github.hello09x.fakeplayer.core.Main;
5 | import io.github.hello09x.fakeplayer.v1_20_4.spi.*;
6 | import org.bukkit.Bukkit;
7 | import org.bukkit.Server;
8 | import org.bukkit.World;
9 | import org.bukkit.entity.Entity;
10 | import org.bukkit.entity.Player;
11 | import org.jetbrains.annotations.NotNull;
12 |
13 | import java.net.InetAddress;
14 | import java.util.Set;
15 |
16 | public class NMSBridgeImpl implements NMSBridge {
17 |
18 | private final static Set SUPPORTS = Set.of("1.20.3");
19 |
20 | @Override
21 | public @NotNull NMSEntity fromEntity(@NotNull Entity entity) {
22 | return new NMSEntityImpl(entity);
23 | }
24 |
25 | @Override
26 | public @NotNull NMSServer fromServer(@NotNull Server server) {
27 | return new NMSServerImpl(server);
28 | }
29 |
30 | @Override
31 | public @NotNull NMSServerLevel fromWorld(@NotNull World world) {
32 | return new NMSServerLevelImpl(world);
33 | }
34 |
35 | @Override
36 | public @NotNull NMSServerPlayer fromPlayer(@NotNull Player player) {
37 | return new NMSServerPlayerImpl(player);
38 | }
39 |
40 | @Override
41 | public @NotNull NMSNetwork createNetwork(@NotNull InetAddress address) {
42 | return new NMSNetworkImpl(address);
43 | }
44 |
45 | @Override
46 | public boolean isSupported() {
47 | return SUPPORTS.contains(Bukkit.getMinecraftVersion());
48 | }
49 |
50 | @Override
51 | public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
52 | return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting);
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_5/src/main/java/io/github/hello09x/fakeplayer/v1_20_5/spi/NMSBridgeImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_5.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.*;
4 | import io.github.hello09x.fakeplayer.core.Main;
5 | import io.github.hello09x.fakeplayer.v1_20_6.spi.*;
6 | import org.bukkit.Bukkit;
7 | import org.bukkit.Server;
8 | import org.bukkit.World;
9 | import org.bukkit.entity.Entity;
10 | import org.bukkit.entity.Player;
11 | import org.jetbrains.annotations.NotNull;
12 |
13 | import java.net.InetAddress;
14 | import java.util.Set;
15 |
16 | public class NMSBridgeImpl implements NMSBridge {
17 |
18 | private final static Set SUPPORTS = Set.of("1.20.5");
19 |
20 | @Override
21 | public @NotNull NMSEntity fromEntity(@NotNull Entity entity) {
22 | return new NMSEntityImpl(entity);
23 | }
24 |
25 | @Override
26 | public @NotNull NMSServer fromServer(@NotNull Server server) {
27 | return new NMSServerImpl(server);
28 | }
29 |
30 | @Override
31 | public @NotNull NMSServerLevel fromWorld(@NotNull World world) {
32 | return new NMSServerLevelImpl(world);
33 | }
34 |
35 | @Override
36 | public @NotNull NMSServerPlayer fromPlayer(@NotNull Player player) {
37 | return new NMSServerPlayerImpl(player);
38 | }
39 |
40 | @Override
41 | public @NotNull NMSNetwork createNetwork(@NotNull InetAddress address) {
42 | return new NMSNetworkImpl(address);
43 | }
44 |
45 | @Override
46 | public boolean isSupported() {
47 | return SUPPORTS.contains(Bukkit.getMinecraftVersion());
48 | }
49 |
50 | @Override
51 | public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
52 | return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting);
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_1/src/main/java/io/github/hello09x/fakeplayer/v1_21_1/spi/NMSBridgeImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_1.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.*;
4 | import io.github.hello09x.fakeplayer.core.Main;
5 | import io.github.hello09x.fakeplayer.v1_21.spi.*;
6 | import org.bukkit.Bukkit;
7 | import org.bukkit.Server;
8 | import org.bukkit.World;
9 | import org.bukkit.entity.Entity;
10 | import org.bukkit.entity.Player;
11 | import org.jetbrains.annotations.NotNull;
12 |
13 | import java.net.InetAddress;
14 | import java.util.Set;
15 |
16 | public class NMSBridgeImpl implements NMSBridge {
17 |
18 | private final static Set SUPPORTS = Set.of("1.21.1");
19 |
20 | @Override
21 | public @NotNull NMSEntity fromEntity(@NotNull Entity entity) {
22 | return new NMSEntityImpl(entity);
23 | }
24 |
25 | @Override
26 | public @NotNull NMSServer fromServer(@NotNull Server server) {
27 | return new NMSServerImpl(server);
28 | }
29 |
30 | @Override
31 | public @NotNull NMSServerLevel fromWorld(@NotNull World world) {
32 | return new NMSServerLevelImpl(world);
33 | }
34 |
35 | @Override
36 | public @NotNull NMSServerPlayer fromPlayer(@NotNull Player player) {
37 | return new NMSServerPlayerImpl(player);
38 | }
39 |
40 | @Override
41 | public @NotNull NMSNetwork createNetwork(@NotNull InetAddress address) {
42 | return new NMSNetworkImpl(address);
43 | }
44 |
45 | @Override
46 | public boolean isSupported() {
47 | return SUPPORTS.contains(Bukkit.getMinecraftVersion());
48 | }
49 |
50 | @Override
51 | public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
52 | return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting);
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_7/src/main/java/io/github/hello09x/fakeplayer/v1_21_7/spi/NMSBridgeImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_7.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.*;
4 | import io.github.hello09x.fakeplayer.core.Main;
5 | import io.github.hello09x.fakeplayer.v1_21_6.spi.*;
6 | import org.bukkit.Bukkit;
7 | import org.bukkit.Server;
8 | import org.bukkit.World;
9 | import org.bukkit.entity.Entity;
10 | import org.bukkit.entity.Player;
11 | import org.jetbrains.annotations.NotNull;
12 |
13 | import java.net.InetAddress;
14 | import java.util.Set;
15 |
16 | public class NMSBridgeImpl implements NMSBridge {
17 |
18 | private final static Set SUPPORTS = Set.of("1.21.7");
19 |
20 | @Override
21 | public @NotNull NMSEntity fromEntity(@NotNull Entity entity) {
22 | return new NMSEntityImpl(entity);
23 | }
24 |
25 | @Override
26 | public @NotNull NMSServer fromServer(@NotNull Server server) {
27 | return new NMSServerImpl(server);
28 | }
29 |
30 | @Override
31 | public @NotNull NMSServerLevel fromWorld(@NotNull World world) {
32 | return new NMSServerLevelImpl(world);
33 | }
34 |
35 | @Override
36 | public @NotNull NMSServerPlayer fromPlayer(@NotNull Player player) {
37 | return new NMSServerPlayerImpl(player);
38 | }
39 |
40 | @Override
41 | public @NotNull NMSNetwork createNetwork(@NotNull InetAddress address) {
42 | return new NMSNetworkImpl(address);
43 | }
44 |
45 | @Override
46 | public boolean isSupported() {
47 | return SUPPORTS.contains(Bukkit.getMinecraftVersion());
48 | }
49 |
50 | @Override
51 | public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
52 | return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting);
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_8/src/main/java/io/github/hello09x/fakeplayer/v1_21_8/spi/NMSBridgeImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_8.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.*;
4 | import io.github.hello09x.fakeplayer.core.Main;
5 | import io.github.hello09x.fakeplayer.v1_21_6.spi.*;
6 | import org.bukkit.Bukkit;
7 | import org.bukkit.Server;
8 | import org.bukkit.World;
9 | import org.bukkit.entity.Entity;
10 | import org.bukkit.entity.Player;
11 | import org.jetbrains.annotations.NotNull;
12 |
13 | import java.net.InetAddress;
14 | import java.util.Set;
15 |
16 | public class NMSBridgeImpl implements NMSBridge {
17 |
18 | private final static Set SUPPORTS = Set.of("1.21.8");
19 |
20 | @Override
21 | public @NotNull NMSEntity fromEntity(@NotNull Entity entity) {
22 | return new NMSEntityImpl(entity);
23 | }
24 |
25 | @Override
26 | public @NotNull NMSServer fromServer(@NotNull Server server) {
27 | return new NMSServerImpl(server);
28 | }
29 |
30 | @Override
31 | public @NotNull NMSServerLevel fromWorld(@NotNull World world) {
32 | return new NMSServerLevelImpl(world);
33 | }
34 |
35 | @Override
36 | public @NotNull NMSServerPlayer fromPlayer(@NotNull Player player) {
37 | return new NMSServerPlayerImpl(player);
38 | }
39 |
40 | @Override
41 | public @NotNull NMSNetwork createNetwork(@NotNull InetAddress address) {
42 | return new NMSNetworkImpl(address);
43 | }
44 |
45 | @Override
46 | public boolean isSupported() {
47 | return SUPPORTS.contains(Bukkit.getMinecraftVersion());
48 | }
49 |
50 | @Override
51 | public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
52 | return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting);
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/fakeplayer-v1_21_10/src/main/java/io/github/hello09x/fakeplayer/v1_21_10/spi/NMSBridgeImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_21_10.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.*;
4 | import io.github.hello09x.fakeplayer.core.Main;
5 | import io.github.hello09x.fakeplayer.v1_21_9.spi.*;
6 | import org.bukkit.Bukkit;
7 | import org.bukkit.Server;
8 | import org.bukkit.World;
9 | import org.bukkit.entity.Entity;
10 | import org.bukkit.entity.Player;
11 | import org.jetbrains.annotations.NotNull;
12 |
13 | import java.net.InetAddress;
14 | import java.util.Set;
15 |
16 | public class NMSBridgeImpl implements NMSBridge {
17 |
18 | private final static Set SUPPORTS = Set.of("1.21.10");
19 |
20 | @Override
21 | public @NotNull NMSEntity fromEntity(@NotNull Entity entity) {
22 | return new NMSEntityImpl(entity);
23 | }
24 |
25 | @Override
26 | public @NotNull NMSServer fromServer(@NotNull Server server) {
27 | return new NMSServerImpl(server);
28 | }
29 |
30 | @Override
31 | public @NotNull NMSServerLevel fromWorld(@NotNull World world) {
32 | return new NMSServerLevelImpl(world);
33 | }
34 |
35 | @Override
36 | public @NotNull NMSServerPlayer fromPlayer(@NotNull Player player) {
37 | return new NMSServerPlayerImpl(player);
38 | }
39 |
40 | @Override
41 | public @NotNull NMSNetwork createNetwork(@NotNull InetAddress address) {
42 | return new NMSNetworkImpl(address);
43 | }
44 |
45 | @Override
46 | public boolean isSupported() {
47 | return SUPPORTS.contains(Bukkit.getMinecraftVersion());
48 | }
49 |
50 | @Override
51 | public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
52 | return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting);
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/TeleportCommand.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.command.impl;
2 |
3 | import com.google.inject.Singleton;
4 | import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
5 | import dev.jorel.commandapi.executors.CommandArguments;
6 | import io.github.hello09x.devtools.core.utils.EntityUtils;
7 | import org.bukkit.command.CommandSender;
8 | import org.bukkit.entity.Player;
9 | import org.jetbrains.annotations.NotNull;
10 |
11 | import static net.kyori.adventure.text.Component.translatable;
12 | import static net.kyori.adventure.text.format.NamedTextColor.RED;
13 |
14 | @Singleton
15 | public class TeleportCommand extends AbstractCommand {
16 |
17 | /**
18 | * 传送到假人
19 | */
20 | public void tp(@NotNull Player sender, @NotNull CommandArguments args) throws WrapperCommandSyntaxException {
21 | var fake = getFakeplayer(sender, args);
22 | this.teleport(sender, sender, fake);
23 | }
24 |
25 | /**
26 | * 将假人传送过来
27 | */
28 | public void tphere(@NotNull Player sender, @NotNull CommandArguments args) throws WrapperCommandSyntaxException {
29 | var fake = getFakeplayer(sender, args);
30 | this.teleport(sender, fake, sender);
31 | }
32 |
33 | /**
34 | * 与假人交换位置
35 | */
36 | public void tps(@NotNull Player sender, @NotNull CommandArguments args) throws WrapperCommandSyntaxException {
37 | var fake = getFakeplayer(sender, args);
38 |
39 | var l1 = sender.getLocation();
40 | var l2 = fake.getLocation();
41 |
42 | EntityUtils.teleportAndSound(fake, l1);
43 | EntityUtils.teleportAndSound(sender, l2);
44 | }
45 |
46 | private void teleport(@NotNull CommandSender sender, @NotNull Player from, @NotNull Player to) {
47 | if (!EntityUtils.teleportAndSound(from, to.getLocation())) {
48 | sender.sendMessage(translatable("fakeplayer.command.teleport.error.canceled", RED));
49 | }
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/fakeplayer-v1_20_1/src/main/java/io/github/hello09x/fakeplayer/v1_20_1/spi/NMSNetworkImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.v1_20_1.spi;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.NMSNetwork;
4 | import io.github.hello09x.fakeplayer.api.spi.NMSServerGamePacketListener;
5 | import io.github.hello09x.fakeplayer.v1_20_1.network.FakeConnection;
6 | import io.github.hello09x.fakeplayer.v1_20_1.network.FakeServerGamePacketListenerImpl;
7 | import org.bukkit.Server;
8 | import org.bukkit.craftbukkit.v1_20_R1.CraftServer;
9 | import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
10 | import org.bukkit.entity.Player;
11 | import org.jetbrains.annotations.NotNull;
12 |
13 | import java.net.InetAddress;
14 |
15 | public class NMSNetworkImpl implements NMSNetwork {
16 |
17 | private final @NotNull FakeConnection connection;
18 |
19 | private NMSServerGamePacketListener serverGamePacketListener;
20 |
21 | public NMSNetworkImpl(
22 | @NotNull InetAddress address
23 | ) {
24 | this.connection = new FakeConnection(address);
25 | }
26 |
27 | @Override
28 | public @NotNull NMSServerGamePacketListener placeNewPlayer(@NotNull Server server, @NotNull Player player) {
29 | var handle = ((CraftPlayer) player).getHandle();
30 | ((CraftServer) server).getHandle().placeNewPlayer(
31 | this.connection,
32 | handle
33 | );
34 | var listener = new FakeServerGamePacketListenerImpl(
35 | ((CraftServer) server).getServer(),
36 | this.connection,
37 | handle
38 | );
39 | this.serverGamePacketListener = listener;
40 | handle.connection = listener;
41 | return listener;
42 | }
43 |
44 | @NotNull
45 | @Override
46 | public NMSServerGamePacketListener getServerGamePacketListener() throws IllegalStateException {
47 | if (this.serverGamePacketListener == null) {
48 | throw new IllegalStateException("not initialized");
49 | }
50 | return this.serverGamePacketListener;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/MoveCommand.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.command.impl;
2 |
3 | import com.google.inject.Singleton;
4 | import dev.jorel.commandapi.executors.CommandExecutor;
5 | import io.github.hello09x.fakeplayer.core.Main;
6 | import org.bukkit.scheduler.BukkitRunnable;
7 | import org.bukkit.scheduler.BukkitTask;
8 | import org.jetbrains.annotations.Range;
9 |
10 | import java.util.HashMap;
11 | import java.util.Map;
12 | import java.util.UUID;
13 |
14 | @Singleton
15 | public class MoveCommand extends AbstractCommand {
16 |
17 | private final Map stopTasks = new HashMap<>();
18 |
19 | /**
20 | * 假人移动
21 | */
22 | public CommandExecutor move(@Range(from = 0, to = 1) float forward, @Range(from = 0, to = 1) float strafing) {
23 | return (sender, args) -> {
24 | var fake = getFakeplayer(sender, args);
25 | var handle = bridge.fromPlayer(fake);
26 | float vel = fake.isSneaking() ? 0.3F : 1.0F;
27 | if (forward != 0.0F) {
28 | handle.setZza(vel * forward);
29 | }
30 | if (strafing != 0.0F) {
31 | handle.setXxa(vel * strafing);
32 | }
33 |
34 | var task = stopTasks.remove(fake.getUniqueId());
35 | if (task != null && !task.isCancelled()) {
36 | task.cancel();
37 | }
38 |
39 | var fakeId = fake.getUniqueId();
40 | var stopping = new BukkitRunnable() {
41 | @Override
42 | public void run() {
43 | handle.setXxa(0);
44 | handle.setZza(0);
45 | var self = stopTasks.get(fakeId);
46 | if (self != null && self.getTaskId() == this.getTaskId()) {
47 | stopTasks.remove(fakeId);
48 | }
49 | }
50 | };
51 |
52 | this.stopTasks.put(fakeId, stopping.runTaskLater(Main.getInstance(), fake.isSprinting() ? 40 : 20));
53 | };
54 | }
55 |
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/util/update/UpdateChecker.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.util.update;
2 |
3 | import com.google.gson.Gson;
4 | import io.github.hello09x.devtools.core.version.InvalidVersionException;
5 | import io.github.hello09x.devtools.core.version.Version;
6 | import org.jetbrains.annotations.NotNull;
7 |
8 | import java.io.IOException;
9 | import java.net.URI;
10 | import java.net.http.HttpClient;
11 | import java.net.http.HttpRequest;
12 | import java.net.http.HttpResponse;
13 | import java.nio.charset.StandardCharsets;
14 |
15 | public class UpdateChecker {
16 |
17 | private final static Gson gson = new Gson();
18 |
19 | private final String author;
20 |
21 | private final String repository;
22 |
23 | public UpdateChecker(@NotNull String author, @NotNull String repository) {
24 | this.author = author;
25 | this.repository = repository;
26 | }
27 |
28 | public static boolean isNew(@NotNull String local, @NotNull String remote) {
29 | Version a, b;
30 | try {
31 | a = Version.parse(local);
32 | b = Version.parse(remote);
33 | } catch (InvalidVersionException e) {
34 | return false;
35 | }
36 |
37 | return a.compareTo(b) < 0;
38 | }
39 |
40 | public @NotNull Release getLastRelease() throws IOException, InterruptedException {
41 | var url = String.format("https://api.github.com/repos/%s/%s/releases/latest", this.author, this.repository);
42 | var client = HttpClient.newHttpClient();
43 | var request = HttpRequest.newBuilder()
44 | .uri(URI.create(url))
45 | .GET()
46 | .build();
47 |
48 | var response = client.send(request, HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8));
49 | if (response.statusCode() != 200) {
50 | throw new IllegalStateException("Not 200 response: " + response.statusCode() + ": " + response.body());
51 | }
52 |
53 | var body = response.body();
54 | return gson.fromJson(body, Release.class);
55 | }
56 |
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/util/Reflections.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.util;
2 |
3 | import org.checkerframework.checker.units.qual.N;
4 | import org.jetbrains.annotations.NotNull;
5 | import org.jetbrains.annotations.Nullable;
6 |
7 | import java.lang.reflect.Field;
8 | import java.lang.reflect.Modifier;
9 |
10 | public class Reflections {
11 |
12 | public static @Nullable Field getFirstFieldByType(
13 | @NotNull Class> clazz,
14 | @NotNull Class> fieldType,
15 | boolean includeStatic
16 | ) {
17 | for (var field : clazz.getDeclaredFields()) {
18 | if (includeStatic ^ Modifier.isStatic(field.getModifiers())) {
19 | continue;
20 | }
21 | if (field.getType() == fieldType) {
22 | field.setAccessible(true);
23 | return field;
24 | }
25 | }
26 | return null;
27 | }
28 |
29 |
30 | public static @N Field getFistFieldByTypeIncludeParent(
31 | @NotNull Class> clazz,
32 | @NotNull Class> fieldType
33 | ) {
34 | for (var field : clazz.getDeclaredFields()) {
35 | if (field.getType() == fieldType) {
36 | field.setAccessible(true);
37 | return field;
38 | }
39 | }
40 | var superclass = clazz.getSuperclass();
41 | if (superclass == null || superclass == Object.class) {
42 | return null;
43 | }
44 | return getFistFieldByTypeIncludeParent(superclass, fieldType);
45 | }
46 |
47 | public static @Nullable Field getFirstFieldByAssignFromType(
48 | @NotNull Class> clazz,
49 | @NotNull Class> fieldType,
50 | boolean includeStatic
51 | ) {
52 | for (var field : clazz.getDeclaredFields()) {
53 | if (includeStatic ^ Modifier.isStatic(field.getModifiers())) {
54 | continue;
55 | }
56 | if (fieldType.isAssignableFrom(field.getType())) {
57 | field.setAccessible(true);
58 | return field;
59 | }
60 | }
61 | return null;
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/Permission.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.command;
2 |
3 | public interface Permission {
4 |
5 | String spawn = "fakeplayer.command.spawn";
6 | String spawnName = "fakeplayer.command.spawn.name";
7 | String spawnLocation = "fakeplayer.command.spawn.location";
8 |
9 | String select = "fakeplayer.command.select";
10 | String selection = "fakeplayer.command.selection";
11 |
12 | String kill = "fakeplayer.command.kill";
13 | String list = "fakeplayer.command.list";
14 | String distance = "fakeplayer.command.distance";
15 | String drop = "fakeplayer.command.drop";
16 | String dropstack = "fakeplayer.command.dropstack";
17 | String dropinv = "fakeplayer.command.dropinv";
18 | String skin = "fakeplayer.command.skin";
19 | String invsee = "fakeplayer.command.invsee";
20 | String hold = "fakeplayer.command.hold";
21 | String status = "fakeplayer.command.status";
22 | String respawn = "fakeplayer.command.respawn";
23 | String expme = "fakeplayer.command.expme";
24 | String tp = "fakeplayer.command.tp";
25 | String tphere = "fakeplayer.command.tphere";
26 | String tps = "fakeplayer.command.tps";
27 | String set = "fakeplayer.command.set";
28 | String config = "fakeplayer.command.config";
29 | String mine = "fakeplayer.command.mine";
30 | String attack = "fakeplayer.command.attack";
31 | String use = "fakeplayer.command.use";
32 | String jump = "fakeplayer.command.jump";
33 | String sneak = "fakeplayer.command.sneak";
34 | String sprint = "fakeplayer.command.sprint";
35 | String look = "fakeplayer.command.look";
36 | String turn = "fakeplayer.command.turn";
37 | String move = "fakeplayer.command.move";
38 | String ride = "fakeplayer.command.ride";
39 | String swap = "fakeplayer.command.swap";
40 | String replenish = "fakeplayer.config.replenish";
41 | String replenishFromChest = "fakeplayer.config.replenish.chest";
42 | String autofish = "fakeplayer.config.autofish";
43 | String sleep = "fakeplayer.command.sleep";
44 | String wakeup = "fakeplayer.command.wakeup";
45 | String cmd = "fakeplayer.command.cmd";
46 | String stop = "fakeplayer.command.stop";
47 |
48 |
49 | String op = "OP";
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/entity/action/impl/LookAtEntityAction.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.entity.action.impl;
2 |
3 | import io.github.hello09x.fakeplayer.api.spi.Action;
4 | import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer;
5 | import io.papermc.paper.entity.LookAnchor;
6 | import org.bukkit.entity.Damageable;
7 | import org.bukkit.entity.Entity;
8 | import org.bukkit.entity.Player;
9 | import org.jetbrains.annotations.NotNull;
10 | import org.jetbrains.annotations.Nullable;
11 |
12 | import java.util.Collection;
13 |
14 | public class LookAtEntityAction implements Action {
15 |
16 |
17 | @NotNull
18 | private final NMSServerPlayer player;
19 |
20 | public LookAtEntityAction(@NotNull NMSServerPlayer player) {
21 | this.player = player;
22 | }
23 |
24 |
25 | @Override
26 | public boolean tick() {
27 | var bukkitPlayer = player.getPlayer();
28 | var entities = bukkitPlayer.getLocation().getNearbyEntitiesByType(Damageable.class, 4.5, 4.5, 4.5);
29 | if (entities.isEmpty()) {
30 | return false;
31 | }
32 |
33 | var entity = this.getNearestEntity(bukkitPlayer, entities);
34 | if (entity == null) {
35 | return false;
36 | }
37 |
38 | bukkitPlayer.lookAt(entity, LookAnchor.EYES, LookAnchor.EYES);
39 | player.resetLastActionTime();
40 | return true;
41 | }
42 |
43 | @Override
44 | public void inactiveTick() {
45 |
46 | }
47 |
48 | @Override
49 | public void stop() {
50 |
51 | }
52 |
53 | private @Nullable Entity getNearestEntity(@NotNull Player player, @NotNull Collection extends Entity> entities) {
54 | if (entities.isEmpty()) {
55 | return null;
56 | }
57 | var loc = player.getLocation();
58 | Entity nearest = null;
59 | double distance = 0;
60 | for (var entity : entities) {
61 | if (nearest == null) {
62 | nearest = entity;
63 | } else {
64 | var d = loc.distance(entity.getLocation());
65 | if (d < distance) {
66 | nearest = entity;
67 | distance = d;
68 | }
69 | }
70 | }
71 | return nearest;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/util/Skins.java:
--------------------------------------------------------------------------------
1 | package io.github.hello09x.fakeplayer.core.util;
2 |
3 | import com.destroystokyo.paper.profile.PlayerProfile;
4 | import io.github.hello09x.devtools.core.utils.SchedulerUtils;
5 | import org.bukkit.OfflinePlayer;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.plugin.java.JavaPlugin;
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | import java.util.concurrent.CompletableFuture;
11 |
12 | public class Skins {
13 |
14 | /**
15 | * 复制皮肤, 仅能复制在线玩家的皮肤
16 | *
17 | * @param from 皮肤来源
18 | * @param to 复制到
19 | * @return 是否复制成功
20 | */
21 | public static boolean copySkin(@NotNull OfflinePlayer from, @NotNull Player to) {
22 | var profile = from.getPlayerProfile();
23 | if (profile.hasTextures()) {
24 | copyTexture(profile, to);
25 | return true;
26 | }
27 | return false;
28 | }
29 |
30 | /**
31 | * 复制皮肤, 如果来源玩家不在线, 则通过 mojang API 下载皮肤后再复制
32 | *
33 | * @param from 皮肤来源
34 | * @param to 复制到
35 | */
36 | public static CompletableFuture copySkinFromMojang(@NotNull JavaPlugin plugin, @NotNull OfflinePlayer from, @NotNull Player to) {
37 | if (copySkin(from, to)) {
38 | return CompletableFuture.completedFuture(true);
39 | }
40 |
41 | var profile = from.getPlayerProfile();
42 | return CompletableFuture
43 | .supplyAsync(profile::complete)
44 | .thenComposeAsync(completed -> SchedulerUtils.runTask(plugin, () -> {
45 | if (!completed) {
46 | return false;
47 | }
48 | try {
49 | copyTexture(profile, to);
50 | return true;
51 | } catch (Throwable e) {
52 | return false;
53 | }
54 | }));
55 | }
56 |
57 | private static void copyTexture(@NotNull PlayerProfile from, @NotNull Player to) {
58 | var profile = to.getPlayerProfile();
59 | profile.setTextures(from.getTextures());
60 | from.getProperties().stream().filter(p -> p.getName().equals("textures")).findAny().ifPresent(profile::setProperty);
61 | to.setPlayerProfile(profile);
62 | }
63 |
64 |
65 | }
66 |
--------------------------------------------------------------------------------