Skip to content

Commit

Permalink
feat: Added 1.20.4 support. Changed module names.
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeV220 committed Jan 1, 2024
1 parent 1e1b1f8 commit fbf0a4c
Show file tree
Hide file tree
Showing 23 changed files with 196 additions and 43 deletions.
17 changes: 9 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,15 @@ dependencies {
implementation project(path: ':bukkit')
implementation project(path: ':bungee')
implementation project(path: ':velocity')
implementation project(path: ':multiver:mc-1-17', configuration: 'reobf')
implementation project(path: ':multiver:mc-1-18', configuration: 'reobf')
implementation project(path: ':multiver:mc-1-18-2', configuration: 'reobf')
implementation project(path: ':multiver:mc-1-19', configuration: 'reobf')
implementation project(path: ':multiver:mc-1-19-3', configuration: 'reobf')
implementation project(path: ':multiver:mc-1-19-4', configuration: 'reobf')
implementation project(path: ':multiver:mc-1-20', configuration: 'reobf')
implementation project(path: ':multiver:mc-1-20-2', configuration: 'reobf')
implementation project(path: ':multiver:mc_1_17_R1', configuration: 'reobf')
implementation project(path: ':multiver:mc_1_18_R1', configuration: 'reobf')
implementation project(path: ':multiver:mc_1_18_R2', configuration: 'reobf')
implementation project(path: ':multiver:mc_1_19_R1', configuration: 'reobf')
implementation project(path: ':multiver:mc_1_19_R2', configuration: 'reobf')
implementation project(path: ':multiver:mc_1_19_R3', configuration: 'reobf')
implementation project(path: ':multiver:mc_1_20_R1', configuration: 'reobf')
implementation project(path: ':multiver:mc_1_20_R2', configuration: 'reobf')
implementation project(path: ':multiver:mc_1_20_R3', configuration: 'reobf')
}

shadowJar {
Expand Down
17 changes: 9 additions & 8 deletions bukkit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ dependencies {
compileOnly 'dev.folia:folia-api:1.19.4-R0.1-SNAPSHOT'
compileOnly "io.papermc:paperlib:${paperlibVersion}"
compileOnly project(path: ':core')
compileOnly project(path: ':multiver:mc-1-17', configuration: 'reobf')
compileOnly project(path: ':multiver:mc-1-18', configuration: 'reobf')
compileOnly project(path: ':multiver:mc-1-18-2', configuration: 'reobf')
compileOnly project(path: ':multiver:mc-1-19', configuration: 'reobf')
compileOnly project(path: ':multiver:mc-1-19-3', configuration: 'reobf')
compileOnly project(path: ':multiver:mc-1-19-4', configuration: 'reobf')
compileOnly project(path: ':multiver:mc-1-20', configuration: 'reobf')
compileOnly project(path: ':multiver:mc-1-20-2', configuration: 'reobf')
compileOnly project(path: ':multiver:mc_1_17_R1', configuration: 'reobf')
compileOnly project(path: ':multiver:mc_1_18_R1', configuration: 'reobf')
compileOnly project(path: ':multiver:mc_1_18_R2', configuration: 'reobf')
compileOnly project(path: ':multiver:mc_1_19_R1', configuration: 'reobf')
compileOnly project(path: ':multiver:mc_1_19_R2', configuration: 'reobf')
compileOnly project(path: ':multiver:mc_1_19_R3', configuration: 'reobf')
compileOnly project(path: ':multiver:mc_1_20_R1', configuration: 'reobf')
compileOnly project(path: ':multiver:mc_1_20_R2', configuration: 'reobf')
compileOnly project(path: ':multiver:mc_1_20_R3', configuration: 'reobf')

implementation "net.kyori:adventure-platform-bukkit:4.3.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,15 @@ public void onEnable() {
SchedulerManager.getScheduler().mainThreadHeartbeat(tick);
}, 1L, 1L);
switch (getCurrentVersion()) {
case V1_17_R1 -> skinOverlay.setSkinHandler(new SkinHandler_1_17());
case V1_18_R1 -> skinOverlay.setSkinHandler(new SkinHandler_1_18());
case V1_17_R1 -> skinOverlay.setSkinHandler(new SkinHandler_1_17_R1());
case V1_18_R1 -> skinOverlay.setSkinHandler(new SkinHandler_1_18_R1());
case V1_18_R2 -> skinOverlay.setSkinHandler(new SkinHandler_1_18_R2());
case V1_19_R1 -> skinOverlay.setSkinHandler(new SkinHandler_1_19());
case V1_19_R1 -> skinOverlay.setSkinHandler(new SkinHandler_1_19_R1());
case V1_19_R2 -> skinOverlay.setSkinHandler(new SkinHandler_1_19_R2());
case V1_19_R3 -> skinOverlay.setSkinHandler(new SkinHandler_1_19_R3());
case V1_20_R1 -> skinOverlay.setSkinHandler(new SkinHandler_1_20());
case V1_20_R2 -> skinOverlay.setSkinHandler(new SkinHandler_1_20_2());
case V1_20_R1 -> skinOverlay.setSkinHandler(new SkinHandler_1_20_R1());
case V1_20_R2 -> skinOverlay.setSkinHandler(new SkinHandler_1_20_R2());
case V1_20_R3 -> skinOverlay.setSkinHandler(new SkinHandler_1_20_R3());
case UNKNOWN -> skinOverlay.setSkinHandler(new SkinHandler_Unsupported());
default -> skinOverlay.setSkinHandler(new SkinHandler_Legacy());
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ author = GeorgeV22
version = 7.0.0
mcVersion = 1.18.2
apiVersion = 1.13
libraryVersion = 11.7.0-beta.4
libraryVersion = 11.7.0-beta.8
libraryLoaderVersion = 1.6.1
mineskinVersion = e00167583d
acfVersion = 0.5.1-G-4.0-SNAPSHOT
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import static com.georgev22.skinoverlay.handler.handlers.SkinHandler_Unsupported.wrapper;

public final class SkinHandler_1_17 extends SkinHandler {
public final class SkinHandler_1_17_R1 extends SkinHandler {

@Override
public CompletableFuture<Boolean> updateSkin(@NotNull PlayerObject playerObject, @NotNull Skin skin) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import static com.georgev22.skinoverlay.handler.handlers.SkinHandler_Unsupported.wrapper;

public final class SkinHandler_1_18 extends SkinHandler {
public final class SkinHandler_1_18_R1 extends SkinHandler {

@Override
public CompletableFuture<Boolean> updateSkin(@NotNull PlayerObject playerObject, @NotNull Skin skin) {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

import static com.georgev22.skinoverlay.handler.handlers.SkinHandler_Unsupported.wrapper;

public final class SkinHandler_1_19 extends SkinHandler {
public final class SkinHandler_1_19_R1 extends SkinHandler {

@Override
public CompletableFuture<Boolean> updateSkin(@NotNull PlayerObject playerObject, @NotNull Skin skin) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import static com.georgev22.skinoverlay.handler.handlers.SkinHandler_Unsupported.wrapper;

public final class SkinHandler_1_20 extends SkinHandler {
public final class SkinHandler_1_20_R1 extends SkinHandler {

@Override
public CompletableFuture<Boolean> updateSkin(@NotNull PlayerObject playerObject, @NotNull Skin skin) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;

public final class SkinHandler_1_20_2 extends SkinHandler {
public final class SkinHandler_1_20_R2 extends SkinHandler {

@Override
public CompletableFuture<Boolean> updateSkin(@NotNull PlayerObject playerObject, @NotNull Skin skin) {
Expand Down
16 changes: 16 additions & 0 deletions multiver/mc_1_20_R3/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins {
id "io.papermc.paperweight.userdev" version "1.5.5"
}

repositories {
mavenLocal()
mavenCentral()
}

dependencies {
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.20.4-R0.1-SNAPSHOT")

implementation project(path: ':core')

compileOnly "io.papermc:paperlib:1.0.8"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@

package com.georgev22.skinoverlay.handler.handlers;

import com.georgev22.library.maps.HashObjectMap;
import com.georgev22.library.maps.ObjectMap;
import com.georgev22.library.scheduler.SchedulerManager;
import com.georgev22.skinoverlay.handler.SGameProfile;
import com.georgev22.skinoverlay.handler.SProperty;
import com.georgev22.skinoverlay.handler.SkinHandler;
import com.georgev22.skinoverlay.handler.profile.SGameProfileMojang;
import com.georgev22.skinoverlay.storage.data.Skin;
import com.georgev22.skinoverlay.utilities.player.PlayerObject;
import com.mojang.authlib.GameProfile;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.*;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.level.ServerPlayerGameMode;
import net.minecraft.world.level.biome.BiomeManager;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import java.util.HashSet;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;

public final class SkinHandler_1_20_R3 extends SkinHandler {

@Override
public CompletableFuture<Boolean> updateSkin(@NotNull PlayerObject playerObject, @NotNull Skin skin) {
return CompletableFuture.supplyAsync(() -> {
try {
Player player = playerObject.player();
final CraftPlayer craftPlayer = (CraftPlayer) player;
final ServerPlayer entityPlayer = craftPlayer.getHandle();

ClientboundPlayerInfoRemovePacket removePlayer = new ClientboundPlayerInfoRemovePacket(List.of(entityPlayer.getUUID()));
ClientboundPlayerInfoUpdatePacket addPlayer = ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(entityPlayer));
//noinspection resource
ServerLevel world = entityPlayer.serverLevel();
ServerPlayerGameMode gamemode = entityPlayer.gameMode;

ClientboundRespawnPacket respawn = new ClientboundRespawnPacket(
new CommonPlayerSpawnInfo(
world.dimensionTypeId(),
world.dimension(),
BiomeManager.obfuscateSeed(world.getSeed()),
gamemode.getGameModeForPlayer(),
gamemode.getPreviousGameModeForPlayer(),
world.isDebug(),
world.isFlat(),
entityPlayer.getLastDeathLocation(),
entityPlayer.getPortalCooldown()
),
(byte) 3
);
Location l = player.getLocation();
ClientboundPlayerPositionPacket pos = new ClientboundPlayerPositionPacket(l.getX(), l.getY(), l.getZ(), l.getYaw(), l.getPitch(), new HashSet<>(), 0);
ClientboundSetCarriedItemPacket slot = new ClientboundSetCarriedItemPacket(player.getInventory().getHeldItemSlot());

sendPacket(entityPlayer, removePlayer);
sendPacket(entityPlayer, addPlayer);

sendPacket(entityPlayer, respawn);

entityPlayer.onUpdateAbilities();

sendPacket(entityPlayer, pos);
sendPacket(entityPlayer, slot);
craftPlayer.updateScaledHealth();
player.updateInventory();
entityPlayer.resetSentInfo();
return true;
} catch (Exception exception) {
throw new RuntimeException(exception);
}
});
}

@Override
public void applySkin(@NotNull PlayerObject playerObject, @NotNull Skin skin) {
SchedulerManager.getScheduler().runTaskLater(skinOverlay.getClass(), () -> {
Player player = playerObject.player();
player.hidePlayer(skinOverlay.getSkinOverlay().plugin(), player);
player.showPlayer(skinOverlay.getSkinOverlay().plugin(), player);
skinOverlay.getSkinHandler().updateSkin(playerObject, skin).handleAsync((aBoolean, throwable) -> {
if (throwable != null) {
skinOverlay.getLogger().log(Level.SEVERE, "Error updating skin", throwable);
return false;
}
return aBoolean;
}).thenAccept(aBoolean -> SchedulerManager.getScheduler().runTask(skinOverlay.getClass(), () -> {
if (aBoolean)
skinOverlay.onlinePlayers().stream().filter(playerObjects -> playerObjects != playerObject).forEach(playerObjects -> {
Player p = playerObjects.player();
p.hidePlayer(skinOverlay.getSkinOverlay().plugin(), player);
p.showPlayer(skinOverlay.getSkinOverlay().plugin(), player);
});
}));
}, 20L);
}

@Override
public GameProfile getInternalGameProfile(@NotNull PlayerObject playerObject) {
Player player = playerObject.player();
final CraftPlayer craftPlayer = (CraftPlayer) player;
final ServerPlayer entityPlayer = craftPlayer.getHandle();
return entityPlayer.getGameProfile();
}

@Override
public SGameProfile getGameProfile(@NotNull PlayerObject playerObject) {
if (sGameProfiles.containsKey(playerObject)) {
return sGameProfiles.get(playerObject);
}
return sGameProfiles.append(playerObject, wrapper(this.getInternalGameProfile(playerObject))).get(playerObject);
}

public static @NotNull SGameProfile wrapper(@NotNull GameProfile gameProfile) {
ObjectMap<String, SProperty> propertyObjectMap = new HashObjectMap<>();
gameProfile.getProperties().forEach((s, property) -> propertyObjectMap.append(s, new SProperty(property.name(), property.value(), property.signature())));
return new SGameProfileMojang(gameProfile.getName(), gameProfile.getId(), propertyObjectMap);
}

private void sendPacket(@NotNull ServerPlayer player, Packet<?> packet) {
player.connection.send(packet);
}
}

34 changes: 18 additions & 16 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@ include 'bukkit'
include 'bungee'
include 'velocity'
include 'multiver'
include ':multiver:mc-1-17'
include ':multiver:mc-1-18'
include ':multiver:mc-1-18-2'
include ':multiver:mc-1-19'
include ':multiver:mc-1-19-3'
include ':multiver:mc-1-19-4'
include 'multiver:mc-1-20'
include 'multiver:mc-1-20-2'
findProject(':multiver:mc-1-17')?.name = 'mc-1-17'
findProject(':multiver:mc-1-18')?.name = 'mc-1-18'
findProject(':multiver:mc-1-18-2')?.name = 'mc-1-18-2'
findProject(':multiver:mc-1-19')?.name = 'mc-1-19'
findProject(':multiver:mc-1-19-3')?.name = 'mc-1-19-3'
findProject(':multiver:mc-1-19-4')?.name = 'mc-1-19-4'
findProject(':multiver:mc-1-20')?.name = 'mc-1-20'
findProject(':multiver:mc-1-20-2')?.name = 'mc-1-20-2'
include ':multiver:mc_1_17_R1'
include ':multiver:mc_1_18_R1'
include ':multiver:mc_1_18_R2'
include ':multiver:mc_1_19_R1'
include ':multiver:mc_1_19_R2'
include ':multiver:mc_1_19_R3'
include ':multiver:mc_1_20_R1'
include ':multiver:mc_1_20_R2'
include ':multiver:mc_1_20_R3'
findProject(':multiver:mc_1_17_R1')?.name = 'mc_1_17_R1'
findProject(':multiver:mc_1_18_R1')?.name = 'mc_1_18_R1'
findProject(':multiver:mc_1_18_R2')?.name = 'mc_1_18_R2'
findProject(':multiver:mc_1_19_R1')?.name = 'mc_1_19_R1'
findProject(':multiver:mc_1_19_R2')?.name = 'mc_1_19_R2'
findProject(':multiver:mc_1_19_R3')?.name = 'mc_1_19_R3'
findProject(':multiver:mc_1_20_R1')?.name = 'mc_1_20_R1'
findProject(':multiver:mc_1_20_R2')?.name = 'mc_1_20_R2'
findProject(':multiver:mc_1_20_R3')?.name = 'mc_1_20_R3'

0 comments on commit fbf0a4c

Please sign in to comment.