Supports 1.21.1

This commit is contained in:
tanyaofei 2024-08-16 09:41:15 +08:00
parent ce13799ce2
commit ffb2575627
99 changed files with 1201 additions and 693 deletions

View File

@ -161,6 +161,11 @@ If your server does not restrict various player commands, you can use this direc
`fakeplayer.basic` includes all secure permissions, except for `/fp cmd` commands.
</details>
## Placeholder Variables
+ `%fakeplayer_total%`: Total count of fake players
+ `%fakeplayer_creator%`: The creator name of a fake player
+ `%fakeplayer_actions`: Active actions of a fake player such as : `USE|ATTACK`
# Custom Translation
1. Create a `message` folder in `plugins/fakeplayer`
2. Copy [this file](fakeplayer-core/src/main/resources/message/message.properties) to `message` folder

View File

@ -7,6 +7,7 @@ import io.github.hello09x.fakeplayer.api.spi.NMSBridge;
import io.github.hello09x.fakeplayer.core.config.FakeplayerConfig;
import io.github.hello09x.fakeplayer.core.manager.FakeplayerList;
import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
import io.github.hello09x.fakeplayer.core.manager.action.ActionManager;
import io.github.hello09x.fakeplayer.core.manager.invsee.InvseeManager;
import io.github.hello09x.fakeplayer.core.manager.invsee.OpenInvInvseeManagerImpl;
import io.github.hello09x.fakeplayer.core.manager.invsee.SimpleInvseeManagerImpl;
@ -15,6 +16,7 @@ import io.github.hello09x.fakeplayer.core.placeholder.FakeplayerPlaceholderExpan
import io.github.hello09x.fakeplayer.core.util.ClassUtils;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ServiceLoader;
@ -31,7 +33,7 @@ public class FakeplayerModule extends AbstractModule {
@Provides
@Singleton
public InvseeManager invseeManager(FakeplayerConfig config, FakeplayerManager fakeplayerManager, FakeplayerList fakeplayerList) {
public @NotNull InvseeManager invseeManager(FakeplayerConfig config, FakeplayerManager fakeplayerManager, FakeplayerList fakeplayerList) {
return switch (config.getInvseeImplement()) {
case SIMPLE -> new SimpleInvseeManagerImpl(fakeplayerManager, fakeplayerList);
case AUTO -> {
@ -47,7 +49,7 @@ public class FakeplayerModule extends AbstractModule {
@Provides
@Singleton
private NMSBridge nmsBridge() {
private @NotNull NMSBridge nmsBridge() {
var bridge = ServiceLoader
.load(NMSBridge.class, NMSBridge.class.getClassLoader())
.stream()
@ -64,11 +66,11 @@ public class FakeplayerModule extends AbstractModule {
@Singleton
@Provides
private @Nullable FakeplayerPlaceholderExpansion fakeplayerPlaceholderExpansion(FakeplayerManager fakeplayerManager) {
private @Nullable FakeplayerPlaceholderExpansion fakeplayerPlaceholderExpansion(FakeplayerManager fakeplayerManager, ActionManager actionManager) {
if (!Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI") || !ClassUtils.isClassExists("me.clip.placeholderapi.expansion.PlaceholderExpansion")) {
return null;
}
return new FakeplayerPlaceholderExpansionImpl(fakeplayerManager);
return new FakeplayerPlaceholderExpansionImpl(fakeplayerManager, actionManager);
}
}

View File

@ -11,12 +11,11 @@ import io.github.hello09x.fakeplayer.core.Main;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.*;
import java.util.logging.Logger;
import java.util.stream.Collectors;
@Singleton
public class ActionManager {
@ -44,6 +43,19 @@ public class ActionManager {
.isPresent();
}
public @NotNull @Unmodifiable Set<ActionType> getActiveActions(@NotNull Player player) {
var manager = this.managers.get(player.getUniqueId());
if (manager == null || managers.isEmpty()) {
return Collections.emptySet();
}
return manager.entrySet()
.stream()
.filter(actions -> actions.getValue().getSetting().remains > 0)
.map(Map.Entry::getKey)
.collect(Collectors.toSet());
}
public void setAction(
@NotNull Player player,
@NotNull ActionType action,

View File

@ -5,6 +5,7 @@ import com.google.inject.Inject;
import com.google.inject.Singleton;
import io.github.hello09x.fakeplayer.core.Main;
import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
import io.github.hello09x.fakeplayer.core.manager.action.ActionManager;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -13,6 +14,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @author tanyaofei
@ -22,10 +24,12 @@ import java.util.Optional;
public class FakeplayerPlaceholderExpansionImpl extends PlaceholderExpansion implements FakeplayerPlaceholderExpansion {
private final FakeplayerManager manager;
private final ActionManager actionManager;
@Inject
public FakeplayerPlaceholderExpansionImpl(FakeplayerManager manager) {
public FakeplayerPlaceholderExpansionImpl(FakeplayerManager manager, ActionManager actionManager) {
this.manager = manager;
this.actionManager = actionManager;
}
@Override
@ -55,6 +59,11 @@ public class FakeplayerPlaceholderExpansionImpl extends PlaceholderExpansion imp
return Optional.ofNullable(manager.getCreatorName(player)).orElse(params);
}
// papi parse CONSOLE_1 fakeplayer_actions
if (params.equalsIgnoreCase("actions") && player != null && manager.isFake(player)) {
return actionManager.getActiveActions(player).stream().map(Enum::name).collect(Collectors.joining("|"));
}
return params;
}

View File

@ -32,31 +32,49 @@
<dependency>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-v1_20_R1</artifactId>
<artifactId>fakeplayer-v1_20_1</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-v1_20_R2</artifactId>
<artifactId>fakeplayer-v1_20_2</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-v1_20_R3_R4</artifactId>
<artifactId>fakeplayer-v1_20_3</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-v1_20_R5_R6</artifactId>
<artifactId>fakeplayer-v1_20_4</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-v1_21_R1</artifactId>
<artifactId>fakeplayer-v1_20_5</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-v1_20_6</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-v1_21</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-v1_21_1</artifactId>
<version>${revision}</version>
</dependency>
@ -119,6 +137,11 @@
<include name="fakeplayer-${revision}.jar"/>
</fileset>
</copy>
<copy tofile="../server-1.21.1/plugins/fakeplayer.jar">
<fileset dir="${project.build.directory}">
<include name="fakeplayer-${revision}.jar"/>
</fileset>
</copy>
</target>
</configuration>
<goals>

View File

@ -1,5 +1,8 @@
io.github.hello09x.fakeplayer.v1_20_R1.spi.NMSBridgeImpl
io.github.hello09x.fakeplayer.v1_20_R2.spi.NMSBridgeImpl
io.github.hello09x.fakeplayer.v1_20_R3_R4.spi.NMSBridgeImpl
io.github.hello09x.fakeplayer.v1_20_R5_R6.spi.NMSBridgeImpl
io.github.hello09x.fakeplayer.v1_21_R1.spi.NMSBridgeImpl
io.github.hello09x.fakeplayer.v1_20_1.spi.NMSBridgeImpl
io.github.hello09x.fakeplayer.v1_20_2.spi.NMSBridgeImpl
io.github.hello09x.fakeplayer.v1_20_3.spi.NMSBridgeImpl
io.github.hello09x.fakeplayer.v1_20_4.spi.NMSBridgeImpl
io.github.hello09x.fakeplayer.v1_20_5.spi.NMSBridgeImpl
io.github.hello09x.fakeplayer.v1_20_6.spi.NMSBridgeImpl
io.github.hello09x.fakeplayer.v1_21.spi.NMSBridgeImpl
io.github.hello09x.fakeplayer.v1_21_1.spi.NMSBridgeImpl

View File

@ -9,7 +9,7 @@
<version>${revision}</version>
</parent>
<artifactId>fakeplayer-v1_20_R1</artifactId>
<artifactId>fakeplayer-v1_20_1</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_21_R1.action;
package io.github.hello09x.fakeplayer.v1_20_1.action;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_21_R1.action;
package io.github.hello09x.fakeplayer.v1_20_1.action;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;

View File

@ -1,7 +1,7 @@
package io.github.hello09x.fakeplayer.v1_20_R2.action;
package io.github.hello09x.fakeplayer.v1_20_1.action;
import io.github.hello09x.fakeplayer.api.spi.Action;
import io.github.hello09x.fakeplayer.v1_20_R2.action.util.Tracer;
import io.github.hello09x.fakeplayer.v1_20_1.action.util.Tracer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.phys.HitResult;
import org.jetbrains.annotations.NotNull;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_21_R1.action;
package io.github.hello09x.fakeplayer.v1_20_1.action;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerPlayer;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_21_R1.action.util;
package io.github.hello09x.fakeplayer.v1_20_1.action.util;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.ClipContext;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R1.network;
package io.github.hello09x.fakeplayer.v1_20_1.network;
import io.github.hello09x.fakeplayer.core.network.FakeChannel;
import net.minecraft.network.Connection;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R1.network;
package io.github.hello09x.fakeplayer.v1_20_1.network;
import com.mojang.datafixers.DataFixer;
import net.minecraft.advancements.Advancement;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R1.network;
package io.github.hello09x.fakeplayer.v1_20_1.network;
import io.github.hello09x.fakeplayer.api.spi.NMSServerGamePacketListener;
import io.github.hello09x.fakeplayer.core.Main;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R1.spi;
package io.github.hello09x.fakeplayer.v1_20_1.spi;
import io.github.hello09x.fakeplayer.api.spi.ActionSetting;
@ -6,9 +6,9 @@ import io.github.hello09x.fakeplayer.api.spi.ActionTicker;
import io.github.hello09x.fakeplayer.api.spi.ActionType;
import io.github.hello09x.fakeplayer.api.spi.NMSBridge;
import io.github.hello09x.fakeplayer.core.entity.action.BaseActionTicker;
import io.github.hello09x.fakeplayer.v1_20_R1.action.AttackAction;
import io.github.hello09x.fakeplayer.v1_20_R1.action.MineAction;
import io.github.hello09x.fakeplayer.v1_20_R1.action.UseAction;
import io.github.hello09x.fakeplayer.v1_20_1.action.AttackAction;
import io.github.hello09x.fakeplayer.v1_20_1.action.MineAction;
import io.github.hello09x.fakeplayer.v1_20_1.action.UseAction;
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R1.spi;
package io.github.hello09x.fakeplayer.v1_20_1.spi;
import io.github.hello09x.fakeplayer.api.spi.*;
import io.github.hello09x.fakeplayer.core.Main;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R1.spi;
package io.github.hello09x.fakeplayer.v1_20_1.spi;
import io.github.hello09x.fakeplayer.api.spi.NMSEntity;
import lombok.Getter;

View File

@ -1,9 +1,9 @@
package io.github.hello09x.fakeplayer.v1_20_R1.spi;
package io.github.hello09x.fakeplayer.v1_20_1.spi;
import io.github.hello09x.fakeplayer.api.spi.NMSNetwork;
import io.github.hello09x.fakeplayer.api.spi.NMSServerGamePacketListener;
import io.github.hello09x.fakeplayer.v1_20_R1.network.FakeConnection;
import io.github.hello09x.fakeplayer.v1_20_R1.network.FakeServerGamePacketListenerImpl;
import io.github.hello09x.fakeplayer.v1_20_1.network.FakeConnection;
import io.github.hello09x.fakeplayer.v1_20_1.network.FakeServerGamePacketListenerImpl;
import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_20_R1.CraftServer;
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R1.spi;
package io.github.hello09x.fakeplayer.v1_20_1.spi;
import com.mojang.authlib.GameProfile;
import io.github.hello09x.devtools.core.utils.WorldUtils;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R1.spi;
package io.github.hello09x.fakeplayer.v1_20_1.spi;
import io.github.hello09x.fakeplayer.api.spi.NMSServerLevel;
import lombok.Getter;

View File

@ -1,9 +1,9 @@
package io.github.hello09x.fakeplayer.v1_20_R1.spi;
package io.github.hello09x.fakeplayer.v1_20_1.spi;
import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer;
import io.github.hello09x.fakeplayer.core.constant.ConstantPool;
import io.github.hello09x.fakeplayer.core.util.Reflections;
import io.github.hello09x.fakeplayer.v1_20_R1.network.FakePlayerAdvancements;
import io.github.hello09x.fakeplayer.v1_20_1.network.FakePlayerAdvancements;
import lombok.Getter;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;

View File

@ -9,7 +9,7 @@
<version>${revision}</version>
</parent>
<artifactId>fakeplayer-v1_20_R2</artifactId>
<artifactId>fakeplayer-v1_20_2</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R1.action;
package io.github.hello09x.fakeplayer.v1_20_2.action;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R1.action;
package io.github.hello09x.fakeplayer.v1_20_2.action;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;

View File

@ -1,7 +1,7 @@
package io.github.hello09x.fakeplayer.v1_21_R1.action;
package io.github.hello09x.fakeplayer.v1_20_2.action;
import io.github.hello09x.fakeplayer.api.spi.Action;
import io.github.hello09x.fakeplayer.v1_21_R1.action.util.Tracer;
import io.github.hello09x.fakeplayer.v1_20_2.action.util.Tracer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.phys.HitResult;
import org.jetbrains.annotations.NotNull;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R1.action;
package io.github.hello09x.fakeplayer.v1_20_2.action;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerPlayer;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R2.action.util;
package io.github.hello09x.fakeplayer.v1_20_2.action.util;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.ClipContext;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R2.network;
package io.github.hello09x.fakeplayer.v1_20_2.network;
import io.github.hello09x.fakeplayer.core.network.FakeChannel;
import net.minecraft.network.Connection;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R2.network;
package io.github.hello09x.fakeplayer.v1_20_2.network;
import com.mojang.datafixers.DataFixer;
import net.minecraft.advancements.AdvancementHolder;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R2.network;
package io.github.hello09x.fakeplayer.v1_20_2.network;
import io.github.hello09x.fakeplayer.api.spi.NMSServerGamePacketListener;
import io.github.hello09x.fakeplayer.core.Main;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R2.spi;
package io.github.hello09x.fakeplayer.v1_20_2.spi;
import io.github.hello09x.fakeplayer.api.spi.ActionSetting;
@ -6,9 +6,9 @@ import io.github.hello09x.fakeplayer.api.spi.ActionTicker;
import io.github.hello09x.fakeplayer.api.spi.ActionType;
import io.github.hello09x.fakeplayer.api.spi.NMSBridge;
import io.github.hello09x.fakeplayer.core.entity.action.BaseActionTicker;
import io.github.hello09x.fakeplayer.v1_20_R2.action.AttackAction;
import io.github.hello09x.fakeplayer.v1_20_R2.action.MineAction;
import io.github.hello09x.fakeplayer.v1_20_R2.action.UseAction;
import io.github.hello09x.fakeplayer.v1_20_2.action.AttackAction;
import io.github.hello09x.fakeplayer.v1_20_2.action.MineAction;
import io.github.hello09x.fakeplayer.v1_20_2.action.UseAction;
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R2.spi;
package io.github.hello09x.fakeplayer.v1_20_2.spi;
import io.github.hello09x.fakeplayer.api.spi.*;
import io.github.hello09x.fakeplayer.core.Main;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R2.spi;
package io.github.hello09x.fakeplayer.v1_20_2.spi;
import io.github.hello09x.fakeplayer.api.spi.NMSEntity;
import lombok.Getter;

View File

@ -1,9 +1,9 @@
package io.github.hello09x.fakeplayer.v1_20_R2.spi;
package io.github.hello09x.fakeplayer.v1_20_2.spi;
import io.github.hello09x.fakeplayer.api.spi.NMSNetwork;
import io.github.hello09x.fakeplayer.api.spi.NMSServerGamePacketListener;
import io.github.hello09x.fakeplayer.v1_20_R2.network.FakeConnection;
import io.github.hello09x.fakeplayer.v1_20_R2.network.FakeServerGamePacketListenerImpl;
import io.github.hello09x.fakeplayer.v1_20_2.network.FakeConnection;
import io.github.hello09x.fakeplayer.v1_20_2.network.FakeServerGamePacketListenerImpl;
import net.minecraft.network.ConnectionProtocol;
import net.minecraft.server.network.CommonListenerCookie;
import org.bukkit.Server;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R2.spi;
package io.github.hello09x.fakeplayer.v1_20_2.spi;
import com.mojang.authlib.GameProfile;
import io.github.hello09x.devtools.core.utils.WorldUtils;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R2.spi;
package io.github.hello09x.fakeplayer.v1_20_2.spi;
import io.github.hello09x.fakeplayer.api.spi.NMSServerLevel;
import lombok.Getter;

View File

@ -1,9 +1,9 @@
package io.github.hello09x.fakeplayer.v1_20_R2.spi;
package io.github.hello09x.fakeplayer.v1_20_2.spi;
import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer;
import io.github.hello09x.fakeplayer.core.constant.ConstantPool;
import io.github.hello09x.fakeplayer.core.util.Reflections;
import io.github.hello09x.fakeplayer.v1_20_R2.network.FakePlayerAdvancements;
import io.github.hello09x.fakeplayer.v1_20_2.network.FakePlayerAdvancements;
import lombok.Getter;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;

102
fakeplayer-v1_20_3/pom.xml Normal file
View File

@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-parent</artifactId>
<version>${revision}</version>
</parent>
<artifactId>fakeplayer-v1_20_3</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<nms.version>1.20.4-R0.1-SNAPSHOT</nms.version>
</properties>
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-v1_20_4</artifactId>
<version>${revision}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>${nms.version}</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>2.0.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:${nms.version}:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>
org.spigotmc:spigot:${nms.version}:jar:remapped-mojang
</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>
${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar
</inputFile>
<srgIn>org.spigotmc:minecraft-server:${nms.version}:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:${nms.version}:jar:remapped-obf
</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,55 @@
package io.github.hello09x.fakeplayer.v1_20_3.spi;
import io.github.hello09x.fakeplayer.api.spi.*;
import io.github.hello09x.fakeplayer.core.Main;
import io.github.hello09x.fakeplayer.v1_20_4.spi.*;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.net.InetAddress;
import java.util.Set;
public class NMSBridgeImpl implements NMSBridge {
private final static Set<String> SUPPORTS = Set.of("1.20.3");
@Override
public @NotNull NMSEntity fromEntity(@NotNull Entity entity) {
return new NMSEntityImpl(entity);
}
@Override
public @NotNull NMSServer fromServer(@NotNull Server server) {
return new NMSServerImpl(server);
}
@Override
public @NotNull NMSServerLevel fromWorld(@NotNull World world) {
return new NMSServerLevelImpl(world);
}
@Override
public @NotNull NMSServerPlayer fromPlayer(@NotNull Player player) {
return new NMSServerPlayerImpl(player);
}
@Override
public @NotNull NMSNetwork createNetwork(@NotNull InetAddress address) {
return new NMSNetworkImpl(address);
}
@Override
public boolean isSupported() {
return SUPPORTS.contains(Bukkit.getMinecraftVersion());
}
@Override
public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting);
}
}

View File

@ -9,7 +9,7 @@
<version>${revision}</version>
</parent>
<artifactId>fakeplayer-v1_20_R3_R4</artifactId>
<artifactId>fakeplayer-v1_20_4</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R2.action;
package io.github.hello09x.fakeplayer.v1_20_4.action;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R2.action;
package io.github.hello09x.fakeplayer.v1_20_4.action;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;

View File

@ -1,7 +1,7 @@
package io.github.hello09x.fakeplayer.v1_20_R1.action;
package io.github.hello09x.fakeplayer.v1_20_4.action;
import io.github.hello09x.fakeplayer.api.spi.Action;
import io.github.hello09x.fakeplayer.v1_20_R1.action.util.Tracer;
import io.github.hello09x.fakeplayer.v1_20_4.action.util.Tracer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.phys.HitResult;
import org.jetbrains.annotations.NotNull;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R2.action;
package io.github.hello09x.fakeplayer.v1_20_4.action;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerPlayer;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R1.action.util;
package io.github.hello09x.fakeplayer.v1_20_4.action.util;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.ClipContext;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R3_R4.network;
package io.github.hello09x.fakeplayer.v1_20_4.network;
import io.github.hello09x.fakeplayer.core.network.FakeChannel;
import net.minecraft.network.Connection;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_21_R1.network;
package io.github.hello09x.fakeplayer.v1_20_4.network;
import com.mojang.datafixers.DataFixer;
import net.minecraft.advancements.AdvancementHolder;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R3_R4.network;
package io.github.hello09x.fakeplayer.v1_20_4.network;
import io.github.hello09x.fakeplayer.api.spi.NMSServerGamePacketListener;
import io.github.hello09x.fakeplayer.core.Main;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R3_R4.spi;
package io.github.hello09x.fakeplayer.v1_20_4.spi;
import io.github.hello09x.fakeplayer.api.spi.ActionSetting;
@ -6,9 +6,9 @@ import io.github.hello09x.fakeplayer.api.spi.ActionTicker;
import io.github.hello09x.fakeplayer.api.spi.ActionType;
import io.github.hello09x.fakeplayer.api.spi.NMSBridge;
import io.github.hello09x.fakeplayer.core.entity.action.BaseActionTicker;
import io.github.hello09x.fakeplayer.v1_20_R3_R4.action.AttackAction;
import io.github.hello09x.fakeplayer.v1_20_R3_R4.action.MineAction;
import io.github.hello09x.fakeplayer.v1_20_R3_R4.action.UseAction;
import io.github.hello09x.fakeplayer.v1_20_4.action.AttackAction;
import io.github.hello09x.fakeplayer.v1_20_4.action.MineAction;
import io.github.hello09x.fakeplayer.v1_20_4.action.UseAction;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R3_R4.spi;
package io.github.hello09x.fakeplayer.v1_20_4.spi;
import io.github.hello09x.fakeplayer.api.spi.*;
import io.github.hello09x.fakeplayer.core.Main;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R3_R4.spi;
package io.github.hello09x.fakeplayer.v1_20_4.spi;
import io.github.hello09x.fakeplayer.api.spi.NMSEntity;
import lombok.Getter;

View File

@ -1,9 +1,9 @@
package io.github.hello09x.fakeplayer.v1_20_R3_R4.spi;
package io.github.hello09x.fakeplayer.v1_20_4.spi;
import io.github.hello09x.fakeplayer.api.spi.NMSNetwork;
import io.github.hello09x.fakeplayer.api.spi.NMSServerGamePacketListener;
import io.github.hello09x.fakeplayer.v1_20_R3_R4.network.FakeConnection;
import io.github.hello09x.fakeplayer.v1_20_R3_R4.network.FakeServerGamePacketListenerImpl;
import io.github.hello09x.fakeplayer.v1_20_4.network.FakeConnection;
import io.github.hello09x.fakeplayer.v1_20_4.network.FakeServerGamePacketListenerImpl;
import net.minecraft.network.ConnectionProtocol;
import net.minecraft.server.network.CommonListenerCookie;
import org.bukkit.Server;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R3_R4.spi;
package io.github.hello09x.fakeplayer.v1_20_4.spi;
import com.mojang.authlib.GameProfile;
import io.github.hello09x.devtools.core.utils.WorldUtils;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R3_R4.spi;
package io.github.hello09x.fakeplayer.v1_20_4.spi;
import io.github.hello09x.fakeplayer.api.spi.NMSServerLevel;
import lombok.Getter;

View File

@ -1,9 +1,9 @@
package io.github.hello09x.fakeplayer.v1_20_R3_R4.spi;
package io.github.hello09x.fakeplayer.v1_20_4.spi;
import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer;
import io.github.hello09x.fakeplayer.core.constant.ConstantPool;
import io.github.hello09x.fakeplayer.core.util.Reflections;
import io.github.hello09x.fakeplayer.v1_20_R3_R4.network.FakePlayerAdvancements;
import io.github.hello09x.fakeplayer.v1_20_4.network.FakePlayerAdvancements;
import lombok.Getter;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;

102
fakeplayer-v1_20_5/pom.xml Normal file
View File

@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-parent</artifactId>
<version>${revision}</version>
</parent>
<artifactId>fakeplayer-v1_20_5</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<nms.version>1.20.6-R0.1-SNAPSHOT</nms.version>
</properties>
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-v1_20_6</artifactId>
<version>${revision}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>${nms.version}</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>2.0.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:${nms.version}:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>
org.spigotmc:spigot:${nms.version}:jar:remapped-mojang
</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>
${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar
</inputFile>
<srgIn>org.spigotmc:minecraft-server:${nms.version}:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:${nms.version}:jar:remapped-obf
</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,55 @@
package io.github.hello09x.fakeplayer.v1_20_5.spi;
import io.github.hello09x.fakeplayer.api.spi.*;
import io.github.hello09x.fakeplayer.core.Main;
import io.github.hello09x.fakeplayer.v1_20_6.spi.*;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.net.InetAddress;
import java.util.Set;
public class NMSBridgeImpl implements NMSBridge {
private final static Set<String> SUPPORTS = Set.of("1.20.5");
@Override
public @NotNull NMSEntity fromEntity(@NotNull Entity entity) {
return new NMSEntityImpl(entity);
}
@Override
public @NotNull NMSServer fromServer(@NotNull Server server) {
return new NMSServerImpl(server);
}
@Override
public @NotNull NMSServerLevel fromWorld(@NotNull World world) {
return new NMSServerLevelImpl(world);
}
@Override
public @NotNull NMSServerPlayer fromPlayer(@NotNull Player player) {
return new NMSServerPlayerImpl(player);
}
@Override
public @NotNull NMSNetwork createNetwork(@NotNull InetAddress address) {
return new NMSNetworkImpl(address);
}
@Override
public boolean isSupported() {
return SUPPORTS.contains(Bukkit.getMinecraftVersion());
}
@Override
public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting);
}
}

View File

@ -9,7 +9,7 @@
<version>${revision}</version>
</parent>
<artifactId>fakeplayer-v1_20_R5_R6</artifactId>
<artifactId>fakeplayer-v1_20_6</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R5_R6.action;
package io.github.hello09x.fakeplayer.v1_20_6.action;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R5_R6.action;
package io.github.hello09x.fakeplayer.v1_20_6.action;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;

View File

@ -1,7 +1,7 @@
package io.github.hello09x.fakeplayer.v1_20_R5_R6.action;
package io.github.hello09x.fakeplayer.v1_20_6.action;
import io.github.hello09x.fakeplayer.api.spi.Action;
import io.github.hello09x.fakeplayer.v1_20_R5_R6.action.util.Tracer;
import io.github.hello09x.fakeplayer.v1_20_6.action.util.Tracer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.phys.HitResult;
import org.jetbrains.annotations.NotNull;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R5_R6.action;
package io.github.hello09x.fakeplayer.v1_20_6.action;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerPlayer;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R5_R6.action.util;
package io.github.hello09x.fakeplayer.v1_20_6.action.util;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.ClipContext;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R5_R6.network;
package io.github.hello09x.fakeplayer.v1_20_6.network;
import io.github.hello09x.fakeplayer.core.network.FakeChannel;
import net.minecraft.network.Connection;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R5_R6.network;
package io.github.hello09x.fakeplayer.v1_20_6.network;
import com.mojang.datafixers.DataFixer;
import net.minecraft.advancements.AdvancementHolder;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R5_R6.network;
package io.github.hello09x.fakeplayer.v1_20_6.network;
import io.github.hello09x.fakeplayer.api.spi.NMSServerGamePacketListener;
import io.github.hello09x.fakeplayer.core.Main;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R5_R6.spi;
package io.github.hello09x.fakeplayer.v1_20_6.spi;
import io.github.hello09x.fakeplayer.api.spi.ActionSetting;
@ -6,9 +6,9 @@ import io.github.hello09x.fakeplayer.api.spi.ActionTicker;
import io.github.hello09x.fakeplayer.api.spi.ActionType;
import io.github.hello09x.fakeplayer.api.spi.NMSBridge;
import io.github.hello09x.fakeplayer.core.entity.action.BaseActionTicker;
import io.github.hello09x.fakeplayer.v1_20_R5_R6.action.AttackAction;
import io.github.hello09x.fakeplayer.v1_20_R5_R6.action.MineAction;
import io.github.hello09x.fakeplayer.v1_20_R5_R6.action.UseAction;
import io.github.hello09x.fakeplayer.v1_20_6.action.AttackAction;
import io.github.hello09x.fakeplayer.v1_20_6.action.MineAction;
import io.github.hello09x.fakeplayer.v1_20_6.action.UseAction;
import org.bukkit.craftbukkit.v1_20_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R5_R6.spi;
package io.github.hello09x.fakeplayer.v1_20_6.spi;
import io.github.hello09x.fakeplayer.api.spi.*;
import io.github.hello09x.fakeplayer.core.Main;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R5_R6.spi;
package io.github.hello09x.fakeplayer.v1_20_6.spi;
import io.github.hello09x.fakeplayer.api.spi.NMSEntity;
import lombok.Getter;

View File

@ -1,9 +1,9 @@
package io.github.hello09x.fakeplayer.v1_20_R5_R6.spi;
package io.github.hello09x.fakeplayer.v1_20_6.spi;
import io.github.hello09x.fakeplayer.api.spi.NMSNetwork;
import io.github.hello09x.fakeplayer.api.spi.NMSServerGamePacketListener;
import io.github.hello09x.fakeplayer.v1_20_R5_R6.network.FakeConnection;
import io.github.hello09x.fakeplayer.v1_20_R5_R6.network.FakeServerGamePacketListenerImpl;
import io.github.hello09x.fakeplayer.v1_20_6.network.FakeConnection;
import io.github.hello09x.fakeplayer.v1_20_6.network.FakeServerGamePacketListenerImpl;
import net.minecraft.server.network.CommonListenerCookie;
import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_20_R4.CraftServer;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R5_R6.spi;
package io.github.hello09x.fakeplayer.v1_20_6.spi;
import com.mojang.authlib.GameProfile;
import io.github.hello09x.devtools.core.utils.WorldUtils;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R5_R6.spi;
package io.github.hello09x.fakeplayer.v1_20_6.spi;
import io.github.hello09x.fakeplayer.api.spi.NMSServerLevel;
import lombok.Getter;

View File

@ -1,9 +1,9 @@
package io.github.hello09x.fakeplayer.v1_20_R5_R6.spi;
package io.github.hello09x.fakeplayer.v1_20_6.spi;
import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer;
import io.github.hello09x.fakeplayer.core.constant.ConstantPool;
import io.github.hello09x.fakeplayer.core.util.Reflections;
import io.github.hello09x.fakeplayer.v1_20_R5_R6.network.FakePlayerAdvancements;
import io.github.hello09x.fakeplayer.v1_20_6.network.FakePlayerAdvancements;
import lombok.Getter;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;

View File

@ -1,49 +0,0 @@
package io.github.hello09x.fakeplayer.v1_20_R3_R4.action;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.HitResult;
public class AttackAction extends TraceAction {
private final ServerPlayer player;
public AttackAction(ServerPlayer player) {
super(player);
this.player = player;
}
@Override
public boolean tick() {
var hit = this.getTarget();
if (hit == null) {
return false;
}
if (hit.getType() != HitResult.Type.ENTITY) {
return false;
}
var entityHit = (EntityHitResult) hit;
player.attack(entityHit.getEntity());
player.swing(InteractionHand.MAIN_HAND);
player.resetAttackStrengthTicker();
player.resetLastActionTime();
return true;
}
@Override
public void inactiveTick() {
}
@Override
public void stop() {
}
}

View File

@ -1,160 +0,0 @@
package io.github.hello09x.fakeplayer.v1_20_R3_R4.action;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import org.jetbrains.annotations.Nullable;
import static net.minecraft.network.protocol.game.ServerboundPlayerActionPacket.Action.*;
public class MineAction extends TraceAction {
private final Current current = new Current();
public MineAction(ServerPlayer player) {
super(player);
}
@Override
@SuppressWarnings("resource")
public boolean tick() {
var hit = this.getTarget();
if (hit == null) {
return false;
}
if (hit.getType() != HitResult.Type.BLOCK) {
return false;
}
if (current.freeze > 0) {
current.freeze--;
return false;
}
var blockHit = (BlockHitResult) hit;
var pos = blockHit.getBlockPos();
var side = blockHit.getDirection();
if (player.blockActionRestricted(player.level(), pos, player.gameMode.getGameModeForPlayer())) {
return false;
}
if (current.pos != null && player.level().getBlockState(current.pos).isAir()) {
current.pos = null;
return false;
}
var state = player.level().getBlockState(pos);
var broken = false;
if (player.gameMode.getGameModeForPlayer().isCreative()) {
player.gameMode.handleBlockBreakAction(
pos,
START_DESTROY_BLOCK,
side,
player.level().getMaxBuildHeight(),
-1
);
current.freeze = 5;
broken = true;
} else if (current.pos == null || !current.pos.equals(pos)) {
if (current.pos != null) {
player.gameMode.handleBlockBreakAction(
current.pos,
ABORT_DESTROY_BLOCK,
side,
player.level().getMaxBuildHeight(),
-1
);
}
player.gameMode.handleBlockBreakAction(
pos,
START_DESTROY_BLOCK,
side,
player.level().getMaxBuildHeight(),
-1
);
if (!state.isAir() && current.progress == 0) {
state.attack(player.level(), pos, player);
}
if (!state.isAir() && state.getDestroyProgress(player, player.level(), pos) >= 1) {
current.pos = null;
broken = true;
} else {
current.pos = pos;
current.progress = 0;
}
} else {
current.progress += state.getDestroyProgress(player, player.level(), pos);
if (current.progress >= 1) {
player.gameMode.handleBlockBreakAction(
pos,
STOP_DESTROY_BLOCK,
side,
player.level().getMaxBuildHeight(),
-1
);
current.pos = null;
current.freeze = 5;
broken = true;
}
player.level().destroyBlockProgress(-1, pos, (int) (current.progress * 10));
}
player.resetLastActionTime();
player.swing(InteractionHand.MAIN_HAND);
return broken;
}
@Override
public void inactiveTick() {
stop();
}
@Override
@SuppressWarnings("resource")
public void stop() {
if (current.pos == null) {
return;
}
player.level().destroyBlockProgress(-1, current.pos, -1);
player.gameMode.handleBlockBreakAction(
current.pos,
ABORT_DESTROY_BLOCK,
Direction.DOWN,
player.level().getMaxBuildHeight(),
-1
);
current.pos = null;
current.freeze = 0;
current.progress = 0;
}
private static class Current {
/**
* 当前左键的目标位置
*/
@Nullable
public BlockPos pos;
/**
* 破坏方块的进度
*/
public float progress;
/**
* 冷却, 单位: tick
*/
public int freeze;
}
}

View File

@ -1,24 +0,0 @@
package io.github.hello09x.fakeplayer.v1_20_R3_R4.action;
import io.github.hello09x.fakeplayer.api.spi.Action;
import io.github.hello09x.fakeplayer.v1_20_R3_R4.action.util.Tracer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.phys.HitResult;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class TraceAction implements Action {
protected final ServerPlayer player;
protected TraceAction(@NotNull ServerPlayer player) {
this.player = player;
}
protected @Nullable HitResult getTarget() {
double reach = player.gameMode.isCreative() ? 5 : 4.5f;
return Tracer.rayTrace(player, 1, reach, false);
}
}

View File

@ -1,97 +0,0 @@
package io.github.hello09x.fakeplayer.v1_20_R3_R4.action;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.decoration.ItemFrame;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult;
import org.jetbrains.annotations.NotNull;
public class UseAction extends TraceAction {
private final Current current = new Current();
public UseAction(@NotNull ServerPlayer player) {
super(player);
}
@Override
@SuppressWarnings("resource")
public boolean tick() {
if (current.freeze > 0) {
current.freeze--;
return false;
}
if (player.isUsingItem()) {
return true;
}
var hit = this.getTarget();
if (hit == null) {
return false;
}
for (var hand : InteractionHand.values()) {
switch (hit.getType()) {
case BLOCK -> {
player.resetLastActionTime();
var world = player.serverLevel();
var blockHit = (BlockHitResult) hit;
var pos = blockHit.getBlockPos();
var side = blockHit.getDirection();
if (pos.getY() < player.level().getMaxBuildHeight() - (side == Direction.UP ? 1 : 0) && world.mayInteract(player, pos)) {
var result = player.gameMode.useItemOn(player, world, player.getItemInHand(hand), hand, blockHit);
if (result.consumesAction()) {
player.swing(hand);
current.freeze = 3;
return true;
}
}
}
case ENTITY -> {
player.resetLastActionTime();
var entityHit = (EntityHitResult) hit;
var entity = entityHit.getEntity();
boolean handWasEmpty = player.getItemInHand(hand).isEmpty();
boolean itemFrameEmpty = (entity instanceof ItemFrame) && ((ItemFrame) entity).getItem().isEmpty();
var pos = entityHit.getLocation().subtract(entity.getX(), entity.getY(), entity.getZ());
if (entity.interactAt(player, pos, hand).consumesAction()) {
current.freeze = 3;
return true;
}
if (player.interactOn(entity, hand).consumesAction() && !(handWasEmpty && itemFrameEmpty)) {
current.freeze = 3;
return true;
}
}
}
var handItem = player.getItemInHand(hand);
if (player.gameMode.useItem(player, player.level(), handItem, hand).consumesAction()) {
player.resetLastActionTime();
current.freeze = 3;
return true;
}
}
return false;
}
@Override
public void inactiveTick() {
}
@Override
public void stop() {
current.freeze = 0;
player.releaseUsingItem();
}
private final static class Current {
/**
* 冷却, 单位: tick
*/
public int freeze;
}
}

View File

@ -1,105 +0,0 @@
package io.github.hello09x.fakeplayer.v1_20_R3_R4.action.util;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.phys.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.function.Predicate;
/**
* copy from fabric carpet mod
*/
public class Tracer {
public static @Nullable HitResult rayTrace(
@NotNull Entity source,
float partialTicks,
double reach,
boolean fluids
) {
var blockHit = rayTraceBlocks(source, partialTicks, reach, fluids);
double maxSqDist = reach * reach;
if (blockHit != null) {
maxSqDist = blockHit.getLocation().distanceToSqr(source.getEyePosition(partialTicks));
}
EntityHitResult entityHit = rayTraceEntities(source, partialTicks, reach, maxSqDist);
return entityHit == null ? blockHit : entityHit;
}
@SuppressWarnings("resource")
public static @Nullable BlockHitResult rayTraceBlocks(
@NotNull Entity source,
float partialTicks,
double reach,
boolean fluids
) {
var pos = source.getEyePosition(partialTicks);
var rotation = source.getViewVector(partialTicks);
var reachEnd = pos.add(rotation.x * reach, rotation.y * reach, rotation.z * reach);
return source.level().clip(new ClipContext(pos, reachEnd, ClipContext.Block.OUTLINE, fluids ?
ClipContext.Fluid.ANY : ClipContext.Fluid.NONE, source));
}
public static @Nullable EntityHitResult rayTraceEntities(
@NotNull Entity source,
float partialTicks,
double reach,
double maxSqDist
) {
var pos = source.getEyePosition(partialTicks);
var reachVec = source.getViewVector(partialTicks).scale(reach);
var box = source.getBoundingBox().expandTowards(reachVec).inflate(1);
return rayTraceEntities(source,
pos,
pos.add(reachVec),
box,
e -> !e.isSpectator() && e.isPickable(),
maxSqDist);
}
public static @Nullable EntityHitResult rayTraceEntities(
@NotNull Entity source,
@NotNull Vec3 start,
@NotNull Vec3 end,
@NotNull AABB box,
@NotNull Predicate<Entity> predicate,
double maxSqDistance
) {
@SuppressWarnings("resource")
var world = source.level();
double targetDistance = maxSqDistance;
Entity target = null;
Vec3 targetHitPos = null;
for (Entity current : world.getEntities(source, box, predicate)) {
var currentBox = current.getBoundingBox().inflate(current.getPickRadius());
var currentHit = currentBox.clip(start, end);
if (currentBox.contains(start)) {
if (targetDistance >= 0) {
target = current;
targetHitPos = currentHit.orElse(start);
targetDistance = 0;
}
} else if (currentHit.isPresent()) {
var currentHitPos = currentHit.get();
var currentDistance = start.distanceToSqr(currentHitPos);
if (currentDistance < targetDistance || targetDistance == 0) {
if (current.getRootVehicle() == source.getRootVehicle()) {
if (targetDistance == 0) {
target = current;
targetHitPos = currentHitPos;
}
}
else
{
target = current;
targetHitPos = currentHitPos;
targetDistance = currentDistance;
}
}
}
}
return target == null ? null : new EntityHitResult(target, targetHitPos);
}
}

100
fakeplayer-v1_21/pom.xml Normal file
View File

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-parent</artifactId>
<version>${revision}</version>
</parent>
<artifactId>fakeplayer-v1_21</artifactId>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<nms.version>1.21-R0.1-SNAPSHOT</nms.version>
</properties>
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>${nms.version}</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>2.0.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:${nms.version}:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>
org.spigotmc:spigot:${nms.version}:jar:remapped-mojang
</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>
${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar
</inputFile>
<srgIn>org.spigotmc:minecraft-server:${nms.version}:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:${nms.version}:jar:remapped-obf
</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,49 @@
package io.github.hello09x.fakeplayer.v1_21.action;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.HitResult;
public class AttackAction extends TraceAction {
private final ServerPlayer player;
public AttackAction(ServerPlayer player) {
super(player);
this.player = player;
}
@Override
public boolean tick() {
var hit = this.getTarget();
if (hit == null) {
return false;
}
if (hit.getType() != HitResult.Type.ENTITY) {
return false;
}
var entityHit = (EntityHitResult) hit;
player.attack(entityHit.getEntity());
player.swing(InteractionHand.MAIN_HAND);
player.resetAttackStrengthTicker();
player.resetLastActionTime();
return true;
}
@Override
public void inactiveTick() {
}
@Override
public void stop() {
}
}

View File

@ -0,0 +1,160 @@
package io.github.hello09x.fakeplayer.v1_21.action;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import org.jetbrains.annotations.Nullable;
import static net.minecraft.network.protocol.game.ServerboundPlayerActionPacket.Action.*;
public class MineAction extends TraceAction {
private final Current current = new Current();
public MineAction(ServerPlayer player) {
super(player);
}
@Override
@SuppressWarnings("resource")
public boolean tick() {
var hit = this.getTarget();
if (hit == null) {
return false;
}
if (hit.getType() != HitResult.Type.BLOCK) {
return false;
}
if (current.freeze > 0) {
current.freeze--;
return false;
}
var blockHit = (BlockHitResult) hit;
var pos = blockHit.getBlockPos();
var side = blockHit.getDirection();
if (player.blockActionRestricted(player.level(), pos, player.gameMode.getGameModeForPlayer())) {
return false;
}
if (current.pos != null && player.level().getBlockState(current.pos).isAir()) {
current.pos = null;
return false;
}
var state = player.level().getBlockState(pos);
var broken = false;
if (player.gameMode.getGameModeForPlayer().isCreative()) {
player.gameMode.handleBlockBreakAction(
pos,
START_DESTROY_BLOCK,
side,
player.level().getMaxBuildHeight(),
-1
);
current.freeze = 5;
broken = true;
} else if (current.pos == null || !current.pos.equals(pos)) {
if (current.pos != null) {
player.gameMode.handleBlockBreakAction(
current.pos,
ABORT_DESTROY_BLOCK,
side,
player.level().getMaxBuildHeight(),
-1
);
}
player.gameMode.handleBlockBreakAction(
pos,
START_DESTROY_BLOCK,
side,
player.level().getMaxBuildHeight(),
-1
);
if (!state.isAir() && current.progress == 0) {
state.attack(player.level(), pos, player);
}
if (!state.isAir() && state.getDestroyProgress(player, player.level(), pos) >= 1) {
current.pos = null;
broken = true;
} else {
current.pos = pos;
current.progress = 0;
}
} else {
current.progress += state.getDestroyProgress(player, player.level(), pos);
if (current.progress >= 1) {
player.gameMode.handleBlockBreakAction(
pos,
STOP_DESTROY_BLOCK,
side,
player.level().getMaxBuildHeight(),
-1
);
current.pos = null;
current.freeze = 5;
broken = true;
}
player.level().destroyBlockProgress(-1, pos, (int) (current.progress * 10));
}
player.resetLastActionTime();
player.swing(InteractionHand.MAIN_HAND);
return broken;
}
@Override
public void inactiveTick() {
stop();
}
@Override
@SuppressWarnings("resource")
public void stop() {
if (current.pos == null) {
return;
}
player.level().destroyBlockProgress(-1, current.pos, -1);
player.gameMode.handleBlockBreakAction(
current.pos,
ABORT_DESTROY_BLOCK,
Direction.DOWN,
player.level().getMaxBuildHeight(),
-1
);
current.pos = null;
current.freeze = 0;
current.progress = 0;
}
private static class Current {
/**
* 当前左键的目标位置
*/
@Nullable
public BlockPos pos;
/**
* 破坏方块的进度
*/
public float progress;
/**
* 冷却, 单位: tick
*/
public int freeze;
}
}

View File

@ -0,0 +1,24 @@
package io.github.hello09x.fakeplayer.v1_21.action;
import io.github.hello09x.fakeplayer.api.spi.Action;
import io.github.hello09x.fakeplayer.v1_21.action.util.Tracer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.phys.HitResult;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class TraceAction implements Action {
protected final ServerPlayer player;
protected TraceAction(@NotNull ServerPlayer player) {
this.player = player;
}
protected @Nullable HitResult getTarget() {
double reach = player.gameMode.isCreative() ? 5 : 4.5f;
return Tracer.rayTrace(player, 1, reach, false);
}
}

View File

@ -0,0 +1,97 @@
package io.github.hello09x.fakeplayer.v1_21.action;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.decoration.ItemFrame;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult;
import org.jetbrains.annotations.NotNull;
public class UseAction extends TraceAction {
private final Current current = new Current();
public UseAction(@NotNull ServerPlayer player) {
super(player);
}
@Override
@SuppressWarnings("resource")
public boolean tick() {
if (current.freeze > 0) {
current.freeze--;
return false;
}
if (player.isUsingItem()) {
return true;
}
var hit = this.getTarget();
if (hit == null) {
return false;
}
for (var hand : InteractionHand.values()) {
switch (hit.getType()) {
case BLOCK -> {
player.resetLastActionTime();
var world = player.serverLevel();
var blockHit = (BlockHitResult) hit;
var pos = blockHit.getBlockPos();
var side = blockHit.getDirection();
if (pos.getY() < player.level().getMaxBuildHeight() - (side == Direction.UP ? 1 : 0) && world.mayInteract(player, pos)) {
var result = player.gameMode.useItemOn(player, world, player.getItemInHand(hand), hand, blockHit);
if (result.consumesAction()) {
player.swing(hand);
current.freeze = 3;
return true;
}
}
}
case ENTITY -> {
player.resetLastActionTime();
var entityHit = (EntityHitResult) hit;
var entity = entityHit.getEntity();
boolean handWasEmpty = player.getItemInHand(hand).isEmpty();
boolean itemFrameEmpty = (entity instanceof ItemFrame) && ((ItemFrame) entity).getItem().isEmpty();
var pos = entityHit.getLocation().subtract(entity.getX(), entity.getY(), entity.getZ());
if (entity.interactAt(player, pos, hand).consumesAction()) {
current.freeze = 3;
return true;
}
if (player.interactOn(entity, hand).consumesAction() && !(handWasEmpty && itemFrameEmpty)) {
current.freeze = 3;
return true;
}
}
}
var handItem = player.getItemInHand(hand);
if (player.gameMode.useItem(player, player.level(), handItem, hand).consumesAction()) {
player.resetLastActionTime();
current.freeze = 3;
return true;
}
}
return false;
}
@Override
public void inactiveTick() {
}
@Override
public void stop() {
current.freeze = 0;
player.releaseUsingItem();
}
private final static class Current {
/**
* 冷却, 单位: tick
*/
public int freeze;
}
}

View File

@ -0,0 +1,105 @@
package io.github.hello09x.fakeplayer.v1_21.action.util;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.phys.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.function.Predicate;
/**
* copy from fabric carpet mod
*/
public class Tracer {
public static @Nullable HitResult rayTrace(
@NotNull Entity source,
float partialTicks,
double reach,
boolean fluids
) {
var blockHit = rayTraceBlocks(source, partialTicks, reach, fluids);
double maxSqDist = reach * reach;
if (blockHit != null) {
maxSqDist = blockHit.getLocation().distanceToSqr(source.getEyePosition(partialTicks));
}
EntityHitResult entityHit = rayTraceEntities(source, partialTicks, reach, maxSqDist);
return entityHit == null ? blockHit : entityHit;
}
@SuppressWarnings("resource")
public static @Nullable BlockHitResult rayTraceBlocks(
@NotNull Entity source,
float partialTicks,
double reach,
boolean fluids
) {
var pos = source.getEyePosition(partialTicks);
var rotation = source.getViewVector(partialTicks);
var reachEnd = pos.add(rotation.x * reach, rotation.y * reach, rotation.z * reach);
return source.level().clip(new ClipContext(pos, reachEnd, ClipContext.Block.OUTLINE, fluids ?
ClipContext.Fluid.ANY : ClipContext.Fluid.NONE, source));
}
public static @Nullable EntityHitResult rayTraceEntities(
@NotNull Entity source,
float partialTicks,
double reach,
double maxSqDist
) {
var pos = source.getEyePosition(partialTicks);
var reachVec = source.getViewVector(partialTicks).scale(reach);
var box = source.getBoundingBox().expandTowards(reachVec).inflate(1);
return rayTraceEntities(source,
pos,
pos.add(reachVec),
box,
e -> !e.isSpectator() && e.isPickable(),
maxSqDist);
}
public static @Nullable EntityHitResult rayTraceEntities(
@NotNull Entity source,
@NotNull Vec3 start,
@NotNull Vec3 end,
@NotNull AABB box,
@NotNull Predicate<Entity> predicate,
double maxSqDistance
) {
@SuppressWarnings("resource")
var world = source.level();
double targetDistance = maxSqDistance;
Entity target = null;
Vec3 targetHitPos = null;
for (Entity current : world.getEntities(source, box, predicate)) {
var currentBox = current.getBoundingBox().inflate(current.getPickRadius());
var currentHit = currentBox.clip(start, end);
if (currentBox.contains(start)) {
if (targetDistance >= 0) {
target = current;
targetHitPos = currentHit.orElse(start);
targetDistance = 0;
}
} else if (currentHit.isPresent()) {
var currentHitPos = currentHit.get();
var currentDistance = start.distanceToSqr(currentHitPos);
if (currentDistance < targetDistance || targetDistance == 0) {
if (current.getRootVehicle() == source.getRootVehicle()) {
if (targetDistance == 0) {
target = current;
targetHitPos = currentHitPos;
}
}
else
{
target = current;
targetHitPos = currentHitPos;
targetDistance = currentDistance;
}
}
}
}
return target == null ? null : new EntityHitResult(target, targetHitPos);
}
}

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_21_R1.network;
package io.github.hello09x.fakeplayer.v1_21.network;
import io.github.hello09x.fakeplayer.core.Main;
import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_20_R3_R4.network;
package io.github.hello09x.fakeplayer.v1_21.network;
import com.mojang.datafixers.DataFixer;
import net.minecraft.advancements.AdvancementHolder;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_21_R1.network;
package io.github.hello09x.fakeplayer.v1_21.network;
import io.github.hello09x.fakeplayer.api.spi.NMSServerGamePacketListener;
import io.github.hello09x.fakeplayer.core.Main;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_21_R1.spi;
package io.github.hello09x.fakeplayer.v1_21.spi;
import io.github.hello09x.fakeplayer.api.spi.ActionSetting;
@ -6,9 +6,9 @@ import io.github.hello09x.fakeplayer.api.spi.ActionTicker;
import io.github.hello09x.fakeplayer.api.spi.ActionType;
import io.github.hello09x.fakeplayer.api.spi.NMSBridge;
import io.github.hello09x.fakeplayer.core.entity.action.BaseActionTicker;
import io.github.hello09x.fakeplayer.v1_21_R1.action.AttackAction;
import io.github.hello09x.fakeplayer.v1_21_R1.action.MineAction;
import io.github.hello09x.fakeplayer.v1_21_R1.action.UseAction;
import io.github.hello09x.fakeplayer.v1_21.action.AttackAction;
import io.github.hello09x.fakeplayer.v1_21.action.MineAction;
import io.github.hello09x.fakeplayer.v1_21.action.UseAction;
import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_21_R1.spi;
package io.github.hello09x.fakeplayer.v1_21.spi;
import io.github.hello09x.fakeplayer.api.spi.*;
import io.github.hello09x.fakeplayer.core.Main;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_21_R1.spi;
package io.github.hello09x.fakeplayer.v1_21.spi;
import io.github.hello09x.fakeplayer.api.spi.NMSEntity;
import lombok.Getter;

View File

@ -1,9 +1,9 @@
package io.github.hello09x.fakeplayer.v1_21_R1.spi;
package io.github.hello09x.fakeplayer.v1_21.spi;
import io.github.hello09x.fakeplayer.api.spi.NMSNetwork;
import io.github.hello09x.fakeplayer.api.spi.NMSServerGamePacketListener;
import io.github.hello09x.fakeplayer.v1_21_R1.network.FakeConnection;
import io.github.hello09x.fakeplayer.v1_21_R1.network.FakeServerGamePacketListenerImpl;
import io.github.hello09x.fakeplayer.v1_21.network.FakeConnection;
import io.github.hello09x.fakeplayer.v1_21.network.FakeServerGamePacketListenerImpl;
import net.minecraft.server.network.CommonListenerCookie;
import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_21_R1.CraftServer;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_21_R1.spi;
package io.github.hello09x.fakeplayer.v1_21.spi;
import com.mojang.authlib.GameProfile;
import io.github.hello09x.devtools.core.utils.WorldUtils;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.v1_21_R1.spi;
package io.github.hello09x.fakeplayer.v1_21.spi;
import io.github.hello09x.fakeplayer.api.spi.NMSServerLevel;
import lombok.Getter;

View File

@ -1,9 +1,9 @@
package io.github.hello09x.fakeplayer.v1_21_R1.spi;
package io.github.hello09x.fakeplayer.v1_21.spi;
import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer;
import io.github.hello09x.fakeplayer.core.constant.ConstantPool;
import io.github.hello09x.fakeplayer.core.util.Reflections;
import io.github.hello09x.fakeplayer.v1_21_R1.network.FakePlayerAdvancements;
import io.github.hello09x.fakeplayer.v1_21.network.FakePlayerAdvancements;
import lombok.Getter;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;

107
fakeplayer-v1_21_1/pom.xml Normal file
View File

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-parent</artifactId>
<version>${revision}</version>
</parent>
<artifactId>fakeplayer-v1_21_1</artifactId>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<nms.version>1.21.1-R0.1-SNAPSHOT</nms.version>
</properties>
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-v1_21</artifactId>
<version>${revision}</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>${nms.version}</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>2.0.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:${nms.version}:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>
org.spigotmc:spigot:${nms.version}:jar:remapped-mojang
</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>
${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar
</inputFile>
<srgIn>org.spigotmc:minecraft-server:${nms.version}:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:${nms.version}:jar:remapped-obf
</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,55 @@
package io.github.hello09x.fakeplayer.v1_21_1.spi;
import io.github.hello09x.fakeplayer.api.spi.*;
import io.github.hello09x.fakeplayer.core.Main;
import io.github.hello09x.fakeplayer.v1_21.spi.*;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.net.InetAddress;
import java.util.Set;
public class NMSBridgeImpl implements NMSBridge {
private final static Set<String> SUPPORTS = Set.of("1.21.1");
@Override
public @NotNull NMSEntity fromEntity(@NotNull Entity entity) {
return new NMSEntityImpl(entity);
}
@Override
public @NotNull NMSServer fromServer(@NotNull Server server) {
return new NMSServerImpl(server);
}
@Override
public @NotNull NMSServerLevel fromWorld(@NotNull World world) {
return new NMSServerLevelImpl(world);
}
@Override
public @NotNull NMSServerPlayer fromPlayer(@NotNull Player player) {
return new NMSServerPlayerImpl(player);
}
@Override
public @NotNull NMSNetwork createNetwork(@NotNull InetAddress address) {
return new NMSNetworkImpl(address);
}
@Override
public boolean isSupported() {
return SUPPORTS.contains(Bukkit.getMinecraftVersion());
}
@Override
public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) {
return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting);
}
}

View File

@ -1,125 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-parent</artifactId>
<version>${revision}</version>
</parent>
<artifactId>fakeplayer-v1_21_R1</artifactId>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<nms.version>1.21-R0.1-SNAPSHOT</nms.version>
</properties>
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>${nms.version}</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
</configuration>
<executions>
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>2.0.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:${nms.version}:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>
org.spigotmc:spigot:${nms.version}:jar:remapped-mojang
</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>
${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar
</inputFile>
<srgIn>org.spigotmc:minecraft-server:${nms.version}:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:${nms.version}:jar:remapped-obf
</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

15
pom.xml
View File

@ -14,17 +14,20 @@
<module>fakeplayer-api</module>
<module>fakeplayer-core</module>
<module>fakeplayer-dist</module>
<module>fakeplayer-v1_20_R1</module>
<module>fakeplayer-v1_20_R2</module>
<module>fakeplayer-v1_20_R3_R4</module>
<module>fakeplayer-v1_20_R5_R6</module>
<module>fakeplayer-v1_21_R1</module>
<module>fakeplayer-v1_20_1</module>
<module>fakeplayer-v1_20_2</module>
<module>fakeplayer-v1_20_3</module>
<module>fakeplayer-v1_20_4</module>
<module>fakeplayer-v1_20_6</module>
<module>fakeplayer-v1_21</module>
<module>fakeplayer-v1_21_1</module>
<module>fakeplayer-v1_20_5</module>
</modules>
<properties>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>0.3.9-b.4</revision>
<revision>0.3.9-rc.1</revision>
<detools.version>0.1.4-SNAPSHOT</detools.version>
</properties>