refactor: cleanup the code
This commit is contained in:
parent
c7154510de
commit
ebdcdd34ae
4 changed files with 6 additions and 42 deletions
|
@ -78,10 +78,6 @@
|
||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
|
||||||
<id>dmulloy2-repo</id>
|
|
||||||
<url>https://repo.dmulloy2.net/repository/public/</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>codemc-snapshots</id>
|
<id>codemc-snapshots</id>
|
||||||
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
|
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
|
||||||
|
@ -164,12 +160,6 @@
|
||||||
<version>3.1.0</version>
|
<version>3.1.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.comphenix.protocol</groupId>
|
|
||||||
<artifactId>ProtocolLib</artifactId>
|
|
||||||
<version>5.0.0-SNAPSHOT</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package net.artelnatif.nicko;
|
package net.artelnatif.nicko;
|
||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
|
||||||
import de.studiocode.invui.gui.structure.Structure;
|
import de.studiocode.invui.gui.structure.Structure;
|
||||||
import de.studiocode.invui.item.builder.ItemBuilder;
|
import de.studiocode.invui.item.builder.ItemBuilder;
|
||||||
import de.studiocode.invui.item.impl.SimpleItem;
|
import de.studiocode.invui.item.impl.SimpleItem;
|
||||||
|
@ -38,7 +36,6 @@ public class NickoBukkit extends JavaPlugin {
|
||||||
private MojangAPI mojangAPI;
|
private MojangAPI mojangAPI;
|
||||||
private PlayerDataStore dataStore;
|
private PlayerDataStore dataStore;
|
||||||
private LocaleFileManager localeFileManager;
|
private LocaleFileManager localeFileManager;
|
||||||
private ProtocolManager protocolManager;
|
|
||||||
|
|
||||||
public NickoBukkit() { this.unitTesting = false; }
|
public NickoBukkit() { this.unitTesting = false; }
|
||||||
|
|
||||||
|
@ -97,7 +94,6 @@ public class NickoBukkit extends JavaPlugin {
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
config = new NickoConfiguration(this);
|
config = new NickoConfiguration(this);
|
||||||
dataStore = new PlayerDataStore(this);
|
dataStore = new PlayerDataStore(this);
|
||||||
protocolManager = ProtocolLibrary.getProtocolManager();
|
|
||||||
|
|
||||||
getLogger().info("Loading internals...");
|
getLogger().info("Loading internals...");
|
||||||
if (getInternals() == null) {
|
if (getInternals() == null) {
|
||||||
|
@ -167,10 +163,6 @@ public class NickoBukkit extends JavaPlugin {
|
||||||
return localeFileManager;
|
return localeFileManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolManager getProtocolManager() {
|
|
||||||
return protocolManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isUnitTesting() {
|
public boolean isUnitTesting() {
|
||||||
return unitTesting;
|
return unitTesting;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
package net.artelnatif.nicko.impl;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
|
||||||
import net.artelnatif.nicko.NickoBukkit;
|
|
||||||
|
|
||||||
public interface InternalsProtocolLib extends Internals {
|
|
||||||
default ProtocolManager getProtocolLib() {
|
|
||||||
return NickoBukkit.getInstance().getProtocolManager();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -94,12 +94,9 @@ public class v1_19_R2 implements Internals {
|
||||||
Optional<MojangSkin> skin;
|
Optional<MojangSkin> skin;
|
||||||
|
|
||||||
final ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
final ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||||
final GameProfile gameProfile = serverPlayer.getGameProfile();
|
final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName);
|
||||||
final GameProfile newGameProfile = new GameProfile(player.getUniqueId(), profileName);
|
|
||||||
|
|
||||||
final ClientboundPlayerInfoRemovePacket remove = new ClientboundPlayerInfoRemovePacket(List.of(player.getUniqueId()));
|
final ClientboundPlayerInfoRemovePacket remove = new ClientboundPlayerInfoRemovePacket(List.of(player.getUniqueId()));
|
||||||
// TODO: 1/20/23 Sets Gamemode to Survival but keeps the flying? Visual effect only?
|
|
||||||
//final ClientboundPlayerInfoUpdatePacket init = ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(serverPlayer));
|
|
||||||
|
|
||||||
if (skinChange || changeOnlyName) {
|
if (skinChange || changeOnlyName) {
|
||||||
try {
|
try {
|
||||||
|
@ -108,7 +105,7 @@ public class v1_19_R2 implements Internals {
|
||||||
if (uuid.isPresent()) {
|
if (uuid.isPresent()) {
|
||||||
skin = (reset ? mojang.getSkinWithoutCaching(uuid.get()) : mojang.getSkin(uuid.get()));
|
skin = (reset ? mojang.getSkinWithoutCaching(uuid.get()) : mojang.getSkin(uuid.get()));
|
||||||
if (skin.isPresent()) {
|
if (skin.isPresent()) {
|
||||||
final PropertyMap properties = newGameProfile.getProperties();
|
final PropertyMap properties = gameProfile.getProperties();
|
||||||
properties.removeAll("textures");
|
properties.removeAll("textures");
|
||||||
properties.put("textures", new Property("textures", skin.get().value(), skin.get().signature()));
|
properties.put("textures", new Property("textures", skin.get().value(), skin.get().signature()));
|
||||||
updateSelf(player);
|
updateSelf(player);
|
||||||
|
@ -137,7 +134,7 @@ public class v1_19_R2 implements Internals {
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
field.set(init, List.of(new ClientboundPlayerInfoUpdatePacket.Entry(
|
field.set(init, List.of(new ClientboundPlayerInfoUpdatePacket.Entry(
|
||||||
player.getUniqueId(),
|
player.getUniqueId(),
|
||||||
newGameProfile,
|
gameProfile,
|
||||||
true,
|
true,
|
||||||
serverPlayer.latency,
|
serverPlayer.latency,
|
||||||
serverPlayer.gameMode.getGameModeForPlayer(),
|
serverPlayer.gameMode.getGameModeForPlayer(),
|
||||||
|
@ -148,15 +145,10 @@ public class v1_19_R2 implements Internals {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("======= AFTER ");
|
|
||||||
System.out.println("init.entries().toString() = " + init.entries().toString());
|
|
||||||
|
|
||||||
serverPlayer.connection.send(remove);
|
|
||||||
serverPlayer.connection.send(init);
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
Bukkit.getOnlinePlayers().forEach(online -> {
|
||||||
ServerPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
final ServerPlayer onlinePlayer = ((CraftPlayer) online).getHandle();
|
||||||
onlineEntityPlayer.connection.send(remove);
|
onlinePlayer.connection.send(remove);
|
||||||
onlineEntityPlayer.connection.send(init);
|
onlinePlayer.connection.send(init);
|
||||||
});
|
});
|
||||||
updateOthers(player);
|
updateOthers(player);
|
||||||
return new ActionResult();
|
return new ActionResult();
|
||||||
|
|
Loading…
Reference in a new issue