Compare commits
No commits in common. "899a7e2f32fdd688d0df46899c57470b47033c77" and "4282b1f0cdab09dc79975229a96d905112d74e4f" have entirely different histories.
899a7e2f32
...
4282b1f0cd
7 changed files with 53 additions and 41 deletions
|
@ -35,11 +35,12 @@ dependencies {
|
||||||
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
|
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
|
||||||
|
|
||||||
compileOnly("me.clip:placeholderapi:2.11.5")
|
compileOnly("me.clip:placeholderapi:2.11.5")
|
||||||
compileOnly("net.kyori:adventure-api:4.24.0")
|
compileOnly("net.kyori:adventure-api:4.21.0")
|
||||||
compileOnly("xyz.xenondevs.invui:invui-core:$invuiVersion")
|
compileOnly("xyz.xenondevs.invui:invui-core:$invuiVersion")
|
||||||
compileOnly("net.wesjd:anvilgui:1.10.4-SNAPSHOT")
|
compileOnly("net.wesjd:anvilgui:1.10.4-SNAPSHOT")
|
||||||
|
|
||||||
implementation("com.github.retrooper:packetevents-spigot:2.9.5")
|
implementation("com.github.retrooper:packetevents-spigot:2.9.0")
|
||||||
|
|
||||||
implementation("com.github.jsixface:yamlconfig:1.2")
|
implementation("com.github.jsixface:yamlconfig:1.2")
|
||||||
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:$jacksonVersion")
|
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:$jacksonVersion")
|
||||||
implementation("com.fasterxml.jackson.core:jackson-core:$jacksonVersion")
|
implementation("com.fasterxml.jackson.core:jackson-core:$jacksonVersion")
|
||||||
|
@ -47,6 +48,11 @@ dependencies {
|
||||||
implementation("org.mariadb.jdbc:mariadb-java-client:3.5.2")
|
implementation("org.mariadb.jdbc:mariadb-java-client:3.5.2")
|
||||||
implementation("redis.clients:jedis:5.2.0")
|
implementation("redis.clients:jedis:5.2.0")
|
||||||
implementation("com.google.code.gson:gson:2.13.1")
|
implementation("com.google.code.gson:gson:2.13.1")
|
||||||
|
|
||||||
|
testImplementation("org.mockbukkit.mockbukkit:mockbukkit-v1.21:$mockBukkitVersion")
|
||||||
|
testImplementation(platform("org.junit:junit-bom:5.13.4"))
|
||||||
|
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||||
|
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
|
|
@ -2,7 +2,6 @@ package xyz.ineanto.nicko;
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.PacketEvents;
|
import com.github.retrooper.packetevents.PacketEvents;
|
||||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||||
import com.github.retrooper.packetevents.settings.PacketEventsSettings;
|
|
||||||
import io.github.retrooper.packetevents.factory.spigot.SpigotPacketEventsBuilder;
|
import io.github.retrooper.packetevents.factory.spigot.SpigotPacketEventsBuilder;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
@ -33,23 +32,22 @@ import java.io.IOException;
|
||||||
public class Nicko extends JavaPlugin {
|
public class Nicko extends JavaPlugin {
|
||||||
private static Nicko plugin;
|
private static Nicko plugin;
|
||||||
|
|
||||||
private final MojangAPI mojangApi = new MojangAPI();
|
private MojangAPI mojangAPI;
|
||||||
private final PlayerNameStore nameStore = new PlayerNameStore();
|
|
||||||
private PlayerDataStore dataStore;
|
private PlayerDataStore dataStore;
|
||||||
private ConfigurationManager configurationManager;
|
private ConfigurationManager configurationManager;
|
||||||
private Configuration configuration;
|
private Configuration configuration;
|
||||||
private CustomLanguage customLanguage;
|
private CustomLanguage customLanguage;
|
||||||
|
private PlayerNameStore nameStore;
|
||||||
private RandomNameFetcher nameFetcher;
|
private RandomNameFetcher nameFetcher;
|
||||||
|
|
||||||
|
public Nicko() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
PacketEvents.setAPI(
|
PacketEvents.setAPI(SpigotPacketEventsBuilder.build(this));
|
||||||
SpigotPacketEventsBuilder.build(this,
|
PacketEvents.getAPI().getSettings().checkForUpdates(false).kickOnPacketException(true);
|
||||||
new PacketEventsSettings()
|
|
||||||
.checkForUpdates(true)
|
|
||||||
.kickOnPacketException(true)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
PacketEvents.getAPI().load();
|
PacketEvents.getAPI().load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,13 +55,12 @@ public class Nicko extends JavaPlugin {
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
plugin = this;
|
plugin = this;
|
||||||
|
|
||||||
|
PacketEvents.getAPI().init();
|
||||||
|
|
||||||
configurationManager = new ConfigurationManager(getDataFolder());
|
configurationManager = new ConfigurationManager(getDataFolder());
|
||||||
configurationManager.saveDefaultConfig();
|
configurationManager.saveDefaultConfig();
|
||||||
|
|
||||||
nameFetcher = new RandomNameFetcher(this);
|
dataStore = new PlayerDataStore(mojangAPI, getNickoConfig());
|
||||||
dataStore = new PlayerDataStore(mojangApi, getNickoConfig());
|
|
||||||
|
|
||||||
PacketEvents.getAPI().init();
|
|
||||||
|
|
||||||
if (PacketEvents.getAPI().getServerManager().getVersion().isOlderThan(ServerVersion.V_1_20)) {
|
if (PacketEvents.getAPI().getServerManager().getVersion().isOlderThan(ServerVersion.V_1_20)) {
|
||||||
getLogger().severe("This version (" + PacketEvents.getAPI().getServerManager().getVersion() + ") is not officially supported by Nicko!");
|
getLogger().severe("This version (" + PacketEvents.getAPI().getServerManager().getVersion() + ") is not officially supported by Nicko!");
|
||||||
|
@ -98,6 +95,10 @@ public class Nicko extends JavaPlugin {
|
||||||
dataStore.setCache(cache);
|
dataStore.setCache(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nameStore = new PlayerNameStore();
|
||||||
|
mojangAPI = new MojangAPI();
|
||||||
|
nameFetcher = new RandomNameFetcher(this);
|
||||||
|
|
||||||
new ConfigurationMigrator(this).migrate();
|
new ConfigurationMigrator(this).migrate();
|
||||||
InvUI.getInstance().setPlugin(this);
|
InvUI.getInstance().setPlugin(this);
|
||||||
|
|
||||||
|
@ -180,7 +181,7 @@ public class Nicko extends JavaPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MojangAPI getMojangAPI() {
|
public MojangAPI getMojangAPI() {
|
||||||
return mojangApi;
|
return mojangAPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CustomLanguage getCustomLocale() {
|
public CustomLanguage getCustomLocale() {
|
||||||
|
|
|
@ -2,7 +2,6 @@ package xyz.ineanto.nicko.appearance;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
|
||||||
import xyz.ineanto.nicko.Nicko;
|
import xyz.ineanto.nicko.Nicko;
|
||||||
import xyz.ineanto.nicko.event.custom.PlayerDisguiseEvent;
|
import xyz.ineanto.nicko.event.custom.PlayerDisguiseEvent;
|
||||||
import xyz.ineanto.nicko.event.custom.PlayerResetDisguiseEvent;
|
import xyz.ineanto.nicko.event.custom.PlayerResetDisguiseEvent;
|
||||||
|
@ -61,23 +60,17 @@ public class AppearanceManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
packetSender.sendEntityMetadataUpdate();
|
// Not needed, but still broken using PE.
|
||||||
packetSender.sendTabListUpdate(displayName);
|
|
||||||
packetSender.sendEntityRespawn();
|
|
||||||
|
|
||||||
//packetSender.sendChunkData();
|
|
||||||
//packetSender.sendPlayerRespawn();
|
//packetSender.sendPlayerRespawn();
|
||||||
|
|
||||||
// From "https://minecraft.wiki/w/Java_Edition_protocol/FAQ#%E2%80%A6my_player_isn't_spawning!"
|
|
||||||
// "The client will also spawn after spending 30 seconds in the
|
|
||||||
// loading screen, even if it never received Game Event 13."
|
|
||||||
// Sending a teleport to the player's current location fixes this.
|
|
||||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
|
||||||
|
|
||||||
// Call the event.
|
// Call the event.
|
||||||
final PlayerDisguiseEvent event = new PlayerDisguiseEvent(player, profile.getSkin(), profile.getName());
|
final PlayerDisguiseEvent event = new PlayerDisguiseEvent(player, profile.getSkin(), profile.getName());
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
packetSender.sendEntityMetadataUpdate();
|
||||||
|
packetSender.sendTabListUpdate(displayName);
|
||||||
|
|
||||||
|
packetSender.sendEntityRespawn();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ public class NickoPluginLoader implements PluginLoader {
|
||||||
final MavenLibraryResolver resolver = new MavenLibraryResolver();
|
final MavenLibraryResolver resolver = new MavenLibraryResolver();
|
||||||
|
|
||||||
resolver.addRepository(new RemoteRepository.Builder("xenondevs", "default", "https://repo.xenondevs.xyz/releases/").build());
|
resolver.addRepository(new RemoteRepository.Builder("xenondevs", "default", "https://repo.xenondevs.xyz/releases/").build());
|
||||||
resolver.addDependency(new Dependency(new DefaultArtifact("xyz.xenondevs.invui:invui:pom:1.46"), null));
|
resolver.addDependency(new Dependency(new DefaultArtifact("xyz.xenondevs.invui:invui:pom:1.45"), null));
|
||||||
|
|
||||||
pluginClasspathBuilder.addLibrary(resolver);
|
pluginClasspathBuilder.addLibrary(resolver);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import java.io.IOException;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.Random;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
public record PacketEventsPacketSender(Player player, NickoProfile profile) implements PacketSender {
|
public record PacketEventsPacketSender(Player player, NickoProfile profile) implements PacketSender {
|
||||||
|
@ -35,11 +36,9 @@ public record PacketEventsPacketSender(Player player, NickoProfile profile) impl
|
||||||
public void sendEntityRespawn() {
|
public void sendEntityRespawn() {
|
||||||
if (!profile.hasData()) return;
|
if (!profile.hasData()) return;
|
||||||
|
|
||||||
final int entityId = player.getEntityId();
|
|
||||||
|
|
||||||
final WrapperPlayServerDestroyEntities destroy = new WrapperPlayServerDestroyEntities(player.getEntityId());
|
final WrapperPlayServerDestroyEntities destroy = new WrapperPlayServerDestroyEntities(player.getEntityId());
|
||||||
final WrapperPlayServerSpawnEntity spawn = new WrapperPlayServerSpawnEntity(
|
final WrapperPlayServerSpawnEntity spawn = new WrapperPlayServerSpawnEntity(
|
||||||
entityId,
|
new Random().nextInt(9999),
|
||||||
Optional.of(player.getUniqueId()),
|
Optional.of(player.getUniqueId()),
|
||||||
EntityTypes.PLAYER,
|
EntityTypes.PLAYER,
|
||||||
new Vector3d(player.getX(), player.getY(), player.getZ()),
|
new Vector3d(player.getX(), player.getY(), player.getZ()),
|
||||||
|
@ -50,11 +49,9 @@ public record PacketEventsPacketSender(Player player, NickoProfile profile) impl
|
||||||
Optional.empty()
|
Optional.empty()
|
||||||
);
|
);
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().stream()
|
Bukkit.getOnlinePlayers().stream().filter(receiver -> receiver.getUniqueId() != player.getUniqueId()).forEach(receiver -> {
|
||||||
.filter(receiver -> receiver.getUniqueId() != player.getUniqueId())
|
sendPacket(destroy, player);
|
||||||
.forEach(receiver -> {
|
sendPacket(spawn, player);
|
||||||
sendPacket(destroy, receiver);
|
|
||||||
sendPacket(spawn, receiver);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +83,8 @@ public record PacketEventsPacketSender(Player player, NickoProfile profile) impl
|
||||||
return ActionResult.error(LanguageKey.Error.MOJANG);
|
return ActionResult.error(LanguageKey.Error.MOJANG);
|
||||||
}
|
}
|
||||||
|
|
||||||
playerProfile.setProperties(skin.get().asProfileProperties());
|
final MojangSkin skinResult = skin.get();
|
||||||
|
playerProfile.setProperties(skinResult.asProfileProperties());
|
||||||
player.setPlayerProfile(playerProfile);
|
player.setPlayerProfile(playerProfile);
|
||||||
return ActionResult.ok();
|
return ActionResult.ok();
|
||||||
} catch (ExecutionException | IOException e) {
|
} catch (ExecutionException | IOException e) {
|
||||||
|
@ -113,7 +111,7 @@ public record PacketEventsPacketSender(Player player, NickoProfile profile) impl
|
||||||
Difficulty.getById(world.getDifficulty().ordinal()),
|
Difficulty.getById(world.getDifficulty().ordinal()),
|
||||||
world.getSeed(),
|
world.getSeed(),
|
||||||
SpigotConversionUtil.fromBukkitGameMode(player.getGameMode()),
|
SpigotConversionUtil.fromBukkitGameMode(player.getGameMode()),
|
||||||
null,
|
SpigotConversionUtil.fromBukkitGameMode(player.getPreviousGameMode()),
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
|
@ -129,6 +127,7 @@ public record PacketEventsPacketSender(Player player, NickoProfile profile) impl
|
||||||
public void sendTabListUpdate(String displayName) {
|
public void sendTabListUpdate(String displayName) {
|
||||||
final EnumSet<WrapperPlayServerPlayerInfoUpdate.Action> actions = EnumSet.of(
|
final EnumSet<WrapperPlayServerPlayerInfoUpdate.Action> actions = EnumSet.of(
|
||||||
WrapperPlayServerPlayerInfoUpdate.Action.ADD_PLAYER,
|
WrapperPlayServerPlayerInfoUpdate.Action.ADD_PLAYER,
|
||||||
|
WrapperPlayServerPlayerInfoUpdate.Action.INITIALIZE_CHAT,
|
||||||
WrapperPlayServerPlayerInfoUpdate.Action.UPDATE_LISTED,
|
WrapperPlayServerPlayerInfoUpdate.Action.UPDATE_LISTED,
|
||||||
WrapperPlayServerPlayerInfoUpdate.Action.UPDATE_DISPLAY_NAME,
|
WrapperPlayServerPlayerInfoUpdate.Action.UPDATE_DISPLAY_NAME,
|
||||||
WrapperPlayServerPlayerInfoUpdate.Action.UPDATE_GAME_MODE,
|
WrapperPlayServerPlayerInfoUpdate.Action.UPDATE_GAME_MODE,
|
||||||
|
|
|
@ -6,6 +6,15 @@ author: Ineanto
|
||||||
description: "The feature packed, next generation disguise plugin for Minecraft."
|
description: "The feature packed, next generation disguise plugin for Minecraft."
|
||||||
api-version: "1.21"
|
api-version: "1.21"
|
||||||
softdepend: [ PlaceholderAPI ]
|
softdepend: [ PlaceholderAPI ]
|
||||||
|
depend:
|
||||||
|
- ProtocolLib
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
server:
|
||||||
|
ProtocolLib:
|
||||||
|
load: BEFORE
|
||||||
|
join-classpath: true
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
nicko.*:
|
nicko.*:
|
||||||
default: op
|
default: op
|
||||||
|
|
4
src/test/java/xyz/ineanto/nicko/test/TestPluginMock.java
Normal file
4
src/test/java/xyz/ineanto/nicko/test/TestPluginMock.java
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
package xyz.ineanto.nicko.test;
|
||||||
|
|
||||||
|
public class TestPluginMock {
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue