mirror of
https://github.com/tanyaofei/minecraft-fakeplayer.git
synced 2025-07-13 21:02:27 +08:00
Nothing important
This commit is contained in:
parent
0b81a1075e
commit
a00b1d22b9
@ -13,8 +13,9 @@ import io.github.hello09x.fakeplayer.core.config.FakeplayerConfig;
|
|||||||
import io.github.hello09x.fakeplayer.core.listener.FakeplayerLifecycleListener;
|
import io.github.hello09x.fakeplayer.core.listener.FakeplayerLifecycleListener;
|
||||||
import io.github.hello09x.fakeplayer.core.listener.FakeplayerListener;
|
import io.github.hello09x.fakeplayer.core.listener.FakeplayerListener;
|
||||||
import io.github.hello09x.fakeplayer.core.listener.PlayerListener;
|
import io.github.hello09x.fakeplayer.core.listener.PlayerListener;
|
||||||
import io.github.hello09x.fakeplayer.core.listener.ReplenishListener;
|
import io.github.hello09x.fakeplayer.core.manager.FakeplayerAutofishManager;
|
||||||
import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
|
import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
|
||||||
|
import io.github.hello09x.fakeplayer.core.manager.FakeplayerReplenishManager;
|
||||||
import io.github.hello09x.fakeplayer.core.manager.WildFakeplayerManager;
|
import io.github.hello09x.fakeplayer.core.manager.WildFakeplayerManager;
|
||||||
import io.github.hello09x.fakeplayer.core.repository.UsedIdRepository;
|
import io.github.hello09x.fakeplayer.core.repository.UsedIdRepository;
|
||||||
import io.github.hello09x.fakeplayer.core.util.update.UpdateChecker;
|
import io.github.hello09x.fakeplayer.core.util.update.UpdateChecker;
|
||||||
@ -63,7 +64,8 @@ public final class Main extends JavaPlugin {
|
|||||||
manager.registerEvents(injector.getInstance(PlayerListener.class), this);
|
manager.registerEvents(injector.getInstance(PlayerListener.class), this);
|
||||||
manager.registerEvents(injector.getInstance(FakeplayerLifecycleListener.class), this);
|
manager.registerEvents(injector.getInstance(FakeplayerLifecycleListener.class), this);
|
||||||
manager.registerEvents(injector.getInstance(FakeplayerListener.class), this);
|
manager.registerEvents(injector.getInstance(FakeplayerListener.class), this);
|
||||||
manager.registerEvents(injector.getInstance(ReplenishListener.class), this);
|
manager.registerEvents(injector.getInstance(FakeplayerAutofishManager.class), this);
|
||||||
|
manager.registerEvents(injector.getInstance(FakeplayerReplenishManager.class), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (injector.getInstance(FakeplayerConfig.class).isCheckForUpdates()) {
|
if (injector.getInstance(FakeplayerConfig.class).isCheckForUpdates()) {
|
||||||
|
@ -7,6 +7,7 @@ import dev.jorel.commandapi.executors.CommandArguments;
|
|||||||
import dev.jorel.commandapi.executors.CommandExecutor;
|
import dev.jorel.commandapi.executors.CommandExecutor;
|
||||||
import io.github.hello09x.fakeplayer.api.spi.ActionSetting;
|
import io.github.hello09x.fakeplayer.api.spi.ActionSetting;
|
||||||
import io.github.hello09x.fakeplayer.api.spi.ActionType;
|
import io.github.hello09x.fakeplayer.api.spi.ActionType;
|
||||||
|
import io.github.hello09x.fakeplayer.core.manager.FakeplayerAutofishManager;
|
||||||
import io.github.hello09x.fakeplayer.core.manager.action.ActionManager;
|
import io.github.hello09x.fakeplayer.core.manager.action.ActionManager;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -19,10 +20,12 @@ import static net.kyori.adventure.text.Component.translatable;
|
|||||||
public class ActionCommand extends AbstractCommand {
|
public class ActionCommand extends AbstractCommand {
|
||||||
|
|
||||||
private final ActionManager actionManager;
|
private final ActionManager actionManager;
|
||||||
|
private final FakeplayerAutofishManager autofishManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ActionCommand(ActionManager actionManager) {
|
public ActionCommand(ActionManager actionManager, FakeplayerAutofishManager autofishManager) {
|
||||||
this.actionManager = actionManager;
|
this.actionManager = actionManager;
|
||||||
|
this.autofishManager = autofishManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull CommandExecutor action(@NotNull ActionType action, @NotNull ActionSetting setting) {
|
public @NotNull CommandExecutor action(@NotNull ActionType action, @NotNull ActionSetting setting) {
|
||||||
@ -41,7 +44,7 @@ public class ActionCommand extends AbstractCommand {
|
|||||||
var fake = super.getFakeplayer(sender, args);
|
var fake = super.getFakeplayer(sender, args);
|
||||||
if (action == ActionType.USE
|
if (action == ActionType.USE
|
||||||
&& fake.getInventory().getItemInMainHand().getType() == Material.FISHING_ROD
|
&& fake.getInventory().getItemInMainHand().getType() == Material.FISHING_ROD
|
||||||
&& manager.isAutofish(fake)
|
&& autofishManager.isAutofish(fake)
|
||||||
) {
|
) {
|
||||||
// 如果是自动钓鱼则改为 1 次
|
// 如果是自动钓鱼则改为 1 次
|
||||||
setting = ActionSetting.once();
|
setting = ActionSetting.once();
|
||||||
|
@ -9,7 +9,9 @@ import io.github.hello09x.fakeplayer.core.Main;
|
|||||||
import io.github.hello09x.fakeplayer.core.config.FakeplayerConfig;
|
import io.github.hello09x.fakeplayer.core.config.FakeplayerConfig;
|
||||||
import io.github.hello09x.fakeplayer.core.config.PreventKicking;
|
import io.github.hello09x.fakeplayer.core.config.PreventKicking;
|
||||||
import io.github.hello09x.fakeplayer.core.constant.MetadataKeys;
|
import io.github.hello09x.fakeplayer.core.constant.MetadataKeys;
|
||||||
|
import io.github.hello09x.fakeplayer.core.manager.FakeplayerAutofishManager;
|
||||||
import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
|
import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
|
||||||
|
import io.github.hello09x.fakeplayer.core.manager.FakeplayerReplenishManager;
|
||||||
import io.github.hello09x.fakeplayer.core.manager.FakeplayerSkinManager;
|
import io.github.hello09x.fakeplayer.core.manager.FakeplayerSkinManager;
|
||||||
import io.github.hello09x.fakeplayer.core.manager.action.ActionManager;
|
import io.github.hello09x.fakeplayer.core.manager.action.ActionManager;
|
||||||
import io.github.hello09x.fakeplayer.core.manager.naming.SequenceName;
|
import io.github.hello09x.fakeplayer.core.manager.naming.SequenceName;
|
||||||
@ -37,17 +39,16 @@ import static net.kyori.adventure.text.Component.translatable;
|
|||||||
import static net.kyori.adventure.text.format.NamedTextColor.*;
|
import static net.kyori.adventure.text.format.NamedTextColor.*;
|
||||||
import static net.kyori.adventure.text.format.TextDecoration.ITALIC;
|
import static net.kyori.adventure.text.format.TextDecoration.ITALIC;
|
||||||
|
|
||||||
public class FakePlayer {
|
public class Fakeplayer {
|
||||||
|
|
||||||
private final static InternalAddressGenerator ipGen = new InternalAddressGenerator();
|
private final static InternalAddressGenerator ipGen = new InternalAddressGenerator();
|
||||||
|
|
||||||
private final static FakeplayerConfig config = Main.getInjector().getInstance(FakeplayerConfig.class);
|
private final static FakeplayerConfig config = Main.getInjector().getInstance(FakeplayerConfig.class);
|
||||||
|
|
||||||
private final static NMSBridge bridge = Main.getInjector().getInstance(NMSBridge.class);
|
private final static NMSBridge bridge = Main.getInjector().getInstance(NMSBridge.class);
|
||||||
|
|
||||||
private final static FakeplayerManager manager = Main.getInjector().getInstance(FakeplayerManager.class);
|
private final static FakeplayerManager manager = Main.getInjector().getInstance(FakeplayerManager.class);
|
||||||
|
|
||||||
private final static FakeplayerSkinManager skinManager = Main.getInjector().getInstance(FakeplayerSkinManager.class);
|
private final static FakeplayerSkinManager skinManager = Main.getInjector().getInstance(FakeplayerSkinManager.class);
|
||||||
|
private final static FakeplayerReplenishManager replenishManager = Main.getInjector().getInstance(FakeplayerReplenishManager.class);
|
||||||
|
private final static FakeplayerAutofishManager autofishManager = Main.getInjector().getInstance(FakeplayerAutofishManager.class);
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Getter
|
@Getter
|
||||||
@ -89,7 +90,7 @@ public class FakePlayer {
|
|||||||
* @param sequenceName 序列名
|
* @param sequenceName 序列名
|
||||||
* @param lifespan 存活时间
|
* @param lifespan 存活时间
|
||||||
*/
|
*/
|
||||||
public FakePlayer(
|
public Fakeplayer(
|
||||||
@NotNull CommandSender creator,
|
@NotNull CommandSender creator,
|
||||||
@NotNull String creatorIp,
|
@NotNull String creatorIp,
|
||||||
@NotNull SequenceName sequenceName,
|
@NotNull SequenceName sequenceName,
|
||||||
@ -157,10 +158,10 @@ public class FakePlayer {
|
|||||||
skinManager.useDefaultSkin(creator, player);
|
skinManager.useDefaultSkin(creator, player);
|
||||||
}
|
}
|
||||||
if (option.replenish()) {
|
if (option.replenish()) {
|
||||||
manager.setReplenish(player, true);
|
replenishManager.setReplenish(player, true);
|
||||||
}
|
}
|
||||||
if (option.autofish()) {
|
if (option.autofish()) {
|
||||||
manager.setAutofish(player, true);
|
autofishManager.setAutofish(player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.network = bridge.createNetwork(address);
|
this.network = bridge.createNetwork(address);
|
@ -12,7 +12,7 @@ public class FakeplayerTicker extends BukkitRunnable {
|
|||||||
public final static long NON_REMOVE_AT = -1;
|
public final static long NON_REMOVE_AT = -1;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final FakePlayer player;
|
private final Fakeplayer player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 移除时间
|
* 移除时间
|
||||||
@ -26,7 +26,7 @@ public class FakeplayerTicker extends BukkitRunnable {
|
|||||||
private boolean firstTick;
|
private boolean firstTick;
|
||||||
|
|
||||||
public FakeplayerTicker(
|
public FakeplayerTicker(
|
||||||
@NotNull FakePlayer player,
|
@NotNull Fakeplayer player,
|
||||||
long lifespan
|
long lifespan
|
||||||
) {
|
) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
@ -4,16 +4,12 @@ import com.google.inject.Inject;
|
|||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
import io.github.hello09x.devtools.core.utils.ComponentUtils;
|
import io.github.hello09x.devtools.core.utils.ComponentUtils;
|
||||||
import io.github.hello09x.devtools.core.utils.MetadataUtils;
|
import io.github.hello09x.devtools.core.utils.MetadataUtils;
|
||||||
import io.github.hello09x.fakeplayer.api.spi.ActionSetting;
|
|
||||||
import io.github.hello09x.fakeplayer.api.spi.ActionType;
|
|
||||||
import io.github.hello09x.fakeplayer.core.Main;
|
import io.github.hello09x.fakeplayer.core.Main;
|
||||||
import io.github.hello09x.fakeplayer.core.config.FakeplayerConfig;
|
import io.github.hello09x.fakeplayer.core.config.FakeplayerConfig;
|
||||||
import io.github.hello09x.fakeplayer.core.constant.MetadataKeys;
|
import io.github.hello09x.fakeplayer.core.constant.MetadataKeys;
|
||||||
import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
|
import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
|
||||||
import io.github.hello09x.fakeplayer.core.manager.action.ActionManager;
|
import io.github.hello09x.fakeplayer.core.repository.FakeplayerProfileRepository;
|
||||||
import io.github.hello09x.fakeplayer.core.repository.FakePlayerProfileRepository;
|
|
||||||
import io.github.hello09x.fakeplayer.core.repository.UsedIdRepository;
|
import io.github.hello09x.fakeplayer.core.repository.UsedIdRepository;
|
||||||
import net.kyori.adventure.util.Ticks;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.attribute.AttributeInstance;
|
import org.bukkit.attribute.AttributeInstance;
|
||||||
@ -22,7 +18,6 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.player.PlayerFishEvent;
|
|
||||||
import org.bukkit.event.player.PlayerKickEvent;
|
import org.bukkit.event.player.PlayerKickEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
@ -43,15 +38,13 @@ public class FakeplayerListener implements Listener {
|
|||||||
private final static Logger log = Main.getInstance().getLogger();
|
private final static Logger log = Main.getInstance().getLogger();
|
||||||
|
|
||||||
private final FakeplayerManager manager;
|
private final FakeplayerManager manager;
|
||||||
private final ActionManager actionManager;
|
|
||||||
private final UsedIdRepository usedIdRepository;
|
private final UsedIdRepository usedIdRepository;
|
||||||
private final FakePlayerProfileRepository profileRepository;
|
private final FakeplayerProfileRepository profileRepository;
|
||||||
private final FakeplayerConfig config;
|
private final FakeplayerConfig config;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FakeplayerListener(FakeplayerManager manager, ActionManager actionManager, UsedIdRepository usedIdRepository, FakePlayerProfileRepository profileRepository, FakeplayerConfig config) {
|
public FakeplayerListener(FakeplayerManager manager, UsedIdRepository usedIdRepository, FakeplayerProfileRepository profileRepository, FakeplayerConfig config) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
this.actionManager = actionManager;
|
|
||||||
this.usedIdRepository = usedIdRepository;
|
this.usedIdRepository = usedIdRepository;
|
||||||
this.profileRepository = profileRepository;
|
this.profileRepository = profileRepository;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
@ -166,27 +159,4 @@ public class FakeplayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
|
||||||
public void autoFishing(@NotNull PlayerFishEvent event) {
|
|
||||||
if (event.getState() != PlayerFishEvent.State.BITE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var player = event.getPlayer();
|
|
||||||
if (manager.isNotFake(player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!player.hasMetadata(MetadataKeys.AUTOFISH)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(Main.getInstance(), () -> {
|
|
||||||
actionManager.setAction(player, ActionType.USE, ActionSetting.once());
|
|
||||||
Bukkit.getScheduler().runTaskLater(Main.getInstance(), () -> {
|
|
||||||
actionManager.setAction(player, ActionType.USE, ActionSetting.once());
|
|
||||||
}, Ticks.TICKS_PER_SECOND);
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,71 @@
|
|||||||
|
package io.github.hello09x.fakeplayer.core.manager;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
import io.github.hello09x.fakeplayer.api.spi.ActionSetting;
|
||||||
|
import io.github.hello09x.fakeplayer.api.spi.ActionType;
|
||||||
|
import io.github.hello09x.fakeplayer.core.Main;
|
||||||
|
import io.github.hello09x.fakeplayer.core.constant.MetadataKeys;
|
||||||
|
import io.github.hello09x.fakeplayer.core.manager.action.ActionManager;
|
||||||
|
import net.kyori.adventure.util.Ticks;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerFishEvent;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author tanyaofei
|
||||||
|
* @since 2024/8/11
|
||||||
|
**/
|
||||||
|
@Singleton
|
||||||
|
public class FakeplayerAutofishManager implements Listener {
|
||||||
|
|
||||||
|
private final FakeplayerManager manager;
|
||||||
|
private final ActionManager actionManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public FakeplayerAutofishManager(FakeplayerManager manager, ActionManager actionManager) {
|
||||||
|
this.manager = manager;
|
||||||
|
this.actionManager = actionManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAutofish(@NotNull Player fake) {
|
||||||
|
return fake.hasMetadata(MetadataKeys.AUTOFISH);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAutofish(@NotNull Player target, boolean autofish) {
|
||||||
|
if (!autofish) {
|
||||||
|
target.removeMetadata(MetadataKeys.AUTOFISH, Main.getInstance());
|
||||||
|
} else {
|
||||||
|
target.setMetadata(MetadataKeys.AUTOFISH, new FixedMetadataValue(Main.getInstance(), true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||||
|
public void autoFishing(@NotNull PlayerFishEvent event) {
|
||||||
|
if (event.getState() != PlayerFishEvent.State.BITE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var player = event.getPlayer();
|
||||||
|
if (manager.isNotFake(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!player.hasMetadata(MetadataKeys.AUTOFISH)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskLater(Main.getInstance(), () -> {
|
||||||
|
actionManager.setAction(player, ActionType.USE, ActionSetting.once());
|
||||||
|
Bukkit.getScheduler().runTaskLater(Main.getInstance(), () -> {
|
||||||
|
actionManager.setAction(player, ActionType.USE, ActionSetting.once());
|
||||||
|
}, Ticks.TICKS_PER_SECOND);
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package io.github.hello09x.fakeplayer.core.manager;
|
package io.github.hello09x.fakeplayer.core.manager;
|
||||||
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
import io.github.hello09x.fakeplayer.core.entity.FakePlayer;
|
import io.github.hello09x.fakeplayer.core.entity.Fakeplayer;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
@ -12,18 +12,16 @@ import java.util.stream.Stream;
|
|||||||
@Singleton
|
@Singleton
|
||||||
public class FakeplayerList {
|
public class FakeplayerList {
|
||||||
|
|
||||||
private final Map<String, FakePlayer> playersByName = new HashMap<>();
|
private final Map<String, Fakeplayer> playersByName = new HashMap<>();
|
||||||
|
private final Map<UUID, Fakeplayer> playersByUUID = new HashMap<>();
|
||||||
private final Map<UUID, FakePlayer> playersByUUID = new HashMap<>();
|
private final Map<String, List<Fakeplayer>> playersByCreator = new HashMap<>();
|
||||||
|
|
||||||
private final Map<String, List<FakePlayer>> playersByCreator = new HashMap<>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加一个假人到假人清单
|
* 添加一个假人到假人清单
|
||||||
*
|
*
|
||||||
* @param player 假人
|
* @param player 假人
|
||||||
*/
|
*/
|
||||||
public void add(@NotNull FakePlayer player) {
|
public void add(@NotNull Fakeplayer player) {
|
||||||
this.playersByName.put(player.getName(), player);
|
this.playersByName.put(player.getName(), player);
|
||||||
this.playersByUUID.put(player.getUUID(), player);
|
this.playersByUUID.put(player.getUUID(), player);
|
||||||
this.playersByCreator.computeIfAbsent(player.getCreator().getName(), key -> new LinkedList<>()).add(player);
|
this.playersByCreator.computeIfAbsent(player.getCreator().getName(), key -> new LinkedList<>()).add(player);
|
||||||
@ -35,7 +33,7 @@ public class FakeplayerList {
|
|||||||
* @param name 名称
|
* @param name 名称
|
||||||
* @return 假人
|
* @return 假人
|
||||||
*/
|
*/
|
||||||
public @Nullable FakePlayer getByName(@NotNull String name) {
|
public @Nullable Fakeplayer getByName(@NotNull String name) {
|
||||||
return Optional.ofNullable(this.playersByName.get(name)).map(this::checkOnline).orElse(null);
|
return Optional.ofNullable(this.playersByName.get(name)).map(this::checkOnline).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +43,7 @@ public class FakeplayerList {
|
|||||||
* @param uuid UUID
|
* @param uuid UUID
|
||||||
* @return 假人
|
* @return 假人
|
||||||
*/
|
*/
|
||||||
public @Nullable FakePlayer getByUUID(@NotNull UUID uuid) {
|
public @Nullable Fakeplayer getByUUID(@NotNull UUID uuid) {
|
||||||
return Optional.ofNullable(this.playersByUUID.get(uuid)).map(this::checkOnline).orElse(null);
|
return Optional.ofNullable(this.playersByUUID.get(uuid)).map(this::checkOnline).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +53,7 @@ public class FakeplayerList {
|
|||||||
* @param creator 创建者
|
* @param creator 创建者
|
||||||
* @return 假人
|
* @return 假人
|
||||||
*/
|
*/
|
||||||
public @NotNull @Unmodifiable List<FakePlayer> getByCreator(@NotNull String creator) {
|
public @NotNull @Unmodifiable List<Fakeplayer> getByCreator(@NotNull String creator) {
|
||||||
return Optional.ofNullable(this.playersByCreator.get(creator)).map(Collections::unmodifiableList).orElse(Collections.emptyList());
|
return Optional.ofNullable(this.playersByCreator.get(creator)).map(Collections::unmodifiableList).orElse(Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +62,7 @@ public class FakeplayerList {
|
|||||||
*
|
*
|
||||||
* @param player 假人
|
* @param player 假人
|
||||||
*/
|
*/
|
||||||
public void remove(@NotNull FakePlayer player) {
|
public void remove(@NotNull Fakeplayer player) {
|
||||||
this.playersByName.remove(player.getName());
|
this.playersByName.remove(player.getName());
|
||||||
this.playersByUUID.remove(player.getUUID());
|
this.playersByUUID.remove(player.getUUID());
|
||||||
Optional.ofNullable(this.playersByCreator.get(player.getCreator().getName())).map(players -> players.remove(player));
|
Optional.ofNullable(this.playersByCreator.get(player.getCreator().getName())).map(players -> players.remove(player));
|
||||||
@ -76,7 +74,7 @@ public class FakeplayerList {
|
|||||||
* @param uuid UUID
|
* @param uuid UUID
|
||||||
* @return 被移除的假人
|
* @return 被移除的假人
|
||||||
*/
|
*/
|
||||||
public @Nullable FakePlayer removeByUUID(@NotNull UUID uuid) {
|
public @Nullable Fakeplayer removeByUUID(@NotNull UUID uuid) {
|
||||||
var player = getByUUID(uuid);
|
var player = getByUUID(uuid);
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -103,7 +101,7 @@ public class FakeplayerList {
|
|||||||
*
|
*
|
||||||
* @return 假人
|
* @return 假人
|
||||||
*/
|
*/
|
||||||
public @NotNull @Unmodifiable List<FakePlayer> getAll() {
|
public @NotNull @Unmodifiable List<Fakeplayer> getAll() {
|
||||||
return List.copyOf(this.playersByUUID.values());
|
return List.copyOf(this.playersByUUID.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +111,7 @@ public class FakeplayerList {
|
|||||||
* @param player 假人
|
* @param player 假人
|
||||||
* @return 假人
|
* @return 假人
|
||||||
*/
|
*/
|
||||||
private @Nullable FakePlayer checkOnline(@NotNull FakePlayer player) {
|
private @Nullable Fakeplayer checkOnline(@NotNull Fakeplayer player) {
|
||||||
if (!player.isOnline()) {
|
if (!player.isOnline()) {
|
||||||
this.remove(player);
|
this.remove(player);
|
||||||
return null;
|
return null;
|
||||||
@ -122,7 +120,7 @@ public class FakeplayerList {
|
|||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull Stream<FakePlayer> stream() {
|
public @NotNull Stream<Fakeplayer> stream() {
|
||||||
return this.playersByUUID.values().stream();
|
return this.playersByUUID.values().stream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import io.github.hello09x.fakeplayer.api.spi.NMSBridge;
|
|||||||
import io.github.hello09x.fakeplayer.core.Main;
|
import io.github.hello09x.fakeplayer.core.Main;
|
||||||
import io.github.hello09x.fakeplayer.core.config.FakeplayerConfig;
|
import io.github.hello09x.fakeplayer.core.config.FakeplayerConfig;
|
||||||
import io.github.hello09x.fakeplayer.core.constant.MetadataKeys;
|
import io.github.hello09x.fakeplayer.core.constant.MetadataKeys;
|
||||||
import io.github.hello09x.fakeplayer.core.entity.FakePlayer;
|
import io.github.hello09x.fakeplayer.core.entity.Fakeplayer;
|
||||||
import io.github.hello09x.fakeplayer.core.entity.SpawnOption;
|
import io.github.hello09x.fakeplayer.core.entity.SpawnOption;
|
||||||
import io.github.hello09x.fakeplayer.core.manager.invsee.Invsee;
|
import io.github.hello09x.fakeplayer.core.manager.invsee.Invsee;
|
||||||
import io.github.hello09x.fakeplayer.core.manager.naming.NameManager;
|
import io.github.hello09x.fakeplayer.core.manager.naming.NameManager;
|
||||||
@ -99,7 +99,7 @@ public class FakeplayerManager {
|
|||||||
var sn = name == null ? nameManager.getRegularName(creator) : nameManager.getSpecifiedName(name);
|
var sn = name == null ? nameManager.getRegularName(creator) : nameManager.getSpecifiedName(name);
|
||||||
log.info("UUID of fake player %s is %s".formatted(sn.name(), sn.uuid()));
|
log.info("UUID of fake player %s is %s".formatted(sn.name(), sn.uuid()));
|
||||||
|
|
||||||
var fp = new FakePlayer(
|
var fp = new Fakeplayer(
|
||||||
creator,
|
creator,
|
||||||
AddressUtils.getAddress(creator),
|
AddressUtils.getAddress(creator),
|
||||||
sn,
|
sn,
|
||||||
@ -139,7 +139,7 @@ public class FakeplayerManager {
|
|||||||
return Optional
|
return Optional
|
||||||
.ofNullable(this.playerList.getByName(name))
|
.ofNullable(this.playerList.getByName(name))
|
||||||
.filter(p -> p.isCreatedBy(creator))
|
.filter(p -> p.isCreatedBy(creator))
|
||||||
.map(FakePlayer::getPlayer)
|
.map(Fakeplayer::getPlayer)
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ public class FakeplayerManager {
|
|||||||
public @Nullable Player get(@NotNull String name) {
|
public @Nullable Player get(@NotNull String name) {
|
||||||
return Optional
|
return Optional
|
||||||
.ofNullable(this.playerList.getByName(name))
|
.ofNullable(this.playerList.getByName(name))
|
||||||
.map(FakePlayer::getPlayer)
|
.map(Fakeplayer::getPlayer)
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ public class FakeplayerManager {
|
|||||||
public @Nullable String getCreatorName(@NotNull Player target) {
|
public @Nullable String getCreatorName(@NotNull Player target) {
|
||||||
return Optional
|
return Optional
|
||||||
.ofNullable(this.playerList.getByUUID(target.getUniqueId()))
|
.ofNullable(this.playerList.getByUUID(target.getUniqueId()))
|
||||||
.map(FakePlayer::getCreator)
|
.map(Fakeplayer::getCreator)
|
||||||
.map(CommandSender::getName)
|
.map(CommandSender::getName)
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ public class FakeplayerManager {
|
|||||||
*/
|
*/
|
||||||
public @Nullable CommandSender getCreator(@NotNull Player target) {
|
public @Nullable CommandSender getCreator(@NotNull Player target) {
|
||||||
return Optional.ofNullable(this.playerList.getByUUID(target.getUniqueId()))
|
return Optional.ofNullable(this.playerList.getByUUID(target.getUniqueId()))
|
||||||
.map(FakePlayer::getCreator)
|
.map(Fakeplayer::getCreator)
|
||||||
.map(creator -> {
|
.map(creator -> {
|
||||||
if (creator instanceof Player p) {
|
if (creator instanceof Player p) {
|
||||||
return Bukkit.getPlayer(p.getUniqueId());
|
return Bukkit.getPlayer(p.getUniqueId());
|
||||||
@ -245,7 +245,7 @@ public class FakeplayerManager {
|
|||||||
* @return 经过筛选的假人
|
* @return 经过筛选的假人
|
||||||
*/
|
*/
|
||||||
public @NotNull List<Player> getAll(@Nullable Predicate<Player> predicate) {
|
public @NotNull List<Player> getAll(@Nullable Predicate<Player> predicate) {
|
||||||
var stream = this.playerList.getAll().stream().map(FakePlayer::getPlayer);
|
var stream = this.playerList.getAll().stream().map(Fakeplayer::getPlayer);
|
||||||
if (predicate != null) {
|
if (predicate != null) {
|
||||||
stream = stream.filter(predicate);
|
stream = stream.filter(predicate);
|
||||||
}
|
}
|
||||||
@ -290,7 +290,7 @@ public class FakeplayerManager {
|
|||||||
* @return 假人
|
* @return 假人
|
||||||
*/
|
*/
|
||||||
public @NotNull List<Player> getAll(@NotNull CommandSender creator, @Nullable Predicate<Player> predicate) {
|
public @NotNull List<Player> getAll(@NotNull CommandSender creator, @Nullable Predicate<Player> predicate) {
|
||||||
var stream = this.playerList.getByCreator(creator.getName()).stream().map(FakePlayer::getPlayer);
|
var stream = this.playerList.getByCreator(creator.getName()).stream().map(Fakeplayer::getPlayer);
|
||||||
if (predicate != null) {
|
if (predicate != null) {
|
||||||
stream = stream.filter(predicate);
|
stream = stream.filter(predicate);
|
||||||
}
|
}
|
||||||
@ -340,42 +340,6 @@ public class FakeplayerManager {
|
|||||||
return this.playerList.countByCreator(creator.getName());
|
return this.playerList.countByCreator(creator.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置假人是否自动填装
|
|
||||||
*
|
|
||||||
* @param target 假人
|
|
||||||
* @param replenish 是否自动补货
|
|
||||||
*/
|
|
||||||
public void setReplenish(@NotNull Player target, boolean replenish) {
|
|
||||||
if (!replenish) {
|
|
||||||
target.removeMetadata(MetadataKeys.REPLENISH, Main.getInstance());
|
|
||||||
} else {
|
|
||||||
target.setMetadata(MetadataKeys.REPLENISH, new FixedMetadataValue(Main.getInstance(), true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断假人是否自动补货
|
|
||||||
*
|
|
||||||
* @param target 假人
|
|
||||||
* @return 是否自动补货
|
|
||||||
*/
|
|
||||||
public boolean isReplenish(@NotNull Player target) {
|
|
||||||
return target.hasMetadata(MetadataKeys.REPLENISH);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAutofish(@NotNull Player target) {
|
|
||||||
return target.hasMetadata(MetadataKeys.AUTOFISH);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAutofish(@NotNull Player target, boolean autofish) {
|
|
||||||
if (!autofish) {
|
|
||||||
target.removeMetadata(MetadataKeys.AUTOFISH, Main.getInstance());
|
|
||||||
} else {
|
|
||||||
target.setMetadata(MetadataKeys.AUTOFISH, new FixedMetadataValue(Main.getInstance(), true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置玩家当前选择的假人
|
* 设置玩家当前选择的假人
|
||||||
*
|
*
|
||||||
@ -419,7 +383,7 @@ public class FakeplayerManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var target = Optional.ofNullable(this.playerList.getByUUID(uuid)).map(FakePlayer::getPlayer).orElse(null);
|
var target = Optional.ofNullable(this.playerList.getByUUID(uuid)).map(Fakeplayer::getPlayer).orElse(null);
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
this.setSelection(p, null);
|
this.setSelection(p, null);
|
||||||
}
|
}
|
||||||
@ -452,7 +416,7 @@ public class FakeplayerManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispatchCommandsEarly(@NotNull FakePlayer fp, @NotNull List<String> commands) {
|
public void dispatchCommandsEarly(@NotNull Fakeplayer fp, @NotNull List<String> commands) {
|
||||||
if (commands.isEmpty()) {
|
if (commands.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
package io.github.hello09x.fakeplayer.core.listener;
|
package io.github.hello09x.fakeplayer.core.manager;
|
||||||
|
|
||||||
|
|
||||||
import com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent;
|
import com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
@ -7,7 +6,7 @@ import com.google.inject.Singleton;
|
|||||||
import io.github.hello09x.devtools.core.utils.BlockUtils;
|
import io.github.hello09x.devtools.core.utils.BlockUtils;
|
||||||
import io.github.hello09x.fakeplayer.core.Main;
|
import io.github.hello09x.fakeplayer.core.Main;
|
||||||
import io.github.hello09x.fakeplayer.core.command.Permission;
|
import io.github.hello09x.fakeplayer.core.command.Permission;
|
||||||
import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
|
import io.github.hello09x.fakeplayer.core.constant.MetadataKeys;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
@ -24,28 +23,57 @@ import org.bukkit.event.player.PlayerItemBreakEvent;
|
|||||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author tanyaofei
|
||||||
|
* @since 2024/8/11
|
||||||
|
**/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ReplenishListener implements Listener {
|
public class FakeplayerReplenishManager implements Listener {
|
||||||
|
|
||||||
private final FakeplayerManager manager;
|
private final FakeplayerManager manager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ReplenishListener(FakeplayerManager manager) {
|
public FakeplayerReplenishManager(FakeplayerManager manager) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置假人是否自动填装
|
||||||
|
*
|
||||||
|
* @param target 假人
|
||||||
|
* @param replenish 是否自动补货
|
||||||
|
*/
|
||||||
|
public void setReplenish(@NotNull Player target, boolean replenish) {
|
||||||
|
if (!replenish) {
|
||||||
|
target.removeMetadata(MetadataKeys.REPLENISH, Main.getInstance());
|
||||||
|
} else {
|
||||||
|
target.setMetadata(MetadataKeys.REPLENISH, new FixedMetadataValue(Main.getInstance(), true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断假人是否自动补货
|
||||||
|
*
|
||||||
|
* @param target 假人
|
||||||
|
* @return 是否自动补货
|
||||||
|
*/
|
||||||
|
public boolean isReplenish(@NotNull Player target) {
|
||||||
|
return target.hasMetadata(MetadataKeys.REPLENISH);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消耗物品自动填装
|
* 消耗物品自动填装
|
||||||
*/
|
*/
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||||
public void onItemUse(@NotNull PlayerItemConsumeEvent event) {
|
public void onItemUse(@NotNull PlayerItemConsumeEvent event) {
|
||||||
var player = event.getPlayer();
|
var player = event.getPlayer();
|
||||||
if (!manager.isReplenish(player)) {
|
if (!this.isReplenish(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +92,7 @@ public class ReplenishListener implements Listener {
|
|||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||||
public void onBlockPlace(@NotNull BlockPlaceEvent event) {
|
public void onBlockPlace(@NotNull BlockPlaceEvent event) {
|
||||||
var player = event.getPlayer();
|
var player = event.getPlayer();
|
||||||
if (!manager.isReplenish(player)) {
|
if (!this.isReplenish(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +111,7 @@ public class ReplenishListener implements Listener {
|
|||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||||
public void onItemBreak(@NotNull PlayerItemBreakEvent event) {
|
public void onItemBreak(@NotNull PlayerItemBreakEvent event) {
|
||||||
var player = event.getPlayer();
|
var player = event.getPlayer();
|
||||||
if (!manager.isReplenish(player)) {
|
if (!this.isReplenish(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +130,7 @@ public class ReplenishListener implements Listener {
|
|||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||||
public void onProjectileLaunch(@NotNull PlayerLaunchProjectileEvent event) {
|
public void onProjectileLaunch(@NotNull PlayerLaunchProjectileEvent event) {
|
||||||
var player = event.getPlayer();
|
var player = event.getPlayer();
|
||||||
if (!manager.isReplenish(event.getPlayer())) {
|
if (!this.isReplenish(event.getPlayer())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var item = event.getItemStack();
|
var item = event.getItemStack();
|
||||||
@ -247,5 +275,4 @@ public class ReplenishListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -10,7 +10,7 @@ import com.google.inject.Singleton;
|
|||||||
import io.github.hello09x.devtools.core.utils.SchedulerUtils;
|
import io.github.hello09x.devtools.core.utils.SchedulerUtils;
|
||||||
import io.github.hello09x.fakeplayer.core.Main;
|
import io.github.hello09x.fakeplayer.core.Main;
|
||||||
import io.github.hello09x.fakeplayer.core.config.FakeplayerConfig;
|
import io.github.hello09x.fakeplayer.core.config.FakeplayerConfig;
|
||||||
import io.github.hello09x.fakeplayer.core.repository.FakePlayerSkinRepository;
|
import io.github.hello09x.fakeplayer.core.repository.FakeplayerSkinRepository;
|
||||||
import io.github.hello09x.fakeplayer.core.repository.model.FakePlayerSkin;
|
import io.github.hello09x.fakeplayer.core.repository.model.FakePlayerSkin;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@ -32,7 +32,7 @@ import java.util.logging.Logger;
|
|||||||
public class FakeplayerSkinManager {
|
public class FakeplayerSkinManager {
|
||||||
|
|
||||||
private final static Logger log = Main.getInstance().getLogger();
|
private final static Logger log = Main.getInstance().getLogger();
|
||||||
private final FakePlayerSkinRepository repository;
|
private final FakeplayerSkinRepository repository;
|
||||||
private final FakeplayerConfig config;
|
private final FakeplayerConfig config;
|
||||||
private final Cache<UUID, PlayerProfile> profileCache = CacheBuilder
|
private final Cache<UUID, PlayerProfile> profileCache = CacheBuilder
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
@ -40,7 +40,7 @@ public class FakeplayerSkinManager {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FakeplayerSkinManager(FakePlayerSkinRepository repository, FakeplayerConfig config) {
|
public FakeplayerSkinManager(FakeplayerSkinRepository repository, FakeplayerConfig config) {
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import com.google.inject.Singleton;
|
|||||||
import io.github.hello09x.fakeplayer.core.Main;
|
import io.github.hello09x.fakeplayer.core.Main;
|
||||||
import io.github.hello09x.fakeplayer.core.config.FakeplayerConfig;
|
import io.github.hello09x.fakeplayer.core.config.FakeplayerConfig;
|
||||||
import io.github.hello09x.fakeplayer.core.manager.naming.exception.IllegalCustomNameException;
|
import io.github.hello09x.fakeplayer.core.manager.naming.exception.IllegalCustomNameException;
|
||||||
import io.github.hello09x.fakeplayer.core.repository.FakePlayerProfileRepository;
|
import io.github.hello09x.fakeplayer.core.repository.FakeplayerProfileRepository;
|
||||||
import io.github.hello09x.fakeplayer.core.repository.UsedIdRepository;
|
import io.github.hello09x.fakeplayer.core.repository.UsedIdRepository;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
@ -34,14 +34,14 @@ public class NameManager {
|
|||||||
private final static int MIN_LENGTH = 3; // mojang required
|
private final static int MIN_LENGTH = 3; // mojang required
|
||||||
|
|
||||||
private final UsedIdRepository legacyUsedIdRepository;
|
private final UsedIdRepository legacyUsedIdRepository;
|
||||||
private final FakePlayerProfileRepository profileRepository;
|
private final FakeplayerProfileRepository profileRepository;
|
||||||
private final FakeplayerConfig config;
|
private final FakeplayerConfig config;
|
||||||
private final Map<String, NameSource> nameSources = new HashMap<>();
|
private final Map<String, NameSource> nameSources = new HashMap<>();
|
||||||
|
|
||||||
private final String serverId;
|
private final String serverId;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public NameManager(UsedIdRepository legacyUsedIdRepository, FakePlayerProfileRepository profileRepository, FakeplayerConfig config) {
|
public NameManager(UsedIdRepository legacyUsedIdRepository, FakeplayerProfileRepository profileRepository, FakeplayerConfig config) {
|
||||||
this.legacyUsedIdRepository = legacyUsedIdRepository;
|
this.legacyUsedIdRepository = legacyUsedIdRepository;
|
||||||
this.profileRepository = profileRepository;
|
this.profileRepository = profileRepository;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
@ -16,12 +16,12 @@ import java.util.UUID;
|
|||||||
* @since 2024/8/3
|
* @since 2024/8/3
|
||||||
**/
|
**/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class FakePlayerProfileRepository {
|
public class FakeplayerProfileRepository {
|
||||||
|
|
||||||
private final JdbcTemplate jdbc;
|
private final JdbcTemplate jdbc;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FakePlayerProfileRepository(JdbcTemplate jdbc) {
|
public FakeplayerProfileRepository(JdbcTemplate jdbc) {
|
||||||
this.jdbc = jdbc;
|
this.jdbc = jdbc;
|
||||||
this.initTables();
|
this.initTables();
|
||||||
}
|
}
|
@ -16,12 +16,12 @@ import java.util.UUID;
|
|||||||
* @since 2024/8/8
|
* @since 2024/8/8
|
||||||
**/
|
**/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class FakePlayerSkinRepository {
|
public class FakeplayerSkinRepository {
|
||||||
|
|
||||||
private final JdbcTemplate jdbc;
|
private final JdbcTemplate jdbc;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FakePlayerSkinRepository(JdbcTemplate jdbc) {
|
public FakeplayerSkinRepository(JdbcTemplate jdbc) {
|
||||||
this.jdbc = jdbc;
|
this.jdbc = jdbc;
|
||||||
this.initTables();
|
this.initTables();
|
||||||
}
|
}
|
@ -3,7 +3,8 @@ package io.github.hello09x.fakeplayer.core.repository.model;
|
|||||||
import io.github.hello09x.devtools.core.utils.SingletonSupplier;
|
import io.github.hello09x.devtools.core.utils.SingletonSupplier;
|
||||||
import io.github.hello09x.fakeplayer.core.Main;
|
import io.github.hello09x.fakeplayer.core.Main;
|
||||||
import io.github.hello09x.fakeplayer.core.command.Permission;
|
import io.github.hello09x.fakeplayer.core.command.Permission;
|
||||||
import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
|
import io.github.hello09x.fakeplayer.core.manager.FakeplayerAutofishManager;
|
||||||
|
import io.github.hello09x.fakeplayer.core.manager.FakeplayerReplenishManager;
|
||||||
import net.kyori.adventure.translation.Translatable;
|
import net.kyori.adventure.translation.Translatable;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
@ -55,8 +56,8 @@ public record Config<T>(
|
|||||||
) implements Translatable {
|
) implements Translatable {
|
||||||
|
|
||||||
private static final Map<String, Config<?>> values = new HashMap<>();
|
private static final Map<String, Config<?>> values = new HashMap<>();
|
||||||
|
private static final SingletonSupplier<FakeplayerAutofishManager> autofishManager = new SingletonSupplier<>(() -> Main.getInjector().getInstance(FakeplayerAutofishManager.class));
|
||||||
private final static SingletonSupplier<FakeplayerManager> manager = new SingletonSupplier<>(() -> Main.getInjector().getInstance(FakeplayerManager.class));
|
private static final SingletonSupplier<FakeplayerReplenishManager> replenishManager = new SingletonSupplier<>(() -> Main.getInjector().getInstance(FakeplayerReplenishManager.class));
|
||||||
|
|
||||||
public static Config<Boolean> collidable = build(
|
public static Config<Boolean> collidable = build(
|
||||||
"collidable",
|
"collidable",
|
||||||
@ -136,7 +137,7 @@ public record Config<T>(
|
|||||||
List.of("true", "false"),
|
List.of("true", "false"),
|
||||||
Permission.replenish,
|
Permission.replenish,
|
||||||
Boolean::valueOf,
|
Boolean::valueOf,
|
||||||
new Accessor<>(manager.get()::isReplenish, manager.get()::setReplenish)
|
new Accessor<>(replenishManager.get()::isReplenish, replenishManager.get()::setReplenish)
|
||||||
);
|
);
|
||||||
|
|
||||||
public static Config<Boolean> autofish = build(
|
public static Config<Boolean> autofish = build(
|
||||||
@ -147,7 +148,7 @@ public record Config<T>(
|
|||||||
List.of("true", "false"),
|
List.of("true", "false"),
|
||||||
Permission.autofish,
|
Permission.autofish,
|
||||||
Boolean::valueOf,
|
Boolean::valueOf,
|
||||||
new Accessor<>(Main.getInjector().getInstance(FakeplayerManager.class)::isAutofish, Main.getInjector().getInstance(FakeplayerManager.class)::setAutofish)
|
new Accessor<>(autofishManager.get()::isAutofish, autofishManager.get()::setAutofish)
|
||||||
);
|
);
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
2
pom.xml
2
pom.xml
@ -24,7 +24,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<java.version>21</java.version>
|
<java.version>21</java.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<revision>0.3.9-b.2</revision>
|
<revision>0.3.9-b.4</revision>
|
||||||
|
|
||||||
<detools.version>0.1.3-SNAPSHOT</detools.version>
|
<detools.version>0.1.3-SNAPSHOT</detools.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
Loading…
Reference in New Issue
Block a user