-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
152 changed files
with
7,884 additions
and
3,065 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,3 +126,4 @@ fabric.properties | |
.idea/ | ||
/folia/ | ||
/purpur/ | ||
/server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?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>1.0.0</version> | ||
</parent> | ||
|
||
<artifactId>fakeplayer-api</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.papermc.paper</groupId> | ||
<artifactId>paper-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.github.hello09x</groupId> | ||
<artifactId>bedrock</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/action/ActionType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package io.github.hello09x.fakeplayer.api.action; | ||
|
||
import lombok.AllArgsConstructor; | ||
import net.kyori.adventure.translation.Translatable; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
@AllArgsConstructor | ||
public enum ActionType implements Translatable { | ||
|
||
/** | ||
* 攻击实体 | ||
*/ | ||
ATTACK("fakeplayer.action.attack"), | ||
|
||
/** | ||
* 挖掘 | ||
*/ | ||
MINE("fakeplayer.action.mine"), | ||
|
||
/** | ||
* 右键 | ||
*/ | ||
USE("fakeplayer.action.use"), | ||
|
||
/** | ||
* 跳跃 | ||
*/ | ||
JUMP("fakeplayer.action.jump"), | ||
|
||
/** | ||
* 看向附近实体 | ||
*/ | ||
LOOK_AT_NEAREST_ENTITY("fakeplayer.action.look-at-entity"), | ||
|
||
/** | ||
* 丢弃手上 1 个物品 | ||
*/ | ||
DROP_ITEM("fakeplayer.action.drop-item"), | ||
|
||
/** | ||
* 丢弃手上整组物品 | ||
*/ | ||
DROP_STACK("fakeplayer.action.drop-stack"), | ||
|
||
/** | ||
* 丢弃背包 | ||
*/ | ||
DROP_INVENTORY("fakeplayer.action.drop-inventory"); | ||
|
||
final String translationKey; | ||
|
||
|
||
@Override | ||
public @NotNull String translationKey() { | ||
return this.translationKey; | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/action/BaseActionTicker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package io.github.hello09x.fakeplayer.api.action; | ||
|
||
import io.github.hello09x.fakeplayer.api.action.impl.*; | ||
import io.github.hello09x.fakeplayer.api.spi.Action; | ||
import io.github.hello09x.fakeplayer.api.spi.ActionTicker; | ||
import io.github.hello09x.fakeplayer.api.spi.NMSBridge; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Objects; | ||
|
||
public abstract class BaseActionTicker implements ActionTicker { | ||
|
||
protected Action action; | ||
|
||
@NotNull | ||
protected ActionSetting setting; | ||
|
||
public BaseActionTicker(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) { | ||
var bridge = Objects.requireNonNull(NMSBridge.getInstance()); | ||
this.setting = setting; | ||
this.action = switch (action) { | ||
case JUMP -> new JumpAction(bridge.player(player)); | ||
case LOOK_AT_NEAREST_ENTITY -> new LookAtEntityAction(bridge.player(player)); | ||
case DROP_ITEM -> new DropItemAction(bridge.player(player)); | ||
case DROP_STACK -> new DropStackAction(bridge.player(player)); | ||
case DROP_INVENTORY -> new DropInventoryAction(bridge.player(player)); | ||
default -> null; | ||
}; | ||
} | ||
|
||
|
||
@Override | ||
public void tick() { | ||
if (setting.wait > 0) { | ||
setting.wait--; | ||
inactiveTick(); | ||
return; | ||
} | ||
|
||
if (setting.remains == 0) { | ||
inactiveTick(); | ||
return; | ||
} | ||
|
||
var valid = action.tick(); | ||
if (valid) { | ||
if (setting.remains > 0) { | ||
setting.remains--; | ||
} | ||
setting.wait = setting.interval; | ||
} | ||
} | ||
|
||
@Override | ||
public void inactiveTick() { | ||
action.inactiveTick(); | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
action.stop(); | ||
} | ||
|
||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...-api/src/main/java/io/github/hello09x/fakeplayer/api/action/impl/DropInventoryAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.github.hello09x.fakeplayer.api.action.impl; | ||
|
||
import io.github.hello09x.fakeplayer.api.spi.Action; | ||
import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class DropInventoryAction implements Action { | ||
|
||
|
||
@NotNull | ||
private final NMSServerPlayer player; | ||
|
||
public DropInventoryAction(@NotNull NMSServerPlayer player) { | ||
this.player = player; | ||
} | ||
|
||
@Override | ||
public boolean tick() { | ||
var inventory = player.getPlayer().getInventory(); | ||
for (int i = inventory.getSize(); i >= 0; i--) { | ||
player.drop(i, false, true); | ||
} | ||
player.resetLastActionTime(); | ||
return true; | ||
} | ||
|
||
@Override | ||
public void inactiveTick() { | ||
|
||
} | ||
|
||
@Override | ||
public void stop() { | ||
|
||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...layer-api/src/main/java/io/github/hello09x/fakeplayer/api/action/impl/DropItemAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.github.hello09x.fakeplayer.api.action.impl; | ||
|
||
import io.github.hello09x.fakeplayer.api.spi.Action; | ||
import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class DropItemAction implements Action { | ||
|
||
@NotNull | ||
private final NMSServerPlayer player; | ||
|
||
public DropItemAction(@NotNull NMSServerPlayer player) { | ||
this.player = player; | ||
} | ||
|
||
@Override | ||
public boolean tick() { | ||
player.drop(false); | ||
player.resetLastActionTime(); | ||
return true; | ||
} | ||
|
||
@Override | ||
public void inactiveTick() { | ||
|
||
} | ||
|
||
@Override | ||
public void stop() { | ||
|
||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...ayer-api/src/main/java/io/github/hello09x/fakeplayer/api/action/impl/DropStackAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.github.hello09x.fakeplayer.api.action.impl; | ||
|
||
import io.github.hello09x.fakeplayer.api.spi.Action; | ||
import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class DropStackAction implements Action { | ||
|
||
@NotNull | ||
private final NMSServerPlayer player; | ||
|
||
public DropStackAction(@NotNull NMSServerPlayer player) { | ||
this.player = player; | ||
} | ||
|
||
|
||
@Override | ||
public boolean tick() { | ||
player.drop(true); | ||
player.resetLastActionTime(); | ||
return true; | ||
} | ||
|
||
@Override | ||
public void inactiveTick() { | ||
|
||
} | ||
|
||
@Override | ||
public void stop() { | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.