still trying to figure out why protocollib doesn't work.
This commit is contained in:
parent
a01b564912
commit
567184b07d
12 changed files with 54 additions and 18 deletions
BIN
logs/2023-04-28-1.log.gz
Normal file
BIN
logs/2023-04-28-1.log.gz
Normal file
Binary file not shown.
BIN
logs/2023-04-28-2.log.gz
Normal file
BIN
logs/2023-04-28-2.log.gz
Normal file
Binary file not shown.
BIN
logs/2023-04-28-3.log.gz
Normal file
BIN
logs/2023-04-28-3.log.gz
Normal file
Binary file not shown.
BIN
logs/2023-04-28-4.log.gz
Normal file
BIN
logs/2023-04-28-4.log.gz
Normal file
Binary file not shown.
BIN
logs/2023-04-28-5.log.gz
Normal file
BIN
logs/2023-04-28-5.log.gz
Normal file
Binary file not shown.
BIN
logs/2023-04-28-6.log.gz
Normal file
BIN
logs/2023-04-28-6.log.gz
Normal file
Binary file not shown.
BIN
logs/2023-04-28-7.log.gz
Normal file
BIN
logs/2023-04-28-7.log.gz
Normal file
Binary file not shown.
BIN
logs/2023-04-28-8.log.gz
Normal file
BIN
logs/2023-04-28-8.log.gz
Normal file
Binary file not shown.
2
pom.xml
2
pom.xml
|
@ -55,7 +55,7 @@
|
||||||
<!-- Spigot API -->
|
<!-- Spigot API -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.19.4-R0.1-SNAPSHOT</version>
|
<version>1.19.4-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
|
@ -3,7 +3,10 @@ package net.artelnatif.nicko;
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
import com.comphenix.protocol.events.*;
|
import com.comphenix.protocol.events.ListenerPriority;
|
||||||
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import net.artelnatif.nicko.command.NickoCommand;
|
import net.artelnatif.nicko.command.NickoCommand;
|
||||||
import net.artelnatif.nicko.config.Configuration;
|
import net.artelnatif.nicko.config.Configuration;
|
||||||
import net.artelnatif.nicko.config.ConfigurationManager;
|
import net.artelnatif.nicko.config.ConfigurationManager;
|
||||||
|
@ -17,6 +20,7 @@ import net.artelnatif.nicko.mojang.MojangAPI;
|
||||||
import net.artelnatif.nicko.placeholder.PlaceHolderHook;
|
import net.artelnatif.nicko.placeholder.PlaceHolderHook;
|
||||||
import net.artelnatif.nicko.storage.PlayerDataStore;
|
import net.artelnatif.nicko.storage.PlayerDataStore;
|
||||||
import net.artelnatif.nicko.storage.name.PlayerNameStore;
|
import net.artelnatif.nicko.storage.name.PlayerNameStore;
|
||||||
|
import net.artelnatif.nicko.wrapper.WrapperPlayServerRespawn;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
|
@ -29,7 +33,6 @@ import xyz.xenondevs.invui.item.impl.SimpleItem;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
public class NickoBukkit extends JavaPlugin {
|
public class NickoBukkit extends JavaPlugin {
|
||||||
private static NickoBukkit plugin;
|
private static NickoBukkit plugin;
|
||||||
|
@ -119,13 +122,20 @@ public class NickoBukkit extends JavaPlugin {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent event) {
|
public void onPacketSending(PacketEvent event) {
|
||||||
final PacketContainer packet = event.getPacket();
|
final PacketContainer packet = event.getPacket();
|
||||||
packet.getStructures().getFields().forEach(fieldAccessor -> {
|
final WrapperPlayServerRespawn respawn = new WrapperPlayServerRespawn(packet);
|
||||||
final Field field = fieldAccessor.getField();
|
getLogger().info(respawn.getDimension().getName());
|
||||||
getLogger().info("field=[" +
|
getLogger().info(String.valueOf(respawn.isCopyMetadata()));
|
||||||
"name=" + field.getName() + "," +
|
getLogger().info(String.valueOf(respawn.getSeed()));
|
||||||
"type=" + field.getType().getSimpleName() +
|
getLogger().info(String.valueOf(respawn.getLastDeathLocation().isPresent()));
|
||||||
"]");
|
/**
|
||||||
});
|
* packet.getStructures().getFields().forEach(fieldAccessor -> {
|
||||||
|
* final Field field = fieldAccessor.getField();
|
||||||
|
* getLogger().info("field=[" +
|
||||||
|
* "name=" + field.getName() + "," +
|
||||||
|
* "type=" + field.getType().getSimpleName() +
|
||||||
|
* "]");
|
||||||
|
* });
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -139,16 +139,22 @@ public class AppearanceManager {
|
||||||
|
|
||||||
private void respawnPlayer() {
|
private void respawnPlayer() {
|
||||||
Bukkit.broadcastMessage("Respawning player");
|
Bukkit.broadcastMessage("Respawning player");
|
||||||
|
|
||||||
final World world = player.getWorld();
|
final World world = player.getWorld();
|
||||||
final WrapperPlayServerRespawn respawn = new WrapperPlayServerRespawn();
|
final WrapperPlayServerRespawn respawn = new WrapperPlayServerRespawn();
|
||||||
respawn.setGameMode(player.getGameMode());
|
respawn.setGameMode(player.getGameMode());
|
||||||
|
respawn.setPreviousGameMode(player.getGameMode());
|
||||||
respawn.setDifficulty(world.getDifficulty());
|
respawn.setDifficulty(world.getDifficulty());
|
||||||
respawn.setDimension(world);
|
respawn.setDimension(world);
|
||||||
respawn.setSeed(world.getSeed());
|
respawn.setSeed(world.getSeed());
|
||||||
respawn.setLastDeathLocation(player.getLocation());
|
respawn.setLastDeathLocation(player.getLocation());
|
||||||
|
respawn.setCopyMetadata(false);
|
||||||
respawn.getHandle().getBooleans().write(0, false); // is debug
|
respawn.getHandle().getBooleans().write(0, false); // is debug
|
||||||
respawn.getHandle().getBooleans().write(1, false); // is flat
|
respawn.getHandle().getBooleans().write(1, false); // is flat
|
||||||
respawn.sendPacket(player);
|
respawn.sendPacket(player);
|
||||||
|
/*final EntityPlayer cp = ((CraftPlayer) player).getHandle();
|
||||||
|
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(cp.cG().Z(), cp.P(), player.getWorld().getSeed(), EnumGamemode.a, EnumGamemode.a, true, true, (byte) 0x00, Optional.empty());
|
||||||
|
cp.b.a(respawn);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTabList(WrappedGameProfile gameProfile, String displayName) {
|
private void updateTabList(WrappedGameProfile gameProfile, String displayName) {
|
||||||
|
|
|
@ -2,10 +2,8 @@ package net.artelnatif.nicko.wrapper;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
|
||||||
import com.comphenix.protocol.utility.MinecraftVersion;
|
import com.comphenix.protocol.utility.MinecraftVersion;
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||||
import com.comphenix.protocol.wrappers.BukkitConverters;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||||
import org.bukkit.Difficulty;
|
import org.bukkit.Difficulty;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
@ -28,6 +26,8 @@ public class WrapperPlayServerRespawn extends AbstractPacket {
|
||||||
handle.getModifier().writeDefaults();
|
handle.getModifier().writeDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WrapperPlayServerRespawn(PacketContainer container) { super(container, TYPE); }
|
||||||
|
|
||||||
//.............
|
//.............
|
||||||
// Dimension Field (1.8 - Present)
|
// Dimension Field (1.8 - Present)
|
||||||
// The dimension field has changed numerous times:
|
// The dimension field has changed numerous times:
|
||||||
|
@ -42,11 +42,7 @@ public class WrapperPlayServerRespawn extends AbstractPacket {
|
||||||
|
|
||||||
public World getDimension() {
|
public World getDimension() {
|
||||||
if (MinecraftVersion.WILD_UPDATE.atOrAbove()) {
|
if (MinecraftVersion.WILD_UPDATE.atOrAbove()) {
|
||||||
// 1.19 and above
|
return handle.getWorldKeys().read(0);
|
||||||
return handle.getHolders(
|
|
||||||
MinecraftReflection.getDimensionManager(),
|
|
||||||
BukkitConverters.getDimensionConverter()
|
|
||||||
).read(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return handle.getDimensionTypes().read(0);
|
return handle.getDimensionTypes().read(0);
|
||||||
|
@ -58,7 +54,7 @@ public class WrapperPlayServerRespawn extends AbstractPacket {
|
||||||
handle.getWorldKeys().write(0, value);
|
handle.getWorldKeys().write(0, value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 1.18 and below
|
|
||||||
handle.getDimensionTypes().write(0, value);
|
handle.getDimensionTypes().write(0, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,6 +70,30 @@ public class WrapperPlayServerRespawn extends AbstractPacket {
|
||||||
handle.getGameModes().write(0, EnumWrappers.NativeGameMode.fromBukkit(value));
|
handle.getGameModes().write(0, EnumWrappers.NativeGameMode.fromBukkit(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//.............
|
||||||
|
// Previous GameMode Field
|
||||||
|
//.............
|
||||||
|
|
||||||
|
public void getPreviousGameMode() {
|
||||||
|
handle.getGameModes().read(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPreviousGameMode(GameMode value) {
|
||||||
|
handle.getGameModes().write(1, EnumWrappers.NativeGameMode.fromBukkit(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
//.............
|
||||||
|
// Copy Metadata Field
|
||||||
|
//.............
|
||||||
|
|
||||||
|
public boolean isCopyMetadata() {
|
||||||
|
return handle.getBytes().read(0) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCopyMetadata(boolean value) {
|
||||||
|
handle.getBytes().write(0, ((byte) (value ? 1 : 0)));
|
||||||
|
}
|
||||||
|
|
||||||
//.............
|
//.............
|
||||||
// Last death location Field
|
// Last death location Field
|
||||||
// Added in 1.19.
|
// Added in 1.19.
|
||||||
|
|
Loading…
Reference in a new issue