Skip to content

Commit

Permalink
feat(Sponge7): Sponge7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeV220 committed Jan 22, 2023
1 parent 8559493 commit ed0c892
Show file tree
Hide file tree
Showing 18 changed files with 617 additions and 49 deletions.
21 changes: 19 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,23 @@ allprojects {
}

dependencies {
compileOnly "com.georgev22.library:database:${libraryVersion}:all"
compileOnly "com.georgev22.library:maps:${libraryVersion}:all"
compileOnly "com.georgev22.library:scheduler:${libraryVersion}:all"
compileOnly "com.georgev22.library:utilities:${libraryVersion}:all"
compileOnly "com.georgev22.library:yaml:${libraryVersion}:all"
compileOnly "com.georgev22.library:minecraft:${libraryVersion}"


compileOnly 'org.apache.logging.log4j:log4j-api:2.17.0'
compileOnly 'net.kyori:adventure-api:4.12.0'
compileOnly 'net.kyori:adventure-text-serializer-legacy:4.12.0'
compileOnly 'com.google.code.gson:gson:2.10.1'
compileOnly 'co.aikar:acf-paper:0.5.1-G-1.0-SNAPSHOT'
compileOnly 'co.aikar:acf-bungee:0.5.1-G-1.0-SNAPSHOT'
compileOnly 'co.aikar:acf-velocity:0.5.1-G-1.0-SNAPSHOT'
compileOnly 'co.aikar:acf-sponge:0.5.1-G-1.0-SNAPSHOT'
compileOnly 'co.aikar:acf-sponge8:0.5.1-G-1.0-SNAPSHOT'
compileOnly 'com.georgev22:martexlibrary:8.14.0'
compileOnly 'com.georgev22.api:libraryloader:1.4.0'
compileOnly 'org.jetbrains:annotations:23.1.0'
compileOnly 'commons-codec:commons-codec:1.15'
Expand All @@ -99,18 +108,26 @@ repositories {
}

dependencies {
implementation "com.georgev22.library:database:${libraryVersion}"
implementation "com.georgev22.library:maps:${libraryVersion}"
implementation "com.georgev22.library:scheduler:${libraryVersion}"
implementation "com.georgev22.library:utilities:${libraryVersion}"
implementation "com.georgev22.library:yaml:${libraryVersion}"
implementation "com.georgev22.library:minecraft:${libraryVersion}"

implementation 'co.aikar:acf-paper:0.5.1-G-1.0-SNAPSHOT'
implementation 'co.aikar:acf-bungee:0.5.1-G-1.0-SNAPSHOT'
implementation 'co.aikar:acf-velocity:0.5.1-G-1.0-SNAPSHOT'
implementation 'co.aikar:acf-sponge:0.5.1-G-1.0-SNAPSHOT'
implementation 'co.aikar:acf-sponge8:0.5.1-G-1.0-SNAPSHOT'
implementation 'com.georgev22:martexlibrary:8.14.0'
implementation 'com.georgev22.api:libraryloader:1.4.0'
implementation 'com.google.code.gson:gson:2.10.1'
implementation project(path: ':core')
implementation project(path: ':bukkit')
implementation project(path: ':bungee')
implementation project(path: ':velocity')
implementation project(path: ':sponge')
implementation project(path: ':sponge7')
implementation project(path: ':mc-1-17', configuration: 'reobf')
implementation project(path: ':mc-1-18', configuration: 'reobf')
implementation project(path: ':mc-1-18-2', configuration: 'reobf')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,9 @@ private void loadCommandLocales() {
((PaperCommandManager) commandManager).getLocales().loadYamlLanguageFile(new File(getDataFolder(), "lang_en.yml"), Locale.ENGLISH);
case VELOCITY ->
((VelocityCommandManager) commandManager).getLocales().loadYamlLanguageFile(new File(getDataFolder(), "lang_en.yml"), Locale.ENGLISH);
case SPONGE ->
case SPONGE8 ->
((SpongeCommandManager) commandManager).getLocales().loadYamlLanguageFile(new File(getDataFolder(), "lang_en.yml"), Locale.ENGLISH);
case SPONGE7 -> ((Sponge7CommandManager) commandManager).getLocales().loadLanguages();
}
commandManager.usePerIssuerLocale(true);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import co.aikar.commands.CommandIssuer;
import com.georgev22.library.maps.HashObjectMap;
import com.georgev22.library.minecraft.BukkitMinecraftUtils;
import com.georgev22.library.minecraft.BungeeMinecraftUtils;
import com.georgev22.library.minecraft.VelocityMinecraftUtils;
import com.georgev22.library.minecraft.*;
import com.georgev22.library.utilities.Utils;
import com.georgev22.library.yaml.configmanager.CFG;
import com.georgev22.skinoverlay.SkinOverlay;
Expand Down Expand Up @@ -112,38 +110,38 @@ public void msgConsole(Map<String, String> map, boolean ignoreCase) {
BungeeMinecraftUtils.printMsg(Utils.placeHolder(Arrays.stream(this.getMessages()).toList(), map, ignoreCase));
case VELOCITY ->
VelocityMinecraftUtils.printMsg(Utils.placeHolder(Arrays.stream(this.getMessages()).toList(), map, ignoreCase));
case SPONGE7 ->
Sponge7MinecraftUtils.printMsg(SkinOverlay.getInstance().getLogger(), Utils.placeHolder(Arrays.stream(this.getMessages()).toList(), map, ignoreCase));
case SPONGE8 ->
Sponge8MinecraftUtils.printMsg(SkinOverlay.getInstance().getLogger(), Utils.placeHolder(Arrays.stream(this.getMessages()).toList(), map, ignoreCase));
}
} else {
switch (SkinOverlay.getInstance().type()) {
case PAPER -> BukkitMinecraftUtils.printMsg(Utils.placeHolder(this.getMessages()[0], map, ignoreCase));
case BUNGEE -> BungeeMinecraftUtils.printMsg(Utils.placeHolder(this.getMessages()[0], map, ignoreCase));
case VELOCITY ->
VelocityMinecraftUtils.printMsg(Utils.placeHolder(this.getMessages()[0], map, ignoreCase));
case SPONGE7 ->
Sponge7MinecraftUtils.printMsg(SkinOverlay.getInstance().getLogger(), Utils.placeHolder(this.getMessages()[0], map, ignoreCase));
case SPONGE8 ->
Sponge8MinecraftUtils.printMsg(SkinOverlay.getInstance().getLogger(), Utils.placeHolder(this.getMessages()[0], map, ignoreCase));
}
}
}

public void msgAll() {
if (this.isMultiLined()) {
SkinOverlay.getInstance().getSkinOverlay().onlinePlayers().forEach(playerObject -> {
playerObject.sendMessage(this.getMessages());
});
SkinOverlay.getInstance().getSkinOverlay().onlinePlayers().forEach(playerObject -> playerObject.sendMessage(this.getMessages()));
} else {
SkinOverlay.getInstance().getSkinOverlay().onlinePlayers().forEach(playerObject -> {
playerObject.sendMessage(this.getMessages()[0]);
});
SkinOverlay.getInstance().getSkinOverlay().onlinePlayers().forEach(playerObject -> playerObject.sendMessage(this.getMessages()[0]));
}
}

public void msgAll(Map<String, String> map, boolean ignoreCase) {
if (this.isMultiLined()) {
SkinOverlay.getInstance().getSkinOverlay().onlinePlayers().forEach(playerObject -> {
playerObject.sendMessage(placeHolder(this.getMessages(), map, ignoreCase));
});
SkinOverlay.getInstance().getSkinOverlay().onlinePlayers().forEach(playerObject -> playerObject.sendMessage(placeHolder(this.getMessages(), map, ignoreCase)));
} else {
SkinOverlay.getInstance().getSkinOverlay().onlinePlayers().forEach(playerObject -> {
playerObject.sendMessage(placeHolder(this.getMessages()[0], map, ignoreCase));
});
SkinOverlay.getInstance().getSkinOverlay().onlinePlayers().forEach(playerObject -> playerObject.sendMessage(placeHolder(this.getMessages()[0], map, ignoreCase)));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.georgev22.skinoverlay.utilities;

import com.georgev22.library.minecraft.colors.Color;
import com.georgev22.library.utilities.Color;
import com.georgev22.skinoverlay.SkinOverlay;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ enum Type {
PAPER,
BUNGEE,
VELOCITY,
SPONGE
SPONGE8,
SPONGE7
}

}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ bungeeMain = com.georgev22.skinoverlay.SkinOverlayBungee
spongeMain = com.georgev22.skinoverlay.SkinOverlaySponge
pluginName = SkinOverlay
author = GeorgeV22
libraryVersion = 9.1.1
mcVersion = 1.18.2
apiVersion = 1.13
version = 3.5.0
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ include 'mc-1-17'
include 'bungee'
include 'velocity'
include 'sponge'
include 'sponge7'

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.georgev22.api.libraryloader.annotations.MavenLibrary;
import com.georgev22.api.libraryloader.exceptions.InvalidDependencyException;
import com.georgev22.api.libraryloader.exceptions.UnknownDependencyException;
import com.georgev22.library.minecraft.SpongeMinecraftUtils;
import com.georgev22.library.minecraft.Sponge8MinecraftUtils;
import com.georgev22.library.scheduler.SchedulerManager;
import com.georgev22.library.utilities.LoggerWrapper;
import com.georgev22.library.utilities.Utils;
Expand Down Expand Up @@ -76,7 +76,7 @@ public void onInit() {
SkinOverlay.getInstance().setCommandManager(new SpongeCommandManager(pluginContainer, getDataFolder()));
SkinOverlay.getInstance().onLoad(this);
SkinOverlay.getInstance().setupCommands();
SpongeMinecraftUtils.registerListeners(pluginContainer,
Sponge8MinecraftUtils.registerListeners(pluginContainer,
new PlayerListeners(),
new DeveloperInformListener());
}
Expand Down Expand Up @@ -114,7 +114,7 @@ public void onDisable() {

@Override
public Type type() {
return Type.SPONGE;
return Type.SPONGE8;
}

@Override
Expand Down Expand Up @@ -168,7 +168,7 @@ public List<PlayerObject> onlinePlayers() {

@Override
public Object getPlugin() {
return this;
return pluginContainer;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.georgev22.skinoverlay.handler.handlers;

import com.georgev22.library.exceptions.ReflectionException;
import com.georgev22.library.minecraft.SpongeMinecraftUtils;
import com.georgev22.library.minecraft.Sponge8MinecraftUtils;
import com.georgev22.library.scheduler.SchedulerManager;
import com.georgev22.library.utilities.Utils;
import com.georgev22.library.yaml.file.FileConfiguration;
Expand Down Expand Up @@ -54,7 +54,7 @@ public SkinHandler_Sponge() {
entityDataPacketClass = Utils.Reflection.getClass("net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket", classLoader);
entityDataSerializersClass = Utils.Reflection.getClass("net.minecraft.network.syncher.EntityDataSerializers", classLoader);
entityDataAccessorClass = Utils.Reflection.getClass("net.minecraft.network.syncher.EntityDataAccessor", classLoader);
if (SpongeMinecraftUtils.MinecraftVersion.getCurrentVersion().equals(SpongeMinecraftUtils.MinecraftVersion.V1_19_R2)) {
if (Sponge8MinecraftUtils.MinecraftVersion.getCurrentVersion().equals(Sponge8MinecraftUtils.MinecraftVersion.V1_19_R2)) {
removePlayerPacketClass = Utils.Reflection.getClass("net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket", classLoader);
addPlayerPacketClass = Utils.Reflection.getClass("net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket", classLoader);
} else {
Expand All @@ -67,8 +67,12 @@ public SkinHandler_Sponge() {
@SneakyThrows
@Override
public void updateSkin(@NotNull FileConfiguration fileConfiguration, @NotNull PlayerObject playerObject, boolean reset, @NotNull String skinName) {
Property property = UserData.getUser(playerObject.playerUUID()).getSkinProperty();
updateSkin(fileConfiguration, playerObject, reset, skinName, UserData.getUser(playerObject.playerUUID()).getSkinProperty());
}

@SneakyThrows
@Override
public void updateSkin(@NotNull FileConfiguration fileConfiguration, @NotNull PlayerObject playerObject, boolean reset, @NotNull String skinName, Property property) {
ServerPlayer receiver = (ServerPlayer) playerObject.getPlayer();

receiver.user().offer(Keys.UPDATE_GAME_PROFILE, true);
Expand Down Expand Up @@ -106,7 +110,7 @@ public void updateSkin(@NotNull FileConfiguration fileConfiguration, @NotNull Pl
Object addPlayer;
Object removePlayer;
//Add remove player packet
if (SpongeMinecraftUtils.MinecraftVersion.getCurrentVersion().equals(SpongeMinecraftUtils.MinecraftVersion.V1_19_R2)) {
if (Sponge8MinecraftUtils.MinecraftVersion.getCurrentVersion().equals(Sponge8MinecraftUtils.MinecraftVersion.V1_19_R2)) {
removePlayer = invokeConstructor(removePlayerPacketClass, List.of(receiver.uniqueId()));
addPlayer = fetchMethodAndInvoke(addPlayerPacketClass, "createPlayerInitializing", null,
new Object[]{List.of(serverPlayer)},
Expand All @@ -126,7 +130,7 @@ public void updateSkin(@NotNull FileConfiguration fileConfiguration, @NotNull Pl
//Respawn packet
try {

switch (SpongeMinecraftUtils.MinecraftVersion.getCurrentVersion()) {
switch (Sponge8MinecraftUtils.MinecraftVersion.getCurrentVersion()) {
case V1_19_R2, UNKNOWN -> respawnPacket = invokeConstructor(
respawnPacketClass,
dimensionType,
Expand Down Expand Up @@ -177,7 +181,7 @@ public void updateSkin(@NotNull FileConfiguration fileConfiguration, @NotNull Pl
new Object[]{
entityDataAccessor = invokeConstructor(
entityDataAccessorClass,
SpongeMinecraftUtils.MinecraftVersion.getCurrentVersion().isBelow(SpongeMinecraftUtils.MinecraftVersion.V1_17_R1) ? 16 : 17,
Sponge8MinecraftUtils.MinecraftVersion.getCurrentVersion().isBelow(Sponge8MinecraftUtils.MinecraftVersion.V1_17_R1) ? 16 : 17,
fetchField(entityDataSerializersClass, null, "BYTE")),
(byte) (0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40)
},
Expand All @@ -190,7 +194,7 @@ public void updateSkin(@NotNull FileConfiguration fileConfiguration, @NotNull Pl
new Object[]{
entityDataAccessor = invokeConstructor(
entityDataAccessorClass,
SpongeMinecraftUtils.MinecraftVersion.getCurrentVersion().isBelow(SpongeMinecraftUtils.MinecraftVersion.V1_17_R1) ? 16 : 17,
Sponge8MinecraftUtils.MinecraftVersion.getCurrentVersion().isBelow(Sponge8MinecraftUtils.MinecraftVersion.V1_17_R1) ? 16 : 17,
fetchField(entityDataSerializersClass, null, "BYTE")),
(byte)
((fileConfiguration.getBoolean("Options.overlays." + skinName + ".cape", false) ? 0x01 : 0x00) |
Expand All @@ -211,7 +215,7 @@ public void updateSkin(@NotNull FileConfiguration fileConfiguration, @NotNull Pl
} catch (Exception ignore) {
markDirty(synchedEntityData, entityDataAccessor);
}
if (SpongeMinecraftUtils.MinecraftVersion.getCurrentVersion().equals(SpongeMinecraftUtils.MinecraftVersion.V1_19_R2)) {
if (Sponge8MinecraftUtils.MinecraftVersion.getCurrentVersion().equals(Sponge8MinecraftUtils.MinecraftVersion.V1_19_R2)) {
entityDataPacket = invokeConstructor(entityDataPacketClass,
fetchMethodAndInvoke(serverPlayerClass, "getId", serverPlayer, new Object[]{}, new Class[]{}),
fetchMethodAndInvoke(synchedEntityData.getClass(), "packDirty", synchedEntityData, new Object[]{}, new Class[]{})
Expand All @@ -234,7 +238,7 @@ public void updateSkin(@NotNull FileConfiguration fileConfiguration, @NotNull Pl
try {
Class<?> playerPositionPacketClass = Utils.Reflection.getClass("net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket", classLoader);
Class<?> playerCarriedItemPacketClass = Utils.Reflection.getClass("net.minecraft.network.protocol.game.ClientboundSetCarriedItemPacket", classLoader);
switch (SpongeMinecraftUtils.MinecraftVersion.getCurrentVersion()) {
switch (Sponge8MinecraftUtils.MinecraftVersion.getCurrentVersion()) {
case V1_19_R2, V1_19_R1, V1_18_R2, V1_18_R1 ->
playerPositionPacket = invokeConstructor(playerPositionPacketClass,
serverLocation.x(),
Expand Down Expand Up @@ -288,7 +292,7 @@ public void updateSkin(@NotNull FileConfiguration fileConfiguration, @NotNull Pl
sendPacket(playerConnection, playerPositionPacket);
sendPacket(playerConnection, playerCarriedItemPacket);

if (SpongeMinecraftUtils.MinecraftVersion.getCurrentVersion().isAboveOrEqual(SpongeMinecraftUtils.MinecraftVersion.V1_17_R1)) {
if (Sponge8MinecraftUtils.MinecraftVersion.getCurrentVersion().isAboveOrEqual(Sponge8MinecraftUtils.MinecraftVersion.V1_17_R1)) {
Object container = fetchDeclaredField(serverPlayerClass.getSuperclass(), serverPlayer, "containerMenu");
fetchMethodAndInvoke(container.getClass(), "sendAllDataToRemote", container, new Object[]{}, new Class[]{});
} else {
Expand All @@ -299,11 +303,6 @@ public void updateSkin(@NotNull FileConfiguration fileConfiguration, @NotNull Pl
fetchMethodAndInvoke(serverPlayerClass, "resetSentInfo", serverPlayer, new Object[]{}, new Class[]{});
}

@Override
public void updateSkin(@NotNull FileConfiguration fileConfiguration, @NotNull PlayerObject playerObject, boolean reset, @NotNull String skinName, Property property) {
updateSkin(fileConfiguration, playerObject, reset, skinName);
}

@Override
protected GameProfile getGameProfile0(@NotNull PlayerObject playerObject) throws IOException, ExecutionException, InterruptedException {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.georgev22.library.maps.HashObjectMap;
import com.georgev22.library.maps.ObjectMap;
import com.georgev22.library.minecraft.SpongeMinecraftUtils;
import com.georgev22.library.minecraft.Sponge8MinecraftUtils;
import com.georgev22.library.scheduler.SchedulerManager;
import com.georgev22.skinoverlay.SkinOverlay;
import com.georgev22.skinoverlay.utilities.OptionsUtil;
Expand Down Expand Up @@ -59,7 +59,7 @@ public void onLogin(ServerSideConnectionEvent.Join loginEvent) {
.append("%author%", String.join(", ", skinOverlay.getDescription().authors()))
.append("%main%", skinOverlay.getDescription().main())
.append("%javaversion%", System.getProperty("java.version"))
.append("%serverversion%", SpongeMinecraftUtils.MinecraftVersion.getCurrentVersionName())
.append("%serverversion%", Sponge8MinecraftUtils.MinecraftVersion.getCurrentVersionName())
.append("%experimental%", String.valueOf(OptionsUtil.EXPERIMENTAL_FEATURES.getBooleanValue())), true);
}, 200L);
}
Expand Down

0 comments on commit ed0c892

Please sign in to comment.