Skip to content

Commit

Permalink
fix(SkinOptions): Improve proxy skin handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeV220 committed Mar 17, 2023
1 parent a116c79 commit b847a9d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.georgev22.skinoverlay.utilities.BungeeCordPluginMessageUtils;
import com.georgev22.skinoverlay.utilities.OptionsUtil;
import com.georgev22.skinoverlay.utilities.SkinOptions;
import com.georgev22.skinoverlay.utilities.Utilities;
import com.georgev22.skinoverlay.utilities.interfaces.SkinOverlayImpl;
import com.georgev22.skinoverlay.utilities.player.PlayerObject;
import com.georgev22.skinoverlay.utilities.player.PlayerObjectBungee;
Expand All @@ -28,9 +29,7 @@
import org.bstats.bungeecord.Metrics;
import org.jetbrains.annotations.NotNull;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.ObjectOutputStream;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -80,14 +79,10 @@ public void onEnable() {
@Override
public void updateSkin(@NotNull PlayerObject playerObject, @NotNull SkinOptions skinOptions, Utils.@NotNull Callback<Boolean> callback) {
try {
ByteArrayOutputStream bo = new ByteArrayOutputStream();
ObjectOutputStream so = new ObjectOutputStream(bo);
so.writeObject(skinOptions);
so.flush();
if (skinOptions.getSkinName().equalsIgnoreCase("default")) {
new BungeeCordPluginMessageUtils().sendDataTooAllServers("reset", playerObject.playerUUID().toString(), bo.toString());
new BungeeCordPluginMessageUtils().sendDataTooAllServers("reset", playerObject.playerUUID().toString(), Utilities.skinOptionsToBytes(skinOptions));
} else {
new BungeeCordPluginMessageUtils().sendDataTooAllServers("change", playerObject.playerUUID().toString(), bo.toString());
new BungeeCordPluginMessageUtils().sendDataTooAllServers("change", playerObject.playerUUID().toString(), Utilities.skinOptionsToBytes(skinOptions));
}
callback.onSuccess();
} catch (Exception exception) {
Expand All @@ -98,14 +93,10 @@ public void updateSkin(@NotNull PlayerObject playerObject, @NotNull SkinOptions
@Override
public void updateSkin(@NotNull PlayerObject playerObject, @NotNull SkinOptions skinOptions, Property property, Utils.@NotNull Callback<Boolean> callback) {
try {
ByteArrayOutputStream bo = new ByteArrayOutputStream();
ObjectOutputStream so = new ObjectOutputStream(bo);
so.writeObject(skinOptions);
so.flush();
if (skinOptions.getSkinName().equalsIgnoreCase("default")) {
new BungeeCordPluginMessageUtils().sendDataTooAllServers("resetWithProperties", playerObject.playerUUID().toString(), bo.toString(), property.getName(), property.getValue(), property.getSignature());
new BungeeCordPluginMessageUtils().sendDataTooAllServers("resetWithProperties", playerObject.playerUUID().toString(), Utilities.skinOptionsToBytes(skinOptions), property.getName(), property.getValue(), property.getSignature());
} else {
new BungeeCordPluginMessageUtils().sendDataTooAllServers("changeWithProperties", playerObject.playerUUID().toString(), bo.toString(), property.getName(), property.getValue(), property.getSignature());
new BungeeCordPluginMessageUtils().sendDataTooAllServers("changeWithProperties", playerObject.playerUUID().toString(), Utilities.skinOptionsToBytes(skinOptions), property.getName(), property.getValue(), property.getSignature());
}
callback.onSuccess();
} catch (Exception exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.georgev22.skinoverlay.listeners.velocity.PlayerListeners;
import com.georgev22.skinoverlay.utilities.OptionsUtil;
import com.georgev22.skinoverlay.utilities.SkinOptions;
import com.georgev22.skinoverlay.utilities.Utilities;
import com.georgev22.skinoverlay.utilities.VelocityPluginMessageUtils;
import com.georgev22.skinoverlay.utilities.interfaces.SkinOverlayImpl;
import com.georgev22.skinoverlay.utilities.player.PlayerObject;
Expand All @@ -33,9 +34,7 @@
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.ObjectOutputStream;
import java.nio.file.Path;
import java.time.Duration;
import java.util.Arrays;
Expand Down Expand Up @@ -118,14 +117,10 @@ public void onEnable() {
@Override
public void updateSkin(@NotNull PlayerObject playerObject, @NotNull SkinOptions skinOptions, Utils.@NotNull Callback<Boolean> callback) {
try {
ByteArrayOutputStream bo = new ByteArrayOutputStream();
ObjectOutputStream so = new ObjectOutputStream(bo);
so.writeObject(skinOptions);
so.flush();
if (skinOptions.getSkinName().equalsIgnoreCase("default")) {
new VelocityPluginMessageUtils().sendDataTooAllServers(getProxy(), "reset", playerObject.playerUUID().toString(), bo.toString());
new VelocityPluginMessageUtils().sendDataTooAllServers(getProxy(), "reset", playerObject.playerUUID().toString(), Utilities.skinOptionsToBytes(skinOptions));
} else {
new VelocityPluginMessageUtils().sendDataTooAllServers(getProxy(), "change", playerObject.playerUUID().toString(), bo.toString());
new VelocityPluginMessageUtils().sendDataTooAllServers(getProxy(), "change", playerObject.playerUUID().toString(), Utilities.skinOptionsToBytes(skinOptions));
}
callback.onSuccess();
} catch (Exception exception) {
Expand All @@ -136,14 +131,10 @@ public void updateSkin(@NotNull PlayerObject playerObject, @NotNull SkinOptions
@Override
public void updateSkin(@NotNull PlayerObject playerObject, @NotNull SkinOptions skinOptions, Property property, Utils.@NotNull Callback<Boolean> callback) {
try {
ByteArrayOutputStream bo = new ByteArrayOutputStream();
ObjectOutputStream so = new ObjectOutputStream(bo);
so.writeObject(skinOptions);
so.flush();
if (skinOptions.getSkinName().equalsIgnoreCase("default")) {
new VelocityPluginMessageUtils().sendDataTooAllServers(getProxy(), "resetWithProperties", playerObject.playerUUID().toString(), bo.toString(), property.getName(), property.getValue(), property.getSignature());
new VelocityPluginMessageUtils().sendDataTooAllServers(getProxy(), "resetWithProperties", playerObject.playerUUID().toString(), Utilities.skinOptionsToBytes(skinOptions), property.getName(), property.getValue(), property.getSignature());
} else {
new VelocityPluginMessageUtils().sendDataTooAllServers(getProxy(), "changeWithProperties", playerObject.playerUUID().toString(), bo.toString(), property.getName(), property.getValue(), property.getSignature());
new VelocityPluginMessageUtils().sendDataTooAllServers(getProxy(), "changeWithProperties", playerObject.playerUUID().toString(), Utilities.skinOptionsToBytes(skinOptions), property.getName(), property.getValue(), property.getSignature());
}
callback.onSuccess();
} catch (Exception exception) {
Expand Down

0 comments on commit b847a9d

Please sign in to comment.