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>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>dmulloy2-repo</id>
|
||||
<url>https://repo.dmulloy2.net/repository/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>codemc-snapshots</id>
|
||||
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
|
||||
|
@ -164,12 +160,6 @@
|
|||
<version>3.1.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
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.item.builder.ItemBuilder;
|
||||
import de.studiocode.invui.item.impl.SimpleItem;
|
||||
|
@ -38,7 +36,6 @@ public class NickoBukkit extends JavaPlugin {
|
|||
private MojangAPI mojangAPI;
|
||||
private PlayerDataStore dataStore;
|
||||
private LocaleFileManager localeFileManager;
|
||||
private ProtocolManager protocolManager;
|
||||
|
||||
public NickoBukkit() { this.unitTesting = false; }
|
||||
|
||||
|
@ -97,7 +94,6 @@ public class NickoBukkit extends JavaPlugin {
|
|||
saveDefaultConfig();
|
||||
config = new NickoConfiguration(this);
|
||||
dataStore = new PlayerDataStore(this);
|
||||
protocolManager = ProtocolLibrary.getProtocolManager();
|
||||
|
||||
getLogger().info("Loading internals...");
|
||||
if (getInternals() == null) {
|
||||
|
@ -167,10 +163,6 @@ public class NickoBukkit extends JavaPlugin {
|
|||
return localeFileManager;
|
||||
}
|
||||
|
||||
public ProtocolManager getProtocolManager() {
|
||||
return protocolManager;
|
||||
}
|
||||
|
||||
public boolean isUnitTesting() {
|
||||
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;
|
||||
|
||||
final ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||
final GameProfile gameProfile = serverPlayer.getGameProfile();
|
||||
final GameProfile newGameProfile = new GameProfile(player.getUniqueId(), profileName);
|
||||
final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName);
|
||||
|
||||
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) {
|
||||
try {
|
||||
|
@ -108,7 +105,7 @@ public class v1_19_R2 implements Internals {
|
|||
if (uuid.isPresent()) {
|
||||
skin = (reset ? mojang.getSkinWithoutCaching(uuid.get()) : mojang.getSkin(uuid.get()));
|
||||
if (skin.isPresent()) {
|
||||
final PropertyMap properties = newGameProfile.getProperties();
|
||||
final PropertyMap properties = gameProfile.getProperties();
|
||||
properties.removeAll("textures");
|
||||
properties.put("textures", new Property("textures", skin.get().value(), skin.get().signature()));
|
||||
updateSelf(player);
|
||||
|
@ -137,7 +134,7 @@ public class v1_19_R2 implements Internals {
|
|||
field.setAccessible(true);
|
||||
field.set(init, List.of(new ClientboundPlayerInfoUpdatePacket.Entry(
|
||||
player.getUniqueId(),
|
||||
newGameProfile,
|
||||
gameProfile,
|
||||
true,
|
||||
serverPlayer.latency,
|
||||
serverPlayer.gameMode.getGameModeForPlayer(),
|
||||
|
@ -148,15 +145,10 @@ public class v1_19_R2 implements Internals {
|
|||
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 -> {
|
||||
ServerPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
||||
onlineEntityPlayer.connection.send(remove);
|
||||
onlineEntityPlayer.connection.send(init);
|
||||
final ServerPlayer onlinePlayer = ((CraftPlayer) online).getHandle();
|
||||
onlinePlayer.connection.send(remove);
|
||||
onlinePlayer.connection.send(init);
|
||||
});
|
||||
updateOthers(player);
|
||||
return new ActionResult();
|
||||
|
|
Loading…
Reference in a new issue